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