use insert function instead of for loop
[LibreOffice.git] / extensions / source / bibliography / datman.hxx
blob405cf83d85a548cb2739dfd0c7224b5966737be2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include "bibview.hxx"
24 #include <com/sun/star/awt/XControlModel.hpp>
25 #include <com/sun/star/form/XForm.hpp>
26 #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
27 #include <com/sun/star/form/runtime/XFormController.hpp>
28 #include <comphelper/compbase.hxx>
29 #include <comphelper/interfacecontainer4.hxx>
30 #include <com/sun/star/form/XLoadable.hpp>
31 #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
32 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
33 #include <cppuhelper/implbase.hxx>
34 #include <vcl/vclptr.hxx>
36 namespace weld { class Window; }
38 namespace bib
40 class BibView;
41 class BibBeamer;
44 class BibToolBar;
45 struct BibDBDescriptor;
47 class BibInterceptorHelper
48 :public cppu::WeakImplHelper< css::frame::XDispatchProviderInterceptor >
50 private:
51 css::uno::Reference< css::frame::XDispatchProvider > xMasterDispatchProvider;
52 css::uno::Reference< css::frame::XDispatchProvider > xSlaveDispatchProvider;
53 css::uno::Reference< css::frame::XDispatch > xFormDispatch;
54 css::uno::Reference< css::frame::XDispatchProviderInterception > xInterception;
56 protected:
57 virtual ~BibInterceptorHelper( ) override;
59 public:
60 BibInterceptorHelper( const ::bib::BibBeamer* pBibBeamer, css::uno::Reference< css::frame::XDispatch > const & xDispatch);
62 void ReleaseInterceptor();
64 // XDispatchProvider
65 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags ) override;
66 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& aDescripts ) override;
67 // XDispatchProviderInterceptor
68 virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) override;
69 virtual void SAL_CALL setSlaveDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) override;
70 virtual css::uno::Reference< css::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) override;
71 virtual void SAL_CALL setMasterDispatchProvider( const css::uno::Reference< css::frame::XDispatchProvider >& xNewMasterDispatchProvider ) override;
74 typedef comphelper::WeakComponentImplHelper < css::form::XLoadable
75 > BibDataManager_Base;
76 class BibDataManager final : public BibDataManager_Base
78 private:
79 css::uno::Reference< css::form::XForm > m_xForm;
80 css::uno::Reference< css::awt::XControlModel > m_xGridModel;
81 css::uno::Reference< css::sdb::XSingleSelectQueryComposer > m_xParser;
82 css::uno::Reference< css::form::runtime::XFormController > m_xFormCtrl;
83 css::uno::Reference< css::frame::XDispatch > m_xFormDispatch;
84 rtl::Reference<BibInterceptorHelper> m_xInterceptorHelper;
86 OUString aActiveDataTable;
87 OUString aDataSourceURL;
88 OUString aQuoteChar;
90 ::comphelper::OInterfaceContainerHelper4<css::form::XLoadListener> m_aLoadListeners;
92 VclPtr< ::bib::BibView> pBibView;
93 VclPtr<BibToolBar> pToolbar;
95 OUString sIdentifierMapping;
97 void InsertFields(const css::uno::Reference< css::form::XFormComponent > & xGrid);
99 css::uno::Reference< css::awt::XControlModel > const &
100 updateGridModel(const css::uno::Reference< css::form::XForm > & xDbForm);
101 static css::uno::Reference< css::awt::XControlModel >
102 createGridModel( const OUString& rName );
104 // XLoadable
105 virtual void SAL_CALL load( ) override;
106 virtual void SAL_CALL unload( ) override;
107 virtual void SAL_CALL reload( ) override;
108 virtual sal_Bool SAL_CALL isLoaded( ) override;
109 virtual void SAL_CALL addLoadListener( const css::uno::Reference< css::form::XLoadListener >& aListener ) override;
110 virtual void SAL_CALL removeLoadListener( const css::uno::Reference< css::form::XLoadListener >& aListener ) override;
112 using WeakComponentImplHelperBase::disposing;
114 public:
116 BibDataManager();
117 virtual ~BibDataManager() override;
119 css::uno::Reference< css::form::XForm > createDatabaseForm( BibDBDescriptor& aDesc);
121 css::uno::Reference< css::awt::XControlModel > updateGridModel();
123 css::uno::Sequence< OUString> getDataSources() const;
125 const OUString& getActiveDataSource() const {return aDataSourceURL;}
126 void setActiveDataSource(const OUString& rURL);
128 const OUString& getActiveDataTable() const { return aActiveDataTable;}
129 void setActiveDataTable(const OUString& rTable);
131 void setFilter(const OUString& rQuery);
132 OUString getFilter() const;
134 css::uno::Sequence< OUString> getQueryFields() const;
135 OUString getQueryField() const;
136 void startQueryWith(const OUString& rQuery);
138 const css::uno::Reference< css::sdb::XSingleSelectQueryComposer >& getParser() const { return m_xParser; }
139 const css::uno::Reference< css::form::XForm >& getForm() const { return m_xForm; }
142 static OUString getControlName(sal_Int32 nFormatKey );
144 css::uno::Reference< css::awt::XControlModel > loadControlModel(const OUString& rName,
145 bool bForceListBox);
147 void CreateMappingDialog(weld::Window* pParent);
148 OUString CreateDBChangeDialog(weld::Window* pParent);
150 void DispatchDBChangeDialog();
152 void SetView( ::bib::BibView* pView ) { pBibView = pView; }
154 void SetToolbar(BibToolBar* pSet);
156 const OUString& GetIdentifierMapping();
157 void ResetIdentifierMapping() {sIdentifierMapping.clear();}
159 css::uno::Reference< css::form::runtime::XFormController > const & GetFormController();
160 void RegisterInterceptor( const ::bib::BibBeamer* pBibBeamer);
162 bool HasActiveConnection() const;
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */