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