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