1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file
5f6e50924SAndrew Rist * distributed with this work for additional information
6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at
10f6e50924SAndrew Rist *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist *
13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist * software distributed under the License is distributed on an
15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the
17f6e50924SAndrew Rist * specific language governing permissions and limitations
18f6e50924SAndrew Rist * under the License.
19f6e50924SAndrew Rist *
20f6e50924SAndrew Rist *************************************************************/
21f6e50924SAndrew Rist
22f6e50924SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir #include <svx/svdundo.hxx>
27cdf0e10cSrcweir #include <sfx2/app.hxx>
28cdf0e10cSrcweir #include <sfx2/request.hxx>
29cdf0e10cSrcweir #include <sfx2/objface.hxx>
30cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
31cdf0e10cSrcweir #include "svx/unoapi.hxx"
32cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp>
33cdf0e10cSrcweir #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp>
34cdf0e10cSrcweir #include <svx/dialmgr.hxx>
35cdf0e10cSrcweir #include <svx/svdoashp.hxx>
36cdf0e10cSrcweir #ifndef _SVX_DIALOGS_HRC
37cdf0e10cSrcweir #include <svx/dialogs.hrc>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #include <svx/svdview.hxx>
40cdf0e10cSrcweir #include <svx/sdasitm.hxx>
41cdf0e10cSrcweir #include <svx/svdoashp.hxx>
42cdf0e10cSrcweir #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
43cdf0e10cSrcweir #include <sfx2/bindings.hxx>
44cdf0e10cSrcweir #include <editeng/eeitem.hxx>
45cdf0e10cSrcweir #include <editeng/charscaleitem.hxx>
46cdf0e10cSrcweir #include <editeng/kernitem.hxx>
47cdf0e10cSrcweir #include <svx/sdrpaintwindow.hxx>
48cdf0e10cSrcweir
49cdf0e10cSrcweir #include <svx/svxids.hrc>
50cdf0e10cSrcweir #include <svx/fontworkbar.hxx>
51cdf0e10cSrcweir #include "svx/fontworkgallery.hxx"
52cdf0e10cSrcweir
53cdf0e10cSrcweir using ::rtl::OUString;
54cdf0e10cSrcweir
55cdf0e10cSrcweir using namespace ::svx;
56cdf0e10cSrcweir using namespace ::cppu;
57cdf0e10cSrcweir using namespace ::com::sun::star;
58cdf0e10cSrcweir using namespace ::com::sun::star::beans;
59cdf0e10cSrcweir using namespace ::com::sun::star::uno;
60cdf0e10cSrcweir
SetAlignmentState(SdrView * pSdrView,SfxItemSet & rSet)61cdf0e10cSrcweir void SetAlignmentState( SdrView* pSdrView, SfxItemSet& rSet )
62cdf0e10cSrcweir {
63cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
64cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
65cdf0e10cSrcweir
66cdf0e10cSrcweir sal_Int32 nAlignment = -1;
67cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
70cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir sal_Int32 nOldAlignment = nAlignment;
73*26734c99SArmin Le Grand SdrTextHorzAdjustItem& rTextHorzAdjustItem = (SdrTextHorzAdjustItem&)pObj->GetMergedItem( SDRATTR_TEXT_HORZADJUST );
74*26734c99SArmin Le Grand SdrTextFitToSizeTypeItem& rTextFitToSizeTypeItem = (SdrTextFitToSizeTypeItem&)pObj->GetMergedItem( SDRATTR_TEXT_FITTOSIZE );
75cdf0e10cSrcweir switch ( rTextHorzAdjustItem.GetValue() )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir case SDRTEXTHORZADJUST_LEFT : nAlignment = 0; break;
78cdf0e10cSrcweir case SDRTEXTHORZADJUST_CENTER : nAlignment = 1; break;
79cdf0e10cSrcweir case SDRTEXTHORZADJUST_RIGHT : nAlignment = 2; break;
80cdf0e10cSrcweir case SDRTEXTHORZADJUST_BLOCK :
81cdf0e10cSrcweir {
82*26734c99SArmin Le Grand if ( rTextFitToSizeTypeItem.GetValue() == SDRTEXTFIT_NONE )
83cdf0e10cSrcweir nAlignment = 3;
84*26734c99SArmin Le Grand else if ( rTextFitToSizeTypeItem.GetValue() == SDRTEXTFIT_ALLLINES )
85cdf0e10cSrcweir nAlignment = 4;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir }
88cdf0e10cSrcweir if ( ( nOldAlignment != -1 ) && ( nOldAlignment != nAlignment ) )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir nAlignment = -1;
91cdf0e10cSrcweir break;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir }
94cdf0e10cSrcweir }
95cdf0e10cSrcweir rSet.Put( SfxInt32Item( SID_FONTWORK_ALIGNMENT, nAlignment ) );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
SetCharacterSpacingState(SdrView * pSdrView,SfxItemSet & rSet)98cdf0e10cSrcweir void SetCharacterSpacingState( SdrView* pSdrView, SfxItemSet& rSet )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
101cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
102cdf0e10cSrcweir
103cdf0e10cSrcweir sal_Int32 nCharacterSpacing = -1;
104cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
107cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir sal_Int32 nOldCharacterSpacing = nCharacterSpacing;
110cdf0e10cSrcweir SvxCharScaleWidthItem& rCharScaleWidthItem = (SvxCharScaleWidthItem&)pObj->GetMergedItem( EE_CHAR_FONTWIDTH );
111cdf0e10cSrcweir nCharacterSpacing = rCharScaleWidthItem.GetValue();
112cdf0e10cSrcweir if ( ( nOldCharacterSpacing != -1 ) && ( nOldCharacterSpacing != nCharacterSpacing ) )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir nCharacterSpacing = -1;
115cdf0e10cSrcweir break;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir }
118cdf0e10cSrcweir }
119cdf0e10cSrcweir rSet.Put( SfxInt32Item( SID_FONTWORK_CHARACTER_SPACING, nCharacterSpacing ) );
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir
SetKernCharacterPairsState(SdrView * pSdrView,SfxItemSet & rSet)123cdf0e10cSrcweir void SetKernCharacterPairsState( SdrView* pSdrView, SfxItemSet& rSet )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
126cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
127cdf0e10cSrcweir
128cdf0e10cSrcweir sal_Bool bChecked = sal_False;
129cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
130cdf0e10cSrcweir {
131cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
132cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir SvxKerningItem& rKerningItem = (SvxKerningItem&)pObj->GetMergedItem( EE_CHAR_KERNING );
135cdf0e10cSrcweir if ( rKerningItem.GetValue() )
136cdf0e10cSrcweir bChecked = sal_True;
137cdf0e10cSrcweir }
138cdf0e10cSrcweir }
139cdf0e10cSrcweir rSet.Put( SfxBoolItem( SID_FONTWORK_KERN_CHARACTER_PAIRS, bChecked ) );
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
SetFontWorkShapeTypeState(SdrView * pSdrView,SfxItemSet & rSet)142cdf0e10cSrcweir void SetFontWorkShapeTypeState( SdrView* pSdrView, SfxItemSet& rSet )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
145cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
146cdf0e10cSrcweir
147cdf0e10cSrcweir rtl::OUString aFontWorkShapeType;
148cdf0e10cSrcweir
149cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
152cdf0e10cSrcweir if( pObj->ISA( SdrObjCustomShape ) )
153cdf0e10cSrcweir {
154cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
155cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
156cdf0e10cSrcweir Any* pAny = aGeometryItem.GetPropertyValueByName( sType );
157cdf0e10cSrcweir if( pAny )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir rtl::OUString aType;
160cdf0e10cSrcweir if ( *pAny >>= aType )
161cdf0e10cSrcweir {
162cdf0e10cSrcweir if ( aFontWorkShapeType.getLength() )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir if ( !aFontWorkShapeType.equals( aType ) ) // different FontWorkShapeTypes selected ?
165cdf0e10cSrcweir {
166cdf0e10cSrcweir aFontWorkShapeType = rtl::OUString();
167cdf0e10cSrcweir break;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir }
170cdf0e10cSrcweir aFontWorkShapeType = aType;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir }
175cdf0e10cSrcweir rSet.Put( SfxStringItem( SID_FONTWORK_SHAPE_TYPE, aFontWorkShapeType ) );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir /*************************************************************************
179cdf0e10cSrcweir |*
180cdf0e10cSrcweir |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
181cdf0e10cSrcweir |* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
182cdf0e10cSrcweir |*
183cdf0e10cSrcweir \************************************************************************/
184cdf0e10cSrcweir
185cdf0e10cSrcweir #define ShellClass FontworkBar
186cdf0e10cSrcweir
SFX_SLOTMAP(FontworkBar)187cdf0e10cSrcweir SFX_SLOTMAP(FontworkBar)
188cdf0e10cSrcweir {
189cdf0e10cSrcweir { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
190cdf0e10cSrcweir };
191cdf0e10cSrcweir
SFX_IMPL_INTERFACE(FontworkBar,SfxShell,SVX_RES (RID_SVX_FONTWORK_BAR))192cdf0e10cSrcweir SFX_IMPL_INTERFACE(FontworkBar, SfxShell, SVX_RES(RID_SVX_FONTWORK_BAR))
193cdf0e10cSrcweir {
194cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, SVX_RES(RID_SVX_FONTWORK_BAR) );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir
197cdf0e10cSrcweir TYPEINIT1( FontworkBar, SfxShell );
198cdf0e10cSrcweir
199cdf0e10cSrcweir
200cdf0e10cSrcweir /*************************************************************************
201cdf0e10cSrcweir |*
202cdf0e10cSrcweir |* Standard-Konstruktor
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir \************************************************************************/
205cdf0e10cSrcweir
FontworkBar(SfxViewShell * pViewShell)206cdf0e10cSrcweir FontworkBar::FontworkBar(SfxViewShell* pViewShell )
207cdf0e10cSrcweir : SfxShell(pViewShell)
208cdf0e10cSrcweir {
209cdf0e10cSrcweir DBG_ASSERT( pViewShell, "svx::FontworkBar::FontworkBar(), I need a viewshell!" );
210cdf0e10cSrcweir if( pViewShell )
211cdf0e10cSrcweir SetPool(&pViewShell->GetPool());
212cdf0e10cSrcweir
213cdf0e10cSrcweir SetHelpId( SVX_INTERFACE_FONTWORK_BAR );
214cdf0e10cSrcweir SetName( String( SVX_RES( RID_SVX_FONTWORK_BAR) ));
215cdf0e10cSrcweir }
216cdf0e10cSrcweir
217cdf0e10cSrcweir
218cdf0e10cSrcweir /*************************************************************************
219cdf0e10cSrcweir |*
220cdf0e10cSrcweir |* Destruktor
221cdf0e10cSrcweir |*
222cdf0e10cSrcweir \************************************************************************/
223cdf0e10cSrcweir
~FontworkBar()224cdf0e10cSrcweir FontworkBar::~FontworkBar()
225cdf0e10cSrcweir {
226cdf0e10cSrcweir SetRepeatTarget(NULL);
227cdf0e10cSrcweir }
228cdf0e10cSrcweir
ImpGetViewWin(SdrView * pView)229cdf0e10cSrcweir static Window* ImpGetViewWin(SdrView* pView)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir if( pView )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir const sal_uInt32 nAnz(pView->PaintWindowCount());
234cdf0e10cSrcweir for(sal_uInt32 nNum(0L); nNum < nAnz; nNum++)
235cdf0e10cSrcweir {
236cdf0e10cSrcweir OutputDevice* pOut = &(pView->GetPaintWindow(nNum)->GetOutputDevice());
237cdf0e10cSrcweir
238cdf0e10cSrcweir if(OUTDEV_WINDOW == pOut->GetOutDevType())
239cdf0e10cSrcweir {
240cdf0e10cSrcweir return (Window*)pOut;
241cdf0e10cSrcweir }
242cdf0e10cSrcweir }
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir return 0L;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir
248cdf0e10cSrcweir namespace svx {
checkForSelectedFontWork(SdrView * pSdrView,sal_uInt32 & nCheckStatus)249cdf0e10cSrcweir bool checkForSelectedFontWork( SdrView* pSdrView, sal_uInt32& nCheckStatus )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir if ( nCheckStatus & 2 )
252cdf0e10cSrcweir return ( nCheckStatus & 1 ) != 0;
253cdf0e10cSrcweir
254cdf0e10cSrcweir static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
255cdf0e10cSrcweir
256cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
257cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
258cdf0e10cSrcweir sal_Bool bFound = sal_False;
259cdf0e10cSrcweir for(i=0;(i<nCount) && !bFound ; i++)
260cdf0e10cSrcweir {
261cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
262cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
265cdf0e10cSrcweir Any* pAny = aGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
266cdf0e10cSrcweir if( pAny )
267cdf0e10cSrcweir *pAny >>= bFound;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir if ( bFound )
271cdf0e10cSrcweir nCheckStatus |= 1;
272cdf0e10cSrcweir nCheckStatus |= 2;
273cdf0e10cSrcweir return bFound;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir }
276cdf0e10cSrcweir
impl_execute(SdrView *,SfxRequest & rReq,SdrCustomShapeGeometryItem & rGeometryItem,SdrObject * pObj)277cdf0e10cSrcweir static void impl_execute( SdrView*, SfxRequest& rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
280cdf0e10cSrcweir static const rtl::OUString sSameLetterHeights( RTL_CONSTASCII_USTRINGPARAM ( "SameLetterHeights" ) );
281cdf0e10cSrcweir
282cdf0e10cSrcweir sal_uInt16 nSID = rReq.GetSlot();
283cdf0e10cSrcweir switch( nSID )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir case SID_FONTWORK_SAME_LETTER_HEIGHTS:
286cdf0e10cSrcweir {
287cdf0e10cSrcweir com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sSameLetterHeights );
288cdf0e10cSrcweir if( pAny )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir sal_Bool bOn;
291cdf0e10cSrcweir (*pAny) >>= bOn;
292cdf0e10cSrcweir bOn = !bOn;
293cdf0e10cSrcweir (*pAny) <<= bOn;
294cdf0e10cSrcweir }
295cdf0e10cSrcweir }
296cdf0e10cSrcweir break;
297cdf0e10cSrcweir
298cdf0e10cSrcweir case SID_FONTWORK_ALIGNMENT:
299cdf0e10cSrcweir {
300cdf0e10cSrcweir if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_FONTWORK_ALIGNMENT ) == SFX_ITEM_SET )
301cdf0e10cSrcweir {
302cdf0e10cSrcweir sal_Int32 nValue = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_ALIGNMENT))->GetValue();
303cdf0e10cSrcweir if ( ( nValue >= 0 ) && ( nValue < 5 ) )
304cdf0e10cSrcweir {
305*26734c99SArmin Le Grand SdrFitToSizeType eFTS = SDRTEXTFIT_NONE;
306cdf0e10cSrcweir SdrTextHorzAdjust eHorzAdjust;
307cdf0e10cSrcweir switch ( nValue )
308cdf0e10cSrcweir {
309*26734c99SArmin Le Grand case 4 : eFTS = SDRTEXTFIT_ALLLINES; // passthrough
310cdf0e10cSrcweir case 3 : eHorzAdjust = SDRTEXTHORZADJUST_BLOCK; break;
311cdf0e10cSrcweir default:
312cdf0e10cSrcweir case 0 : eHorzAdjust = SDRTEXTHORZADJUST_LEFT; break;
313cdf0e10cSrcweir case 1 : eHorzAdjust = SDRTEXTHORZADJUST_CENTER; break;
314cdf0e10cSrcweir case 2 : eHorzAdjust = SDRTEXTHORZADJUST_RIGHT; break;
315cdf0e10cSrcweir }
316cdf0e10cSrcweir pObj->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) );
317*26734c99SArmin Le Grand pObj->SetMergedItem( SdrTextFitToSizeTypeItem( eFTS ) );
318cdf0e10cSrcweir pObj->BroadcastObjectChange();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321cdf0e10cSrcweir }
322cdf0e10cSrcweir break;
323cdf0e10cSrcweir
324cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING:
325cdf0e10cSrcweir {
326cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
329cdf0e10cSrcweir pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
330cdf0e10cSrcweir pObj->BroadcastObjectChange();
331cdf0e10cSrcweir }
332cdf0e10cSrcweir }
333cdf0e10cSrcweir break;
334cdf0e10cSrcweir
335cdf0e10cSrcweir case SID_FONTWORK_KERN_CHARACTER_PAIRS:
336cdf0e10cSrcweir {
337cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) == SFX_ITEM_SET ) )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir // sal_Bool bKernCharacterPairs = ((const SfxBoolItem*)rReq.GetArgs()->GetItem(SID_FONTWORK_KERN_CHARACTER_PAIRS))->GetValue();
340cdf0e10cSrcweir //TODO: pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
341cdf0e10cSrcweir pObj->BroadcastObjectChange();
342cdf0e10cSrcweir }
343cdf0e10cSrcweir }
344cdf0e10cSrcweir break;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir }
347cdf0e10cSrcweir
348cdf0e10cSrcweir #include "svx/gallery.hxx"
349cdf0e10cSrcweir #include <svx/fmmodel.hxx>
350cdf0e10cSrcweir #include <svx/fmpage.hxx>
351cdf0e10cSrcweir #include <svl/itempool.hxx>
352cdf0e10cSrcweir
GetGeometryForCustomShape(SdrCustomShapeGeometryItem & rGeometryItem,const rtl::OUString rCustomShape)353cdf0e10cSrcweir void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem, const rtl::OUString rCustomShape )
354cdf0e10cSrcweir {
355cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
356cdf0e10cSrcweir
357cdf0e10cSrcweir com::sun::star::beans::PropertyValue aPropVal;
358cdf0e10cSrcweir aPropVal.Name = sType;
359cdf0e10cSrcweir aPropVal.Value <<= rCustomShape;
360cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal );
361cdf0e10cSrcweir
362cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
363cdf0e10cSrcweir const rtl::OUString sCoordinateOrigin( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateOrigin" ) );
364cdf0e10cSrcweir const rtl::OUString sCoordinateSize( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateSize" ) );
365cdf0e10cSrcweir const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM ( "Equations" ) );
366cdf0e10cSrcweir const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM ( "Handles" ) );
367cdf0e10cSrcweir const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
368cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sAdjustmentValues );
369cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sCoordinateOrigin );
370cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sCoordinateSize );
371cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sEquations );
372cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sHandles );
373cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sPath );
374cdf0e10cSrcweir
375cdf0e10cSrcweir /* SJ: CustomShapes that are available in the gallery are having the highest
376cdf0e10cSrcweir priority, so we will take a look there before taking the internal default */
377cdf0e10cSrcweir
378cdf0e10cSrcweir if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir std::vector< rtl::OUString > aObjList;
381cdf0e10cSrcweir if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir sal_uInt16 i;
384cdf0e10cSrcweir for ( i = 0; i < aObjList.size(); i++ )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir FmFormModel aFormModel;
389cdf0e10cSrcweir SfxItemPool& rPool = aFormModel.GetItemPool();
390cdf0e10cSrcweir rPool.FreezeIdRanges();
391cdf0e10cSrcweir if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
394cdf0e10cSrcweir if( pSourceObj )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir PropertyValue aPropVal_;
397cdf0e10cSrcweir SdrCustomShapeGeometryItem& rSourceGeometry = (SdrCustomShapeGeometryItem&)pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
398cdf0e10cSrcweir com::sun::star::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType );
399cdf0e10cSrcweir if ( pAny )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir aPropVal_.Name = sType;
402cdf0e10cSrcweir aPropVal_.Value = *pAny;
403cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues );
406cdf0e10cSrcweir if ( pAny )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir aPropVal_.Name = sAdjustmentValues;
409cdf0e10cSrcweir aPropVal_.Value = *pAny;
410cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
411cdf0e10cSrcweir }
412cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin );
413cdf0e10cSrcweir if ( pAny )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir aPropVal_.Name = sCoordinateOrigin;
416cdf0e10cSrcweir aPropVal_.Value = *pAny;
417cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
418cdf0e10cSrcweir }
419cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize );
420cdf0e10cSrcweir if ( pAny )
421cdf0e10cSrcweir {
422cdf0e10cSrcweir aPropVal_.Name = sCoordinateSize;
423cdf0e10cSrcweir aPropVal_.Value = *pAny;
424cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sEquations );
427cdf0e10cSrcweir if ( pAny )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir aPropVal_.Name = sEquations;
430cdf0e10cSrcweir aPropVal_.Value = *pAny;
431cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
432cdf0e10cSrcweir }
433cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sHandles );
434cdf0e10cSrcweir if ( pAny )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir aPropVal_.Name = sHandles;
437cdf0e10cSrcweir aPropVal_.Value = *pAny;
438cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
439cdf0e10cSrcweir }
440cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sPath );
441cdf0e10cSrcweir if ( pAny )
442cdf0e10cSrcweir {
443cdf0e10cSrcweir aPropVal_.Name = sPath;
444cdf0e10cSrcweir aPropVal_.Value = *pAny;
445cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir }
449cdf0e10cSrcweir }
450cdf0e10cSrcweir }
451cdf0e10cSrcweir }
452cdf0e10cSrcweir }
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir
execute(SdrView * pSdrView,SfxRequest & rReq,SfxBindings & rBindings)456cdf0e10cSrcweir void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBindings )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir sal_uInt16 nStrResId = 0;
459cdf0e10cSrcweir
460cdf0e10cSrcweir sal_uInt16 nSID = rReq.GetSlot();
461cdf0e10cSrcweir switch( nSID )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir case SID_FONTWORK_GALLERY_FLOATER:
464cdf0e10cSrcweir {
465cdf0e10cSrcweir FontWorkGalleryDialog aDlg( pSdrView, ImpGetViewWin(pSdrView), nSID );
466cdf0e10cSrcweir aDlg.Execute();
467cdf0e10cSrcweir }
468cdf0e10cSrcweir break;
469cdf0e10cSrcweir
470cdf0e10cSrcweir case SID_FONTWORK_SHAPE_TYPE:
471cdf0e10cSrcweir {
472cdf0e10cSrcweir rtl::OUString aCustomShape;
473cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
474cdf0e10cSrcweir if ( pArgs )
475cdf0e10cSrcweir {
476cdf0e10cSrcweir const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
477cdf0e10cSrcweir aCustomShape = rItm.GetValue();
478cdf0e10cSrcweir }
479cdf0e10cSrcweir if ( aCustomShape.getLength() )
480cdf0e10cSrcweir {
481cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
482cdf0e10cSrcweir sal_uInt32 nCount = rMarkList.GetMarkCount(), i;
483cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
486cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
487cdf0e10cSrcweir {
488cdf0e10cSrcweir const bool bUndo = pSdrView->IsUndoEnabled();
489cdf0e10cSrcweir
490cdf0e10cSrcweir if( bUndo )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir String aStr( SVX_RES( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
493cdf0e10cSrcweir pSdrView->BegUndo( aStr );
494cdf0e10cSrcweir pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
495cdf0e10cSrcweir }
496cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
497cdf0e10cSrcweir GetGeometryForCustomShape( aGeometryItem, aCustomShape );
498cdf0e10cSrcweir pObj->SetMergedItem( aGeometryItem );
499cdf0e10cSrcweir
500cdf0e10cSrcweir Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pObj );
501cdf0e10cSrcweir if ( aXShape.is() )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY );
504cdf0e10cSrcweir if( xDefaulter.is() )
505cdf0e10cSrcweir xDefaulter->createCustomShapeDefaults( aCustomShape );
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
508cdf0e10cSrcweir pObj->BroadcastObjectChange();
509cdf0e10cSrcweir if( bUndo )
510cdf0e10cSrcweir pSdrView->EndUndo();
511cdf0e10cSrcweir pSdrView->AdjustMarkHdl(); //HMH sal_True );
512cdf0e10cSrcweir rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE );
513cdf0e10cSrcweir }
514cdf0e10cSrcweir }
515cdf0e10cSrcweir }
516cdf0e10cSrcweir }
517cdf0e10cSrcweir break;
518cdf0e10cSrcweir
519cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING_DIALOG :
520cdf0e10cSrcweir {
521cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
522cdf0e10cSrcweir {
523cdf0e10cSrcweir sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
524cdf0e10cSrcweir FontworkCharacterSpacingDialog aDlg( 0L, nCharSpacing );
525cdf0e10cSrcweir sal_uInt16 nRet = aDlg.Execute();
526cdf0e10cSrcweir if( nRet != 0 )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir SfxInt32Item aItem( SID_FONTWORK_CHARACTER_SPACING, aDlg.getScale() );
529cdf0e10cSrcweir SfxPoolItem* aItems[] = { &aItem, 0 };
530cdf0e10cSrcweir rBindings.Execute( SID_FONTWORK_CHARACTER_SPACING, (const SfxPoolItem**)aItems );
531cdf0e10cSrcweir }
532cdf0e10cSrcweir }
533cdf0e10cSrcweir }
534cdf0e10cSrcweir break;
535cdf0e10cSrcweir
536cdf0e10cSrcweir case SID_FONTWORK_SHAPE:
537cdf0e10cSrcweir case SID_FONTWORK_ALIGNMENT:
538cdf0e10cSrcweir {
539cdf0e10cSrcweir if ( !nStrResId )
540cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_ALIGNMENT;
541cdf0e10cSrcweir } // PASSTROUGH
542cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING:
543cdf0e10cSrcweir {
544cdf0e10cSrcweir if ( !nStrResId )
545cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
546cdf0e10cSrcweir } // PASSTROUGH
547cdf0e10cSrcweir case SID_FONTWORK_KERN_CHARACTER_PAIRS:
548cdf0e10cSrcweir {
549cdf0e10cSrcweir if ( !nStrResId )
550cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
551cdf0e10cSrcweir } // PASSTROUGH
552cdf0e10cSrcweir case SID_FONTWORK_SAME_LETTER_HEIGHTS:
553cdf0e10cSrcweir {
554cdf0e10cSrcweir if ( !nStrResId )
555cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT;
556cdf0e10cSrcweir
557cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
558cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
559cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
562cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
563cdf0e10cSrcweir {
564cdf0e10cSrcweir const bool bUndo = pSdrView->IsUndoEnabled();
565cdf0e10cSrcweir if( bUndo )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir String aStr( SVX_RES( nStrResId ) );
568cdf0e10cSrcweir pSdrView->BegUndo( aStr );
569cdf0e10cSrcweir pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
570cdf0e10cSrcweir }
571cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
572cdf0e10cSrcweir impl_execute( pSdrView, rReq, aGeometryItem, pObj );
573cdf0e10cSrcweir pObj->SetMergedItem( aGeometryItem );
574cdf0e10cSrcweir pObj->BroadcastObjectChange();
575cdf0e10cSrcweir if( bUndo )
576cdf0e10cSrcweir pSdrView->EndUndo();
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir }
580cdf0e10cSrcweir break;
581cdf0e10cSrcweir };
582cdf0e10cSrcweir }
583cdf0e10cSrcweir
getState(SdrView * pSdrView,SfxItemSet & rSet)584cdf0e10cSrcweir void FontworkBar::getState( SdrView* pSdrView, SfxItemSet& rSet )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir sal_uInt32 nCheckStatus = 0;
587cdf0e10cSrcweir
588cdf0e10cSrcweir /*
589cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SHAPE ) != SFX_ITEM_UNKNOWN )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir sal_Bool bBreak = sal_True;
592cdf0e10cSrcweir }
593cdf0e10cSrcweir */
594cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT_FLOATER ) != SFX_ITEM_UNKNOWN )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
597cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER );
598cdf0e10cSrcweir }
599cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT ) != SFX_ITEM_UNKNOWN )
600cdf0e10cSrcweir {
601cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
602cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_ALIGNMENT );
603cdf0e10cSrcweir else
604cdf0e10cSrcweir SetAlignmentState( pSdrView, rSet );
605cdf0e10cSrcweir }
606cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING_FLOATER ) != SFX_ITEM_UNKNOWN )
607cdf0e10cSrcweir {
608cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
609cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER );
610cdf0e10cSrcweir }
611cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING ) != SFX_ITEM_UNKNOWN )
612cdf0e10cSrcweir {
613cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
614cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING );
615cdf0e10cSrcweir else
616cdf0e10cSrcweir SetCharacterSpacingState( pSdrView, rSet );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) != SFX_ITEM_UNKNOWN )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
621cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS );
622cdf0e10cSrcweir else
623cdf0e10cSrcweir SetKernCharacterPairsState( pSdrView, rSet );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SAME_LETTER_HEIGHTS ) != SFX_ITEM_UNKNOWN )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
628cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS );
629cdf0e10cSrcweir }
630cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SHAPE_TYPE ) != SFX_ITEM_UNKNOWN )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
633cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE );
634cdf0e10cSrcweir else
635cdf0e10cSrcweir SetFontWorkShapeTypeState( pSdrView, rSet );
636cdf0e10cSrcweir }
637cdf0e10cSrcweir }
638