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