xref: /trunk/main/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx>
32 #include <svx/sdr/contact/viewcontactofsdrobj.hxx>
33 #include <svx/sdr/contact/objectcontact.hxx>
34 #include <svx/sdr/contact/displayinfo.hxx>
35 #include <svx/svdobj.hxx>
36 #include <svx/svdoole2.hxx>
37 #include <svx/svdview.hxx>
38 
39 #include "fmobj.hxx"
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace sdr
44 {
45     namespace contact
46     {
47         const SdrObject& ViewObjectContactOfSdrObj::getSdrObject() const
48         {
49             return static_cast< ViewContactOfSdrObj& >(GetViewContact()).GetSdrObject();
50         }
51 
52         ViewObjectContactOfSdrObj::ViewObjectContactOfSdrObj(ObjectContact& rObjectContact, ViewContact& rViewContact)
53         :   ViewObjectContact(rObjectContact, rViewContact)
54         {
55         }
56 
57         ViewObjectContactOfSdrObj::~ViewObjectContactOfSdrObj()
58         {
59         }
60 
61         bool ViewObjectContactOfSdrObj::isPrimitiveVisible(const DisplayInfo& rDisplayInfo) const
62         {
63             const SdrObject& rObject = getSdrObject();
64 
65             // Test layer visibility
66             if(!rDisplayInfo.GetProcessLayers().IsSet(rObject.GetLayer()))
67             {
68                 return false;
69             }
70 
71             if(GetObjectContact().isOutputToPrinter() )
72             {
73                 // Test if print output but not printable
74                 if( !rObject.IsPrintable())
75                     return false;
76             }
77             else
78             {
79                 // test is object is not visible on screen
80                 if( !rObject.IsVisible() )
81                     return false;
82             }
83 
84             // Test for hidden object on MasterPage
85             if(rDisplayInfo.GetSubContentActive() && rObject.IsNotVisibleAsMaster())
86             {
87                 return false;
88             }
89 
90             // Test for Calc object hiding (for OLE and Graphic it's extra, see there)
91             const SdrPageView* pSdrPageView = GetObjectContact().TryToGetSdrPageView();
92 
93             if(pSdrPageView)
94             {
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());
100 
101                 if(bHideOle || bHideChart || bHideDraw || bHideFormControl)
102                 {
103                     if(OBJ_OLE2 == rObject.GetObjIdentifier())
104                     {
105                         if(((SdrOle2Obj&)rObject).IsChart())
106                         {
107                             // chart
108                             if(bHideChart)
109                             {
110                                 return false;
111                             }
112                         }
113                         else
114                         {
115                             // OLE
116                             if(bHideOle)
117                             {
118                                 return false;
119                             }
120                         }
121                     }
122                     else if(OBJ_GRAF == rObject.GetObjIdentifier())
123                     {
124                         // graphic handled like OLE
125                         if(bHideOle)
126                         {
127                             return false;
128                         }
129                     }
130                     else
131                     {
132                         const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0;
133                         if(bIsFormControl && bHideFormControl)
134                         {
135                             return false;
136                         }
137                         // any other draw object
138                         if(!bIsFormControl && bHideDraw)
139                         {
140                             return false;
141                         }
142                     }
143                 }
144             }
145 
146             return true;
147         }
148     } // end of namespace contact
149 } // end of namespace sdr
150 
151 //////////////////////////////////////////////////////////////////////////////
152 // eof
153