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