1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <svx/sdr/contact/viewobjectcontactofsdrpage.hxx>
22 #include <svx/sdr/contact/displayinfo.hxx>
23 #include <svx/sdr/contact/viewcontactofsdrpage.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/sdr/contact/objectcontact.hxx>
27 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
28 #include <basegfx/polygon/b2dpolygontools.hxx>
29 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 #include <drawinglayer/primitive2d/gridprimitive2d.hxx>
31 #include <drawinglayer/primitive2d/helplineprimitive2d.hxx>
32 #include <basegfx/polygon/b2dpolygon.hxx>
33 #include <svx/sdr/primitive2d/sdrprimitivetools.hxx>
35 //////////////////////////////////////////////////////////////////////////////
37 using namespace com::sun::star
;
39 //////////////////////////////////////////////////////////////////////////////
45 const SdrPage
& ViewObjectContactOfPageSubObject::getPage() const
47 return static_cast< ViewContactOfPageSubObject
& >(GetViewContact()).getPage();
50 ViewObjectContactOfPageSubObject::ViewObjectContactOfPageSubObject(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
51 : ViewObjectContact(rObjectContact
, rViewContact
)
55 ViewObjectContactOfPageSubObject::~ViewObjectContactOfPageSubObject()
59 bool ViewObjectContactOfPageSubObject::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
61 if(rDisplayInfo
.GetSubContentActive())
66 if(rDisplayInfo
.GetControlLayerProcessingActive())
71 if(!rDisplayInfo
.GetPageProcessingActive())
76 if(GetObjectContact().isOutputToPrinter())
81 if(!GetObjectContact().TryToGetSdrPageView())
89 bool ViewObjectContactOfPageSubObject::isPrimitiveGhosted(const DisplayInfo
& /*rDisplayInfo*/) const
91 // suppress ghosted for page parts
94 } // end of namespace contact
95 } // end of namespace sdr
97 //////////////////////////////////////////////////////////////////////////////
103 ViewObjectContactOfPageBackground::ViewObjectContactOfPageBackground(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
104 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
108 ViewObjectContactOfPageBackground::~ViewObjectContactOfPageBackground()
112 bool ViewObjectContactOfPageBackground::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
114 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
119 // no page background for preview renderers
120 if(GetObjectContact().IsPreviewRenderer())
128 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageBackground::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
130 // Initialize background. Dependent of IsPageVisible, use ApplicationBackgroundColor or ApplicationDocumentColor. Most
131 // old renderers for export (html, pdf, gallery, ...) set the page to not visible (SetPageVisible(false)). They expect the
132 // given OutputDevice to be initialized with the ApplicationDocumentColor then.
133 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
134 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
138 const SdrView
& rView
= pPageView
->GetView();
141 if(rView
.IsPageVisible())
143 aInitColor
= pPageView
->GetApplicationBackgroundColor();
147 aInitColor
= pPageView
->GetApplicationDocumentColor();
149 if(Color(COL_AUTO
) == aInitColor
)
151 const svtools::ColorConfig aColorConfig
;
152 aInitColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
156 // init background with InitColor
158 const basegfx::BColor
aRGBColor(aInitColor
.getBColor());
159 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor
));
164 } // end of namespace contact
165 } // end of namespace sdr
167 //////////////////////////////////////////////////////////////////////////////
173 ViewObjectContactOfMasterPage::ViewObjectContactOfMasterPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
174 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
178 ViewObjectContactOfMasterPage::~ViewObjectContactOfMasterPage()
182 bool ViewObjectContactOfMasterPage::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
184 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
189 // this object is only used for MasterPages. When not the MasterPage is
190 // displayed as a page, but another page is using it as sub-object, the
191 // geometry needs to be hidden
192 if(rDisplayInfo
.GetSubContentActive())
199 } // end of namespace contact
200 } // end of namespace sdr
202 //////////////////////////////////////////////////////////////////////////////
208 ViewObjectContactOfPageFill::ViewObjectContactOfPageFill(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
209 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
213 ViewObjectContactOfPageFill::~ViewObjectContactOfPageFill()
217 bool ViewObjectContactOfPageFill::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
219 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
224 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
231 if(!pSdrPageView
->GetView().IsPageVisible())
239 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageFill::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
241 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
242 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
246 const SdrPage
& rPage
= getPage();
248 const basegfx::B2DRange
aPageFillRange(0.0, 0.0, (double)rPage
.GetWdt(), (double)rPage
.GetHgt());
249 const basegfx::B2DPolygon
aPageFillPolygon(basegfx::tools::createPolygonFromRect(aPageFillRange
));
250 Color aPageFillColor
;
252 if(pPageView
->GetApplicationDocumentColor() != COL_AUTO
)
254 aPageFillColor
= pPageView
->GetApplicationDocumentColor();
258 const svtools::ColorConfig aColorConfig
;
259 aPageFillColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
262 // create and add primitive
264 const basegfx::BColor
aRGBColor(aPageFillColor
.getBColor());
265 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon
), aRGBColor
));
270 } // end of namespace contact
271 } // end of namespace sdr
273 //////////////////////////////////////////////////////////////////////////////
279 ViewObjectContactOfPageShadow::ViewObjectContactOfPageShadow(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
280 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
284 ViewObjectContactOfPageShadow::~ViewObjectContactOfPageShadow()
288 bool ViewObjectContactOfPageShadow::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
290 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
295 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
302 if(!pSdrPageView
->GetView().IsPageVisible())
307 // no page shadow for preview renderers
308 if(GetObjectContact().IsPreviewRenderer())
313 // no page shadow for high contrast mode
314 if(GetObjectContact().isDrawModeHighContrast())
321 } // end of namespace contact
322 } // end of namespace sdr
324 //////////////////////////////////////////////////////////////////////////////
330 ViewObjectContactOfOuterPageBorder::ViewObjectContactOfOuterPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
331 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
335 ViewObjectContactOfOuterPageBorder::~ViewObjectContactOfOuterPageBorder()
339 bool ViewObjectContactOfOuterPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
341 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
346 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
353 const SdrView
& rView
= pSdrPageView
->GetView();
355 if(!rView
.IsPageVisible() && rView
.IsPageBorderVisible())
362 } // end of namespace contact
363 } // end of namespace sdr
365 //////////////////////////////////////////////////////////////////////////////
371 ViewObjectContactOfInnerPageBorder::ViewObjectContactOfInnerPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
372 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
376 ViewObjectContactOfInnerPageBorder::~ViewObjectContactOfInnerPageBorder()
380 bool ViewObjectContactOfInnerPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
382 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
387 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
394 if(!pSdrPageView
->GetView().IsBordVisible())
399 const SdrPage
& rPage
= getPage();
401 if(!rPage
.GetLftBorder() && !rPage
.GetUppBorder() && !rPage
.GetRgtBorder() && !rPage
.GetLwrBorder())
406 // no inner page border for preview renderers
407 if(GetObjectContact().IsPreviewRenderer())
414 } // end of namespace contact
415 } // end of namespace sdr
417 //////////////////////////////////////////////////////////////////////////////
423 ViewObjectContactOfPageHierarchy::ViewObjectContactOfPageHierarchy(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
424 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
428 ViewObjectContactOfPageHierarchy::~ViewObjectContactOfPageHierarchy()
432 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageHierarchy::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
434 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
436 // process local sub-hierarchy
437 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
439 if(nSubHierarchyCount
)
441 xRetval
= getPrimitive2DSequenceSubHierarchy(rDisplayInfo
);
443 if(xRetval
.hasElements())
446 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
447 const basegfx::B2DRange
aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval
, rViewInformation2D
));
448 const basegfx::B2DRange
aViewRange(rViewInformation2D
.getViewport());
450 // check geometrical visibility
451 if(!aViewRange
.isEmpty() && !aViewRange
.overlaps(aObjectRange
))
453 // not visible, release
461 } // end of namespace contact
462 } // end of namespace sdr
464 //////////////////////////////////////////////////////////////////////////////
470 ViewObjectContactOfPageGrid::ViewObjectContactOfPageGrid(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
471 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
475 ViewObjectContactOfPageGrid::~ViewObjectContactOfPageGrid()
479 bool ViewObjectContactOfPageGrid::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
481 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
486 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
493 const SdrView
& rView
= pSdrPageView
->GetView();
495 if(!rView
.IsGridVisible())
500 // no page grid for preview renderers
501 if(GetObjectContact().IsPreviewRenderer())
506 if(static_cast< ViewContactOfGrid
& >(GetViewContact()).getFront() != (bool)rView
.IsGridFront())
514 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
516 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
517 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
521 const SdrView
& rView
= pPageView
->GetView();
522 const SdrPage
& rPage
= getPage();
523 const Color
aGridColor(rView
.GetGridColor());
524 const basegfx::BColor
aRGBGridColor(aGridColor
.getBColor());
526 basegfx::B2DHomMatrix aGridMatrix
;
527 aGridMatrix
.set(0, 0, (double)(rPage
.GetWdt() - (rPage
.GetRgtBorder() + rPage
.GetLftBorder())));
528 aGridMatrix
.set(1, 1, (double)(rPage
.GetHgt() - (rPage
.GetLwrBorder() + rPage
.GetUppBorder())));
529 aGridMatrix
.set(0, 2, (double)rPage
.GetLftBorder());
530 aGridMatrix
.set(1, 2, (double)rPage
.GetUppBorder());
532 const Size
aRaw(rView
.GetGridCoarse());
533 const Size
aFine(rView
.GetGridFine());
534 const double fWidthX(aRaw
.getWidth());
535 const double fWidthY(aRaw
.getHeight());
536 const sal_uInt32
nSubdivisionsX(aFine
.getWidth() ? aRaw
.getWidth() / aFine
.getWidth() : 0L);
537 const sal_uInt32
nSubdivisionsY(aFine
.getHeight() ? aRaw
.getHeight() / aFine
.getHeight() : 0L);
540 xRetval
[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::GridPrimitive2D(
541 aGridMatrix
, fWidthX
, fWidthY
, 10.0, 3.0, nSubdivisionsX
, nSubdivisionsY
, aRGBGridColor
,
542 drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor
)));
547 } // end of namespace contact
548 } // end of namespace sdr
550 //////////////////////////////////////////////////////////////////////////////
556 ViewObjectContactOfPageHelplines::ViewObjectContactOfPageHelplines(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
557 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
561 ViewObjectContactOfPageHelplines::~ViewObjectContactOfPageHelplines()
565 bool ViewObjectContactOfPageHelplines::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
567 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
572 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
579 const SdrView
& rView
= pSdrPageView
->GetView();
581 if(!rView
.IsHlplVisible())
586 // no helplines for preview renderers
587 if(GetObjectContact().IsPreviewRenderer())
592 if(static_cast< ViewContactOfHelplines
& >(GetViewContact()).getFront() != (bool)rView
.IsHlplFront())
600 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfPageHelplines::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/) const
602 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
603 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
607 const SdrHelpLineList
& rHelpLineList
= pPageView
->GetHelpLines();
608 const sal_uInt32
nCount(rHelpLineList
.GetCount());
612 const basegfx::BColor
aRGBColorA(1.0, 1.0, 1.0);
613 const basegfx::BColor
aRGBColorB(0.0, 0.0, 0.0);
614 xRetval
.realloc(nCount
);
616 for(sal_uInt32
a(0L); a
< nCount
; a
++)
618 const SdrHelpLine
& rHelpLine
= rHelpLineList
[(sal_uInt16
)a
];
619 const basegfx::B2DPoint
aPosition((double)rHelpLine
.GetPos().X(), (double)rHelpLine
.GetPos().Y());
620 const double fDiscreteDashLength(4.0);
622 switch(rHelpLine
.GetKind())
624 default : // SDRHELPLINE_POINT
626 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
627 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_POINT
,
628 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
631 case SDRHELPLINE_VERTICAL
:
633 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
634 aPosition
, basegfx::B2DVector(0.0, 1.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE
,
635 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
638 case SDRHELPLINE_HORIZONTAL
:
640 xRetval
[a
] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::HelplinePrimitive2D(
641 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HELPLINESTYLE2D_LINE
,
642 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
652 } // end of namespace contact
653 } // end of namespace sdr
655 //////////////////////////////////////////////////////////////////////////////
661 ViewObjectContactOfSdrPage::ViewObjectContactOfSdrPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
662 : ViewObjectContact(rObjectContact
, rViewContact
)
666 ViewObjectContactOfSdrPage::~ViewObjectContactOfSdrPage()
670 drawinglayer::primitive2d::Primitive2DSequence
ViewObjectContactOfSdrPage::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
) const
672 drawinglayer::primitive2d::Primitive2DSequence xRetval
;
674 // process local sub-hierarchy
675 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
677 if(nSubHierarchyCount
)
679 const sal_Bool
bDoGhostedDisplaying(
680 GetObjectContact().DoVisualizeEnteredGroup()
681 && !GetObjectContact().isOutputToPrinter()
682 && GetObjectContact().getActiveViewContact() == &GetViewContact());
684 if(bDoGhostedDisplaying
)
686 rDisplayInfo
.ClearGhostedDrawMode();
689 // create object hierarchy
690 xRetval
= getPrimitive2DSequenceSubHierarchy(rDisplayInfo
);
692 if(xRetval
.hasElements())
695 const drawinglayer::geometry::ViewInformation2D
& rViewInformation2D(GetObjectContact().getViewInformation2D());
696 const basegfx::B2DRange
aObjectRange(drawinglayer::primitive2d::getB2DRangeFromPrimitive2DSequence(xRetval
, rViewInformation2D
));
697 const basegfx::B2DRange
aViewRange(rViewInformation2D
.getViewport());
699 // check geometrical visibility
700 if(!aViewRange
.isEmpty() && !aViewRange
.overlaps(aObjectRange
))
702 // not visible, release
707 if(bDoGhostedDisplaying
)
709 rDisplayInfo
.SetGhostedDrawMode();
715 } // end of namespace contact
716 } // end of namespace sdr
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */