Update ooo320-m1
[ooovba.git] / sw / source / core / unocore / unostyle.cxx
blob6033541f9d803e3212308469e38a61c2a9ce6ebc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unostyle.cxx,v $
10 * $Revision: 1.83.24.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
36 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <svtools/smplhint.hxx>
39 #include <svtools/ctrltool.hxx>
40 #include <svtools/style.hxx>
41 #include <svtools/itemiter.hxx>
42 #include <svx/pageitem.hxx>
43 #include <svx/sizeitem.hxx>
44 #include <svx/ulspitem.hxx>
45 #include <svx/lrspitem.hxx>
46 #include <svx/boxitem.hxx>
47 #include <svx/shaditem.hxx>
48 #include <svx/brshitem.hxx>
49 #include <svx/flstitem.hxx>
50 #include <svx/paperinf.hxx>
51 #include <pagedesc.hxx>
52 #include <doc.hxx>
53 #include <docary.hxx>
54 #include <charfmt.hxx>
55 #include <cmdid.h>
56 #include <unostyle.hxx>
57 #include <unosett.hxx>
58 #include <docsh.hxx>
59 #include <swstyle.h>
60 #include <paratr.hxx>
61 #include <unoprnms.hxx>
62 #include <shellio.hxx>
63 #include <docstyle.hxx>
64 #include <unoobj.hxx>
65 #include <fmthdft.hxx>
66 #include <fmtpdsc.hxx>
67 #include <tools/urlobj.hxx>
68 #ifndef _POOLFMT_HRC
69 #include <poolfmt.hrc>
70 #endif
71 #include <poolfmt.hxx>
72 #include "unoevent.hxx"
73 #include <fmtruby.hxx>
74 #include <SwStyleNameMapper.hxx>
75 #include <sfx2/printer.hxx>
76 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
78 #include <com/sun/star/frame/XModel.hpp>
80 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
81 #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_
82 #include <com/sun/star/beans/PropertyAttribute.hpp>
83 #endif
84 #ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPPP_
85 #include <com/sun/star/beans/NamedValue.hpp>
86 #endif
87 #include <istyleaccess.hxx>
88 #include <GetMetricVal.hxx>
89 #include <fmtfsize.hxx>
90 #include <numrule.hxx>
92 #include <boost/shared_ptr.hpp>
94 #include "ccoll.hxx"
95 #include "unocore.hrc"
97 #include <set>
99 #define STYLE_FAMILY_COUNT 5 // we have 5 style families
100 #define TYPE_BOOL 0
101 #define TYPE_SIZE 1
102 #define TYPE_BRUSH 2
103 #define TYPE_ULSPACE 3
104 #define TYPE_SHADOW 4
105 #define TYPE_LRSPACE 5
106 #define TYPE_BOX 6
108 const unsigned short aStyleByIndex[] =
110 SFX_STYLE_FAMILY_CHAR,
111 SFX_STYLE_FAMILY_PARA,
112 SFX_STYLE_FAMILY_PAGE ,
113 SFX_STYLE_FAMILY_FRAME ,
114 SFX_STYLE_FAMILY_PSEUDO
117 // Already implemented autostyle families: 3
118 #define AUTOSTYLE_FAMILY_COUNT 3
119 const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
121 IStyleAccess::AUTO_STYLE_CHAR,
122 IStyleAccess::AUTO_STYLE_RUBY,
123 IStyleAccess::AUTO_STYLE_PARA
126 using namespace ::com::sun::star;
127 using ::rtl::OUString;
129 /******************************************************************************
131 ******************************************************************************/
133 //convert FN_... to RES_ in header and footer itemset
134 sal_uInt16 lcl_ConvertFNToRES(sal_uInt16 nFNId)
136 sal_uInt16 nRes = USHRT_MAX;
137 switch(nFNId)
139 case FN_UNO_FOOTER_ON:
140 case FN_UNO_HEADER_ON:
141 break;
142 case FN_UNO_FOOTER_BACKGROUND:
143 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND;
144 break;
145 case FN_UNO_FOOTER_BOX:
146 case FN_UNO_HEADER_BOX: nRes = RES_BOX;
147 break;
148 case FN_UNO_FOOTER_LR_SPACE:
149 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
150 break;
151 case FN_UNO_FOOTER_SHADOW:
152 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
153 break;
154 case FN_UNO_FOOTER_BODY_DISTANCE:
155 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
156 break;
157 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
158 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
159 break;
160 case FN_UNO_FOOTER_SHARE_CONTENT:
161 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
162 break;
163 case FN_UNO_FOOTER_HEIGHT:
164 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
165 break;
166 case FN_UNO_FOOTER_EAT_SPACING:
167 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
168 break;
170 return nRes;
174 SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
176 switch ( eFamily )
178 case SFX_STYLE_FAMILY_CHAR:
179 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
180 case SFX_STYLE_FAMILY_PARA:
181 return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
182 case SFX_STYLE_FAMILY_FRAME:
183 return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
184 case SFX_STYLE_FAMILY_PAGE:
185 return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
186 case SFX_STYLE_FAMILY_PSEUDO:
187 return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE;
188 default:
189 DBG_ASSERT(sal_False, "someone asking for all styles in unostyle.cxx!" );
190 return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
194 class SwAutoStylesEnumImpl
196 std::vector<SfxItemSet_Pointer_t> mAutoStyles;
197 std::vector<SfxItemSet_Pointer_t>::iterator aIter;
198 SwDoc* pDoc;
199 IStyleAccess::SwAutoStyleFamily eFamily;
200 public:
201 SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
202 ::sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); }
203 SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
204 IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
205 SwDoc* getDoc() const { return pDoc; }
209 /******************************************************************
210 * SwXStyleFamilies
211 ******************************************************************/
212 /* -----------------------------06.04.00 11:24--------------------------------
214 ---------------------------------------------------------------------------*/
215 OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException )
217 return C2U("SwXStyleFamilies");
219 /* -----------------------------06.04.00 11:24--------------------------------
221 ---------------------------------------------------------------------------*/
222 BOOL SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
224 return C2U("com.sun.star.style.StyleFamilies") == rServiceName;
226 /* -----------------------------06.04.00 11:24--------------------------------
228 ---------------------------------------------------------------------------*/
229 uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException )
231 uno::Sequence< OUString > aRet(1);
232 OUString* pArray = aRet.getArray();
233 pArray[0] = C2U("com.sun.star.style.StyleFamilies");
234 return aRet;
236 /*-- 16.12.98 15:13:26---------------------------------------------------
238 -----------------------------------------------------------------------*/
239 SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
240 SwUnoCollection(rDocShell.GetDoc()),
241 pDocShell(&rDocShell),
242 pxCharStyles(0),
243 pxParaStyles(0),
244 pxFrameStyles(0),
245 pxPageStyles(0),
246 pxNumberingStyles(0)
250 /*-- 16.12.98 15:13:26---------------------------------------------------
252 -----------------------------------------------------------------------*/
253 SwXStyleFamilies::~SwXStyleFamilies()
255 delete pxCharStyles;
256 delete pxParaStyles;
257 delete pxFrameStyles;
258 delete pxPageStyles;
259 delete pxNumberingStyles;
261 /*-- 21.12.98 12:05:22---------------------------------------------------
263 -----------------------------------------------------------------------*/
264 uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
265 throw(
266 container::NoSuchElementException,
267 lang::WrappedTargetException,
268 uno::RuntimeException )
270 vos::OGuard aGuard(Application::GetSolarMutex());
271 // der Index kommt aus const unsigned short aStyleByIndex[] =
272 uno::Any aRet;
273 if(!IsValid())
274 throw uno::RuntimeException();
275 if(Name.compareToAscii("CharacterStyles") == 0 )
276 aRet = getByIndex(0);
277 else if(Name.compareToAscii("ParagraphStyles") == 0)
278 aRet = getByIndex(1);
279 else if(Name.compareToAscii("FrameStyles") == 0 )
280 aRet = getByIndex(3);
281 else if(Name.compareToAscii("PageStyles") == 0 )
282 aRet = getByIndex(2);
283 else if(Name.compareToAscii("NumberingStyles") == 0 )
284 aRet = getByIndex(4);
285 else
286 throw container::NoSuchElementException();
287 return aRet;
289 /*-- 21.12.98 12:05:22---------------------------------------------------
291 -----------------------------------------------------------------------*/
292 uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException )
294 uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT);
295 OUString* pNames = aNames.getArray();
296 pNames[0] = C2U("CharacterStyles");
297 pNames[1] = C2U("ParagraphStyles");
298 pNames[2] = C2U("FrameStyles");
299 pNames[3] = C2U("PageStyles");
300 pNames[4] = C2U("NumberingStyles");
301 return aNames;
303 /*-- 21.12.98 12:05:22---------------------------------------------------
305 -----------------------------------------------------------------------*/
306 sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException )
308 if( Name.compareToAscii("CharacterStyles") == 0 ||
309 Name.compareToAscii("ParagraphStyles") == 0 ||
310 Name.compareToAscii("FrameStyles") == 0 ||
311 Name.compareToAscii("PageStyles") == 0 ||
312 Name.compareToAscii("NumberingStyles") == 0 )
313 return sal_True;
314 else
315 return sal_False;
317 /*-- 16.12.98 15:13:27---------------------------------------------------
319 -----------------------------------------------------------------------*/
320 sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException )
322 return STYLE_FAMILY_COUNT;
324 /*-- 16.12.98 15:13:27---------------------------------------------------
326 -----------------------------------------------------------------------*/
327 uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
328 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
330 vos::OGuard aGuard(Application::GetSolarMutex());
331 uno::Any aRet;
332 if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
333 throw lang::IndexOutOfBoundsException();
334 if(IsValid())
336 uno::Reference< container::XNameContainer > aRef;
337 sal_uInt16 nType = aStyleByIndex[nIndex];
338 switch( nType )
340 case SFX_STYLE_FAMILY_CHAR:
342 if(!pxCharStyles)
344 ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
345 *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
347 aRef = *pxCharStyles;
349 break;
350 case SFX_STYLE_FAMILY_PARA:
352 if(!pxParaStyles)
354 ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
355 *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
357 aRef = *pxParaStyles;
359 break;
360 case SFX_STYLE_FAMILY_PAGE :
362 if(!pxPageStyles)
364 ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
365 *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
367 aRef = *pxPageStyles;
369 break;
370 case SFX_STYLE_FAMILY_FRAME :
372 if(!pxFrameStyles)
374 ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
375 *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
377 aRef = *pxFrameStyles;
379 break;
380 case SFX_STYLE_FAMILY_PSEUDO:
382 if(!pxNumberingStyles)
384 ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
385 *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
387 aRef = *pxNumberingStyles;
389 break;
391 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0));
393 else
394 throw uno::RuntimeException();
395 return aRet;
397 /*-- 16.12.98 15:13:27---------------------------------------------------
399 -----------------------------------------------------------------------*/
400 uno::Type SwXStyleFamilies::getElementType(void)
401 throw( uno::RuntimeException )
403 return ::getCppuType((const uno::Reference<container::XNameContainer>*)0);
406 /*-- 16.12.98 15:13:28---------------------------------------------------
408 -----------------------------------------------------------------------*/
409 sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException )
411 return sal_True;
413 /*-- 16.12.98 15:13:28---------------------------------------------------
415 -----------------------------------------------------------------------*/
416 void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
417 const uno::Sequence< beans::PropertyValue >& aOptions)
418 throw( io::IOException, uno::RuntimeException )
420 vos::OGuard aGuard(Application::GetSolarMutex());
421 sal_Bool bLoadStyleText = sal_True;
422 sal_Bool bLoadStylePage = sal_True;
423 sal_Bool bLoadStyleOverwrite = sal_True;
424 sal_Bool bLoadStyleNumbering = sal_True;
425 sal_Bool bLoadStyleFrame = sal_True;
426 if(IsValid() && rURL.getLength())
428 const uno::Any* pVal;
429 int nCount = aOptions.getLength();
430 const beans::PropertyValue* pArray = aOptions.getConstArray();
431 for(int i = 0; i < nCount; i++)
432 if( ( pVal = &pArray[i].Value)->getValueType() ==
433 ::getBooleanCppuType() )
435 String sName = pArray[i].Name;
436 sal_Bool bVal = *(sal_Bool*)pVal->getValue();
437 if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES )))
438 bLoadStyleOverwrite = bVal;
439 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES )))
440 bLoadStyleNumbering = bVal;
441 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES )))
442 bLoadStylePage = bVal;
443 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES )))
444 bLoadStyleFrame = bVal;
445 else if( sName.EqualsAscii(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES )))
446 bLoadStyleText = bVal;
449 SwgReaderOption aOpt;
450 aOpt.SetFrmFmts( bLoadStyleFrame );
451 aOpt.SetTxtFmts( bLoadStyleText );
452 aOpt.SetPageDescs( bLoadStylePage );
453 aOpt.SetNumRules( bLoadStyleNumbering );
454 aOpt.SetMerge( !bLoadStyleOverwrite );
456 ULONG nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, TRUE );
457 if( nErr )
458 throw io::IOException();
460 else
461 throw uno::RuntimeException();
463 /*-- 16.12.98 15:13:28---------------------------------------------------
465 -----------------------------------------------------------------------*/
466 uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void)
467 throw( uno::RuntimeException )
469 vos::OGuard aGuard(Application::GetSolarMutex());
470 uno::Sequence< beans::PropertyValue > aSeq(5);
471 beans::PropertyValue* pArray = aSeq.getArray();
472 uno::Any aVal;
473 sal_Bool bTemp = sal_True;
474 aVal.setValue(&bTemp, ::getCppuBooleanType());
475 pArray[0] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_TEXT_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
476 aVal.setValue(&bTemp, ::getCppuBooleanType());
477 pArray[1] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_FRAME_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
478 aVal.setValue(&bTemp, ::getCppuBooleanType());
479 pArray[2] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_PAGE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
480 aVal.setValue(&bTemp, ::getCppuBooleanType());
481 pArray[3] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_LOAD_NUMBERING_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
482 aVal.setValue(&bTemp, ::getCppuBooleanType());
483 pArray[4] = beans::PropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_OVERWRITE_STYLES)), -1, aVal, beans::PropertyState_DIRECT_VALUE);
484 return aSeq;
487 /******************************************************************
488 * SwXStyleFamily
489 ******************************************************************/
490 /* -----------------------------06.04.00 11:24--------------------------------
492 ---------------------------------------------------------------------------*/
493 OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException )
495 return C2U("SwXStyleFamily");
497 /* -----------------------------06.04.00 11:24--------------------------------
499 ---------------------------------------------------------------------------*/
500 BOOL SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
502 return C2U("com.sun.star.style.StyleFamily") == rServiceName;
504 /* -----------------------------06.04.00 11:24--------------------------------
506 ---------------------------------------------------------------------------*/
507 uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException )
509 uno::Sequence< OUString > aRet(1);
510 OUString* pArray = aRet.getArray();
511 pArray[0] = C2U("com.sun.star.style.StyleFamily");
512 return aRet;
514 /*-- 16.12.98 16:03:56---------------------------------------------------
516 -----------------------------------------------------------------------*/
517 SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
518 eFamily((SfxStyleFamily)nFamily),
519 pBasePool(pDocSh->GetStyleSheetPool()),
520 pDocShell(pDocSh)
522 /* switch( nFamily )
524 case SFX_STYLE_FAMILY_CHAR:
525 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_CHAR_STYLE);
526 break;
527 case SFX_STYLE_FAMILY_PARA:
528 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PARA_STYLE);
529 break;
530 case SFX_STYLE_FAMILY_PAGE:
531 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PAGE_STYLE);
532 break;
533 case SFX_STYLE_FAMILY_FRAME:
534 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_FRAME_STYLE);
535 break;
536 case SFX_STYLE_FAMILY_PSEUDO:
537 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_NUM_STYLE);
538 break;
540 StartListening(*pBasePool);
542 /*-- 16.12.98 16:03:56---------------------------------------------------
544 -----------------------------------------------------------------------*/
545 SwXStyleFamily::~SwXStyleFamily()
549 sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String *pString, sal_uInt16 nIndex = USHRT_MAX )
551 sal_Int32 nCount = 0;
552 switch( eFamily )
554 case SFX_STYLE_FAMILY_CHAR:
556 sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
557 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
558 nIndex = nIndex - nBaseCount;
559 const sal_uInt16 nArrLen = rDoc.GetCharFmts()->Count();
560 for( sal_uInt16 i = 0; i < nArrLen; i++ )
562 SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
563 if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
564 continue;
565 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
567 if ( nIndex == nCount )
569 // the default character format needs to be set to "Default!"
570 if(rDoc.GetDfltCharFmt() == pFmt)
571 SwStyleNameMapper::FillUIName(
572 RES_POOLCOLL_STANDARD, *pString );
573 else
574 *pString = pFmt->GetName();
575 break;
577 nCount++;
580 nCount += nBaseCount;
582 break;
583 case SFX_STYLE_FAMILY_PARA:
585 sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
586 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
587 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
588 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
589 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
590 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
591 nIndex = nIndex - nBaseCount;
592 const sal_uInt16 nArrLen = rDoc.GetTxtFmtColls()->Count();
593 for ( sal_uInt16 i = 0; i < nArrLen; i++ )
595 SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i];
596 if ( pColl->IsDefault() )
597 continue;
598 if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) )
600 if ( nIndex == nCount )
602 *pString = pColl->GetName();
603 break;
605 nCount++;
608 nCount += nBaseCount;
610 break;
611 case SFX_STYLE_FAMILY_FRAME:
613 sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
614 nIndex = nIndex - nBaseCount;
615 const sal_uInt16 nArrLen = rDoc.GetFrmFmts()->Count();
616 for( sal_uInt16 i = 0; i < nArrLen; i++ )
618 SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
619 if(pFmt->IsDefault() || pFmt->IsAuto())
620 continue;
621 if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
623 if ( nIndex == nCount )
625 *pString = pFmt->GetName();
626 break;
628 nCount++;
631 nCount += nBaseCount;
633 break;
634 case SFX_STYLE_FAMILY_PAGE:
636 sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
637 nIndex = nIndex - nBaseCount;
638 const sal_uInt16 nArrLen = rDoc.GetPageDescCnt();
639 for(sal_uInt16 i = 0; i < nArrLen; ++i)
641 const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
643 /*if(rDesc.IsDefault() || rDesc.IsAuto())
644 continue;*/
645 if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) )
647 if ( nIndex == nCount )
649 *pString = rDesc.GetName();
650 break;
652 nCount++;
655 nCount += nBaseCount;
657 break;
658 case SFX_STYLE_FAMILY_PSEUDO:
660 sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
661 nIndex = nIndex - nBaseCount;
662 const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
663 for(USHORT i = 0; i < rNumTbl.Count(); ++i)
665 const SwNumRule& rRule = *rNumTbl[ i ];
666 if( rRule.IsAutoRule() )
667 continue;
668 if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) )
670 if ( nIndex == nCount )
672 *pString = rRule.GetName();
673 break;
675 nCount++;
678 nCount += nBaseCount;
680 break;
682 default:
685 return nCount;
687 /*-- 16.12.98 16:03:57---------------------------------------------------
689 -----------------------------------------------------------------------*/
690 sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException )
692 vos::OGuard aGuard(Application::GetSolarMutex());
693 return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
695 /*-- 16.12.98 16:03:57---------------------------------------------------
697 -----------------------------------------------------------------------*/
698 uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
699 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
701 vos::OGuard aGuard(Application::GetSolarMutex());
702 uno::Any aRet;
703 if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
705 sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
706 if(pBasePool)
708 String sStyleName;
709 switch( eFamily )
711 case SFX_STYLE_FAMILY_CHAR:
713 if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
714 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
715 else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
716 RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
717 SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
718 - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
719 + nIndex, sStyleName );
721 break;
722 case SFX_STYLE_FAMILY_PARA:
724 if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
725 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName );
726 else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
727 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
728 SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN
729 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
730 + nIndex, sStyleName );
731 else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
732 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
733 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
734 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN
735 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
736 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
737 + nIndex), sStyleName );
738 else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
739 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
740 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
741 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
742 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(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_DOC_END - RES_POOLCOLL_DOC_BEGIN +
748 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
749 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
750 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
751 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
752 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN
753 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
754 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
755 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
756 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
757 + nIndex), sStyleName );
758 else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
759 RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
760 RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
761 RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
762 RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
763 RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
764 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN
765 - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN
766 - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
767 - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
768 - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
769 - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
770 + nIndex), sStyleName );
772 break;
773 case SFX_STYLE_FAMILY_FRAME:
775 if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) )
777 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName );
780 break;
781 case SFX_STYLE_FAMILY_PAGE:
783 if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) )
785 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName );
788 break;
789 case SFX_STYLE_FAMILY_PSEUDO:
791 if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
793 SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
796 break;
798 default:
801 if ( !sStyleName.Len() )
802 lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
804 if ( sStyleName.Len() )
806 SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
807 if(pBase)
809 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
810 if(!xStyle.is())
812 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
813 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
814 eFamily == SFX_STYLE_FAMILY_FRAME ?
815 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
816 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
818 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
820 else
821 throw container::NoSuchElementException();
823 else
824 throw lang::IndexOutOfBoundsException();
826 else
827 throw uno::RuntimeException();
829 else
830 throw lang::IndexOutOfBoundsException();
832 return aRet;
834 /*-- 16.12.98 16:03:57---------------------------------------------------
836 -----------------------------------------------------------------------*/
837 uno::Any SwXStyleFamily::getByName(const OUString& rName)
838 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
840 vos::OGuard aGuard(Application::GetSolarMutex());
841 uno::Any aRet;
842 String sStyleName;
843 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
844 if(pBasePool)
846 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
847 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
848 if(pBase)
850 uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
851 if(!xStyle.is())
853 xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
854 new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
855 eFamily == SFX_STYLE_FAMILY_FRAME ?
856 new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
857 new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
859 aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
861 else
862 throw container::NoSuchElementException();
864 else
865 throw uno::RuntimeException();
866 return aRet;
869 /*-- 16.12.98 16:03:57---------------------------------------------------
871 -----------------------------------------------------------------------*/
872 uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException )
874 vos::OGuard aGuard(Application::GetSolarMutex());
875 uno::Sequence< OUString > aRet;
876 if(pBasePool)
878 SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, 0xffff);
879 sal_uInt16 nCount = pIterator->Count();
880 aRet.realloc(nCount);
881 OUString* pArray = aRet.getArray();
882 String aString;
883 for(sal_uInt16 i = 0; i < nCount; i++)
885 SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
886 pArray[i] = OUString ( aString );
888 delete pIterator;
890 else
891 throw uno::RuntimeException();
892 return aRet;
894 /*-- 16.12.98 16:03:57---------------------------------------------------
896 -----------------------------------------------------------------------*/
897 sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException )
899 vos::OGuard aGuard(Application::GetSolarMutex());
900 sal_Bool bRet = sal_False;
901 if(pBasePool)
903 String sStyleName;
904 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
905 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
906 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
907 bRet = 0 != pBase;
909 else
910 throw uno::RuntimeException();
911 return bRet;
914 /*-- 16.12.98 16:03:58---------------------------------------------------
916 -----------------------------------------------------------------------*/
917 uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException )
919 return ::getCppuType((const uno::Reference<style::XStyle>*)0);
922 /*-- 16.12.98 16:03:58---------------------------------------------------
924 -----------------------------------------------------------------------*/
925 sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException )
927 if(!pBasePool)
928 throw uno::RuntimeException();
929 return sal_True;
931 /*-- 16.12.98 16:03:58---------------------------------------------------
933 -----------------------------------------------------------------------*/
934 void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
935 throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
937 vos::OGuard aGuard(Application::GetSolarMutex());
938 if(pBasePool)
940 String sStyleName;
941 SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
942 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
943 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
944 SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
945 if(pBase || pUINameBase)
946 throw container::ElementExistException();
947 else
949 if(rElement.getValueType().getTypeClass() ==
950 uno::TypeClass_INTERFACE)
952 uno::Reference< uno::XInterface > * pxRef =
953 (uno::Reference< uno::XInterface > *)rElement.getValue();
955 uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
957 SwXStyle* pNewStyle = 0;
958 if(xStyleTunnel.is())
960 pNewStyle = reinterpret_cast< SwXStyle * >(
961 sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
963 if(!pNewStyle || !pNewStyle->IsDescriptor() ||
964 pNewStyle->GetFamily() != eFamily)
965 throw lang::IllegalArgumentException();
966 if(pNewStyle)
968 sal_uInt16 nMask = 0xffff;
969 if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
970 nMask &= ~SWSTYLEBIT_CONDCOLL;
971 #if OSL_DEBUG_LEVEL > 1
972 SfxStyleSheetBase& rNewBase =
973 #endif
974 pBasePool->Make(sStyleName, eFamily, nMask);
975 pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
976 pNewStyle->SetStyleName(sStyleName);
977 String sParentStyleName(pNewStyle->GetParentStyleName());
978 if(sParentStyleName.Len())
980 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
981 SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
982 if(pParentBase && pParentBase->GetFamily() == eFamily &&
983 &pParentBase->GetPool() == pBasePool)
984 pBasePool->SetParent( eFamily, sStyleName, sParentStyleName );
987 #if OSL_DEBUG_LEVEL > 1
988 (void)rNewBase;
989 #endif
990 //so, jetzt sollten noch die Properties des Descriptors angewandt werden
991 pNewStyle->ApplyDescriptorProperties();
993 else
994 throw lang::IllegalArgumentException();
996 else
997 throw lang::IllegalArgumentException();
1000 else
1001 throw uno::RuntimeException();
1003 /*-- 16.12.98 16:03:59---------------------------------------------------
1005 -----------------------------------------------------------------------*/
1006 void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement)
1007 throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
1009 vos::OGuard aGuard(Application::GetSolarMutex());
1010 if(pBasePool)
1012 pBasePool->SetSearchMask(eFamily);
1013 SfxStyleSheetBase* pBase = pBasePool->Find(rName);
1014 //Ersetzung geht nur fuer benutzerdefinierte Styles
1015 if(!pBase)
1016 throw container::NoSuchElementException();
1017 if(!pBase->IsUserDefined())
1018 throw lang::IllegalArgumentException();
1019 //if theres an object available to this style then it must be invalidated
1020 uno::Reference< style::XStyle > xStyle = _FindStyle(pBase->GetName());
1021 if(xStyle.is())
1023 uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
1024 if(xTunnel.is())
1026 SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
1027 sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
1028 pStyle->Invalidate();
1032 pBasePool->Remove(pBase);
1033 insertByName(rName, rElement);
1035 else
1036 throw uno::RuntimeException();
1038 /*-- 16.12.98 16:03:59---------------------------------------------------
1040 -----------------------------------------------------------------------*/
1041 void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
1043 vos::OGuard aGuard(Application::GetSolarMutex());
1044 if(pBasePool)
1046 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1047 String aString;
1048 SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1050 SfxStyleSheetBase* pBase = pBasePool->Find( aString );
1051 if(pBase)
1052 pBasePool->Remove(pBase);
1053 else
1054 throw container::NoSuchElementException();
1056 else
1057 throw uno::RuntimeException();
1060 uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException)
1062 OSL_ENSURE( 0, "###unexpected!" );
1063 return uno::Reference< beans::XPropertySetInfo >();
1066 void SAL_CALL SwXStyleFamily::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
1068 OSL_ENSURE( 0, "###unexpected!" );
1071 uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1073 uno::Any aRet;
1075 if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1077 vos::OGuard aGuard(Application::GetSolarMutex());
1078 sal_uInt32 nResId = 0;
1079 switch ( eFamily )
1081 case SFX_STYLE_FAMILY_CHAR:
1082 nResId = STR_STYLE_FAMILY_CHARACTER; break;
1083 case SFX_STYLE_FAMILY_PARA:
1084 nResId = STR_STYLE_FAMILY_PARAGRAPH; break;
1085 case SFX_STYLE_FAMILY_FRAME:
1086 nResId = STR_STYLE_FAMILY_FRAME; break;
1087 case SFX_STYLE_FAMILY_PAGE:
1088 nResId = STR_STYLE_FAMILY_PAGE; break;
1089 case SFX_STYLE_FAMILY_PSEUDO:
1090 nResId = STR_STYLE_FAMILY_NUMBERING; break;
1091 default:
1092 OSL_ENSURE( 0, "SwXStyleFamily::getPropertyValue(): invalid family" );
1094 if ( nResId > 0 )
1096 OUString sDisplayName( String( SW_RES( nResId ) ) );
1097 aRet = uno::makeAny( sDisplayName );
1100 else
1102 throw beans::UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
1105 return aRet;
1108 void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1110 OSL_ENSURE( 0, "###unexpected!" );
1113 void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1115 OSL_ENSURE( 0, "###unexpected!" );
1118 void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1120 OSL_ENSURE( 0, "###unexpected!" );
1123 void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
1125 OSL_ENSURE( 0, "###unexpected!" );
1129 /*-- 16.12.98 16:03:59---------------------------------------------------
1131 -----------------------------------------------------------------------*/
1132 void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1134 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
1135 if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
1137 pBasePool = 0;
1138 pDocShell = 0;
1139 EndListening(rBC);
1142 /*-- 16.12.98 16:03:59---------------------------------------------------
1144 -----------------------------------------------------------------------*/
1145 SwXStyle* SwXStyleFamily::_FindStyle(const String& rStyleName)const
1147 sal_uInt16 nLCount = pBasePool->GetListenerCount();
1148 SfxListener* pListener = 0;
1149 for( sal_uInt16 i = 0; i < nLCount; i++)
1151 pListener = pBasePool->GetListener( i );
1152 SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
1153 if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
1155 return pTempStyle;
1158 return 0;
1160 /******************************************************************
1162 ******************************************************************/
1163 class SwStyleProperties_Impl
1165 const PropertyEntryVector_t aPropertyEntries;
1166 uno::Any** pAnyArr;
1167 sal_uInt32 nArrLen;
1169 public:
1170 SwStyleProperties_Impl(const SfxItemPropertyMap* _pMap);
1171 ~SwStyleProperties_Impl();
1173 sal_Bool SetProperty(const ::rtl::OUString& rName, uno::Any aVal);
1174 sal_Bool GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny);
1175 sal_Bool ClearProperty( const ::rtl::OUString& rPropertyName );
1176 void ClearAllProperties( );
1177 void GetProperty(const ::rtl::OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
1179 const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
1182 //--------------------------------------------------------------------
1183 //--------------------------------------------------------------------
1184 SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap* pMap) :
1185 // _pMap(pMap),
1186 aPropertyEntries( pMap->getPropertyEntries() ),
1187 nArrLen(0)
1189 nArrLen = aPropertyEntries.size();
1190 //const SfxItemPropertyMap* pTmp = _pMap;
1192 pAnyArr = new uno::Any* [nArrLen];
1193 for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1194 pAnyArr[i] = 0;
1196 //--------------------------------------------------------------------
1197 //--------------------------------------------------------------------
1198 SwStyleProperties_Impl::~SwStyleProperties_Impl()
1200 for ( sal_uInt16 i =0 ; i < nArrLen; i++ )
1201 delete pAnyArr[i];
1202 delete[] pAnyArr;
1205 //--------------------------------------------------------------------
1206 //--------------------------------------------------------------------
1207 sal_Bool SwStyleProperties_Impl::SetProperty(const ::rtl::OUString& rName, uno::Any aVal)
1209 sal_uInt16 nPos = 0;
1210 sal_Bool bRet = sal_False;
1211 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1212 while( aIt != aPropertyEntries.end() )
1214 if(rName == aIt->sName)
1216 delete pAnyArr[nPos];
1217 pAnyArr[nPos] = new uno::Any ( aVal );
1218 bRet = sal_True;
1219 break;
1221 ++nPos;
1222 ++aIt;
1224 return bRet;
1227 sal_Bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
1229 sal_Bool bRet = sal_False;
1230 sal_uInt16 nPos = 0;
1231 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1232 while( aIt != aPropertyEntries.end() )
1234 if( rName == aIt->sName )
1236 delete pAnyArr[nPos];
1237 pAnyArr[ nPos ] = 0;
1238 bRet = sal_True;
1239 break;
1241 ++nPos;
1242 ++aIt;
1244 return bRet;
1246 void SwStyleProperties_Impl::ClearAllProperties( )
1248 for ( sal_uInt16 i = 0; i < nArrLen; i++ )
1250 delete pAnyArr[i];
1251 pAnyArr[ i ] = 0;
1254 //--------------------------------------------------------------------
1255 //--------------------------------------------------------------------
1256 sal_Bool SwStyleProperties_Impl::GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny )
1258 sal_Bool bRet = sal_False;
1259 sal_uInt16 nPos = 0;
1260 PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1261 while( aIt != aPropertyEntries.end() )
1263 if( rName == aIt->sName )
1265 rpAny = pAnyArr[nPos];
1266 bRet = sal_True;
1267 break;
1269 ++aIt;
1272 return bRet;
1275 void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
1277 rAny = rxPropertySet->getPropertyValue( rPropertyName );
1280 /******************************************************************
1282 ******************************************************************/
1283 /* -----------------------------10.03.00 18:02--------------------------------
1285 ---------------------------------------------------------------------------*/
1286 const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
1288 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
1289 return aSeq;
1291 /* -----------------------------10.03.00 18:04--------------------------------
1293 ---------------------------------------------------------------------------*/
1294 sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
1295 throw(uno::RuntimeException)
1297 if( rId.getLength() == 16
1298 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
1299 rId.getConstArray(), 16 ) )
1301 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1303 return 0;
1306 TYPEINIT1(SwXStyle, SfxListener);
1307 /* -----------------------------06.04.00 11:24--------------------------------
1309 ---------------------------------------------------------------------------*/
1310 OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException )
1312 return C2U("SwXStyle");
1314 /* -----------------------------06.04.00 11:24--------------------------------
1316 ---------------------------------------------------------------------------*/
1317 BOOL SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
1319 BOOL bRet = C2U("com.sun.star.style.Style") == rServiceName;
1320 if(!bRet && SFX_STYLE_FAMILY_CHAR == eFamily)
1321 bRet = !rServiceName.compareToAscii("com.sun.star.style.CharacterStyle")||
1322 !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties")||
1323 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian")||
1324 !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex");
1325 if(!bRet && SFX_STYLE_FAMILY_PARA == eFamily)
1326 bRet = (C2U("com.sun.star.style.ParagraphStyle") == rServiceName)||
1327 (C2U("com.sun.star.style.ParagraphProperties") == rServiceName) ||
1328 (C2U("com.sun.star.style.ParagraphPropertiesAsian") == rServiceName) ||
1329 (C2U("com.sun.star.style.ParagraphPropertiesComplex") == rServiceName);
1330 if(!bRet && SFX_STYLE_FAMILY_PAGE == eFamily)
1331 bRet = (C2U("com.sun.star.style.PageStyle") == rServiceName)||
1332 (C2U("com.sun.star.style.PageProperties") == rServiceName);
1334 return bRet;
1336 /* -----------------------------06.04.00 11:24--------------------------------
1338 ---------------------------------------------------------------------------*/
1339 uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException )
1341 long nCount = 1;
1342 if(SFX_STYLE_FAMILY_PARA == eFamily)
1344 nCount = 5;
1345 if(bIsConditional)
1346 nCount++;
1348 else if(SFX_STYLE_FAMILY_CHAR == eFamily)
1349 nCount = 5;
1350 else if(SFX_STYLE_FAMILY_PAGE == eFamily)
1351 nCount = 3;
1352 uno::Sequence< OUString > aRet(nCount);
1353 OUString* pArray = aRet.getArray();
1354 pArray[0] = C2U("com.sun.star.style.Style");
1355 switch(eFamily)
1357 case SFX_STYLE_FAMILY_CHAR:
1358 pArray[1] = C2U("com.sun.star.style.CharacterStyle");
1359 pArray[2] = C2U("com.sun.star.style.CharacterProperties");
1360 pArray[3] = C2U("com.sun.star.style.CharacterPropertiesAsian");
1361 pArray[4] = C2U("com.sun.star.style.CharacterPropertiesComplex");
1362 break;
1363 case SFX_STYLE_FAMILY_PAGE:
1364 pArray[1] = C2U("com.sun.star.style.PageStyle");
1365 pArray[2] = C2U("com.sun.star.style.PageProperties");
1366 break;
1367 case SFX_STYLE_FAMILY_PARA:
1368 pArray[1] = C2U("com.sun.star.style.ParagraphStyle");
1369 pArray[2] = C2U("com.sun.star.style.ParagraphProperties");
1370 pArray[3] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
1371 pArray[4] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
1372 if(bIsConditional)
1373 pArray[5] = C2U("com.sun.star.style.ConditionalParagraphStyle");
1374 break;
1376 default:
1379 return aRet;
1381 /*-- 17.12.98 08:26:49---------------------------------------------------
1383 -----------------------------------------------------------------------*/
1384 SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, BOOL bConditional) :
1385 m_pDoc( pDoc ),
1386 pBasePool(0),
1387 eFamily(eFam),
1388 bIsDescriptor(sal_True),
1389 bIsConditional(bConditional)
1391 // Register ourselves as a listener to the document (via the page descriptor)
1392 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1393 // get the property set for the default style data
1394 // First get the model
1395 uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1396 // Ask the model for it's family supplier interface
1397 uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1398 // Get the style families
1399 uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1401 uno::Any aAny;
1402 sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
1403 switch( eFamily )
1405 case SFX_STYLE_FAMILY_CHAR:
1407 nMapId = PROPERTY_MAP_CHAR_STYLE;
1408 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) ) );
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;
1414 break;
1415 case SFX_STYLE_FAMILY_PARA:
1417 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1418 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) ) );
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;
1424 break;
1425 case SFX_STYLE_FAMILY_PAGE:
1427 nMapId = PROPERTY_MAP_PAGE_STYLE;
1428 aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) ) );
1429 // Get the Frame family (and keep it for later)
1430 aAny >>= mxStyleFamily;
1431 aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1432 aAny >>= mxStyleData;
1434 break;
1435 case SFX_STYLE_FAMILY_FRAME :
1437 nMapId = PROPERTY_MAP_FRAME_STYLE;
1439 break;
1440 case SFX_STYLE_FAMILY_PSEUDO:
1442 nMapId = PROPERTY_MAP_NUM_STYLE;
1444 break;
1446 default:
1449 pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
1453 SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
1454 SwDoc* pDoc, const String& rStyleName) :
1455 m_pDoc(pDoc),
1456 sStyleName(rStyleName),
1457 pBasePool(&rPool),
1458 eFamily(eFam),
1459 bIsDescriptor(sal_False),
1460 bIsConditional(sal_False),
1461 pPropImpl(0)
1463 StartListening(rPool);
1464 if(eFam == SFX_STYLE_FAMILY_PARA)
1466 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1467 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1468 DBG_ASSERT(pBase, "where is the style?" );
1469 if(pBase)
1471 const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
1472 if(nId != USHRT_MAX)
1473 bIsConditional = ::IsConditionalByPoolId( nId );
1474 else
1475 bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
1479 /*-- 17.12.98 08:26:50---------------------------------------------------
1481 -----------------------------------------------------------------------*/
1482 SwXStyle::~SwXStyle()
1484 if(pBasePool)
1485 EndListening(*pBasePool);
1486 delete pPropImpl;
1488 /*-- 17.12.98 08:26:51---------------------------------------------------
1490 -----------------------------------------------------------------------*/
1491 void SwXStyle::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
1493 ClientModify(this, pOld, pNew);
1494 if(!GetRegisteredIn())
1496 m_pDoc = 0;
1497 mxStyleData.clear();
1498 mxStyleFamily.clear();
1501 OUString SwXStyle::getName(void) throw( uno::RuntimeException )
1503 vos::OGuard aGuard(Application::GetSolarMutex());
1504 String aString;
1505 if(pBasePool)
1507 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1508 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1509 DBG_ASSERT(pBase, "where is the style?" );
1510 if(!pBase)
1511 throw uno::RuntimeException();
1512 SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
1514 else
1515 aString = sStyleName;
1516 return OUString (aString);
1518 /*-- 17.12.98 08:26:51---------------------------------------------------
1520 -----------------------------------------------------------------------*/
1521 void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException )
1523 vos::OGuard aGuard(Application::GetSolarMutex());
1524 if(pBasePool)
1526 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1527 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1528 DBG_ASSERT(pBase, "where is the style?" );
1529 sal_Bool bExcept = sal_True;
1530 if(pBase && pBase->IsUserDefined())
1532 rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
1533 bExcept = !xTmp->SetName(rName);
1534 if(!bExcept)
1535 sStyleName = String(rName);
1537 if(bExcept)
1538 throw uno::RuntimeException();
1540 else
1541 sStyleName = String(rName);
1543 /*-- 17.12.98 08:26:51---------------------------------------------------
1545 -----------------------------------------------------------------------*/
1546 sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException )
1548 vos::OGuard aGuard(Application::GetSolarMutex());
1549 sal_Bool bRet = sal_False;
1550 if(pBasePool)
1552 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1553 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1554 //if it is not found it must be non user defined
1555 if(pBase)
1556 bRet = pBase->IsUserDefined();
1558 else
1559 throw uno::RuntimeException();
1560 return bRet;
1562 /*-- 17.12.98 08:26:51---------------------------------------------------
1564 -----------------------------------------------------------------------*/
1565 sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException )
1567 vos::OGuard aGuard(Application::GetSolarMutex());
1568 sal_Bool bRet = sal_False;
1569 if(pBasePool)
1571 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED);
1572 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1573 if(pBase)
1574 bRet = pBase->IsUsed();
1576 else
1577 throw uno::RuntimeException();
1578 return bRet;
1580 /*-- 17.12.98 08:26:52---------------------------------------------------
1582 -----------------------------------------------------------------------*/
1583 OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException )
1585 vos::OGuard aGuard(Application::GetSolarMutex());
1586 String aString;
1587 if(pBasePool)
1589 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
1590 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1591 if(pBase)
1592 aString = pBase->GetParent();
1594 else if(bIsDescriptor)
1595 aString = sParentStyleName;
1596 else
1597 throw uno::RuntimeException();
1598 SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1599 return OUString ( aString );
1601 /*-- 17.12.98 08:26:52---------------------------------------------------
1603 -----------------------------------------------------------------------*/
1604 void SwXStyle::setParentStyle(const OUString& rParentStyle)
1605 throw( container::NoSuchElementException, uno::RuntimeException )
1607 vos::OGuard aGuard(Application::GetSolarMutex());
1608 String sParentStyle;
1609 SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
1610 if(pBasePool)
1612 pBasePool->SetSearchMask(eFamily);
1613 BOOL bExcept = FALSE;
1614 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1615 if(pBase)
1617 rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
1618 //make it a 'real' style - necessary for pooled styles
1619 xBase->GetItemSet();
1620 if(xBase->GetParent() != sParentStyle)
1622 bExcept = !xBase->SetParent(sParentStyle);
1625 else
1626 bExcept = TRUE;
1627 if(bExcept)
1628 throw uno::RuntimeException();
1630 else if(bIsDescriptor)
1632 sParentStyleName = String(sParentStyle);
1635 uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
1636 aAny >>= mxStyleData;
1638 catch ( container::NoSuchElementException& )
1641 catch ( lang::WrappedTargetException& )
1644 catch ( uno::RuntimeException& )
1648 else
1649 throw uno::RuntimeException();
1651 /*-- 17.12.98 08:26:52---------------------------------------------------
1653 -----------------------------------------------------------------------*/
1655 uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional )
1657 uno::Reference< beans::XPropertySetInfo > xRet;
1658 switch( eFamily )
1660 case SFX_STYLE_FAMILY_CHAR:
1662 static uno::Reference< beans::XPropertySetInfo > xCharRef;
1663 if(!xCharRef.is())
1665 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
1667 xRet = xCharRef;
1669 break;
1670 case SFX_STYLE_FAMILY_PARA:
1672 static uno::Reference< beans::XPropertySetInfo > xParaRef;
1673 if(!xParaRef.is())
1675 sal_uInt16 nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1676 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
1678 xRet = xParaRef;
1680 break;
1681 case SFX_STYLE_FAMILY_PAGE :
1683 static uno::Reference< beans::XPropertySetInfo > xPageRef;
1684 if(!xPageRef.is())
1686 xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
1688 xRet = xPageRef;
1690 break;
1691 case SFX_STYLE_FAMILY_FRAME :
1693 static uno::Reference< beans::XPropertySetInfo > xFrameRef;
1694 if(!xFrameRef.is())
1696 xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
1698 xRet = xFrameRef;
1700 break;
1701 case SFX_STYLE_FAMILY_PSEUDO:
1703 static uno::Reference< beans::XPropertySetInfo > xNumRef;
1704 if(!xNumRef.is())
1706 xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
1708 xRet = xNumRef;
1710 break;
1712 default:
1715 return xRet;
1718 uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void)
1719 throw( uno::RuntimeException )
1721 return lcl_getPropertySetInfo( eFamily, bIsConditional );
1723 /* -----------------23.04.99 13:28-------------------
1725 * --------------------------------------------------*/
1726 void SwXStyle::ApplyDescriptorProperties()
1728 bIsDescriptor = sal_False;
1729 mxStyleData.clear();
1730 mxStyleFamily.clear();
1732 const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
1733 PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
1734 while(aIt != rPropertyVector.end())
1736 uno::Any* pAny;
1737 pPropImpl->GetProperty(aIt->sName, pAny);
1738 if(pAny)
1739 setPropertyValue(aIt->sName, *pAny);
1740 ++aIt;
1744 /*-- 18.04.01 13:07:27---------------------------------------------------
1746 -----------------------------------------------------------------------*/
1747 struct SwStyleBase_Impl
1749 SwDoc& rDoc;
1751 const SwPageDesc* pOldPageDesc;
1753 rtl::Reference< SwDocStyleSheet > mxNewBase;
1754 SfxItemSet* pItemSet;
1756 const String& rStyleName;
1757 sal_uInt16 nPDescPos;
1759 SwStyleBase_Impl(SwDoc& rSwDoc, const String& rName) :
1760 rDoc(rSwDoc),
1761 pOldPageDesc(0),
1762 pItemSet(0),
1763 rStyleName(rName),
1764 nPDescPos(0xffff)
1767 ~SwStyleBase_Impl(){ delete pItemSet; }
1769 sal_Bool HasItemSet() {return mxNewBase.is();}
1770 SfxItemSet& GetItemSet()
1772 DBG_ASSERT(mxNewBase.is(), "no SwDocStyleSheet available");
1773 if(!pItemSet)
1774 pItemSet = new SfxItemSet(mxNewBase->GetItemSet());
1775 return *pItemSet;
1778 const SwPageDesc& GetOldPageDesc();
1780 /* -----------------------------25.04.01 12:44--------------------------------
1782 ---------------------------------------------------------------------------*/
1783 const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
1785 if(!pOldPageDesc)
1787 sal_uInt16 i;
1788 sal_uInt16 nPDescCount = rDoc.GetPageDescCnt();
1789 for(i = 0; i < nPDescCount; i++)
1791 const SwPageDesc& rDesc =
1792 const_cast<const SwDoc &>(rDoc).GetPageDesc( i );
1793 if(rDesc.GetName() == rStyleName)
1795 pOldPageDesc = & rDesc;
1796 nPDescPos = i;
1797 break;
1800 if(!pOldPageDesc)
1802 for(i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
1804 const String aFmtName(SW_RES(i));
1805 if(aFmtName == rStyleName)
1807 pOldPageDesc = rDoc.GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
1808 break;
1811 for(i = 0; i < nPDescCount + 1; i++)
1813 const SwPageDesc& rDesc =
1814 const_cast<const SwDoc &>(rDoc).GetPageDesc( i );
1815 if(rDesc.GetName() == rStyleName)
1817 nPDescPos = i;
1818 break;
1823 return *pOldPageDesc;
1826 /* -----------------------------19.04.01 09:44--------------------------------
1828 ---------------------------------------------------------------------------*/
1830 void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
1831 const SfxItemPropertySet& rPropSet,
1832 const uno::Any& rValue,
1833 SwStyleBase_Impl& rBase,
1834 SfxStyleSheetBasePool* pBasePool,
1835 SwDoc* pDoc,
1836 SfxStyleFamily eFamily)
1837 throw(beans::PropertyVetoException, lang::IllegalArgumentException,
1838 lang::WrappedTargetException, uno::RuntimeException)
1841 switch(rEntry.nWID)
1843 case RES_PAPER_BIN:
1845 SfxPrinter *pPrinter = pDoc->getPrinter( true );
1846 OUString sTmp;
1847 sal_uInt16 nBin = USHRT_MAX;
1848 if ( !( rValue >>= sTmp ) )
1849 throw lang::IllegalArgumentException();
1850 if ( sTmp.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "[From printer settings]" ) ) )
1851 nBin = USHRT_MAX-1;
1852 else if ( pPrinter )
1854 for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ )
1856 if (sTmp == OUString ( pPrinter->GetPaperBinName ( i ) ) )
1858 nBin = i;
1859 break;
1863 if ( nBin == USHRT_MAX )
1864 throw lang::IllegalArgumentException();
1865 else
1867 SfxItemSet& rStyleSet = rBase.GetItemSet();
1868 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
1869 aSet.SetParent(&rStyleSet);
1870 rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet);
1871 rStyleSet.Put(aSet);
1874 break;
1875 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
1877 if(rValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) )
1879 uno::Reference< container::XIndexReplace > * pxRulesRef =
1880 (uno::Reference< container::XIndexReplace > *)rValue.getValue();
1882 uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
1884 SwXNumberingRules* pSwXRules = 0;
1885 if(xNumberTunnel.is())
1887 pSwXRules = reinterpret_cast< SwXNumberingRules * >(
1888 sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
1890 if(pSwXRules)
1892 const String* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
1893 const String* pBulletFontNames = pSwXRules->GetBulletFontNames();
1895 SwNumRule aSetRule(*pSwXRules->GetNumRule());
1896 const SwCharFmts* pFmts = pDoc->GetCharFmts();
1897 sal_uInt16 nChCount = pFmts->Count();
1898 for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1901 const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
1902 if(pFmt)
1904 SwNumFmt aFmt(*pFmt);
1906 pCharStyleNames[i] != SwXNumberingRules::GetInvalidStyle() &&
1907 ((pCharStyleNames[i].Len() && !pFmt->GetCharFmt()) ||
1908 pCharStyleNames[i].Len() &&
1909 pFmt->GetCharFmt()->GetName() != pCharStyleNames[i] ))
1912 SwCharFmt* pCharFmt = 0;
1913 if(pCharStyleNames[i].Len())
1915 for(sal_uInt16 j = 0; j< nChCount; j++)
1917 SwCharFmt* pTmp = (*pFmts)[j];
1918 if(pTmp->GetName() == pCharStyleNames[i])
1920 pCharFmt = pTmp;
1921 break;
1924 if(!pCharFmt)
1927 SfxStyleSheetBase* pBase;
1928 pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1929 if(!pBase)
1930 pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1931 pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
1935 aFmt.SetCharFmt( pCharFmt );
1938 //jetzt nochmal fuer Fonts
1939 if(pBulletFontNames[i] != SwXNumberingRules::GetInvalidStyle() &&
1940 ((pBulletFontNames[i].Len() && !pFmt->GetBulletFont()) ||
1941 pBulletFontNames[i].Len() &&
1942 pFmt->GetBulletFont()->GetName() != pBulletFontNames[i] ))
1944 const SvxFontListItem* pFontListItem =
1945 (const SvxFontListItem* )pDoc->GetDocShell()
1946 ->GetItem( SID_ATTR_CHAR_FONTLIST );
1947 const FontList* pList = pFontListItem->GetFontList();
1948 FontInfo aInfo = pList->Get(
1949 pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
1950 Font aFont(aInfo);
1951 aFmt.SetBulletFont(&aFont);
1953 aSetRule.Set( i, &aFmt );
1956 rBase.mxNewBase->SetNumRule(aSetRule);
1959 else
1960 throw lang::IllegalArgumentException();
1962 break;
1963 // case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei
1965 // sal_Int8 nLevel = 0;
1966 // if( rValue >>= nLevel )
1967 // rBase.mxNewBase->GetCollection()->SetOutlineLevel( nLevel );
1968 // else
1969 // rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING );
1971 //break;
1972 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei
1974 sal_Int16 nLevel = 0;
1975 rValue >>= nLevel;
1976 if( 0 <= nLevel && nLevel <= MAXLEVEL)
1977 rBase.mxNewBase->GetCollection()->SetAttrOutlineLevel( nLevel );
1979 break; //<-end,zhaojianwei
1980 case FN_UNO_FOLLOW_STYLE:
1982 OUString sTmp;
1983 rValue >>= sTmp;
1984 String aString;
1985 SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True ) ;
1986 rBase.mxNewBase->SetFollow( aString );
1988 break;
1989 case RES_PAGEDESC :
1990 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
1991 goto put_itemset;
1993 // Sonderbehandlung RES_PAGEDESC
1994 if(rValue.getValueType() != ::getCppuType((const OUString*)0))
1995 throw lang::IllegalArgumentException();
1996 SfxItemSet& rStyleSet = rBase.GetItemSet();
1998 SwFmtPageDesc* pNewDesc = 0;
1999 const SfxPoolItem* pItem;
2000 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
2002 pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
2004 if(!pNewDesc)
2005 pNewDesc = new SwFmtPageDesc();
2006 OUString uDescName;
2007 rValue >>= uDescName;
2008 String sDescName;
2009 SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2010 if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
2012 //sal_uInt16 nCount = pDoc->GetPageDescCnt();
2013 sal_Bool bPut = sal_False;
2014 if(sDescName.Len())
2016 SwPageDesc* pPageDesc = ::GetPageDescByName_Impl(*pDoc, sDescName);
2017 if(pPageDesc)
2019 pPageDesc->Add( pNewDesc );
2020 bPut = sal_True;
2022 else
2024 throw lang::IllegalArgumentException();
2027 if(!bPut)
2029 rStyleSet.ClearItem(RES_BREAK);
2030 rStyleSet.Put(SwFmtPageDesc());
2032 else
2033 rStyleSet.Put(*pNewDesc);
2035 delete pNewDesc;
2037 break;
2038 case FN_UNO_IS_AUTO_UPDATE:
2040 BOOL bAuto = *(sal_Bool*)rValue.getValue();
2041 if(SFX_STYLE_FAMILY_PARA == eFamily)
2042 rBase.mxNewBase->GetCollection()->SetAutoUpdateFmt(bAuto);
2043 else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2044 rBase.mxNewBase->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
2046 break;
2047 case FN_UNO_PARA_STYLE_CONDITIONS:
2049 uno::Sequence< beans::NamedValue > aSeq;
2050 if (!(rValue >>= aSeq))
2051 throw lang::IllegalArgumentException();
2053 DBG_ASSERT(COND_COMMAND_COUNT == 28,
2054 "invalid size of comman count?");
2055 const beans::NamedValue *pSeq = aSeq.getConstArray();
2056 sal_Int32 nLen = aSeq.getLength();
2058 sal_Bool bFailed = sal_False;
2059 SwCondCollItem aCondItem;
2060 for(USHORT i = 0; i < nLen; i++)
2062 OUString aTmp;
2063 if ((pSeq[i].Value >>= aTmp))
2065 // get UI style name from programmatic style name
2066 String aStyleName;
2067 SwStyleNameMapper::FillUIName( aTmp, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True );
2070 // check for correct context and style name
2072 sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name );
2074 pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
2075 sal_Bool bStyleFound = sal_False;
2076 const SfxStyleSheetBase* pBase = pBasePool->First();
2077 while (pBase && !bStyleFound)
2079 if(pBase->GetName() == aStyleName)
2080 bStyleFound = sal_True;
2081 pBase = pBasePool->Next();
2084 if (nIdx == -1 || !bStyleFound)
2086 bFailed = sal_True;
2087 break;
2090 aCondItem.SetStyle( &aStyleName, nIdx);
2092 else
2093 bFailed = sal_True;
2095 if (bFailed)
2096 throw lang::IllegalArgumentException();
2097 rBase.GetItemSet().Put( aCondItem );
2099 break;
2100 case FN_UNO_CATEGORY:
2102 if(!rBase.mxNewBase->IsUserDefined())
2103 throw lang::IllegalArgumentException();
2104 short nSet = 0;
2105 rValue >>= nSet;
2107 sal_uInt16 nId;
2108 switch( nSet )
2110 case style::ParagraphStyleCategory::TEXT:
2111 nId = SWSTYLEBIT_TEXT;
2112 break;
2113 case style::ParagraphStyleCategory::CHAPTER:
2114 nId = SWSTYLEBIT_CHAPTER;
2115 break;
2116 case style::ParagraphStyleCategory::LIST:
2117 nId = SWSTYLEBIT_LIST;
2118 break;
2119 case style::ParagraphStyleCategory::INDEX:
2120 nId = SWSTYLEBIT_IDX;
2121 break;
2122 case style::ParagraphStyleCategory::EXTRA:
2123 nId = SWSTYLEBIT_EXTRA;
2124 break;
2125 case style::ParagraphStyleCategory::HTML:
2126 nId = SWSTYLEBIT_HTML;
2127 break;
2128 default: throw lang::IllegalArgumentException();
2130 rBase.mxNewBase->SetMask( nId|SFXSTYLEBIT_USERDEF );
2132 break;
2133 case SID_SWREGISTER_COLLECTION:
2135 OUString sName;
2136 rValue >>= sName;
2137 SwRegisterItem aReg( sName.getLength() != 0);
2138 aReg.SetWhich(SID_SWREGISTER_MODE);
2139 rBase.GetItemSet().Put(aReg);
2140 String aString;
2141 SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True);
2143 rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
2145 break;
2146 case RES_TXTATR_CJK_RUBY:
2147 if(MID_RUBY_CHARSTYLE == rEntry.nMemberId )
2149 OUString sTmp;
2150 if(rValue >>= sTmp)
2152 SfxItemSet& rStyleSet = rBase.GetItemSet();
2153 SwFmtRuby* pRuby = 0;
2154 const SfxPoolItem* pItem;
2155 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, sal_True, &pItem ) )
2156 pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
2157 if(!pRuby)
2158 pRuby = new SwFmtRuby(aEmptyStr);
2159 String sStyle;
2160 SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2161 pRuby->SetCharFmtName( sTmp );
2162 pRuby->SetCharFmtId( 0 );
2163 if(sTmp.getLength())
2165 sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
2166 pRuby->SetCharFmtId(nId);
2168 rStyleSet.Put(*pRuby);
2169 delete pRuby;
2171 else
2172 throw lang::IllegalArgumentException();
2174 goto put_itemset;
2175 //break;
2176 case RES_PARATR_DROP:
2178 if( MID_DROPCAP_CHAR_STYLE_NAME == rEntry.nMemberId)
2180 if(rValue.getValueType() == ::getCppuType((const OUString*)0))
2182 SfxItemSet& rStyleSet = rBase.GetItemSet();
2184 SwFmtDrop* pDrop = 0;
2185 const SfxPoolItem* pItem;
2186 if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PARATR_DROP, sal_True, &pItem ) )
2187 pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
2188 if(!pDrop)
2189 pDrop = new SwFmtDrop();
2190 OUString uStyle;
2191 rValue >>= uStyle;
2192 String sStyle;
2193 SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
2194 SwDocStyleSheet* pStyle =
2195 (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
2196 if(pStyle)
2197 pDrop->SetCharFmt(pStyle->GetCharFmt());
2198 else
2199 throw lang::IllegalArgumentException();
2200 rStyleSet.Put(*pDrop);
2201 delete pDrop;
2203 else
2204 throw lang::IllegalArgumentException();
2205 break;
2208 //no break!
2209 default:
2210 put_itemset:
2212 SfxItemSet& rStyleSet = rBase.GetItemSet();
2213 SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
2214 aSet.SetParent(&rStyleSet);
2215 rPropSet.setPropertyValue(rEntry, rValue, aSet);
2216 rStyleSet.Put(aSet);
2217 // --> OD 2006-10-18 #i70223#
2218 if ( SFX_STYLE_FAMILY_PARA == eFamily &&
2219 rEntry.nWID == RES_PARATR_NUMRULE &&
2220 rBase.mxNewBase.is() && rBase.mxNewBase->GetCollection() &&
2221 //rBase.mxNewBase->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei
2222 rBase.mxNewBase->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei
2225 OUString sNewNumberingRuleName;
2226 rValue >>= sNewNumberingRuleName;
2227 String sTmp( sNewNumberingRuleName );
2228 if ( sNewNumberingRuleName.getLength() == 0 ||
2229 sTmp != pDoc->GetOutlineNumRule()->GetName() )
2231 // delete assignment to list level of outline style.
2232 //rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
2233 rBase.mxNewBase->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,adde by zhaojianwei
2239 /* -----------------------------18.04.01 13:29--------------------------------
2241 ---------------------------------------------------------------------------*/
2242 void SAL_CALL SwXStyle::SetPropertyValues_Impl(
2243 const uno::Sequence< OUString >& rPropertyNames,
2244 const uno::Sequence< uno::Any >& rValues )
2245 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
2246 lang::WrappedTargetException, uno::RuntimeException)
2248 if ( !m_pDoc )
2249 throw uno::RuntimeException();
2250 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2251 switch(eFamily)
2253 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2254 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2255 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2256 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2257 default:
2260 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2261 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2263 if(rPropertyNames.getLength() != rValues.getLength())
2264 throw lang::IllegalArgumentException();
2266 const OUString* pNames = rPropertyNames.getConstArray();
2267 const uno::Any* pValues = rValues.getConstArray();
2269 SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName);
2270 if(pBasePool)
2272 sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2273 pBasePool->SetSearchMask(eFamily);
2274 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2275 pBasePool->SetSearchMask(eFamily, nSaveMask );
2276 DBG_ASSERT(pBase, "where is the style?" );
2277 if(pBase)
2278 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
2279 else
2280 throw uno::RuntimeException();
2283 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2285 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]);
2287 if(!pEntry ||
2288 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2289 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2290 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2291 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2292 if(aBaseImpl.mxNewBase.is())
2294 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
2295 pBasePool, m_pDoc, eFamily);
2297 else if(bIsDescriptor)
2299 if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
2300 throw lang::IllegalArgumentException();
2302 else
2303 throw uno::RuntimeException();
2305 if(aBaseImpl.HasItemSet())
2306 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
2309 void SwXStyle::setPropertyValues(
2310 const uno::Sequence< OUString >& rPropertyNames,
2311 const uno::Sequence< uno::Any >& rValues )
2312 throw(beans::PropertyVetoException, lang::IllegalArgumentException,
2313 lang::WrappedTargetException, uno::RuntimeException)
2315 vos::OGuard aGuard(Application::GetSolarMutex());
2317 // workaround for bad designed API
2320 SetPropertyValues_Impl( rPropertyNames, rValues );
2322 catch (beans::UnknownPropertyException &rException)
2324 // wrap the original (here not allowed) exception in
2325 // a lang::WrappedTargetException that gets thrown instead.
2326 lang::WrappedTargetException aWExc;
2327 aWExc.TargetException <<= rException;
2328 throw aWExc;
2333 uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
2334 const SfxItemPropertySet& rPropSet,
2335 SwStyleBase_Impl& rBase,
2336 SfxStyleSheetBase* pBase,
2337 SfxStyleFamily eFamily,
2338 SwDoc *pDoc) throw(uno::RuntimeException)
2340 uno::Any aRet;
2341 if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
2343 BOOL bPhys = pBase != 0;
2344 if(pBase)
2346 bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
2347 // The standard character format is not existing physically
2348 if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
2349 ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
2350 ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
2351 bPhys = FALSE;
2353 aRet.setValue(&bPhys, ::getBooleanCppuType());
2355 else if(pBase)
2357 if(!rBase.mxNewBase.is())
2358 rBase.mxNewBase = new SwDocStyleSheet( *(SwDocStyleSheet*)pBase );
2359 switch(rEntry.nWID)
2361 case RES_PAPER_BIN:
2363 SfxItemSet& rSet = rBase.GetItemSet();
2364 rPropSet.getPropertyValue(rEntry, rSet, aRet);
2365 sal_Int8 nBin = 0;
2366 aRet >>= nBin;
2367 if ( nBin == -1 )
2368 aRet <<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) );
2369 else
2371 SfxPrinter *pPrinter = pDoc->getPrinter( false );
2372 OUString sTmp;
2373 if (pPrinter )
2374 sTmp = pPrinter->GetPaperBinName ( nBin );
2375 aRet <<= sTmp;
2378 break;
2379 case FN_UNO_NUM_RULES: //Sonderbehandlung fuer das SvxNumRuleItem:
2381 const SwNumRule* pRule = rBase.mxNewBase->GetNumRule();
2382 DBG_ASSERT(pRule, "Wo ist die NumRule?");
2383 uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule);
2384 aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
2386 break;
2387 //case FN_UNO_DEFAULT_OUTLINE_LEVEL: //#outline level,removed by zahojianwei
2389 // DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2390 // BYTE nLevel = rBase.mxNewBase->GetCollection()->GetOutlineLevel();
2391 // if( nLevel != NO_NUMBERING )
2392 // aRet <<= static_cast<sal_Int8>( nLevel );
2394 //break;
2395 case RES_PARATR_OUTLINELEVEL: //add by zahojianwei
2397 DBG_ASSERT( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2398 int nLevel = rBase.mxNewBase->GetCollection()->GetAttrOutlineLevel();
2399 aRet <<= static_cast<sal_Int16>( nLevel );
2401 break; //<-end,zhaojianwei
2402 case FN_UNO_FOLLOW_STYLE:
2404 String aString;
2405 SwStyleNameMapper::FillProgName(rBase.mxNewBase->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2406 aRet <<= OUString( aString );
2408 break;
2409 case RES_PAGEDESC :
2410 if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
2411 goto query_itemset;
2413 // Sonderbehandlung RES_PAGEDESC
2414 const SfxPoolItem* pItem;
2415 if(SFX_ITEM_SET == rBase.GetItemSet().GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
2417 const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
2418 if(pDesc)
2420 String aString;
2421 SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, sal_True );
2422 aRet <<= OUString( aString );
2426 break;
2427 case FN_UNO_IS_AUTO_UPDATE:
2429 BOOL bAuto = FALSE;
2430 if(SFX_STYLE_FAMILY_PARA == eFamily)
2431 bAuto = rBase.mxNewBase->GetCollection()->IsAutoUpdateFmt();
2432 else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2433 bAuto = rBase.mxNewBase->GetFrmFmt()->IsAutoUpdateFmt();
2434 aRet.setValue(&bAuto, ::getBooleanCppuType());
2436 break;
2437 case FN_UNO_DISPLAY_NAME:
2439 OUString sName(rBase.mxNewBase->GetDisplayName());
2440 aRet <<= sName;
2442 break;
2443 case FN_UNO_PARA_STYLE_CONDITIONS:
2445 DBG_ASSERT(COND_COMMAND_COUNT == 28,
2446 "invalid size of comman count?");
2447 //SfxItemSet& rStyleSet = rBase.GetItemSet();
2448 uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
2449 beans::NamedValue *pSeq = aSeq.getArray();
2451 SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection();
2452 const CommandStruct *pCmds = SwCondCollItem::GetCmds();
2453 for (USHORT n = 0; n < COND_COMMAND_COUNT; ++n)
2455 String aStyleName;
2457 const SwCollCondition* pCond = 0;
2458 if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
2459 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
2460 HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
2461 && pCond->GetTxtFmtColl() )
2463 // get programmatic style name from UI style name
2464 aStyleName = pCond->GetTxtFmtColl()->GetName();
2465 SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), sal_True);
2468 pSeq[n].Name = GetCommandContextByIndex(n);
2469 pSeq[n].Value <<= rtl::OUString( aStyleName );
2471 aRet <<= aSeq;
2473 break;
2474 case FN_UNO_CATEGORY:
2476 sal_uInt16 nPoolId = rBase.mxNewBase->GetCollection()->GetPoolFmtId();
2477 short nRet = -1;
2478 switch ( COLL_GET_RANGE_BITS & nPoolId )
2480 case COLL_TEXT_BITS:
2481 nRet = style::ParagraphStyleCategory::TEXT;
2482 break;
2483 case COLL_DOC_BITS:
2484 nRet = style::ParagraphStyleCategory::CHAPTER;
2485 break;
2486 case COLL_LISTS_BITS:
2487 nRet = style::ParagraphStyleCategory::LIST;
2488 break;
2489 case COLL_REGISTER_BITS:
2490 nRet = style::ParagraphStyleCategory::INDEX;
2491 break;
2492 case COLL_EXTRA_BITS:
2493 nRet = style::ParagraphStyleCategory::EXTRA;
2494 break;
2495 case COLL_HTML_BITS:
2496 nRet = style::ParagraphStyleCategory::HTML;
2497 break;
2499 aRet <<= nRet;
2501 break;
2502 case SID_SWREGISTER_COLLECTION:
2504 const SwPageDesc *pPageDesc = rBase.mxNewBase->GetPageDesc();
2505 const SwTxtFmtColl* pCol = 0;
2506 String aString;
2507 if( pPageDesc )
2508 pCol = pPageDesc->GetRegisterFmtColl();
2509 if( pCol )
2510 SwStyleNameMapper::FillProgName(
2511 pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, sal_True );
2512 aRet <<= OUString ( aString );
2514 break;
2515 default:
2516 query_itemset:
2518 SfxItemSet& rSet = rBase.GetItemSet();
2519 rPropSet.getPropertyValue(rEntry, rSet, aRet);
2523 else
2524 throw uno::RuntimeException();
2525 return aRet;
2527 /* -----------------------------19.04.01 09:26--------------------------------
2529 ---------------------------------------------------------------------------*/
2530 uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
2531 const uno::Sequence< OUString > & rPropertyNames )
2532 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2534 if ( !m_pDoc )
2535 throw uno::RuntimeException();
2536 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2537 switch(eFamily)
2539 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2540 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2541 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2542 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2543 default:
2546 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2547 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2549 const OUString* pNames = rPropertyNames.getConstArray();
2550 uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
2551 uno::Any* pRet = aRet.getArray();
2552 SwStyleBase_Impl aBase(*m_pDoc, sStyleName);
2553 SfxStyleSheetBase* pBase = 0;
2554 for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2556 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp]);
2557 if(!pEntry ||
2558 (!bIsConditional && pNames[nProp].equalsAsciiL(SW_PROP_NAME(UNO_NAME_PARA_STYLE_CONDITIONS))))
2559 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2560 if(pBasePool)
2562 if(!pBase)
2564 sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2565 pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
2566 pBase = pBasePool->Find(sStyleName);
2567 pBasePool->SetSearchMask(eFamily, nSaveMask );
2569 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() );
2571 else if(bIsDescriptor)
2573 uno::Any *pAny = 0;
2574 pPropImpl->GetProperty ( pNames[nProp], pAny );
2575 if( !pAny )
2577 sal_Bool bExcept = sal_False;
2578 switch( eFamily )
2580 case SFX_STYLE_FAMILY_PSEUDO:
2581 bExcept = sal_True;
2582 break;
2583 case SFX_STYLE_FAMILY_PARA:
2584 case SFX_STYLE_FAMILY_PAGE:
2585 pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
2586 break;
2587 case SFX_STYLE_FAMILY_CHAR:
2588 case SFX_STYLE_FAMILY_FRAME :
2590 if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END )
2592 SwFmt * pFmt;
2593 if ( eFamily == SFX_STYLE_FAMILY_CHAR )
2594 pFmt = m_pDoc->GetDfltCharFmt();
2595 else
2596 pFmt = m_pDoc->GetDfltFrmFmt();
2597 const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool();
2598 const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID );
2599 rItem.QueryValue ( pRet[nProp], pEntry->nMemberId );
2601 else
2602 bExcept = sal_True;
2604 break;
2606 default:
2609 if (bExcept )
2611 uno::RuntimeException aExcept;
2612 aExcept.Message = OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames[nProp];
2613 throw aExcept;
2616 else
2617 pRet [ nProp ] = *pAny;
2619 else
2620 throw uno::RuntimeException();
2622 return aRet;
2624 /* -----------------------------04.11.03 09:26--------------------------------
2626 ---------------------------------------------------------------------------*/
2627 uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
2628 const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException)
2630 vos::OGuard aGuard(Application::GetSolarMutex());
2631 uno::Sequence< uno::Any > aValues;
2633 // workaround for bad designed API
2636 aValues = GetPropertyValues_Impl( rPropertyNames );
2638 catch (beans::UnknownPropertyException &)
2640 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2642 catch (lang::WrappedTargetException &)
2644 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
2647 return aValues;
2649 /*-- 18.04.01 13:07:29---------------------------------------------------
2650 -----------------------------------------------------------------------*/
2651 void SwXStyle::addPropertiesChangeListener(
2652 const uno::Sequence< OUString >& /*aPropertyNames*/,
2653 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2654 throw(uno::RuntimeException)
2657 /*-- 18.04.01 13:07:30---------------------------------------------------
2659 -----------------------------------------------------------------------*/
2660 void SwXStyle::removePropertiesChangeListener(
2661 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2662 throw(uno::RuntimeException)
2665 /*-- 18.04.01 13:07:30---------------------------------------------------
2667 -----------------------------------------------------------------------*/
2668 void SwXStyle::firePropertiesChangeEvent(
2669 const uno::Sequence< OUString >& /*aPropertyNames*/,
2670 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2671 throw(uno::RuntimeException)
2674 /*-- 17.12.98 08:26:53---------------------------------------------------
2676 -----------------------------------------------------------------------*/
2677 void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
2678 throw( beans::UnknownPropertyException,
2679 beans::PropertyVetoException,
2680 lang::IllegalArgumentException,
2681 lang::WrappedTargetException,
2682 uno::RuntimeException)
2684 vos::OGuard aGuard(Application::GetSolarMutex());
2685 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2686 const uno::Sequence<uno::Any> aValues(&rValue, 1);
2687 SetPropertyValues_Impl( aProperties, aValues );
2689 /*-- 17.12.98 08:26:53---------------------------------------------------
2691 -----------------------------------------------------------------------*/
2692 uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName)
2693 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2695 vos::OGuard aGuard(Application::GetSolarMutex());
2696 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2697 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
2700 /*-- 17.12.98 08:26:53---------------------------------------------------
2702 -----------------------------------------------------------------------*/
2703 void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/,
2704 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2705 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2707 DBG_WARNING("not implemented");
2709 /*-- 17.12.98 08:26:54---------------------------------------------------
2711 -----------------------------------------------------------------------*/
2712 void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/,
2713 const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2714 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2716 DBG_WARNING("not implemented");
2718 /*-- 17.12.98 08:26:54---------------------------------------------------
2720 -----------------------------------------------------------------------*/
2721 void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/,
2722 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2723 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2725 DBG_WARNING("not implemented");
2727 /*-- 17.12.98 08:26:54---------------------------------------------------
2729 -----------------------------------------------------------------------*/
2730 void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/,
2731 const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2732 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2734 DBG_WARNING("not implemented");
2737 /*-- 08.03.99 10:50:26---------------------------------------------------
2739 -----------------------------------------------------------------------*/
2740 beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName)
2741 throw( beans::UnknownPropertyException, uno::RuntimeException )
2743 vos::OGuard aGuard(Application::GetSolarMutex());
2745 uno::Sequence< OUString > aNames(1);
2746 OUString* pNames = aNames.getArray();
2747 pNames[0] = rPropertyName;
2748 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
2749 return aStates.getConstArray()[0];
2751 /*-- 08.03.99 10:50:27---------------------------------------------------
2753 -----------------------------------------------------------------------*/
2754 uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
2755 const uno::Sequence< OUString >& rPropertyNames)
2756 throw( beans::UnknownPropertyException, uno::RuntimeException )
2758 vos::OGuard aGuard(Application::GetSolarMutex());
2759 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
2760 beans::PropertyState* pStates = aRet.getArray();
2761 if(pBasePool)
2763 pBasePool->SetSearchMask(eFamily );
2764 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2765 DBG_ASSERT(pBase, "where is the style?" );
2767 if(pBase)
2769 const OUString* pNames = rPropertyNames.getConstArray();
2770 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2771 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2772 switch(eFamily)
2774 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2775 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2776 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
2777 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2778 default:
2781 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2782 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2784 SfxItemSet aSet = xStyle->GetItemSet();
2785 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
2787 const String& rPropName = pNames[i];
2788 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( rPropName);
2789 if(!pEntry)
2790 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
2791 if( FN_UNO_NUM_RULES == pEntry->nWID ||
2792 FN_UNO_FOLLOW_STYLE == pEntry->nWID )
2794 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2796 // else if( FN_UNO_DEFAULT_OUTLINE_LEVEL == pEntry->nWID ) //#outline level,removed by zahojianwei
2797 // {
2798 // pStates[i] =
2799 // ( xStyle->GetCollection()->GetOutlineLevel()
2800 // == NO_NUMBERING )
2801 // ? beans::PropertyState_DEFAULT_VALUE
2802 // : beans::PropertyState_DIRECT_VALUE;
2803 // } //<-end,zhaojianwei
2804 else if(SFX_STYLE_FAMILY_PAGE == eFamily &&
2805 (rPropName.EqualsAscii("Header", 0, 6)
2806 || rPropName.EqualsAscii("Footer", 0, 6)))
2808 sal_uInt16 nResId = lcl_ConvertFNToRES(pEntry->nWID);
2809 BOOL bFooter = rPropName.EqualsAscii("Footer", 0, 6);
2810 const SvxSetItem* pSetItem;
2811 if(SFX_ITEM_SET == aSet.GetItemState(
2812 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
2813 sal_False, (const SfxPoolItem**)&pSetItem))
2815 const SfxItemSet& rSet = pSetItem->GetItemSet();
2816 SfxItemState eState = rSet.GetItemState(nResId, sal_False);
2817 if(SFX_ITEM_SET == eState)
2818 pStates[i] = beans::PropertyState_DIRECT_VALUE;
2819 else
2820 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2822 else
2823 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2825 else
2827 pStates[i] = pPropSet->getPropertyState(*pEntry, aSet);
2828 if( SFX_STYLE_FAMILY_PAGE == eFamily &&
2829 SID_ATTR_PAGE_SIZE == pEntry->nWID &&
2830 beans::PropertyState_DIRECT_VALUE == pStates[i] )
2832 const SvxSizeItem& rSize =
2833 static_cast < const SvxSizeItem& >(
2834 aSet.Get(SID_ATTR_PAGE_SIZE) );
2835 sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
2836 if( ( LONG_MAX == rSize.GetSize().Width() &&
2837 (MID_SIZE_WIDTH == nMemberId ||
2838 MID_SIZE_SIZE == nMemberId ) ) ||
2839 ( LONG_MAX == rSize.GetSize().Height() &&
2840 MID_SIZE_HEIGHT == nMemberId ) )
2842 pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2848 else
2849 throw uno::RuntimeException();
2851 else
2852 throw uno::RuntimeException();
2853 return aRet;
2855 /*-- 08.03.99 10:50:27---------------------------------------------------
2857 -----------------------------------------------------------------------*/
2858 void SwXStyle::setPropertyToDefault(const OUString& rPropertyName)
2859 throw( beans::UnknownPropertyException, uno::RuntimeException )
2861 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2862 setPropertiesToDefault ( aSequence );
2865 void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
2866 throw (beans::UnknownPropertyException, uno::RuntimeException)
2868 vos::OGuard aGuard(Application::GetSolarMutex());
2869 SwFmt *pTargetFmt = 0;
2871 if(pBasePool)
2873 pBasePool->SetSearchMask(eFamily);
2874 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2875 DBG_ASSERT(pBase, "Where is the style?");
2877 if(pBase)
2879 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2880 switch(eFamily)
2882 case SFX_STYLE_FAMILY_CHAR: pTargetFmt = xStyle->GetCharFmt(); break;
2883 case SFX_STYLE_FAMILY_PARA: pTargetFmt = xStyle->GetCollection(); break;
2884 case SFX_STYLE_FAMILY_FRAME: pTargetFmt = xStyle->GetFrmFmt(); break;
2885 case SFX_STYLE_FAMILY_PAGE:
2887 sal_uInt16 nPgDscPos = USHRT_MAX;
2888 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
2889 if( pDesc )
2890 pTargetFmt = &pDesc->GetMaster();
2892 break;
2893 case SFX_STYLE_FAMILY_PSEUDO:
2894 break;
2895 default:
2900 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2901 switch(eFamily)
2903 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2904 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
2905 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
2906 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
2907 default:
2910 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2911 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
2913 const OUString* pNames = aPropertyNames.getConstArray();
2915 if ( pTargetFmt )
2917 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
2919 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
2920 if( !pEntry )
2921 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2922 if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES )
2923 throw uno::RuntimeException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Cannot reset: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2924 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY )
2925 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertiesToDefault: property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2927 //if( pEntry->nWID == FN_UNO_DEFAULT_OUTLINE_LEVEL ) //#outline level, removed by zhaojianwei
2928 // static_cast<SwTxtFmtColl*>(pTargetFmt)->SetOutlineLevel( NO_NUMBERING );
2929 //else
2930 // pTargetFmt->ResetFmtAttr( pEntry->nWID );
2931 if( pEntry->nWID == RES_PARATR_OUTLINELEVEL ) //add by zhaojianwei
2932 static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
2933 else
2934 pTargetFmt->ResetFmtAttr( pEntry->nWID ); //<-end,zhaojianwei
2937 else if ( bIsDescriptor )
2939 for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
2940 pPropImpl->ClearProperty ( pNames[ nProp ] );
2944 void SAL_CALL SwXStyle::setAllPropertiesToDefault( )
2945 throw (uno::RuntimeException)
2947 vos::OGuard aGuard(Application::GetSolarMutex());
2948 if(pBasePool)
2950 pBasePool->SetSearchMask(eFamily);
2951 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2952 DBG_ASSERT(pBase, "where is the style, you fiend!?");
2954 if(pBase)
2956 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2958 SwFmt *pTargetFmt = 0;
2959 sal_uInt16 nPgDscPos = USHRT_MAX;
2960 switch( eFamily )
2962 case SFX_STYLE_FAMILY_CHAR :
2963 pTargetFmt = xStyle->GetCharFmt();
2964 break;
2965 case SFX_STYLE_FAMILY_PARA :
2967 pTargetFmt = xStyle->GetCollection();
2968 // --> OD 2007-07-25 #132402# - make code robust
2969 if ( xStyle->GetCollection() )
2971 // xStyle->GetCollection()->SetOutlineLevel( NO_NUMBERING ); //#outline level,removed by zhaojianwei
2972 xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle(); //<-end,add by zhaojianwei
2974 // <--
2976 break;
2977 case SFX_STYLE_FAMILY_FRAME:
2978 pTargetFmt = xStyle->GetFrmFmt();
2979 break;
2980 case SFX_STYLE_FAMILY_PAGE:
2982 SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
2983 if( pDesc )
2985 pTargetFmt = &pDesc->GetMaster();
2986 pDesc->SetUseOn ( nsUseOnPage::PD_ALL );
2989 break;
2990 case SFX_STYLE_FAMILY_PSEUDO:
2991 break;
2993 default:
2996 if( pTargetFmt )
2998 if( USHRT_MAX != nPgDscPos )
3000 SwPageDesc& rPageDesc = m_pDoc->_GetPageDesc(nPgDscPos);
3001 rPageDesc.ResetAllMasterAttr();
3003 SvxLRSpaceItem aLR(RES_LR_SPACE);
3004 sal_Int32 nSize = GetMetricVal ( CM_1) * 2;
3005 aLR.SetLeft ( nSize );
3006 aLR.SetLeft ( nSize );
3007 SvxULSpaceItem aUL( RES_UL_SPACE );
3008 aUL.SetUpper ( static_cast < sal_uInt16 > ( nSize ) );
3009 aUL.SetLower ( static_cast < sal_uInt16 > ( nSize ) );
3010 pTargetFmt->SetFmtAttr( aLR );
3011 pTargetFmt->SetFmtAttr( aUL );
3013 SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
3014 SwFmtFrmSize aFrmSz( ATT_FIX_SIZE );
3015 if( RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId() )
3017 if( m_pDoc->getPrinter( false ) )
3019 const Size aPhysSize( SvxPaperInfo::GetPaperSize(
3020 static_cast<Printer*>( m_pDoc->getPrinter( false ) )) );
3021 aFrmSz.SetSize( aPhysSize );
3023 else
3025 // --> OD 2008-07-25 #i91928#
3026 // aFrmSz.SetWidth( LONG_MAX );
3027 // aFrmSz.SetHeight( LONG_MAX );
3028 aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() );
3029 // <--
3033 else
3035 aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
3037 if( pStdPgDsc->GetLandscape() )
3039 SwTwips nTmp = aFrmSz.GetHeight();
3040 aFrmSz.SetHeight( aFrmSz.GetWidth() );
3041 aFrmSz.SetWidth( nTmp );
3043 pTargetFmt->SetFmtAttr( aFrmSz );
3045 else
3047 // --> OD 2007-01-25 #i73790# - method renamed
3048 pTargetFmt->ResetAllFmtAttr();
3049 // <--
3052 if( USHRT_MAX != nPgDscPos )
3053 m_pDoc->ChgPageDesc( nPgDscPos,
3054 const_cast<const SwDoc *>(m_pDoc)
3055 ->GetPageDesc(nPgDscPos) );
3059 else
3060 throw uno::RuntimeException();
3062 else if ( bIsDescriptor )
3063 pPropImpl->ClearAllProperties();
3064 else
3065 throw uno::RuntimeException();
3068 uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
3069 throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3071 vos::OGuard aGuard(Application::GetSolarMutex());
3072 sal_Int32 nCount = aPropertyNames.getLength();
3073 uno::Sequence < uno::Any > aRet ( nCount );
3074 if ( nCount )
3076 if( pBasePool)
3078 pBasePool->SetSearchMask(eFamily);
3079 SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
3080 DBG_ASSERT(pBase, "Doesn't seem to be a style!");
3082 if(pBase)
3084 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3085 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
3086 switch(eFamily)
3088 case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3089 case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3090 case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3091 case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
3092 default:
3095 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3096 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3098 const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent();
3099 const OUString *pNames = aPropertyNames.getConstArray();
3100 uno::Any *pRet = aRet.getArray();
3101 for ( sal_Int32 i = 0 ; i < nCount; i++)
3103 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[i] );
3104 if ( !pEntry )
3105 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) );
3107 if( pParentSet )
3108 aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]);
3109 else if( pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID) )
3111 const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID);
3112 rItem.QueryValue(pRet[i], pEntry->nMemberId);
3116 else
3117 throw uno::RuntimeException();
3119 else
3120 throw uno::RuntimeException();
3122 return aRet;
3124 /*-- 08.03.99 10:50:27---------------------------------------------------
3126 -----------------------------------------------------------------------*/
3127 uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName)
3128 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3130 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
3131 return getPropertyDefaults ( aSequence ).getConstArray()[0];
3133 /* -----------------21.01.99 13:08-------------------
3135 * --------------------------------------------------*/
3136 void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3138 SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
3139 if( pHint )
3141 if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
3143 pBasePool = 0;
3144 EndListening(rBC);
3146 else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) )
3148 ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily);
3149 SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(sStyleName);
3150 if(!pOwnBase)
3152 EndListening(rBC);
3153 Invalidate();
3158 /* -----------------------------15.08.00 11:35--------------------------------
3160 ---------------------------------------------------------------------------*/
3161 void SwXStyle::Invalidate()
3163 sStyleName.Erase();
3164 pBasePool = 0;
3165 m_pDoc = 0;
3166 mxStyleData.clear();
3167 mxStyleFamily.clear();
3171 /******************************************************************
3172 * SwXPageStyle
3173 ******************************************************************/
3174 /*-- 17.12.98 08:43:35---------------------------------------------------
3176 -----------------------------------------------------------------------*/
3177 SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
3178 SwDocShell* pDocSh, SfxStyleFamily eFam,
3179 const String& rStyleName)://, const SfxItemPropertyMap* _pMap) :
3180 SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName),//, _pMap),
3181 pDocShell(pDocSh)
3185 /* -----------------23.08.99 15:52-------------------
3187 --------------------------------------------------*/
3188 SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) :
3189 SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE),
3190 pDocShell(pDocSh)
3194 /*-- 17.12.98 08:43:35---------------------------------------------------
3196 -----------------------------------------------------------------------*/
3197 SwXPageStyle::~SwXPageStyle()
3201 /* -----------------------------18.04.01 13:50--------------------------------
3203 ---------------------------------------------------------------------------*/
3204 void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
3205 const uno::Sequence< OUString >& rPropertyNames,
3206 const uno::Sequence< uno::Any >& rValues )
3207 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException,
3208 lang::WrappedTargetException, uno::RuntimeException)
3210 if(!GetDoc())
3211 throw uno::RuntimeException();
3213 if(rPropertyNames.getLength() != rValues.getLength())
3214 throw lang::IllegalArgumentException();
3216 const OUString* pNames = rPropertyNames.getConstArray();
3217 const uno::Any* pValues = rValues.getConstArray();
3218 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3219 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3220 SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName());
3221 if(GetBasePool())
3223 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3224 GetBasePool()->SetSearchMask(GetFamily());
3225 SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
3226 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3227 DBG_ASSERT(pBase, "where is the style?" );
3228 if(pBase)
3229 aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
3230 else
3231 throw uno::RuntimeException();
3234 for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
3236 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
3237 if (!pEntry)
3238 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3239 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3240 throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3242 if(GetBasePool())
3244 switch(pEntry->nWID)
3246 case FN_UNO_HEADER_ON:
3247 case FN_UNO_HEADER_BACKGROUND:
3248 case FN_UNO_HEADER_BOX:
3249 case FN_UNO_HEADER_LR_SPACE:
3250 case FN_UNO_HEADER_SHADOW:
3251 case FN_UNO_HEADER_BODY_DISTANCE:
3252 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
3253 case FN_UNO_HEADER_SHARE_CONTENT:
3254 case FN_UNO_HEADER_HEIGHT:
3255 case FN_UNO_HEADER_EAT_SPACING:
3257 case FN_UNO_FOOTER_ON:
3258 case FN_UNO_FOOTER_BACKGROUND:
3259 case FN_UNO_FOOTER_BOX:
3260 case FN_UNO_FOOTER_LR_SPACE:
3261 case FN_UNO_FOOTER_SHADOW:
3262 case FN_UNO_FOOTER_BODY_DISTANCE:
3263 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
3264 case FN_UNO_FOOTER_SHARE_CONTENT:
3265 case FN_UNO_FOOTER_HEIGHT:
3266 case FN_UNO_FOOTER_EAT_SPACING:
3268 sal_Bool bSetItem = sal_False;
3269 sal_Bool bFooter = sal_False;
3270 sal_uInt16 nItemType = TYPE_BOOL;
3271 sal_uInt16 nRes = 0;
3272 switch(pEntry->nWID)
3274 case FN_UNO_FOOTER_ON: bFooter = sal_True;
3275 //kein break;
3276 case FN_UNO_HEADER_ON: nRes = SID_ATTR_PAGE_ON;
3277 break;
3278 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True;
3279 // kein break;
3280 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND; nItemType = TYPE_BRUSH;
3281 break;
3282 case FN_UNO_FOOTER_BOX: bFooter = sal_True;
3283 // kein break;
3284 case FN_UNO_HEADER_BOX: nRes = RES_BOX; nItemType = TYPE_BOX;
3285 break;
3286 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3287 // kein break;
3288 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;nItemType = TYPE_LRSPACE;
3289 break;
3290 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3291 // kein break;
3292 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;nItemType = TYPE_SHADOW;
3293 break;
3294 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3295 // kein break;
3296 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;nItemType = TYPE_ULSPACE;
3297 break;
3298 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3299 // kein break;
3300 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3301 break;
3302 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3303 // kein break;
3304 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3305 break;
3306 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3307 // kein break;
3308 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;nItemType = TYPE_SIZE;
3309 break;
3310 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True;
3311 // kein break;
3312 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;nItemType = TYPE_SIZE;
3313 break;
3315 const SvxSetItem* pSetItem;
3316 if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
3317 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3318 sal_False, (const SfxPoolItem**)&pSetItem))
3320 SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone();
3321 SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
3322 const SfxPoolItem* pItem = 0;
3323 SfxPoolItem* pNewItem = 0;
3324 rSetSet.GetItemState(nRes, sal_True, &pItem);
3325 if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes))
3326 pItem = &rSetSet.GetPool()->GetDefaultItem(nRes);
3327 if(pItem)
3329 pNewItem = pItem->Clone();
3331 else
3333 switch(nItemType)
3335 case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes); break;
3336 case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes); break;
3337 case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes); break;
3338 case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break;
3339 case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes); break;
3340 case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break;
3341 case TYPE_BOX: pNewItem = new SvxBoxItem(nRes); break;
3344 bSetItem = pNewItem->PutValue(pValues[nProp], pEntry->nMemberId);
3345 rSetSet.Put(*pNewItem);
3346 aBaseImpl.GetItemSet().Put(*pNewSetItem);
3347 delete pNewItem;
3348 delete pNewSetItem;
3350 else if(SID_ATTR_PAGE_ON == nRes )
3352 sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue();
3353 if(bVal)
3355 SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
3356 RES_BACKGROUND, RES_SHADOW,
3357 RES_LR_SPACE, RES_UL_SPACE,
3358 nRes, nRes,
3359 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
3360 SID_ATTR_PAGE_DYNAMIC, SID_ATTR_PAGE_DYNAMIC,
3361 SID_ATTR_PAGE_SHARED, SID_ATTR_PAGE_SHARED,
3362 0 );
3363 aTempSet.Put(SfxBoolItem(nRes, sal_True));
3364 aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
3365 aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
3366 aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
3367 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True));
3368 aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True));
3370 SvxSetItem aNewSetItem( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3371 aTempSet);
3372 aBaseImpl.GetItemSet().Put(aNewSetItem);
3376 break;
3377 case FN_PARAM_FTN_INFO :
3379 const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
3380 SfxPoolItem* pNewFtnItem = rItem.Clone();
3381 sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
3382 aBaseImpl.GetItemSet().Put(*pNewFtnItem);
3383 delete pNewFtnItem;
3384 if(!bPut)
3385 throw lang::IllegalArgumentException();
3387 break;
3388 case FN_UNO_HEADER :
3389 case FN_UNO_HEADER_LEFT :
3390 case FN_UNO_HEADER_RIGHT :
3391 case FN_UNO_FOOTER :
3392 case FN_UNO_FOOTER_LEFT :
3393 case FN_UNO_FOOTER_RIGHT :
3394 throw lang::IllegalArgumentException();
3395 //break;
3396 default:
3397 lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
3398 GetBasePool(), GetDoc(), GetFamily());
3401 else if(IsDescriptor())
3403 if(!GetPropImpl()->SetProperty(pNames[nProp], pValues[nProp]))
3404 throw lang::IllegalArgumentException();
3406 else
3407 throw uno::RuntimeException();
3409 if(aBaseImpl.HasItemSet())
3411 BOOL bDoesUndo = GetDoc()->DoesUndo();
3412 if( bDoesUndo )
3414 // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
3415 GetDoc()->DelAllUndoObj();
3416 GetDoc()->DoUndo( FALSE );
3418 aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
3419 GetDoc()->DoUndo( bDoesUndo );
3423 void SwXPageStyle::setPropertyValues(
3424 const uno::Sequence< OUString >& rPropertyNames,
3425 const uno::Sequence< uno::Any >& rValues )
3426 throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
3428 vos::OGuard aGuard(Application::GetSolarMutex());
3430 // workaround for bad designed API
3433 SetPropertyValues_Impl( rPropertyNames, rValues );
3435 catch (beans::UnknownPropertyException &rException)
3437 // wrap the original (here not allowed) exception in
3438 // a lang::WrappedTargetException that gets thrown instead.
3439 lang::WrappedTargetException aWExc;
3440 aWExc.TargetException <<= rException;
3441 throw aWExc;
3444 /* -----------------------------04.11.03 13:50--------------------------------
3446 ---------------------------------------------------------------------------*/
3447 uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
3448 const uno::Sequence< OUString >& rPropertyNames )
3449 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3451 if(!GetDoc())
3452 throw uno::RuntimeException();
3454 sal_Int32 nLength = rPropertyNames.getLength();
3455 const OUString* pNames = rPropertyNames.getConstArray();
3456 uno::Sequence< uno::Any > aRet ( nLength );
3458 uno::Any* pRet = aRet.getArray();
3459 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3460 const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
3461 SwStyleBase_Impl aBase(*GetDoc(), GetStyleName());
3462 SfxStyleSheetBase* pBase = 0;
3463 for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
3465 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( pNames[nProp] );
3466 if (!pEntry)
3467 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3469 if(GetBasePool())
3471 if(!pBase)
3473 sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3474 GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
3475 pBase = GetBasePool()->Find(GetStyleName());
3476 GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3478 sal_uInt16 nRes = 0;
3479 sal_Bool bHeader = sal_False, bAll = sal_False, bLeft = sal_False, bRight = sal_False;
3480 switch(pEntry->nWID)
3482 case FN_UNO_HEADER_ON:
3483 case FN_UNO_HEADER_BACKGROUND:
3484 case FN_UNO_HEADER_BOX:
3485 case FN_UNO_HEADER_LR_SPACE:
3486 case FN_UNO_HEADER_SHADOW:
3487 case FN_UNO_HEADER_BODY_DISTANCE:
3488 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE:
3489 case FN_UNO_HEADER_SHARE_CONTENT:
3490 case FN_UNO_HEADER_HEIGHT:
3491 case FN_UNO_HEADER_EAT_SPACING:
3493 case FN_UNO_FOOTER_ON:
3494 case FN_UNO_FOOTER_BACKGROUND:
3495 case FN_UNO_FOOTER_BOX:
3496 case FN_UNO_FOOTER_LR_SPACE:
3497 case FN_UNO_FOOTER_SHADOW:
3498 case FN_UNO_FOOTER_BODY_DISTANCE:
3499 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
3500 case FN_UNO_FOOTER_SHARE_CONTENT:
3501 case FN_UNO_FOOTER_HEIGHT:
3502 case FN_UNO_FOOTER_EAT_SPACING:
3504 SfxStyleSheetBasePool* pBasePool2 = ((SwXPageStyle*)this)->GetBasePool();
3505 pBasePool2->SetSearchMask(GetFamily());
3506 SfxStyleSheetBase* pBase2 = pBasePool2->Find(GetStyleName());
3507 if(pBase2)
3509 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3510 const SfxItemSet& rSet = xStyle->GetItemSet();
3511 sal_Bool bFooter = sal_False;
3512 switch(pEntry->nWID)
3514 case FN_UNO_FOOTER_ON:
3515 bFooter = sal_True;
3516 // kein break!
3517 case FN_UNO_HEADER_ON:
3519 //falls das SetItem nicht da ist, dann ist der Wert sal_False
3520 BOOL bRet = sal_False;
3521 pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
3522 nRes = SID_ATTR_PAGE_ON;
3524 break;
3525 case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_True;
3526 // kein break;
3527 case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND;
3528 break;
3529 case FN_UNO_FOOTER_BOX: bFooter = sal_True;
3530 // kein break;
3531 case FN_UNO_HEADER_BOX: nRes = RES_BOX;
3532 break;
3533 case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3534 // kein break;
3535 case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
3536 break;
3537 case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3538 // kein break;
3539 case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
3540 break;
3541 case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3542 // kein break;
3543 case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
3544 break;
3545 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3546 // kein break;
3547 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3548 break;
3549 case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3550 // kein break;
3551 case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3552 break;
3553 case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3554 // kein break;
3555 case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
3556 break;
3557 case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True;
3558 // kein break;
3559 case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
3560 break;
3562 const SvxSetItem* pSetItem;
3563 if(SFX_ITEM_SET == rSet.GetItemState(
3564 bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3565 sal_False, (const SfxPoolItem**)&pSetItem))
3567 const SfxItemSet& rTmpSet = pSetItem->GetItemSet();
3568 const SfxPoolItem* pItem = 0;
3569 rTmpSet.GetItemState(nRes, sal_True, &pItem);
3570 if(!pItem && nRes != rTmpSet.GetPool()->GetSlotId(nRes))
3571 pItem = &rTmpSet.GetPool()->GetDefaultItem(nRes);
3572 if(pItem)
3573 pItem->QueryValue(pRet[nProp], pEntry->nMemberId);
3577 break;
3578 case FN_UNO_HEADER :
3579 bAll = sal_True; goto Header;
3580 case FN_UNO_HEADER_LEFT :
3581 bLeft = sal_True; goto Header;
3582 case FN_UNO_HEADER_RIGHT :
3583 bRight = sal_True; goto Header;
3584 Header:
3585 bHeader = sal_True;
3586 nRes = RES_HEADER; goto MakeObject;
3587 case FN_UNO_FOOTER :
3588 bAll = sal_True; goto Footer;
3589 case FN_UNO_FOOTER_LEFT :
3590 bLeft = sal_True; goto Footer;
3591 case FN_UNO_FOOTER_RIGHT :
3592 bRight = sal_True;
3593 Footer:
3594 nRes = RES_FOOTER;
3595 MakeObject:
3597 const SwPageDesc& rDesc = aBase.GetOldPageDesc();
3598 const SwFrmFmt* pFrmFmt = 0;
3599 sal_Bool bShare = bHeader && rDesc.IsHeaderShared()||
3600 !bHeader && rDesc.IsFooterShared();
3601 // TextLeft returns the left content if there is one,
3602 // Text and TextRight return the master content.
3603 // TextRight does the same as Text and is for
3604 // comptability only.
3605 if( bLeft && !bShare )
3606 pFrmFmt = &rDesc.GetLeft();
3607 else
3608 pFrmFmt = &rDesc.GetMaster();
3609 if(pFrmFmt)
3611 const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
3612 const SfxPoolItem* pItem;
3613 SwFrmFmt* pHeadFootFmt;
3614 if(SFX_ITEM_SET == rSet.GetItemState(nRes, sal_True, &pItem) &&
3615 0 != (pHeadFootFmt = bHeader ?
3616 ((SwFmtHeader*)pItem)->GetHeaderFmt() :
3617 ((SwFmtFooter*)pItem)->GetFooterFmt()))
3619 // gibt es schon ein Objekt dafuer?
3620 SwXHeadFootText* pxHdFt = (SwXHeadFootText*)SwClientIter( *pHeadFootFmt ).
3621 First( TYPE( SwXHeadFootText ));
3622 uno::Reference< text::XText > xRet = pxHdFt;
3623 if(!pxHdFt)
3624 xRet = new SwXHeadFootText(*pHeadFootFmt, bHeader);
3625 pRet[nProp].setValue(&xRet, ::getCppuType((uno::Reference<text::XText>*)0));
3629 break;
3630 case FN_PARAM_FTN_INFO :
3632 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3633 const SfxItemSet& rSet = xStyle->GetItemSet();
3634 const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
3635 rItem.QueryValue(pRet[nProp], pEntry->nMemberId);
3637 break;
3638 default:
3639 pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3642 else if(IsDescriptor())
3644 uno::Any* pAny = 0;
3645 GetPropImpl()->GetProperty(pNames[nProp], pAny);
3646 if ( !pAny )
3647 GetPropImpl()->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
3648 else
3649 pRet[nProp] = *pAny;
3651 else
3652 throw uno::RuntimeException();
3654 return aRet;
3656 /* -----------------------------18.04.01 13:50--------------------------------
3658 ---------------------------------------------------------------------------*/
3659 uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
3660 const uno::Sequence< OUString >& rPropertyNames )
3661 throw(uno::RuntimeException)
3663 vos::OGuard aGuard(Application::GetSolarMutex());
3664 uno::Sequence< uno::Any > aValues;
3666 // workaround for bad designed API
3669 aValues = GetPropertyValues_Impl( rPropertyNames );
3671 catch (beans::UnknownPropertyException &)
3673 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
3675 catch (lang::WrappedTargetException &)
3677 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
3680 return aValues;
3682 /*-- 17.12.98 08:43:36---------------------------------------------------
3684 -----------------------------------------------------------------------*/
3685 uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw(
3686 beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3688 vos::OGuard aGuard(Application::GetSolarMutex());
3689 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3690 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
3692 /*-- 17.12.98 08:43:36---------------------------------------------------
3694 -----------------------------------------------------------------------*/
3695 void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
3696 throw( beans::UnknownPropertyException,
3697 beans::PropertyVetoException,
3698 lang::IllegalArgumentException,
3699 lang::WrappedTargetException,
3700 uno::RuntimeException)
3702 vos::OGuard aGuard(Application::GetSolarMutex());
3703 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3704 const uno::Sequence<uno::Any> aValues(&rValue, 1);
3705 SetPropertyValues_Impl( aProperties, aValues );
3708 SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
3709 : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, FALSE)
3712 /* -----------------------------15.12.00 15:45--------------------------------
3714 ---------------------------------------------------------------------------*/
3715 SwXFrameStyle::~SwXFrameStyle()
3718 /* -----------------------------15.12.00 14:30--------------------------------
3720 ---------------------------------------------------------------------------*/
3721 uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException)
3723 uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes();
3724 sal_Int32 nLen = aTypes.getLength();
3725 aTypes.realloc(nLen + 1);
3726 aTypes.getArray()[nLen] = ::getCppuType((uno::Reference<XEventsSupplier>*)0);
3727 return aTypes;
3729 /* -----------------------------15.12.00 14:30--------------------------------
3731 ---------------------------------------------------------------------------*/
3732 uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
3734 uno::Any aRet;
3735 if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0))
3736 aRet <<= uno::Reference<XEventsSupplier>(this);
3737 else
3738 aRet = SwXStyle::queryInterface(rType);
3739 return aRet;
3741 /* -----------------------------15.12.00 14:30--------------------------------
3743 ---------------------------------------------------------------------------*/
3744 uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException)
3746 return new SwFrameStyleEventDescriptor( *this );
3748 /*-- 19.05.2006 11:23:55---------------------------------------------------
3750 -----------------------------------------------------------------------*/
3751 SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
3752 SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
3755 /*-- 19.05.2006 11:23:56---------------------------------------------------
3757 -----------------------------------------------------------------------*/
3758 SwXAutoStyles::~SwXAutoStyles()
3761 /*-- 19.05.2006 11:23:57---------------------------------------------------
3763 -----------------------------------------------------------------------*/
3764 sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException )
3766 return AUTOSTYLE_FAMILY_COUNT;
3768 /*-- 19.05.2006 11:23:57---------------------------------------------------
3770 -----------------------------------------------------------------------*/
3771 uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
3772 throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
3773 uno::RuntimeException )
3775 vos::OGuard aGuard(Application::GetSolarMutex());
3776 uno::Any aRet;
3777 if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
3778 throw lang::IndexOutOfBoundsException();
3779 if(IsValid())
3781 uno::Reference< style::XAutoStyleFamily > aRef;
3782 IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
3783 switch( nType )
3785 case IStyleAccess::AUTO_STYLE_CHAR:
3787 if(!xAutoCharStyles.is())
3788 xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
3789 aRef = xAutoCharStyles;
3791 break;
3792 case IStyleAccess::AUTO_STYLE_RUBY:
3794 if(!xAutoRubyStyles.is())
3795 xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
3796 aRef = xAutoRubyStyles;
3798 break;
3799 case IStyleAccess::AUTO_STYLE_PARA:
3801 if(!xAutoParaStyles.is())
3802 xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
3803 aRef = xAutoParaStyles;
3805 break;
3807 default:
3810 aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0));
3812 else
3813 throw uno::RuntimeException();
3814 return aRet;
3816 /*-- 19.05.2006 11:23:57---------------------------------------------------
3818 -----------------------------------------------------------------------*/
3819 uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException)
3821 return ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0);
3823 /*-- 19.05.2006 11:23:58---------------------------------------------------
3825 -----------------------------------------------------------------------*/
3826 sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException)
3828 return sal_True;
3830 /*-- 19.05.2006 11:23:58---------------------------------------------------
3832 -----------------------------------------------------------------------*/
3833 uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name)
3834 throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
3836 uno::Any aRet;
3837 if(Name.compareToAscii("CharacterStyles") == 0 )
3838 aRet = getByIndex(0);
3839 else if(Name.compareToAscii("RubyStyles") == 0 )
3840 aRet = getByIndex(1);
3841 else if(Name.compareToAscii("ParagraphStyles") == 0 )
3842 aRet = getByIndex(2);
3843 else
3844 throw container::NoSuchElementException();
3845 return aRet;
3847 /*-- 19.05.2006 11:23:59---------------------------------------------------
3849 -----------------------------------------------------------------------*/
3850 uno::Sequence< rtl::OUString > SwXAutoStyles::getElementNames(void)
3851 throw( uno::RuntimeException )
3853 uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT);
3854 OUString* pNames = aNames.getArray();
3855 pNames[0] = C2U("CharacterStyles");
3856 pNames[1] = C2U("RubyStyles");
3857 pNames[2] = C2U("ParagraphStyles");
3858 return aNames;
3860 /*-- 19.05.2006 11:24:00---------------------------------------------------
3862 -----------------------------------------------------------------------*/
3863 sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name)
3864 throw( uno::RuntimeException )
3866 if( Name.compareToAscii("CharacterStyles") == 0 ||
3867 Name.compareToAscii("RubyStyles") == 0 ||
3868 Name.compareToAscii("ParagraphStyles") == 0 )
3869 return sal_True;
3870 else
3871 return sal_False;
3874 /*-- 19.05.2006 11:24:02---------------------------------------------------
3876 -----------------------------------------------------------------------*/
3877 SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
3878 pDocShell( pDocSh ), eFamily(nFamily)
3880 // Register ourselves as a listener to the document (via the page descriptor)
3881 pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
3883 /*-- 19.05.2006 11:24:02---------------------------------------------------
3885 -----------------------------------------------------------------------*/
3886 SwXAutoStyleFamily::~SwXAutoStyleFamily()
3890 void SwXAutoStyleFamily::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
3892 ClientModify(this, pOld, pNew);
3893 if(!GetRegisteredIn())
3894 pDocShell = 0;
3897 /*-- 31.05.2006 11:24:02---------------------------------------------------
3899 -----------------------------------------------------------------------*/
3900 uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
3901 const uno::Sequence< beans::PropertyValue >& Values )
3902 throw (uno::RuntimeException)
3904 if( !pDocShell )
3905 throw uno::RuntimeException();
3906 const USHORT* pRange = 0;
3907 const SfxItemPropertySet* pPropSet = 0;
3908 switch( eFamily )
3910 case IStyleAccess::AUTO_STYLE_CHAR:
3912 pRange = aCharAutoFmtSetRange;
3913 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
3915 break;
3916 case IStyleAccess::AUTO_STYLE_RUBY:
3918 pRange = 0;//aTxtNodeSetRange;
3919 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE);
3921 break;
3922 case IStyleAccess::AUTO_STYLE_PARA:
3924 pRange = aTxtNodeSetRange;
3925 pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
3927 break;
3929 default:
3932 SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
3933 const beans::PropertyValue* pSeq = Values.getConstArray();
3934 sal_Int32 nLen = Values.getLength();
3935 for( sal_Int32 i = 0; i < nLen; ++i )
3939 pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet );
3941 catch (beans::UnknownPropertyException &)
3943 ASSERT( false, "Unknown property" );
3945 catch (lang::IllegalArgumentException &)
3947 ASSERT( false, "Illegal argument" );
3951 SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
3952 uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
3953 return xRet;
3955 /*-- 31.05.2006 11:24:02---------------------------------------------------
3957 -----------------------------------------------------------------------*/
3958 uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( )
3959 throw (uno::RuntimeException)
3961 if( !pDocShell )
3962 throw uno::RuntimeException();
3963 return uno::Reference< container::XEnumeration >
3964 (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily ));
3966 /*-- 19.05.2006 11:24:03---------------------------------------------------
3968 -----------------------------------------------------------------------*/
3969 uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException)
3971 return ::getCppuType((const uno::Reference<style::XAutoStyle>*)0);
3973 /*-- 19.05.2006 11:24:04---------------------------------------------------
3975 -----------------------------------------------------------------------*/
3976 sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException)
3978 return sal_False;
3981 /*-- 31.05.2006 11:24:05---------------------------------------------------
3983 -----------------------------------------------------------------------*/
3984 SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
3985 : pDoc( pInitDoc ), eFamily( eFam )
3987 // special case for ruby auto styles:
3988 if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
3990 std::set< std::pair< USHORT, USHORT > > aRubyMap;
3991 SwAttrPool& rAttrPool = pDoc->GetAttrPool();
3992 USHORT nCount = rAttrPool.GetItemCount( RES_TXTATR_CJK_RUBY );
3994 for ( USHORT nI = 0; nI < nCount; ++nI )
3996 const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem( RES_TXTATR_CJK_RUBY, nI ));
3997 if ( pItem && pItem->GetTxtRuby() )
3999 std::pair< USHORT, USHORT > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
4000 if ( aRubyMap.find( aPair ) == aRubyMap.end() )
4002 aRubyMap.insert( aPair );
4003 SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) );
4004 pItemSet->Put( *pItem );
4005 mAutoStyles.push_back( pItemSet );
4010 else
4012 pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
4015 aIter = mAutoStyles.begin();
4018 /*-- 31.05.2006 11:24:05---------------------------------------------------
4020 -----------------------------------------------------------------------*/
4021 SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
4022 : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
4024 // Register ourselves as a listener to the document (via the page descriptor)
4025 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4027 /*-- 31.05.2006 11:24:05---------------------------------------------------
4029 -----------------------------------------------------------------------*/
4030 SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
4032 delete pImpl;
4035 void SwXAutoStylesEnumerator::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
4037 ClientModify(this, pOld, pNew);
4038 if(!GetRegisteredIn())
4040 delete pImpl;
4041 pImpl = 0;
4046 /*-- 31.05.2006 11:24:05---------------------------------------------------
4048 -----------------------------------------------------------------------*/
4049 ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
4050 throw (uno::RuntimeException)
4052 if( !pImpl )
4053 throw uno::RuntimeException();
4054 return pImpl->hasMoreElements();
4056 /*-- 31.05.2006 11:24:05---------------------------------------------------
4058 -----------------------------------------------------------------------*/
4059 uno::Any SwXAutoStylesEnumerator::nextElement( )
4060 throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
4062 if( !pImpl )
4063 throw uno::RuntimeException();
4064 uno::Any aRet;
4065 if( pImpl->hasMoreElements() )
4067 SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
4068 uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
4069 pNextSet, pImpl->getFamily());
4070 aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0));
4072 return aRet;
4074 /*-- 19.05.2006 11:24:09---------------------------------------------------
4076 -----------------------------------------------------------------------*/
4077 SwXAutoStyle::SwXAutoStyle( SwDoc* pDoc, SfxItemSet_Pointer_t pInitSet, IStyleAccess::SwAutoStyleFamily eFam )
4078 : pSet( pInitSet ), eFamily( eFam )
4080 // Register ourselves as a listener to the document (via the page descriptor)
4081 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4084 /*-- 19.05.2006 11:24:09---------------------------------------------------
4086 -----------------------------------------------------------------------*/
4087 SwXAutoStyle::~SwXAutoStyle()
4091 void SwXAutoStyle::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
4093 ClientModify(this, pOld, pNew);
4094 if(!GetRegisteredIn())
4095 pSet.reset();
4098 /*-- 19.05.2006 11:24:09---------------------------------------------------
4100 -----------------------------------------------------------------------*/
4101 uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( )
4102 throw (uno::RuntimeException)
4104 uno::Reference< beans::XPropertySetInfo > xRet;
4105 switch( eFamily )
4107 case IStyleAccess::AUTO_STYLE_CHAR:
4109 static uno::Reference< beans::XPropertySetInfo > xCharRef;
4110 if(!xCharRef.is())
4112 xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo();
4114 xRet = xCharRef;
4116 break;
4117 case IStyleAccess::AUTO_STYLE_RUBY:
4119 static uno::Reference< beans::XPropertySetInfo > xRubyRef;
4120 if(!xRubyRef.is())
4122 sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE;
4123 xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4125 xRet = xRubyRef;
4127 break;
4128 case IStyleAccess::AUTO_STYLE_PARA:
4130 static uno::Reference< beans::XPropertySetInfo > xParaRef;
4131 if(!xParaRef.is())
4133 sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
4134 xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4136 xRet = xParaRef;
4138 break;
4140 default:
4144 return xRet;
4147 /*-- 19.05.2006 11:24:09---------------------------------------------------
4149 -----------------------------------------------------------------------*/
4150 void SwXAutoStyle::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ )
4151 throw( beans::UnknownPropertyException,
4152 beans::PropertyVetoException,
4153 lang::IllegalArgumentException,
4154 lang::WrappedTargetException,
4155 uno::RuntimeException)
4159 /*-- 19.05.2006 11:24:09---------------------------------------------------
4161 -----------------------------------------------------------------------*/
4162 uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName )
4163 throw( beans::UnknownPropertyException,
4164 lang::WrappedTargetException,
4165 uno::RuntimeException )
4167 vos::OGuard aGuard(Application::GetSolarMutex());
4168 const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
4169 return GetPropertyValues_Impl(aProperties).getConstArray()[0];
4172 /*-- 19.05.2006 11:24:09---------------------------------------------------
4174 -----------------------------------------------------------------------*/
4175 void SwXAutoStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/,
4176 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
4177 throw( beans::UnknownPropertyException,
4178 lang::WrappedTargetException,
4179 uno::RuntimeException )
4183 /*-- 19.05.2006 11:24:09---------------------------------------------------
4185 -----------------------------------------------------------------------*/
4186 void SwXAutoStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/,
4187 const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
4188 throw( beans::UnknownPropertyException,
4189 lang::WrappedTargetException,
4190 uno::RuntimeException )
4194 /*-- 19.05.2006 11:24:09---------------------------------------------------
4196 -----------------------------------------------------------------------*/
4197 void SwXAutoStyle::addVetoableChangeListener( const OUString& /*PropertyName*/,
4198 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4199 throw( beans::UnknownPropertyException,
4200 lang::WrappedTargetException,
4201 uno::RuntimeException )
4205 /*-- 19.05.2006 11:24:09---------------------------------------------------
4207 -----------------------------------------------------------------------*/
4208 void SwXAutoStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/,
4209 const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4210 throw( beans::UnknownPropertyException,
4211 lang::WrappedTargetException,
4212 uno::RuntimeException )
4216 /*-- 19.05.2006 11:24:09---------------------------------------------------
4218 -----------------------------------------------------------------------*/
4219 void SwXAutoStyle::setPropertyValues(
4220 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4221 const uno::Sequence< uno::Any >& /*aValues*/ )
4222 throw (beans::PropertyVetoException, lang::IllegalArgumentException,
4223 lang::WrappedTargetException, uno::RuntimeException)
4227 /*-- 19.05.2006 11:24:09---------------------------------------------------
4229 -----------------------------------------------------------------------*/
4230 uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
4231 const uno::Sequence< OUString > & rPropertyNames )
4232 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4234 if( !pSet.get() )
4235 throw uno::RuntimeException();
4236 // query_item
4238 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4239 switch(eFamily)
4241 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4242 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4243 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4244 default:
4248 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4249 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4250 const OUString* pNames = rPropertyNames.getConstArray();
4252 sal_Int32 nLen = rPropertyNames.getLength();
4253 uno::Sequence< uno::Any > aRet( nLen );
4254 uno::Any* pValues = aRet.getArray();
4256 SfxItemSet& rSet = *pSet.get();
4258 for( sal_Int32 i = 0; i < nLen; ++i )
4260 const String& rPropName = pNames[i];
4261 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
4262 if(!pEntry)
4263 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
4264 else if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
4266 OUString sName(StylePool::nameOf( pSet ));
4267 pValues[i] <<= sName;
4269 else
4270 pPropSet->getPropertyValue( *pEntry, rSet, pValues[i] );
4272 return aRet;
4275 /*-- 19.05.2006 11:24:09---------------------------------------------------
4277 -----------------------------------------------------------------------*/
4278 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
4279 const uno::Sequence< ::rtl::OUString >& rPropertyNames )
4280 throw (uno::RuntimeException)
4282 vos::OGuard aGuard(Application::GetSolarMutex());
4283 uno::Sequence< uno::Any > aValues;
4285 // workaround for bad designed API
4288 aValues = GetPropertyValues_Impl( rPropertyNames );
4290 catch (beans::UnknownPropertyException &)
4292 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property exception caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4294 catch (lang::WrappedTargetException &)
4296 throw uno::RuntimeException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "WrappedTargetException caught" ) ), static_cast < cppu::OWeakObject * > ( this ) );
4299 return aValues;
4302 /*-- 19.05.2006 11:24:10---------------------------------------------------
4304 -----------------------------------------------------------------------*/
4305 void SwXAutoStyle::addPropertiesChangeListener(
4306 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4307 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4308 throw (uno::RuntimeException)
4312 /*-- 19.05.2006 11:24:10---------------------------------------------------
4314 -----------------------------------------------------------------------*/
4315 void SwXAutoStyle::removePropertiesChangeListener(
4316 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4317 throw (uno::RuntimeException)
4321 /*-- 19.05.2006 11:24:11---------------------------------------------------
4323 -----------------------------------------------------------------------*/
4324 void SwXAutoStyle::firePropertiesChangeEvent(
4325 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/,
4326 const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4327 throw (uno::RuntimeException)
4331 /*-- 19.05.2006 11:24:11---------------------------------------------------
4333 -----------------------------------------------------------------------*/
4334 beans::PropertyState SwXAutoStyle::getPropertyState( const OUString& rPropertyName )
4335 throw( beans::UnknownPropertyException,
4336 uno::RuntimeException)
4338 vos::OGuard aGuard(Application::GetSolarMutex());
4340 uno::Sequence< OUString > aNames(1);
4341 OUString* pNames = aNames.getArray();
4342 pNames[0] = rPropertyName;
4343 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
4344 return aStates.getConstArray()[0];
4347 /*-- 19.05.2006 11:24:11---------------------------------------------------
4349 -----------------------------------------------------------------------*/
4350 void SwXAutoStyle::setPropertyToDefault( const OUString& /*PropertyName*/ )
4351 throw( beans::UnknownPropertyException,
4352 uno::RuntimeException )
4356 /*-- 19.05.2006 11:24:11---------------------------------------------------
4358 -----------------------------------------------------------------------*/
4359 uno::Any SwXAutoStyle::getPropertyDefault( const OUString& rPropertyName )
4360 throw( beans::UnknownPropertyException,
4361 lang::WrappedTargetException,
4362 uno::RuntimeException)
4364 const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4365 return getPropertyDefaults ( aSequence ).getConstArray()[0];
4368 /*-- 19.05.2006 11:24:12---------------------------------------------------
4370 -----------------------------------------------------------------------*/
4371 uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
4372 const uno::Sequence< ::rtl::OUString >& rPropertyNames )
4373 throw (beans::UnknownPropertyException, uno::RuntimeException)
4375 if( !pSet.get() )
4376 throw uno::RuntimeException();
4377 vos::OGuard aGuard(Application::GetSolarMutex());
4378 uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4379 beans::PropertyState* pStates = aRet.getArray();
4380 const OUString* pNames = rPropertyNames.getConstArray();
4382 sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4383 switch(eFamily)
4385 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4386 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4387 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4388 default:
4392 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4393 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4394 SfxItemSet& rSet = *pSet.get();
4395 for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4397 const String& rPropName = pNames[i];
4398 const SfxItemPropertySimpleEntry* pEntry = pMap->getByName(rPropName);
4399 if(!pEntry)
4400 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
4401 pStates[i] = pPropSet->getPropertyState(*pEntry, rSet );
4403 return aRet;
4406 /*-- 19.05.2006 11:24:12---------------------------------------------------
4408 -----------------------------------------------------------------------*/
4409 void SwXAutoStyle::setAllPropertiesToDefault( )
4410 throw (uno::RuntimeException)
4414 /*-- 19.05.2006 11:24:13---------------------------------------------------
4416 -----------------------------------------------------------------------*/
4417 void SwXAutoStyle::setPropertiesToDefault(
4418 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ )
4419 throw (beans::UnknownPropertyException, uno::RuntimeException)
4423 /*-- 19.05.2006 11:24:14---------------------------------------------------
4425 -----------------------------------------------------------------------*/
4426 uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults(
4427 const uno::Sequence< ::rtl::OUString >& /*aPropertyNames*/ )
4428 throw (beans::UnknownPropertyException, lang::WrappedTargetException,
4429 uno::RuntimeException)
4431 uno::Sequence< uno::Any > aRet(0);
4432 return aRet;
4435 /*-- 19.05.2006 11:24:14---------------------------------------------------
4437 -----------------------------------------------------------------------*/
4438 uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::RuntimeException)
4440 if( !pSet.get() )
4441 throw uno::RuntimeException();
4442 vos::OGuard aGuard(Application::GetSolarMutex());
4443 std::vector< beans::PropertyValue > aPropertyVector;
4445 sal_Int8 nPropSetId = 0;
4446 switch(eFamily)
4448 case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4449 case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4450 case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4451 default:
4455 const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4456 const SfxItemPropertyMap *pMap = pPropSet->getPropertyMap();
4457 PropertyEntryVector_t aPropVector = pMap->getPropertyEntries();
4458 // struct compareWhichIds
4459 // {
4460 // bool operator()(const USHORT w1, const USHORT w2) const
4461 // {
4462 // return w1 < w2;
4463 // }
4464 // };
4465 // typedef std::map<const USHORT, SfxItemPropertyNamedEntry, compareWhichIds> PropertyMap_t;
4466 // PropertyMap_t aPropMap;
4467 // aPropMap.reserve( aPropVector.size() );
4468 // PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
4469 // while( aIt != aPropertyEntries.end() )
4470 // {
4471 // aPropMap[aIt->nWID] = *aIt;
4472 // ++aIt;
4473 // }
4475 SfxItemSet& rSet = *pSet.get();
4476 SfxItemIter aIter(rSet);
4477 const SfxPoolItem* pItem = aIter.FirstItem();
4479 while ( pItem )
4481 const USHORT nWID = pItem->Which();
4483 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID];
4484 // if( aMapIt != aPropMap.getEnd() )
4485 // {
4486 // beans::PropertyValue aPropertyValue;
4487 // aPropertyValue.Name = aIt->sName;
4488 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4489 // aPropertyVector.push_back( aPropertyValue );
4490 // }
4491 // TODO: Optimize - and fix! the old iteration filled each WhichId
4492 // only once but there are more properties than WhichIds
4493 PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
4494 while( aIt != aPropVector.end() )
4496 if ( aIt->nWID == nWID )
4498 beans::PropertyValue aPropertyValue;
4499 aPropertyValue.Name = aIt->sName;
4500 pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4501 aPropertyVector.push_back( aPropertyValue );
4503 ++aIt;
4505 /* int i = 0;
4506 while ( pMap[i].nWID != 0 )
4508 if ( pMap[i].nWID == nWID )
4510 beans::PropertyValue aPropertyValue;
4511 String sString( OUString::createFromAscii( pMap[i].pName ) );
4512 aPropertyValue.Name = sString;
4513 pItem->QueryValue( aPropertyValue.Value, pMap[i].nMemberId );
4514 aPropertyVector.push_back( aPropertyValue );
4515 break;
4517 ++i;
4519 pItem = aIter.NextItem();
4522 const sal_Int32 nCount = aPropertyVector.size();
4523 uno::Sequence< beans::PropertyValue > aRet( nCount );
4524 beans::PropertyValue* pProps = aRet.getArray();
4526 for ( int i = 0; i < nCount; ++i, pProps++ )
4528 *pProps = aPropertyVector[i];
4531 return aRet;