LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/core - stlsheet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 353 575 61.4 %
Date: 2013-07-09 Functions: 37 59 62.7 %
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             : 
      21             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      22             : #include <com/sun/star/lang/DisposedException.hpp>
      23             : #include <com/sun/star/style/XStyle.hpp>
      24             : 
      25             : #include <osl/mutex.hxx>
      26             : #include <vcl/svapp.hxx>
      27             : #include <comphelper/serviceinfohelper.hxx>
      28             : #include <boost/bind.hpp>
      29             : 
      30             : #include <editeng/outliner.hxx>
      31             : #include <editeng/eeitem.hxx>
      32             : #include <editeng/fhgtitem.hxx>
      33             : #include <svx/svdoattr.hxx>
      34             : #include <editeng/ulspitem.hxx>
      35             : #include <svl/smplhint.hxx>
      36             : #include <svl/itemset.hxx>
      37             : 
      38             : #include <svx/sdr/properties/attributeproperties.hxx>
      39             : #include <svx/xflbmtit.hxx>
      40             : #include <svx/xflbstit.hxx>
      41             : #include <editeng/bulletitem.hxx>
      42             : #include <editeng/lrspitem.hxx>
      43             : #include <svx/unoshprp.hxx>
      44             : #include <svx/unoshape.hxx>
      45             : #include <svx/svdpool.hxx>
      46             : #include "stlsheet.hxx"
      47             : #include "sdresid.hxx"
      48             : #include "sdpage.hxx"
      49             : #include "drawdoc.hxx"
      50             : #include "stlpool.hxx"
      51             : #include "glob.hrc"
      52             : #include "app.hrc"
      53             : #include "glob.hxx"
      54             : #include "helpids.h"
      55             : #include "../ui/inc/DrawViewShell.hxx"
      56             : #include "../ui/inc/ViewShellBase.hxx"
      57             : #include <editeng/boxitem.hxx>
      58             : 
      59             : 
      60             : using ::osl::MutexGuard;
      61             : using ::osl::ClearableMutexGuard;
      62             : using ::cppu::OInterfaceContainerHelper;
      63             : using ::com::sun::star::table::BorderLine;
      64             : using namespace ::com::sun::star::uno;
      65             : using namespace ::com::sun::star::util;
      66             : using namespace ::com::sun::star::lang;
      67             : using namespace ::com::sun::star::style;
      68             : using namespace ::com::sun::star::beans;
      69             : using namespace ::com::sun::star::container;
      70             : using namespace ::com::sun::star::drawing;
      71             : 
      72             : #define WID_STYLE_HIDDEN    7997
      73             : #define WID_STYLE_DISPNAME  7998
      74             : #define WID_STYLE_FAMILY    7999
      75             : 
      76       74228 : static SvxItemPropertySet& GetStylePropertySet()
      77             : {
      78             :     static const SfxItemPropertyMapEntry aFullPropertyMap_Impl[] =
      79             :     {
      80           4 :         { RTL_CONSTASCII_STRINGPARAM("Family"),                 WID_STYLE_FAMILY,       &::getCppuType((const OUString*)0), PropertyAttribute::READONLY,    0},
      81           4 :         { RTL_CONSTASCII_STRINGPARAM("UserDefinedAttributes"),  SDRATTR_XMLATTRIBUTES,  &XNameContainer::static_type(), 0,     0},
      82           4 :         { RTL_CONSTASCII_STRINGPARAM("DisplayName"),            WID_STYLE_DISPNAME,     &::getCppuType((const OUString*)0), PropertyAttribute::READONLY,    0},
      83           4 :         { RTL_CONSTASCII_STRINGPARAM("Hidden"),                 WID_STYLE_HIDDEN,       &::getCppuType((bool*)0),       0,     0},
      84             : 
      85           8 :         SVX_UNOEDIT_NUMBERING_PROPERTIE,
      86          20 :         SHADOW_PROPERTIES
      87          48 :         LINE_PROPERTIES
      88          16 :         LINE_PROPERTIES_START_END
      89         104 :         FILL_PROPERTIES
      90           4 :         EDGERADIUS_PROPERTIES
      91         336 :         TEXT_PROPERTIES_DEFAULTS
      92          20 :         CONNECTOR_PROPERTIES
      93          80 :         SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS
      94           4 :         { MAP_CHAR_LEN("TopBorder"),                    SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, TOP_BORDER }, \
      95           4 :         { MAP_CHAR_LEN("BottomBorder"),                 SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, BOTTOM_BORDER }, \
      96           4 :         { MAP_CHAR_LEN("LeftBorder"),                   SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, LEFT_BORDER }, \
      97           4 :         { MAP_CHAR_LEN("RightBorder"),                  SDRATTR_TABLE_BORDER,           &::getCppuType((const BorderLine*)0), 0, RIGHT_BORDER }, \
      98             :         {0,0,0,0,0,0}
      99       74896 :     };
     100             : 
     101       74228 :     static SvxItemPropertySet aPropSet( aFullPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
     102       74228 :     return aPropSet;
     103             : }
     104             : 
     105        5280 : class ModifyListenerForewarder : public SfxListener
     106             : {
     107             : public:
     108             :     ModifyListenerForewarder( SdStyleSheet* pStyleSheet );
     109             : 
     110             :     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint);
     111             : 
     112             : private:
     113             :     SdStyleSheet* mpStyleSheet;
     114             : };
     115             : 
     116        2739 : ModifyListenerForewarder::ModifyListenerForewarder( SdStyleSheet* pStyleSheet )
     117        2739 : : mpStyleSheet( pStyleSheet )
     118             : {
     119        2739 :     if( pStyleSheet )
     120             :     {
     121        2739 :         SfxBroadcaster& rBC = static_cast< SfxBroadcaster& >( *pStyleSheet );
     122        2739 :         StartListening( rBC );
     123             :     }
     124        2739 : }
     125             : 
     126        7110 : void ModifyListenerForewarder::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
     127             : {
     128        7110 :     if( mpStyleSheet )
     129        7110 :         mpStyleSheet->notifyModifyListener();
     130        7110 : }
     131             : 
     132        6608 : SdStyleSheet::SdStyleSheet(const OUString& rDisplayName, SfxStyleSheetBasePool& _rPool, SfxStyleFamily eFamily, sal_uInt16 _nMask)
     133             : : SdStyleSheetBase( OUString( rDisplayName ), _rPool, eFamily, _nMask)
     134             : , ::cppu::BaseMutex()
     135             : , msApiName( rDisplayName )
     136             : , mxPool( const_cast< SfxStyleSheetBasePool* >(&_rPool) )
     137        6608 : , mrBHelper( m_aMutex )
     138             : {
     139        6608 : }
     140             : 
     141           0 : SdStyleSheet::SdStyleSheet( const SdStyleSheet & r )
     142             : : SdStyleSheetBase( r )
     143             : , ::cppu::BaseMutex()
     144             : , msApiName( r.msApiName )
     145             : , mxPool( r.mxPool )
     146           0 : , mrBHelper( m_aMutex )
     147             : {
     148           0 : }
     149             : 
     150       19122 : SdStyleSheet::~SdStyleSheet()
     151             : {
     152        6374 :     delete pSet;
     153        6374 :     pSet = NULL;    // that following destructors also get a change
     154       12748 : }
     155             : 
     156           0 : void SdStyleSheet::SetApiName( const OUString& rApiName )
     157             : {
     158           0 :     msApiName = rApiName;
     159           0 : }
     160             : 
     161        8398 : OUString SdStyleSheet::GetApiName() const
     162             : {
     163        8398 :     if( !msApiName.isEmpty() )
     164        8398 :         return msApiName;
     165             :     else
     166           0 :         return GetName();
     167             : }
     168             : 
     169             : 
     170           0 : void SdStyleSheet::Load (SvStream& rIn, sal_uInt16 nVersion)
     171             : {
     172           0 :     SfxStyleSheetBase::Load(rIn, nVersion);
     173             : 
     174             :     /* previously, the default mask was 0xAFFE. The needed flags were masked
     175             :        from this mask. Now the flag SFXSTYLEBIT_READONLY was introduced and with
     176             :        this, all style sheets are read only. Since no style sheet should be read
     177             :        only in Draw, we reset the flag here.  */
     178           0 :     nMask &= ~SFXSTYLEBIT_READONLY;
     179           0 : }
     180             : 
     181             : 
     182           0 : void SdStyleSheet::Store(SvStream& rOut)
     183             : {
     184           0 :     SfxStyleSheetBase::Store(rOut);
     185           0 : }
     186             : 
     187             : 
     188        7214 : bool SdStyleSheet::SetParent(const OUString& rParentName)
     189             : {
     190        7214 :     bool bResult = false;
     191             : 
     192        7214 :     if (SfxStyleSheet::SetParent(rParentName))
     193             :     {
     194             :         // PseudoStyleSheets do not have their own ItemSets
     195        7214 :         if (nFamily != SD_STYLE_FAMILY_PSEUDO)
     196             :         {
     197        6135 :             if( !rParentName.isEmpty() )
     198             :             {
     199        4881 :                 SfxStyleSheetBase* pStyle = pPool->Find(rParentName, nFamily);
     200        4881 :                 if (pStyle)
     201             :                 {
     202        4881 :                     bResult = true;
     203        4881 :                     SfxItemSet& rParentSet = pStyle->GetItemSet();
     204        4881 :                     GetItemSet().SetParent(&rParentSet);
     205        4881 :                     Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     206             :                 }
     207             :             }
     208             :             else
     209             :             {
     210        1254 :                 bResult = true;
     211        1254 :                 GetItemSet().SetParent(NULL);
     212        1254 :                 Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
     213             :             }
     214             :         }
     215             :         else
     216             :         {
     217        1079 :             bResult = true;
     218             :         }
     219             :     }
     220        7214 :     return bResult;
     221             : }
     222             : 
     223             : /**
     224             :  * create if necessary and return ItemSets
     225             :  */
     226     1338560 : SfxItemSet& SdStyleSheet::GetItemSet()
     227             : {
     228     1338560 :     if (nFamily == SD_STYLE_FAMILY_GRAPHICS || nFamily == SD_STYLE_FAMILY_MASTERPAGE)
     229             :     {
     230             :         // we create the ItemSet 'on demand' if necessary
     231     1324275 :         if (!pSet)
     232             :         {
     233             :             sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST,              XATTR_LINE_LAST,
     234             :                                          XATTR_FILL_FIRST,              XATTR_FILL_LAST,
     235             : 
     236             :                                         SDRATTR_SHADOW_FIRST,           SDRATTR_SHADOW_LAST,
     237             :                                         SDRATTR_TEXT_MINFRAMEHEIGHT,    SDRATTR_TEXT_CONTOURFRAME,
     238             : 
     239             :                                         SDRATTR_TEXT_WORDWRAP,          SDRATTR_TEXT_AUTOGROWSIZE,
     240             : 
     241             :                                         SDRATTR_EDGE_FIRST,             SDRATTR_EDGE_LAST,
     242             :                                         SDRATTR_MEASURE_FIRST,          SDRATTR_MEASURE_LAST,
     243             : 
     244             :                                         EE_PARA_START,                  EE_CHAR_END,
     245             : 
     246             :                                         SDRATTR_XMLATTRIBUTES,          SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
     247             : 
     248             :                                         SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     249        2590 :                                         0, 0 };
     250             : 
     251        2590 :             pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
     252             :         }
     253             : 
     254     1324275 :         return *pSet;
     255             :     }
     256             : 
     257       14285 :     else if( nFamily == SD_STYLE_FAMILY_CELL )
     258             :     {
     259       13489 :         if (!pSet)
     260             :         {
     261             :             sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST,              XATTR_LINE_LAST,
     262             :                                          XATTR_FILL_FIRST,              XATTR_FILL_LAST,
     263             : 
     264             :                                         SDRATTR_SHADOW_FIRST,           SDRATTR_SHADOW_LAST,
     265             :                                         SDRATTR_TEXT_MINFRAMEHEIGHT,    SDRATTR_TEXT_CONTOURFRAME,
     266             : 
     267             :                                         SDRATTR_TEXT_WORDWRAP,          SDRATTR_TEXT_AUTOGROWSIZE,
     268             : 
     269             :                                         EE_PARA_START,                  EE_CHAR_END,
     270             : 
     271             :                                         SDRATTR_TABLE_FIRST,            SDRATTR_TABLE_LAST,
     272             :                                         SDRATTR_XMLATTRIBUTES,          SDRATTR_XMLATTRIBUTES,
     273             : 
     274        2856 :                                         0, 0 };
     275             : 
     276        2856 :             pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
     277             :         }
     278             : 
     279       13489 :         return *pSet;
     280             :     }
     281             : 
     282             :     // this is a dummy template for the internal template of the
     283             :     // current presentation layout; return the ItemSet of that template
     284             :     else
     285             :     {
     286             : 
     287         796 :         SdStyleSheet* pSdSheet = GetRealStyleSheet();
     288             : 
     289         796 :         if (pSdSheet)
     290             :         {
     291         796 :             return(pSdSheet->GetItemSet());
     292             :         }
     293             :         else
     294             :         {
     295           0 :             if (!pSet)
     296             :             {
     297             :                 sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST,              XATTR_LINE_LAST,
     298             :                                              XATTR_FILL_FIRST,              XATTR_FILL_LAST,
     299             : 
     300             :                                              SDRATTR_SHADOW_FIRST,          SDRATTR_SHADOW_LAST,
     301             :                                              SDRATTR_TEXT_MINFRAMEHEIGHT,   SDRATTR_TEXT_CONTOURFRAME,
     302             : 
     303             :                                              SDRATTR_TEXT_WORDWRAP,         SDRATTR_TEXT_AUTOGROWSIZE,
     304             : 
     305             :                                              SDRATTR_EDGE_FIRST,            SDRATTR_EDGE_LAST,
     306             :                                              SDRATTR_MEASURE_FIRST,         SDRATTR_MEASURE_LAST,
     307             : 
     308             :                                              EE_PARA_START,                 EE_CHAR_END,
     309             : 
     310             :                                             SDRATTR_XMLATTRIBUTES,          SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
     311             : 
     312             :                                             SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
     313           0 :                                              0, 0 };
     314             : 
     315           0 :                 pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
     316             :             }
     317             : 
     318           0 :             return(*pSet);
     319             :         }
     320             :     }
     321             : }
     322             : 
     323             : /**
     324             :  * A template is used when it is referenced by inserted object or by a used
     325             :  * template.
     326             :  */
     327         485 : bool SdStyleSheet::IsUsed() const
     328             : {
     329         485 :     bool bResult = false;
     330             : 
     331         485 :     sal_uInt16 nListenerCount = GetListenerCount();
     332         485 :     if (nListenerCount > 0)
     333             :     {
     334         996 :         for (sal_uInt16 n = 0; n < nListenerCount; n++)
     335             :         {
     336         594 :             SfxListener* pListener = GetListener(n);
     337         594 :             if( pListener == this )
     338           0 :                 continue;
     339             : 
     340         594 :             const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener));
     341         594 :             if (pUser)
     342         198 :                 bResult = pUser->isUsedByModel();
     343         594 :             if (bResult)
     344           0 :                 break;
     345             :         }
     346             :     }
     347             : 
     348         485 :     if( !bResult )
     349             :     {
     350         485 :         MutexGuard aGuard( mrBHelper.rMutex );
     351             : 
     352         485 :         OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() );
     353         485 :         if( pContainer )
     354             :         {
     355         396 :             Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() );
     356         396 :             Reference< XInterface > *p = aModifyListeners.getArray();
     357         396 :             sal_Int32 nCount = aModifyListeners.getLength();
     358        1716 :             while( nCount-- && !bResult )
     359             :             {
     360         924 :                 Reference< XStyle > xStyle( *p++, UNO_QUERY );
     361         924 :                 if( xStyle.is() )
     362         924 :                     bResult = xStyle->isInUse();
     363        1320 :             }
     364         485 :         }
     365             :     }
     366         485 :     return bResult;
     367             : }
     368             : 
     369             : /**
     370             :  * Determine the style sheet for which this dummy is for.
     371             :  */
     372         796 : SdStyleSheet* SdStyleSheet::GetRealStyleSheet() const
     373             : {
     374         796 :     OUString aRealStyle;
     375        1592 :     OUString aSep( SD_LT_SEPARATOR );
     376         796 :     SdStyleSheet* pRealStyle = NULL;
     377         796 :     SdDrawDocument* pDoc = ((SdStyleSheetPool*)pPool)->GetDoc();
     378             : 
     379         796 :     ::sd::DrawViewShell* pDrawViewShell = 0;
     380             : 
     381         796 :     ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase* >( SfxViewShell::Current() );
     382         796 :     if( pBase )
     383           0 :         pDrawViewShell = dynamic_cast< ::sd::DrawViewShell* >( pBase->GetMainViewShell().get() );
     384             : 
     385         796 :     if (pDrawViewShell && pDrawViewShell->GetDoc() == pDoc)
     386             :     {
     387           0 :         SdPage* pPage = pDrawViewShell->getCurrentPage();
     388           0 :         if( pPage )
     389             :         {
     390           0 :             aRealStyle = pPage->GetLayoutName();
     391             :             // cut after separator string
     392             : 
     393           0 :             if( aRealStyle.indexOf(aSep) >= 0)
     394             :             {
     395           0 :                 aRealStyle = aRealStyle.copy(0,(aRealStyle.indexOf(aSep) + aSep.getLength()));
     396             :             }
     397             :         }
     398             :     }
     399         796 :     if (aRealStyle.isEmpty())
     400             :     {
     401         796 :         SdPage* pPage = pDoc->GetSdPage(0, PK_STANDARD);
     402             : 
     403         796 :         if (pPage)
     404             :         {
     405          40 :             aRealStyle = pDoc->GetSdPage(0, PK_STANDARD)->GetLayoutName();
     406             :         }
     407             :         else
     408             :         {
     409             :             /* no page available yet. This can happen when actualising the
     410             :                document templates.  */
     411         756 :             SfxStyleSheetIterator aIter(pPool, SD_STYLE_FAMILY_MASTERPAGE);
     412         756 :             SfxStyleSheetBase* pSheet = aIter.First();
     413         756 :             if( pSheet )
     414         756 :                 aRealStyle = pSheet->GetName();
     415             :         }
     416             : 
     417         796 :             if( aRealStyle.indexOf(aSep) >= 0)
     418             :             {
     419         796 :                 aRealStyle = aRealStyle.copy(0,(aRealStyle.indexOf(aSep) + aSep.getLength()));
     420             :             }
     421             :     }
     422             : 
     423             :     /* now map from the name (specified for country language) to the internal
     424             :        name (independent of the country language)  */
     425        1592 :     OUString aInternalName;
     426        1592 :     OUString aStyleName(aName);
     427             : 
     428         796 :     if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_TITLE)))
     429             :     {
     430           8 :         aInternalName = OUString(SdResId(STR_LAYOUT_TITLE));
     431             :     }
     432         788 :     else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_SUBTITLE)))
     433             :     {
     434           8 :         aInternalName = OUString(SdResId(STR_LAYOUT_SUBTITLE));
     435             :     }
     436         780 :     else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_BACKGROUND)))
     437             :     {
     438           8 :         aInternalName = OUString(SdResId(STR_LAYOUT_BACKGROUND));
     439             :     }
     440         772 :         else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)))
     441             :     {
     442         692 :         aInternalName = OUString(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
     443             :     }
     444          80 :         else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_NOTES)))
     445             :     {
     446           8 :         aInternalName = OUString(SdResId(STR_LAYOUT_NOTES));
     447             :     }
     448             :     else
     449             :     {
     450          72 :         OUString aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
     451          72 :         sal_Int32 nPos = aStyleName.indexOf(aOutlineStr);
     452          72 :         if (nPos >= 0)
     453             :         {
     454          72 :             String aNumStr(aStyleName.copy(aOutlineStr.getLength()));
     455          72 :             aInternalName = OUString(SdResId(STR_LAYOUT_OUTLINE));
     456          72 :             aInternalName += aNumStr;
     457          72 :         }
     458             :     }
     459             : 
     460         796 :     aRealStyle += aInternalName;
     461         796 :     pRealStyle = static_cast< SdStyleSheet* >( pPool->Find(aRealStyle, SD_STYLE_FAMILY_MASTERPAGE) );
     462             : 
     463             : #ifdef DBG_UTIL
     464             :     if( !pRealStyle )
     465             :     {
     466             :         SfxStyleSheetIterator aIter(pPool, SD_STYLE_FAMILY_MASTERPAGE);
     467             :         if( aIter.Count() > 0 )
     468             :             // StyleSheet not found, but pool already loaded
     469             :             DBG_ASSERT(pRealStyle, "Internal StyleSheet not found");
     470             :     }
     471             : #endif
     472             : 
     473        1592 :     return pRealStyle;
     474             : }
     475             : 
     476             : /**
     477             :  * Determine pseudo style sheet which stands for this style sheet.
     478             :  */
     479           0 : SdStyleSheet* SdStyleSheet::GetPseudoStyleSheet() const
     480             : {
     481           0 :     SdStyleSheet* pPseudoStyle = NULL;
     482           0 :     OUString aSep( SD_LT_SEPARATOR );
     483           0 :     OUString aStyleName(aName);
     484             :         // without layout name and separator
     485             : 
     486           0 :     if( aStyleName.indexOf(aSep) >=0 )
     487             :     {
     488           0 :         aStyleName = aStyleName.copy (aStyleName.indexOf(aSep) + aSep.getLength());
     489             :     }
     490             : 
     491           0 :     if (aStyleName == OUString(SdResId(STR_LAYOUT_TITLE)))
     492             :     {
     493           0 :         aStyleName = OUString(SdResId(STR_PSEUDOSHEET_TITLE));
     494             :     }
     495           0 :     else if (aStyleName == OUString(SdResId(STR_LAYOUT_SUBTITLE)))
     496             :     {
     497           0 :         aStyleName = OUString(SdResId(STR_PSEUDOSHEET_SUBTITLE));
     498             :     }
     499           0 :     else if (aStyleName == OUString(SdResId(STR_LAYOUT_BACKGROUND)))
     500             :     {
     501           0 :         aStyleName = OUString(SdResId(STR_PSEUDOSHEET_BACKGROUND));
     502             :     }
     503           0 :     else if (aStyleName == OUString(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)))
     504             :     {
     505           0 :         aStyleName = OUString(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
     506             :     }
     507           0 :     else if (aStyleName == OUString(SdResId(STR_LAYOUT_NOTES)))
     508             :     {
     509           0 :         aStyleName = OUString(SdResId(STR_PSEUDOSHEET_NOTES));
     510             :     }
     511             :     else
     512             :     {
     513           0 :         OUString aOutlineStr((SdResId(STR_LAYOUT_OUTLINE)));
     514           0 :         sal_Int32 nPos = aStyleName.indexOf(aOutlineStr);
     515           0 :         if (nPos != -1)
     516             :         {
     517           0 :             OUString aNumStr(aStyleName.copy(aOutlineStr.getLength()));
     518           0 :             aStyleName = OUString(SdResId(STR_PSEUDOSHEET_OUTLINE));
     519           0 :             aStyleName += aNumStr;
     520           0 :         }
     521             :     }
     522             : 
     523           0 :     pPseudoStyle = static_cast<SdStyleSheet*>(pPool->Find(aStyleName, SD_STYLE_FAMILY_PSEUDO));
     524             :     DBG_ASSERT(pPseudoStyle, "PseudoStyleSheet missing");
     525             : 
     526           0 :     return pPseudoStyle;
     527             : }
     528             : 
     529             : 
     530      428602 : void SdStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
     531             : {
     532             :     // first, base class functionality
     533      428602 :     SfxStyleSheet::Notify(rBC, rHint);
     534             : 
     535             :     /* if the dummy gets a notify about a changed attribute, he takes care that
     536             :        the actual ment style sheet sends broadcasts. */
     537      428602 :     SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint);
     538      428602 :     sal_uLong nId = pSimple == NULL ? 0 : pSimple->GetId();
     539      428602 :     if (nId == SFX_HINT_DATACHANGED && nFamily == SD_STYLE_FAMILY_PSEUDO)
     540             :     {
     541           0 :         SdStyleSheet* pRealStyle = GetRealStyleSheet();
     542           0 :         if (pRealStyle)
     543           0 :             pRealStyle->Broadcast(rHint);
     544             :     }
     545      428602 : }
     546             : 
     547             : /**
     548             :  * Adjust the bullet width and the left text indent of the provided ItemSets to
     549             :  * their font height. The new values are calculated that the ratio to the font
     550             :  * height is as in the style sheet.
     551             :  *
     552             :  * @param bOnlyMissingItems If sal_True, only not set items are completed. With
     553             :  * sal_False, are items are overwritten.
     554             :  */
     555           0 : void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, sal_Bool bOnlyMissingItems)
     556             : {
     557             :     /* If not explicit set, ddjust bullet width and text indent to new font
     558             :        height. */
     559           0 :     SfxStyleFamily eFamily = nFamily;
     560           0 :     OUString aStyleName(aName);
     561           0 :     if (eFamily == SD_STYLE_FAMILY_PSEUDO)
     562             :     {
     563           0 :         SfxStyleSheet* pRealStyle = GetRealStyleSheet();
     564           0 :         eFamily = pRealStyle->GetFamily();
     565           0 :         aStyleName = pRealStyle->GetName();
     566             :     }
     567             : 
     568           0 :     if (eFamily == SD_STYLE_FAMILY_MASTERPAGE &&
     569           0 :         aStyleName.indexOf(OUString(SdResId(STR_LAYOUT_OUTLINE))) != -1 &&
     570           0 :         rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SFX_ITEM_SET)
     571             :     {
     572           0 :         const SfxItemSet* pCurSet = &GetItemSet();
     573           0 :         sal_uInt32 nNewHeight = ((SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT)).GetHeight();
     574           0 :         sal_uInt32 nOldHeight = ((SvxFontHeightItem&)pCurSet->Get(EE_CHAR_FONTHEIGHT)).GetHeight();
     575             : 
     576           0 :         if (rSet.GetItemState(EE_PARA_BULLET) != SFX_ITEM_SET || !bOnlyMissingItems)
     577             :         {
     578           0 :             const SvxBulletItem& rBItem = (const SvxBulletItem&)pCurSet->Get(EE_PARA_BULLET);
     579           0 :             double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight;
     580           0 :             SvxBulletItem aNewBItem(rBItem);
     581           0 :             aNewBItem.SetWidth((sal_uInt32)(fBulletFraction * nNewHeight));
     582           0 :             rSet.Put(aNewBItem);
     583             :         }
     584             : 
     585           0 :         if (rSet.GetItemState(EE_PARA_LRSPACE) != SFX_ITEM_SET || !bOnlyMissingItems)
     586             :         {
     587           0 :             const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&)pCurSet->Get(EE_PARA_LRSPACE);
     588           0 :             double fIndentFraction = double(rLRItem.GetTxtLeft()) / nOldHeight;
     589           0 :             SvxLRSpaceItem aNewLRItem(rLRItem);
     590           0 :             aNewLRItem.SetTxtLeft(fIndentFraction * nNewHeight);
     591           0 :             double fFirstIndentFraction = double(rLRItem.GetTxtFirstLineOfst()) / nOldHeight;
     592           0 :             aNewLRItem.SetTxtFirstLineOfst((short)(fFirstIndentFraction * nNewHeight));
     593           0 :             rSet.Put(aNewLRItem);
     594             :         }
     595             : 
     596           0 :         if (rSet.GetItemState(EE_PARA_ULSPACE) != SFX_ITEM_SET || !bOnlyMissingItems)
     597             :         {
     598           0 :             const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pCurSet->Get(EE_PARA_ULSPACE);
     599           0 :             SvxULSpaceItem aNewULItem(rULItem);
     600           0 :             double fLowerFraction = double(rULItem.GetLower()) / nOldHeight;
     601           0 :             aNewULItem.SetLower((sal_uInt16)(fLowerFraction * nNewHeight));
     602           0 :             double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight;
     603           0 :             aNewULItem.SetUpper((sal_uInt16)(fUpperFraction * nNewHeight));
     604           0 :             rSet.Put(aNewULItem);
     605             :         }
     606           0 :     }
     607           0 : }
     608             : 
     609             : // --------------------------------------------------------------------
     610             : 
     611           0 : bool SdStyleSheet::HasFollowSupport() const
     612             : {
     613           0 :     return false;
     614             : }
     615             : 
     616             : // --------------------------------------------------------------------
     617             : 
     618           7 : bool SdStyleSheet::HasParentSupport() const
     619             : {
     620           7 :     return true;
     621             : }
     622             : 
     623             : // --------------------------------------------------------------------
     624             : 
     625           0 : bool SdStyleSheet::HasClearParentSupport() const
     626             : {
     627           0 :     return true;
     628             : }
     629             : 
     630             : // --------------------------------------------------------------------
     631             : 
     632         154 : bool SdStyleSheet::SetName( const OUString& rName )
     633             : {
     634         154 :     return SfxStyleSheet::SetName( rName );
     635             : }
     636             : 
     637             : // --------------------------------------------------------------------
     638             : 
     639        3850 : void SdStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
     640             : {
     641        3850 :     SfxStyleSheet::SetHelpId( r, nId );
     642             : 
     643        3850 :     if( (nId >= HID_PSEUDOSHEET_OUTLINE1) && ( nId <= HID_PSEUDOSHEET_OUTLINE9 ) )
     644             :     {
     645        1557 :         msApiName = "outline";
     646        1557 :         msApiName += OUString( (sal_Unicode)( '1' + (nId - HID_PSEUDOSHEET_OUTLINE1) ) );
     647             :     }
     648             :     else
     649             :     {
     650             :         static struct ApiNameMap
     651             :         {
     652             :             const sal_Char* mpApiName;
     653             :             sal_uInt32      mnApiNameLength;
     654             :             sal_uInt32      mnHelpId;
     655             :         }
     656             :         pApiNameMap[] =
     657             :         {
     658             :             { RTL_CONSTASCII_STRINGPARAM( "title" ),            HID_PSEUDOSHEET_TITLE },
     659             :             { RTL_CONSTASCII_STRINGPARAM( "subtitle" ),         HID_PSEUDOSHEET_SUBTITLE },
     660             :             { RTL_CONSTASCII_STRINGPARAM( "background" ),       HID_PSEUDOSHEET_BACKGROUND },
     661             :             { RTL_CONSTASCII_STRINGPARAM( "backgroundobjects" ),HID_PSEUDOSHEET_BACKGROUNDOBJECTS },
     662             :             { RTL_CONSTASCII_STRINGPARAM( "notes" ),            HID_PSEUDOSHEET_NOTES },
     663             :             { RTL_CONSTASCII_STRINGPARAM( "standard" ),         HID_STANDARD_STYLESHEET_NAME },
     664             :             { RTL_CONSTASCII_STRINGPARAM( "objectwitharrow" ),  HID_POOLSHEET_OBJWITHARROW },
     665             :             { RTL_CONSTASCII_STRINGPARAM( "objectwithshadow" ), HID_POOLSHEET_OBJWITHSHADOW },
     666             :             { RTL_CONSTASCII_STRINGPARAM( "objectwithoutfill" ),HID_POOLSHEET_OBJWITHOUTFILL },
     667             :             { RTL_CONSTASCII_STRINGPARAM( "text" ),             HID_POOLSHEET_TEXT },
     668             :             { RTL_CONSTASCII_STRINGPARAM( "textbody" ),         HID_POOLSHEET_TEXTBODY },
     669             :             { RTL_CONSTASCII_STRINGPARAM( "textbodyjustfied" ), HID_POOLSHEET_TEXTBODY_JUSTIFY },
     670             :             { RTL_CONSTASCII_STRINGPARAM( "textbodyindent" ),   HID_POOLSHEET_TEXTBODY_INDENT },
     671             :             { RTL_CONSTASCII_STRINGPARAM( "title" ),            HID_POOLSHEET_TITLE },
     672             :             { RTL_CONSTASCII_STRINGPARAM( "title1" ),           HID_POOLSHEET_TITLE1 },
     673             :             { RTL_CONSTASCII_STRINGPARAM( "title2" ),           HID_POOLSHEET_TITLE2 },
     674             :             { RTL_CONSTASCII_STRINGPARAM( "headline" ),         HID_POOLSHEET_HEADLINE },
     675             :             { RTL_CONSTASCII_STRINGPARAM( "headline1" ),        HID_POOLSHEET_HEADLINE1 },
     676             :             { RTL_CONSTASCII_STRINGPARAM( "headline2" ),        HID_POOLSHEET_HEADLINE2 },
     677             :             { RTL_CONSTASCII_STRINGPARAM( "measure" ),          HID_POOLSHEET_MEASURE },
     678             :             { 0, 0, 0 }
     679             :         };
     680             : 
     681        2293 :         ApiNameMap* p = pApiNameMap;
     682       24796 :         while( p->mpApiName )
     683             :         {
     684       22335 :             if( nId == p->mnHelpId )
     685             :             {
     686        2125 :                 msApiName = OUString( p->mpApiName, p->mnApiNameLength, RTL_TEXTENCODING_ASCII_US );
     687        2125 :                 break;
     688             :             }
     689       20210 :             p++;
     690             :         }
     691             :     }
     692        3850 : }
     693             : 
     694             : // --------------------------------------------------------------------
     695             : 
     696         766 : OUString SdStyleSheet::GetFamilyString( SfxStyleFamily eFamily )
     697             : {
     698         766 :     switch( eFamily )
     699             :     {
     700             :     case SD_STYLE_FAMILY_CELL:
     701         323 :         return OUString( "cell" );
     702             :     default:
     703             :         OSL_FAIL( "SdStyleSheet::GetFamilyString(), illegal family!" );
     704             :     case SD_STYLE_FAMILY_GRAPHICS:
     705         443 :         return OUString( "graphics" );
     706             :     }
     707             : }
     708             : 
     709             : // --------------------------------------------------------------------
     710             : 
     711       70448 : void SdStyleSheet::throwIfDisposed() throw (RuntimeException)
     712             : {
     713       70448 :     if( !mxPool.is() )
     714           0 :         throw DisposedException();
     715       70448 : }
     716             : 
     717             : // --------------------------------------------------------------------
     718             : 
     719           0 : SdStyleSheet* SdStyleSheet::CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily )
     720             : {
     721           0 :     OUString aPrefix( "user" );
     722           0 :     OUString aName;
     723           0 :     sal_Int32 nIndex = 1;
     724           0 :     do
     725             :     {
     726           0 :         aName = aPrefix + OUString::valueOf( nIndex++ );
     727             :     }
     728           0 :     while( rPool.Find( aName, eFamily ) != 0 );
     729             : 
     730           0 :     return new SdStyleSheet(aName, rPool, eFamily, SFXSTYLEBIT_USERDEF);
     731             : }
     732             : 
     733             : // --------------------------------------------------------------------
     734             : // XInterface
     735             : // --------------------------------------------------------------------
     736             : 
     737      112687 : void SAL_CALL SdStyleSheet::release(  ) throw ()
     738             : {
     739      112687 :     if (osl_atomic_decrement( &m_refCount ) == 0)
     740             :     {
     741             :         // restore reference count:
     742        6374 :         osl_atomic_increment( &m_refCount );
     743        6374 :         if (! mrBHelper.bDisposed) try
     744             :         {
     745           0 :             dispose();
     746             :         }
     747           0 :         catch (RuntimeException const& exc)
     748             :         { // don't break throw ()
     749             :             OSL_FAIL(
     750             :                 OUStringToOString(
     751             :                     exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
     752             :             static_cast<void>(exc);
     753             :         }
     754             :         OSL_ASSERT( mrBHelper.bDisposed );
     755        6374 :         SdStyleSheetBase::release();
     756             :     }
     757      112687 : }
     758             : 
     759             : // --------------------------------------------------------------------
     760             : // XComponent
     761             : // --------------------------------------------------------------------
     762             : 
     763        6374 : void SAL_CALL SdStyleSheet::dispose(  ) throw (RuntimeException)
     764             : {
     765        6374 :     ClearableMutexGuard aGuard( mrBHelper.rMutex );
     766        6374 :     if (!mrBHelper.bDisposed && !mrBHelper.bInDispose)
     767             :     {
     768        6374 :         mrBHelper.bInDispose = sal_True;
     769        6374 :         aGuard.clear();
     770             :         try
     771             :         {
     772             :             // side effect: keeping a reference to this
     773        6374 :             EventObject aEvt( static_cast< OWeakObject * >( this ) );
     774             :             try
     775             :             {
     776        6374 :                 mrBHelper.aLC.disposeAndClear( aEvt );
     777        6374 :                 disposing();
     778             :             }
     779           0 :             catch (...)
     780             :             {
     781           0 :                 MutexGuard aGuard2( mrBHelper.rMutex );
     782             :                 // bDisposed and bInDispose must be set in this order:
     783           0 :                 mrBHelper.bDisposed = sal_True;
     784           0 :                 mrBHelper.bInDispose = sal_False;
     785           0 :                 throw;
     786             :             }
     787       12748 :             MutexGuard aGuard2( mrBHelper.rMutex );
     788             :             // bDisposed and bInDispose must be set in this order:
     789        6374 :             mrBHelper.bDisposed = sal_True;
     790       12748 :             mrBHelper.bInDispose = sal_False;
     791             :         }
     792           0 :         catch (RuntimeException &)
     793             :         {
     794           0 :             throw;
     795             :         }
     796           0 :         catch (const Exception & exc)
     797             :         {
     798           0 :             throw RuntimeException( "unexpected UNO exception caught: "  +  exc.Message, Reference< XInterface >() );
     799             :         }
     800        6374 :     }
     801        6374 : }
     802             : 
     803             : // --------------------------------------------------------------------
     804             : 
     805        6374 : void SdStyleSheet::disposing()
     806             : {
     807        6374 :     mxPool.clear();
     808        6374 : }
     809             : 
     810             : // --------------------------------------------------------------------
     811             : 
     812           0 : void SAL_CALL SdStyleSheet::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
     813             : {
     814           0 :     ClearableMutexGuard aGuard( mrBHelper.rMutex );
     815           0 :     if (mrBHelper.bDisposed || mrBHelper.bInDispose)
     816             :     {
     817           0 :         aGuard.clear();
     818           0 :         EventObject aEvt( static_cast< OWeakObject * >( this ) );
     819           0 :         xListener->disposing( aEvt );
     820             :     }
     821             :     else
     822             :     {
     823           0 :         mrBHelper.addListener( ::getCppuType( &xListener ), xListener );
     824           0 :     }
     825           0 : }
     826             : 
     827             : // --------------------------------------------------------------------
     828             : 
     829           0 : void SAL_CALL SdStyleSheet::removeEventListener( const Reference< XEventListener >& xListener  ) throw (RuntimeException)
     830             : {
     831           0 :     mrBHelper.removeListener( ::getCppuType( &xListener ), xListener );
     832           0 : }
     833             : 
     834             : //------------------------------------------------------------------------
     835             : // XModifyBroadcaster
     836             : //------------------------------------------------------------------------
     837             : 
     838        6398 : void SAL_CALL SdStyleSheet::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
     839             : {
     840        6398 :     ClearableMutexGuard aGuard( mrBHelper.rMutex );
     841        6398 :     if (mrBHelper.bDisposed || mrBHelper.bInDispose)
     842             :     {
     843           0 :         aGuard.clear();
     844           0 :         EventObject aEvt( static_cast< OWeakObject * >( this ) );
     845           0 :         xListener->disposing( aEvt );
     846             :     }
     847             :     else
     848             :     {
     849        6398 :         if( !mpModifyListenerForewarder.get() )
     850        2739 :             mpModifyListenerForewarder.reset( new ModifyListenerForewarder( this ) );
     851        6398 :         mrBHelper.addListener( XModifyListener::static_type(), xListener );
     852        6398 :     }
     853        6398 : }
     854             : 
     855             : //------------------------------------------------------------------------
     856             : 
     857           0 : void SAL_CALL SdStyleSheet::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException)
     858             : {
     859           0 :     mrBHelper.removeListener( XModifyListener::static_type(), xListener );
     860           0 : }
     861             : 
     862             : //------------------------------------------------------------------------
     863             : 
     864        7110 : void SdStyleSheet::notifyModifyListener()
     865             : {
     866        7110 :     MutexGuard aGuard( mrBHelper.rMutex );
     867             : 
     868        7110 :     OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( XModifyListener::static_type() );
     869        7110 :     if( pContainer )
     870             :     {
     871        7110 :         EventObject aEvt( static_cast< OWeakObject * >( this ) );
     872        7110 :         pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
     873        7110 :     }
     874        7110 : }
     875             : 
     876             : 
     877             : // --------------------------------------------------------------------
     878             : // XServiceInfo
     879             : // --------------------------------------------------------------------
     880             : 
     881           0 : OUString SAL_CALL SdStyleSheet::getImplementationName() throw(RuntimeException)
     882             : {
     883           0 :     return OUString( "SdStyleSheet" );
     884             : }
     885             : 
     886             : // --------------------------------------------------------------------
     887             : 
     888           0 : sal_Bool SAL_CALL SdStyleSheet::supportsService( const OUString& ServiceName ) throw(RuntimeException)
     889             : {
     890           0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     891             : }
     892             : 
     893             : // --------------------------------------------------------------------
     894             : 
     895           0 : Sequence< OUString > SAL_CALL SdStyleSheet::getSupportedServiceNames() throw(RuntimeException)
     896             : {
     897           0 :     Sequence< OUString > aNameSequence( 10 );
     898           0 :     OUString* pStrings = aNameSequence.getArray();
     899             : 
     900           0 :     *pStrings++ = "com.sun.star.style.Style";
     901           0 :     *pStrings++ = "com.sun.star.drawing.FillProperties";
     902           0 :     *pStrings++ = "com.sun.star.drawing.LineProperties";
     903           0 :     *pStrings++ = "com.sun.star.drawing.ShadowProperties";
     904           0 :     *pStrings++ = "com.sun.star.drawing.ConnectorProperties";
     905           0 :     *pStrings++ = "com.sun.star.drawing.MeasureProperties";
     906           0 :     *pStrings++ = "com.sun.star.style.ParagraphProperties";
     907           0 :     *pStrings++ = "com.sun.star.style.CharacterProperties";
     908           0 :     *pStrings++ = "com.sun.star.drawing.TextProperties";
     909           0 :     *pStrings++ = "com.sun.star.drawing.Text";
     910             : 
     911           0 :     return aNameSequence;
     912             : }
     913             : 
     914             : // --------------------------------------------------------------------
     915             : // XNamed
     916             : // --------------------------------------------------------------------
     917             : 
     918         488 : OUString SAL_CALL SdStyleSheet::getName() throw(RuntimeException)
     919             : {
     920         488 :     SolarMutexGuard aGuard;
     921         488 :     throwIfDisposed();
     922         488 :     return GetApiName();
     923             : }
     924             : 
     925             : // --------------------------------------------------------------------
     926             : 
     927           0 : void SAL_CALL SdStyleSheet::setName( const OUString& rName  ) throw(RuntimeException)
     928             : {
     929           0 :     SolarMutexGuard aGuard;
     930           0 :     throwIfDisposed();
     931             : 
     932           0 :     if( SetName( rName ) )
     933             :     {
     934           0 :         msApiName = rName;
     935           0 :         Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
     936           0 :     }
     937           0 : }
     938             : 
     939             : // --------------------------------------------------------------------
     940             : // XStyle
     941             : // --------------------------------------------------------------------
     942             : 
     943           0 : sal_Bool SAL_CALL SdStyleSheet::isUserDefined() throw(RuntimeException)
     944             : {
     945           0 :     SolarMutexGuard aGuard;
     946           0 :     throwIfDisposed();
     947           0 :     return IsUserDefined() ? sal_True : sal_False;
     948             : }
     949             : 
     950             : // --------------------------------------------------------------------
     951             : 
     952         204 : sal_Bool SAL_CALL SdStyleSheet::isInUse() throw(RuntimeException)
     953             : {
     954         204 :     SolarMutexGuard aGuard;
     955         204 :     throwIfDisposed();
     956         204 :     return IsUsed() ? sal_True : sal_False;
     957             : }
     958             : 
     959             : // --------------------------------------------------------------------
     960             : 
     961         124 : OUString SAL_CALL SdStyleSheet::getParentStyle() throw(RuntimeException)
     962             : {
     963         124 :     SolarMutexGuard aGuard;
     964         124 :     throwIfDisposed();
     965             : 
     966         124 :     if( !GetParent().isEmpty() )
     967             :     {
     968         106 :         SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) );
     969         106 :         if( pParentStyle )
     970         106 :             return pParentStyle->msApiName;
     971             :     }
     972          18 :     return OUString();
     973             : }
     974             : 
     975             : // --------------------------------------------------------------------
     976             : 
     977         145 : void SAL_CALL SdStyleSheet::setParentStyle( const OUString& rParentName  ) throw(NoSuchElementException, RuntimeException)
     978             : {
     979         145 :     SolarMutexGuard aGuard;
     980         145 :     throwIfDisposed();
     981             : 
     982         145 :     if( !rParentName.isEmpty() )
     983             :     {
     984         137 :         const SfxStyles& rStyles = mxPool->GetStyles();
     985             : 
     986             :         /* Use reverse iterator to find the parents quicker - most probably its inserted recently.
     987             :          * Also avoids/fixes the issue n#708518
     988             :          * To fix it completely its probably wiser to compare this->GetName() and pStyle->GetName() or use complete names for styles (?)
     989             :          */
     990        9580 :         for( SfxStyles::const_reverse_iterator iter( rStyles.rbegin() ); iter != rStyles.rend(); ++iter )
     991             :         {
     992        9580 :             SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( (*iter).get() );
     993        9580 :             if( pStyle && (pStyle->nFamily == nFamily) && (pStyle->msApiName == rParentName) )
     994             :             {
     995         137 :                 if( pStyle != this )
     996         137 :                     SetParent( pStyle->GetName() );
     997         419 :                 return;
     998             :             }
     999             :         }
    1000           0 :         throw NoSuchElementException();
    1001             :     }
    1002             :     else
    1003             :     {
    1004           8 :         SetParent( rParentName );
    1005           8 :     }
    1006             : }
    1007             : 
    1008             : // --------------------------------------------------------------------
    1009             : // XPropertySet
    1010             : // --------------------------------------------------------------------
    1011             : 
    1012         731 : Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo() throw(RuntimeException)
    1013             : {
    1014         731 :     throwIfDisposed();
    1015         731 :     static Reference< XPropertySetInfo > xInfo;
    1016         731 :     if( !xInfo.is() )
    1017           4 :         xInfo = GetStylePropertySet().getPropertySetInfo();
    1018         731 :     return xInfo;
    1019             : }
    1020             : 
    1021             : // --------------------------------------------------------------------
    1022             : 
    1023        4690 : void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
    1024             : {
    1025        4690 :     SolarMutexGuard aGuard;
    1026        4690 :     throwIfDisposed();
    1027             : 
    1028        4690 :     const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
    1029        4690 :     if( pEntry == NULL )
    1030             :     {
    1031         279 :         throw UnknownPropertyException();
    1032             :     }
    1033             :     else
    1034             :     {
    1035        4411 :         if( pEntry->nWID == WID_STYLE_HIDDEN )
    1036             :         {
    1037           0 :             sal_Bool bValue = sal_False;
    1038           0 :             if ( aValue >>= bValue )
    1039           0 :                 SetHidden( bValue );
    1040           0 :             return;
    1041             :         }
    1042        4411 :         if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
    1043           0 :             return; // not yet implemented for styles
    1044             : 
    1045        4411 :         if( pEntry->nWID == WID_STYLE_FAMILY )
    1046           0 :             throw PropertyVetoException();
    1047             : 
    1048        4411 :         if( (pEntry->nWID == EE_PARA_NUMBULLET) && (GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) )
    1049             :         {
    1050          12 :             OUString aStr;
    1051          12 :             const sal_uInt32 nTempHelpId = GetHelpId( aStr );
    1052             : 
    1053          12 :             if( (nTempHelpId >= HID_PSEUDOSHEET_OUTLINE2) && (nTempHelpId <= HID_PSEUDOSHEET_OUTLINE9) )
    1054           0 :                 return;
    1055             :         }
    1056             : 
    1057        4411 :         SfxItemSet &rStyleSet = GetItemSet();
    1058             : 
    1059        4411 :         if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
    1060             :         {
    1061             :             BitmapMode eMode;
    1062           0 :             if( aValue >>= eMode )
    1063             :             {
    1064           0 :                 rStyleSet.Put( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
    1065           0 :                 rStyleSet.Put( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
    1066           0 :                 return;
    1067             :             }
    1068           0 :             throw IllegalArgumentException();
    1069             :         }
    1070             : 
    1071        4411 :         SfxItemSet aSet( GetPool().GetPool(),   pEntry->nWID, pEntry->nWID);
    1072        4411 :         aSet.Put( rStyleSet );
    1073             : 
    1074        4411 :         if( !aSet.Count() )
    1075             :         {
    1076        1856 :             if( EE_PARA_NUMBULLET == pEntry->nWID )
    1077             :             {
    1078          21 :                 Font aBulletFont;
    1079          21 :                 SdStyleSheetPool::PutNumBulletItem( this, aBulletFont );
    1080          21 :                 aSet.Put( rStyleSet );
    1081             :             }
    1082             :             else
    1083             :             {
    1084        1835 :                 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
    1085             :             }
    1086             :         }
    1087             : 
    1088        4433 :         if( pEntry->nMemberId == MID_NAME &&
    1089          66 :             ( pEntry->nWID == XATTR_FILLBITMAP || pEntry->nWID == XATTR_FILLGRADIENT ||
    1090          66 :               pEntry->nWID == XATTR_FILLHATCH || pEntry->nWID == XATTR_FILLFLOATTRANSPARENCE ||
    1091          30 :               pEntry->nWID == XATTR_LINESTART || pEntry->nWID == XATTR_LINEEND || pEntry->nWID == XATTR_LINEDASH) )
    1092             :         {
    1093          22 :             OUString aTempName;
    1094          22 :             if(!(aValue >>= aTempName ))
    1095           0 :                 throw IllegalArgumentException();
    1096             : 
    1097          22 :             SvxShape::SetFillAttribute( pEntry->nWID, aTempName, aSet );
    1098             :         }
    1099        4389 :         else if(!SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pEntry, aValue, aSet ))
    1100             :         {
    1101        4284 :             SvxItemPropertySet_setPropertyValue( GetStylePropertySet(), pEntry, aValue, aSet );
    1102             :         }
    1103             : 
    1104        4411 :         rStyleSet.Put( aSet );
    1105        4411 :         Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
    1106        4690 :     }
    1107             : }
    1108             : 
    1109             : // --------------------------------------------------------------------
    1110             : 
    1111        1480 : Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1112             : {
    1113        1480 :     SolarMutexGuard aGuard;
    1114             : 
    1115        1480 :     throwIfDisposed();
    1116             : 
    1117        1480 :     const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
    1118        1480 :     if( pEntry == NULL )
    1119             :     {
    1120           0 :         throw UnknownPropertyException();
    1121             :     }
    1122             :     else
    1123             :     {
    1124        1480 :         Any aAny;
    1125             : 
    1126        1480 :         if( pEntry->nWID == WID_STYLE_FAMILY )
    1127             :         {
    1128          36 :             if( nFamily == SD_STYLE_FAMILY_MASTERPAGE )
    1129             :             {
    1130          28 :                 const OUString aLayoutName( GetName() );
    1131          28 :                 aAny <<= aLayoutName.copy( 0, aLayoutName.indexOf( SD_LT_SEPARATOR) );
    1132             :             }
    1133             :             else
    1134             :             {
    1135           8 :                 aAny <<= GetFamilyString(nFamily);
    1136             :             }
    1137             :         }
    1138        1444 :         else if( pEntry->nWID == WID_STYLE_DISPNAME )
    1139             :         {
    1140           0 :             aAny <<= maDisplayName;
    1141             :         }
    1142        1444 :         else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
    1143             :         {
    1144           0 :             aAny <<= sal_False;
    1145             :         }
    1146        1444 :         else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
    1147             :         {
    1148           0 :             SfxItemSet &rStyleSet = GetItemSet();
    1149             : 
    1150           0 :             XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)rStyleSet.GetItem(XATTR_FILLBMP_STRETCH);
    1151           0 :             XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)rStyleSet.GetItem(XATTR_FILLBMP_TILE);
    1152             : 
    1153           0 :             if( pStretchItem && pTileItem )
    1154             :             {
    1155           0 :                 if( pTileItem->GetValue() )
    1156           0 :                     aAny <<= BitmapMode_REPEAT;
    1157           0 :                 else if( pStretchItem->GetValue() )
    1158           0 :                     aAny <<= BitmapMode_STRETCH;
    1159             :                 else
    1160           0 :                     aAny <<= BitmapMode_NO_REPEAT;
    1161             :             }
    1162             :         }
    1163        1444 :         else if( pEntry->nWID == WID_STYLE_HIDDEN )
    1164             :         {
    1165         124 :             aAny <<= IsHidden( );
    1166             :         }
    1167             :         else
    1168             :         {
    1169        1320 :             SfxItemSet aSet( GetPool().GetPool(),   pEntry->nWID, pEntry->nWID);
    1170             : 
    1171             :             const SfxPoolItem* pItem;
    1172        1320 :             SfxItemSet& rStyleSet = GetItemSet();
    1173             : 
    1174        1320 :             if( rStyleSet.GetItemState( pEntry->nWID, sal_True, &pItem ) == SFX_ITEM_SET )
    1175        1320 :                 aSet.Put(  *pItem );
    1176             : 
    1177        1320 :             if( !aSet.Count() )
    1178           0 :                 aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
    1179             : 
    1180        1320 :             if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pEntry, aAny ))
    1181          12 :                 return aAny;
    1182             : 
    1183             :             // Hole Wert aus ItemSet
    1184        1308 :             aAny = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(),pEntry, aSet );
    1185             :         }
    1186             : 
    1187        1468 :         if( *pEntry->pType != aAny.getValueType() )
    1188             :         {
    1189             :             // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
    1190           0 :             if( ( *pEntry->pType == ::getCppuType((const sal_Int16*)0)) && aAny.getValueType() == ::getCppuType((const sal_Int32*)0) )
    1191             :             {
    1192           0 :                 sal_Int32 nValue = 0;
    1193           0 :                 aAny >>= nValue;
    1194           0 :                 aAny <<= (sal_Int16)nValue;
    1195             :             }
    1196             :             else
    1197             :             {
    1198             :                 OSL_FAIL("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
    1199             :             }
    1200             :         }
    1201             : 
    1202        1468 :         return aAny;
    1203        1480 :     }
    1204             : }
    1205             : 
    1206             : // --------------------------------------------------------------------
    1207             : 
    1208           0 : void SAL_CALL SdStyleSheet::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
    1209           0 : void SAL_CALL SdStyleSheet::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
    1210           0 : void SAL_CALL SdStyleSheet::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
    1211           0 : void SAL_CALL SdStyleSheet::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >&  ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException) {}
    1212             : 
    1213             : // --------------------------------------------------------------------
    1214             : // XPropertyState
    1215             : // --------------------------------------------------------------------
    1216             : 
    1217       61057 : PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
    1218             : {
    1219       61057 :     SolarMutexGuard aGuard;
    1220             : 
    1221       61057 :     throwIfDisposed();
    1222             : 
    1223       61057 :     const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
    1224             : 
    1225       61057 :     if( pEntry == NULL )
    1226           0 :         throw UnknownPropertyException();
    1227             : 
    1228       61057 :     if( pEntry->nWID == WID_STYLE_FAMILY )
    1229             :     {
    1230           0 :         return PropertyState_DIRECT_VALUE;
    1231             :     }
    1232       61057 :     else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
    1233             :     {
    1234         293 :         return PropertyState_DEFAULT_VALUE;
    1235             :     }
    1236       60764 :     else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
    1237             :     {
    1238         295 :         const SfxItemSet& rSet = GetItemSet();
    1239             : 
    1240         590 :         if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET ||
    1241         295 :             rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET )
    1242             :         {
    1243           0 :             return PropertyState_DIRECT_VALUE;
    1244             :         }
    1245             :         else
    1246             :         {
    1247         295 :             return PropertyState_AMBIGUOUS_VALUE;
    1248             :         }
    1249             :     }
    1250             :     else
    1251             :     {
    1252       60469 :         SfxItemSet &rStyleSet = GetItemSet();
    1253             : 
    1254             :         PropertyState eState;
    1255             : 
    1256       60469 :         switch( rStyleSet.GetItemState( pEntry->nWID, sal_False ) )
    1257             :         {
    1258             :         case SFX_ITEM_READONLY:
    1259             :         case SFX_ITEM_SET:
    1260        2803 :             eState = PropertyState_DIRECT_VALUE;
    1261        2803 :             break;
    1262             :         case SFX_ITEM_DEFAULT:
    1263       53802 :             eState = PropertyState_DEFAULT_VALUE;
    1264       53802 :             break;
    1265             :         default:
    1266        3864 :             eState = PropertyState_AMBIGUOUS_VALUE;
    1267        3864 :             break;
    1268             :         }
    1269             : 
    1270             :         // if a item is set, this doesn't mean we want it :)
    1271       60469 :         if( ( PropertyState_DIRECT_VALUE == eState ) )
    1272             :         {
    1273        2803 :             switch( pEntry->nWID )
    1274             :             {
    1275             :             case XATTR_FILLBITMAP:
    1276             :             case XATTR_FILLGRADIENT:
    1277             :             case XATTR_FILLHATCH:
    1278             :             case XATTR_FILLFLOATTRANSPARENCE:
    1279             :             case XATTR_LINEEND:
    1280             :             case XATTR_LINESTART:
    1281             :             case XATTR_LINEDASH:
    1282             :                 {
    1283         117 :                     NameOrIndex* pItem = (NameOrIndex*)rStyleSet.GetItem((sal_uInt16)pEntry->nWID);
    1284         117 :                     if( ( pItem == NULL ) || ( pItem->GetName().Len() == 0) )
    1285          78 :                         eState = PropertyState_DEFAULT_VALUE;
    1286             :                 }
    1287             :             }
    1288             :         }
    1289             : 
    1290       60469 :         return eState;
    1291       61057 :     }
    1292             : }
    1293             : 
    1294             : // --------------------------------------------------------------------
    1295             : 
    1296         124 : Sequence< PropertyState > SAL_CALL SdStyleSheet::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException)
    1297             : {
    1298         124 :     SolarMutexGuard aGuard;
    1299             : 
    1300         124 :     throwIfDisposed();
    1301             : 
    1302         124 :     sal_Int32 nCount = aPropertyName.getLength();
    1303         124 :     const OUString* pNames = aPropertyName.getConstArray();
    1304             : 
    1305         124 :     Sequence< PropertyState > aPropertyStateSequence( nCount );
    1306         124 :     PropertyState* pState = aPropertyStateSequence.getArray();
    1307             : 
    1308       17856 :     while( nCount-- )
    1309       17608 :         *pState++ = getPropertyState( *pNames++ );
    1310             : 
    1311         124 :     return aPropertyStateSequence;
    1312             : }
    1313             : 
    1314             : // --------------------------------------------------------------------
    1315             : 
    1316        1405 : void SAL_CALL SdStyleSheet::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException)
    1317             : {
    1318        1405 :     SolarMutexGuard aGuard;
    1319             : 
    1320        1405 :     throwIfDisposed();
    1321             : 
    1322        1405 :     const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
    1323        1405 :     if( pEntry == NULL )
    1324           0 :         throw UnknownPropertyException();
    1325             : 
    1326        1405 :     SfxItemSet &rStyleSet = GetItemSet();
    1327             : 
    1328        1405 :     if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
    1329             :     {
    1330           0 :         rStyleSet.ClearItem( XATTR_FILLBMP_STRETCH );
    1331           0 :         rStyleSet.ClearItem( XATTR_FILLBMP_TILE );
    1332             :     }
    1333             :     else
    1334             :     {
    1335        1405 :         rStyleSet.ClearItem( pEntry->nWID );
    1336             :     }
    1337        1405 :     Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
    1338        1405 : }
    1339             : 
    1340             : // --------------------------------------------------------------------
    1341             : 
    1342           0 : Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
    1343             : {
    1344           0 :     SolarMutexGuard aGuard;
    1345             : 
    1346           0 :     throwIfDisposed();
    1347             : 
    1348           0 :     const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
    1349           0 :     if( pEntry == NULL )
    1350           0 :         throw UnknownPropertyException();
    1351           0 :     Any aRet;
    1352           0 :     if( pEntry->nWID == WID_STYLE_FAMILY )
    1353             :     {
    1354           0 :         aRet <<= GetFamilyString(nFamily);
    1355             :     }
    1356           0 :     else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
    1357             :     {
    1358           0 :         aRet <<= sal_False;
    1359             :     }
    1360           0 :     else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
    1361             :     {
    1362           0 :         aRet <<= BitmapMode_REPEAT;
    1363             :     }
    1364             :     else
    1365             :     {
    1366           0 :         SfxItemPool& rMyPool = GetPool().GetPool();
    1367           0 :         SfxItemSet aSet( rMyPool,   pEntry->nWID, pEntry->nWID);
    1368           0 :         aSet.Put( rMyPool.GetDefaultItem( pEntry->nWID ) );
    1369           0 :         aRet = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(), pEntry, aSet );
    1370             :     }
    1371           0 :     return aRet;
    1372             : }
    1373             : 
    1374             : // --------------------------------------------------------------------
    1375             : 
    1376             : /** this is used because our property map is not sorted yet */
    1377       68632 : const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw()
    1378             : {
    1379       68632 :     return GetStylePropertySet().getPropertyMapEntry(rPropertyName);
    1380          33 : }
    1381             : 
    1382             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10