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 <sdr/contact/viewobjectcontactofsdrpage.hxx>
22 #include <svx/sdr/contact/displayinfo.hxx>
23 #include <sdr/contact/viewcontactofsdrpage.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/svdpagv.hxx>
27 #include <svx/sdr/contact/objectcontact.hxx>
28 #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
29 #include <basegfx/polygon/b2dpolygontools.hxx>
30 #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx>
31 #include <drawinglayer/primitive2d/gridprimitive2d.hxx>
32 #include <drawinglayer/primitive2d/helplineprimitive2d.hxx>
33 #include <basegfx/polygon/b2dpolygon.hxx>
34 #include <sdr/primitive2d/sdrprimitivetools.hxx>
36 using namespace com::sun::star
;
38 namespace sdr::contact
{
40 const SdrPage
& ViewObjectContactOfPageSubObject::getPage() const
42 return static_cast< ViewContactOfPageSubObject
& >(GetViewContact()).getPage();
45 ViewObjectContactOfPageSubObject::ViewObjectContactOfPageSubObject(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
46 : ViewObjectContact(rObjectContact
, rViewContact
)
50 ViewObjectContactOfPageSubObject::~ViewObjectContactOfPageSubObject()
54 bool ViewObjectContactOfPageSubObject::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
56 if(rDisplayInfo
.GetSubContentActive())
61 if(rDisplayInfo
.GetControlLayerProcessingActive())
66 if(!GetObjectContact().isPageDecorationActive())
71 if(GetObjectContact().isOutputToPrinter())
76 if(!GetObjectContact().TryToGetSdrPageView())
84 bool ViewObjectContactOfPageSubObject::isPrimitiveGhosted(const DisplayInfo
& /*rDisplayInfo*/) const
86 // suppress ghosted for page parts
90 ViewObjectContactOfPageBackground::ViewObjectContactOfPageBackground(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
91 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
95 ViewObjectContactOfPageBackground::~ViewObjectContactOfPageBackground()
99 bool ViewObjectContactOfPageBackground::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
101 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
106 // no page background for preview renderers
107 if(GetObjectContact().IsPreviewRenderer())
115 void ViewObjectContactOfPageBackground::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
117 // Initialize background. Dependent of IsPageVisible, use ApplicationBackgroundColor or ApplicationDocumentColor. Most
118 // old renderers for export (html, pdf, gallery, ...) set the page to not visible (SetPageVisible(false)). They expect the
119 // given OutputDevice to be initialized with the ApplicationDocumentColor then.
120 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
124 const SdrView
& rView
= pPageView
->GetView();
127 if(rView
.IsPageVisible())
129 aInitColor
= pPageView
->GetApplicationBackgroundColor();
133 aInitColor
= pPageView
->GetApplicationDocumentColor();
135 if(COL_AUTO
== aInitColor
)
137 const svtools::ColorConfig aColorConfig
;
138 aInitColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
142 // init background with InitColor
143 const basegfx::BColor
aRGBColor(aInitColor
.getBColor());
144 rVisitor
.visit(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor
, (255 - aInitColor
.GetAlpha()) / 255.0));
148 ViewObjectContactOfMasterPage::ViewObjectContactOfMasterPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
149 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
153 ViewObjectContactOfMasterPage::~ViewObjectContactOfMasterPage()
157 bool ViewObjectContactOfMasterPage::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
159 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
164 // this object is only used for MasterPages. When not the MasterPage is
165 // displayed as a page, but another page is using it as sub-object, the
166 // geometry needs to be hidden
167 if(rDisplayInfo
.GetSubContentActive())
175 ViewObjectContactOfPageFill::ViewObjectContactOfPageFill(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
176 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
180 ViewObjectContactOfPageFill::~ViewObjectContactOfPageFill()
184 bool ViewObjectContactOfPageFill::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
186 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
191 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
198 if(!pSdrPageView
->GetView().IsPageVisible())
206 void ViewObjectContactOfPageFill::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
208 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
212 const SdrPage
& rPage
= getPage();
214 const basegfx::B2DRange
aPageFillRange(0.0, 0.0, static_cast<double>(rPage
.GetWidth()), static_cast<double>(rPage
.GetHeight()));
215 const basegfx::B2DPolygon
aPageFillPolygon(basegfx::utils::createPolygonFromRect(aPageFillRange
));
216 Color aPageFillColor
;
218 if(pPageView
->GetApplicationDocumentColor() != COL_AUTO
)
220 aPageFillColor
= pPageView
->GetApplicationDocumentColor();
224 const svtools::ColorConfig aColorConfig
;
225 aPageFillColor
= aColorConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
228 // create and add primitive
229 const basegfx::BColor
aRGBColor(aPageFillColor
.getBColor());
230 rVisitor
.visit(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon
), aRGBColor
));
234 ViewObjectContactOfPageShadow::ViewObjectContactOfPageShadow(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
235 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
239 ViewObjectContactOfPageShadow::~ViewObjectContactOfPageShadow()
243 bool ViewObjectContactOfPageShadow::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
245 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
250 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
257 if(!pSdrPageView
->GetView().IsPageVisible())
262 if(!pSdrPageView
->GetView().IsPageShadowVisible())
267 // no page shadow for preview renderers
268 if(GetObjectContact().IsPreviewRenderer())
273 // no page shadow for high contrast mode
274 if(GetObjectContact().isDrawModeHighContrast())
282 ViewObjectContactOfOuterPageBorder::ViewObjectContactOfOuterPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
283 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
287 ViewObjectContactOfOuterPageBorder::~ViewObjectContactOfOuterPageBorder()
291 bool ViewObjectContactOfOuterPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
293 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
298 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
305 const SdrView
& rView
= pSdrPageView
->GetView();
307 return rView
.IsPageVisible() || !rView
.IsPageBorderVisible();
310 ViewObjectContactOfInnerPageBorder::ViewObjectContactOfInnerPageBorder(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
311 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
315 ViewObjectContactOfInnerPageBorder::~ViewObjectContactOfInnerPageBorder()
319 bool ViewObjectContactOfInnerPageBorder::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
321 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
326 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
333 if(!pSdrPageView
->GetView().IsBordVisible())
338 const SdrPage
& rPage
= getPage();
340 if(!rPage
.GetLeftBorder() && !rPage
.GetUpperBorder() && !rPage
.GetRightBorder() && !rPage
.GetLowerBorder())
345 // no inner page border for preview renderers
346 if(GetObjectContact().IsPreviewRenderer())
354 ViewObjectContactOfPageHierarchy::ViewObjectContactOfPageHierarchy(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
355 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
359 ViewObjectContactOfPageHierarchy::~ViewObjectContactOfPageHierarchy()
363 void ViewObjectContactOfPageHierarchy::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
365 // process local sub-hierarchy
366 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
368 if(!nSubHierarchyCount
)
371 getPrimitive2DSequenceSubHierarchy(rDisplayInfo
, rVisitor
);
374 ViewObjectContactOfPageGrid::ViewObjectContactOfPageGrid(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
375 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
379 ViewObjectContactOfPageGrid::~ViewObjectContactOfPageGrid()
383 bool ViewObjectContactOfPageGrid::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
385 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
390 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
397 const SdrView
& rView
= pSdrPageView
->GetView();
399 if(!rView
.IsGridVisible())
404 // no page grid for preview renderers
405 if(GetObjectContact().IsPreviewRenderer())
410 if(static_cast< ViewContactOfGrid
& >(GetViewContact()).getFront() != rView
.IsGridFront())
418 void ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
420 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
424 const SdrView
& rView
= pPageView
->GetView();
425 const SdrPage
& rPage
= getPage();
426 const Color
aGridColor(rView
.GetGridColor());
427 const basegfx::BColor
aRGBGridColor(aGridColor
.getBColor());
429 basegfx::B2DHomMatrix aGridMatrix
;
430 aGridMatrix
.set(0, 0, static_cast<double>(rPage
.GetWidth() - (rPage
.GetRightBorder() + rPage
.GetLeftBorder())));
431 aGridMatrix
.set(1, 1, static_cast<double>(rPage
.GetHeight() - (rPage
.GetLowerBorder() + rPage
.GetUpperBorder())));
432 aGridMatrix
.set(0, 2, static_cast<double>(rPage
.GetLeftBorder()));
433 aGridMatrix
.set(1, 2, static_cast<double>(rPage
.GetUpperBorder()));
435 const Size
aRaw(rView
.GetGridCoarse());
436 const Size
aFine(rView
.GetGridFine());
437 const double fWidthX(aRaw
.getWidth());
438 const double fWidthY(aRaw
.getHeight());
439 const sal_uInt32
nSubdivisionsX(aFine
.getWidth() ? aRaw
.getWidth() / aFine
.getWidth() : 0);
440 const sal_uInt32
nSubdivisionsY(aFine
.getHeight() ? aRaw
.getHeight() / aFine
.getHeight() : 0);
442 rVisitor
.visit(new drawinglayer::primitive2d::GridPrimitive2D(
443 aGridMatrix
, fWidthX
, fWidthY
, 10.0, 3.0, nSubdivisionsX
, nSubdivisionsY
, aRGBGridColor
,
444 drawinglayer::primitive2d::createDefaultCross_3x3(aRGBGridColor
)));
448 ViewObjectContactOfPageHelplines::ViewObjectContactOfPageHelplines(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
449 : ViewObjectContactOfPageSubObject(rObjectContact
, rViewContact
)
453 ViewObjectContactOfPageHelplines::~ViewObjectContactOfPageHelplines()
457 bool ViewObjectContactOfPageHelplines::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
459 if(!ViewObjectContactOfPageSubObject::isPrimitiveVisible(rDisplayInfo
))
464 SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
471 const SdrView
& rView
= pSdrPageView
->GetView();
473 if(!rView
.IsHlplVisible())
478 // no helplines for preview renderers
479 if(GetObjectContact().IsPreviewRenderer())
484 if(static_cast< ViewContactOfHelplines
& >(GetViewContact()).getFront() != rView
.IsHlplFront())
492 void ViewObjectContactOfPageHelplines::createPrimitive2DSequence(const DisplayInfo
& /*rDisplayInfo*/, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
494 const SdrPageView
* pPageView
= GetObjectContact().TryToGetSdrPageView();
498 const SdrHelpLineList
& rHelpLineList
= pPageView
->GetHelpLines();
499 const sal_uInt32
nCount(rHelpLineList
.GetCount());
503 const basegfx::BColor
aRGBColorA(1.0, 1.0, 1.0);
504 const basegfx::BColor
aRGBColorB(0.0, 0.0, 0.0);
506 for(sal_uInt32
a(0); a
< nCount
; a
++)
508 const SdrHelpLine
& rHelpLine
= rHelpLineList
[static_cast<sal_uInt16
>(a
)];
509 const basegfx::B2DPoint
aPosition(static_cast<double>(rHelpLine
.GetPos().X()), static_cast<double>(rHelpLine
.GetPos().Y()));
510 const double fDiscreteDashLength(4.0);
512 switch(rHelpLine
.GetKind())
514 default : // SdrHelpLineKind::Point
516 rVisitor
.visit(new drawinglayer::primitive2d::HelplinePrimitive2D(
517 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HelplineStyle2D::Point
,
518 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
521 case SdrHelpLineKind::Vertical
:
523 rVisitor
.visit(new drawinglayer::primitive2d::HelplinePrimitive2D(
524 aPosition
, basegfx::B2DVector(0.0, 1.0), drawinglayer::primitive2d::HelplineStyle2D::Line
,
525 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
528 case SdrHelpLineKind::Horizontal
:
530 rVisitor
.visit(new drawinglayer::primitive2d::HelplinePrimitive2D(
531 aPosition
, basegfx::B2DVector(1.0, 0.0), drawinglayer::primitive2d::HelplineStyle2D::Line
,
532 aRGBColorA
, aRGBColorB
, fDiscreteDashLength
));
541 ViewObjectContactOfSdrPage::ViewObjectContactOfSdrPage(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
542 : ViewObjectContact(rObjectContact
, rViewContact
)
546 ViewObjectContactOfSdrPage::~ViewObjectContactOfSdrPage()
550 void ViewObjectContactOfSdrPage::getPrimitive2DSequenceHierarchy(DisplayInfo
& rDisplayInfo
, drawinglayer::primitive2d::Primitive2DDecompositionVisitor
& rVisitor
) const
552 // process local sub-hierarchy
553 const sal_uInt32
nSubHierarchyCount(GetViewContact().GetObjectCount());
555 if(!nSubHierarchyCount
)
558 const bool bDoGhostedDisplaying(
559 GetObjectContact().DoVisualizeEnteredGroup()
560 && !GetObjectContact().isOutputToPrinter()
561 && GetObjectContact().getActiveViewContact() == &GetViewContact());
563 if(bDoGhostedDisplaying
)
565 rDisplayInfo
.ClearGhostedDrawMode();
568 // visit object hierarchy
569 getPrimitive2DSequenceSubHierarchy(rDisplayInfo
, rVisitor
);
571 if(bDoGhostedDisplaying
)
573 rDisplayInfo
.SetGhostedDrawMode();
579 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */