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

Generated by: LCOV version 1.10