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