1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdpage.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <svx/svdpage.hxx>
37 #include <sot/storage.hxx>
38 #include <sot/clsids.hxx>
39 #include <sot/storage.hxx>
40 #include <svx/svdview.hxx>
45 #include <vcl/svapp.hxx>
47 #include <tools/diagnose_ex.h>
49 #include <svx/svdetc.hxx>
50 #include <svx/svdobj.hxx>
51 #include <svx/svdogrp.hxx>
52 #include <svx/svdograf.hxx> // fuer SwapInAll()
53 #include <svx/svdoedge.hxx> // Zum kopieren der Konnektoren
54 #include <svx/svdoole2.hxx> // Sonderbehandlung OLE beim SdrExchangeFormat
55 #include "svditer.hxx"
56 #include <svx/svdmodel.hxx>
57 #include <svx/svdlayer.hxx>
58 #include <svx/svdotext.hxx>
59 #include <svx/svdpagv.hxx>
60 #include <svx/svdundo.hxx>
61 #include <svx/fmglob.hxx>
62 #include <svx/polysc3d.hxx>
64 #include <svx/fmdpage.hxx>
66 #include <sfx2/objsh.hxx>
67 #include <vcl/salbtype.hxx> // FRound
68 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
69 #include <svx/sdr/contact/viewobjectcontact.hxx>
70 #include <svx/sdr/contact/displayinfo.hxx>
73 using namespace ::com::sun::star
;
76 void DumpObjectList (const ::std::vector
<SdrObjectWeakRef
>& rContainer
)
78 ::std::vector
<SdrObjectWeakRef
>::const_iterator
iObject (rContainer
.begin());
79 ::std::vector
<SdrObjectWeakRef
>::const_iterator
iEnd (rContainer
.end());
80 for (int nIndex
=0 ; iObject
!=iEnd
; ++iObject
,++nIndex
)
82 const SdrObject
* pObject
= iObject
->get();
83 OSL_TRACE("%d : %x, %s", nIndex
,
85 ::rtl::OUStringToOString(pObject
->GetName(),RTL_TEXTENCODING_UTF8
).getStr());
91 class SdrObjList::WeakSdrObjectContainerType
92 : public ::std::vector
<SdrObjectWeakRef
>
95 WeakSdrObjectContainerType (const sal_Int32 nInitialSize
)
96 : ::std::vector
<SdrObjectWeakRef
>(nInitialSize
) {};
101 static const sal_Int32
InitialObjectContainerCapacity (64);
104 TYPEINIT0(SdrObjList
);
106 SdrObjList::SdrObjList(SdrModel
* pNewModel
, SdrPage
* pNewPage
, SdrObjList
* pNewUpList
):
109 mbIsNavigationOrderDirty(false)
111 DBG_CTOR(SdrObjList
,NULL
);
112 maList
.reserve(InitialObjectContainerCapacity
);
116 bObjOrdNumsDirty
=FALSE
;
119 eListKind
=SDROBJLIST_UNKNOWN
;
122 SdrObjList::SdrObjList(const SdrObjList
& rSrcList
):
125 mbIsNavigationOrderDirty(false)
127 DBG_CTOR(SdrObjList
,NULL
);
128 maList
.reserve(InitialObjectContainerCapacity
);
132 bObjOrdNumsDirty
=FALSE
;
135 eListKind
=SDROBJLIST_UNKNOWN
;
139 SdrObjList::~SdrObjList()
141 DBG_DTOR(SdrObjList
,NULL
);
144 // To avoid that the Clear() method will broadcast changes when in destruction
145 // which would call virtual methos (not allowed in destructor), the model is set
149 Clear(); // Containerinhalt loeschen!
152 void SdrObjList::operator=(const SdrObjList
& rSrcList
)
155 eListKind
=rSrcList
.eListKind
;
156 CopyObjects(rSrcList
);
159 void SdrObjList::CopyObjects(const SdrObjList
& rSrcList
)
162 bObjOrdNumsDirty
=FALSE
;
164 ULONG nCloneErrCnt
=0;
165 ULONG nAnz
=rSrcList
.GetObjCount();
166 SdrInsertReason
aReason(SDRREASON_COPY
);
168 for (no
=0; no
<nAnz
; no
++) {
169 SdrObject
* pSO
=rSrcList
.GetObj(no
);
172 //SdrObject* pDO=pSO->Clone(pPage,pModel);
173 SdrObject
* pDO
= pSO
->Clone();
174 pDO
->SetModel(pModel
);
178 NbcInsertObject(pDO
,CONTAINER_APPEND
,&aReason
);
183 // und nun zu den Konnektoren
184 // Die neuen Objekte werden auf die der rSrcList abgebildet
185 // und so die Objektverbindungen hergestellt.
186 // Aehnliche Implementation an folgenden Stellen:
187 // void SdrObjList::CopyObjects(const SdrObjList& rSrcList)
188 // SdrModel* SdrExchangeView::GetMarkedObjModel() const
189 // FASTBOOL SdrExchangeView::Paste(const SdrModel& rMod,...)
190 // void SdrEditView::CopyMarked()
191 if (nCloneErrCnt
==0) {
192 for (no
=0; no
<nAnz
; no
++) {
193 const SdrObject
* pSrcOb
=rSrcList
.GetObj(no
);
194 SdrEdgeObj
* pSrcEdge
=PTR_CAST(SdrEdgeObj
,pSrcOb
);
195 if (pSrcEdge
!=NULL
) {
196 SdrObject
* pSrcNode1
=pSrcEdge
->GetConnectedNode(TRUE
);
197 SdrObject
* pSrcNode2
=pSrcEdge
->GetConnectedNode(FALSE
);
198 if (pSrcNode1
!=NULL
&& pSrcNode1
->GetObjList()!=pSrcEdge
->GetObjList()) pSrcNode1
=NULL
; // Listenuebergreifend
199 if (pSrcNode2
!=NULL
&& pSrcNode2
->GetObjList()!=pSrcEdge
->GetObjList()) pSrcNode2
=NULL
; // ist (noch) nicht
200 if (pSrcNode1
!=NULL
|| pSrcNode2
!=NULL
) {
201 SdrObject
* pEdgeObjTmp
=GetObj(no
);
202 SdrEdgeObj
* pDstEdge
=PTR_CAST(SdrEdgeObj
,pEdgeObjTmp
);
203 if (pDstEdge
!=NULL
) {
204 if (pSrcNode1
!=NULL
) {
205 ULONG nDstNode1
=pSrcNode1
->GetOrdNum();
206 SdrObject
* pDstNode1
=GetObj(nDstNode1
);
207 if (pDstNode1
!=NULL
) { // Sonst grober Fehler!
208 pDstEdge
->ConnectToNode(TRUE
,pDstNode1
);
210 DBG_ERROR("SdrObjList::operator=(): pDstNode1==NULL!");
213 if (pSrcNode2
!=NULL
) {
214 ULONG nDstNode2
=pSrcNode2
->GetOrdNum();
215 SdrObject
* pDstNode2
=GetObj(nDstNode2
);
216 if (pDstNode2
!=NULL
) { // Node war sonst wohl nicht markiert
217 pDstEdge
->ConnectToNode(FALSE
,pDstNode2
);
219 DBG_ERROR("SdrObjList::operator=(): pDstNode2==NULL!");
223 DBG_ERROR("SdrObjList::operator=(): pDstEdge==NULL!");
230 ByteString
aStr("SdrObjList::operator=(): Fehler beim Clonen ");
232 if(nCloneErrCnt
== 1)
234 aStr
+= "eines Zeichenobjekts.";
239 aStr
+= ByteString::CreateFromInt32( nCloneErrCnt
);
240 aStr
+= " Zeichenobjekten.";
243 aStr
+= " Objektverbindungen werden nicht mitkopiert.";
245 DBG_ERROR(aStr
.GetBuffer());
250 void SdrObjList::Clear()
252 sal_Bool
bObjectsRemoved(sal_False
);
254 while( ! maList
.empty())
256 // remove last object from list
257 SdrObject
* pObj
= maList
.back();
258 RemoveObjectFromContainer(maList
.size()-1);
260 // flushViewObjectContacts() is done since SdrObject::Free is not guaranteed
261 // to delete the object and thus refresh visualisations
262 pObj
->GetViewContact().flushViewObjectContacts(true);
264 bObjectsRemoved
= sal_True
;
266 // sent remove hint (after removal, see RemoveObject())
269 SdrHint
aHint(*pObj
);
270 aHint
.SetKind(HINT_OBJREMOVED
);
271 aHint
.SetPage(pPage
);
272 pModel
->Broadcast(aHint
);
275 // delete the object itself
276 SdrObject::Free( pObj
);
279 if(pModel
&& bObjectsRemoved
)
281 pModel
->SetChanged();
285 SdrPage
* SdrObjList::GetPage() const
290 void SdrObjList::SetPage(SdrPage
* pNewPage
)
292 if (pPage
!=pNewPage
) {
294 ULONG nAnz
=GetObjCount();
295 for (ULONG no
=0; no
<nAnz
; no
++) {
296 SdrObject
* pObj
=GetObj(no
);
297 pObj
->SetPage(pPage
);
302 SdrModel
* SdrObjList::GetModel() const
307 void SdrObjList::SetModel(SdrModel
* pNewModel
)
309 if (pModel
!=pNewModel
) {
311 ULONG nAnz
=GetObjCount();
312 for (ULONG i
=0; i
<nAnz
; i
++) {
313 SdrObject
* pObj
=GetObj(i
);
314 pObj
->SetModel(pModel
);
319 void SdrObjList::RecalcObjOrdNums()
321 ULONG nAnz
=GetObjCount();
322 for (ULONG no
=0; no
<nAnz
; no
++) {
323 SdrObject
* pObj
=GetObj(no
);
326 bObjOrdNumsDirty
=FALSE
;
329 void SdrObjList::RecalcRects()
331 aOutRect
=Rectangle();
333 ULONG nAnz
=GetObjCount();
335 for (i
=0; i
<nAnz
; i
++) {
336 SdrObject
* pObj
=GetObj(i
);
338 aOutRect
=pObj
->GetCurrentBoundRect();
339 aSnapRect
=pObj
->GetSnapRect();
341 aOutRect
.Union(pObj
->GetCurrentBoundRect());
342 aSnapRect
.Union(pObj
->GetSnapRect());
347 void SdrObjList::SetRectsDirty()
350 if (pUpList
!=NULL
) pUpList
->SetRectsDirty();
353 void SdrObjList::impChildInserted(SdrObject
& rChild
) const
355 sdr::contact::ViewContact
* pParent
= rChild
.GetViewContact().GetParentContact();
359 pParent
->ActionChildInserted(rChild
.GetViewContact());
363 void SdrObjList::NbcInsertObject(SdrObject
* pObj
, ULONG nPos
, const SdrInsertReason
* /*pReason*/)
365 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::NbcInsertObject(NULL)");
367 DBG_ASSERT(!pObj
->IsInserted(),"ZObjekt hat bereits Inserted-Status");
368 ULONG nAnz
=GetObjCount();
369 if (nPos
>nAnz
) nPos
=nAnz
;
370 InsertObjectIntoContainer(*pObj
,nPos
);
372 if (nPos
<nAnz
) bObjOrdNumsDirty
=TRUE
;
373 pObj
->SetOrdNum(nPos
);
374 pObj
->SetObjList(this);
375 pObj
->SetPage(pPage
);
377 // #110094# Inform the parent about change to allow invalidations at
378 // evtl. existing parent visualisations
379 impChildInserted(*pObj
);
382 aOutRect
.Union(pObj
->GetCurrentBoundRect());
383 aSnapRect
.Union(pObj
->GetSnapRect());
385 pObj
->SetInserted(TRUE
); // Ruft u.a. den UserCall
389 void SdrObjList::InsertObject(SdrObject
* pObj
, ULONG nPos
, const SdrInsertReason
* pReason
)
391 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::InsertObject(NULL)");
395 // #69055# if anchor is used, reset it before grouping
398 const Point
& rAnchorPos
= pObj
->GetAnchorPos();
399 if(rAnchorPos
.X() || rAnchorPos
.Y())
400 pObj
->NbcSetAnchorPos(Point());
403 // do insert to new group
404 NbcInsertObject(pObj
, nPos
, pReason
);
406 // Falls das Objekt in eine Gruppe eingefuegt wird
407 // und nicht mit seinen Bruedern ueberlappt, muss es
408 // einen eigenen Redraw bekommen
412 pOwnerObj
->ActionChanged();
417 // Hier muss ein anderer Broadcast her!
418 // Repaint ab Objekt Nummer ... (Achtung: GroupObj)
421 SdrHint
aHint(*pObj
);
423 aHint
.SetKind(HINT_OBJINSERTED
);
424 pModel
->Broadcast(aHint
);
427 pModel
->SetChanged();
432 SdrObject
* SdrObjList::NbcRemoveObject(ULONG nObjNum
)
434 if (nObjNum
>= maList
.size())
436 OSL_ASSERT(nObjNum
<maList
.size());
440 ULONG nAnz
=GetObjCount();
441 SdrObject
* pObj
=maList
[nObjNum
];
442 RemoveObjectFromContainer(nObjNum
);
444 // flushViewObjectContacts() clears the VOC's and those invalidate
445 pObj
->GetViewContact().flushViewObjectContacts(true);
447 DBG_ASSERT(pObj
!=NULL
,"Object zum Removen nicht gefunden");
449 DBG_ASSERT(pObj
->IsInserted(),"ZObjekt hat keinen Inserted-Status");
450 pObj
->SetInserted(FALSE
); // Ruft u.a. den UserCall
451 pObj
->SetObjList(NULL
);
453 if (!bObjOrdNumsDirty
) { // Optimierung fuer den Fall, dass das letzte Obj rausgenommen wird
454 if (nObjNum
!=ULONG(nAnz
-1)) {
455 bObjOrdNumsDirty
=TRUE
;
463 SdrObject
* SdrObjList::RemoveObject(ULONG nObjNum
)
465 if (nObjNum
>= maList
.size())
467 OSL_ASSERT(nObjNum
<maList
.size());
471 ULONG nAnz
=GetObjCount();
472 SdrObject
* pObj
=maList
[nObjNum
];
473 RemoveObjectFromContainer(nObjNum
);
475 DBG_ASSERT(pObj
!=NULL
,"Object zum Removen nicht gefunden");
478 // flushViewObjectContacts() clears the VOC's and those invalidate
479 pObj
->GetViewContact().flushViewObjectContacts(true);
481 DBG_ASSERT(pObj
->IsInserted(),"ZObjekt hat keinen Inserted-Status");
483 // Hier muss ein anderer Broadcast her!
484 if (pObj
->GetPage()!=NULL
) {
485 SdrHint
aHint(*pObj
);
486 aHint
.SetKind(HINT_OBJREMOVED
);
487 pModel
->Broadcast(aHint
);
489 pModel
->SetChanged();
491 pObj
->SetInserted(FALSE
); // Ruft u.a. den UserCall
492 pObj
->SetObjList(NULL
);
494 if (!bObjOrdNumsDirty
) { // Optimierung fuer den Fall, dass das letzte Obj rausgenommen wird
495 if (nObjNum
!=ULONG(nAnz
-1)) {
496 bObjOrdNumsDirty
=TRUE
;
501 if(pOwnerObj
&& !GetObjCount())
503 // empty group created; it needs to be repainted since it's
504 // visualisation changes
505 pOwnerObj
->ActionChanged();
511 SdrObject
* SdrObjList::NbcReplaceObject(SdrObject
* pNewObj
, ULONG nObjNum
)
513 if (nObjNum
>= maList
.size() || pNewObj
== NULL
)
515 OSL_ASSERT(nObjNum
<maList
.size());
516 OSL_ASSERT(pNewObj
!=NULL
);
520 SdrObject
* pObj
=maList
[nObjNum
];
521 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::ReplaceObject: Object zum Removen nicht gefunden");
523 DBG_ASSERT(pObj
->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt hat keinen Inserted-Status");
524 pObj
->SetInserted(FALSE
);
525 pObj
->SetObjList(NULL
);
527 ReplaceObjectInContainer(*pNewObj
,nObjNum
);
529 // flushViewObjectContacts() clears the VOC's and those invalidate
530 pObj
->GetViewContact().flushViewObjectContacts(true);
532 pNewObj
->SetOrdNum(nObjNum
);
533 pNewObj
->SetObjList(this);
534 pNewObj
->SetPage(pPage
);
536 // #110094# Inform the parent about change to allow invalidations at
537 // evtl. existing parent visualisations
538 impChildInserted(*pNewObj
);
540 pNewObj
->SetInserted(TRUE
);
546 SdrObject
* SdrObjList::ReplaceObject(SdrObject
* pNewObj
, ULONG nObjNum
)
548 if (nObjNum
>= maList
.size())
550 OSL_ASSERT(nObjNum
<maList
.size());
555 OSL_ASSERT(pNewObj
!=NULL
);
559 SdrObject
* pObj
=maList
[nObjNum
];
560 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::ReplaceObject: Object zum Removen nicht gefunden");
562 DBG_ASSERT(pObj
->IsInserted(),"SdrObjList::ReplaceObject: ZObjekt hat keinen Inserted-Status");
564 // Hier muss ein anderer Broadcast her!
565 if (pObj
->GetPage()!=NULL
) {
566 SdrHint
aHint(*pObj
);
567 aHint
.SetKind(HINT_OBJREMOVED
);
568 pModel
->Broadcast(aHint
);
571 pObj
->SetInserted(FALSE
);
572 pObj
->SetObjList(NULL
);
574 ReplaceObjectInContainer(*pNewObj
,nObjNum
);
576 // flushViewObjectContacts() clears the VOC's and those invalidate
577 pObj
->GetViewContact().flushViewObjectContacts(true);
579 pNewObj
->SetOrdNum(nObjNum
);
580 pNewObj
->SetObjList(this);
581 pNewObj
->SetPage(pPage
);
583 // #110094# Inform the parent about change to allow invalidations at
584 // evtl. existing parent visualisations
585 impChildInserted(*pNewObj
);
587 pNewObj
->SetInserted(TRUE
);
589 // Hier muss ein anderer Broadcast her!
590 if (pNewObj
->GetPage()!=NULL
) {
591 SdrHint
aHint(*pNewObj
);
592 aHint
.SetKind(HINT_OBJINSERTED
);
593 pModel
->Broadcast(aHint
);
595 pModel
->SetChanged();
602 SdrObject
* SdrObjList::NbcSetObjectOrdNum(ULONG nOldObjNum
, ULONG nNewObjNum
)
604 if (nOldObjNum
>= maList
.size() || nNewObjNum
>= maList
.size())
606 OSL_ASSERT(nOldObjNum
<maList
.size());
607 OSL_ASSERT(nNewObjNum
<maList
.size());
611 SdrObject
* pObj
=maList
[nOldObjNum
];
612 if (nOldObjNum
==nNewObjNum
) return pObj
;
613 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::NbcSetObjectOrdNum: Object nicht gefunden");
615 DBG_ASSERT(pObj
->IsInserted(),"SdrObjList::NbcSetObjectOrdNum: ZObjekt hat keinen Inserted-Status");
616 RemoveObjectFromContainer(nOldObjNum
);
618 InsertObjectIntoContainer(*pObj
,nNewObjNum
);
620 // #110094# No need to delete visualisation data since same object
621 // gets inserted again. Also a single ActionChanged is enough
622 pObj
->ActionChanged();
624 pObj
->SetOrdNum(nNewObjNum
);
625 bObjOrdNumsDirty
=TRUE
;
630 SdrObject
* SdrObjList::SetObjectOrdNum(ULONG nOldObjNum
, ULONG nNewObjNum
)
632 if (nOldObjNum
>= maList
.size() || nNewObjNum
>= maList
.size())
634 OSL_ASSERT(nOldObjNum
<maList
.size());
635 OSL_ASSERT(nNewObjNum
<maList
.size());
639 SdrObject
* pObj
=maList
[nOldObjNum
];
640 if (nOldObjNum
==nNewObjNum
) return pObj
;
641 DBG_ASSERT(pObj
!=NULL
,"SdrObjList::SetObjectOrdNum: Object nicht gefunden");
643 DBG_ASSERT(pObj
->IsInserted(),"SdrObjList::SetObjectOrdNum: ZObjekt hat keinen Inserted-Status");
644 RemoveObjectFromContainer(nOldObjNum
);
645 InsertObjectIntoContainer(*pObj
,nNewObjNum
);
647 // #110094#No need to delete visualisation data since same object
648 // gets inserted again. Also a single ActionChanged is enough
649 pObj
->ActionChanged();
651 pObj
->SetOrdNum(nNewObjNum
);
652 bObjOrdNumsDirty
=TRUE
;
655 // Hier muss ein anderer Broadcast her!
656 if (pObj
->GetPage()!=NULL
) pModel
->Broadcast(SdrHint(*pObj
));
657 pModel
->SetChanged();
663 const Rectangle
& SdrObjList::GetAllObjSnapRect() const
666 ((SdrObjList
*)this)->RecalcRects();
667 ((SdrObjList
*)this)->bRectsDirty
=FALSE
;
672 const Rectangle
& SdrObjList::GetAllObjBoundRect() const
675 ((SdrObjList
*)this)->RecalcRects();
676 ((SdrObjList
*)this)->bRectsDirty
=FALSE
;
681 void SdrObjList::NbcReformatAllTextObjects()
683 ULONG nAnz
=GetObjCount();
686 Printer
* pPrinter
= NULL
;
690 if (pModel
->GetRefDevice() && pModel
->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER
)
692 // Kein RefDevice oder RefDevice kein Printer
693 pPrinter
= (Printer
*) pModel
->GetRefDevice();
699 SdrObject
* pObj
= GetObj(nNum
);
701 pObj
->GetObjInventor() == SdrInventor
&&
702 pObj
->GetObjIdentifier() == OBJ_OLE2
&&
703 !( (SdrOle2Obj
*) pObj
)->IsEmpty() )
705 //const SvInPlaceObjectRef& xObjRef = ((SdrOle2Obj*) pObj)->GetObjRef();
706 //TODO/LATER: PrinterChangeNotification needed
707 //if( xObjRef.Is() && ( xObjRef->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE ) )
708 // xObjRef->OnDocumentPrinterChanged(pPrinter);
711 pObj
->NbcReformatText();
712 nAnz
=GetObjCount(); // ReformatText may delete an object
718 void SdrObjList::ReformatAllTextObjects()
720 NbcReformatAllTextObjects();
723 /** steps over all available objects and reformats all
724 edge objects that are connected to other objects so that
725 they may reposition itselfs.
728 void SdrObjList::ReformatAllEdgeObjects()
730 const sal_uInt32 nCount
=GetObjCount();
733 for( nObj
= 0; nObj
< nCount
; nObj
++ )
735 SdrObject
* pObj
= GetObj(nObj
);
736 if( pObj
->ISA(SdrEdgeObj
) )
737 static_cast<SdrEdgeObj
*>(pObj
)->Reformat();
741 void SdrObjList::BurnInStyleSheetAttributes()
743 for(sal_uInt32
a(0L); a
< GetObjCount(); a
++)
745 GetObj(a
)->BurnInStyleSheetAttributes();
749 ULONG
SdrObjList::GetObjCount() const
751 return maList
.size();
757 SdrObject
* SdrObjList::GetObj(ULONG nNum
) const
759 if (nNum
>= maList
.size())
761 OSL_ASSERT(nNum
<maList
.size());
771 FASTBOOL
SdrObjList::IsReadOnly() const
774 if (pPage
!=NULL
&& pPage
!=this) bRet
=pPage
->IsReadOnly();
778 ULONG
SdrObjList::CountAllObjects() const
780 ULONG nCnt
=GetObjCount();
782 for (USHORT nNum
=0; nNum
<nAnz
; nNum
++) {
783 SdrObjList
* pSubOL
=GetObj(nNum
)->GetSubList();
785 nCnt
+=pSubOL
->CountAllObjects();
791 void SdrObjList::ForceSwapInObjects() const
793 ULONG nObjAnz
=GetObjCount();
794 for (ULONG nObjNum
=nObjAnz
; nObjNum
>0;) {
795 SdrObject
* pObj
=GetObj(--nObjNum
);
796 SdrGrafObj
* pGrafObj
=PTR_CAST(SdrGrafObj
,pObj
);
797 if (pGrafObj
!=NULL
) {
798 pGrafObj
->ForceSwapIn();
800 SdrObjList
* pOL
=pObj
->GetSubList();
802 pOL
->ForceSwapInObjects();
807 void SdrObjList::ForceSwapOutObjects() const
809 ULONG nObjAnz
=GetObjCount();
810 for (ULONG nObjNum
=nObjAnz
; nObjNum
>0;) {
811 SdrObject
* pObj
=GetObj(--nObjNum
);
812 SdrGrafObj
* pGrafObj
=PTR_CAST(SdrGrafObj
,pObj
);
813 if (pGrafObj
!=NULL
) {
814 pGrafObj
->ForceSwapOut();
816 SdrObjList
* pOL
=pObj
->GetSubList();
818 pOL
->ForceSwapOutObjects();
823 void SdrObjList::FlattenGroups()
825 sal_Int32 nObj
= GetObjCount();
827 for( i
=nObj
-1; i
>=0; --i
)
831 void SdrObjList::UnGroupObj( ULONG nObjNum
)
833 // if the given object is no group, this method is a noop
834 SdrObject
* pUngroupObj
= GetObj( nObjNum
);
837 SdrObjList
* pSrcLst
= pUngroupObj
->GetSubList();
838 //sal_Int32 nCount( 0 );
839 if( pUngroupObj
->ISA( SdrObjGroup
) && pSrcLst
)
841 SdrObjGroup
* pUngroupGroup
= static_cast< SdrObjGroup
* > (pUngroupObj
);
843 // ungroup recursively (has to be head recursion,
844 // otherwise our indices will get trashed when doing it in
846 pSrcLst
->FlattenGroups();
848 // the position at which we insert the members of rUngroupGroup
849 sal_Int32
nInsertPos( pUngroupGroup
->GetOrdNum() );
852 sal_Int32 i
, nAnz
= pSrcLst
->GetObjCount();
853 for( i
=0; i
<nAnz
; ++i
)
855 pObj
= pSrcLst
->RemoveObject(0);
856 SdrInsertReason
aReason(SDRREASON_VIEWCALL
, pUngroupGroup
);
857 InsertObject(pObj
, nInsertPos
, &aReason
);
861 RemoveObject(nInsertPos
);
866 DBG_ERROR("SdrObjList::UnGroupObj: object index invalid");
873 bool SdrObjList::HasObjectNavigationOrder (void) const
875 return mpNavigationOrder
.get() != NULL
;
881 void SdrObjList::SetObjectNavigationPosition (
883 const sal_uInt32 nNewPosition
)
885 // When the navigation order container has not yet been created then
886 // create one now. It is initialized with the z-order taken from
888 if (mpNavigationOrder
.get() == NULL
)
890 mpNavigationOrder
.reset(new WeakSdrObjectContainerType(maList
.size()));
894 mpNavigationOrder
->begin());
896 OSL_ASSERT(mpNavigationOrder
.get()!=NULL
);
897 OSL_ASSERT( mpNavigationOrder
->size() == maList
.size());
899 SdrObjectWeakRef
aReference (&rObject
);
901 // Look up the object whose navigation position is to be changed.
902 WeakSdrObjectContainerType::iterator
iObject (::std::find(
903 mpNavigationOrder
->begin(),
904 mpNavigationOrder
->end(),
906 if (iObject
== mpNavigationOrder
->end())
908 // The given object is not a member of the navigation order.
912 // Move the object to its new position.
913 const sal_uInt32 nOldPosition
= ::std::distance(mpNavigationOrder
->begin(), iObject
);
914 if (nOldPosition
!= nNewPosition
)
916 mpNavigationOrder
->erase(iObject
);
917 sal_uInt32
nInsertPosition (nNewPosition
);
918 // Adapt insertion position for the just erased object.
919 if (nNewPosition
>= nOldPosition
)
920 nInsertPosition
-= 1;
921 if (nInsertPosition
>= mpNavigationOrder
->size())
922 mpNavigationOrder
->push_back(aReference
);
924 mpNavigationOrder
->insert(mpNavigationOrder
->begin()+nInsertPosition
, aReference
);
926 mbIsNavigationOrderDirty
= true;
928 // The navigation order is written out to file so mark the model as modified.
930 pModel
->SetChanged();
937 SdrObject
* SdrObjList::GetObjectForNavigationPosition (const sal_uInt32 nNavigationPosition
) const
939 if (HasObjectNavigationOrder())
941 // There is a user defined navigation order. Make sure the object
942 // index is correct and look up the object in mpNavigationOrder.
943 if (nNavigationPosition
>= mpNavigationOrder
->size())
945 OSL_ASSERT(nNavigationPosition
< mpNavigationOrder
->size());
948 return (*mpNavigationOrder
)[nNavigationPosition
].get();
952 // There is no user defined navigation order. Use the z-order
954 if (nNavigationPosition
>= maList
.size())
956 OSL_ASSERT(nNavigationPosition
< maList
.size());
959 return maList
[nNavigationPosition
];
967 void SdrObjList::ClearObjectNavigationOrder (void)
969 mpNavigationOrder
.reset();
970 mbIsNavigationOrderDirty
= true;
976 bool SdrObjList::RecalcNavigationPositions (void)
978 bool bUpToDate (false);
980 if (mbIsNavigationOrderDirty
)
982 if (mpNavigationOrder
.get() != NULL
)
984 mbIsNavigationOrderDirty
= false;
986 WeakSdrObjectContainerType::iterator iObject
;
987 WeakSdrObjectContainerType::const_iterator
iEnd (mpNavigationOrder
->end());
988 sal_uInt32
nIndex (0);
989 for (iObject
=mpNavigationOrder
->begin(); iObject
!=iEnd
; ++iObject
,++nIndex
)
990 (*iObject
)->SetNavigationPosition(nIndex
);
996 return mpNavigationOrder
.get() != NULL
;
1002 void SdrObjList::SetNavigationOrder (const uno::Reference
<container::XIndexAccess
>& rxOrder
)
1006 const sal_Int32 nCount
= rxOrder
->getCount();
1007 if ((sal_uInt32
)nCount
!= maList
.size())
1010 if (mpNavigationOrder
.get() == NULL
)
1011 mpNavigationOrder
.reset(new WeakSdrObjectContainerType(nCount
));
1013 for (sal_Int32 nIndex
=0; nIndex
<nCount
; ++nIndex
)
1015 uno::Reference
<uno::XInterface
> xShape (rxOrder
->getByIndex(nIndex
), uno::UNO_QUERY
);
1016 SdrObject
* pObject
= SdrObject::getSdrObjectFromXShape(xShape
);
1017 if (pObject
== NULL
)
1019 (*mpNavigationOrder
)[nIndex
] = pObject
;
1022 mbIsNavigationOrderDirty
= true;
1025 ClearObjectNavigationOrder();
1031 void SdrObjList::InsertObjectIntoContainer (
1033 const sal_uInt32 nInsertPosition
)
1035 OSL_ASSERT(nInsertPosition
<=maList
.size());
1037 // Update the navigation positions.
1038 if (HasObjectNavigationOrder())
1040 // The new object does not have a user defined position so append it
1042 rObject
.SetNavigationPosition(mpNavigationOrder
->size());
1043 mpNavigationOrder
->push_back(&rObject
);
1046 // Insert object into object list. Because the insert() method requires
1047 // a valid iterator as insertion position, we have to use push_back() to
1048 // insert at the end of the list.
1049 if (nInsertPosition
>= maList
.size())
1050 maList
.push_back(&rObject
);
1052 maList
.insert(maList
.begin()+nInsertPosition
, &rObject
);
1053 bObjOrdNumsDirty
=TRUE
;
1059 void SdrObjList::ReplaceObjectInContainer (
1060 SdrObject
& rNewObject
,
1061 const sal_uInt32 nObjectPosition
)
1063 if (nObjectPosition
>= maList
.size())
1065 OSL_ASSERT(nObjectPosition
<maList
.size());
1069 // Update the navigation positions.
1070 if (HasObjectNavigationOrder())
1072 // A user defined position of the object that is to be replaced is
1073 // not transferred to the new object so erase the former and append
1074 // the later object from/to the navigation order.
1075 OSL_ASSERT(nObjectPosition
< maList
.size());
1076 SdrObjectWeakRef
aReference (maList
[nObjectPosition
]);
1077 WeakSdrObjectContainerType::iterator
iObject (::std::find(
1078 mpNavigationOrder
->begin(),
1079 mpNavigationOrder
->end(),
1081 if (iObject
!= mpNavigationOrder
->end())
1082 mpNavigationOrder
->erase(iObject
);
1084 mpNavigationOrder
->push_back(&rNewObject
);
1086 mbIsNavigationOrderDirty
= true;
1089 maList
[nObjectPosition
] = &rNewObject
;
1090 bObjOrdNumsDirty
=TRUE
;
1096 void SdrObjList::RemoveObjectFromContainer (
1097 const sal_uInt32 nObjectPosition
)
1099 if (nObjectPosition
>= maList
.size())
1101 OSL_ASSERT(nObjectPosition
<maList
.size());
1105 // Update the navigation positions.
1106 if (HasObjectNavigationOrder())
1108 SdrObjectWeakRef
aReference (maList
[nObjectPosition
]);
1109 WeakSdrObjectContainerType::iterator
iObject (::std::find(
1110 mpNavigationOrder
->begin(),
1111 mpNavigationOrder
->end(),
1113 if (iObject
!= mpNavigationOrder
->end())
1114 mpNavigationOrder
->erase(iObject
);
1115 mbIsNavigationOrderDirty
= true;
1118 maList
.erase(maList
.begin()+nObjectPosition
);
1119 bObjOrdNumsDirty
=TRUE
;
1125 ////////////////////////////////////////////////////////////////////////////////////////////////////
1127 void SdrPageGridFrameList::Clear()
1129 USHORT nAnz
=GetCount();
1130 for (USHORT i
=0; i
<nAnz
; i
++) {
1131 delete GetObject(i
);
1136 //////////////////////////////////////////////////////////////////////////////
1137 // #111111# PageUser section
1139 void SdrPage::AddPageUser(sdr::PageUser
& rNewUser
)
1141 maPageUsers
.push_back(&rNewUser
);
1144 void SdrPage::RemovePageUser(sdr::PageUser
& rOldUser
)
1146 const ::sdr::PageUserVector::iterator aFindResult
= ::std::find(maPageUsers
.begin(), maPageUsers
.end(), &rOldUser
);
1147 if(aFindResult
!= maPageUsers
.end())
1149 maPageUsers
.erase(aFindResult
);
1153 //////////////////////////////////////////////////////////////////////////////
1154 // #110094# DrawContact section
1156 sdr::contact::ViewContact
* SdrPage::CreateObjectSpecificViewContact()
1158 return new sdr::contact::ViewContactOfSdrPage(*this);
1161 sdr::contact::ViewContact
& SdrPage::GetViewContact() const
1165 ((SdrPage
*)this)->mpViewContact
= ((SdrPage
*)this)->CreateObjectSpecificViewContact();
1168 return *mpViewContact
;
1171 ////////////////////////////////////////////////////////////////////////////////////////////////////
1173 TYPEINIT1(SdrPage
,SdrObjList
);
1175 SdrPage::SdrPage(SdrModel
& rNewModel
, bool bMasterPage
)
1176 : SdrObjList(&rNewModel
, this),
1184 pLayerAdmin(new SdrLayerAdmin(&rNewModel
.GetLayerAdmin())),
1186 mpMasterPageDescriptor(0L),
1188 mbMaster(bMasterPage
),
1190 mbObjectsNotPersistent(false),
1191 mbSwappingLocked(false),
1192 mbPageBorderOnlyLeftRight(false)
1194 DBG_CTOR(SdrPage
,NULL
);
1195 aPrefVisiLayers
.SetAll();
1196 eListKind
= (bMasterPage
) ? SDROBJLIST_MASTERPAGE
: SDROBJLIST_DRAWPAGE
;
1199 SdrPage::SdrPage(const SdrPage
& rSrcPage
)
1200 : SdrObjList(rSrcPage
.pModel
, this),
1201 tools::WeakBase
< SdrPage
>(),
1203 nWdt(rSrcPage
.nWdt
),
1204 nHgt(rSrcPage
.nHgt
),
1205 nBordLft(rSrcPage
.nBordLft
),
1206 nBordUpp(rSrcPage
.nBordUpp
),
1207 nBordRgt(rSrcPage
.nBordRgt
),
1208 nBordLwr(rSrcPage
.nBordLwr
),
1209 pLayerAdmin(new SdrLayerAdmin(rSrcPage
.pModel
->GetLayerAdmin())),
1211 mpMasterPageDescriptor(0L),
1212 nPageNum(rSrcPage
.nPageNum
),
1213 mbMaster(rSrcPage
.mbMaster
),
1215 mbObjectsNotPersistent(rSrcPage
.mbObjectsNotPersistent
),
1216 mbSwappingLocked(rSrcPage
.mbSwappingLocked
),
1217 mbPageBorderOnlyLeftRight(rSrcPage
.mbPageBorderOnlyLeftRight
)
1219 DBG_CTOR(SdrPage
,NULL
);
1220 aPrefVisiLayers
.SetAll();
1221 eListKind
= (mbMaster
) ? SDROBJLIST_MASTERPAGE
: SDROBJLIST_DRAWPAGE
;
1223 // copy things from source
1224 // Warning: this leads to slicing (see issue 93186) and has to be
1225 // removed as soon as possible.
1228 // be careful and correct eListKind, a member of SdrObjList which
1229 // will be changed by the SdrOIbjList::operator= before...
1230 eListKind
= (mbMaster
) ? SDROBJLIST_MASTERPAGE
: SDROBJLIST_DRAWPAGE
;
1232 // The previous assignment to *this may have resulted in a call to
1233 // createUnoPage at a partially initialized (sliced) SdrPage object.
1234 // Due to the vtable being not yet fully set-up at this stage,
1235 // createUnoPage() may have been called at the wrong class.
1236 // To force a call to the right createUnoPage() at a later time when the
1237 // new object is full constructed mxUnoPage is disposed now.
1238 uno::Reference
<lang::XComponent
> xComponent (mxUnoPage
, uno::UNO_QUERY
);
1239 if (xComponent
.is())
1242 xComponent
->dispose();
1248 if( mxUnoPage
.is() ) try
1250 uno::Reference
< lang::XComponent
> xPageComponent( mxUnoPage
, uno::UNO_QUERY_THROW
);
1252 xPageComponent
->dispose();
1254 catch( const uno::Exception
& )
1256 DBG_UNHANDLED_EXCEPTION();
1260 // tell all the registered PageUsers that the page is in destruction
1261 // This causes some (all?) PageUsers to remove themselves from the list
1262 // of page users. Therefore we have to use a copy of the list for the
1264 ::sdr::PageUserVector
aListCopy (maPageUsers
.begin(), maPageUsers
.end());
1265 for(::sdr::PageUserVector::iterator aIterator
= aListCopy
.begin(); aIterator
!= aListCopy
.end(); aIterator
++)
1267 sdr::PageUser
* pPageUser
= *aIterator
;
1268 DBG_ASSERT(pPageUser
, "SdrPage::~SdrPage: corrupt PageUser list (!)");
1269 pPageUser
->PageInDestruction(*this);
1273 // Clear the vector. This means that user do not need to call RemovePageUser()
1274 // when they get called from PageInDestruction().
1275 maPageUsers
.clear();
1277 SdrObject::Free( pBackgroundObj
);
1280 TRG_ClearMasterPage();
1285 delete mpViewContact
;
1289 DBG_DTOR(SdrPage
,NULL
);
1292 void SdrPage::operator=(const SdrPage
& rSrcPage
)
1296 delete mpViewContact
;
1300 SdrObject::Free( pBackgroundObj
);
1302 // Joe also sets some parameters for the class this one
1303 // is derived from. SdrObjList does the same bad handling of
1304 // copy constructor and operator=, so i better let it stand here.
1307 // copy all the local parameters to make this instance
1308 // a valid copy od source page before copying and inserting
1309 // the contained objects
1310 mbMaster
= rSrcPage
.mbMaster
;
1311 mbSwappingLocked
= rSrcPage
.mbSwappingLocked
;
1312 mbPageBorderOnlyLeftRight
= rSrcPage
.mbPageBorderOnlyLeftRight
;
1313 aPrefVisiLayers
= rSrcPage
.aPrefVisiLayers
;
1314 nWdt
= rSrcPage
.nWdt
;
1315 nHgt
= rSrcPage
.nHgt
;
1316 nBordLft
= rSrcPage
.nBordLft
;
1317 nBordUpp
= rSrcPage
.nBordUpp
;
1318 nBordRgt
= rSrcPage
.nBordRgt
;
1319 nBordLwr
= rSrcPage
.nBordLwr
;
1320 nPageNum
= rSrcPage
.nPageNum
;
1322 if(rSrcPage
.TRG_HasMasterPage())
1324 TRG_SetMasterPage(rSrcPage
.TRG_GetMasterPage());
1325 TRG_SetMasterPageVisibleLayers(rSrcPage
.TRG_GetMasterPageVisibleLayers());
1329 TRG_ClearMasterPage();
1331 //aMasters = rSrcPage.aMasters;
1333 mbObjectsNotPersistent
= rSrcPage
.mbObjectsNotPersistent
;
1335 if(rSrcPage
.pBackgroundObj
)
1337 pBackgroundObj
= rSrcPage
.pBackgroundObj
->Clone();
1338 pBackgroundObj
->SetPage( this );
1339 pBackgroundObj
->SetModel( pModel
);
1341 // #i62000# for single-page MPBGO, force no line
1342 pBackgroundObj
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
1345 // Now copy the contained obejcts (by cloning them)
1346 SdrObjList::operator=(rSrcPage
);
1349 SdrPage
* SdrPage::Clone() const
1354 SdrPage
* SdrPage::Clone(SdrModel
* pNewModel
) const
1356 if (pNewModel
==NULL
) pNewModel
=pModel
;
1357 SdrPage
* pPage2
=new SdrPage(*pNewModel
);
1362 void SdrPage::SetSize(const Size
& aSiz
)
1364 bool bChanged(false);
1366 if(aSiz
.Width() != nWdt
)
1368 nWdt
= aSiz
.Width();
1372 if(aSiz
.Height() != nHgt
)
1374 nHgt
= aSiz
.Height();
1384 Size
SdrPage::GetSize() const
1386 return Size(nWdt
,nHgt
);
1389 INT32
SdrPage::GetWdt() const
1394 void SdrPage::SetOrientation(Orientation eOri
)
1396 // Quadratisch ist und bleibt immer Portrait
1397 Size
aSiz(GetSize());
1398 if (aSiz
.Width()!=aSiz
.Height()) {
1399 if ((eOri
==ORIENTATION_PORTRAIT
) == (aSiz
.Width()>aSiz
.Height())) {
1400 SetSize(Size(aSiz
.Height(),aSiz
.Width()));
1405 Orientation
SdrPage::GetOrientation() const
1407 // Quadratisch ist Portrait
1408 Orientation eRet
=ORIENTATION_PORTRAIT
;
1409 Size
aSiz(GetSize());
1410 if (aSiz
.Width()>aSiz
.Height()) eRet
=ORIENTATION_LANDSCAPE
;
1414 INT32
SdrPage::GetHgt() const
1419 void SdrPage::SetBorder(INT32 nLft
, INT32 nUpp
, INT32 nRgt
, INT32 nLwr
)
1421 bool bChanged(false);
1423 if(nBordLft
!= nLft
)
1429 if(nBordUpp
!= nUpp
)
1435 if(nBordRgt
!= nRgt
)
1441 if(nBordLwr
!= nLwr
)
1453 void SdrPage::SetLftBorder(INT32 nBorder
)
1455 if(nBordLft
!= nBorder
)
1462 void SdrPage::SetUppBorder(INT32 nBorder
)
1464 if(nBordUpp
!= nBorder
)
1471 void SdrPage::SetRgtBorder(INT32 nBorder
)
1473 if(nBordRgt
!= nBorder
)
1480 void SdrPage::SetLwrBorder(INT32 nBorder
)
1482 if(nBordLwr
!= nBorder
)
1489 INT32
SdrPage::GetLftBorder() const
1494 INT32
SdrPage::GetUppBorder() const
1499 INT32
SdrPage::GetRgtBorder() const
1504 INT32
SdrPage::GetLwrBorder() const
1509 void SdrPage::SetModel(SdrModel
* pNewModel
)
1511 SdrModel
* pOldModel
=pModel
;
1512 SdrObjList::SetModel(pNewModel
);
1513 if (pNewModel
!=pOldModel
)
1515 if (pNewModel
!=NULL
) {
1516 pLayerAdmin
->SetParent(&pNewModel
->GetLayerAdmin());
1518 pLayerAdmin
->SetParent(NULL
);
1520 pLayerAdmin
->SetModel(pNewModel
);
1522 if( pBackgroundObj
)
1523 pBackgroundObj
->SetModel( pNewModel
);
1526 // update listeners at possible api wrapper object
1527 if( pOldModel
!= pNewModel
)
1529 if( mxUnoPage
.is() )
1531 SvxDrawPage
* pPage2
= SvxDrawPage::getImplementation( mxUnoPage
);
1533 pPage2
->ChangeModel( pNewModel
);
1538 ////////////////////////////////////////////////////////////////////////////////////////////////////
1540 // #i68775# React on PageNum changes (from Model in most cases)
1541 void SdrPage::SetPageNum(sal_uInt16 nNew
)
1543 if(nNew
!= nPageNum
)
1548 // notify visualisations, also notifies e.g. buffered MasterPages
1553 USHORT
SdrPage::GetPageNum() const
1559 if (pModel
&& pModel
->IsMPgNumsDirty())
1560 ((SdrModel
*)pModel
)->RecalcPageNums(TRUE
);
1562 if (pModel
&& pModel
->IsPagNumsDirty())
1563 ((SdrModel
*)pModel
)->RecalcPageNums(FALSE
);
1568 void SdrPage::SetChanged()
1571 // For test purposes, use the new ViewContact for change
1572 // notification now.
1577 pModel
->SetChanged();
1581 ////////////////////////////////////////////////////////////////////////////////////////////////////
1582 // MasterPage interface
1584 void SdrPage::TRG_SetMasterPage(SdrPage
& rNew
)
1586 if(mpMasterPageDescriptor
&& &(mpMasterPageDescriptor
->GetUsedPage()) == &rNew
)
1589 if(mpMasterPageDescriptor
)
1590 TRG_ClearMasterPage();
1592 mpMasterPageDescriptor
= new ::sdr::MasterPageDescriptor(*this, rNew
);
1593 GetViewContact().ActionChanged();
1596 void SdrPage::TRG_ClearMasterPage()
1598 if(mpMasterPageDescriptor
)
1602 // the flushViewObjectContacts() will do needed invalidates by deleting the involved VOCs
1603 mpMasterPageDescriptor
->GetUsedPage().GetViewContact().flushViewObjectContacts(true);
1605 delete mpMasterPageDescriptor
;
1606 mpMasterPageDescriptor
= 0L;
1610 SdrPage
& SdrPage::TRG_GetMasterPage() const
1612 DBG_ASSERT(mpMasterPageDescriptor
!= 0L, "TRG_GetMasterPage(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1613 return mpMasterPageDescriptor
->GetUsedPage();
1616 const SetOfByte
& SdrPage::TRG_GetMasterPageVisibleLayers() const
1618 DBG_ASSERT(mpMasterPageDescriptor
!= 0L, "TRG_GetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1619 return mpMasterPageDescriptor
->GetVisibleLayers();
1622 void SdrPage::TRG_SetMasterPageVisibleLayers(const SetOfByte
& rNew
)
1624 DBG_ASSERT(mpMasterPageDescriptor
!= 0L, "TRG_SetMasterPageVisibleLayers(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1625 mpMasterPageDescriptor
->SetVisibleLayers(rNew
);
1628 sdr::contact::ViewContact
& SdrPage::TRG_GetMasterPageDescriptorViewContact() const
1630 DBG_ASSERT(mpMasterPageDescriptor
!= 0L, "TRG_GetMasterPageDescriptorViewContact(): No MasterPage available. Use TRG_HasMasterPage() before access (!)");
1631 return mpMasterPageDescriptor
->GetViewContact();
1634 // #115423# used from SdrModel::RemoveMasterPage
1635 void SdrPage::TRG_ImpMasterPageRemoved(const SdrPage
& rRemovedPage
)
1637 if(TRG_HasMasterPage())
1639 if(&TRG_GetMasterPage() == &rRemovedPage
)
1641 TRG_ClearMasterPage();
1646 const SdrPageGridFrameList
* SdrPage::GetGridFrameList(const SdrPageView
* /*pPV*/, const Rectangle
* /*pRect*/) const
1651 XubString
SdrPage::GetLayoutName() const
1653 // Die wollte Dieter haben.
1657 void SdrPage::SetBackgroundObj( SdrObject
* pObj
)
1661 pObj
->SetPage( this );
1662 pObj
->SetModel( pModel
);
1663 pObj
->SetLayer( 1 ); // Nothing known about the backgroundlayer...
1665 // #i62000# for single-page MPBGO, force no line
1666 pObj
->SetMergedItem(XLineStyleItem(XLINE_NONE
));
1669 SdrObject::Free( pBackgroundObj
);
1670 pBackgroundObj
= pObj
;
1673 void SdrPage::SetInserted( bool bIns
)
1675 if( mbInserted
!= bIns
)
1679 SdrObjListIter
aIter( *this, IM_FLAT
);
1680 while ( aIter
.IsMore() )
1682 SdrObject
* pObj
= aIter
.Next();
1683 if ( pObj
->ISA(SdrOle2Obj
) )
1686 ( (SdrOle2Obj
*) pObj
)->Connect();
1688 ( (SdrOle2Obj
*) pObj
)->Disconnect();
1695 uno::Reference
< uno::XInterface
> SdrPage::getUnoPage()
1697 // try weak reference first
1698 if( !mxUnoPage
.is() )
1701 mxUnoPage
= createUnoPage();
1707 uno::Reference
< uno::XInterface
> SdrPage::createUnoPage()
1709 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> xInt
=
1710 static_cast<cppu::OWeakObject
*>( new SvxFmDrawPage( this ) );
1714 SfxStyleSheet
* SdrPage::GetTextStyleSheetForObject( SdrObject
* pObj
) const
1716 return pObj
->GetStyleSheet();
1719 FASTBOOL
SdrPage::HasTransparentObjects( BOOL bCheckForAlphaChannel
) const
1721 FASTBOOL bRet
= FALSE
;
1723 for( ULONG n
= 0, nCount
= GetObjCount(); ( n
< nCount
) && !bRet
; n
++ )
1724 if( GetObj( n
)->IsTransparent( bCheckForAlphaChannel
) )
1730 /** returns an averaged background color of this page */
1731 // #i75566# GetBackgroundColor -> GetPageBackgroundColor and bScreenDisplay hint value
1732 Color
SdrPage::GetPageBackgroundColor( SdrPageView
* pView
, bool bScreenDisplay
) const
1736 if(bScreenDisplay
&& (!pView
|| pView
->GetApplicationDocumentColor() == COL_AUTO
))
1738 svtools::ColorConfig aColorConfig
;
1739 aColor
= aColorConfig
.GetColorValue( svtools::DOCCOLOR
).nColor
;
1743 aColor
= pView
->GetApplicationDocumentColor();
1746 // first, see if we have a background object
1747 SdrObject
* pBackgroundObj2
= NULL
;
1750 if( IsMasterPage() )
1753 pBackgroundObj2
= GetObj( 0 );
1757 pBackgroundObj2
= GetBackgroundObj();
1758 if( NULL
== pBackgroundObj2
)
1760 // if not, see if we have a masterpage and get that background object
1761 if(TRG_HasMasterPage())
1763 SdrPage
& rMasterPage
= TRG_GetMasterPage();
1765 if(rMasterPage
.GetObjCount())
1767 pBackgroundObj2
= rMasterPage
.GetObj( 0 );
1773 if( pBackgroundObj2
)
1775 const SfxItemSet
& rSet
= pBackgroundObj2
->GetMergedItemSet();
1776 GetDraftFillColor( rSet
, aColor
);
1782 /** *deprecated, use GetBackgroundColor with SdrPageView */
1783 Color
SdrPage::GetPageBackgroundColor() const
1784 // #i75566# GetBackgroundColor -> GetPageBackgroundColor
1786 return GetPageBackgroundColor( NULL
, true );
1789 /** this method returns true if the object from the ViewObjectContact should
1790 be visible on this page while rendering.
1791 bEdit selects if visibility test is for an editing view or a final render,
1794 bool SdrPage::checkVisibility(
1795 const sdr::contact::ViewObjectContact
& /*rOriginal*/,
1796 const sdr::contact::DisplayInfo
& /*rDisplayInfo*/,
1799 // this will be handled in the application if needed
1803 // #110094# DrawContact support: Methods for handling Page changes
1804 void SdrPage::ActionChanged() const
1806 // Do necessary ViewContact actions
1807 GetViewContact().ActionChanged();
1809 // #i48535# also handle MasterPage change
1810 if(TRG_HasMasterPage())
1812 TRG_GetMasterPageDescriptorViewContact().ActionChanged();
1816 // NYI: Dummy implementations for declarations in svdpage.hxx
1817 Bitmap
SdrPage::GetBitmap(const SetOfByte
& /*rVisibleLayers*/, FASTBOOL
/*bTrimBorders*/) const
1819 DBG_ASSERT(0, "SdrPage::GetBitmap(): not yet implemented.");
1822 GDIMetaFile
SdrPage::GetMetaFile(const SetOfByte
& /*rVisibleLayers*/, FASTBOOL
/*bTrimBorders*/)
1824 DBG_ASSERT(0, "SdrPage::GetMetaFile(): not yet implemented.");
1825 return GDIMetaFile();
1828 //////////////////////////////////////////////////////////////////////////////
1829 // sdr::Comment interface
1831 const sdr::Comment
& SdrPage::GetCommentByIndex(sal_uInt32 nIndex
)
1833 DBG_ASSERT(nIndex
< maComments
.size(), "SdrPage::GetCommentByIndex: Access out of range (!)");
1834 return maComments
[nIndex
];
1837 void SdrPage::AddComment(const sdr::Comment
& rNew
)
1839 maComments
.push_back(rNew
);
1840 ::std::sort(maComments
.begin(), maComments
.end());
1843 void SdrPage::ReplaceCommentByIndex(sal_uInt32 nIndex
, const sdr::Comment
& rNew
)
1845 DBG_ASSERT(nIndex
< maComments
.size(), "SdrPage::GetCommentByIndex: Access out of range (!)");
1847 if(maComments
[nIndex
] != rNew
)
1849 maComments
[nIndex
] = rNew
;
1850 ::std::sort(maComments
.begin(), maComments
.end());
1854 //////////////////////////////////////////////////////////////////////////////
1855 // use new redirector instead of pPaintProc
1857 StandardCheckVisisbilityRedirector::StandardCheckVisisbilityRedirector()
1858 : ViewObjectContactRedirector()
1862 StandardCheckVisisbilityRedirector::~StandardCheckVisisbilityRedirector()
1866 drawinglayer::primitive2d::Primitive2DSequence
StandardCheckVisisbilityRedirector::createRedirectedPrimitive2DSequence(
1867 const sdr::contact::ViewObjectContact
& rOriginal
,
1868 const sdr::contact::DisplayInfo
& rDisplayInfo
)
1870 SdrObject
* pObject
= rOriginal
.GetViewContact().TryToGetSdrObject();
1874 if(pObject
->GetPage())
1876 if(pObject
->GetPage()->checkVisibility(rOriginal
, rDisplayInfo
, false))
1878 return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal
, rDisplayInfo
);
1882 return drawinglayer::primitive2d::Primitive2DSequence();
1886 // not an object, maybe a page
1887 return ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal
, rDisplayInfo
);
1891 //////////////////////////////////////////////////////////////////////////////