1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
28 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
29 #include <svx/sdr/contact/objectcontact.hxx>
30 #include <svx/sdr/contact/displayinfo.hxx>
31 #include <svx/svdobj.hxx>
32 #include <svx/svdoole2.hxx>
33 #include <svx/svdview.hxx>
34 
35 #include "fmobj.hxx"
36 
37 //////////////////////////////////////////////////////////////////////////////
38 
39 namespace sdr
40 {
41 	namespace contact
42 	{
43 		const SdrObject& ViewObjectContactOfSdrObj::getSdrObject() const
44 		{
45 			return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
46 		}
47 
48 		ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
49 		:	ViewObjectContact(rObjectContact, rViewContact)
50 		{
51 		}
52 
53 		ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
54 		{
55 		}
56 
57 		bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
58 		{
59 			const SdrObject& rObject = getSdrObject();
60 
61 			// Test layer visibility
62 			if(!rDisplayInfo.GetProcessLayers().IsSet(rObject.GetLayer()))
63 			{
64 				return false;
65 			}
66 
67 			if(GetObjectContact().isOutputToPrinter() )
68 			{
69 				// Test if print output but not printable
70 				if( !rObject.IsPrintable())
71 					return false;
72 			}
73 			else
74 			{
75 				// test is object is not visible on screen
76 				if( !rObject.IsVisible() )
77 					return false;
78 			}
79 
80 			// Test for hidden object on MasterPage
81 			if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
82 			{
83 				return false;
84 			}
85 
86             // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
87             const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
88 
89             if(pSdrPageView)
90             {
91             	const SdrView& rSdrView = pSdrPageView->GetView();
92                 const bool bHideOle(rSdrView.getHideOle());
93 			    const bool bHideChart(rSdrView.getHideChart());
94 			    const bool bHideDraw(rSdrView.getHideDraw());
95                 const bool bHideFormControl(rSdrView.getHideFormControl());
96 
97                 if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
98 			    {
99 				    if(OBJ_OLE2 == rObject.GetObjIdentifier())
100 				    {
101 					    if(((SdrOle2Obj&)rObject).IsChart())
102 					    {
103 						    // chart
104 						    if(bHideChart)
105 						    {
106 							    return false;
107 						    }
108 					    }
109 					    else
110 					    {
111 						    // OLE
112 						    if(bHideOle)
113 						    {
114 							    return false;
115 						    }
116 					    }
117 				    }
118 				    else if(OBJ_GRAF == rObject.GetObjIdentifier())
119 				    {
120 					    // graphic handled like OLE
121 					    if(bHideOle)
122 					    {
123 						    return false;
124 					    }
125 				    }
126 				    else
127 				    {
128                         const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0;
129                         if(bIsFormControl && bHideFormControl)
130                         {
131                             return false;
132                         }
133 					    // any other draw object
134                         if(!bIsFormControl && bHideDraw)
135 					    {
136 						    return false;
137 					    }
138 				    }
139                 }
140             }
141 
142 			return true;
143 		}
144 	} // end of namespace contact
145 } // end of namespace sdr
146 
147 //////////////////////////////////////////////////////////////////////////////
148 // eof
149