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