1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _BIB_DATMAN_HXX
29*cdf0e10cSrcweir #define _BIB_DATMAN_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/awt/XControlModel.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/sdbc/XResultSet.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/form/runtime/XFormController.hpp>
36*cdf0e10cSrcweir #include <cppuhelper/compbase2.hxx>
37*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
38*cdf0e10cSrcweir #include <com/sun/star/form/XLoadable.hpp>
39*cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx>
40*cdf0e10cSrcweir // #100312# --------------------
41*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
43*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir class Window;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir //-----------------------------------------------------------------------------
48*cdf0e10cSrcweir namespace bib
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 	class BibView;
51*cdf0e10cSrcweir 	// #100312# -----------
52*cdf0e10cSrcweir 	class BibBeamer;
53*cdf0e10cSrcweir }
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir class BibToolBar;
56*cdf0e10cSrcweir struct BibDBDescriptor;
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir // #100312# ---------------------
59*cdf0e10cSrcweir class BibInterceptorHelper
60*cdf0e10cSrcweir 	:public cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchProviderInterceptor >
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir private:
63*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xMasterDispatchProvider;
64*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xSlaveDispatchProvider;
65*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xFormDispatch;
66*cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir protected:
69*cdf0e10cSrcweir 	~BibInterceptorHelper( );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir public:
72*cdf0e10cSrcweir 	BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir 	void ReleaseInterceptor();
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir 	// XDispatchProvider
77*cdf0e10cSrcweir 	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);
78*cdf0e10cSrcweir     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);
79*cdf0e10cSrcweir 	// XDispatchProviderInterceptor
80*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
81*cdf0e10cSrcweir     virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
82*cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
83*cdf0e10cSrcweir     virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
84*cdf0e10cSrcweir };
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir typedef cppu::WeakComponentImplHelper2	<	::com::sun::star::beans::XPropertyChangeListener
87*cdf0e10cSrcweir 										,	::com::sun::star::form::XLoadable
88*cdf0e10cSrcweir 										>	BibDataManager_Base;
89*cdf0e10cSrcweir class BibDataManager
90*cdf0e10cSrcweir 			:public ::comphelper::OMutexAndBroadcastHelper
91*cdf0e10cSrcweir 			,public BibDataManager_Base
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir private:
94*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > 					    m_xForm;
95*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			    m_xGridModel;
96*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 			    m_xSourceProps;
97*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >   m_xParser;
98*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xFormCtrl;
99*cdf0e10cSrcweir         // #100312# -------------------
100*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >      m_xFormDispatch;
101*cdf0e10cSrcweir         BibInterceptorHelper* m_pInterceptorHelper;
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir         ::rtl::OUString                     aActiveDataTable;
104*cdf0e10cSrcweir 		::rtl::OUString						aDataSourceURL;
105*cdf0e10cSrcweir 		::rtl::OUString						aQuoteChar;
106*cdf0e10cSrcweir 		::com::sun::star::uno::Any						aUID;
107*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > 				xBibCursor;
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir 		::cppu::OInterfaceContainerHelper	m_aLoadListeners;
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 		::bib::BibView* 			pBibView;
112*cdf0e10cSrcweir 		BibToolBar*					pToolbar;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir 		rtl::OUString 				sIdentifierMapping;
115*cdf0e10cSrcweir protected:
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 		void						InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
118*cdf0e10cSrcweir 		void						SetMeAsUidListener();
119*cdf0e10cSrcweir 		void						RemoveMeAsUidListener();
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir 		void						UpdateAddressbookCursor(::rtl::OUString aSourceName);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
124*cdf0e10cSrcweir 									updateGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm);
125*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
126*cdf0e10cSrcweir 									createGridModel( const ::rtl::OUString& rName );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 		// XLoadable
129*cdf0e10cSrcweir 		virtual void SAL_CALL load(  ) throw (::com::sun::star::uno::RuntimeException);
130*cdf0e10cSrcweir 		virtual void SAL_CALL unload(  ) throw (::com::sun::star::uno::RuntimeException);
131*cdf0e10cSrcweir 		virtual void SAL_CALL reload(  ) throw (::com::sun::star::uno::RuntimeException);
132*cdf0e10cSrcweir 		virtual sal_Bool SAL_CALL isLoaded(  ) throw (::com::sun::star::uno::RuntimeException);
133*cdf0e10cSrcweir 		virtual void SAL_CALL addLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
134*cdf0e10cSrcweir 		virtual void SAL_CALL removeLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir         virtual void SAL_CALL disposing();
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir public:
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 		BibDataManager();
141*cdf0e10cSrcweir 		~BibDataManager();
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir 		virtual void				SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
144*cdf0e10cSrcweir 																throw( ::com::sun::star::uno::RuntimeException );
145*cdf0e10cSrcweir 		virtual void 				SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
146*cdf0e10cSrcweir 																throw( ::com::sun::star::uno::RuntimeException );
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > 					createDatabaseForm(	BibDBDescriptor&	aDesc);
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			updateGridModel();
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::rtl::OUString>			getDataSources();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 		::rtl::OUString				getActiveDataSource() {return aDataSourceURL;}
157*cdf0e10cSrcweir 		void						setActiveDataSource(const ::rtl::OUString& rURL);
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		::rtl::OUString				getActiveDataTable();
160*cdf0e10cSrcweir 		void						setActiveDataTable(const ::rtl::OUString& rTable);
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 		void						setFilter(const ::rtl::OUString& rQuery);
163*cdf0e10cSrcweir 		::rtl::OUString						getFilter();
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::rtl::OUString>			getQueryFields();
166*cdf0e10cSrcweir 		::rtl::OUString						getQueryField();
167*cdf0e10cSrcweir 		void						startQueryWith(const ::rtl::OUString& rQuery);
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >&    getParser()	{ return m_xParser; }
170*cdf0e10cSrcweir 		const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& 					    getForm()	{ return m_xForm; }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 		::rtl::OUString						getControlName(sal_Int32 nFormatKey );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 		::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > 			loadControlModel(const ::rtl::OUString& rName,
176*cdf0e10cSrcweir 														sal_Bool bForceListBox = sal_False);
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 		void						CreateMappingDialog(Window* pParent);
179*cdf0e10cSrcweir         ::rtl::OUString             CreateDBChangeDialog(Window* pParent);
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         void                        DispatchDBChangeDialog();
182*cdf0e10cSrcweir         sal_Bool                    HasActiveConnection() const;
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir 		void						SetView( ::bib::BibView* pView ) { pBibView = pView; }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 		void						SetToolbar(BibToolBar* pSet);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 		const rtl::OUString&		GetIdentifierMapping();
189*cdf0e10cSrcweir 		void						ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();}
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController();
192*cdf0e10cSrcweir         // #100312# ----------
193*cdf0e10cSrcweir         void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer);
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         sal_Bool                    HasActiveConnection();
196*cdf0e10cSrcweir };
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir #endif
200