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