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 <com/sun/star/beans/PropertyAttribute.hpp>
21 : #include <com/sun/star/lang/DisposedException.hpp>
22 : #include <com/sun/star/style/XStyle.hpp>
23 :
24 : #include <osl/mutex.hxx>
25 : #include <vcl/svapp.hxx>
26 : #include <cppuhelper/supportsservice.hxx>
27 : #include <boost/bind.hpp>
28 :
29 : #include <editeng/outliner.hxx>
30 : #include <editeng/eeitem.hxx>
31 : #include <editeng/fhgtitem.hxx>
32 : #include <svx/svdoattr.hxx>
33 : #include <editeng/ulspitem.hxx>
34 : #include <svl/smplhint.hxx>
35 : #include <svl/itemset.hxx>
36 :
37 : #include <svx/xflbmtit.hxx>
38 : #include <svx/xflbstit.hxx>
39 : #include <editeng/bulletitem.hxx>
40 : #include <editeng/lrspitem.hxx>
41 : #include <svx/unoshprp.hxx>
42 : #include <svx/unoshape.hxx>
43 : #include <svx/svdpool.hxx>
44 : #include "stlsheet.hxx"
45 : #include "sdresid.hxx"
46 : #include "sdpage.hxx"
47 : #include "drawdoc.hxx"
48 : #include "stlpool.hxx"
49 : #include "glob.hrc"
50 : #include "app.hrc"
51 : #include "glob.hxx"
52 : #include "helpids.h"
53 : #include "../ui/inc/DrawViewShell.hxx"
54 : #include "../ui/inc/ViewShellBase.hxx"
55 : #include <editeng/boxitem.hxx>
56 :
57 : #include <boost/make_shared.hpp>
58 :
59 : using ::osl::MutexGuard;
60 : using ::osl::ClearableMutexGuard;
61 : using ::cppu::OInterfaceContainerHelper;
62 : using ::com::sun::star::table::BorderLine;
63 : using namespace ::com::sun::star::uno;
64 : using namespace ::com::sun::star::util;
65 : using namespace ::com::sun::star::lang;
66 : using namespace ::com::sun::star::style;
67 : using namespace ::com::sun::star::beans;
68 : using namespace ::com::sun::star::container;
69 : using namespace ::com::sun::star::drawing;
70 :
71 : #define WID_STYLE_HIDDEN 7997
72 : #define WID_STYLE_DISPNAME 7998
73 : #define WID_STYLE_FAMILY 7999
74 :
75 511348 : static SvxItemPropertySet& GetStylePropertySet()
76 : {
77 : static const SfxItemPropertyMapEntry aFullPropertyMap_Impl[] =
78 : {
79 18 : { OUString("Family"), WID_STYLE_FAMILY, ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0},
80 18 : { OUString("UserDefinedAttributes"), SDRATTR_XMLATTRIBUTES, cppu::UnoType<XNameContainer>::get(), 0, 0},
81 18 : { OUString("DisplayName"), WID_STYLE_DISPNAME, ::cppu::UnoType<OUString>::get(), PropertyAttribute::READONLY, 0},
82 18 : { OUString("Hidden"), WID_STYLE_HIDDEN, ::getCppuType((bool*)0), 0, 0},
83 :
84 36 : SVX_UNOEDIT_NUMBERING_PROPERTIE,
85 90 : SHADOW_PROPERTIES
86 216 : LINE_PROPERTIES
87 72 : LINE_PROPERTIES_START_END
88 486 : FILL_PROPERTIES
89 18 : EDGERADIUS_PROPERTIES
90 1566 : TEXT_PROPERTIES_DEFAULTS
91 90 : CONNECTOR_PROPERTIES
92 360 : SPECIAL_DIMENSIONING_PROPERTIES_DEFAULTS
93 18 : { OUString("TopBorder"), SDRATTR_TABLE_BORDER, ::cppu::UnoType<BorderLine>::get(), 0, TOP_BORDER }, \
94 18 : { OUString("BottomBorder"), SDRATTR_TABLE_BORDER, ::cppu::UnoType<BorderLine>::get(), 0, BOTTOM_BORDER }, \
95 18 : { OUString("LeftBorder"), SDRATTR_TABLE_BORDER, ::cppu::UnoType<BorderLine>::get(), 0, LEFT_BORDER }, \
96 18 : { OUString("RightBorder"), SDRATTR_TABLE_BORDER, ::cppu::UnoType<BorderLine>::get(), 0, RIGHT_BORDER }, \
97 : { OUString(), 0, css::uno::Type(), 0, 0 }
98 514444 : };
99 :
100 511348 : static SvxItemPropertySet aPropSet( aFullPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
101 511348 : return aPropSet;
102 : }
103 :
104 23760 : class ModifyListenerForewarder : public SfxListener
105 : {
106 : public:
107 : ModifyListenerForewarder( SdStyleSheet* pStyleSheet );
108 :
109 : virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) SAL_OVERRIDE;
110 :
111 : private:
112 : SdStyleSheet* mpStyleSheet;
113 : };
114 :
115 11880 : ModifyListenerForewarder::ModifyListenerForewarder( SdStyleSheet* pStyleSheet )
116 11880 : : mpStyleSheet( pStyleSheet )
117 : {
118 11880 : if( pStyleSheet )
119 : {
120 11880 : SfxBroadcaster& rBC = static_cast< SfxBroadcaster& >( *pStyleSheet );
121 11880 : StartListening( rBC );
122 : }
123 11880 : }
124 :
125 31938 : void ModifyListenerForewarder::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/)
126 : {
127 31938 : if( mpStyleSheet )
128 31938 : mpStyleSheet->notifyModifyListener();
129 31938 : }
130 :
131 28762 : SdStyleSheet::SdStyleSheet(const OUString& rDisplayName, SfxStyleSheetBasePool& _rPool, SfxStyleFamily eFamily, sal_uInt16 _nMask)
132 : : SdStyleSheetBase( OUString( rDisplayName ), _rPool, eFamily, _nMask)
133 : , ::cppu::BaseMutex()
134 : , msApiName( rDisplayName )
135 : , mxPool( const_cast< SfxStyleSheetBasePool* >(&_rPool) )
136 28762 : , mrBHelper( m_aMutex )
137 : {
138 28762 : }
139 :
140 0 : SdStyleSheet::SdStyleSheet( const SdStyleSheet & r )
141 : : SdStyleSheetBase( r )
142 : , ::cppu::BaseMutex()
143 : , msApiName( r.msApiName )
144 : , mxPool( r.mxPool )
145 0 : , mrBHelper( m_aMutex )
146 : {
147 0 : }
148 :
149 86286 : SdStyleSheet::~SdStyleSheet()
150 : {
151 28762 : delete pSet;
152 28762 : pSet = NULL; // that following destructors also get a change
153 57524 : }
154 :
155 6 : void SdStyleSheet::SetApiName( const OUString& rApiName )
156 : {
157 6 : msApiName = rApiName;
158 6 : }
159 :
160 38988 : OUString SdStyleSheet::GetApiName() const
161 : {
162 38988 : if( !msApiName.isEmpty() )
163 38988 : return msApiName;
164 : else
165 0 : return GetName();
166 : }
167 :
168 0 : void SdStyleSheet::Load (SvStream& rIn, sal_uInt16 nVersion)
169 : {
170 0 : SfxStyleSheetBase::Load(rIn, nVersion);
171 :
172 : /* previously, the default mask was 0xAFFE. The needed flags were masked
173 : from this mask. Now the flag SFXSTYLEBIT_READONLY was introduced and with
174 : this, all style sheets are read only. Since no style sheet should be read
175 : only in Draw, we reset the flag here. */
176 0 : nMask &= ~SFXSTYLEBIT_READONLY;
177 0 : }
178 :
179 0 : void SdStyleSheet::Store(SvStream& rOut)
180 : {
181 0 : SfxStyleSheetBase::Store(rOut);
182 0 : }
183 :
184 31680 : bool SdStyleSheet::SetParent(const OUString& rParentName)
185 : {
186 31680 : bool bResult = false;
187 :
188 31680 : if (SfxStyleSheet::SetParent(rParentName))
189 : {
190 : // PseudoStyleSheets do not have their own ItemSets
191 31680 : if (nFamily != SD_STYLE_FAMILY_PSEUDO)
192 : {
193 27000 : if( !rParentName.isEmpty() )
194 : {
195 21440 : SfxStyleSheetBase* pStyle = pPool->Find(rParentName, nFamily);
196 21440 : if (pStyle)
197 : {
198 21440 : bResult = true;
199 21440 : SfxItemSet& rParentSet = pStyle->GetItemSet();
200 21440 : GetItemSet().SetParent(&rParentSet);
201 21440 : Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
202 : }
203 : }
204 : else
205 : {
206 5560 : bResult = true;
207 5560 : GetItemSet().SetParent(NULL);
208 5560 : Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
209 : }
210 : }
211 : else
212 : {
213 4680 : bResult = true;
214 : }
215 : }
216 31680 : return bResult;
217 : }
218 :
219 : /**
220 : * create if necessary and return ItemSets
221 : */
222 1982046 : SfxItemSet& SdStyleSheet::GetItemSet()
223 : {
224 1982046 : if (nFamily == SD_STYLE_FAMILY_GRAPHICS || nFamily == SD_STYLE_FAMILY_MASTERPAGE)
225 : {
226 : // we create the ItemSet 'on demand' if necessary
227 1931952 : if (!pSet)
228 : {
229 : sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
230 : XATTR_FILL_FIRST, XATTR_FILL_LAST,
231 :
232 : SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
233 : SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
234 :
235 : SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
236 :
237 : SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST,
238 : SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
239 :
240 : EE_PARA_START, EE_CHAR_END,
241 :
242 : SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
243 :
244 : SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
245 11346 : 0, 0 };
246 :
247 11346 : pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
248 : }
249 :
250 1931952 : return *pSet;
251 : }
252 :
253 50094 : else if( nFamily == SD_STYLE_FAMILY_CELL )
254 : {
255 48174 : if (!pSet)
256 : {
257 : sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
258 : XATTR_FILL_FIRST, XATTR_FILL_LAST,
259 :
260 : SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
261 : SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
262 :
263 : SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
264 :
265 : EE_PARA_START, EE_CHAR_END,
266 :
267 : SDRATTR_TABLE_FIRST, SDRATTR_TABLE_LAST,
268 : SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES,
269 :
270 12376 : 0, 0 };
271 :
272 12376 : pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
273 : }
274 :
275 48174 : return *pSet;
276 : }
277 :
278 : // this is a dummy template for the internal template of the
279 : // current presentation layout; return the ItemSet of that template
280 : else
281 : {
282 :
283 1920 : SdStyleSheet* pSdSheet = GetRealStyleSheet();
284 :
285 1920 : if (pSdSheet)
286 : {
287 1920 : return(pSdSheet->GetItemSet());
288 : }
289 : else
290 : {
291 0 : if (!pSet)
292 : {
293 : sal_uInt16 nWhichPairTable[] = { XATTR_LINE_FIRST, XATTR_LINE_LAST,
294 : XATTR_FILL_FIRST, XATTR_FILL_LAST,
295 :
296 : SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST,
297 : SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_CONTOURFRAME,
298 :
299 : SDRATTR_TEXT_WORDWRAP, SDRATTR_TEXT_AUTOGROWSIZE,
300 :
301 : SDRATTR_EDGE_FIRST, SDRATTR_EDGE_LAST,
302 : SDRATTR_MEASURE_FIRST, SDRATTR_MEASURE_LAST,
303 :
304 : EE_PARA_START, EE_CHAR_END,
305 :
306 : SDRATTR_XMLATTRIBUTES, SDRATTR_TEXT_USEFIXEDCELLHEIGHT,
307 :
308 : SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
309 0 : 0, 0 };
310 :
311 0 : pSet = new SfxItemSet(GetPool().GetPool(), nWhichPairTable);
312 : }
313 :
314 0 : return(*pSet);
315 : }
316 : }
317 : }
318 :
319 : /**
320 : * A template is used when it is referenced by inserted object or by a used
321 : * template.
322 : */
323 18394 : bool SdStyleSheet::IsUsed() const
324 : {
325 18394 : bool bResult = false;
326 :
327 18394 : const size_t nListenerCount = GetSizeOfVector();
328 31372 : for (size_t n = 0; n < nListenerCount; ++n)
329 : {
330 12978 : SfxListener* pListener = GetListener(n);
331 12978 : if( pListener == this )
332 0 : continue;
333 :
334 12978 : const svl::StyleSheetUser* const pUser(dynamic_cast<svl::StyleSheetUser*>(pListener));
335 12978 : if (pUser)
336 9726 : bResult = pUser->isUsedByModel();
337 12978 : if (bResult)
338 0 : break;
339 : }
340 :
341 18394 : if( !bResult )
342 : {
343 18394 : MutexGuard aGuard( mrBHelper.rMutex );
344 :
345 18394 : OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
346 18394 : if( pContainer )
347 : {
348 3252 : Sequence< Reference< XInterface > > aModifyListeners( pContainer->getElements() );
349 3252 : Reference< XInterface > *p = aModifyListeners.getArray();
350 3252 : sal_Int32 nCount = aModifyListeners.getLength();
351 13492 : while( nCount-- && !bResult )
352 : {
353 6988 : Reference< XStyle > xStyle( *p++, UNO_QUERY );
354 6988 : if( xStyle.is() )
355 6988 : bResult = xStyle->isInUse();
356 10240 : }
357 18394 : }
358 : }
359 18394 : return bResult;
360 : }
361 :
362 : /**
363 : * Determine the style sheet for which this dummy is for.
364 : */
365 1920 : SdStyleSheet* SdStyleSheet::GetRealStyleSheet() const
366 : {
367 1920 : OUString aRealStyle;
368 3840 : OUString aSep( SD_LT_SEPARATOR );
369 1920 : SdStyleSheet* pRealStyle = NULL;
370 1920 : SdDrawDocument* pDoc = ((SdStyleSheetPool*)pPool)->GetDoc();
371 :
372 1920 : ::sd::DrawViewShell* pDrawViewShell = 0;
373 :
374 1920 : ::sd::ViewShellBase* pBase = dynamic_cast< ::sd::ViewShellBase* >( SfxViewShell::Current() );
375 1920 : if( pBase )
376 0 : pDrawViewShell = dynamic_cast< ::sd::DrawViewShell* >( pBase->GetMainViewShell().get() );
377 :
378 1920 : if (pDrawViewShell && pDrawViewShell->GetDoc() == pDoc)
379 : {
380 0 : SdPage* pPage = pDrawViewShell->getCurrentPage();
381 0 : if( pPage )
382 : {
383 0 : aRealStyle = pPage->GetLayoutName();
384 : // cut after separator string
385 :
386 0 : if( aRealStyle.indexOf(aSep) >= 0)
387 : {
388 0 : aRealStyle = aRealStyle.copy(0,(aRealStyle.indexOf(aSep) + aSep.getLength()));
389 : }
390 : }
391 : }
392 1920 : if (aRealStyle.isEmpty())
393 : {
394 1920 : SdPage* pPage = pDoc->GetSdPage(0, PK_STANDARD);
395 :
396 1920 : if (pPage)
397 : {
398 80 : aRealStyle = pDoc->GetSdPage(0, PK_STANDARD)->GetLayoutName();
399 : }
400 : else
401 : {
402 : /* no page available yet. This can happen when actualising the
403 : document templates. */
404 1840 : SfxStyleSheetIterator aIter(pPool, SD_STYLE_FAMILY_MASTERPAGE);
405 1840 : SfxStyleSheetBase* pSheet = aIter.First();
406 1840 : if( pSheet )
407 1840 : aRealStyle = pSheet->GetName();
408 : }
409 :
410 1920 : if( aRealStyle.indexOf(aSep) >= 0)
411 : {
412 1920 : aRealStyle = aRealStyle.copy(0,(aRealStyle.indexOf(aSep) + aSep.getLength()));
413 : }
414 : }
415 :
416 : /* now map from the name (specified for country language) to the internal
417 : name (independent of the country language) */
418 3840 : OUString aInternalName;
419 3840 : OUString aStyleName(aName);
420 :
421 1920 : if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_TITLE)))
422 : {
423 20 : aInternalName = OUString(SdResId(STR_LAYOUT_TITLE));
424 : }
425 1900 : else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_SUBTITLE)))
426 : {
427 20 : aInternalName = OUString(SdResId(STR_LAYOUT_SUBTITLE));
428 : }
429 1880 : else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_BACKGROUND)))
430 : {
431 20 : aInternalName = OUString(SdResId(STR_LAYOUT_BACKGROUND));
432 : }
433 1860 : else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS)))
434 : {
435 1660 : aInternalName = OUString(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS));
436 : }
437 200 : else if (aStyleName == OUString(SdResId(STR_PSEUDOSHEET_NOTES)))
438 : {
439 20 : aInternalName = OUString(SdResId(STR_LAYOUT_NOTES));
440 : }
441 : else
442 : {
443 180 : OUString aOutlineStr(SdResId(STR_PSEUDOSHEET_OUTLINE));
444 180 : sal_Int32 nPos = aStyleName.indexOf(aOutlineStr);
445 180 : if (nPos >= 0)
446 : {
447 180 : OUString aNumStr(aStyleName.copy(aOutlineStr.getLength()));
448 180 : aInternalName = OUString(SdResId(STR_LAYOUT_OUTLINE));
449 180 : aInternalName += aNumStr;
450 180 : }
451 : }
452 :
453 1920 : aRealStyle += aInternalName;
454 1920 : pRealStyle = static_cast< SdStyleSheet* >( pPool->Find(aRealStyle, SD_STYLE_FAMILY_MASTERPAGE) );
455 :
456 : #ifdef DBG_UTIL
457 : if( !pRealStyle )
458 : {
459 : SfxStyleSheetIterator aIter(pPool, SD_STYLE_FAMILY_MASTERPAGE);
460 : if( aIter.Count() > 0 )
461 : // StyleSheet not found, but pool already loaded
462 : DBG_ASSERT(pRealStyle, "Internal StyleSheet not found");
463 : }
464 : #endif
465 :
466 3840 : return pRealStyle;
467 : }
468 :
469 : /**
470 : * Determine pseudo style sheet which stands for this style sheet.
471 : */
472 0 : SdStyleSheet* SdStyleSheet::GetPseudoStyleSheet() const
473 : {
474 0 : SdStyleSheet* pPseudoStyle = NULL;
475 0 : OUString aSep( SD_LT_SEPARATOR );
476 0 : OUString aStyleName(aName);
477 : // without layout name and separator
478 :
479 0 : if( aStyleName.indexOf(aSep) >=0 )
480 : {
481 0 : aStyleName = aStyleName.copy (aStyleName.indexOf(aSep) + aSep.getLength());
482 : }
483 :
484 0 : if (aStyleName == OUString(SdResId(STR_LAYOUT_TITLE)))
485 : {
486 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_TITLE));
487 : }
488 0 : else if (aStyleName == OUString(SdResId(STR_LAYOUT_SUBTITLE)))
489 : {
490 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_SUBTITLE));
491 : }
492 0 : else if (aStyleName == OUString(SdResId(STR_LAYOUT_BACKGROUND)))
493 : {
494 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_BACKGROUND));
495 : }
496 0 : else if (aStyleName == OUString(SdResId(STR_LAYOUT_BACKGROUNDOBJECTS)))
497 : {
498 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_BACKGROUNDOBJECTS));
499 : }
500 0 : else if (aStyleName == OUString(SdResId(STR_LAYOUT_NOTES)))
501 : {
502 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_NOTES));
503 : }
504 : else
505 : {
506 0 : OUString aOutlineStr((SdResId(STR_LAYOUT_OUTLINE)));
507 0 : sal_Int32 nPos = aStyleName.indexOf(aOutlineStr);
508 0 : if (nPos != -1)
509 : {
510 0 : OUString aNumStr(aStyleName.copy(aOutlineStr.getLength()));
511 0 : aStyleName = OUString(SdResId(STR_PSEUDOSHEET_OUTLINE));
512 0 : aStyleName += aNumStr;
513 0 : }
514 : }
515 :
516 0 : pPseudoStyle = static_cast<SdStyleSheet*>(pPool->Find(aStyleName, SD_STYLE_FAMILY_PSEUDO));
517 : DBG_ASSERT(pPseudoStyle, "PseudoStyleSheet missing");
518 :
519 0 : return pPseudoStyle;
520 : }
521 :
522 2126878 : void SdStyleSheet::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
523 : {
524 : // first, base class functionality
525 2126878 : SfxStyleSheet::Notify(rBC, rHint);
526 :
527 : /* if the dummy gets a notify about a changed attribute, he takes care that
528 : the actual ment style sheet sends broadcasts. */
529 2126878 : const SfxSimpleHint* pSimple = dynamic_cast<const SfxSimpleHint*>(&rHint);
530 2126878 : if (pSimple && pSimple->GetId() == SFX_HINT_DATACHANGED && nFamily == SD_STYLE_FAMILY_PSEUDO)
531 : {
532 0 : SdStyleSheet* pRealStyle = GetRealStyleSheet();
533 0 : if (pRealStyle)
534 0 : pRealStyle->Broadcast(rHint);
535 : }
536 2126878 : }
537 :
538 : /**
539 : * Adjust the bullet width and the left text indent of the provided ItemSets to
540 : * their font height. The new values are calculated that the ratio to the font
541 : * height is as in the style sheet.
542 : *
543 : * @param bOnlyMissingItems If sal_True, only not set items are completed. With
544 : * sal_False, are items are overwritten.
545 : */
546 0 : void SdStyleSheet::AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems)
547 : {
548 : /* If not explicit set, adjust bullet width and text indent to new font
549 : height. */
550 0 : SfxStyleFamily eFamily = nFamily;
551 0 : OUString aStyleName(aName);
552 0 : if (eFamily == SD_STYLE_FAMILY_PSEUDO)
553 : {
554 0 : SfxStyleSheet* pRealStyle = GetRealStyleSheet();
555 0 : eFamily = pRealStyle->GetFamily();
556 0 : aStyleName = pRealStyle->GetName();
557 : }
558 :
559 0 : if (eFamily == SD_STYLE_FAMILY_MASTERPAGE &&
560 0 : aStyleName.indexOf(OUString(SdResId(STR_LAYOUT_OUTLINE))) != -1 &&
561 0 : rSet.GetItemState(EE_CHAR_FONTHEIGHT) == SfxItemState::SET)
562 : {
563 0 : const SfxItemSet* pCurSet = &GetItemSet();
564 0 : sal_uInt32 nNewHeight = ((SvxFontHeightItem&)rSet.Get(EE_CHAR_FONTHEIGHT)).GetHeight();
565 0 : sal_uInt32 nOldHeight = ((SvxFontHeightItem&)pCurSet->Get(EE_CHAR_FONTHEIGHT)).GetHeight();
566 :
567 0 : if (rSet.GetItemState(EE_PARA_BULLET) != SfxItemState::SET || !bOnlyMissingItems)
568 : {
569 0 : const SvxBulletItem& rBItem = (const SvxBulletItem&)pCurSet->Get(EE_PARA_BULLET);
570 0 : double fBulletFraction = double(rBItem.GetWidth()) / nOldHeight;
571 0 : SvxBulletItem aNewBItem(rBItem);
572 0 : aNewBItem.SetWidth((sal_uInt32)(fBulletFraction * nNewHeight));
573 0 : rSet.Put(aNewBItem);
574 : }
575 :
576 0 : if (rSet.GetItemState(EE_PARA_LRSPACE) != SfxItemState::SET || !bOnlyMissingItems)
577 : {
578 0 : const SvxLRSpaceItem& rLRItem = (const SvxLRSpaceItem&)pCurSet->Get(EE_PARA_LRSPACE);
579 0 : double fIndentFraction = double(rLRItem.GetTxtLeft()) / nOldHeight;
580 0 : SvxLRSpaceItem aNewLRItem(rLRItem);
581 0 : aNewLRItem.SetTxtLeft(fIndentFraction * nNewHeight);
582 0 : double fFirstIndentFraction = double(rLRItem.GetTxtFirstLineOfst()) / nOldHeight;
583 0 : aNewLRItem.SetTxtFirstLineOfst((short)(fFirstIndentFraction * nNewHeight));
584 0 : rSet.Put(aNewLRItem);
585 : }
586 :
587 0 : if (rSet.GetItemState(EE_PARA_ULSPACE) != SfxItemState::SET || !bOnlyMissingItems)
588 : {
589 0 : const SvxULSpaceItem& rULItem = (const SvxULSpaceItem&)pCurSet->Get(EE_PARA_ULSPACE);
590 0 : SvxULSpaceItem aNewULItem(rULItem);
591 0 : double fLowerFraction = double(rULItem.GetLower()) / nOldHeight;
592 0 : aNewULItem.SetLower((sal_uInt16)(fLowerFraction * nNewHeight));
593 0 : double fUpperFraction = double(rULItem.GetUpper()) / nOldHeight;
594 0 : aNewULItem.SetUpper((sal_uInt16)(fUpperFraction * nNewHeight));
595 0 : rSet.Put(aNewULItem);
596 : }
597 0 : }
598 0 : }
599 :
600 0 : bool SdStyleSheet::HasFollowSupport() const
601 : {
602 0 : return false;
603 : }
604 :
605 0 : bool SdStyleSheet::HasParentSupport() const
606 : {
607 0 : return true;
608 : }
609 :
610 0 : bool SdStyleSheet::HasClearParentSupport() const
611 : {
612 0 : return true;
613 : }
614 :
615 1658 : bool SdStyleSheet::SetName(const OUString& rName, bool bReindexNow)
616 : {
617 1658 : return SfxStyleSheet::SetName(rName, bReindexNow);
618 : }
619 :
620 16800 : void SdStyleSheet::SetHelpId( const OUString& r, sal_uLong nId )
621 : {
622 16800 : SfxStyleSheet::SetHelpId( r, nId );
623 :
624 16800 : if( (nId >= HID_PSEUDOSHEET_OUTLINE1) && ( nId <= HID_PSEUDOSHEET_OUTLINE9 ) )
625 : {
626 6822 : msApiName = "outline";
627 6822 : msApiName += OUString( (sal_Unicode)( '1' + (nId - HID_PSEUDOSHEET_OUTLINE1) ) );
628 : }
629 : else
630 : {
631 : static struct ApiNameMap
632 : {
633 : const sal_Char* mpApiName;
634 : sal_uInt32 mnApiNameLength;
635 : sal_uInt32 mnHelpId;
636 : }
637 : pApiNameMap[] =
638 : {
639 : { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_PSEUDOSHEET_TITLE },
640 : { RTL_CONSTASCII_STRINGPARAM( "subtitle" ), HID_PSEUDOSHEET_SUBTITLE },
641 : { RTL_CONSTASCII_STRINGPARAM( "background" ), HID_PSEUDOSHEET_BACKGROUND },
642 : { RTL_CONSTASCII_STRINGPARAM( "backgroundobjects" ),HID_PSEUDOSHEET_BACKGROUNDOBJECTS },
643 : { RTL_CONSTASCII_STRINGPARAM( "notes" ), HID_PSEUDOSHEET_NOTES },
644 : { RTL_CONSTASCII_STRINGPARAM( "standard" ), HID_STANDARD_STYLESHEET_NAME },
645 : { RTL_CONSTASCII_STRINGPARAM( "objectwitharrow" ), HID_POOLSHEET_OBJWITHARROW },
646 : { RTL_CONSTASCII_STRINGPARAM( "objectwithshadow" ), HID_POOLSHEET_OBJWITHSHADOW },
647 : { RTL_CONSTASCII_STRINGPARAM( "objectwithoutfill" ),HID_POOLSHEET_OBJWITHOUTFILL },
648 : { RTL_CONSTASCII_STRINGPARAM( "text" ), HID_POOLSHEET_TEXT },
649 : { RTL_CONSTASCII_STRINGPARAM( "textbody" ), HID_POOLSHEET_TEXTBODY },
650 : { RTL_CONSTASCII_STRINGPARAM( "textbodyjustfied" ), HID_POOLSHEET_TEXTBODY_JUSTIFY },
651 : { RTL_CONSTASCII_STRINGPARAM( "textbodyindent" ), HID_POOLSHEET_TEXTBODY_INDENT },
652 : { RTL_CONSTASCII_STRINGPARAM( "title" ), HID_POOLSHEET_TITLE },
653 : { RTL_CONSTASCII_STRINGPARAM( "title1" ), HID_POOLSHEET_TITLE1 },
654 : { RTL_CONSTASCII_STRINGPARAM( "title2" ), HID_POOLSHEET_TITLE2 },
655 : { RTL_CONSTASCII_STRINGPARAM( "headline" ), HID_POOLSHEET_HEADLINE },
656 : { RTL_CONSTASCII_STRINGPARAM( "headline1" ), HID_POOLSHEET_HEADLINE1 },
657 : { RTL_CONSTASCII_STRINGPARAM( "headline2" ), HID_POOLSHEET_HEADLINE2 },
658 : { RTL_CONSTASCII_STRINGPARAM( "measure" ), HID_POOLSHEET_MEASURE },
659 : { 0, 0, 0 }
660 : };
661 :
662 9978 : ApiNameMap* p = pApiNameMap;
663 107616 : while( p->mpApiName )
664 : {
665 96910 : if( nId == p->mnHelpId )
666 : {
667 9250 : msApiName = OUString( p->mpApiName, p->mnApiNameLength, RTL_TEXTENCODING_ASCII_US );
668 9250 : break;
669 : }
670 87660 : p++;
671 : }
672 : }
673 16800 : }
674 :
675 9088 : OUString SdStyleSheet::GetFamilyString( SfxStyleFamily eFamily )
676 : {
677 9088 : switch( eFamily )
678 : {
679 : case SD_STYLE_FAMILY_CELL:
680 3268 : return OUString( "cell" );
681 : default:
682 : OSL_FAIL( "SdStyleSheet::GetFamilyString(), illegal family!" );
683 : case SD_STYLE_FAMILY_GRAPHICS:
684 5820 : return OUString( "graphics" );
685 : }
686 : }
687 :
688 459328 : void SdStyleSheet::throwIfDisposed() throw (RuntimeException)
689 : {
690 459328 : if( !mxPool.is() )
691 0 : throw DisposedException();
692 459328 : }
693 :
694 6 : SdStyleSheet* SdStyleSheet::CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily )
695 : {
696 6 : OUString aPrefix( "user" );
697 12 : OUString aName;
698 6 : sal_Int32 nIndex = 1;
699 6 : do
700 : {
701 6 : aName = aPrefix + OUString::number( nIndex++ );
702 : }
703 6 : while( rPool.Find( aName, eFamily ) != 0 );
704 :
705 12 : return new SdStyleSheet(aName, rPool, eFamily, SFXSTYLEBIT_USERDEF);
706 : }
707 :
708 : // XInterface
709 :
710 878614 : void SAL_CALL SdStyleSheet::release( ) throw ()
711 : {
712 878614 : if (osl_atomic_decrement( &m_refCount ) == 0)
713 : {
714 : // restore reference count:
715 28762 : osl_atomic_increment( &m_refCount );
716 28762 : if (! mrBHelper.bDisposed) try
717 : {
718 0 : dispose();
719 : }
720 0 : catch (RuntimeException const& exc)
721 : { // don't break throw ()
722 : OSL_FAIL(
723 : OUStringToOString(
724 : exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
725 : static_cast<void>(exc);
726 : }
727 : OSL_ASSERT( mrBHelper.bDisposed );
728 28762 : SdStyleSheetBase::release();
729 : }
730 878614 : }
731 :
732 : // XComponent
733 :
734 28762 : void SAL_CALL SdStyleSheet::dispose( ) throw (RuntimeException, std::exception)
735 : {
736 28762 : ClearableMutexGuard aGuard( mrBHelper.rMutex );
737 28762 : if (!mrBHelper.bDisposed && !mrBHelper.bInDispose)
738 : {
739 28762 : mrBHelper.bInDispose = sal_True;
740 28762 : aGuard.clear();
741 : try
742 : {
743 : // side effect: keeping a reference to this
744 28762 : EventObject aEvt( static_cast< OWeakObject * >( this ) );
745 : try
746 : {
747 28762 : mrBHelper.aLC.disposeAndClear( aEvt );
748 28762 : disposing();
749 : }
750 0 : catch (...)
751 : {
752 0 : MutexGuard aGuard2( mrBHelper.rMutex );
753 : // bDisposed and bInDispose must be set in this order:
754 0 : mrBHelper.bDisposed = sal_True;
755 0 : mrBHelper.bInDispose = sal_False;
756 0 : throw;
757 : }
758 57524 : MutexGuard aGuard2( mrBHelper.rMutex );
759 : // bDisposed and bInDispose must be set in this order:
760 28762 : mrBHelper.bDisposed = sal_True;
761 57524 : mrBHelper.bInDispose = sal_False;
762 : }
763 0 : catch (RuntimeException &)
764 : {
765 0 : throw;
766 : }
767 0 : catch (const Exception & exc)
768 : {
769 0 : throw RuntimeException( "unexpected UNO exception caught: " + exc.Message );
770 : }
771 28762 : }
772 28762 : }
773 :
774 28762 : void SdStyleSheet::disposing()
775 : {
776 28762 : mxPool.clear();
777 28762 : }
778 :
779 0 : void SAL_CALL SdStyleSheet::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException, std::exception)
780 : {
781 0 : ClearableMutexGuard aGuard( mrBHelper.rMutex );
782 0 : if (mrBHelper.bDisposed || mrBHelper.bInDispose)
783 : {
784 0 : aGuard.clear();
785 0 : EventObject aEvt( static_cast< OWeakObject * >( this ) );
786 0 : xListener->disposing( aEvt );
787 : }
788 : else
789 : {
790 0 : mrBHelper.addListener( ::getCppuType( &xListener ), xListener );
791 0 : }
792 0 : }
793 :
794 0 : void SAL_CALL SdStyleSheet::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException, std::exception)
795 : {
796 0 : mrBHelper.removeListener( ::getCppuType( &xListener ), xListener );
797 0 : }
798 :
799 : // XModifyBroadcaster
800 :
801 27748 : void SAL_CALL SdStyleSheet::addModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
802 : {
803 27748 : ClearableMutexGuard aGuard( mrBHelper.rMutex );
804 27748 : if (mrBHelper.bDisposed || mrBHelper.bInDispose)
805 : {
806 0 : aGuard.clear();
807 0 : EventObject aEvt( static_cast< OWeakObject * >( this ) );
808 0 : xListener->disposing( aEvt );
809 : }
810 : else
811 : {
812 27748 : if( !mpModifyListenerForewarder.get() )
813 11880 : mpModifyListenerForewarder.reset( new ModifyListenerForewarder( this ) );
814 27748 : mrBHelper.addListener( cppu::UnoType<XModifyListener>::get(), xListener );
815 27748 : }
816 27748 : }
817 :
818 0 : void SAL_CALL SdStyleSheet::removeModifyListener( const Reference< XModifyListener >& xListener ) throw (RuntimeException, std::exception)
819 : {
820 0 : mrBHelper.removeListener( cppu::UnoType<XModifyListener>::get(), xListener );
821 0 : }
822 :
823 31938 : void SdStyleSheet::notifyModifyListener()
824 : {
825 31938 : MutexGuard aGuard( mrBHelper.rMutex );
826 :
827 31938 : OInterfaceContainerHelper * pContainer = mrBHelper.getContainer( cppu::UnoType<XModifyListener>::get() );
828 31938 : if( pContainer )
829 : {
830 31938 : EventObject aEvt( static_cast< OWeakObject * >( this ) );
831 31938 : pContainer->forEach<XModifyListener>( boost::bind( &XModifyListener::modified, _1, boost::cref( aEvt ) ) );
832 31938 : }
833 31938 : }
834 :
835 : // XServiceInfo
836 0 : OUString SAL_CALL SdStyleSheet::getImplementationName() throw(RuntimeException, std::exception)
837 : {
838 0 : return OUString( "SdStyleSheet" );
839 : }
840 :
841 0 : sal_Bool SAL_CALL SdStyleSheet::supportsService( const OUString& ServiceName ) throw(RuntimeException, std::exception)
842 : {
843 0 : return cppu::supportsService( this, ServiceName );
844 : }
845 :
846 0 : Sequence< OUString > SAL_CALL SdStyleSheet::getSupportedServiceNames() throw(RuntimeException, std::exception)
847 : {
848 0 : Sequence< OUString > aNameSequence( 10 );
849 0 : OUString* pStrings = aNameSequence.getArray();
850 :
851 0 : *pStrings++ = "com.sun.star.style.Style";
852 0 : *pStrings++ = "com.sun.star.drawing.FillProperties";
853 0 : *pStrings++ = "com.sun.star.drawing.LineProperties";
854 0 : *pStrings++ = "com.sun.star.drawing.ShadowProperties";
855 0 : *pStrings++ = "com.sun.star.drawing.ConnectorProperties";
856 0 : *pStrings++ = "com.sun.star.drawing.MeasureProperties";
857 0 : *pStrings++ = "com.sun.star.style.ParagraphProperties";
858 0 : *pStrings++ = "com.sun.star.style.CharacterProperties";
859 0 : *pStrings++ = "com.sun.star.drawing.TextProperties";
860 0 : *pStrings++ = "com.sun.star.drawing.Text";
861 :
862 0 : return aNameSequence;
863 : }
864 :
865 : // XNamed
866 1728 : OUString SAL_CALL SdStyleSheet::getName() throw(RuntimeException, std::exception)
867 : {
868 1728 : SolarMutexGuard aGuard;
869 1728 : throwIfDisposed();
870 1728 : return GetApiName();
871 : }
872 :
873 0 : void SAL_CALL SdStyleSheet::setName( const OUString& rName ) throw(RuntimeException, std::exception)
874 : {
875 0 : SolarMutexGuard aGuard;
876 0 : throwIfDisposed();
877 :
878 0 : if( SetName( rName ) )
879 : {
880 0 : msApiName = rName;
881 0 : Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
882 0 : }
883 0 : }
884 :
885 : // XStyle
886 :
887 0 : sal_Bool SAL_CALL SdStyleSheet::isUserDefined() throw(RuntimeException, std::exception)
888 : {
889 0 : SolarMutexGuard aGuard;
890 0 : throwIfDisposed();
891 0 : return IsUserDefined() ? sal_True : sal_False;
892 : }
893 :
894 748 : sal_Bool SAL_CALL SdStyleSheet::isInUse() throw(RuntimeException, std::exception)
895 : {
896 748 : SolarMutexGuard aGuard;
897 748 : throwIfDisposed();
898 748 : return IsUsed() ? sal_True : sal_False;
899 : }
900 :
901 436 : OUString SAL_CALL SdStyleSheet::getParentStyle() throw(RuntimeException, std::exception)
902 : {
903 436 : SolarMutexGuard aGuard;
904 436 : throwIfDisposed();
905 :
906 436 : if( !GetParent().isEmpty() )
907 : {
908 378 : SdStyleSheet* pParentStyle = static_cast< SdStyleSheet* >( mxPool->Find( GetParent(), nFamily ) );
909 378 : if( pParentStyle )
910 378 : return pParentStyle->msApiName;
911 : }
912 58 : return OUString();
913 : }
914 :
915 860 : void SAL_CALL SdStyleSheet::setParentStyle( const OUString& rParentName ) throw(NoSuchElementException, RuntimeException, std::exception)
916 : {
917 860 : SolarMutexGuard aGuard;
918 860 : throwIfDisposed();
919 :
920 860 : if( !rParentName.isEmpty() )
921 : {
922 816 : OUString const name(GetName());
923 816 : sal_Int32 const sep(name.indexOf(SD_LT_SEPARATOR));
924 1632 : OUString const master((sep == -1) ? OUString() : name.copy(0, sep));
925 1632 : boost::shared_ptr<SfxStyleSheetIterator> aSSSI = boost::make_shared<SfxStyleSheetIterator>(mxPool.get(), nFamily);
926 3168 : for (SfxStyleSheetBase *pStyle = aSSSI->First(); pStyle; pStyle = aSSSI->Next())
927 : {
928 : // we hope that we have only sd style sheets
929 1992 : SdStyleSheet* pSdStyleSheet = static_cast<SdStyleSheet*>(pStyle);
930 1992 : OUString const curName(pStyle->GetName());
931 1992 : sal_Int32 const curSep(curName.indexOf(SD_LT_SEPARATOR));
932 : OUString const curMaster((curSep == -1)
933 3168 : ? OUString() : curName.copy(0, curSep));
934 : // check that the master matches, as msApiName exists once per
935 : // master page
936 1992 : if (pSdStyleSheet->msApiName == rParentName && master == curMaster)
937 : {
938 816 : if( pStyle != this )
939 : {
940 816 : SetParent(curName);
941 : }
942 1676 : return;
943 : }
944 1176 : }
945 816 : throw NoSuchElementException();
946 : }
947 : else
948 : {
949 44 : SetParent( rParentName );
950 44 : }
951 : }
952 :
953 : // XPropertySet
954 :
955 12390 : Reference< XPropertySetInfo > SdStyleSheet::getPropertySetInfo() throw(RuntimeException, std::exception)
956 : {
957 12390 : throwIfDisposed();
958 12390 : static Reference< XPropertySetInfo > xInfo;
959 12390 : if( !xInfo.is() )
960 16 : xInfo = GetStylePropertySet().getPropertySetInfo();
961 12390 : return xInfo;
962 : }
963 :
964 55622 : void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, const Any& aValue ) throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception)
965 : {
966 55622 : SolarMutexGuard aGuard;
967 55622 : throwIfDisposed();
968 :
969 55622 : const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
970 55622 : if( pEntry == NULL )
971 : {
972 1704 : throw UnknownPropertyException();
973 : }
974 : else
975 : {
976 53918 : if( pEntry->nWID == WID_STYLE_HIDDEN )
977 : {
978 0 : bool bValue = false;
979 0 : if ( aValue >>= bValue )
980 0 : SetHidden( bValue );
981 0 : return;
982 : }
983 53918 : if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
984 66 : return; // not yet implemented for styles
985 :
986 53852 : if( pEntry->nWID == WID_STYLE_FAMILY )
987 0 : throw PropertyVetoException();
988 :
989 53852 : if( (pEntry->nWID == EE_PARA_NUMBULLET) && (GetFamily() == SD_STYLE_FAMILY_MASTERPAGE) )
990 : {
991 114 : OUString aStr;
992 114 : const sal_uInt32 nTempHelpId = GetHelpId( aStr );
993 :
994 114 : if( (nTempHelpId >= HID_PSEUDOSHEET_OUTLINE2) && (nTempHelpId <= HID_PSEUDOSHEET_OUTLINE9) )
995 4 : return;
996 : }
997 :
998 53848 : SfxItemSet &rStyleSet = GetItemSet();
999 :
1000 53848 : if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1001 : {
1002 : BitmapMode eMode;
1003 0 : if( aValue >>= eMode )
1004 : {
1005 0 : rStyleSet.Put( XFillBmpStretchItem( eMode == BitmapMode_STRETCH ) );
1006 0 : rStyleSet.Put( XFillBmpTileItem( eMode == BitmapMode_REPEAT ) );
1007 0 : return;
1008 : }
1009 0 : throw IllegalArgumentException();
1010 : }
1011 :
1012 53848 : SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID);
1013 53848 : aSet.Put( rStyleSet );
1014 :
1015 53848 : if( !aSet.Count() )
1016 : {
1017 17564 : if( EE_PARA_NUMBULLET == pEntry->nWID )
1018 : {
1019 150 : vcl::Font aBulletFont;
1020 150 : SdStyleSheetPool::PutNumBulletItem( this, aBulletFont );
1021 150 : aSet.Put( rStyleSet );
1022 : }
1023 : else
1024 : {
1025 17414 : aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
1026 : }
1027 : }
1028 :
1029 53966 : if( pEntry->nMemberId == MID_NAME &&
1030 348 : ( pEntry->nWID == XATTR_FILLBITMAP || pEntry->nWID == XATTR_FILLGRADIENT ||
1031 338 : pEntry->nWID == XATTR_FILLHATCH || pEntry->nWID == XATTR_FILLFLOATTRANSPARENCE ||
1032 152 : pEntry->nWID == XATTR_LINESTART || pEntry->nWID == XATTR_LINEEND || pEntry->nWID == XATTR_LINEDASH) )
1033 : {
1034 118 : OUString aTempName;
1035 118 : if(!(aValue >>= aTempName ))
1036 0 : throw IllegalArgumentException();
1037 :
1038 118 : SvxShape::SetFillAttribute( pEntry->nWID, aTempName, aSet );
1039 : }
1040 53730 : else if(!SvxUnoTextRangeBase::SetPropertyValueHelper( aSet, pEntry, aValue, aSet ))
1041 : {
1042 52560 : SvxItemPropertySet_setPropertyValue( GetStylePropertySet(), pEntry, aValue, aSet );
1043 : }
1044 :
1045 53848 : rStyleSet.Put( aSet );
1046 53848 : Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1047 55552 : }
1048 : }
1049 :
1050 17138 : Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1051 : {
1052 17138 : SolarMutexGuard aGuard;
1053 :
1054 17138 : throwIfDisposed();
1055 :
1056 17138 : const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1057 17138 : if( pEntry == NULL )
1058 : {
1059 12 : throw UnknownPropertyException();
1060 : }
1061 : else
1062 : {
1063 17126 : Any aAny;
1064 :
1065 17126 : if( pEntry->nWID == WID_STYLE_FAMILY )
1066 : {
1067 108 : if( nFamily == SD_STYLE_FAMILY_MASTERPAGE )
1068 : {
1069 80 : const OUString aLayoutName( GetName() );
1070 80 : aAny <<= aLayoutName.copy( 0, aLayoutName.indexOf( SD_LT_SEPARATOR) );
1071 : }
1072 : else
1073 : {
1074 28 : aAny <<= GetFamilyString(nFamily);
1075 : }
1076 : }
1077 17018 : else if( pEntry->nWID == WID_STYLE_DISPNAME )
1078 : {
1079 0 : aAny <<= maDisplayName;
1080 : }
1081 17018 : else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1082 : {
1083 0 : aAny <<= sal_False;
1084 : }
1085 17018 : else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1086 : {
1087 0 : SfxItemSet &rStyleSet = GetItemSet();
1088 :
1089 0 : XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)rStyleSet.GetItem(XATTR_FILLBMP_STRETCH);
1090 0 : XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)rStyleSet.GetItem(XATTR_FILLBMP_TILE);
1091 :
1092 0 : if( pStretchItem && pTileItem )
1093 : {
1094 0 : if( pTileItem->GetValue() )
1095 0 : aAny <<= BitmapMode_REPEAT;
1096 0 : else if( pStretchItem->GetValue() )
1097 0 : aAny <<= BitmapMode_STRETCH;
1098 : else
1099 0 : aAny <<= BitmapMode_NO_REPEAT;
1100 : }
1101 : }
1102 17018 : else if( pEntry->nWID == WID_STYLE_HIDDEN )
1103 : {
1104 436 : aAny <<= IsHidden( );
1105 : }
1106 : else
1107 : {
1108 16582 : SfxItemSet aSet( GetPool().GetPool(), pEntry->nWID, pEntry->nWID);
1109 :
1110 : const SfxPoolItem* pItem;
1111 16582 : SfxItemSet& rStyleSet = GetItemSet();
1112 :
1113 16582 : if( rStyleSet.GetItemState( pEntry->nWID, true, &pItem ) == SfxItemState::SET )
1114 12226 : aSet.Put( *pItem );
1115 :
1116 16582 : if( !aSet.Count() )
1117 4356 : aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
1118 :
1119 16582 : if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pEntry, aAny ))
1120 540 : return aAny;
1121 :
1122 : // Hole Wert aus ItemSet
1123 16042 : aAny = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(),pEntry, aSet );
1124 : }
1125 :
1126 16586 : if( pEntry->aType != aAny.getValueType() )
1127 : {
1128 : // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here
1129 36 : if( ( pEntry->aType == ::cppu::UnoType<sal_Int16>::get()) && aAny.getValueType() == ::cppu::UnoType<sal_Int32>::get() )
1130 : {
1131 36 : sal_Int32 nValue = 0;
1132 36 : aAny >>= nValue;
1133 36 : aAny <<= (sal_Int16)nValue;
1134 : }
1135 : else
1136 : {
1137 : OSL_FAIL("SvxShape::GetAnyForItem() Returnvalue has wrong Type!" );
1138 : }
1139 : }
1140 :
1141 16586 : return aAny;
1142 17138 : }
1143 : }
1144 :
1145 0 : void SAL_CALL SdStyleSheet::addPropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) {}
1146 0 : void SAL_CALL SdStyleSheet::removePropertyChangeListener( const OUString& , const Reference< XPropertyChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) {}
1147 0 : void SAL_CALL SdStyleSheet::addVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) {}
1148 0 : void SAL_CALL SdStyleSheet::removeVetoableChangeListener( const OUString& , const Reference< XVetoableChangeListener >& ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) {}
1149 :
1150 : // XPropertyState
1151 :
1152 360536 : PropertyState SAL_CALL SdStyleSheet::getPropertyState( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1153 : {
1154 360536 : SolarMutexGuard aGuard;
1155 :
1156 360536 : throwIfDisposed();
1157 :
1158 360536 : const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1159 :
1160 360536 : if( pEntry == NULL )
1161 0 : throw UnknownPropertyException();
1162 :
1163 360536 : if( pEntry->nWID == WID_STYLE_FAMILY )
1164 : {
1165 0 : return PropertyState_DIRECT_VALUE;
1166 : }
1167 360536 : else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1168 : {
1169 1494 : return PropertyState_DEFAULT_VALUE;
1170 : }
1171 359042 : else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1172 : {
1173 1500 : const SfxItemSet& rSet = GetItemSet();
1174 :
1175 3000 : if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SfxItemState::SET ||
1176 1500 : rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SfxItemState::SET )
1177 : {
1178 0 : return PropertyState_DIRECT_VALUE;
1179 : }
1180 : else
1181 : {
1182 1500 : return PropertyState_AMBIGUOUS_VALUE;
1183 : }
1184 : }
1185 : else
1186 : {
1187 357542 : SfxItemSet &rStyleSet = GetItemSet();
1188 :
1189 : PropertyState eState;
1190 :
1191 357542 : switch( rStyleSet.GetItemState( pEntry->nWID, false ) )
1192 : {
1193 : case SfxItemState::READONLY:
1194 : case SfxItemState::SET:
1195 16050 : eState = PropertyState_DIRECT_VALUE;
1196 16050 : break;
1197 : case SfxItemState::DEFAULT:
1198 316084 : eState = PropertyState_DEFAULT_VALUE;
1199 316084 : break;
1200 : default:
1201 25408 : eState = PropertyState_AMBIGUOUS_VALUE;
1202 25408 : break;
1203 : }
1204 :
1205 : // if a item is set, this doesn't mean we want it :)
1206 357542 : if( ( PropertyState_DIRECT_VALUE == eState ) )
1207 : {
1208 16050 : switch( pEntry->nWID )
1209 : {
1210 : case XATTR_FILLBITMAP:
1211 : case XATTR_FILLGRADIENT:
1212 : case XATTR_FILLHATCH:
1213 : case XATTR_FILLFLOATTRANSPARENCE:
1214 : case XATTR_LINEEND:
1215 : case XATTR_LINESTART:
1216 : case XATTR_LINEDASH:
1217 : {
1218 522 : NameOrIndex* pItem = (NameOrIndex*)rStyleSet.GetItem((sal_uInt16)pEntry->nWID);
1219 522 : if( ( pItem == NULL ) || pItem->GetName().isEmpty() )
1220 348 : eState = PropertyState_DEFAULT_VALUE;
1221 : }
1222 : }
1223 : }
1224 :
1225 357542 : return eState;
1226 360536 : }
1227 : }
1228 :
1229 436 : Sequence< PropertyState > SAL_CALL SdStyleSheet::getPropertyStates( const Sequence< OUString >& aPropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1230 : {
1231 436 : SolarMutexGuard aGuard;
1232 :
1233 436 : throwIfDisposed();
1234 :
1235 436 : sal_Int32 nCount = aPropertyName.getLength();
1236 436 : const OUString* pNames = aPropertyName.getConstArray();
1237 :
1238 436 : Sequence< PropertyState > aPropertyStateSequence( nCount );
1239 436 : PropertyState* pState = aPropertyStateSequence.getArray();
1240 :
1241 64092 : while( nCount-- )
1242 63220 : *pState++ = getPropertyState( *pNames++ );
1243 :
1244 436 : return aPropertyStateSequence;
1245 : }
1246 :
1247 9434 : void SAL_CALL SdStyleSheet::setPropertyToDefault( const OUString& PropertyName ) throw(UnknownPropertyException, RuntimeException, std::exception)
1248 : {
1249 9434 : SolarMutexGuard aGuard;
1250 :
1251 9434 : throwIfDisposed();
1252 :
1253 9434 : const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( PropertyName );
1254 9434 : if( pEntry == NULL )
1255 0 : throw UnknownPropertyException();
1256 :
1257 9434 : SfxItemSet &rStyleSet = GetItemSet();
1258 :
1259 9434 : if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1260 : {
1261 0 : rStyleSet.ClearItem( XATTR_FILLBMP_STRETCH );
1262 0 : rStyleSet.ClearItem( XATTR_FILLBMP_TILE );
1263 : }
1264 : else
1265 : {
1266 9434 : rStyleSet.ClearItem( pEntry->nWID );
1267 : }
1268 9434 : Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1269 9434 : }
1270 :
1271 0 : Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception)
1272 : {
1273 0 : SolarMutexGuard aGuard;
1274 :
1275 0 : throwIfDisposed();
1276 :
1277 0 : const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName );
1278 0 : if( pEntry == NULL )
1279 0 : throw UnknownPropertyException();
1280 0 : Any aRet;
1281 0 : if( pEntry->nWID == WID_STYLE_FAMILY )
1282 : {
1283 0 : aRet <<= GetFamilyString(nFamily);
1284 : }
1285 0 : else if( pEntry->nWID == SDRATTR_TEXTDIRECTION )
1286 : {
1287 0 : aRet <<= sal_False;
1288 : }
1289 0 : else if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE )
1290 : {
1291 0 : aRet <<= BitmapMode_REPEAT;
1292 : }
1293 : else
1294 : {
1295 0 : SfxItemPool& rMyPool = GetPool().GetPool();
1296 0 : SfxItemSet aSet( rMyPool, pEntry->nWID, pEntry->nWID);
1297 0 : aSet.Put( rMyPool.GetDefaultItem( pEntry->nWID ) );
1298 0 : aRet = SvxItemPropertySet_getPropertyValue( GetStylePropertySet(), pEntry, aSet );
1299 : }
1300 0 : return aRet;
1301 : }
1302 :
1303 : /** this is used because our property map is not sorted yet */
1304 442730 : const SfxItemPropertySimpleEntry* SdStyleSheet::getPropertyMapEntry( const OUString& rPropertyName ) const throw (css::uno::RuntimeException)
1305 : {
1306 442730 : return GetStylePropertySet().getPropertyMapEntry(rPropertyName);
1307 : }
1308 :
1309 : //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
1310 : //which need to be explicitly broadcast as changing if their parent style was
1311 : //the one that changed
1312 0 : void SdStyleSheet::BroadcastSdStyleSheetChange(SfxStyleSheetBase* pStyleSheet,
1313 : PresentationObjects ePO, SfxStyleSheetBasePool* pSSPool)
1314 : {
1315 0 : SdStyleSheet* pRealSheet =((SdStyleSheet*)pStyleSheet)->GetRealStyleSheet();
1316 0 : pRealSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1317 :
1318 0 : if( (ePO >= PO_OUTLINE_1) && (ePO <= PO_OUTLINE_8) )
1319 : {
1320 0 : OUString sStyleName(SD_RESSTR(STR_PSEUDOSHEET_OUTLINE) + " ");
1321 :
1322 0 : for( sal_uInt16 n = (sal_uInt16)(ePO - PO_OUTLINE_1 + 2); n < 10; n++ )
1323 : {
1324 0 : OUString aName( sStyleName + OUString::number(n) );
1325 :
1326 0 : SfxStyleSheetBase* pSheet = pSSPool->Find( aName, SD_STYLE_FAMILY_PSEUDO);
1327 :
1328 0 : if(pSheet)
1329 : {
1330 0 : SdStyleSheet* pRealStyleSheet = ((SdStyleSheet*)pSheet)->GetRealStyleSheet();
1331 0 : pRealStyleSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
1332 : }
1333 0 : }
1334 : }
1335 114 : }
1336 :
1337 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|