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 .
19 #ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
20 #define DBAUI_FIELDDESCRIPTIONCONTROL_HXX
22 #include <vcl/tabpage.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"
28 // field description columns of a table
32 #define COLUMN_DESCRIPTION 4
34 #define FIELD_FIRST_VIRTUAL_COLUMN 5
36 #define FIELD_PROPERTY_REQUIRED 5
37 #define FIELD_PROPERTY_NUMTYPE 6
38 #define FIELD_PROPERTY_AUTOINC 7
39 #define FIELD_PROPERTY_DEFAULT 8
40 #define FIELD_PROPERTY_TEXTLEN 9
41 #define FIELD_PROPERTY_LENGTH 10
42 #define FIELD_PROPERTY_SCALE 11
43 #define FIELD_PROPERTY_BOOL_DEFAULT 12
44 #define FIELD_PROPERTY_FORMAT 13
45 #define FIELD_PRPOERTY_COLUMNNAME 14
46 #define FIELD_PRPOERTY_TYPE 15
47 #define FIELD_PRPOERTY_AUTOINCREMENT 16
58 class OTableDesignHelpBar
;
59 class OPropListBoxCtrl
;
61 class OPropNumericEditCtrl
;
62 class OFieldDescription
;
63 class OPropColumnEditCtrl
;
65 class OFieldDescControl
: public TabPage
68 OTableDesignHelpBar
* pHelp
;
69 Window
* pLastFocusWindow
;
70 Window
* m_pActFocusWindow
;
72 FixedText
* pDefaultText
;
73 FixedText
* pRequiredText
;
74 FixedText
* pAutoIncrementText
;
75 FixedText
* pTextLenText
;
76 FixedText
* pNumTypeText
;
77 FixedText
* pLengthText
;
78 FixedText
* pScaleText
;
79 FixedText
* pFormatText
;
80 FixedText
* pBoolDefaultText
;
81 FixedText
* m_pColumnNameText
;
82 FixedText
* m_pTypeText
;
83 FixedText
* m_pAutoIncrementValueText
;
85 OPropListBoxCtrl
* pRequired
;
86 OPropListBoxCtrl
* pNumType
;
87 OPropListBoxCtrl
* pAutoIncrement
;
88 OPropEditCtrl
* pDefault
;
89 OPropNumericEditCtrl
* pTextLen
;
90 OPropNumericEditCtrl
* pLength
;
91 OPropNumericEditCtrl
* pScale
;
92 OPropEditCtrl
* pFormatSample
;
93 OPropListBoxCtrl
* pBoolDefault
;
94 OPropColumnEditCtrl
* m_pColumnName
;
95 OPropListBoxCtrl
* m_pType
;
96 OPropEditCtrl
* m_pAutoIncrementValue
;
100 ScrollBar
* m_pVertScroll
;
101 ScrollBar
* m_pHorzScroll
;
103 TOTypeInfoSP m_pPreviousType
;
113 bool m_bRightAligned
;
115 OFieldDescription
* pActFieldDescr
;
117 DECL_LINK( OnScroll
, ScrollBar
*);
119 DECL_LINK( FormatClickHdl
, Button
* );
120 DECL_LINK( ChangeHdl
, ListBox
* );
122 // used by ActivatePropertyField
123 DECL_LINK( OnControlFocusLost
, Control
* );
124 DECL_LINK( OnControlFocusGot
, Control
* );
126 void UpdateFormatSample(OFieldDescription
* pFieldDescr
);
127 void ArrangeAggregates();
129 void SetPosSize( Control
** ppControl
, long nRow
, sal_uInt16 nCol
);
131 void ScrollAggregate(Control
* pText
, Control
* pInput
, Control
* pButton
, long nDeltaX
, long nDeltaY
);
132 void ScrollAllAggregates();
134 sal_Bool
isTextFormat(const OFieldDescription
* _pFieldDescr
,sal_uInt32
& _nFormatKey
) const;
136 OPropNumericEditCtrl
* CreateNumericControl(sal_uInt16 _nHelpStr
,short _nProperty
,const OString
& _sHelpId
);
137 FixedText
* CreateText(sal_uInt16 _nTextRes
);
138 void InitializeControl(Control
* _pControl
,const OString
& _sHelpId
,bool _bAddChangeHandler
);
141 inline void setRightAligned() { m_bRightAligned
= true; }
142 inline bool isRightAligned() const { return m_bRightAligned
; }
144 inline void saveCurrentFieldDescData() { SaveData( pActFieldDescr
); }
145 inline OFieldDescription
* getCurrentFieldDescData() { return pActFieldDescr
; }
146 inline void setCurrentFieldDescData( OFieldDescription
* _pDesc
) { pActFieldDescr
= _pDesc
; }
148 sal_uInt16
CountActiveAggregates() const;
149 sal_Int32
GetMaxControlHeight() const;
151 virtual void ActivateAggregate( EControlType eType
);
152 virtual void DeactivateAggregate( EControlType eType
);
153 virtual sal_Bool
IsReadOnly() { return sal_False
; };
155 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::util::XNumberFormatter
> GetFormatter() const = 0;
157 virtual ::com::sun::star::lang::Locale
GetLocale() const = 0;
159 virtual void CellModified(long nRow
, sal_uInt16 nColId
) = 0;
160 virtual void SetModified(sal_Bool bModified
); // base implementation is empty
162 virtual TOTypeInfoSP
getTypeInfo(sal_Int32 _nPos
) = 0;
163 virtual const OTypeInfoMap
* getTypeInfo() const = 0;
165 virtual sal_Bool
isAutoIncrementValueEnabled() const = 0;
166 virtual OUString
getAutoIncrementValue() const = 0;
168 String
BoolStringPersistent(const String
& rUIString
) const;
169 String
BoolStringUI(const String
& rPersistentString
) const;
171 const OPropColumnEditCtrl
* getColumnCtrl() const { return m_pColumnName
; }
173 void implFocusLost(Window
* _pWhich
);
176 OFieldDescControl( Window
* pParent
, OTableDesignHelpBar
* pHelpBar
);
177 OFieldDescControl( Window
* pParent
, const ResId
& rResId
, OTableDesignHelpBar
* pHelpBar
);
178 virtual ~OFieldDescControl();
180 void DisplayData(OFieldDescription
* pFieldDescr
);
182 void SaveData( OFieldDescription
* pFieldDescr
);
184 void SetControlText( sal_uInt16 nControlId
, const String
& rText
);
185 String
GetControlText( sal_uInt16 nControlId
);
186 void SetReadOnly( sal_Bool bReadOnly
);
188 // when resize is called
189 void CheckScrollBars();
190 sal_Bool
isCutAllowed();
191 sal_Bool
isCopyAllowed();
192 sal_Bool
isPasteAllowed();
199 virtual void GetFocus();
200 virtual void LoseFocus();
201 virtual void Resize();
203 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XDatabaseMetaData
> getMetaData() = 0;
204 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
> getConnection() = 0;
206 String
getControlDefault( const OFieldDescription
* _pFieldDescr
,sal_Bool _bCheck
= sal_True
) const;
208 inline void setEditWidth(sal_Int32 _nWidth
) { m_nWidth
= _nWidth
; }
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */