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 : #include <svx/svxids.hrc>
21 : #include <hintids.hxx>
22 : #include <osl/mutex.hxx>
23 : #include <vcl/svapp.hxx>
24 : #include <svl/smplhint.hxx>
25 : #include <svtools/ctrltool.hxx>
26 : #include <svl/style.hxx>
27 : #include <svl/itemiter.hxx>
28 : #include <svx/pageitem.hxx>
29 : #include <editeng/sizeitem.hxx>
30 : #include <editeng/ulspitem.hxx>
31 : #include <editeng/lrspitem.hxx>
32 : #include <editeng/boxitem.hxx>
33 : #include <editeng/shaditem.hxx>
34 : #include <editeng/brushitem.hxx>
35 : #include <editeng/flstitem.hxx>
36 : #include <editeng/paperinf.hxx>
37 : #include <pagedesc.hxx>
38 : #include <doc.hxx>
39 : #include <IDocumentUndoRedo.hxx>
40 : #include <IDocumentDeviceAccess.hxx>
41 : #include <IDocumentStylePoolAccess.hxx>
42 : #include <docary.hxx>
43 : #include <charfmt.hxx>
44 : #include <cmdid.h>
45 : #include <unostyle.hxx>
46 : #include <unosett.hxx>
47 : #include <docsh.hxx>
48 : #include <swstyle.h>
49 : #include <paratr.hxx>
50 : #include <unoprnms.hxx>
51 : #include <shellio.hxx>
52 : #include <docstyle.hxx>
53 : #include <unotextbodyhf.hxx>
54 : #include <fmthdft.hxx>
55 : #include <fmtpdsc.hxx>
56 : #include <poolfmt.hrc>
57 : #include <poolfmt.hxx>
58 : #include "unoevent.hxx"
59 : #include <fmtruby.hxx>
60 : #include <SwStyleNameMapper.hxx>
61 : #include <sfx2/printer.hxx>
62 : #include <com/sun/star/style/ParagraphStyleCategory.hpp>
63 : #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
64 : #include <com/sun/star/beans/PropertyAttribute.hpp>
65 : #include <com/sun/star/beans/NamedValue.hpp>
66 : #include <com/sun/star/drawing/BitmapMode.hpp>
67 : #include <istyleaccess.hxx>
68 : #include <GetMetricVal.hxx>
69 : #include <fmtfsize.hxx>
70 : #include <numrule.hxx>
71 :
72 : #include <comphelper/servicehelper.hxx>
73 : #include <cppuhelper/supportsservice.hxx>
74 : #include <comphelper/sequenceasvector.hxx>
75 :
76 : //UUUU
77 : #include <svx/unobrushitemhelper.hxx>
78 : #include <editeng/unoipset.hxx>
79 : #include <editeng/memberids.hrc>
80 : #include <svx/unoshape.hxx>
81 : #include <svx/xflbstit.hxx>
82 : #include <svx/xflbmtit.hxx>
83 : #include <swunohelper.hxx>
84 : #include <svx/xbtmpit.hxx>
85 :
86 : #include <boost/shared_ptr.hpp>
87 :
88 : #include "ccoll.hxx"
89 : #include "unocore.hrc"
90 :
91 : #include <cassert>
92 : #include <set>
93 :
94 : #define STYLE_FAMILY_COUNT 5 // we have 5 style families
95 :
96 : const sal_uInt16 aStyleByIndex[] =
97 : {
98 : SFX_STYLE_FAMILY_CHAR,
99 : SFX_STYLE_FAMILY_PARA,
100 : SFX_STYLE_FAMILY_PAGE,
101 : SFX_STYLE_FAMILY_FRAME,
102 : SFX_STYLE_FAMILY_PSEUDO
103 : };
104 :
105 : // Already implemented autostyle families: 3
106 : #define AUTOSTYLE_FAMILY_COUNT 3
107 : const IStyleAccess::SwAutoStyleFamily aAutoStyleByIndex[] =
108 : {
109 : IStyleAccess::AUTO_STYLE_CHAR,
110 : IStyleAccess::AUTO_STYLE_RUBY,
111 : IStyleAccess::AUTO_STYLE_PARA
112 : };
113 :
114 : using namespace ::com::sun::star;
115 :
116 490756 : static SwGetPoolIdFromName lcl_GetSwEnumFromSfxEnum ( SfxStyleFamily eFamily )
117 : {
118 490756 : switch ( eFamily )
119 : {
120 : case SFX_STYLE_FAMILY_CHAR:
121 154414 : return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
122 : case SFX_STYLE_FAMILY_PARA:
123 208194 : return nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL;
124 : case SFX_STYLE_FAMILY_FRAME:
125 6564 : return nsSwGetPoolIdFromName::GET_POOLID_FRMFMT;
126 : case SFX_STYLE_FAMILY_PAGE:
127 20888 : return nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC;
128 : case SFX_STYLE_FAMILY_PSEUDO:
129 100696 : return nsSwGetPoolIdFromName::GET_POOLID_NUMRULE;
130 : default:
131 : OSL_ENSURE(false, "someone asking for all styles in unostyle.cxx!" );
132 0 : return nsSwGetPoolIdFromName::GET_POOLID_CHRFMT;
133 : }
134 : }
135 :
136 184 : class SwAutoStylesEnumImpl
137 : {
138 : std::vector<SfxItemSet_Pointer_t> mAutoStyles;
139 : std::vector<SfxItemSet_Pointer_t>::iterator aIter;
140 : SwDoc* pDoc;
141 : IStyleAccess::SwAutoStyleFamily eFamily;
142 : public:
143 : SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam );
144 312 : bool hasMoreElements() { return aIter != mAutoStyles.end(); }
145 66 : SfxItemSet_Pointer_t nextElement() { return *(aIter++); }
146 66 : IStyleAccess::SwAutoStyleFamily getFamily() const { return eFamily; }
147 66 : SwDoc* getDoc() const { return pDoc; }
148 : };
149 :
150 0 : OUString SwXStyleFamilies::getImplementationName(void) throw( uno::RuntimeException, std::exception )
151 : {
152 0 : return OUString("SwXStyleFamilies");
153 : }
154 :
155 0 : sal_Bool SwXStyleFamilies::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
156 : {
157 0 : return cppu::supportsService(this, rServiceName);
158 : }
159 :
160 0 : uno::Sequence< OUString > SwXStyleFamilies::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
161 : {
162 0 : uno::Sequence< OUString > aRet(1);
163 0 : OUString* pArray = aRet.getArray();
164 0 : pArray[0] = "com.sun.star.style.StyleFamilies";
165 0 : return aRet;
166 : }
167 :
168 4636 : SwXStyleFamilies::SwXStyleFamilies(SwDocShell& rDocShell) :
169 : SwUnoCollection(rDocShell.GetDoc()),
170 : pDocShell(&rDocShell),
171 : pxCharStyles(0),
172 : pxParaStyles(0),
173 : pxFrameStyles(0),
174 : pxPageStyles(0),
175 4636 : pxNumberingStyles(0)
176 : {
177 :
178 4636 : }
179 :
180 13902 : SwXStyleFamilies::~SwXStyleFamilies()
181 : {
182 4634 : delete pxCharStyles;
183 4634 : delete pxParaStyles;
184 4634 : delete pxFrameStyles;
185 4634 : delete pxPageStyles;
186 4634 : delete pxNumberingStyles;
187 9268 : }
188 :
189 81918 : uno::Any SAL_CALL SwXStyleFamilies::getByName(const OUString& Name)
190 : throw(
191 : container::NoSuchElementException,
192 : lang::WrappedTargetException,
193 : uno::RuntimeException, std::exception )
194 : {
195 81918 : SolarMutexGuard aGuard;
196 : // the index comes from const unsigned short aStyleByIndex[] = ...
197 81918 : uno::Any aRet;
198 81918 : if(!IsValid())
199 0 : throw uno::RuntimeException();
200 81918 : if(Name=="CharacterStyles" )
201 34362 : aRet = getByIndex(0);
202 47556 : else if(Name=="ParagraphStyles" )
203 23208 : aRet = getByIndex(1);
204 24348 : else if(Name=="FrameStyles" )
205 4494 : aRet = getByIndex(3);
206 19854 : else if(Name=="PageStyles" )
207 5904 : aRet = getByIndex(2);
208 13950 : else if(Name=="NumberingStyles" )
209 13882 : aRet = getByIndex(4);
210 : else
211 68 : throw container::NoSuchElementException();
212 81918 : return aRet;
213 : }
214 :
215 2 : uno::Sequence< OUString > SwXStyleFamilies::getElementNames(void) throw( uno::RuntimeException, std::exception )
216 : {
217 2 : uno::Sequence< OUString > aNames(STYLE_FAMILY_COUNT);
218 2 : OUString* pNames = aNames.getArray();
219 2 : pNames[0] = "CharacterStyles";
220 2 : pNames[1] = "ParagraphStyles";
221 2 : pNames[2] = "FrameStyles";
222 2 : pNames[3] = "PageStyles";
223 2 : pNames[4] = "NumberingStyles";
224 2 : return aNames;
225 : }
226 :
227 8038 : sal_Bool SwXStyleFamilies::hasByName(const OUString& Name) throw( uno::RuntimeException, std::exception )
228 : {
229 22458 : if( Name=="CharacterStyles" ||
230 10930 : Name=="ParagraphStyles" ||
231 7678 : Name=="FrameStyles" ||
232 12648 : Name=="PageStyles" ||
233 1480 : Name=="NumberingStyles" )
234 7976 : return sal_True;
235 : else
236 62 : return sal_False;
237 : }
238 :
239 2 : sal_Int32 SwXStyleFamilies::getCount(void) throw( uno::RuntimeException, std::exception )
240 : {
241 2 : return STYLE_FAMILY_COUNT;
242 : }
243 :
244 81870 : uno::Any SwXStyleFamilies::getByIndex(sal_Int32 nIndex)
245 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
246 : {
247 81870 : SolarMutexGuard aGuard;
248 81870 : uno::Any aRet;
249 81870 : if(nIndex < 0 || nIndex >= STYLE_FAMILY_COUNT)
250 2 : throw lang::IndexOutOfBoundsException();
251 81868 : if(IsValid())
252 : {
253 81868 : uno::Reference< container::XNameContainer > aRef;
254 81868 : const sal_uInt16 nType = aStyleByIndex[nIndex];
255 81868 : switch( nType )
256 : {
257 : case SFX_STYLE_FAMILY_CHAR:
258 : {
259 34374 : if(!pxCharStyles)
260 : {
261 3456 : ((SwXStyleFamilies*)this)->pxCharStyles = new uno::Reference< container::XNameContainer > ();
262 3456 : *pxCharStyles = new SwXStyleFamily(pDocShell, nType);
263 : }
264 34374 : aRef = *pxCharStyles;
265 : }
266 34374 : break;
267 : case SFX_STYLE_FAMILY_PARA:
268 : {
269 23208 : if(!pxParaStyles)
270 : {
271 4154 : ((SwXStyleFamilies*)this)->pxParaStyles = new uno::Reference< container::XNameContainer > ();
272 4154 : *pxParaStyles = new SwXStyleFamily(pDocShell, nType);
273 : }
274 23208 : aRef = *pxParaStyles;
275 : }
276 23208 : break;
277 : case SFX_STYLE_FAMILY_PAGE :
278 : {
279 5908 : if(!pxPageStyles)
280 : {
281 3912 : ((SwXStyleFamilies*)this)->pxPageStyles = new uno::Reference< container::XNameContainer > ();
282 3912 : *pxPageStyles = new SwXStyleFamily(pDocShell, nType);
283 : }
284 5908 : aRef = *pxPageStyles;
285 : }
286 5908 : break;
287 : case SFX_STYLE_FAMILY_FRAME :
288 : {
289 4494 : if(!pxFrameStyles)
290 : {
291 1720 : ((SwXStyleFamilies*)this)->pxFrameStyles = new uno::Reference< container::XNameContainer > ();
292 1720 : *pxFrameStyles = new SwXStyleFamily(pDocShell, nType);
293 : }
294 4494 : aRef = *pxFrameStyles;
295 : }
296 4494 : break;
297 : case SFX_STYLE_FAMILY_PSEUDO:
298 : {
299 13884 : if(!pxNumberingStyles)
300 : {
301 3456 : ((SwXStyleFamilies*)this)->pxNumberingStyles = new uno::Reference< container::XNameContainer > ();
302 3456 : *pxNumberingStyles = new SwXStyleFamily(pDocShell, nType);
303 : }
304 13884 : aRef = *pxNumberingStyles;
305 : }
306 13884 : break;
307 : }
308 81868 : aRet.setValue(&aRef, cppu::UnoType<container::XNameContainer>::get());
309 : }
310 : else
311 0 : throw uno::RuntimeException();
312 81870 : return aRet;
313 : }
314 :
315 2 : uno::Type SwXStyleFamilies::getElementType(void)
316 : throw( uno::RuntimeException, std::exception )
317 : {
318 2 : return cppu::UnoType<container::XNameContainer>::get();
319 :
320 : }
321 :
322 2 : sal_Bool SwXStyleFamilies::hasElements(void) throw( uno::RuntimeException, std::exception )
323 : {
324 2 : return sal_True;
325 : }
326 :
327 0 : void SwXStyleFamilies::loadStylesFromURL(const OUString& rURL,
328 : const uno::Sequence< beans::PropertyValue >& aOptions)
329 : throw (io::IOException, uno::RuntimeException,
330 : std::exception)
331 : {
332 0 : SolarMutexGuard aGuard;
333 0 : bool bLoadStyleText = true;
334 0 : bool bLoadStylePage = true;
335 0 : bool bLoadStyleOverwrite = true;
336 0 : bool bLoadStyleNumbering = true;
337 0 : bool bLoadStyleFrame = true;
338 0 : if(IsValid() && !rURL.isEmpty())
339 : {
340 : const uno::Any* pVal;
341 0 : int nCount = aOptions.getLength();
342 0 : const beans::PropertyValue* pArray = aOptions.getConstArray();
343 0 : for(int i = 0; i < nCount; i++)
344 0 : if( ( pVal = &pArray[i].Value)->getValueType() ==
345 0 : ::getBooleanCppuType() )
346 : {
347 0 : const OUString sName = pArray[i].Name;
348 0 : bool bVal = *(sal_Bool*)pVal->getValue();
349 0 : if( sName == UNO_NAME_OVERWRITE_STYLES )
350 0 : bLoadStyleOverwrite = bVal;
351 0 : else if( sName == UNO_NAME_LOAD_NUMBERING_STYLES )
352 0 : bLoadStyleNumbering = bVal;
353 0 : else if( sName == UNO_NAME_LOAD_PAGE_STYLES )
354 0 : bLoadStylePage = bVal;
355 0 : else if( sName == UNO_NAME_LOAD_FRAME_STYLES )
356 0 : bLoadStyleFrame = bVal;
357 0 : else if( sName == UNO_NAME_LOAD_TEXT_STYLES )
358 0 : bLoadStyleText = bVal;
359 : }
360 :
361 0 : SwgReaderOption aOpt;
362 0 : aOpt.SetFrmFmts( bLoadStyleFrame );
363 0 : aOpt.SetTxtFmts( bLoadStyleText );
364 0 : aOpt.SetPageDescs( bLoadStylePage );
365 0 : aOpt.SetNumRules( bLoadStyleNumbering );
366 0 : aOpt.SetMerge( !bLoadStyleOverwrite );
367 :
368 0 : sal_uLong nErr = pDocShell->LoadStylesFromFile( rURL, aOpt, true );
369 0 : if( nErr )
370 0 : throw io::IOException();
371 : }
372 : else
373 0 : throw uno::RuntimeException();
374 0 : }
375 :
376 0 : uno::Sequence< beans::PropertyValue > SwXStyleFamilies::getStyleLoaderOptions(void)
377 : throw( uno::RuntimeException, std::exception )
378 : {
379 0 : SolarMutexGuard aGuard;
380 0 : uno::Sequence< beans::PropertyValue > aSeq(5);
381 0 : beans::PropertyValue* pArray = aSeq.getArray();
382 0 : uno::Any aVal;
383 0 : sal_Bool bTemp = sal_True;
384 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
385 0 : pArray[0] = beans::PropertyValue(UNO_NAME_LOAD_TEXT_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
386 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
387 0 : pArray[1] = beans::PropertyValue(UNO_NAME_LOAD_FRAME_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
388 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
389 0 : pArray[2] = beans::PropertyValue(UNO_NAME_LOAD_PAGE_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
390 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
391 0 : pArray[3] = beans::PropertyValue(UNO_NAME_LOAD_NUMBERING_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
392 0 : aVal.setValue(&bTemp, ::getCppuBooleanType());
393 0 : pArray[4] = beans::PropertyValue(UNO_NAME_OVERWRITE_STYLES, -1, aVal, beans::PropertyState_DIRECT_VALUE);
394 0 : return aSeq;
395 : }
396 :
397 0 : OUString SwXStyleFamily::getImplementationName(void) throw( uno::RuntimeException, std::exception )
398 : {
399 0 : return OUString("SwXStyleFamily");
400 : }
401 :
402 0 : sal_Bool SwXStyleFamily::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
403 : {
404 0 : return cppu::supportsService(this, rServiceName);
405 : }
406 :
407 0 : uno::Sequence< OUString > SwXStyleFamily::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
408 : {
409 0 : uno::Sequence< OUString > aRet(1);
410 0 : OUString* pArray = aRet.getArray();
411 0 : pArray[0] = "com.sun.star.style.StyleFamily";
412 0 : return aRet;
413 : }
414 :
415 16698 : SwXStyleFamily::SwXStyleFamily(SwDocShell* pDocSh, sal_uInt16 nFamily) :
416 : eFamily((SfxStyleFamily)nFamily),
417 16698 : pBasePool(pDocSh->GetStyleSheetPool()),
418 33396 : pDocShell(pDocSh)
419 : {
420 16698 : StartListening(*pBasePool);
421 16698 : }
422 :
423 33376 : SwXStyleFamily::~SwXStyleFamily()
424 : {
425 :
426 33376 : }
427 :
428 50962 : static bool lcl_GetHeaderFooterItem(
429 : SfxItemSet const& rSet, OUString const& rPropName, bool const bFooter,
430 : SvxSetItem const*& o_rpItem)
431 : {
432 : SfxItemState eState = rSet.GetItemState(
433 : (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
434 50962 : false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
435 90792 : if (SfxItemState::SET != eState &&
436 39830 : rPropName == UNO_NAME_FIRST_IS_SHARED)
437 : { // fdo#79269 header may not exist, check footer then
438 : eState = rSet.GetItemState(
439 24 : (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
440 24 : false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
441 : }
442 50962 : return SfxItemState::SET == eState;
443 : }
444 :
445 180 : static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
446 : SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX)
447 : {
448 180 : sal_Int32 nCount = 0;
449 180 : switch( eFamily )
450 : {
451 : case SFX_STYLE_FAMILY_CHAR:
452 : {
453 : sal_uInt16 nBaseCount = RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
454 6 : RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN;
455 6 : nIndex = nIndex - nBaseCount;
456 6 : const size_t nArrLen = rDoc.GetCharFmts()->size();
457 16 : for( size_t i = 0; i < nArrLen; ++i )
458 : {
459 12 : SwCharFmt* pFmt = (*rDoc.GetCharFmts())[ i ];
460 12 : if( pFmt->IsDefault() && pFmt != rDoc.GetDfltCharFmt() )
461 0 : continue;
462 12 : if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
463 : {
464 12 : if ( nIndex == nCount )
465 : {
466 : // the default character format needs to be set to "Default!"
467 2 : if(rDoc.GetDfltCharFmt() == pFmt)
468 : SwStyleNameMapper::FillUIName(
469 0 : RES_POOLCOLL_STANDARD, *pString );
470 : else
471 2 : *pString = pFmt->GetName();
472 2 : break;
473 : }
474 10 : nCount++;
475 : }
476 : }
477 6 : nCount += nBaseCount;
478 : }
479 6 : break;
480 : case SFX_STYLE_FAMILY_PARA:
481 : {
482 : sal_uInt16 nBaseCount = RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
483 : RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
484 : RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
485 : RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
486 : RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
487 0 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN;
488 0 : nIndex = nIndex - nBaseCount;
489 0 : const size_t nArrLen = rDoc.GetTxtFmtColls()->size();
490 0 : for ( size_t i = 0; i < nArrLen; ++i )
491 : {
492 0 : SwTxtFmtColl * pColl = (*rDoc.GetTxtFmtColls())[i];
493 0 : if ( pColl->IsDefault() )
494 0 : continue;
495 0 : if ( IsPoolUserFmt ( pColl->GetPoolFmtId() ) )
496 : {
497 0 : if ( nIndex == nCount )
498 : {
499 0 : *pString = pColl->GetName();
500 0 : break;
501 : }
502 0 : nCount++;
503 : }
504 : }
505 0 : nCount += nBaseCount;
506 : }
507 0 : break;
508 : case SFX_STYLE_FAMILY_FRAME:
509 : {
510 0 : sal_uInt16 nBaseCount = RES_POOLFRM_END - RES_POOLFRM_BEGIN;
511 0 : nIndex = nIndex - nBaseCount;
512 0 : const size_t nArrLen = rDoc.GetFrmFmts()->size();
513 0 : for( size_t i = 0; i < nArrLen; ++i )
514 : {
515 0 : SwFrmFmt* pFmt = (*rDoc.GetFrmFmts())[ i ];
516 0 : if(pFmt->IsDefault() || pFmt->IsAuto())
517 0 : continue;
518 0 : if ( IsPoolUserFmt ( pFmt->GetPoolFmtId() ) )
519 : {
520 0 : if ( nIndex == nCount )
521 : {
522 0 : *pString = pFmt->GetName();
523 0 : break;
524 : }
525 0 : nCount++;
526 : }
527 : }
528 0 : nCount += nBaseCount;
529 : }
530 0 : break;
531 : case SFX_STYLE_FAMILY_PAGE:
532 : {
533 30 : sal_uInt16 nBaseCount = RES_POOLPAGE_END - RES_POOLPAGE_BEGIN;
534 30 : nIndex = nIndex - nBaseCount;
535 30 : const sal_uInt16 nArrLen = rDoc.GetPageDescCnt();
536 384 : for(sal_uInt16 i = 0; i < nArrLen; ++i)
537 : {
538 358 : const SwPageDesc& rDesc = rDoc.GetPageDesc(i);
539 :
540 358 : if ( IsPoolUserFmt ( rDesc.GetPoolFmtId() ) )
541 : {
542 58 : if ( nIndex == nCount )
543 : {
544 4 : *pString = rDesc.GetName();
545 4 : break;
546 : }
547 54 : nCount++;
548 : }
549 : }
550 30 : nCount += nBaseCount;
551 : }
552 30 : break;
553 : case SFX_STYLE_FAMILY_PSEUDO:
554 : {
555 144 : sal_uInt16 nBaseCount = RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN;
556 144 : nIndex = nIndex - nBaseCount;
557 144 : const SwNumRuleTbl& rNumTbl = rDoc.GetNumRuleTbl();
558 1056 : for(size_t i = 0; i < rNumTbl.size(); ++i)
559 : {
560 996 : const SwNumRule& rRule = *rNumTbl[ i ];
561 996 : if( rRule.IsAutoRule() )
562 144 : continue;
563 852 : if ( IsPoolUserFmt ( rRule.GetPoolFmtId() ) )
564 : {
565 852 : if ( nIndex == nCount )
566 : {
567 84 : *pString = rRule.GetName();
568 84 : break;
569 : }
570 768 : nCount++;
571 : }
572 : }
573 144 : nCount += nBaseCount;
574 : }
575 144 : break;
576 :
577 : default:
578 : ;
579 : }
580 180 : return nCount;
581 : }
582 :
583 88 : sal_Int32 SwXStyleFamily::getCount(void) throw( uno::RuntimeException, std::exception )
584 : {
585 88 : SolarMutexGuard aGuard;
586 88 : return lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, NULL );
587 : }
588 :
589 736 : uno::Any SwXStyleFamily::getByIndex(sal_Int32 nTempIndex)
590 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
591 : {
592 736 : SolarMutexGuard aGuard;
593 736 : uno::Any aRet;
594 736 : if ( nTempIndex >= 0 && nTempIndex < USHRT_MAX )
595 : {
596 736 : sal_uInt16 nIndex = static_cast < sal_uInt16 > ( nTempIndex );
597 736 : if(pBasePool)
598 : {
599 736 : OUString sStyleName;
600 736 : switch( eFamily )
601 : {
602 : case SFX_STYLE_FAMILY_CHAR:
603 : {
604 16 : if ( nIndex < ( RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
605 12 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCHR_NORMAL_BEGIN + nIndex), sStyleName );
606 4 : else if ( nIndex < ( RES_POOLCHR_HTML_END - RES_POOLCHR_HTML_BEGIN +
607 : RES_POOLCHR_NORMAL_END - RES_POOLCHR_NORMAL_BEGIN ) )
608 : SwStyleNameMapper::FillUIName ( RES_POOLCHR_HTML_BEGIN
609 : - RES_POOLCHR_NORMAL_END + RES_POOLCHR_NORMAL_BEGIN
610 0 : + nIndex, sStyleName );
611 : }
612 16 : break;
613 : case SFX_STYLE_FAMILY_PARA:
614 : {
615 6 : if ( nIndex < ( RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
616 6 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_TEXT_BEGIN + nIndex), sStyleName );
617 0 : else if ( nIndex < ( RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
618 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
619 : SwStyleNameMapper::FillUIName ( RES_POOLCOLL_LISTS_BEGIN
620 : - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
621 0 : + nIndex, sStyleName );
622 0 : else if ( nIndex < ( RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
623 : RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
624 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
625 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_EXTRA_BEGIN
626 : - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
627 : - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
628 0 : + nIndex), sStyleName );
629 0 : else if ( nIndex < ( RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
630 : RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
631 : RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
632 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
633 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_REGISTER_BEGIN
634 : - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
635 : - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
636 : - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
637 0 : + nIndex), sStyleName );
638 0 : else if ( nIndex < ( RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
639 : RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
640 : RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
641 : RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
642 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
643 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_DOC_BEGIN
644 : - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
645 : - 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 0 : + nIndex), sStyleName );
649 0 : else if ( nIndex < ( RES_POOLCOLL_HTML_END - RES_POOLCOLL_HTML_BEGIN +
650 : RES_POOLCOLL_DOC_END - RES_POOLCOLL_DOC_BEGIN +
651 : RES_POOLCOLL_REGISTER_END - RES_POOLCOLL_REGISTER_BEGIN +
652 : RES_POOLCOLL_EXTRA_END - RES_POOLCOLL_EXTRA_BEGIN +
653 : RES_POOLCOLL_LISTS_END - RES_POOLCOLL_LISTS_BEGIN +
654 : RES_POOLCOLL_TEXT_END - RES_POOLCOLL_TEXT_BEGIN ) )
655 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLCOLL_HTML_BEGIN
656 : - RES_POOLCOLL_DOC_END + RES_POOLCOLL_DOC_BEGIN
657 : - RES_POOLCOLL_REGISTER_END + RES_POOLCOLL_REGISTER_BEGIN
658 : - RES_POOLCOLL_EXTRA_END + RES_POOLCOLL_EXTRA_BEGIN
659 : - RES_POOLCOLL_LISTS_END + RES_POOLCOLL_LISTS_BEGIN
660 : - RES_POOLCOLL_TEXT_END + RES_POOLCOLL_TEXT_BEGIN
661 0 : + nIndex), sStyleName );
662 : }
663 6 : break;
664 : case SFX_STYLE_FAMILY_FRAME:
665 : {
666 0 : if ( nIndex < ( RES_POOLFRM_END - RES_POOLFRM_BEGIN ) )
667 : {
668 0 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLFRM_BEGIN + nIndex), sStyleName );
669 : }
670 : }
671 0 : break;
672 : case SFX_STYLE_FAMILY_PAGE:
673 : {
674 28 : if ( nIndex < ( RES_POOLPAGE_END - RES_POOLPAGE_BEGIN ) )
675 : {
676 24 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + nIndex), sStyleName );
677 : }
678 : }
679 28 : break;
680 : case SFX_STYLE_FAMILY_PSEUDO:
681 : {
682 686 : if ( nIndex < ( RES_POOLNUMRULE_END - RES_POOLNUMRULE_BEGIN ) )
683 : {
684 602 : SwStyleNameMapper::FillUIName ( static_cast< sal_uInt16 >(RES_POOLNUMRULE_BEGIN + nIndex), sStyleName );
685 : }
686 : }
687 686 : break;
688 :
689 : default:
690 : ;
691 : }
692 736 : if (sStyleName.isEmpty())
693 92 : lcl_GetCountOrName ( *pDocShell->GetDoc(), eFamily, &sStyleName, nIndex );
694 :
695 736 : if (!sStyleName.isEmpty())
696 : {
697 734 : SfxStyleSheetBase* pBase = pBasePool->Find( sStyleName, eFamily );
698 734 : if(pBase)
699 : {
700 734 : uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
701 734 : if(!xStyle.is())
702 : {
703 2872 : xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
704 28 : new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
705 704 : eFamily == SFX_STYLE_FAMILY_FRAME ?
706 0 : new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
707 2140 : new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
708 : }
709 734 : aRet.setValue(&xStyle, cppu::UnoType<style::XStyle>::get());
710 : }
711 : else
712 0 : throw uno::RuntimeException();
713 : }
714 : else
715 2 : throw lang::IndexOutOfBoundsException();
716 : }
717 : else
718 0 : throw uno::RuntimeException();
719 : }
720 : else
721 0 : throw lang::IndexOutOfBoundsException();
722 :
723 736 : return aRet;
724 : }
725 :
726 141482 : uno::Any SwXStyleFamily::getByName(const OUString& rName)
727 : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
728 : {
729 141482 : SolarMutexGuard aGuard;
730 141482 : uno::Any aRet;
731 282964 : OUString sStyleName;
732 141482 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
733 141482 : if(pBasePool)
734 : {
735 141482 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
736 141482 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
737 141482 : if(pBase)
738 : {
739 136570 : uno::Reference< style::XStyle > xStyle = _FindStyle(sStyleName);
740 136570 : if(!xStyle.is())
741 : {
742 339154 : xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ?
743 9162 : new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) :
744 79290 : eFamily == SFX_STYLE_FAMILY_FRAME ?
745 11010 : new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()):
746 239692 : new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);
747 : }
748 136570 : aRet.setValue(&xStyle, cppu::UnoType<style::XStyle>::get());
749 : }
750 : else
751 4912 : throw container::NoSuchElementException();
752 : }
753 : else
754 0 : throw uno::RuntimeException();
755 278052 : return aRet;
756 :
757 : }
758 :
759 2086 : uno::Sequence< OUString > SwXStyleFamily::getElementNames(void) throw( uno::RuntimeException, std::exception )
760 : {
761 2086 : SolarMutexGuard aGuard;
762 4172 : comphelper::SequenceAsVector< OUString > aRet;
763 2086 : if(pBasePool)
764 : {
765 2086 : SfxStyleSheetIteratorPtr pIt = pBasePool->CreateIterator(eFamily, SFXSTYLEBIT_ALL);
766 4172 : OUString aString;
767 91232 : for (SfxStyleSheetBase* pStyle = pIt->First(); pStyle; pStyle = pIt->Next())
768 : {
769 89146 : SwStyleNameMapper::FillProgName(pStyle->GetName(), aString,
770 178292 : lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
771 89146 : aRet.push_back(aString);
772 2086 : }
773 : }
774 : else
775 0 : throw uno::RuntimeException();
776 :
777 4172 : return aRet.getAsConstList();
778 : }
779 :
780 98998 : sal_Bool SwXStyleFamily::hasByName(const OUString& rName) throw( uno::RuntimeException, std::exception )
781 : {
782 98998 : SolarMutexGuard aGuard;
783 98998 : bool bRet = false;
784 98998 : if(pBasePool)
785 : {
786 98998 : OUString sStyleName;
787 98998 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
788 98998 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
789 98998 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
790 98998 : bRet = 0 != pBase;
791 : }
792 : else
793 0 : throw uno::RuntimeException();
794 98998 : return bRet;
795 :
796 : }
797 :
798 2 : uno::Type SwXStyleFamily::getElementType(void) throw( uno::RuntimeException, std::exception )
799 : {
800 2 : return cppu::UnoType<style::XStyle>::get();
801 :
802 : }
803 :
804 2 : sal_Bool SwXStyleFamily::hasElements(void) throw( uno::RuntimeException, std::exception )
805 : {
806 2 : if(!pBasePool)
807 0 : throw uno::RuntimeException();
808 2 : return sal_True;
809 : }
810 :
811 74092 : void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
812 : throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
813 : {
814 74092 : SolarMutexGuard aGuard;
815 74092 : if(pBasePool)
816 : {
817 74092 : OUString sStyleName;
818 74092 : SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
819 74092 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
820 74092 : SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName);
821 74092 : SfxStyleSheetBase* pUINameBase = pBasePool->Find( sStyleName );
822 74092 : if(pBase || pUINameBase)
823 174 : throw container::ElementExistException();
824 : else
825 : {
826 73918 : if(rElement.getValueType().getTypeClass() ==
827 : uno::TypeClass_INTERFACE)
828 : {
829 : uno::Reference< uno::XInterface > * pxRef =
830 73918 : (uno::Reference< uno::XInterface > *)rElement.getValue();
831 :
832 73918 : uno::Reference<lang::XUnoTunnel> xStyleTunnel( *pxRef, uno::UNO_QUERY);
833 :
834 73918 : SwXStyle* pNewStyle = 0;
835 73918 : if(xStyleTunnel.is())
836 : {
837 : pNewStyle = reinterpret_cast< SwXStyle * >(
838 73916 : sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
839 : }
840 :
841 73918 : if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != eFamily)
842 2 : throw lang::IllegalArgumentException();
843 :
844 73916 : sal_uInt16 nMask = SFXSTYLEBIT_ALL;
845 73916 : if(eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional())
846 17486 : nMask &= ~SWSTYLEBIT_CONDCOLL;
847 : #if OSL_DEBUG_LEVEL > 1
848 : SfxStyleSheetBase& rNewBase =
849 : #endif
850 73916 : pBasePool->Make(sStyleName, eFamily, nMask);
851 73916 : pNewStyle->SetDoc(pDocShell->GetDoc(), pBasePool);
852 73916 : pNewStyle->SetStyleName(sStyleName);
853 147832 : const OUString sParentStyleName(pNewStyle->GetParentStyleName());
854 73916 : if (!sParentStyleName.isEmpty())
855 : {
856 26814 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
857 26814 : SfxStyleSheetBase* pParentBase = pBasePool->Find(sParentStyleName);
858 53492 : if(pParentBase && pParentBase->GetFamily() == eFamily &&
859 26678 : &pParentBase->GetPool() == pBasePool)
860 26678 : pBasePool->SetParent( eFamily, sStyleName, sParentStyleName );
861 :
862 : }
863 : #if OSL_DEBUG_LEVEL > 1
864 : (void)rNewBase;
865 : #endif
866 : // after all, we still need to apply the properties of the descriptor
867 147834 : pNewStyle->ApplyDescriptorProperties();
868 : }
869 : else
870 0 : throw lang::IllegalArgumentException();
871 74092 : }
872 : }
873 : else
874 0 : throw uno::RuntimeException();
875 73916 : }
876 :
877 0 : void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement)
878 : throw( lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
879 : {
880 0 : SolarMutexGuard aGuard;
881 0 : if(pBasePool)
882 : {
883 0 : pBasePool->SetSearchMask(eFamily);
884 0 : SfxStyleSheetBase* pBase = pBasePool->Find(rName);
885 : // replacements only for userdefined styles
886 0 : if(!pBase)
887 0 : throw container::NoSuchElementException();
888 0 : if(!pBase->IsUserDefined())
889 0 : throw lang::IllegalArgumentException();
890 : //if theres an object available to this style then it must be invalidated
891 0 : uno::Reference< style::XStyle > xStyle = _FindStyle(pBase->GetName());
892 0 : if(xStyle.is())
893 : {
894 0 : uno::Reference<lang::XUnoTunnel> xTunnel( xStyle, uno::UNO_QUERY);
895 0 : if(xTunnel.is())
896 : {
897 : SwXStyle* pStyle = reinterpret_cast< SwXStyle * >(
898 0 : sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething( SwXStyle::getUnoTunnelId()) ));
899 0 : pStyle->Invalidate();
900 0 : }
901 : }
902 :
903 0 : pBasePool->Remove(pBase);
904 0 : insertByName(rName, rElement);
905 : }
906 : else
907 0 : throw uno::RuntimeException();
908 0 : }
909 :
910 4 : void SwXStyleFamily::removeByName(const OUString& rName) throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
911 : {
912 4 : SolarMutexGuard aGuard;
913 4 : if(pBasePool)
914 : {
915 4 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
916 4 : OUString aString;
917 4 : SwStyleNameMapper::FillUIName(rName, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
918 :
919 4 : SfxStyleSheetBase* pBase = pBasePool->Find( aString );
920 4 : if(pBase)
921 2 : pBasePool->Remove(pBase);
922 : else
923 2 : throw container::NoSuchElementException();
924 : }
925 : else
926 0 : throw uno::RuntimeException();
927 2 : }
928 :
929 0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXStyleFamily::getPropertySetInfo( ) throw (uno::RuntimeException, std::exception)
930 : {
931 0 : return uno::Reference< beans::XPropertySetInfo >();
932 : }
933 :
934 0 : void SAL_CALL SwXStyleFamily::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
935 : {
936 : OSL_FAIL( "###unexpected!" );
937 0 : }
938 :
939 0 : uno::Any SAL_CALL SwXStyleFamily::getPropertyValue( const OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
940 : {
941 0 : uno::Any aRet;
942 :
943 0 : if ( sPropertyName == "DisplayName" )
944 : {
945 0 : SolarMutexGuard aGuard;
946 0 : sal_uInt32 nResId = 0;
947 0 : switch ( eFamily )
948 : {
949 : case SFX_STYLE_FAMILY_CHAR:
950 0 : nResId = STR_STYLE_FAMILY_CHARACTER; break;
951 : case SFX_STYLE_FAMILY_PARA:
952 0 : nResId = STR_STYLE_FAMILY_PARAGRAPH; break;
953 : case SFX_STYLE_FAMILY_FRAME:
954 0 : nResId = STR_STYLE_FAMILY_FRAME; break;
955 : case SFX_STYLE_FAMILY_PAGE:
956 0 : nResId = STR_STYLE_FAMILY_PAGE; break;
957 : case SFX_STYLE_FAMILY_PSEUDO:
958 0 : nResId = STR_STYLE_FAMILY_NUMBERING; break;
959 : default:
960 : OSL_FAIL( "SwXStyleFamily::getPropertyValue(): invalid family" );
961 : }
962 0 : if ( nResId > 0 )
963 : {
964 0 : aRet = uno::makeAny( SW_RESSTR( nResId ) );
965 0 : }
966 : }
967 : else
968 : {
969 0 : throw beans::UnknownPropertyException( "unknown property: " + sPropertyName, static_cast<OWeakObject *>(this) );
970 : }
971 :
972 0 : return aRet;
973 : }
974 :
975 0 : void SAL_CALL SwXStyleFamily::addPropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
976 : {
977 : OSL_FAIL( "###unexpected!" );
978 0 : }
979 :
980 0 : void SAL_CALL SwXStyleFamily::removePropertyChangeListener( const OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
981 : {
982 : OSL_FAIL( "###unexpected!" );
983 0 : }
984 :
985 0 : void SAL_CALL SwXStyleFamily::addVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
986 : {
987 : OSL_FAIL( "###unexpected!" );
988 0 : }
989 :
990 0 : void SAL_CALL SwXStyleFamily::removeVetoableChangeListener( const OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
991 : {
992 : OSL_FAIL( "###unexpected!" );
993 0 : }
994 :
995 410844 : void SwXStyleFamily::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
996 : {
997 410844 : const SfxSimpleHint *pHint = dynamic_cast<const SfxSimpleHint*>( &rHint );
998 410844 : if( pHint && ( pHint->GetId() & SFX_HINT_DYING ) )
999 : {
1000 60 : pBasePool = 0;
1001 60 : pDocShell = 0;
1002 60 : EndListening(rBC);
1003 : }
1004 410844 : }
1005 :
1006 137304 : SwXStyle* SwXStyleFamily::_FindStyle(const OUString& rStyleName)const
1007 : {
1008 137304 : const size_t nLCount = pBasePool->GetSizeOfVector();
1009 1003453 : for( size_t i = 0; i < nLCount; ++i)
1010 : {
1011 914269 : SfxListener* pListener = pBasePool->GetListener( i );
1012 914269 : SwXStyle* pTempStyle = dynamic_cast<SwXStyle*>( pListener );
1013 914269 : if(pTempStyle && pTempStyle->GetFamily() == eFamily && pTempStyle->GetStyleName() == rStyleName)
1014 : {
1015 48120 : return pTempStyle;
1016 : }
1017 : }
1018 89184 : return 0;
1019 : }
1020 :
1021 : class SwStyleProperties_Impl
1022 : {
1023 : const PropertyEntryVector_t aPropertyEntries;
1024 : uno::Any** pAnyArr;
1025 : sal_uInt32 nArrLen;
1026 :
1027 : public:
1028 : SwStyleProperties_Impl(const SfxItemPropertyMap& rMap);
1029 : ~SwStyleProperties_Impl();
1030 :
1031 : bool SetProperty(const OUString& rName, uno::Any aVal);
1032 : bool GetProperty(const OUString& rName, uno::Any*& rpAny);
1033 : bool ClearProperty( const OUString& rPropertyName );
1034 : void ClearAllProperties( );
1035 : void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny );
1036 :
1037 73916 : const PropertyEntryVector_t& GetPropertyVector() const {return aPropertyEntries; }
1038 :
1039 : };
1040 :
1041 74092 : SwStyleProperties_Impl::SwStyleProperties_Impl(const SfxItemPropertyMap& rMap) :
1042 : aPropertyEntries( rMap.getPropertyEntries() ),
1043 74092 : nArrLen(0)
1044 : {
1045 74092 : nArrLen = aPropertyEntries.size();
1046 :
1047 74092 : pAnyArr = new uno::Any* [nArrLen];
1048 4863966 : for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1049 4789874 : pAnyArr[i] = 0;
1050 74092 : }
1051 :
1052 148184 : SwStyleProperties_Impl::~SwStyleProperties_Impl()
1053 : {
1054 4863966 : for ( sal_uInt32 i =0 ; i < nArrLen; i++ )
1055 4789874 : delete pAnyArr[i];
1056 74092 : delete[] pAnyArr;
1057 74092 : }
1058 :
1059 208486 : bool SwStyleProperties_Impl::SetProperty(const OUString& rName, uno::Any aVal)
1060 : {
1061 208486 : sal_uInt16 nPos = 0;
1062 208486 : bool bRet = false;
1063 208486 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1064 16569490 : while( aIt != aPropertyEntries.end() )
1065 : {
1066 16361004 : if(rName == aIt->sName)
1067 : {
1068 208486 : delete pAnyArr[nPos];
1069 208486 : pAnyArr[nPos] = new uno::Any ( aVal );
1070 208486 : bRet = true;
1071 208486 : break;
1072 : }
1073 16152518 : ++nPos;
1074 16152518 : ++aIt;
1075 : }
1076 208486 : return bRet;
1077 : }
1078 :
1079 0 : bool SwStyleProperties_Impl::ClearProperty( const OUString& rName )
1080 : {
1081 0 : bool bRet = false;
1082 0 : sal_uInt32 nPos = 0;
1083 0 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1084 0 : while( aIt != aPropertyEntries.end() )
1085 : {
1086 0 : if( rName == aIt->sName )
1087 : {
1088 0 : delete pAnyArr[nPos];
1089 0 : pAnyArr[ nPos ] = 0;
1090 0 : bRet = true;
1091 0 : break;
1092 : }
1093 0 : ++nPos;
1094 0 : ++aIt;
1095 : }
1096 0 : return bRet;
1097 : }
1098 :
1099 0 : void SwStyleProperties_Impl::ClearAllProperties( )
1100 : {
1101 0 : for ( sal_uInt32 i = 0; i < nArrLen; i++ )
1102 : {
1103 0 : delete pAnyArr[i];
1104 0 : pAnyArr[ i ] = 0;
1105 : }
1106 0 : }
1107 :
1108 4788690 : bool SwStyleProperties_Impl::GetProperty(const OUString& rName, uno::Any*& rpAny )
1109 : {
1110 4788690 : bool bRet = false;
1111 4788690 : sal_uInt32 nPos = 0;
1112 4788690 : PropertyEntryVector_t::const_iterator aIt = aPropertyEntries.begin();
1113 325314856 : while( aIt != aPropertyEntries.end() )
1114 : {
1115 320526166 : if( rName == aIt->sName )
1116 : {
1117 4788690 : rpAny = pAnyArr[nPos];
1118 4788690 : bRet = true;
1119 4788690 : break;
1120 : }
1121 315737476 : ++nPos;
1122 315737476 : ++aIt;
1123 : }
1124 :
1125 4788690 : return bRet;
1126 : }
1127 :
1128 0 : void SwStyleProperties_Impl::GetProperty( const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any & rAny )
1129 : {
1130 0 : rAny = rxPropertySet->getPropertyValue( rPropertyName );
1131 0 : }
1132 :
1133 : namespace
1134 : {
1135 : class theSwXStyleUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXStyleUnoTunnelId > {};
1136 : }
1137 :
1138 149148 : const uno::Sequence< sal_Int8 > & SwXStyle::getUnoTunnelId()
1139 : {
1140 149148 : return theSwXStyleUnoTunnelId::get().getSeq();
1141 : }
1142 :
1143 74574 : sal_Int64 SAL_CALL SwXStyle::getSomething( const uno::Sequence< sal_Int8 >& rId )
1144 : throw(uno::RuntimeException, std::exception)
1145 : {
1146 149148 : if( rId.getLength() == 16
1147 223722 : && 0 == memcmp( getUnoTunnelId().getConstArray(),
1148 149148 : rId.getConstArray(), 16 ) )
1149 : {
1150 74574 : return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
1151 : }
1152 0 : return 0;
1153 : }
1154 :
1155 78 : TYPEINIT1(SwXStyle, SfxListener);
1156 :
1157 0 : OUString SwXStyle::getImplementationName(void) throw( uno::RuntimeException, std::exception )
1158 : {
1159 0 : return OUString("SwXStyle");
1160 : }
1161 :
1162 26 : sal_Bool SwXStyle::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception )
1163 : {
1164 26 : return cppu::supportsService(this, rServiceName);
1165 : }
1166 :
1167 26 : uno::Sequence< OUString > SwXStyle::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception )
1168 : {
1169 26 : long nCount = 1;
1170 26 : if(SFX_STYLE_FAMILY_PARA == eFamily)
1171 : {
1172 16 : nCount = 5;
1173 16 : if(bIsConditional)
1174 8 : nCount++;
1175 : }
1176 10 : else if(SFX_STYLE_FAMILY_CHAR == eFamily)
1177 8 : nCount = 5;
1178 2 : else if(SFX_STYLE_FAMILY_PAGE == eFamily)
1179 2 : nCount = 3;
1180 26 : uno::Sequence< OUString > aRet(nCount);
1181 26 : OUString* pArray = aRet.getArray();
1182 26 : pArray[0] = "com.sun.star.style.Style";
1183 26 : switch(eFamily)
1184 : {
1185 : case SFX_STYLE_FAMILY_CHAR:
1186 8 : pArray[1] = "com.sun.star.style.CharacterStyle";
1187 8 : pArray[2] = "com.sun.star.style.CharacterProperties";
1188 8 : pArray[3] = "com.sun.star.style.CharacterPropertiesAsian";
1189 8 : pArray[4] = "com.sun.star.style.CharacterPropertiesComplex";
1190 8 : break;
1191 : case SFX_STYLE_FAMILY_PAGE:
1192 2 : pArray[1] = "com.sun.star.style.PageStyle";
1193 2 : pArray[2] = "com.sun.star.style.PageProperties";
1194 2 : break;
1195 : case SFX_STYLE_FAMILY_PARA:
1196 16 : pArray[1] = "com.sun.star.style.ParagraphStyle";
1197 16 : pArray[2] = "com.sun.star.style.ParagraphProperties";
1198 16 : pArray[3] = "com.sun.star.style.ParagraphPropertiesAsian";
1199 16 : pArray[4] = "com.sun.star.style.ParagraphPropertiesComplex";
1200 16 : if(bIsConditional)
1201 8 : pArray[5] = "com.sun.star.style.ConditionalParagraphStyle";
1202 16 : break;
1203 :
1204 : default:
1205 : ;
1206 : }
1207 26 : return aRet;
1208 : }
1209 :
1210 74092 : SwXStyle::SwXStyle( SwDoc *pDoc, SfxStyleFamily eFam, bool bConditional) :
1211 : m_pDoc( pDoc ),
1212 : pBasePool(0),
1213 : eFamily(eFam),
1214 : bIsDescriptor(true),
1215 74092 : bIsConditional(bConditional)
1216 : {
1217 : // Register ourselves as a listener to the document (via the page descriptor)
1218 74092 : pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
1219 : // get the property set for the default style data
1220 : // First get the model
1221 74092 : uno::Reference < frame::XModel > xModel = pDoc->GetDocShell()->GetBaseModel();
1222 : // Ask the model for it's family supplier interface
1223 148184 : uno::Reference < style::XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY );
1224 : // Get the style families
1225 148184 : uno::Reference < container::XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies();
1226 :
1227 148184 : uno::Any aAny;
1228 74092 : sal_uInt16 nMapId = PROPERTY_MAP_NUM_STYLE;
1229 74092 : switch( eFamily )
1230 : {
1231 : case SFX_STYLE_FAMILY_CHAR:
1232 : {
1233 19464 : nMapId = PROPERTY_MAP_CHAR_STYLE;
1234 19464 : aAny = xFamilies->getByName ("CharacterStyles");
1235 : // Get the Frame family (and keep it for later)
1236 19464 : aAny >>= mxStyleFamily;
1237 : }
1238 19464 : break;
1239 : case SFX_STYLE_FAMILY_PARA:
1240 : {
1241 17490 : nMapId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE;
1242 17490 : aAny = xFamilies->getByName ("ParagraphStyles");
1243 : // Get the Frame family (and keep it for later)
1244 17490 : aAny >>= mxStyleFamily;
1245 17490 : aAny = mxStyleFamily->getByName ("Standard");
1246 17490 : aAny >>= mxStyleData;
1247 : }
1248 17490 : break;
1249 : case SFX_STYLE_FAMILY_PAGE:
1250 : {
1251 650 : nMapId = PROPERTY_MAP_PAGE_STYLE;
1252 650 : aAny = xFamilies->getByName ("PageStyles");
1253 : // Get the Frame family (and keep it for later)
1254 650 : aAny >>= mxStyleFamily;
1255 650 : aAny = mxStyleFamily->getByName ("Standard");
1256 650 : aAny >>= mxStyleData;
1257 : }
1258 650 : break;
1259 : case SFX_STYLE_FAMILY_FRAME :
1260 : {
1261 46 : nMapId = PROPERTY_MAP_FRAME_STYLE;
1262 : }
1263 46 : break;
1264 : case SFX_STYLE_FAMILY_PSEUDO:
1265 : {
1266 36442 : nMapId = PROPERTY_MAP_NUM_STYLE;
1267 : }
1268 36442 : break;
1269 :
1270 : default:
1271 : ;
1272 : }
1273 148184 : pPropImpl = new SwStyleProperties_Impl(aSwMapProvider.GetPropertySet(nMapId)->getPropertyMap());
1274 74092 : }
1275 :
1276 89184 : SwXStyle::SwXStyle(SfxStyleSheetBasePool& rPool, SfxStyleFamily eFam,
1277 : SwDoc* pDoc, const OUString& rStyleName) :
1278 : m_pDoc(pDoc),
1279 : m_sStyleName(rStyleName),
1280 : pBasePool(&rPool),
1281 : eFamily(eFam),
1282 : bIsDescriptor(false),
1283 : bIsConditional(false),
1284 89184 : pPropImpl(0)
1285 : {
1286 89184 : StartListening(rPool);
1287 89184 : if(eFam == SFX_STYLE_FAMILY_PARA)
1288 : {
1289 56370 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1290 56370 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1291 : OSL_ENSURE(pBase, "where is the style?" );
1292 56370 : if(pBase)
1293 : {
1294 56370 : const sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName(m_sStyleName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL);
1295 56370 : if(nId != USHRT_MAX)
1296 53148 : bIsConditional = ::IsConditionalByPoolId( nId );
1297 : else
1298 3222 : bIsConditional = RES_CONDTXTFMTCOLL == ((SwDocStyleSheet*)pBase)->GetCollection()->Which();
1299 : }
1300 : }
1301 89184 : }
1302 :
1303 476272 : SwXStyle::~SwXStyle()
1304 : {
1305 163276 : SolarMutexGuard aGuard;
1306 163276 : if(pBasePool)
1307 163044 : EndListening(*pBasePool);
1308 163276 : delete pPropImpl;
1309 312996 : }
1310 :
1311 0 : void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
1312 : {
1313 0 : ClientModify(this, pOld, pNew);
1314 0 : if(!GetRegisteredIn())
1315 : {
1316 0 : m_pDoc = 0;
1317 0 : mxStyleData.clear();
1318 0 : mxStyleFamily.clear();
1319 : }
1320 0 : }
1321 :
1322 16202 : OUString SwXStyle::getName(void) throw( uno::RuntimeException, std::exception )
1323 : {
1324 16202 : SolarMutexGuard aGuard;
1325 16202 : if(pBasePool)
1326 : {
1327 16202 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1328 16202 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1329 : OSL_ENSURE(pBase, "where is the style?" );
1330 16202 : if(!pBase)
1331 0 : throw uno::RuntimeException();
1332 16202 : OUString aString;
1333 16202 : SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
1334 16202 : return aString;
1335 : }
1336 0 : return m_sStyleName;
1337 : }
1338 :
1339 16 : void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException, std::exception )
1340 : {
1341 16 : SolarMutexGuard aGuard;
1342 16 : if(pBasePool)
1343 : {
1344 16 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1345 16 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1346 : OSL_ENSURE(pBase, "where is the style?" );
1347 16 : bool bExcept = true;
1348 16 : if(pBase && pBase->IsUserDefined())
1349 : {
1350 16 : rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
1351 16 : bExcept = !xTmp->SetName(rName);
1352 16 : if(!bExcept)
1353 16 : m_sStyleName = rName;
1354 : }
1355 16 : if(bExcept)
1356 0 : throw uno::RuntimeException();
1357 : }
1358 : else
1359 0 : m_sStyleName = rName;
1360 16 : }
1361 :
1362 3128 : sal_Bool SwXStyle::isUserDefined(void) throw( uno::RuntimeException, std::exception )
1363 : {
1364 3128 : SolarMutexGuard aGuard;
1365 3128 : bool bRet = false;
1366 3128 : if(pBasePool)
1367 : {
1368 3128 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
1369 3128 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1370 : //if it is not found it must be non user defined
1371 3128 : if(pBase)
1372 3128 : bRet = pBase->IsUserDefined();
1373 : }
1374 : else
1375 0 : throw uno::RuntimeException();
1376 3128 : return bRet;
1377 : }
1378 :
1379 30 : sal_Bool SwXStyle::isInUse(void) throw( uno::RuntimeException, std::exception )
1380 : {
1381 30 : SolarMutexGuard aGuard;
1382 30 : bool bRet = false;
1383 30 : if(pBasePool)
1384 : {
1385 30 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_USED);
1386 30 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1387 30 : if(pBase)
1388 30 : bRet = pBase->IsUsed();
1389 : }
1390 : else
1391 0 : throw uno::RuntimeException();
1392 30 : return bRet;
1393 : }
1394 :
1395 5650 : OUString SwXStyle::getParentStyle(void) throw( uno::RuntimeException, std::exception )
1396 : {
1397 5650 : SolarMutexGuard aGuard;
1398 5650 : OUString aString;
1399 5650 : if(pBasePool)
1400 : {
1401 5650 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL);
1402 5650 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1403 5650 : if(pBase)
1404 5650 : aString = pBase->GetParent();
1405 : }
1406 0 : else if(bIsDescriptor)
1407 0 : aString = m_sParentStyleName;
1408 : else
1409 0 : throw uno::RuntimeException();
1410 5650 : SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
1411 5650 : return aString;
1412 : }
1413 :
1414 50272 : void SwXStyle::setParentStyle(const OUString& rParentStyle)
1415 : throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
1416 : {
1417 50272 : SolarMutexGuard aGuard;
1418 100544 : OUString sParentStyle;
1419 50272 : SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( eFamily ), true );
1420 50272 : if(pBasePool)
1421 : {
1422 23458 : pBasePool->SetSearchMask(eFamily);
1423 23458 : bool bExcept = false;
1424 23458 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
1425 23458 : if(pBase)
1426 : {
1427 23458 : rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
1428 : //make it a 'real' style - necessary for pooled styles
1429 23458 : xBase->GetItemSet();
1430 23458 : if(xBase->GetParent() != sParentStyle)
1431 : {
1432 13100 : bExcept = !xBase->SetParent(sParentStyle);
1433 23458 : }
1434 : }
1435 : else
1436 0 : bExcept = true;
1437 23458 : if(bExcept)
1438 0 : throw uno::RuntimeException();
1439 : }
1440 26814 : else if(bIsDescriptor)
1441 : {
1442 26814 : m_sParentStyleName = sParentStyle;
1443 : try
1444 : {
1445 26814 : uno::Any aAny = mxStyleFamily->getByName ( sParentStyle );
1446 26678 : aAny >>= mxStyleData;
1447 : }
1448 136 : catch ( container::NoSuchElementException& )
1449 : {
1450 : }
1451 0 : catch ( lang::WrappedTargetException& )
1452 : {
1453 : }
1454 0 : catch ( uno::RuntimeException& )
1455 : {
1456 : }
1457 : }
1458 : else
1459 50272 : throw uno::RuntimeException();
1460 50272 : }
1461 :
1462 55266 : static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, bool bIsConditional )
1463 : {
1464 55266 : uno::Reference< beans::XPropertySetInfo > xRet;
1465 55266 : switch( eFamily )
1466 : {
1467 : case SFX_STYLE_FAMILY_CHAR:
1468 : {
1469 8352 : static uno::Reference< beans::XPropertySetInfo > xCharRef;
1470 8352 : if(!xCharRef.is())
1471 : {
1472 56 : xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_STYLE)->getPropertySetInfo();
1473 : }
1474 8352 : xRet = xCharRef;
1475 : }
1476 8352 : break;
1477 : case SFX_STYLE_FAMILY_PARA:
1478 : {
1479 40898 : static uno::Reference< beans::XPropertySetInfo > xCondParaRef;
1480 40898 : static uno::Reference< beans::XPropertySetInfo > xParaRef;
1481 40898 : if(!xParaRef.is())
1482 : {
1483 124 : xCondParaRef = aSwMapProvider.GetPropertySet(
1484 62 : PROPERTY_MAP_CONDITIONAL_PARA_STYLE)->getPropertySetInfo();
1485 124 : xParaRef = aSwMapProvider.GetPropertySet(
1486 62 : PROPERTY_MAP_PARA_STYLE)->getPropertySetInfo();
1487 : }
1488 40898 : xRet = bIsConditional ? xCondParaRef : xParaRef;
1489 : }
1490 40898 : break;
1491 : case SFX_STYLE_FAMILY_PAGE :
1492 : {
1493 3756 : static uno::Reference< beans::XPropertySetInfo > xPageRef;
1494 3756 : if(!xPageRef.is())
1495 : {
1496 56 : xPageRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE)->getPropertySetInfo();
1497 : }
1498 3756 : xRet = xPageRef;
1499 : }
1500 3756 : break;
1501 : case SFX_STYLE_FAMILY_FRAME :
1502 : {
1503 1432 : static uno::Reference< beans::XPropertySetInfo > xFrameRef;
1504 1432 : if(!xFrameRef.is())
1505 : {
1506 44 : xFrameRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_FRAME_STYLE)->getPropertySetInfo();
1507 : }
1508 1432 : xRet = xFrameRef;
1509 : }
1510 1432 : break;
1511 : case SFX_STYLE_FAMILY_PSEUDO:
1512 : {
1513 828 : static uno::Reference< beans::XPropertySetInfo > xNumRef;
1514 828 : if(!xNumRef.is())
1515 : {
1516 38 : xNumRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_NUM_STYLE)->getPropertySetInfo();
1517 : }
1518 828 : xRet = xNumRef;
1519 : }
1520 828 : break;
1521 :
1522 : default:
1523 : ;
1524 : }
1525 55266 : return xRet;
1526 : }
1527 :
1528 55266 : uno::Reference< beans::XPropertySetInfo > SwXStyle::getPropertySetInfo(void)
1529 : throw( uno::RuntimeException, std::exception )
1530 : {
1531 55266 : return lcl_getPropertySetInfo( eFamily, bIsConditional );
1532 : }
1533 :
1534 73916 : void SwXStyle::ApplyDescriptorProperties()
1535 : {
1536 73916 : bIsDescriptor = false;
1537 73916 : mxStyleData.clear();
1538 73916 : mxStyleFamily.clear();
1539 :
1540 73916 : const PropertyEntryVector_t& rPropertyVector = pPropImpl->GetPropertyVector();
1541 73916 : PropertyEntryVector_t::const_iterator aIt = rPropertyVector.begin();
1542 4936522 : while(aIt != rPropertyVector.end())
1543 : {
1544 : uno::Any* pAny;
1545 4788690 : pPropImpl->GetProperty(aIt->sName, pAny);
1546 4788690 : if(pAny)
1547 208476 : setPropertyValue(aIt->sName, *pAny);
1548 4788690 : ++aIt;
1549 : }
1550 73916 : }
1551 :
1552 : class SwStyleBase_Impl
1553 : {
1554 : private:
1555 : SwDoc& mrDoc;
1556 : const SwPageDesc* mpOldPageDesc;
1557 : rtl::Reference< SwDocStyleSheet > mxNewBase;
1558 : SfxItemSet* mpItemSet;
1559 : OUString mrStyleName;
1560 : const SwAttrSet* mpParentStyle;
1561 :
1562 : public:
1563 728454 : SwStyleBase_Impl(SwDoc& rSwDoc, const OUString& rName, const SwAttrSet* pParentStyle)
1564 : : mrDoc(rSwDoc)
1565 : , mpOldPageDesc(0)
1566 : , mpItemSet(0)
1567 : , mrStyleName(rName)
1568 728454 : , mpParentStyle(pParentStyle)
1569 : {
1570 728454 : }
1571 :
1572 728454 : ~SwStyleBase_Impl()
1573 728454 : {
1574 728454 : delete mpItemSet;
1575 728454 : }
1576 :
1577 2178198 : rtl::Reference< SwDocStyleSheet >& getNewBase()
1578 : {
1579 2178198 : return mxNewBase;
1580 : }
1581 :
1582 665604 : void setNewBase(SwDocStyleSheet* pNew)
1583 : {
1584 665604 : mxNewBase = pNew;
1585 665604 : }
1586 :
1587 643460 : bool HasItemSet() const
1588 : {
1589 643460 : return mxNewBase.is();
1590 : }
1591 :
1592 21880 : SfxItemSet* replaceItemSet(SfxItemSet* pNew)
1593 : {
1594 21880 : SfxItemSet* pRetval = mpItemSet;
1595 21880 : mpItemSet = pNew;
1596 21880 : return pRetval;
1597 : }
1598 :
1599 1201904 : SfxItemSet& GetItemSet()
1600 : {
1601 : OSL_ENSURE(mxNewBase.is(), "no SwDocStyleSheet available");
1602 1201904 : if (!mpItemSet)
1603 : {
1604 614754 : mpItemSet = new SfxItemSet(mxNewBase->GetItemSet());
1605 :
1606 : //UUUU set parent style to have the correct XFillStyle setting as XFILL_NONE
1607 614754 : if(!mpItemSet->GetParent() && mpParentStyle)
1608 : {
1609 303846 : mpItemSet->SetParent(mpParentStyle);
1610 : }
1611 : }
1612 1201904 : return *mpItemSet;
1613 : }
1614 :
1615 : const SwPageDesc& GetOldPageDesc();
1616 : };
1617 :
1618 3552 : const SwPageDesc& SwStyleBase_Impl::GetOldPageDesc()
1619 : {
1620 3552 : if(!mpOldPageDesc)
1621 : {
1622 3538 : const sal_uInt16 nPDescCount = mrDoc.GetPageDescCnt();
1623 7546 : for(sal_uInt16 i = 0; i < nPDescCount; ++i)
1624 : {
1625 7546 : const SwPageDesc& rDesc = mrDoc.GetPageDesc( i );
1626 7546 : if(rDesc.GetName() == mrStyleName)
1627 : {
1628 3538 : mpOldPageDesc = & rDesc;
1629 3538 : break;
1630 : }
1631 : }
1632 3538 : if(!mpOldPageDesc)
1633 : {
1634 0 : for(sal_uInt16 i = RC_POOLPAGEDESC_BEGIN; i <= STR_POOLPAGE_LANDSCAPE; ++i)
1635 : {
1636 0 : if(SW_RESSTR(i) == mrStyleName)
1637 : {
1638 0 : mpOldPageDesc = mrDoc.getIDocumentStylePoolAccess().GetPageDescFromPool( static_cast< sal_uInt16 >(RES_POOLPAGE_BEGIN + i - RC_POOLPAGEDESC_BEGIN) );
1639 0 : break;
1640 : }
1641 : }
1642 : }
1643 : }
1644 : assert(mpOldPageDesc != 0);
1645 3552 : return *mpOldPageDesc;
1646 : }
1647 :
1648 836832 : static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
1649 : const SfxItemPropertySet& rPropSet,
1650 : const uno::Any& rValue,
1651 : SwStyleBase_Impl& rBase,
1652 : SfxStyleSheetBasePool* pBasePool,
1653 : SwDoc* pDoc,
1654 : SfxStyleFamily eFamily)
1655 : throw(beans::PropertyVetoException, lang::IllegalArgumentException,
1656 : lang::WrappedTargetException, uno::RuntimeException,
1657 : std::exception)
1658 :
1659 : {
1660 : //UUUU adapted switch logic to a more readable state; removed goto's and made
1661 : // execution of standard setting of proerty in ItemSet dependent of this variable
1662 836832 : bool bDone(false);
1663 :
1664 : //UUUU
1665 836832 : const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
1666 836832 : uno::Any aValue(rValue);
1667 :
1668 : //UUUU check for needed metric translation
1669 836832 : if(rEntry.nMemberId & SFX_METRIC_ITEM)
1670 : {
1671 0 : bool bDoIt(true);
1672 :
1673 0 : if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
1674 : {
1675 : // exception: If these ItemTypes are used, do not convert when these are negative
1676 : // since this means they are intended as percent values
1677 0 : sal_Int32 nValue = 0;
1678 :
1679 0 : if(aValue >>= nValue)
1680 : {
1681 0 : bDoIt = nValue > 0;
1682 : }
1683 : }
1684 :
1685 0 : if(bDoIt && pDoc)
1686 : {
1687 0 : const SfxItemPool& rPool = pDoc->GetAttrPool();
1688 0 : const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
1689 :
1690 0 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
1691 : {
1692 0 : SvxUnoConvertFromMM(eMapUnit, aValue);
1693 : }
1694 : }
1695 : }
1696 :
1697 836832 : switch(rEntry.nWID)
1698 : {
1699 : case FN_UNO_HIDDEN:
1700 : {
1701 5686 : bool bHidden = false;
1702 5686 : if ( rValue >>= bHidden )
1703 : {
1704 : //make it a 'real' style - necessary for pooled styles
1705 5686 : rBase.getNewBase()->GetItemSet();
1706 5686 : rBase.getNewBase()->SetHidden( bHidden );
1707 : }
1708 : }
1709 5686 : break;
1710 :
1711 : case FN_UNO_STYLE_INTEROP_GRAB_BAG:
1712 : {
1713 75526 : rBase.getNewBase()->GetItemSet();
1714 75526 : rBase.getNewBase()->SetGrabBagItem(rValue);
1715 : }
1716 75526 : break;
1717 :
1718 : case XATTR_FILLGRADIENT:
1719 : case XATTR_FILLHATCH:
1720 : case XATTR_FILLBITMAP:
1721 : case XATTR_FILLFLOATTRANSPARENCE:
1722 : // not yet needed; activate when LineStyle support may be added
1723 : // case XATTR_LINESTART:
1724 : // case XATTR_LINEEND:
1725 : // case XATTR_LINEDASH:
1726 : {
1727 0 : if(MID_NAME == nMemberId)
1728 : {
1729 : //UUUU add set commands for FillName items
1730 0 : OUString aTempName;
1731 0 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1732 :
1733 0 : if(!(aValue >>= aTempName))
1734 : {
1735 0 : throw lang::IllegalArgumentException();
1736 : }
1737 :
1738 0 : SvxShape::SetFillAttribute(rEntry.nWID, aTempName, rStyleSet);
1739 0 : bDone = true;
1740 : }
1741 0 : else if(MID_GRAFURL == nMemberId)
1742 : {
1743 0 : if(XATTR_FILLBITMAP == rEntry.nWID)
1744 : {
1745 : //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
1746 0 : const Graphic aNullGraphic;
1747 0 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1748 0 : XFillBitmapItem aXFillBitmapItem(rStyleSet.GetPool(), aNullGraphic);
1749 :
1750 0 : aXFillBitmapItem.PutValue(aValue, nMemberId);
1751 0 : rStyleSet.Put(aXFillBitmapItem);
1752 0 : bDone = true;
1753 : }
1754 : }
1755 :
1756 0 : break;
1757 : }
1758 : case RES_BACKGROUND:
1759 : {
1760 : //UUUU
1761 902 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1762 902 : const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rStyleSet, RES_BACKGROUND));
1763 1804 : SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
1764 :
1765 902 : aChangedBrushItem.PutValue(aValue, nMemberId);
1766 :
1767 902 : if(!(aChangedBrushItem == aOriginalBrushItem))
1768 : {
1769 452 : setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, rStyleSet);
1770 : }
1771 :
1772 902 : bDone = true;
1773 1804 : break;
1774 : }
1775 : case OWN_ATTR_FILLBMP_MODE:
1776 : {
1777 : //UUUU
1778 : drawing::BitmapMode eMode;
1779 :
1780 0 : if(!(aValue >>= eMode))
1781 : {
1782 0 : sal_Int32 nMode = 0;
1783 :
1784 0 : if(!(aValue >>= nMode))
1785 : {
1786 0 : throw lang::IllegalArgumentException();
1787 : }
1788 :
1789 0 : eMode = (drawing::BitmapMode)nMode;
1790 : }
1791 :
1792 0 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1793 :
1794 0 : rStyleSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
1795 0 : rStyleSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
1796 :
1797 0 : bDone = true;
1798 0 : break;
1799 : }
1800 : case RES_PAPER_BIN:
1801 : {
1802 12 : SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( true );
1803 12 : OUString sTmp;
1804 12 : sal_uInt16 nBin = USHRT_MAX;
1805 12 : if ( !( aValue >>= sTmp ) )
1806 0 : throw lang::IllegalArgumentException();
1807 12 : if ( sTmp == "[From printer settings]" )
1808 12 : nBin = USHRT_MAX-1;
1809 0 : else if ( pPrinter )
1810 : {
1811 0 : for (sal_uInt16 i=0, nEnd = pPrinter->GetPaperBinCount(); i < nEnd; i++ )
1812 : {
1813 0 : if (sTmp == pPrinter->GetPaperBinName ( i ) )
1814 : {
1815 0 : nBin = i;
1816 0 : break;
1817 : }
1818 : }
1819 : }
1820 12 : if ( nBin == USHRT_MAX )
1821 0 : throw lang::IllegalArgumentException();
1822 : else
1823 : {
1824 12 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1825 12 : SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
1826 12 : aSet.SetParent(&rStyleSet);
1827 12 : rPropSet.setPropertyValue(rEntry, uno::makeAny ( static_cast < sal_Int8 > ( nBin == USHRT_MAX-1 ? -1 : nBin ) ), aSet);
1828 12 : rStyleSet.Put(aSet);
1829 : }
1830 :
1831 12 : bDone = true;
1832 12 : break;
1833 : }
1834 : case FN_UNO_NUM_RULES: // special handling for a SvxNumRuleItem:
1835 : {
1836 276742 : if(aValue.getValueType() == cppu::UnoType<container::XIndexReplace>::get())
1837 : {
1838 : uno::Reference< container::XIndexReplace > * pxRulesRef =
1839 276742 : (uno::Reference< container::XIndexReplace > *)aValue.getValue();
1840 :
1841 276742 : uno::Reference<lang::XUnoTunnel> xNumberTunnel( *pxRulesRef, uno::UNO_QUERY);
1842 :
1843 276742 : SwXNumberingRules* pSwXRules = 0;
1844 276742 : if(xNumberTunnel.is())
1845 : {
1846 : pSwXRules = reinterpret_cast< SwXNumberingRules * >(
1847 276742 : sal::static_int_cast< sal_IntPtr >(xNumberTunnel->getSomething( SwXNumberingRules::getUnoTunnelId()) ));
1848 : }
1849 276742 : if(pSwXRules)
1850 : {
1851 276742 : const OUString* pCharStyleNames = pSwXRules->GetNewCharStyleNames();
1852 276742 : const OUString* pBulletFontNames = pSwXRules->GetBulletFontNames();
1853 :
1854 276742 : SwNumRule aSetRule(*pSwXRules->GetNumRule());
1855 276742 : const SwCharFmts* pFmts = pDoc->GetCharFmts();
1856 276742 : const size_t nChCount = pFmts->size();
1857 3044162 : for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1858 : {
1859 :
1860 2767420 : const SwNumFmt* pFmt = aSetRule.GetNumFmt( i );
1861 2767420 : if(pFmt)
1862 : {
1863 1541572 : SwNumFmt aFmt(*pFmt);
1864 7687516 : if (!pCharStyleNames[i].isEmpty() &&
1865 3083144 : !SwXNumberingRules::isInvalidStyle(pCharStyleNames[i]) &&
1866 1541572 : (!pFmt->GetCharFmt() || pFmt->GetCharFmt()->GetName() != pCharStyleNames[i]) )
1867 : {
1868 :
1869 0 : SwCharFmt* pCharFmt = 0;
1870 0 : for(size_t j = 0; j< nChCount; ++j)
1871 : {
1872 0 : SwCharFmt* pTmp = (*pFmts)[j];
1873 0 : if(pTmp->GetName() == pCharStyleNames[i])
1874 : {
1875 0 : pCharFmt = pTmp;
1876 0 : break;
1877 : }
1878 : }
1879 0 : if(!pCharFmt)
1880 : {
1881 :
1882 : SfxStyleSheetBase* pBase;
1883 0 : pBase = ((SfxStyleSheetBasePool*)pBasePool)->Find(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1884 0 : if(!pBase)
1885 0 : pBase = &pBasePool->Make(pCharStyleNames[i], SFX_STYLE_FAMILY_CHAR);
1886 0 : pCharFmt = ((SwDocStyleSheet*)pBase)->GetCharFmt();
1887 :
1888 : }
1889 :
1890 0 : aFmt.SetCharFmt( pCharFmt );
1891 : }
1892 : // same for fonts:
1893 4624716 : if (!pBulletFontNames[i].isEmpty() &&
1894 1541572 : !SwXNumberingRules::isInvalidStyle(pBulletFontNames[i]) &&
1895 0 : (!pFmt->GetBulletFont() || pFmt->GetBulletFont()->GetName() != pBulletFontNames[i]) )
1896 : {
1897 : const SvxFontListItem* pFontListItem =
1898 0 : (const SvxFontListItem* )pDoc->GetDocShell()
1899 0 : ->GetItem( SID_ATTR_CHAR_FONTLIST );
1900 0 : const FontList* pList = pFontListItem->GetFontList();
1901 : vcl::FontInfo aInfo = pList->Get(
1902 0 : pBulletFontNames[i],WEIGHT_NORMAL, ITALIC_NONE);
1903 0 : vcl::Font aFont(aInfo);
1904 0 : aFmt.SetBulletFont(&aFont);
1905 : }
1906 1541572 : aSetRule.Set( i, &aFmt );
1907 : }
1908 : }
1909 276742 : rBase.getNewBase()->SetNumRule(aSetRule);
1910 276742 : }
1911 : }
1912 : else
1913 0 : throw lang::IllegalArgumentException();
1914 :
1915 276742 : bDone = true;
1916 276742 : break;
1917 : }
1918 :
1919 : case RES_PARATR_OUTLINELEVEL:
1920 : {
1921 35276 : sal_Int16 nLevel = 0;
1922 35276 : aValue >>= nLevel;
1923 35276 : if( 0 <= nLevel && nLevel <= MAXLEVEL)
1924 35276 : rBase.getNewBase()->GetCollection()->SetAttrOutlineLevel( nLevel );
1925 :
1926 35276 : bDone = true;
1927 35276 : break;
1928 : }
1929 :
1930 : case FN_UNO_FOLLOW_STYLE:
1931 : {
1932 10248 : OUString sTmp;
1933 10248 : aValue >>= sTmp;
1934 20496 : OUString aString;
1935 10248 : SwStyleNameMapper::FillUIName(sTmp, aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true ) ;
1936 10248 : rBase.getNewBase()->SetFollow( aString );
1937 :
1938 10248 : bDone = true;
1939 20496 : break;
1940 : }
1941 : case RES_PAGEDESC :
1942 : {
1943 84 : if (MID_PAGEDESC_PAGEDESCNAME != nMemberId)
1944 42 : break;
1945 : // special handling for RES_PAGEDESC
1946 42 : if(aValue.getValueType() != ::cppu::UnoType<OUString>::get())
1947 0 : throw lang::IllegalArgumentException();
1948 42 : SfxItemSet& rStyleSet = rBase.GetItemSet();
1949 :
1950 42 : SwFmtPageDesc* pNewDesc = 0;
1951 : const SfxPoolItem* pItem;
1952 42 : if(SfxItemState::SET == rStyleSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
1953 : {
1954 42 : pNewDesc = new SwFmtPageDesc(*((SwFmtPageDesc*)pItem));
1955 : }
1956 42 : if(!pNewDesc)
1957 0 : pNewDesc = new SwFmtPageDesc();
1958 42 : OUString uDescName;
1959 42 : aValue >>= uDescName;
1960 84 : OUString sDescName;
1961 42 : SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
1962 42 : if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
1963 : {
1964 42 : bool bPut = false;
1965 42 : if (!sDescName.isEmpty())
1966 : {
1967 2 : SwPageDesc* pPageDesc = SwPageDesc::GetByName(*pDoc, sDescName);
1968 2 : if(pPageDesc)
1969 : {
1970 2 : pNewDesc->RegisterToPageDesc( *pPageDesc );
1971 2 : bPut = true;
1972 : }
1973 : else
1974 : {
1975 0 : throw lang::IllegalArgumentException();
1976 : }
1977 : }
1978 42 : if(!bPut)
1979 : {
1980 40 : rStyleSet.ClearItem(RES_BREAK);
1981 40 : rStyleSet.Put(SwFmtPageDesc());
1982 : }
1983 : else
1984 2 : rStyleSet.Put(*pNewDesc);
1985 :
1986 : }
1987 42 : delete pNewDesc;
1988 42 : bDone = true;
1989 84 : break;
1990 : }
1991 : case FN_UNO_IS_AUTO_UPDATE:
1992 : {
1993 6140 : bool bAuto = *(sal_Bool*)aValue.getValue();
1994 6140 : if(SFX_STYLE_FAMILY_PARA == eFamily)
1995 5902 : rBase.getNewBase()->GetCollection()->SetAutoUpdateFmt(bAuto);
1996 238 : else if(SFX_STYLE_FAMILY_FRAME == eFamily)
1997 238 : rBase.getNewBase()->GetFrmFmt()->SetAutoUpdateFmt(bAuto);
1998 :
1999 6140 : bDone = true;
2000 6140 : break;
2001 : }
2002 : case FN_UNO_PARA_STYLE_CONDITIONS:
2003 : {
2004 0 : uno::Sequence< beans::NamedValue > aSeq;
2005 0 : if (!(aValue >>= aSeq))
2006 0 : throw lang::IllegalArgumentException();
2007 :
2008 : OSL_ENSURE(COND_COMMAND_COUNT == 28,
2009 : "invalid size of comman count?");
2010 0 : const beans::NamedValue *pSeq = aSeq.getConstArray();
2011 0 : const sal_Int32 nLen = aSeq.getLength();
2012 :
2013 0 : bool bFailed = false;
2014 0 : SwCondCollItem aCondItem;
2015 0 : for(sal_Int32 i = 0; i < nLen; ++i)
2016 : {
2017 0 : OUString aTmp;
2018 0 : if ((pSeq[i].Value >>= aTmp))
2019 : {
2020 : // get UI style name from programmatic style name
2021 0 : OUString aStyleName;
2022 : SwStyleNameMapper::FillUIName(aTmp, aStyleName,
2023 0 : lcl_GetSwEnumFromSfxEnum(eFamily), true);
2024 :
2025 : // check for correct context and style name
2026 :
2027 0 : sal_Int16 nIdx = GetCommandContextIndex( pSeq[i].Name );
2028 :
2029 0 : pBasePool->SetSearchMask( SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_ALL );
2030 0 : bool bStyleFound = false;
2031 0 : const SfxStyleSheetBase* pBase = pBasePool->First();
2032 0 : while (pBase && !bStyleFound)
2033 : {
2034 0 : if(pBase->GetName() == aStyleName)
2035 0 : bStyleFound = true;
2036 0 : pBase = pBasePool->Next();
2037 : }
2038 :
2039 0 : if (nIdx == -1 || !bStyleFound)
2040 : {
2041 0 : bFailed = true;
2042 0 : break;
2043 : }
2044 :
2045 0 : aCondItem.SetStyle(&aStyleName, nIdx);
2046 : }
2047 : else
2048 0 : bFailed = true;
2049 0 : }
2050 0 : if (bFailed)
2051 0 : throw lang::IllegalArgumentException();
2052 0 : rBase.GetItemSet().Put( aCondItem );
2053 0 : bDone = true;
2054 0 : break;
2055 : }
2056 : case FN_UNO_CATEGORY:
2057 : {
2058 24 : if(!rBase.getNewBase()->IsUserDefined())
2059 0 : throw lang::IllegalArgumentException();
2060 24 : short nSet = 0;
2061 24 : aValue >>= nSet;
2062 :
2063 : sal_uInt16 nId;
2064 24 : switch( nSet )
2065 : {
2066 : case style::ParagraphStyleCategory::TEXT:
2067 16 : nId = SWSTYLEBIT_TEXT;
2068 16 : break;
2069 : case style::ParagraphStyleCategory::CHAPTER:
2070 0 : nId = SWSTYLEBIT_CHAPTER;
2071 0 : break;
2072 : case style::ParagraphStyleCategory::LIST:
2073 6 : nId = SWSTYLEBIT_LIST;
2074 6 : break;
2075 : case style::ParagraphStyleCategory::INDEX:
2076 0 : nId = SWSTYLEBIT_IDX;
2077 0 : break;
2078 : case style::ParagraphStyleCategory::EXTRA:
2079 2 : nId = SWSTYLEBIT_EXTRA;
2080 2 : break;
2081 : case style::ParagraphStyleCategory::HTML:
2082 0 : nId = SWSTYLEBIT_HTML;
2083 0 : break;
2084 0 : default: throw lang::IllegalArgumentException();
2085 : }
2086 :
2087 24 : rBase.getNewBase()->SetMask( nId|SFXSTYLEBIT_USERDEF );
2088 24 : bDone = true;
2089 24 : break;
2090 : }
2091 : case SID_SWREGISTER_COLLECTION:
2092 : {
2093 10 : OUString sName;
2094 10 : aValue >>= sName;
2095 20 : SwRegisterItem aReg( !sName.isEmpty() );
2096 10 : aReg.SetWhich(SID_SWREGISTER_MODE);
2097 10 : rBase.GetItemSet().Put(aReg);
2098 20 : OUString aString;
2099 10 : SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true);
2100 :
2101 10 : rBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) );
2102 10 : bDone = true;
2103 20 : break;
2104 : }
2105 : case RES_TXTATR_CJK_RUBY:
2106 : {
2107 0 : if(MID_RUBY_CHARSTYLE == nMemberId )
2108 : {
2109 0 : OUString sTmp;
2110 0 : if(aValue >>= sTmp)
2111 : {
2112 0 : SfxItemSet& rStyleSet = rBase.GetItemSet();
2113 0 : SwFmtRuby* pRuby = 0;
2114 : const SfxPoolItem* pItem;
2115 0 : if(SfxItemState::SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, true, &pItem ) )
2116 0 : pRuby = new SwFmtRuby(*((SwFmtRuby*)pItem));
2117 0 : if(!pRuby)
2118 0 : pRuby = new SwFmtRuby(OUString());
2119 0 : OUString sStyle;
2120 0 : SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
2121 0 : pRuby->SetCharFmtName( sTmp );
2122 0 : pRuby->SetCharFmtId( 0 );
2123 0 : if(!sTmp.isEmpty())
2124 : {
2125 0 : sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
2126 0 : pRuby->SetCharFmtId(nId);
2127 : }
2128 0 : rStyleSet.Put(*pRuby);
2129 0 : delete pRuby;
2130 : }
2131 : else
2132 0 : throw lang::IllegalArgumentException();
2133 : }
2134 0 : break;
2135 : }
2136 : case RES_PARATR_DROP:
2137 : {
2138 4 : if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId)
2139 : {
2140 0 : if(aValue.getValueType() == ::cppu::UnoType<OUString>::get())
2141 : {
2142 0 : SfxItemSet& rStyleSet = rBase.GetItemSet();
2143 :
2144 0 : SwFmtDrop* pDrop = 0;
2145 : const SfxPoolItem* pItem;
2146 0 : if(SfxItemState::SET == rStyleSet.GetItemState( RES_PARATR_DROP, true, &pItem ) )
2147 0 : pDrop = new SwFmtDrop(*((SwFmtDrop*)pItem));
2148 0 : if(!pDrop)
2149 0 : pDrop = new SwFmtDrop();
2150 0 : OUString uStyle;
2151 0 : aValue >>= uStyle;
2152 0 : OUString sStyle;
2153 0 : SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
2154 : SwDocStyleSheet* pStyle =
2155 0 : (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR);
2156 0 : if(pStyle)
2157 0 : pDrop->SetCharFmt(pStyle->GetCharFmt());
2158 : else
2159 0 : throw lang::IllegalArgumentException();
2160 0 : rStyleSet.Put(*pDrop);
2161 0 : delete pDrop;
2162 : }
2163 : else
2164 0 : throw lang::IllegalArgumentException();
2165 :
2166 0 : bDone = true;
2167 : }
2168 4 : break;
2169 : }
2170 : default:
2171 : {
2172 : // nothing to do
2173 426178 : break;
2174 : }
2175 : }
2176 :
2177 836832 : if(!bDone)
2178 : {
2179 : // default ItemSet handling
2180 507436 : SfxItemSet& rStyleSet = rBase.GetItemSet();
2181 507436 : SfxItemSet aSet(*rStyleSet.GetPool(), rEntry.nWID, rEntry.nWID);
2182 507436 : aSet.SetParent(&rStyleSet);
2183 507436 : rPropSet.setPropertyValue(rEntry, aValue, aSet);
2184 507434 : rStyleSet.Put(aSet);
2185 :
2186 : // --> OD 2006-10-18 #i70223#
2187 797850 : if ( SFX_STYLE_FAMILY_PARA == eFamily &&
2188 290480 : rEntry.nWID == RES_PARATR_NUMRULE &&
2189 507626 : rBase.getNewBase().is() && rBase.getNewBase()->GetCollection() &&
2190 : //rBase.getNewBase()->GetCollection()->GetOutlineLevel() < MAXLEVEL /* assigned to list level of outline style */) //#outline level,removed by zhaojianwei
2191 64 : rBase.getNewBase()->GetCollection()->IsAssignedToListLevelOfOutlineStyle() ) ////<-end,add by zhaojianwei
2192 : {
2193 0 : OUString sNewNumberingRuleName;
2194 0 : aValue >>= sNewNumberingRuleName;
2195 0 : if ( sNewNumberingRuleName.isEmpty() ||
2196 0 : sNewNumberingRuleName != pDoc->GetOutlineNumRule()->GetName() )
2197 : {
2198 0 : rBase.getNewBase()->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
2199 0 : }
2200 507436 : }
2201 836832 : }
2202 836830 : }
2203 :
2204 632984 : void SAL_CALL SwXStyle::SetPropertyValues_Impl(
2205 : const uno::Sequence< OUString >& rPropertyNames,
2206 : const uno::Sequence< uno::Any >& rValues )
2207 : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
2208 : lang::IllegalArgumentException, lang::WrappedTargetException,
2209 : uno::RuntimeException, std::exception)
2210 : {
2211 632984 : if ( !m_pDoc )
2212 0 : throw uno::RuntimeException();
2213 :
2214 632984 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2215 :
2216 632984 : switch(eFamily)
2217 : {
2218 211494 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2219 714 : case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2220 0 : case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2221 303846 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2222 : default: ;
2223 : }
2224 632984 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2225 632984 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2226 :
2227 632984 : if(rPropertyNames.getLength() != rValues.getLength())
2228 : {
2229 0 : throw lang::IllegalArgumentException();
2230 : }
2231 :
2232 632984 : const OUString* pNames = rPropertyNames.getConstArray();
2233 632984 : const uno::Any* pValues = rValues.getConstArray();
2234 :
2235 632984 : SwStyleBase_Impl aBaseImpl(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent
2236 632984 : if(pBasePool)
2237 : {
2238 599798 : const sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2239 599798 : pBasePool->SetSearchMask(eFamily);
2240 599798 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
2241 599798 : pBasePool->SetSearchMask(eFamily, nSaveMask );
2242 : OSL_ENSURE(pBase, "where is the style?" );
2243 599798 : if(pBase)
2244 599798 : aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
2245 : else
2246 0 : throw uno::RuntimeException();
2247 : }
2248 :
2249 1597450 : for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2250 : {
2251 965508 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[nProp]);
2252 :
2253 1931016 : if(!pEntry ||
2254 1921074 : (!bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS))
2255 1028 : throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2256 964480 : if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2257 12 : throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2258 964468 : if(aBaseImpl.getNewBase().is())
2259 : {
2260 756982 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, pBasePool, m_pDoc, eFamily);
2261 : }
2262 207486 : else if(bIsDescriptor)
2263 : {
2264 207486 : if(!pPropImpl->SetProperty(pNames[nProp], pValues[nProp]))
2265 : {
2266 0 : throw lang::IllegalArgumentException();
2267 : }
2268 : }
2269 : else
2270 : {
2271 0 : throw uno::RuntimeException();
2272 : }
2273 : }
2274 :
2275 631942 : if(aBaseImpl.HasItemSet())
2276 : {
2277 599762 : aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
2278 632984 : }
2279 631942 : }
2280 :
2281 53168 : void SwXStyle::setPropertyValues(
2282 : const uno::Sequence< OUString >& rPropertyNames,
2283 : const uno::Sequence< uno::Any >& rValues )
2284 : throw(beans::PropertyVetoException, lang::IllegalArgumentException,
2285 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
2286 : {
2287 53168 : SolarMutexGuard aGuard;
2288 :
2289 : // workaround for bad designed API
2290 : try
2291 : {
2292 53168 : SetPropertyValues_Impl( rPropertyNames, rValues );
2293 : }
2294 514 : catch (const beans::UnknownPropertyException &rException)
2295 : {
2296 : // wrap the original (here not allowed) exception in
2297 : // a lang::WrappedTargetException that gets thrown instead.
2298 514 : lang::WrappedTargetException aWExc;
2299 514 : aWExc.TargetException <<= rException;
2300 514 : throw aWExc;
2301 53168 : }
2302 52654 : }
2303 :
2304 81326 : static uno::Any lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
2305 : const SfxItemPropertySet& rPropSet,
2306 : SwStyleBase_Impl& rBase,
2307 : SfxStyleSheetBase* pBase,
2308 : SfxStyleFamily eFamily,
2309 : SwDoc *pDoc) throw(uno::RuntimeException)
2310 : {
2311 81326 : uno::Any aRet;
2312 :
2313 81326 : if(FN_UNO_IS_PHYSICAL == rEntry.nWID)
2314 : {
2315 16146 : sal_Bool bPhys = pBase != 0;
2316 16146 : if(pBase)
2317 : {
2318 16146 : bPhys = ((SwDocStyleSheet*)pBase)->IsPhysical();
2319 : // The standard character format is not existing physically
2320 18804 : if( bPhys && SFX_STYLE_FAMILY_CHAR == eFamily &&
2321 16530 : ((SwDocStyleSheet*)pBase)->GetCharFmt() &&
2322 192 : ((SwDocStyleSheet*)pBase)->GetCharFmt()->IsDefault() )
2323 60 : bPhys = sal_False;
2324 : }
2325 16146 : aRet.setValue(&bPhys, ::getBooleanCppuType());
2326 : }
2327 65180 : else if (FN_UNO_HIDDEN == rEntry.nWID)
2328 : {
2329 842 : sal_Bool bHidden = sal_False;
2330 842 : if(pBase)
2331 : {
2332 842 : rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*(SwDocStyleSheet*)pBase) );
2333 842 : bHidden = xBase->IsHidden();
2334 : }
2335 842 : aRet.setValue(&bHidden, ::getBooleanCppuType());
2336 : }
2337 64338 : else if (FN_UNO_STYLE_INTEROP_GRAB_BAG == rEntry.nWID)
2338 : {
2339 18 : if (pBase)
2340 : {
2341 18 : rtl::Reference<SwDocStyleSheet> xBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
2342 18 : xBase->GetGrabBagItem(aRet);
2343 : }
2344 : }
2345 64320 : else if(pBase)
2346 : {
2347 64320 : if(!rBase.getNewBase().is())
2348 : {
2349 55274 : rBase.setNewBase(new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ));
2350 : }
2351 :
2352 : //UUUU
2353 64320 : const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM));
2354 :
2355 : //UUUU adapted switch logic to a more readable state; removed goto's and made
2356 : // execution of standard setting of proerty in ItemSet dependent of this variable
2357 64320 : bool bDone(false);
2358 :
2359 64320 : switch(rEntry.nWID)
2360 : {
2361 : case RES_PAPER_BIN:
2362 : {
2363 14 : SfxItemSet& rSet = rBase.GetItemSet();
2364 14 : rPropSet.getPropertyValue(rEntry, rSet, aRet);
2365 14 : sal_Int8 nBin = 0;
2366 14 : aRet >>= nBin;
2367 14 : if ( nBin == -1 )
2368 14 : aRet <<= OUString( "[From printer settings]" );
2369 : else
2370 : {
2371 0 : SfxPrinter *pPrinter = pDoc->getIDocumentDeviceAccess().getPrinter( false );
2372 0 : OUString sTmp;
2373 0 : if (pPrinter )
2374 0 : sTmp = pPrinter->GetPaperBinName ( nBin );
2375 0 : aRet <<= sTmp;
2376 : }
2377 :
2378 14 : bDone = true;
2379 14 : break;
2380 : }
2381 : case FN_UNO_NUM_RULES: // special handling for a SvxNumRuleItem:
2382 : {
2383 36266 : const SwNumRule* pRule = rBase.getNewBase()->GetNumRule();
2384 : OSL_ENSURE(pRule, "Where is the NumRule?");
2385 36266 : uno::Reference< container::XIndexReplace > xRules = new SwXNumberingRules(*pRule, pDoc);
2386 :
2387 36266 : aRet.setValue(&xRules, cppu::UnoType<container::XIndexReplace>::get());
2388 36266 : bDone = true;
2389 36266 : break;
2390 : }
2391 : break;
2392 : case RES_PARATR_OUTLINELEVEL:
2393 : {
2394 : OSL_ENSURE( SFX_STYLE_FAMILY_PARA == eFamily, "only paras" );
2395 92 : int nLevel = rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel();
2396 92 : aRet <<= static_cast<sal_Int16>( nLevel );
2397 92 : bDone = true;
2398 92 : break;
2399 : }
2400 : case FN_UNO_FOLLOW_STYLE:
2401 : {
2402 4662 : OUString aString;
2403 4662 : SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
2404 4662 : aRet <<= aString;
2405 4662 : bDone = true;
2406 4662 : break;
2407 : }
2408 : case RES_PAGEDESC :
2409 : {
2410 8 : if (MID_PAGEDESC_PAGEDESCNAME != nMemberId)
2411 4 : break;
2412 : // special handling for RES_PAGEDESC
2413 : const SfxPoolItem* pItem;
2414 4 : if (SfxItemState::SET == rBase.GetItemSet().GetItemState(RES_PAGEDESC, true, &pItem))
2415 : {
2416 0 : const SwPageDesc* pDesc = ((const SwFmtPageDesc*)pItem)->GetPageDesc();
2417 0 : if(pDesc)
2418 : {
2419 0 : OUString aString;
2420 0 : SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
2421 0 : aRet <<= aString;
2422 : }
2423 :
2424 : }
2425 4 : bDone = true;
2426 4 : break;
2427 : }
2428 : case FN_UNO_IS_AUTO_UPDATE:
2429 : {
2430 546 : sal_Bool bAuto = sal_False;
2431 546 : if(SFX_STYLE_FAMILY_PARA == eFamily)
2432 516 : bAuto = rBase.getNewBase()->GetCollection()->IsAutoUpdateFmt();
2433 30 : else if(SFX_STYLE_FAMILY_FRAME == eFamily)
2434 30 : bAuto = rBase.getNewBase()->GetFrmFmt()->IsAutoUpdateFmt();
2435 546 : aRet.setValue(&bAuto, ::getBooleanCppuType());
2436 :
2437 546 : bDone = true;
2438 546 : break;
2439 : }
2440 : case FN_UNO_DISPLAY_NAME:
2441 : {
2442 5964 : aRet <<= rBase.getNewBase()->GetDisplayName();
2443 :
2444 5964 : bDone = true;
2445 5964 : break;
2446 : }
2447 : case FN_UNO_PARA_STYLE_CONDITIONS:
2448 : {
2449 : OSL_ENSURE(COND_COMMAND_COUNT == 28,
2450 : "invalid size of comman count?");
2451 4 : uno::Sequence< beans::NamedValue > aSeq(COND_COMMAND_COUNT);
2452 4 : beans::NamedValue *pSeq = aSeq.getArray();
2453 :
2454 4 : SwFmt *pFmt = ((SwDocStyleSheet*)pBase)->GetCollection();
2455 4 : const CommandStruct *pCmds = SwCondCollItem::GetCmds();
2456 116 : for (sal_uInt16 n = 0; n < COND_COMMAND_COUNT; ++n)
2457 : {
2458 112 : OUString aStyleName;
2459 :
2460 112 : const SwCollCondition* pCond = 0;
2461 448 : if( pFmt && RES_CONDTXTFMTCOLL == pFmt->Which() &&
2462 : 0 != ( pCond = ((SwConditionTxtFmtColl*)pFmt)->
2463 336 : HasCondition( SwCollCondition( 0, pCmds[n].nCnd, pCmds[n].nSubCond ) ) )
2464 112 : && pCond->GetTxtFmtColl() )
2465 : {
2466 : // get programmatic style name from UI style name
2467 0 : aStyleName = pCond->GetTxtFmtColl()->GetName();
2468 0 : SwStyleNameMapper::FillProgName(aStyleName, aStyleName, lcl_GetSwEnumFromSfxEnum ( eFamily ), true);
2469 : }
2470 :
2471 112 : pSeq[n].Name = GetCommandContextByIndex(n);
2472 112 : pSeq[n].Value <<= aStyleName;
2473 112 : }
2474 4 : aRet <<= aSeq;
2475 :
2476 4 : bDone = true;
2477 4 : break;
2478 : }
2479 : case FN_UNO_CATEGORY:
2480 : {
2481 516 : const sal_uInt16 nPoolId = rBase.getNewBase()->GetCollection()->GetPoolFmtId();
2482 516 : short nRet = -1;
2483 :
2484 516 : switch ( COLL_GET_RANGE_BITS & nPoolId )
2485 : {
2486 : case COLL_TEXT_BITS:
2487 198 : nRet = style::ParagraphStyleCategory::TEXT;
2488 198 : break;
2489 : case COLL_DOC_BITS:
2490 0 : nRet = style::ParagraphStyleCategory::CHAPTER;
2491 0 : break;
2492 : case COLL_LISTS_BITS:
2493 58 : nRet = style::ParagraphStyleCategory::LIST;
2494 58 : break;
2495 : case COLL_REGISTER_BITS:
2496 78 : nRet = style::ParagraphStyleCategory::INDEX;
2497 78 : break;
2498 : case COLL_EXTRA_BITS:
2499 98 : nRet = style::ParagraphStyleCategory::EXTRA;
2500 98 : break;
2501 : case COLL_HTML_BITS:
2502 0 : nRet = style::ParagraphStyleCategory::HTML;
2503 0 : break;
2504 : }
2505 :
2506 516 : aRet <<= nRet;
2507 516 : bDone = true;
2508 516 : break;
2509 : }
2510 : case SID_SWREGISTER_COLLECTION:
2511 : {
2512 14 : const SwPageDesc *pPageDesc = rBase.getNewBase()->GetPageDesc();
2513 14 : const SwTxtFmtColl* pCol = 0;
2514 14 : OUString aString;
2515 14 : if( pPageDesc )
2516 14 : pCol = pPageDesc->GetRegisterFmtColl();
2517 14 : if( pCol )
2518 : SwStyleNameMapper::FillProgName(
2519 0 : pCol->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true );
2520 14 : aRet <<= aString;
2521 14 : bDone = true;
2522 14 : break;
2523 : }
2524 : case RES_BACKGROUND:
2525 : {
2526 : //UUUU
2527 172 : const SfxItemSet& rSet = rBase.GetItemSet();
2528 172 : const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet, RES_BACKGROUND));
2529 :
2530 172 : if(!aOriginalBrushItem.QueryValue(aRet, nMemberId))
2531 : {
2532 : OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
2533 : }
2534 :
2535 172 : bDone = true;
2536 172 : break;
2537 : }
2538 : case OWN_ATTR_FILLBMP_MODE:
2539 : {
2540 : //UUUU
2541 4 : const SfxItemSet& rSet = rBase.GetItemSet();
2542 4 : const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH));
2543 4 : const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE));
2544 :
2545 4 : if( pTileItem && pTileItem->GetValue() )
2546 : {
2547 4 : aRet <<= drawing::BitmapMode_REPEAT;
2548 : }
2549 0 : else if( pStretchItem && pStretchItem->GetValue() )
2550 : {
2551 0 : aRet <<= drawing::BitmapMode_STRETCH;
2552 : }
2553 : else
2554 : {
2555 0 : aRet <<= drawing::BitmapMode_NO_REPEAT;
2556 : }
2557 :
2558 4 : bDone = true;
2559 4 : break;
2560 : }
2561 : default:
2562 : {
2563 : // nothing to do as default
2564 16058 : break;
2565 : }
2566 : }
2567 :
2568 64320 : if(!bDone)
2569 : {
2570 16062 : SfxItemSet& rSet = rBase.GetItemSet();
2571 16062 : rPropSet.getPropertyValue(rEntry, rSet, aRet);
2572 :
2573 : //UUUU
2574 16062 : if(rEntry.aType == ::cppu::UnoType<sal_Int16>::get() && rEntry.aType != aRet.getValueType())
2575 : {
2576 : // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
2577 1020 : sal_Int32 nValue = 0;
2578 1020 : if (aRet >>= nValue)
2579 56 : aRet <<= (sal_Int16)nValue;
2580 : }
2581 :
2582 : //UUUU check for needed metric translation
2583 16062 : if(rEntry.nMemberId & SFX_METRIC_ITEM)
2584 : {
2585 8 : bool bDoIt(true);
2586 :
2587 8 : if(XATTR_FILLBMP_SIZEX == rEntry.nWID || XATTR_FILLBMP_SIZEY == rEntry.nWID)
2588 : {
2589 : // exception: If these ItemTypes are used, do not convert when these are negative
2590 : // since this means they are intended as percent values
2591 8 : sal_Int32 nValue = 0;
2592 :
2593 8 : if(aRet >>= nValue)
2594 : {
2595 8 : bDoIt = nValue > 0;
2596 : }
2597 : }
2598 :
2599 8 : if(bDoIt && pDoc)
2600 : {
2601 0 : const SfxItemPool& rPool = pDoc->GetAttrPool();
2602 0 : const SfxMapUnit eMapUnit(rPool.GetMetric(rEntry.nWID));
2603 :
2604 0 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
2605 : {
2606 0 : SvxUnoConvertToMM(eMapUnit, aRet);
2607 : }
2608 : }
2609 : }
2610 : }
2611 : }
2612 : else
2613 : {
2614 0 : throw uno::RuntimeException();
2615 : }
2616 :
2617 81326 : return aRet;
2618 : }
2619 :
2620 65698 : uno::Sequence< uno::Any > SAL_CALL SwXStyle::GetPropertyValues_Impl(
2621 : const uno::Sequence< OUString > & rPropertyNames )
2622 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
2623 : {
2624 65698 : if ( !m_pDoc )
2625 0 : throw uno::RuntimeException();
2626 :
2627 65698 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2628 :
2629 65698 : switch(eFamily)
2630 : {
2631 23482 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2632 2050 : case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2633 0 : case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE ;break;
2634 37052 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2635 : default: ;
2636 : }
2637 :
2638 65698 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2639 65698 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2640 65698 : const OUString* pNames = rPropertyNames.getConstArray();
2641 65698 : uno::Sequence< uno::Any > aRet(rPropertyNames.getLength());
2642 65698 : uno::Any* pRet = aRet.getArray();
2643 131396 : SwStyleBase_Impl aBase(*m_pDoc, m_sStyleName, &GetDoc()->GetDfltTxtFmtColl()->GetAttrSet()); //UUUU add pDfltTxtFmtColl as parent
2644 65698 : SfxStyleSheetBase* pBase = 0;
2645 :
2646 139436 : for(sal_Int32 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
2647 : {
2648 73740 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName( pNames[nProp]);
2649 147480 : if(!pEntry ||
2650 144532 : (!bIsConditional && pNames[nProp] == UNO_NAME_PARA_STYLE_CONDITIONS))
2651 2 : throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
2652 :
2653 73738 : if(pBasePool)
2654 : {
2655 73738 : if(!pBase)
2656 : {
2657 65696 : const sal_uInt16 nSaveMask = pBasePool->GetSearchMask();
2658 65696 : pBasePool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
2659 65696 : pBase = pBasePool->Find(m_sStyleName);
2660 65696 : pBasePool->SetSearchMask(eFamily, nSaveMask );
2661 : }
2662 :
2663 73738 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, eFamily, GetDoc() );
2664 : }
2665 0 : else if(bIsDescriptor)
2666 : {
2667 0 : uno::Any *pAny = 0;
2668 0 : pPropImpl->GetProperty ( pNames[nProp], pAny );
2669 0 : if( !pAny )
2670 : {
2671 0 : bool bExcept = false;
2672 0 : switch( eFamily )
2673 : {
2674 : case SFX_STYLE_FAMILY_PSEUDO:
2675 0 : bExcept = true;
2676 0 : break;
2677 : case SFX_STYLE_FAMILY_PARA:
2678 : case SFX_STYLE_FAMILY_PAGE:
2679 0 : pPropImpl->GetProperty ( pNames[nProp], mxStyleData, pRet[ nProp ] );
2680 0 : break;
2681 : case SFX_STYLE_FAMILY_CHAR:
2682 : case SFX_STYLE_FAMILY_FRAME :
2683 : {
2684 0 : if (pEntry->nWID >= POOLATTR_BEGIN && pEntry->nWID < RES_UNKNOWNATR_END )
2685 : {
2686 : SwFmt * pFmt;
2687 0 : if ( eFamily == SFX_STYLE_FAMILY_CHAR )
2688 0 : pFmt = m_pDoc->GetDfltCharFmt();
2689 : else
2690 0 : pFmt = m_pDoc->GetDfltFrmFmt();
2691 0 : const SwAttrPool * pPool = pFmt->GetAttrSet().GetPool();
2692 0 : const SfxPoolItem & rItem = pPool->GetDefaultItem ( pEntry->nWID );
2693 0 : rItem.QueryValue ( pRet[nProp], pEntry->nMemberId );
2694 : }
2695 : else
2696 0 : bExcept = true;
2697 : }
2698 0 : break;
2699 :
2700 : default:
2701 : ;
2702 : }
2703 0 : if (bExcept )
2704 : {
2705 0 : uno::RuntimeException aExcept;
2706 0 : aExcept.Message = "No default value for: " + pNames[nProp];
2707 0 : throw aExcept;
2708 : }
2709 : }
2710 : else
2711 0 : pRet [ nProp ] = *pAny;
2712 : }
2713 : else
2714 0 : throw uno::RuntimeException();
2715 : }
2716 131392 : return aRet;
2717 : }
2718 :
2719 1080 : uno::Sequence< uno::Any > SwXStyle::getPropertyValues(
2720 : const uno::Sequence< OUString >& rPropertyNames ) throw(uno::RuntimeException, std::exception)
2721 : {
2722 1080 : SolarMutexGuard aGuard;
2723 1080 : uno::Sequence< uno::Any > aValues;
2724 :
2725 : // workaround for bad designed API
2726 : try
2727 : {
2728 1080 : aValues = GetPropertyValues_Impl( rPropertyNames );
2729 : }
2730 0 : catch (beans::UnknownPropertyException &)
2731 : {
2732 0 : throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
2733 : }
2734 0 : catch (lang::WrappedTargetException &)
2735 : {
2736 0 : throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
2737 : }
2738 :
2739 1080 : return aValues;
2740 : }
2741 :
2742 6 : void SwXStyle::addPropertiesChangeListener(
2743 : const uno::Sequence< OUString >& /*aPropertyNames*/,
2744 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2745 : throw(uno::RuntimeException, std::exception)
2746 : {
2747 6 : }
2748 :
2749 0 : void SwXStyle::removePropertiesChangeListener(
2750 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2751 : throw(uno::RuntimeException, std::exception)
2752 : {
2753 0 : }
2754 :
2755 0 : void SwXStyle::firePropertiesChangeEvent(
2756 : const uno::Sequence< OUString >& /*aPropertyNames*/,
2757 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
2758 : throw(uno::RuntimeException, std::exception)
2759 : {
2760 0 : }
2761 :
2762 579816 : void SwXStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
2763 : throw( beans::UnknownPropertyException,
2764 : beans::PropertyVetoException,
2765 : lang::IllegalArgumentException,
2766 : lang::WrappedTargetException,
2767 : uno::RuntimeException, std::exception)
2768 : {
2769 579816 : SolarMutexGuard aGuard;
2770 1159632 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2771 1159632 : const uno::Sequence<uno::Any> aValues(&rValue, 1);
2772 :
2773 1159632 : SetPropertyValues_Impl( aProperties, aValues );
2774 579288 : }
2775 :
2776 64618 : uno::Any SwXStyle::getPropertyValue(const OUString& rPropertyName)
2777 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
2778 : {
2779 64618 : SolarMutexGuard aGuard;
2780 129236 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
2781 129236 : return GetPropertyValues_Impl(aProperties).getConstArray()[0];
2782 :
2783 : }
2784 :
2785 0 : void SwXStyle::addPropertyChangeListener(const OUString& /*rPropertyName*/,
2786 : const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2787 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
2788 : {
2789 : OSL_FAIL("not implemented");
2790 0 : }
2791 :
2792 0 : void SwXStyle::removePropertyChangeListener(const OUString& /*rPropertyName*/,
2793 : const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2794 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
2795 : {
2796 : OSL_FAIL("not implemented");
2797 0 : }
2798 :
2799 0 : void SwXStyle::addVetoableChangeListener(const OUString& /*rPropertyName*/,
2800 : const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2801 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
2802 : {
2803 : OSL_FAIL("not implemented");
2804 0 : }
2805 :
2806 0 : void SwXStyle::removeVetoableChangeListener(const OUString& /*rPropertyName*/,
2807 : const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2808 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
2809 : {
2810 : OSL_FAIL("not implemented");
2811 0 : }
2812 :
2813 1730 : beans::PropertyState SwXStyle::getPropertyState(const OUString& rPropertyName)
2814 : throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
2815 : {
2816 1730 : SolarMutexGuard aGuard;
2817 3460 : uno::Sequence< OUString > aNames(1);
2818 1730 : OUString* pNames = aNames.getArray();
2819 1730 : pNames[0] = rPropertyName;
2820 3460 : uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
2821 3460 : return aStates.getConstArray()[0];
2822 : }
2823 :
2824 21434 : uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
2825 : const uno::Sequence< OUString >& rPropertyNames)
2826 : throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
2827 : {
2828 21434 : SolarMutexGuard aGuard;
2829 21434 : uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
2830 21434 : beans::PropertyState* pStates = aRet.getArray();
2831 :
2832 21434 : if(pBasePool)
2833 : {
2834 21434 : pBasePool->SetSearchMask(eFamily );
2835 21434 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
2836 : OSL_ENSURE(pBase, "where is the style?" );
2837 :
2838 21434 : if(pBase)
2839 : {
2840 21434 : const OUString* pNames = rPropertyNames.getConstArray();
2841 21434 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2842 21434 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
2843 :
2844 21434 : switch(eFamily)
2845 : {
2846 20072 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
2847 30 : case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE ;break;
2848 74 : case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
2849 2 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE ;break;
2850 : default: ;
2851 : }
2852 :
2853 21434 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
2854 21434 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
2855 21434 : const SfxItemSet& rSet = xStyle->GetItemSet();
2856 :
2857 3221416 : for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
2858 : {
2859 3199982 : const OUString sPropName = pNames[i];
2860 3199982 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
2861 3199982 : bool bDone(false);
2862 :
2863 3199982 : if(!pEntry)
2864 : {
2865 0 : throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
2866 : }
2867 :
2868 3199982 : if( FN_UNO_NUM_RULES == pEntry->nWID || FN_UNO_FOLLOW_STYLE == pEntry->nWID )
2869 : {
2870 : // handle NumRules first, done
2871 17842 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
2872 17842 : bDone = true;
2873 : }
2874 :
2875 : // allow to retarget the SfxItemSet working on, default correctly. Only
2876 : // use pSourceSet below this point (except in header/footer processing)
2877 3199982 : const SfxItemSet* pSourceSet = &rSet;
2878 :
2879 3199982 : if(!bDone)
2880 : {
2881 : // check for Header/Footer entry
2882 3182140 : const bool bHeader(SFX_STYLE_FAMILY_PAGE == eFamily && sPropName.startsWith("Header"));
2883 3182140 : const bool bFooter(SFX_STYLE_FAMILY_PAGE == eFamily && sPropName.startsWith("Footer"));
2884 :
2885 3182140 : if(bHeader || bFooter || sPropName == UNO_NAME_FIRST_IS_SHARED)
2886 : {
2887 : const SvxSetItem* pSetItem;
2888 :
2889 2908 : if (lcl_GetHeaderFooterItem(rSet, sPropName, bFooter, pSetItem))
2890 : {
2891 : // retarget the SfxItemSet to the HeaderFooter SfxSetItem's SfxItenSet
2892 200 : pSourceSet = &pSetItem->GetItemSet();
2893 : }
2894 : else
2895 : {
2896 : // if no SetItem, value is ambigous and we are done
2897 2708 : pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2898 2708 : bDone = true;
2899 : }
2900 : }
2901 : }
2902 :
2903 3199982 : if(!bDone && OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
2904 : {
2905 : //UUUU
2906 36740 : if(SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_STRETCH, false)
2907 18370 : || SfxItemState::SET == pSourceSet->GetItemState(XATTR_FILLBMP_TILE, false))
2908 : {
2909 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
2910 : }
2911 : else
2912 : {
2913 18370 : pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
2914 : }
2915 :
2916 18370 : bDone = true;
2917 : }
2918 :
2919 : //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
2920 : // as beans::PropertyState_DIRECT_VALUE to let users of this property call
2921 : // getPropertyValue where the member properties will be mapped from the
2922 : // fill attributes to the according SvxBrushItem entries
2923 9561026 : if(!bDone && RES_BACKGROUND == pEntry->nWID
2924 3292302 : && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet))
2925 : {
2926 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
2927 0 : bDone = true;
2928 : }
2929 :
2930 3199982 : if(!bDone)
2931 : {
2932 3161062 : pStates[i] = pPropSet->getPropertyState(*pEntry, *pSourceSet);
2933 :
2934 3161062 : if(SFX_STYLE_FAMILY_PAGE == eFamily && SID_ATTR_PAGE_SIZE == pEntry->nWID && beans::PropertyState_DIRECT_VALUE == pStates[i])
2935 : {
2936 158 : const SvxSizeItem& rSize = static_cast <const SvxSizeItem&>( rSet.Get(SID_ATTR_PAGE_SIZE));
2937 158 : sal_uInt8 nMemberId = pEntry->nMemberId & 0x7f;
2938 :
2939 316 : if( ( LONG_MAX == rSize.GetSize().Width() &&
2940 0 : (MID_SIZE_WIDTH == nMemberId ||
2941 316 : MID_SIZE_SIZE == nMemberId ) ) ||
2942 158 : ( LONG_MAX == rSize.GetSize().Height() &&
2943 : MID_SIZE_HEIGHT == nMemberId ) )
2944 : {
2945 0 : pStates[i] = beans::PropertyState_DEFAULT_VALUE;
2946 : }
2947 : }
2948 : }
2949 3221416 : }
2950 : }
2951 : else
2952 : {
2953 0 : throw uno::RuntimeException();
2954 : }
2955 : }
2956 : else
2957 : {
2958 0 : throw uno::RuntimeException();
2959 : }
2960 :
2961 21434 : return aRet;
2962 : }
2963 :
2964 131508 : void SwXStyle::setPropertyToDefault(const OUString& rPropertyName)
2965 : throw( beans::UnknownPropertyException, uno::RuntimeException, std::exception )
2966 : {
2967 131508 : const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
2968 149336 : setPropertiesToDefault ( aSequence );
2969 113680 : }
2970 :
2971 131516 : void SAL_CALL SwXStyle::setPropertiesToDefault( const uno::Sequence< OUString >& aPropertyNames )
2972 : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
2973 : {
2974 131516 : SolarMutexGuard aGuard;
2975 131516 : SwFmt *pTargetFmt = 0;
2976 :
2977 131516 : if(pBasePool)
2978 : {
2979 131516 : pBasePool->SetSearchMask(eFamily);
2980 131516 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
2981 : OSL_ENSURE(pBase, "Where is the style?");
2982 :
2983 131516 : if(pBase)
2984 : {
2985 131516 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
2986 131516 : switch(eFamily)
2987 : {
2988 : case SFX_STYLE_FAMILY_CHAR:
2989 5692 : pTargetFmt = xStyle->GetCharFmt();
2990 5692 : break;
2991 :
2992 : case SFX_STYLE_FAMILY_PARA:
2993 125820 : pTargetFmt = xStyle->GetCollection();
2994 125820 : break;
2995 :
2996 : case SFX_STYLE_FAMILY_FRAME:
2997 0 : pTargetFmt = xStyle->GetFrmFmt();
2998 0 : break;
2999 :
3000 : case SFX_STYLE_FAMILY_PAGE:
3001 : {
3002 2 : SwPageDesc *pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName());
3003 2 : if( pDesc )
3004 2 : pTargetFmt = &pDesc->GetMaster();
3005 2 : break;
3006 : }
3007 : case SFX_STYLE_FAMILY_PSEUDO:
3008 2 : break;
3009 : default: ;
3010 131516 : }
3011 : }
3012 : }
3013 :
3014 131516 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
3015 :
3016 131516 : switch(eFamily)
3017 : {
3018 125820 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3019 0 : case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3020 2 : case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3021 2 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
3022 : default: ;
3023 : }
3024 :
3025 131516 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3026 131516 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
3027 131516 : const OUString* pNames = aPropertyNames.getConstArray();
3028 :
3029 131516 : if(pTargetFmt)
3030 : {
3031 245200 : for(sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++)
3032 : {
3033 131514 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[nProp]);
3034 :
3035 131514 : if( !pEntry )
3036 : {
3037 0 : throw beans::UnknownPropertyException ( "Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3038 : }
3039 :
3040 131514 : if ( pEntry->nWID == FN_UNO_FOLLOW_STYLE || pEntry->nWID == FN_UNO_NUM_RULES )
3041 : {
3042 17828 : throw uno::RuntimeException ("Cannot reset: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3043 : }
3044 :
3045 113686 : if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
3046 : {
3047 0 : throw uno::RuntimeException("setPropertiesToDefault: property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3048 : }
3049 :
3050 113686 : if( pEntry->nWID == RES_PARATR_OUTLINELEVEL )
3051 : {
3052 50 : static_cast<SwTxtFmtColl*>(pTargetFmt)->DeleteAssignmentToListLevelOfOutlineStyle();
3053 : }
3054 : else
3055 : {
3056 113636 : pTargetFmt->ResetFmtAttr( pEntry->nWID );
3057 : }
3058 :
3059 113686 : if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID)
3060 : {
3061 : //UUUU
3062 0 : SwDoc* pDoc = pTargetFmt->GetDoc();
3063 0 : SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST);
3064 0 : aSet.SetParent(&pTargetFmt->GetAttrSet());
3065 :
3066 0 : aSet.ClearItem(XATTR_FILLBMP_STRETCH);
3067 0 : aSet.ClearItem(XATTR_FILLBMP_TILE);
3068 :
3069 0 : pTargetFmt->SetFmtAttr(aSet);
3070 : }
3071 : }
3072 : }
3073 2 : else if(bIsDescriptor)
3074 : {
3075 0 : for(sal_Int32 nProp = 0, nEnd = aPropertyNames.getLength(); nProp < nEnd; nProp++)
3076 : {
3077 0 : pPropImpl->ClearProperty(pNames[nProp]);
3078 : }
3079 131516 : }
3080 113688 : }
3081 :
3082 5538 : void SAL_CALL SwXStyle::setAllPropertiesToDefault( )
3083 : throw (uno::RuntimeException, std::exception)
3084 : {
3085 5538 : SolarMutexGuard aGuard;
3086 :
3087 5538 : if(pBasePool)
3088 : {
3089 5538 : pBasePool->SetSearchMask(eFamily);
3090 5538 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
3091 : OSL_ENSURE(pBase, "Where is the style?");
3092 :
3093 5538 : if(pBase)
3094 : {
3095 5538 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3096 5538 : SwFmt *pTargetFmt = 0;
3097 5538 : sal_uInt16 nPgDscPos = USHRT_MAX;
3098 5538 : switch(eFamily)
3099 : {
3100 : case SFX_STYLE_FAMILY_CHAR:
3101 1240 : pTargetFmt = xStyle->GetCharFmt();
3102 1240 : break;
3103 :
3104 : case SFX_STYLE_FAMILY_PARA:
3105 : {
3106 3390 : pTargetFmt = xStyle->GetCollection();
3107 3390 : if(xStyle->GetCollection())
3108 : {
3109 3390 : xStyle->GetCollection()->DeleteAssignmentToListLevelOfOutlineStyle();
3110 : }
3111 3390 : break;
3112 : }
3113 :
3114 : case SFX_STYLE_FAMILY_FRAME:
3115 238 : pTargetFmt = xStyle->GetFrmFmt();
3116 238 : break;
3117 :
3118 : case SFX_STYLE_FAMILY_PAGE:
3119 : {
3120 670 : SwPageDesc *pDesc = m_pDoc->FindPageDesc(xStyle->GetPageDesc()->GetName(), &nPgDscPos);
3121 670 : if( pDesc )
3122 : {
3123 670 : pTargetFmt = &pDesc->GetMaster();
3124 670 : pDesc->SetUseOn(nsUseOnPage::PD_ALL);
3125 : }
3126 670 : break;
3127 : }
3128 :
3129 : case SFX_STYLE_FAMILY_PSEUDO:
3130 0 : break;
3131 :
3132 : default: ;
3133 : }
3134 :
3135 5538 : if(pTargetFmt)
3136 : {
3137 5538 : if(USHRT_MAX != nPgDscPos)
3138 : {
3139 670 : SwPageDesc& rPageDesc = m_pDoc->GetPageDesc(nPgDscPos);
3140 670 : rPageDesc.ResetAllMasterAttr();
3141 :
3142 670 : SvxLRSpaceItem aLR(RES_LR_SPACE);
3143 670 : sal_Int32 nSize = GetMetricVal(CM_1) * 2;
3144 670 : aLR.SetLeft(nSize);
3145 670 : aLR.SetLeft(nSize);
3146 1340 : SvxULSpaceItem aUL(RES_UL_SPACE);
3147 670 : aUL.SetUpper(static_cast <sal_uInt16> (nSize));
3148 670 : aUL.SetLower(static_cast <sal_uInt16> (nSize));
3149 670 : pTargetFmt->SetFmtAttr(aLR);
3150 670 : pTargetFmt->SetFmtAttr(aUL);
3151 670 : SwPageDesc* pStdPgDsc = m_pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD);
3152 1340 : SwFmtFrmSize aFrmSz(ATT_FIX_SIZE);
3153 :
3154 670 : if(RES_POOLPAGE_STANDARD == rPageDesc.GetPoolFmtId())
3155 : {
3156 316 : if(m_pDoc->getIDocumentDeviceAccess().getPrinter(false))
3157 : {
3158 : const Size aPhysSize( SvxPaperInfo::GetPaperSize(
3159 18 : static_cast<Printer*>(m_pDoc->getIDocumentDeviceAccess().getPrinter(false))));
3160 18 : aFrmSz.SetSize(aPhysSize);
3161 : }
3162 : else
3163 : {
3164 298 : aFrmSz.SetSize(SvxPaperInfo::GetDefaultPaperSize());
3165 : }
3166 :
3167 : }
3168 : else
3169 : {
3170 354 : aFrmSz = pStdPgDsc->GetMaster().GetFrmSize();
3171 : }
3172 :
3173 670 : if(pStdPgDsc->GetLandscape())
3174 : {
3175 0 : SwTwips nTmp = aFrmSz.GetHeight();
3176 0 : aFrmSz.SetHeight(aFrmSz.GetWidth());
3177 0 : aFrmSz.SetWidth(nTmp);
3178 : }
3179 :
3180 1340 : pTargetFmt->SetFmtAttr( aFrmSz );
3181 : }
3182 : else
3183 : {
3184 4868 : pTargetFmt->ResetAllFmtAttr();
3185 : }
3186 :
3187 5538 : if(USHRT_MAX != nPgDscPos)
3188 : {
3189 670 : m_pDoc->ChgPageDesc(nPgDscPos, m_pDoc->GetPageDesc(nPgDscPos));
3190 : }
3191 5538 : }
3192 : }
3193 : else
3194 : {
3195 0 : throw uno::RuntimeException();
3196 : }
3197 : }
3198 0 : else if ( bIsDescriptor )
3199 : {
3200 0 : pPropImpl->ClearAllProperties();
3201 : }
3202 : else
3203 : {
3204 0 : throw uno::RuntimeException();
3205 5538 : }
3206 5538 : }
3207 :
3208 8 : uno::Sequence< uno::Any > SAL_CALL SwXStyle::getPropertyDefaults( const uno::Sequence< OUString >& aPropertyNames )
3209 : throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
3210 : {
3211 8 : SolarMutexGuard aGuard;
3212 8 : sal_Int32 nCount = aPropertyNames.getLength();
3213 :
3214 8 : uno::Sequence < uno::Any > aRet(nCount);
3215 :
3216 8 : if(nCount)
3217 : {
3218 8 : if(pBasePool)
3219 : {
3220 8 : pBasePool->SetSearchMask(eFamily);
3221 8 : SfxStyleSheetBase* pBase = pBasePool->Find(m_sStyleName);
3222 : OSL_ENSURE(pBase, "Doesn't seem to be a style!");
3223 :
3224 8 : if(pBase)
3225 : {
3226 8 : rtl::Reference< SwDocStyleSheet > xStyle(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
3227 8 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_STYLE;
3228 8 : switch(eFamily)
3229 : {
3230 4 : case SFX_STYLE_FAMILY_PARA : nPropSetId = bIsConditional ? PROPERTY_MAP_CONDITIONAL_PARA_STYLE : PROPERTY_MAP_PARA_STYLE; break;
3231 0 : case SFX_STYLE_FAMILY_FRAME : nPropSetId = PROPERTY_MAP_FRAME_STYLE; break;
3232 2 : case SFX_STYLE_FAMILY_PAGE : nPropSetId = PROPERTY_MAP_PAGE_STYLE; break;
3233 0 : case SFX_STYLE_FAMILY_PSEUDO: nPropSetId = PROPERTY_MAP_NUM_STYLE; break;
3234 : default: ;
3235 : }
3236 8 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
3237 8 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3238 :
3239 8 : const SfxItemSet &rSet = xStyle->GetItemSet(), *pParentSet = rSet.GetParent();
3240 8 : const OUString *pNames = aPropertyNames.getConstArray();
3241 8 : uno::Any *pRet = aRet.getArray();
3242 :
3243 1034 : for(sal_Int32 i = 0; i < nCount; i++)
3244 : {
3245 1026 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(pNames[i]);
3246 :
3247 1026 : if(!pEntry)
3248 : {
3249 0 : throw beans::UnknownPropertyException("Unknown property: " + pNames[i], static_cast < cppu::OWeakObject * >(this));
3250 : }
3251 :
3252 1026 : if (pEntry->nWID >= RES_UNKNOWNATR_END)
3253 : {
3254 : // these cannot be in an item set, especially not the
3255 : // parent set, so the default value is void
3256 182 : continue;
3257 : }
3258 :
3259 844 : if(pParentSet)
3260 : {
3261 844 : aSwMapProvider.GetPropertySet(nPropSetId)->getPropertyValue(pNames[i], *pParentSet, pRet[i]);
3262 : }
3263 0 : else if(pEntry->nWID != rSet.GetPool()->GetSlotId(pEntry->nWID))
3264 : {
3265 0 : const SfxPoolItem& rItem = rSet.GetPool()->GetDefaultItem(pEntry->nWID);
3266 :
3267 0 : rItem.QueryValue(pRet[i], pEntry->nMemberId);
3268 : }
3269 8 : }
3270 : }
3271 : else
3272 : {
3273 0 : throw uno::RuntimeException();
3274 : }
3275 : }
3276 : else
3277 : {
3278 0 : throw uno::RuntimeException();
3279 : }
3280 : }
3281 8 : return aRet;
3282 : }
3283 :
3284 0 : uno::Any SwXStyle::getPropertyDefault(const OUString& rPropertyName)
3285 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
3286 : {
3287 0 : const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
3288 0 : return getPropertyDefaults ( aSequence ).getConstArray()[0];
3289 : }
3290 :
3291 394744 : void SwXStyle::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
3292 : {
3293 394744 : const SfxSimpleHint* pHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
3294 394744 : if( pHint )
3295 : {
3296 56 : if(( pHint->GetId() & SFX_HINT_DYING ) || ( pHint->GetId() & SFX_STYLESHEET_ERASED))
3297 : {
3298 56 : pBasePool = 0;
3299 56 : EndListening(rBC);
3300 : }
3301 0 : else if( pHint->GetId() &(SFX_STYLESHEET_CHANGED|SFX_STYLESHEET_ERASED) )
3302 : {
3303 0 : ((SfxStyleSheetBasePool&)rBC).SetSearchMask(eFamily);
3304 0 : SfxStyleSheetBase* pOwnBase = ((SfxStyleSheetBasePool&)rBC).Find(m_sStyleName);
3305 0 : if(!pOwnBase)
3306 : {
3307 0 : EndListening(rBC);
3308 0 : Invalidate();
3309 : }
3310 : }
3311 : }
3312 394744 : }
3313 :
3314 0 : void SwXStyle::Invalidate()
3315 : {
3316 0 : m_sStyleName = OUString();
3317 0 : pBasePool = 0;
3318 0 : m_pDoc = 0;
3319 0 : mxStyleData.clear();
3320 0 : mxStyleFamily.clear();
3321 0 : }
3322 :
3323 9190 : SwXPageStyle::SwXPageStyle(SfxStyleSheetBasePool& rPool,
3324 : SwDocShell* pDocSh, SfxStyleFamily eFam,
3325 : const OUString& rStyleName):
3326 9190 : SwXStyle(rPool, eFam, pDocSh->GetDoc(), rStyleName)
3327 : {
3328 :
3329 9190 : }
3330 :
3331 650 : SwXPageStyle::SwXPageStyle(SwDocShell* pDocSh) :
3332 650 : SwXStyle(pDocSh->GetDoc(), SFX_STYLE_FAMILY_PAGE)
3333 : {
3334 650 : }
3335 :
3336 19680 : SwXPageStyle::~SwXPageStyle()
3337 : {
3338 :
3339 19680 : }
3340 :
3341 8108 : static void lcl_putItemToSet(const SvxSetItem* pSetItem, const SfxItemPropertySet& rPropSet, const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rVal, SwStyleBase_Impl& rBaseImpl, SfxStyleSheetBasePool* pPool, SwDoc *pDoc, SfxStyleFamily eFamily)
3342 : {
3343 : // create a new SvxSetItem and get it's ItemSet as new target
3344 8108 : SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone());
3345 8108 : SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
3346 :
3347 : // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
3348 8108 : rSetSet.SetParent(&pDoc->GetDfltFrmFmt()->GetAttrSet());
3349 :
3350 : // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the
3351 : // default method to set the property
3352 8108 : SfxItemSet* pRememberItemSet = rBaseImpl.replaceItemSet(&rSetSet);
3353 8108 : lcl_SetStyleProperty(rEntry, rPropSet, rVal, rBaseImpl, pPool, pDoc, eFamily);
3354 8108 : rBaseImpl.replaceItemSet(pRememberItemSet);
3355 :
3356 : // reset paret at ItemSet from SetItem
3357 8108 : rSetSet.SetParent(0);
3358 :
3359 : // set the new SvxSetItem at the real target and delete it
3360 8108 : rBaseImpl.GetItemSet().Put(*pNewSetItem);
3361 8108 : delete pNewSetItem;
3362 8108 : }
3363 :
3364 11532 : void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
3365 : const uno::Sequence< OUString >& rPropertyNames,
3366 : const uno::Sequence< uno::Any >& rValues )
3367 : throw (beans::UnknownPropertyException, beans::PropertyVetoException,
3368 : lang::IllegalArgumentException, lang::WrappedTargetException,
3369 : uno::RuntimeException, std::exception)
3370 : {
3371 11532 : if(!GetDoc())
3372 0 : throw uno::RuntimeException();
3373 :
3374 11532 : if(rPropertyNames.getLength() != rValues.getLength())
3375 0 : throw lang::IllegalArgumentException();
3376 :
3377 11532 : const OUString* pNames = rPropertyNames.getConstArray();
3378 11532 : const uno::Any* pValues = rValues.getConstArray();
3379 11532 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3380 11532 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3381 11532 : SwStyleBase_Impl aBaseImpl(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent
3382 11532 : if(GetBasePool())
3383 : {
3384 10532 : const sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3385 10532 : GetBasePool()->SetSearchMask(GetFamily());
3386 10532 : SfxStyleSheetBase* pBase = GetBasePool()->Find(GetStyleName());
3387 10532 : GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3388 : OSL_ENSURE(pBase, "where is the style?" );
3389 10532 : if(pBase)
3390 : {
3391 10532 : aBaseImpl.setNewBase(new SwDocStyleSheet(*(SwDocStyleSheet*)pBase));
3392 : }
3393 : else
3394 : {
3395 0 : throw uno::RuntimeException();
3396 : }
3397 : }
3398 :
3399 129908 : for(sal_Int16 nProp = 0; nProp < rPropertyNames.getLength(); nProp++)
3400 : {
3401 118390 : const OUString& rPropName = pNames[nProp];
3402 118390 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName);
3403 :
3404 118390 : if (!pEntry)
3405 : {
3406 10 : throw beans::UnknownPropertyException("Unknown property: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3407 : }
3408 :
3409 118380 : if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3410 : {
3411 4 : throw beans::PropertyVetoException ("Property is read-only: " + pNames[nProp], static_cast < cppu::OWeakObject * > ( this ) );
3412 : }
3413 :
3414 118376 : if(GetBasePool())
3415 : {
3416 117376 : switch(pEntry->nWID)
3417 : {
3418 : case SID_ATTR_PAGE_ON:
3419 : case RES_BACKGROUND:
3420 : case RES_BOX:
3421 : case RES_LR_SPACE:
3422 : case RES_SHADOW:
3423 : case RES_UL_SPACE:
3424 : case SID_ATTR_PAGE_DYNAMIC:
3425 : case SID_ATTR_PAGE_SHARED:
3426 : case SID_ATTR_PAGE_SHARED_FIRST:
3427 : case SID_ATTR_PAGE_SIZE:
3428 : case RES_HEADER_FOOTER_EAT_SPACING:
3429 : {
3430 : // these entries are used in Header, Footer and (partially) in the PageStyle itself.
3431 : // Check for Header/Footer entry
3432 67626 : const bool bHeader(rPropName.startsWith("Header"));
3433 67626 : const bool bFooter(rPropName.startsWith("Footer"));
3434 :
3435 67626 : if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED)
3436 : {
3437 : // it is a Header/Footer entry, access the SvxSetItem containing it's information
3438 37096 : const SvxSetItem* pSetItem = 0;
3439 37096 : if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(),
3440 37096 : rPropName, bFooter, pSetItem))
3441 : {
3442 8106 : lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3443 :
3444 8106 : if (pEntry->nWID == SID_ATTR_PAGE_SHARED_FIRST)
3445 : {
3446 : // Need to add this to the other as well
3447 32 : if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(
3448 : bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
3449 32 : false, (const SfxPoolItem**)&pSetItem))
3450 : {
3451 2 : lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3452 : }
3453 : }
3454 : }
3455 28990 : else if(pEntry->nWID == SID_ATTR_PAGE_ON)
3456 : {
3457 2342 : bool bVal = *(sal_Bool*)pValues[nProp].getValue();
3458 :
3459 2342 : if(bVal)
3460 : {
3461 : // Header/footer gets switched on, create defauts and the needed SfxSetItem
3462 2330 : SfxItemSet aTempSet(*aBaseImpl.GetItemSet().GetPool(),
3463 : RES_FRMATR_BEGIN,RES_FRMATR_END - 1, // [82
3464 :
3465 : //UUUU FillAttribute support
3466 : XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014
3467 :
3468 : SID_ATTR_BORDER_INNER,SID_ATTR_BORDER_INNER, // [10023
3469 : SID_ATTR_PAGE_SIZE,SID_ATTR_PAGE_SIZE, // [10051
3470 : SID_ATTR_PAGE_ON,SID_ATTR_PAGE_SHARED, // [10060
3471 : SID_ATTR_PAGE_SHARED_FIRST,SID_ATTR_PAGE_SHARED_FIRST,
3472 2330 : 0);
3473 :
3474 : //UUUU set correct parent to get the XFILL_NONE FillStyle as needed
3475 2330 : aTempSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet());
3476 :
3477 2330 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_ON, true));
3478 2330 : aTempSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(MM50, MM50)));
3479 2330 : aTempSet.Put(SvxLRSpaceItem(RES_LR_SPACE));
3480 2330 : aTempSet.Put(SvxULSpaceItem(RES_UL_SPACE));
3481 2330 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED, true));
3482 2330 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_SHARED_FIRST, true));
3483 2330 : aTempSet.Put(SfxBoolItem(SID_ATTR_PAGE_DYNAMIC, true));
3484 :
3485 4660 : SvxSetItem aNewSetItem(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, aTempSet);
3486 4660 : aBaseImpl.GetItemSet().Put(aNewSetItem);
3487 : }
3488 : }
3489 : }
3490 : else
3491 : {
3492 30530 : switch(pEntry->nWID)
3493 : {
3494 : case SID_ATTR_PAGE_DYNAMIC:
3495 : case SID_ATTR_PAGE_SHARED:
3496 : case SID_ATTR_PAGE_SHARED_FIRST:
3497 : case SID_ATTR_PAGE_ON:
3498 : case RES_HEADER_FOOTER_EAT_SPACING:
3499 : {
3500 : // these slots are exclusive to Header/Footer, thus this is an error
3501 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3502 : break;
3503 : }
3504 : default:
3505 : {
3506 : // part of PageStyle, fallback to default
3507 30530 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3508 : }
3509 : }
3510 : }
3511 67626 : break;
3512 : }
3513 :
3514 : case XATTR_FILLBMP_SIZELOG:
3515 : case XATTR_FILLBMP_TILEOFFSETX:
3516 : case XATTR_FILLBMP_TILEOFFSETY:
3517 : case XATTR_FILLBMP_POSOFFSETX:
3518 : case XATTR_FILLBMP_POSOFFSETY:
3519 : case XATTR_FILLBMP_POS:
3520 : case XATTR_FILLBMP_SIZEX:
3521 : case XATTR_FILLBMP_SIZEY:
3522 : case XATTR_FILLBMP_STRETCH:
3523 : case XATTR_FILLBMP_TILE:
3524 : case OWN_ATTR_FILLBMP_MODE:
3525 : case XATTR_FILLCOLOR:
3526 : case XATTR_FILLBACKGROUND:
3527 : case XATTR_FILLBITMAP:
3528 : case XATTR_GRADIENTSTEPCOUNT:
3529 : case XATTR_FILLGRADIENT:
3530 : case XATTR_FILLHATCH:
3531 : case XATTR_FILLSTYLE:
3532 : case XATTR_FILLTRANSPARENCE:
3533 : case XATTR_FILLFLOATTRANSPARENCE:
3534 : case XATTR_SECONDARYFILLCOLOR:
3535 : {
3536 : // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle
3537 : // itself, so decide what to do using the name
3538 0 : const bool bHeader(rPropName.startsWith("Header"));
3539 0 : const bool bFooter(rPropName.startsWith("Footer"));
3540 :
3541 0 : if (bHeader || bFooter)
3542 : {
3543 0 : const SvxSetItem* pSetItem = 0;
3544 :
3545 0 : if(SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, (const SfxPoolItem**)&pSetItem))
3546 : {
3547 : // create a new SvxSetItem and get it's ItemSet as new target
3548 0 : SvxSetItem* pNewSetItem = static_cast< SvxSetItem* >(pSetItem->Clone());
3549 0 : SfxItemSet& rSetSet = pNewSetItem->GetItemSet();
3550 :
3551 : // set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
3552 0 : rSetSet.SetParent(&GetDoc()->GetDfltFrmFmt()->GetAttrSet());
3553 :
3554 : // replace the used SfxItemSet at the SwStyleBase_Impl temporarily and use the
3555 : // default method to set the property
3556 0 : SfxItemSet* pRememberItemSet = aBaseImpl.replaceItemSet(&rSetSet);
3557 0 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3558 0 : aBaseImpl.replaceItemSet(pRememberItemSet);
3559 :
3560 : // reset paret at ItemSet from SetItem
3561 0 : rSetSet.SetParent(0);
3562 :
3563 : // set the new SvxSetItem at the real target and delete it
3564 0 : aBaseImpl.GetItemSet().Put(*pNewSetItem);
3565 0 : delete pNewSetItem;
3566 0 : }
3567 : }
3568 : else
3569 : {
3570 : // part of PageStyle, fallback to default
3571 0 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3572 : }
3573 :
3574 0 : break;
3575 : }
3576 : case FN_PARAM_FTN_INFO :
3577 : {
3578 8538 : const SfxPoolItem& rItem = aBaseImpl.GetItemSet().Get(FN_PARAM_FTN_INFO);
3579 8538 : SfxPoolItem* pNewFtnItem = rItem.Clone();
3580 8538 : bool bPut = pNewFtnItem->PutValue(pValues[nProp], pEntry->nMemberId);
3581 8538 : aBaseImpl.GetItemSet().Put(*pNewFtnItem);
3582 8538 : delete pNewFtnItem;
3583 8538 : if(!bPut)
3584 0 : throw lang::IllegalArgumentException();
3585 8538 : break;
3586 : }
3587 : case FN_UNO_HEADER :
3588 : case FN_UNO_HEADER_LEFT :
3589 : case FN_UNO_HEADER_RIGHT :
3590 : case FN_UNO_HEADER_FIRST :
3591 : case FN_UNO_FOOTER :
3592 : case FN_UNO_FOOTER_LEFT :
3593 : case FN_UNO_FOOTER_RIGHT :
3594 : case FN_UNO_FOOTER_FIRST :
3595 : {
3596 0 : throw lang::IllegalArgumentException();
3597 : break;
3598 : }
3599 : default:
3600 : {
3601 : //UUUU
3602 41212 : lcl_SetStyleProperty(*pEntry, *pPropSet, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
3603 41212 : break;
3604 : }
3605 : }
3606 : }
3607 1000 : else if(IsDescriptor())
3608 : {
3609 1000 : if(!GetPropImpl()->SetProperty(rPropName, pValues[nProp]))
3610 0 : throw lang::IllegalArgumentException();
3611 : }
3612 : else
3613 : {
3614 0 : throw uno::RuntimeException();
3615 : }
3616 : }
3617 :
3618 11518 : if(aBaseImpl.HasItemSet())
3619 : {
3620 10518 : ::sw::UndoGuard const undoGuard(GetDoc()->GetIDocumentUndoRedo());
3621 :
3622 10518 : if (undoGuard.UndoWasEnabled())
3623 : {
3624 : // Fix i64460: as long as Undo of page styles with header/footer causes trouble...
3625 528 : GetDoc()->GetIDocumentUndoRedo().DelAllUndoObj();
3626 : }
3627 :
3628 10518 : aBaseImpl.getNewBase()->SetItemSet(aBaseImpl.GetItemSet());
3629 11532 : }
3630 11518 : }
3631 :
3632 4812 : void SwXPageStyle::setPropertyValues(
3633 : const uno::Sequence< OUString >& rPropertyNames,
3634 : const uno::Sequence< uno::Any >& rValues )
3635 : throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
3636 : {
3637 4812 : SolarMutexGuard aGuard;
3638 :
3639 : // workaround for bad designed API
3640 : try
3641 : {
3642 4812 : SetPropertyValues_Impl( rPropertyNames, rValues );
3643 : }
3644 0 : catch (const beans::UnknownPropertyException &rException)
3645 : {
3646 : // wrap the original (here not allowed) exception in
3647 : // a lang::WrappedTargetException that gets thrown instead.
3648 0 : lang::WrappedTargetException aWExc;
3649 0 : aWExc.TargetException <<= rException;
3650 0 : throw aWExc;
3651 4812 : }
3652 4812 : }
3653 :
3654 : static uno::Reference<text::XText>
3655 3552 : lcl_makeHeaderFooter(
3656 : const sal_uInt16 nRes, const bool bHeader, SwFrmFmt const*const pFrmFmt)
3657 : {
3658 3552 : if (!pFrmFmt) { return 0; }
3659 :
3660 3552 : const SfxItemSet& rSet = pFrmFmt->GetAttrSet();
3661 : const SfxPoolItem* pItem;
3662 3552 : if (SfxItemState::SET == rSet.GetItemState(nRes, true, &pItem))
3663 : {
3664 : SwFrmFmt *const pHeadFootFmt = (bHeader)
3665 : ? static_cast<SwFmtHeader*>(const_cast<SfxPoolItem*>(pItem))->
3666 1670 : GetHeaderFmt()
3667 : : static_cast<SwFmtFooter*>(const_cast<SfxPoolItem*>(pItem))->
3668 4998 : GetFooterFmt();
3669 3328 : if (pHeadFootFmt)
3670 : {
3671 2764 : return SwXHeadFootText::CreateXHeadFootText(*pHeadFootFmt, bHeader);
3672 : }
3673 : }
3674 788 : return 0;
3675 : }
3676 :
3677 18240 : uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
3678 : const uno::Sequence< OUString >& rPropertyNames )
3679 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
3680 : {
3681 18240 : if(!GetDoc())
3682 0 : throw uno::RuntimeException();
3683 :
3684 18240 : sal_Int32 nLength = rPropertyNames.getLength();
3685 18240 : const OUString* pNames = rPropertyNames.getConstArray();
3686 18240 : uno::Sequence< uno::Any > aRet ( nLength );
3687 :
3688 18240 : uno::Any* pRet = aRet.getArray();
3689 18240 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PAGE_STYLE);
3690 18240 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
3691 36480 : SwStyleBase_Impl aBase(*GetDoc(), GetStyleName(), &GetDoc()->GetDfltFrmFmt()->GetAttrSet()); //UUUU add pDfltFrmFmt as parent
3692 18240 : SfxStyleSheetBase* pBase = 0;
3693 :
3694 38102 : for(sal_Int32 nProp = 0; nProp < nLength; nProp++)
3695 : {
3696 19862 : const OUString& rPropName = pNames[nProp];
3697 19862 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName);
3698 :
3699 19862 : if (!pEntry)
3700 : {
3701 0 : throw beans::UnknownPropertyException("Unknown property: " + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3702 : }
3703 :
3704 19862 : if(GetBasePool())
3705 : {
3706 19862 : if(!pBase)
3707 : {
3708 18240 : const sal_uInt16 nSaveMask = GetBasePool()->GetSearchMask();
3709 18240 : GetBasePool()->SetSearchMask(GetFamily(), SFXSTYLEBIT_ALL );
3710 18240 : pBase = GetBasePool()->Find(GetStyleName());
3711 18240 : GetBasePool()->SetSearchMask(GetFamily(), nSaveMask );
3712 : }
3713 :
3714 19862 : sal_uInt16 nRes = 0;
3715 19862 : bool bLeft = false;
3716 19862 : bool bFirst = false;
3717 19862 : const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
3718 :
3719 19862 : switch(pEntry->nWID)
3720 : {
3721 : case SID_ATTR_PAGE_ON:
3722 : case RES_BACKGROUND:
3723 : case RES_BOX:
3724 : case RES_LR_SPACE:
3725 : case RES_SHADOW:
3726 : case RES_UL_SPACE:
3727 : case SID_ATTR_PAGE_DYNAMIC:
3728 : case SID_ATTR_PAGE_SHARED:
3729 : case SID_ATTR_PAGE_SHARED_FIRST:
3730 : case SID_ATTR_PAGE_SIZE:
3731 : case RES_HEADER_FOOTER_EAT_SPACING:
3732 : {
3733 : // These slots are used for Header, Footer and (partially) for PageStyle directly.
3734 : // Check for Header/Footer entry
3735 12174 : const bool bHeader(rPropName.startsWith("Header"));
3736 12174 : const bool bFooter(rPropName.startsWith("Footer"));
3737 :
3738 12174 : if(bHeader || bFooter || rPropName == UNO_NAME_FIRST_IS_SHARED)
3739 : {
3740 : // slot is a Header/Footer slot
3741 10958 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3742 10958 : const SfxItemSet& rSet = xStyle->GetItemSet();
3743 : const SvxSetItem* pSetItem;
3744 :
3745 10958 : if (lcl_GetHeaderFooterItem(rSet, rPropName, bFooter, pSetItem))
3746 : {
3747 : // get from SfxItemSet of the corresponding SfxSetItem
3748 2832 : const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3749 2832 : SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet));
3750 2832 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3751 2832 : aBase.replaceItemSet(pRememberItemSet);
3752 : }
3753 8126 : else if(pEntry->nWID == SID_ATTR_PAGE_ON)
3754 : {
3755 : // header/footer is not available, thus off. Default is sal_False, though
3756 7810 : sal_Bool bRet = sal_False;
3757 7810 : pRet[nProp].setValue(&bRet, ::getCppuBooleanType());
3758 10958 : }
3759 : }
3760 : else
3761 : {
3762 1216 : switch(pEntry->nWID)
3763 : {
3764 : case SID_ATTR_PAGE_DYNAMIC:
3765 : case SID_ATTR_PAGE_SHARED:
3766 : case SID_ATTR_PAGE_SHARED_FIRST:
3767 : case SID_ATTR_PAGE_ON:
3768 : case RES_HEADER_FOOTER_EAT_SPACING:
3769 : {
3770 : // these slots are exclusive to Header/Footer, thus this is an error
3771 0 : throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropName, static_cast < cppu::OWeakObject * > ( this ) );
3772 : break;
3773 : }
3774 : default:
3775 : {
3776 : // part of PageStyle, fallback to default
3777 1216 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3778 : }
3779 : }
3780 : }
3781 :
3782 12174 : break;
3783 : }
3784 :
3785 : case XATTR_FILLBMP_SIZELOG:
3786 : case XATTR_FILLBMP_TILEOFFSETX:
3787 : case XATTR_FILLBMP_TILEOFFSETY:
3788 : case XATTR_FILLBMP_POSOFFSETX:
3789 : case XATTR_FILLBMP_POSOFFSETY:
3790 : case XATTR_FILLBMP_POS:
3791 : case XATTR_FILLBMP_SIZEX:
3792 : case XATTR_FILLBMP_SIZEY:
3793 : case XATTR_FILLBMP_STRETCH:
3794 : case XATTR_FILLBMP_TILE:
3795 : case OWN_ATTR_FILLBMP_MODE:
3796 : case XATTR_FILLCOLOR:
3797 : case XATTR_FILLBACKGROUND:
3798 : case XATTR_FILLBITMAP:
3799 : case XATTR_GRADIENTSTEPCOUNT:
3800 : case XATTR_FILLGRADIENT:
3801 : case XATTR_FILLHATCH:
3802 : case XATTR_FILLSTYLE:
3803 : case XATTR_FILLTRANSPARENCE:
3804 : case XATTR_FILLFLOATTRANSPARENCE:
3805 : case XATTR_SECONDARYFILLCOLOR:
3806 : {
3807 : // This DrawingLayer FillStyle attributes can be part of Header, Footer and PageStyle
3808 : // itself, so decide what to do using the name
3809 0 : const bool bHeader(rPropName.startsWith("Header"));
3810 0 : const bool bFooter(rPropName.startsWith("Footer"));
3811 :
3812 0 : if (bHeader || bFooter)
3813 : {
3814 0 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3815 0 : const SfxItemSet& rSet = xStyle->GetItemSet();
3816 : const SvxSetItem* pSetItem;
3817 0 : if(SfxItemState::SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, (const SfxPoolItem**)&pSetItem))
3818 : {
3819 : // set at SfxItemSet of the corresponding SfxSetItem
3820 0 : const SfxItemSet& rSetSet = pSetItem->GetItemSet();
3821 0 : SfxItemSet* pRememberItemSet = aBase.replaceItemSet(&const_cast< SfxItemSet& >(rSetSet));
3822 0 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3823 0 : aBase.replaceItemSet(pRememberItemSet);
3824 0 : }
3825 : }
3826 : else
3827 : {
3828 : // part of PageStyle, fallback to default
3829 0 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3830 : }
3831 :
3832 0 : break;
3833 : }
3834 :
3835 : case FN_UNO_HEADER:
3836 : case FN_UNO_HEADER_LEFT:
3837 : case FN_UNO_HEADER_FIRST:
3838 : case FN_UNO_HEADER_RIGHT:
3839 : case FN_UNO_FOOTER:
3840 : case FN_UNO_FOOTER_LEFT:
3841 : case FN_UNO_FOOTER_FIRST:
3842 : case FN_UNO_FOOTER_RIGHT:
3843 : {
3844 : //UUUU cleanups for readability (undos removed, rearranged)
3845 3552 : bool bHeader(false);
3846 :
3847 3552 : switch(pEntry->nWID)
3848 : {
3849 1396 : case FN_UNO_HEADER: bHeader = true; nRes = RES_HEADER; break;
3850 222 : case FN_UNO_HEADER_LEFT: bHeader = true; nRes = RES_HEADER; bLeft = true; break;
3851 158 : case FN_UNO_HEADER_FIRST: bHeader = true; nRes = RES_HEADER; bFirst = true; break;
3852 6 : case FN_UNO_HEADER_RIGHT: bHeader = true; nRes = RES_HEADER; break;
3853 1400 : case FN_UNO_FOOTER: bHeader = false; nRes = RES_FOOTER; break;
3854 210 : case FN_UNO_FOOTER_LEFT: bHeader = false; nRes = RES_FOOTER; bLeft = true; break;
3855 156 : case FN_UNO_FOOTER_FIRST: bHeader = false; nRes = RES_FOOTER; bFirst = true; break;
3856 4 : case FN_UNO_FOOTER_RIGHT: bHeader = false; nRes = RES_FOOTER; break;
3857 0 : default: break;
3858 : }
3859 :
3860 3552 : const SwPageDesc& rDesc = aBase.GetOldPageDesc();
3861 3552 : const SwFrmFmt* pFrmFmt = 0;
3862 3552 : bool bShare = (bHeader && rDesc.IsHeaderShared()) || (!bHeader && rDesc.IsFooterShared());
3863 3552 : bool bShareFirst = rDesc.IsFirstShared();
3864 : // TextLeft returns the left content if there is one,
3865 : // Text and TextRight return the master content.
3866 : // TextRight does the same as Text and is for
3867 : // comptability only.
3868 3552 : if( bLeft && !bShare )
3869 : {
3870 168 : pFrmFmt = &rDesc.GetLeft();
3871 : }
3872 3384 : else if (bFirst && !bShareFirst)
3873 : {
3874 50 : pFrmFmt = &rDesc.GetFirstMaster();
3875 : // no need to make GetFirstLeft() accessible
3876 : // since it is always shared
3877 : }
3878 : else
3879 : {
3880 3334 : pFrmFmt = &rDesc.GetMaster();
3881 : }
3882 : const uno::Reference< text::XText > xRet =
3883 3552 : lcl_makeHeaderFooter(nRes, bHeader, pFrmFmt);
3884 3552 : if (xRet.is())
3885 : {
3886 2764 : pRet[nProp] <<= xRet;
3887 : }
3888 3552 : break;
3889 : }
3890 :
3891 : case FN_PARAM_FTN_INFO :
3892 : {
3893 596 : rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *(SwDocStyleSheet*)pBase ) );
3894 596 : const SfxItemSet& rSet = xStyle->GetItemSet();
3895 596 : const SfxPoolItem& rItem = rSet.Get(FN_PARAM_FTN_INFO);
3896 596 : rItem.QueryValue(pRet[nProp], nMemberId);
3897 596 : break;
3898 : }
3899 : default:
3900 : {
3901 : //UUUU
3902 3540 : pRet[nProp] = lcl_GetStyleProperty(*pEntry, *pPropSet, aBase, pBase, GetFamily(), GetDoc() );
3903 3540 : break;
3904 : }
3905 : }
3906 : }
3907 0 : else if(IsDescriptor())
3908 : {
3909 0 : uno::Any* pAny = 0;
3910 0 : GetPropImpl()->GetProperty(rPropName, pAny);
3911 :
3912 0 : if ( !pAny )
3913 : {
3914 0 : GetPropImpl()->GetProperty(rPropName, mxStyleData, pRet[nProp]);
3915 : }
3916 : else
3917 : {
3918 0 : pRet[nProp] = *pAny;
3919 : }
3920 : }
3921 : else
3922 : {
3923 0 : throw uno::RuntimeException();
3924 : }
3925 : }
3926 :
3927 36480 : return aRet;
3928 : }
3929 :
3930 288 : uno::Sequence< uno::Any > SwXPageStyle::getPropertyValues(
3931 : const uno::Sequence< OUString >& rPropertyNames )
3932 : throw(uno::RuntimeException, std::exception)
3933 : {
3934 288 : SolarMutexGuard aGuard;
3935 288 : uno::Sequence< uno::Any > aValues;
3936 :
3937 : // workaround for bad designed API
3938 : try
3939 : {
3940 288 : aValues = GetPropertyValues_Impl( rPropertyNames );
3941 : }
3942 0 : catch (beans::UnknownPropertyException &)
3943 : {
3944 0 : throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
3945 : }
3946 0 : catch (lang::WrappedTargetException &)
3947 : {
3948 0 : throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
3949 : }
3950 :
3951 288 : return aValues;
3952 : }
3953 :
3954 17952 : uno::Any SwXPageStyle::getPropertyValue(const OUString& rPropertyName) throw(
3955 : beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
3956 : {
3957 17952 : SolarMutexGuard aGuard;
3958 35904 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3959 35904 : return GetPropertyValues_Impl(aProperties).getConstArray()[0];
3960 : }
3961 :
3962 6720 : void SwXPageStyle::setPropertyValue(const OUString& rPropertyName, const uno::Any& rValue)
3963 : throw( beans::UnknownPropertyException,
3964 : beans::PropertyVetoException,
3965 : lang::IllegalArgumentException,
3966 : lang::WrappedTargetException,
3967 : uno::RuntimeException, std::exception)
3968 : {
3969 6720 : SolarMutexGuard aGuard;
3970 13440 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
3971 13440 : const uno::Sequence<uno::Any> aValues(&rValue, 1);
3972 13440 : SetPropertyValues_Impl( aProperties, aValues );
3973 6706 : }
3974 :
3975 46 : SwXFrameStyle::SwXFrameStyle ( SwDoc *pDoc )
3976 46 : : SwXStyle ( pDoc, SFX_STYLE_FAMILY_FRAME, false)
3977 : {
3978 46 : }
3979 :
3980 7432 : SwXFrameStyle::~SwXFrameStyle()
3981 : {
3982 7432 : }
3983 :
3984 0 : uno::Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(uno::RuntimeException, std::exception)
3985 : {
3986 0 : uno::Sequence< uno::Type > aTypes = SwXStyle::getTypes();
3987 0 : sal_Int32 nLen = aTypes.getLength();
3988 0 : aTypes.realloc(nLen + 1);
3989 0 : aTypes.getArray()[nLen] = cppu::UnoType<XEventsSupplier>::get();
3990 0 : return aTypes;
3991 : }
3992 :
3993 5878 : uno::Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException, std::exception)
3994 : {
3995 5878 : uno::Any aRet;
3996 5878 : if(rType == cppu::UnoType<XEventsSupplier>::get())
3997 30 : aRet <<= uno::Reference<XEventsSupplier>(this);
3998 : else
3999 5848 : aRet = SwXStyle::queryInterface(rType);
4000 5878 : return aRet;
4001 : }
4002 :
4003 30 : uno::Reference< container::XNameReplace > SwXFrameStyle::getEvents( ) throw(uno::RuntimeException, std::exception)
4004 : {
4005 30 : return new SwFrameStyleEventDescriptor( *this );
4006 : }
4007 :
4008 360 : SwXAutoStyles::SwXAutoStyles(SwDocShell& rDocShell) :
4009 360 : SwUnoCollection(rDocShell.GetDoc()), pDocShell( &rDocShell )
4010 : {
4011 360 : }
4012 :
4013 716 : SwXAutoStyles::~SwXAutoStyles()
4014 : {
4015 716 : }
4016 :
4017 0 : sal_Int32 SwXAutoStyles::getCount(void) throw( uno::RuntimeException, std::exception )
4018 : {
4019 0 : return AUTOSTYLE_FAMILY_COUNT;
4020 : }
4021 :
4022 734 : uno::Any SwXAutoStyles::getByIndex(sal_Int32 nIndex)
4023 : throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException,
4024 : uno::RuntimeException, std::exception )
4025 : {
4026 734 : SolarMutexGuard aGuard;
4027 734 : uno::Any aRet;
4028 734 : if(nIndex < 0 || nIndex >= AUTOSTYLE_FAMILY_COUNT)
4029 0 : throw lang::IndexOutOfBoundsException();
4030 734 : if(IsValid())
4031 : {
4032 734 : uno::Reference< style::XAutoStyleFamily > aRef;
4033 734 : IStyleAccess::SwAutoStyleFamily nType = aAutoStyleByIndex[nIndex];
4034 734 : switch( nType )
4035 : {
4036 : case IStyleAccess::AUTO_STYLE_CHAR:
4037 : {
4038 268 : if(!xAutoCharStyles.is())
4039 254 : xAutoCharStyles = new SwXAutoStyleFamily(pDocShell, nType);
4040 268 : aRef = xAutoCharStyles;
4041 : }
4042 268 : break;
4043 : case IStyleAccess::AUTO_STYLE_RUBY:
4044 : {
4045 60 : if(!xAutoRubyStyles.is())
4046 60 : xAutoRubyStyles = new SwXAutoStyleFamily(pDocShell, nType );
4047 60 : aRef = xAutoRubyStyles;
4048 : }
4049 60 : break;
4050 : case IStyleAccess::AUTO_STYLE_PARA:
4051 : {
4052 406 : if(!xAutoParaStyles.is())
4053 356 : xAutoParaStyles = new SwXAutoStyleFamily(pDocShell, nType );
4054 406 : aRef = xAutoParaStyles;
4055 : }
4056 406 : break;
4057 :
4058 : default:
4059 : ;
4060 : }
4061 734 : aRet.setValue(&aRef, cppu::UnoType<style::XAutoStyleFamily>::get());
4062 : }
4063 : else
4064 0 : throw uno::RuntimeException();
4065 734 : return aRet;
4066 : }
4067 :
4068 0 : uno::Type SwXAutoStyles::getElementType( ) throw(uno::RuntimeException, std::exception)
4069 : {
4070 0 : return cppu::UnoType<style::XAutoStyleFamily>::get();
4071 : }
4072 :
4073 0 : sal_Bool SwXAutoStyles::hasElements( ) throw(uno::RuntimeException, std::exception)
4074 : {
4075 0 : return sal_True;
4076 : }
4077 :
4078 734 : uno::Any SwXAutoStyles::getByName(const OUString& Name)
4079 : throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception )
4080 : {
4081 734 : uno::Any aRet;
4082 734 : if(Name.equalsAscii("CharacterStyles") )
4083 268 : aRet = getByIndex(0);
4084 466 : else if(Name.equalsAscii("RubyStyles") )
4085 60 : aRet = getByIndex(1);
4086 406 : else if(Name.equalsAscii("ParagraphStyles") )
4087 406 : aRet = getByIndex(2);
4088 : else
4089 0 : throw container::NoSuchElementException();
4090 734 : return aRet;
4091 : }
4092 :
4093 0 : uno::Sequence< OUString > SwXAutoStyles::getElementNames(void)
4094 : throw( uno::RuntimeException, std::exception )
4095 : {
4096 0 : uno::Sequence< OUString > aNames(AUTOSTYLE_FAMILY_COUNT);
4097 0 : OUString* pNames = aNames.getArray();
4098 0 : pNames[0] = "CharacterStyles";
4099 0 : pNames[1] = "RubyStyles";
4100 0 : pNames[2] = "ParagraphStyles";
4101 0 : return aNames;
4102 : }
4103 :
4104 550 : sal_Bool SwXAutoStyles::hasByName(const OUString& Name)
4105 : throw( uno::RuntimeException, std::exception )
4106 : {
4107 1442 : if( Name.equalsAscii("CharacterStyles") ||
4108 892 : Name.equalsAscii("RubyStyles") ||
4109 342 : Name.equalsAscii("ParagraphStyles") )
4110 550 : return sal_True;
4111 : else
4112 0 : return sal_False;
4113 : }
4114 :
4115 670 : SwXAutoStyleFamily::SwXAutoStyleFamily(SwDocShell* pDocSh, IStyleAccess::SwAutoStyleFamily nFamily) :
4116 670 : pDocShell( pDocSh ), eFamily(nFamily)
4117 : {
4118 : // Register ourselves as a listener to the document (via the page descriptor)
4119 670 : pDocSh->GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4120 670 : }
4121 :
4122 1332 : SwXAutoStyleFamily::~SwXAutoStyleFamily()
4123 : {
4124 1332 : }
4125 :
4126 0 : void SwXAutoStyleFamily::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4127 : {
4128 0 : ClientModify(this, pOld, pNew);
4129 0 : if(!GetRegisteredIn())
4130 0 : pDocShell = 0;
4131 0 : }
4132 :
4133 2672 : uno::Reference< style::XAutoStyle > SwXAutoStyleFamily::insertStyle(
4134 : const uno::Sequence< beans::PropertyValue >& Values )
4135 : throw (uno::RuntimeException, std::exception)
4136 : {
4137 2672 : if (!pDocShell)
4138 : {
4139 0 : throw uno::RuntimeException();
4140 : }
4141 :
4142 2672 : const sal_uInt16* pRange = 0;
4143 2672 : const SfxItemPropertySet* pPropSet = 0;
4144 2672 : switch( eFamily )
4145 : {
4146 : case IStyleAccess::AUTO_STYLE_CHAR:
4147 : {
4148 1166 : pRange = aCharAutoFmtSetRange;
4149 1166 : pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE);
4150 1166 : break;
4151 : }
4152 : case IStyleAccess::AUTO_STYLE_RUBY:
4153 : {
4154 0 : pRange = 0;//aTxtNodeSetRange;
4155 0 : pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_RUBY_AUTO_STYLE);
4156 0 : break;
4157 : }
4158 : case IStyleAccess::AUTO_STYLE_PARA:
4159 : {
4160 1506 : pRange = aTxtNodeSetRange; //UUUU checked, already added support for [XATTR_FILL_FIRST, XATTR_FILL_LAST]
4161 1506 : pPropSet = aSwMapProvider.GetPropertySet(PROPERTY_MAP_PARA_AUTO_STYLE);
4162 1506 : break;
4163 : }
4164 : default: ;
4165 : }
4166 :
4167 2672 : if( !pPropSet)
4168 0 : throw uno::RuntimeException();
4169 :
4170 2672 : SwAttrSet aSet( pDocShell->GetDoc()->GetAttrPool(), pRange );
4171 2672 : const beans::PropertyValue* pSeq = Values.getConstArray();
4172 2672 : sal_Int32 nLen = Values.getLength();
4173 2672 : const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == eFamily);
4174 :
4175 2672 : if(!bTakeCareOfDrawingLayerFillStyle)
4176 : {
4177 22074 : for( sal_Int32 i = 0; i < nLen; ++i )
4178 : {
4179 : try
4180 : {
4181 20908 : pPropSet->setPropertyValue( pSeq[i].Name, pSeq[i].Value, aSet );
4182 : }
4183 0 : catch (const beans::UnknownPropertyException &)
4184 : {
4185 : OSL_FAIL( "Unknown property" );
4186 : }
4187 0 : catch (const lang::IllegalArgumentException &)
4188 : {
4189 : OSL_FAIL( "Illegal argument" );
4190 : }
4191 : }
4192 : }
4193 : else
4194 : {
4195 : //UUUU set parent to ItemSet to ensure XFILL_NONE as XFillStyleItem
4196 : // to make cases in RES_BACKGROUND work correct; target *is* a style
4197 : // where this is the case
4198 1506 : aSet.SetParent(&pDocShell->GetDoc()->GetDfltTxtFmtColl()->GetAttrSet());
4199 :
4200 : //UUUU here the used DrawingLayer FillStyles are imported when family is
4201 : // equal to IStyleAccess::AUTO_STYLE_PARA, thus we will need to serve the
4202 : // used slots functionality here to do this correctly
4203 1506 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
4204 :
4205 17782 : for( sal_Int32 i = 0; i < nLen; ++i )
4206 : {
4207 16276 : const OUString& rPropName = pSeq[i].Name;
4208 16276 : uno::Any aValue(pSeq[i].Value);
4209 16276 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(rPropName);
4210 :
4211 16276 : if (!pEntry)
4212 : {
4213 : SAL_WARN("sw.core", "SwXAutoStyleFamily::Modify: Unknown property: " << rPropName);
4214 2 : continue;
4215 : }
4216 :
4217 16274 : const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
4218 16274 : bool bDone(false);
4219 :
4220 : // check for needed metric translation
4221 16274 : if(pEntry->nMemberId & SFX_METRIC_ITEM)
4222 : {
4223 0 : bool bDoIt(true);
4224 :
4225 0 : if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
4226 : {
4227 : // exception: If these ItemTypes are used, do not convert when these are negative
4228 : // since this means they are intended as percent values
4229 0 : sal_Int32 nValue = 0;
4230 :
4231 0 : if(aValue >>= nValue)
4232 : {
4233 0 : bDoIt = nValue > 0;
4234 : }
4235 : }
4236 :
4237 0 : if(bDoIt)
4238 : {
4239 0 : const SfxItemPool& rPool = pDocShell->GetDoc()->GetAttrPool();
4240 0 : const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
4241 :
4242 0 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
4243 : {
4244 0 : SvxUnoConvertFromMM(eMapUnit, aValue);
4245 : }
4246 : }
4247 : }
4248 :
4249 16274 : switch(pEntry->nWID)
4250 : {
4251 : case XATTR_FILLGRADIENT:
4252 : case XATTR_FILLHATCH:
4253 : case XATTR_FILLBITMAP:
4254 : case XATTR_FILLFLOATTRANSPARENCE:
4255 : // not yet needed; activate when LineStyle support may be added
4256 : // case XATTR_LINESTART:
4257 : // case XATTR_LINEEND:
4258 : // case XATTR_LINEDASH:
4259 : {
4260 0 : if(MID_NAME == nMemberId)
4261 : {
4262 : //UUUU add set commands for FillName items
4263 0 : OUString aTempName;
4264 :
4265 0 : if(!(aValue >>= aTempName))
4266 : {
4267 0 : throw lang::IllegalArgumentException();
4268 : }
4269 :
4270 0 : SvxShape::SetFillAttribute(pEntry->nWID, aTempName, aSet);
4271 0 : bDone = true;
4272 : }
4273 0 : else if(MID_GRAFURL == nMemberId)
4274 : {
4275 0 : if(XATTR_FILLBITMAP == pEntry->nWID)
4276 : {
4277 : //UUUU Bitmap also has the MID_GRAFURL mode where a Bitmap URL is used
4278 0 : const Graphic aNullGraphic;
4279 0 : XFillBitmapItem aXFillBitmapItem(aSet.GetPool(), aNullGraphic);
4280 :
4281 0 : aXFillBitmapItem.PutValue(aValue, nMemberId);
4282 0 : aSet.Put(aXFillBitmapItem);
4283 0 : bDone = true;
4284 : }
4285 : }
4286 :
4287 0 : break;
4288 : }
4289 : case RES_BACKGROUND:
4290 : {
4291 : //UUUU
4292 24 : const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND));
4293 48 : SvxBrushItem aChangedBrushItem(aOriginalBrushItem);
4294 :
4295 24 : aChangedBrushItem.PutValue(aValue, nMemberId);
4296 :
4297 24 : if(!(aChangedBrushItem == aOriginalBrushItem))
4298 : {
4299 6 : setSvxBrushItemAsFillAttributesToTargetSet(aChangedBrushItem, aSet);
4300 : }
4301 :
4302 24 : bDone = true;
4303 48 : break;
4304 : }
4305 : case OWN_ATTR_FILLBMP_MODE:
4306 : {
4307 : //UUUU
4308 : drawing::BitmapMode eMode;
4309 :
4310 0 : if(!(aValue >>= eMode))
4311 : {
4312 0 : sal_Int32 nMode = 0;
4313 :
4314 0 : if(!(aValue >>= nMode))
4315 : {
4316 0 : throw lang::IllegalArgumentException();
4317 : }
4318 :
4319 0 : eMode = (drawing::BitmapMode)nMode;
4320 : }
4321 :
4322 0 : aSet.Put(XFillBmpStretchItem(drawing::BitmapMode_STRETCH == eMode));
4323 0 : aSet.Put(XFillBmpTileItem(drawing::BitmapMode_REPEAT == eMode));
4324 :
4325 0 : bDone = true;
4326 0 : break;
4327 : }
4328 16250 : default: break;
4329 : }
4330 :
4331 16274 : if(!bDone)
4332 : {
4333 : try
4334 : {
4335 16250 : pPropSet->setPropertyValue( rPropName, aValue, aSet );
4336 : }
4337 0 : catch (const beans::UnknownPropertyException &)
4338 : {
4339 : OSL_FAIL( "Unknown property" );
4340 : }
4341 0 : catch (const lang::IllegalArgumentException &)
4342 : {
4343 : OSL_FAIL( "Illegal argument" );
4344 : }
4345 : }
4346 16274 : }
4347 :
4348 : //UUUU clear parent again
4349 1506 : aSet.SetParent(0);
4350 : }
4351 :
4352 : //UUUU need to ensure uniqueness of evtl. added NameOrIndex items
4353 : // currently in principle only needed when bTakeCareOfDrawingLayerFillStyle,
4354 : // but does not hurt and is easily forgotten later eventually, so keep it
4355 : // as common case
4356 2672 : pDocShell->GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aSet);
4357 :
4358 : // AutomaticStyle creation
4359 2672 : SfxItemSet_Pointer_t pSet = pDocShell->GetDoc()->GetIStyleAccess().cacheAutomaticStyle( aSet, eFamily );
4360 5344 : uno::Reference<style::XAutoStyle> xRet = new SwXAutoStyle(pDocShell->GetDoc(), pSet, eFamily);
4361 :
4362 5344 : return xRet;
4363 : }
4364 :
4365 184 : uno::Reference< container::XEnumeration > SwXAutoStyleFamily::createEnumeration( )
4366 : throw (uno::RuntimeException, std::exception)
4367 : {
4368 184 : if( !pDocShell )
4369 0 : throw uno::RuntimeException();
4370 : return uno::Reference< container::XEnumeration >
4371 184 : (new SwXAutoStylesEnumerator( pDocShell->GetDoc(), eFamily ));
4372 : }
4373 :
4374 0 : uno::Type SwXAutoStyleFamily::getElementType( ) throw(uno::RuntimeException, std::exception)
4375 : {
4376 0 : return cppu::UnoType<style::XAutoStyle>::get();
4377 : }
4378 :
4379 0 : sal_Bool SwXAutoStyleFamily::hasElements( ) throw(uno::RuntimeException, std::exception)
4380 : {
4381 0 : return sal_False;
4382 : }
4383 :
4384 184 : SwAutoStylesEnumImpl::SwAutoStylesEnumImpl( SwDoc* pInitDoc, IStyleAccess::SwAutoStyleFamily eFam )
4385 184 : : pDoc( pInitDoc ), eFamily( eFam )
4386 : {
4387 : // special case for ruby auto styles:
4388 184 : if ( IStyleAccess::AUTO_STYLE_RUBY == eFam )
4389 : {
4390 60 : std::set< std::pair< sal_uInt16, sal_uInt16 > > aRubyMap;
4391 60 : SwAttrPool& rAttrPool = pDoc->GetAttrPool();
4392 60 : sal_uInt32 nCount = rAttrPool.GetItemCount2( RES_TXTATR_CJK_RUBY );
4393 :
4394 78 : for ( sal_uInt32 nI = 0; nI < nCount; ++nI )
4395 : {
4396 18 : const SwFmtRuby* pItem = static_cast<const SwFmtRuby*>(rAttrPool.GetItem2( RES_TXTATR_CJK_RUBY, nI ));
4397 18 : if ( pItem && pItem->GetTxtRuby() )
4398 : {
4399 12 : std::pair< sal_uInt16, sal_uInt16 > aPair( pItem->GetPosition(), pItem->GetAdjustment() );
4400 12 : if ( aRubyMap.find( aPair ) == aRubyMap.end() )
4401 : {
4402 2 : aRubyMap.insert( aPair );
4403 2 : SfxItemSet_Pointer_t pItemSet( new SfxItemSet( rAttrPool, RES_TXTATR_CJK_RUBY, RES_TXTATR_CJK_RUBY ) );
4404 2 : pItemSet->Put( *pItem );
4405 2 : mAutoStyles.push_back( pItemSet );
4406 : }
4407 : }
4408 60 : }
4409 : }
4410 : else
4411 : {
4412 124 : pDoc->GetIStyleAccess().getAllStyles( mAutoStyles, eFamily );
4413 : }
4414 :
4415 184 : aIter = mAutoStyles.begin();
4416 184 : }
4417 :
4418 184 : SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam )
4419 184 : : pImpl( new SwAutoStylesEnumImpl( pDoc, eFam ) )
4420 : {
4421 : // Register ourselves as a listener to the document (via the page descriptor)
4422 184 : pDoc->getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4423 184 : }
4424 :
4425 552 : SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
4426 : {
4427 184 : delete pImpl;
4428 368 : }
4429 :
4430 0 : void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4431 : {
4432 0 : ClientModify(this, pOld, pNew);
4433 0 : if(!GetRegisteredIn())
4434 : {
4435 0 : delete pImpl;
4436 0 : pImpl = 0;
4437 : }
4438 0 : }
4439 :
4440 246 : sal_Bool SwXAutoStylesEnumerator::hasMoreElements( )
4441 : throw (uno::RuntimeException, std::exception)
4442 : {
4443 246 : if( !pImpl )
4444 0 : throw uno::RuntimeException();
4445 246 : return pImpl->hasMoreElements();
4446 : }
4447 :
4448 66 : uno::Any SwXAutoStylesEnumerator::nextElement( )
4449 : throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
4450 : {
4451 66 : if( !pImpl )
4452 0 : throw uno::RuntimeException();
4453 66 : uno::Any aRet;
4454 66 : if( pImpl->hasMoreElements() )
4455 : {
4456 66 : SfxItemSet_Pointer_t pNextSet = pImpl->nextElement();
4457 66 : uno::Reference< style::XAutoStyle > xAutoStyle = new SwXAutoStyle(pImpl->getDoc(),
4458 132 : pNextSet, pImpl->getFamily());
4459 132 : aRet.setValue(&xAutoStyle, cppu::UnoType<style::XAutoStyle>::get());
4460 : }
4461 66 : return aRet;
4462 : }
4463 :
4464 : //UUUU SwXAutoStyle with the family IStyleAccess::AUTO_STYLE_PARA (or
4465 : // PROPERTY_MAP_PARA_AUTO_STYLE) now uses DrawingLayer FillStyles to allow
4466 : // unified paragraph background fill, thus the UNO API implementation has to
4467 : // support the needed slots for these. This seems to be used only for reading
4468 : // (no setPropertyValue implementation here), so maybe specialized for saving
4469 : // the Writer Doc to ODF
4470 :
4471 2738 : SwXAutoStyle::SwXAutoStyle(
4472 : SwDoc* pDoc,
4473 : SfxItemSet_Pointer_t pInitSet,
4474 : IStyleAccess::SwAutoStyleFamily eFam)
4475 : : mpSet(pInitSet),
4476 : meFamily(eFam),
4477 2738 : mrDoc(*pDoc)
4478 : {
4479 : // Register ourselves as a listener to the document (via the page descriptor)
4480 2738 : mrDoc.getIDocumentStylePoolAccess().GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this);
4481 2738 : }
4482 :
4483 5476 : SwXAutoStyle::~SwXAutoStyle()
4484 : {
4485 5476 : }
4486 :
4487 0 : void SwXAutoStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
4488 : {
4489 0 : ClientModify(this, pOld, pNew);
4490 0 : if(!GetRegisteredIn())
4491 : {
4492 0 : mpSet.reset();
4493 : }
4494 0 : }
4495 :
4496 122 : uno::Reference< beans::XPropertySetInfo > SwXAutoStyle::getPropertySetInfo( )
4497 : throw (uno::RuntimeException, std::exception)
4498 : {
4499 122 : uno::Reference< beans::XPropertySetInfo > xRet;
4500 122 : switch( meFamily )
4501 : {
4502 : case IStyleAccess::AUTO_STYLE_CHAR:
4503 : {
4504 12 : static uno::Reference< beans::XPropertySetInfo > xCharRef;
4505 12 : if(!xCharRef.is())
4506 : {
4507 2 : xCharRef = aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE)->getPropertySetInfo();
4508 : }
4509 12 : xRet = xCharRef;
4510 : }
4511 12 : break;
4512 : case IStyleAccess::AUTO_STYLE_RUBY:
4513 : {
4514 4 : static uno::Reference< beans::XPropertySetInfo > xRubyRef;
4515 4 : if(!xRubyRef.is())
4516 : {
4517 2 : const sal_uInt16 nMapId = PROPERTY_MAP_RUBY_AUTO_STYLE;
4518 2 : xRubyRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4519 : }
4520 4 : xRet = xRubyRef;
4521 : }
4522 4 : break;
4523 : case IStyleAccess::AUTO_STYLE_PARA:
4524 : {
4525 106 : static uno::Reference< beans::XPropertySetInfo > xParaRef;
4526 106 : if(!xParaRef.is())
4527 : {
4528 8 : const sal_uInt16 nMapId = PROPERTY_MAP_PARA_AUTO_STYLE;
4529 8 : xParaRef = aSwMapProvider.GetPropertySet(nMapId)->getPropertySetInfo();
4530 : }
4531 106 : xRet = xParaRef;
4532 : }
4533 106 : break;
4534 :
4535 : default:
4536 : ;
4537 : }
4538 :
4539 122 : return xRet;
4540 : }
4541 :
4542 0 : void SwXAutoStyle::setPropertyValue( const OUString& /*rPropertyName*/, const uno::Any& /*rValue*/ )
4543 : throw( beans::UnknownPropertyException,
4544 : beans::PropertyVetoException,
4545 : lang::IllegalArgumentException,
4546 : lang::WrappedTargetException,
4547 : uno::RuntimeException, std::exception)
4548 : {
4549 0 : }
4550 :
4551 104 : uno::Any SwXAutoStyle::getPropertyValue( const OUString& rPropertyName )
4552 : throw( beans::UnknownPropertyException,
4553 : lang::WrappedTargetException,
4554 : uno::RuntimeException, std::exception )
4555 : {
4556 104 : SolarMutexGuard aGuard;
4557 208 : const uno::Sequence<OUString> aProperties(&rPropertyName, 1);
4558 208 : return GetPropertyValues_Impl(aProperties).getConstArray()[0];
4559 : }
4560 :
4561 0 : void SwXAutoStyle::addPropertyChangeListener( const OUString& /*aPropertyName*/,
4562 : const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
4563 : throw( beans::UnknownPropertyException,
4564 : lang::WrappedTargetException,
4565 : uno::RuntimeException, std::exception )
4566 : {
4567 0 : }
4568 :
4569 0 : void SwXAutoStyle::removePropertyChangeListener( const OUString& /*aPropertyName*/,
4570 : const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ )
4571 : throw( beans::UnknownPropertyException,
4572 : lang::WrappedTargetException,
4573 : uno::RuntimeException, std::exception )
4574 : {
4575 0 : }
4576 :
4577 0 : void SwXAutoStyle::addVetoableChangeListener( const OUString& /*PropertyName*/,
4578 : const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4579 : throw( beans::UnknownPropertyException,
4580 : lang::WrappedTargetException,
4581 : uno::RuntimeException, std::exception )
4582 : {
4583 0 : }
4584 :
4585 0 : void SwXAutoStyle::removeVetoableChangeListener( const OUString& /*PropertyName*/,
4586 : const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ )
4587 : throw( beans::UnknownPropertyException,
4588 : lang::WrappedTargetException,
4589 : uno::RuntimeException, std::exception )
4590 : {
4591 0 : }
4592 :
4593 0 : void SwXAutoStyle::setPropertyValues(
4594 : const uno::Sequence< OUString >& /*aPropertyNames*/,
4595 : const uno::Sequence< uno::Any >& /*aValues*/ )
4596 : throw (beans::PropertyVetoException, lang::IllegalArgumentException,
4597 : lang::WrappedTargetException, uno::RuntimeException, std::exception)
4598 : {
4599 0 : }
4600 :
4601 2836 : uno::Sequence< uno::Any > SwXAutoStyle::GetPropertyValues_Impl(
4602 : const uno::Sequence< OUString > & rPropertyNames )
4603 : throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
4604 : {
4605 2836 : if( !mpSet.get() )
4606 : {
4607 0 : throw uno::RuntimeException();
4608 : }
4609 :
4610 : // query_item
4611 2836 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4612 2836 : switch(meFamily)
4613 : {
4614 1172 : case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4615 2 : case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4616 1662 : case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4617 : default: ;
4618 : }
4619 :
4620 2836 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4621 2836 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
4622 2836 : const OUString* pNames = rPropertyNames.getConstArray();
4623 :
4624 2836 : const sal_Int32 nLen(rPropertyNames.getLength());
4625 2836 : uno::Sequence< uno::Any > aRet( nLen );
4626 2836 : uno::Any* pValues = aRet.getArray();
4627 2836 : const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily);
4628 :
4629 5806 : for( sal_Int32 i = 0; i < nLen; ++i )
4630 : {
4631 2970 : const OUString sPropName = pNames[i];
4632 2970 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
4633 2970 : if(!pEntry)
4634 : {
4635 0 : throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
4636 : }
4637 :
4638 5940 : uno::Any aTarget;
4639 2970 : bool bDone(false);
4640 :
4641 2970 : if ( RES_TXTATR_AUTOFMT == pEntry->nWID || RES_AUTO_STYLE == pEntry->nWID )
4642 : {
4643 2672 : OUString sName(StylePool::nameOf( mpSet ));
4644 2672 : aTarget <<= sName;
4645 2672 : bDone = true;
4646 : }
4647 298 : else if(bTakeCareOfDrawingLayerFillStyle)
4648 : {
4649 : //UUUU add support for DrawingLayer FillStyle slots
4650 288 : switch(pEntry->nWID)
4651 : {
4652 : case RES_BACKGROUND:
4653 : {
4654 0 : const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(*mpSet, RES_BACKGROUND));
4655 0 : const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM));
4656 :
4657 0 : if(!aOriginalBrushItem.QueryValue(aTarget, nMemberId))
4658 : {
4659 : OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)");
4660 : }
4661 :
4662 0 : bDone = true;
4663 0 : break;
4664 : }
4665 : case OWN_ATTR_FILLBMP_MODE:
4666 : {
4667 0 : const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&mpSet->Get(XATTR_FILLBMP_STRETCH));
4668 0 : const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&mpSet->Get(XATTR_FILLBMP_TILE));
4669 :
4670 0 : if( pTileItem && pTileItem->GetValue() )
4671 : {
4672 0 : aTarget <<= drawing::BitmapMode_REPEAT;
4673 : }
4674 0 : else if( pStretchItem && pStretchItem->GetValue() )
4675 : {
4676 0 : aTarget <<= drawing::BitmapMode_STRETCH;
4677 : }
4678 : else
4679 : {
4680 0 : aTarget <<= drawing::BitmapMode_NO_REPEAT;
4681 : }
4682 :
4683 0 : bDone = true;
4684 0 : break;
4685 : }
4686 : }
4687 : }
4688 :
4689 2970 : if(!bDone)
4690 : {
4691 298 : pPropSet->getPropertyValue( *pEntry, *mpSet, aTarget );
4692 : }
4693 :
4694 2970 : if(bTakeCareOfDrawingLayerFillStyle)
4695 : {
4696 1794 : if(pEntry->aType == ::getCppuType((const sal_Int16*)0) && pEntry->aType != aTarget.getValueType())
4697 : {
4698 : // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
4699 24 : sal_Int32 nValue = 0;
4700 24 : aTarget >>= nValue;
4701 24 : aTarget <<= (sal_Int16)nValue;
4702 : }
4703 :
4704 : // check for needed metric translation
4705 1794 : if(pEntry->nMemberId & SFX_METRIC_ITEM)
4706 : {
4707 0 : bool bDoIt(true);
4708 :
4709 0 : if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID)
4710 : {
4711 : // exception: If these ItemTypes are used, do not convert when these are negative
4712 : // since this means they are intended as percent values
4713 0 : sal_Int32 nValue = 0;
4714 :
4715 0 : if(aTarget >>= nValue)
4716 : {
4717 0 : bDoIt = nValue > 0;
4718 : }
4719 : }
4720 :
4721 0 : if(bDoIt)
4722 : {
4723 0 : const SfxItemPool& rPool = mrDoc.GetAttrPool();
4724 0 : const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID));
4725 :
4726 0 : if(eMapUnit != SFX_MAPUNIT_100TH_MM)
4727 : {
4728 0 : SvxUnoConvertToMM(eMapUnit, aTarget);
4729 : }
4730 : }
4731 : }
4732 : }
4733 :
4734 : // add value
4735 2970 : pValues[i] = aTarget;
4736 2970 : }
4737 :
4738 2836 : return aRet;
4739 : }
4740 :
4741 2732 : uno::Sequence< uno::Any > SwXAutoStyle::getPropertyValues (
4742 : const uno::Sequence< OUString >& rPropertyNames )
4743 : throw (uno::RuntimeException, std::exception)
4744 : {
4745 2732 : SolarMutexGuard aGuard;
4746 2732 : uno::Sequence< uno::Any > aValues;
4747 :
4748 : // workaround for bad designed API
4749 : try
4750 : {
4751 2732 : aValues = GetPropertyValues_Impl( rPropertyNames );
4752 : }
4753 0 : catch (beans::UnknownPropertyException &)
4754 : {
4755 0 : throw uno::RuntimeException("Unknown property exception caught", static_cast < cppu::OWeakObject * > ( this ) );
4756 : }
4757 0 : catch (lang::WrappedTargetException &)
4758 : {
4759 0 : throw uno::RuntimeException("WrappedTargetException caught", static_cast < cppu::OWeakObject * > ( this ) );
4760 : }
4761 :
4762 2732 : return aValues;
4763 : }
4764 :
4765 0 : void SwXAutoStyle::addPropertiesChangeListener(
4766 : const uno::Sequence< OUString >& /*aPropertyNames*/,
4767 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4768 : throw (uno::RuntimeException, std::exception)
4769 : {
4770 0 : }
4771 :
4772 0 : void SwXAutoStyle::removePropertiesChangeListener(
4773 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4774 : throw (uno::RuntimeException, std::exception)
4775 : {
4776 0 : }
4777 :
4778 0 : void SwXAutoStyle::firePropertiesChangeEvent(
4779 : const uno::Sequence< OUString >& /*aPropertyNames*/,
4780 : const uno::Reference< beans::XPropertiesChangeListener >& /*xListener*/ )
4781 : throw (uno::RuntimeException, std::exception)
4782 : {
4783 0 : }
4784 :
4785 0 : beans::PropertyState SwXAutoStyle::getPropertyState( const OUString& rPropertyName )
4786 : throw( beans::UnknownPropertyException,
4787 : uno::RuntimeException, std::exception)
4788 : {
4789 0 : SolarMutexGuard aGuard;
4790 :
4791 0 : uno::Sequence< OUString > aNames(1);
4792 0 : OUString* pNames = aNames.getArray();
4793 0 : pNames[0] = rPropertyName;
4794 0 : uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aNames);
4795 0 : return aStates.getConstArray()[0];
4796 : }
4797 :
4798 0 : void SwXAutoStyle::setPropertyToDefault( const OUString& /*PropertyName*/ )
4799 : throw( beans::UnknownPropertyException,
4800 : uno::RuntimeException, std::exception )
4801 : {
4802 0 : }
4803 :
4804 0 : uno::Any SwXAutoStyle::getPropertyDefault( const OUString& rPropertyName )
4805 : throw( beans::UnknownPropertyException,
4806 : lang::WrappedTargetException,
4807 : uno::RuntimeException, std::exception)
4808 : {
4809 0 : const uno::Sequence < OUString > aSequence ( &rPropertyName, 1 );
4810 0 : return getPropertyDefaults ( aSequence ).getConstArray()[0];
4811 : }
4812 :
4813 62 : uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
4814 : const uno::Sequence< OUString >& rPropertyNames )
4815 : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
4816 : {
4817 62 : if (!mpSet.get())
4818 : {
4819 0 : throw uno::RuntimeException();
4820 : }
4821 :
4822 62 : SolarMutexGuard aGuard;
4823 62 : uno::Sequence< beans::PropertyState > aRet(rPropertyNames.getLength());
4824 62 : beans::PropertyState* pStates = aRet.getArray();
4825 62 : const OUString* pNames = rPropertyNames.getConstArray();
4826 :
4827 62 : sal_Int8 nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE;
4828 62 : switch(meFamily)
4829 : {
4830 6 : case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4831 2 : case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4832 54 : case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4833 : default: ;
4834 : }
4835 :
4836 62 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4837 62 : const SfxItemPropertyMap& rMap = pPropSet->getPropertyMap();
4838 62 : const bool bTakeCareOfDrawingLayerFillStyle(IStyleAccess::AUTO_STYLE_PARA == meFamily);
4839 :
4840 7866 : for(sal_Int32 i = 0; i < rPropertyNames.getLength(); i++)
4841 : {
4842 7804 : const OUString sPropName = pNames[i];
4843 7804 : const SfxItemPropertySimpleEntry* pEntry = rMap.getByName(sPropName);
4844 7804 : if(!pEntry)
4845 : {
4846 0 : throw beans::UnknownPropertyException("Unknown property: " + sPropName, static_cast < cppu::OWeakObject * > ( this ) );
4847 : }
4848 :
4849 7804 : bool bDone(false);
4850 :
4851 7804 : if(bTakeCareOfDrawingLayerFillStyle)
4852 : {
4853 : //UUUU DrawingLayer PropertyStyle support
4854 7398 : switch(pEntry->nWID)
4855 : {
4856 : case OWN_ATTR_FILLBMP_MODE:
4857 : {
4858 108 : if(SfxItemState::SET == mpSet->GetItemState(XATTR_FILLBMP_STRETCH, false)
4859 54 : || SfxItemState::SET == mpSet->GetItemState(XATTR_FILLBMP_TILE, false))
4860 : {
4861 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
4862 : }
4863 : else
4864 : {
4865 54 : pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
4866 : }
4867 :
4868 54 : bDone = true;
4869 54 : break;
4870 : }
4871 : case RES_BACKGROUND:
4872 : {
4873 270 : if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet))
4874 : {
4875 0 : pStates[i] = beans::PropertyState_DIRECT_VALUE;
4876 0 : bDone = true;
4877 : }
4878 :
4879 270 : break;
4880 : }
4881 : }
4882 : }
4883 :
4884 7804 : if(!bDone)
4885 : {
4886 7750 : pStates[i] = pPropSet->getPropertyState(*pEntry, *mpSet );
4887 : }
4888 7804 : }
4889 :
4890 62 : return aRet;
4891 : }
4892 :
4893 0 : void SwXAutoStyle::setAllPropertiesToDefault( )
4894 : throw (uno::RuntimeException, std::exception)
4895 : {
4896 0 : }
4897 :
4898 0 : void SwXAutoStyle::setPropertiesToDefault(
4899 : const uno::Sequence< OUString >& /*rPropertyNames*/ )
4900 : throw (beans::UnknownPropertyException, uno::RuntimeException, std::exception)
4901 : {
4902 0 : }
4903 :
4904 0 : uno::Sequence< uno::Any > SwXAutoStyle::getPropertyDefaults(
4905 : const uno::Sequence< OUString >& /*aPropertyNames*/ )
4906 : throw (beans::UnknownPropertyException, lang::WrappedTargetException,
4907 : uno::RuntimeException, std::exception)
4908 : {
4909 0 : uno::Sequence< uno::Any > aRet(0);
4910 0 : return aRet;
4911 : }
4912 :
4913 0 : uno::Sequence< beans::PropertyValue > SwXAutoStyle::getProperties() throw (uno::RuntimeException, std::exception)
4914 : {
4915 0 : if( !mpSet.get() )
4916 0 : throw uno::RuntimeException();
4917 0 : SolarMutexGuard aGuard;
4918 0 : std::vector< beans::PropertyValue > aPropertyVector;
4919 :
4920 0 : sal_Int8 nPropSetId = 0;
4921 0 : switch(meFamily)
4922 : {
4923 0 : case IStyleAccess::AUTO_STYLE_CHAR : nPropSetId = PROPERTY_MAP_CHAR_AUTO_STYLE; break;
4924 0 : case IStyleAccess::AUTO_STYLE_RUBY : nPropSetId = PROPERTY_MAP_RUBY_AUTO_STYLE; break;
4925 0 : case IStyleAccess::AUTO_STYLE_PARA : nPropSetId = PROPERTY_MAP_PARA_AUTO_STYLE; break;
4926 : default: ;
4927 : }
4928 :
4929 0 : const SfxItemPropertySet* pPropSet = aSwMapProvider.GetPropertySet(nPropSetId);
4930 0 : const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
4931 0 : PropertyEntryVector_t aPropVector = rMap.getPropertyEntries();
4932 :
4933 0 : SfxItemSet& rSet = *mpSet.get();
4934 0 : SfxItemIter aIter(rSet);
4935 0 : const SfxPoolItem* pItem = aIter.FirstItem();
4936 :
4937 0 : while ( pItem )
4938 : {
4939 0 : const sal_uInt16 nWID = pItem->Which();
4940 :
4941 : // TODO: Optimize - and fix! the old iteration filled each WhichId
4942 : // only once but there are more properties than WhichIds
4943 0 : PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
4944 0 : while( aIt != aPropVector.end() )
4945 : {
4946 0 : if ( aIt->nWID == nWID )
4947 : {
4948 0 : beans::PropertyValue aPropertyValue;
4949 0 : aPropertyValue.Name = aIt->sName;
4950 0 : pItem->QueryValue( aPropertyValue.Value, aIt->nMemberId );
4951 0 : aPropertyVector.push_back( aPropertyValue );
4952 : }
4953 0 : ++aIt;
4954 : }
4955 0 : pItem = aIter.NextItem();
4956 : }
4957 :
4958 0 : const sal_Int32 nCount = aPropertyVector.size();
4959 0 : uno::Sequence< beans::PropertyValue > aRet( nCount );
4960 0 : beans::PropertyValue* pProps = aRet.getArray();
4961 :
4962 0 : for ( int i = 0; i < nCount; ++i, pProps++ )
4963 : {
4964 0 : *pProps = aPropertyVector[i];
4965 : }
4966 :
4967 0 : return aRet;
4968 270 : }
4969 :
4970 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|