Line data Source code
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 :
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 <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/svdview.hxx>
31 : #include <vcl/outdev.hxx>
32 :
33 : #include "fmobj.hxx"
34 :
35 : namespace sdr { namespace contact {
36 :
37 109342 : const SdrObject& ViewObjectContactOfSdrObj::getSdrObject() const
38 : {
39 109342 : return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
40 : }
41 :
42 20378 : ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
43 20378 : : ViewObjectContact(rObjectContact, rViewContact)
44 : {
45 20378 : }
46 :
47 31821 : ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
48 : {
49 31821 : }
50 :
51 48438 : bool ViewObjectContactOfSdrObj::isPrimitiveVisibleOnAnyLayer(const SetOfByte& aLayers) const
52 : {
53 48438 : return aLayers.IsSet(getSdrObject().GetLayer());
54 : }
55 :
56 54657 : bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
57 : {
58 54657 : const SdrObject& rObject = getSdrObject();
59 :
60 : // Test layer visibility
61 54657 : if(!isPrimitiveVisibleOnAnyLayer(rDisplayInfo.GetProcessLayers()))
62 : {
63 25023 : return false;
64 : }
65 :
66 29634 : if(GetObjectContact().isOutputToPrinter() )
67 : {
68 : // Test if print output but not printable
69 0 : if( !rObject.IsPrintable())
70 0 : return false;
71 : }
72 : else
73 : {
74 : // test is object is not visible on screen
75 29634 : if( !rObject.IsVisible() )
76 0 : return false;
77 : }
78 :
79 : // Test for hidden object on MasterPage
80 29634 : if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
81 : {
82 148 : return false;
83 : }
84 :
85 : // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
86 29486 : const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
87 :
88 29486 : if(pSdrPageView)
89 : {
90 27110 : const SdrView& rSdrView = pSdrPageView->GetView();
91 27110 : const bool bHideOle(rSdrView.getHideOle());
92 27110 : const bool bHideChart(rSdrView.getHideChart());
93 27110 : const bool bHideDraw(rSdrView.getHideDraw());
94 27110 : const bool bHideFormControl(rSdrView.getHideFormControl());
95 :
96 27110 : if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
97 : {
98 0 : if(OBJ_OLE2 == rObject.GetObjIdentifier())
99 : {
100 0 : if(static_cast<const SdrOle2Obj&>(rObject).IsChart())
101 : {
102 : // chart
103 0 : if(bHideChart)
104 : {
105 0 : return false;
106 : }
107 : }
108 : else
109 : {
110 : // OLE
111 0 : if(bHideOle)
112 : {
113 0 : return false;
114 : }
115 : }
116 : }
117 0 : else if(OBJ_GRAF == rObject.GetObjIdentifier())
118 : {
119 : // graphic handled like OLE
120 0 : if(bHideOle)
121 : {
122 0 : return false;
123 : }
124 : }
125 : else
126 : {
127 0 : const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0;
128 0 : if(bIsFormControl && bHideFormControl)
129 : {
130 0 : return false;
131 : }
132 : // any other draw object
133 0 : if(!bIsFormControl && bHideDraw)
134 : {
135 0 : return false;
136 : }
137 : }
138 : }
139 : }
140 :
141 29486 : return true;
142 : }
143 :
144 3074 : boost::optional<const OutputDevice&> ViewObjectContactOfSdrObj::getPageViewOutputDevice() const
145 : {
146 3074 : ObjectContactOfPageView* pPageViewContact = dynamic_cast< ObjectContactOfPageView* >( &GetObjectContact() );
147 3074 : if ( pPageViewContact )
148 : {
149 : // if the PageWindow has a patched PaintWindow, use the original PaintWindow
150 : // this ensures that our control is _not_ re-created just because somebody
151 : // (temporarily) changed the window to paint onto.
152 : // #i72429# / 2007-02-20 / frank.schoenheit (at) sun.com
153 3070 : SdrPageWindow& rPageWindow( pPageViewContact->GetPageWindow() );
154 3070 : if ( rPageWindow.GetOriginalPaintWindow() )
155 2595 : return rPageWindow.GetOriginalPaintWindow()->GetOutputDevice();
156 :
157 475 : return rPageWindow.GetPaintWindow().GetOutputDevice();
158 : }
159 4 : return boost::optional<const OutputDevice&>();
160 : }
161 :
162 651 : }}
163 :
164 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|