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