1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/viewobjectcontactofsdrobj.hxx>
22 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
23 #include <svx/sdr/contact/objectcontact.hxx>
24 #include <svx/sdr/contact/displayinfo.hxx>
25 #include <svx/sdr/contact/objectcontactofpageview.hxx>
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>
37 namespace sdr::contact
{
39 const SdrObject
& ViewObjectContactOfSdrObj::getSdrObject() const
41 return static_cast< ViewContactOfSdrObj
& >(GetViewContact()).GetSdrObject();
44 ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact
& rObjectContact
, ViewContact
& rViewContact
)
45 : ViewObjectContact(rObjectContact
, rViewContact
)
49 ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
53 bool ViewObjectContactOfSdrObj::isPrimitiveVisibleOnAnyLayer(const SdrLayerIDSet
& aLayers
) const
55 return aLayers
.IsSet(getSdrObject().GetLayer());
58 bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo
& rDisplayInfo
) const
60 const SdrObject
& rObject
= getSdrObject();
62 // Test layer visibility
63 if(!isPrimitiveVisibleOnAnyLayer(rDisplayInfo
.GetProcessLayers()))
68 if(GetObjectContact().isOutputToPrinter() )
70 // Test if print output but not printable
71 if( !rObject
.IsPrintable())
76 // test is object is not visible on screen
77 if( !rObject
.IsVisible() )
81 // Test for hidden object on MasterPage
82 if(rDisplayInfo
.GetSubContentActive() && rObject
.IsNotVisibleAsMaster())
87 if (GetObjectContact().isOutputToPDFFile() && rObject
.isAnnotationObject())
90 // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
91 const SdrPageView
* pSdrPageView
= GetObjectContact().TryToGetSdrPageView();
95 const SdrView
& rSdrView
= pSdrPageView
->GetView();
96 const bool bHideOle(rSdrView
.getHideOle());
97 const bool bHideChart(rSdrView
.getHideChart());
98 const bool bHideDraw(rSdrView
.getHideDraw());
99 const bool bHideFormControl(rSdrView
.getHideFormControl());
101 if(bHideOle
|| bHideChart
|| bHideDraw
|| bHideFormControl
)
103 if(SdrObjKind::OLE2
== rObject
.GetObjIdentifier())
105 if(static_cast<const SdrOle2Obj
&>(rObject
).IsChart())
122 else if(SdrObjKind::Graphic
== rObject
.GetObjIdentifier())
124 // graphic handled like OLE
132 const bool bIsFormControl
= dynamic_cast< const FmFormObj
* >( &rObject
) != nullptr;
133 if(bIsFormControl
&& bHideFormControl
)
137 // any other draw object
138 if(!bIsFormControl
&& bHideDraw
)
146 // tdf#91260 check if the object is anchored on a different Writer page
147 // than the one being painted, and if so ignore it (Writer has only one
148 // SdrPage, so the part of the object that should be visible will be
149 // painted on the page where it is anchored)
150 // Note that we cannot check the ViewInformation2D ViewPort for this
151 // because it is only the part of the page that is currently visible.
152 basegfx::B2IPoint
const aAnchor(vcl::unotools::b2IPointFromPoint(getSdrObject().GetAnchorPos()));
153 if (aAnchor
.getX() || aAnchor
.getY()) // only Writer sets anchor position
155 if (!rDisplayInfo
.GetWriterPageFrame().isEmpty() &&
156 !rDisplayInfo
.GetWriterPageFrame().isInside(aAnchor
))
162 // Check if this object is in the visible range.
163 const drawinglayer::geometry::ViewInformation2D
& rViewInfo
= GetObjectContact().getViewInformation2D();
164 basegfx::B2DRange aObjRange
= GetViewContact().getRange(rViewInfo
);
165 if (!aObjRange
.isEmpty())
167 const basegfx::B2DRange
& rViewRange
= rViewInfo
.getViewport();
168 bool bVisible
= rViewRange
.isEmpty() || rViewRange
.overlaps(aObjRange
);
176 const OutputDevice
* ViewObjectContactOfSdrObj::getPageViewOutputDevice() const
178 ObjectContactOfPageView
* pPageViewContact
= dynamic_cast< ObjectContactOfPageView
* >( &GetObjectContact() );
179 if ( pPageViewContact
)
181 // if the PageWindow has a patched PaintWindow, use the original PaintWindow
182 // this ensures that our control is _not_ re-created just because somebody
183 // (temporarily) changed the window to paint onto.
184 // #i72429# / 2007-02-20 / frank.schoenheit (at) sun.com
185 SdrPageWindow
& rPageWindow( pPageViewContact
->GetPageWindow() );
186 if ( rPageWindow
.GetOriginalPaintWindow() )
187 return &rPageWindow
.GetOriginalPaintWindow()->GetOutputDevice();
189 return &rPageWindow
.GetPaintWindow().GetOutputDevice();
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */