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