1f6e50924SAndrew Rist /**************************************************************
2*5ffb42a1Smseidel *
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
10*5ffb42a1Smseidel *
11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5ffb42a1Smseidel *
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.
19*5ffb42a1Smseidel *
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;
7326734c99SArmin Le Grand SdrTextHorzAdjustItem& rTextHorzAdjustItem = (SdrTextHorzAdjustItem&)pObj->GetMergedItem( SDRATTR_TEXT_HORZADJUST );
7426734c99SArmin 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 {
8226734c99SArmin Le Grand if ( rTextFitToSizeTypeItem.GetValue() == SDRTEXTFIT_NONE )
83cdf0e10cSrcweir nAlignment = 3;
8426734c99SArmin 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 |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
180cdf0e10cSrcweir |* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
181cdf0e10cSrcweir \************************************************************************/
182cdf0e10cSrcweir
183cdf0e10cSrcweir #define ShellClass FontworkBar
184cdf0e10cSrcweir
SFX_SLOTMAP(FontworkBar)185cdf0e10cSrcweir SFX_SLOTMAP(FontworkBar)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
188cdf0e10cSrcweir };
189cdf0e10cSrcweir
SFX_IMPL_INTERFACE(FontworkBar,SfxShell,SVX_RES (RID_SVX_FONTWORK_BAR))190cdf0e10cSrcweir SFX_IMPL_INTERFACE(FontworkBar, SfxShell, SVX_RES(RID_SVX_FONTWORK_BAR))
191cdf0e10cSrcweir {
192cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, SVX_RES(RID_SVX_FONTWORK_BAR) );
193cdf0e10cSrcweir }
194cdf0e10cSrcweir
195cdf0e10cSrcweir TYPEINIT1( FontworkBar, SfxShell );
196cdf0e10cSrcweir
197cdf0e10cSrcweir
198cdf0e10cSrcweir /*************************************************************************
199cdf0e10cSrcweir |* Standard-Konstruktor
200cdf0e10cSrcweir \************************************************************************/
201cdf0e10cSrcweir
FontworkBar(SfxViewShell * pViewShell)202cdf0e10cSrcweir FontworkBar::FontworkBar(SfxViewShell* pViewShell )
203cdf0e10cSrcweir : SfxShell(pViewShell)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir DBG_ASSERT( pViewShell, "svx::FontworkBar::FontworkBar(), I need a viewshell!" );
206cdf0e10cSrcweir if( pViewShell )
207cdf0e10cSrcweir SetPool(&pViewShell->GetPool());
208cdf0e10cSrcweir
209cdf0e10cSrcweir SetHelpId( SVX_INTERFACE_FONTWORK_BAR );
210cdf0e10cSrcweir SetName( String( SVX_RES( RID_SVX_FONTWORK_BAR) ));
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir
214cdf0e10cSrcweir /*************************************************************************
215cdf0e10cSrcweir |* Destruktor
216cdf0e10cSrcweir \************************************************************************/
217cdf0e10cSrcweir
~FontworkBar()218cdf0e10cSrcweir FontworkBar::~FontworkBar()
219cdf0e10cSrcweir {
220cdf0e10cSrcweir SetRepeatTarget(NULL);
221cdf0e10cSrcweir }
222cdf0e10cSrcweir
ImpGetViewWin(SdrView * pView)223cdf0e10cSrcweir static Window* ImpGetViewWin(SdrView* pView)
224cdf0e10cSrcweir {
225cdf0e10cSrcweir if( pView )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir const sal_uInt32 nAnz(pView->PaintWindowCount());
228*5ffb42a1Smseidel for(sal_uInt32 nNum(0L); nNum < nAnz; nNum++)
229cdf0e10cSrcweir {
230cdf0e10cSrcweir OutputDevice* pOut = &(pView->GetPaintWindow(nNum)->GetOutputDevice());
231cdf0e10cSrcweir
232*5ffb42a1Smseidel if(OUTDEV_WINDOW == pOut->GetOutDevType())
233cdf0e10cSrcweir {
234cdf0e10cSrcweir return (Window*)pOut;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir }
237cdf0e10cSrcweir }
238cdf0e10cSrcweir
239cdf0e10cSrcweir return 0L;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir namespace svx {
checkForSelectedFontWork(SdrView * pSdrView,sal_uInt32 & nCheckStatus)243cdf0e10cSrcweir bool checkForSelectedFontWork( SdrView* pSdrView, sal_uInt32& nCheckStatus )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir if ( nCheckStatus & 2 )
246cdf0e10cSrcweir return ( nCheckStatus & 1 ) != 0;
247cdf0e10cSrcweir
248cdf0e10cSrcweir static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
249cdf0e10cSrcweir
250cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
251cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
252cdf0e10cSrcweir sal_Bool bFound = sal_False;
253cdf0e10cSrcweir for(i=0;(i<nCount) && !bFound ; i++)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
256cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
259cdf0e10cSrcweir Any* pAny = aGeometryItem.GetPropertyValueByName( sTextPath, sTextPath );
260cdf0e10cSrcweir if( pAny )
261cdf0e10cSrcweir *pAny >>= bFound;
262cdf0e10cSrcweir }
263cdf0e10cSrcweir }
264cdf0e10cSrcweir if ( bFound )
265cdf0e10cSrcweir nCheckStatus |= 1;
266cdf0e10cSrcweir nCheckStatus |= 2;
267cdf0e10cSrcweir return bFound;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
impl_execute(SdrView *,SfxRequest & rReq,SdrCustomShapeGeometryItem & rGeometryItem,SdrObject * pObj)271cdf0e10cSrcweir static void impl_execute( SdrView*, SfxRequest& rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
272cdf0e10cSrcweir {
273cdf0e10cSrcweir static const rtl::OUString sTextPath( RTL_CONSTASCII_USTRINGPARAM ( "TextPath" ) );
274cdf0e10cSrcweir static const rtl::OUString sSameLetterHeights( RTL_CONSTASCII_USTRINGPARAM ( "SameLetterHeights" ) );
275cdf0e10cSrcweir
276cdf0e10cSrcweir sal_uInt16 nSID = rReq.GetSlot();
277cdf0e10cSrcweir switch( nSID )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir case SID_FONTWORK_SAME_LETTER_HEIGHTS:
280cdf0e10cSrcweir {
281cdf0e10cSrcweir com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sTextPath, sSameLetterHeights );
282cdf0e10cSrcweir if( pAny )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir sal_Bool bOn;
285cdf0e10cSrcweir (*pAny) >>= bOn;
286cdf0e10cSrcweir bOn = !bOn;
287cdf0e10cSrcweir (*pAny) <<= bOn;
288cdf0e10cSrcweir }
289cdf0e10cSrcweir }
290cdf0e10cSrcweir break;
291cdf0e10cSrcweir
292cdf0e10cSrcweir case SID_FONTWORK_ALIGNMENT:
293cdf0e10cSrcweir {
294cdf0e10cSrcweir if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_FONTWORK_ALIGNMENT ) == SFX_ITEM_SET )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir sal_Int32 nValue = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_ALIGNMENT))->GetValue();
297cdf0e10cSrcweir if ( ( nValue >= 0 ) && ( nValue < 5 ) )
298cdf0e10cSrcweir {
29926734c99SArmin Le Grand SdrFitToSizeType eFTS = SDRTEXTFIT_NONE;
300cdf0e10cSrcweir SdrTextHorzAdjust eHorzAdjust;
301cdf0e10cSrcweir switch ( nValue )
302cdf0e10cSrcweir {
30326734c99SArmin Le Grand case 4 : eFTS = SDRTEXTFIT_ALLLINES; // passthrough
304cdf0e10cSrcweir case 3 : eHorzAdjust = SDRTEXTHORZADJUST_BLOCK; break;
305cdf0e10cSrcweir default:
306cdf0e10cSrcweir case 0 : eHorzAdjust = SDRTEXTHORZADJUST_LEFT; break;
307cdf0e10cSrcweir case 1 : eHorzAdjust = SDRTEXTHORZADJUST_CENTER; break;
308cdf0e10cSrcweir case 2 : eHorzAdjust = SDRTEXTHORZADJUST_RIGHT; break;
309cdf0e10cSrcweir }
310cdf0e10cSrcweir pObj->SetMergedItem( SdrTextHorzAdjustItem( eHorzAdjust ) );
31126734c99SArmin Le Grand pObj->SetMergedItem( SdrTextFitToSizeTypeItem( eFTS ) );
312cdf0e10cSrcweir pObj->BroadcastObjectChange();
313cdf0e10cSrcweir }
314cdf0e10cSrcweir }
315cdf0e10cSrcweir }
316cdf0e10cSrcweir break;
317cdf0e10cSrcweir
318cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING:
319cdf0e10cSrcweir {
320cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
323cdf0e10cSrcweir pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
324cdf0e10cSrcweir pObj->BroadcastObjectChange();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir
329cdf0e10cSrcweir case SID_FONTWORK_KERN_CHARACTER_PAIRS:
330cdf0e10cSrcweir {
331cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) == SFX_ITEM_SET ) )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir // sal_Bool bKernCharacterPairs = ((const SfxBoolItem*)rReq.GetArgs()->GetItem(SID_FONTWORK_KERN_CHARACTER_PAIRS))->GetValue();
334cdf0e10cSrcweir //TODO: pObj->SetMergedItem( SvxCharScaleWidthItem( (sal_uInt16)nCharSpacing, EE_CHAR_FONTWIDTH ) );
335cdf0e10cSrcweir pObj->BroadcastObjectChange();
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir break;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir }
341cdf0e10cSrcweir
342cdf0e10cSrcweir #include "svx/gallery.hxx"
343cdf0e10cSrcweir #include <svx/fmmodel.hxx>
344cdf0e10cSrcweir #include <svx/fmpage.hxx>
345cdf0e10cSrcweir #include <svl/itempool.hxx>
346cdf0e10cSrcweir
GetGeometryForCustomShape(SdrCustomShapeGeometryItem & rGeometryItem,const rtl::OUString rCustomShape)347cdf0e10cSrcweir void GetGeometryForCustomShape( SdrCustomShapeGeometryItem& rGeometryItem, const rtl::OUString rCustomShape )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir const rtl::OUString sType( RTL_CONSTASCII_USTRINGPARAM ( "Type" ) );
350cdf0e10cSrcweir
351cdf0e10cSrcweir com::sun::star::beans::PropertyValue aPropVal;
352cdf0e10cSrcweir aPropVal.Name = sType;
353cdf0e10cSrcweir aPropVal.Value <<= rCustomShape;
354cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal );
355cdf0e10cSrcweir
356cdf0e10cSrcweir const rtl::OUString sAdjustmentValues( RTL_CONSTASCII_USTRINGPARAM ( "AdjustmentValues" ) );
357cdf0e10cSrcweir const rtl::OUString sCoordinateOrigin( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateOrigin" ) );
358cdf0e10cSrcweir const rtl::OUString sCoordinateSize( RTL_CONSTASCII_USTRINGPARAM ( "CoordinateSize" ) );
359cdf0e10cSrcweir const rtl::OUString sEquations( RTL_CONSTASCII_USTRINGPARAM ( "Equations" ) );
360cdf0e10cSrcweir const rtl::OUString sHandles( RTL_CONSTASCII_USTRINGPARAM ( "Handles" ) );
361cdf0e10cSrcweir const rtl::OUString sPath( RTL_CONSTASCII_USTRINGPARAM ( "Path" ) );
362cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sAdjustmentValues );
363cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sCoordinateOrigin );
364cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sCoordinateSize );
365cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sEquations );
366cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sHandles );
367cdf0e10cSrcweir rGeometryItem.ClearPropertyValue( sPath );
368cdf0e10cSrcweir
369cdf0e10cSrcweir /* SJ: CustomShapes that are available in the gallery are having the highest
370*5ffb42a1Smseidel priority, so we will take a look there before taking the internal default */
371cdf0e10cSrcweir
372cdf0e10cSrcweir if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir std::vector< rtl::OUString > aObjList;
375cdf0e10cSrcweir if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir sal_uInt16 i;
378cdf0e10cSrcweir for ( i = 0; i < aObjList.size(); i++ )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir if ( aObjList[ i ].equalsIgnoreAsciiCase( rCustomShape ) )
381cdf0e10cSrcweir {
382cdf0e10cSrcweir FmFormModel aFormModel;
383cdf0e10cSrcweir SfxItemPool& rPool = aFormModel.GetItemPool();
384cdf0e10cSrcweir rPool.FreezeIdRanges();
385cdf0e10cSrcweir if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
386cdf0e10cSrcweir {
387cdf0e10cSrcweir const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
388cdf0e10cSrcweir if( pSourceObj )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir PropertyValue aPropVal_;
391cdf0e10cSrcweir SdrCustomShapeGeometryItem& rSourceGeometry = (SdrCustomShapeGeometryItem&)pSourceObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
392cdf0e10cSrcweir com::sun::star::uno::Any* pAny = rSourceGeometry.GetPropertyValueByName( sType );
393cdf0e10cSrcweir if ( pAny )
394cdf0e10cSrcweir {
395cdf0e10cSrcweir aPropVal_.Name = sType;
396cdf0e10cSrcweir aPropVal_.Value = *pAny;
397cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
398cdf0e10cSrcweir }
399cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sAdjustmentValues );
400cdf0e10cSrcweir if ( pAny )
401cdf0e10cSrcweir {
402cdf0e10cSrcweir aPropVal_.Name = sAdjustmentValues;
403cdf0e10cSrcweir aPropVal_.Value = *pAny;
404cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
405cdf0e10cSrcweir }
406cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateOrigin );
407cdf0e10cSrcweir if ( pAny )
408cdf0e10cSrcweir {
409cdf0e10cSrcweir aPropVal_.Name = sCoordinateOrigin;
410cdf0e10cSrcweir aPropVal_.Value = *pAny;
411cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
412cdf0e10cSrcweir }
413cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sCoordinateSize );
414cdf0e10cSrcweir if ( pAny )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir aPropVal_.Name = sCoordinateSize;
417cdf0e10cSrcweir aPropVal_.Value = *pAny;
418cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
419cdf0e10cSrcweir }
420cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sEquations );
421cdf0e10cSrcweir if ( pAny )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir aPropVal_.Name = sEquations;
424cdf0e10cSrcweir aPropVal_.Value = *pAny;
425cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
426cdf0e10cSrcweir }
427cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sHandles );
428cdf0e10cSrcweir if ( pAny )
429cdf0e10cSrcweir {
430cdf0e10cSrcweir aPropVal_.Name = sHandles;
431cdf0e10cSrcweir aPropVal_.Value = *pAny;
432cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
433cdf0e10cSrcweir }
434cdf0e10cSrcweir pAny = rSourceGeometry.GetPropertyValueByName( sPath );
435cdf0e10cSrcweir if ( pAny )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir aPropVal_.Name = sPath;
438cdf0e10cSrcweir aPropVal_.Value = *pAny;
439cdf0e10cSrcweir rGeometryItem.SetPropertyValue( aPropVal_ );
440cdf0e10cSrcweir }
441cdf0e10cSrcweir }
442cdf0e10cSrcweir }
443cdf0e10cSrcweir }
444cdf0e10cSrcweir }
445cdf0e10cSrcweir }
446cdf0e10cSrcweir }
447cdf0e10cSrcweir }
448cdf0e10cSrcweir
449cdf0e10cSrcweir
execute(SdrView * pSdrView,SfxRequest & rReq,SfxBindings & rBindings)450cdf0e10cSrcweir void FontworkBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBindings )
451cdf0e10cSrcweir {
452cdf0e10cSrcweir sal_uInt16 nStrResId = 0;
453cdf0e10cSrcweir
454cdf0e10cSrcweir sal_uInt16 nSID = rReq.GetSlot();
455cdf0e10cSrcweir switch( nSID )
456cdf0e10cSrcweir {
457cdf0e10cSrcweir case SID_FONTWORK_GALLERY_FLOATER:
458cdf0e10cSrcweir {
459cdf0e10cSrcweir FontWorkGalleryDialog aDlg( pSdrView, ImpGetViewWin(pSdrView), nSID );
460cdf0e10cSrcweir aDlg.Execute();
461cdf0e10cSrcweir }
462cdf0e10cSrcweir break;
463cdf0e10cSrcweir
464cdf0e10cSrcweir case SID_FONTWORK_SHAPE_TYPE:
465cdf0e10cSrcweir {
466cdf0e10cSrcweir rtl::OUString aCustomShape;
467cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
468cdf0e10cSrcweir if ( pArgs )
469cdf0e10cSrcweir {
470cdf0e10cSrcweir const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
471cdf0e10cSrcweir aCustomShape = rItm.GetValue();
472cdf0e10cSrcweir }
473cdf0e10cSrcweir if ( aCustomShape.getLength() )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
476cdf0e10cSrcweir sal_uInt32 nCount = rMarkList.GetMarkCount(), i;
477cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
478cdf0e10cSrcweir {
479cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
480cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir const bool bUndo = pSdrView->IsUndoEnabled();
483cdf0e10cSrcweir
484cdf0e10cSrcweir if( bUndo )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir String aStr( SVX_RES( RID_SVXSTR_UNDO_APPLY_FONTWORK_SHAPE ) );
487cdf0e10cSrcweir pSdrView->BegUndo( aStr );
488cdf0e10cSrcweir pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
489cdf0e10cSrcweir }
490cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
491cdf0e10cSrcweir GetGeometryForCustomShape( aGeometryItem, aCustomShape );
492cdf0e10cSrcweir pObj->SetMergedItem( aGeometryItem );
493cdf0e10cSrcweir
494cdf0e10cSrcweir Reference< drawing::XShape > aXShape = GetXShapeForSdrObject( (SdrObjCustomShape*)pObj );
495cdf0e10cSrcweir if ( aXShape.is() )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( aXShape, UNO_QUERY );
498cdf0e10cSrcweir if( xDefaulter.is() )
499cdf0e10cSrcweir xDefaulter->createCustomShapeDefaults( aCustomShape );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir
502cdf0e10cSrcweir pObj->BroadcastObjectChange();
503cdf0e10cSrcweir if( bUndo )
504cdf0e10cSrcweir pSdrView->EndUndo();
505*5ffb42a1Smseidel pSdrView->AdjustMarkHdl(); // HMH sal_True );
506cdf0e10cSrcweir rBindings.Invalidate( SID_FONTWORK_SHAPE_TYPE );
507cdf0e10cSrcweir }
508cdf0e10cSrcweir }
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir break;
512cdf0e10cSrcweir
513cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING_DIALOG :
514cdf0e10cSrcweir {
515cdf0e10cSrcweir if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( SID_FONTWORK_CHARACTER_SPACING ) == SFX_ITEM_SET ) )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir sal_Int32 nCharSpacing = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_FONTWORK_CHARACTER_SPACING))->GetValue();
518cdf0e10cSrcweir FontworkCharacterSpacingDialog aDlg( 0L, nCharSpacing );
519cdf0e10cSrcweir sal_uInt16 nRet = aDlg.Execute();
520cdf0e10cSrcweir if( nRet != 0 )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir SfxInt32Item aItem( SID_FONTWORK_CHARACTER_SPACING, aDlg.getScale() );
523cdf0e10cSrcweir SfxPoolItem* aItems[] = { &aItem, 0 };
524cdf0e10cSrcweir rBindings.Execute( SID_FONTWORK_CHARACTER_SPACING, (const SfxPoolItem**)aItems );
525cdf0e10cSrcweir }
526cdf0e10cSrcweir }
527cdf0e10cSrcweir }
528cdf0e10cSrcweir break;
529cdf0e10cSrcweir
530cdf0e10cSrcweir case SID_FONTWORK_SHAPE:
531cdf0e10cSrcweir case SID_FONTWORK_ALIGNMENT:
532cdf0e10cSrcweir {
533cdf0e10cSrcweir if ( !nStrResId )
534cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_ALIGNMENT;
535cdf0e10cSrcweir } // PASSTROUGH
536cdf0e10cSrcweir case SID_FONTWORK_CHARACTER_SPACING:
537cdf0e10cSrcweir {
538cdf0e10cSrcweir if ( !nStrResId )
539cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
540cdf0e10cSrcweir } // PASSTROUGH
541cdf0e10cSrcweir case SID_FONTWORK_KERN_CHARACTER_PAIRS:
542cdf0e10cSrcweir {
543cdf0e10cSrcweir if ( !nStrResId )
544cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_CHARACTER_SPACING;
545cdf0e10cSrcweir } // PASSTROUGH
546cdf0e10cSrcweir case SID_FONTWORK_SAME_LETTER_HEIGHTS:
547cdf0e10cSrcweir {
548cdf0e10cSrcweir if ( !nStrResId )
549cdf0e10cSrcweir nStrResId = RID_SVXSTR_UNDO_APPLY_FONTWORK_SAME_LETTER_HEIGHT;
550cdf0e10cSrcweir
551cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
552cdf0e10cSrcweir sal_uIntPtr nCount = rMarkList.GetMarkCount(), i;
553cdf0e10cSrcweir for( i = 0; i < nCount; i++ )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
556cdf0e10cSrcweir if( pObj->ISA(SdrObjCustomShape) )
557cdf0e10cSrcweir {
558cdf0e10cSrcweir const bool bUndo = pSdrView->IsUndoEnabled();
559cdf0e10cSrcweir if( bUndo )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir String aStr( SVX_RES( nStrResId ) );
562cdf0e10cSrcweir pSdrView->BegUndo( aStr );
563cdf0e10cSrcweir pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
564cdf0e10cSrcweir }
565cdf0e10cSrcweir SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
566cdf0e10cSrcweir impl_execute( pSdrView, rReq, aGeometryItem, pObj );
567cdf0e10cSrcweir pObj->SetMergedItem( aGeometryItem );
568cdf0e10cSrcweir pObj->BroadcastObjectChange();
569cdf0e10cSrcweir if( bUndo )
570cdf0e10cSrcweir pSdrView->EndUndo();
571cdf0e10cSrcweir }
572cdf0e10cSrcweir }
573cdf0e10cSrcweir }
574cdf0e10cSrcweir break;
575cdf0e10cSrcweir };
576cdf0e10cSrcweir }
577cdf0e10cSrcweir
getState(SdrView * pSdrView,SfxItemSet & rSet)578cdf0e10cSrcweir void FontworkBar::getState( SdrView* pSdrView, SfxItemSet& rSet )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir sal_uInt32 nCheckStatus = 0;
581cdf0e10cSrcweir
582cdf0e10cSrcweir /*
583cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SHAPE ) != SFX_ITEM_UNKNOWN )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir sal_Bool bBreak = sal_True;
586cdf0e10cSrcweir }
587cdf0e10cSrcweir */
588cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT_FLOATER ) != SFX_ITEM_UNKNOWN )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
591cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_ALIGNMENT_FLOATER );
592cdf0e10cSrcweir }
593cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_ALIGNMENT ) != SFX_ITEM_UNKNOWN )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
596cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_ALIGNMENT );
597cdf0e10cSrcweir else
598cdf0e10cSrcweir SetAlignmentState( pSdrView, rSet );
599cdf0e10cSrcweir }
600cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING_FLOATER ) != SFX_ITEM_UNKNOWN )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
603cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING_FLOATER );
604cdf0e10cSrcweir }
605cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_CHARACTER_SPACING ) != SFX_ITEM_UNKNOWN )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
608cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_CHARACTER_SPACING );
609cdf0e10cSrcweir else
610cdf0e10cSrcweir SetCharacterSpacingState( pSdrView, rSet );
611cdf0e10cSrcweir }
612cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_KERN_CHARACTER_PAIRS ) != SFX_ITEM_UNKNOWN )
613cdf0e10cSrcweir {
614cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
615cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_KERN_CHARACTER_PAIRS );
616cdf0e10cSrcweir else
617cdf0e10cSrcweir SetKernCharacterPairsState( pSdrView, rSet );
618cdf0e10cSrcweir }
619cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SAME_LETTER_HEIGHTS ) != SFX_ITEM_UNKNOWN )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
622cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_SAME_LETTER_HEIGHTS );
623cdf0e10cSrcweir }
624cdf0e10cSrcweir if ( rSet.GetItemState( SID_FONTWORK_SHAPE_TYPE ) != SFX_ITEM_UNKNOWN )
625cdf0e10cSrcweir {
626*5ffb42a1Smseidel if ( !checkForSelectedFontWork( pSdrView, nCheckStatus ) )
627cdf0e10cSrcweir rSet.DisableItem( SID_FONTWORK_SHAPE_TYPE );
628cdf0e10cSrcweir else
629cdf0e10cSrcweir SetFontWorkShapeTypeState( pSdrView, rSet );
630cdf0e10cSrcweir }
631cdf0e10cSrcweir }
632