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