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