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