Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <svx/sdr/properties/attributeproperties.hxx>
30 : : #include <svx/sdr/properties/itemsettools.hxx>
31 : : #include <tools/debug.hxx>
32 : : #include <svl/itemset.hxx>
33 : : #include <svl/style.hxx>
34 : : #include <svl/whiter.hxx>
35 : : #include <svl/poolitem.hxx>
36 : : #include <svx/svdobj.hxx>
37 : : #include <svx/svddef.hxx>
38 : : #include <svx/xit.hxx>
39 : : #include <svx/xbtmpit.hxx>
40 : : #include <svx/xlndsit.hxx>
41 : : #include <svx/xlnstit.hxx>
42 : : #include <svx/xlnedit.hxx>
43 : : #include <svx/xflgrit.hxx>
44 : : #include <svx/xflftrit.hxx>
45 : : #include <svx/xflhtit.hxx>
46 : : #include <svx/xlnasit.hxx>
47 : : #include <svx/xflasit.hxx>
48 : : #include <svx/svdmodel.hxx>
49 : : #include <svx/svdtrans.hxx>
50 : : #include <svx/svdpage.hxx>
51 : :
52 : : // #114265#
53 : : #include <svl/smplhint.hxx>
54 : :
55 : : //////////////////////////////////////////////////////////////////////////////
56 : :
57 : : namespace sdr
58 : : {
59 : : namespace properties
60 : : {
61 : 60988 : void AttributeProperties::ImpAddStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
62 : : {
63 : : // test if old StyleSheet is cleared, else it would be lost
64 : : // after this method -> memory leak (!)
65 : : DBG_ASSERT(!mpStyleSheet, "Old style sheet not deleted before setting new one (!)");
66 : :
67 [ + + ]: 60988 : if(pNewStyleSheet)
68 : : {
69 : 3678 : mpStyleSheet = pNewStyleSheet;
70 : :
71 : : // local ItemSet is needed here, force it
72 : 3678 : GetObjectItemSet();
73 : :
74 : : // register as listener
75 : 3678 : StartListening(pNewStyleSheet->GetPool());
76 : 3678 : StartListening(*pNewStyleSheet);
77 : :
78 : : // Delete hard attributes where items are set in the style sheet
79 [ + + ]: 3678 : if(!bDontRemoveHardAttr)
80 : : {
81 [ + - ]: 983 : const SfxItemSet& rStyle = pNewStyleSheet->GetItemSet();
82 [ + - ]: 983 : SfxWhichIter aIter(rStyle);
83 [ + - ]: 983 : sal_uInt16 nWhich = aIter.FirstWhich();
84 : :
85 [ + + ]: 197583 : while(nWhich)
86 : : {
87 [ + - ][ + + ]: 196600 : if(SFX_ITEM_SET == rStyle.GetItemState(nWhich))
88 : : {
89 [ + - ]: 20514 : mpItemSet->ClearItem(nWhich);
90 : : }
91 : :
92 [ + - ]: 196600 : nWhich = aIter.NextWhich();
93 [ + - ]: 983 : }
94 : : }
95 : :
96 : : // set new stylesheet as parent
97 : 3678 : mpItemSet->SetParent(&pNewStyleSheet->GetItemSet());
98 : : }
99 : 60988 : }
100 : :
101 : 121018 : void AttributeProperties::ImpRemoveStyleSheet()
102 : : {
103 : : // Check type since it is destroyed when the type is deleted
104 [ + + ][ + - ]: 121018 : if(GetStyleSheet() && HAS_BASE(SfxStyleSheet, mpStyleSheet))
[ + - ][ + + ]
105 : : {
106 : 3627 : EndListening(*mpStyleSheet);
107 : 3627 : EndListening(mpStyleSheet->GetPool());
108 : :
109 : : // reset parent of ItemSet
110 [ + - ]: 3627 : if(mpItemSet)
111 : : {
112 : 3627 : mpItemSet->SetParent(0L);
113 : : }
114 : :
115 : 3627 : SdrObject& rObj = GetSdrObject();
116 : 3627 : rObj.SetBoundRectDirty();
117 : 3627 : rObj.SetRectsDirty(sal_True);
118 : : }
119 : :
120 : 121018 : mpStyleSheet = 0L;
121 : 121018 : }
122 : :
123 : : // create a new itemset
124 : 0 : SfxItemSet& AttributeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
125 : : {
126 : : return *(new SfxItemSet(rPool,
127 : :
128 : : // ranges from SdrAttrObj
129 : : SDRATTR_START, SDRATTR_SHADOW_LAST,
130 : : SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
131 : : SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
132 : :
133 : : // end
134 [ # # ]: 0 : 0, 0));
135 : : }
136 : :
137 : 60121 : AttributeProperties::AttributeProperties(SdrObject& rObj)
138 : : : DefaultProperties(rObj),
139 [ + - ]: 60121 : mpStyleSheet(0L)
140 : : {
141 : 60121 : }
142 : :
143 : 6 : AttributeProperties::AttributeProperties(const AttributeProperties& rProps, SdrObject& rObj)
144 : : : DefaultProperties(rProps, rObj),
145 [ + - ]: 6 : mpStyleSheet(0L)
146 : : {
147 [ + - ][ - + ]: 6 : if(rProps.GetStyleSheet())
148 : : {
149 [ # # ][ # # ]: 0 : ImpAddStyleSheet(rProps.GetStyleSheet(), sal_True);
150 : : }
151 : 6 : }
152 : :
153 [ + - ]: 60030 : AttributeProperties::~AttributeProperties()
154 : : {
155 [ + - ]: 60030 : ImpRemoveStyleSheet();
156 [ - + ]: 60030 : }
157 : :
158 : 0 : BaseProperties& AttributeProperties::Clone(SdrObject& rObj) const
159 : : {
160 [ # # ]: 0 : return *(new AttributeProperties(*this, rObj));
161 : : }
162 : :
163 : 152916 : void AttributeProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
164 : : {
165 : : // own modifications
166 : 152916 : SdrObject& rObj = GetSdrObject();
167 : :
168 : 152916 : rObj.SetBoundRectDirty();
169 : 152916 : rObj.SetRectsDirty(sal_True);
170 : 152916 : rObj.SetChanged();
171 : 152916 : }
172 : :
173 : 1437072 : void AttributeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem)
174 : : {
175 [ + + ]: 1437072 : if(pNewItem)
176 : : {
177 : 1399504 : const SfxPoolItem* pItem = pNewItem;
178 : 1399504 : SdrModel* pModel = GetSdrObject().GetModel();
179 : :
180 [ + + + + : 1399504 : switch( nWhich )
+ + + + ]
181 : : {
182 : : case XATTR_FILLBITMAP:
183 : : {
184 : 2433 : pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pModel );
185 : 2433 : break;
186 : : }
187 : : case XATTR_LINEDASH:
188 : : {
189 : 1386 : pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pModel );
190 : 1386 : break;
191 : : }
192 : : case XATTR_LINESTART:
193 : : {
194 : 43 : pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pModel );
195 : 43 : break;
196 : : }
197 : : case XATTR_LINEEND:
198 : : {
199 : 43 : pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pModel );
200 : 43 : break;
201 : : }
202 : : case XATTR_FILLGRADIENT:
203 : : {
204 : 1072 : pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pModel );
205 : 1072 : break;
206 : : }
207 : : case XATTR_FILLFLOATTRANSPARENCE:
208 : : {
209 : : // #85953# allow all kinds of XFillFloatTransparenceItem to be set
210 : 4488 : pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pModel );
211 : 4488 : break;
212 : : }
213 : : case XATTR_FILLHATCH:
214 : : {
215 : 3466 : pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pModel );
216 : 3466 : break;
217 : : }
218 : : }
219 : :
220 : : // set item
221 [ + - ]: 1399504 : if(pItem)
222 : : {
223 : : // force ItemSet
224 : 1399504 : GetObjectItemSet();
225 : 1399504 : mpItemSet->Put(*pItem);
226 : :
227 : : // delete item if it was a generated one
228 [ + + ]: 1399504 : if(pItem != pNewItem)
229 : : {
230 [ + - ]: 1396 : delete (SfxPoolItem*)pItem;
231 : : }
232 : : }
233 : : }
234 : : else
235 : : {
236 : : // clear item if ItemSet exists
237 [ + + ]: 37568 : if(mpItemSet)
238 : : {
239 : 37420 : mpItemSet->ClearItem(nWhich);
240 : : }
241 : : }
242 : 1437072 : }
243 : :
244 : 60808 : void AttributeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
245 : : {
246 : 60808 : ImpRemoveStyleSheet();
247 : 60808 : ImpAddStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
248 : :
249 : 60808 : SdrObject& rObj = GetSdrObject();
250 : 60808 : rObj.SetBoundRectDirty();
251 : 60808 : rObj.SetRectsDirty(sal_True);
252 : 60808 : }
253 : :
254 : 242548 : SfxStyleSheet* AttributeProperties::GetStyleSheet() const
255 : : {
256 : 242548 : return mpStyleSheet;
257 : : }
258 : :
259 : 60451 : void AttributeProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
260 : : {
261 : : OSL_ASSERT(pNewModel!=NULL);
262 : :
263 [ + - ][ + - ]: 60451 : if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
[ + - ]
264 : : {
265 [ + + ]: 60451 : if(mpItemSet)
266 : : {
267 : : // migrate ItemSet to new pool. Scaling is NOT necessary
268 : : // because this functionality is used by UNDO only. Thus
269 : : // objects and ItemSets would be moved back to their original
270 : : // pool before usage.
271 : 5036 : SfxItemSet* pOldSet = mpItemSet;
272 : 5036 : SfxStyleSheet* pStySheet = GetStyleSheet();
273 : :
274 [ + + ]: 5036 : if(pStySheet)
275 : : {
276 : 180 : ImpRemoveStyleSheet();
277 : : }
278 : :
279 : 5036 : mpItemSet = mpItemSet->Clone(sal_False, pDestPool);
280 : 5036 : GetSdrObject().GetModel()->MigrateItemSet(pOldSet, mpItemSet, pNewModel);
281 : :
282 : : // set stylesheet (if used)
283 [ + + ]: 5036 : if(pStySheet)
284 : : {
285 : : // #i109515#
286 : 180 : SfxItemPool* pStyleSheetPool = &pStySheet->GetPool().GetPool();
287 : :
288 [ + - ]: 180 : if(pStyleSheetPool == pDestPool)
289 : : {
290 : : // just re-set stylesheet
291 : 180 : ImpAddStyleSheet(pStySheet, sal_True);
292 : : }
293 : : else
294 : : {
295 : : // StyleSheet is NOT from the correct pool.
296 : : // Look one up in the right pool with the same
297 : : // name or use the default.
298 : :
299 : : // Look up the style in the new document.
300 : : OSL_ASSERT(pNewModel->GetStyleSheetPool() != NULL);
301 : : SfxStyleSheet* pNewStyleSheet = dynamic_cast<SfxStyleSheet*>(
302 : 0 : pNewModel->GetStyleSheetPool()->Find(
303 : 0 : pStySheet->GetName(),
304 [ # # ]: 0 : SFX_STYLE_FAMILY_ALL));
305 [ # # # # ]: 0 : if (pNewStyleSheet == NULL
[ # # ]
306 : 0 : || &pNewStyleSheet->GetPool().GetPool() != pDestPool)
307 : : {
308 : : // There is no copy of the style in the new
309 : : // document. Use the default as a fallback.
310 : 0 : pNewStyleSheet = pNewModel->GetDefaultStyleSheet();
311 : : }
312 : 0 : ImpAddStyleSheet(pNewStyleSheet, sal_True);
313 : : }
314 : : }
315 : :
316 [ + - ]: 5036 : delete pOldSet;
317 : : }
318 : : }
319 : 60451 : }
320 : :
321 : 111621 : void AttributeProperties::SetModel(SdrModel* pOldModel, SdrModel* pNewModel)
322 : : {
323 [ + + ][ + - ]: 111621 : if(pOldModel != pNewModel && pNewModel && !pNewModel->IsLoading())
[ + - ][ + + ]
324 : : {
325 : : // For a living model move the items from one pool to the other
326 [ - + ]: 60063 : if(pOldModel)
327 : : {
328 : : // If metric has changed, scale items.
329 : 0 : MapUnit aOldUnit(pOldModel->GetScaleUnit());
330 : 0 : MapUnit aNewUnit(pNewModel->GetScaleUnit());
331 : 0 : sal_Bool bScaleUnitChanged(aNewUnit != aOldUnit);
332 : 0 : Fraction aMetricFactor;
333 : :
334 [ # # ]: 0 : if(bScaleUnitChanged)
335 : : {
336 [ # # ][ # # ]: 0 : aMetricFactor = GetMapFactor(aOldUnit, aNewUnit).X();
337 [ # # ]: 0 : Scale(aMetricFactor);
338 : : }
339 : :
340 : : // Move all styles which are used by the object to the new
341 : : // StyleSheet pool
342 [ # # ]: 0 : SfxStyleSheet* pOldStyleSheet = GetStyleSheet();
343 : :
344 [ # # ]: 0 : if(pOldStyleSheet)
345 : : {
346 : 0 : SfxStyleSheetBase* pSheet = pOldStyleSheet;
347 [ # # ]: 0 : SfxStyleSheetBasePool* pOldPool = pOldModel->GetStyleSheetPool();
348 [ # # ]: 0 : SfxStyleSheetBasePool* pNewPool = pNewModel->GetStyleSheetPool();
349 : : DBG_ASSERT(pOldPool, "Properties::SetModel(): Object has StyleSheet but no StyleSheetPool (!)");
350 : :
351 [ # # ][ # # ]: 0 : if(pOldPool && pNewPool)
352 : : {
353 : : // build a list of to-be-copied Styles
354 [ # # ]: 0 : std::vector<SfxStyleSheetBase*> aStyleList;
355 : 0 : SfxStyleSheetBase* pAnchor = 0L;
356 : :
357 [ # # ]: 0 : while(pSheet)
358 : : {
359 [ # # ][ # # ]: 0 : pAnchor = pNewPool->Find(pSheet->GetName(), pSheet->GetFamily());
360 : :
361 [ # # ]: 0 : if(!pAnchor)
362 : : {
363 [ # # ]: 0 : aStyleList.push_back(pSheet);
364 [ # # ][ # # ]: 0 : pSheet = pOldPool->Find(pSheet->GetParent(), pSheet->GetFamily());
365 : : }
366 : : else
367 : : {
368 : : // the style does exist
369 : 0 : pSheet = 0L;
370 : : }
371 : : }
372 : :
373 : : // copy and set the parents
374 : 0 : SfxStyleSheetBase* pNewSheet = 0L;
375 : 0 : SfxStyleSheetBase* pLastSheet = 0L;
376 : 0 : SfxStyleSheetBase* pForThisObject = 0L;
377 : :
378 : 0 : std::vector<SfxStyleSheetBase*>::iterator iter;
379 [ # # ][ # # ]: 0 : for (iter = aStyleList.begin(); iter != aStyleList.end(); ++iter)
[ # # ]
380 : : {
381 [ # # ][ # # ]: 0 : pNewSheet = &pNewPool->Make((*iter)->GetName(), (*iter)->GetFamily(), (*iter)->GetMask());
[ # # ][ # # ]
[ # # ]
382 [ # # ][ # # ]: 0 : pNewSheet->GetItemSet().Put((*iter)->GetItemSet(), sal_False);
[ # # ][ # # ]
383 : :
384 [ # # ]: 0 : if(bScaleUnitChanged)
385 : : {
386 [ # # ][ # # ]: 0 : sdr::properties::ScaleItemSet(pNewSheet->GetItemSet(), aMetricFactor);
387 : : }
388 : :
389 [ # # ]: 0 : if(pLastSheet)
390 : : {
391 [ # # ][ # # ]: 0 : pLastSheet->SetParent(pNewSheet->GetName());
392 : : }
393 : :
394 [ # # ]: 0 : if(!pForThisObject)
395 : : {
396 : 0 : pForThisObject = pNewSheet;
397 : : }
398 : :
399 : 0 : pLastSheet = pNewSheet;
400 : : }
401 : :
402 : : // Set link to the Style found in the Pool
403 [ # # ][ # # ]: 0 : if(pAnchor && pLastSheet)
404 : : {
405 [ # # ][ # # ]: 0 : pLastSheet->SetParent(pAnchor->GetName());
406 : : }
407 : :
408 : : // if list was empty (all Styles exist in destination pool)
409 : : // pForThisObject is not yet set
410 [ # # ][ # # ]: 0 : if(!pForThisObject && pAnchor)
411 : : {
412 : 0 : pForThisObject = pAnchor;
413 : : }
414 : :
415 : : // De-register at old and register at new Style
416 [ # # ][ # # ]: 0 : if(GetStyleSheet() != pForThisObject)
417 : : {
418 [ # # ]: 0 : ImpRemoveStyleSheet();
419 [ # # ]: 0 : ImpAddStyleSheet((SfxStyleSheet*)pForThisObject, sal_True);
420 : 0 : }
421 : : }
422 : : else
423 : : {
424 : : // there is no StyleSheetPool in the new model, thus set
425 : : // all items as hard items in the object
426 [ # # ]: 0 : std::vector<const SfxItemSet*> aSetList;
427 [ # # ]: 0 : const SfxItemSet* pItemSet = &pOldStyleSheet->GetItemSet();
428 : :
429 [ # # ]: 0 : while(pItemSet)
430 : : {
431 [ # # ]: 0 : aSetList.push_back(pItemSet);
432 : 0 : pItemSet = pItemSet->GetParent();
433 : : }
434 : :
435 [ # # ]: 0 : SfxItemSet* pNewSet = &CreateObjectSpecificItemSet(pNewModel->GetItemPool());
436 : :
437 [ # # ]: 0 : std::vector<const SfxItemSet*>::reverse_iterator riter;
438 [ # # ][ # # ]: 0 : for (riter = aSetList.rbegin(); riter != aSetList.rend(); ++riter)
[ # # ]
439 [ # # ][ # # ]: 0 : pNewSet->Put(*(*riter));
440 : :
441 : : // Items which were hard attributes before need to stay
442 [ # # ]: 0 : if(mpItemSet)
443 : : {
444 [ # # ]: 0 : SfxWhichIter aIter(*mpItemSet);
445 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
446 : :
447 [ # # ]: 0 : while(nWhich)
448 : : {
449 [ # # ][ # # ]: 0 : if(mpItemSet->GetItemState(nWhich, sal_False) == SFX_ITEM_SET)
450 : : {
451 [ # # ][ # # ]: 0 : pNewSet->Put(mpItemSet->Get(nWhich));
452 : : }
453 : :
454 [ # # ]: 0 : nWhich = aIter.NextWhich();
455 [ # # ]: 0 : }
456 : : }
457 : :
458 [ # # ]: 0 : if(bScaleUnitChanged)
459 : : {
460 [ # # ]: 0 : ScaleItemSet(*pNewSet, aMetricFactor);
461 : : }
462 : :
463 [ # # ]: 0 : if(mpItemSet)
464 : : {
465 [ # # ][ # # ]: 0 : if(GetStyleSheet())
466 : : {
467 [ # # ]: 0 : ImpRemoveStyleSheet();
468 : : }
469 : :
470 [ # # ][ # # ]: 0 : delete mpItemSet;
471 : 0 : mpItemSet = 0L;
472 : : }
473 : :
474 : 0 : mpItemSet = pNewSet;
475 : : }
476 : : }
477 : : }
478 : :
479 : : // each object gets the default Style if there is none set yet.
480 [ + + ][ + - ]: 60063 : if(!GetStyleSheet() && pNewModel && !pNewModel->IsLoading())
[ + - ][ + + ]
481 : : {
482 : 59903 : GetObjectItemSet(); // i#118414 force ItemSet to allow style to be set
483 : 59903 : SetStyleSheet(pNewModel->GetDefaultStyleSheet(), sal_True);
484 : : }
485 : : }
486 : 111621 : }
487 : :
488 : 0 : void AttributeProperties::ForceStyleToHardAttributes()
489 : : {
490 [ # # ][ # # ]: 0 : if(GetStyleSheet() && HAS_BASE(SfxStyleSheet, mpStyleSheet))
[ # # ][ # # ]
491 : : {
492 : : // prepare copied, new itemset, but WITHOUT parent
493 [ # # ]: 0 : GetObjectItemSet();
494 [ # # ][ # # ]: 0 : SfxItemSet* pDestItemSet = new SfxItemSet(*mpItemSet);
495 : 0 : pDestItemSet->SetParent(0L);
496 : :
497 : : // pepare forgetting the current stylesheet like in RemoveStyleSheet()
498 [ # # ]: 0 : EndListening(*mpStyleSheet);
499 [ # # ]: 0 : EndListening(mpStyleSheet->GetPool());
500 : :
501 : : // prepare the iter; use the mpObjectItemSet which may have less
502 : : // WhichIDs than the style.
503 [ # # ]: 0 : SfxWhichIter aIter(*pDestItemSet);
504 [ # # ]: 0 : sal_uInt16 nWhich(aIter.FirstWhich());
505 : 0 : const SfxPoolItem *pItem = NULL;
506 : :
507 : : // now set all hard attributes of the current at the new itemset
508 [ # # ]: 0 : while(nWhich)
509 : : {
510 : : // #i61284# use mpItemSet with parents, makes things easier and reduces to
511 : : // one loop
512 [ # # ][ # # ]: 0 : if(SFX_ITEM_SET == mpItemSet->GetItemState(nWhich, true, &pItem))
513 : : {
514 [ # # ]: 0 : pDestItemSet->Put(*pItem);
515 : : }
516 : :
517 [ # # ]: 0 : nWhich = aIter.NextWhich();
518 : : }
519 : :
520 : : // replace itemsets
521 [ # # ][ # # ]: 0 : delete mpItemSet;
522 : 0 : mpItemSet = pDestItemSet;
523 : :
524 : : // set necessary changes like in RemoveStyleSheet()
525 [ # # ]: 0 : GetSdrObject().SetBoundRectDirty();
526 [ # # ]: 0 : GetSdrObject().SetRectsDirty(sal_True);
527 : :
528 [ # # ]: 0 : mpStyleSheet = NULL;
529 : : }
530 : 0 : }
531 : :
532 : 17243 : void AttributeProperties::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
533 : : {
534 : 17243 : sal_Bool bHintUsed(sal_False);
535 : :
536 [ + - ][ + + ]: 17243 : SfxStyleSheetHint *pStyleHint = PTR_CAST(SfxStyleSheetHint, &rHint);
537 : :
538 [ + + ][ + + ]: 17243 : if(pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet())
[ + + ]
539 : : {
540 : 85 : SdrObject& rObj = GetSdrObject();
541 : : //SdrPage* pPage = rObj.GetPage();
542 : :
543 [ - + - - ]: 85 : switch(pStyleHint->GetHint())
544 : : {
545 : : case SFX_STYLESHEET_CREATED :
546 : : {
547 : : // cannot happen, nothing to do
548 : 0 : break;
549 : : }
550 : : case SFX_STYLESHEET_MODIFIED :
551 : : case SFX_STYLESHEET_CHANGED :
552 : : {
553 : : // notify change
554 : 85 : break;
555 : : }
556 : : case SFX_STYLESHEET_ERASED :
557 : : case SFX_STYLESHEET_INDESTRUCTION :
558 : : {
559 : : // Style needs to be exchanged
560 : 0 : SfxStyleSheet* pNewStSh = 0L;
561 [ # # ]: 0 : SdrModel* pModel = rObj.GetModel();
562 : :
563 : : // #111111#
564 : : // Do nothing if object is in destruction, else a StyleSheet may be found from
565 : : // a StyleSheetPool which is just being deleted itself. and thus it would be fatal
566 : : // to register as listener to that new StyleSheet.
567 [ # # ][ # # ]: 0 : if(pModel && !rObj.IsInDestruction())
[ # # ][ # # ]
568 : : {
569 [ # # ][ # # ]: 0 : if(HAS_BASE(SfxStyleSheet, GetStyleSheet()))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
570 : : {
571 [ # # ]: 0 : pNewStSh = (SfxStyleSheet*)pModel->GetStyleSheetPool()->Find(
572 [ # # ][ # # ]: 0 : GetStyleSheet()->GetParent(), GetStyleSheet()->GetFamily());
[ # # ][ # # ]
573 : : }
574 : :
575 [ # # ]: 0 : if(!pNewStSh)
576 : : {
577 : 0 : pNewStSh = pModel->GetDefaultStyleSheet();
578 : : }
579 : : }
580 : :
581 : : // remove used style, it's erased or in destruction
582 [ # # ]: 0 : ImpRemoveStyleSheet();
583 : :
584 [ # # ]: 0 : if(pNewStSh)
585 : : {
586 [ # # ]: 0 : ImpAddStyleSheet(pNewStSh, sal_True);
587 : : }
588 : :
589 : 0 : break;
590 : : }
591 : : }
592 : :
593 : : // Get old BoundRect. Do this after the style change is handled
594 : : // in the ItemSet parts because GetBoundRect() may calculate a new
595 [ + - ]: 85 : Rectangle aBoundRect = rObj.GetLastBoundRect();
596 : :
597 [ + - ]: 85 : rObj.SetRectsDirty(sal_True);
598 : :
599 : : // tell the object about the change
600 [ + - ]: 85 : rObj.SetChanged();
601 [ + - ]: 85 : rObj.BroadcastObjectChange();
602 : :
603 : : //if(pPage && pPage->IsInserted())
604 : : //{
605 : : // rObj.BroadcastObjectChange();
606 : : //}
607 : :
608 [ + - ]: 85 : rObj.SendUserCall(SDRUSERCALL_CHGATTR, aBoundRect);
609 : :
610 : 85 : bHintUsed = sal_True;
611 : : }
612 : :
613 [ + + ]: 17243 : if(!bHintUsed)
614 : : {
615 : : // forward to SdrObject ATM. Not sure if this will be necessary
616 : : // in the future.
617 : 17158 : GetSdrObject().Notify(rBC, rHint);
618 : : }
619 : 17243 : }
620 : : } // end of namespace properties
621 : : } // end of namespace sdr
622 : :
623 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|