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 #ifndef CHART_CHARTDOCUMENTWRAPPER_HXX
24 #define CHART_CHARTDOCUMENTWRAPPER_HXX
25 
26 #include "WrappedPropertySet.hxx"
27 //#include "OPropertySet.hxx"
28 #include "ServiceMacros.hxx"
29 #include <com/sun/star/chart2/XChartDocument.hpp>
30 #include <com/sun/star/chart/XChartDocument.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #include <com/sun/star/uno/XAggregation.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/util/XRefreshable.hpp>
37 #include <cppuhelper/implbase5.hxx>
38 #include <osl/mutex.hxx>
39 #include <unotools/eventlisteneradapter.hxx>
40 #include <comphelper/uno3.hxx>
41 
42 #include <boost/shared_ptr.hpp>
43 
44 namespace chart
45 {
46 
47 namespace wrapper
48 {
49 
50 class Chart2ModelContact;
51 
52 class ChartDocumentWrapper_Base : public ::cppu::ImplInheritanceHelper5
53                                 < WrappedPropertySet
54                                 , ::com::sun::star::chart::XChartDocument
55                                 , ::com::sun::star::drawing::XDrawPageSupplier
56                                 , ::com::sun::star::lang::XMultiServiceFactory
57                                 , ::com::sun::star::lang::XServiceInfo
58                                 , ::com::sun::star::uno::XAggregation
59                                 >
60 {
61 };
62 
63 class ChartDocumentWrapper : public ChartDocumentWrapper_Base
64                            , public ::utl::OEventListenerAdapter
65 {
66 public:
67 	explicit ChartDocumentWrapper(
68         const ::com::sun::star::uno::Reference<
69             ::com::sun::star::uno::XComponentContext > & xContext );
70 	virtual ~ChartDocumentWrapper();
71 
72     /// XServiceInfo declarations
73     APPHELPER_XSERVICEINFO_DECL()
74     APPHELPER_SERVICE_FACTORY_HELPER(ChartDocumentWrapper)
75 
76     void setAddIn( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable >& xAddIn );
77     ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable > getAddIn() const;
78 
79     void setUpdateAddIn( sal_Bool bUpdateAddIn );
80     sal_Bool getUpdateAddIn() const;
81 
82     void setBaseDiagram( const rtl::OUString& rBaseDiagram );
83     rtl::OUString getBaseDiagram() const;
84 
85     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getAdditionalShapes() const;
86 
87     ::com::sun::star::uno::Reference<
88             ::com::sun::star::drawing::XDrawPage > impl_getDrawPage() const
89         throw (::com::sun::star::uno::RuntimeException);
90 
91 protected:
92 
93     // ____ chart::XChartDocument ____
94     virtual ::com::sun::star::uno::Reference<
95         ::com::sun::star::drawing::XShape > SAL_CALL getTitle()
96         throw (::com::sun::star::uno::RuntimeException);
97     virtual ::com::sun::star::uno::Reference<
98         ::com::sun::star::drawing::XShape > SAL_CALL getSubTitle()
99         throw (::com::sun::star::uno::RuntimeException);
100     virtual ::com::sun::star::uno::Reference<
101         ::com::sun::star::drawing::XShape > SAL_CALL getLegend()
102         throw (::com::sun::star::uno::RuntimeException);
103     virtual ::com::sun::star::uno::Reference<
104         ::com::sun::star::beans::XPropertySet > SAL_CALL getArea()
105         throw (::com::sun::star::uno::RuntimeException);
106     virtual ::com::sun::star::uno::Reference<
107         ::com::sun::star::chart::XDiagram > SAL_CALL getDiagram()
108         throw (::com::sun::star::uno::RuntimeException);
109     virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference<
110                                       ::com::sun::star::chart::XDiagram >& xDiagram )
111         throw (::com::sun::star::uno::RuntimeException);
112     virtual ::com::sun::star::uno::Reference<
113         ::com::sun::star::chart::XChartData > SAL_CALL getData()
114         throw (::com::sun::star::uno::RuntimeException);
115     virtual void SAL_CALL attachData( const ::com::sun::star::uno::Reference<
116                                       ::com::sun::star::chart::XChartData >& xData )
117         throw (::com::sun::star::uno::RuntimeException);
118 
119     // ____ XModel ____
120     virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& URL, const ::com::sun::star::uno::Sequence<
121                                               ::com::sun::star::beans::PropertyValue >& Arguments )
122         throw (::com::sun::star::uno::RuntimeException);
123     virtual ::rtl::OUString SAL_CALL getURL()
124         throw (::com::sun::star::uno::RuntimeException);
125     virtual ::com::sun::star::uno::Sequence<
126         ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs()
127         throw (::com::sun::star::uno::RuntimeException);
128     virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference<
129                                              ::com::sun::star::frame::XController >& Controller )
130         throw (::com::sun::star::uno::RuntimeException);
131     virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference<
132                                                 ::com::sun::star::frame::XController >& Controller )
133         throw (::com::sun::star::uno::RuntimeException);
134     virtual void SAL_CALL lockControllers()
135         throw (::com::sun::star::uno::RuntimeException);
136     virtual void SAL_CALL unlockControllers()
137         throw (::com::sun::star::uno::RuntimeException);
138     virtual sal_Bool SAL_CALL hasControllersLocked()
139         throw (::com::sun::star::uno::RuntimeException);
140     virtual ::com::sun::star::uno::Reference<
141         ::com::sun::star::frame::XController > SAL_CALL getCurrentController()
142         throw (::com::sun::star::uno::RuntimeException);
143     virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference<
144                                                 ::com::sun::star::frame::XController >& Controller )
145         throw (::com::sun::star::container::NoSuchElementException,
146                ::com::sun::star::uno::RuntimeException);
147     virtual ::com::sun::star::uno::Reference<
148         ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection()
149         throw (::com::sun::star::uno::RuntimeException);
150 
151     // ____ XComponent ____
152     virtual void SAL_CALL dispose()
153         throw (::com::sun::star::uno::RuntimeException);
154     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference<
155                                             ::com::sun::star::lang::XEventListener >& xListener )
156         throw (::com::sun::star::uno::RuntimeException);
157     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference<
158                                                ::com::sun::star::lang::XEventListener >& aListener )
159         throw (::com::sun::star::uno::RuntimeException);
160 
161     // ____ XInterface (for new interfaces) ____
162     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
163         throw (::com::sun::star::uno::RuntimeException);
164 
165     // ____ ::utl::OEventListenerAdapter ____
166     virtual void _disposing( const ::com::sun::star::lang::EventObject& rSource );
167 
168     // ____ XDrawPageSupplier ____
169     virtual ::com::sun::star::uno::Reference<
170             ::com::sun::star::drawing::XDrawPage > SAL_CALL getDrawPage()
171         throw (::com::sun::star::uno::RuntimeException);
172 
173     // ____ XMultiServiceFactory ____
174     virtual ::com::sun::star::uno::Reference<
175             ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier )
176         throw (::com::sun::star::uno::Exception,
177                ::com::sun::star::uno::RuntimeException);
178     virtual ::com::sun::star::uno::Reference<
179             ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(
180                 const ::rtl::OUString& ServiceSpecifier,
181                 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments )
182         throw (::com::sun::star::uno::Exception,
183                ::com::sun::star::uno::RuntimeException);
184     virtual ::com::sun::star::uno::Sequence<
185             ::rtl::OUString > SAL_CALL getAvailableServiceNames()
186         throw (::com::sun::star::uno::RuntimeException);
187 
188     // ____ XAggregation ____
189     virtual void SAL_CALL setDelegator(
190         const ::com::sun::star::uno::Reference<
191             ::com::sun::star::uno::XInterface >& rDelegator )
192         throw (::com::sun::star::uno::RuntimeException);
193     virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType )
194         throw (::com::sun::star::uno::RuntimeException);
195 
196     // ____ WrappedPropertySet ____
197     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence();
198     virtual const std::vector< WrappedProperty* > createWrappedProperties();
199     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet();
200 
201 private: //methods
202     void impl_resetAddIn();
203 
204 private: //member
205     ::boost::shared_ptr< Chart2ModelContact >   m_spChart2ModelContact;
206 
207     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   m_xDelegator;
208 
209     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >   m_xTitle;
210     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >   m_xSubTitle;
211     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >   m_xLegend;
212     ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartData > m_xChartData;
213     ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram >   m_xDiagram;
214     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xArea;
215 
216     ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable > m_xAddIn;
217     rtl::OUString   m_aBaseDiagram;
218     sal_Bool        m_bUpdateAddIn;
219 
220     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   m_xChartView;
221     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>
222 			                                                                m_xShapeFactory;
223 
224     bool                                                                    m_bIsDisposed;
225 };
226 
227 } //  namespace wrapper
228 } //  namespace chart
229 
230 // CHART_CHARTDOCUMENT_HXX
231 #endif
232