LibreOffice Module svx (master)  1
viewobjectcontactofsdrpage.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
24 #include <svx/svdview.hxx>
25 #include <svx/svdpage.hxx>
26 #include <svx/svdpagv.hxx>
35 
36 using namespace com::sun::star;
37 
38 namespace sdr { namespace contact {
39 
40 const SdrPage& ViewObjectContactOfPageSubObject::getPage() const
41 {
42  return static_cast< ViewContactOfPageSubObject& >(GetViewContact()).getPage();
43 }
44 
45 ViewObjectContactOfPageSubObject::ViewObjectContactOfPageSubObject(ObjectContact& rObjectContact, ViewContact& rViewContact)
46 : ViewObjectContact(rObjectContact, rViewContact)
47 {
48 }
49 
51 {
52 }
53 
55 {
56  if(rDisplayInfo.GetSubContentActive())
57  {
58  return false;
59  }
60 
61  if(rDisplayInfo.GetControlLayerProcessingActive())
62  {
63  return false;
64  }
65 
66  if(!rDisplayInfo.GetPageProcessingActive())
67  {
68  return false;
69  }
70 
72  {
73  return false;
74  }
75 
77  {
78  return false;
79  }
80 
81  return true;
82 }
83 
85 {
86  // suppress ghosted for page parts
87  return false;
88 }
89 
91 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
92 {
93 }
94 
96 {
97 }
98 
100 {
102  {
103  return false;
104  }
105 
106  // no page background for preview renderers
107  if(GetObjectContact().IsPreviewRenderer())
108  {
109  return false;
110  }
111 
112  return true;
113 }
114 
116 {
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();
122 
123  if(pPageView)
124  {
125  const SdrView& rView = pPageView->GetView();
126  Color aInitColor;
127 
128  if(rView.IsPageVisible())
129  {
130  aInitColor = pPageView->GetApplicationBackgroundColor();
131  }
132  else
133  {
134  aInitColor = pPageView->GetApplicationDocumentColor();
135 
136  if(COL_AUTO == aInitColor)
137  {
138  const svtools::ColorConfig aColorConfig;
139  aInitColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor;
140  }
141  }
142 
143  // init background with InitColor
144  xRetval.resize(1);
145  const basegfx::BColor aRGBColor(aInitColor.getBColor());
147  }
148 
149  return xRetval;
150 }
151 
153 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
154 {
155 }
156 
158 {
159 }
160 
162 {
164  {
165  return false;
166  }
167 
168  // this object is only used for MasterPages. When not the MasterPage is
169  // displayed as a page, but another page is using it as sub-object, the
170  // geometry needs to be hidden
171  if(rDisplayInfo.GetSubContentActive())
172  {
173  return false;
174  }
175 
176  return true;
177 }
178 
180 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
181 {
182 }
183 
185 {
186 }
187 
189 {
191  {
192  return false;
193  }
194 
196 
197  if(!pSdrPageView)
198  {
199  return false;
200  }
201 
202  if(!pSdrPageView->GetView().IsPageVisible())
203  {
204  return false;
205  }
206 
207  return true;
208 }
209 
211 {
212  const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
214 
215  if(pPageView)
216  {
217  const SdrPage& rPage = getPage();
218 
219  const basegfx::B2DRange aPageFillRange(0.0, 0.0, static_cast<double>(rPage.GetWidth()), static_cast<double>(rPage.GetHeight()));
220  const basegfx::B2DPolygon aPageFillPolygon(basegfx::utils::createPolygonFromRect(aPageFillRange));
221  Color aPageFillColor;
222 
223  if(pPageView->GetApplicationDocumentColor() != COL_AUTO)
224  {
225  aPageFillColor = pPageView->GetApplicationDocumentColor();
226  }
227  else
228  {
229  const svtools::ColorConfig aColorConfig;
230  aPageFillColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor;
231  }
232 
233  // create and add primitive
234  xRetval.resize(1);
235  const basegfx::BColor aRGBColor(aPageFillColor.getBColor());
237  }
238 
239  return xRetval;
240 }
241 
243 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
244 {
245 }
246 
248 {
249 }
250 
252 {
254  {
255  return false;
256  }
257 
259 
260  if(!pSdrPageView)
261  {
262  return false;
263  }
264 
265  if(!pSdrPageView->GetView().IsPageVisible())
266  {
267  return false;
268  }
269 
270  if(!pSdrPageView->GetView().IsPageShadowVisible())
271  {
272  return false;
273  }
274 
275  // no page shadow for preview renderers
277  {
278  return false;
279  }
280 
281  // no page shadow for high contrast mode
283  {
284  return false;
285  }
286 
287  return true;
288 }
289 
291 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
292 {
293 }
294 
296 {
297 }
298 
300 {
302  {
303  return false;
304  }
305 
307 
308  if(!pSdrPageView)
309  {
310  return false;
311  }
312 
313  const SdrView& rView = pSdrPageView->GetView();
314 
315  return rView.IsPageVisible() || !rView.IsPageBorderVisible();
316 }
317 
319 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
320 {
321 }
322 
324 {
325 }
326 
328 {
330  {
331  return false;
332  }
333 
335 
336  if(!pSdrPageView)
337  {
338  return false;
339  }
340 
341  if(!pSdrPageView->GetView().IsBordVisible())
342  {
343  return false;
344  }
345 
346  const SdrPage& rPage = getPage();
347 
348  if(!rPage.GetLeftBorder() && !rPage.GetUpperBorder() && !rPage.GetRightBorder() && !rPage.GetLowerBorder())
349  {
350  return false;
351  }
352 
353  // no inner page border for preview renderers
355  {
356  return false;
357  }
358 
359  return true;
360 }
361 
363 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
364 {
365 }
366 
368 {
369 }
370 
372 {
374 
375  // process local sub-hierarchy
376  const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
377 
378  if(nSubHierarchyCount)
379  {
380  xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
381 
382  if(!xRetval.empty())
383  {
384  // get ranges
385  const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
386  const basegfx::B2DRange aObjectRange(xRetval.getB2DRange(rViewInformation2D));
387  const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
388 
389  // check geometrical visibility
390  if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
391  {
392  // not visible, release
393  xRetval.clear();
394  }
395  }
396  }
397 
398  return xRetval;
399 }
400 
402 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
403 {
404 }
405 
407 {
408 }
409 
411 {
413  {
414  return false;
415  }
416 
418 
419  if(!pSdrPageView)
420  {
421  return false;
422  }
423 
424  const SdrView& rView = pSdrPageView->GetView();
425 
426  if(!rView.IsGridVisible())
427  {
428  return false;
429  }
430 
431  // no page grid for preview renderers
433  {
434  return false;
435  }
436 
437  if(static_cast< ViewContactOfGrid& >(GetViewContact()).getFront() != rView.IsGridFront())
438  {
439  return false;
440  }
441 
442  return true;
443 }
444 
446 {
447  const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
449 
450  if(pPageView)
451  {
452  const SdrView& rView = pPageView->GetView();
453  const SdrPage& rPage = getPage();
454  const Color aGridColor(rView.GetGridColor());
455  const basegfx::BColor aRGBGridColor(aGridColor.getBColor());
456 
457  basegfx::B2DHomMatrix aGridMatrix;
458  aGridMatrix.set(0, 0, static_cast<double>(rPage.GetWidth() - (rPage.GetRightBorder() + rPage.GetLeftBorder())));
459  aGridMatrix.set(1, 1, static_cast<double>(rPage.GetHeight() - (rPage.GetLowerBorder() + rPage.GetUpperBorder())));
460  aGridMatrix.set(0, 2, static_cast<double>(rPage.GetLeftBorder()));
461  aGridMatrix.set(1, 2, static_cast<double>(rPage.GetUpperBorder()));
462 
463  const Size aRaw(rView.GetGridCoarse());
464  const Size aFine(rView.GetGridFine());
465  const double fWidthX(aRaw.getWidth());
466  const double fWidthY(aRaw.getHeight());
467  const sal_uInt32 nSubdivisionsX(aFine.getWidth() ? aRaw.getWidth() / aFine.getWidth() : 0L);
468  const sal_uInt32 nSubdivisionsY(aFine.getHeight() ? aRaw.getHeight() / aFine.getHeight() : 0L);
469 
470  xRetval.resize(1);
472  aGridMatrix, fWidthX, fWidthY, 10.0, 3.0, nSubdivisionsX, nSubdivisionsY, aRGBGridColor,
474  }
475 
476  return xRetval;
477 }
478 
480 : ViewObjectContactOfPageSubObject(rObjectContact, rViewContact)
481 {
482 }
483 
485 {
486 }
487 
489 {
491  {
492  return false;
493  }
494 
496 
497  if(!pSdrPageView)
498  {
499  return false;
500  }
501 
502  const SdrView& rView = pSdrPageView->GetView();
503 
504  if(!rView.IsHlplVisible())
505  {
506  return false;
507  }
508 
509  // no helplines for preview renderers
511  {
512  return false;
513  }
514 
515  if(static_cast< ViewContactOfHelplines& >(GetViewContact()).getFront() != rView.IsHlplFront())
516  {
517  return false;
518  }
519 
520  return true;
521 }
522 
524 {
526  const SdrPageView* pPageView = GetObjectContact().TryToGetSdrPageView();
527 
528  if(pPageView)
529  {
530  const SdrHelpLineList& rHelpLineList = pPageView->GetHelpLines();
531  const sal_uInt32 nCount(rHelpLineList.GetCount());
532 
533  if(nCount)
534  {
535  const basegfx::BColor aRGBColorA(1.0, 1.0, 1.0);
536  const basegfx::BColor aRGBColorB(0.0, 0.0, 0.0);
537  xRetval.resize(nCount);
538 
539  for(sal_uInt32 a(0); a < nCount; a++)
540  {
541  const SdrHelpLine& rHelpLine = rHelpLineList[static_cast<sal_uInt16>(a)];
542  const basegfx::B2DPoint aPosition(static_cast<double>(rHelpLine.GetPos().X()), static_cast<double>(rHelpLine.GetPos().Y()));
543  const double fDiscreteDashLength(4.0);
544 
545  switch(rHelpLine.GetKind())
546  {
547  default : // SdrHelpLineKind::Point
548  {
551  aRGBColorA, aRGBColorB, fDiscreteDashLength));
552  break;
553  }
555  {
558  aRGBColorA, aRGBColorB, fDiscreteDashLength));
559  break;
560  }
562  {
565  aRGBColorA, aRGBColorB, fDiscreteDashLength));
566  break;
567  }
568  }
569  }
570  }
571  }
572 
573  return xRetval;
574 }
575 
577 : ViewObjectContact(rObjectContact, rViewContact)
578 {
579 }
580 
582 {
583 }
584 
586 {
588 
589  // process local sub-hierarchy
590  const sal_uInt32 nSubHierarchyCount(GetViewContact().GetObjectCount());
591 
592  if(nSubHierarchyCount)
593  {
594  const bool bDoGhostedDisplaying(
595  GetObjectContact().DoVisualizeEnteredGroup()
596  && !GetObjectContact().isOutputToPrinter()
597  && GetObjectContact().getActiveViewContact() == &GetViewContact());
598 
599  if(bDoGhostedDisplaying)
600  {
601  rDisplayInfo.ClearGhostedDrawMode();
602  }
603 
604  // create object hierarchy
605  xRetval = getPrimitive2DSequenceSubHierarchy(rDisplayInfo);
606 
607  if(!xRetval.empty())
608  {
609  // get ranges
610  const drawinglayer::geometry::ViewInformation2D& rViewInformation2D(GetObjectContact().getViewInformation2D());
611  const basegfx::B2DRange aObjectRange(xRetval.getB2DRange(rViewInformation2D));
612  const basegfx::B2DRange aViewRange(rViewInformation2D.getViewport());
613 
614  // check geometrical visibility
615  if(!aViewRange.isEmpty() && !aViewRange.overlaps(aObjectRange))
616  {
617  // not visible, release
618  xRetval.clear();
619  }
620  }
621 
622  if(bDoGhostedDisplaying)
623  {
624  rDisplayInfo.SetGhostedDrawMode();
625  }
626  }
627 
628  return xRetval;
629 }
630 
631 }}
632 
633 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsGridFront() const
Draw Grid in front of objects or behind them.
Definition: svdpntv.hxx:380
virtual bool isDrawModeHighContrast() const
ViewObjectContactOfOuterPageBorder(ObjectContact &rObjectContact, ViewContact &rViewContact)
const basegfx::B2DRange & getViewport() const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
bool IsHlplVisible() const
Draw Help line of the Page or not.
Definition: svdpntv.hxx:383
sal_Int32 GetHeight() const
Definition: svdpage.cxx:1417
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequence(const DisplayInfo &rDisplayInfo) const override
bool IsPageVisible() const
Draw Page as a white area or not.
Definition: svdpntv.hxx:365
SdrView & GetView()
Definition: svdpagv.hxx:137
sal_uInt8 GetTransparency() const
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequence(const DisplayInfo &rDisplayInfo) const override
virtual drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceHierarchy(DisplayInfo &rDisplayInfo) const override
sal_Int32 GetRightBorder() const
Definition: svdpage.cxx:1502
bool GetPageProcessingActive() const
Definition: displayinfo.hxx:90
sal_Int32 GetLowerBorder() const
Definition: svdpage.cxx:1507
const SdrHelpLineList & GetHelpLines() const
Definition: svdpagv.hxx:223
sal_Int32 GetLeftBorder() const
Definition: svdpage.cxx:1492
ViewObjectContactOfSdrPage(ObjectContact &rObjectContact, ViewContact &rViewContact)
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
bool IsBordVisible() const
Draw Border line or not.
Definition: svdpntv.hxx:374
const Color & GetGridColor() const
Definition: svdpntv.hxx:388
ViewObjectContactOfPageHierarchy(ObjectContact &rObjectContact, ViewContact &rViewContact)
drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceSubHierarchy(DisplayInfo &rDisplayInfo) const
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequence(const DisplayInfo &rDisplayInfo) const override
SdrHelpLineKind GetKind() const
Definition: svdhlpln.hxx:49
bool IsGridVisible() const
Draw Grid or not.
Definition: svdpntv.hxx:377
const Size & GetGridFine() const
Definition: svdpntv.hxx:419
int nCount
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
const Point & GetPos() const
Definition: svdhlpln.hxx:51
ViewObjectContactOfPageHelplines(ObjectContact &rObjectContact, ViewContact &rViewContact)
const Color & GetApplicationDocumentColor() const
Definition: svdpagv.hxx:258
virtual bool isOutputToPrinter() const
ObjectContact & GetObjectContact() const
bool IsHlplFront() const
Draw Help line in front of the objects or behind them.
Definition: svdpntv.hxx:386
uno_Any a
bool GetControlLayerProcessingActive() const
Definition: displayinfo.hxx:86
sal_Int32 GetUpperBorder() const
Definition: svdpage.cxx:1497
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
BitmapEx createDefaultCross_3x3(const basegfx::BColor &rBColor)
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
virtual bool isPrimitiveGhosted(const DisplayInfo &rDisplayInfo) const override
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
virtual drawinglayer::primitive2d::Primitive2DContainer getPrimitive2DSequenceHierarchy(DisplayInfo &rDisplayInfo) const override
long X() const
const Size & GetGridCoarse() const
Definition: svdpntv.hxx:418
sal_uInt16 GetCount() const
Definition: svdhlpln.hxx:71
ViewObjectContactOfMasterPage(ObjectContact &rObjectContact, ViewContact &rViewContact)
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
ViewObjectContactOfInnerPageBorder(ObjectContact &rObjectContact, ViewContact &rViewContact)
virtual drawinglayer::primitive2d::Primitive2DContainer createPrimitive2DSequence(const DisplayInfo &rDisplayInfo) const override
bool IsPageShadowVisible() const
Draw Page shadow or not.
Definition: svdpntv.hxx:368
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
basegfx::BColor getBColor() const
ViewObjectContactOfPageShadow(ObjectContact &rObjectContact, ViewContact &rViewContact)
ViewContact & GetViewContact() const
bool IsPageBorderVisible() const
Draw Page as a white area or not.
Definition: svdpntv.hxx:371
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D &aViewInformation) const
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
sal_Int32 GetWidth() const
Definition: svdpage.cxx:1391
bool GetSubContentActive() const
Definition: displayinfo.hxx:98
const Color & GetApplicationBackgroundColor() const
Definition: svdpagv.hxx:254
ViewObjectContactOfPageBackground(ObjectContact &rObjectContact, ViewContact &rViewContact)
ViewObjectContactOfPageFill(ObjectContact &rObjectContact, ViewContact &rViewContact)
long Y() const
ViewObjectContactOfPageGrid(ObjectContact &rObjectContact, ViewContact &rViewContact)
virtual SdrPageView * TryToGetSdrPageView() const
access to SdrPageView. May return 0L like the default implementations do. Override as needed...