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