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>
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
37namespace 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
68 if(GetObjectContact().isOutputToPrinter() )
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(SdrObjKind::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(SdrObjKind::Graphic == 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: */
bool IsSet(SdrLayerID a) const
Definition: svdsob.hxx:69
Abstract DrawObject.
Definition: svdobj.hxx:260
virtual SdrObjKind GetObjIdentifier() const
Definition: svdobj.cxx:626
bool IsVisible() const
Definition: svdobj.hxx:762
bool IsPrintable() const
Definition: svdobj.hxx:760
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:835
SdrView & GetView()
Definition: svdpagv.hxx:130
SdrPaintWindow & GetPaintWindow() const
const SdrPaintWindow * GetOriginalPaintWindow() const
bool getHideFormControl() const
Definition: svdpntv.hxx:419
bool getHideDraw() const
Definition: svdpntv.hxx:418
bool getHideOle() const
Definition: svdpntv.hxx:416
bool getHideChart() const
Definition: svdpntv.hxx:417
OutputDevice & GetOutputDevice() const
bool isInside(const Tuple2D< TYPE > &rTuple) const
bool isEmpty() const
bool overlaps(const Range2D &rRange) const
TYPE getX() const
TYPE getY() const
const basegfx::B2DRange & getViewport() const
basegfx::B2IRectangle const & GetWriterPageFrame() const
Definition: displayinfo.hxx:73
bool GetSubContentActive() const
Definition: displayinfo.hxx:85
const SdrLayerIDSet & GetProcessLayers() const
Definition: displayinfo.hxx:66
virtual SdrPageView * TryToGetSdrPageView() const
access to SdrPageView. May return 0L like the default implementations do. Override as needed.
const drawinglayer::geometry::ViewInformation2D & getViewInformation2D() const
virtual basegfx::B2DRange getRange(const drawinglayer::geometry::ViewInformation2D &rViewInfo2D) const
virtual bool isPrimitiveVisible(const DisplayInfo &rDisplayInfo) const override
virtual bool isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet &aLayers) const
Test whether the primitive is visible on any layer from aLayers.
const OutputDevice * getPageViewOutputDevice() const
retrieves the device which a PageView belongs to, starting from its ObjectContactOfPageView
ViewObjectContactOfSdrObj(ObjectContact &rObjectContact, ViewContact &rViewContact)
ViewContact & GetViewContact() const
ObjectContact & GetObjectContact() const
basegfx::B2IPoint b2IPointFromPoint(Point const &rPoint)
@ OLE2
foreign graphic (StarView Graphic)
@ Graphic
OutlineText, special text object for StarDraw.
bool bVisible