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