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