LCOV - code coverage report
Current view: top level - svx/source/toolbars - fontworkbar.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 319 0.0 %
Date: 2014-04-14 Functions: 0 22 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10