1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_BIBLIOGRAPHY_DATMAN_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_BIBLIOGRAPHY_DATMAN_HXX
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/compbase.hxx>
29 #include <comphelper/interfacecontainer2.hxx>
30 #include <com/sun/star/form/XLoadable.hpp>
31 #include <comphelper/broadcasthelper.hxx>
32 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
33 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
34 #include <cppuhelper/implbase.hxx>
35 #include <vcl/vclptr.hxx>
37 namespace vcl
{ class Window
; }
38 namespace weld
{ class Window
; }
47 struct BibDBDescriptor
;
49 class BibInterceptorHelper
50 :public cppu::WeakImplHelper
< css::frame::XDispatchProviderInterceptor
>
53 css::uno::Reference
< css::frame::XDispatchProvider
> xMasterDispatchProvider
;
54 css::uno::Reference
< css::frame::XDispatchProvider
> xSlaveDispatchProvider
;
55 css::uno::Reference
< css::frame::XDispatch
> xFormDispatch
;
56 css::uno::Reference
< css::frame::XDispatchProviderInterception
> xInterception
;
59 virtual ~BibInterceptorHelper( ) override
;
62 BibInterceptorHelper( ::bib::BibBeamer
* pBibBeamer
, css::uno::Reference
< css::frame::XDispatch
> const & xDispatch
);
64 void ReleaseInterceptor();
67 virtual css::uno::Reference
< css::frame::XDispatch
> SAL_CALL
queryDispatch( const css::util::URL
& aURL
, const OUString
& aTargetFrameName
, sal_Int32 nSearchFlags
) override
;
68 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches( const css::uno::Sequence
< css::frame::DispatchDescriptor
>& aDescripts
) override
;
69 // XDispatchProviderInterceptor
70 virtual css::uno::Reference
< css::frame::XDispatchProvider
> SAL_CALL
getSlaveDispatchProvider( ) override
;
71 virtual void SAL_CALL
setSlaveDispatchProvider( const css::uno::Reference
< css::frame::XDispatchProvider
>& xNewSlaveDispatchProvider
) override
;
72 virtual css::uno::Reference
< css::frame::XDispatchProvider
> SAL_CALL
getMasterDispatchProvider( ) override
;
73 virtual void SAL_CALL
setMasterDispatchProvider( const css::uno::Reference
< css::frame::XDispatchProvider
>& xNewMasterDispatchProvider
) override
;
76 typedef cppu::WeakComponentImplHelper
< css::form::XLoadable
77 > BibDataManager_Base
;
78 class BibDataManager final
79 :public ::comphelper::OMutexAndBroadcastHelper
80 ,public BibDataManager_Base
83 css::uno::Reference
< css::form::XForm
> m_xForm
;
84 css::uno::Reference
< css::awt::XControlModel
> m_xGridModel
;
85 css::uno::Reference
< css::sdb::XSingleSelectQueryComposer
> m_xParser
;
86 css::uno::Reference
< css::form::runtime::XFormController
> m_xFormCtrl
;
87 css::uno::Reference
< css::frame::XDispatch
> m_xFormDispatch
;
88 rtl::Reference
<BibInterceptorHelper
> m_xInterceptorHelper
;
90 OUString aActiveDataTable
;
91 OUString aDataSourceURL
;
94 ::comphelper::OInterfaceContainerHelper2 m_aLoadListeners
;
96 VclPtr
< ::bib::BibView
> pBibView
;
97 VclPtr
<BibToolBar
> pToolbar
;
99 OUString sIdentifierMapping
;
101 void InsertFields(const css::uno::Reference
< css::form::XFormComponent
> & xGrid
);
103 css::uno::Reference
< css::awt::XControlModel
> const &
104 updateGridModel(const css::uno::Reference
< css::form::XForm
> & xDbForm
);
105 static css::uno::Reference
< css::awt::XControlModel
>
106 createGridModel( const OUString
& rName
);
109 virtual void SAL_CALL
load( ) override
;
110 virtual void SAL_CALL
unload( ) override
;
111 virtual void SAL_CALL
reload( ) override
;
112 virtual sal_Bool SAL_CALL
isLoaded( ) override
;
113 virtual void SAL_CALL
addLoadListener( const css::uno::Reference
< css::form::XLoadListener
>& aListener
) override
;
114 virtual void SAL_CALL
removeLoadListener( const css::uno::Reference
< css::form::XLoadListener
>& aListener
) override
;
116 using WeakComponentImplHelperBase::disposing
;
121 virtual ~BibDataManager() override
;
123 css::uno::Reference
< css::form::XForm
> createDatabaseForm( BibDBDescriptor
& aDesc
);
125 css::uno::Reference
< css::awt::XControlModel
> updateGridModel();
127 css::uno::Sequence
< OUString
> getDataSources();
129 const OUString
& getActiveDataSource() {return aDataSourceURL
;}
130 void setActiveDataSource(const OUString
& rURL
);
132 const OUString
& getActiveDataTable() { return aActiveDataTable
;}
133 void setActiveDataTable(const OUString
& rTable
);
135 void setFilter(const OUString
& rQuery
);
136 OUString
getFilter();
138 css::uno::Sequence
< OUString
> getQueryFields();
139 OUString
getQueryField();
140 void startQueryWith(const OUString
& rQuery
);
142 const css::uno::Reference
< css::sdb::XSingleSelectQueryComposer
>& getParser() { return m_xParser
; }
143 const css::uno::Reference
< css::form::XForm
>& getForm() { return m_xForm
; }
146 static OUString
getControlName(sal_Int32 nFormatKey
);
148 css::uno::Reference
< css::awt::XControlModel
> loadControlModel(const OUString
& rName
,
151 void CreateMappingDialog(weld::Window
* pParent
);
152 OUString
CreateDBChangeDialog(weld::Window
* pParent
);
154 void DispatchDBChangeDialog();
156 void SetView( ::bib::BibView
* pView
) { pBibView
= pView
; }
158 void SetToolbar(BibToolBar
* pSet
);
160 const OUString
& GetIdentifierMapping();
161 void ResetIdentifierMapping() {sIdentifierMapping
.clear();}
163 css::uno::Reference
< css::form::runtime::XFormController
> const & GetFormController();
164 void RegisterInterceptor( ::bib::BibBeamer
* pBibBeamer
);
166 bool HasActiveConnection();
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */