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

Generated by: LCOV version 1.10