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: svdpagv.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"
33 #include <svx/svdpagv.hxx>
34 #include <com/sun/star/awt/XWindow.hpp>
35 #include <com/sun/star/awt/PosSize.hpp>
36 #include <comphelper/processfactory.hxx>
37 #include <svx/svdoutl.hxx>
38 #include <svx/xpoly.hxx>
39 #include <svx/svdouno.hxx>
40 #include <svx/svdpage.hxx>
41 #include <svx/svdview.hxx>
43 #include <svx/svdedxv.hxx>
44 #include <svx/svdpagv.hxx>
45 #include <svx/svdoutl.hxx>
46 #include <svx/svdpagv.hxx>
47 #include <svx/outliner.hxx>
48 #include <svx/svdetc.hxx>
49 #include <svx/svdobj.hxx>
50 #include <svx/svdouno.hxx>
51 #include <svx/svdpage.hxx>
52 #include <svx/svdview.hxx>
53 #include "svditer.hxx"
54 #include <svx/svdogrp.hxx>
55 #include <svx/svdtypes.hxx>
57 #include <svx/svdotext.hxx> // fuer PaintOutlinerView
58 #include <svx/svdoole2.hxx>
61 #include <svx/sdr/contact/objectcontactofpageview.hxx>
62 #include <svx/svdogrp.hxx>
63 #include <svx/sdr/contact/viewobjectcontactredirector.hxx>
64 #include <svx/fmview.hxx>
66 // for search on vector
69 using namespace ::rtl
;
70 using namespace ::com::sun::star
;
71 #include <svx/sdrpagewindow.hxx>
72 #include <sdrpaintwindow.hxx>
74 TYPEINIT1(SdrPageView
, SfxListener
);
75 DBG_NAME(SdrPageView
);
77 ////////////////////////////////////////////////////////////////////////////////////////////////////
78 // interface to SdrPageWindow
80 SdrPageWindow
* SdrPageView::FindPageWindow(SdrPaintWindow
& rPaintWindow
) const
82 for(SdrPageWindowVector::const_iterator a
= maPageWindows
.begin(); a
!= maPageWindows
.end(); a
++)
84 if(&((*a
)->GetPaintWindow()) == &rPaintWindow
)
93 const SdrPageWindow
* SdrPageView::FindPatchedPageWindow( const OutputDevice
& _rOutDev
) const
95 for ( SdrPageWindowVector::const_iterator loop
= maPageWindows
.begin();
96 loop
!= maPageWindows
.end();
100 const SdrPageWindow
& rPageWindow( *(*loop
) );
101 const SdrPaintWindow
& rPaintWindow( rPageWindow
.GetOriginalPaintWindow() ? *rPageWindow
.GetOriginalPaintWindow() : rPageWindow
.GetPaintWindow() );
102 if ( &rPaintWindow
.GetOutputDevice() == &_rOutDev
)
111 SdrPageWindow
* SdrPageView::FindPageWindow(const OutputDevice
& rOutDev
) const
113 for(SdrPageWindowVector::const_iterator a
= maPageWindows
.begin(); a
!= maPageWindows
.end(); a
++)
115 if(&((*a
)->GetPaintWindow().GetOutputDevice()) == &rOutDev
)
124 SdrPageWindow
* SdrPageView::GetPageWindow(sal_uInt32 nIndex
) const
127 if(nIndex
< maPageWindows
.size())
129 return maPageWindows
[nIndex
];
135 void SdrPageView::ClearPageWindows()
138 for(SdrPageWindowVector::const_iterator a
= maPageWindows
.begin(); a
!= maPageWindows
.end(); a
++)
143 maPageWindows
.clear();
146 void SdrPageView::AppendPageWindow(SdrPageWindow
& rNew
)
148 maPageWindows
.push_back(&rNew
);
151 SdrPageWindow
* SdrPageView::RemovePageWindow(sal_uInt32 nPos
)
153 if(nPos
< maPageWindows
.size())
155 SdrPageWindowVector::iterator aAccess
= maPageWindows
.begin() + nPos
;
156 // #114376# remember return value
157 SdrPageWindow
* pErasedSdrPageWindow
= *aAccess
;
158 maPageWindows
.erase(aAccess
);
159 return pErasedSdrPageWindow
;
165 SdrPageWindow
* SdrPageView::RemovePageWindow(SdrPageWindow
& rOld
)
167 const SdrPageWindowVector::iterator aFindResult
= ::std::find(maPageWindows
.begin(), maPageWindows
.end(), &rOld
);
169 if(aFindResult
!= maPageWindows
.end())
171 // #114376# remember return value
172 SdrPageWindow
* pSdrPageWindow
= *aFindResult
;
173 maPageWindows
.erase(aFindResult
);
174 return pSdrPageWindow
;
180 //////////////////////////////////////////////////////////////////////////////
182 SdrPageView::SdrPageView(SdrPage
* pPage1
, SdrView
& rNewView
)
184 // #103911# col_auto color lets the view takes the default SvxColorConfig entry
185 maDocumentColor( COL_AUTO
),
186 maBackgroundColor(COL_AUTO
), // #i48367# also react on autocolor
187 mpPreparedPageWindow(0) // #i72752#
189 DBG_CTOR(SdrPageView
,NULL
);
194 aPgOrg
.X()=mpPage
->GetLftBorder();
195 aPgOrg
.Y()=mpPage
->GetUppBorder();
197 mbHasMarked
= sal_False
;
201 mbVisible
= sal_False
;
204 SetAktGroupAndList(NULL
, mpPage
);
206 StartListening(*rNewView
.GetModel());
208 for(sal_uInt32
a(0L); a
< rNewView
.PaintWindowCount(); a
++)
210 AddPaintWindowToPageView(*rNewView
.GetPaintWindow(a
));
214 SdrPageView::~SdrPageView()
216 DBG_DTOR(SdrPageView
,NULL
);
218 // cleanup window vector
222 SdrPageWindow
& SdrPageView::CreateNewPageWindowEntry(SdrPaintWindow
& rPaintWindow
)
224 // MIB 3.7.08: Das WinRec muss sofort in die Liste eingetragen werden,
225 // weil sich das InsertControlContainer darauf verlaesst
226 //SdrPageViewWinRec* pRec = new SdrPageViewWinRec( *this, pOut );
227 //pWinList->Insert(pRec);
228 SdrPageWindow
& rWindow
= *(new SdrPageWindow(*this, rPaintWindow
));
229 AppendPageWindow(rWindow
);
234 void SdrPageView::AddPaintWindowToPageView(SdrPaintWindow
& rPaintWindow
)
236 if(!FindPageWindow(rPaintWindow
))
238 CreateNewPageWindowEntry(rPaintWindow
);
242 void SdrPageView::RemovePaintWindowFromPageView(SdrPaintWindow
& rPaintWindow
)
244 SdrPageWindow
* pCandidate
= FindPageWindow(rPaintWindow
);
248 pCandidate
= RemovePageWindow(*pCandidate
);
257 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
> SdrPageView::GetControlContainer( const OutputDevice
& _rDevice
) const
259 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlContainer
> xReturn
;
260 const SdrPageWindow
* pCandidate
= FindPatchedPageWindow( _rDevice
);
263 xReturn
= pCandidate
->GetControlContainer( true );
268 void __EXPORT
SdrPageView::Notify(SfxBroadcaster
& /*rBC*/, const SfxHint
& /*rHint*/)
270 // not really interested in
273 void SdrPageView::ModelHasChanged()
275 if (GetAktGroup()!=NULL
) CheckAktGroup();
278 sal_Bool
SdrPageView::IsReadOnly() const
280 return (0L == GetPage() || GetView().GetModel()->IsReadOnly() || GetPage()->IsReadOnly() || GetObjList()->IsReadOnly());
283 void SdrPageView::Show()
287 mbVisible
= sal_True
;
290 for(sal_uInt32
a(0L); a
< GetView().PaintWindowCount(); a
++)
292 AddPaintWindowToPageView(*GetView().GetPaintWindow(a
));
297 void SdrPageView::Hide()
302 mbVisible
= sal_False
;
307 Rectangle
SdrPageView::GetPageRect() const
309 if (GetPage()==NULL
) return Rectangle();
310 return Rectangle(Point(),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
313 void SdrPageView::InvalidateAllWin()
315 if(IsVisible() && GetPage())
317 Rectangle
aRect(Point(0,0),Size(GetPage()->GetWdt()+1,GetPage()->GetHgt()+1));
318 aRect
.Union(GetPage()->GetAllObjBoundRect());
319 GetView().InvalidateAllWin(aRect
);
323 void SdrPageView::InvalidateAllWin(const Rectangle
& rRect
, sal_Bool bPlus1Pix
)
327 GetView().InvalidateAllWin(rRect
, bPlus1Pix
);
331 void SdrPageView::PaintOutlinerView(OutputDevice
* pOut
, const Rectangle
& rRect
) const
333 if (GetView().pTextEditOutliner
==NULL
) return;
334 //const SdrObject* pTextObjTmp=GetView().GetTextEditObject();
335 //const SdrTextObj* pText=PTR_CAST(SdrTextObj,pTextObjTmp);
336 //FASTBOOL bTextFrame=pText!=NULL && pText->IsTextFrame();
337 ULONG nViewAnz
=GetView().pTextEditOutliner
->GetViewCount();
338 for (ULONG i
=0; i
<nViewAnz
; i
++) {
339 OutlinerView
* pOLV
=GetView().pTextEditOutliner
->GetView(i
);
340 if (pOLV
->GetWindow()==pOut
) {
341 GetView().ImpPaintOutlinerView(*pOLV
, rRect
);
347 ////////////////////////////////////////////////////////////////////////////////////////////////////
349 void SdrPageView::PrePaint()
351 const sal_uInt32
nCount(PageWindowCount());
353 for(sal_uInt32
a(0); a
< nCount
; a
++)
355 SdrPageWindow
* pCandidate
= GetPageWindow(a
);
359 pCandidate
->PrePaint();
364 void SdrPageView::CompleteRedraw(SdrPaintWindow
& rPaintWindow
, const Region
& rReg
, sdr::contact::ViewObjectContactRedirector
* pRedirector
) const
368 SdrPageWindow
* pPageWindow
= FindPageWindow(rPaintWindow
);
369 sal_Bool
bIsTempTarget(sal_False
);
373 // create temp PageWindow
374 pPageWindow
= new SdrPageWindow(*((SdrPageView
*)this), rPaintWindow
);
375 bIsTempTarget
= sal_True
;
379 pPageWindow
->PrepareRedraw(rReg
);
380 pPageWindow
->RedrawAll(pRedirector
);
382 // get rid of temp PageWindow
391 ////////////////////////////////////////////////////////////////////////////////////////////////////
392 // #i74769# use SdrPaintWindow directly
394 void SdrPageView::setPreparedPageWindow(SdrPageWindow
* pKnownTarget
)
396 // #i72752# remember prepared SdrPageWindow
397 mpPreparedPageWindow
= pKnownTarget
;
400 void SdrPageView::DrawLayer(SdrLayerID nID
, OutputDevice
* pGivenTarget
, sdr::contact::ViewObjectContactRedirector
* pRedirector
) const
406 const SdrPageWindow
* pKnownTarget
= FindPageWindow(*pGivenTarget
);
410 // paint known target
411 pKnownTarget
->RedrawLayer(&nID
, pRedirector
);
415 // #i72752# DrawLayer() uses a OutputDevice different from BeginDrawLayer. This happens
416 // e.g. when SW paints a single text line in text edit mode. Try to use it
417 SdrPageWindow
* pPreparedTarget
= mpPreparedPageWindow
;
421 // if we have a prepared target, do not use a new SdrPageWindow since this
422 // works but is expensive. Just use a temporary PaintWindow
423 SdrPaintWindow
aTemporaryPaintWindow(mrView
, *pGivenTarget
);
425 // Copy existing paint region to use the same as prepared in BeginDrawLayer
426 SdrPaintWindow
& rExistingPaintWindow
= pPreparedTarget
->GetPaintWindow();
427 const Region
& rExistingRegion
= rExistingPaintWindow
.GetRedrawRegion();
428 aTemporaryPaintWindow
.SetRedrawRegion(rExistingRegion
);
430 // patch the ExistingPageWindow
431 pPreparedTarget
->patchPaintWindow(aTemporaryPaintWindow
);
434 pPreparedTarget
->RedrawLayer(&nID
, pRedirector
);
436 // restore the ExistingPageWindow
437 pPreparedTarget
->unpatchPaintWindow();
441 OSL_ENSURE(false, "SdrPageView::DrawLayer: Creating temporary SdrPageWindow (ObjectContact), this should never be needed (!)");
443 // None of the known OutputDevices is the target of this paint, use
444 // a temporary SdrPageWindow for this Redraw.
445 SdrPaintWindow
aTemporaryPaintWindow(mrView
, *pGivenTarget
);
446 SdrPageWindow
aTemporaryPageWindow(*((SdrPageView
*)this), aTemporaryPaintWindow
);
449 // Copy existing paint region if other PageWindows exist, this was created by
450 // PrepareRedraw() from BeginDrawLayer(). Needs to be used e.g. when suddenly SW
451 // paints into an unknown device other than the view was created for (e.g. VirtualDevice)
452 if(PageWindowCount())
454 SdrPageWindow
* pExistingPageWindow
= GetPageWindow(0L);
455 SdrPaintWindow
& rExistingPaintWindow
= pExistingPageWindow
->GetPaintWindow();
456 const Region
& rExistingRegion
= rExistingPaintWindow
.GetRedrawRegion();
457 aTemporaryPaintWindow
.SetRedrawRegion(rExistingRegion
);
460 aTemporaryPageWindow
.RedrawLayer(&nID
, pRedirector
);
466 // paint in all known windows
467 for(sal_uInt32
a(0L); a
< PageWindowCount(); a
++)
469 SdrPageWindow
* pTarget
= GetPageWindow(a
);
470 pTarget
->RedrawLayer(&nID
, pRedirector
);
476 void SdrPageView::SetDesignMode( bool _bDesignMode
) const
478 for ( sal_uInt32 i
= 0L; i
< PageWindowCount(); ++i
)
480 const SdrPageWindow
& rPageViewWindow
= *GetPageWindow(i
);
481 rPageViewWindow
.SetDesignMode( _bDesignMode
);
485 ////////////////////////////////////////////////////////////////////////////////////////////////////
488 #define RGBCOLOR(r,g,b) ((ULONG)(((BYTE)(b) | ((USHORT)(g)<<8)) | (((ULONG)(BYTE)(r))<<16)))
491 void SdrPageView::DrawPageViewGrid(OutputDevice
& rOut
, const Rectangle
& rRect
, Color aColor
)
496 long nx1
=GetView().aGridBig
.Width();
497 long nx2
=GetView().aGridFin
.Width();
498 long ny1
=GetView().aGridBig
.Height();
499 long ny2
=GetView().aGridFin
.Height();
505 if (nx1
==0) { nx1
=ny1
; nx2
=ny2
; }
506 if (ny1
==0) { ny1
=nx1
; ny2
=nx2
; }
514 // no more global output size, use window size instead to decide grid sizes
515 long nScreenWdt
= rOut
.GetOutputSizePixel().Width();
516 // old: long nScreenWdt=System::GetDesktopRectPixel().GetWidth();
518 // Grid bei kleinen Zoomstufen etwas erweitern
519 //Size a1PixSiz(rOut.PixelToLogic(Size(1,1)));
523 if (nScreenWdt
>=1600)
528 else if (nScreenWdt
>=1024)
538 Size
aMinDotDist(rOut
.PixelToLogic(Size(nMinDotPix
,nMinDotPix
)));
539 //Size a3PixSiz(rOut.PixelToLogic(Size(2,2)));
540 Size
aMinLinDist(rOut
.PixelToLogic(Size(nMinLinPix
,nMinLinPix
)));
541 FASTBOOL bHoriSolid
=nx2
<aMinDotDist
.Width();
542 FASTBOOL bVertSolid
=ny2
<aMinDotDist
.Height();
543 // Linienabstand vergroessern (mind. 4 Pixel)
544 // Vergroesserung: *2 *5 *10 *20 *50 *100 ...
547 while (nx1
<aMinLinDist
.Width())
552 if (nTgl
==1) nx1
=nVal0
*5; // => nx1*=2.5
556 nTgl
++; if (nTgl
>=3) nTgl
=0;
560 while (ny1
<aMinLinDist
.Height())
565 if (nTgl
==1) ny1
=nVal0
*5; // => ny1*=2.5
573 // Keine Zwischenpunkte, wenn...
574 //if (nx2<a2PixSiz.Width()) nx2=nx1;
575 //if (ny2<a2PixSiz.Height()) ny2=ny1;
577 FASTBOOL bHoriFine
=nx2
<nx1
;
578 FASTBOOL bVertFine
=ny2
<ny1
;
579 FASTBOOL bHoriLines
=bHoriSolid
|| bHoriFine
|| !bVertFine
;
580 FASTBOOL bVertLines
=bVertSolid
|| bVertFine
;
582 Color
aColorMerk( rOut
.GetLineColor() );
583 rOut
.SetLineColor( aColor
);
585 bool bMap0
=rOut
.IsMapModeEnabled();
586 #ifdef WIN // SetPixel-Profiling fuer Windows
587 COLORREF aWinColRef
=PALETTERGB(aColor
.GetRed()>>8,aColor
.GetGreen()>>8,aColor
.GetBlue()>>8);
588 HDC aWinhDC
=Sysdepen::GethDC(rOut
);
591 long nWrX
=0;//aWriterPageOffset.X();
592 long nWrY
=0;//aWriterPageOffset.Y();
594 long x1
=GetPage()->GetLftBorder()+1+nWrX
;
595 long x2
=GetPage()->GetWdt()-GetPage()->GetRgtBorder()-1+nWrY
;
596 long y1
=GetPage()->GetUppBorder()+1+nWrX
;
597 long y2
=GetPage()->GetHgt()-GetPage()->GetLwrBorder()-1+nWrY
;
598 const SdrPageGridFrameList
* pFrames
=GetPage()->GetGridFrameList(this,NULL
);
599 //USHORT nBufSiz=1024; // 4k Buffer = max. 512 Punkte
600 // #90353# long* pBuf = NULL;
601 USHORT nGridPaintAnz
=1;
602 if (pFrames
!=NULL
) nGridPaintAnz
=pFrames
->GetCount();
603 for (USHORT nGridPaintNum
=0; nGridPaintNum
<nGridPaintAnz
; nGridPaintNum
++) {
605 const SdrPageGridFrame
& rGF
=(*pFrames
)[nGridPaintNum
];
606 nWrX
=rGF
.GetPaperRect().Left();
607 nWrY
=rGF
.GetPaperRect().Top();
608 x1
=rGF
.GetUserArea().Left();
609 x2
=rGF
.GetUserArea().Right();
610 y1
=rGF
.GetUserArea().Top();
611 y2
=rGF
.GetUserArea().Bottom();
612 aOrg
=rGF
.GetUserArea().TopLeft();
613 aOrg
-=rGF
.GetPaperRect().TopLeft();
615 if (!rRect
.IsEmpty()) {
616 Size
a1PixSiz(rOut
.PixelToLogic(Size(1,1)));
617 long nX1Pix
=a1PixSiz
.Width(); // 1 Pixel Toleranz drauf
618 long nY1Pix
=a1PixSiz
.Height();
619 if (x1
<rRect
.Left() -nX1Pix
) x1
=rRect
.Left() -nX1Pix
;
620 if (x2
>rRect
.Right() +nX1Pix
) x2
=rRect
.Right() +nX1Pix
;
621 if (y1
<rRect
.Top() -nY1Pix
) y1
=rRect
.Top() -nY1Pix
;
622 if (y2
>rRect
.Bottom()+nY1Pix
) y2
=rRect
.Bottom()+nY1Pix
;
626 long xBigOrg
=aOrg
.X()+nWrX
;
627 while (xBigOrg
>=x1
) xBigOrg
-=nx1
;
628 while (xBigOrg
<x1
) xBigOrg
+=nx1
;
629 long xFinOrg
=xBigOrg
;
630 while (xFinOrg
>=x1
) xFinOrg
-=nx2
;
631 while (xFinOrg
<x1
) xFinOrg
+=nx2
;
633 long yBigOrg
=aOrg
.Y()+nWrY
;
634 while (yBigOrg
>=y1
) yBigOrg
-=ny1
;
635 while (yBigOrg
<y1
) yBigOrg
+=ny1
;
636 long yFinOrg
=yBigOrg
;
637 while (yFinOrg
>=y1
) yFinOrg
-=ny2
;
638 while (yFinOrg
<y1
) yFinOrg
+=ny2
;
640 if( x1
<= x2
&& y1
<= y2
)
644 ULONG nGridFlags
= ( bHoriSolid
? GRID_HORZLINES
: GRID_DOTS
);
645 UINT16 nSteps
= sal_uInt16(nx1
/ nx2
);
646 UINT32 nRestPerStepMul1000
= nSteps
? ( ((nx1
* 1000L)/ nSteps
) - (nx2
* 1000L) ) : 0;
647 UINT32 nStepOffset
= 0;
648 UINT16 nPointOffset
= 0;
650 for(UINT16 a
=0;a
<nSteps
;a
++)
654 Rectangle( xFinOrg
+ (a
* nx2
) + nPointOffset
, yBigOrg
, x2
, y2
),
655 Size( nx1
, ny1
), nGridFlags
);
658 nStepOffset
+= nRestPerStepMul1000
;
659 while(nStepOffset
>= 1000)
669 ULONG nGridFlags
= ( bVertSolid
? GRID_VERTLINES
: GRID_DOTS
);
670 UINT16 nSteps
= sal_uInt16(ny1
/ ny2
);
671 UINT32 nRestPerStepMul1000
= nSteps
? ( ((ny1
* 1000L)/ nSteps
) - (ny2
* 1000L) ) : 0;
672 UINT32 nStepOffset
= 0;
673 UINT16 nPointOffset
= 0;
675 for(UINT16 a
=0;a
<nSteps
;a
++)
679 Rectangle( xBigOrg
, yFinOrg
+ (a
* ny2
) + nPointOffset
, x2
, y2
),
680 Size( nx1
, ny1
), nGridFlags
);
683 nStepOffset
+= nRestPerStepMul1000
;
684 while(nStepOffset
>= 1000)
691 // rOut.DrawGrid( Rectangle( xo + xBigOrg, yo + yFinOrg, x2, y2 ), Size( nx1, ny2 ), nGridFlags );
696 rOut
.EnableMapMode(bMap0
);
697 rOut
.SetLineColor(aColorMerk
);
701 void SdrPageView::AdjHdl()
703 GetView().AdjustMarkHdl();
706 void SdrPageView::SetLayer(const XubString
& rName
, SetOfByte
& rBS
, sal_Bool bJa
)
711 SdrLayerID nID
= GetPage()->GetLayerAdmin().GetLayerID(rName
, sal_True
);
713 if(SDRLAYER_NOTFOUND
!= nID
)
717 sal_Bool
SdrPageView::IsLayer(const XubString
& rName
, const SetOfByte
& rBS
) const
722 sal_Bool
bRet(sal_False
);
726 SdrLayerID nId
= GetPage()->GetLayerAdmin().GetLayerID(rName
, sal_True
);
728 if(SDRLAYER_NOTFOUND
!= nId
)
730 bRet
= rBS
.IsSet(nId
);
737 void SdrPageView::SetAllLayers(SetOfByte
& rB
, sal_Bool bJa
)
742 rB
.Clear(SDRLAYER_NOTFOUND
);
750 sal_Bool
SdrPageView::IsObjMarkable(SdrObject
* pObj
) const
754 // Vom Markieren ausgeschlossen?
755 if(pObj
->IsMarkProtect())
761 if(pObj
->ISA(SdrObjGroup
))
763 // If object is a Group object, visibility depends evtl. on
764 // multiple layers. If one object is markable, Group is markable.
765 SdrObjList
* pObjList
= ((SdrObjGroup
*)pObj
)->GetSubList();
767 if(pObjList
&& pObjList
->GetObjCount())
769 sal_Bool
bGroupIsMarkable(sal_False
);
771 for(sal_uInt32
a(0L); !bGroupIsMarkable
&& a
< pObjList
->GetObjCount(); a
++)
773 SdrObject
* pCandidate
= pObjList
->GetObj(a
);
776 if(IsObjMarkable(pCandidate
))
778 bGroupIsMarkable
= sal_True
;
782 return bGroupIsMarkable
;
787 // Allow empty groups to be selected to be able to delete them
793 // Der Layer muss sichtbar und darf nicht gesperrt sein
794 SdrLayerID nL
= pObj
->GetLayer();
795 return (aLayerVisi
.IsSet(BYTE(nL
)) && !aLayerLock
.IsSet(BYTE(nL
)));
802 void SdrPageView::SetPageOrigin(const Point
& rOrg
)
806 if (GetView().IsGridVisible()) {
812 void SdrPageView::ImpInvalidateHelpLineArea(USHORT nNum
) const
814 if (GetView().IsHlplVisible() && nNum
<aHelpLines
.GetCount()) {
815 const SdrHelpLine
& rHL
=aHelpLines
[nNum
];
817 for(sal_uInt32
a(0L); a
< GetView().PaintWindowCount(); a
++)
819 SdrPaintWindow
* pCandidate
= GetView().GetPaintWindow(a
);
821 if(pCandidate
->OutputToWindow())
823 OutputDevice
& rOutDev
= pCandidate
->GetOutputDevice();
824 Rectangle
aR(rHL
.GetBoundRect(rOutDev
));
825 Size
aSiz(rOutDev
.PixelToLogic(Size(1,1)));
826 aR
.Left() -= aSiz
.Width();
827 aR
.Right() += aSiz
.Width();
828 aR
.Top() -= aSiz
.Height();
829 aR
.Bottom() += aSiz
.Height();
830 ((SdrView
&)GetView()).InvalidateOneWin((Window
&)rOutDev
, aR
);
836 void SdrPageView::SetHelpLines(const SdrHelpLineList
& rHLL
)
842 void SdrPageView::SetHelpLine(USHORT nNum
, const SdrHelpLine
& rNewHelpLine
)
844 if (nNum
<aHelpLines
.GetCount() && aHelpLines
[nNum
]!=rNewHelpLine
) {
845 FASTBOOL bNeedRedraw
=TRUE
;
846 if (aHelpLines
[nNum
].GetKind()==rNewHelpLine
.GetKind()) {
847 switch (rNewHelpLine
.GetKind()) {
848 case SDRHELPLINE_VERTICAL
: if (aHelpLines
[nNum
].GetPos().X()==rNewHelpLine
.GetPos().X()) bNeedRedraw
=FALSE
; break;
849 case SDRHELPLINE_HORIZONTAL
: if (aHelpLines
[nNum
].GetPos().Y()==rNewHelpLine
.GetPos().Y()) bNeedRedraw
=FALSE
; break;
853 if (bNeedRedraw
) ImpInvalidateHelpLineArea(nNum
);
854 aHelpLines
[nNum
]=rNewHelpLine
;
855 if (bNeedRedraw
) ImpInvalidateHelpLineArea(nNum
);
859 void SdrPageView::DeleteHelpLine(USHORT nNum
)
861 if (nNum
<aHelpLines
.GetCount()) {
862 ImpInvalidateHelpLineArea(nNum
);
863 aHelpLines
.Delete(nNum
);
867 void SdrPageView::InsertHelpLine(const SdrHelpLine
& rHL
, USHORT nNum
)
869 if (nNum
>aHelpLines
.GetCount()) nNum
=aHelpLines
.GetCount();
870 aHelpLines
.Insert(rHL
,nNum
);
871 if (GetView().IsHlplVisible()) {
872 if (GetView().IsHlplFront()) {
873 // Hier optimieren ...
874 ImpInvalidateHelpLineArea(nNum
);
876 ImpInvalidateHelpLineArea(nNum
);
881 // Betretene Gruppe und Liste setzen
882 void SdrPageView::SetAktGroupAndList(SdrObject
* pNewGroup
, SdrObjList
* pNewList
)
884 if(pAktGroup
!= pNewGroup
)
886 pAktGroup
= pNewGroup
;
888 if(pAktList
!= pNewList
)
894 sal_Bool
SdrPageView::EnterGroup(SdrObject
* pObj
)
896 sal_Bool
bRet(sal_False
);
898 if(pObj
&& pObj
->IsGroupObject())
900 sal_Bool
bGlueInvalidate(GetView().ImpIsGlueVisible());
904 GetView().GlueInvalidate();
908 GetView().UnmarkAll();
910 // set current group and list
911 SdrObjList
* pNewObjList
= pObj
->GetSubList();
912 SetAktGroupAndList(pObj
, pNewObjList
);
914 // select contained object if only one object is contained,
915 // else select nothing and let the user decide what to do next
916 if(pNewObjList
&& pNewObjList
->GetObjCount() == 1)
918 SdrObject
* pFirstObject
= pNewObjList
->GetObj(0L);
920 if(GetView().GetSdrPageView())
922 GetView().MarkObj(pFirstObject
, GetView().GetSdrPageView());
927 GetView().AdjustMarkHdl();
929 // invalidate only when view wants to visualize group entering
930 if(GetView().DoVisualizeEnteredGroup())
937 GetView().GlueInvalidate();
946 void SdrPageView::LeaveOneGroup()
950 BOOL bGlueInvalidate
= (GetView().ImpIsGlueVisible());
953 GetView().GlueInvalidate();
955 SdrObject
* pLastGroup
= GetAktGroup();
956 SdrObject
* pParentGroup
= GetAktGroup()->GetUpGroup();
957 SdrObjList
* pParentList
= GetPage();
960 pParentList
= pParentGroup
->GetSubList();
962 // Alles deselektieren
963 GetView().UnmarkAll();
965 // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
966 SetAktGroupAndList(pParentGroup
, pParentList
);
968 // gerade verlassene Gruppe selektieren
970 if(GetView().GetSdrPageView())
971 GetView().MarkObj(pLastGroup
, GetView().GetSdrPageView());
973 GetView().AdjustMarkHdl();
975 // invalidate only when view wants to visualize group entering
976 if(GetView().DoVisualizeEnteredGroup())
980 GetView().GlueInvalidate();
984 void SdrPageView::LeaveAllGroup()
988 BOOL bGlueInvalidate
= (GetView().ImpIsGlueVisible());
991 GetView().GlueInvalidate();
993 SdrObject
* pLastGroup
= GetAktGroup();
995 // Alles deselektieren
996 GetView().UnmarkAll();
998 // Zuweisungen, pAktGroup und pAktList muessen gesetzt sein
999 SetAktGroupAndList(NULL
, GetPage());
1001 // Oberste letzte Gruppe finden und selektieren
1004 while(pLastGroup
->GetUpGroup())
1005 pLastGroup
= pLastGroup
->GetUpGroup();
1007 if(GetView().GetSdrPageView())
1008 GetView().MarkObj(pLastGroup
, GetView().GetSdrPageView());
1011 GetView().AdjustMarkHdl();
1013 // invalidate only when view wants to visualize group entering
1014 if(GetView().DoVisualizeEnteredGroup())
1018 GetView().GlueInvalidate();
1022 USHORT
SdrPageView::GetEnteredLevel() const
1025 SdrObject
* pGrp
=GetAktGroup();
1026 while (pGrp
!=NULL
) {
1028 pGrp
=pGrp
->GetUpGroup();
1033 XubString
SdrPageView::GetActualGroupName() const
1037 XubString
aStr(GetAktGroup()->GetName());
1040 aStr
+= sal_Unicode('?');
1048 XubString
SdrPageView::GetActualPathName(sal_Unicode cSep
) const
1051 BOOL
bNamFnd(FALSE
);
1052 SdrObject
* pGrp
= GetAktGroup();
1056 XubString
aStr1(pGrp
->GetName());
1059 aStr1
+= sal_Unicode('?');
1064 pGrp
= pGrp
->GetUpGroup();
1070 if(!bNamFnd
&& GetAktGroup())
1073 aStr
+= sal_Unicode('(');
1074 aStr
+= String::CreateFromInt32( GetEnteredLevel() );
1075 aStr
+= sal_Unicode(')');
1081 void SdrPageView::CheckAktGroup()
1083 SdrObject
* pGrp
=GetAktGroup();
1084 while (pGrp
!=NULL
&&
1085 (!pGrp
->IsInserted() || pGrp
->GetObjList()==NULL
||
1086 pGrp
->GetPage()==NULL
|| pGrp
->GetModel()==NULL
)) { // irgendwas daneben?
1087 pGrp
=pGrp
->GetUpGroup();
1089 if (pGrp
!=GetAktGroup()) {
1090 if (pGrp
!=NULL
) EnterGroup(pGrp
);
1091 else LeaveAllGroup();
1095 // #103834# Set background color for svx at SdrPageViews
1096 void SdrPageView::SetApplicationBackgroundColor(Color aBackgroundColor
)
1098 maBackgroundColor
= aBackgroundColor
;
1102 Color
SdrPageView::GetApplicationBackgroundColor() const
1104 return maBackgroundColor
;
1107 // #103911# Set document color for svx at SdrPageViews
1108 void SdrPageView::SetApplicationDocumentColor(Color aDocumentColor
)
1110 maDocumentColor
= aDocumentColor
;
1113 Color
SdrPageView::GetApplicationDocumentColor() const
1115 return maDocumentColor
;
1118 ////////////////////////////////////////////////////////////////////////////////////////////////////