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

Generated by: LCOV version 1.11