LCOV - code coverage report
Current view: top level - sw/source/core/unocore - unostyle.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2248 0.0 %
Date: 2014-04-14 Functions: 0 179 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/svxids.hrc>
      21             : #include <hintids.hxx>
      22             : #include <osl/mutex.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <svl/smplhint.hxx>
      25             : #include <svtools/ctrltool.hxx>
      26             : #include <svl/style.hxx>
      27             : #include <svl/itemiter.hxx>
      28             : #include <svx/pageitem.hxx>
      29             : #include <editeng/sizeitem.hxx>
      30             : #include <editeng/ulspitem.hxx>
      31             : #include <editeng/lrspitem.hxx>
      32             : #include <editeng/boxitem.hxx>
      33             : #include <editeng/shaditem.hxx>
      34             : #include <editeng/brushitem.hxx>
      35             : #include <editeng/flstitem.hxx>
      36             : #include <editeng/paperinf.hxx>
      37             : #include <pagedesc.hxx>
      38             : #include <doc.hxx>
      39             : #include <IDocumentUndoRedo.hxx>
      40             : #include <docary.hxx>
      41             : #include <charfmt.hxx>
      42             : #include <cmdid.h>
      43             : #include <unostyle.hxx>
      44             : #include <unosett.hxx>
      45             : #include <docsh.hxx>
      46             : #include <swstyle.h>
      47             : #include <paratr.hxx>
      48             : #include <unoprnms.hxx>
      49             : #include <shellio.hxx>
      50             : #include <docstyle.hxx>
      51             : #include <unotextbodyhf.hxx>
      52             : #include <fmthdft.hxx>
      53             : #include <fmtpdsc.hxx>
      54             : #include <poolfmt.hrc>
      55             : #include <poolfmt.hxx>
      56             : #include "unoevent.hxx"
      57             : #include <fmtruby.hxx>
      58             : #include <SwStyleNameMapper.hxx>
      59             : #include <sfx2/printer.hxx>
      60             : #include <com/sun/star/style/ParagraphStyleCategory.hpp>
      61             : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
      62             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      63             : #include <com/sun/star/beans/NamedValue.hpp>
      64             : #include <com/sun/star/drawing/BitmapMode.hpp>
      65             : #include <istyleaccess.hxx>
      66             : #include <GetMetricVal.hxx>
      67             : #include <fmtfsize.hxx>
      68             : #include <numrule.hxx>
      69             : 
      70             : #include <comphelper/servicehelper.hxx>
      71             : #include <cppuhelper/supportsservice.hxx>
      72             : 
      73             : //UUUU
      74             : #include <unobrushitemhelper.hxx>
      75             : #include <editeng/unoipset.hxx>
      76             : #include <editeng/memberids.hrc>
      77             : #include <svx/unoshape.hxx>
      78             : #include <svx/xflbstit.hxx>
      79             : #include <svx/xflbmtit.hxx>
      80             : 
      81             : #include <boost/shared_ptr.hpp>
      82             : 
      83             : #include "ccoll.hxx"
      84             : #include "unocore.hrc"
      85             : 
      86             : #include <cassert>
      87             : #include <set>
      88             : 
      89             : #define STYLE_FAMILY_COUNT 5            // we have 5 style families
      90             : #define TYPE_BOOL       0
      91             : #define TYPE_SIZE       1
      92             : #define TYPE_BRUSH      2
      93             : #define TYPE_ULSPACE    3
      94             : #define TYPE_SHADOW     4
      95             : #define TYPE_LRSPACE    5
      96             : #define TYPE_BOX        6
      97             : 
      98             : const unsigned short aStyleByIndex[] =
      99             : {
     100             :     SFX_STYLE_FAMILY_CHAR,
     101             :     SFX_STYLE_FAMILY_PARA,
     102             :     SFX_STYLE_FAMILY_PAGE     ,
     103             :     SFX_STYLE_FAMILY_FRAME    ,
     104             :     SFX_STYLE_FAMILY_PSEUDO
     105             : };
     106             : 
     107             : // Already implemented autostyle families: 3
     108             : #define AUTOSTYLE_FAMILY_COUNT 3
     109             : const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
     110             : {
     111             :     IStyleAccess::AUTO_STYLE_CHAR,
     112             :     IStyleAccess::AUTO_STYLE_RUBY,
     113             :     IStyleAccess::AUTO_STYLE_PARA
     114             : };
     115             : 
     116             : using namespace ::com::sun::star;
     117             : 
     118             : //convert FN_... to RES_ in header and footer itemset
     119           0 : static sal_uInt16 lcl_ConvertFNToRES(sal_uInt16 nFNId)
     120             : {
     121           0 :     sal_uInt16 nRes = USHRT_MAX;
     122           0 :     switch(nFNId)
     123             :     {
     124             :         case FN_UNO_FOOTER_ON:
     125             :         case FN_UNO_HEADER_ON:
     126           0 :         break;
     127             :         case FN_UNO_FOOTER_BACKGROUND:
     128           0 :         case FN_UNO_HEADER_BACKGROUND:      nRes = RES_BACKGROUND;
     129           0 :         break;
     130             :         case FN_UNO_FOOTER_BOX:
     131           0 :         case FN_UNO_HEADER_BOX:             nRes = RES_BOX;
     132           0 :         break;
     133             :         case FN_UNO_FOOTER_LR_SPACE:
     134           0 :         case FN_UNO_HEADER_LR_SPACE:        nRes = RES_LR_SPACE;
     135           0 :         break;
     136             :         case FN_UNO_FOOTER_SHADOW:
     137           0 :         case FN_UNO_HEADER_SHADOW:          nRes = RES_SHADOW;
     138           0 :         break;
     139             :         case FN_UNO_FOOTER_BODY_DISTANCE:
     140           0 :         case FN_UNO_HEADER_BODY_DISTANCE:   nRes = RES_UL_SPACE;
     141           0 :         break;
     142             :         case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
     143           0 :         case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
     144           0 :         break;
     145             :         case FN_UNO_FOOTER_SHARE_CONTENT:
     146           0 :         case FN_UNO_HEADER_SHARE_CONTENT:   nRes = SID_ATTR_PAGE_SHARED;
     147           0 :         break;
     148           0 :         case FN_UNO_FIRST_SHARE_CONTENT:   nRes = SID_ATTR_PAGE_SHARED_FIRST;
     149           0 :         break;
     150             :         case FN_UNO_FOOTER_HEIGHT:
     151           0 :         case FN_UNO_HEADER_HEIGHT:          nRes = SID_ATTR_PAGE_SIZE;
     152           0 :         break;
     153             :         case FN_UNO_FOOTER_EAT_SPACING:
     154           0 :         case FN_UNO_HEADER_EAT_SPACING:   nRes = RES_HEADER_FOOTER_EAT_SPACING;
     155           0 :         break;
     156             :     }
     157           0 :     return nRes;
     158             : 
     159             : }
     160             : 
     161           0 : static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
     162             : {
     163           0 :     switch ( eFamily )
     164             :     {
     165             :         case SFX_STYLE_FAMILY_CHAR:
     166           0 :             return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
     167             :         case SFX_STYLE_FAMILY_PARA:
     168           0 :             return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
     169             :         case SFX_STYLE_FAMILY_FRAME:
     170           0 :             return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
     171             :         case SFX_STYLE_FAMILY_PAGE:
     172           0 :             return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
     173             :         case SFX_STYLE_FAMILY_PSEUDO:
     174           0 :             return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE;
     175             :         default:
     176             :             OSL_ENSURE(false, "someone asking for all styles in unostyle.cxx!" );
     177           0 :             return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
     178             :     }
     179             : }
     180             : 
     181           0 : class SwAutoStylesEnumImpl
     182             : {
     183             :     std::vector<SfxItemSet_Pointer_t> mAutoStyles;
     184             :     std::vector<SfxItemSet_Pointer_t>::iterator aIter;
     185             :     SwDoc* pDoc;
     186             :     IStyleAccess::SwAutoStyleFamily eFamily;
     187             : public:
     188             :     SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
     189           0 :     sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); }
     190           0 :     SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
     191           0 :     IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
     192           0 :     SwDoc* getDoc() const { return pDoc; }
     193             : };
     194             : 
     195             : /******************************************************************
     196             :  * SwXStyleFamilies
     197             :  ******************************************************************/
     198           0 : OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException, std::exception )
     199             : {
     200           0 :     return OUString("SwXStyleFamilies");
     201             : }
     202             : 
     203           0 : sal_Bool SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
     204             : {
     205           0 :     return cppu::supportsService(this, rServiceName);
     206             : }
     207             : 
     208           0 : uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
     209             : {
     210           0 :     uno::Sequence< OUString > aRet(1);
     211           0 :     OUString* pArray = aRet.getArray();
     212           0 :     pArray[0] = "com.sun.star.style.StyleFamilies";
     213           0 :     return aRet;
     214             : }
     215             : 
     216           0 : SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
     217             :     SwUnoCollection(rDocShell.GetDoc()),
     218             :     pDocShell(&rDocShell),
     219             :     pxCharStyles(0),
     220             :     pxParaStyles(0),
     221             :     pxFrameStyles(0),
     222             :     pxPageStyles(0),
     223           0 :     pxNumberingStyles(0)
     224             : {
     225             : 
     226           0 : }
     227             : 
     228           0 : SwXStyleFamilies::~SwXStyleFamilies()
     229             : {
     230           0 :     delete pxCharStyles;
     231           0 :     delete pxParaStyles;
     232           0 :     delete pxFrameStyles;
     233           0 :     delete pxPageStyles;
     234           0 :     delete pxNumberingStyles;
     235           0 : }
     236             : 
     237           0 : uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
     238             :     throw(
     239             :         container::NoSuchElementException,
     240             :         lang::WrappedTargetException,
     241             :         uno::RuntimeException, std::exception )
     242             : {
     243           0 :     SolarMutexGuard aGuard;
     244             : // der Index kommt aus const unsigned short aStyleByIndex[] =
     245           0 :     uno::Any aRet;
     246           0 :     if(!IsValid())
     247           0 :         throw uno::RuntimeException();
     248           0 :     if(Name.equalsAscii("CharacterStyles") )
     249           0 :         aRet = getByIndex(0);
     250           0 :     else if(Name.equalsAscii("ParagraphStyles") )
     251           0 :         aRet = getByIndex(1);
     252           0 :     else if(Name.equalsAscii("FrameStyles") )
     253           0 :         aRet = getByIndex(3);
     254           0 :     else if(Name.equalsAscii("PageStyles") )
     255           0 :         aRet = getByIndex(2);
     256           0 :     else if(Name.equalsAscii("NumberingStyles") )
     257           0 :         aRet = getByIndex(4);
     258             :     else
     259           0 :         throw container::NoSuchElementException();
     260           0 :     return aRet;
     261             : }
     262             : 
     263           0 : uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException, std::exception )
     264             : {
     265           0 :     uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT);
     266           0 :     OUString* pNames = aNames.getArray();
     267           0 :     pNames[0] = "CharacterStyles";
     268           0 :     pNames[1] = "ParagraphStyles";
     269           0 :     pNames[2] = "FrameStyles";
     270           0 :     pNames[3] = "PageStyles";
     271           0 :     pNames[4] = "NumberingStyles";
     272           0 :     return aNames;
     273             : }
     274             : 
     275           0 : sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException, std::exception )
     276             : {
     277           0 :     if( Name.equalsAscii("CharacterStyles") ||
     278           0 :         Name.equalsAscii("ParagraphStyles") ||
     279           0 :         Name.equalsAscii("FrameStyles") ||
     280           0 :         Name.equalsAscii("PageStyles") ||
     281           0 :         Name.equalsAscii("NumberingStyles") )
     282           0 :         return sal_True;
     283             :     else
     284           0 :         return sal_False;
     285             : }
     286             : 
     287           0 : sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException, std::exception )
     288             : {
     289           0 :     return STYLE_FAMILY_COUNT;
     290             : }
     291             : 
     292           0 : uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
     293             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     294             : {
     295           0 :     SolarMutexGuard aGuard;
     296           0 :     uno::Any aRet;
     297           0 :     if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
     298           0 :         throw lang::IndexOutOfBoundsException();
     299           0 :     if(IsValid())
     300             :     {
     301           0 :         uno::Reference< container::XNameContainer >  aRef;
     302           0 :         sal_uInt16 nType = aStyleByIndex[nIndex];
     303           0 :         switch( nType )
     304             :         {
     305             :             case SFX_STYLE_FAMILY_CHAR:
     306             :             {
     307           0 :                 if(!pxCharStyles)
     308             :                 {
     309           0 :                     ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
     310           0 :                     *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
     311             :                 }
     312           0 :                 aRef = *pxCharStyles;
     313             :             }
     314           0 :             break;
     315             :             case SFX_STYLE_FAMILY_PARA:
     316             :             {
     317           0 :                 if(!pxParaStyles)
     318             :                 {
     319           0 :                     ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
     320           0 :                     *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
     321             :                 }
     322           0 :                 aRef = *pxParaStyles;
     323             :             }
     324           0 :             break;
     325             :             case SFX_STYLE_FAMILY_PAGE     :
     326             :             {
     327           0 :                 if(!pxPageStyles)
     328             :                 {
     329           0 :                     ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
     330           0 :                     *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
     331             :                 }
     332           0 :                 aRef = *pxPageStyles;
     333             :             }
     334           0 :             break;
     335             :             case SFX_STYLE_FAMILY_FRAME    :
     336             :             {
     337           0 :                 if(!pxFrameStyles)
     338             :                 {
     339           0 :                     ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
     340           0 :                     *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
     341             :                 }
     342           0 :                 aRef = *pxFrameStyles;
     343             :             }
     344           0 :             break;
     345             :             case SFX_STYLE_FAMILY_PSEUDO:
     346             :             {
     347           0 :                 if(!pxNumberingStyles)
     348             :                 {
     349           0 :                     ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
     350           0 :                     *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
     351             :                 }
     352           0 :                 aRef = *pxNumberingStyles;
     353             :             }
     354           0 :             break;
     355             :         }
     356           0 :         aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0));
     357             :     }
     358             :     else
     359           0 :         throw uno::RuntimeException();
     360           0 :     return aRet;
     361             : }
     362             : 
     363           0 : uno::Type SwXStyleFamilies::getElementType(void)
     364             :     throw( uno::RuntimeException, std::exception )
     365             : {
     366           0 :     return ::getCppuType((const uno::Reference<container::XNameContainer>*)0);
     367             : 
     368             : }
     369             : 
     370           0 : sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException, std::exception )
     371             : {
     372           0 :     return sal_True;
     373             : }
     374             : 
     375           0 : void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
     376             :     const uno::Sequence< beans::PropertyValue >& aOptions)
     377             :     throw (io::IOException, uno::RuntimeException,
     378             :            std::exception)
     379             : {
     380           0 :     SolarMutexGuard aGuard;
     381           0 :     sal_Bool    bLoadStyleText = sal_True;
     382           0 :     sal_Bool    bLoadStylePage = sal_True;
     383           0 :     sal_Bool    bLoadStyleOverwrite = sal_True;
     384           0 :     sal_Bool    bLoadStyleNumbering = sal_True;
     385           0 :     sal_Bool    bLoadStyleFrame = sal_True;
     386           0 :     if(IsValid() && !rURL.isEmpty())
     387             :     {
     388             :         const uno::Any* pVal;
     389           0 :         int nCount = aOptions.getLength();
     390           0 :         const beans::PropertyValue* pArray = aOptions.getConstArray();
     391           0 :         for(int i = 0; i < nCount; i++)
     392           0 :             if( ( pVal = &pArray[i].Value)->getValueType() ==
     393           0 :                     ::getBooleanCppuType() )
     394             :             {
     395           0 :                 const OUString sName = pArray[i].Name;
     396           0 :                 sal_Bool bVal = *(sal_Bool*)pVal->getValue();
     397           0 :                 if( sName == UNO_NAME_OVERWRITE_STYLES )
     398           0 :                     bLoadStyleOverwrite = bVal;
     399           0 :                 else if( sName == UNO_NAME_LOAD_NUMBERING_STYLES )
     400           0 :                     bLoadStyleNumbering = bVal;
     401           0 :                 else if( sName == UNO_NAME_LOAD_PAGE_STYLES )
     402           0 :                     bLoadStylePage = bVal;
     403           0 :                 else if( sName == UNO_NAME_LOAD_FRAME_STYLES )
     404           0 :                     bLoadStyleFrame = bVal;
     405           0 :                 else if( sName == UNO_NAME_LOAD_TEXT_STYLES )
     406           0 :                     bLoadStyleText = bVal;
     407             :             }
     408             : 
     409           0 :         SwgReaderOption aOpt;
     410           0 :         aOpt.SetFrmFmts( bLoadStyleFrame );
     411           0 :         aOpt.SetTxtFmts( bLoadStyleText );
     412           0 :         aOpt.SetPageDescs( bLoadStylePage );
     413           0 :         aOpt.SetNumRules( bLoadStyleNumbering );
     414           0 :         aOpt.SetMerge( !bLoadStyleOverwrite );
     415             : 
     416           0 :         sal_uLong nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, sal_True );
     417           0 :         if( nErr )
     418           0 :             throw io::IOException();
     419             :     }
     420             :     else
     421           0 :         throw uno::RuntimeException();
     422           0 : }
     423             : 
     424           0 : uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void)
     425             :         throw( uno::RuntimeException, std::exception )
     426             : {
     427           0 :     SolarMutexGuard aGuard;
     428           0 :     uno::Sequence< beans::PropertyValue > aSeq(5);
     429           0 :     beans::PropertyValue* pArray = aSeq.getArray();
     430           0 :     uno::Any aVal;
     431           0 :     sal_Bool bTemp = sal_True;
     432           0 :     aVal.setValue(&bTemp, ::getCppuBooleanType());
     433           0 :     pArray[0] = beans::PropertyValue(UNO_NAME_LOAD_TEXT_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
     434           0 :     aVal.setValue(&bTemp, ::getCppuBooleanType());
     435           0 :     pArray[1] = beans::PropertyValue(UNO_NAME_LOAD_FRAME_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
     436           0 :     aVal.setValue(&bTemp, ::getCppuBooleanType());
     437           0 :     pArray[2] = beans::PropertyValue(UNO_NAME_LOAD_PAGE_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
     438           0 :     aVal.setValue(&bTemp, ::getCppuBooleanType());
     439           0 :     pArray[3] = beans::PropertyValue(UNO_NAME_LOAD_NUMBERING_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
     440           0 :     aVal.setValue(&bTemp, ::getCppuBooleanType());
     441           0 :     pArray[4] = beans::PropertyValue(UNO_NAME_OVERWRITE_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
     442           0 :     return aSeq;
     443             : }
     444             : 
     445             : /******************************************************************
     446             :  * SwXStyleFamily
     447             :  ******************************************************************/
     448           0 : OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException, std::exception )
     449             : {
     450           0 :     return OUString("SwXStyleFamily");
     451             : }
     452             : 
     453           0 : sal_Bool SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
     454             : {
     455           0 :     return cppu::supportsService(this, rServiceName);
     456             : }
     457             : 
     458           0 : uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
     459             : {
     460           0 :     uno::Sequence< OUString > aRet(1);
     461           0 :     OUString* pArray = aRet.getArray();
     462           0 :     pArray[0] = "com.sun.star.style.StyleFamily";
     463           0 :     return aRet;
     464             : }
     465             : 
     466           0 : SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
     467             :         eFamily((SfxStyleFamily)nFamily),
     468           0 :         pBasePool(pDocSh->GetStyleSheetPool()),
     469           0 :         pDocShell(pDocSh)
     470             : {
     471           0 :     StartListening(*pBasePool);
     472           0 : }
     473             : 
     474           0 : SwXStyleFamily::~SwXStyleFamily()
     475             : {
     476             : 
     477           0 : }
     478             : 
     479           0 : static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
     480             :     SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX)
     481             : {
     482           0 :     sal_Int32 nCount = 0;
     483           0 :     switch( eFamily )
     484             :     {
     485             :         case SFX_STYLE_FAMILY_CHAR:
     486             :         {
     487             :             sal_uInt16 nBaseCount =  RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN  +
     488           0 :                                      RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
     489           0 :             nIndex = nIndex - nBaseCount;
     490           0 :             const sal_uInt16 nArrLen = rDoc.GetCharFmts()->size();
     491           0 :             for( sal_uInt16 i = 0; i < nArrLen; i++ )
     492             :             {
     493           0 :                 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
     494           0 :                 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
     495           0 :                     continue;
     496           0 :                 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
     497             :                 {
     498           0 :                     if ( nIndex == nCount )
     499             :                     {
     500             :                         // the default character format needs to be set to "Default!"
     501           0 :                         if(rDoc.GetDfltCharFmt() == pFmt)
     502             :                             SwStyleNameMapper::FillUIName(
     503           0 :                                 RES_POOLCOLL_STANDARD, *pString );
     504             :                         else
     505           0 :                             *pString = pFmt->GetName();
     506           0 :                         break;
     507             :                     }
     508           0 :                     nCount++;
     509             :                 }
     510             :             }
     511           0 :             nCount += nBaseCount;
     512             :         }
     513           0 :         break;
     514             :         case SFX_STYLE_FAMILY_PARA:
     515             :         {
     516             :             sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
     517             :                                     RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
     518             :                                     RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
     519             :                                     RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
     520             :                                     RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     521           0 :                                     RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN;
     522           0 :             nIndex = nIndex - nBaseCount;
     523           0 :             const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->size();
     524           0 :             for ( sal_uInt16 i = 0; i < nArrLen; i++ )
     525             :             {
     526           0 :                 SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i];
     527           0 :                 if ( pColl->IsDefault() )
     528           0 :                     continue;
     529           0 :                 if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) )
     530             :                 {
     531           0 :                     if ( nIndex == nCount )
     532             :                     {
     533           0 :                         *pString = pColl->GetName();
     534           0 :                         break;
     535             :                     }
     536           0 :                     nCount++;
     537             :                 }
     538             :             }
     539           0 :             nCount += nBaseCount;
     540             :         }
     541           0 :         break;
     542             :         case SFX_STYLE_FAMILY_FRAME:
     543             :         {
     544           0 :             sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
     545           0 :             nIndex = nIndex - nBaseCount;
     546           0 :             const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->size();
     547           0 :             for( sal_uInt16 i = 0; i < nArrLen; i++ )
     548             :             {
     549           0 :                 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
     550           0 :                 if(pFmt->IsDefault() || pFmt->IsAuto())
     551           0 :                     continue;
     552           0 :                 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
     553             :                 {
     554           0 :                     if ( nIndex == nCount )
     555             :                     {
     556           0 :                         *pString = pFmt->GetName();
     557           0 :                         break;
     558             :                     }
     559           0 :                     nCount++;
     560             :                 }
     561             :             }
     562           0 :             nCount += nBaseCount;
     563             :         }
     564           0 :         break;
     565             :         case SFX_STYLE_FAMILY_PAGE:
     566             :         {
     567           0 :             sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
     568           0 :             nIndex = nIndex - nBaseCount;
     569           0 :             const sal_uInt16 nArrLen = rDoc.GetPageDescCnt();
     570           0 :             for(sal_uInt16 i = 0; i < nArrLen; ++i)
     571             :             {
     572           0 :                 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
     573             : 
     574           0 :                 if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) )
     575             :                 {
     576           0 :                     if ( nIndex == nCount )
     577             :                     {
     578           0 :                         *pString = rDesc.GetName();
     579           0 :                         break;
     580             :                     }
     581           0 :                     nCount++;
     582             :                 }
     583             :             }
     584           0 :             nCount += nBaseCount;
     585             :         }
     586           0 :         break;
     587             :         case SFX_STYLE_FAMILY_PSEUDO:
     588             :         {
     589           0 :             sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
     590           0 :             nIndex = nIndex - nBaseCount;
     591           0 :             const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
     592           0 :             for(sal_uInt16 i = 0; i < rNumTbl.size(); ++i)
     593             :             {
     594           0 :                 const SwNumRule& rRule = *rNumTbl[ i ];
     595           0 :                 if( rRule.IsAutoRule() )
     596           0 :                     continue;
     597           0 :                 if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) )
     598             :                 {
     599           0 :                     if ( nIndex == nCount )
     600             :                     {
     601           0 :                         *pString = rRule.GetName();
     602           0 :                         break;
     603             :                     }
     604           0 :                     nCount++;
     605             :                 }
     606             :             }
     607           0 :             nCount += nBaseCount;
     608             :         }
     609           0 :         break;
     610             : 
     611             :         default:
     612             :             ;
     613             :     }
     614           0 :     return nCount;
     615             : }
     616             : 
     617           0 : sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException, std::exception )
     618             : {
     619           0 :     SolarMutexGuard aGuard;
     620           0 :     return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
     621             : }
     622             : 
     623           0 : uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
     624             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     625             : {
     626           0 :     SolarMutexGuard aGuard;
     627           0 :     uno::Any aRet;
     628           0 :     if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
     629             :     {
     630           0 :         sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
     631           0 :         if(pBasePool)
     632             :         {
     633           0 :             OUString sStyleName;
     634           0 :             switch( eFamily )
     635             :             {
     636             :                 case SFX_STYLE_FAMILY_CHAR:
     637             :                 {
     638           0 :                     if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
     639           0 :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
     640           0 :                     else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN  +
     641             :                                          RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
     642             :                         SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
     643             :                                                         - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
     644           0 :                                                         + nIndex, sStyleName );
     645             :                 }
     646           0 :                 break;
     647             :                 case SFX_STYLE_FAMILY_PARA:
     648             :                 {
     649           0 :                     if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
     650           0 :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName );
     651           0 :                     else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     652             :                                          RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN ) )
     653             :                         SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN
     654             :                                                         - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
     655           0 :                                                         + nIndex, sStyleName );
     656           0 :                     else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
     657             :                                          RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     658             :                                          RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN ) )
     659             :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN
     660             :                                                          - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
     661             :                                                          - RES_POOLCOLL_TEXT_END  + RES_POOLCOLL_TEXT_BEGIN
     662           0 :                                                          + nIndex), sStyleName );
     663           0 :                     else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
     664             :                                          RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
     665             :                                          RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     666             :                                          RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN ) )
     667             :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_REGISTER_BEGIN
     668             :                                                          - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
     669             :                                                          - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
     670             :                                                          - RES_POOLCOLL_TEXT_END  + RES_POOLCOLL_TEXT_BEGIN
     671           0 :                                                          + nIndex), sStyleName );
     672           0 :                     else if ( nIndex < ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
     673             :                                          RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
     674             :                                          RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
     675             :                                          RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     676             :                                          RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN ) )
     677             :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN
     678             :                                                          - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
     679             :                                                          - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
     680             :                                                          - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
     681             :                                                          - RES_POOLCOLL_TEXT_END  + RES_POOLCOLL_TEXT_BEGIN
     682           0 :                                                          + nIndex), sStyleName );
     683           0 :                     else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
     684             :                                          RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
     685             :                                          RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
     686             :                                          RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
     687             :                                          RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
     688             :                                          RES_POOLCOLL_TEXT_END  - RES_POOLCOLL_TEXT_BEGIN ) )
     689             :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN
     690             :                                                          - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN
     691             :                                                          - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
     692             :                                                          - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
     693             :                                                          - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
     694             :                                                          - RES_POOLCOLL_TEXT_END  + RES_POOLCOLL_TEXT_BEGIN
     695           0 :                                                          + nIndex), sStyleName );
     696             :                 }
     697           0 :                 break;
     698             :                 case SFX_STYLE_FAMILY_FRAME:
     699             :                 {
     700           0 :                     if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) )
     701             :                     {
     702           0 :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName );
     703             :                     }
     704             :                 }
     705           0 :                 break;
     706             :                 case SFX_STYLE_FAMILY_PAGE:
     707             :                 {
     708           0 :                     if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) )
     709             :                     {
     710           0 :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName );
     711             :                     }
     712             :                 }
     713           0 :                 break;
     714             :                 case SFX_STYLE_FAMILY_PSEUDO:
     715             :                 {
     716           0 :                     if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
     717             :                     {
     718           0 :                         SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
     719             :                     }
     720             :                 }
     721           0 :                 break;
     722             : 
     723             :                 default:
     724             :                     ;
     725             :             }
     726           0 :             if (sStyleName.isEmpty())
     727           0 :                 lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
     728             : 
     729           0 :             if (!sStyleName.isEmpty())
     730             :             {
     731           0 :                 SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
     732           0 :                 if(pBase)
     733             :                 {
     734           0 :                     uno::Reference< style::XStyle >  xStyle = _FindStyle(sStyleName);
     735           0 :                     if(!xStyle.is())
     736             :                     {
     737           0 :                         xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
     738           0 :                             new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
     739           0 :                                 eFamily == SFX_STYLE_FAMILY_FRAME ?
     740           0 :                                 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
     741           0 :                                     new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
     742             :                     }
     743           0 :                     aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
     744             :                 }
     745             :                 else
     746           0 :                     throw container::NoSuchElementException();
     747             :             }
     748             :             else
     749           0 :                 throw lang::IndexOutOfBoundsException();
     750             :         }
     751             :         else
     752           0 :             throw uno::RuntimeException();
     753             :     }
     754             :     else
     755           0 :         throw lang::IndexOutOfBoundsException();
     756             : 
     757           0 :     return aRet;
     758             : }
     759             : 
     760           0 : uno::Any SwXStyleFamily::getByName(const OUString& rName)
     761             :     throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     762             : {
     763           0 :     SolarMutexGuard aGuard;
     764           0 :     uno::Any aRet;
     765           0 :     OUString sStyleName;
     766           0 :     SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
     767           0 :     if(pBasePool)
     768             :     {
     769           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     770           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
     771           0 :         if(pBase)
     772             :         {
     773           0 :             uno::Reference< style::XStyle >  xStyle = _FindStyle(sStyleName);
     774           0 :             if(!xStyle.is())
     775             :             {
     776           0 :                 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
     777           0 :                     new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
     778           0 :                         eFamily == SFX_STYLE_FAMILY_FRAME ?
     779           0 :                         new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
     780           0 :                             new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
     781             :             }
     782           0 :             aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
     783             :         }
     784             :         else
     785           0 :             throw container::NoSuchElementException();
     786             :     }
     787             :     else
     788           0 :         throw uno::RuntimeException();
     789           0 :     return aRet;
     790             : 
     791             : }
     792             : 
     793           0 : uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException, std::exception )
     794             : {
     795           0 :     SolarMutexGuard aGuard;
     796           0 :     uno::Sequence< OUString > aRet;
     797           0 :     if(pBasePool)
     798             :     {
     799           0 :         SfxStyleSheetIteratorPtr pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
     800           0 :         sal_uInt16 nCount = pIterator->Count();
     801           0 :         aRet.realloc(nCount);
     802           0 :         OUString* pArray = aRet.getArray();
     803           0 :         OUString aString;
     804           0 :         for(sal_uInt16 i = 0; i < nCount; i++)
     805             :         {
     806           0 :             SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
     807           0 :             pArray[i] = aString;
     808           0 :         }
     809             :     }
     810             :     else
     811           0 :         throw uno::RuntimeException();
     812           0 :     return aRet;
     813             : }
     814             : 
     815           0 : sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception )
     816             : {
     817           0 :     SolarMutexGuard aGuard;
     818           0 :     sal_Bool bRet = sal_False;
     819           0 :     if(pBasePool)
     820             :     {
     821           0 :         OUString sStyleName;
     822           0 :         SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
     823           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     824           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
     825           0 :         bRet = 0 != pBase;
     826             :     }
     827             :     else
     828           0 :         throw uno::RuntimeException();
     829           0 :     return bRet;
     830             : 
     831             : }
     832             : 
     833           0 : uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException, std::exception )
     834             : {
     835           0 :     return ::getCppuType((const uno::Reference<style::XStyle>*)0);
     836             : 
     837             : }
     838             : 
     839           0 : sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException, std::exception )
     840             : {
     841           0 :     if(!pBasePool)
     842           0 :         throw uno::RuntimeException();
     843           0 :     return sal_True;
     844             : }
     845             : 
     846           0 : void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
     847             :         throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     848             : {
     849           0 :     SolarMutexGuard aGuard;
     850           0 :     if(pBasePool)
     851             :     {
     852           0 :         OUString sStyleName;
     853           0 :         SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
     854           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     855           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
     856           0 :         SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
     857           0 :         if(pBase || pUINameBase)
     858           0 :             throw container::ElementExistException();
     859             :         else
     860             :         {
     861           0 :             if(rElement.getValueType().getTypeClass() ==
     862             :                                             uno::TypeClass_INTERFACE)
     863             :             {
     864             :                 uno::Reference< uno::XInterface > * pxRef =
     865           0 :                     (uno::Reference< uno::XInterface > *)rElement.getValue();
     866             : 
     867           0 :                 uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
     868             : 
     869           0 :                 SwXStyle* pNewStyle = 0;
     870           0 :                 if(xStyleTunnel.is())
     871             :                 {
     872             :                     pNewStyle = reinterpret_cast< SwXStyle * >(
     873           0 :                             sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
     874             :                 }
     875             : 
     876           0 :                 if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != eFamily)
     877           0 :                     throw lang::IllegalArgumentException();
     878             : 
     879           0 :                 sal_uInt16 nMask = SFXSTYLEBIT_ALL;
     880           0 :                 if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
     881           0 :                     nMask &= ~SWSTYLEBIT_CONDCOLL;
     882             : #if OSL_DEBUG_LEVEL > 1
     883             :                 SfxStyleSheetBase& rNewBase =
     884             : #endif
     885           0 :                 pBasePool->Make(sStyleName, eFamily, nMask);
     886           0 :                 pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
     887           0 :                 pNewStyle->SetStyleName(sStyleName);
     888           0 :                 const OUString sParentStyleName(pNewStyle->GetParentStyleName());
     889           0 :                 if (!sParentStyleName.isEmpty())
     890             :                 {
     891           0 :                     pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     892           0 :                     SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
     893           0 :                     if(pParentBase && pParentBase->GetFamily() == eFamily &&
     894           0 :                         &pParentBase->GetPool() == pBasePool)
     895           0 :                         pBasePool->SetParent( eFamily, sStyleName, sParentStyleName );
     896             : 
     897             :                 }
     898             : #if OSL_DEBUG_LEVEL > 1
     899             :                 (void)rNewBase;
     900             : #endif
     901             :                 //so, jetzt sollten noch die Properties des Descriptors angewandt werden
     902           0 :                 pNewStyle->ApplyDescriptorProperties();
     903             :             }
     904             :             else
     905           0 :                 throw lang::IllegalArgumentException();
     906           0 :         }
     907             :     }
     908             :     else
     909           0 :         throw uno::RuntimeException();
     910           0 : }
     911             : 
     912           0 : void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement)
     913             :     throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     914             : {
     915           0 :     SolarMutexGuard aGuard;
     916           0 :     if(pBasePool)
     917             :     {
     918           0 :         pBasePool->SetSearchMask(eFamily);
     919           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(rName);
     920             :         //Ersetzung geht nur fuer benutzerdefinierte Styles
     921           0 :         if(!pBase)
     922           0 :             throw container::NoSuchElementException();
     923           0 :         if(!pBase->IsUserDefined())
     924           0 :             throw lang::IllegalArgumentException();
     925             :         //if theres an object available to this style then it must be invalidated
     926           0 :         uno::Reference< style::XStyle >  xStyle = _FindStyle(pBase->GetName());
     927           0 :         if(xStyle.is())
     928             :         {
     929           0 :             uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
     930           0 :             if(xTunnel.is())
     931             :             {
     932             :                 SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
     933           0 :                         sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
     934           0 :                 pStyle->Invalidate();
     935           0 :             }
     936             :         }
     937             : 
     938           0 :         pBasePool->Remove(pBase);
     939           0 :         insertByName(rName, rElement);
     940             :     }
     941             :     else
     942           0 :         throw uno::RuntimeException();
     943           0 : }
     944             : 
     945           0 : void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
     946             : {
     947           0 :     SolarMutexGuard aGuard;
     948           0 :     if(pBasePool)
     949             :     {
     950           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     951           0 :         OUString aString;
     952           0 :         SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
     953             : 
     954           0 :         SfxStyleSheetBase* pBase = pBasePool->Find( aString );
     955           0 :         if(pBase)
     956           0 :             pBasePool->Remove(pBase);
     957             :         else
     958           0 :             throw container::NoSuchElementException();
     959             :     }
     960             :     else
     961           0 :         throw uno::RuntimeException();
     962           0 : }
     963             : 
     964           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo(  ) throw (uno::RuntimeException, std::exception)
     965             : {
     966           0 :     return uno::Reference< beans::XPropertySetInfo >();
     967             : }
     968             : 
     969           0 : void SAL_CALL SwXStyleFamily::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     970             : {
     971             :     OSL_FAIL( "###unexpected!" );
     972           0 : }
     973             : 
     974           0 : uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     975             : {
     976           0 :     uno::Any aRet;
     977             : 
     978           0 :     if ( sPropertyName == "DisplayName" )
     979             :     {
     980           0 :         SolarMutexGuard aGuard;
     981           0 :         sal_uInt32 nResId = 0;
     982           0 :         switch ( eFamily )
     983             :         {
     984             :             case SFX_STYLE_FAMILY_CHAR:
     985           0 :                 nResId = STR_STYLE_FAMILY_CHARACTER; break;
     986             :             case SFX_STYLE_FAMILY_PARA:
     987           0 :                 nResId = STR_STYLE_FAMILY_PARAGRAPH; break;
     988             :             case SFX_STYLE_FAMILY_FRAME:
     989           0 :                 nResId = STR_STYLE_FAMILY_FRAME; break;
     990             :             case SFX_STYLE_FAMILY_PAGE:
     991           0 :                 nResId = STR_STYLE_FAMILY_PAGE; break;
     992             :             case SFX_STYLE_FAMILY_PSEUDO:
     993           0 :                 nResId = STR_STYLE_FAMILY_NUMBERING; break;
     994             :             default:
     995             :                 OSL_FAIL( "SwXStyleFamily::getPropertyValue(): invalid family" );
     996             :         }
     997           0 :         if ( nResId > 0 )
     998             :         {
     999           0 :             aRet = uno::makeAny( SW_RESSTR( nResId ) );
    1000           0 :         }
    1001             :     }
    1002             :     else
    1003             :     {
    1004           0 :         throw beans::UnknownPropertyException( OUString("unknown property: ") + sPropertyName, static_cast<OWeakObject *>(this) );
    1005             :     }
    1006             : 
    1007           0 :     return aRet;
    1008             : }
    1009             : 
    1010           0 : void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1011             : {
    1012             :     OSL_FAIL( "###unexpected!" );
    1013           0 : }
    1014             : 
    1015           0 : void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1016             : {
    1017             :     OSL_FAIL( "###unexpected!" );
    1018           0 : }
    1019             : 
    1020           0 : void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1021             : {
    1022             :     OSL_FAIL( "###unexpected!" );
    1023           0 : }
    1024             : 
    1025           0 : void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1026             : {
    1027             :     OSL_FAIL( "###unexpected!" );
    1028           0 : }
    1029             : 
    1030           0 : void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
    1031             : {
    1032           0 :     SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
    1033           0 :     if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
    1034             :     {
    1035           0 :         pBasePool = 0;
    1036           0 :         pDocShell = 0;
    1037           0 :         EndListening(rBC);
    1038             :     }
    1039           0 : }
    1040             : 
    1041           0 : SwXStyle*   SwXStyleFamily::_FindStyle(const OUString& rStyleName)const
    1042             : {
    1043           0 :     sal_uInt16  nLCount = pBasePool->GetListenerCount();
    1044           0 :     SfxListener* pListener = 0;
    1045           0 :     for( sal_uInt16 i = 0; i < nLCount; i++)
    1046             :     {
    1047           0 :         pListener = pBasePool->GetListener( i );
    1048           0 :         SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
    1049           0 :         if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
    1050             :         {
    1051           0 :             return pTempStyle;
    1052             :         }
    1053             :     }
    1054           0 :     return 0;
    1055             : }
    1056             : 
    1057             : class SwStyleProperties_Impl
    1058             : {
    1059             :     const PropertyEntryVector_t aPropertyEntries;
    1060             :     uno::Any**                  pAnyArr;
    1061             :     sal_uInt32                  nArrLen;
    1062             : 
    1063             : public:
    1064             :     SwStyleProperties_Impl(const SfxItemPropertyMap& rMap);
    1065             :     ~SwStyleProperties_Impl();
    1066             : 
    1067             :     sal_Bool    SetProperty(const OUString& rName, uno::Any aVal);
    1068             :     sal_Bool    GetProperty(const OUString& rName, uno::Any*& rpAny);
    1069             :     sal_Bool    ClearProperty( const OUString& rPropertyName );
    1070             :     void    ClearAllProperties( );
    1071             :     void        GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
    1072             : 
    1073           0 :     const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
    1074             : 
    1075             : };
    1076             : 
    1077           0 : SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap& rMap) :
    1078             :     aPropertyEntries( rMap.getPropertyEntries() ),
    1079           0 :     nArrLen(0)
    1080             : {
    1081           0 :     nArrLen = aPropertyEntries.size();
    1082             : 
    1083           0 :     pAnyArr = new uno::Any* [nArrLen];
    1084           0 :     for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
    1085           0 :         pAnyArr[i] = 0;
    1086           0 : }
    1087             : 
    1088           0 : SwStyleProperties_Impl::~SwStyleProperties_Impl()
    1089             : {
    1090           0 :     for ( sal_uInt16 i =0 ; i < nArrLen; i++ )
    1091           0 :         delete pAnyArr[i];
    1092           0 :     delete[] pAnyArr;
    1093           0 : }
    1094             : 
    1095           0 : sal_Bool SwStyleProperties_Impl::SetProperty(const OUString& rName, uno::Any aVal)
    1096             : {
    1097           0 :     sal_uInt16 nPos = 0;
    1098           0 :     sal_Bool bRet = sal_False;
    1099           0 :     PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
    1100           0 :     while( aIt != aPropertyEntries.end() )
    1101             :     {
    1102           0 :         if(rName == aIt->sName)
    1103             :         {
    1104           0 :             delete pAnyArr[nPos];
    1105           0 :             pAnyArr[nPos] = new uno::Any ( aVal );
    1106           0 :             bRet = sal_True;
    1107           0 :             break;
    1108             :         }
    1109           0 :         ++nPos;
    1110           0 :         ++aIt;
    1111             :     }
    1112           0 :     return bRet;
    1113             : }
    1114             : 
    1115           0 : sal_Bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
    1116             : {
    1117           0 :     sal_Bool bRet = sal_False;
    1118           0 :     sal_uInt16 nPos = 0;
    1119           0 :     PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
    1120           0 :     while( aIt != aPropertyEntries.end() )
    1121             :     {
    1122           0 :         if( rName == aIt->sName )
    1123             :         {
    1124           0 :             delete pAnyArr[nPos];
    1125           0 :             pAnyArr[ nPos ] = 0;
    1126           0 :             bRet = sal_True;
    1127           0 :             break;
    1128             :         }
    1129           0 :         ++nPos;
    1130           0 :         ++aIt;
    1131             :     }
    1132           0 :     return bRet;
    1133             : }
    1134             : 
    1135           0 : void SwStyleProperties_Impl::ClearAllProperties( )
    1136             : {
    1137           0 :     for ( sal_uInt16 i = 0; i < nArrLen; i++ )
    1138             :     {
    1139           0 :         delete pAnyArr[i];
    1140           0 :         pAnyArr[ i ] = 0;
    1141             :     }
    1142           0 : }
    1143             : 
    1144           0 : sal_Bool SwStyleProperties_Impl::GetProperty(const OUString& rName, uno::Any*& rpAny )
    1145             : {
    1146           0 :     sal_Bool bRet = sal_False;
    1147           0 :     sal_uInt16 nPos = 0;
    1148           0 :     PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
    1149           0 :     while( aIt != aPropertyEntries.end() )
    1150             :     {
    1151           0 :         if( rName == aIt->sName )
    1152             :         {
    1153           0 :             rpAny = pAnyArr[nPos];
    1154           0 :             bRet = sal_True;
    1155           0 :             break;
    1156             :         }
    1157           0 :         ++nPos;
    1158           0 :         ++aIt;
    1159             :     }
    1160             : 
    1161           0 :     return bRet;
    1162             : }
    1163             : 
    1164           0 : void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
    1165             : {
    1166           0 :     rAny = rxPropertySet->getPropertyValue( rPropertyName );
    1167           0 : }
    1168             : 
    1169             : namespace
    1170             : {
    1171             :     class theSwXStyleUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXStyleUnoTunnelId > {};
    1172             : }
    1173             : 
    1174           0 : const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
    1175             : {
    1176           0 :     return theSwXStyleUnoTunnelId::get().getSeq();
    1177             : }
    1178             : 
    1179           0 : sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
    1180             :     throw(uno::RuntimeException, std::exception)
    1181             : {
    1182           0 :     if( rId.getLength() == 16
    1183           0 :         && 0 == memcmp( getUnoTunnelId().getConstArray(),
    1184           0 :                                         rId.getConstArray(), 16 ) )
    1185             :     {
    1186           0 :         return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
    1187             :     }
    1188           0 :     return 0;
    1189             : }
    1190             : 
    1191           0 : TYPEINIT1(SwXStyle, SfxListener);
    1192             : 
    1193           0 : OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException, std::exception )
    1194             : {
    1195           0 :     return OUString("SwXStyle");
    1196             : }
    1197             : 
    1198           0 : sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
    1199             : {
    1200           0 :     return cppu::supportsService(this, rServiceName);
    1201             : }
    1202             : 
    1203           0 : uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
    1204             : {
    1205           0 :     long nCount = 1;
    1206           0 :     if(SFX_STYLE_FAMILY_PARA == eFamily)
    1207             :     {
    1208           0 :         nCount = 5;
    1209           0 :         if(bIsConditional)
    1210           0 :             nCount++;
    1211             :     }
    1212           0 :     else if(SFX_STYLE_FAMILY_CHAR == eFamily)
    1213           0 :         nCount = 5;
    1214           0 :     else if(SFX_STYLE_FAMILY_PAGE == eFamily)
    1215           0 :         nCount = 3;
    1216           0 :     uno::Sequence< OUString > aRet(nCount);
    1217           0 :     OUString* pArray = aRet.getArray();
    1218           0 :     pArray[0] = "com.sun.star.style.Style";
    1219           0 :     switch(eFamily)
    1220             :     {
    1221             :         case SFX_STYLE_FAMILY_CHAR:
    1222           0 :             pArray[1] = "com.sun.star.style.CharacterStyle";
    1223           0 :             pArray[2] = "com.sun.star.style.CharacterProperties";
    1224           0 :             pArray[3] = "com.sun.star.style.CharacterPropertiesAsian";
    1225           0 :             pArray[4] = "com.sun.star.style.CharacterPropertiesComplex";
    1226           0 :         break;
    1227             :         case SFX_STYLE_FAMILY_PAGE:
    1228           0 :             pArray[1] = "com.sun.star.style.PageStyle";
    1229           0 :             pArray[2] = "com.sun.star.style.PageProperties";
    1230           0 :         break;
    1231             :         case SFX_STYLE_FAMILY_PARA:
    1232           0 :             pArray[1] = "com.sun.star.style.ParagraphStyle";
    1233           0 :             pArray[2] = "com.sun.star.style.ParagraphProperties";
    1234           0 :             pArray[3] = "com.sun.star.style.ParagraphPropertiesAsian";
    1235           0 :             pArray[4] = "com.sun.star.style.ParagraphPropertiesComplex";
    1236           0 :         if(bIsConditional)
    1237           0 :             pArray[5] = "com.sun.star.style.ConditionalParagraphStyle";
    1238           0 :         break;
    1239             : 
    1240             :         default:
    1241             :             ;
    1242             :     }
    1243           0 :     return aRet;
    1244             : }
    1245             : 
    1246           0 : SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, sal_Bool bConditional) :
    1247             :     m_pDoc( pDoc ),
    1248             :     pBasePool(0),
    1249             :     eFamily(eFam),
    1250             :     bIsDescriptor(sal_True),
    1251           0 :     bIsConditional(bConditional)
    1252             : {
    1253             :     // Register ourselves as a listener to the document (via the page descriptor)
    1254           0 :     pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
    1255             :     // get the property set for the default style data
    1256             :     // First get the model
    1257           0 :     uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
    1258             :     // Ask the model for it's family supplier interface
    1259           0 :     uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
    1260             :     // Get the style families
    1261           0 :     uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
    1262             : 
    1263           0 :     uno::Any aAny;
    1264           0 :     sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
    1265           0 :     switch( eFamily )
    1266             :     {
    1267             :         case SFX_STYLE_FAMILY_CHAR:
    1268             :         {
    1269           0 :             nMapId = PROPERTY_MAP_CHAR_STYLE;
    1270           0 :             aAny = xFamilies->getByName ("CharacterStyles");
    1271             :             // Get the Frame family (and keep it for later)
    1272           0 :             aAny >>= mxStyleFamily;
    1273             :         }
    1274           0 :         break;
    1275             :         case SFX_STYLE_FAMILY_PARA:
    1276             :         {
    1277           0 :             nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
    1278           0 :             aAny = xFamilies->getByName ("ParagraphStyles");
    1279             :             // Get the Frame family (and keep it for later)
    1280           0 :             aAny >>= mxStyleFamily;
    1281           0 :             aAny = mxStyleFamily->getByName ("Standard");
    1282           0 :             aAny >>= mxStyleData;
    1283             :         }
    1284           0 :         break;
    1285             :         case SFX_STYLE_FAMILY_PAGE:
    1286             :         {
    1287           0 :             nMapId = PROPERTY_MAP_PAGE_STYLE;
    1288           0 :             aAny = xFamilies->getByName ("PageStyles");
    1289             :             // Get the Frame family (and keep it for later)
    1290           0 :             aAny >>= mxStyleFamily;
    1291           0 :             aAny = mxStyleFamily->getByName ("Standard");
    1292           0 :             aAny >>= mxStyleData;
    1293             :         }
    1294           0 :         break;
    1295             :         case SFX_STYLE_FAMILY_FRAME :
    1296             :         {
    1297           0 :             nMapId = PROPERTY_MAP_FRAME_STYLE;
    1298             :         }
    1299           0 :         break;
    1300             :         case SFX_STYLE_FAMILY_PSEUDO:
    1301             :         {
    1302           0 :             nMapId = PROPERTY_MAP_NUM_STYLE;
    1303             :         }
    1304           0 :         break;
    1305             : 
    1306             :         default:
    1307             :             ;
    1308             :     }
    1309           0 :     pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
    1310           0 : }
    1311             : 
    1312           0 : SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
    1313             :         SwDoc* pDoc, const OUString& rStyleName) :
    1314             :     m_pDoc(pDoc),
    1315             :     m_sStyleName(rStyleName),
    1316             :     pBasePool(&rPool),
    1317             :     eFamily(eFam),
    1318             :     bIsDescriptor(sal_False),
    1319             :     bIsConditional(sal_False),
    1320           0 :     pPropImpl(0)
    1321             : {
    1322           0 :     StartListening(rPool);
    1323           0 :     if(eFam == SFX_STYLE_FAMILY_PARA)
    1324             :     {
    1325           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
    1326           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1327             :         OSL_ENSURE(pBase, "where is the style?" );
    1328           0 :         if(pBase)
    1329             :         {
    1330           0 :             const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(m_sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
    1331           0 :             if(nId != USHRT_MAX)
    1332           0 :                 bIsConditional = ::IsConditionalByPoolId( nId );
    1333             :             else
    1334           0 :                 bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
    1335             :         }
    1336             :     }
    1337           0 : }
    1338             : 
    1339           0 : SwXStyle::~SwXStyle()
    1340             : {
    1341           0 :     if(pBasePool)
    1342           0 :         EndListening(*pBasePool);
    1343           0 :     delete pPropImpl;
    1344           0 : }
    1345             : 
    1346           0 : void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    1347             : {
    1348           0 :     ClientModify(this, pOld, pNew);
    1349           0 :     if(!GetRegisteredIn())
    1350             :     {
    1351           0 :         m_pDoc = 0;
    1352           0 :         mxStyleData.clear();
    1353           0 :         mxStyleFamily.clear();
    1354             :     }
    1355           0 : }
    1356             : 
    1357           0 : OUString SwXStyle::getName(void) throw( uno::RuntimeException, std::exception )
    1358             : {
    1359           0 :     SolarMutexGuard aGuard;
    1360           0 :     if(pBasePool)
    1361             :     {
    1362           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
    1363           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1364             :         OSL_ENSURE(pBase, "where is the style?" );
    1365           0 :         if(!pBase)
    1366           0 :             throw uno::RuntimeException();
    1367           0 :         OUString aString;
    1368           0 :         SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
    1369           0 :         return aString;
    1370             :     }
    1371           0 :     return m_sStyleName;
    1372             : }
    1373             : 
    1374           0 : void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException, std::exception )
    1375             : {
    1376           0 :     SolarMutexGuard aGuard;
    1377           0 :     if(pBasePool)
    1378             :     {
    1379           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
    1380           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1381             :         OSL_ENSURE(pBase, "where is the style?" );
    1382           0 :         bool bExcept = true;
    1383           0 :         if(pBase && pBase->IsUserDefined())
    1384             :         {
    1385           0 :             rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    1386           0 :             bExcept = !xTmp->SetName(rName);
    1387           0 :             if(!bExcept)
    1388           0 :                 m_sStyleName = rName;
    1389             :         }
    1390           0 :         if(bExcept)
    1391           0 :             throw uno::RuntimeException();
    1392             :     }
    1393             :     else
    1394           0 :         m_sStyleName = rName;
    1395           0 : }
    1396             : 
    1397           0 : sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException, std::exception )
    1398             : {
    1399           0 :     SolarMutexGuard aGuard;
    1400           0 :     sal_Bool bRet = sal_False;
    1401           0 :     if(pBasePool)
    1402             :     {
    1403           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
    1404           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1405             :         //if it is not found it must be non user defined
    1406           0 :         if(pBase)
    1407           0 :             bRet = pBase->IsUserDefined();
    1408             :     }
    1409             :     else
    1410           0 :         throw uno::RuntimeException();
    1411           0 :     return bRet;
    1412             : }
    1413             : 
    1414           0 : sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException, std::exception )
    1415             : {
    1416           0 :     SolarMutexGuard aGuard;
    1417           0 :     sal_Bool bRet = sal_False;
    1418           0 :     if(pBasePool)
    1419             :     {
    1420           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED);
    1421           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1422           0 :         if(pBase)
    1423           0 :             bRet = pBase->IsUsed();
    1424             :     }
    1425             :     else
    1426           0 :         throw uno::RuntimeException();
    1427           0 :     return bRet;
    1428             : }
    1429             : 
    1430           0 : OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException, std::exception )
    1431             : {
    1432           0 :     SolarMutexGuard aGuard;
    1433           0 :     OUString aString;
    1434           0 :     if(pBasePool)
    1435             :     {
    1436           0 :         pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
    1437           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1438           0 :         if(pBase)
    1439           0 :             aString = pBase->GetParent();
    1440             :     }
    1441           0 :     else if(bIsDescriptor)
    1442           0 :         aString = m_sParentStyleName;
    1443             :     else
    1444           0 :         throw uno::RuntimeException();
    1445           0 :     SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
    1446           0 :     return aString;
    1447             : }
    1448             : 
    1449           0 : void SwXStyle::setParentStyle(const OUString& rParentStyle)
    1450             :             throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
    1451             : {
    1452           0 :     SolarMutexGuard aGuard;
    1453           0 :     OUString sParentStyle;
    1454           0 :     SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
    1455           0 :     if(pBasePool)
    1456             :     {
    1457           0 :         pBasePool->SetSearchMask(eFamily);
    1458           0 :         bool bExcept = false;
    1459           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    1460           0 :         if(pBase)
    1461             :         {
    1462           0 :             rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
    1463             :             //make it a 'real' style - necessary for pooled styles
    1464           0 :             xBase->GetItemSet();
    1465           0 :             if(xBase->GetParent() != sParentStyle)
    1466             :             {
    1467           0 :                 bExcept = !xBase->SetParent(sParentStyle);
    1468           0 :             }
    1469             :         }
    1470             :         else
    1471           0 :             bExcept = true;
    1472           0 :         if(bExcept)
    1473           0 :             throw uno::RuntimeException();
    1474             :     }
    1475           0 :     else if(bIsDescriptor)
    1476             :     {
    1477           0 :         m_sParentStyleName = sParentStyle;
    1478             :         try
    1479             :         {
    1480           0 :             uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
    1481           0 :             aAny >>= mxStyleData;
    1482             :         }
    1483           0 :         catch ( container::NoSuchElementException& )
    1484             :         {
    1485             :         }
    1486           0 :         catch ( lang::WrappedTargetException& )
    1487             :         {
    1488             :         }
    1489           0 :         catch ( uno::RuntimeException& )
    1490             :         {
    1491             :         }
    1492             :     }
    1493             :     else
    1494           0 :         throw uno::RuntimeException();
    1495           0 : }
    1496             : 
    1497           0 : static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional )
    1498             : {
    1499           0 :     uno::Reference< beans::XPropertySetInfo >  xRet;
    1500           0 :     switch( eFamily )
    1501             :     {
    1502             :         case SFX_STYLE_FAMILY_CHAR:
    1503             :         {
    1504           0 :             static uno::Reference< beans::XPropertySetInfo >  xCharRef;
    1505           0 :             if(!xCharRef.is())
    1506             :             {
    1507           0 :                 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
    1508             :             }
    1509           0 :             xRet = xCharRef;
    1510             :         }
    1511           0 :         break;
    1512             :         case SFX_STYLE_FAMILY_PARA:
    1513             :         {
    1514           0 :             static uno::Reference< beans::XPropertySetInfo > xCondParaRef;
    1515           0 :             static uno::Reference< beans::XPropertySetInfo >  xParaRef;
    1516           0 :             if(!xParaRef.is())
    1517             :             {
    1518           0 :                 xCondParaRef = aSwMapProvider.GetPropertySet(
    1519           0 :                     PROPERTY_MAP_CONDITIONAL_PARA_STYLE)->getPropertySetInfo();
    1520           0 :                 xParaRef = aSwMapProvider.GetPropertySet(
    1521           0 :                     PROPERTY_MAP_PARA_STYLE)->getPropertySetInfo();
    1522             :             }
    1523           0 :             xRet = bIsConditional ? xCondParaRef : xParaRef;
    1524             :         }
    1525           0 :         break;
    1526             :         case SFX_STYLE_FAMILY_PAGE     :
    1527             :         {
    1528           0 :             static uno::Reference< beans::XPropertySetInfo >  xPageRef;
    1529           0 :             if(!xPageRef.is())
    1530             :             {
    1531           0 :                 xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
    1532             :             }
    1533           0 :             xRet = xPageRef;
    1534             :         }
    1535           0 :         break;
    1536             :         case SFX_STYLE_FAMILY_FRAME    :
    1537             :         {
    1538           0 :             static uno::Reference< beans::XPropertySetInfo >  xFrameRef;
    1539           0 :             if(!xFrameRef.is())
    1540             :             {
    1541           0 :                 xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
    1542             :             }
    1543           0 :             xRet = xFrameRef;
    1544             :         }
    1545           0 :         break;
    1546             :         case SFX_STYLE_FAMILY_PSEUDO:
    1547             :         {
    1548           0 :             static uno::Reference< beans::XPropertySetInfo >  xNumRef;
    1549           0 :             if(!xNumRef.is())
    1550             :             {
    1551           0 :                 xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
    1552             :             }
    1553           0 :             xRet = xNumRef;
    1554             :         }
    1555           0 :         break;
    1556             : 
    1557             :         default:
    1558             :             ;
    1559             :     }
    1560           0 :     return xRet;
    1561             : }
    1562             : 
    1563           0 : uno::Reference< beans::XPropertySetInfo >  SwXStyle::getPropertySetInfo(void)
    1564             :     throw( uno::RuntimeException, std::exception )
    1565             : {
    1566           0 :     return lcl_getPropertySetInfo( eFamily, bIsConditional );
    1567             : }
    1568             : 
    1569           0 : void    SwXStyle::ApplyDescriptorProperties()
    1570             : {
    1571           0 :     bIsDescriptor = sal_False;
    1572           0 :     mxStyleData.clear();
    1573           0 :     mxStyleFamily.clear();
    1574             : 
    1575           0 :     const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
    1576           0 :     PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
    1577           0 :     while(aIt != rPropertyVector.end())
    1578             :     {
    1579             :         uno::Any* pAny;
    1580           0 :         pPropImpl->GetProperty(aIt->sName, pAny);
    1581           0 :         if(pAny)
    1582           0 :             setPropertyValue(aIt->sName, *pAny);
    1583           0 :         ++aIt;
    1584             :     }
    1585           0 : }
    1586             : 
    1587             : struct SwStyleBase_Impl
    1588             : {
    1589             :     SwDoc&              rDoc;
    1590             : 
    1591             :     const SwPageDesc*   pOldPageDesc;
    1592             : 
    1593             :     rtl::Reference< SwDocStyleSheet > mxNewBase;
    1594             :     SfxItemSet*         pItemSet;
    1595             : 
    1596             :     OUString     rStyleName;
    1597             : 
    1598           0 :     SwStyleBase_Impl(SwDoc& rSwDoc, const OUString& rName) :
    1599             :         rDoc(rSwDoc),
    1600             :         pOldPageDesc(0),
    1601             :         pItemSet(0),
    1602           0 :         rStyleName(rName)
    1603           0 :         {}
    1604             : 
    1605           0 :     ~SwStyleBase_Impl(){ delete pItemSet; }
    1606             : 
    1607           0 :     sal_Bool HasItemSet() {return mxNewBase.is();}
    1608           0 :     SfxItemSet& GetItemSet()
    1609             :         {
    1610             :             OSL_ENSURE(mxNewBase.is(), "no SwDocStyleSheet available");
    1611           0 :             if(!pItemSet)
    1612           0 :                 pItemSet = new SfxItemSet(mxNewBase->GetItemSet());
    1613           0 :             return *pItemSet;
    1614             :         }
    1615             : 
    1616             :         const SwPageDesc& GetOldPageDesc();
    1617             : };
    1618             : 
    1619           0 : const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
    1620             : {
    1621           0 :     if(!pOldPageDesc)
    1622             :     {
    1623             :         sal_uInt16 i;
    1624           0 :         sal_uInt16 nPDescCount = rDoc.GetPageDescCnt();
    1625           0 :         for(i = 0; i < nPDescCount; i++)
    1626             :         {
    1627           0 :             const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
    1628           0 :             if(rDesc.GetName() == rStyleName)
    1629             :             {
    1630           0 :                 pOldPageDesc = & rDesc;
    1631           0 :                 break;
    1632             :             }
    1633             :         }
    1634           0 :         if(!pOldPageDesc)
    1635             :         {
    1636           0 :             for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
    1637             :             {
    1638           0 :                 const OUString aFmtName(SW_RES(i));
    1639           0 :                 if(aFmtName == rStyleName)
    1640             :                 {
    1641           0 :                     pOldPageDesc = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
    1642           0 :                     break;
    1643             :                 }
    1644           0 :             }
    1645             :         }
    1646             :     }
    1647             :     assert(pOldPageDesc != 0);
    1648           0 :     return *pOldPageDesc;
    1649             : }
    1650             : 
    1651           0 : static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
    1652             :                         const SfxItemPropertySet& rPropSet,
    1653             :                         const uno::Any& rValue,
    1654             :                         SwStyleBase_Impl& rBase,
    1655             :                         SfxStyleSheetBasePool* pBasePool,
    1656             :                         SwDoc* pDoc,
    1657             :                         SfxStyleFamily eFamily)
    1658             :                             throw(beans::PropertyVetoException, lang::IllegalArgumentException,
    1659             :                                 lang::WrappedTargetException, uno::RuntimeException)
    1660             : 
    1661             : {
    1662             :     //UUUU adapted switch logic to a more readable state; removed goto's and made
    1663             :     // execution of standard setting of proerty in ItemSet dependent of this variable
    1664           0 :     bool bDone(false);
    1665             : 
    1666             :     //UUUU
    1667           0 :     const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
    1668           0 :     uno::Any aValue(rValue);
    1669             : 
    1670             :     //UUUU check for needed metric translation
    1671           0 :     if(rEntry.nMemberId & SFX_METRIC_ITEM)
    1672             :     {
    1673           0 :         bool bDoIt(true);
    1674             : 
    1675           0 :         if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
    1676             :         {
    1677             :             // exception: If these ItemTypes are used, do not convert when these are negative
    1678             :             // since this means they are intended as percent values
    1679           0 :             sal_Int32 nValue = 0;
    1680             : 
    1681           0 :             if(aValue >>= nValue)
    1682             :             {
    1683           0 :                 bDoIt = nValue > 0;
    1684             :             }
    1685             :         }
    1686             : 
    1687           0 :         if(bDoIt && pDoc)
    1688             :         {
    1689           0 :             const SfxItemPool& rPool = pDoc->GetAttrPool();
    1690           0 :             const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
    1691             : 
    1692           0 :             if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    1693             :             {
    1694           0 :                 SvxUnoConvertFromMM(eMapUnit, aValue);
    1695             :             }
    1696             :         }
    1697             :     }
    1698             : 
    1699           0 :     switch(rEntry.nWID)
    1700             :     {
    1701             :         case FN_UNO_HIDDEN:
    1702             :         {
    1703           0 :             sal_Bool bHidden = sal_False;
    1704           0 :             if ( rValue >>= bHidden )
    1705             :             {
    1706             :                 //make it a 'real' style - necessary for pooled styles
    1707           0 :                 rBase.mxNewBase->GetItemSet();
    1708           0 :                 rBase.mxNewBase->SetHidden( bHidden );
    1709             :             }
    1710             :         }
    1711           0 :         break;
    1712             : 
    1713             :         case FN_UNO_STYLE_INTEROP_GRAB_BAG:
    1714             :         {
    1715           0 :             rBase.mxNewBase->GetItemSet();
    1716           0 :             rBase.mxNewBase->SetGrabBagItem(rValue);
    1717             :         }
    1718           0 :         break;
    1719             : 
    1720             :         case XATTR_FILLBITMAP:
    1721             :         case XATTR_FILLGRADIENT:
    1722             :         case XATTR_FILLHATCH:
    1723             :         case XATTR_FILLFLOATTRANSPARENCE:
    1724             :         // not yet needed; activate when LineStyle support may be added
    1725             :         // case XATTR_LINESTART:
    1726             :         // case XATTR_LINEEND:
    1727             :         // case XATTR_LINEDASH:
    1728             :         {
    1729             :             //UUUU add set commands for FillName items
    1730           0 :             if(MID_NAME == nMemberId)
    1731             :             {
    1732           0 :                 OUString aTempName;
    1733           0 :                 SfxItemSet& rStyleSet = rBase.GetItemSet();
    1734             : 
    1735           0 :                 if(!(aValue >>= aTempName))
    1736             :                 {
    1737           0 :                     throw lang::IllegalArgumentException();
    1738             :                 }
    1739             : 
    1740           0 :                 SvxShape::SetFillAttribute(rEntry.nWID, aTempName, rStyleSet);
    1741           0 :                 bDone = true;
    1742             :             }
    1743             : 
    1744           0 :             break;
    1745             :         }
    1746             :         case RES_BACKGROUND:
    1747             :         {
    1748           0 :             if (SFX_STYLE_FAMILY_FRAME == eFamily)
    1749             :             {
    1750             :                 //UUUU
    1751           0 :                 SfxItemSet& rStyleSet = rBase.GetItemSet();
    1752           0 :                 const SvxBrushItem aOriginalBrushItem(sw::getSvxBrushItemFromSourceSet(rStyleSet));
    1753           0 :                 SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
    1754             : 
    1755           0 :                 aChangedBrushItem.PutValue(aValue, nMemberId);
    1756             : 
    1757           0 :                 if(!(aChangedBrushItem == aOriginalBrushItem))
    1758             :                 {
    1759           0 :                     sw::setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet);
    1760             :                 }
    1761             : 
    1762           0 :                 bDone = true;
    1763             :             }
    1764           0 :             break;
    1765             :         }
    1766             :         case OWN_ATTR_FILLBMP_MODE:
    1767             :         {
    1768             :             //UUUU
    1769             :             drawing::BitmapMode eMode;
    1770             : 
    1771           0 :             if(!(aValue >>= eMode))
    1772             :             {
    1773           0 :                 sal_Int32 nMode = 0;
    1774             : 
    1775           0 :                 if(!(aValue >>= nMode))
    1776             :                 {
    1777           0 :                     throw lang::IllegalArgumentException();
    1778             :                 }
    1779             : 
    1780           0 :                 eMode = (drawing::BitmapMode)nMode;
    1781             :             }
    1782             : 
    1783           0 :             SfxItemSet& rStyleSet = rBase.GetItemSet();
    1784             : 
    1785           0 :             rStyleSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
    1786           0 :             rStyleSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
    1787             : 
    1788           0 :             bDone = true;
    1789           0 :             break;
    1790             :         }
    1791             :         case RES_PAPER_BIN:
    1792             :         {
    1793           0 :             SfxPrinter *pPrinter = pDoc->getPrinter( true );
    1794           0 :             OUString sTmp;
    1795           0 :             sal_uInt16 nBin = USHRT_MAX;
    1796           0 :             if ( !( aValue >>= sTmp ) )
    1797           0 :                 throw lang::IllegalArgumentException();
    1798           0 :             if ( sTmp == "[From printer settings]" )
    1799           0 :                 nBin = USHRT_MAX-1;
    1800           0 :             else if ( pPrinter )
    1801             :             {
    1802           0 :                 for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ )
    1803             :                 {
    1804           0 :                     if (sTmp == pPrinter->GetPaperBinName ( i ) )
    1805             :                     {
    1806           0 :                         nBin = i;
    1807           0 :                         break;
    1808             :                     }
    1809             :                 }
    1810             :             }
    1811           0 :             if ( nBin == USHRT_MAX )
    1812           0 :                 throw lang::IllegalArgumentException();
    1813             :             else
    1814             :             {
    1815           0 :                 SfxItemSet& rStyleSet = rBase.GetItemSet();
    1816           0 :                 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
    1817           0 :                 aSet.SetParent(&rStyleSet);
    1818           0 :                 rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet);
    1819           0 :                 rStyleSet.Put(aSet);
    1820             :             }
    1821             : 
    1822           0 :             bDone = true;
    1823           0 :             break;
    1824             :         }
    1825             :         case  FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
    1826             :         {
    1827           0 :             if(aValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) )
    1828             :             {
    1829             :                 uno::Reference< container::XIndexReplace > * pxRulesRef =
    1830           0 :                         (uno::Reference< container::XIndexReplace > *)aValue.getValue();
    1831             : 
    1832           0 :                 uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
    1833             : 
    1834           0 :                 SwXNumberingRules* pSwXRules = 0;
    1835           0 :                 if(xNumberTunnel.is())
    1836             :                 {
    1837             :                     pSwXRules = reinterpret_cast< SwXNumberingRules * >(
    1838           0 :                             sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
    1839             :                 }
    1840           0 :                 if(pSwXRules)
    1841             :                 {
    1842           0 :                     const OUString* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
    1843           0 :                     const OUString* pBulletFontNames = pSwXRules->GetBulletFontNames();
    1844             : 
    1845           0 :                     SwNumRule aSetRule(*pSwXRules->GetNumRule());
    1846           0 :                     const SwCharFmts* pFmts = pDoc->GetCharFmts();
    1847           0 :                     sal_uInt16 nChCount = pFmts->size();
    1848           0 :                     for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
    1849             :                     {
    1850             : 
    1851           0 :                         const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
    1852           0 :                         if(pFmt)
    1853             :                         {
    1854           0 :                             SwNumFmt aFmt(*pFmt);
    1855           0 :                             if (!pCharStyleNames[i].isEmpty() &&
    1856           0 :                                 !SwXNumberingRules::isInvalidStyle(pCharStyleNames[i]) &&
    1857           0 :                                 (!pFmt->GetCharFmt() || pFmt->GetCharFmt()->GetName() != pCharStyleNames[i]) )
    1858             :                             {
    1859             : 
    1860           0 :                                 SwCharFmt* pCharFmt = 0;
    1861           0 :                                 for(sal_uInt16 j = 0; j< nChCount; j++)
    1862             :                                 {
    1863           0 :                                     SwCharFmt* pTmp = (*pFmts)[j];
    1864           0 :                                     if(pTmp->GetName() == pCharStyleNames[i])
    1865             :                                     {
    1866           0 :                                         pCharFmt = pTmp;
    1867           0 :                                         break;
    1868             :                                     }
    1869             :                                 }
    1870           0 :                                 if(!pCharFmt)
    1871             :                                 {
    1872             : 
    1873             :                                     SfxStyleSheetBase* pBase;
    1874           0 :                                     pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
    1875           0 :                                     if(!pBase)
    1876           0 :                                         pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
    1877           0 :                                     pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
    1878             : 
    1879             :                                 }
    1880             : 
    1881           0 :                                 aFmt.SetCharFmt( pCharFmt );
    1882             :                             }
    1883             :                             //jetzt nochmal fuer Fonts
    1884           0 :                             if (!pBulletFontNames[i].isEmpty() &&
    1885           0 :                                 !SwXNumberingRules::isInvalidStyle(pBulletFontNames[i]) &&
    1886           0 :                                 (!pFmt->GetBulletFont() || pFmt->GetBulletFont()->GetName() != pBulletFontNames[i]) )
    1887             :                             {
    1888             :                                 const SvxFontListItem* pFontListItem =
    1889           0 :                                         (const SvxFontListItem* )pDoc->GetDocShell()
    1890           0 :                                                             ->GetItem( SID_ATTR_CHAR_FONTLIST );
    1891           0 :                                 const FontList*  pList = pFontListItem->GetFontList();
    1892             :                                 FontInfo aInfo = pList->Get(
    1893           0 :                                     pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
    1894           0 :                                 Font aFont(aInfo);
    1895           0 :                                 aFmt.SetBulletFont(&aFont);
    1896             :                             }
    1897           0 :                             aSetRule.Set( i, &aFmt );
    1898             :                         }
    1899             :                     }
    1900           0 :                     rBase.mxNewBase->SetNumRule(aSetRule);
    1901           0 :                 }
    1902             :             }
    1903             :             else
    1904           0 :                 throw lang::IllegalArgumentException();
    1905             : 
    1906           0 :             bDone = true;
    1907           0 :             break;
    1908             :         }
    1909             :         case RES_PARATR_OUTLINELEVEL:
    1910             :         {
    1911           0 :             sal_Int16 nLevel = 0;
    1912           0 :             aValue >>= nLevel;
    1913           0 :             if( 0 <= nLevel && nLevel <= MAXLEVEL)
    1914           0 :                 rBase.mxNewBase->GetCollection()->SetAttrOutlineLevel( nLevel );
    1915             : 
    1916           0 :             bDone = true;
    1917           0 :             break;
    1918             :         }
    1919             :         case FN_UNO_FOLLOW_STYLE:
    1920             :         {
    1921           0 :             OUString sTmp;
    1922           0 :             aValue >>= sTmp;
    1923           0 :             OUString aString;
    1924           0 :             SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true ) ;
    1925           0 :             rBase.mxNewBase->SetFollow( aString );
    1926             : 
    1927           0 :             bDone = true;
    1928           0 :             break;
    1929             :         }
    1930             :         case RES_PAGEDESC :
    1931             :         {
    1932             :             // Sonderbehandlung RES_PAGEDESC
    1933           0 :             if(aValue.getValueType() != ::getCppuType((const OUString*)0))
    1934           0 :                 throw lang::IllegalArgumentException();
    1935           0 :             SfxItemSet& rStyleSet = rBase.GetItemSet();
    1936             : 
    1937           0 :             SwFmtPageDesc* pNewDesc = 0;
    1938             :             const SfxPoolItem* pItem;
    1939           0 :             if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
    1940             :             {
    1941           0 :                 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
    1942             :             }
    1943           0 :             if(!pNewDesc)
    1944           0 :                 pNewDesc = new SwFmtPageDesc();
    1945           0 :             OUString uDescName;
    1946           0 :             aValue >>= uDescName;
    1947           0 :             OUString sDescName;
    1948           0 :             SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
    1949           0 :             if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
    1950             :             {
    1951           0 :                 sal_Bool bPut = sal_False;
    1952           0 :                 if (!sDescName.isEmpty())
    1953             :                 {
    1954           0 :                     SwPageDesc* pPageDesc = SwPageDesc::GetByName(*pDoc, sDescName);
    1955           0 :                     if(pPageDesc)
    1956             :                     {
    1957           0 :                         pNewDesc->RegisterToPageDesc( *pPageDesc );
    1958           0 :                         bPut = sal_True;
    1959             :                     }
    1960             :                     else
    1961             :                     {
    1962           0 :                         throw lang::IllegalArgumentException();
    1963             :                     }
    1964             :                 }
    1965           0 :                 if(!bPut)
    1966             :                 {
    1967           0 :                     rStyleSet.ClearItem(RES_BREAK);
    1968           0 :                     rStyleSet.Put(SwFmtPageDesc());
    1969             :                 }
    1970             :                 else
    1971           0 :                     rStyleSet.Put(*pNewDesc);
    1972             : 
    1973           0 :                 delete pNewDesc;
    1974           0 :                 bDone = true;
    1975             :             }
    1976             : 
    1977           0 :             break;
    1978             :         }
    1979             :         case FN_UNO_IS_AUTO_UPDATE:
    1980             :         {
    1981           0 :             sal_Bool bAuto = *(sal_Bool*)aValue.getValue();
    1982           0 :             if(SFX_STYLE_FAMILY_PARA == eFamily)
    1983           0 :                 rBase.mxNewBase->GetCollection()->SetAutoUpdateFmt(bAuto);
    1984           0 :             else if(SFX_STYLE_FAMILY_FRAME == eFamily)
    1985           0 :                 rBase.mxNewBase->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
    1986             : 
    1987           0 :             bDone = true;
    1988           0 :             break;
    1989             :         }
    1990             :         case FN_UNO_PARA_STYLE_CONDITIONS:
    1991             :         {
    1992           0 :             uno::Sequence< beans::NamedValue > aSeq;
    1993           0 :             if (!(aValue >>= aSeq))
    1994           0 :                 throw lang::IllegalArgumentException();
    1995             : 
    1996             :             OSL_ENSURE(COND_COMMAND_COUNT == 28,
    1997             :                     "invalid size of comman count?");
    1998           0 :             const beans::NamedValue *pSeq = aSeq.getConstArray();
    1999           0 :             sal_Int32 nLen = aSeq.getLength();
    2000             : 
    2001           0 :             sal_Bool bFailed = sal_False;
    2002           0 :             SwCondCollItem aCondItem;
    2003           0 :             for(sal_uInt16 i = 0; i < nLen; i++)
    2004             :             {
    2005           0 :                 OUString aTmp;
    2006           0 :                 if ((pSeq[i].Value >>= aTmp))
    2007             :                 {
    2008             :                     // get UI style name from programmatic style name
    2009           0 :                     OUString aStyleName;
    2010             :                     SwStyleNameMapper::FillUIName(aTmp, aStyleName,
    2011           0 :                             lcl_GetSwEnumFromSfxEnum(eFamily), true);
    2012             : 
    2013             :                     // check for correct context and style name
    2014             : 
    2015           0 :                     sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name );
    2016             : 
    2017           0 :                     pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
    2018           0 :                     sal_Bool bStyleFound = sal_False;
    2019           0 :                     const SfxStyleSheetBase* pBase = pBasePool->First();
    2020           0 :                     while (pBase && !bStyleFound)
    2021             :                     {
    2022           0 :                         if(pBase->GetName() == aStyleName)
    2023           0 :                             bStyleFound = sal_True;
    2024           0 :                         pBase = pBasePool->Next();
    2025             :                     }
    2026             : 
    2027           0 :                     if (nIdx == -1 || !bStyleFound)
    2028             :                     {
    2029           0 :                         bFailed = sal_True;
    2030           0 :                         break;
    2031             :                     }
    2032             : 
    2033           0 :                     aCondItem.SetStyle(&aStyleName, nIdx);
    2034             :                 }
    2035             :                 else
    2036           0 :                     bFailed = sal_True;
    2037           0 :             }
    2038           0 :             if (bFailed)
    2039           0 :                 throw lang::IllegalArgumentException();
    2040           0 :             rBase.GetItemSet().Put( aCondItem );
    2041           0 :             bDone = true;
    2042           0 :             break;
    2043             :         }
    2044             :         case FN_UNO_CATEGORY:
    2045             :         {
    2046           0 :             if(!rBase.mxNewBase->IsUserDefined())
    2047           0 :                 throw lang::IllegalArgumentException();
    2048           0 :             short nSet = 0;
    2049           0 :             aValue >>= nSet;
    2050             : 
    2051             :             sal_uInt16 nId;
    2052           0 :             switch( nSet )
    2053             :             {
    2054             :                 case style::ParagraphStyleCategory::TEXT:
    2055           0 :                     nId = SWSTYLEBIT_TEXT;
    2056           0 :                     break;
    2057             :                 case style::ParagraphStyleCategory::CHAPTER:
    2058           0 :                     nId = SWSTYLEBIT_CHAPTER;
    2059           0 :                     break;
    2060             :                 case style::ParagraphStyleCategory::LIST:
    2061           0 :                     nId = SWSTYLEBIT_LIST;
    2062           0 :                     break;
    2063             :                 case style::ParagraphStyleCategory::INDEX:
    2064           0 :                     nId = SWSTYLEBIT_IDX;
    2065           0 :                     break;
    2066             :                 case style::ParagraphStyleCategory::EXTRA:
    2067           0 :                     nId = SWSTYLEBIT_EXTRA;
    2068           0 :                     break;
    2069             :                 case style::ParagraphStyleCategory::HTML:
    2070           0 :                     nId = SWSTYLEBIT_HTML;
    2071           0 :                     break;
    2072           0 :                 default: throw lang::IllegalArgumentException();
    2073             :             }
    2074             : 
    2075           0 :             rBase.mxNewBase->SetMask( nId|SFXSTYLEBIT_USERDEF );
    2076           0 :             bDone = true;
    2077           0 :             break;
    2078             :         }
    2079             :         case SID_SWREGISTER_COLLECTION:
    2080             :         {
    2081           0 :             OUString sName;
    2082           0 :             aValue >>= sName;
    2083           0 :             SwRegisterItem aReg( !sName.isEmpty() );
    2084           0 :             aReg.SetWhich(SID_SWREGISTER_MODE);
    2085           0 :             rBase.GetItemSet().Put(aReg);
    2086           0 :             OUString aString;
    2087           0 :             SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true);
    2088             : 
    2089           0 :             rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
    2090           0 :             bDone = true;
    2091           0 :             break;
    2092             :         }
    2093             :         case RES_TXTATR_CJK_RUBY:
    2094             :         {
    2095           0 :             if(MID_RUBY_CHARSTYLE == nMemberId )
    2096             :             {
    2097           0 :                 OUString sTmp;
    2098           0 :                 if(aValue >>= sTmp)
    2099             :                 {
    2100           0 :                     SfxItemSet& rStyleSet = rBase.GetItemSet();
    2101           0 :                     SwFmtRuby* pRuby = 0;
    2102             :                     const SfxPoolItem* pItem;
    2103           0 :                     if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, true, &pItem ) )
    2104           0 :                         pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
    2105           0 :                     if(!pRuby)
    2106           0 :                         pRuby = new SwFmtRuby(OUString());
    2107           0 :                     OUString sStyle;
    2108           0 :                     SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
    2109           0 :                     pRuby->SetCharFmtName( sTmp );
    2110           0 :                     pRuby->SetCharFmtId( 0 );
    2111           0 :                     if(!sTmp.isEmpty())
    2112             :                     {
    2113           0 :                         sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
    2114           0 :                         pRuby->SetCharFmtId(nId);
    2115             :                     }
    2116           0 :                     rStyleSet.Put(*pRuby);
    2117           0 :                     delete pRuby;
    2118             :                 }
    2119             :                 else
    2120           0 :                     throw lang::IllegalArgumentException();
    2121             :             }
    2122           0 :             break;
    2123             :         }
    2124             :         case RES_PARATR_DROP:
    2125             :         {
    2126           0 :             if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId)
    2127             :             {
    2128           0 :                 if(aValue.getValueType() == ::getCppuType((const OUString*)0))
    2129             :                 {
    2130           0 :                     SfxItemSet& rStyleSet = rBase.GetItemSet();
    2131             : 
    2132           0 :                     SwFmtDrop* pDrop = 0;
    2133             :                     const SfxPoolItem* pItem;
    2134           0 :                     if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, true, &pItem ) )
    2135           0 :                         pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
    2136           0 :                     if(!pDrop)
    2137           0 :                         pDrop = new SwFmtDrop();
    2138           0 :                     OUString uStyle;
    2139           0 :                     aValue >>= uStyle;
    2140           0 :                     OUString sStyle;
    2141           0 :                     SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
    2142             :                     SwDocStyleSheet* pStyle =
    2143           0 :                         (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
    2144           0 :                     if(pStyle)
    2145           0 :                         pDrop->SetCharFmt(pStyle->GetCharFmt());
    2146             :                     else
    2147           0 :                         throw lang::IllegalArgumentException();
    2148           0 :                     rStyleSet.Put(*pDrop);
    2149           0 :                     delete pDrop;
    2150             :                 }
    2151             :                 else
    2152           0 :                     throw lang::IllegalArgumentException();
    2153             : 
    2154           0 :                 bDone = true;
    2155             :             }
    2156           0 :             break;
    2157             :         }
    2158             :         default:
    2159             :         {
    2160             :             // nothing to do
    2161           0 :             break;
    2162             :         }
    2163             :     }
    2164             : 
    2165           0 :     if(!bDone)
    2166             :     {
    2167             :         // default ItemSet handling
    2168           0 :         SfxItemSet& rStyleSet = rBase.GetItemSet();
    2169           0 :         SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
    2170           0 :         aSet.SetParent(&rStyleSet);
    2171           0 :         rPropSet.setPropertyValue(rEntry, aValue, aSet);
    2172           0 :         rStyleSet.Put(aSet);
    2173             : 
    2174             :         // --> OD 2006-10-18 #i70223#
    2175           0 :         if ( SFX_STYLE_FAMILY_PARA == eFamily &&
    2176           0 :                 rEntry.nWID == RES_PARATR_NUMRULE &&
    2177           0 :                 rBase.mxNewBase.is() && rBase.mxNewBase->GetCollection() &&
    2178             :                 //rBase.mxNewBase->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei
    2179           0 :                 rBase.mxNewBase->GetCollection()->IsAssignedToListLevelOfOutlineStyle() )       ////<-end,add by zhaojianwei
    2180             :         {
    2181           0 :             OUString sNewNumberingRuleName;
    2182           0 :             aValue >>= sNewNumberingRuleName;
    2183           0 :             OUString sTmp( sNewNumberingRuleName );
    2184           0 :             if ( sNewNumberingRuleName.getLength() == 0 || sTmp != pDoc->GetOutlineNumRule()->GetName() )
    2185             :             {
    2186           0 :                 rBase.mxNewBase->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
    2187           0 :             }
    2188           0 :         }
    2189           0 :     }
    2190           0 : }
    2191             : 
    2192           0 : void SAL_CALL SwXStyle::SetPropertyValues_Impl(
    2193             :     const uno::Sequence< OUString >& rPropertyNames,
    2194             :     const uno::Sequence< uno::Any >& rValues )
    2195             :     throw (beans::UnknownPropertyException, beans::PropertyVetoException,
    2196             :            lang::IllegalArgumentException, lang::WrappedTargetException,
    2197             :            uno::RuntimeException, std::exception)
    2198             : {
    2199           0 :     if ( !m_pDoc )
    2200           0 :         throw uno::RuntimeException();
    2201           0 :     sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
    2202           0 :     switch(eFamily)
    2203             :     {
    2204           0 :         case SFX_STYLE_FAMILY_PARA  : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
    2205           0 :         case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
    2206           0 :         case SFX_STYLE_FAMILY_PAGE  : nPropSetId = PROPERTY_MAP_PAGE_STYLE  ;break;
    2207           0 :         case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE   ;break;
    2208             :         default:
    2209             :             ;
    2210             :     }
    2211           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    2212           0 :     const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
    2213             : 
    2214           0 :     if(rPropertyNames.getLength() != rValues.getLength())
    2215           0 :         throw lang::IllegalArgumentException();
    2216             : 
    2217           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    2218           0 :     const uno::Any* pValues = rValues.getConstArray();
    2219             : 
    2220           0 :     SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName);
    2221           0 :     if(pBasePool)
    2222             :     {
    2223           0 :         sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
    2224           0 :         pBasePool->SetSearchMask(eFamily);
    2225           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    2226           0 :         pBasePool->SetSearchMask(eFamily, nSaveMask );
    2227             :         OSL_ENSURE(pBase, "where is the style?" );
    2228           0 :         if(pBase)
    2229           0 :             aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
    2230             :         else
    2231           0 :             throw uno::RuntimeException();
    2232             :     }
    2233             : 
    2234           0 :     for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
    2235             :     {
    2236           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]);
    2237             : 
    2238           0 :         if(!pEntry ||
    2239           0 :            (!bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS))
    2240           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2241           0 :         if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    2242           0 :             throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2243           0 :         if(aBaseImpl.mxNewBase.is())
    2244             :         {
    2245           0 :             lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
    2246           0 :                                  pBasePool, m_pDoc, eFamily);
    2247             :         }
    2248           0 :         else if(bIsDescriptor)
    2249             :         {
    2250           0 :             if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
    2251           0 :                 throw lang::IllegalArgumentException();
    2252             :         }
    2253             :         else
    2254           0 :             throw uno::RuntimeException();
    2255             :     }
    2256           0 :     if(aBaseImpl.HasItemSet())
    2257           0 :         aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
    2258           0 : }
    2259             : 
    2260           0 : void SwXStyle::setPropertyValues(
    2261             :     const uno::Sequence< OUString >& rPropertyNames,
    2262             :     const uno::Sequence< uno::Any >& rValues )
    2263             :         throw(beans::PropertyVetoException, lang::IllegalArgumentException,
    2264             :                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    2265             : {
    2266           0 :     SolarMutexGuard aGuard;
    2267             : 
    2268             :     // workaround for bad designed API
    2269             :     try
    2270             :     {
    2271           0 :         SetPropertyValues_Impl( rPropertyNames, rValues );
    2272             :     }
    2273           0 :     catch (const beans::UnknownPropertyException &rException)
    2274             :     {
    2275             :         // wrap the original (here not allowed) exception in
    2276             :         // a lang::WrappedTargetException that gets thrown instead.
    2277           0 :         lang::WrappedTargetException aWExc;
    2278           0 :         aWExc.TargetException <<= rException;
    2279           0 :         throw aWExc;
    2280           0 :     }
    2281           0 : }
    2282             : 
    2283           0 : static uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
    2284             :                         const SfxItemPropertySet& rPropSet,
    2285             :                         SwStyleBase_Impl& rBase,
    2286             :                         SfxStyleSheetBase* pBase,
    2287             :                         SfxStyleFamily eFamily,
    2288             :                         SwDoc *pDoc) throw(uno::RuntimeException)
    2289             : {
    2290           0 :     uno::Any aRet;
    2291             : 
    2292           0 :     if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
    2293             :     {
    2294           0 :         sal_Bool bPhys = pBase != 0;
    2295           0 :         if(pBase)
    2296             :         {
    2297           0 :             bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
    2298             :             // The standard character format is not existing physically
    2299           0 :             if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
    2300           0 :                 ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
    2301           0 :                 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
    2302           0 :                 bPhys = sal_False;
    2303             :         }
    2304           0 :         aRet.setValue(&bPhys, ::getBooleanCppuType());
    2305             :     }
    2306           0 :     else if (FN_UNO_HIDDEN == rEntry.nWID)
    2307             :     {
    2308           0 :         sal_Bool bHidden = sal_False;
    2309           0 :         if(pBase)
    2310             :         {
    2311           0 :             rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
    2312           0 :             bHidden = xBase->IsHidden();
    2313             :         }
    2314           0 :         aRet.setValue(&bHidden, ::getBooleanCppuType());
    2315             :     }
    2316           0 :     else if (FN_UNO_STYLE_INTEROP_GRAB_BAG == rEntry.nWID)
    2317             :     {
    2318           0 :         if (pBase)
    2319             :         {
    2320           0 :             rtl::Reference<SwDocStyleSheet> xBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
    2321           0 :             xBase->GetGrabBagItem(aRet);
    2322             :         }
    2323             :     }
    2324           0 :     else if(pBase)
    2325             :     {
    2326           0 :         if(!rBase.mxNewBase.is())
    2327             :         {
    2328           0 :             rBase.mxNewBase = new SwDocStyleSheet( *(SwDocStyleSheet*)pBase );
    2329             :         }
    2330             : 
    2331             :         //UUUU
    2332           0 :         const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
    2333             : 
    2334             :         //UUUU adapted switch logic to a more readable state; removed goto's and made
    2335             :         // execution of standard setting of proerty in ItemSet dependent of this variable
    2336           0 :         bool bDone(false);
    2337             : 
    2338           0 :         switch(rEntry.nWID)
    2339             :         {
    2340             :             case RES_PAPER_BIN:
    2341             :             {
    2342           0 :                 SfxItemSet& rSet = rBase.GetItemSet();
    2343           0 :                 rPropSet.getPropertyValue(rEntry, rSet, aRet);
    2344           0 :                 sal_Int8 nBin = 0;
    2345           0 :                 aRet >>= nBin;
    2346           0 :                 if ( nBin == -1 )
    2347           0 :                     aRet <<= OUString( "[From printer settings]" );
    2348             :                 else
    2349             :                 {
    2350           0 :                     SfxPrinter *pPrinter = pDoc->getPrinter( false );
    2351           0 :                     OUString sTmp;
    2352           0 :                     if (pPrinter )
    2353           0 :                         sTmp = pPrinter->GetPaperBinName ( nBin );
    2354           0 :                     aRet <<= sTmp;
    2355             :                 }
    2356             : 
    2357           0 :                 bDone = true;
    2358           0 :                 break;
    2359             :             }
    2360             :             case  FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
    2361             :             {
    2362           0 :                 const SwNumRule* pRule = rBase.mxNewBase->GetNumRule();
    2363             :                 OSL_ENSURE(pRule, "Wo ist die NumRule?");
    2364           0 :                 uno::Reference< container::XIndexReplace >  xRules = new SwXNumberingRules(*pRule, pDoc);
    2365             : 
    2366           0 :                 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
    2367           0 :                 bDone = true;
    2368           0 :                 break;
    2369             :             }
    2370             :             break;
    2371             :             case RES_PARATR_OUTLINELEVEL:
    2372             :             {
    2373             :                 OSL_ENSURE( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
    2374           0 :                 int nLevel = rBase.mxNewBase->GetCollection()->GetAttrOutlineLevel();
    2375           0 :                 aRet <<= static_cast<sal_Int16>( nLevel );
    2376           0 :                 bDone = true;
    2377           0 :                 break;
    2378             :             }
    2379             :             case FN_UNO_FOLLOW_STYLE:
    2380             :             {
    2381           0 :                 OUString aString;
    2382           0 :                 SwStyleNameMapper::FillProgName(rBase.mxNewBase->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
    2383           0 :                 aRet <<= aString;
    2384           0 :                 bDone = true;
    2385           0 :                 break;
    2386             :             }
    2387             :             case RES_PAGEDESC :
    2388             :             {
    2389             :                 // Sonderbehandlung RES_PAGEDESC
    2390             :                 const SfxPoolItem* pItem;
    2391           0 :                 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, true, &pItem ) )
    2392             :                 {
    2393           0 :                     const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
    2394           0 :                     if(pDesc)
    2395             :                     {
    2396           0 :                         OUString aString;
    2397           0 :                         SwStyleNameMapper::FillProgName(pDesc->GetName(), aString,  nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
    2398           0 :                         aRet <<= aString;
    2399             :                     }
    2400             : 
    2401           0 :                     bDone = true;
    2402             :                 }
    2403             : 
    2404           0 :                 break;
    2405             :             }
    2406             :             case FN_UNO_IS_AUTO_UPDATE:
    2407             :             {
    2408           0 :                 sal_Bool bAuto = sal_False;
    2409           0 :                 if(SFX_STYLE_FAMILY_PARA == eFamily)
    2410           0 :                     bAuto = rBase.mxNewBase->GetCollection()->IsAutoUpdateFmt();
    2411           0 :                 else if(SFX_STYLE_FAMILY_FRAME == eFamily)
    2412           0 :                     bAuto = rBase.mxNewBase->GetFrmFmt()->IsAutoUpdateFmt();
    2413           0 :                 aRet.setValue(&bAuto, ::getBooleanCppuType());
    2414             : 
    2415           0 :                 bDone = true;
    2416           0 :                 break;
    2417             :             }
    2418             :             case FN_UNO_DISPLAY_NAME:
    2419             :             {
    2420           0 :                 OUString sName(rBase.mxNewBase->GetDisplayName());
    2421           0 :                 aRet <<= sName;
    2422             : 
    2423           0 :                 bDone = true;
    2424           0 :                 break;
    2425             :             }
    2426             :             case FN_UNO_PARA_STYLE_CONDITIONS:
    2427             :             {
    2428             :                 OSL_ENSURE(COND_COMMAND_COUNT == 28,
    2429             :                         "invalid size of comman count?");
    2430           0 :                 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
    2431           0 :                 beans::NamedValue *pSeq = aSeq.getArray();
    2432             : 
    2433           0 :                 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection();
    2434           0 :                 const CommandStruct *pCmds = SwCondCollItem::GetCmds();
    2435           0 :                 for (sal_uInt16 n = 0;  n < COND_COMMAND_COUNT;  ++n)
    2436             :                 {
    2437           0 :                     OUString aStyleName;
    2438             : 
    2439           0 :                     const SwCollCondition* pCond = 0;
    2440           0 :                     if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
    2441             :                         0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
    2442           0 :                         HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
    2443           0 :                         && pCond->GetTxtFmtColl() )
    2444             :                     {
    2445             :                         // get programmatic style name from UI style name
    2446           0 :                         aStyleName = pCond->GetTxtFmtColl()->GetName();
    2447           0 :                         SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
    2448             :                     }
    2449             : 
    2450           0 :                     pSeq[n].Name  = GetCommandContextByIndex(n);
    2451           0 :                     pSeq[n].Value <<= aStyleName;
    2452           0 :                 }
    2453           0 :                 aRet <<= aSeq;
    2454             : 
    2455           0 :                 bDone = true;
    2456           0 :                 break;
    2457             :             }
    2458             :             case FN_UNO_CATEGORY:
    2459             :             {
    2460           0 :                 sal_uInt16 nPoolId = rBase.mxNewBase->GetCollection()->GetPoolFmtId();
    2461           0 :                 short nRet = -1;
    2462             : 
    2463           0 :                 switch ( COLL_GET_RANGE_BITS & nPoolId )
    2464             :                 {
    2465             :                     case COLL_TEXT_BITS:
    2466           0 :                         nRet = style::ParagraphStyleCategory::TEXT;
    2467           0 :                         break;
    2468             :                     case COLL_DOC_BITS:
    2469           0 :                         nRet = style::ParagraphStyleCategory::CHAPTER;
    2470           0 :                         break;
    2471             :                     case COLL_LISTS_BITS:
    2472           0 :                         nRet = style::ParagraphStyleCategory::LIST;
    2473           0 :                         break;
    2474             :                     case COLL_REGISTER_BITS:
    2475           0 :                         nRet = style::ParagraphStyleCategory::INDEX;
    2476           0 :                         break;
    2477             :                     case COLL_EXTRA_BITS:
    2478           0 :                         nRet = style::ParagraphStyleCategory::EXTRA;
    2479           0 :                         break;
    2480             :                     case COLL_HTML_BITS:
    2481           0 :                         nRet = style::ParagraphStyleCategory::HTML;
    2482           0 :                         break;
    2483             :                 }
    2484             : 
    2485           0 :                 aRet <<= nRet;
    2486           0 :                 bDone = true;
    2487           0 :                 break;
    2488             :             }
    2489             :             case SID_SWREGISTER_COLLECTION:
    2490             :             {
    2491           0 :                 const SwPageDesc *pPageDesc = rBase.mxNewBase->GetPageDesc();
    2492           0 :                 const SwTxtFmtColl* pCol = 0;
    2493           0 :                 OUString aString;
    2494           0 :                 if( pPageDesc )
    2495           0 :                     pCol = pPageDesc->GetRegisterFmtColl();
    2496           0 :                 if( pCol )
    2497             :                     SwStyleNameMapper::FillProgName(
    2498           0 :                                 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true );
    2499           0 :                 aRet <<= aString;
    2500           0 :                 bDone = true;
    2501           0 :                 break;
    2502             :             }
    2503             :             case RES_BACKGROUND:
    2504             :             {
    2505           0 :                 if (SFX_STYLE_FAMILY_FRAME == eFamily)
    2506             :                 {
    2507             :                     //UUUU
    2508           0 :                     const SfxItemSet& rSet = rBase.GetItemSet();
    2509           0 :                     const SvxBrushItem aOriginalBrushItem(sw::getSvxBrushItemFromSourceSet(rSet));
    2510             : 
    2511           0 :                     if(!aOriginalBrushItem.QueryValue(aRet, nMemberId))
    2512             :                     {
    2513             :                         OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
    2514             :                     }
    2515             : 
    2516           0 :                     bDone = true;
    2517             :                 }
    2518           0 :                 break;
    2519             :             }
    2520             :             case OWN_ATTR_FILLBMP_MODE:
    2521             :             {
    2522             :                 //UUUU
    2523           0 :                 const SfxItemSet& rSet = rBase.GetItemSet();
    2524           0 :                 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
    2525           0 :                 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
    2526             : 
    2527           0 :                 if( pTileItem && pTileItem->GetValue() )
    2528             :                 {
    2529           0 :                     aRet <<= drawing::BitmapMode_REPEAT;
    2530             :                 }
    2531           0 :                 else if( pStretchItem && pStretchItem->GetValue() )
    2532             :                 {
    2533           0 :                     aRet <<= drawing::BitmapMode_STRETCH;
    2534             :                 }
    2535             :                 else
    2536             :                 {
    2537           0 :                     aRet <<= drawing::BitmapMode_NO_REPEAT;
    2538             :                 }
    2539             : 
    2540           0 :                 bDone = true;
    2541           0 :                 break;
    2542             :             }
    2543             :             default:
    2544             :             {
    2545             :                 // nothing to do as default
    2546           0 :                 break;
    2547             :             }
    2548             :         }
    2549             : 
    2550           0 :         if(!bDone)
    2551             :         {
    2552           0 :             SfxItemSet& rSet = rBase.GetItemSet();
    2553           0 :             rPropSet.getPropertyValue(rEntry, rSet, aRet);
    2554             : 
    2555             :             //UUUU
    2556           0 :             if(rEntry.aType == ::getCppuType((const sal_Int16*)0) && rEntry.aType != aRet.getValueType())
    2557             :             {
    2558             :                 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
    2559           0 :                 sal_Int32 nValue = 0;
    2560           0 :                 if (aRet >>= nValue)
    2561           0 :                     aRet <<= (sal_Int16)nValue;
    2562             :             }
    2563             : 
    2564             :             //UUUU check for needed metric translation
    2565           0 :             if(rEntry.nMemberId & SFX_METRIC_ITEM)
    2566             :             {
    2567           0 :                 bool bDoIt(true);
    2568             : 
    2569           0 :                 if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
    2570             :                 {
    2571             :                     // exception: If these ItemTypes are used, do not convert when these are negative
    2572             :                     // since this means they are intended as percent values
    2573           0 :                     sal_Int32 nValue = 0;
    2574             : 
    2575           0 :                     if(aRet >>= nValue)
    2576             :                     {
    2577           0 :                         bDoIt = nValue > 0;
    2578             :                     }
    2579             :                 }
    2580             : 
    2581           0 :                 if(bDoIt && pDoc)
    2582             :                 {
    2583           0 :                     const SfxItemPool& rPool = pDoc->GetAttrPool();
    2584           0 :                     const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
    2585             : 
    2586           0 :                     if(eMapUnit != SFX_MAPUNIT_100TH_MM)
    2587             :                     {
    2588           0 :                         SvxUnoConvertToMM(eMapUnit, aRet);
    2589             :                     }
    2590             :                 }
    2591             :             }
    2592             :         }
    2593             :     }
    2594             :     else
    2595             :     {
    2596           0 :         throw uno::RuntimeException();
    2597             :     }
    2598             : 
    2599           0 :     return aRet;
    2600             : }
    2601             : 
    2602           0 : uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
    2603             :         const uno::Sequence< OUString > & rPropertyNames )
    2604             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
    2605             : {
    2606           0 :     if ( !m_pDoc )
    2607           0 :         throw uno::RuntimeException();
    2608           0 :     sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
    2609           0 :     switch(eFamily)
    2610             :     {
    2611           0 :         case SFX_STYLE_FAMILY_PARA  : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
    2612           0 :         case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
    2613           0 :         case SFX_STYLE_FAMILY_PAGE  : nPropSetId = PROPERTY_MAP_PAGE_STYLE  ;break;
    2614           0 :         case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE   ;break;
    2615             :         default:
    2616             :             ;
    2617             :     }
    2618           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    2619           0 :     const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
    2620             : 
    2621           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    2622           0 :     uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
    2623           0 :     uno::Any* pRet = aRet.getArray();
    2624           0 :     SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName);
    2625           0 :     SfxStyleSheetBase* pBase = 0;
    2626           0 :     for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
    2627             :     {
    2628           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]);
    2629           0 :         if(!pEntry ||
    2630           0 :            (!bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS))
    2631           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2632           0 :         if(pBasePool)
    2633             :         {
    2634           0 :             if(!pBase)
    2635             :             {
    2636           0 :                 sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
    2637           0 :                 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
    2638           0 :                 pBase = pBasePool->Find(m_sStyleName);
    2639           0 :                 pBasePool->SetSearchMask(eFamily, nSaveMask );
    2640             :             }
    2641           0 :             pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() );
    2642             :         }
    2643           0 :         else if(bIsDescriptor)
    2644             :         {
    2645           0 :             uno::Any *pAny = 0;
    2646           0 :             pPropImpl->GetProperty ( pNames[nProp], pAny );
    2647           0 :             if( !pAny )
    2648             :             {
    2649           0 :                 bool bExcept = false;
    2650           0 :                 switch( eFamily )
    2651             :                 {
    2652             :                     case SFX_STYLE_FAMILY_PSEUDO:
    2653           0 :                         bExcept = true;
    2654           0 :                     break;
    2655             :                     case SFX_STYLE_FAMILY_PARA:
    2656             :                     case SFX_STYLE_FAMILY_PAGE:
    2657           0 :                         pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
    2658           0 :                     break;
    2659             :                     case SFX_STYLE_FAMILY_CHAR:
    2660             :                     case SFX_STYLE_FAMILY_FRAME :
    2661             :                     {
    2662           0 :                         if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END )
    2663             :                         {
    2664             :                             SwFmt * pFmt;
    2665           0 :                             if ( eFamily == SFX_STYLE_FAMILY_CHAR )
    2666           0 :                                 pFmt = m_pDoc->GetDfltCharFmt();
    2667             :                             else
    2668           0 :                                 pFmt = m_pDoc->GetDfltFrmFmt();
    2669           0 :                             const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool();
    2670           0 :                             const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID );
    2671           0 :                             rItem.QueryValue ( pRet[nProp], pEntry->nMemberId );
    2672             :                         }
    2673             :                         else
    2674           0 :                             bExcept = true;
    2675             :                     }
    2676           0 :                     break;
    2677             : 
    2678             :                     default:
    2679             :                         ;
    2680             :                 }
    2681           0 :                 if (bExcept )
    2682             :                 {
    2683           0 :                     uno::RuntimeException aExcept;
    2684           0 :                     aExcept.Message = "No default value for: " + pNames[nProp];
    2685           0 :                     throw aExcept;
    2686             :                 }
    2687             :             }
    2688             :             else
    2689           0 :                 pRet [ nProp ] = *pAny;
    2690             :         }
    2691             :         else
    2692           0 :             throw uno::RuntimeException();
    2693             :     }
    2694           0 :     return aRet;
    2695             : }
    2696             : 
    2697           0 : uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
    2698             :     const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException, std::exception)
    2699             : {
    2700           0 :     SolarMutexGuard aGuard;
    2701           0 :     uno::Sequence< uno::Any > aValues;
    2702             : 
    2703             :     // workaround for bad designed API
    2704             :     try
    2705             :     {
    2706           0 :         aValues = GetPropertyValues_Impl( rPropertyNames );
    2707             :     }
    2708           0 :     catch (beans::UnknownPropertyException &)
    2709             :     {
    2710           0 :         throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
    2711             :     }
    2712           0 :     catch (lang::WrappedTargetException &)
    2713             :     {
    2714           0 :         throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
    2715             :     }
    2716             : 
    2717           0 :     return aValues;
    2718             : }
    2719             : 
    2720           0 : void SwXStyle::addPropertiesChangeListener(
    2721             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
    2722             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    2723             :         throw(uno::RuntimeException, std::exception)
    2724             : {
    2725           0 : }
    2726             : 
    2727           0 : void SwXStyle::removePropertiesChangeListener(
    2728             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    2729             :         throw(uno::RuntimeException, std::exception)
    2730             : {
    2731           0 : }
    2732             : 
    2733           0 : void SwXStyle::firePropertiesChangeEvent(
    2734             :     const uno::Sequence< OUString >& /*aPropertyNames*/,
    2735             :     const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    2736             :         throw(uno::RuntimeException, std::exception)
    2737             : {
    2738           0 : }
    2739             : 
    2740           0 : void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
    2741             :     throw( beans::UnknownPropertyException,
    2742             :         beans::PropertyVetoException,
    2743             :         lang::IllegalArgumentException,
    2744             :         lang::WrappedTargetException,
    2745             :         uno::RuntimeException, std::exception)
    2746             : {
    2747           0 :     SolarMutexGuard aGuard;
    2748           0 :     const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
    2749           0 :     const uno::Sequence<uno::Any> aValues(&rValue, 1);
    2750           0 :     SetPropertyValues_Impl( aProperties, aValues );
    2751           0 : }
    2752             : 
    2753           0 : uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName)
    2754             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    2755             : {
    2756           0 :     SolarMutexGuard aGuard;
    2757           0 :     const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
    2758           0 :     return GetPropertyValues_Impl(aProperties).getConstArray()[0];
    2759             : 
    2760             : }
    2761             : 
    2762           0 : void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/,
    2763             :     const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
    2764             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    2765             : {
    2766             :     OSL_FAIL("not implemented");
    2767           0 : }
    2768             : 
    2769           0 : void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/,
    2770             :     const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
    2771             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    2772             : {
    2773             :     OSL_FAIL("not implemented");
    2774           0 : }
    2775             : 
    2776           0 : void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/,
    2777             :     const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
    2778             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    2779             : {
    2780             :     OSL_FAIL("not implemented");
    2781           0 : }
    2782             : 
    2783           0 : void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/,
    2784             :     const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
    2785             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    2786             : {
    2787             :     OSL_FAIL("not implemented");
    2788           0 : }
    2789             : 
    2790           0 : beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName)
    2791             :         throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
    2792             : {
    2793           0 :     SolarMutexGuard aGuard;
    2794             : 
    2795           0 :     uno::Sequence< OUString > aNames(1);
    2796           0 :     OUString* pNames = aNames.getArray();
    2797           0 :     pNames[0] = rPropertyName;
    2798           0 :     uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
    2799           0 :     return aStates.getConstArray()[0];
    2800             : }
    2801             : 
    2802           0 : uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
    2803             :     const uno::Sequence< OUString >& rPropertyNames)
    2804             :         throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
    2805             : {
    2806           0 :     SolarMutexGuard aGuard;
    2807           0 :     uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
    2808           0 :     beans::PropertyState* pStates = aRet.getArray();
    2809           0 :     if(pBasePool)
    2810             :     {
    2811           0 :         pBasePool->SetSearchMask(eFamily );
    2812           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    2813             :         OSL_ENSURE(pBase, "where is the style?" );
    2814             : 
    2815           0 :         if(pBase)
    2816             :         {
    2817           0 :             const OUString* pNames = rPropertyNames.getConstArray();
    2818           0 :             rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    2819           0 :             sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
    2820           0 :             switch(eFamily)
    2821             :             {
    2822           0 :                 case SFX_STYLE_FAMILY_PARA  : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
    2823           0 :                 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
    2824           0 :                 case SFX_STYLE_FAMILY_PAGE  : nPropSetId = PROPERTY_MAP_PAGE_STYLE;   break;
    2825           0 :                 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE   ;break;
    2826             :                 default:
    2827             :                     ;
    2828             :             }
    2829           0 :             const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    2830           0 :             const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
    2831             : 
    2832           0 :             SfxItemSet aSet = xStyle->GetItemSet();
    2833           0 :             for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
    2834             :             {
    2835           0 :                 const OUString sPropName = pNames[i];
    2836           0 :                 const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
    2837           0 :                 if(!pEntry)
    2838           0 :                     throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
    2839           0 :                 if( FN_UNO_NUM_RULES ==  pEntry->nWID ||
    2840           0 :                     FN_UNO_FOLLOW_STYLE == pEntry->nWID )
    2841             :                 {
    2842           0 :                     pStates[i] = beans::PropertyState_DIRECT_VALUE;
    2843             :                 }
    2844           0 :                 else if(SFX_STYLE_FAMILY_PAGE == eFamily &&
    2845           0 :                         (sPropName.startsWith("Header") || sPropName.startsWith("Footer")))
    2846             :                 {
    2847           0 :                     sal_uInt16 nResId = lcl_ConvertFNToRES(pEntry->nWID);
    2848           0 :                     sal_Bool bFooter = sPropName.startsWith("Footer");
    2849             :                     const SvxSetItem* pSetItem;
    2850           0 :                     if(SFX_ITEM_SET == aSet.GetItemState(
    2851             :                             bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
    2852           0 :                             false, (const SfxPoolItem**)&pSetItem))
    2853             :                     {
    2854           0 :                         const SfxItemSet& rSet = pSetItem->GetItemSet();
    2855           0 :                         SfxItemState eState = rSet.GetItemState(nResId, false);
    2856           0 :                         if(SFX_ITEM_SET == eState)
    2857           0 :                             pStates[i] = beans::PropertyState_DIRECT_VALUE;
    2858             :                         else
    2859           0 :                             pStates[i] = beans::PropertyState_DEFAULT_VALUE;
    2860             :                     }
    2861             :                     else
    2862           0 :                         pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
    2863             :                 }
    2864             :                 else
    2865             :                 {
    2866           0 :                     pStates[i] = pPropSet->getPropertyState(*pEntry, aSet);
    2867           0 :                     if( SFX_STYLE_FAMILY_PAGE == eFamily &&
    2868           0 :                         SID_ATTR_PAGE_SIZE == pEntry->nWID &&
    2869           0 :                         beans::PropertyState_DIRECT_VALUE == pStates[i] )
    2870             :                     {
    2871             :                         const SvxSizeItem& rSize =
    2872             :                             static_cast < const SvxSizeItem& >(
    2873           0 :                                     aSet.Get(SID_ATTR_PAGE_SIZE) );
    2874           0 :                         sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
    2875           0 :                         if( ( LONG_MAX == rSize.GetSize().Width() &&
    2876           0 :                               (MID_SIZE_WIDTH == nMemberId ||
    2877           0 :                                MID_SIZE_SIZE == nMemberId ) ) ||
    2878           0 :                             ( LONG_MAX == rSize.GetSize().Height() &&
    2879             :                               MID_SIZE_HEIGHT == nMemberId ) )
    2880             :                         {
    2881           0 :                             pStates[i] = beans::PropertyState_DEFAULT_VALUE;
    2882             :                         }
    2883             :                     }
    2884             :                 }
    2885           0 :             }
    2886             :         }
    2887             :         else
    2888           0 :             throw uno::RuntimeException();
    2889             :     }
    2890             :     else
    2891           0 :         throw uno::RuntimeException();
    2892           0 :     return aRet;
    2893             : }
    2894             : 
    2895           0 : void SwXStyle::setPropertyToDefault(const OUString& rPropertyName)
    2896             :         throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
    2897             : {
    2898           0 :     const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
    2899           0 :     setPropertiesToDefault ( aSequence );
    2900           0 : }
    2901             : 
    2902           0 : void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
    2903             :     throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    2904             : {
    2905           0 :     SolarMutexGuard aGuard;
    2906           0 :     SwFmt *pTargetFmt = 0;
    2907             : 
    2908           0 :     if(pBasePool)
    2909             :     {
    2910           0 :         pBasePool->SetSearchMask(eFamily);
    2911           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    2912             :         OSL_ENSURE(pBase, "Where is the style?");
    2913             : 
    2914           0 :         if(pBase)
    2915             :         {
    2916           0 :             rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    2917           0 :             switch(eFamily)
    2918             :             {
    2919           0 :                 case SFX_STYLE_FAMILY_CHAR: pTargetFmt = xStyle->GetCharFmt(); break;
    2920           0 :                 case SFX_STYLE_FAMILY_PARA: pTargetFmt = xStyle->GetCollection(); break;
    2921           0 :                 case SFX_STYLE_FAMILY_FRAME: pTargetFmt = xStyle->GetFrmFmt(); break;
    2922             :                 case SFX_STYLE_FAMILY_PAGE:
    2923             :                     {
    2924           0 :                         sal_uInt16 nPgDscPos = USHRT_MAX;
    2925           0 :                         SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
    2926           0 :                         if( pDesc )
    2927           0 :                             pTargetFmt = &pDesc->GetMaster();
    2928             :                     }
    2929           0 :                     break;
    2930             :                 case SFX_STYLE_FAMILY_PSEUDO:
    2931           0 :                     break;
    2932             :                 default:
    2933             :                     ;
    2934           0 :             }
    2935             :         }
    2936             :     }
    2937           0 :     sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
    2938           0 :     switch(eFamily)
    2939             :     {
    2940           0 :         case SFX_STYLE_FAMILY_PARA  : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
    2941           0 :         case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
    2942           0 :         case SFX_STYLE_FAMILY_PAGE  : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
    2943           0 :         case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
    2944             :         default:
    2945             :             ;
    2946             :     }
    2947           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    2948           0 :     const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
    2949             : 
    2950           0 :     const OUString* pNames = aPropertyNames.getConstArray();
    2951             : 
    2952           0 :     if ( pTargetFmt )
    2953             :     {
    2954           0 :         for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
    2955             :         {
    2956           0 :             const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
    2957           0 :             if( !pEntry )
    2958           0 :                 throw beans::UnknownPropertyException ( OUString( "Property is unknown: " ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2959           0 :             if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES )
    2960           0 :                 throw uno::RuntimeException ("Cannot reset: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2961           0 :             if ( pEntry->nFlags & beans::PropertyAttribute::READONLY )
    2962           0 :                 throw uno::RuntimeException("setPropertiesToDefault: property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    2963             : 
    2964           0 :             if( pEntry->nWID == RES_PARATR_OUTLINELEVEL )
    2965           0 :                 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
    2966             :             else
    2967           0 :                 pTargetFmt->ResetFmtAttr( pEntry->nWID );
    2968             :         }
    2969             :     }
    2970           0 :     else if ( bIsDescriptor )
    2971             :     {
    2972           0 :         for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
    2973           0 :             pPropImpl->ClearProperty ( pNames[ nProp ] );
    2974           0 :     }
    2975           0 : }
    2976             : 
    2977           0 : void SAL_CALL SwXStyle::setAllPropertiesToDefault(  )
    2978             :     throw (uno::RuntimeException, std::exception)
    2979             : {
    2980           0 :     SolarMutexGuard aGuard;
    2981           0 :     if(pBasePool)
    2982             :     {
    2983           0 :         pBasePool->SetSearchMask(eFamily);
    2984           0 :         SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    2985             :         OSL_ENSURE(pBase, "where is the style, you fiend!?");
    2986             : 
    2987           0 :         if(pBase)
    2988             :         {
    2989           0 :             rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    2990             : 
    2991           0 :             SwFmt *pTargetFmt = 0;
    2992           0 :             sal_uInt16 nPgDscPos = USHRT_MAX;
    2993           0 :             switch( eFamily )
    2994             :             {
    2995             :             case SFX_STYLE_FAMILY_CHAR :
    2996           0 :                 pTargetFmt = xStyle->GetCharFmt();
    2997           0 :                 break;
    2998             :             case SFX_STYLE_FAMILY_PARA :
    2999             :                 {
    3000           0 :                     pTargetFmt = xStyle->GetCollection();
    3001           0 :                     if ( xStyle->GetCollection() )
    3002           0 :                         xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
    3003             :                 }
    3004           0 :                 break;
    3005             :             case SFX_STYLE_FAMILY_FRAME:
    3006           0 :                 pTargetFmt = xStyle->GetFrmFmt();
    3007           0 :                 break;
    3008             :             case SFX_STYLE_FAMILY_PAGE:
    3009             :                 {
    3010           0 :                     SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
    3011           0 :                     if( pDesc )
    3012             :                     {
    3013           0 :                         pTargetFmt = &pDesc->GetMaster();
    3014           0 :                         pDesc->SetUseOn ( nsUseOnPage::PD_ALL );
    3015             :                     }
    3016             :                 }
    3017           0 :                 break;
    3018             :             case SFX_STYLE_FAMILY_PSEUDO:
    3019           0 :                 break;
    3020             : 
    3021             :             default:
    3022             :                 ;
    3023             :             }
    3024           0 :             if( pTargetFmt )
    3025             :             {
    3026           0 :                 if( USHRT_MAX != nPgDscPos )
    3027             :                 {
    3028           0 :                     SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
    3029           0 :                     rPageDesc.ResetAllMasterAttr();
    3030             : 
    3031           0 :                     SvxLRSpaceItem aLR(RES_LR_SPACE);
    3032           0 :                     sal_Int32 nSize = GetMetricVal ( CM_1) * 2;
    3033           0 :                     aLR.SetLeft ( nSize );
    3034           0 :                     aLR.SetLeft ( nSize );
    3035           0 :                     SvxULSpaceItem aUL( RES_UL_SPACE );
    3036           0 :                     aUL.SetUpper ( static_cast < sal_uInt16 > ( nSize ) );
    3037           0 :                     aUL.SetLower ( static_cast < sal_uInt16 > ( nSize ) );
    3038           0 :                     pTargetFmt->SetFmtAttr( aLR );
    3039           0 :                     pTargetFmt->SetFmtAttr( aUL );
    3040             : 
    3041           0 :                     SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
    3042           0 :                     SwFmtFrmSize aFrmSz( ATT_FIX_SIZE );
    3043           0 :                     if( RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId() )
    3044             :                     {
    3045           0 :                         if( m_pDoc->getPrinter( false ) )
    3046             :                         {
    3047             :                             const Size aPhysSize( SvxPaperInfo::GetPaperSize(
    3048           0 :                                         static_cast<Printer*>( m_pDoc->getPrinter( false ) )) );
    3049           0 :                             aFrmSz.SetSize( aPhysSize );
    3050             :                         }
    3051             :                         else
    3052           0 :                             aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() );
    3053             : 
    3054             :                     }
    3055             :                     else
    3056             :                     {
    3057           0 :                         aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
    3058             :                     }
    3059           0 :                     if( pStdPgDsc->GetLandscape() )
    3060             :                     {
    3061           0 :                         SwTwips nTmp = aFrmSz.GetHeight();
    3062           0 :                         aFrmSz.SetHeight( aFrmSz.GetWidth() );
    3063           0 :                         aFrmSz.SetWidth( nTmp );
    3064             :                     }
    3065           0 :                     pTargetFmt->SetFmtAttr( aFrmSz );
    3066             :                 }
    3067             :                 else
    3068           0 :                     pTargetFmt->ResetAllFmtAttr();
    3069             : 
    3070           0 :                 if( USHRT_MAX != nPgDscPos )
    3071           0 :                     m_pDoc->ChgPageDesc( nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos) );
    3072           0 :             }
    3073             : 
    3074             :         }
    3075             :         else
    3076           0 :             throw uno::RuntimeException();
    3077             :     }
    3078           0 :     else if ( bIsDescriptor )
    3079           0 :         pPropImpl->ClearAllProperties();
    3080             :     else
    3081           0 :         throw uno::RuntimeException();
    3082           0 : }
    3083             : 
    3084           0 : uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
    3085             :     throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    3086             : {
    3087           0 :     SolarMutexGuard aGuard;
    3088           0 :     sal_Int32 nCount = aPropertyNames.getLength();
    3089           0 :     uno::Sequence < uno::Any > aRet ( nCount );
    3090           0 :     if ( nCount )
    3091             :     {
    3092           0 :         if( pBasePool)
    3093             :         {
    3094           0 :             pBasePool->SetSearchMask(eFamily);
    3095           0 :             SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
    3096             :             OSL_ENSURE(pBase, "Doesn't seem to be a style!");
    3097             : 
    3098           0 :             if(pBase)
    3099             :             {
    3100           0 :                 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    3101           0 :                 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
    3102           0 :                 switch(eFamily)
    3103             :                 {
    3104           0 :                     case SFX_STYLE_FAMILY_PARA  : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
    3105           0 :                     case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
    3106           0 :                     case SFX_STYLE_FAMILY_PAGE  : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
    3107           0 :                     case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
    3108             :                     default:
    3109             :                         ;
    3110             :                 }
    3111           0 :                 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    3112           0 :                 const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
    3113             : 
    3114           0 :                 const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent();
    3115           0 :                 const OUString *pNames = aPropertyNames.getConstArray();
    3116           0 :                 uno::Any *pRet = aRet.getArray();
    3117           0 :                 for ( sal_Int32 i = 0 ; i < nCount; i++)
    3118             :                 {
    3119           0 :                     const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[i] );
    3120           0 :                     if ( !pEntry )
    3121           0 :                         throw beans::UnknownPropertyException ( OUString( "Unknown property: " ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
    3122             : 
    3123           0 :                     if (pEntry->nWID >= RES_UNKNOWNATR_END)
    3124             :                     {
    3125             :                         // these cannot be in an item set, especially not the
    3126             :                         // parent set, so the default value is void
    3127           0 :                         continue;
    3128             :                     }
    3129           0 :                     if( pParentSet )
    3130           0 :                         aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]);
    3131           0 :                     else if( pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID) )
    3132             :                     {
    3133           0 :                         const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID);
    3134           0 :                         rItem.QueryValue(pRet[i], pEntry->nMemberId);
    3135             :                     }
    3136           0 :                 }
    3137             :             }
    3138             :             else
    3139           0 :                 throw uno::RuntimeException();
    3140             :         }
    3141             :         else
    3142           0 :             throw uno::RuntimeException();
    3143             :     }
    3144           0 :     return aRet;
    3145             : }
    3146             : 
    3147           0 : uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName)
    3148             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3149             : {
    3150           0 :     const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
    3151           0 :     return getPropertyDefaults ( aSequence ).getConstArray()[0];
    3152             : }
    3153             : 
    3154           0 : void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
    3155             : {
    3156           0 :     SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
    3157           0 :     if( pHint )
    3158             :     {
    3159           0 :         if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
    3160             :         {
    3161           0 :             pBasePool = 0;
    3162           0 :             EndListening(rBC);
    3163             :         }
    3164           0 :         else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) )
    3165             :         {
    3166           0 :             ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily);
    3167           0 :             SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(m_sStyleName);
    3168           0 :             if(!pOwnBase)
    3169             :             {
    3170           0 :                 EndListening(rBC);
    3171           0 :                 Invalidate();
    3172             :             }
    3173             :         }
    3174             :     }
    3175           0 : }
    3176             : 
    3177           0 : void SwXStyle::Invalidate()
    3178             : {
    3179           0 :     m_sStyleName = OUString();
    3180           0 :     pBasePool = 0;
    3181           0 :     m_pDoc = 0;
    3182           0 :     mxStyleData.clear();
    3183           0 :     mxStyleFamily.clear();
    3184           0 : }
    3185             : 
    3186             : /******************************************************************
    3187             :  * SwXPageStyle
    3188             :  ******************************************************************/
    3189           0 : SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
    3190             :         SwDocShell* pDocSh, SfxStyleFamily eFam,
    3191             :         const OUString& rStyleName):
    3192           0 :     SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName)
    3193             : {
    3194             : 
    3195           0 : }
    3196             : 
    3197           0 : SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) :
    3198           0 :     SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE)
    3199             : {
    3200           0 : }
    3201             : 
    3202           0 : SwXPageStyle::~SwXPageStyle()
    3203             : {
    3204             : 
    3205           0 : }
    3206             : 
    3207           0 : static void lcl_putItemToSet(const SvxSetItem* pSetItem, sal_uInt16 nRes, sal_uInt16 nItemType, const uno::Any& rVal, sal_uInt8 nMemberId, SwStyleBase_Impl& rBaseImpl)
    3208             : {
    3209           0 :     SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone();
    3210           0 :     SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
    3211           0 :     const SfxPoolItem* pItem = 0;
    3212           0 :     SfxPoolItem* pNewItem = 0;
    3213           0 :     rSetSet.GetItemState(nRes, true, &pItem);
    3214           0 :     if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes))
    3215           0 :         pItem = &rSetSet.GetPool()->GetDefaultItem(nRes);
    3216           0 :     if(pItem)
    3217             :     {
    3218           0 :         pNewItem = pItem->Clone();
    3219             :     }
    3220             :     else
    3221             :     {
    3222           0 :         switch(nItemType)
    3223             :         {
    3224           0 :             case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes);       break;
    3225           0 :             case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes);       break;
    3226           0 :             case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes);     break;
    3227           0 :             case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break;
    3228           0 :             case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes);  break;
    3229           0 :             case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break;
    3230           0 :             case TYPE_BOX: pNewItem = new SvxBoxItem(nRes);         break;
    3231             :         }
    3232             :     }
    3233             :     assert(pNewItem);
    3234           0 :     if (pNewItem)
    3235             :     {
    3236           0 :         pNewItem->PutValue(rVal, nMemberId);
    3237           0 :         rSetSet.Put(*pNewItem);
    3238           0 :         delete pNewItem;
    3239             :     }
    3240           0 :     rBaseImpl.GetItemSet().Put(*pNewSetItem);
    3241           0 :     delete pNewSetItem;
    3242           0 : }
    3243             : 
    3244           0 : void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
    3245             :     const uno::Sequence< OUString >& rPropertyNames,
    3246             :     const uno::Sequence< uno::Any >& rValues )
    3247             :     throw (beans::UnknownPropertyException, beans::PropertyVetoException,
    3248             :            lang::IllegalArgumentException, lang::WrappedTargetException,
    3249             :            uno::RuntimeException, std::exception)
    3250             : {
    3251           0 :     if(!GetDoc())
    3252           0 :         throw uno::RuntimeException();
    3253             : 
    3254           0 :     if(rPropertyNames.getLength() != rValues.getLength())
    3255           0 :         throw lang::IllegalArgumentException();
    3256             : 
    3257           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    3258           0 :     const uno::Any* pValues = rValues.getConstArray();
    3259           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
    3260           0 :     const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
    3261           0 :     SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName());
    3262           0 :     if(GetBasePool())
    3263             :     {
    3264           0 :         sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
    3265           0 :         GetBasePool()->SetSearchMask(GetFamily());
    3266           0 :         SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
    3267           0 :         GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
    3268             :         OSL_ENSURE(pBase, "where is the style?" );
    3269           0 :         if(pBase)
    3270           0 :             aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
    3271             :         else
    3272           0 :             throw uno::RuntimeException();
    3273             :     }
    3274             : 
    3275           0 :     for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
    3276             :     {
    3277           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
    3278           0 :         if (!pEntry)
    3279           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    3280           0 :         if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
    3281           0 :             throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    3282             : 
    3283           0 :         if(GetBasePool())
    3284             :         {
    3285           0 :             switch(pEntry->nWID)
    3286             :             {
    3287             :                 case FN_UNO_HEADER_ON:
    3288             :                 case FN_UNO_HEADER_BACKGROUND:
    3289             :                 case FN_UNO_HEADER_BOX:
    3290             :                 case FN_UNO_HEADER_LR_SPACE:
    3291             :                 case FN_UNO_HEADER_SHADOW:
    3292             :                 case FN_UNO_HEADER_BODY_DISTANCE:
    3293             :                 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
    3294             :                 case FN_UNO_HEADER_SHARE_CONTENT:
    3295             :                 case FN_UNO_HEADER_HEIGHT:
    3296             :                 case FN_UNO_HEADER_EAT_SPACING:
    3297             : 
    3298             :                 case FN_UNO_FIRST_SHARE_CONTENT:
    3299             : 
    3300             :                 case FN_UNO_FOOTER_ON:
    3301             :                 case FN_UNO_FOOTER_BACKGROUND:
    3302             :                 case FN_UNO_FOOTER_BOX:
    3303             :                 case FN_UNO_FOOTER_LR_SPACE:
    3304             :                 case FN_UNO_FOOTER_SHADOW:
    3305             :                 case FN_UNO_FOOTER_BODY_DISTANCE:
    3306             :                 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
    3307             :                 case FN_UNO_FOOTER_SHARE_CONTENT:
    3308             :                 case FN_UNO_FOOTER_HEIGHT:
    3309             :                 case FN_UNO_FOOTER_EAT_SPACING:
    3310             :                 {
    3311           0 :                     bool bFooter = false;
    3312           0 :                     sal_uInt16 nItemType = TYPE_BOOL;
    3313           0 :                     sal_uInt16 nRes = 0;
    3314           0 :                     switch(pEntry->nWID)
    3315             :                     {
    3316           0 :                         case FN_UNO_FOOTER_ON:                  bFooter = true;
    3317             :                         // no break
    3318           0 :                         case FN_UNO_HEADER_ON:                  nRes = SID_ATTR_PAGE_ON;
    3319           0 :                         break;
    3320           0 :                         case FN_UNO_FOOTER_BACKGROUND:          bFooter = true;
    3321             :                         // no break
    3322           0 :                         case FN_UNO_HEADER_BACKGROUND:          nRes = RES_BACKGROUND; nItemType = TYPE_BRUSH;
    3323           0 :                         break;
    3324           0 :                         case FN_UNO_FOOTER_BOX:                 bFooter = true;
    3325             :                         // no break
    3326           0 :                         case FN_UNO_HEADER_BOX:                 nRes = RES_BOX; nItemType = TYPE_BOX;
    3327           0 :                         break;
    3328           0 :                         case FN_UNO_FOOTER_LR_SPACE:            bFooter = true;
    3329             :                         // no break
    3330           0 :                         case FN_UNO_HEADER_LR_SPACE:            nRes = RES_LR_SPACE;nItemType = TYPE_LRSPACE;
    3331           0 :                         break;
    3332           0 :                         case FN_UNO_FOOTER_SHADOW:              bFooter = true;
    3333             :                         // no break
    3334           0 :                         case FN_UNO_HEADER_SHADOW:              nRes = RES_SHADOW;nItemType = TYPE_SHADOW;
    3335           0 :                         break;
    3336           0 :                         case FN_UNO_FOOTER_BODY_DISTANCE:       bFooter = true;
    3337             :                         // no break
    3338           0 :                         case FN_UNO_HEADER_BODY_DISTANCE:       nRes = RES_UL_SPACE;nItemType = TYPE_ULSPACE;
    3339           0 :                         break;
    3340           0 :                         case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = true;
    3341             :                         // no break
    3342           0 :                         case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
    3343           0 :                         break;
    3344           0 :                         case FN_UNO_FOOTER_SHARE_CONTENT:       bFooter = true;
    3345             :                         // no break
    3346           0 :                         case FN_UNO_HEADER_SHARE_CONTENT:       nRes = SID_ATTR_PAGE_SHARED;
    3347           0 :                         break;
    3348           0 :                         case FN_UNO_FIRST_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED_FIRST;
    3349           0 :                         break;
    3350           0 :                         case FN_UNO_FOOTER_HEIGHT:              bFooter = true;
    3351             :                         // no break
    3352           0 :                         case FN_UNO_HEADER_HEIGHT:              nRes = SID_ATTR_PAGE_SIZE;nItemType = TYPE_SIZE;
    3353           0 :                         break;
    3354           0 :                         case FN_UNO_FOOTER_EAT_SPACING:     bFooter = true;
    3355             :                         // no break
    3356           0 :                         case FN_UNO_HEADER_EAT_SPACING:     nRes = RES_HEADER_FOOTER_EAT_SPACING;nItemType = TYPE_SIZE;
    3357           0 :                         break;
    3358             :                     }
    3359             :                     const SvxSetItem* pSetItem;
    3360           0 :                     if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
    3361             :                             bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
    3362           0 :                             false, (const SfxPoolItem**)&pSetItem))
    3363             :                     {
    3364           0 :                         lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
    3365             : 
    3366           0 :                         if (nRes == SID_ATTR_PAGE_SHARED_FIRST)
    3367             :                         {
    3368             :                             // Need to add this to the other as well
    3369           0 :                             if (SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
    3370             :                                         bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
    3371           0 :                                         false, (const SfxPoolItem**)&pSetItem))
    3372           0 :                                 lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
    3373             :                         }
    3374             :                     }
    3375           0 :                     else if(SID_ATTR_PAGE_ON == nRes )
    3376             :                     {
    3377           0 :                         sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue();
    3378           0 :                         if(bVal)
    3379             :                         {
    3380           0 :                             SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
    3381             :                                 RES_BACKGROUND, RES_SHADOW,
    3382             :                                 RES_LR_SPACE, RES_UL_SPACE,
    3383             :                                 nRes, nRes,
    3384             :                                 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
    3385             :                                 SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
    3386             :                                 SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
    3387             :                                 SID_ATTR_PAGE_SHARED_FIRST, SID_ATTR_PAGE_SHARED_FIRST,
    3388           0 :                                 0 );
    3389           0 :                             aTempSet.Put(SfxBoolItem(nRes, true));
    3390           0 :                             aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
    3391           0 :                             aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
    3392           0 :                             aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
    3393           0 :                             aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, true));
    3394           0 :                             aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST, true));
    3395           0 :                             aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, true));
    3396             : 
    3397             :                             SvxSetItem aNewSetItem( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
    3398           0 :                                     aTempSet);
    3399           0 :                             aBaseImpl.GetItemSet().Put(aNewSetItem);
    3400             :                         }
    3401             :                     }
    3402             :                 }
    3403           0 :                 break;
    3404             :                 case FN_PARAM_FTN_INFO :
    3405             :                 {
    3406           0 :                     const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
    3407           0 :                     SfxPoolItem* pNewFtnItem = rItem.Clone();
    3408           0 :                     sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
    3409           0 :                     aBaseImpl.GetItemSet().Put(*pNewFtnItem);
    3410           0 :                     delete pNewFtnItem;
    3411           0 :                     if(!bPut)
    3412           0 :                         throw lang::IllegalArgumentException();
    3413             :                 }
    3414           0 :                 break;
    3415             :                 case  FN_UNO_HEADER       :
    3416             :                 case  FN_UNO_HEADER_LEFT  :
    3417             :                 case  FN_UNO_HEADER_RIGHT :
    3418             :                 case  FN_UNO_HEADER_FIRST :
    3419             :                 case  FN_UNO_FOOTER       :
    3420             :                 case  FN_UNO_FOOTER_LEFT  :
    3421             :                 case  FN_UNO_FOOTER_RIGHT :
    3422             :                 case  FN_UNO_FOOTER_FIRST :
    3423           0 :                     throw lang::IllegalArgumentException();
    3424             :                 //break;
    3425             :                 default:
    3426           0 :                     lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
    3427           0 :                                         GetBasePool(), GetDoc(), GetFamily());
    3428             :             }
    3429             :         }
    3430           0 :         else if(IsDescriptor())
    3431             :         {
    3432           0 :             if(!GetPropImpl()->SetProperty(pNames[nProp], pValues[nProp]))
    3433           0 :                 throw lang::IllegalArgumentException();
    3434             :         }
    3435             :         else
    3436           0 :             throw uno::RuntimeException();
    3437             :     }
    3438           0 :     if(aBaseImpl.HasItemSet())
    3439             :     {
    3440           0 :         ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
    3441           0 :         if (undoGuard.UndoWasEnabled())
    3442             :         {
    3443             :             // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
    3444           0 :             GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
    3445             :         }
    3446           0 :         aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
    3447           0 :     }
    3448           0 : }
    3449             : 
    3450           0 : void SwXPageStyle::setPropertyValues(
    3451             :     const uno::Sequence< OUString >& rPropertyNames,
    3452             :     const uno::Sequence< uno::Any >& rValues )
    3453             :         throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    3454             : {
    3455           0 :     SolarMutexGuard aGuard;
    3456             : 
    3457             :     // workaround for bad designed API
    3458             :     try
    3459             :     {
    3460           0 :         SetPropertyValues_Impl( rPropertyNames, rValues );
    3461             :     }
    3462           0 :     catch (const beans::UnknownPropertyException &rException)
    3463             :     {
    3464             :         // wrap the original (here not allowed) exception in
    3465             :         // a lang::WrappedTargetException that gets thrown instead.
    3466           0 :         lang::WrappedTargetException aWExc;
    3467           0 :         aWExc.TargetException <<= rException;
    3468           0 :         throw aWExc;
    3469           0 :     }
    3470           0 : }
    3471             : 
    3472             : static uno::Reference<text::XText>
    3473           0 : lcl_makeHeaderFooter(
    3474             :     const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt)
    3475             : {
    3476           0 :     if (!pFrmFmt) { return 0; }
    3477             : 
    3478           0 :     const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
    3479             :     const SfxPoolItem* pItem;
    3480           0 :     if (SFX_ITEM_SET == rSet.GetItemState(nRes, true, &pItem))
    3481             :     {
    3482             :         SwFrmFmt *const pHeadFootFmt = (bHeader)
    3483             :             ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))->
    3484           0 :                     GetHeaderFmt()
    3485             :             : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))->
    3486           0 :                     GetFooterFmt();
    3487           0 :         if (pHeadFootFmt)
    3488             :         {
    3489           0 :             return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader);
    3490             :         }
    3491             :     }
    3492           0 :     return 0;
    3493             : }
    3494             : 
    3495           0 : uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
    3496             :         const uno::Sequence< OUString >& rPropertyNames )
    3497             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
    3498             : {
    3499           0 :     if(!GetDoc())
    3500           0 :         throw uno::RuntimeException();
    3501             : 
    3502           0 :     sal_Int32 nLength = rPropertyNames.getLength();
    3503           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    3504           0 :     uno::Sequence< uno::Any > aRet ( nLength );
    3505             : 
    3506           0 :     uno::Any* pRet = aRet.getArray();
    3507           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
    3508           0 :     const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
    3509           0 :     SwStyleBase_Impl aBase(*GetDoc(), GetStyleName());
    3510           0 :     SfxStyleSheetBase* pBase = 0;
    3511           0 :     for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
    3512             :     {
    3513           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
    3514           0 :         if (!pEntry)
    3515           0 :             throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
    3516             : 
    3517           0 :         if(GetBasePool())
    3518             :         {
    3519           0 :             if(!pBase)
    3520             :             {
    3521           0 :                 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
    3522           0 :                 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
    3523           0 :                 pBase = GetBasePool()->Find(GetStyleName());
    3524           0 :                 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
    3525             :             }
    3526           0 :             sal_uInt16 nRes = 0;
    3527           0 :             bool bHeader = false;
    3528           0 :             bool bLeft = false;
    3529           0 :             bool bFirst = false;
    3530           0 :             switch(pEntry->nWID)
    3531             :             {
    3532             :                 case FN_UNO_HEADER_ON:
    3533             :                 case FN_UNO_HEADER_BACKGROUND:
    3534             :                 case FN_UNO_HEADER_BOX:
    3535             :                 case FN_UNO_HEADER_LR_SPACE:
    3536             :                 case FN_UNO_HEADER_SHADOW:
    3537             :                 case FN_UNO_HEADER_BODY_DISTANCE:
    3538             :                 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
    3539             :                 case FN_UNO_HEADER_SHARE_CONTENT:
    3540             :                 case FN_UNO_HEADER_HEIGHT:
    3541             :                 case FN_UNO_HEADER_EAT_SPACING:
    3542             : 
    3543             :                 case FN_UNO_FIRST_SHARE_CONTENT:
    3544             : 
    3545             :                 case FN_UNO_FOOTER_ON:
    3546             :                 case FN_UNO_FOOTER_BACKGROUND:
    3547             :                 case FN_UNO_FOOTER_BOX:
    3548             :                 case FN_UNO_FOOTER_LR_SPACE:
    3549             :                 case FN_UNO_FOOTER_SHADOW:
    3550             :                 case FN_UNO_FOOTER_BODY_DISTANCE:
    3551             :                 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
    3552             :                 case FN_UNO_FOOTER_SHARE_CONTENT:
    3553             :                 case FN_UNO_FOOTER_HEIGHT:
    3554             :                 case FN_UNO_FOOTER_EAT_SPACING:
    3555             :                 {
    3556           0 :                     SfxStyleSheetBasePool* pBasePool2 = ((SwXPageStyle*)this)->GetBasePool();
    3557           0 :                     pBasePool2->SetSearchMask(GetFamily());
    3558           0 :                     SfxStyleSheetBase* pBase2 = pBasePool2->Find(GetStyleName());
    3559           0 :                     if(pBase2)
    3560             :                     {
    3561           0 :                         rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    3562           0 :                         const SfxItemSet& rSet = xStyle->GetItemSet();
    3563           0 :                         bool bFooter = false;
    3564           0 :                         switch(pEntry->nWID)
    3565             :                         {
    3566             :                             case FN_UNO_FOOTER_ON:
    3567           0 :                                 bFooter = true;
    3568             :                             // no break
    3569             :                             case FN_UNO_HEADER_ON:
    3570             :                             {
    3571             :                                 //falls das SetItem nicht da ist, dann ist der Wert sal_False
    3572           0 :                                 sal_Bool bRet = sal_False;
    3573           0 :                                 pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
    3574           0 :                                 nRes = SID_ATTR_PAGE_ON;
    3575             :                             }
    3576           0 :                             break;
    3577           0 :                             case FN_UNO_FOOTER_BACKGROUND:      bFooter = true;
    3578             :                             // no break
    3579           0 :                             case FN_UNO_HEADER_BACKGROUND:      nRes = RES_BACKGROUND;
    3580           0 :                             break;
    3581           0 :                             case FN_UNO_FOOTER_BOX:             bFooter = true;
    3582             :                             // no break
    3583           0 :                             case FN_UNO_HEADER_BOX:             nRes = RES_BOX;
    3584           0 :                             break;
    3585           0 :                             case FN_UNO_FOOTER_LR_SPACE:        bFooter = true;
    3586             :                             // no break
    3587           0 :                             case FN_UNO_HEADER_LR_SPACE:        nRes = RES_LR_SPACE;
    3588           0 :                             break;
    3589           0 :                             case FN_UNO_FOOTER_SHADOW:          bFooter = true;
    3590             :                             // no break
    3591           0 :                             case FN_UNO_HEADER_SHADOW:          nRes = RES_SHADOW;
    3592           0 :                             break;
    3593           0 :                             case FN_UNO_FOOTER_BODY_DISTANCE:   bFooter = true;
    3594             :                             // no break
    3595           0 :                             case FN_UNO_HEADER_BODY_DISTANCE:   nRes = RES_UL_SPACE;
    3596           0 :                             break;
    3597           0 :                             case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = true;
    3598             :                             // no break
    3599           0 :                             case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
    3600           0 :                             break;
    3601           0 :                             case FN_UNO_FOOTER_SHARE_CONTENT:   bFooter = true;
    3602             :                             // no break
    3603           0 :                             case FN_UNO_HEADER_SHARE_CONTENT:   nRes = SID_ATTR_PAGE_SHARED;
    3604           0 :                             break;
    3605           0 :                             case FN_UNO_FIRST_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED_FIRST;
    3606           0 :                             break;
    3607           0 :                             case FN_UNO_FOOTER_HEIGHT:          bFooter = true;
    3608             :                             // no break
    3609           0 :                             case FN_UNO_HEADER_HEIGHT:          nRes = SID_ATTR_PAGE_SIZE;
    3610           0 :                             break;
    3611           0 :                             case FN_UNO_FOOTER_EAT_SPACING: bFooter = true;
    3612             :                             // no break
    3613           0 :                             case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
    3614           0 :                             break;
    3615             :                         }
    3616             :                         const SvxSetItem* pSetItem;
    3617           0 :                         if(SFX_ITEM_SET == rSet.GetItemState(
    3618             :                                 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
    3619           0 :                                 false, (const SfxPoolItem**)&pSetItem))
    3620             :                         {
    3621           0 :                             const SfxItemSet& rTmpSet = pSetItem->GetItemSet();
    3622           0 :                             const SfxPoolItem* pItem = 0;
    3623           0 :                             rTmpSet.GetItemState(nRes, true, &pItem);
    3624           0 :                             if(!pItem && nRes != rTmpSet.GetPool()->GetSlotId(nRes))
    3625           0 :                                 pItem = &rTmpSet.GetPool()->GetDefaultItem(nRes);
    3626           0 :                             if(pItem)
    3627           0 :                                 pItem->QueryValue(pRet[nProp], pEntry->nMemberId);
    3628           0 :                         }
    3629             :                     }
    3630             :                 }
    3631           0 :                 break;
    3632             :                 case  FN_UNO_HEADER       :
    3633           0 :                     goto Header;
    3634             :                 case  FN_UNO_HEADER_LEFT  :
    3635           0 :                     bLeft = true; goto Header;
    3636             :                 case  FN_UNO_HEADER_FIRST  :
    3637           0 :                     bFirst = true; goto Header;
    3638             :                 case  FN_UNO_HEADER_RIGHT :
    3639           0 :                     goto Header;
    3640             : Header:
    3641           0 :                     bHeader = true;
    3642           0 :                     nRes = RES_HEADER; goto MakeObject;
    3643             :                 case  FN_UNO_FOOTER       :
    3644           0 :                     goto Footer;
    3645             :                 case  FN_UNO_FOOTER_LEFT  :
    3646           0 :                     bLeft = true; goto Footer;
    3647             :                 case  FN_UNO_FOOTER_FIRST  :
    3648           0 :                     bFirst = true; goto Footer;
    3649             :                 case  FN_UNO_FOOTER_RIGHT :
    3650             : Footer:
    3651           0 :                     nRes = RES_FOOTER;
    3652             : MakeObject:
    3653             :                 {
    3654           0 :                     const SwPageDesc& rDesc = aBase.GetOldPageDesc();
    3655           0 :                     const SwFrmFmt* pFrmFmt = 0;
    3656           0 :                     bool bShare = (bHeader && rDesc.IsHeaderShared())||
    3657           0 :                                     (!bHeader && rDesc.IsFooterShared());
    3658           0 :                     bool bShareFirst = rDesc.IsFirstShared();
    3659             :                     // TextLeft returns the left content if there is one,
    3660             :                     // Text and TextRight return the master content.
    3661             :                     // TextRight does the same as Text and is for
    3662             :                     // comptability only.
    3663           0 :                     if( bLeft && !bShare )
    3664             :                     {
    3665           0 :                         pFrmFmt = &rDesc.GetLeft();
    3666             :                     }
    3667           0 :                     else if (bFirst && !bShareFirst)
    3668             :                     {
    3669           0 :                         pFrmFmt = &rDesc.GetFirstMaster();
    3670             :                         // no need to make GetFirstLeft() accessible
    3671             :                         // since it is always shared
    3672             :                     }
    3673             :                     else
    3674             :                     {
    3675           0 :                         pFrmFmt = &rDesc.GetMaster();
    3676             :                     }
    3677             :                     const uno::Reference< text::XText > xRet =
    3678           0 :                         lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt);
    3679           0 :                     if (xRet.is())
    3680             :                     {
    3681           0 :                         pRet[nProp] <<= xRet;
    3682           0 :                     }
    3683             :                 }
    3684           0 :                 break;
    3685             :                 case FN_PARAM_FTN_INFO :
    3686             :                 {
    3687           0 :                     rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
    3688           0 :                     const SfxItemSet& rSet = xStyle->GetItemSet();
    3689           0 :                     const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
    3690           0 :                     rItem.QueryValue(pRet[nProp], pEntry->nMemberId);
    3691             :                 }
    3692           0 :                 break;
    3693             :                 default:
    3694           0 :                 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
    3695             :             }
    3696             :         }
    3697           0 :         else if(IsDescriptor())
    3698             :         {
    3699           0 :             uno::Any* pAny = 0;
    3700           0 :             GetPropImpl()->GetProperty(pNames[nProp], pAny);
    3701           0 :             if ( !pAny )
    3702           0 :                 GetPropImpl()->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
    3703             :             else
    3704           0 :                 pRet[nProp] = *pAny;
    3705             :         }
    3706             :         else
    3707           0 :             throw uno::RuntimeException();
    3708             :     }
    3709           0 :     return aRet;
    3710             : }
    3711             : 
    3712           0 : uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
    3713             :     const uno::Sequence< OUString >& rPropertyNames )
    3714             :         throw(uno::RuntimeException, std::exception)
    3715             : {
    3716           0 :     SolarMutexGuard aGuard;
    3717           0 :     uno::Sequence< uno::Any > aValues;
    3718             : 
    3719             :     // workaround for bad designed API
    3720             :     try
    3721             :     {
    3722           0 :         aValues = GetPropertyValues_Impl( rPropertyNames );
    3723             :     }
    3724           0 :     catch (beans::UnknownPropertyException &)
    3725             :     {
    3726           0 :         throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
    3727             :     }
    3728           0 :     catch (lang::WrappedTargetException &)
    3729             :     {
    3730           0 :         throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
    3731             :     }
    3732             : 
    3733           0 :     return aValues;
    3734             : }
    3735             : 
    3736           0 : uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw(
    3737             :     beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    3738             : {
    3739           0 :     SolarMutexGuard aGuard;
    3740           0 :     const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
    3741           0 :     return GetPropertyValues_Impl(aProperties).getConstArray()[0];
    3742             : }
    3743             : 
    3744           0 : void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
    3745             :     throw( beans::UnknownPropertyException,
    3746             :         beans::PropertyVetoException,
    3747             :         lang::IllegalArgumentException,
    3748             :         lang::WrappedTargetException,
    3749             :         uno::RuntimeException, std::exception)
    3750             : {
    3751           0 :     SolarMutexGuard aGuard;
    3752           0 :     const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
    3753           0 :     const uno::Sequence<uno::Any> aValues(&rValue, 1);
    3754           0 :     SetPropertyValues_Impl( aProperties, aValues );
    3755           0 : }
    3756             : 
    3757           0 : SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
    3758           0 : : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False)
    3759             : {
    3760           0 : }
    3761             : 
    3762           0 : SwXFrameStyle::~SwXFrameStyle()
    3763             : {
    3764           0 : }
    3765             : 
    3766           0 : uno::Sequence< uno::Type > SwXFrameStyle::getTypes(  ) throw(uno::RuntimeException, std::exception)
    3767             : {
    3768           0 :     uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes();
    3769           0 :     sal_Int32 nLen = aTypes.getLength();
    3770           0 :     aTypes.realloc(nLen + 1);
    3771           0 :     aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0);
    3772           0 :     return aTypes;
    3773             : }
    3774             : 
    3775           0 : uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
    3776             : {
    3777           0 :     uno::Any aRet;
    3778           0 :     if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0))
    3779           0 :         aRet <<= uno::Reference<XEventsSupplier>(this);
    3780             :     else
    3781           0 :         aRet = SwXStyle::queryInterface(rType);
    3782           0 :     return aRet;
    3783             : }
    3784             : 
    3785           0 : uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents(  ) throw(uno::RuntimeException, std::exception)
    3786             : {
    3787           0 :     return new SwFrameStyleEventDescriptor( *this );
    3788             : }
    3789             : 
    3790           0 : SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
    3791           0 :     SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
    3792             : {
    3793           0 : }
    3794             : 
    3795           0 : SwXAutoStyles::~SwXAutoStyles()
    3796             : {
    3797           0 : }
    3798             : 
    3799           0 : sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException, std::exception )
    3800             : {
    3801           0 :     return AUTOSTYLE_FAMILY_COUNT;
    3802             : }
    3803             : 
    3804           0 : uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
    3805             :         throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
    3806             :                 uno::RuntimeException, std::exception )
    3807             : {
    3808           0 :     SolarMutexGuard aGuard;
    3809           0 :     uno::Any aRet;
    3810           0 :     if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
    3811           0 :         throw lang::IndexOutOfBoundsException();
    3812           0 :     if(IsValid())
    3813             :     {
    3814           0 :         uno::Reference< style::XAutoStyleFamily >  aRef;
    3815           0 :         IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
    3816           0 :         switch( nType )
    3817             :         {
    3818             :             case IStyleAccess::AUTO_STYLE_CHAR:
    3819             :             {
    3820           0 :                 if(!xAutoCharStyles.is())
    3821           0 :                     xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
    3822           0 :                 aRef = xAutoCharStyles;
    3823             :             }
    3824           0 :             break;
    3825             :             case IStyleAccess::AUTO_STYLE_RUBY:
    3826             :             {
    3827           0 :                 if(!xAutoRubyStyles.is())
    3828           0 :                     xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
    3829           0 :                 aRef = xAutoRubyStyles;
    3830             :             }
    3831           0 :             break;
    3832             :             case IStyleAccess::AUTO_STYLE_PARA:
    3833             :             {
    3834           0 :                 if(!xAutoParaStyles.is())
    3835           0 :                     xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
    3836           0 :                 aRef = xAutoParaStyles;
    3837             :             }
    3838           0 :             break;
    3839             : 
    3840             :             default:
    3841             :                 ;
    3842             :         }
    3843           0 :         aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0));
    3844             :     }
    3845             :     else
    3846           0 :         throw uno::RuntimeException();
    3847           0 :     return aRet;
    3848             : }
    3849             : 
    3850           0 : uno::Type SwXAutoStyles::getElementType(  ) throw(uno::RuntimeException, std::exception)
    3851             : {
    3852           0 :     return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0);
    3853             : }
    3854             : 
    3855           0 : sal_Bool SwXAutoStyles::hasElements(  ) throw(uno::RuntimeException, std::exception)
    3856             : {
    3857           0 :     return sal_True;
    3858             : }
    3859             : 
    3860           0 : uno::Any SwXAutoStyles::getByName(const OUString& Name)
    3861             :         throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
    3862             : {
    3863           0 :     uno::Any aRet;
    3864           0 :     if(Name.equalsAscii("CharacterStyles") )
    3865           0 :         aRet = getByIndex(0);
    3866           0 :     else if(Name.equalsAscii("RubyStyles") )
    3867           0 :         aRet = getByIndex(1);
    3868           0 :     else if(Name.equalsAscii("ParagraphStyles") )
    3869           0 :         aRet = getByIndex(2);
    3870             :     else
    3871           0 :         throw container::NoSuchElementException();
    3872           0 :     return aRet;
    3873             : }
    3874             : 
    3875           0 : uno::Sequence< OUString > SwXAutoStyles::getElementNames(void)
    3876             :             throw( uno::RuntimeException, std::exception )
    3877             : {
    3878           0 :     uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT);
    3879           0 :     OUString* pNames = aNames.getArray();
    3880           0 :     pNames[0] = "CharacterStyles";
    3881           0 :     pNames[1] = "RubyStyles";
    3882           0 :     pNames[2] = "ParagraphStyles";
    3883           0 :     return aNames;
    3884             : }
    3885             : 
    3886           0 : sal_Bool SwXAutoStyles::hasByName(const OUString& Name)
    3887             :             throw( uno::RuntimeException, std::exception )
    3888             : {
    3889           0 :     if( Name.equalsAscii("CharacterStyles") ||
    3890           0 :         Name.equalsAscii("RubyStyles") ||
    3891           0 :         Name.equalsAscii("ParagraphStyles") )
    3892           0 :         return sal_True;
    3893             :     else
    3894           0 :         return sal_False;
    3895             : }
    3896             : 
    3897           0 : SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
    3898           0 :     pDocShell( pDocSh ), eFamily(nFamily)
    3899             : {
    3900             :     // Register ourselves as a listener to the document (via the page descriptor)
    3901           0 :     pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
    3902           0 : }
    3903             : 
    3904           0 : SwXAutoStyleFamily::~SwXAutoStyleFamily()
    3905             : {
    3906           0 : }
    3907             : 
    3908           0 : void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    3909             : {
    3910           0 :     ClientModify(this, pOld, pNew);
    3911           0 :     if(!GetRegisteredIn())
    3912           0 :         pDocShell = 0;
    3913           0 : }
    3914             : 
    3915           0 : uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
    3916             :     const uno::Sequence< beans::PropertyValue >& Values )
    3917             :         throw (uno::RuntimeException, std::exception)
    3918             : {
    3919           0 :     if( !pDocShell )
    3920           0 :         throw uno::RuntimeException();
    3921           0 :     const sal_uInt16* pRange = 0;
    3922           0 :     const SfxItemPropertySet* pPropSet = 0;
    3923           0 :     switch( eFamily )
    3924             :     {
    3925             :         case IStyleAccess::AUTO_STYLE_CHAR:
    3926             :         {
    3927           0 :             pRange = aCharAutoFmtSetRange;
    3928           0 :             pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
    3929             :         }
    3930           0 :         break;
    3931             :         case IStyleAccess::AUTO_STYLE_RUBY:
    3932             :         {
    3933           0 :             pRange = 0;//aTxtNodeSetRange;
    3934           0 :             pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE);
    3935             :         }
    3936           0 :         break;
    3937             :         case IStyleAccess::AUTO_STYLE_PARA:
    3938             :         {
    3939           0 :             pRange = aTxtNodeSetRange;
    3940           0 :             pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
    3941             :         }
    3942           0 :         break;
    3943             : 
    3944             :         default:
    3945             :             ;
    3946             :     }
    3947             : 
    3948           0 :     if( !pPropSet)
    3949           0 :         throw uno::RuntimeException();
    3950             : 
    3951           0 :     SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
    3952           0 :     const beans::PropertyValue* pSeq = Values.getConstArray();
    3953           0 :     sal_Int32 nLen = Values.getLength();
    3954           0 :     for( sal_Int32 i = 0; i < nLen; ++i )
    3955             :     {
    3956             :         try
    3957             :         {
    3958           0 :             pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet );
    3959             :         }
    3960           0 :         catch (beans::UnknownPropertyException &)
    3961             :         {
    3962             :             OSL_FAIL( "Unknown property" );
    3963             :         }
    3964           0 :         catch (lang::IllegalArgumentException &)
    3965             :         {
    3966             :             OSL_FAIL( "Illegal argument" );
    3967             :         }
    3968             :     }
    3969             : 
    3970           0 :     SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
    3971           0 :     uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
    3972           0 :     return xRet;
    3973             : }
    3974             : 
    3975           0 : uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration(  )
    3976             :         throw (uno::RuntimeException, std::exception)
    3977             : {
    3978           0 :     if( !pDocShell )
    3979           0 :         throw uno::RuntimeException();
    3980             :     return uno::Reference< container::XEnumeration >
    3981           0 :         (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily ));
    3982             : }
    3983             : 
    3984           0 : uno::Type SwXAutoStyleFamily::getElementType(  ) throw(uno::RuntimeException, std::exception)
    3985             : {
    3986           0 :     return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0);
    3987             : }
    3988             : 
    3989           0 : sal_Bool SwXAutoStyleFamily::hasElements(  ) throw(uno::RuntimeException, std::exception)
    3990             : {
    3991           0 :     return sal_False;
    3992             : }
    3993             : 
    3994           0 : SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
    3995           0 : : pDoc( pInitDoc ), eFamily( eFam )
    3996             : {
    3997             :     // special case for ruby auto styles:
    3998           0 :     if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
    3999             :     {
    4000           0 :         std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap;
    4001           0 :         SwAttrPool& rAttrPool = pDoc->GetAttrPool();
    4002           0 :         sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY );
    4003             : 
    4004           0 :         for ( sal_uInt32 nI = 0; nI < nCount; ++nI )
    4005             :         {
    4006           0 :             const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI ));
    4007           0 :             if ( pItem && pItem->GetTxtRuby() )
    4008             :             {
    4009           0 :                 std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
    4010           0 :                 if ( aRubyMap.find( aPair ) == aRubyMap.end() )
    4011             :                 {
    4012           0 :                     aRubyMap.insert( aPair );
    4013           0 :                     SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) );
    4014           0 :                     pItemSet->Put( *pItem );
    4015           0 :                     mAutoStyles.push_back( pItemSet );
    4016             :                 }
    4017             :             }
    4018           0 :         }
    4019             :     }
    4020             :     else
    4021             :     {
    4022           0 :         pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
    4023             :     }
    4024             : 
    4025           0 :     aIter = mAutoStyles.begin();
    4026           0 : }
    4027             : 
    4028           0 : SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
    4029           0 : : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
    4030             : {
    4031             :     // Register ourselves as a listener to the document (via the page descriptor)
    4032           0 :     pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
    4033           0 : }
    4034             : 
    4035           0 : SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
    4036             : {
    4037           0 :     delete pImpl;
    4038           0 : }
    4039             : 
    4040           0 : void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    4041             : {
    4042           0 :     ClientModify(this, pOld, pNew);
    4043           0 :     if(!GetRegisteredIn())
    4044             :     {
    4045           0 :         delete pImpl;
    4046           0 :         pImpl = 0;
    4047             :     }
    4048           0 : }
    4049             : 
    4050           0 : sal_Bool SwXAutoStylesEnumerator::hasMoreElements(  )
    4051             :     throw (uno::RuntimeException, std::exception)
    4052             : {
    4053           0 :     if( !pImpl )
    4054           0 :         throw uno::RuntimeException();
    4055           0 :     return pImpl->hasMoreElements();
    4056             : }
    4057             : 
    4058           0 : uno::Any SwXAutoStylesEnumerator::nextElement(  )
    4059             :     throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4060             : {
    4061           0 :     if( !pImpl )
    4062           0 :         throw uno::RuntimeException();
    4063           0 :     uno::Any aRet;
    4064           0 :     if( pImpl->hasMoreElements() )
    4065             :     {
    4066           0 :         SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
    4067           0 :         uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
    4068           0 :                                                         pNextSet, pImpl->getFamily());
    4069           0 :         aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0));
    4070             :     }
    4071           0 :     return aRet;
    4072             : }
    4073             : 
    4074           0 : SwXAutoStyle::SwXAutoStyle( SwDoc* pDoc, SfxItemSet_Pointer_t pInitSet, IStyleAccess::SwAutoStyleFamily eFam )
    4075           0 : : pSet( pInitSet ), eFamily( eFam )
    4076             : {
    4077             :     // Register ourselves as a listener to the document (via the page descriptor)
    4078           0 :     pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
    4079           0 : }
    4080             : 
    4081           0 : SwXAutoStyle::~SwXAutoStyle()
    4082             : {
    4083           0 : }
    4084             : 
    4085           0 : void SwXAutoStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
    4086             : {
    4087           0 :     ClientModify(this, pOld, pNew);
    4088           0 :     if(!GetRegisteredIn())
    4089           0 :         pSet.reset();
    4090           0 : }
    4091             : 
    4092           0 : uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo(  )
    4093             :                 throw (uno::RuntimeException, std::exception)
    4094             : {
    4095           0 :     uno::Reference< beans::XPropertySetInfo >  xRet;
    4096           0 :     switch( eFamily )
    4097             :     {
    4098             :         case IStyleAccess::AUTO_STYLE_CHAR:
    4099             :         {
    4100           0 :             static uno::Reference< beans::XPropertySetInfo >  xCharRef;
    4101           0 :             if(!xCharRef.is())
    4102             :             {
    4103           0 :                 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo();
    4104             :             }
    4105           0 :             xRet = xCharRef;
    4106             :         }
    4107           0 :         break;
    4108             :         case IStyleAccess::AUTO_STYLE_RUBY:
    4109             :         {
    4110           0 :             static uno::Reference< beans::XPropertySetInfo >  xRubyRef;
    4111           0 :             if(!xRubyRef.is())
    4112             :             {
    4113           0 :                 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE;
    4114           0 :                 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
    4115             :             }
    4116           0 :             xRet = xRubyRef;
    4117             :         }
    4118           0 :         break;
    4119             :         case IStyleAccess::AUTO_STYLE_PARA:
    4120             :         {
    4121           0 :             static uno::Reference< beans::XPropertySetInfo >  xParaRef;
    4122           0 :             if(!xParaRef.is())
    4123             :             {
    4124           0 :                 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
    4125           0 :                 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
    4126             :             }
    4127           0 :             xRet = xParaRef;
    4128             :         }
    4129           0 :         break;
    4130             : 
    4131             :         default:
    4132             :             ;
    4133             :     }
    4134             : 
    4135           0 :     return xRet;
    4136             : }
    4137             : 
    4138           0 : void SwXAutoStyle::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ )
    4139             :      throw( beans::UnknownPropertyException,
    4140             :             beans::PropertyVetoException,
    4141             :             lang::IllegalArgumentException,
    4142             :             lang::WrappedTargetException,
    4143             :             uno::RuntimeException, std::exception)
    4144             : {
    4145           0 : }
    4146             : 
    4147           0 : uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName )
    4148             :     throw( beans::UnknownPropertyException,
    4149             :            lang::WrappedTargetException,
    4150             :            uno::RuntimeException, std::exception )
    4151             : {
    4152           0 :     SolarMutexGuard aGuard;
    4153           0 :     const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
    4154           0 :     return GetPropertyValues_Impl(aProperties).getConstArray()[0];
    4155             : }
    4156             : 
    4157           0 : void SwXAutoStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/,
    4158             :                                               const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
    4159             :     throw( beans::UnknownPropertyException,
    4160             :            lang::WrappedTargetException,
    4161             :            uno::RuntimeException, std::exception )
    4162             : {
    4163           0 : }
    4164             : 
    4165           0 : void SwXAutoStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/,
    4166             :                                                  const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
    4167             :     throw( beans::UnknownPropertyException,
    4168             :            lang::WrappedTargetException,
    4169             :            uno::RuntimeException, std::exception )
    4170             : {
    4171           0 : }
    4172             : 
    4173           0 : void SwXAutoStyle::addVetoableChangeListener( const OUString& /*PropertyName*/,
    4174             :                                               const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
    4175             :     throw( beans::UnknownPropertyException,
    4176             :            lang::WrappedTargetException,
    4177             :            uno::RuntimeException, std::exception )
    4178             : {
    4179           0 : }
    4180             : 
    4181           0 : void SwXAutoStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/,
    4182             :                                                  const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
    4183             :     throw( beans::UnknownPropertyException,
    4184             :            lang::WrappedTargetException,
    4185             :            uno::RuntimeException, std::exception )
    4186             : {
    4187           0 : }
    4188             : 
    4189           0 : void SwXAutoStyle::setPropertyValues(
    4190             :         const uno::Sequence< OUString >& /*aPropertyNames*/,
    4191             :         const uno::Sequence< uno::Any >& /*aValues*/ )
    4192             :             throw (beans::PropertyVetoException, lang::IllegalArgumentException,
    4193             :                 lang::WrappedTargetException, uno::RuntimeException, std::exception)
    4194             : {
    4195           0 : }
    4196             : 
    4197           0 : uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
    4198             :         const uno::Sequence< OUString > & rPropertyNames )
    4199             :     throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
    4200             : {
    4201           0 :     if( !pSet.get() )
    4202           0 :         throw uno::RuntimeException();
    4203             :     // query_item
    4204             : 
    4205           0 :     sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
    4206           0 :     switch(eFamily)
    4207             :     {
    4208           0 :         case IStyleAccess::AUTO_STYLE_CHAR  : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;  break;
    4209           0 :         case IStyleAccess::AUTO_STYLE_RUBY  : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE;  break;
    4210           0 :         case IStyleAccess::AUTO_STYLE_PARA  : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE;  break;
    4211             :         default:
    4212             :             ;
    4213             :     }
    4214             : 
    4215           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    4216           0 :     const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
    4217           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    4218             : 
    4219           0 :     sal_Int32 nLen = rPropertyNames.getLength();
    4220           0 :     uno::Sequence< uno::Any > aRet( nLen );
    4221           0 :     uno::Any* pValues = aRet.getArray();
    4222             : 
    4223           0 :     SfxItemSet& rSet = *pSet.get();
    4224             : 
    4225           0 :     for( sal_Int32 i = 0; i < nLen; ++i )
    4226             :     {
    4227           0 :         const OUString sPropName = pNames[i];
    4228           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
    4229           0 :         if(!pEntry)
    4230           0 :             throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
    4231           0 :         else if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
    4232             :         {
    4233           0 :             pValues[i] <<= StylePool::nameOf( pSet );
    4234             :         }
    4235             :         else
    4236           0 :             pPropSet->getPropertyValue( *pEntry, rSet, pValues[i] );
    4237           0 :     }
    4238           0 :     return aRet;
    4239             : }
    4240             : 
    4241           0 : uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
    4242             :         const uno::Sequence< OUString >& rPropertyNames )
    4243             :             throw (uno::RuntimeException, std::exception)
    4244             : {
    4245           0 :     SolarMutexGuard aGuard;
    4246           0 :     uno::Sequence< uno::Any > aValues;
    4247             : 
    4248             :     // workaround for bad designed API
    4249             :     try
    4250             :     {
    4251           0 :         aValues = GetPropertyValues_Impl( rPropertyNames );
    4252             :     }
    4253           0 :     catch (beans::UnknownPropertyException &)
    4254             :     {
    4255           0 :         throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
    4256             :     }
    4257           0 :     catch (lang::WrappedTargetException &)
    4258             :     {
    4259           0 :         throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
    4260             :     }
    4261             : 
    4262           0 :     return aValues;
    4263             : }
    4264             : 
    4265           0 : void SwXAutoStyle::addPropertiesChangeListener(
    4266             :         const uno::Sequence< OUString >& /*aPropertyNames*/,
    4267             :         const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    4268             :             throw (uno::RuntimeException, std::exception)
    4269             : {
    4270           0 : }
    4271             : 
    4272           0 : void SwXAutoStyle::removePropertiesChangeListener(
    4273             :         const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    4274             :             throw (uno::RuntimeException, std::exception)
    4275             : {
    4276           0 : }
    4277             : 
    4278           0 : void SwXAutoStyle::firePropertiesChangeEvent(
    4279             :         const uno::Sequence< OUString >& /*aPropertyNames*/,
    4280             :         const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
    4281             :             throw (uno::RuntimeException, std::exception)
    4282             : {
    4283           0 : }
    4284             : 
    4285           0 : beans::PropertyState SwXAutoStyle::getPropertyState( const OUString& rPropertyName )
    4286             :     throw( beans::UnknownPropertyException,
    4287             :            uno::RuntimeException, std::exception)
    4288             : {
    4289           0 :     SolarMutexGuard aGuard;
    4290             : 
    4291           0 :     uno::Sequence< OUString > aNames(1);
    4292           0 :     OUString* pNames = aNames.getArray();
    4293           0 :     pNames[0] = rPropertyName;
    4294           0 :     uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
    4295           0 :     return aStates.getConstArray()[0];
    4296             : }
    4297             : 
    4298           0 : void SwXAutoStyle::setPropertyToDefault( const OUString& /*PropertyName*/ )
    4299             :     throw( beans::UnknownPropertyException,
    4300             :            uno::RuntimeException, std::exception )
    4301             : {
    4302           0 : }
    4303             : 
    4304           0 : uno::Any SwXAutoStyle::getPropertyDefault( const OUString& rPropertyName )
    4305             :     throw( beans::UnknownPropertyException,
    4306             :            lang::WrappedTargetException,
    4307             :            uno::RuntimeException, std::exception)
    4308             : {
    4309           0 :     const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
    4310           0 :     return getPropertyDefaults ( aSequence ).getConstArray()[0];
    4311             : }
    4312             : 
    4313           0 : uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
    4314             :         const uno::Sequence< OUString >& rPropertyNames )
    4315             :             throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    4316             : {
    4317           0 :     if( !pSet.get() )
    4318           0 :         throw uno::RuntimeException();
    4319           0 :     SolarMutexGuard aGuard;
    4320           0 :     uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
    4321           0 :     beans::PropertyState* pStates = aRet.getArray();
    4322           0 :     const OUString* pNames = rPropertyNames.getConstArray();
    4323             : 
    4324           0 :     sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
    4325           0 :     switch(eFamily)
    4326             :     {
    4327           0 :         case IStyleAccess::AUTO_STYLE_CHAR  : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;  break;
    4328           0 :         case IStyleAccess::AUTO_STYLE_RUBY  : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE;  break;
    4329           0 :         case IStyleAccess::AUTO_STYLE_PARA  : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE;  break;
    4330             :         default:
    4331             :             ;
    4332             :     }
    4333             : 
    4334           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    4335           0 :     const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
    4336           0 :     SfxItemSet& rSet = *pSet.get();
    4337           0 :     for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
    4338             :     {
    4339           0 :         const OUString sPropName = pNames[i];
    4340           0 :         const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
    4341           0 :         if(!pEntry)
    4342           0 :             throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
    4343           0 :         pStates[i] = pPropSet->getPropertyState(*pEntry, rSet );
    4344           0 :     }
    4345           0 :     return aRet;
    4346             : }
    4347             : 
    4348           0 : void SwXAutoStyle::setAllPropertiesToDefault(  )
    4349             :             throw (uno::RuntimeException, std::exception)
    4350             : {
    4351           0 : }
    4352             : 
    4353           0 : void SwXAutoStyle::setPropertiesToDefault(
    4354             :         const uno::Sequence< OUString >& /*aPropertyNames*/ )
    4355             :             throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
    4356             : {
    4357           0 : }
    4358             : 
    4359           0 : uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults(
    4360             :         const uno::Sequence< OUString >& /*aPropertyNames*/ )
    4361             :             throw (beans::UnknownPropertyException, lang::WrappedTargetException,
    4362             :                     uno::RuntimeException, std::exception)
    4363             : {
    4364           0 :     uno::Sequence< uno::Any > aRet(0);
    4365           0 :     return aRet;
    4366             : }
    4367             : 
    4368           0 : uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::RuntimeException, std::exception)
    4369             : {
    4370           0 :     if( !pSet.get() )
    4371           0 :         throw uno::RuntimeException();
    4372           0 :     SolarMutexGuard aGuard;
    4373           0 :     std::vector< beans::PropertyValue > aPropertyVector;
    4374             : 
    4375           0 :     sal_Int8 nPropSetId = 0;
    4376           0 :     switch(eFamily)
    4377             :     {
    4378           0 :         case IStyleAccess::AUTO_STYLE_CHAR  : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;  break;
    4379           0 :         case IStyleAccess::AUTO_STYLE_RUBY  : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE;  break;
    4380           0 :         case IStyleAccess::AUTO_STYLE_PARA  : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE;  break;
    4381             :         default:
    4382             :             ;
    4383             :     }
    4384             : 
    4385           0 :     const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
    4386           0 :     const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
    4387           0 :     PropertyEntryVector_t aPropVector = rMap.getPropertyEntries();
    4388             : 
    4389           0 :     SfxItemSet& rSet = *pSet.get();
    4390           0 :     SfxItemIter aIter(rSet);
    4391           0 :     const SfxPoolItem* pItem = aIter.FirstItem();
    4392             : 
    4393           0 :     while ( pItem )
    4394             :     {
    4395           0 :         const sal_uInt16 nWID = pItem->Which();
    4396             : 
    4397             :         // TODO: Optimize - and fix! the old iteration filled each WhichId
    4398             :         // only once but there are more properties than WhichIds
    4399           0 :         PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
    4400           0 :         while( aIt != aPropVector.end() )
    4401             :         {
    4402           0 :             if ( aIt->nWID == nWID )
    4403             :             {
    4404           0 :                 beans::PropertyValue aPropertyValue;
    4405           0 :                 aPropertyValue.Name = aIt->sName;
    4406           0 :                 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
    4407           0 :                 aPropertyVector.push_back( aPropertyValue );
    4408             :             }
    4409           0 :             ++aIt;
    4410             :         }
    4411           0 :         pItem = aIter.NextItem();
    4412             :     }
    4413             : 
    4414           0 :     const sal_Int32 nCount = aPropertyVector.size();
    4415           0 :     uno::Sequence< beans::PropertyValue > aRet( nCount );
    4416           0 :     beans::PropertyValue* pProps = aRet.getArray();
    4417             : 
    4418           0 :     for ( int i = 0; i < nCount; ++i, pProps++ )
    4419             :     {
    4420           0 :         *pProps = aPropertyVector[i];
    4421             :     }
    4422             : 
    4423           0 :     return aRet;
    4424           0 : }
    4425             : 
    4426             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10