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