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: viewobjectcontactofsdrpage.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svx.hxx"
35 #include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx>
36 #include <svx/sdr/contact/displayinfo.hxx>
37 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
38 #include <svx/svdview.hxx>
39 #include <svx/svdpage.hxx>
40 #include <svx/sdr/contact/objectcontact.hxx>
41 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
42 #include <basegfx/polygon/b2dpolygontools.hxx>
43 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
44 #include <drawinglayer/primitive2d/gridprimitive2d.hxx>
45 #include <drawinglayer/primitive2d/helplineprimitive2d.hxx>
46 #include <basegfx/polygon/b2dpolygon.hxx>
47 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
49 //////////////////////////////////////////////////////////////////////////////
51 using namespace com::sun::star
;
53 //////////////////////////////////////////////////////////////////////////////
59 const SdrPage
& ViewObjectContactOfPageSubObject::getPage() const
61 return static_cast< ViewContactOfPageSubObject
& >(GetViewContact()).getPage();
64 ViewObjectContactOfPageSubObject::ViewObjectContactOfPageSubObject(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
65 : ViewObjectContact(rObjectContact
, rViewContact
)
69 ViewObjectContactOfPageSubObject::~ViewObjectContactOfPageSubObject()
73 bool ViewObjectContactOfPageSubObject::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
75 if(rDisplayInfo
.GetSubContentActive())
80 if(rDisplayInfo
.GetControlLayerProcessingActive())
85 if(!rDisplayInfo
.GetPageProcessingActive())
90 if(GetObjectContact().isOutputToPrinter())
95 if(!GetObjectContact().TryToGetSdrPageView())
103 bool ViewObjectContactOfPageSubObject::isPrimitiveGhosted(const DisplayInfo
& /*rDisplayInfo*/) const
105 // suppress ghosted for page parts
108 } // end of namespace contact
109 } // end of namespace sdr
111 //////////////////////////////////////////////////////////////////////////////
117 ViewObjectContactOfPageBackground::ViewObjectContactOfPageBackground(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
118 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
122 ViewObjectContactOfPageBackground::~ViewObjectContactOfPageBackground()
126 bool ViewObjectContactOfPageBackground::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
128 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
133 // no page background for preview renderers
134 if(GetObjectContact().IsPreviewRenderer())
142 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageBackground::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
144 // Initialize background. Dependent of IsPageVisible, use ApplicationBackgroundColor or ApplicationDocumentColor. Most
145 // old renderers for export (html, pdf, gallery, ...) set the page to not visible (SetPageVisible(false)). They expect the
146 // given OutputDevice to be initialized with the ApplicationDocumentColor then.
147 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
148 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
152 const SdrView
& rView
= pPageView
->GetView();
155 if(rView
.IsPageVisible())
157 aInitColor
= pPageView
->GetApplicationBackgroundColor();
161 aInitColor
= pPageView
->GetApplicationDocumentColor();
163 if(Color(COL_AUTO
) == aInitColor
)
165 const svtools::ColorConfig aColorConfig
;
166 aInitColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
170 // init background with InitColor
172 const basegfx::BColor
aRGBColor(aInitColor
.getBColor());
173 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor
));
178 } // end of namespace contact
179 } // end of namespace sdr
181 //////////////////////////////////////////////////////////////////////////////
187 ViewObjectContactOfMasterPage::ViewObjectContactOfMasterPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
188 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
192 ViewObjectContactOfMasterPage::~ViewObjectContactOfMasterPage()
196 bool ViewObjectContactOfMasterPage::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
198 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
203 // this object is only used for MasterPages. When not the MasterPage is
204 // displayed as a page, but another page is using it as sub-object, the
205 // geometry needs to be hidden
206 if(rDisplayInfo
.GetSubContentActive())
213 } // end of namespace contact
214 } // end of namespace sdr
216 //////////////////////////////////////////////////////////////////////////////
222 ViewObjectContactOfPageFill::ViewObjectContactOfPageFill(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
223 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
227 ViewObjectContactOfPageFill::~ViewObjectContactOfPageFill()
231 bool ViewObjectContactOfPageFill::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
233 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
238 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
245 if(!pSdrPageView
->GetView().IsPageVisible())
253 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageFill::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
255 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
256 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
260 const SdrPage
& rPage
= getPage();
262 const basegfx::B2DRange
aPageFillRange(0.0, 0.0, (double)rPage
.GetWdt(), (double)rPage
.GetHgt());
263 const basegfx::B2DPolygon
aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange
));
264 Color aPageFillColor
;
266 if(pPageView
->GetApplicationDocumentColor() != COL_AUTO
)
268 aPageFillColor
= pPageView
->GetApplicationDocumentColor();
272 const svtools::ColorConfig aColorConfig
;
273 aPageFillColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
276 // create and add primitive
278 const basegfx::BColor
aRGBColor(aPageFillColor
.getBColor());
279 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon
), aRGBColor
));
284 } // end of namespace contact
285 } // end of namespace sdr
287 //////////////////////////////////////////////////////////////////////////////
293 ViewObjectContactOfPageShadow::ViewObjectContactOfPageShadow(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
294 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
298 ViewObjectContactOfPageShadow::~ViewObjectContactOfPageShadow()
302 bool ViewObjectContactOfPageShadow::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
304 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
309 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
316 if(!pSdrPageView
->GetView().IsPageVisible())
321 // no page shadow for preview renderers
322 if(GetObjectContact().IsPreviewRenderer())
329 } // end of namespace contact
330 } // end of namespace sdr
332 //////////////////////////////////////////////////////////////////////////////
338 ViewObjectContactOfOuterPageBorder::ViewObjectContactOfOuterPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
339 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
343 ViewObjectContactOfOuterPageBorder::~ViewObjectContactOfOuterPageBorder()
347 bool ViewObjectContactOfOuterPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
349 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
354 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
361 const SdrView
& rView
= pSdrPageView
->GetView();
363 if(!rView
.IsPageVisible() && rView
.IsPageBorderVisible())
370 } // end of namespace contact
371 } // end of namespace sdr
373 //////////////////////////////////////////////////////////////////////////////
379 ViewObjectContactOfInnerPageBorder::ViewObjectContactOfInnerPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
380 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
384 ViewObjectContactOfInnerPageBorder::~ViewObjectContactOfInnerPageBorder()
388 bool ViewObjectContactOfInnerPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
390 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
395 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
402 if(!pSdrPageView
->GetView().IsBordVisible())
407 const SdrPage
& rPage
= getPage();
409 if(!rPage
.GetLftBorder() && !rPage
.GetUppBorder() && !rPage
.GetRgtBorder() && !rPage
.GetLwrBorder())
414 // no inner page border for preview renderers
415 if(GetObjectContact().IsPreviewRenderer())
422 } // end of namespace contact
423 } // end of namespace sdr
425 //////////////////////////////////////////////////////////////////////////////
431 ViewObjectContactOfPageHierarchy::ViewObjectContactOfPageHierarchy(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
432 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
436 ViewObjectContactOfPageHierarchy::~ViewObjectContactOfPageHierarchy()
440 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageHierarchy::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
442 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
444 // process local sub-hierarchy
445 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
447 if(nSubHierarchyCount
)
449 xRetval
= getPrimitive2DSequenceSubHierarchy(rDisplayInfo
);
451 if(xRetval
.hasElements())
454 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
455 const basegfx::B2DRange
aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval
, rViewInformation2D
));
456 const basegfx::B2DRange
aViewRange(rViewInformation2D
.getViewport());
458 // check geometrical visibility
459 if(!aViewRange
.isEmpty() && !aViewRange
.overlaps(aObjectRange
))
461 // not visible, release
469 } // end of namespace contact
470 } // end of namespace sdr
472 //////////////////////////////////////////////////////////////////////////////
478 ViewObjectContactOfPageGrid::ViewObjectContactOfPageGrid(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
479 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
483 ViewObjectContactOfPageGrid::~ViewObjectContactOfPageGrid()
487 bool ViewObjectContactOfPageGrid::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
489 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
494 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
501 const SdrView
& rView
= pSdrPageView
->GetView();
503 if(!rView
.IsGridVisible())
508 // no page grid for preview renderers
509 if(GetObjectContact().IsPreviewRenderer())
514 if(static_cast< ViewContactOfGrid
& >(GetViewContact()).getFront() != (bool)rView
.IsGridFront())
522 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
524 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
525 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
529 const SdrView
& rView
= pPageView
->GetView();
530 const SdrPage
& rPage
= getPage();
531 const Color
aGridColor(rView
.GetGridColor());
532 const basegfx::BColor
aRGBGridColor(aGridColor
.getBColor());
534 basegfx::B2DHomMatrix aGridMatrix
;
535 aGridMatrix
.set(0, 0, (double)(rPage
.GetWdt() - (rPage
.GetRgtBorder() + rPage
.GetLftBorder())));
536 aGridMatrix
.set(1, 1, (double)(rPage
.GetHgt() - (rPage
.GetLwrBorder() + rPage
.GetUppBorder())));
537 aGridMatrix
.set(0, 2, (double)rPage
.GetLftBorder());
538 aGridMatrix
.set(1, 2, (double)rPage
.GetUppBorder());
540 const Size
aRaw(rView
.GetGridCoarse());
541 const Size
aFine(rView
.GetGridFine());
542 const double fWidthX(aRaw
.getWidth());
543 const double fWidthY(aRaw
.getHeight());
544 const sal_uInt32
nSubdivisionsX(aFine
.getWidth() ? aRaw
.getWidth() / aFine
.getWidth() : 0L);
545 const sal_uInt32
nSubdivisionsY(aFine
.getHeight() ? aRaw
.getHeight() / aFine
.getHeight() : 0L);
548 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::GridPrimitive2D(
549 aGridMatrix
, fWidthX
, fWidthY
, 10.0, 3.0, nSubdivisionsX
, nSubdivisionsY
, aRGBGridColor
,
550 drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor
)));
555 } // end of namespace contact
556 } // end of namespace sdr
558 //////////////////////////////////////////////////////////////////////////////
564 ViewObjectContactOfPageHelplines::ViewObjectContactOfPageHelplines(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
565 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
569 ViewObjectContactOfPageHelplines::~ViewObjectContactOfPageHelplines()
573 bool ViewObjectContactOfPageHelplines::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
575 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
580 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
587 const SdrView
& rView
= pSdrPageView
->GetView();
589 if(!rView
.IsHlplVisible())
594 // no helplines for preview renderers
595 if(GetObjectContact().IsPreviewRenderer())
600 if(static_cast< ViewContactOfHelplines
& >(GetViewContact()).getFront() != (bool)rView
.IsHlplFront())
608 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageHelplines::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
610 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
611 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
615 const SdrHelpLineList
& rHelpLineList
= pPageView
->GetHelpLines();
616 const sal_uInt32
nCount(rHelpLineList
.GetCount());
620 const basegfx::BColor
aRGBColorA(1.0, 1.0, 1.0);
621 const basegfx::BColor
aRGBColorB(0.0, 0.0, 0.0);
622 xRetval
.realloc(nCount
);
624 for(sal_uInt32
a(0L); a
< nCount
; a
++)
626 const SdrHelpLine
& rHelpLine
= rHelpLineList
[(sal_uInt16
)a
];
627 const basegfx::B2DPoint
aPosition((double)rHelpLine
.GetPos().X(), (double)rHelpLine
.GetPos().Y());
628 const double fDiscreteDashLength(4.0);
630 switch(rHelpLine
.GetKind())
632 default : // SDRHELPLINE_POINT
634 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
635 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_POINT
,
636 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
639 case SDRHELPLINE_VERTICAL
:
641 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
642 aPosition
, basegfx::B2DVector(0.0, 1.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE
,
643 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
646 case SDRHELPLINE_HORIZONTAL
:
648 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
649 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE
,
650 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
660 } // end of namespace contact
661 } // end of namespace sdr
663 //////////////////////////////////////////////////////////////////////////////
669 ViewObjectContactOfSdrPage::ViewObjectContactOfSdrPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
670 : ViewObjectContact(rObjectContact
, rViewContact
)
674 ViewObjectContactOfSdrPage::~ViewObjectContactOfSdrPage()
678 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfSdrPage::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
680 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
682 // process local sub-hierarchy
683 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
685 if(nSubHierarchyCount
)
687 const sal_Bool
bDoGhostedDisplaying(
688 GetObjectContact().DoVisualizeEnteredGroup()
689 && !GetObjectContact().isOutputToPrinter()
690 && GetObjectContact().getActiveViewContact() == &GetViewContact());
692 if(bDoGhostedDisplaying
)
694 rDisplayInfo
.ClearGhostedDrawMode();
697 // create object hierarchy
698 xRetval
= getPrimitive2DSequenceSubHierarchy(rDisplayInfo
);
700 if(xRetval
.hasElements())
703 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
704 const basegfx::B2DRange
aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval
, rViewInformation2D
));
705 const basegfx::B2DRange
aViewRange(rViewInformation2D
.getViewport());
707 // check geometrical visibility
708 if(!aViewRange
.isEmpty() && !aViewRange
.overlaps(aObjectRange
))
710 // not visible, release
715 if(bDoGhostedDisplaying
)
717 rDisplayInfo
.SetGhostedDrawMode();
723 } // end of namespace contact
724 } // end of namespace sdr
726 //////////////////////////////////////////////////////////////////////////////