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 320 : static sal_uInt16 lcl_ConvertFNToRES(sal_uInt16 nFNId)
111 : {
112 320 : sal_uInt16 nRes = USHRT_MAX;
113 320 : 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 80 : case FN_UNO_HEADER_BACKGROUND: nRes = RES_BACKGROUND;
120 80 : break;
121 : case FN_UNO_FOOTER_BOX:
122 128 : case FN_UNO_HEADER_BOX: nRes = RES_BOX;
123 128 : break;
124 : case FN_UNO_FOOTER_LR_SPACE:
125 32 : case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
126 32 : break;
127 : case FN_UNO_FOOTER_SHADOW:
128 16 : case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
129 16 : break;
130 : case FN_UNO_FOOTER_BODY_DISTANCE:
131 16 : case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
132 16 : break;
133 : case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE:
134 16 : case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
135 16 : 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 16 : case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
143 16 : break;
144 : case FN_UNO_FOOTER_EAT_SPACING:
145 16 : case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;
146 16 : break;
147 : }
148 320 : return nRes;
149 :
150 : }
151 :
152 15084 : static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
153 : {
154 15084 : switch ( eFamily )
155 : {
156 : case SFX_STYLE_FAMILY_CHAR:
157 3652 : return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
158 : case SFX_STYLE_FAMILY_PARA:
159 8823 : return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
160 : case SFX_STYLE_FAMILY_FRAME:
161 548 : return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
162 : case SFX_STYLE_FAMILY_PAGE:
163 1677 : return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
164 : case SFX_STYLE_FAMILY_PSEUDO:
165 384 : 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 12 : 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 24 : ::sal_Bool hasMoreElements() { return aIter != mAutoStyles.end(); }
181 6 : SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
182 6 : IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
183 6 : 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 448 : SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
208 : SwUnoCollection(rDocShell.GetDoc()),
209 : pDocShell(&rDocShell),
210 : pxCharStyles(0),
211 : pxParaStyles(0),
212 : pxFrameStyles(0),
213 : pxPageStyles(0),
214 448 : pxNumberingStyles(0)
215 : {
216 :
217 448 : }
218 :
219 210 : SwXStyleFamilies::~SwXStyleFamilies()
220 : {
221 70 : delete pxCharStyles;
222 70 : delete pxParaStyles;
223 70 : delete pxFrameStyles;
224 70 : delete pxPageStyles;
225 70 : delete pxNumberingStyles;
226 140 : }
227 :
228 2931 : uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
229 : throw(
230 : container::NoSuchElementException,
231 : lang::WrappedTargetException,
232 : uno::RuntimeException )
233 : {
234 2931 : SolarMutexGuard aGuard;
235 : // der Index kommt aus const unsigned short aStyleByIndex[] =
236 2931 : uno::Any aRet;
237 2931 : if(!IsValid())
238 0 : throw uno::RuntimeException();
239 2931 : if(Name.compareToAscii("CharacterStyles") == 0 )
240 883 : aRet = getByIndex(0);
241 2048 : else if(Name.compareToAscii("ParagraphStyles") == 0)
242 641 : aRet = getByIndex(1);
243 1407 : else if(Name.compareToAscii("FrameStyles") == 0 )
244 540 : aRet = getByIndex(3);
245 867 : else if(Name.compareToAscii("PageStyles") == 0 )
246 573 : aRet = getByIndex(2);
247 294 : else if(Name.compareToAscii("NumberingStyles") == 0 )
248 294 : aRet = getByIndex(4);
249 : else
250 0 : throw container::NoSuchElementException();
251 2931 : 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 804 : sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException )
267 : {
268 2355 : if( Name.compareToAscii("CharacterStyles") == 0 ||
269 639 : Name.compareToAscii("ParagraphStyles") == 0 ||
270 454 : Name.compareToAscii("FrameStyles") == 0 ||
271 304 : Name.compareToAscii("PageStyles") == 0 ||
272 154 : Name.compareToAscii("NumberingStyles") == 0 )
273 800 : return sal_True;
274 : else
275 4 : 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 2931 : uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
284 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
285 : {
286 2931 : SolarMutexGuard aGuard;
287 2931 : uno::Any aRet;
288 2931 : if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
289 0 : throw lang::IndexOutOfBoundsException();
290 2931 : if(IsValid())
291 : {
292 2931 : uno::Reference< container::XNameContainer > aRef;
293 2931 : sal_uInt16 nType = aStyleByIndex[nIndex];
294 2931 : switch( nType )
295 : {
296 : case SFX_STYLE_FAMILY_CHAR:
297 : {
298 883 : if(!pxCharStyles)
299 : {
300 295 : ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
301 295 : *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
302 : }
303 883 : aRef = *pxCharStyles;
304 : }
305 883 : break;
306 : case SFX_STYLE_FAMILY_PARA:
307 : {
308 641 : if(!pxParaStyles)
309 : {
310 294 : ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
311 294 : *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
312 : }
313 641 : aRef = *pxParaStyles;
314 : }
315 641 : break;
316 : case SFX_STYLE_FAMILY_PAGE :
317 : {
318 573 : if(!pxPageStyles)
319 : {
320 386 : ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
321 386 : *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
322 : }
323 573 : aRef = *pxPageStyles;
324 : }
325 573 : break;
326 : case SFX_STYLE_FAMILY_FRAME :
327 : {
328 540 : if(!pxFrameStyles)
329 : {
330 217 : ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
331 217 : *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
332 : }
333 540 : aRef = *pxFrameStyles;
334 : }
335 540 : break;
336 : case SFX_STYLE_FAMILY_PSEUDO:
337 : {
338 294 : if(!pxNumberingStyles)
339 : {
340 61 : ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
341 61 : *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
342 : }
343 294 : aRef = *pxNumberingStyles;
344 : }
345 294 : break;
346 : }
347 2931 : aRet.setValue(&aRef, ::getCppuType((const uno::Reference<container::XNameContainer>*)0));
348 : }
349 : else
350 0 : throw uno::RuntimeException();
351 5862 : 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 1253 : SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
457 : eFamily((SfxStyleFamily)nFamily),
458 1253 : pBasePool(pDocSh->GetStyleSheetPool()),
459 2506 : pDocShell(pDocSh)
460 : {
461 1253 : StartListening(*pBasePool);
462 1253 : }
463 :
464 538 : SwXStyleFamily::~SwXStyleFamily()
465 : {
466 :
467 538 : }
468 :
469 4 : static sal_Int32 lcl_GetCountOrName ( const SwDoc &rDoc, SfxStyleFamily eFamily, String *pString, sal_uInt16 nIndex = USHRT_MAX )
470 : {
471 4 : sal_Int32 nCount = 0;
472 4 : 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 4 : sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
579 4 : nIndex = nIndex - nBaseCount;
580 4 : const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
581 8 : for(sal_uInt16 i = 0; i < rNumTbl.size(); ++i)
582 : {
583 4 : const SwNumRule& rRule = *rNumTbl[ i ];
584 4 : if( rRule.IsAutoRule() )
585 4 : 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 4 : nCount += nBaseCount;
597 : }
598 4 : break;
599 :
600 : default:
601 : ;
602 : }
603 4 : return nCount;
604 : }
605 :
606 4 : sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException )
607 : {
608 4 : SolarMutexGuard aGuard;
609 4 : return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
610 : }
611 :
612 40 : uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
613 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
614 : {
615 40 : SolarMutexGuard aGuard;
616 40 : uno::Any aRet;
617 40 : if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
618 : {
619 40 : sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
620 40 : if(pBasePool)
621 : {
622 40 : String sStyleName;
623 40 : 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 40 : if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
706 : {
707 40 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
708 : }
709 : }
710 40 : break;
711 :
712 : default:
713 : ;
714 : }
715 40 : if ( !sStyleName.Len() )
716 0 : lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
717 :
718 40 : if ( sStyleName.Len() )
719 : {
720 40 : SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
721 40 : if(pBase)
722 : {
723 40 : uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
724 40 : 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 40 : new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
731 : }
732 40 : aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
733 : }
734 : else
735 0 : throw container::NoSuchElementException();
736 : }
737 : else
738 40 : throw lang::IndexOutOfBoundsException();
739 : }
740 : else
741 40 : throw uno::RuntimeException();
742 : }
743 : else
744 0 : throw lang::IndexOutOfBoundsException();
745 :
746 40 : return aRet;
747 : }
748 :
749 4185 : uno::Any SwXStyleFamily::getByName(const OUString& rName)
750 : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
751 : {
752 4185 : SolarMutexGuard aGuard;
753 4185 : uno::Any aRet;
754 4185 : String sStyleName;
755 4185 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
756 4185 : if(pBasePool)
757 : {
758 4185 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
759 4185 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
760 4185 : if(pBase)
761 : {
762 4183 : uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
763 4183 : if(!xStyle.is())
764 : {
765 : xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
766 882 : new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
767 : eFamily == SFX_STYLE_FAMILY_FRAME ?
768 1290 : new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
769 5991 : new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
770 : }
771 4183 : aRet.setValue(&xStyle, ::getCppuType((uno::Reference<style::XStyle>*)0));
772 : }
773 : else
774 2 : throw container::NoSuchElementException();
775 : }
776 : else
777 0 : throw uno::RuntimeException();
778 8368 : return aRet;
779 :
780 : }
781 :
782 86 : uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException )
783 : {
784 86 : SolarMutexGuard aGuard;
785 86 : uno::Sequence< OUString > aRet;
786 86 : if(pBasePool)
787 : {
788 86 : SfxStyleSheetIterator* pIterator = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
789 86 : sal_uInt16 nCount = pIterator->Count();
790 86 : aRet.realloc(nCount);
791 86 : OUString* pArray = aRet.getArray();
792 86 : String aString;
793 2660 : for(sal_uInt16 i = 0; i < nCount; i++)
794 : {
795 2574 : SwStyleNameMapper::FillProgName((*pIterator)[i]->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
796 2574 : pArray[i] = OUString ( aString );
797 : }
798 86 : delete pIterator;
799 : }
800 : else
801 0 : throw uno::RuntimeException();
802 172 : return aRet;
803 : }
804 :
805 3221 : sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException )
806 : {
807 3221 : SolarMutexGuard aGuard;
808 3221 : sal_Bool bRet = sal_False;
809 3221 : if(pBasePool)
810 : {
811 3221 : String sStyleName;
812 3221 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
813 3221 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
814 3221 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
815 3221 : bRet = 0 != pBase;
816 : }
817 : else
818 0 : throw uno::RuntimeException();
819 6442 : 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 814 : void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
837 : throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException )
838 : {
839 814 : SolarMutexGuard aGuard;
840 814 : if(pBasePool)
841 : {
842 814 : String sStyleName;
843 814 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
844 814 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
845 814 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
846 814 : SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
847 814 : if(pBase || pUINameBase)
848 0 : throw container::ElementExistException();
849 : else
850 : {
851 814 : if(rElement.getValueType().getTypeClass() ==
852 : uno::TypeClass_INTERFACE)
853 : {
854 : uno::Reference< uno::XInterface > * pxRef =
855 814 : (uno::Reference< uno::XInterface > *)rElement.getValue();
856 :
857 814 : uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
858 :
859 814 : SwXStyle* pNewStyle = 0;
860 814 : if(xStyleTunnel.is())
861 : {
862 : pNewStyle = reinterpret_cast< SwXStyle * >(
863 814 : sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
864 : }
865 1628 : if(!pNewStyle || !pNewStyle->IsDescriptor() ||
866 814 : pNewStyle->GetFamily() != eFamily)
867 0 : throw lang::IllegalArgumentException();
868 814 : if(pNewStyle)
869 : {
870 814 : sal_uInt16 nMask = SFXSTYLEBIT_ALL;
871 814 : if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
872 196 : nMask &= ~SWSTYLEBIT_CONDCOLL;
873 : #if OSL_DEBUG_LEVEL > 1
874 : SfxStyleSheetBase& rNewBase =
875 : #endif
876 814 : pBasePool->Make(sStyleName, eFamily, nMask);
877 814 : pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
878 814 : pNewStyle->SetStyleName(sStyleName);
879 814 : String sParentStyleName(pNewStyle->GetParentStyleName());
880 814 : if(sParentStyleName.Len())
881 : {
882 320 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
883 320 : SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
884 638 : if(pParentBase && pParentBase->GetFamily() == eFamily &&
885 318 : &pParentBase->GetPool() == pBasePool)
886 318 : 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 814 : pNewStyle->ApplyDescriptorProperties();
894 : }
895 : else
896 814 : throw lang::IllegalArgumentException();
897 : }
898 : else
899 0 : throw lang::IllegalArgumentException();
900 814 : }
901 : }
902 : else
903 814 : throw uno::RuntimeException();
904 814 : }
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 6922 : void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
1026 : {
1027 6922 : SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
1028 6922 : if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
1029 : {
1030 2 : pBasePool = 0;
1031 2 : pDocShell = 0;
1032 2 : EndListening(rBC);
1033 : }
1034 6922 : }
1035 :
1036 4223 : SwXStyle* SwXStyleFamily::_FindStyle(const String& rStyleName)const
1037 : {
1038 4223 : sal_uInt16 nLCount = pBasePool->GetListenerCount();
1039 4223 : SfxListener* pListener = 0;
1040 36256 : for( sal_uInt16 i = 0; i < nLCount; i++)
1041 : {
1042 32397 : pListener = pBasePool->GetListener( i );
1043 32397 : SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
1044 32397 : if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
1045 : {
1046 364 : return pTempStyle;
1047 : }
1048 : }
1049 3859 : 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 814 : const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
1069 :
1070 : };
1071 :
1072 814 : SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap& rMap) :
1073 : aPropertyEntries( rMap.getPropertyEntries() ),
1074 814 : nArrLen(0)
1075 : {
1076 814 : nArrLen = aPropertyEntries.size();
1077 :
1078 814 : pAnyArr = new uno::Any* [nArrLen];
1079 60906 : for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1080 60092 : pAnyArr[i] = 0;
1081 814 : }
1082 :
1083 1628 : SwStyleProperties_Impl::~SwStyleProperties_Impl()
1084 : {
1085 60906 : for ( sal_uInt16 i =0 ; i < nArrLen; i++ )
1086 60092 : delete pAnyArr[i];
1087 814 : delete[] pAnyArr;
1088 814 : }
1089 :
1090 2280 : sal_Bool SwStyleProperties_Impl::SetProperty(const ::rtl::OUString& rName, uno::Any aVal)
1091 : {
1092 2280 : sal_uInt16 nPos = 0;
1093 2280 : sal_Bool bRet = sal_False;
1094 2280 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1095 110088 : while( aIt != aPropertyEntries.end() )
1096 : {
1097 107808 : if(rName == aIt->sName)
1098 : {
1099 2280 : delete pAnyArr[nPos];
1100 2280 : pAnyArr[nPos] = new uno::Any ( aVal );
1101 2280 : bRet = sal_True;
1102 2280 : break;
1103 : }
1104 105528 : ++nPos;
1105 105528 : ++aIt;
1106 : }
1107 2280 : 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 60092 : sal_Bool SwStyleProperties_Impl::GetProperty(const ::rtl::OUString& rName, uno::Any*& rpAny )
1140 : {
1141 60092 : sal_Bool bRet = sal_False;
1142 60092 : sal_uInt16 nPos = 0;
1143 60092 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1144 2993996 : while( aIt != aPropertyEntries.end() )
1145 : {
1146 2933904 : if( rName == aIt->sName )
1147 : {
1148 60092 : rpAny = pAnyArr[nPos];
1149 60092 : bRet = sal_True;
1150 60092 : break;
1151 : }
1152 2873812 : ++nPos;
1153 2873812 : ++aIt;
1154 : }
1155 :
1156 60092 : 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 1716 : const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
1170 : {
1171 1716 : return theSwXStyleUnoTunnelId::get().getSeq();
1172 : }
1173 :
1174 858 : sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
1175 : throw(uno::RuntimeException)
1176 : {
1177 1716 : if( rId.getLength() == 16
1178 858 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
1179 1716 : rId.getConstArray(), 16 ) )
1180 : {
1181 858 : 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 814 : SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, sal_Bool bConditional) :
1257 : m_pDoc( pDoc ),
1258 : pBasePool(0),
1259 : eFamily(eFam),
1260 : bIsDescriptor(sal_True),
1261 814 : bIsConditional(bConditional)
1262 : {
1263 : // Register ourselves as a listener to the document (via the page descriptor)
1264 814 : pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1265 : // get the property set for the default style data
1266 : // First get the model
1267 814 : uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1268 : // Ask the model for it's family supplier interface
1269 814 : uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1270 : // Get the style families
1271 814 : uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1272 :
1273 814 : uno::Any aAny;
1274 814 : sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
1275 814 : switch( eFamily )
1276 : {
1277 : case SFX_STYLE_FAMILY_CHAR:
1278 : {
1279 424 : nMapId = PROPERTY_MAP_CHAR_STYLE;
1280 424 : aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "CharacterStyles" ) ) );
1281 : // Get the Frame family (and keep it for later)
1282 424 : aAny >>= mxStyleFamily;
1283 : }
1284 424 : break;
1285 : case SFX_STYLE_FAMILY_PARA:
1286 : {
1287 196 : nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1288 196 : aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "ParagraphStyles" ) ) );
1289 : // Get the Frame family (and keep it for later)
1290 196 : aAny >>= mxStyleFamily;
1291 196 : aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1292 196 : aAny >>= mxStyleData;
1293 : }
1294 196 : break;
1295 : case SFX_STYLE_FAMILY_PAGE:
1296 : {
1297 50 : nMapId = PROPERTY_MAP_PAGE_STYLE;
1298 50 : aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "PageStyles" ) ) );
1299 : // Get the Frame family (and keep it for later)
1300 50 : aAny >>= mxStyleFamily;
1301 50 : aAny = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Standard" ) ) );
1302 50 : aAny >>= mxStyleData;
1303 : }
1304 50 : 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 144 : nMapId = PROPERTY_MAP_NUM_STYLE;
1313 : }
1314 144 : break;
1315 :
1316 : default:
1317 : ;
1318 : }
1319 814 : pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
1320 814 : }
1321 :
1322 3859 : 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 3859 : pPropImpl(0)
1331 : {
1332 3859 : StartListening(rPool);
1333 3859 : if(eFam == SFX_STYLE_FAMILY_PARA)
1334 : {
1335 2090 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1336 2090 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1337 : OSL_ENSURE(pBase, "where is the style?" );
1338 2090 : if(pBase)
1339 : {
1340 2090 : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
1341 2090 : if(nId != USHRT_MAX)
1342 2078 : bIsConditional = ::IsConditionalByPoolId( nId );
1343 : else
1344 12 : bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
1345 : }
1346 : }
1347 3859 : }
1348 :
1349 12657 : SwXStyle::~SwXStyle()
1350 : {
1351 4673 : if(pBasePool)
1352 4672 : EndListening(*pBasePool);
1353 4673 : delete pPropImpl;
1354 7984 : }
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 1202 : OUString SwXStyle::getName(void) throw( uno::RuntimeException )
1368 : {
1369 1202 : SolarMutexGuard aGuard;
1370 1202 : String aString;
1371 1202 : if(pBasePool)
1372 : {
1373 1202 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1374 1202 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1375 : OSL_ENSURE(pBase, "where is the style?" );
1376 1202 : if(!pBase)
1377 0 : throw uno::RuntimeException();
1378 1202 : SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
1379 : }
1380 : else
1381 0 : aString = sStyleName;
1382 1202 : 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 : sal_Bool bExcept = sal_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 300 : sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException )
1409 : {
1410 300 : SolarMutexGuard aGuard;
1411 300 : sal_Bool bRet = sal_False;
1412 300 : if(pBasePool)
1413 : {
1414 300 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1415 300 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1416 : //if it is not found it must be non user defined
1417 300 : if(pBase)
1418 300 : bRet = pBase->IsUserDefined();
1419 : }
1420 : else
1421 0 : throw uno::RuntimeException();
1422 300 : 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 536 : OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException )
1442 : {
1443 536 : SolarMutexGuard aGuard;
1444 536 : String aString;
1445 536 : if(pBasePool)
1446 : {
1447 536 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
1448 536 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1449 536 : if(pBase)
1450 536 : aString = pBase->GetParent();
1451 : }
1452 0 : else if(bIsDescriptor)
1453 0 : aString = sParentStyleName;
1454 : else
1455 0 : throw uno::RuntimeException();
1456 536 : SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
1457 536 : return OUString ( aString );
1458 : }
1459 :
1460 2059 : void SwXStyle::setParentStyle(const OUString& rParentStyle)
1461 : throw( container::NoSuchElementException, uno::RuntimeException )
1462 : {
1463 2059 : SolarMutexGuard aGuard;
1464 2059 : String sParentStyle;
1465 2059 : SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
1466 2059 : if(pBasePool)
1467 : {
1468 1739 : pBasePool->SetSearchMask(eFamily);
1469 1739 : sal_Bool bExcept = sal_False;
1470 1739 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
1471 1739 : if(pBase)
1472 : {
1473 1739 : rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
1474 : //make it a 'real' style - necessary for pooled styles
1475 1739 : xBase->GetItemSet();
1476 1739 : if(xBase->GetParent() != sParentStyle)
1477 : {
1478 742 : bExcept = !xBase->SetParent(sParentStyle);
1479 1739 : }
1480 : }
1481 : else
1482 0 : bExcept = sal_True;
1483 1739 : if(bExcept)
1484 0 : throw uno::RuntimeException();
1485 : }
1486 320 : else if(bIsDescriptor)
1487 : {
1488 320 : sParentStyleName = String(sParentStyle);
1489 : try
1490 : {
1491 322 : uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
1492 318 : aAny >>= mxStyleData;
1493 : }
1494 2 : 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 2059 : }
1507 :
1508 3536 : static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, sal_Bool bIsConditional )
1509 : {
1510 3536 : uno::Reference< beans::XPropertySetInfo > xRet;
1511 3536 : switch( eFamily )
1512 : {
1513 : case SFX_STYLE_FAMILY_CHAR:
1514 : {
1515 688 : static uno::Reference< beans::XPropertySetInfo > xCharRef;
1516 688 : if(!xCharRef.is())
1517 : {
1518 11 : xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
1519 : }
1520 688 : xRet = xCharRef;
1521 : }
1522 688 : break;
1523 : case SFX_STYLE_FAMILY_PARA:
1524 : {
1525 2382 : static uno::Reference< beans::XPropertySetInfo > xCondParaRef;
1526 2382 : static uno::Reference< beans::XPropertySetInfo > xParaRef;
1527 2382 : if(!xParaRef.is())
1528 : {
1529 : xCondParaRef = aSwMapProvider.GetPropertySet(
1530 13 : PROPERTY_MAP_CONDITIONAL_PARA_STYLE)->getPropertySetInfo();
1531 : xParaRef = aSwMapProvider.GetPropertySet(
1532 13 : PROPERTY_MAP_PARA_STYLE)->getPropertySetInfo();
1533 : }
1534 2382 : xRet = bIsConditional ? xCondParaRef : xParaRef;
1535 : }
1536 2382 : break;
1537 : case SFX_STYLE_FAMILY_PAGE :
1538 : {
1539 329 : static uno::Reference< beans::XPropertySetInfo > xPageRef;
1540 329 : if(!xPageRef.is())
1541 : {
1542 13 : xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
1543 : }
1544 329 : xRet = xPageRef;
1545 : }
1546 329 : break;
1547 : case SFX_STYLE_FAMILY_FRAME :
1548 : {
1549 76 : static uno::Reference< beans::XPropertySetInfo > xFrameRef;
1550 76 : if(!xFrameRef.is())
1551 : {
1552 10 : xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
1553 : }
1554 76 : xRet = xFrameRef;
1555 : }
1556 76 : break;
1557 : case SFX_STYLE_FAMILY_PSEUDO:
1558 : {
1559 61 : static uno::Reference< beans::XPropertySetInfo > xNumRef;
1560 61 : if(!xNumRef.is())
1561 : {
1562 7 : xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
1563 : }
1564 61 : xRet = xNumRef;
1565 : }
1566 61 : break;
1567 :
1568 : default:
1569 : ;
1570 : }
1571 3536 : return xRet;
1572 : }
1573 :
1574 3536 : uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void)
1575 : throw( uno::RuntimeException )
1576 : {
1577 3536 : return lcl_getPropertySetInfo( eFamily, bIsConditional );
1578 : }
1579 :
1580 814 : void SwXStyle::ApplyDescriptorProperties()
1581 : {
1582 814 : bIsDescriptor = sal_False;
1583 814 : mxStyleData.clear();
1584 814 : mxStyleFamily.clear();
1585 :
1586 814 : const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
1587 814 : PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
1588 61720 : while(aIt != rPropertyVector.end())
1589 : {
1590 : uno::Any* pAny;
1591 60092 : pPropImpl->GetProperty(aIt->sName, pAny);
1592 60092 : if(pAny)
1593 2280 : setPropertyValue(aIt->sName, *pAny);
1594 60092 : ++aIt;
1595 : }
1596 814 : }
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 9581 : SwStyleBase_Impl(SwDoc& rSwDoc, const String& rName) :
1611 : rDoc(rSwDoc),
1612 : pOldPageDesc(0),
1613 : pItemSet(0),
1614 : rStyleName(rName),
1615 9581 : nPDescPos(0xffff)
1616 9581 : {}
1617 :
1618 9581 : ~SwStyleBase_Impl(){ delete pItemSet; }
1619 :
1620 6238 : sal_Bool HasItemSet() {return mxNewBase.is();}
1621 33044 : SfxItemSet& GetItemSet()
1622 : {
1623 : OSL_ENSURE(mxNewBase.is(), "no SwDocStyleSheet available");
1624 33044 : if(!pItemSet)
1625 5961 : pItemSet = new SfxItemSet(mxNewBase->GetItemSet());
1626 33044 : return *pItemSet;
1627 : }
1628 :
1629 : const SwPageDesc& GetOldPageDesc();
1630 : };
1631 :
1632 234 : const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
1633 : {
1634 234 : if(!pOldPageDesc)
1635 : {
1636 : sal_uInt16 i;
1637 234 : sal_uInt16 nPDescCount = rDoc.GetPageDescCnt();
1638 384 : for(i = 0; i < nPDescCount; i++)
1639 : {
1640 384 : const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1641 384 : if(rDesc.GetName() == rStyleName)
1642 : {
1643 234 : pOldPageDesc = & rDesc;
1644 234 : nPDescPos = i;
1645 234 : break;
1646 : }
1647 : }
1648 234 : 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 234 : return *pOldPageDesc;
1671 : }
1672 :
1673 23716 : 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 23716 : switch(rEntry.nWID)
1685 : {
1686 : case FN_UNO_HIDDEN:
1687 : {
1688 570 : sal_Bool bHidden = sal_False;
1689 570 : if ( rValue >>= bHidden )
1690 : {
1691 : //make it a 'real' style - necessary for pooled styles
1692 570 : rBase.mxNewBase->GetItemSet();
1693 570 : rBase.mxNewBase->SetHidden( bHidden );
1694 : }
1695 : }
1696 570 : 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 149 : if(rValue.getValueType() == ::getCppuType((uno::Reference< container::XIndexReplace>*)0) )
1733 : {
1734 : uno::Reference< container::XIndexReplace > * pxRulesRef =
1735 149 : (uno::Reference< container::XIndexReplace > *)rValue.getValue();
1736 :
1737 149 : uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
1738 :
1739 149 : SwXNumberingRules* pSwXRules = 0;
1740 149 : if(xNumberTunnel.is())
1741 : {
1742 : pSwXRules = reinterpret_cast< SwXNumberingRules * >(
1743 149 : sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
1744 : }
1745 149 : if(pSwXRules)
1746 : {
1747 149 : const String* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
1748 149 : const String* pBulletFontNames = pSwXRules->GetBulletFontNames();
1749 :
1750 149 : SwNumRule aSetRule(*pSwXRules->GetNumRule());
1751 149 : const SwCharFmts* pFmts = pDoc->GetCharFmts();
1752 149 : sal_uInt16 nChCount = pFmts->size();
1753 1639 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1754 : {
1755 :
1756 1490 : const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
1757 1490 : if(pFmt)
1758 : {
1759 664 : SwNumFmt aFmt(*pFmt);
1760 3368 : if(
1761 1992 : !SwXNumberingRules::isInvalidStyle(pCharStyleNames[i]) &&
1762 356 : ((pCharStyleNames[i].Len() && !pFmt->GetCharFmt()) ||
1763 356 : (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 664 : 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 664 : aSetRule.Set( i, &aFmt );
1809 : }
1810 : }
1811 149 : rBase.mxNewBase->SetNumRule(aSetRule);
1812 149 : }
1813 : }
1814 : else
1815 0 : throw lang::IllegalArgumentException();
1816 : }
1817 149 : break;
1818 : case RES_PARATR_OUTLINELEVEL:
1819 : {
1820 1306 : sal_Int16 nLevel = 0;
1821 1306 : rValue >>= nLevel;
1822 1306 : if( 0 <= nLevel && nLevel <= MAXLEVEL)
1823 1306 : rBase.mxNewBase->GetCollection()->SetAttrOutlineLevel( nLevel );
1824 : }
1825 1306 : break;
1826 : case FN_UNO_FOLLOW_STYLE:
1827 : {
1828 24 : OUString sTmp;
1829 24 : rValue >>= sTmp;
1830 24 : String aString;
1831 24 : SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true ) ;
1832 24 : rBase.mxNewBase->SetFollow( aString );
1833 : }
1834 24 : break;
1835 : case RES_PAGEDESC :
1836 32 : if( MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
1837 16 : goto put_itemset;
1838 : {
1839 : // Sonderbehandlung RES_PAGEDESC
1840 16 : if(rValue.getValueType() != ::getCppuType((const OUString*)0))
1841 0 : throw lang::IllegalArgumentException();
1842 16 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1843 :
1844 16 : SwFmtPageDesc* pNewDesc = 0;
1845 : const SfxPoolItem* pItem;
1846 16 : if(SFX_ITEM_SET == rStyleSet.GetItemState( RES_PAGEDESC, sal_True, &pItem ) )
1847 : {
1848 16 : pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
1849 : }
1850 16 : if(!pNewDesc)
1851 0 : pNewDesc = new SwFmtPageDesc();
1852 16 : OUString uDescName;
1853 16 : rValue >>= uDescName;
1854 16 : String sDescName;
1855 16 : SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
1856 16 : if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
1857 : {
1858 16 : sal_Bool bPut = sal_False;
1859 16 : 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 16 : if(!bPut)
1873 : {
1874 16 : rStyleSet.ClearItem(RES_BREAK);
1875 16 : rStyleSet.Put(SwFmtPageDesc());
1876 : }
1877 : else
1878 0 : rStyleSet.Put(*pNewDesc);
1879 : }
1880 16 : delete pNewDesc;
1881 : }
1882 16 : break;
1883 : case FN_UNO_IS_AUTO_UPDATE:
1884 : {
1885 364 : sal_Bool bAuto = *(sal_Bool*)rValue.getValue();
1886 364 : if(SFX_STYLE_FAMILY_PARA == eFamily)
1887 352 : rBase.mxNewBase->GetCollection()->SetAutoUpdateFmt(bAuto);
1888 12 : else if(SFX_STYLE_FAMILY_FRAME == eFamily)
1889 12 : rBase.mxNewBase->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
1890 : }
1891 364 : 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 8 : if(!rBase.mxNewBase->IsUserDefined())
1948 0 : throw lang::IllegalArgumentException();
1949 8 : short nSet = 0;
1950 8 : rValue >>= nSet;
1951 :
1952 : sal_uInt16 nId;
1953 8 : switch( nSet )
1954 : {
1955 : case style::ParagraphStyleCategory::TEXT:
1956 6 : nId = SWSTYLEBIT_TEXT;
1957 6 : 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 2 : nId = SWSTYLEBIT_EXTRA;
1969 2 : break;
1970 : case style::ParagraphStyleCategory::HTML:
1971 0 : nId = SWSTYLEBIT_HTML;
1972 0 : break;
1973 0 : default: throw lang::IllegalArgumentException();
1974 : }
1975 8 : rBase.mxNewBase->SetMask( nId|SFXSTYLEBIT_USERDEF );
1976 : }
1977 8 : 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 21279 : SfxItemSet& rStyleSet = rBase.GetItemSet();
2057 21279 : SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
2058 21279 : aSet.SetParent(&rStyleSet);
2059 21279 : rPropSet.setPropertyValue(rEntry, rValue, aSet);
2060 21279 : rStyleSet.Put(aSet);
2061 : // #i70223#
2062 21387 : if ( SFX_STYLE_FAMILY_PARA == eFamily &&
2063 : rEntry.nWID == RES_PARATR_NUMRULE &&
2064 72 : rBase.mxNewBase.is() && rBase.mxNewBase->GetCollection() &&
2065 36 : 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 21279 : }
2077 : }
2078 : }
2079 23716 : }
2080 :
2081 5424 : 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 5424 : if ( !m_pDoc )
2088 0 : throw uno::RuntimeException();
2089 5424 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2090 5424 : switch(eFamily)
2091 : {
2092 3412 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2093 36 : 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 170 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2096 : default:
2097 : ;
2098 : }
2099 5424 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2100 5424 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2101 :
2102 5424 : if(rPropertyNames.getLength() != rValues.getLength())
2103 0 : throw lang::IllegalArgumentException();
2104 :
2105 5424 : const OUString* pNames = rPropertyNames.getConstArray();
2106 5424 : const uno::Any* pValues = rValues.getConstArray();
2107 :
2108 5424 : SwStyleBase_Impl aBaseImpl(*m_pDoc, sStyleName);
2109 5424 : if(pBasePool)
2110 : {
2111 5020 : sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2112 5020 : pBasePool->SetSearchMask(eFamily);
2113 5020 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2114 5020 : pBasePool->SetSearchMask(eFamily, nSaveMask );
2115 : OSL_ENSURE(pBase, "where is the style?" );
2116 5020 : if(pBase)
2117 5020 : aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
2118 : else
2119 0 : throw uno::RuntimeException();
2120 : }
2121 :
2122 24974 : for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2123 : {
2124 19550 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]);
2125 :
2126 57946 : if(!pEntry ||
2127 38396 : (!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 19550 : 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 19550 : if(aBaseImpl.mxNewBase.is())
2132 : {
2133 17270 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
2134 34540 : pBasePool, m_pDoc, eFamily);
2135 : }
2136 2280 : else if(bIsDescriptor)
2137 : {
2138 2280 : if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
2139 0 : throw lang::IllegalArgumentException();
2140 : }
2141 : else
2142 0 : throw uno::RuntimeException();
2143 : }
2144 5424 : if(aBaseImpl.HasItemSet())
2145 5020 : aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
2146 5424 : }
2147 :
2148 1966 : 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 1966 : SolarMutexGuard aGuard;
2155 :
2156 : // workaround for bad designed API
2157 : try
2158 : {
2159 1966 : 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 1966 : }
2169 1966 : }
2170 :
2171 2631 : 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 2631 : uno::Any aRet;
2179 2631 : if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
2180 : {
2181 1168 : sal_Bool bPhys = pBase != 0;
2182 1168 : if(pBase)
2183 : {
2184 1168 : bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
2185 : // The standard character format is not existing physically
2186 1196 : if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
2187 14 : ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
2188 14 : ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
2189 4 : bPhys = sal_False;
2190 : }
2191 1168 : aRet.setValue(&bPhys, ::getBooleanCppuType());
2192 : }
2193 1463 : else if (FN_UNO_HIDDEN == rEntry.nWID)
2194 : {
2195 52 : sal_Bool bHidden = sal_False;
2196 52 : if(pBase)
2197 : {
2198 52 : rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
2199 52 : bHidden = xBase->IsHidden();
2200 : }
2201 52 : aRet.setValue(&bHidden, ::getBooleanCppuType());
2202 : }
2203 1411 : else if(pBase)
2204 : {
2205 1411 : if(!rBase.mxNewBase.is())
2206 851 : rBase.mxNewBase = new SwDocStyleSheet( *(SwDocStyleSheet*)pBase );
2207 1411 : 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 165 : const SwNumRule* pRule = rBase.mxNewBase->GetNumRule();
2230 : OSL_ENSURE(pRule, "Wo ist die NumRule?");
2231 165 : uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule, pDoc);
2232 165 : aRet.setValue(&xRules, ::getCppuType((uno::Reference<container::XIndexReplace>*)0));
2233 : }
2234 165 : break;
2235 : case RES_PARATR_OUTLINELEVEL:
2236 : {
2237 : OSL_ENSURE( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2238 8 : int nLevel = rBase.mxNewBase->GetCollection()->GetAttrOutlineLevel();
2239 8 : aRet <<= static_cast<sal_Int16>( nLevel );
2240 : }
2241 8 : break;
2242 : case FN_UNO_FOLLOW_STYLE:
2243 : {
2244 469 : String aString;
2245 469 : SwStyleNameMapper::FillProgName(rBase.mxNewBase->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
2246 469 : aRet <<= OUString( aString );
2247 : }
2248 469 : 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 34 : sal_Bool bAuto = sal_False;
2270 34 : if(SFX_STYLE_FAMILY_PARA == eFamily)
2271 34 : bAuto = rBase.mxNewBase->GetCollection()->IsAutoUpdateFmt();
2272 0 : else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2273 0 : bAuto = rBase.mxNewBase->GetFrmFmt()->IsAutoUpdateFmt();
2274 34 : aRet.setValue(&bAuto, ::getBooleanCppuType());
2275 : }
2276 34 : break;
2277 : case FN_UNO_DISPLAY_NAME:
2278 : {
2279 14 : OUString sName(rBase.mxNewBase->GetDisplayName());
2280 14 : aRet <<= sName;
2281 : }
2282 14 : 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 34 : sal_uInt16 nPoolId = rBase.mxNewBase->GetCollection()->GetPoolFmtId();
2316 34 : short nRet = -1;
2317 34 : switch ( COLL_GET_RANGE_BITS & nPoolId )
2318 : {
2319 : case COLL_TEXT_BITS:
2320 12 : nRet = style::ParagraphStyleCategory::TEXT;
2321 12 : break;
2322 : case COLL_DOC_BITS:
2323 0 : nRet = style::ParagraphStyleCategory::CHAPTER;
2324 0 : break;
2325 : case COLL_LISTS_BITS:
2326 4 : nRet = style::ParagraphStyleCategory::LIST;
2327 4 : break;
2328 : case COLL_REGISTER_BITS:
2329 4 : nRet = style::ParagraphStyleCategory::INDEX;
2330 4 : break;
2331 : case COLL_EXTRA_BITS:
2332 8 : nRet = style::ParagraphStyleCategory::EXTRA;
2333 8 : break;
2334 : case COLL_HTML_BITS:
2335 0 : nRet = style::ParagraphStyleCategory::HTML;
2336 0 : break;
2337 : }
2338 34 : aRet <<= nRet;
2339 : }
2340 34 : 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 687 : SfxItemSet& rSet = rBase.GetItemSet();
2358 687 : rPropSet.getPropertyValue(rEntry, rSet, aRet);
2359 : }
2360 : }
2361 : }
2362 : else
2363 0 : throw uno::RuntimeException();
2364 2631 : return aRet;
2365 : }
2366 :
2367 1758 : 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 1758 : if ( !m_pDoc )
2372 0 : throw uno::RuntimeException();
2373 1758 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2374 1758 : switch(eFamily)
2375 : {
2376 1332 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2377 46 : 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 210 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2380 : default:
2381 : ;
2382 : }
2383 1758 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2384 1758 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2385 :
2386 1758 : const OUString* pNames = rPropertyNames.getConstArray();
2387 1758 : uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
2388 1758 : uno::Any* pRet = aRet.getArray();
2389 1758 : SwStyleBase_Impl aBase(*m_pDoc, sStyleName);
2390 1758 : SfxStyleSheetBase* pBase = 0;
2391 3960 : for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2392 : {
2393 2202 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]);
2394 6494 : if(!pEntry ||
2395 4292 : (!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 2202 : if(pBasePool)
2398 : {
2399 2202 : if(!pBase)
2400 : {
2401 1758 : sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2402 1758 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
2403 1758 : pBase = pBasePool->Find(sStyleName);
2404 1758 : pBasePool->SetSearchMask(eFamily, nSaveMask );
2405 : }
2406 2202 : 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 : sal_Bool bExcept = sal_False;
2415 0 : switch( eFamily )
2416 : {
2417 : case SFX_STYLE_FAMILY_PSEUDO:
2418 0 : bExcept = sal_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 = sal_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 1758 : return aRet;
2460 : }
2461 :
2462 40 : uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
2463 : const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException)
2464 : {
2465 40 : SolarMutexGuard aGuard;
2466 40 : uno::Sequence< uno::Any > aValues;
2467 :
2468 : // workaround for bad designed API
2469 : try
2470 : {
2471 40 : 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 40 : 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 3458 : 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 3458 : SolarMutexGuard aGuard;
2513 3458 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2514 3458 : const uno::Sequence<uno::Any> aValues(&rValue, 1);
2515 3458 : SetPropertyValues_Impl( aProperties, aValues );
2516 3458 : }
2517 :
2518 1718 : uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName)
2519 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2520 : {
2521 1718 : SolarMutexGuard aGuard;
2522 1718 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2523 1718 : 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 122 : beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName)
2556 : throw( beans::UnknownPropertyException, uno::RuntimeException )
2557 : {
2558 122 : SolarMutexGuard aGuard;
2559 :
2560 122 : uno::Sequence< OUString > aNames(1);
2561 122 : OUString* pNames = aNames.getArray();
2562 122 : pNames[0] = rPropertyName;
2563 122 : uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
2564 122 : return aStates.getConstArray()[0];
2565 : }
2566 :
2567 174 : uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
2568 : const uno::Sequence< OUString >& rPropertyNames)
2569 : throw( beans::UnknownPropertyException, uno::RuntimeException )
2570 : {
2571 174 : SolarMutexGuard aGuard;
2572 174 : uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
2573 174 : beans::PropertyState* pStates = aRet.getArray();
2574 174 : if(pBasePool)
2575 : {
2576 174 : pBasePool->SetSearchMask(eFamily );
2577 174 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2578 : OSL_ENSURE(pBase, "where is the style?" );
2579 :
2580 174 : if(pBase)
2581 : {
2582 174 : const OUString* pNames = rPropertyNames.getConstArray();
2583 174 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2584 174 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2585 174 : switch(eFamily)
2586 : {
2587 156 : 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 8 : 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 174 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2595 174 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2596 :
2597 174 : SfxItemSet aSet = xStyle->GetItemSet();
2598 5658 : for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
2599 : {
2600 5484 : const String& rPropName = pNames[i];
2601 5484 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( rPropName);
2602 5484 : if(!pEntry)
2603 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
2604 5484 : 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 6716 : else if(SFX_STYLE_FAMILY_PAGE == eFamily &&
2610 696 : (rPropName.EqualsAscii("Header", 0, 6)
2611 536 : || rPropName.EqualsAscii("Footer", 0, 6)))
2612 : {
2613 320 : sal_uInt16 nResId = lcl_ConvertFNToRES(pEntry->nWID);
2614 320 : sal_Bool bFooter = rPropName.EqualsAscii("Footer", 0, 6);
2615 : const SvxSetItem* pSetItem;
2616 320 : if(SFX_ITEM_SET == aSet.GetItemState(
2617 : bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
2618 320 : sal_False, (const SfxPoolItem**)&pSetItem))
2619 : {
2620 160 : const SfxItemSet& rSet = pSetItem->GetItemSet();
2621 160 : SfxItemState eState = rSet.GetItemState(nResId, sal_False);
2622 160 : if(SFX_ITEM_SET == eState)
2623 40 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
2624 : else
2625 120 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2626 : }
2627 : else
2628 160 : pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2629 : }
2630 : else
2631 : {
2632 5164 : pStates[i] = pPropSet->getPropertyState(*pEntry, aSet);
2633 5180 : if( SFX_STYLE_FAMILY_PAGE == eFamily &&
2634 : SID_ATTR_PAGE_SIZE == pEntry->nWID &&
2635 16 : beans::PropertyState_DIRECT_VALUE == pStates[i] )
2636 : {
2637 : const SvxSizeItem& rSize =
2638 : static_cast < const SvxSizeItem& >(
2639 16 : aSet.Get(SID_ATTR_PAGE_SIZE) );
2640 16 : sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
2641 32 : if( ( LONG_MAX == rSize.GetSize().Width() &&
2642 : (MID_SIZE_WIDTH == nMemberId ||
2643 : MID_SIZE_SIZE == nMemberId ) ) ||
2644 16 : ( LONG_MAX == rSize.GetSize().Height() &&
2645 : MID_SIZE_HEIGHT == nMemberId ) )
2646 : {
2647 0 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2648 : }
2649 : }
2650 : }
2651 5658 : }
2652 : }
2653 : else
2654 0 : throw uno::RuntimeException();
2655 : }
2656 : else
2657 0 : throw uno::RuntimeException();
2658 348 : return aRet;
2659 : }
2660 :
2661 676 : void SwXStyle::setPropertyToDefault(const OUString& rPropertyName)
2662 : throw( beans::UnknownPropertyException, uno::RuntimeException )
2663 : {
2664 676 : const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2665 676 : setPropertiesToDefault ( aSequence );
2666 676 : }
2667 :
2668 676 : void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
2669 : throw (beans::UnknownPropertyException, uno::RuntimeException)
2670 : {
2671 676 : SolarMutexGuard aGuard;
2672 676 : SwFmt *pTargetFmt = 0;
2673 :
2674 676 : if(pBasePool)
2675 : {
2676 676 : pBasePool->SetSearchMask(eFamily);
2677 676 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2678 : OSL_ENSURE(pBase, "Where is the style?");
2679 :
2680 676 : if(pBase)
2681 : {
2682 676 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2683 676 : switch(eFamily)
2684 : {
2685 0 : case SFX_STYLE_FAMILY_CHAR: pTargetFmt = xStyle->GetCharFmt(); break;
2686 676 : 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 676 : }
2701 : }
2702 : }
2703 676 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2704 676 : switch(eFamily)
2705 : {
2706 676 : 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 676 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2714 676 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2715 :
2716 676 : const OUString* pNames = aPropertyNames.getConstArray();
2717 :
2718 676 : if ( pTargetFmt )
2719 : {
2720 1352 : for( sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++ )
2721 : {
2722 676 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
2723 676 : if( !pEntry )
2724 0 : throw beans::UnknownPropertyException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2725 676 : 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 676 : 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 676 : if( pEntry->nWID == RES_PARATR_OUTLINELEVEL )
2731 0 : static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
2732 : else
2733 676 : 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 676 : }
2741 676 : }
2742 :
2743 549 : void SAL_CALL SwXStyle::setAllPropertiesToDefault( )
2744 : throw (uno::RuntimeException)
2745 : {
2746 549 : SolarMutexGuard aGuard;
2747 549 : if(pBasePool)
2748 : {
2749 549 : pBasePool->SetSearchMask(eFamily);
2750 549 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
2751 : OSL_ENSURE(pBase, "where is the style, you fiend!?");
2752 :
2753 549 : if(pBase)
2754 : {
2755 549 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2756 :
2757 549 : SwFmt *pTargetFmt = 0;
2758 549 : sal_uInt16 nPgDscPos = USHRT_MAX;
2759 549 : switch( eFamily )
2760 : {
2761 : case SFX_STYLE_FAMILY_CHAR :
2762 110 : pTargetFmt = xStyle->GetCharFmt();
2763 110 : break;
2764 : case SFX_STYLE_FAMILY_PARA :
2765 : {
2766 352 : pTargetFmt = xStyle->GetCollection();
2767 352 : if ( xStyle->GetCollection() )
2768 352 : xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2769 : }
2770 352 : break;
2771 : case SFX_STYLE_FAMILY_FRAME:
2772 12 : pTargetFmt = xStyle->GetFrmFmt();
2773 12 : break;
2774 : case SFX_STYLE_FAMILY_PAGE:
2775 : {
2776 75 : SwPageDesc *pDesc = m_pDoc->FindPageDescByName( xStyle->GetPageDesc()->GetName(), &nPgDscPos );
2777 75 : if( pDesc )
2778 : {
2779 75 : pTargetFmt = &pDesc->GetMaster();
2780 75 : pDesc->SetUseOn ( nsUseOnPage::PD_ALL );
2781 : }
2782 : }
2783 75 : break;
2784 : case SFX_STYLE_FAMILY_PSEUDO:
2785 0 : break;
2786 :
2787 : default:
2788 : ;
2789 : }
2790 549 : if( pTargetFmt )
2791 : {
2792 549 : if( USHRT_MAX != nPgDscPos )
2793 : {
2794 75 : SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
2795 75 : rPageDesc.ResetAllMasterAttr();
2796 :
2797 75 : SvxLRSpaceItem aLR(RES_LR_SPACE);
2798 75 : sal_Int32 nSize = GetMetricVal ( CM_1) * 2;
2799 75 : aLR.SetLeft ( nSize );
2800 75 : aLR.SetLeft ( nSize );
2801 75 : SvxULSpaceItem aUL( RES_UL_SPACE );
2802 75 : aUL.SetUpper ( static_cast < sal_uInt16 > ( nSize ) );
2803 75 : aUL.SetLower ( static_cast < sal_uInt16 > ( nSize ) );
2804 75 : pTargetFmt->SetFmtAttr( aLR );
2805 75 : pTargetFmt->SetFmtAttr( aUL );
2806 :
2807 75 : SwPageDesc* pStdPgDsc = m_pDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
2808 75 : SwFmtFrmSize aFrmSz( ATT_FIX_SIZE );
2809 75 : if( RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId() )
2810 : {
2811 35 : if( m_pDoc->getPrinter( false ) )
2812 : {
2813 : const Size aPhysSize( SvxPaperInfo::GetPaperSize(
2814 2 : static_cast<Printer*>( m_pDoc->getPrinter( false ) )) );
2815 2 : aFrmSz.SetSize( aPhysSize );
2816 : }
2817 : else
2818 33 : aFrmSz.SetSize( SvxPaperInfo::GetDefaultPaperSize() );
2819 :
2820 : }
2821 : else
2822 : {
2823 40 : aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
2824 : }
2825 75 : if( pStdPgDsc->GetLandscape() )
2826 : {
2827 0 : SwTwips nTmp = aFrmSz.GetHeight();
2828 0 : aFrmSz.SetHeight( aFrmSz.GetWidth() );
2829 0 : aFrmSz.SetWidth( nTmp );
2830 : }
2831 75 : pTargetFmt->SetFmtAttr( aFrmSz );
2832 : }
2833 : else
2834 474 : pTargetFmt->ResetAllFmtAttr();
2835 :
2836 549 : if( USHRT_MAX != nPgDscPos )
2837 75 : m_pDoc->ChgPageDesc( nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos) );
2838 549 : }
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 549 : }
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 30852 : void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
2921 : {
2922 30852 : SfxSimpleHint *pHint = PTR_CAST( SfxSimpleHint, &rHint );
2923 30852 : if( pHint )
2924 : {
2925 1 : if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
2926 : {
2927 1 : pBasePool = 0;
2928 1 : 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 30852 : }
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 882 : SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
2956 : SwDocShell* pDocSh, SfxStyleFamily eFam,
2957 : const String& rStyleName):
2958 882 : SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName)
2959 : {
2960 :
2961 882 : }
2962 :
2963 50 : SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) :
2964 50 : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE)
2965 : {
2966 50 : }
2967 :
2968 1864 : SwXPageStyle::~SwXPageStyle()
2969 : {
2970 :
2971 1864 : }
2972 :
2973 424 : 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 424 : SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone();
2976 424 : SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
2977 424 : const SfxPoolItem* pItem = 0;
2978 424 : SfxPoolItem* pNewItem = 0;
2979 424 : rSetSet.GetItemState(nRes, sal_True, &pItem);
2980 424 : if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes))
2981 70 : pItem = &rSetSet.GetPool()->GetDefaultItem(nRes);
2982 424 : if(pItem)
2983 : {
2984 424 : 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 424 : pNewItem->PutValue(rVal, nMemberId);
3000 424 : rSetSet.Put(*pNewItem);
3001 424 : rBaseImpl.GetItemSet().Put(*pNewSetItem);
3002 424 : delete pNewItem;
3003 424 : delete pNewSetItem;
3004 424 : }
3005 :
3006 814 : 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 814 : if(!GetDoc())
3013 0 : throw uno::RuntimeException();
3014 :
3015 814 : if(rPropertyNames.getLength() != rValues.getLength())
3016 0 : throw lang::IllegalArgumentException();
3017 :
3018 814 : const OUString* pNames = rPropertyNames.getConstArray();
3019 814 : const uno::Any* pValues = rValues.getConstArray();
3020 814 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3021 814 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3022 814 : SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName());
3023 814 : if(GetBasePool())
3024 : {
3025 814 : sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3026 814 : GetBasePool()->SetSearchMask(GetFamily());
3027 814 : SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
3028 814 : GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3029 : OSL_ENSURE(pBase, "where is the style?" );
3030 814 : if(pBase)
3031 814 : aBaseImpl.mxNewBase = new SwDocStyleSheet(*(SwDocStyleSheet*)pBase);
3032 : else
3033 0 : throw uno::RuntimeException();
3034 : }
3035 :
3036 11288 : for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
3037 : {
3038 10474 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
3039 10474 : if (!pEntry)
3040 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3041 10474 : 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 10474 : if(GetBasePool())
3045 : {
3046 10474 : 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 3428 : sal_Bool bFooter = sal_False;
3073 3428 : sal_uInt16 nItemType = TYPE_BOOL;
3074 3428 : sal_uInt16 nRes = 0;
3075 3428 : switch(pEntry->nWID)
3076 : {
3077 44 : case FN_UNO_FOOTER_ON: bFooter = sal_True;
3078 : //kein break;
3079 94 : case FN_UNO_HEADER_ON: nRes = SID_ATTR_PAGE_ON;
3080 94 : break;
3081 0 : case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_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 = sal_True;
3086 : // kein break;
3087 48 : case FN_UNO_HEADER_BOX: nRes = RES_BOX; nItemType = TYPE_BOX;
3088 48 : break;
3089 28 : case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3090 : // kein break;
3091 56 : case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;nItemType = TYPE_LRSPACE;
3092 56 : break;
3093 0 : case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3094 : // kein break;
3095 6 : case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;nItemType = TYPE_SHADOW;
3096 6 : break;
3097 402 : case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3098 : // kein break;
3099 804 : case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;nItemType = TYPE_ULSPACE;
3100 804 : break;
3101 402 : case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3102 : // kein break;
3103 804 : case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3104 804 : break;
3105 8 : case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3106 : // kein break;
3107 16 : case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3108 16 : break;
3109 8 : case FN_UNO_FIRST_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED_FIRST;
3110 8 : break;
3111 402 : case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3112 : // kein break;
3113 804 : case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;nItemType = TYPE_SIZE;
3114 804 : break;
3115 394 : case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_True;
3116 : // kein break;
3117 788 : case FN_UNO_HEADER_EAT_SPACING: nRes = RES_HEADER_FOOTER_EAT_SPACING;nItemType = TYPE_SIZE;
3118 788 : break;
3119 : }
3120 : const SvxSetItem* pSetItem;
3121 6856 : if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
3122 : bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3123 6856 : sal_False, (const SfxPoolItem**)&pSetItem))
3124 : {
3125 424 : lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
3126 :
3127 424 : if (nRes == SID_ATTR_PAGE_SHARED_FIRST)
3128 : {
3129 : // Need to add this to the other as well
3130 16 : if (SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
3131 : bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
3132 16 : sal_False, (const SfxPoolItem**)&pSetItem))
3133 0 : lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
3134 : }
3135 : }
3136 3004 : else if(SID_ATTR_PAGE_ON == nRes )
3137 : {
3138 84 : sal_Bool bVal = *(sal_Bool*)pValues[nProp].getValue();
3139 84 : if(bVal)
3140 : {
3141 84 : 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 168 : 0 );
3150 84 : aTempSet.Put(SfxBoolItem(nRes, sal_True));
3151 84 : aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
3152 84 : aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
3153 84 : aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
3154 84 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, sal_True));
3155 84 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST, sal_True));
3156 84 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, sal_True));
3157 :
3158 : SvxSetItem aNewSetItem( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3159 84 : aTempSet);
3160 84 : aBaseImpl.GetItemSet().Put(aNewSetItem);
3161 : }
3162 : }
3163 : }
3164 3428 : break;
3165 : case FN_PARAM_FTN_INFO :
3166 : {
3167 600 : const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
3168 600 : SfxPoolItem* pNewFtnItem = rItem.Clone();
3169 600 : sal_Bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
3170 600 : aBaseImpl.GetItemSet().Put(*pNewFtnItem);
3171 600 : delete pNewFtnItem;
3172 600 : if(!bPut)
3173 0 : throw lang::IllegalArgumentException();
3174 : }
3175 600 : 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 6446 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl,
3188 12892 : 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 814 : if(aBaseImpl.HasItemSet())
3200 : {
3201 814 : ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
3202 814 : if (undoGuard.UndoWasEnabled())
3203 : {
3204 : // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
3205 2 : GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3206 : }
3207 814 : aBaseImpl.mxNewBase->SetItemSet(aBaseImpl.GetItemSet());
3208 814 : }
3209 814 : }
3210 :
3211 463 : 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 463 : SolarMutexGuard aGuard;
3217 :
3218 : // workaround for bad designed API
3219 : try
3220 : {
3221 463 : 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 463 : }
3231 463 : }
3232 :
3233 : static uno::Reference<text::XText>
3234 234 : lcl_makeHeaderFooter(
3235 : const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt)
3236 : {
3237 234 : if (!pFrmFmt) { return 0; }
3238 :
3239 234 : const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
3240 : const SfxPoolItem* pItem;
3241 234 : 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 116 : GetHeaderFmt()
3246 : : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))->
3247 350 : GetFooterFmt();
3248 234 : if (pHeadFootFmt)
3249 : {
3250 186 : return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader);
3251 : }
3252 : }
3253 48 : return 0;
3254 : }
3255 :
3256 1585 : 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 1585 : if(!GetDoc())
3261 0 : throw uno::RuntimeException();
3262 :
3263 1585 : sal_Int32 nLength = rPropertyNames.getLength();
3264 1585 : const OUString* pNames = rPropertyNames.getConstArray();
3265 1585 : uno::Sequence< uno::Any > aRet ( nLength );
3266 :
3267 1585 : uno::Any* pRet = aRet.getArray();
3268 1585 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3269 1585 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3270 1585 : SwStyleBase_Impl aBase(*GetDoc(), GetStyleName());
3271 1585 : SfxStyleSheetBase* pBase = 0;
3272 3390 : for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
3273 : {
3274 1805 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp] );
3275 1805 : if (!pEntry)
3276 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3277 :
3278 1805 : if(GetBasePool())
3279 : {
3280 1805 : if(!pBase)
3281 : {
3282 1585 : sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3283 1585 : GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
3284 1585 : pBase = GetBasePool()->Find(GetStyleName());
3285 1585 : GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3286 : }
3287 1805 : sal_uInt16 nRes = 0;
3288 1805 : bool bHeader = false;
3289 1805 : sal_Bool bLeft = sal_False;
3290 1805 : bool bFirst = false;
3291 1805 : 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 1078 : SfxStyleSheetBasePool* pBasePool2 = ((SwXPageStyle*)this)->GetBasePool();
3318 1078 : pBasePool2->SetSearchMask(GetFamily());
3319 1078 : SfxStyleSheetBase* pBase2 = pBasePool2->Find(GetStyleName());
3320 1078 : if(pBase2)
3321 : {
3322 1078 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3323 1078 : const SfxItemSet& rSet = xStyle->GetItemSet();
3324 1078 : sal_Bool bFooter = sal_False;
3325 1078 : switch(pEntry->nWID)
3326 : {
3327 : case FN_UNO_FOOTER_ON:
3328 478 : bFooter = sal_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 956 : sal_Bool bRet = sal_False;
3334 956 : pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
3335 956 : nRes = SID_ATTR_PAGE_ON;
3336 : }
3337 956 : break;
3338 0 : case FN_UNO_FOOTER_BACKGROUND: bFooter = sal_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 = sal_True;
3343 : // kein break;
3344 0 : case FN_UNO_HEADER_BOX: nRes = RES_BOX;
3345 0 : break;
3346 8 : case FN_UNO_FOOTER_LR_SPACE: bFooter = sal_True;
3347 : // kein break;
3348 16 : case FN_UNO_HEADER_LR_SPACE: nRes = RES_LR_SPACE;
3349 16 : break;
3350 0 : case FN_UNO_FOOTER_SHADOW: bFooter = sal_True;
3351 : // kein break;
3352 0 : case FN_UNO_HEADER_SHADOW: nRes = RES_SHADOW;
3353 0 : break;
3354 4 : case FN_UNO_FOOTER_BODY_DISTANCE: bFooter = sal_True;
3355 : // kein break;
3356 8 : case FN_UNO_HEADER_BODY_DISTANCE: nRes = RES_UL_SPACE;
3357 8 : break;
3358 4 : case FN_UNO_FOOTER_IS_DYNAMIC_DISTANCE: bFooter = sal_True;
3359 : // kein break;
3360 8 : case FN_UNO_HEADER_IS_DYNAMIC_DISTANCE: nRes = SID_ATTR_PAGE_DYNAMIC;
3361 8 : break;
3362 28 : case FN_UNO_FOOTER_SHARE_CONTENT: bFooter = sal_True;
3363 : // kein break;
3364 56 : case FN_UNO_HEADER_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED;
3365 56 : break;
3366 24 : case FN_UNO_FIRST_SHARE_CONTENT: nRes = SID_ATTR_PAGE_SHARED_FIRST;
3367 24 : break;
3368 4 : case FN_UNO_FOOTER_HEIGHT: bFooter = sal_True;
3369 : // kein break;
3370 10 : case FN_UNO_HEADER_HEIGHT: nRes = SID_ATTR_PAGE_SIZE;
3371 10 : break;
3372 0 : case FN_UNO_FOOTER_EAT_SPACING: bFooter = sal_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 1078 : if(SFX_ITEM_SET == rSet.GetItemState(
3379 : bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
3380 1078 : sal_False, (const SfxPoolItem**)&pSetItem))
3381 : {
3382 232 : const SfxItemSet& rTmpSet = pSetItem->GetItemSet();
3383 232 : const SfxPoolItem* pItem = 0;
3384 232 : rTmpSet.GetItemState(nRes, sal_True, &pItem);
3385 232 : if(!pItem && nRes != rTmpSet.GetPool()->GetSlotId(nRes))
3386 0 : pItem = &rTmpSet.GetPool()->GetDefaultItem(nRes);
3387 232 : if(pItem)
3388 232 : pItem->QueryValue(pRet[nProp], pEntry->nMemberId);
3389 1078 : }
3390 : }
3391 : }
3392 1078 : break;
3393 : case FN_UNO_HEADER :
3394 64 : goto Header;
3395 : case FN_UNO_HEADER_LEFT :
3396 28 : bLeft = sal_True; goto Header;
3397 : case FN_UNO_HEADER_FIRST :
3398 24 : bFirst = true; goto Header;
3399 : case FN_UNO_HEADER_RIGHT :
3400 0 : goto Header;
3401 : Header:
3402 116 : bHeader = true;
3403 116 : nRes = RES_HEADER; goto MakeObject;
3404 : case FN_UNO_FOOTER :
3405 64 : goto Footer;
3406 : case FN_UNO_FOOTER_LEFT :
3407 30 : bLeft = sal_True; goto Footer;
3408 : case FN_UNO_FOOTER_FIRST :
3409 24 : bFirst = sal_True; goto Footer;
3410 : case FN_UNO_FOOTER_RIGHT :
3411 : Footer:
3412 118 : nRes = RES_FOOTER;
3413 : MakeObject:
3414 : {
3415 234 : const SwPageDesc& rDesc = aBase.GetOldPageDesc();
3416 234 : const SwFrmFmt* pFrmFmt = 0;
3417 116 : sal_Bool bShare = (bHeader && rDesc.IsHeaderShared())||
3418 350 : (!bHeader && rDesc.IsFooterShared());
3419 234 : 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 234 : if( bLeft && !bShare )
3425 : {
3426 32 : pFrmFmt = &rDesc.GetLeft();
3427 : }
3428 202 : else if (bFirst && !bShareFirst)
3429 : {
3430 32 : pFrmFmt = &rDesc.GetFirst();
3431 : }
3432 : else
3433 : {
3434 170 : pFrmFmt = &rDesc.GetMaster();
3435 : }
3436 : const uno::Reference< text::XText > xRet =
3437 234 : lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt);
3438 234 : if (xRet.is())
3439 : {
3440 186 : pRet[nProp] <<= xRet;
3441 234 : }
3442 : }
3443 234 : break;
3444 : case FN_PARAM_FTN_INFO :
3445 : {
3446 64 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3447 64 : const SfxItemSet& rSet = xStyle->GetItemSet();
3448 64 : const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
3449 64 : rItem.QueryValue(pRet[nProp], pEntry->nMemberId);
3450 : }
3451 64 : break;
3452 : default:
3453 429 : 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 1585 : return aRet;
3469 : }
3470 :
3471 8 : uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
3472 : const uno::Sequence< OUString >& rPropertyNames )
3473 : throw(uno::RuntimeException)
3474 : {
3475 8 : SolarMutexGuard aGuard;
3476 8 : uno::Sequence< uno::Any > aValues;
3477 :
3478 : // workaround for bad designed API
3479 : try
3480 : {
3481 8 : 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 8 : return aValues;
3493 : }
3494 :
3495 1577 : uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw(
3496 : beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
3497 : {
3498 1577 : SolarMutexGuard aGuard;
3499 1577 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3500 1577 : return GetPropertyValues_Impl(aProperties).getConstArray()[0];
3501 : }
3502 :
3503 351 : 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 351 : SolarMutexGuard aGuard;
3511 351 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3512 351 : const uno::Sequence<uno::Any> aValues(&rValue, 1);
3513 351 : SetPropertyValues_Impl( aProperties, aValues );
3514 351 : }
3515 :
3516 0 : SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
3517 0 : : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, sal_False)
3518 : {
3519 0 : }
3520 :
3521 860 : SwXFrameStyle::~SwXFrameStyle()
3522 : {
3523 860 : }
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 508 : uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
3535 : {
3536 508 : uno::Any aRet;
3537 508 : if(rType == ::getCppuType((uno::Reference<XEventsSupplier>*)0))
3538 0 : aRet <<= uno::Reference<XEventsSupplier>(this);
3539 : else
3540 508 : aRet = SwXStyle::queryInterface(rType);
3541 508 : 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 27 : SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
3550 27 : SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
3551 : {
3552 27 : }
3553 :
3554 22 : SwXAutoStyles::~SwXAutoStyles()
3555 : {
3556 22 : }
3557 :
3558 0 : sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException )
3559 : {
3560 0 : return AUTOSTYLE_FAMILY_COUNT;
3561 : }
3562 :
3563 50 : uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
3564 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
3565 : uno::RuntimeException )
3566 : {
3567 50 : SolarMutexGuard aGuard;
3568 50 : uno::Any aRet;
3569 50 : if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
3570 0 : throw lang::IndexOutOfBoundsException();
3571 50 : if(IsValid())
3572 : {
3573 50 : uno::Reference< style::XAutoStyleFamily > aRef;
3574 50 : IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
3575 50 : switch( nType )
3576 : {
3577 : case IStyleAccess::AUTO_STYLE_CHAR:
3578 : {
3579 15 : if(!xAutoCharStyles.is())
3580 15 : xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
3581 15 : aRef = xAutoCharStyles;
3582 : }
3583 15 : break;
3584 : case IStyleAccess::AUTO_STYLE_RUBY:
3585 : {
3586 4 : if(!xAutoRubyStyles.is())
3587 4 : xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
3588 4 : aRef = xAutoRubyStyles;
3589 : }
3590 4 : break;
3591 : case IStyleAccess::AUTO_STYLE_PARA:
3592 : {
3593 31 : if(!xAutoParaStyles.is())
3594 27 : xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
3595 31 : aRef = xAutoParaStyles;
3596 : }
3597 31 : break;
3598 :
3599 : default:
3600 : ;
3601 : }
3602 50 : aRet.setValue(&aRef, ::getCppuType((const uno::Reference<style::XAutoStyleFamily>*)0));
3603 : }
3604 : else
3605 0 : throw uno::RuntimeException();
3606 100 : 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 50 : uno::Any SwXAutoStyles::getByName(const rtl::OUString& Name)
3620 : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
3621 : {
3622 50 : uno::Any aRet;
3623 50 : if(Name.compareToAscii("CharacterStyles") == 0 )
3624 15 : aRet = getByIndex(0);
3625 35 : else if(Name.compareToAscii("RubyStyles") == 0 )
3626 4 : aRet = getByIndex(1);
3627 31 : else if(Name.compareToAscii("ParagraphStyles") == 0 )
3628 31 : aRet = getByIndex(2);
3629 : else
3630 0 : throw container::NoSuchElementException();
3631 50 : 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 38 : sal_Bool SwXAutoStyles::hasByName(const rtl::OUString& Name)
3646 : throw( uno::RuntimeException )
3647 : {
3648 92 : if( Name.compareToAscii("CharacterStyles") == 0 ||
3649 27 : Name.compareToAscii("RubyStyles") == 0 ||
3650 27 : Name.compareToAscii("ParagraphStyles") == 0 )
3651 38 : return sal_True;
3652 : else
3653 0 : return sal_False;
3654 : }
3655 :
3656 46 : SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
3657 46 : pDocShell( pDocSh ), eFamily(nFamily)
3658 : {
3659 : // Register ourselves as a listener to the document (via the page descriptor)
3660 46 : pDocSh->GetDoc()->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
3661 46 : }
3662 :
3663 48 : SwXAutoStyleFamily::~SwXAutoStyleFamily()
3664 : {
3665 48 : }
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 56 : uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
3675 : const uno::Sequence< beans::PropertyValue >& Values )
3676 : throw (uno::RuntimeException)
3677 : {
3678 56 : if( !pDocShell )
3679 0 : throw uno::RuntimeException();
3680 56 : const sal_uInt16* pRange = 0;
3681 56 : const SfxItemPropertySet* pPropSet = 0;
3682 56 : switch( eFamily )
3683 : {
3684 : case IStyleAccess::AUTO_STYLE_CHAR:
3685 : {
3686 11 : pRange = aCharAutoFmtSetRange;
3687 11 : pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
3688 : }
3689 11 : 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 45 : pRange = aTxtNodeSetRange;
3699 45 : pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
3700 : }
3701 45 : break;
3702 :
3703 : default:
3704 : ;
3705 : }
3706 56 : SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
3707 56 : const beans::PropertyValue* pSeq = Values.getConstArray();
3708 56 : sal_Int32 nLen = Values.getLength();
3709 254 : for( sal_Int32 i = 0; i < nLen; ++i )
3710 : {
3711 : try
3712 : {
3713 198 : 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 56 : SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
3726 56 : uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
3727 56 : return xRet;
3728 : }
3729 :
3730 12 : uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( )
3731 : throw (uno::RuntimeException)
3732 : {
3733 12 : if( !pDocShell )
3734 0 : throw uno::RuntimeException();
3735 : return uno::Reference< container::XEnumeration >
3736 12 : (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 12 : SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
3750 12 : : pDoc( pInitDoc ), eFamily( eFam )
3751 : {
3752 : // special case for ruby auto styles:
3753 12 : if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
3754 : {
3755 4 : std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap;
3756 4 : SwAttrPool& rAttrPool = pDoc->GetAttrPool();
3757 4 : sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY );
3758 :
3759 4 : 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 4 : }
3774 : }
3775 : else
3776 : {
3777 8 : pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
3778 : }
3779 :
3780 12 : aIter = mAutoStyles.begin();
3781 12 : }
3782 :
3783 12 : SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
3784 12 : : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
3785 : {
3786 : // Register ourselves as a listener to the document (via the page descriptor)
3787 12 : pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
3788 12 : }
3789 :
3790 36 : SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
3791 : {
3792 12 : delete pImpl;
3793 24 : }
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 18 : ::sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
3806 : throw (uno::RuntimeException)
3807 : {
3808 18 : if( !pImpl )
3809 0 : throw uno::RuntimeException();
3810 18 : return pImpl->hasMoreElements();
3811 : }
3812 :
3813 6 : uno::Any SwXAutoStylesEnumerator::nextElement( )
3814 : throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
3815 : {
3816 6 : if( !pImpl )
3817 0 : throw uno::RuntimeException();
3818 6 : uno::Any aRet;
3819 6 : if( pImpl->hasMoreElements() )
3820 : {
3821 6 : SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
3822 6 : uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
3823 6 : pNextSet, pImpl->getFamily());
3824 6 : aRet.setValue(&xAutoStyle, ::getCppuType((uno::Reference<style::XAutoStyle>*)0));
3825 : }
3826 6 : return aRet;
3827 : }
3828 :
3829 62 : SwXAutoStyle::SwXAutoStyle( SwDoc* pDoc, SfxItemSet_Pointer_t pInitSet, IStyleAccess::SwAutoStyleFamily eFam )
3830 62 : : pSet( pInitSet ), eFamily( eFam )
3831 : {
3832 : // Register ourselves as a listener to the document (via the page descriptor)
3833 62 : pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
3834 62 : }
3835 :
3836 124 : SwXAutoStyle::~SwXAutoStyle()
3837 : {
3838 124 : }
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 12 : uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( )
3848 : throw (uno::RuntimeException)
3849 : {
3850 12 : uno::Reference< beans::XPropertySetInfo > xRet;
3851 12 : 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 12 : static uno::Reference< beans::XPropertySetInfo > xParaRef;
3877 12 : if(!xParaRef.is())
3878 : {
3879 2 : sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
3880 2 : xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
3881 : }
3882 12 : xRet = xParaRef;
3883 : }
3884 12 : break;
3885 :
3886 : default:
3887 : ;
3888 : }
3889 :
3890 12 : 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 12 : uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName )
3903 : throw( beans::UnknownPropertyException,
3904 : lang::WrappedTargetException,
3905 : uno::RuntimeException )
3906 : {
3907 12 : SolarMutexGuard aGuard;
3908 12 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3909 12 : 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 74 : uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
3953 : const uno::Sequence< OUString > & rPropertyNames )
3954 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3955 : {
3956 74 : if( !pSet.get() )
3957 0 : throw uno::RuntimeException();
3958 : // query_item
3959 :
3960 74 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
3961 74 : switch(eFamily)
3962 : {
3963 11 : 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 63 : case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
3966 : default:
3967 : ;
3968 : }
3969 :
3970 74 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3971 74 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3972 74 : const OUString* pNames = rPropertyNames.getConstArray();
3973 :
3974 74 : sal_Int32 nLen = rPropertyNames.getLength();
3975 74 : uno::Sequence< uno::Any > aRet( nLen );
3976 74 : uno::Any* pValues = aRet.getArray();
3977 :
3978 74 : SfxItemSet& rSet = *pSet.get();
3979 :
3980 152 : for( sal_Int32 i = 0; i < nLen; ++i )
3981 : {
3982 78 : const String& rPropName = pNames[i];
3983 78 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName);
3984 78 : if(!pEntry)
3985 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3986 78 : else if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
3987 : {
3988 56 : OUString sName(StylePool::nameOf( pSet ));
3989 56 : pValues[i] <<= sName;
3990 : }
3991 : else
3992 22 : pPropSet->getPropertyValue( *pEntry, rSet, pValues[i] );
3993 78 : }
3994 74 : return aRet;
3995 : }
3996 :
3997 62 : uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
3998 : const uno::Sequence< ::rtl::OUString >& rPropertyNames )
3999 : throw (uno::RuntimeException)
4000 : {
4001 62 : SolarMutexGuard aGuard;
4002 62 : uno::Sequence< uno::Any > aValues;
4003 :
4004 : // workaround for bad designed API
4005 : try
4006 : {
4007 62 : 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 62 : 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 6 : uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
4070 : const uno::Sequence< ::rtl::OUString >& rPropertyNames )
4071 : throw (beans::UnknownPropertyException, uno::RuntimeException)
4072 : {
4073 6 : if( !pSet.get() )
4074 0 : throw uno::RuntimeException();
4075 6 : SolarMutexGuard aGuard;
4076 6 : uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4077 6 : beans::PropertyState* pStates = aRet.getArray();
4078 6 : const OUString* pNames = rPropertyNames.getConstArray();
4079 :
4080 6 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4081 6 : 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 6 : case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4086 : default:
4087 : ;
4088 : }
4089 :
4090 6 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4091 6 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
4092 6 : SfxItemSet& rSet = *pSet.get();
4093 660 : for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4094 : {
4095 654 : const String& rPropName = pNames[i];
4096 654 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName);
4097 654 : if(!pEntry)
4098 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
4099 654 : pStates[i] = pPropSet->getPropertyState(*pEntry, rSet );
4100 654 : }
4101 6 : 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 72 : }
4181 :
4182 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|