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