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