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