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>
54 #include <charfmt.hxx>
56 #include <unostyle.hxx>
57 #include <unosett.hxx>
61 #include <unoprnms.hxx>
62 #include <shellio.hxx>
63 #include <docstyle.hxx>
65 #include <fmthdft.hxx>
66 #include <fmtpdsc.hxx>
67 #include <tools/urlobj.hxx>
69 #include <poolfmt.hrc>
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>
84 #ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPPP_
85 #include <com/sun/star/beans/NamedValue.hpp>
87 #include <istyleaccess.hxx>
88 #include <GetMetricVal.hxx>
89 #include <fmtfsize.hxx>
90 #include <numrule.hxx>
92 #include <boost/shared_ptr.hpp>
95 #include "unocore.hrc"
99 #define STYLE_FAMILY_COUNT 5 // we have 5 style families
103 #define TYPE_ULSPACE 3
104 #define TYPE_SHADOW 4
105 #define TYPE_LRSPACE 5
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
;
139 case FN_UNO_FOOTER_ON
:
140 case FN_UNO_HEADER_ON
:
142 case FN_UNO_FOOTER_BACKGROUND
:
143 case FN_UNO_HEADER_BACKGROUND
: nRes
= RES_BACKGROUND
;
145 case FN_UNO_FOOTER_BOX
:
146 case FN_UNO_HEADER_BOX
: nRes
= RES_BOX
;
148 case FN_UNO_FOOTER_LR_SPACE
:
149 case FN_UNO_HEADER_LR_SPACE
: nRes
= RES_LR_SPACE
;
151 case FN_UNO_FOOTER_SHADOW
:
152 case FN_UNO_HEADER_SHADOW
: nRes
= RES_SHADOW
;
154 case FN_UNO_FOOTER_BODY_DISTANCE
:
155 case FN_UNO_HEADER_BODY_DISTANCE
: nRes
= RES_UL_SPACE
;
157 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE
:
158 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE
: nRes
= SID_ATTR_PAGE_DYNAMIC
;
160 case FN_UNO_FOOTER_SHARE_CONTENT
:
161 case FN_UNO_HEADER_SHARE_CONTENT
: nRes
= SID_ATTR_PAGE_SHARED
;
163 case FN_UNO_FOOTER_HEIGHT
:
164 case FN_UNO_HEADER_HEIGHT
: nRes
= SID_ATTR_PAGE_SIZE
;
166 case FN_UNO_FOOTER_EAT_SPACING
:
167 case FN_UNO_HEADER_EAT_SPACING
: nRes
= RES_HEADER_FOOTER_EAT_SPACING
;
174 SwGetPoolIdFromName
lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily 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
;
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
;
199 IStyleAccess::SwAutoStyleFamily eFamily
;
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 /******************************************************************
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");
236 /*-- 16.12.98 15:13:26---------------------------------------------------
238 -----------------------------------------------------------------------*/
239 SwXStyleFamilies::SwXStyleFamilies(SwDocShell
& rDocShell
) :
240 SwUnoCollection(rDocShell
.GetDoc()),
241 pDocShell(&rDocShell
),
250 /*-- 16.12.98 15:13:26---------------------------------------------------
252 -----------------------------------------------------------------------*/
253 SwXStyleFamilies::~SwXStyleFamilies()
257 delete pxFrameStyles
;
259 delete pxNumberingStyles
;
261 /*-- 21.12.98 12:05:22---------------------------------------------------
263 -----------------------------------------------------------------------*/
264 uno::Any SAL_CALL
SwXStyleFamilies::getByName(const OUString
& Name
)
266 container::NoSuchElementException
,
267 lang::WrappedTargetException
,
268 uno::RuntimeException
)
270 vos::OGuard
aGuard(Application::GetSolarMutex());
271 // der Index kommt aus const unsigned short aStyleByIndex[] =
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);
286 throw container::NoSuchElementException();
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");
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 )
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());
332 if(nIndex
< 0 || nIndex
>= STYLE_FAMILY_COUNT
)
333 throw lang::IndexOutOfBoundsException();
336 uno::Reference
< container::XNameContainer
> aRef
;
337 sal_uInt16 nType
= aStyleByIndex
[nIndex
];
340 case SFX_STYLE_FAMILY_CHAR
:
344 ((SwXStyleFamilies
*)this)->pxCharStyles
= new uno::Reference
< container::XNameContainer
> ();
345 *pxCharStyles
= new SwXStyleFamily(pDocShell
, nType
);
347 aRef
= *pxCharStyles
;
350 case SFX_STYLE_FAMILY_PARA
:
354 ((SwXStyleFamilies
*)this)->pxParaStyles
= new uno::Reference
< container::XNameContainer
> ();
355 *pxParaStyles
= new SwXStyleFamily(pDocShell
, nType
);
357 aRef
= *pxParaStyles
;
360 case SFX_STYLE_FAMILY_PAGE
:
364 ((SwXStyleFamilies
*)this)->pxPageStyles
= new uno::Reference
< container::XNameContainer
> ();
365 *pxPageStyles
= new SwXStyleFamily(pDocShell
, nType
);
367 aRef
= *pxPageStyles
;
370 case SFX_STYLE_FAMILY_FRAME
:
374 ((SwXStyleFamilies
*)this)->pxFrameStyles
= new uno::Reference
< container::XNameContainer
> ();
375 *pxFrameStyles
= new SwXStyleFamily(pDocShell
, nType
);
377 aRef
= *pxFrameStyles
;
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
;
391 aRet
.setValue(&aRef
, ::getCppuType((const uno::Reference
<container::XNameContainer
>*)0));
394 throw uno::RuntimeException();
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
)
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
);
458 throw io::IOException();
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();
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
);
487 /******************************************************************
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");
514 /*-- 16.12.98 16:03:56---------------------------------------------------
516 -----------------------------------------------------------------------*/
517 SwXStyleFamily::SwXStyleFamily(SwDocShell
* pDocSh
, sal_uInt16 nFamily
) :
518 eFamily((SfxStyleFamily
)nFamily
),
519 pBasePool(pDocSh
->GetStyleSheetPool()),
524 case SFX_STYLE_FAMILY_CHAR:
525 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_CHAR_STYLE);
527 case SFX_STYLE_FAMILY_PARA:
528 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PARA_STYLE);
530 case SFX_STYLE_FAMILY_PAGE:
531 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_PAGE_STYLE);
533 case SFX_STYLE_FAMILY_FRAME:
534 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_FRAME_STYLE);
536 case SFX_STYLE_FAMILY_PSEUDO:
537 _pPropMap = aSwMapProvider.GetPropertyMap(PROPERTY_MAP_NUM_STYLE);
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;
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() )
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
);
574 *pString
= pFmt
->GetName();
580 nCount
+= nBaseCount
;
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() )
598 if ( IsPoolUserFmt ( pColl
->GetPoolFmtId() ) )
600 if ( nIndex
== nCount
)
602 *pString
= pColl
->GetName();
608 nCount
+= nBaseCount
;
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())
621 if ( IsPoolUserFmt ( pFmt
->GetPoolFmtId() ) )
623 if ( nIndex
== nCount
)
625 *pString
= pFmt
->GetName();
631 nCount
+= nBaseCount
;
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())
645 if ( IsPoolUserFmt ( rDesc
.GetPoolFmtId() ) )
647 if ( nIndex
== nCount
)
649 *pString
= rDesc
.GetName();
655 nCount
+= nBaseCount
;
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() )
668 if ( IsPoolUserFmt ( rRule
.GetPoolFmtId() ) )
670 if ( nIndex
== nCount
)
672 *pString
= rRule
.GetName();
678 nCount
+= nBaseCount
;
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());
703 if ( nTempIndex
>= 0 && nTempIndex
< USHRT_MAX
)
705 sal_uInt16 nIndex
= static_cast < sal_uInt16
> ( nTempIndex
);
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
);
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
);
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
);
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
);
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
);
801 if ( !sStyleName
.Len() )
802 lcl_GetCountOrName ( *pDocShell
->GetDoc(), eFamily
, &sStyleName
, nIndex
);
804 if ( sStyleName
.Len() )
806 SfxStyleSheetBase
* pBase
= pBasePool
->Find( sStyleName
, eFamily
);
809 uno::Reference
< style::XStyle
> xStyle
= _FindStyle(sStyleName
);
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));
821 throw container::NoSuchElementException();
824 throw lang::IndexOutOfBoundsException();
827 throw uno::RuntimeException();
830 throw lang::IndexOutOfBoundsException();
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());
843 SwStyleNameMapper::FillUIName(rName
, sStyleName
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
);
846 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
847 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
850 uno::Reference
< style::XStyle
> xStyle
= _FindStyle(sStyleName
);
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));
862 throw container::NoSuchElementException();
865 throw uno::RuntimeException();
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
;
878 SfxStyleSheetIterator
* pIterator
= pBasePool
->CreateIterator(eFamily
, 0xffff);
879 sal_uInt16 nCount
= pIterator
->Count();
880 aRet
.realloc(nCount
);
881 OUString
* pArray
= aRet
.getArray();
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
);
891 throw uno::RuntimeException();
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
;
904 SwStyleNameMapper::FillUIName(rName
, sStyleName
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
);
905 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
906 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
910 throw uno::RuntimeException();
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
)
928 throw uno::RuntimeException();
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());
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();
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();
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
=
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
990 //so, jetzt sollten noch die Properties des Descriptors angewandt werden
991 pNewStyle
->ApplyDescriptorProperties();
994 throw lang::IllegalArgumentException();
997 throw lang::IllegalArgumentException();
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());
1012 pBasePool
->SetSearchMask(eFamily
);
1013 SfxStyleSheetBase
* pBase
= pBasePool
->Find(rName
);
1014 //Ersetzung geht nur fuer benutzerdefinierte Styles
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());
1023 uno::Reference
<lang::XUnoTunnel
> xTunnel( xStyle
, uno::UNO_QUERY
);
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
);
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());
1046 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
1048 SwStyleNameMapper::FillUIName(rName
, aString
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
);
1050 SfxStyleSheetBase
* pBase
= pBasePool
->Find( aString
);
1052 pBasePool
->Remove(pBase
);
1054 throw container::NoSuchElementException();
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
)
1075 if ( sPropertyName
.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
1077 vos::OGuard
aGuard(Application::GetSolarMutex());
1078 sal_uInt32 nResId
= 0;
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;
1092 OSL_ENSURE( 0, "SwXStyleFamily::getPropertyValue(): invalid family" );
1096 OUString
sDisplayName( String( SW_RES( nResId
) ) );
1097 aRet
= uno::makeAny( sDisplayName
);
1102 throw beans::UnknownPropertyException( OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName
, static_cast<OWeakObject
*>(this) );
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
) )
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
)
1160 /******************************************************************
1162 ******************************************************************/
1163 class SwStyleProperties_Impl
1165 const PropertyEntryVector_t aPropertyEntries
;
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
) :
1186 aPropertyEntries( pMap
->getPropertyEntries() ),
1189 nArrLen
= aPropertyEntries
.size();
1190 //const SfxItemPropertyMap* pTmp = _pMap;
1192 pAnyArr
= new uno::Any
* [nArrLen
];
1193 for ( sal_uInt32 i
=0 ; i
< nArrLen
; i
++ )
1196 //--------------------------------------------------------------------
1197 //--------------------------------------------------------------------
1198 SwStyleProperties_Impl::~SwStyleProperties_Impl()
1200 for ( sal_uInt16 i
=0 ; i
< nArrLen
; i
++ )
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
);
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;
1246 void SwStyleProperties_Impl::ClearAllProperties( )
1248 for ( sal_uInt16 i
= 0; i
< nArrLen
; i
++ )
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
];
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();
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) );
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
);
1336 /* -----------------------------06.04.00 11:24--------------------------------
1338 ---------------------------------------------------------------------------*/
1339 uno::Sequence
< OUString
> SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException
)
1342 if(SFX_STYLE_FAMILY_PARA
== eFamily
)
1348 else if(SFX_STYLE_FAMILY_CHAR
== eFamily
)
1350 else if(SFX_STYLE_FAMILY_PAGE
== eFamily
)
1352 uno::Sequence
< OUString
> aRet(nCount
);
1353 OUString
* pArray
= aRet
.getArray();
1354 pArray
[0] = C2U("com.sun.star.style.Style");
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");
1363 case SFX_STYLE_FAMILY_PAGE
:
1364 pArray
[1] = C2U("com.sun.star.style.PageStyle");
1365 pArray
[2] = C2U("com.sun.star.style.PageProperties");
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");
1373 pArray
[5] = C2U("com.sun.star.style.ConditionalParagraphStyle");
1381 /*-- 17.12.98 08:26:49---------------------------------------------------
1383 -----------------------------------------------------------------------*/
1384 SwXStyle::SwXStyle( SwDoc
*pDoc
, SfxStyleFamily eFam
, BOOL bConditional
) :
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();
1402 sal_uInt16 nMapId
= PROPERTY_MAP_NUM_STYLE
;
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;
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
;
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
;
1435 case SFX_STYLE_FAMILY_FRAME
:
1437 nMapId
= PROPERTY_MAP_FRAME_STYLE
;
1440 case SFX_STYLE_FAMILY_PSEUDO
:
1442 nMapId
= PROPERTY_MAP_NUM_STYLE
;
1449 pPropImpl
= new SwStyleProperties_Impl(aSwMapProvider
.GetPropertySet(nMapId
)->getPropertyMap());
1453 SwXStyle::SwXStyle(SfxStyleSheetBasePool
& rPool
, SfxStyleFamily eFam
,
1454 SwDoc
* pDoc
, const String
& rStyleName
) :
1456 sStyleName(rStyleName
),
1459 bIsDescriptor(sal_False
),
1460 bIsConditional(sal_False
),
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?" );
1471 const sal_uInt16 nId
= SwStyleNameMapper::GetPoolIdFromUIName(sStyleName
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
);
1472 if(nId
!= USHRT_MAX
)
1473 bIsConditional
= ::IsConditionalByPoolId( nId
);
1475 bIsConditional
= RES_CONDTXTFMTCOLL
== ((SwDocStyleSheet
*)pBase
)->GetCollection()->Which();
1479 /*-- 17.12.98 08:26:50---------------------------------------------------
1481 -----------------------------------------------------------------------*/
1482 SwXStyle::~SwXStyle()
1485 EndListening(*pBasePool
);
1488 /*-- 17.12.98 08:26:51---------------------------------------------------
1490 -----------------------------------------------------------------------*/
1491 void SwXStyle::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
1493 ClientModify(this, pOld
, pNew
);
1494 if(!GetRegisteredIn())
1497 mxStyleData
.clear();
1498 mxStyleFamily
.clear();
1501 OUString
SwXStyle::getName(void) throw( uno::RuntimeException
)
1503 vos::OGuard
aGuard(Application::GetSolarMutex());
1507 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
1508 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
1509 DBG_ASSERT(pBase
, "where is the style?" );
1511 throw uno::RuntimeException();
1512 SwStyleNameMapper::FillProgName(pBase
->GetName(), aString
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
);
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());
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
);
1535 sStyleName
= String(rName
);
1538 throw uno::RuntimeException();
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
;
1552 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
1553 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
1554 //if it is not found it must be non user defined
1556 bRet
= pBase
->IsUserDefined();
1559 throw uno::RuntimeException();
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
;
1571 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_USED
);
1572 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
1574 bRet
= pBase
->IsUsed();
1577 throw uno::RuntimeException();
1580 /*-- 17.12.98 08:26:52---------------------------------------------------
1582 -----------------------------------------------------------------------*/
1583 OUString
SwXStyle::getParentStyle(void) throw( uno::RuntimeException
)
1585 vos::OGuard
aGuard(Application::GetSolarMutex());
1589 pBasePool
->SetSearchMask(eFamily
, SFXSTYLEBIT_ALL
);
1590 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
1592 aString
= pBase
->GetParent();
1594 else if(bIsDescriptor
)
1595 aString
= sParentStyleName
;
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
);
1612 pBasePool
->SetSearchMask(eFamily
);
1613 BOOL bExcept
= FALSE
;
1614 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
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
);
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
& )
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
;
1660 case SFX_STYLE_FAMILY_CHAR
:
1662 static uno::Reference
< beans::XPropertySetInfo
> xCharRef
;
1665 xCharRef
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_CHAR_STYLE
)->getPropertySetInfo();
1670 case SFX_STYLE_FAMILY_PARA
:
1672 static uno::Reference
< beans::XPropertySetInfo
> xParaRef
;
1675 sal_uInt16 nMapId
= bIsConditional
? PROPERTY_MAP_CONDITIONAL_PARA_STYLE
: PROPERTY_MAP_PARA_STYLE
;
1676 xParaRef
= aSwMapProvider
.GetPropertySet(nMapId
)->getPropertySetInfo();
1681 case SFX_STYLE_FAMILY_PAGE
:
1683 static uno::Reference
< beans::XPropertySetInfo
> xPageRef
;
1686 xPageRef
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_PAGE_STYLE
)->getPropertySetInfo();
1691 case SFX_STYLE_FAMILY_FRAME
:
1693 static uno::Reference
< beans::XPropertySetInfo
> xFrameRef
;
1696 xFrameRef
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_FRAME_STYLE
)->getPropertySetInfo();
1701 case SFX_STYLE_FAMILY_PSEUDO
:
1703 static uno::Reference
< beans::XPropertySetInfo
> xNumRef
;
1706 xNumRef
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_NUM_STYLE
)->getPropertySetInfo();
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())
1737 pPropImpl
->GetProperty(aIt
->sName
, pAny
);
1739 setPropertyValue(aIt
->sName
, *pAny
);
1744 /*-- 18.04.01 13:07:27---------------------------------------------------
1746 -----------------------------------------------------------------------*/
1747 struct SwStyleBase_Impl
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
) :
1767 ~SwStyleBase_Impl(){ delete pItemSet
; }
1769 sal_Bool
HasItemSet() {return mxNewBase
.is();}
1770 SfxItemSet
& GetItemSet()
1772 DBG_ASSERT(mxNewBase
.is(), "no SwDocStyleSheet available");
1774 pItemSet
= new SfxItemSet(mxNewBase
->GetItemSet());
1778 const SwPageDesc
& GetOldPageDesc();
1780 /* -----------------------------25.04.01 12:44--------------------------------
1782 ---------------------------------------------------------------------------*/
1783 const SwPageDesc
& SwStyleBase_Impl::GetOldPageDesc()
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
;
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
) );
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
)
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
,
1836 SfxStyleFamily eFamily
)
1837 throw(beans::PropertyVetoException
, lang::IllegalArgumentException
,
1838 lang::WrappedTargetException
, uno::RuntimeException
)
1845 SfxPrinter
*pPrinter
= pDoc
->getPrinter( true );
1847 sal_uInt16 nBin
= USHRT_MAX
;
1848 if ( !( rValue
>>= sTmp
) )
1849 throw lang::IllegalArgumentException();
1850 if ( sTmp
.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "[From printer settings]" ) ) )
1852 else if ( pPrinter
)
1854 for (sal_uInt16 i
=0, nEnd
= pPrinter
->GetPaperBinCount(); i
< nEnd
; i
++ )
1856 if (sTmp
== OUString ( pPrinter
->GetPaperBinName ( i
) ) )
1863 if ( nBin
== USHRT_MAX
)
1864 throw lang::IllegalArgumentException();
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
);
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()) ));
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
);
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
])
1927 SfxStyleSheetBase
* pBase
;
1928 pBase
= ((SfxStyleSheetBasePool
*)pBasePool
)->Find(pCharStyleNames
[i
], SFX_STYLE_FAMILY_CHAR
);
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
);
1951 aFmt
.SetBulletFont(&aFont
);
1953 aSetRule
.Set( i
, &aFmt
);
1956 rBase
.mxNewBase
->SetNumRule(aSetRule
);
1960 throw lang::IllegalArgumentException();
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 );
1969 // rBase.mxNewBase->GetCollection()->SetOutlineLevel( NO_NUMBERING );
1972 case RES_PARATR_OUTLINELEVEL
: //add by zahojianwei
1974 sal_Int16 nLevel
= 0;
1976 if( 0 <= nLevel
&& nLevel
<= MAXLEVEL
)
1977 rBase
.mxNewBase
->GetCollection()->SetAttrOutlineLevel( nLevel
);
1979 break; //<-end,zhaojianwei
1980 case FN_UNO_FOLLOW_STYLE
:
1985 SwStyleNameMapper::FillUIName(sTmp
, aString
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
) ;
1986 rBase
.mxNewBase
->SetFollow( aString
);
1990 if( MID_PAGEDESC_PAGEDESCNAME
!= rEntry
.nMemberId
)
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
));
2005 pNewDesc
= new SwFmtPageDesc();
2007 rValue
>>= uDescName
;
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
;
2016 SwPageDesc
* pPageDesc
= ::GetPageDescByName_Impl(*pDoc
, sDescName
);
2019 pPageDesc
->Add( pNewDesc
);
2024 throw lang::IllegalArgumentException();
2029 rStyleSet
.ClearItem(RES_BREAK
);
2030 rStyleSet
.Put(SwFmtPageDesc());
2033 rStyleSet
.Put(*pNewDesc
);
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
);
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
++)
2063 if ((pSeq
[i
].Value
>>= aTmp
))
2065 // get UI style name from programmatic style name
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
)
2090 aCondItem
.SetStyle( &aStyleName
, nIdx
);
2096 throw lang::IllegalArgumentException();
2097 rBase
.GetItemSet().Put( aCondItem
);
2100 case FN_UNO_CATEGORY
:
2102 if(!rBase
.mxNewBase
->IsUserDefined())
2103 throw lang::IllegalArgumentException();
2110 case style::ParagraphStyleCategory::TEXT
:
2111 nId
= SWSTYLEBIT_TEXT
;
2113 case style::ParagraphStyleCategory::CHAPTER
:
2114 nId
= SWSTYLEBIT_CHAPTER
;
2116 case style::ParagraphStyleCategory::LIST
:
2117 nId
= SWSTYLEBIT_LIST
;
2119 case style::ParagraphStyleCategory::INDEX
:
2120 nId
= SWSTYLEBIT_IDX
;
2122 case style::ParagraphStyleCategory::EXTRA
:
2123 nId
= SWSTYLEBIT_EXTRA
;
2125 case style::ParagraphStyleCategory::HTML
:
2126 nId
= SWSTYLEBIT_HTML
;
2128 default: throw lang::IllegalArgumentException();
2130 rBase
.mxNewBase
->SetMask( nId
|SFXSTYLEBIT_USERDEF
);
2133 case SID_SWREGISTER_COLLECTION
:
2137 SwRegisterItem
aReg( sName
.getLength() != 0);
2138 aReg
.SetWhich(SID_SWREGISTER_MODE
);
2139 rBase
.GetItemSet().Put(aReg
);
2141 SwStyleNameMapper::FillUIName(sName
, aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
2143 rBase
.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION
, aString
) );
2146 case RES_TXTATR_CJK_RUBY
:
2147 if(MID_RUBY_CHARSTYLE
== rEntry
.nMemberId
)
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
));
2158 pRuby
= new SwFmtRuby(aEmptyStr
);
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
);
2172 throw lang::IllegalArgumentException();
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
));
2189 pDrop
= new SwFmtDrop();
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
);
2197 pDrop
->SetCharFmt(pStyle
->GetCharFmt());
2199 throw lang::IllegalArgumentException();
2200 rStyleSet
.Put(*pDrop
);
2204 throw lang::IllegalArgumentException();
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
)
2249 throw uno::RuntimeException();
2250 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_STYLE
;
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;
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
);
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?" );
2278 aBaseImpl
.mxNewBase
= new SwDocStyleSheet(*(SwDocStyleSheet
*)pBase
);
2280 throw uno::RuntimeException();
2283 for(sal_Int16 nProp
= 0; nProp
< rPropertyNames
.getLength(); nProp
++)
2285 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName( pNames
[nProp
]);
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();
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
;
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
)
2341 if(FN_UNO_IS_PHYSICAL
== rEntry
.nWID
)
2343 BOOL bPhys
= pBase
!= 0;
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() )
2353 aRet
.setValue(&bPhys
, ::getBooleanCppuType());
2357 if(!rBase
.mxNewBase
.is())
2358 rBase
.mxNewBase
= new SwDocStyleSheet( *(SwDocStyleSheet
*)pBase
);
2363 SfxItemSet
& rSet
= rBase
.GetItemSet();
2364 rPropSet
.getPropertyValue(rEntry
, rSet
, aRet
);
2368 aRet
<<= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "[From printer settings]" ) );
2371 SfxPrinter
*pPrinter
= pDoc
->getPrinter( false );
2374 sTmp
= pPrinter
->GetPaperBinName ( nBin
);
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));
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 );
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
:
2405 SwStyleNameMapper::FillProgName(rBase
.mxNewBase
->GetFollow(), aString
, lcl_GetSwEnumFromSfxEnum ( eFamily
), sal_True
);
2406 aRet
<<= OUString( aString
);
2410 if( MID_PAGEDESC_PAGEDESCNAME
!= rEntry
.nMemberId
)
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();
2421 SwStyleNameMapper::FillProgName(pDesc
->GetName(), aString
, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC
, sal_True
);
2422 aRet
<<= OUString( aString
);
2427 case FN_UNO_IS_AUTO_UPDATE
:
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());
2437 case FN_UNO_DISPLAY_NAME
:
2439 OUString
sName(rBase
.mxNewBase
->GetDisplayName());
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
)
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
);
2474 case FN_UNO_CATEGORY
:
2476 sal_uInt16 nPoolId
= rBase
.mxNewBase
->GetCollection()->GetPoolFmtId();
2478 switch ( COLL_GET_RANGE_BITS
& nPoolId
)
2480 case COLL_TEXT_BITS
:
2481 nRet
= style::ParagraphStyleCategory::TEXT
;
2484 nRet
= style::ParagraphStyleCategory::CHAPTER
;
2486 case COLL_LISTS_BITS
:
2487 nRet
= style::ParagraphStyleCategory::LIST
;
2489 case COLL_REGISTER_BITS
:
2490 nRet
= style::ParagraphStyleCategory::INDEX
;
2492 case COLL_EXTRA_BITS
:
2493 nRet
= style::ParagraphStyleCategory::EXTRA
;
2495 case COLL_HTML_BITS
:
2496 nRet
= style::ParagraphStyleCategory::HTML
;
2502 case SID_SWREGISTER_COLLECTION
:
2504 const SwPageDesc
*pPageDesc
= rBase
.mxNewBase
->GetPageDesc();
2505 const SwTxtFmtColl
* pCol
= 0;
2508 pCol
= pPageDesc
->GetRegisterFmtColl();
2510 SwStyleNameMapper::FillProgName(
2511 pCol
->GetName(), aString
, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL
, sal_True
);
2512 aRet
<<= OUString ( aString
);
2518 SfxItemSet
& rSet
= rBase
.GetItemSet();
2519 rPropSet
.getPropertyValue(rEntry
, rSet
, aRet
);
2524 throw uno::RuntimeException();
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
)
2535 throw uno::RuntimeException();
2536 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_STYLE
;
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;
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
]);
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 ) );
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
)
2574 pPropImpl
->GetProperty ( pNames
[nProp
], pAny
);
2577 sal_Bool bExcept
= sal_False
;
2580 case SFX_STYLE_FAMILY_PSEUDO
:
2583 case SFX_STYLE_FAMILY_PARA
:
2584 case SFX_STYLE_FAMILY_PAGE
:
2585 pPropImpl
->GetProperty ( pNames
[nProp
], mxStyleData
, pRet
[ nProp
] );
2587 case SFX_STYLE_FAMILY_CHAR
:
2588 case SFX_STYLE_FAMILY_FRAME
:
2590 if (pEntry
->nWID
>= POOLATTR_BEGIN
&& pEntry
->nWID
< RES_UNKNOWNATR_END
)
2593 if ( eFamily
== SFX_STYLE_FAMILY_CHAR
)
2594 pFmt
= m_pDoc
->GetDfltCharFmt();
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
);
2611 uno::RuntimeException aExcept
;
2612 aExcept
.Message
= OUString ( RTL_CONSTASCII_USTRINGPARAM ( "No default value for: " ) ) + pNames
[nProp
];
2617 pRet
[ nProp
] = *pAny
;
2620 throw uno::RuntimeException();
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 ) );
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();
2763 pBasePool
->SetSearchMask(eFamily
);
2764 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
2765 DBG_ASSERT(pBase
, "where is the style?" );
2769 const OUString
* pNames
= rPropertyNames
.getConstArray();
2770 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *(SwDocStyleSheet
*)pBase
) );
2771 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_STYLE
;
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;
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
);
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
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
;
2820 pStates
[i
] = beans::PropertyState_DEFAULT_VALUE
;
2823 pStates
[i
] = beans::PropertyState_AMBIGUOUS_VALUE
;
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
;
2849 throw uno::RuntimeException();
2852 throw uno::RuntimeException();
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;
2873 pBasePool
->SetSearchMask(eFamily
);
2874 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
2875 DBG_ASSERT(pBase
, "Where is the style?");
2879 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *(SwDocStyleSheet
*)pBase
) );
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
);
2890 pTargetFmt
= &pDesc
->GetMaster();
2893 case SFX_STYLE_FAMILY_PSEUDO
:
2900 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_STYLE
;
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;
2910 const SfxItemPropertySet
* pPropSet
= aSwMapProvider
.GetPropertySet(nPropSetId
);
2911 const SfxItemPropertyMap
*pMap
= pPropSet
->getPropertyMap();
2913 const OUString
* pNames
= aPropertyNames
.getConstArray();
2917 for( sal_Int32 nProp
= 0, nEnd
= aPropertyNames
.getLength(); nProp
< nEnd
; nProp
++ )
2919 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName( pNames
[nProp
] );
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 );
2930 // pTargetFmt->ResetFmtAttr( pEntry->nWID );
2931 if( pEntry
->nWID
== RES_PARATR_OUTLINELEVEL
) //add by zhaojianwei
2932 static_cast<SwTxtFmtColl
*>(pTargetFmt
)->DeleteAssignmentToListLevelOfOutlineStyle();
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());
2950 pBasePool
->SetSearchMask(eFamily
);
2951 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
2952 DBG_ASSERT(pBase
, "where is the style, you fiend!?");
2956 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *(SwDocStyleSheet
*)pBase
) );
2958 SwFmt
*pTargetFmt
= 0;
2959 sal_uInt16 nPgDscPos
= USHRT_MAX
;
2962 case SFX_STYLE_FAMILY_CHAR
:
2963 pTargetFmt
= xStyle
->GetCharFmt();
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
2977 case SFX_STYLE_FAMILY_FRAME
:
2978 pTargetFmt
= xStyle
->GetFrmFmt();
2980 case SFX_STYLE_FAMILY_PAGE
:
2982 SwPageDesc
*pDesc
= m_pDoc
->FindPageDescByName( xStyle
->GetPageDesc()->GetName(), &nPgDscPos
);
2985 pTargetFmt
= &pDesc
->GetMaster();
2986 pDesc
->SetUseOn ( nsUseOnPage::PD_ALL
);
2990 case SFX_STYLE_FAMILY_PSEUDO
:
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
);
3025 // --> OD 2008-07-25 #i91928#
3026 // aFrmSz.SetWidth( LONG_MAX );
3027 // aFrmSz.SetHeight( LONG_MAX );
3028 aFrmSz
.SetSize( SvxPaperInfo::GetDefaultPaperSize() );
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
);
3047 // --> OD 2007-01-25 #i73790# - method renamed
3048 pTargetFmt
->ResetAllFmtAttr();
3052 if( USHRT_MAX
!= nPgDscPos
)
3053 m_pDoc
->ChgPageDesc( nPgDscPos
,
3054 const_cast<const SwDoc
*>(m_pDoc
)
3055 ->GetPageDesc(nPgDscPos
) );
3060 throw uno::RuntimeException();
3062 else if ( bIsDescriptor
)
3063 pPropImpl
->ClearAllProperties();
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
);
3078 pBasePool
->SetSearchMask(eFamily
);
3079 SfxStyleSheetBase
* pBase
= pBasePool
->Find(sStyleName
);
3080 DBG_ASSERT(pBase
, "Doesn't seem to be a style!");
3084 rtl::Reference
< SwDocStyleSheet
> xStyle( new SwDocStyleSheet( *(SwDocStyleSheet
*)pBase
) );
3085 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_STYLE
;
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;
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
] );
3105 throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames
[i
], static_cast < cppu::OWeakObject
* > ( this ) );
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
);
3117 throw uno::RuntimeException();
3120 throw uno::RuntimeException();
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
);
3141 if(( pHint
->GetId() & SFX_HINT_DYING
) || ( pHint
->GetId() & SFX_STYLESHEET_ERASED
))
3146 else if( pHint
->GetId() &(SFX_STYLESHEET_CHANGED
|SFX_STYLESHEET_ERASED
) )
3148 ((SfxStyleSheetBasePool
&)rBC
).SetSearchMask(eFamily
);
3149 SfxStyleSheetBase
* pOwnBase
= ((SfxStyleSheetBasePool
&)rBC
).Find(sStyleName
);
3158 /* -----------------------------15.08.00 11:35--------------------------------
3160 ---------------------------------------------------------------------------*/
3161 void SwXStyle::Invalidate()
3166 mxStyleData
.clear();
3167 mxStyleFamily
.clear();
3171 /******************************************************************
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),
3185 /* -----------------23.08.99 15:52-------------------
3187 --------------------------------------------------*/
3188 SwXPageStyle::SwXPageStyle(SwDocShell
* pDocSh
) :
3189 SwXStyle(pDocSh
->GetDoc(), SFX_STYLE_FAMILY_PAGE
),
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
)
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());
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?" );
3229 aBaseImpl
.mxNewBase
= new SwDocStyleSheet(*(SwDocStyleSheet
*)pBase
);
3231 throw uno::RuntimeException();
3234 for(sal_Int16 nProp
= 0; nProp
< rPropertyNames
.getLength(); nProp
++)
3236 const SfxItemPropertySimpleEntry
* pEntry
= pMap
->getByName( pNames
[nProp
] );
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 ) );
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
;
3276 case FN_UNO_HEADER_ON
: nRes
= SID_ATTR_PAGE_ON
;
3278 case FN_UNO_FOOTER_BACKGROUND
: bFooter
= sal_True
;
3280 case FN_UNO_HEADER_BACKGROUND
: nRes
= RES_BACKGROUND
; nItemType
= TYPE_BRUSH
;
3282 case FN_UNO_FOOTER_BOX
: bFooter
= sal_True
;
3284 case FN_UNO_HEADER_BOX
: nRes
= RES_BOX
; nItemType
= TYPE_BOX
;
3286 case FN_UNO_FOOTER_LR_SPACE
: bFooter
= sal_True
;
3288 case FN_UNO_HEADER_LR_SPACE
: nRes
= RES_LR_SPACE
;nItemType
= TYPE_LRSPACE
;
3290 case FN_UNO_FOOTER_SHADOW
: bFooter
= sal_True
;
3292 case FN_UNO_HEADER_SHADOW
: nRes
= RES_SHADOW
;nItemType
= TYPE_SHADOW
;
3294 case FN_UNO_FOOTER_BODY_DISTANCE
: bFooter
= sal_True
;
3296 case FN_UNO_HEADER_BODY_DISTANCE
: nRes
= RES_UL_SPACE
;nItemType
= TYPE_ULSPACE
;
3298 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE
: bFooter
= sal_True
;
3300 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE
: nRes
= SID_ATTR_PAGE_DYNAMIC
;
3302 case FN_UNO_FOOTER_SHARE_CONTENT
: bFooter
= sal_True
;
3304 case FN_UNO_HEADER_SHARE_CONTENT
: nRes
= SID_ATTR_PAGE_SHARED
;
3306 case FN_UNO_FOOTER_HEIGHT
: bFooter
= sal_True
;
3308 case FN_UNO_HEADER_HEIGHT
: nRes
= SID_ATTR_PAGE_SIZE
;nItemType
= TYPE_SIZE
;
3310 case FN_UNO_FOOTER_EAT_SPACING
: bFooter
= sal_True
;
3312 case FN_UNO_HEADER_EAT_SPACING
: nRes
= RES_HEADER_FOOTER_EAT_SPACING
;nItemType
= TYPE_SIZE
;
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
);
3329 pNewItem
= pItem
->Clone();
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
);
3350 else if(SID_ATTR_PAGE_ON
== nRes
)
3352 sal_Bool bVal
= *(sal_Bool
*)pValues
[nProp
].getValue();
3355 SfxItemSet
aTempSet(*aBaseImpl
.GetItemSet().GetPool(),
3356 RES_BACKGROUND
, RES_SHADOW
,
3357 RES_LR_SPACE
, RES_UL_SPACE
,
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
,
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
,
3372 aBaseImpl
.GetItemSet().Put(aNewSetItem
);
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
);
3385 throw lang::IllegalArgumentException();
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();
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();
3407 throw uno::RuntimeException();
3409 if(aBaseImpl
.HasItemSet())
3411 BOOL bDoesUndo
= GetDoc()->DoesUndo();
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
;
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
)
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
] );
3467 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames
[nProp
], static_cast < cppu::OWeakObject
* > ( this ) );
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());
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
:
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
;
3525 case FN_UNO_FOOTER_BACKGROUND
: bFooter
= sal_True
;
3527 case FN_UNO_HEADER_BACKGROUND
: nRes
= RES_BACKGROUND
;
3529 case FN_UNO_FOOTER_BOX
: bFooter
= sal_True
;
3531 case FN_UNO_HEADER_BOX
: nRes
= RES_BOX
;
3533 case FN_UNO_FOOTER_LR_SPACE
: bFooter
= sal_True
;
3535 case FN_UNO_HEADER_LR_SPACE
: nRes
= RES_LR_SPACE
;
3537 case FN_UNO_FOOTER_SHADOW
: bFooter
= sal_True
;
3539 case FN_UNO_HEADER_SHADOW
: nRes
= RES_SHADOW
;
3541 case FN_UNO_FOOTER_BODY_DISTANCE
: bFooter
= sal_True
;
3543 case FN_UNO_HEADER_BODY_DISTANCE
: nRes
= RES_UL_SPACE
;
3545 case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE
: bFooter
= sal_True
;
3547 case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE
: nRes
= SID_ATTR_PAGE_DYNAMIC
;
3549 case FN_UNO_FOOTER_SHARE_CONTENT
: bFooter
= sal_True
;
3551 case FN_UNO_HEADER_SHARE_CONTENT
: nRes
= SID_ATTR_PAGE_SHARED
;
3553 case FN_UNO_FOOTER_HEIGHT
: bFooter
= sal_True
;
3555 case FN_UNO_HEADER_HEIGHT
: nRes
= SID_ATTR_PAGE_SIZE
;
3557 case FN_UNO_FOOTER_EAT_SPACING
: bFooter
= sal_True
;
3559 case FN_UNO_HEADER_EAT_SPACING
: nRes
= RES_HEADER_FOOTER_EAT_SPACING
;
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
);
3573 pItem
->QueryValue(pRet
[nProp
], pEntry
->nMemberId
);
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
;
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
:
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();
3608 pFrmFmt
= &rDesc
.GetMaster();
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
;
3624 xRet
= new SwXHeadFootText(*pHeadFootFmt
, bHeader
);
3625 pRet
[nProp
].setValue(&xRet
, ::getCppuType((uno::Reference
<text::XText
>*)0));
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
);
3639 pRet
[nProp
] = lcl_GetStyleProperty(*pEntry
, *pPropSet
, aBase
, pBase
, GetFamily(), GetDoc() );
3642 else if(IsDescriptor())
3645 GetPropImpl()->GetProperty(pNames
[nProp
], pAny
);
3647 GetPropImpl()->GetProperty ( pNames
[nProp
], mxStyleData
, pRet
[ nProp
] );
3649 pRet
[nProp
] = *pAny
;
3652 throw uno::RuntimeException();
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 ) );
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);
3729 /* -----------------------------15.12.00 14:30--------------------------------
3731 ---------------------------------------------------------------------------*/
3732 uno::Any
SwXFrameStyle::queryInterface( const uno::Type
& rType
) throw(uno::RuntimeException
)
3735 if(rType
== ::getCppuType((uno::Reference
<XEventsSupplier
>*)0))
3736 aRet
<<= uno::Reference
<XEventsSupplier
>(this);
3738 aRet
= SwXStyle::queryInterface(rType
);
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());
3777 if(nIndex
< 0 || nIndex
>= AUTOSTYLE_FAMILY_COUNT
)
3778 throw lang::IndexOutOfBoundsException();
3781 uno::Reference
< style::XAutoStyleFamily
> aRef
;
3782 IStyleAccess::SwAutoStyleFamily nType
= aAutoStyleByIndex
[nIndex
];
3785 case IStyleAccess::AUTO_STYLE_CHAR
:
3787 if(!xAutoCharStyles
.is())
3788 xAutoCharStyles
= new SwXAutoStyleFamily(pDocShell
, nType
);
3789 aRef
= xAutoCharStyles
;
3792 case IStyleAccess::AUTO_STYLE_RUBY
:
3794 if(!xAutoRubyStyles
.is())
3795 xAutoRubyStyles
= new SwXAutoStyleFamily(pDocShell
, nType
);
3796 aRef
= xAutoRubyStyles
;
3799 case IStyleAccess::AUTO_STYLE_PARA
:
3801 if(!xAutoParaStyles
.is())
3802 xAutoParaStyles
= new SwXAutoStyleFamily(pDocShell
, nType
);
3803 aRef
= xAutoParaStyles
;
3810 aRet
.setValue(&aRef
, ::getCppuType((const uno::Reference
<style::XAutoStyleFamily
>*)0));
3813 throw uno::RuntimeException();
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
)
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
)
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);
3844 throw container::NoSuchElementException();
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");
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 )
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())
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
)
3905 throw uno::RuntimeException();
3906 const USHORT
* pRange
= 0;
3907 const SfxItemPropertySet
* pPropSet
= 0;
3910 case IStyleAccess::AUTO_STYLE_CHAR
:
3912 pRange
= aCharAutoFmtSetRange
;
3913 pPropSet
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE
);
3916 case IStyleAccess::AUTO_STYLE_RUBY
:
3918 pRange
= 0;//aTxtNodeSetRange;
3919 pPropSet
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE
);
3922 case IStyleAccess::AUTO_STYLE_PARA
:
3924 pRange
= aTxtNodeSetRange
;
3925 pPropSet
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE
);
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
);
3955 /*-- 31.05.2006 11:24:02---------------------------------------------------
3957 -----------------------------------------------------------------------*/
3958 uno::Reference
< container::XEnumeration
> SwXAutoStyleFamily::createEnumeration( )
3959 throw (uno::RuntimeException
)
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
)
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
);
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()
4035 void SwXAutoStylesEnumerator::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
4037 ClientModify(this, pOld
, pNew
);
4038 if(!GetRegisteredIn())
4046 /*-- 31.05.2006 11:24:05---------------------------------------------------
4048 -----------------------------------------------------------------------*/
4049 ::sal_Bool
SwXAutoStylesEnumerator::hasMoreElements( )
4050 throw (uno::RuntimeException
)
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
)
4063 throw uno::RuntimeException();
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));
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())
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
;
4107 case IStyleAccess::AUTO_STYLE_CHAR
:
4109 static uno::Reference
< beans::XPropertySetInfo
> xCharRef
;
4112 xCharRef
= aSwMapProvider
.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE
)->getPropertySetInfo();
4117 case IStyleAccess::AUTO_STYLE_RUBY
:
4119 static uno::Reference
< beans::XPropertySetInfo
> xRubyRef
;
4122 sal_uInt16 nMapId
= PROPERTY_MAP_RUBY_AUTO_STYLE
;
4123 xRubyRef
= aSwMapProvider
.GetPropertySet(nMapId
)->getPropertySetInfo();
4128 case IStyleAccess::AUTO_STYLE_PARA
:
4130 static uno::Reference
< beans::XPropertySetInfo
> xParaRef
;
4133 sal_uInt16 nMapId
= PROPERTY_MAP_PARA_AUTO_STYLE
;
4134 xParaRef
= aSwMapProvider
.GetPropertySet(nMapId
)->getPropertySetInfo();
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
)
4235 throw uno::RuntimeException();
4238 sal_Int8 nPropSetId
= PROPERTY_MAP_CHAR_AUTO_STYLE
;
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;
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
);
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
;
4270 pPropSet
->getPropertyValue( *pEntry
, rSet
, pValues
[i
] );
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 ) );
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
)
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
;
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;
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
);
4400 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName
, static_cast < cppu::OWeakObject
* > ( this ) );
4401 pStates
[i
] = pPropSet
->getPropertyState(*pEntry
, rSet
);
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);
4435 /*-- 19.05.2006 11:24:14---------------------------------------------------
4437 -----------------------------------------------------------------------*/
4438 uno::Sequence
< beans::PropertyValue
> SwXAutoStyle::getProperties() throw (uno::RuntimeException
)
4441 throw uno::RuntimeException();
4442 vos::OGuard
aGuard(Application::GetSolarMutex());
4443 std::vector
< beans::PropertyValue
> aPropertyVector
;
4445 sal_Int8 nPropSetId
= 0;
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;
4455 const SfxItemPropertySet
* pPropSet
= aSwMapProvider
.GetPropertySet(nPropSetId
);
4456 const SfxItemPropertyMap
*pMap
= pPropSet
->getPropertyMap();
4457 PropertyEntryVector_t aPropVector
= pMap
->getPropertyEntries();
4458 // struct compareWhichIds
4460 // bool operator()(const USHORT w1, const USHORT w2) const
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() )
4471 // aPropMap[aIt->nWID] = *aIt;
4475 SfxItemSet
& rSet
= *pSet
.get();
4476 SfxItemIter
aIter(rSet
);
4477 const SfxPoolItem
* pItem
= aIter
.FirstItem();
4481 const USHORT nWID
= pItem
->Which();
4483 // PropertyMap_t::const_iterator aMapIt = aPropMap[nWID];
4484 // if( aMapIt != aPropMap.getEnd() )
4486 // beans::PropertyValue aPropertyValue;
4487 // aPropertyValue.Name = aIt->sName;
4488 // pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4489 // aPropertyVector.push_back( aPropertyValue );
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
);
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 );
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
];