xref: /AOO41X/main/extensions/source/bibliography/datman.hxx (revision 46dbaceef8c12a09e4905feda473ecab36e10d03)
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 
24 #ifndef _BIB_DATMAN_HXX
25 #define _BIB_DATMAN_HXX
26 
27 #include <com/sun/star/awt/XControlModel.hpp>
28 #include <com/sun/star/form/XForm.hpp>
29 #include <com/sun/star/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
31 #include <com/sun/star/form/runtime/XFormController.hpp>
32 #include <cppuhelper/compbase2.hxx>
33 #include <cppuhelper/interfacecontainer.h>
34 #include <com/sun/star/form/XLoadable.hpp>
35 #include <comphelper/broadcasthelper.hxx>
36 // #100312# --------------------
37 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
38 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
39 #include <cppuhelper/implbase1.hxx>
40 
41 class Window;
42 
43 //-----------------------------------------------------------------------------
44 namespace bib
45 {
46     class BibView;
47     // #100312# -----------
48     class BibBeamer;
49 }
50 
51 class BibToolBar;
52 struct BibDBDescriptor;
53 
54 // #100312# ---------------------
55 class BibInterceptorHelper
56     :public cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchProviderInterceptor >
57 {
58 private:
59     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xMasterDispatchProvider;
60     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xSlaveDispatchProvider;
61     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xFormDispatch;
62     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception;
63 
64 protected:
65     ~BibInterceptorHelper( );
66 
67 public:
68     BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch);
69 
70     void ReleaseInterceptor();
71 
72     // XDispatchProvider
73     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);
74     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);
75     // XDispatchProviderInterceptor
76     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
77     virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
78     virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider(  ) throw (::com::sun::star::uno::RuntimeException);
79     virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
80 };
81 
82 typedef cppu::WeakComponentImplHelper2  <   ::com::sun::star::beans::XPropertyChangeListener
83                                         ,   ::com::sun::star::form::XLoadable
84                                         >   BibDataManager_Base;
85 class BibDataManager
86             :public ::comphelper::OMutexAndBroadcastHelper
87             ,public BibDataManager_Base
88 {
89 private:
90         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >                       m_xForm;
91         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >                m_xGridModel;
92         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >               m_xSourceProps;
93         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >   m_xParser;
94         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >    m_xFormCtrl;
95         // #100312# -------------------
96         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >      m_xFormDispatch;
97         BibInterceptorHelper* m_pInterceptorHelper;
98 
99         ::rtl::OUString                     aActiveDataTable;
100         ::rtl::OUString                     aDataSourceURL;
101         ::rtl::OUString                     aQuoteChar;
102         ::com::sun::star::uno::Any                      aUID;
103         ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >              xBibCursor;
104 
105         ::cppu::OInterfaceContainerHelper   m_aLoadListeners;
106 
107         ::bib::BibView*             pBibView;
108         BibToolBar*                 pToolbar;
109 
110         rtl::OUString               sIdentifierMapping;
111 protected:
112 
113         void                        InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
114         void                        SetMeAsUidListener();
115         void                        RemoveMeAsUidListener();
116 
117         void                        UpdateAddressbookCursor(::rtl::OUString aSourceName);
118 
119         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
120                                     updateGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm);
121         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
122                                     createGridModel( const ::rtl::OUString& rName );
123 
124         // XLoadable
125         virtual void SAL_CALL load(  ) throw (::com::sun::star::uno::RuntimeException);
126         virtual void SAL_CALL unload(  ) throw (::com::sun::star::uno::RuntimeException);
127         virtual void SAL_CALL reload(  ) throw (::com::sun::star::uno::RuntimeException);
128         virtual sal_Bool SAL_CALL isLoaded(  ) throw (::com::sun::star::uno::RuntimeException);
129         virtual void SAL_CALL addLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
130         virtual void SAL_CALL removeLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
131 
132         virtual void SAL_CALL disposing();
133 
134 public:
135 
136         BibDataManager();
137         ~BibDataManager();
138 
139         virtual void                SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
140                                                                 throw( ::com::sun::star::uno::RuntimeException );
141         virtual void                SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
142                                                                 throw( ::com::sun::star::uno::RuntimeException );
143 
144 
145 
146         ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >                   createDatabaseForm( BibDBDescriptor&    aDesc);
147 
148         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >            updateGridModel();
149 
150         ::com::sun::star::uno::Sequence< ::rtl::OUString>           getDataSources();
151 
getActiveDataSource()152         ::rtl::OUString             getActiveDataSource() {return aDataSourceURL;}
153         void                        setActiveDataSource(const ::rtl::OUString& rURL);
154 
155         ::rtl::OUString             getActiveDataTable();
156         void                        setActiveDataTable(const ::rtl::OUString& rTable);
157 
158         void                        setFilter(const ::rtl::OUString& rQuery);
159         ::rtl::OUString                     getFilter();
160 
161         ::com::sun::star::uno::Sequence< ::rtl::OUString>           getQueryFields();
162         ::rtl::OUString                     getQueryField();
163         void                        startQueryWith(const ::rtl::OUString& rQuery);
164 
getParser()165         const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >&    getParser() { return m_xParser; }
getForm()166         const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >&                        getForm()   { return m_xForm; }
167 
168 
169         ::rtl::OUString                     getControlName(sal_Int32 nFormatKey );
170 
171         ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >            loadControlModel(const ::rtl::OUString& rName,
172                                                         sal_Bool bForceListBox = sal_False);
173 
174         void                        CreateMappingDialog(Window* pParent);
175         ::rtl::OUString             CreateDBChangeDialog(Window* pParent);
176 
177         void                        DispatchDBChangeDialog();
178         sal_Bool                    HasActiveConnection() const;
179 
SetView(::bib::BibView * pView)180         void                        SetView( ::bib::BibView* pView ) { pBibView = pView; }
181 
182         void                        SetToolbar(BibToolBar* pSet);
183 
184         const rtl::OUString&        GetIdentifierMapping();
ResetIdentifierMapping()185         void                        ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();}
186 
187         ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController();
188         // #100312# ----------
189         void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer);
190 
191         sal_Bool                    HasActiveConnection();
192 };
193 
194 
195 #endif
196