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