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 .
22 #include <vcl/weld.hxx>
24 #include <com/sun/star/sdbc/XConnection.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
37 class FormLinkDialog
: public weld::GenericDialogController
40 css::uno::Reference
< css::uno::XComponentContext
>
42 css::uno::Reference
< css::beans::XPropertySet
>
44 css::uno::Reference
< css::beans::XPropertySet
>
47 std::vector
< OUString
> m_aRelationDetailColumns
;
48 std::vector
< OUString
> m_aRelationMasterColumns
;
50 OUString m_sDetailLabel
;
51 OUString m_sMasterLabel
;
53 std::unique_ptr
<weld::Label
> m_xExplanation
;
54 std::unique_ptr
<weld::Label
> m_xDetailLabel
;
55 std::unique_ptr
<weld::Label
> m_xMasterLabel
;
56 std::unique_ptr
<FieldLinkRow
> m_xRow1
;
57 std::unique_ptr
<FieldLinkRow
> m_xRow2
;
58 std::unique_ptr
<FieldLinkRow
> m_xRow3
;
59 std::unique_ptr
<FieldLinkRow
> m_xRow4
;
60 std::unique_ptr
<weld::Button
> m_xOK
;
61 std::unique_ptr
<weld::Button
> m_xSuggest
;
65 weld::Window
* _pParent
,
66 const css::uno::Reference
< css::beans::XPropertySet
>& _rxDetailForm
,
67 const css::uno::Reference
< css::beans::XPropertySet
>& _rxMasterForm
,
68 const css::uno::Reference
< css::uno::XComponentContext
>& _rxContext
,
69 const OUString
& _sExplanation
= OUString(),
70 OUString _sDetailLabel
= OUString(),
71 OUString _sMasterLabel
= OUString()
74 virtual ~FormLinkDialog() override
;
76 // Dialog overridables
77 virtual short run() override
;
80 DECL_LINK( OnSuggest
, weld::Button
&, void );
81 DECL_LINK( OnFieldChanged
, FieldLinkRow
&, void );
82 DECL_LINK( OnInitialize
, void*, void);
84 void updateOkButton();
85 void initializeFieldLists();
86 void initializeColumnLabels();
87 void initializeLinks();
88 void initializeSuggest();
89 void commitLinkPairs();
91 void initializeFieldRowsFrom(
92 std::vector
< OUString
>& _rDetailFields
,
93 std::vector
< OUString
>& _rMasterFields
96 static OUString
getFormDataSourceType(
97 const css::uno::Reference
< css::beans::XPropertySet
>& _rxForm
101 const css::uno::Reference
< css::beans::XPropertySet
>& _rxForm
,
102 css::uno::Sequence
< OUString
>& /* [out] */ _rNames
105 void ensureFormConnection(
106 const css::uno::Reference
< css::beans::XPropertySet
>& _rxFormProps
,
107 css::uno::Reference
< css::sdbc::XConnection
>& /* [out] */ _rxConnection
110 static void getConnectionMetaData(
111 const css::uno::Reference
< css::beans::XPropertySet
>& _rxFormProps
,
112 css::uno::Reference
< css::sdbc::XDatabaseMetaData
>& /* [out] */ _rxMeta
115 css::uno::Reference
< css::beans::XPropertySet
>
116 getCanonicUnderlyingTable( const css::uno::Reference
< css::beans::XPropertySet
>& _rxFormProps
) const;
117 static bool getExistingRelation(
118 const css::uno::Reference
< css::beans::XPropertySet
>& _rxLHS
,
119 const css::uno::Reference
< css::beans::XPropertySet
>& _rxRHS
,
120 std::vector
< OUString
>& /* [out] */ _rLeftFields
,
121 std::vector
< OUString
>& /* [out] */ _rRightFields
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */