1*46dbaceeSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*46dbaceeSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*46dbaceeSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*46dbaceeSAndrew Rist  * distributed with this work for additional information
6*46dbaceeSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*46dbaceeSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*46dbaceeSAndrew Rist  * "License"); you may not use this file except in compliance
9*46dbaceeSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*46dbaceeSAndrew Rist  *
11*46dbaceeSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*46dbaceeSAndrew Rist  *
13*46dbaceeSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*46dbaceeSAndrew Rist  * software distributed under the License is distributed on an
15*46dbaceeSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*46dbaceeSAndrew Rist  * KIND, either express or implied.  See the License for the
17*46dbaceeSAndrew Rist  * specific language governing permissions and limitations
18*46dbaceeSAndrew Rist  * under the License.
19*46dbaceeSAndrew Rist  *
20*46dbaceeSAndrew Rist  *************************************************************/
21*46dbaceeSAndrew Rist 
22*46dbaceeSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _BIB_DATMAN_HXX
25cdf0e10cSrcweir #define _BIB_DATMAN_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
28cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
29cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
30cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
31cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormController.hpp>
32cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
33cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
34cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp>
35cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
36cdf0e10cSrcweir // #100312# --------------------
37cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
38cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
39cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class Window;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //-----------------------------------------------------------------------------
44cdf0e10cSrcweir namespace bib
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	class BibView;
47cdf0e10cSrcweir 	// #100312# -----------
48cdf0e10cSrcweir 	class BibBeamer;
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class BibToolBar;
52cdf0e10cSrcweir struct BibDBDescriptor;
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // #100312# ---------------------
55cdf0e10cSrcweir class BibInterceptorHelper
56cdf0e10cSrcweir 	:public cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchProviderInterceptor >
57cdf0e10cSrcweir {
58cdf0e10cSrcweir private:
59cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xMasterDispatchProvider;
60cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xSlaveDispatchProvider;
61cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xFormDispatch;
62cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir protected:
65cdf0e10cSrcweir 	~BibInterceptorHelper( );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir public:
68cdf0e10cSrcweir 	BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	void ReleaseInterceptor();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// XDispatchProvider
73cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir 	// XDispatchProviderInterceptor
76cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir     virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
78cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
79cdf0e10cSrcweir     virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir };
81cdf0e10cSrcweir 
82cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper2	<	::com::sun::star::beans::XPropertyChangeListener
83cdf0e10cSrcweir 										,	::com::sun::star::form::XLoadable
84cdf0e10cSrcweir 										>	BibDataManager_Base;
85cdf0e10cSrcweir class BibDataManager
86cdf0e10cSrcweir 			:public ::comphelper::OMutexAndBroadcastHelper
87cdf0e10cSrcweir 			,public BibDataManager_Base
88cdf0e10cSrcweir {
89cdf0e10cSrcweir private:
90cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > 					    m_xForm;
91cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			    m_xGridModel;
92cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 			    m_xSourceProps;
93cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >   m_xParser;
94cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xFormCtrl;
95cdf0e10cSrcweir         // #100312# -------------------
96cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >      m_xFormDispatch;
97cdf0e10cSrcweir         BibInterceptorHelper* m_pInterceptorHelper;
98cdf0e10cSrcweir 
99cdf0e10cSrcweir         ::rtl::OUString                     aActiveDataTable;
100cdf0e10cSrcweir 		::rtl::OUString						aDataSourceURL;
101cdf0e10cSrcweir 		::rtl::OUString						aQuoteChar;
102cdf0e10cSrcweir 		::com::sun::star::uno::Any						aUID;
103cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > 				xBibCursor;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 		::cppu::OInterfaceContainerHelper	m_aLoadListeners;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		::bib::BibView* 			pBibView;
108cdf0e10cSrcweir 		BibToolBar*					pToolbar;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		rtl::OUString 				sIdentifierMapping;
111cdf0e10cSrcweir protected:
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 		void						InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
114cdf0e10cSrcweir 		void						SetMeAsUidListener();
115cdf0e10cSrcweir 		void						RemoveMeAsUidListener();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 		void						UpdateAddressbookCursor(::rtl::OUString aSourceName);
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
120cdf0e10cSrcweir 									updateGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm);
121cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
122cdf0e10cSrcweir 									createGridModel( const ::rtl::OUString& rName );
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 		// XLoadable
125cdf0e10cSrcweir 		virtual void SAL_CALL load(  ) throw (::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir 		virtual void SAL_CALL unload(  ) throw (::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir 		virtual void SAL_CALL reload(  ) throw (::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL isLoaded(  ) throw (::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 		virtual void SAL_CALL addLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
130cdf0e10cSrcweir 		virtual void SAL_CALL removeLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
131cdf0e10cSrcweir 
132cdf0e10cSrcweir         virtual void SAL_CALL disposing();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir public:
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		BibDataManager();
137cdf0e10cSrcweir 		~BibDataManager();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		virtual void				SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
140cdf0e10cSrcweir 																throw( ::com::sun::star::uno::RuntimeException );
141cdf0e10cSrcweir 		virtual void 				SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
142cdf0e10cSrcweir 																throw( ::com::sun::star::uno::RuntimeException );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 
146cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > 					createDatabaseForm(	BibDBDescriptor&	aDesc);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			updateGridModel();
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::rtl::OUString>			getDataSources();
151cdf0e10cSrcweir 
getActiveDataSource()152cdf0e10cSrcweir 		::rtl::OUString				getActiveDataSource() {return aDataSourceURL;}
153cdf0e10cSrcweir 		void						setActiveDataSource(const ::rtl::OUString& rURL);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		::rtl::OUString				getActiveDataTable();
156cdf0e10cSrcweir 		void						setActiveDataTable(const ::rtl::OUString& rTable);
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 		void						setFilter(const ::rtl::OUString& rQuery);
159cdf0e10cSrcweir 		::rtl::OUString						getFilter();
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::rtl::OUString>			getQueryFields();
162cdf0e10cSrcweir 		::rtl::OUString						getQueryField();
163cdf0e10cSrcweir 		void						startQueryWith(const ::rtl::OUString& rQuery);
164cdf0e10cSrcweir 
getParser()165cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >&    getParser()	{ return m_xParser; }
getForm()166cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& 					    getForm()	{ return m_xForm; }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 		::rtl::OUString						getControlName(sal_Int32 nFormatKey );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			loadControlModel(const ::rtl::OUString& rName,
172cdf0e10cSrcweir 														sal_Bool bForceListBox = sal_False);
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		void						CreateMappingDialog(Window* pParent);
175cdf0e10cSrcweir         ::rtl::OUString             CreateDBChangeDialog(Window* pParent);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir         void                        DispatchDBChangeDialog();
178cdf0e10cSrcweir         sal_Bool                    HasActiveConnection() const;
179cdf0e10cSrcweir 
SetView(::bib::BibView * pView)180cdf0e10cSrcweir 		void						SetView( ::bib::BibView* pView ) { pBibView = pView; }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 		void						SetToolbar(BibToolBar* pSet);
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 		const rtl::OUString&		GetIdentifierMapping();
ResetIdentifierMapping()185cdf0e10cSrcweir 		void						ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();}
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController();
188cdf0e10cSrcweir         // #100312# ----------
189cdf0e10cSrcweir         void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir         sal_Bool                    HasActiveConnection();
192cdf0e10cSrcweir };
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 
195cdf0e10cSrcweir #endif
196