LibreOffice Module dbaccess (master) 1
FieldDescControl.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <vcl/weld.hxx>
22#include "IClipBoardTest.hxx"
23#include "QEnumTypes.hxx"
24#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
25#include <com/sun/star/util/XNumberFormatter.hpp>
26#include "TypeInfo.hxx"
27#include <unotools/resmgr.hxx>
28
29// field description columns of a table
30#define FIELD_NAME 1
31#define FIELD_TYPE 2
32#define HELP_TEXT 3
33#define COLUMN_DESCRIPTION 4
34
35#define FIELD_FIRST_VIRTUAL_COLUMN 5
36
37#define FIELD_PROPERTY_REQUIRED 5
38#define FIELD_PROPERTY_NUMTYPE 6
39#define FIELD_PROPERTY_AUTOINC 7
40#define FIELD_PROPERTY_DEFAULT 8
41#define FIELD_PROPERTY_TEXTLEN 9
42#define FIELD_PROPERTY_LENGTH 10
43#define FIELD_PROPERTY_SCALE 11
44#define FIELD_PROPERTY_BOOL_DEFAULT 12
45#define FIELD_PROPERTY_FORMAT 13
46#define FIELD_PROPERTY_COLUMNNAME 14
47#define FIELD_PROPERTY_TYPE 15
48#define FIELD_PROPERTY_AUTOINCREMENT 16
49
50namespace dbaui
51{
52 class OTableDesignHelpBar;
53 class OPropListBoxCtrl;
54 class OPropEditCtrl;
55 class OPropNumericEditCtrl;
56 class OFieldDescription;
57 class OPropColumnEditCtrl;
58
60 {
61 private:
62 std::unique_ptr<weld::Builder> m_xBuilder;
63 std::unique_ptr<weld::Container> m_xContainer;
64
68
69 std::unique_ptr<weld::Label> m_xDefaultText;
70 std::unique_ptr<weld::Label> m_xRequiredText;
71 std::unique_ptr<weld::Label> m_xAutoIncrementText;
72 std::unique_ptr<weld::Label> m_xTextLenText;
73 std::unique_ptr<weld::Label> m_xNumTypeText;
74 std::unique_ptr<weld::Label> m_xLengthText;
75 std::unique_ptr<weld::Label> m_xScaleText;
76 std::unique_ptr<weld::Label> m_xFormatText;
77 std::unique_ptr<weld::Label> m_xBoolDefaultText;
78 std::unique_ptr<weld::Label> m_xColumnNameText;
79 std::unique_ptr<weld::Label> m_xTypeText;
80 std::unique_ptr<weld::Label> m_xAutoIncrementValueText;
81
82 std::unique_ptr<OPropListBoxCtrl> m_xRequired;
83 std::unique_ptr<OPropListBoxCtrl> m_xNumType;
84 std::unique_ptr<OPropListBoxCtrl> m_xAutoIncrement;
85 std::unique_ptr<OPropEditCtrl> m_xDefault;
86 std::unique_ptr<OPropNumericEditCtrl> m_xTextLen;
87 std::unique_ptr<OPropNumericEditCtrl> m_xLength;
88 std::unique_ptr<OPropNumericEditCtrl> m_xScale;
89 std::unique_ptr<OPropEditCtrl> m_xFormatSample;
90 std::unique_ptr<OPropListBoxCtrl> m_xBoolDefault;
91 std::unique_ptr<OPropColumnEditCtrl> m_xColumnName;
92 std::unique_ptr<OPropListBoxCtrl> m_xType;
93 std::unique_ptr<OPropEditCtrl> m_xAutoIncrementValue;
94
95 std::unique_ptr<weld::Button> m_xFormat;
96
98
100 short m_nPos;
101 OUString aYes;
102 OUString aNo;
103
104 sal_Int32 m_nEditWidth;
105
107
108 DECL_LINK(FormatClickHdl, weld::Button&, void);
109 DECL_LINK(ChangeHdl, weld::ComboBox&, void);
110
111 // used by ActivatePropertyField
112 DECL_LINK( OnControlFocusLost, weld::Widget&, void );
113 DECL_LINK( OnControlFocusGot, weld::Widget&, void );
114
115 DECL_LINK( HelpFocusOut, weld::Widget&, void );
116
117 void UpdateFormatSample(OFieldDescription const * pFieldDescr);
118
119 bool isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
120 std::unique_ptr<OPropNumericEditCtrl> CreateNumericControl(const OUString& rId, TranslateId pHelpId, short _nProperty, const OUString& _sHelpId);
121 void InitializeControl(weld::Widget* _pControl,const OUString& _sHelpId);
122 void InitializeControl(OPropListBoxCtrl* _pControl,const OUString& _sHelpId,bool _bAddChangeHandler);
123
124 bool IsFocusInEditableWidget() const;
125
126 void dispose();
127 protected:
131
132 virtual void ActivateAggregate( EControlType eType );
133 virtual void DeactivateAggregate( EControlType eType );
134 virtual bool IsReadOnly() { return false; };
135
136 virtual css::uno::Reference< css::util::XNumberFormatter > GetFormatter() const = 0;
137
138 virtual css::lang::Locale GetLocale() const = 0;
139
140 virtual void CellModified(sal_Int32 nRow, sal_uInt16 nColId ) = 0;
141 virtual void SetModified(bool bModified); // base implementation is empty
142
143 virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos) = 0;
144 virtual const OTypeInfoMap* getTypeInfo() const = 0;
145
146 virtual bool isAutoIncrementValueEnabled() const = 0;
147 virtual OUString getAutoIncrementValue() const = 0;
148
149 OUString BoolStringPersistent(std::u16string_view rUIString) const;
150 OUString BoolStringUI(const OUString& rPersistentString) const;
151
152 const OPropColumnEditCtrl* getColumnCtrl() const { return m_xColumnName.get(); }
153
154 void implFocusLost(weld::Widget* _pWhich);
155
156 public:
158 virtual ~OFieldDescControl();
159
160 void DisplayData(OFieldDescription* pFieldDescr );
161
162 void SaveData( OFieldDescription* pFieldDescr );
163
164 void SetControlText( sal_uInt16 nControlId, const OUString& rText );
165 void SetReadOnly( bool bReadOnly );
166
167 void Enable(bool bEnable) { m_xContainer->set_sensitive(bEnable); }
168 void SetHelpId(const OUString& rId) { m_xContainer->set_help_id(rId); }
169
170 virtual bool isCutAllowed() override;
171 virtual bool isCopyAllowed() override;
172 virtual bool isPasteAllowed() override;
173
174 virtual void cut() override;
175 virtual void copy() override;
176 virtual void paste() override;
177
179 {
180 m_aControlFocusIn = rLink;
181 }
182
183 void Init();
184
185 void GrabFocus();
186
187 bool HasChildPathFocus() const;
188
189 virtual css::uno::Reference< css::sdbc::XDatabaseMetaData> getMetaData() = 0;
190 virtual css::uno::Reference< css::sdbc::XConnection> getConnection() = 0;
191
192 OUString getControlDefault( const OFieldDescription* pFieldDescr, bool _bCheck = true) const;
193 // tdf#138409 take the control default in the UI Locale format, e.g. 12,34 and return a string
194 // suitable as the database default, e.g. 12.34
195 OUString CanonicalizeToControlDefault(const OFieldDescription* pFieldDescr, const OUString& rUserText) const;
196
197 void setEditWidth(sal_Int32 _nWidth) { m_nEditWidth = _nWidth; }
198 };
199}
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool isCopyAllowed() override
virtual void ActivateAggregate(EControlType eType)
weld::Widget * m_pActFocusWindow
void connect_focus_in(const Link< weld::Widget &, void > &rLink)
DECL_LINK(ChangeHdl, weld::ComboBox &, void)
void SaveData(OFieldDescription *pFieldDescr)
std::unique_ptr< weld::Builder > m_xBuilder
std::unique_ptr< weld::Label > m_xDefaultText
weld::Widget * m_pLastFocusWindow
std::unique_ptr< OPropListBoxCtrl > m_xType
DECL_LINK(FormatClickHdl, weld::Button &, void)
std::unique_ptr< OPropNumericEditCtrl > m_xLength
DECL_LINK(HelpFocusOut, weld::Widget &, void)
std::unique_ptr< OPropNumericEditCtrl > CreateNumericControl(const OUString &rId, TranslateId pHelpId, short _nProperty, const OUString &_sHelpId)
OUString BoolStringPersistent(std::u16string_view rUIString) const
virtual void SetModified(bool bModified)
virtual void copy() override
OUString getControlDefault(const OFieldDescription *pFieldDescr, bool _bCheck=true) const
OFieldDescription * getCurrentFieldDescData()
virtual TOTypeInfoSP getTypeInfo(sal_Int32 _nPos)=0
DECL_LINK(OnControlFocusLost, weld::Widget &, void)
std::unique_ptr< OPropNumericEditCtrl > m_xScale
void SetReadOnly(bool bReadOnly)
Link< weld::Widget &, void > m_aControlFocusIn
virtual void paste() override
virtual void CellModified(sal_Int32 nRow, sal_uInt16 nColId)=0
virtual bool isAutoIncrementValueEnabled() const =0
void SetHelpId(const OUString &rId)
std::unique_ptr< weld::Label > m_xTypeText
virtual css::uno::Reference< css::sdbc::XConnection > getConnection()=0
OFieldDescription * pActFieldDescr
virtual void cut() override
void setEditWidth(sal_Int32 _nWidth)
std::unique_ptr< OPropListBoxCtrl > m_xRequired
std::unique_ptr< weld::Label > m_xTextLenText
std::unique_ptr< weld::Label > m_xScaleText
std::unique_ptr< weld::Container > m_xContainer
DECL_LINK(OnControlFocusGot, weld::Widget &, void)
std::unique_ptr< weld::Label > m_xColumnNameText
virtual bool isPasteAllowed() override
virtual OUString getAutoIncrementValue() const =0
std::unique_ptr< weld::Label > m_xNumTypeText
std::unique_ptr< weld::Label > m_xAutoIncrementText
void DisplayData(OFieldDescription *pFieldDescr)
std::unique_ptr< OPropListBoxCtrl > m_xNumType
void UpdateFormatSample(OFieldDescription const *pFieldDescr)
OFieldDescControl(weld::Container *pPage, OTableDesignHelpBar *pHelpBar)
std::unique_ptr< OPropNumericEditCtrl > m_xTextLen
std::unique_ptr< weld::Label > m_xAutoIncrementValueText
OUString BoolStringUI(const OUString &rPersistentString) const
std::unique_ptr< weld::Button > m_xFormat
void SetControlText(sal_uInt16 nControlId, const OUString &rText)
std::unique_ptr< weld::Label > m_xFormatText
virtual bool isCutAllowed() override
void setCurrentFieldDescData(OFieldDescription *_pDesc)
const OPropColumnEditCtrl * getColumnCtrl() const
bool isTextFormat(const OFieldDescription *_pFieldDescr, sal_uInt32 &_nFormatKey) const
std::unique_ptr< OPropListBoxCtrl > m_xBoolDefault
void implFocusLost(weld::Widget *_pWhich)
virtual const OTypeInfoMap * getTypeInfo() const =0
std::unique_ptr< weld::Label > m_xBoolDefaultText
std::unique_ptr< OPropColumnEditCtrl > m_xColumnName
void InitializeControl(weld::Widget *_pControl, const OUString &_sHelpId)
std::unique_ptr< OPropEditCtrl > m_xFormatSample
std::unique_ptr< weld::Label > m_xRequiredText
virtual css::uno::Reference< css::sdbc::XDatabaseMetaData > getMetaData()=0
std::unique_ptr< OPropEditCtrl > m_xDefault
std::unique_ptr< OPropEditCtrl > m_xAutoIncrementValue
std::unique_ptr< weld::Label > m_xLengthText
std::unique_ptr< OPropListBoxCtrl > m_xAutoIncrement
OUString CanonicalizeToControlDefault(const OFieldDescription *pFieldDescr, const OUString &rUserText) const
virtual void DeactivateAggregate(EControlType eType)
virtual css::lang::Locale GetLocale() const =0
virtual css::uno::Reference< css::util::XNumberFormatter > GetFormatter() const =0
OTableDesignHelpBar * m_pHelp
OUString eType
Definition: generalpage.cxx:78
std::multimap< sal_Int32, TOTypeInfoSP > OTypeInfoMap
Definition: TypeInfo.hxx:100
std::shared_ptr< OTypeInfo > TOTypeInfoSP
Definition: TypeInfo.hxx:99
EControlType
Definition: QEnumTypes.hxx:63