1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef _BIB_DATMAN_HXX
29 #define _BIB_DATMAN_HXX
31 #include <com/sun/star/awt/XControlModel.hpp>
32 #include <com/sun/star/form/XForm.hpp>
33 #include <com/sun/star/sdbc/XResultSet.hpp>
34 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
35 #include <com/sun/star/form/runtime/XFormController.hpp>
36 #include <cppuhelper/compbase2.hxx>
37 #include <cppuhelper/interfacecontainer.h>
38 #include <com/sun/star/form/XLoadable.hpp>
39 #include <comphelper/broadcasthelper.hxx>
40 // #100312# --------------------
41 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
42 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
43 #include <cppuhelper/implbase1.hxx>
47 //-----------------------------------------------------------------------------
51 // #100312# -----------
56 struct BibDBDescriptor
;
58 // #100312# ---------------------
59 class BibInterceptorHelper
60 :public cppu::WeakImplHelper1
< ::com::sun::star::frame::XDispatchProviderInterceptor
>
63 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
> xMasterDispatchProvider
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
> xSlaveDispatchProvider
;
65 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xFormDispatch
;
66 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProviderInterception
> xInterception
;
69 ~BibInterceptorHelper( );
72 BibInterceptorHelper( ::bib::BibBeamer
* pBibBeamer
, ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xDispatch
);
74 void ReleaseInterceptor();
77 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 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 // XDispatchProviderInterceptor
80 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
> SAL_CALL
getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException
);
81 virtual void SAL_CALL
setSlaveDispatchProvider( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xNewSlaveDispatchProvider
) throw (::com::sun::star::uno::RuntimeException
);
82 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
> SAL_CALL
getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException
);
83 virtual void SAL_CALL
setMasterDispatchProvider( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatchProvider
>& xNewMasterDispatchProvider
) throw (::com::sun::star::uno::RuntimeException
);
86 typedef cppu::WeakComponentImplHelper2
< ::com::sun::star::beans::XPropertyChangeListener
87 , ::com::sun::star::form::XLoadable
88 > BibDataManager_Base
;
90 :public ::comphelper::OMutexAndBroadcastHelper
91 ,public BibDataManager_Base
94 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> m_xForm
;
95 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> m_xGridModel
;
96 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> m_xSourceProps
;
97 ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XSingleSelectQueryComposer
> m_xParser
;
98 ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> m_xFormCtrl
;
99 // #100312# -------------------
100 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> m_xFormDispatch
;
101 BibInterceptorHelper
* m_pInterceptorHelper
;
103 ::rtl::OUString aActiveDataTable
;
104 ::rtl::OUString aDataSourceURL
;
105 ::rtl::OUString aQuoteChar
;
106 ::com::sun::star::uno::Any aUID
;
107 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
> xBibCursor
;
109 ::cppu::OInterfaceContainerHelper m_aLoadListeners
;
111 ::bib::BibView
* pBibView
;
112 BibToolBar
* pToolbar
;
114 rtl::OUString sIdentifierMapping
;
117 void InsertFields(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XFormComponent
> & xGrid
);
118 void SetMeAsUidListener();
119 void RemoveMeAsUidListener();
121 void UpdateAddressbookCursor(::rtl::OUString aSourceName
);
123 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>
124 updateGridModel(const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> & xDbForm
);
125 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
>
126 createGridModel( const ::rtl::OUString
& rName
);
129 virtual void SAL_CALL
load( ) throw (::com::sun::star::uno::RuntimeException
);
130 virtual void SAL_CALL
unload( ) throw (::com::sun::star::uno::RuntimeException
);
131 virtual void SAL_CALL
reload( ) throw (::com::sun::star::uno::RuntimeException
);
132 virtual sal_Bool SAL_CALL
isLoaded( ) throw (::com::sun::star::uno::RuntimeException
);
133 virtual void SAL_CALL
addLoadListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XLoadListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
134 virtual void SAL_CALL
removeLoadListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XLoadListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
136 virtual void SAL_CALL
disposing();
143 virtual void SAL_CALL
propertyChange(const ::com::sun::star::beans::PropertyChangeEvent
& evt
)
144 throw( ::com::sun::star::uno::RuntimeException
);
145 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
)
146 throw( ::com::sun::star::uno::RuntimeException
);
150 ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
> createDatabaseForm( BibDBDescriptor
& aDesc
);
152 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> updateGridModel();
154 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getDataSources();
156 ::rtl::OUString
getActiveDataSource() {return aDataSourceURL
;}
157 void setActiveDataSource(const ::rtl::OUString
& rURL
);
159 ::rtl::OUString
getActiveDataTable();
160 void setActiveDataTable(const ::rtl::OUString
& rTable
);
162 void setFilter(const ::rtl::OUString
& rQuery
);
163 ::rtl::OUString
getFilter();
165 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getQueryFields();
166 ::rtl::OUString
getQueryField();
167 void startQueryWith(const ::rtl::OUString
& rQuery
);
169 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdb::XSingleSelectQueryComposer
>& getParser() { return m_xParser
; }
170 const ::com::sun::star::uno::Reference
< ::com::sun::star::form::XForm
>& getForm() { return m_xForm
; }
173 ::rtl::OUString
getControlName(sal_Int32 nFormatKey
);
175 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControlModel
> loadControlModel(const ::rtl::OUString
& rName
,
176 sal_Bool bForceListBox
= sal_False
);
178 void CreateMappingDialog(Window
* pParent
);
179 ::rtl::OUString
CreateDBChangeDialog(Window
* pParent
);
181 void DispatchDBChangeDialog();
182 sal_Bool
HasActiveConnection() const;
184 void SetView( ::bib::BibView
* pView
) { pBibView
= pView
; }
186 void SetToolbar(BibToolBar
* pSet
);
188 const rtl::OUString
& GetIdentifierMapping();
189 void ResetIdentifierMapping() {sIdentifierMapping
= rtl::OUString();}
191 ::com::sun::star::uno::Reference
< ::com::sun::star::form::runtime::XFormController
> GetFormController();
192 // #100312# ----------
193 void RegisterInterceptor( ::bib::BibBeamer
* pBibBeamer
);
195 sal_Bool
HasActiveConnection();