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