LCOV - code coverage report
Current view: top level - libreoffice/svx/source/sdr/properties - customshapeproperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 53 85 62.4 %
Date: 2012-12-27 Functions: 11 15 73.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/sdr/properties/customshapeproperties.hxx>
      21             : #include <svl/itemset.hxx>
      22             : #include <svl/style.hxx>
      23             : #include <svx/svdoashp.hxx>
      24             : #include <editeng/eeitem.hxx>
      25             : #include <svx/sdtagitm.hxx>
      26             : #include <svl/whiter.hxx>
      27             : #include <svl/smplhint.hxx>
      28             : 
      29             : //////////////////////////////////////////////////////////////////////////////
      30             : 
      31             : namespace sdr
      32             : {
      33             :     namespace properties
      34             :     {
      35        1791 :         void CustomShapeProperties::UpdateTextFrameStatus()
      36             :         {
      37        1791 :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
      38             :             SdrTextAutoGrowHeightItem& rAutoGrowHeightItem =
      39        1791 :                 (SdrTextAutoGrowHeightItem&)rObj.GetMergedItem( SDRATTR_TEXT_AUTOGROWHEIGHT );
      40        1791 :             rObj.bTextFrame = rAutoGrowHeightItem.GetValue() != 0;
      41             : 
      42        1791 :             if ( rObj.bTextFrame )
      43        1791 :                 rObj.NbcAdjustTextFrameWidthAndHeight();
      44        1791 :         }
      45             : 
      46         862 :         SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
      47             :         {
      48             :             return *(new SfxItemSet(rPool,
      49             : 
      50             :                 // ranges from SdrAttrObj
      51             :                 SDRATTR_START, SDRATTR_SHADOW_LAST,
      52             :                 SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
      53             :                 SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
      54             : 
      55             :                 // Graphic Attributes
      56             :                 SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
      57             : 
      58             :                 // 3d Properties
      59             :                 SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
      60             : 
      61             :                 // CustomShape properties
      62             :                 SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
      63             : 
      64             :                 // range from SdrTextObj
      65             :                 EE_ITEMS_START, EE_ITEMS_END,
      66             : 
      67             :                 // end
      68         862 :                 0, 0));
      69             :         }
      70       32622 :         sal_Bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const
      71             :         {
      72       32622 :             sal_Bool bAllowItemChange = sal_True;
      73       32622 :             if ( !pNewItem )
      74             :             {
      75       12710 :                 if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) )
      76         248 :                     bAllowItemChange = sal_False;
      77             :             }
      78       32622 :             if ( bAllowItemChange )
      79       32374 :                 bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem );
      80       32622 :             return bAllowItemChange;
      81             :         }
      82          62 :         void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich)
      83             :         {
      84          62 :             if ( !nWhich )
      85             :             {
      86          62 :                 SfxWhichIter aIter( *mpItemSet );
      87          62 :                 sal_uInt16 nWhich2 = aIter.FirstWhich();
      88       12834 :                 while( nWhich2 )
      89             :                 {
      90       12710 :                     TextProperties::ClearObjectItemDirect( nWhich2 );
      91       12710 :                     nWhich2 = aIter.NextWhich();
      92             :                 }
      93          62 :                 SfxItemSet aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool()));
      94          62 :                 ItemSetChanged(aSet);
      95             :             }
      96             :             else
      97           0 :                 TextProperties::ClearObjectItem( nWhich );
      98          62 :         }
      99           0 :         void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich)
     100             :         {
     101           0 :             if ( !nWhich )
     102             :             {
     103           0 :                 SfxWhichIter aIter( *mpItemSet );
     104           0 :                 sal_uInt16 nWhich2 = aIter.FirstWhich();
     105           0 :                 while( nWhich2 )
     106             :                 {
     107           0 :                     TextProperties::ClearObjectItemDirect( nWhich2 );
     108           0 :                     nWhich2 = aIter.NextWhich();
     109           0 :                 }
     110             :             }
     111             :             else
     112           0 :                 TextProperties::ClearObjectItemDirect( nWhich );
     113           0 :         }
     114        7900 :         void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet)
     115             :         {
     116        7900 :             SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
     117             : 
     118        7900 :             if( SFX_ITEM_SET == rSet.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) )
     119             :             {
     120        1400 :                 rObj.bTextFrame = ((SdrTextAutoGrowHeightItem&)rSet.Get( SDRATTR_TEXT_AUTOGROWHEIGHT )).GetValue() != 0;
     121             :             }
     122             : 
     123             :             // call parent
     124        7900 :             TextProperties::ItemSetChanged(rSet);
     125             : 
     126             :             // local changes, removing cached objects
     127        7900 :             rObj.InvalidateRenderGeometry();
     128        7900 :         }
     129       32374 :         void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
     130             :         {
     131       32374 :             SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
     132             :             //OutlinerParaObject* pParaObj = rObj.GetOutlinerParaObject();
     133             : 
     134       32374 :             if( pNewItem && ( SDRATTR_TEXT_AUTOGROWHEIGHT == nWhich ) )
     135             :             {
     136        1400 :                 rObj.bTextFrame = ((SdrTextAutoGrowHeightItem*)pNewItem)->GetValue() != 0;
     137             :             }
     138             :             // call parent
     139       32374 :             TextProperties::ItemChange( nWhich, pNewItem );
     140             : 
     141       32374 :             rObj.InvalidateRenderGeometry();
     142       32374 :         }
     143         929 :         void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
     144             :         {
     145         929 :             TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr );
     146         929 :             UpdateTextFrameStatus();
     147         929 :         }
     148         862 :         void CustomShapeProperties::ForceDefaultAttributes()
     149             :         {
     150         862 :             UpdateTextFrameStatus();
     151             : 
     152             : /* SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml
     153             : 
     154             :             SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
     155             :             sal_Bool bTextFrame(rObj.IsTextFrame());
     156             : 
     157             :             // force ItemSet
     158             :             GetObjectItemSet();
     159             : 
     160             :             if(bTextFrame)
     161             :             {
     162             :                 mpItemSet->Put(XLineStyleItem(XLINE_NONE));
     163             :                 mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
     164             :                 mpItemSet->Put(XFillStyleItem(XFILL_NONE));
     165             :             }
     166             :             else
     167             :             {
     168             :                 mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER));
     169             :                 mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
     170             :                 mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
     171             :             }
     172             : */
     173         862 :         }
     174         862 :         CustomShapeProperties::CustomShapeProperties(SdrObject& rObj)
     175         862 :         :   TextProperties(rObj)
     176             :         {
     177         862 :         }
     178             : 
     179           0 :         CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties& rProps, SdrObject& rObj)
     180           0 :         :   TextProperties(rProps, rObj)
     181             :         {
     182           0 :         }
     183             : 
     184        1682 :         CustomShapeProperties::~CustomShapeProperties()
     185             :         {
     186        1682 :         }
     187             : 
     188           0 :         BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) const
     189             :         {
     190           0 :             return *(new CustomShapeProperties(*this, rObj));
     191             :         }
     192           0 :         void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     193             :         {
     194           0 :             TextProperties::Notify( rBC, rHint );
     195             : 
     196           0 :             sal_Bool bRemoveRenderGeometry = sal_False;
     197             : 
     198           0 :             const SfxStyleSheetHint *pStyleHint = PTR_CAST( SfxStyleSheetHint, &rHint );
     199           0 :             const SfxSimpleHint *pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
     200           0 :             if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() )
     201             :             {
     202           0 :                 switch( pStyleHint->GetHint() )
     203             :                 {
     204             :                     case SFX_STYLESHEET_MODIFIED :
     205             :                     case SFX_STYLESHEET_CHANGED  :
     206           0 :                         bRemoveRenderGeometry = sal_True;
     207           0 :                     break;
     208             :                 };
     209             :             }
     210           0 :             else if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DATACHANGED )
     211             :             {
     212           0 :                 bRemoveRenderGeometry = sal_True;
     213             :             }
     214           0 :             if ( bRemoveRenderGeometry )
     215             :             {
     216           0 :                 UpdateTextFrameStatus();
     217             : 
     218             :                 // local changes, removing cached objects
     219           0 :                 SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject();
     220           0 :                 rObj.InvalidateRenderGeometry();
     221             :             }
     222             : 
     223           0 :         }
     224             :     } // end of namespace properties
     225             : } // end of namespace sdr
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10