LibreOffice Module svx (master)  1
viewobjectcontactofsdrobj.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 
26 #include <svx/sdrpagewindow.hxx>
27 #include <svx/sdrpaintwindow.hxx>
28 #include <svx/svdobj.hxx>
29 #include <svx/svdoole2.hxx>
30 #include <svx/svdpagv.hxx>
31 #include <svx/svdview.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/canvastools.hxx>
34 
35 #include <fmobj.hxx>
36 
37 namespace sdr::contact {
38 
40 {
41  return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
42 }
43 
45 : ViewObjectContact(rObjectContact, rViewContact)
46 {
47 }
48 
50 {
51 }
52 
54 {
55  return aLayers.IsSet(getSdrObject().GetLayer());
56 }
57 
59 {
60  const SdrObject& rObject = getSdrObject();
61 
62  // Test layer visibility
64  {
65  return false;
66  }
67 
69  {
70  // Test if print output but not printable
71  if( !rObject.IsPrintable())
72  return false;
73  }
74  else
75  {
76  // test is object is not visible on screen
77  if( !rObject.IsVisible() )
78  return false;
79  }
80 
81  // Test for hidden object on MasterPage
82  if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
83  {
84  return false;
85  }
86 
87  // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
88  const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
89 
90  if(pSdrPageView)
91  {
92  const SdrView& rSdrView = pSdrPageView->GetView();
93  const bool bHideOle(rSdrView.getHideOle());
94  const bool bHideChart(rSdrView.getHideChart());
95  const bool bHideDraw(rSdrView.getHideDraw());
96  const bool bHideFormControl(rSdrView.getHideFormControl());
97 
98  if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
99  {
100  if(OBJ_OLE2 == rObject.GetObjIdentifier())
101  {
102  if(static_cast<const SdrOle2Obj&>(rObject).IsChart())
103  {
104  // chart
105  if(bHideChart)
106  {
107  return false;
108  }
109  }
110  else
111  {
112  // OLE
113  if(bHideOle)
114  {
115  return false;
116  }
117  }
118  }
119  else if(OBJ_GRAF == rObject.GetObjIdentifier())
120  {
121  // graphic handled like OLE
122  if(bHideOle)
123  {
124  return false;
125  }
126  }
127  else
128  {
129  const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != nullptr;
130  if(bIsFormControl && bHideFormControl)
131  {
132  return false;
133  }
134  // any other draw object
135  if(!bIsFormControl && bHideDraw)
136  {
137  return false;
138  }
139  }
140  }
141  }
142 
143  // tdf#91260 check if the object is anchored on a different Writer page
144  // than the one being painted, and if so ignore it (Writer has only one
145  // SdrPage, so the part of the object that should be visible will be
146  // painted on the page where it is anchored)
147  // Note that we cannot check the ViewInformation2D ViewPort for this
148  // because it is only the part of the page that is currently visible.
149  basegfx::B2IPoint const& rAnchor(vcl::unotools::b2IPointFromPoint(getSdrObject().GetAnchorPos()));
150  if (rAnchor.getX() || rAnchor.getY()) // only Writer sets anchor position
151  {
152  if (!rDisplayInfo.GetWriterPageFrame().isEmpty() &&
153  !rDisplayInfo.GetWriterPageFrame().isInside(rAnchor))
154  {
155  return false;
156  }
157  }
158 
159  // Check if this object is in the visible range.
161  basegfx::B2DRange aObjRange = GetViewContact().getRange(rViewInfo);
162  if (!aObjRange.isEmpty())
163  {
164  const basegfx::B2DRange& rViewRange = rViewInfo.getViewport();
165  bool bVisible = rViewRange.isEmpty() || rViewRange.overlaps(aObjRange);
166  if (!bVisible)
167  return false;
168  }
169 
170  return true;
171 }
172 
174 {
175  ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &GetObjectContact() );
176  if ( pPageViewContact )
177  {
178  // if the PageWindow has a patched PaintWindow, use the original PaintWindow
179  // this ensures that our control is _not_ re-created just because somebody
180  // (temporarily) changed the window to paint onto.
181  // #i72429# / 2007-02-20 / frank.schoenheit (at) sun.com
182  SdrPageWindow& rPageWindow( pPageViewContact->GetPageWindow() );
183  if ( rPageWindow.GetOriginalPaintWindow() )
184  return &rPageWindow.GetOriginalPaintWindow()->GetOutputDevice();
185 
186  return &rPageWindow.GetPaintWindow().GetOutputDevice();
187  }
188  return nullptr;
189 }
190 
191 }
192 
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OutlineText, special text object for StarDraw.
Definition: svdobj.hxx:136
bool bVisible
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:883
const basegfx::B2DRange & getViewport() const
const SdrPaintWindow * GetOriginalPaintWindow() const
foreign graphic (StarView Graphic)
Definition: svdobj.hxx:137
SdrView & GetView()
Definition: svdpagv.hxx:135
virtual basegfx::B2DRange getRange(const drawinglayer::geometry::ViewInformation2D &rViewInfo2D) const
bool IsVisible() const
Definition: svdobj.hxx:805
const OutputDevice * getPageViewOutputDevice() const
retrieves the device which a PageView belongs to, starting from its ObjectContactOfPageView ...
ViewObjectContactOfSdrObj(ObjectContact &rObjectContact, ViewContact &rViewContact)
const SdrLayerIDSet & GetProcessLayers() const
Definition: displayinfo.hxx:75
basegfx::B2IPoint b2IPointFromPoint(Point const &rPoint)
virtual bool isOutputToPrinter() const
ObjectContact & GetObjectContact() const
bool isEmpty() const
sal_Int32 getX() const
const drawinglayer::geometry::ViewInformation2D & getViewInformation2D() const
virtual sal_uInt16 GetObjIdentifier() const
Definition: svdobj.cxx:558
bool isInside(const B2ITuple &rTuple) const
bool IsPrintable() const
Definition: svdobj.hxx:803
bool getHideFormControl() const
Definition: svdpntv.hxx:406
Abstract DrawObject.
Definition: svdobj.hxx:312
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:66
bool getHideChart() const
Definition: svdpntv.hxx:404
bool getHideOle() const
Definition: svdpntv.hxx:403
bool isEmpty() const
sal_Int32 getY() const
basegfx::B2IRectangle const & GetWriterPageFrame() const
Definition: displayinfo.hxx:82
ViewContact & GetViewContact() const
bool GetSubContentActive() const
Definition: displayinfo.hxx:98
bool getHideDraw() const
Definition: svdpntv.hxx:405
bool overlaps(const B2DRange &rRange) const
OutputDevice & GetOutputDevice() const
virtual bool isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet &aLayers) const
Test whether the primitive is visible on any layer from aLayers.
virtual SdrPageView * TryToGetSdrPageView() const
access to SdrPageView. May return 0L like the default implementations do. Override as needed...
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override