xref: /AOO41X/main/dbaccess/source/ui/inc/FieldDescControl.hxx (revision 2e2212a7c22e96cf6f6fab0dd042c34a45a64bd6)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef DBAUI_FIELDDESCRIPTIONCONTROL_HXX
24 #define DBAUI_FIELDDESCRIPTIONCONTROL_HXX
25 
26 #ifndef _SV_TABPAGE_HXX
27 #include <vcl/tabpage.hxx>
28 #endif
29 #ifndef DBAUI_ENUMTYPES_HXX
30 #include "QEnumTypes.hxx"
31 #endif
32 #ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
33 #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
34 #endif
35 #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
36 #include <com/sun/star/util/XNumberFormatter.hpp>
37 #endif
38 #ifndef DBAUI_TYPEINFO_HXX
39 #include "TypeInfo.hxx"
40 #endif
41 
42 //------------------------------------------------------------------
43 // die Spalten einer Feld-Beschreibung einer Tabelle
44 #define FIELD_NAME                      1
45 #define FIELD_TYPE                      2
46 #define HELP_TEXT                       3
47 #define COLUMN_DESCRIPTION              4
48 
49 #define FIELD_FIRST_VIRTUAL_COLUMN      5
50 
51 #define FIELD_PROPERTY_REQUIRED         5
52 #define FIELD_PROPERTY_NUMTYPE          6
53 #define FIELD_PROPERTY_AUTOINC          7
54 #define FIELD_PROPERTY_DEFAULT          8
55 #define FIELD_PROPERTY_TEXTLEN          9
56 #define FIELD_PROPERTY_LENGTH           10
57 #define FIELD_PROPERTY_SCALE            11
58 #define FIELD_PROPERTY_BOOL_DEFAULT     12
59 #define FIELD_PROPERTY_FORMAT           13
60 #define FIELD_PRPOERTY_COLUMNNAME       14
61 #define FIELD_PRPOERTY_TYPE             15
62 #define FIELD_PRPOERTY_AUTOINCREMENT    16
63 
64 class FixedText;
65 class PushButton;
66 class SvxNumberFormatShell;
67 class ScrollBar;
68 class Button;
69 class ListBox;
70 class Control;
71 class SvNumberFormatter;
72 
73 namespace dbaui
74 {
75 
76     class OTableDesignHelpBar;
77     class OPropListBoxCtrl;
78     class OPropEditCtrl;
79     class OPropNumericEditCtrl;
80     class OFieldDescription;
81     class OTypeInfo;
82     class OPropColumnEditCtrl;
83     //==================================================================
84     class OFieldDescControl : public TabPage
85     {
86     private:
87         OTableDesignHelpBar*    pHelp;
88         Window*                 pLastFocusWindow;
89         Window*                 m_pActFocusWindow;
90 
91         FixedText*              pDefaultText;
92         FixedText*              pRequiredText;
93         FixedText*              pAutoIncrementText;
94         FixedText*              pTextLenText;
95         FixedText*              pNumTypeText;
96         FixedText*              pLengthText;
97         FixedText*              pScaleText;
98         FixedText*              pFormatText;
99         FixedText*              pBoolDefaultText;
100         FixedText*              m_pColumnNameText;
101         FixedText*              m_pTypeText;
102         FixedText*              m_pAutoIncrementValueText;
103 
104         OPropListBoxCtrl*       pRequired;
105         OPropListBoxCtrl*       pNumType;
106         OPropListBoxCtrl*       pAutoIncrement;
107         OPropEditCtrl*          pDefault;
108         OPropNumericEditCtrl*   pTextLen;
109         OPropNumericEditCtrl*   pLength;
110         OPropNumericEditCtrl*   pScale;
111         OPropEditCtrl*          pFormatSample;
112         OPropListBoxCtrl*       pBoolDefault;
113         OPropColumnEditCtrl*    m_pColumnName;
114         OPropListBoxCtrl*       m_pType;
115         OPropEditCtrl*          m_pAutoIncrementValue;
116 
117         PushButton*             pFormat;
118 
119         ScrollBar*              m_pVertScroll;
120         ScrollBar*              m_pHorzScroll;
121 
122         TOTypeInfoSP            m_pPreviousType;
123         sal_uInt16                  nCurChildId;
124         short                   m_nPos;
125         XubString               aYes;
126         XubString               aNo;
127 
128         long                    m_nOldVThumb;
129         long                    m_nOldHThumb;
130         sal_Int32               m_nWidth;
131 
132         sal_uLong                   nDelayedGrabFocusEvent;
133         sal_Bool                m_bAdded;
134         bool                    m_bRightAligned;
135 
136         OFieldDescription*      pActFieldDescr;
137 
138         DECL_LINK( OnScroll, ScrollBar*);
139 
140         DECL_LINK( FormatClickHdl, Button * );
141         DECL_LINK( ChangeHdl, ListBox * );
142 
143         DECL_LINK( DelayedGrabFocus, Control** );
144             // von ActivatePropertyField benutzt
145         DECL_LINK( OnControlFocusLost, Control* );
146         DECL_LINK( OnControlFocusGot, Control* );
147 
148         void                UpdateFormatSample(OFieldDescription* pFieldDescr);
149         void                ArrangeAggregates();
150 
151         void                SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol );
152 
153         void                ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY);
154         void                ScrollAllAggregates();
155 
156         sal_Bool            isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const;
157         void                Contruct();
158         OPropNumericEditCtrl* CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId);
159         FixedText*          CreateText(sal_uInt16 _nTextRes);
160         void                InitializeControl(Control* _pControl,const rtl::OString& _sHelpId,bool _bAddChangeHandler);
161 
162     protected:
setRightAligned()163         inline  void    setRightAligned()       { m_bRightAligned = true; }
isRightAligned() const164         inline  bool    isRightAligned() const  { return m_bRightAligned; }
165 
saveCurrentFieldDescData()166         inline  void                saveCurrentFieldDescData() { SaveData( pActFieldDescr ); }
getCurrentFieldDescData()167         inline  OFieldDescription*  getCurrentFieldDescData() { return pActFieldDescr; }
setCurrentFieldDescData(OFieldDescription * _pDesc)168         inline  void                setCurrentFieldDescData( OFieldDescription* _pDesc ) { pActFieldDescr = _pDesc; }
169 
170         sal_uInt16          CountActiveAggregates() const;
171         sal_Int32           GetMaxControlHeight() const;
172 
173         virtual void        ActivateAggregate( EControlType eType );
174         virtual void        DeactivateAggregate( EControlType eType );
IsReadOnly()175         virtual sal_Bool        IsReadOnly() { return sal_False; };
176 
177         // Sind von den abgeleiteten Klassen zu impl.
178         virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > GetFormatter() const = 0;
179 
180         virtual ::com::sun::star::lang::Locale  GetLocale() const = 0;
181 
182         virtual void                            CellModified(long nRow, sal_uInt16 nColId ) = 0;
183         virtual void                            SetModified(sal_Bool bModified);    // base implementation is empty
184 
185         virtual TOTypeInfoSP                    getTypeInfo(sal_Int32 _nPos)        = 0;
186         virtual const OTypeInfoMap*             getTypeInfo() const  = 0;
187 
188         virtual sal_Bool                        isAutoIncrementValueEnabled() const = 0;
189         virtual ::rtl::OUString                 getAutoIncrementValue() const = 0;
190 
191         String                                  BoolStringPersistent(const String& rUIString) const;
192         String                                  BoolStringUI(const String& rPersistentString) const;
193 
getColumnCtrl() const194         const OPropColumnEditCtrl*              getColumnCtrl() const { return m_pColumnName; }
195 
196     public:
197         OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar);
198         OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar);
199         virtual ~OFieldDescControl();
200 
201         void                DisplayData(OFieldDescription* pFieldDescr );
202         //  void                DisplayData(const OColumn* pColumn);
203 
204         void                SaveData( OFieldDescription* pFieldDescr );
205         //  void                SaveData( OColumn* pColumn);
206 
207         void                SetControlText( sal_uInt16 nControlId, const String& rText );
208         String              GetControlText( sal_uInt16 nControlId );
209         void                SetReadOnly( sal_Bool bReadOnly );
210 
211         // Resize aufegrufen
212         void                CheckScrollBars();
213         sal_Bool            isCutAllowed();
214         sal_Bool            isCopyAllowed();
215         sal_Bool            isPasteAllowed();
216 
217         void                cut();
218         void                copy();
219         void                paste();
220 
221         virtual void        Init();
222         virtual void        GetFocus();
223         virtual void        LoseFocus();
224         virtual void        Resize();
225 
226         virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> getMetaData() = 0;
227         virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection() = 0;
228 
229         String              getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck = sal_True) const;
230 
setEditWidth(sal_Int32 _nWidth)231         inline void setEditWidth(sal_Int32 _nWidth) { m_nWidth = _nWidth; }
232     protected:
233         void    implFocusLost(Window* _pWhich);
234     };
235 }
236 #endif // DBAUI_FIELDDESCRIPTIONCONTROL_HXX
237 
238 
239