Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / propctrlr / formlinkdialog.hxx
blob45d6691371204fc8e2d47f16c0624660326cc35d
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 #ifndef INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
23 #include <vcl/weld.hxx>
25 #include <com/sun/star/form/XForm.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/sdbc/XConnection.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
31 #include <memory>
34 namespace pcr
36 class FieldLinkRow;
38 //= FormLinkDialog
40 class FormLinkDialog : public weld::GenericDialogController
42 private:
43 css::uno::Reference< css::uno::XComponentContext >
44 m_xContext;
45 css::uno::Reference< css::beans::XPropertySet >
46 m_xDetailForm;
47 css::uno::Reference< css::beans::XPropertySet >
48 m_xMasterForm;
50 std::vector< OUString > m_aRelationDetailColumns;
51 std::vector< OUString > m_aRelationMasterColumns;
53 OUString m_sDetailLabel;
54 OUString m_sMasterLabel;
56 std::unique_ptr<weld::Label> m_xExplanation;
57 std::unique_ptr<weld::Label> m_xDetailLabel;
58 std::unique_ptr<weld::Label> m_xMasterLabel;
59 std::unique_ptr<FieldLinkRow> m_xRow1;
60 std::unique_ptr<FieldLinkRow> m_xRow2;
61 std::unique_ptr<FieldLinkRow> m_xRow3;
62 std::unique_ptr<FieldLinkRow> m_xRow4;
63 std::unique_ptr<weld::Button> m_xOK;
64 std::unique_ptr<weld::Button> m_xSuggest;
66 public:
67 FormLinkDialog(
68 weld::Window* _pParent,
69 const css::uno::Reference< css::beans::XPropertySet >& _rxDetailForm,
70 const css::uno::Reference< css::beans::XPropertySet >& _rxMasterForm,
71 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
72 const OUString& _sExplanation = OUString(),
73 const OUString& _sDetailLabel = OUString(),
74 const OUString& _sMasterLabel = OUString()
77 virtual ~FormLinkDialog() override;
79 // Dialog overridables
80 virtual short run() override;
82 private:
83 DECL_LINK( OnSuggest, weld::Button&, void );
84 DECL_LINK( OnFieldChanged, FieldLinkRow&, void );
85 DECL_LINK( OnInitialize, void*, void);
87 void updateOkButton();
88 void initializeFieldLists();
89 void initializeColumnLabels();
90 void initializeLinks();
91 void initializeSuggest();
92 void commitLinkPairs();
94 void initializeFieldRowsFrom(
95 std::vector< OUString >& _rDetailFields,
96 std::vector< OUString >& _rMasterFields
99 static OUString getFormDataSourceType(
100 const css::uno::Reference< css::beans::XPropertySet >& _rxForm
103 void getFormFields(
104 const css::uno::Reference< css::beans::XPropertySet >& _rxForm,
105 css::uno::Sequence< OUString >& /* [out] */ _rNames
106 ) const;
108 void ensureFormConnection(
109 const css::uno::Reference< css::beans::XPropertySet >& _rxFormProps,
110 css::uno::Reference< css::sdbc::XConnection >& /* [out] */ _rxConnection
111 ) const;
113 static void getConnectionMetaData(
114 const css::uno::Reference< css::beans::XPropertySet >& _rxFormProps,
115 css::uno::Reference< css::sdbc::XDatabaseMetaData >& /* [out] */ _rxMeta
118 css::uno::Reference< css::beans::XPropertySet >
119 getCanonicUnderlyingTable( const css::uno::Reference< css::beans::XPropertySet >& _rxFormProps ) const;
120 static bool getExistingRelation(
121 const css::uno::Reference< css::beans::XPropertySet >& _rxLHS,
122 const css::uno::Reference< css::beans::XPropertySet >& _rxRHS,
123 std::vector< OUString >& /* [out] */ _rLeftFields,
124 std::vector< OUString >& /* [out] */ _rRightFields
128 } // namespace pcr
130 #endif // INCLUDED_EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */