fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / contact / viewobjectcontactofsdrpage.cxx
blob3a93368ffcece5177f6c3c35670f3066234d70ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 //////////////////////////////////////////////////////////////////////////////
41 namespace sdr
43 namespace contact
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())
63 return false;
66 if(rDisplayInfo.GetControlLayerProcessingActive())
68 return false;
71 if(!rDisplayInfo.GetPageProcessingActive())
73 return false;
76 if(GetObjectContact().isOutputToPrinter())
78 return false;
81 if(!GetObjectContact().TryToGetSdrPageView())
83 return false;
86 return true;
89 bool ViewObjectContactOfPageSubObject::isPrimitiveGhosted(const DisplayInfo& /*rDisplayInfo*/) const
91 // suppress ghosted for page parts
92 return false;
94 } // end of namespace contact
95 } // end of namespace sdr
97 //////////////////////////////////////////////////////////////////////////////
99 namespace sdr
101 namespace contact
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))
116 return false;
119 // no page background for preview renderers
120 if(GetObjectContact().IsPreviewRenderer())
122 return false;
125 return true;
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;
136 if(pPageView)
138 const SdrView& rView = pPageView->GetView();
139 Color aInitColor;
141 if(rView.IsPageVisible())
143 aInitColor = pPageView->GetApplicationBackgroundColor();
145 else
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
157 xRetval.realloc(1);
158 const basegfx::BColor aRGBColor(aInitColor.getBColor());
159 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::BackgroundColorPrimitive2D(aRGBColor));
162 return xRetval;
164 } // end of namespace contact
165 } // end of namespace sdr
167 //////////////////////////////////////////////////////////////////////////////
169 namespace sdr
171 namespace contact
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))
186 return false;
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())
194 return false;
197 return true;
199 } // end of namespace contact
200 } // end of namespace sdr
202 //////////////////////////////////////////////////////////////////////////////
204 namespace sdr
206 namespace contact
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))
221 return false;
224 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
226 if(!pSdrPageView)
228 return false;
231 if(!pSdrPageView->GetView().IsPageVisible())
233 return false;
236 return true;
239 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageFill::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
241 const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
242 drawinglayer::primitive2d::Primitive2DSequence xRetval;
244 if(pPageView)
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();
256 else
258 const svtools::ColorConfig aColorConfig;
259 aPageFillColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor;
262 // create and add primitive
263 xRetval.realloc(1);
264 const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
265 xRetval[0] = drawinglayer::primitive2d::Primitive2DReference(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aPageFillPolygon), aRGBColor));
268 return xRetval;
270 } // end of namespace contact
271 } // end of namespace sdr
273 //////////////////////////////////////////////////////////////////////////////
275 namespace sdr
277 namespace contact
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))
292 return false;
295 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
297 if(!pSdrPageView)
299 return false;
302 if(!pSdrPageView->GetView().IsPageVisible())
304 return false;
307 // no page shadow for preview renderers
308 if(GetObjectContact().IsPreviewRenderer())
310 return false;
313 // no page shadow for high contrast mode
314 if(GetObjectContact().isDrawModeHighContrast())
316 return false;
319 return true;
321 } // end of namespace contact
322 } // end of namespace sdr
324 //////////////////////////////////////////////////////////////////////////////
326 namespace sdr
328 namespace contact
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))
343 return false;
346 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
348 if(!pSdrPageView)
350 return false;
353 const SdrView& rView = pSdrPageView->GetView();
355 if(!rView.IsPageVisible() && rView.IsPageBorderVisible())
357 return false;
360 return true;
362 } // end of namespace contact
363 } // end of namespace sdr
365 //////////////////////////////////////////////////////////////////////////////
367 namespace sdr
369 namespace contact
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))
384 return false;
387 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
389 if(!pSdrPageView)
391 return false;
394 if(!pSdrPageView->GetView().IsBordVisible())
396 return false;
399 const SdrPage& rPage = getPage();
401 if(!rPage.GetLftBorder() && !rPage.GetUppBorder() && !rPage.GetRgtBorder() && !rPage.GetLwrBorder())
403 return false;
406 // no inner page border for preview renderers
407 if(GetObjectContact().IsPreviewRenderer())
409 return false;
412 return true;
414 } // end of namespace contact
415 } // end of namespace sdr
417 //////////////////////////////////////////////////////////////////////////////
419 namespace sdr
421 namespace contact
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())
445 // get ranges
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
454 xRetval.realloc(0);
459 return xRetval;
461 } // end of namespace contact
462 } // end of namespace sdr
464 //////////////////////////////////////////////////////////////////////////////
466 namespace sdr
468 namespace contact
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))
483 return false;
486 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
488 if(!pSdrPageView)
490 return false;
493 const SdrView& rView = pSdrPageView->GetView();
495 if(!rView.IsGridVisible())
497 return false;
500 // no page grid for preview renderers
501 if(GetObjectContact().IsPreviewRenderer())
503 return false;
506 if(static_cast< ViewContactOfGrid& >(GetViewContact()).getFront() != (bool)rView.IsGridFront())
508 return false;
511 return true;
514 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageGrid::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
516 const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
517 drawinglayer::primitive2d::Primitive2DSequence xRetval;
519 if(pPageView)
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);
539 xRetval.realloc(1);
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)));
545 return xRetval;
547 } // end of namespace contact
548 } // end of namespace sdr
550 //////////////////////////////////////////////////////////////////////////////
552 namespace sdr
554 namespace contact
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))
569 return false;
572 SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
574 if(!pSdrPageView)
576 return false;
579 const SdrView& rView = pSdrPageView->GetView();
581 if(!rView.IsHlplVisible())
583 return false;
586 // no helplines for preview renderers
587 if(GetObjectContact().IsPreviewRenderer())
589 return false;
592 if(static_cast< ViewContactOfHelplines& >(GetViewContact()).getFront() != (bool)rView.IsHlplFront())
594 return false;
597 return true;
600 drawinglayer::primitive2d::Primitive2DSequence ViewObjectContactOfPageHelplines::createPrimitive2DSequence(const DisplayInfo& /*rDisplayInfo*/) const
602 drawinglayer::primitive2d::Primitive2DSequence xRetval;
603 const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
605 if(pPageView)
607 const SdrHelpLineList& rHelpLineList = pPageView->GetHelpLines();
608 const sal_uInt32 nCount(rHelpLineList.GetCount());
610 if(nCount)
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));
629 break;
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));
636 break;
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));
643 break;
650 return xRetval;
652 } // end of namespace contact
653 } // end of namespace sdr
655 //////////////////////////////////////////////////////////////////////////////
657 namespace sdr
659 namespace contact
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())
694 // get ranges
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
703 xRetval.realloc(0);
707 if(bDoGhostedDisplaying)
709 rDisplayInfo.SetGhostedDrawMode();
713 return xRetval;
715 } // end of namespace contact
716 } // end of namespace sdr
718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */