Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <vector>
21 : #include <boost/ptr_container/ptr_vector.hpp>
22 :
23 : #include <sfx2/docfile.hxx>
24 : #include <vcl/svapp.hxx>
25 : #include <editeng/outliner.hxx>
26 : #include <sfx2/linkmgr.hxx>
27 : #include <svx/svdotext.hxx>
28 : #include <editeng/outlobj.hxx>
29 : #include <svl/urihelper.hxx>
30 : #include <editeng/xmlcnitm.hxx>
31 : #include <svx/svditer.hxx>
32 :
33 : #include "Annotation.hxx"
34 : #include "notifydocumentevent.hxx"
35 : #include "sdresid.hxx"
36 : #include "sdpage.hxx"
37 : #include "glob.hxx"
38 : #include "glob.hrc"
39 : #include "drawdoc.hxx"
40 : #include "stlpool.hxx"
41 : #include "pglink.hxx"
42 : #include "anminfo.hxx"
43 :
44 : #include "../ui/inc/strings.hrc"
45 : #include "../ui/inc/DrawDocShell.hxx"
46 :
47 : #include <tools/tenccvt.hxx>
48 : #include <svl/itemset.hxx>
49 : #include <rtl/strbuf.hxx>
50 :
51 : using namespace ::sd;
52 : using namespace ::com::sun::star;
53 : using namespace ::com::sun::star::uno;
54 : using namespace ::com::sun::star::office;
55 :
56 : /*************************************************************************
57 : |*
58 : |* Sets: names of layout, master page links and templates for presentation
59 : |* objects
60 : |*
61 : |* Preconditions: - The page has to know the correct model!
62 : |* - The corresponding master page has to be in the model.
63 : |* - The corresponding style sheets have to be in the style sheet
64 : |* pool.
65 : |*
66 : |* bReplaceStyleSheets = sal_True : Named style sheets are replaced
67 : |* sal_False: All style sheets are reassigned
68 : |*
69 : |* bSetMasterPage = sal_True : search and assign master page
70 : |*
71 : |* bReverseOrder = sal_False: search master page from head to tail
72 : |* sal_True : search master page from tail to head
73 : |* (for undo operations)
74 : |*
75 : \************************************************************************/
76 :
77 2 : void SdPage::SetPresentationLayout(const OUString& rLayoutName,
78 : bool bReplaceStyleSheets,
79 : bool bSetMasterPage,
80 : bool bReverseOrder)
81 : {
82 : /*********************************************************************
83 : |* Name of the layout of the page
84 : \********************************************************************/
85 2 : OUString aOldLayoutName(maLayoutName); // merken
86 4 : OUStringBuffer aBuf(rLayoutName);
87 2 : aBuf.append(SD_LT_SEPARATOR).append(SdResId(STR_LAYOUT_OUTLINE).toString());
88 2 : maLayoutName = aBuf.makeStringAndClear();
89 :
90 : /*********************************************************************
91 : |* search and replace master page if necessary
92 : \********************************************************************/
93 2 : if (bSetMasterPage && !IsMasterPage())
94 : {
95 : SdPage* pMaster;
96 0 : SdPage* pFoundMaster = 0;
97 0 : sal_uInt16 nMaster = 0;
98 0 : sal_uInt16 nMasterCount = pModel->GetMasterPageCount();
99 :
100 0 : if( !bReverseOrder )
101 : {
102 0 : for ( nMaster = 0; nMaster < nMasterCount; nMaster++ )
103 : {
104 0 : pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster));
105 0 : if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
106 : {
107 0 : pFoundMaster = pMaster;
108 0 : break;
109 : }
110 : }
111 : }
112 : else
113 : {
114 0 : for ( nMaster = nMasterCount; nMaster > 0; nMaster-- )
115 : {
116 0 : pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster - 1));
117 0 : if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
118 : {
119 0 : pFoundMaster = pMaster;
120 0 : break;
121 : }
122 : }
123 : }
124 :
125 : DBG_ASSERT(pFoundMaster, "Masterpage for presentation layout not found!");
126 :
127 : // this should never happen, but we play failsafe here
128 0 : if( pFoundMaster == 0 )
129 0 : pFoundMaster = static_cast< SdDrawDocument *>(pModel)->GetSdPage( 0, mePageKind );
130 :
131 0 : if( pFoundMaster )
132 0 : TRG_SetMasterPage(*pFoundMaster);
133 : }
134 :
135 : /*********************************************************************
136 : |* templates for presentation objects
137 : \********************************************************************/
138 : // list with:
139 : // - pointer to templates for outline text object (old and new templates)
140 : // - replace-data for OutlinerParaObject
141 4 : std::vector<SfxStyleSheetBase*> aOutlineStyles;
142 4 : std::vector<SfxStyleSheetBase*> aOldOutlineStyles;
143 4 : boost::ptr_vector<StyleReplaceData> aReplList;
144 2 : bool bListsFilled = false;
145 :
146 2 : const size_t nObjCount = GetObjCount();
147 :
148 6 : for (size_t nObj = 0; nObj < nObjCount; ++nObj)
149 : {
150 4 : SdrTextObj* pObj = (SdrTextObj*) GetObj(nObj);
151 :
152 8 : if (pObj->GetObjInventor() == SdrInventor &&
153 4 : pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
154 : {
155 0 : if (!bListsFilled || !bReplaceStyleSheets)
156 : {
157 0 : OUString aFullName;
158 0 : OUString aOldFullName;
159 0 : SfxStyleSheetBase* pSheet = NULL;
160 0 : SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
161 :
162 0 : for (sal_Int16 i = -1; i < 9; i++)
163 : {
164 0 : aOldFullName = aOldLayoutName + " " +
165 0 : OUString::number( (i <= 0 ) ? 1 : i + 1 );
166 0 : aFullName = maLayoutName + " " +
167 0 : OUString::number( (i <= 0 ) ? 1 : i + 1);
168 0 : pSheet = pStShPool->Find(aOldFullName, SD_STYLE_FAMILY_MASTERPAGE);
169 : DBG_ASSERT(pSheet, "Old outline style sheet not found");
170 0 : aOldOutlineStyles.push_back(pSheet);
171 :
172 0 : pSheet = pStShPool->Find(aFullName, SD_STYLE_FAMILY_MASTERPAGE);
173 : DBG_ASSERT(pSheet, "New outline style sheet not found");
174 0 : aOutlineStyles.push_back(pSheet);
175 :
176 0 : if (bReplaceStyleSheets && pSheet)
177 : {
178 : // Replace instead Set
179 0 : StyleReplaceData* pReplData = new StyleReplaceData;
180 0 : pReplData->nNewFamily = pSheet->GetFamily();
181 0 : pReplData->nFamily = pSheet->GetFamily();
182 0 : pReplData->aNewName = aFullName;
183 0 : pReplData->aName = aOldFullName;
184 0 : aReplList.push_back(pReplData);
185 : }
186 : else
187 : {
188 0 : OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
189 :
190 0 : if( pOPO )
191 0 : pOPO->SetStyleSheets( i, aFullName, SD_STYLE_FAMILY_MASTERPAGE );
192 : }
193 : }
194 :
195 0 : bListsFilled = true;
196 : }
197 :
198 0 : SfxStyleSheet* pSheet = NULL;
199 0 : SfxStyleSheet* pOldSheet = NULL;
200 :
201 0 : std::vector<SfxStyleSheetBase*>::iterator iterOut = aOutlineStyles.begin();
202 0 : std::vector<SfxStyleSheetBase*>::iterator iterOldOut = aOldOutlineStyles.begin();
203 :
204 0 : while (iterOut != aOutlineStyles.end())
205 : {
206 0 : pSheet = static_cast<SfxStyleSheet*>(*iterOut);
207 0 : pOldSheet = static_cast<SfxStyleSheet*>(*iterOldOut);
208 :
209 0 : if (pSheet != pOldSheet)
210 : {
211 0 : if (pOldSheet)
212 0 : pObj->EndListening(*pOldSheet);
213 :
214 0 : if (pSheet && !pObj->IsListening(*pSheet))
215 0 : pObj->StartListening(*pSheet);
216 : }
217 :
218 0 : ++iterOut;
219 0 : ++iterOldOut;
220 : }
221 :
222 0 : OutlinerParaObject* pOPO = ((SdrTextObj*)pObj)->GetOutlinerParaObject();
223 0 : if ( bReplaceStyleSheets && pOPO )
224 : {
225 0 : boost::ptr_vector<StyleReplaceData>::const_iterator it = aReplList.begin();
226 0 : while (it != aReplList.end())
227 : {
228 0 : pOPO->ChangeStyleSheets( it->aName, it->nFamily, it->aNewName, it->nNewFamily );
229 0 : ++it;
230 : }
231 : }
232 : }
233 8 : else if (pObj->GetObjInventor() == SdrInventor &&
234 4 : pObj->GetObjIdentifier() == OBJ_TITLETEXT)
235 : {
236 : // We do net get PresObjKind via GetPresObjKind() since there are
237 : // only PresObjListe considered. But we want to consider all "Title
238 : // objects" here (paste from clipboard etc.)
239 2 : SfxStyleSheet* pSheet = GetStyleSheetForPresObj(PRESOBJ_TITLE);
240 :
241 2 : if (pSheet)
242 2 : pObj->SetStyleSheet(pSheet, true);
243 : }
244 : else
245 : {
246 2 : SfxStyleSheet* pSheet = GetStyleSheetForPresObj(GetPresObjKind(pObj));
247 :
248 2 : if (pSheet)
249 2 : pObj->SetStyleSheet(pSheet, true);
250 : }
251 2 : }
252 2 : }
253 :
254 : /*************************************************************************
255 : |*
256 : |* disconnect outline text object from templates for outline levels
257 : |*
258 : \************************************************************************/
259 :
260 3018 : void SdPage::EndListenOutlineText()
261 : {
262 3018 : SdrObject* pOutlineTextObj = GetPresObj(PRESOBJ_OUTLINE);
263 :
264 3018 : if (pOutlineTextObj)
265 : {
266 342 : SdStyleSheetPool* pSPool = (SdStyleSheetPool*)pModel->GetStyleSheetPool();
267 : DBG_ASSERT(pSPool, "StyleSheetPool missing");
268 342 : OUString aTrueLayoutName(maLayoutName);
269 342 : sal_Int32 nIndex = aTrueLayoutName.indexOf( SD_LT_SEPARATOR );
270 342 : if( nIndex != -1 )
271 342 : aTrueLayoutName = aTrueLayoutName.copy(0, nIndex);
272 :
273 342 : SfxStyleSheet *pSheet = NULL;
274 684 : std::vector<SfxStyleSheetBase*> aOutlineStyles;
275 342 : pSPool->CreateOutlineSheetList(aTrueLayoutName,aOutlineStyles);
276 :
277 342 : std::vector<SfxStyleSheetBase*>::iterator iter;
278 3420 : for (iter = aOutlineStyles.begin(); iter != aOutlineStyles.end(); ++iter)
279 : {
280 3078 : pSheet = static_cast<SfxStyleSheet*>(*iter);
281 3078 : pOutlineTextObj->EndListening(*pSheet);
282 342 : }
283 : }
284 3018 : }
285 :
286 : /*************************************************************************
287 : |*
288 : |* Set new model
289 : |*
290 : \************************************************************************/
291 :
292 3018 : void SdPage::SetModel(SdrModel* pNewModel)
293 : {
294 3018 : DisconnectLink();
295 :
296 : // assign model
297 3018 : FmFormPage::SetModel(pNewModel);
298 :
299 3018 : ConnectLink();
300 3018 : }
301 :
302 : /*************************************************************************
303 : |*
304 : |* Is this page read-only?
305 : |*
306 : \************************************************************************/
307 :
308 4 : bool SdPage::IsReadOnly() const
309 : {
310 4 : return false;
311 : }
312 :
313 : /*************************************************************************
314 : |*
315 : |* Connect to sfx2::LinkManager
316 : |*
317 : \************************************************************************/
318 :
319 4890 : void SdPage::ConnectLink()
320 : {
321 4890 : sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
322 :
323 9774 : if (pLinkManager && !mpPageLink && !maFileName.isEmpty() && !maBookmarkName.isEmpty() &&
324 4890 : mePageKind==PK_STANDARD && !IsMasterPage() &&
325 0 : ( (SdDrawDocument*) pModel)->IsNewOrLoadCompleted())
326 : {
327 : /**********************************************************************
328 : * Connect
329 : * Only standard pages are allowed to be linked
330 : **********************************************************************/
331 0 : ::sd::DrawDocShell* pDocSh = ((SdDrawDocument*) pModel)->GetDocSh();
332 :
333 0 : if (!pDocSh || !pDocSh->GetMedium()->GetOrigURL().equals(maFileName))
334 : {
335 : // No links to document owned pages!
336 0 : mpPageLink = new SdPageLink(this, maFileName, maBookmarkName);
337 0 : OUString aFilterName(SdResId(STR_IMPRESS));
338 : pLinkManager->InsertFileLink(*mpPageLink, OBJECT_CLIENT_FILE,
339 0 : maFileName, &aFilterName, &maBookmarkName);
340 0 : mpPageLink->Connect();
341 : }
342 : }
343 4890 : }
344 :
345 : /*************************************************************************
346 : |*
347 : |* Disconnect from sfx2::LinkManager
348 : |*
349 : \************************************************************************/
350 :
351 7908 : void SdPage::DisconnectLink()
352 : {
353 7908 : sfx2::LinkManager* pLinkManager = pModel!=NULL ? pModel->GetLinkManager() : NULL;
354 :
355 7908 : if (pLinkManager && mpPageLink)
356 : {
357 : /**********************************************************************
358 : * Disconnect
359 : * (remove deletes *pGraphicLink implicit)
360 : **********************************************************************/
361 0 : pLinkManager->Remove(mpPageLink);
362 0 : mpPageLink=NULL;
363 : }
364 7908 : }
365 :
366 : /*************************************************************************
367 : |*
368 : |* Copy-Ctor
369 : |*
370 : \************************************************************************/
371 :
372 2 : SdPage::SdPage(const SdPage& rSrcPage)
373 : : FmFormPage(rSrcPage)
374 : , SdrObjUserCall()
375 2 : , mpItems(NULL)
376 : {
377 2 : mePageKind = rSrcPage.mePageKind;
378 2 : meAutoLayout = rSrcPage.meAutoLayout;
379 :
380 : // use shape list directly to preserve constness of rSrcPage
381 2 : const std::list< SdrObject* >& rShapeList = rSrcPage.maPresentationShapeList.getList();
382 18 : for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin();
383 12 : aIter != rShapeList.end(); ++aIter )
384 : {
385 4 : SdrObject* pObj = *aIter;
386 4 : InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
387 : }
388 :
389 2 : mbSelected = false;
390 2 : mnTransitionType = rSrcPage.mnTransitionType;
391 2 : mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
392 2 : mbTransitionDirection = rSrcPage.mbTransitionDirection;
393 2 : mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor;
394 2 : mfTransitionDuration = rSrcPage.mfTransitionDuration;
395 2 : mePresChange = rSrcPage.mePresChange;
396 2 : mfTime = rSrcPage.mfTime;
397 2 : mbSoundOn = rSrcPage.mbSoundOn;
398 2 : mbExcluded = rSrcPage.mbExcluded;
399 :
400 2 : maLayoutName = rSrcPage.maLayoutName;
401 2 : maSoundFile = rSrcPage.maSoundFile;
402 2 : mbLoopSound = rSrcPage.mbLoopSound;
403 2 : mbStopSound = rSrcPage.mbStopSound;
404 2 : maCreatedPageName = "";
405 2 : maFileName = rSrcPage.maFileName;
406 2 : maBookmarkName = rSrcPage.maBookmarkName;
407 2 : mbScaleObjects = rSrcPage.mbScaleObjects;
408 2 : mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
409 2 : meCharSet = rSrcPage.meCharSet;
410 2 : mnPaperBin = rSrcPage.mnPaperBin;
411 2 : meOrientation = rSrcPage.meOrientation;
412 :
413 : // header footer
414 2 : setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
415 :
416 2 : mpPageLink = NULL; // is set when inserting via ConnectLink()
417 2 : }
418 :
419 : /*************************************************************************
420 : |*
421 : |* Clone
422 : |*
423 : \************************************************************************/
424 :
425 2 : SdrPage* SdPage::Clone() const
426 : {
427 2 : return Clone(NULL);
428 : }
429 :
430 2 : SdrPage* SdPage::Clone(SdrModel* pNewModel) const
431 : {
432 : DBG_ASSERT( pNewModel == 0, "sd::SdPage::Clone(), new page ignored, please check code! CL" );
433 : (void)pNewModel;
434 :
435 2 : SdPage* pNewPage = new SdPage(*this);
436 :
437 2 : cloneAnimations( *pNewPage );
438 :
439 : // fix user calls for duplicated slide
440 2 : SdrObjListIter aSourceIter( *this, IM_DEEPWITHGROUPS );
441 4 : SdrObjListIter aTargetIter( *pNewPage, IM_DEEPWITHGROUPS );
442 :
443 8 : while( aSourceIter.IsMore() && aTargetIter.IsMore() )
444 : {
445 4 : SdrObject* pSource = aSourceIter.Next();
446 4 : SdrObject* pTarget = aTargetIter.Next();
447 :
448 4 : if( pSource->GetUserCall() )
449 4 : pTarget->SetUserCall( pNewPage );
450 : }
451 :
452 4 : return pNewPage;
453 : }
454 :
455 : /*************************************************************************
456 : |*
457 : |* GetTextStyleSheetForObject
458 : |*
459 : \************************************************************************/
460 :
461 2368 : SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
462 : {
463 2368 : const PresObjKind eKind = ((SdPage*)this)->GetPresObjKind(pObj);
464 2368 : if( eKind != PRESOBJ_NONE )
465 : {
466 826 : return ((SdPage*)this)->GetStyleSheetForPresObj(eKind);
467 : }
468 :
469 1542 : return FmFormPage::GetTextStyleSheetForObject( pObj );
470 : }
471 :
472 0 : SfxItemSet* SdPage::getOrCreateItems()
473 : {
474 0 : if( mpItems == NULL )
475 0 : mpItems = new SfxItemSet( pModel->GetItemPool(), SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES );
476 :
477 0 : return mpItems;
478 : }
479 :
480 0 : bool SdPage::setAlienAttributes( const com::sun::star::uno::Any& rAttributes )
481 : {
482 0 : SfxItemSet* pSet = getOrCreateItems();
483 :
484 0 : SvXMLAttrContainerItem aAlienAttributes( SDRATTR_XMLATTRIBUTES );
485 0 : if( aAlienAttributes.PutValue( rAttributes, 0 ) )
486 : {
487 0 : pSet->Put( aAlienAttributes );
488 0 : return true;
489 : }
490 :
491 0 : return false;
492 : }
493 :
494 62 : void SdPage::getAlienAttributes( com::sun::star::uno::Any& rAttributes )
495 : {
496 : const SfxPoolItem* pItem;
497 :
498 62 : if( (mpItems == NULL) || ( SfxItemState::SET != mpItems->GetItemState( SDRATTR_XMLATTRIBUTES, false, &pItem ) ) )
499 : {
500 62 : SvXMLAttrContainerItem aAlienAttributes;
501 62 : aAlienAttributes.QueryValue( rAttributes, 0 );
502 : }
503 : else
504 : {
505 0 : ((SvXMLAttrContainerItem*)pItem)->QueryValue( rAttributes, 0 );
506 : }
507 62 : }
508 :
509 0 : void SdPage::RemoveEmptyPresentationObjects()
510 : {
511 0 : SdrObjListIter aShapeIter( *this, IM_DEEPWITHGROUPS );
512 :
513 : SdrObject* pShape;
514 0 : for( pShape = aShapeIter.Next(); pShape; pShape = aShapeIter.Next() )
515 : {
516 0 : if( pShape && pShape->IsEmptyPresObj() )
517 : {
518 0 : RemoveObject( pShape->GetOrdNum() );
519 0 : SdrObject::Free( pShape );
520 : }
521 :
522 0 : }
523 0 : }
524 :
525 4 : void SdPage::setTransitionType( sal_Int16 nTransitionType )
526 : {
527 4 : mnTransitionType = nTransitionType;
528 4 : ActionChanged();
529 4 : }
530 :
531 4 : void SdPage::setTransitionSubtype ( sal_Int16 nTransitionSubtype )
532 : {
533 4 : mnTransitionSubtype = nTransitionSubtype;
534 4 : ActionChanged();
535 4 : }
536 :
537 4 : void SdPage::setTransitionDirection ( bool bTransitionbDirection )
538 : {
539 4 : mbTransitionDirection = bTransitionbDirection;
540 4 : ActionChanged();
541 4 : }
542 :
543 4 : void SdPage::setTransitionFadeColor ( sal_Int32 nTransitionFadeColor )
544 : {
545 4 : mnTransitionFadeColor = nTransitionFadeColor;
546 4 : ActionChanged();
547 4 : }
548 :
549 18 : void SdPage::setTransitionDuration ( double fTranstionDuration )
550 : {
551 18 : mfTransitionDuration = fTranstionDuration;
552 18 : ActionChanged();
553 18 : }
554 :
555 0 : OString SdPage::stringify() const
556 : {
557 0 : OStringBuffer aString(100);
558 0 : aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append(mbSelected).append((sal_Int32)mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
559 0 : append(OUStringToOString( maLayoutName, RTL_TEXTENCODING_UTF8 )).
560 0 : append(OUStringToOString(maSoundFile, RTL_TEXTENCODING_UTF8 )).
561 0 : append(mbLoopSound).append(mbStopSound).
562 : /*append(OUStringToOString(maCreatedPageName, RTL_TEXTENCODING_UTF8)).
563 : append(OUStringToOString(maFileName, RTL_TEXTENCODING_UTF8)).*/
564 0 : append(OUStringToOString(maBookmarkName, RTL_TEXTENCODING_UTF8)).
565 0 : append(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append((sal_Int32)mnPaperBin).
566 0 : append((sal_Int32)meOrientation).append((sal_Int32)mnTransitionType).append((sal_Int32)mnTransitionSubtype).append(mbTransitionDirection).
567 0 : append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
568 :
569 0 : const size_t n = GetObjCount();
570 0 : for(size_t i = 0; i < n; ++i)
571 0 : aString.append(GetObj(i)->stringify());
572 0 : return aString.makeStringAndClear();
573 : }
574 :
575 0 : sal_Int32 SdPage::getHash() const
576 : {
577 0 : return stringify().hashCode();
578 : }
579 :
580 0 : void SdPage::createAnnotation( ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation )
581 : {
582 0 : sd::createAnnotation( xAnnotation, this );
583 0 : }
584 :
585 0 : void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIndex )
586 : {
587 0 : if( (nIndex == -1) || (nIndex > (int)maAnnotations.size()) )
588 : {
589 0 : maAnnotations.push_back( xAnnotation );
590 : }
591 : else
592 : {
593 0 : maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
594 : }
595 :
596 0 : if( pModel && pModel->IsUndoEnabled() )
597 : {
598 0 : SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true );
599 0 : if( pAction )
600 0 : pModel->AddUndo( pAction );
601 : }
602 :
603 0 : SetChanged();
604 :
605 0 : if( pModel )
606 : {
607 0 : pModel->SetChanged();
608 0 : NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationInserted", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
609 : }
610 0 : }
611 :
612 0 : void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
613 : {
614 0 : if( pModel && pModel->IsUndoEnabled() )
615 : {
616 0 : SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false );
617 0 : if( pAction )
618 0 : pModel->AddUndo( pAction );
619 : }
620 :
621 0 : AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation );
622 0 : if( iter != maAnnotations.end() )
623 0 : maAnnotations.erase( iter );
624 :
625 0 : if( pModel )
626 : {
627 0 : pModel->SetChanged();
628 0 : NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationRemoved", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
629 : }
630 114 : }
631 :
632 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|