1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define ITEMID_HORJUSTIFY SID_ATTR_ALIGN_HOR_JUSTIFY 32*cdf0e10cSrcweir #define ITEMID_VERJUSTIFY SID_ATTR_ALIGN_VER_JUSTIFY 33*cdf0e10cSrcweir //#define ITEMID_ORIENTATION SID_ATTR_ALIGN_ORIENTATION 34*cdf0e10cSrcweir #define ITEMID_LINEBREAK SID_ATTR_ALIGN_LINEBREAK 35*cdf0e10cSrcweir #define ITEMID_MARGIN SID_ATTR_ALIGN_MARGIN 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include "FieldDescControl.hxx" 38*cdf0e10cSrcweir #include "FieldControls.hxx" 39*cdf0e10cSrcweir #include <tools/debug.hxx> 40*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 41*cdf0e10cSrcweir #include "TableDesignHelpBar.hxx" 42*cdf0e10cSrcweir #include <vcl/scrbar.hxx> 43*cdf0e10cSrcweir #include <vcl/button.hxx> 44*cdf0e10cSrcweir #include <vcl/svapp.hxx> 45*cdf0e10cSrcweir #include <vcl/fixed.hxx> 46*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 47*cdf0e10cSrcweir #include <vector> 48*cdf0e10cSrcweir #include "FieldDescriptions.hxx" 49*cdf0e10cSrcweir #include "dlgattr.hxx" 50*cdf0e10cSrcweir #include <svx/numfmtsh.hxx> 51*cdf0e10cSrcweir #include <svx/svxids.hrc> 52*cdf0e10cSrcweir #include <svx/algitem.hxx> 53*cdf0e10cSrcweir #include <svl/itempool.hxx> 54*cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE // ohne das bekomme ich einen Compiler-Fehler in <svl/zforlist.hxx> 55*cdf0e10cSrcweir #include <svl/zforlist.hxx> 56*cdf0e10cSrcweir #include <svl/rngitem.hxx> 57*cdf0e10cSrcweir #include <svl/intitem.hxx> 58*cdf0e10cSrcweir #include <svl/numuno.hxx> 59*cdf0e10cSrcweir #include <svtools/transfer.hxx> 60*cdf0e10cSrcweir #include <com/sun/star/lang/XUnoTunnel.hpp> 61*cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp> 62*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatPreviewer.hpp> 63*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp> 64*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 65*cdf0e10cSrcweir #include "QEnumTypes.hxx" 66*cdf0e10cSrcweir #include "dbaccess_helpid.hrc" 67*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 68*cdf0e10cSrcweir #include <connectivity/dbconversion.hxx> 69*cdf0e10cSrcweir #include <comphelper/numbers.hxx> 70*cdf0e10cSrcweir #include "UITools.hxx" 71*cdf0e10cSrcweir #include <memory> 72*cdf0e10cSrcweir #include "dbu_control.hrc" 73*cdf0e10cSrcweir #include "dbu_tbl.hrc" 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir using namespace dbaui; 77*cdf0e10cSrcweir using namespace dbtools; 78*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 79*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 80*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 81*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 82*cdf0e10cSrcweir using namespace ::com::sun::star::util; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir //================================================================== 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir // fuer die Controls auf der OFieldDescGenPage 87*cdf0e10cSrcweir #define CONTROL_SPACING_X 18 // 6 88*cdf0e10cSrcweir #define CONTROL_SPACING_Y 4 89*cdf0e10cSrcweir #define CONTROL_WIDTH_1 160 // 100 90*cdf0e10cSrcweir #define CONTROL_WIDTH_2 100 // 60 91*cdf0e10cSrcweir #define CONTROL_WIDTH_3 250 92*cdf0e10cSrcweir #define CONTROL_WIDTH_4 (CONTROL_WIDTH_3 - 20 - 5) 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir #define SBA_DEF_RANGEFORMAT (100 + 143) // RangeItem 95*cdf0e10cSrcweir #define SBA_DEF_FMTVALUE (100 + 144) // SfxULONG, Format 96*cdf0e10cSrcweir #define SBA_ATTR_ALIGN_HOR_JUSTIFY (100 + 145) // SvxHorJustifyItem 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir #define HSCROLL_STEP 20 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir 101*cdf0e10cSrcweir namespace 102*cdf0e10cSrcweir { 103*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 104*cdf0e10cSrcweir double checkDoubleForDateFormat(double _nValue,sal_Int32 _nFormatKey,const Reference< ::com::sun::star::util::XNumberFormatter>& _xNumberFormatter) 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir double nValue = _nValue; 107*cdf0e10cSrcweir sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(_xNumberFormatter,_nFormatKey); 108*cdf0e10cSrcweir if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE 109*cdf0e10cSrcweir || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME ) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir nValue = DBTypeConversion::toStandardDbDate(DBTypeConversion::getNULLDate(_xNumberFormatter->getNumberFormatsSupplier()),nValue); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir return nValue; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 117*cdf0e10cSrcweir template< typename T1, typename T2> void lcl_HideAndDeleteControl(short& _nPos,T1** _pControl,T2** _pControlText) 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir if ( *_pControl ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir --_nPos; 122*cdf0e10cSrcweir (*_pControl)->Hide(); 123*cdf0e10cSrcweir (*_pControlText)->Hide(); 124*cdf0e10cSrcweir delete *_pControl; 125*cdf0e10cSrcweir delete *_pControlText; 126*cdf0e10cSrcweir (*_pControl) = NULL; 127*cdf0e10cSrcweir (*_pControlText) = NULL; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //================================================================== 134*cdf0e10cSrcweir // class OFieldDescControl 135*cdf0e10cSrcweir //================================================================== 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir DBG_NAME(OFieldDescControl) 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir //================================================================== 140*cdf0e10cSrcweir OFieldDescControl::OFieldDescControl( Window* pParent, const ResId& rResId, OTableDesignHelpBar* pHelpBar) 141*cdf0e10cSrcweir :TabPage( pParent, rResId ) 142*cdf0e10cSrcweir ,pHelp( pHelpBar ) 143*cdf0e10cSrcweir ,pLastFocusWindow(NULL) 144*cdf0e10cSrcweir ,m_pActFocusWindow(NULL) 145*cdf0e10cSrcweir ,pDefaultText(NULL) 146*cdf0e10cSrcweir ,pRequiredText(NULL) 147*cdf0e10cSrcweir ,pAutoIncrementText(NULL) 148*cdf0e10cSrcweir ,pTextLenText(NULL) 149*cdf0e10cSrcweir ,pNumTypeText(NULL) 150*cdf0e10cSrcweir ,pLengthText(NULL) 151*cdf0e10cSrcweir ,pScaleText(NULL) 152*cdf0e10cSrcweir ,pFormatText(NULL) 153*cdf0e10cSrcweir ,pBoolDefaultText(NULL) 154*cdf0e10cSrcweir ,m_pColumnNameText(NULL) 155*cdf0e10cSrcweir ,m_pTypeText(NULL) 156*cdf0e10cSrcweir ,m_pAutoIncrementValueText(NULL) 157*cdf0e10cSrcweir ,pRequired(NULL) 158*cdf0e10cSrcweir ,pNumType(NULL) 159*cdf0e10cSrcweir ,pAutoIncrement(NULL) 160*cdf0e10cSrcweir ,pDefault(NULL) 161*cdf0e10cSrcweir ,pTextLen(NULL) 162*cdf0e10cSrcweir ,pLength(NULL) 163*cdf0e10cSrcweir ,pScale(NULL) 164*cdf0e10cSrcweir ,pFormatSample(NULL) 165*cdf0e10cSrcweir ,pBoolDefault(NULL) 166*cdf0e10cSrcweir ,m_pColumnName(NULL) 167*cdf0e10cSrcweir ,m_pType(NULL) 168*cdf0e10cSrcweir ,m_pAutoIncrementValue(NULL) 169*cdf0e10cSrcweir ,pFormat(NULL) 170*cdf0e10cSrcweir ,m_pVertScroll( NULL ) 171*cdf0e10cSrcweir ,m_pHorzScroll( NULL ) 172*cdf0e10cSrcweir ,m_pPreviousType() 173*cdf0e10cSrcweir ,nCurChildId(1) 174*cdf0e10cSrcweir ,m_nPos(-1) 175*cdf0e10cSrcweir ,aYes(ModuleRes(STR_VALUE_YES)) 176*cdf0e10cSrcweir ,aNo(ModuleRes(STR_VALUE_NO)) 177*cdf0e10cSrcweir ,m_nOldVThumb( 0 ) 178*cdf0e10cSrcweir ,m_nOldHThumb( 0 ) 179*cdf0e10cSrcweir ,m_nWidth(50) 180*cdf0e10cSrcweir ,nDelayedGrabFocusEvent(0) 181*cdf0e10cSrcweir ,m_bAdded(sal_False) 182*cdf0e10cSrcweir ,m_bRightAligned(false) 183*cdf0e10cSrcweir ,pActFieldDescr(NULL) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir DBG_CTOR(OFieldDescControl,NULL); 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir Contruct(); 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir //------------------------------------------------------------------------------ 190*cdf0e10cSrcweir OFieldDescControl::OFieldDescControl( Window* pParent, OTableDesignHelpBar* pHelpBar ) 191*cdf0e10cSrcweir :TabPage( pParent, WB_3DLOOK | WB_DIALOGCONTROL ) 192*cdf0e10cSrcweir ,pHelp( pHelpBar ) 193*cdf0e10cSrcweir ,pLastFocusWindow(NULL) 194*cdf0e10cSrcweir ,m_pActFocusWindow(NULL) 195*cdf0e10cSrcweir ,pDefaultText(NULL) 196*cdf0e10cSrcweir ,pRequiredText(NULL) 197*cdf0e10cSrcweir ,pAutoIncrementText(NULL) 198*cdf0e10cSrcweir ,pTextLenText(NULL) 199*cdf0e10cSrcweir ,pNumTypeText(NULL) 200*cdf0e10cSrcweir ,pLengthText(NULL) 201*cdf0e10cSrcweir ,pScaleText(NULL) 202*cdf0e10cSrcweir ,pFormatText(NULL) 203*cdf0e10cSrcweir ,pBoolDefaultText(NULL) 204*cdf0e10cSrcweir ,m_pColumnNameText(NULL) 205*cdf0e10cSrcweir ,m_pTypeText(NULL) 206*cdf0e10cSrcweir ,m_pAutoIncrementValueText(NULL) 207*cdf0e10cSrcweir ,pRequired(NULL) 208*cdf0e10cSrcweir ,pNumType(NULL) 209*cdf0e10cSrcweir ,pAutoIncrement(NULL) 210*cdf0e10cSrcweir ,pDefault(NULL) 211*cdf0e10cSrcweir ,pTextLen(NULL) 212*cdf0e10cSrcweir ,pLength(NULL) 213*cdf0e10cSrcweir ,pScale(NULL) 214*cdf0e10cSrcweir ,pFormatSample(NULL) 215*cdf0e10cSrcweir ,pBoolDefault(NULL) 216*cdf0e10cSrcweir ,m_pColumnName(NULL) 217*cdf0e10cSrcweir ,m_pType(NULL) 218*cdf0e10cSrcweir ,m_pAutoIncrementValue(NULL) 219*cdf0e10cSrcweir ,pFormat(NULL) 220*cdf0e10cSrcweir ,m_pVertScroll( NULL ) 221*cdf0e10cSrcweir ,m_pHorzScroll( NULL ) 222*cdf0e10cSrcweir ,m_pPreviousType() 223*cdf0e10cSrcweir ,nCurChildId(1) 224*cdf0e10cSrcweir ,m_nPos(-1) 225*cdf0e10cSrcweir ,aYes(ModuleRes(STR_VALUE_YES)) 226*cdf0e10cSrcweir ,aNo(ModuleRes(STR_VALUE_NO)) 227*cdf0e10cSrcweir ,m_nOldVThumb( 0 ) 228*cdf0e10cSrcweir ,m_nOldHThumb( 0 ) 229*cdf0e10cSrcweir ,m_nWidth(50) 230*cdf0e10cSrcweir ,nDelayedGrabFocusEvent(0) 231*cdf0e10cSrcweir ,m_bAdded(sal_False) 232*cdf0e10cSrcweir ,m_bRightAligned(false) 233*cdf0e10cSrcweir ,pActFieldDescr(NULL) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir DBG_CTOR(OFieldDescControl,NULL); 236*cdf0e10cSrcweir Contruct(); 237*cdf0e10cSrcweir } 238*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 239*cdf0e10cSrcweir void OFieldDescControl::Contruct() 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir m_pVertScroll = new ScrollBar(this, WB_VSCROLL | WB_REPEAT | WB_DRAG); 242*cdf0e10cSrcweir m_pHorzScroll = new ScrollBar(this, WB_HSCROLL | WB_REPEAT | WB_DRAG); 243*cdf0e10cSrcweir m_pVertScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); 244*cdf0e10cSrcweir m_pHorzScroll->SetScrollHdl(LINK(this, OFieldDescControl, OnScroll)); 245*cdf0e10cSrcweir m_pVertScroll->Show(); 246*cdf0e10cSrcweir m_pHorzScroll->Show(); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir m_pVertScroll->EnableClipSiblings(); 249*cdf0e10cSrcweir m_pHorzScroll->EnableClipSiblings(); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir m_pVertScroll->SetLineSize(1); 252*cdf0e10cSrcweir m_pVertScroll->SetPageSize(1); 253*cdf0e10cSrcweir m_pHorzScroll->SetLineSize(1); 254*cdf0e10cSrcweir m_pHorzScroll->SetPageSize(1); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir m_nOldVThumb = m_nOldHThumb = 0; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir //------------------------------------------------------------------------------ 260*cdf0e10cSrcweir OFieldDescControl::~OFieldDescControl() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir DBG_DTOR(OFieldDescControl,NULL); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pVertScroll); 266*cdf0e10cSrcweir m_pVertScroll = NULL; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir ::std::auto_ptr<Window> aTemp(m_pHorzScroll); 270*cdf0e10cSrcweir m_pHorzScroll = NULL; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir if ( m_bAdded ) 273*cdf0e10cSrcweir ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); 274*cdf0e10cSrcweir pLastFocusWindow = NULL; 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 277*cdf0e10cSrcweir // Childs zerstoeren 278*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 279*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 280*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 281*cdf0e10cSrcweir DeactivateAggregate( tpNumType ); 282*cdf0e10cSrcweir DeactivateAggregate( tpScale ); 283*cdf0e10cSrcweir DeactivateAggregate( tpLength ); 284*cdf0e10cSrcweir DeactivateAggregate( tpFormat ); 285*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrement ); 286*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 287*cdf0e10cSrcweir DeactivateAggregate( tpColumnName ); 288*cdf0e10cSrcweir DeactivateAggregate( tpType ); 289*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrementValue ); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if(nDelayedGrabFocusEvent) 292*cdf0e10cSrcweir Application::RemoveUserEvent(nDelayedGrabFocusEvent); 293*cdf0e10cSrcweir } 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir //------------------------------------------------------------------------------ 296*cdf0e10cSrcweir String OFieldDescControl::BoolStringPersistent(const String& rUIString) const 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir static String aZero('0'); 299*cdf0e10cSrcweir static String aOne('1'); 300*cdf0e10cSrcweir 301*cdf0e10cSrcweir if (rUIString == aNo) 302*cdf0e10cSrcweir return aZero; 303*cdf0e10cSrcweir if (rUIString == aYes) 304*cdf0e10cSrcweir return aOne; 305*cdf0e10cSrcweir return String(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir //------------------------------------------------------------------------------ 309*cdf0e10cSrcweir String OFieldDescControl::BoolStringUI(const String& rPersistentString) const 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir static String aZero('0'); 312*cdf0e10cSrcweir static String aOne('1'); 313*cdf0e10cSrcweir static String aNone(ModuleRes(STR_VALUE_NONE)); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir // FS - 66161 - 14.05.1999 - aeltere Versionen haben eventuell einen sprachabhaengigen String als Default gespeichert 316*cdf0e10cSrcweir if (rPersistentString.Equals(aYes) || rPersistentString.Equals(aNo)) 317*cdf0e10cSrcweir return rPersistentString; 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir if (rPersistentString == aZero) 320*cdf0e10cSrcweir return aNo; 321*cdf0e10cSrcweir if (rPersistentString == aOne) 322*cdf0e10cSrcweir return aYes; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir return aNone; 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir //------------------------------------------------------------------------------ 328*cdf0e10cSrcweir void OFieldDescControl::Init() 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatter > xFormatter = GetFormatter(); 331*cdf0e10cSrcweir ::dbaui::setEvalDateFormatForFormatter(xFormatter); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir //------------------------------------------------------------------------------ 335*cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnScroll, ScrollBar*, /*pBar*/) 336*cdf0e10cSrcweir { 337*cdf0e10cSrcweir ScrollAllAggregates(); 338*cdf0e10cSrcweir return 0; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 341*cdf0e10cSrcweir namespace 342*cdf0e10cSrcweir { 343*cdf0e10cSrcweir void getMaxXPosition(Window* _pWindow,long& _rnMaxXPosition) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir if (_pWindow) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir long nTemp = _pWindow->GetSizePixel().Width() + _pWindow->GetPosPixel().X(); 348*cdf0e10cSrcweir _rnMaxXPosition = ::std::max(_rnMaxXPosition, nTemp); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir //------------------------------------------------------------------------------ 353*cdf0e10cSrcweir void OFieldDescControl::CheckScrollBars() 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir // ein paar Berechnungen zur neuen Position der ScrollBars 356*cdf0e10cSrcweir Size szOverallSize = GetSizePixel(); 357*cdf0e10cSrcweir long nHScrollHeight = m_pHorzScroll->GetSizePixel().Height(); 358*cdf0e10cSrcweir long nVScrollWidth = m_pVertScroll->GetSizePixel().Width(); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir long nNewHWidth = szOverallSize.Width() - nVScrollWidth; 361*cdf0e10cSrcweir long nNewVHeight = szOverallSize.Height() - nHScrollHeight; 362*cdf0e10cSrcweir 363*cdf0e10cSrcweir sal_Bool bNeedHScrollBar(sal_False), bNeedVScrollBar(sal_False); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir // die Bereiche anpassen 366*cdf0e10cSrcweir // brauche ich ScrollBars eigentlich ? 367*cdf0e10cSrcweir // horizontal : 368*cdf0e10cSrcweir long lMaxXPosition = 0; 369*cdf0e10cSrcweir Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue}; 370*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) 371*cdf0e10cSrcweir getMaxXPosition(ppAggregates[i],lMaxXPosition); 372*cdf0e10cSrcweir 373*cdf0e10cSrcweir if (m_pHorzScroll) 374*cdf0e10cSrcweir lMaxXPosition += m_pHorzScroll->GetThumbPos() * HSCROLL_STEP; 375*cdf0e10cSrcweir 376*cdf0e10cSrcweir long lMaxXAvailable = szOverallSize.Width(); 377*cdf0e10cSrcweir bNeedHScrollBar = lMaxXPosition > lMaxXAvailable; 378*cdf0e10cSrcweir // aendert sich vielleicht noch 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir // vertikal 381*cdf0e10cSrcweir // wieviel Controls habe ich 382*cdf0e10cSrcweir sal_uInt16 nActive = CountActiveAggregates(); 383*cdf0e10cSrcweir // welches ist das letzte, was ganz drauf passt ? 384*cdf0e10cSrcweir sal_uInt16 nLastVisible; 385*cdf0e10cSrcweir const sal_Int32 nControlHeight = GetMaxControlHeight(); 386*cdf0e10cSrcweir const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); 387*cdf0e10cSrcweir if (bNeedHScrollBar) 388*cdf0e10cSrcweir nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight)); 389*cdf0e10cSrcweir else 390*cdf0e10cSrcweir nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y) / (nControl_Spacing_y + nControlHeight)); 391*cdf0e10cSrcweir bNeedVScrollBar = nActive>nLastVisible; 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir if (bNeedVScrollBar) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir // in die urspruengliche Berechnung von lMaxXAvailable ist nicht mit eingegangen, dass ich eine VScrollBar habe, also muss ich 396*cdf0e10cSrcweir // das nachholen 397*cdf0e10cSrcweir lMaxXAvailable -= nVScrollWidth; 398*cdf0e10cSrcweir if (!bNeedHScrollBar && (lMaxXPosition > lMaxXAvailable)) 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir // durch die vertikale brauche ich jetzt ploetzlich doch eine horizontale 401*cdf0e10cSrcweir bNeedHScrollBar = sal_True; 402*cdf0e10cSrcweir // nLastVisible anpassen 403*cdf0e10cSrcweir nLastVisible = static_cast<sal_uInt16>((szOverallSize.Height() - nControl_Spacing_y - nHScrollHeight) / (nControl_Spacing_y + nControlHeight)); 404*cdf0e10cSrcweir // bNeedVScrollBar aendert sich nicht : es ist schon auf sal_True und nLastVisible wird hoechstens kleiner 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // jetzt kann ich sie wirklich positionieren und ihre Parameter setzen 409*cdf0e10cSrcweir if (bNeedVScrollBar) 410*cdf0e10cSrcweir { 411*cdf0e10cSrcweir m_pVertScroll->Show(); 412*cdf0e10cSrcweir m_pVertScroll->SetRangeMax(nActive - nLastVisible); 413*cdf0e10cSrcweir // m_pVertScroll->SetThumbPos(0); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir m_pVertScroll->SetPosSizePixel( Point(nNewHWidth, 0), Size(nVScrollWidth, szOverallSize.Height()) ); 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir else 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir m_pVertScroll->Hide(); 420*cdf0e10cSrcweir m_pVertScroll->SetRangeMax(0); 421*cdf0e10cSrcweir m_pVertScroll->SetThumbPos(0); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if (bNeedHScrollBar) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir m_pHorzScroll->Show(); 427*cdf0e10cSrcweir m_pHorzScroll->SetRangeMax((lMaxXPosition - lMaxXAvailable + HSCROLL_STEP - 1 )/HSCROLL_STEP); 428*cdf0e10cSrcweir // m_pHorzScroll->SetThumbPos(0); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir m_pHorzScroll->SetPosSizePixel( Point(0, nNewVHeight), Size(bNeedVScrollBar ? nNewHWidth : szOverallSize.Width(), nHScrollHeight) ); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir else 433*cdf0e10cSrcweir { 434*cdf0e10cSrcweir m_pHorzScroll->Hide(); 435*cdf0e10cSrcweir m_pHorzScroll->SetRangeMax(0); 436*cdf0e10cSrcweir m_pHorzScroll->SetThumbPos(0); 437*cdf0e10cSrcweir } 438*cdf0e10cSrcweir } 439*cdf0e10cSrcweir 440*cdf0e10cSrcweir //------------------------------------------------------------------------------ 441*cdf0e10cSrcweir void OFieldDescControl::Resize() 442*cdf0e10cSrcweir { 443*cdf0e10cSrcweir CheckScrollBars(); 444*cdf0e10cSrcweir ScrollAllAggregates(); 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir 447*cdf0e10cSrcweir //------------------------------------------------------------------------------ 448*cdf0e10cSrcweir inline void OFieldDescControl::ScrollAggregate(Control* pText, Control* pInput, Control* pButton, long nDeltaX, long nDeltaY) 449*cdf0e10cSrcweir { 450*cdf0e10cSrcweir if (!pText) 451*cdf0e10cSrcweir return; 452*cdf0e10cSrcweir pText->SetPosPixel(pText->GetPosPixel() + Point(nDeltaX, nDeltaY)); 453*cdf0e10cSrcweir pInput->SetPosPixel(pInput->GetPosPixel() + Point(nDeltaX, nDeltaY)); 454*cdf0e10cSrcweir if (pButton) 455*cdf0e10cSrcweir pButton->SetPosPixel(pButton->GetPosPixel() + Point(nDeltaX, nDeltaY)); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir //------------------------------------------------------------------------------ 459*cdf0e10cSrcweir void OFieldDescControl::ScrollAllAggregates() 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir long nDeltaX = 0, nDeltaY = 0; 462*cdf0e10cSrcweir if (m_nOldHThumb != m_pHorzScroll->GetThumbPos()) 463*cdf0e10cSrcweir { 464*cdf0e10cSrcweir nDeltaX = (m_nOldHThumb - m_pHorzScroll->GetThumbPos()) * HSCROLL_STEP; 465*cdf0e10cSrcweir m_nOldHThumb = m_pHorzScroll->GetThumbPos(); 466*cdf0e10cSrcweir } 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir if (m_nOldVThumb != m_pVertScroll->GetThumbPos()) 469*cdf0e10cSrcweir { 470*cdf0e10cSrcweir const sal_Int32 nControlHeight = GetMaxControlHeight(); 471*cdf0e10cSrcweir const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); 472*cdf0e10cSrcweir nDeltaY = (m_nOldVThumb - m_pVertScroll->GetThumbPos()) * (nControl_Spacing_y + nControlHeight); 473*cdf0e10cSrcweir m_nOldVThumb = m_pVertScroll->GetThumbPos(); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir if (nDeltaX || nDeltaY) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir Control* ppAggregates[] = { pRequired, pNumType 479*cdf0e10cSrcweir , pAutoIncrement, pDefault 480*cdf0e10cSrcweir , pTextLen, pLength 481*cdf0e10cSrcweir , pScale, m_pColumnName 482*cdf0e10cSrcweir , m_pType, m_pAutoIncrementValue}; 483*cdf0e10cSrcweir Control* ppAggregatesText[] = { pRequiredText, pNumTypeText 484*cdf0e10cSrcweir , pAutoIncrementText, pDefaultText 485*cdf0e10cSrcweir , pTextLenText, pLengthText 486*cdf0e10cSrcweir , pScaleText, m_pColumnNameText 487*cdf0e10cSrcweir , m_pTypeText, m_pAutoIncrementValueText}; 488*cdf0e10cSrcweir OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!"); 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) 491*cdf0e10cSrcweir ScrollAggregate(ppAggregatesText[i],ppAggregates[i],NULL,nDeltaX, nDeltaY); 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir ScrollAggregate(pFormatText,pFormatSample,pFormat,nDeltaX, nDeltaY); 494*cdf0e10cSrcweir } 495*cdf0e10cSrcweir } 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir //------------------------------------------------------------------------------ 498*cdf0e10cSrcweir sal_uInt16 OFieldDescControl::CountActiveAggregates() const 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue}; 501*cdf0e10cSrcweir sal_uInt16 nVisibleAggregates = 0; 502*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) 503*cdf0e10cSrcweir if (ppAggregates[i]) 504*cdf0e10cSrcweir ++nVisibleAggregates; 505*cdf0e10cSrcweir return nVisibleAggregates; 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir //------------------------------------------------------------------------------ 508*cdf0e10cSrcweir sal_Int32 OFieldDescControl::GetMaxControlHeight() const 509*cdf0e10cSrcweir { 510*cdf0e10cSrcweir Size aHeight; 511*cdf0e10cSrcweir Control* ppAggregates[] = { pRequired, pNumType, pAutoIncrement, pDefault, pTextLen, pLength, pScale, pFormat, m_pColumnName, m_pType,m_pAutoIncrementValue}; 512*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir if ( ppAggregates[i] ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir const Size aTemp( ppAggregates[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) ); 517*cdf0e10cSrcweir if ( aTemp.Height() > aHeight.Height() ) 518*cdf0e10cSrcweir aHeight.Height() = aTemp.Height(); 519*cdf0e10cSrcweir } // if ( ppAggregates[i] ) 520*cdf0e10cSrcweir } 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir return aHeight.Height(); 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir //------------------------------------------------------------------------------ 525*cdf0e10cSrcweir void OFieldDescControl::SetReadOnly( sal_Bool bReadOnly ) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 528*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 529*cdf0e10cSrcweir // Controls enablen/disablen 530*cdf0e10cSrcweir Control* ppAggregates[] = { pRequired, pNumType 531*cdf0e10cSrcweir , pAutoIncrement, pDefault 532*cdf0e10cSrcweir , pTextLen, pLength 533*cdf0e10cSrcweir , pScale, m_pColumnName 534*cdf0e10cSrcweir , m_pType, m_pAutoIncrementValue 535*cdf0e10cSrcweir , pFormat}; 536*cdf0e10cSrcweir Control* ppAggregatesText[] = { pRequiredText, pNumTypeText 537*cdf0e10cSrcweir , pAutoIncrementText, pDefaultText 538*cdf0e10cSrcweir , pTextLenText, pLengthText 539*cdf0e10cSrcweir , pScaleText, m_pColumnNameText 540*cdf0e10cSrcweir , m_pTypeText, m_pAutoIncrementValueText 541*cdf0e10cSrcweir , pFormatText}; 542*cdf0e10cSrcweir 543*cdf0e10cSrcweir OSL_ENSURE(sizeof(ppAggregates)/sizeof(ppAggregates[0]) == sizeof(ppAggregatesText)/sizeof(ppAggregatesText[0]),"Lists are not identical!"); 544*cdf0e10cSrcweir 545*cdf0e10cSrcweir for (sal_uInt16 i=0; i<sizeof(ppAggregates)/sizeof(ppAggregates[0]); ++i) 546*cdf0e10cSrcweir { 547*cdf0e10cSrcweir if ( ppAggregatesText[i] ) 548*cdf0e10cSrcweir ppAggregatesText[i]->Enable( !bReadOnly ); 549*cdf0e10cSrcweir if ( ppAggregates[i] ) 550*cdf0e10cSrcweir ppAggregates[i]->Enable( !bReadOnly ); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir } 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir //------------------------------------------------------------------------------ 555*cdf0e10cSrcweir String OFieldDescControl::GetControlText( sal_uInt16 nControlId ) 556*cdf0e10cSrcweir { 557*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 558*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 559*cdf0e10cSrcweir // Texte der Controls auslesen 560*cdf0e10cSrcweir switch( nControlId ) 561*cdf0e10cSrcweir { 562*cdf0e10cSrcweir case FIELD_PROPERTY_BOOL_DEFAULT: 563*cdf0e10cSrcweir if (pBoolDefault) 564*cdf0e10cSrcweir return pBoolDefault->GetSelectEntry(); 565*cdf0e10cSrcweir break; 566*cdf0e10cSrcweir case FIELD_PROPERTY_DEFAULT: 567*cdf0e10cSrcweir if (pDefault) 568*cdf0e10cSrcweir return pDefault->GetText(); 569*cdf0e10cSrcweir break; 570*cdf0e10cSrcweir case FIELD_PROPERTY_REQUIRED: 571*cdf0e10cSrcweir if (pRequired) 572*cdf0e10cSrcweir return pRequired->GetSelectEntry(); 573*cdf0e10cSrcweir break; 574*cdf0e10cSrcweir case FIELD_PROPERTY_TEXTLEN: 575*cdf0e10cSrcweir if (pTextLen) 576*cdf0e10cSrcweir return String::CreateFromInt64(pTextLen->GetValue()); 577*cdf0e10cSrcweir case FIELD_PROPERTY_NUMTYPE: 578*cdf0e10cSrcweir if (pNumType) 579*cdf0e10cSrcweir return pNumType->GetSelectEntry(); 580*cdf0e10cSrcweir break; 581*cdf0e10cSrcweir case FIELD_PROPERTY_AUTOINC: 582*cdf0e10cSrcweir if (pAutoIncrement) 583*cdf0e10cSrcweir return pAutoIncrement->GetSelectEntry(); 584*cdf0e10cSrcweir break; 585*cdf0e10cSrcweir case FIELD_PROPERTY_LENGTH: 586*cdf0e10cSrcweir if (pLength) 587*cdf0e10cSrcweir return pLength->GetText(); 588*cdf0e10cSrcweir break; 589*cdf0e10cSrcweir case FIELD_PROPERTY_SCALE: 590*cdf0e10cSrcweir if (pScale) 591*cdf0e10cSrcweir return pScale->GetText(); 592*cdf0e10cSrcweir break; 593*cdf0e10cSrcweir case FIELD_PROPERTY_FORMAT: 594*cdf0e10cSrcweir if (pFormatSample) 595*cdf0e10cSrcweir return pFormatSample->GetText(); 596*cdf0e10cSrcweir break; 597*cdf0e10cSrcweir case FIELD_PRPOERTY_COLUMNNAME: 598*cdf0e10cSrcweir if(m_pColumnName) 599*cdf0e10cSrcweir return m_pColumnName->GetText(); 600*cdf0e10cSrcweir case FIELD_PRPOERTY_TYPE: 601*cdf0e10cSrcweir if(m_pType) 602*cdf0e10cSrcweir return m_pType->GetSelectEntry(); 603*cdf0e10cSrcweir break; 604*cdf0e10cSrcweir case FIELD_PRPOERTY_AUTOINCREMENT: 605*cdf0e10cSrcweir if(m_pAutoIncrementValue) 606*cdf0e10cSrcweir return m_pAutoIncrementValue->GetText(); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir return String(); 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir 612*cdf0e10cSrcweir //------------------------------------------------------------------------------ 613*cdf0e10cSrcweir void OFieldDescControl::SetControlText( sal_uInt16 nControlId, const String& rText ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 616*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 617*cdf0e10cSrcweir // Texte der Controls setzen 618*cdf0e10cSrcweir switch( nControlId ) 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir case FIELD_PROPERTY_BOOL_DEFAULT: 621*cdf0e10cSrcweir if (pBoolDefault) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir String sOld = pBoolDefault->GetSelectEntry(); 624*cdf0e10cSrcweir pBoolDefault->SelectEntry(rText); 625*cdf0e10cSrcweir if (!sOld.Equals(rText)) 626*cdf0e10cSrcweir LINK(this, OFieldDescControl, ChangeHdl).Call(pBoolDefault); 627*cdf0e10cSrcweir } 628*cdf0e10cSrcweir break; 629*cdf0e10cSrcweir case FIELD_PROPERTY_DEFAULT: 630*cdf0e10cSrcweir if (pDefault) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir pDefault->SetText(rText); 633*cdf0e10cSrcweir UpdateFormatSample(pActFieldDescr); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir break; 636*cdf0e10cSrcweir 637*cdf0e10cSrcweir case FIELD_PROPERTY_REQUIRED: 638*cdf0e10cSrcweir if (pRequired) 639*cdf0e10cSrcweir pRequired->SelectEntry(rText); 640*cdf0e10cSrcweir break; 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir 643*cdf0e10cSrcweir case FIELD_PROPERTY_TEXTLEN: 644*cdf0e10cSrcweir if (pTextLen) 645*cdf0e10cSrcweir pTextLen->SetText(rText); 646*cdf0e10cSrcweir break; 647*cdf0e10cSrcweir 648*cdf0e10cSrcweir case FIELD_PROPERTY_NUMTYPE: 649*cdf0e10cSrcweir if (pNumType) 650*cdf0e10cSrcweir pNumType->SelectEntry(rText); 651*cdf0e10cSrcweir break; 652*cdf0e10cSrcweir 653*cdf0e10cSrcweir case FIELD_PROPERTY_AUTOINC: 654*cdf0e10cSrcweir if (pAutoIncrement) 655*cdf0e10cSrcweir { 656*cdf0e10cSrcweir String sOld = pAutoIncrement->GetSelectEntry(); 657*cdf0e10cSrcweir pAutoIncrement->SelectEntry(rText); 658*cdf0e10cSrcweir if (!sOld.Equals(rText)) 659*cdf0e10cSrcweir LINK(this, OFieldDescControl, ChangeHdl).Call(pAutoIncrement); 660*cdf0e10cSrcweir } 661*cdf0e10cSrcweir break; 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir case FIELD_PROPERTY_LENGTH: 664*cdf0e10cSrcweir if (pLength) 665*cdf0e10cSrcweir pLength->SetText(rText); 666*cdf0e10cSrcweir break; 667*cdf0e10cSrcweir 668*cdf0e10cSrcweir case FIELD_PROPERTY_SCALE: 669*cdf0e10cSrcweir if (pScale) 670*cdf0e10cSrcweir pScale->SetText(rText); 671*cdf0e10cSrcweir break; 672*cdf0e10cSrcweir 673*cdf0e10cSrcweir case FIELD_PROPERTY_FORMAT: 674*cdf0e10cSrcweir if (pActFieldDescr) 675*cdf0e10cSrcweir UpdateFormatSample(pActFieldDescr); 676*cdf0e10cSrcweir break; 677*cdf0e10cSrcweir case FIELD_PRPOERTY_COLUMNNAME: 678*cdf0e10cSrcweir if(m_pColumnName) 679*cdf0e10cSrcweir m_pColumnName->SetText(rText); 680*cdf0e10cSrcweir break; 681*cdf0e10cSrcweir case FIELD_PRPOERTY_TYPE: 682*cdf0e10cSrcweir if(m_pType) 683*cdf0e10cSrcweir m_pType->SelectEntry(rText); 684*cdf0e10cSrcweir break; 685*cdf0e10cSrcweir case FIELD_PRPOERTY_AUTOINCREMENT: 686*cdf0e10cSrcweir if(m_pAutoIncrementValue) 687*cdf0e10cSrcweir m_pAutoIncrementValue->SetText(rText); 688*cdf0e10cSrcweir break; 689*cdf0e10cSrcweir } 690*cdf0e10cSrcweir } 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir //------------------------------------------------------------------------ 693*cdf0e10cSrcweir IMPL_LINK( OFieldDescControl, FormatClickHdl, Button *, /*pButton*/ ) 694*cdf0e10cSrcweir { 695*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 696*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 697*cdf0e10cSrcweir // Temporaere Column erzeugen, mit der Datenaustausch mit Dialog erfolgt 698*cdf0e10cSrcweir if( !pActFieldDescr ) 699*cdf0e10cSrcweir return 0; 700*cdf0e10cSrcweir 701*cdf0e10cSrcweir sal_Int32 nOldFormatKey(pActFieldDescr->GetFormatKey()); 702*cdf0e10cSrcweir SvxCellHorJustify rOldJustify = pActFieldDescr->GetHorJustify(); 703*cdf0e10cSrcweir Reference< XNumberFormatsSupplier > xSupplier = GetFormatter()->getNumberFormatsSupplier(); 704*cdf0e10cSrcweir SvNumberFormatsSupplierObj* pSupplierImpl = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); 705*cdf0e10cSrcweir 706*cdf0e10cSrcweir SvNumberFormatter* pFormatter = pSupplierImpl->GetNumberFormatter(); 707*cdf0e10cSrcweir sal_uInt16 nFlags; 708*cdf0e10cSrcweir if(::dbaui::callColumnFormatDialog(this,pFormatter,pActFieldDescr->GetType(),nOldFormatKey,rOldJustify,nFlags,sal_True)) 709*cdf0e10cSrcweir { 710*cdf0e10cSrcweir sal_Bool bModified = sal_False; 711*cdf0e10cSrcweir if(nOldFormatKey != pActFieldDescr->GetFormatKey()) 712*cdf0e10cSrcweir { 713*cdf0e10cSrcweir pActFieldDescr->SetFormatKey( nOldFormatKey ); 714*cdf0e10cSrcweir bModified = sal_True; 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir if(rOldJustify != pActFieldDescr->GetHorJustify()) 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir pActFieldDescr->SetHorJustify( rOldJustify ); 719*cdf0e10cSrcweir bModified = sal_True; 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir if(bModified) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir SetModified(sal_True); 725*cdf0e10cSrcweir UpdateFormatSample(pActFieldDescr); 726*cdf0e10cSrcweir } 727*cdf0e10cSrcweir } 728*cdf0e10cSrcweir return 0; 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir // ----------------------------------------------------------------------- 732*cdf0e10cSrcweir void OFieldDescControl::SetModified(sal_Bool /*bModified*/) 733*cdf0e10cSrcweir { 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir //------------------------------------------------------------------------ 736*cdf0e10cSrcweir IMPL_LINK( OFieldDescControl, ChangeHdl, ListBox *, pListBox ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 739*cdf0e10cSrcweir if ( !pActFieldDescr ) 740*cdf0e10cSrcweir return 0; 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir if ( pListBox->GetSavedValue() != pListBox->GetSelectEntryPos() ) 743*cdf0e10cSrcweir SetModified(sal_True); 744*cdf0e10cSrcweir 745*cdf0e10cSrcweir // Sonderbehandlund f"ur Bool Felder 746*cdf0e10cSrcweir if(pListBox == pRequired && pBoolDefault ) 747*cdf0e10cSrcweir { 748*cdf0e10cSrcweir // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen 749*cdf0e10cSrcweir String sDef = BoolStringUI(::comphelper::getString(pActFieldDescr->GetControlDefault())); 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir if(pRequired->GetSelectEntryPos() == 0) // JA 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE))); 754*cdf0e10cSrcweir if (!sDef.Equals(aYes) && !sDef.Equals(aNo)) 755*cdf0e10cSrcweir pBoolDefault->SelectEntryPos(1); // nein als Default 756*cdf0e10cSrcweir else 757*cdf0e10cSrcweir pBoolDefault->SelectEntry(sDef); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir else if(pBoolDefault->GetEntryCount() < 3) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); 762*cdf0e10cSrcweir pBoolDefault->SelectEntry(sDef); 763*cdf0e10cSrcweir } 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir 766*cdf0e10cSrcweir // nur fuer AutoIncrement eine Sonderbehandlung 767*cdf0e10cSrcweir if (pListBox == pAutoIncrement) 768*cdf0e10cSrcweir { 769*cdf0e10cSrcweir if(pListBox->GetSelectEntryPos() == 1) 770*cdf0e10cSrcweir { // no 771*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrementValue ); 772*cdf0e10cSrcweir if(pActFieldDescr->IsPrimaryKey()) 773*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 774*cdf0e10cSrcweir else if( pActFieldDescr->getTypeInfo()->bNullable ) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir ActivateAggregate( tpRequired ); 777*cdf0e10cSrcweir if(pRequired) 778*cdf0e10cSrcweir { 779*cdf0e10cSrcweir if( pActFieldDescr->IsNullable() ) 780*cdf0e10cSrcweir pRequired->SelectEntryPos( 1 ); // no 781*cdf0e10cSrcweir else 782*cdf0e10cSrcweir pRequired->SelectEntryPos( 0 ); // yes 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir } 785*cdf0e10cSrcweir ActivateAggregate( tpDefault ); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir else 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 790*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 791*cdf0e10cSrcweir ActivateAggregate( tpAutoIncrementValue ); 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir // und jetzt alle nach oben schieben 794*cdf0e10cSrcweir ArrangeAggregates(); 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir if(pListBox == m_pType) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir TOTypeInfoSP pTypeInfo = getTypeInfo(m_pType->GetSelectEntryPos()); 800*cdf0e10cSrcweir pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False); // SetType(pTypeInfo); 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir DisplayData(pActFieldDescr); 803*cdf0e10cSrcweir CellModified(-1, m_pType->GetPos()); 804*cdf0e10cSrcweir } 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir return 0; 807*cdf0e10cSrcweir } 808*cdf0e10cSrcweir //------------------------------------------------------------------------------ 809*cdf0e10cSrcweir // alle Control neu anordnen, so dass sie in fester Reihenfolge und wirklich 810*cdf0e10cSrcweir // OBEN auf der DescriptionPage stehen 811*cdf0e10cSrcweir void OFieldDescControl::ArrangeAggregates() 812*cdf0e10cSrcweir { 813*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 814*cdf0e10cSrcweir // die Beschreibung eines Controls 815*cdf0e10cSrcweir struct AGGREGATE_DESCRIPTION 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir Control* pctrlInputControl; // das eigentliche Control zur Eingabe 818*cdf0e10cSrcweir Control* pctrlTextControl; // das Label dazu 819*cdf0e10cSrcweir sal_uInt16 nPosSizeArgument; // das zweite Argument fuer SetPosSize 820*cdf0e10cSrcweir }; 821*cdf0e10cSrcweir AGGREGATE_DESCRIPTION adAggregates[] = { 822*cdf0e10cSrcweir { m_pColumnName, m_pColumnNameText, 1}, 823*cdf0e10cSrcweir { m_pType, m_pTypeText, 1}, 824*cdf0e10cSrcweir { pAutoIncrement, pAutoIncrementText, 1 }, 825*cdf0e10cSrcweir { m_pAutoIncrementValue, m_pAutoIncrementValueText, 3 }, 826*cdf0e10cSrcweir { pNumType, pNumTypeText, 1 }, 827*cdf0e10cSrcweir { pRequired, pRequiredText, 1 }, 828*cdf0e10cSrcweir { pTextLen, pTextLenText, 1 }, 829*cdf0e10cSrcweir { pLength, pLengthText, 1 }, 830*cdf0e10cSrcweir { pScale, pScaleText, 1 }, 831*cdf0e10cSrcweir { pDefault, pDefaultText, 3 }, 832*cdf0e10cSrcweir { pFormatSample, pFormatText, 4 }, 833*cdf0e10cSrcweir { pBoolDefault, pBoolDefaultText, 1 }, 834*cdf0e10cSrcweir }; 835*cdf0e10cSrcweir 836*cdf0e10cSrcweir long nMaxWidth = 0; 837*cdf0e10cSrcweir for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir if (adAggregates[i].pctrlTextControl) 840*cdf0e10cSrcweir { 841*cdf0e10cSrcweir nMaxWidth = ::std::max<long>(OutputDevice::GetTextWidth(adAggregates[i].pctrlTextControl->GetText()),nMaxWidth); 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir 845*cdf0e10cSrcweir OSL_ENSURE(nMaxWidth != 0,"Invalid width!"); 846*cdf0e10cSrcweir 847*cdf0e10cSrcweir // und los ... 848*cdf0e10cSrcweir int nCurrentControlPos = 0; 849*cdf0e10cSrcweir Control* pZOrderPredecessor = NULL; 850*cdf0e10cSrcweir for (size_t i=0; i<sizeof(adAggregates)/sizeof(adAggregates[0]); i++) 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir if (adAggregates[i].pctrlInputControl) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir SetPosSize(&adAggregates[i].pctrlTextControl, nCurrentControlPos, 0); 855*cdf0e10cSrcweir SetPosSize(&adAggregates[i].pctrlInputControl, nCurrentControlPos, adAggregates[i].nPosSizeArgument); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // die Z-Order so, dass die Controls auch wirklich in derselben Reihenfolge durchwandert werden koennen, in der sie 858*cdf0e10cSrcweir // hier angeordnet wurden 859*cdf0e10cSrcweir adAggregates[i].pctrlTextControl->SetZOrder(pZOrderPredecessor, pZOrderPredecessor ? WINDOW_ZORDER_BEHIND : WINDOW_ZORDER_FIRST); 860*cdf0e10cSrcweir adAggregates[i].pctrlInputControl->SetZOrder(adAggregates[i].pctrlTextControl, WINDOW_ZORDER_BEHIND ); 861*cdf0e10cSrcweir pZOrderPredecessor = adAggregates[i].pctrlInputControl; 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir if (adAggregates[i].pctrlInputControl == pFormatSample) 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir pFormat->SetZOrder(pZOrderPredecessor, WINDOW_ZORDER_BEHIND); 866*cdf0e10cSrcweir pZOrderPredecessor = pFormat; 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir ++nCurrentControlPos; 870*cdf0e10cSrcweir } 871*cdf0e10cSrcweir } 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir // eine Sonderbehandlung fuer die Format-Controls 874*cdf0e10cSrcweir if (pFormat) 875*cdf0e10cSrcweir { 876*cdf0e10cSrcweir Point ptSamplePos(pFormatSample->GetPosPixel()); 877*cdf0e10cSrcweir Size szSampleSize(pFormatSample->GetSizePixel()); 878*cdf0e10cSrcweir pFormat->SetPosPixel(Point(ptSamplePos.X() + szSampleSize.Width() + 5, ptSamplePos.Y())); 879*cdf0e10cSrcweir } 880*cdf0e10cSrcweir 881*cdf0e10cSrcweir // als letztes noch die ScrollBars in der ZOrder ganz nach oben 882*cdf0e10cSrcweir m_pVertScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST); 883*cdf0e10cSrcweir m_pHorzScroll->SetZOrder(NULL, WINDOW_ZORDER_FIRST); 884*cdf0e10cSrcweir } 885*cdf0e10cSrcweir 886*cdf0e10cSrcweir //------------------------------------------------------------------------------ 887*cdf0e10cSrcweir void OFieldDescControl::ActivateAggregate( EControlType eType ) 888*cdf0e10cSrcweir { 889*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 890*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 891*cdf0e10cSrcweir // Controls erzeugen 892*cdf0e10cSrcweir switch( eType ) 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir case tpDefault: 895*cdf0e10cSrcweir if( pDefault ) 896*cdf0e10cSrcweir return; 897*cdf0e10cSrcweir m_nPos++; 898*cdf0e10cSrcweir pDefaultText = CreateText(STR_DEFAULT_VALUE); 899*cdf0e10cSrcweir pDefault = new OPropEditCtrl( this, STR_HELP_DEFAULT_VALUE, FIELD_PROPERTY_DEFAULT, WB_BORDER ); 900*cdf0e10cSrcweir InitializeControl(pDefault,HID_TAB_ENT_DEFAULT,false); 901*cdf0e10cSrcweir break; 902*cdf0e10cSrcweir case tpAutoIncrementValue: 903*cdf0e10cSrcweir if( m_pAutoIncrementValue || !isAutoIncrementValueEnabled() ) 904*cdf0e10cSrcweir return; 905*cdf0e10cSrcweir m_nPos++; 906*cdf0e10cSrcweir m_pAutoIncrementValueText = CreateText(STR_AUTOINCREMENT_VALUE); 907*cdf0e10cSrcweir m_pAutoIncrementValue = new OPropEditCtrl( this, STR_HELP_AUTOINCREMENT_VALUE, FIELD_PRPOERTY_AUTOINCREMENT, WB_BORDER ); 908*cdf0e10cSrcweir m_pAutoIncrementValue->SetText( getAutoIncrementValue() ); 909*cdf0e10cSrcweir InitializeControl(m_pAutoIncrementValue,HID_TAB_AUTOINCREMENTVALUE,false); 910*cdf0e10cSrcweir break; 911*cdf0e10cSrcweir 912*cdf0e10cSrcweir case tpRequired: 913*cdf0e10cSrcweir { 914*cdf0e10cSrcweir if( pRequired ) 915*cdf0e10cSrcweir return; 916*cdf0e10cSrcweir Reference< XDatabaseMetaData> xMetaData = getMetaData(); 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir if(xMetaData.is() && xMetaData->supportsNonNullableColumns()) 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir m_nPos++; 921*cdf0e10cSrcweir pRequiredText = CreateText(STR_FIELD_REQUIRED); 922*cdf0e10cSrcweir pRequired = new OPropListBoxCtrl( this, STR_HELP_FIELD_REQUIRED, FIELD_PROPERTY_REQUIRED, WB_DROPDOWN); 923*cdf0e10cSrcweir 924*cdf0e10cSrcweir pRequired->InsertEntry( aYes ); 925*cdf0e10cSrcweir pRequired->InsertEntry( aNo ); 926*cdf0e10cSrcweir pRequired->SelectEntryPos(1); 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir InitializeControl(pRequired,HID_TAB_ENT_REQUIRED,true); 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir break; 932*cdf0e10cSrcweir case tpAutoIncrement: 933*cdf0e10cSrcweir { 934*cdf0e10cSrcweir if( pAutoIncrement ) 935*cdf0e10cSrcweir return; 936*cdf0e10cSrcweir m_nPos++; 937*cdf0e10cSrcweir pAutoIncrementText = CreateText(STR_FIELD_AUTOINCREMENT); 938*cdf0e10cSrcweir pAutoIncrement = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PROPERTY_AUTOINC, WB_DROPDOWN ); 939*cdf0e10cSrcweir pAutoIncrement->InsertEntry( aYes ); 940*cdf0e10cSrcweir pAutoIncrement->InsertEntry( aNo ); 941*cdf0e10cSrcweir pAutoIncrement->SelectEntryPos(0); 942*cdf0e10cSrcweir InitializeControl(pAutoIncrement,HID_TAB_ENT_AUTOINCREMENT,true); 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir break; 945*cdf0e10cSrcweir case tpTextLen: 946*cdf0e10cSrcweir if( pTextLen ) 947*cdf0e10cSrcweir return; 948*cdf0e10cSrcweir m_nPos++; 949*cdf0e10cSrcweir pTextLenText = CreateText(STR_TEXT_LENGTH); 950*cdf0e10cSrcweir pTextLen = CreateNumericControl(STR_HELP_TEXT_LENGTH, FIELD_PROPERTY_TEXTLEN,HID_TAB_ENT_TEXT_LEN); 951*cdf0e10cSrcweir break; 952*cdf0e10cSrcweir 953*cdf0e10cSrcweir case tpType: 954*cdf0e10cSrcweir if( m_pType) 955*cdf0e10cSrcweir return; 956*cdf0e10cSrcweir m_nPos++; 957*cdf0e10cSrcweir m_pTypeText = CreateText(STR_TAB_FIELD_DATATYPE); 958*cdf0e10cSrcweir m_pType = new OPropListBoxCtrl( this, STR_HELP_AUTOINCREMENT, FIELD_PRPOERTY_TYPE, WB_DROPDOWN ); 959*cdf0e10cSrcweir m_pType->SetDropDownLineCount(20); 960*cdf0e10cSrcweir { 961*cdf0e10cSrcweir const OTypeInfoMap* pTypeInfo = getTypeInfo(); 962*cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); 963*cdf0e10cSrcweir OTypeInfoMap::const_iterator aEnd = pTypeInfo->end(); 964*cdf0e10cSrcweir for(;aIter != aEnd;++aIter) 965*cdf0e10cSrcweir m_pType->InsertEntry( aIter->second->aUIName ); 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir m_pType->SelectEntryPos(0); 968*cdf0e10cSrcweir InitializeControl(m_pType,HID_TAB_ENT_TYPE,true); 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir case tpColumnName: 971*cdf0e10cSrcweir if( m_pColumnName ) 972*cdf0e10cSrcweir return; 973*cdf0e10cSrcweir m_nPos++; 974*cdf0e10cSrcweir { 975*cdf0e10cSrcweir sal_uInt32 nMax = EDIT_NOLIMIT; 976*cdf0e10cSrcweir ::rtl::OUString aTmpString; 977*cdf0e10cSrcweir try 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir Reference< XDatabaseMetaData> xMetaData = getMetaData(); 980*cdf0e10cSrcweir if ( xMetaData.is() ) 981*cdf0e10cSrcweir { 982*cdf0e10cSrcweir nMax = xMetaData->getMaxColumnNameLength(); 983*cdf0e10cSrcweir aTmpString = xMetaData->getExtraNameCharacters(); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir } 986*cdf0e10cSrcweir catch(Exception&) 987*cdf0e10cSrcweir { 988*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 989*cdf0e10cSrcweir } 990*cdf0e10cSrcweir m_pColumnNameText = CreateText(STR_TAB_FIELD_NAME); 991*cdf0e10cSrcweir m_pColumnName = new OPropColumnEditCtrl( this, 992*cdf0e10cSrcweir aTmpString, 993*cdf0e10cSrcweir STR_HELP_DEFAULT_VALUE, 994*cdf0e10cSrcweir FIELD_PRPOERTY_COLUMNNAME, 995*cdf0e10cSrcweir WB_BORDER ); 996*cdf0e10cSrcweir m_pColumnName->SetMaxTextLen(xub_StrLen( nMax ? nMax : EDIT_NOLIMIT)); 997*cdf0e10cSrcweir m_pColumnName->setCheck( isSQL92CheckEnabled(getConnection()) ); 998*cdf0e10cSrcweir } 999*cdf0e10cSrcweir 1000*cdf0e10cSrcweir InitializeControl(m_pColumnName,HID_TAB_ENT_COLUMNNAME,false); 1001*cdf0e10cSrcweir break; 1002*cdf0e10cSrcweir case tpNumType: 1003*cdf0e10cSrcweir if( pNumType ) 1004*cdf0e10cSrcweir return; 1005*cdf0e10cSrcweir m_nPos++; 1006*cdf0e10cSrcweir pNumTypeText = CreateText(STR_NUMERIC_TYPE); 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir pNumType = new OPropListBoxCtrl( this, STR_HELP_NUMERIC_TYPE, FIELD_PROPERTY_NUMTYPE, WB_DROPDOWN ); 1009*cdf0e10cSrcweir pNumType->SetDropDownLineCount(5); 1010*cdf0e10cSrcweir 1011*cdf0e10cSrcweir pNumType->InsertEntry( String::CreateFromAscii("Byte") ); 1012*cdf0e10cSrcweir pNumType->InsertEntry( String::CreateFromAscii("SmallInt") ); 1013*cdf0e10cSrcweir pNumType->InsertEntry( String::CreateFromAscii("Integer") ); 1014*cdf0e10cSrcweir pNumType->InsertEntry( String::CreateFromAscii("Single") ); 1015*cdf0e10cSrcweir pNumType->InsertEntry( String::CreateFromAscii("Double") ); 1016*cdf0e10cSrcweir pNumType->SelectEntryPos(2); 1017*cdf0e10cSrcweir InitializeControl(pNumType,HID_TAB_ENT_NUMTYP,true); 1018*cdf0e10cSrcweir break; 1019*cdf0e10cSrcweir 1020*cdf0e10cSrcweir case tpLength: 1021*cdf0e10cSrcweir if( pLength ) 1022*cdf0e10cSrcweir return; 1023*cdf0e10cSrcweir m_nPos++; 1024*cdf0e10cSrcweir pLengthText = CreateText(STR_LENGTH); 1025*cdf0e10cSrcweir pLength = CreateNumericControl(STR_HELP_LENGTH, FIELD_PROPERTY_LENGTH,HID_TAB_ENT_LEN); 1026*cdf0e10cSrcweir break; 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir case tpScale: 1029*cdf0e10cSrcweir if( pScale ) 1030*cdf0e10cSrcweir return; 1031*cdf0e10cSrcweir m_nPos++; 1032*cdf0e10cSrcweir pScaleText = CreateText(STR_SCALE); 1033*cdf0e10cSrcweir pScale = CreateNumericControl(STR_HELP_SCALE, FIELD_PROPERTY_SCALE,HID_TAB_ENT_SCALE); 1034*cdf0e10cSrcweir break; 1035*cdf0e10cSrcweir 1036*cdf0e10cSrcweir case tpFormat: 1037*cdf0e10cSrcweir if (!pFormat) 1038*cdf0e10cSrcweir { 1039*cdf0e10cSrcweir m_nPos++; 1040*cdf0e10cSrcweir pFormatText = CreateText(STR_FORMAT); 1041*cdf0e10cSrcweir 1042*cdf0e10cSrcweir pFormatSample = new OPropEditCtrl( this, STR_HELP_FORMAT_CODE, -1, WB_BORDER ); 1043*cdf0e10cSrcweir pFormatSample->SetReadOnly(sal_True); 1044*cdf0e10cSrcweir pFormatSample->Enable(sal_False); 1045*cdf0e10cSrcweir InitializeControl(pFormatSample,HID_TAB_ENT_FORMAT_SAMPLE,false); 1046*cdf0e10cSrcweir 1047*cdf0e10cSrcweir pFormat = new PushButton( this, ModuleRes(PB_FORMAT) ); 1048*cdf0e10cSrcweir const sal_Int32 nControlHeight = GetMaxControlHeight(); 1049*cdf0e10cSrcweir pFormat->SetSizePixel(Size(nControlHeight, nControlHeight)); 1050*cdf0e10cSrcweir pFormat->SetClickHdl( LINK( this, OFieldDescControl, FormatClickHdl ) ); 1051*cdf0e10cSrcweir InitializeControl(pFormat,HID_TAB_ENT_FORMAT,false); 1052*cdf0e10cSrcweir } 1053*cdf0e10cSrcweir 1054*cdf0e10cSrcweir UpdateFormatSample(pActFieldDescr); 1055*cdf0e10cSrcweir break; 1056*cdf0e10cSrcweir case tpBoolDefault: 1057*cdf0e10cSrcweir if (pBoolDefault) 1058*cdf0e10cSrcweir return; 1059*cdf0e10cSrcweir 1060*cdf0e10cSrcweir m_nPos++; 1061*cdf0e10cSrcweir pBoolDefaultText = CreateText(STR_DEFAULT_VALUE); 1062*cdf0e10cSrcweir pBoolDefault = new OPropListBoxCtrl( this, STR_HELP_BOOL_DEFAULT, FIELD_PROPERTY_BOOL_DEFAULT, WB_DROPDOWN ); 1063*cdf0e10cSrcweir pBoolDefault->SetDropDownLineCount(3); 1064*cdf0e10cSrcweir pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); 1065*cdf0e10cSrcweir pBoolDefault->InsertEntry(aYes); 1066*cdf0e10cSrcweir pBoolDefault->InsertEntry(aNo); 1067*cdf0e10cSrcweir 1068*cdf0e10cSrcweir InitializeControl(pBoolDefault,HID_TAB_ENT_BOOL_DEFAULT,false); 1069*cdf0e10cSrcweir break; 1070*cdf0e10cSrcweir } 1071*cdf0e10cSrcweir } 1072*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1073*cdf0e10cSrcweir void OFieldDescControl::InitializeControl(Control* _pControl,const ::rtl::OString& _sHelpId,bool _bAddChangeHandler) 1074*cdf0e10cSrcweir { 1075*cdf0e10cSrcweir _pControl->SetHelpId(_sHelpId); 1076*cdf0e10cSrcweir if ( _bAddChangeHandler ) 1077*cdf0e10cSrcweir ((OPropListBoxCtrl*)_pControl)->SetSelectHdl(LINK(this,OFieldDescControl,ChangeHdl)); 1078*cdf0e10cSrcweir 1079*cdf0e10cSrcweir _pControl->SetGetFocusHdl(LINK(this, OFieldDescControl, OnControlFocusGot)); 1080*cdf0e10cSrcweir _pControl->SetLoseFocusHdl(LINK(this, OFieldDescControl, OnControlFocusLost)); 1081*cdf0e10cSrcweir _pControl->EnableClipSiblings(); 1082*cdf0e10cSrcweir } 1083*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1084*cdf0e10cSrcweir FixedText* OFieldDescControl::CreateText(sal_uInt16 _nTextRes) 1085*cdf0e10cSrcweir { 1086*cdf0e10cSrcweir FixedText* pFixedText = new FixedText( this ); 1087*cdf0e10cSrcweir pFixedText->SetText( ModuleRes(_nTextRes) ); 1088*cdf0e10cSrcweir pFixedText->EnableClipSiblings(); 1089*cdf0e10cSrcweir return pFixedText; 1090*cdf0e10cSrcweir } 1091*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1092*cdf0e10cSrcweir OPropNumericEditCtrl* OFieldDescControl::CreateNumericControl(sal_uInt16 _nHelpStr,short _nProperty,const rtl::OString& _sHelpId) 1093*cdf0e10cSrcweir { 1094*cdf0e10cSrcweir OPropNumericEditCtrl* pControl = new OPropNumericEditCtrl( this, _nHelpStr, _nProperty, WB_BORDER ); 1095*cdf0e10cSrcweir pControl->SetDecimalDigits(0); 1096*cdf0e10cSrcweir pControl->SetMin(0); 1097*cdf0e10cSrcweir pControl->SetMax(0x7FFFFFFF); // soll draussen geaendert werden, wenn noetig 1098*cdf0e10cSrcweir pControl->SetStrictFormat(sal_True); 1099*cdf0e10cSrcweir 1100*cdf0e10cSrcweir InitializeControl(pControl,_sHelpId,false); 1101*cdf0e10cSrcweir 1102*cdf0e10cSrcweir return pControl; 1103*cdf0e10cSrcweir } 1104*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1105*cdf0e10cSrcweir void OFieldDescControl::DeactivateAggregate( EControlType eType ) 1106*cdf0e10cSrcweir { 1107*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1108*cdf0e10cSrcweir pLastFocusWindow = NULL; 1109*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1110*cdf0e10cSrcweir // Controls zerstoeren 1111*cdf0e10cSrcweir switch( eType ) 1112*cdf0e10cSrcweir { 1113*cdf0e10cSrcweir case tpDefault: 1114*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pDefault,&pDefaultText); 1115*cdf0e10cSrcweir break; 1116*cdf0e10cSrcweir 1117*cdf0e10cSrcweir case tpAutoIncrementValue: 1118*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&m_pAutoIncrementValue,&m_pAutoIncrementValueText); 1119*cdf0e10cSrcweir break; 1120*cdf0e10cSrcweir 1121*cdf0e10cSrcweir case tpColumnName: 1122*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&m_pColumnName,&m_pColumnNameText); 1123*cdf0e10cSrcweir break; 1124*cdf0e10cSrcweir 1125*cdf0e10cSrcweir case tpType: 1126*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&m_pType,&m_pTypeText); 1127*cdf0e10cSrcweir break; 1128*cdf0e10cSrcweir 1129*cdf0e10cSrcweir case tpAutoIncrement: 1130*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pAutoIncrement,&pAutoIncrementText); 1131*cdf0e10cSrcweir break; 1132*cdf0e10cSrcweir 1133*cdf0e10cSrcweir case tpRequired: 1134*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pRequired,&pRequiredText); 1135*cdf0e10cSrcweir break; 1136*cdf0e10cSrcweir 1137*cdf0e10cSrcweir case tpTextLen: 1138*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pTextLen,&pTextLenText); 1139*cdf0e10cSrcweir break; 1140*cdf0e10cSrcweir 1141*cdf0e10cSrcweir case tpNumType: 1142*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pNumType,&pNumTypeText); 1143*cdf0e10cSrcweir break; 1144*cdf0e10cSrcweir 1145*cdf0e10cSrcweir case tpLength: 1146*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pLength,&pLengthText); 1147*cdf0e10cSrcweir break; 1148*cdf0e10cSrcweir 1149*cdf0e10cSrcweir case tpScale: 1150*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pScale,&pScaleText); 1151*cdf0e10cSrcweir break; 1152*cdf0e10cSrcweir 1153*cdf0e10cSrcweir case tpFormat: 1154*cdf0e10cSrcweir // TODO: we have to check if we have to increment m_nPos again 1155*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pFormat,&pFormatText); 1156*cdf0e10cSrcweir if ( pFormatSample ) 1157*cdf0e10cSrcweir { 1158*cdf0e10cSrcweir pFormatSample->Hide(); 1159*cdf0e10cSrcweir delete pFormatSample; 1160*cdf0e10cSrcweir pFormatSample = NULL; 1161*cdf0e10cSrcweir } 1162*cdf0e10cSrcweir break; 1163*cdf0e10cSrcweir case tpBoolDefault: 1164*cdf0e10cSrcweir lcl_HideAndDeleteControl(m_nPos,&pBoolDefault,&pBoolDefaultText); 1165*cdf0e10cSrcweir break; 1166*cdf0e10cSrcweir } 1167*cdf0e10cSrcweir } 1168*cdf0e10cSrcweir 1169*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1170*cdf0e10cSrcweir void OFieldDescControl::SetPosSize( Control** ppControl, long nRow, sal_uInt16 nCol ) 1171*cdf0e10cSrcweir { 1172*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1173*cdf0e10cSrcweir 1174*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1175*cdf0e10cSrcweir // Groesse ermitteln 1176*cdf0e10cSrcweir const sal_Int32 nControlHeight = GetMaxControlHeight(); 1177*cdf0e10cSrcweir Size aSize(0,nControlHeight); 1178*cdf0e10cSrcweir if ( isRightAligned() && nCol ) 1179*cdf0e10cSrcweir aSize.Width() = LogicToPixel(Size(m_nWidth, 0),MAP_APPFONT).Width(); 1180*cdf0e10cSrcweir else 1181*cdf0e10cSrcweir { 1182*cdf0e10cSrcweir switch( nCol ) 1183*cdf0e10cSrcweir { 1184*cdf0e10cSrcweir case 0: 1185*cdf0e10cSrcweir default: 1186*cdf0e10cSrcweir aSize.Width() = CONTROL_WIDTH_1; 1187*cdf0e10cSrcweir break; 1188*cdf0e10cSrcweir case 1: 1189*cdf0e10cSrcweir aSize.Width() = CONTROL_WIDTH_2; 1190*cdf0e10cSrcweir break; 1191*cdf0e10cSrcweir case 3: 1192*cdf0e10cSrcweir aSize.Width() = CONTROL_WIDTH_3; 1193*cdf0e10cSrcweir break; 1194*cdf0e10cSrcweir case 4: 1195*cdf0e10cSrcweir aSize.Width() = CONTROL_WIDTH_4; 1196*cdf0e10cSrcweir break; 1197*cdf0e10cSrcweir } // switch( nCol ) 1198*cdf0e10cSrcweir } 1199*cdf0e10cSrcweir 1200*cdf0e10cSrcweir 1201*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1202*cdf0e10cSrcweir // Position ermitteln 1203*cdf0e10cSrcweir Point aPosition; 1204*cdf0e10cSrcweir switch( nCol ) 1205*cdf0e10cSrcweir { 1206*cdf0e10cSrcweir case 0: 1207*cdf0e10cSrcweir aPosition.X() = 0; 1208*cdf0e10cSrcweir aPosition.Y() = 1; 1209*cdf0e10cSrcweir break; 1210*cdf0e10cSrcweir case 1: 1211*cdf0e10cSrcweir case 3: 1212*cdf0e10cSrcweir case 4: 1213*cdf0e10cSrcweir if ( isRightAligned() ) 1214*cdf0e10cSrcweir { 1215*cdf0e10cSrcweir Size aOwnSize = GetSizePixel(); 1216*cdf0e10cSrcweir aPosition.X() = aOwnSize.Width() - aSize.Width(); 1217*cdf0e10cSrcweir } 1218*cdf0e10cSrcweir else 1219*cdf0e10cSrcweir aPosition.X() = CONTROL_WIDTH_1 + CONTROL_SPACING_X; 1220*cdf0e10cSrcweir break; 1221*cdf0e10cSrcweir default: 1222*cdf0e10cSrcweir aPosition.X() = 0; 1223*cdf0e10cSrcweir } 1224*cdf0e10cSrcweir 1225*cdf0e10cSrcweir (*ppControl)->SetSizePixel( aSize ); 1226*cdf0e10cSrcweir aSize = (*ppControl)->GetSizePixel( ); 1227*cdf0e10cSrcweir 1228*cdf0e10cSrcweir const sal_Int32 nControl_Spacing_y = LogicToPixel(Size(0, CONTROL_SPACING_Y),MAP_APPFONT).Height(); 1229*cdf0e10cSrcweir aPosition.Y() += ((nRow+1)*nControl_Spacing_y) + 1230*cdf0e10cSrcweir (nRow*nControlHeight); 1231*cdf0e10cSrcweir 1232*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1233*cdf0e10cSrcweir // Control anzeigen 1234*cdf0e10cSrcweir (*ppControl)->SetPosSizePixel( aPosition, aSize ); 1235*cdf0e10cSrcweir aSize = (*ppControl)->GetSizePixel(); 1236*cdf0e10cSrcweir 1237*cdf0e10cSrcweir (*ppControl)->Show(); 1238*cdf0e10cSrcweir } 1239*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1240*cdf0e10cSrcweir void OFieldDescControl::DisplayData(OFieldDescription* pFieldDescr ) 1241*cdf0e10cSrcweir { 1242*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1243*cdf0e10cSrcweir pActFieldDescr = pFieldDescr; 1244*cdf0e10cSrcweir if(!pFieldDescr) 1245*cdf0e10cSrcweir { 1246*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 1247*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1248*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1249*cdf0e10cSrcweir DeactivateAggregate( tpNumType ); 1250*cdf0e10cSrcweir DeactivateAggregate( tpScale ); 1251*cdf0e10cSrcweir DeactivateAggregate( tpLength ); 1252*cdf0e10cSrcweir DeactivateAggregate( tpFormat ); 1253*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrement ); 1254*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1255*cdf0e10cSrcweir DeactivateAggregate( tpColumnName ); 1256*cdf0e10cSrcweir DeactivateAggregate( tpType ); 1257*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrementValue ); 1258*cdf0e10cSrcweir m_pPreviousType = TOTypeInfoSP(); 1259*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1260*cdf0e10cSrcweir // Zeiger des gespeicherten Focus zuruecksetzen 1261*cdf0e10cSrcweir pLastFocusWindow = NULL; 1262*cdf0e10cSrcweir if ( m_bAdded ) 1263*cdf0e10cSrcweir { 1264*cdf0e10cSrcweir ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::RemoveWindow)); 1265*cdf0e10cSrcweir m_bAdded = sal_False; 1266*cdf0e10cSrcweir } 1267*cdf0e10cSrcweir return; 1268*cdf0e10cSrcweir } 1269*cdf0e10cSrcweir 1270*cdf0e10cSrcweir if ( !m_bAdded ) 1271*cdf0e10cSrcweir { 1272*cdf0e10cSrcweir ::dbaui::notifySystemWindow(this,this,::comphelper::mem_fun(&TaskPaneList::AddWindow)); 1273*cdf0e10cSrcweir m_bAdded = sal_True; 1274*cdf0e10cSrcweir } 1275*cdf0e10cSrcweir 1276*cdf0e10cSrcweir TOTypeInfoSP pFieldType; 1277*cdf0e10cSrcweir if( pFieldDescr ) 1278*cdf0e10cSrcweir pFieldType = pFieldDescr->getTypeInfo(); 1279*cdf0e10cSrcweir 1280*cdf0e10cSrcweir ActivateAggregate( tpColumnName ); 1281*cdf0e10cSrcweir ActivateAggregate( tpType ); 1282*cdf0e10cSrcweir 1283*cdf0e10cSrcweir OSL_ENSURE(pFieldType.get(),"We need a type information here!"); 1284*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1285*cdf0e10cSrcweir // Wenn sich der Typ geaendert hat, Controls austauschen 1286*cdf0e10cSrcweir if( m_pPreviousType != pFieldType ) 1287*cdf0e10cSrcweir { 1288*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1289*cdf0e10cSrcweir // Zeiger des gespeicherten Focus zuruecksetzen 1290*cdf0e10cSrcweir pLastFocusWindow = NULL; 1291*cdf0e10cSrcweir 1292*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1293*cdf0e10cSrcweir // Controls, die nicht mehr angezeigt werden duerfen 1294*cdf0e10cSrcweir DeactivateAggregate( tpNumType ); 1295*cdf0e10cSrcweir 1296*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1297*cdf0e10cSrcweir // determine which controls we should show and which not 1298*cdf0e10cSrcweir 1299*cdf0e10cSrcweir // 1. the required control 1300*cdf0e10cSrcweir if ( pFieldType->bNullable ) 1301*cdf0e10cSrcweir ActivateAggregate( tpRequired ); 1302*cdf0e10cSrcweir else 1303*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1304*cdf0e10cSrcweir 1305*cdf0e10cSrcweir // 2. the autoincrement 1306*cdf0e10cSrcweir if ( pFieldType->bAutoIncrement ) 1307*cdf0e10cSrcweir { 1308*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1309*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 1310*cdf0e10cSrcweir ActivateAggregate( tpAutoIncrement ); 1311*cdf0e10cSrcweir ActivateAggregate( tpAutoIncrementValue ); 1312*cdf0e10cSrcweir } 1313*cdf0e10cSrcweir else 1314*cdf0e10cSrcweir { 1315*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrement ); 1316*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrementValue ); 1317*cdf0e10cSrcweir if(pFieldType->bNullable) 1318*cdf0e10cSrcweir ActivateAggregate( tpRequired ); 1319*cdf0e10cSrcweir else 1320*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1321*cdf0e10cSrcweir ActivateAggregate( tpDefault ); 1322*cdf0e10cSrcweir } 1323*cdf0e10cSrcweir // 3. the scale and precision 1324*cdf0e10cSrcweir if (pFieldType->nPrecision) 1325*cdf0e10cSrcweir { 1326*cdf0e10cSrcweir ActivateAggregate( tpLength ); 1327*cdf0e10cSrcweir pLength->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision())); 1328*cdf0e10cSrcweir pLength->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0); 1329*cdf0e10cSrcweir } 1330*cdf0e10cSrcweir else 1331*cdf0e10cSrcweir DeactivateAggregate( tpLength ); 1332*cdf0e10cSrcweir 1333*cdf0e10cSrcweir if (pFieldType->nMaximumScale) 1334*cdf0e10cSrcweir { 1335*cdf0e10cSrcweir ActivateAggregate( tpScale ); 1336*cdf0e10cSrcweir pScale->SetMax(::std::max<sal_Int32>(pFieldType->nMaximumScale,pFieldDescr->GetScale())); 1337*cdf0e10cSrcweir pScale->SetMin(pFieldType->nMinimumScale); 1338*cdf0e10cSrcweir static const ::rtl::OUString s_sPRECISION(RTL_CONSTASCII_USTRINGPARAM("PRECISION")); 1339*cdf0e10cSrcweir pScale->SetSpecialReadOnly(pFieldType->aCreateParams.getLength() == 0 || pFieldType->aCreateParams == s_sPRECISION); 1340*cdf0e10cSrcweir } 1341*cdf0e10cSrcweir else 1342*cdf0e10cSrcweir DeactivateAggregate( tpScale ); 1343*cdf0e10cSrcweir 1344*cdf0e10cSrcweir // and now look for type specific things 1345*cdf0e10cSrcweir switch( pFieldType->nType ) 1346*cdf0e10cSrcweir { 1347*cdf0e10cSrcweir case DataType::CHAR: 1348*cdf0e10cSrcweir case DataType::VARCHAR: 1349*cdf0e10cSrcweir case DataType::LONGVARCHAR: 1350*cdf0e10cSrcweir DeactivateAggregate( tpLength ); 1351*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1352*cdf0e10cSrcweir 1353*cdf0e10cSrcweir ActivateAggregate( tpDefault ); 1354*cdf0e10cSrcweir ActivateAggregate( tpFormat ); 1355*cdf0e10cSrcweir if (pFieldType->nPrecision) 1356*cdf0e10cSrcweir { 1357*cdf0e10cSrcweir ActivateAggregate( tpTextLen ); 1358*cdf0e10cSrcweir pTextLen->SetMax(::std::max<sal_Int32>(pFieldType->nPrecision,pFieldDescr->GetPrecision())); 1359*cdf0e10cSrcweir pTextLen->SetSpecialReadOnly(pFieldType->aCreateParams.getLength()==0); 1360*cdf0e10cSrcweir } 1361*cdf0e10cSrcweir else 1362*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1363*cdf0e10cSrcweir break; 1364*cdf0e10cSrcweir case DataType::DATE: 1365*cdf0e10cSrcweir case DataType::TIME: 1366*cdf0e10cSrcweir case DataType::TIMESTAMP: 1367*cdf0e10cSrcweir DeactivateAggregate( tpLength ); // we don't need a length for date types 1368*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1369*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1370*cdf0e10cSrcweir 1371*cdf0e10cSrcweir ActivateAggregate( tpDefault ); 1372*cdf0e10cSrcweir ActivateAggregate( tpFormat ); 1373*cdf0e10cSrcweir break; 1374*cdf0e10cSrcweir case DataType::BIT: 1375*cdf0e10cSrcweir if ( pFieldType->aCreateParams.getLength() ) 1376*cdf0e10cSrcweir { 1377*cdf0e10cSrcweir DeactivateAggregate( tpFormat ); 1378*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1379*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1380*cdf0e10cSrcweir break; 1381*cdf0e10cSrcweir } 1382*cdf0e10cSrcweir // run through 1383*cdf0e10cSrcweir case DataType::BOOLEAN: 1384*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1385*cdf0e10cSrcweir DeactivateAggregate( tpFormat ); 1386*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 1387*cdf0e10cSrcweir 1388*cdf0e10cSrcweir ActivateAggregate( tpBoolDefault ); 1389*cdf0e10cSrcweir break; 1390*cdf0e10cSrcweir case DataType::DECIMAL: 1391*cdf0e10cSrcweir case DataType::NUMERIC: 1392*cdf0e10cSrcweir case DataType::BIGINT: 1393*cdf0e10cSrcweir case DataType::FLOAT: 1394*cdf0e10cSrcweir case DataType::DOUBLE: 1395*cdf0e10cSrcweir case DataType::TINYINT: 1396*cdf0e10cSrcweir case DataType::SMALLINT: 1397*cdf0e10cSrcweir case DataType::INTEGER: 1398*cdf0e10cSrcweir case DataType::REAL: 1399*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1400*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1401*cdf0e10cSrcweir 1402*cdf0e10cSrcweir ActivateAggregate( tpFormat ); 1403*cdf0e10cSrcweir break; 1404*cdf0e10cSrcweir case DataType::BINARY: 1405*cdf0e10cSrcweir case DataType::VARBINARY: 1406*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 1407*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1408*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1409*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1410*cdf0e10cSrcweir 1411*cdf0e10cSrcweir ActivateAggregate( tpFormat ); 1412*cdf0e10cSrcweir break; 1413*cdf0e10cSrcweir case DataType::LONGVARBINARY: 1414*cdf0e10cSrcweir case DataType::SQLNULL: 1415*cdf0e10cSrcweir case DataType::OBJECT: 1416*cdf0e10cSrcweir case DataType::DISTINCT: 1417*cdf0e10cSrcweir case DataType::STRUCT: 1418*cdf0e10cSrcweir case DataType::ARRAY: 1419*cdf0e10cSrcweir case DataType::BLOB: 1420*cdf0e10cSrcweir case DataType::CLOB: 1421*cdf0e10cSrcweir case DataType::REF: 1422*cdf0e10cSrcweir case DataType::OTHER: 1423*cdf0e10cSrcweir DeactivateAggregate( tpFormat ); 1424*cdf0e10cSrcweir DeactivateAggregate( tpTextLen ); 1425*cdf0e10cSrcweir DeactivateAggregate( tpBoolDefault ); 1426*cdf0e10cSrcweir 1427*cdf0e10cSrcweir break; 1428*cdf0e10cSrcweir default: 1429*cdf0e10cSrcweir OSL_ENSURE(0,"Unknown type"); 1430*cdf0e10cSrcweir } 1431*cdf0e10cSrcweir m_pPreviousType = pFieldType; 1432*cdf0e10cSrcweir } 1433*cdf0e10cSrcweir if(pFieldDescr) 1434*cdf0e10cSrcweir { 1435*cdf0e10cSrcweir if(pFieldDescr->IsPrimaryKey()) 1436*cdf0e10cSrcweir { 1437*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1438*cdf0e10cSrcweir } 1439*cdf0e10cSrcweir else if ( !pAutoIncrement && pFieldType.get() ) 1440*cdf0e10cSrcweir { 1441*cdf0e10cSrcweir if ( pFieldType->bNullable ) 1442*cdf0e10cSrcweir ActivateAggregate( tpRequired ); 1443*cdf0e10cSrcweir else 1444*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1445*cdf0e10cSrcweir } 1446*cdf0e10cSrcweir } 1447*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1448*cdf0e10cSrcweir // Controls initialisieren 1449*cdf0e10cSrcweir if( pAutoIncrement ) 1450*cdf0e10cSrcweir { 1451*cdf0e10cSrcweir if ( pFieldDescr->IsAutoIncrement() ) 1452*cdf0e10cSrcweir { 1453*cdf0e10cSrcweir pAutoIncrement->SelectEntryPos( 0 ); // yes 1454*cdf0e10cSrcweir ActivateAggregate( tpAutoIncrementValue ); 1455*cdf0e10cSrcweir if ( m_pAutoIncrementValue ) 1456*cdf0e10cSrcweir m_pAutoIncrementValue->SetText(pFieldDescr->GetAutoIncrementValue()); 1457*cdf0e10cSrcweir DeactivateAggregate( tpRequired ); 1458*cdf0e10cSrcweir DeactivateAggregate( tpDefault ); 1459*cdf0e10cSrcweir } 1460*cdf0e10cSrcweir else 1461*cdf0e10cSrcweir { 1462*cdf0e10cSrcweir // disable autoincrement value because it should only be visible when autoincrement is to true 1463*cdf0e10cSrcweir DeactivateAggregate( tpAutoIncrementValue ); 1464*cdf0e10cSrcweir pAutoIncrement->SelectEntryPos( 1 ); // no 1465*cdf0e10cSrcweir ActivateAggregate( tpDefault ); 1466*cdf0e10cSrcweir // hat Auswirkungen auf pRequired 1467*cdf0e10cSrcweir if(!pFieldDescr->IsPrimaryKey()) 1468*cdf0e10cSrcweir ActivateAggregate( tpRequired ); 1469*cdf0e10cSrcweir } 1470*cdf0e10cSrcweir } 1471*cdf0e10cSrcweir 1472*cdf0e10cSrcweir if( pDefault ) 1473*cdf0e10cSrcweir { 1474*cdf0e10cSrcweir pDefault->SetText( getControlDefault(pFieldDescr) ); 1475*cdf0e10cSrcweir pDefault->ClearModifyFlag(); 1476*cdf0e10cSrcweir } 1477*cdf0e10cSrcweir 1478*cdf0e10cSrcweir if( pBoolDefault ) 1479*cdf0e10cSrcweir { 1480*cdf0e10cSrcweir // wenn pRequired auf sal_True gesetzt ist, dann darf das sal_Bool Feld nicht den Eintrag <<keiner>> besitzen 1481*cdf0e10cSrcweir ::rtl::OUString sValue; 1482*cdf0e10cSrcweir pFieldDescr->GetControlDefault() >>= sValue; 1483*cdf0e10cSrcweir String sDef = BoolStringUI(sValue); 1484*cdf0e10cSrcweir 1485*cdf0e10cSrcweir // sicher stellen das <<keiner>> nur vorhanden ist, wenn das Feld NULL sein darf 1486*cdf0e10cSrcweir if ( ( pFieldType.get() && !pFieldType->bNullable ) || !pFieldDescr->IsNullable() ) 1487*cdf0e10cSrcweir { 1488*cdf0e10cSrcweir pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); // der Typ sagt das 1489*cdf0e10cSrcweir 1490*cdf0e10cSrcweir pBoolDefault->RemoveEntry(String(ModuleRes(STR_VALUE_NONE))); 1491*cdf0e10cSrcweir if ( !sDef.Equals(aYes) && !sDef.Equals(aNo) ) 1492*cdf0e10cSrcweir pBoolDefault->SelectEntryPos(1); // nein als Default 1493*cdf0e10cSrcweir else 1494*cdf0e10cSrcweir pBoolDefault->SelectEntry(sDef); 1495*cdf0e10cSrcweir 1496*cdf0e10cSrcweir pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(BoolStringPersistent(pBoolDefault->GetSelectEntry())))); 1497*cdf0e10cSrcweir } 1498*cdf0e10cSrcweir else if(pBoolDefault->GetEntryCount() < 3) 1499*cdf0e10cSrcweir { 1500*cdf0e10cSrcweir pBoolDefault->InsertEntry(String(ModuleRes(STR_VALUE_NONE))); 1501*cdf0e10cSrcweir pBoolDefault->SelectEntry(sDef); 1502*cdf0e10cSrcweir } 1503*cdf0e10cSrcweir else 1504*cdf0e10cSrcweir pBoolDefault->SelectEntry(sDef); 1505*cdf0e10cSrcweir } 1506*cdf0e10cSrcweir 1507*cdf0e10cSrcweir if( pRequired ) 1508*cdf0e10cSrcweir { 1509*cdf0e10cSrcweir if( pFieldDescr->IsNullable() ) 1510*cdf0e10cSrcweir pRequired->SelectEntryPos( 1 ); // no 1511*cdf0e10cSrcweir else 1512*cdf0e10cSrcweir pRequired->SelectEntryPos( 0 ); // yes 1513*cdf0e10cSrcweir } 1514*cdf0e10cSrcweir 1515*cdf0e10cSrcweir if( pTextLen ) 1516*cdf0e10cSrcweir { 1517*cdf0e10cSrcweir pTextLen->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) ); 1518*cdf0e10cSrcweir pTextLen->ClearModifyFlag(); 1519*cdf0e10cSrcweir } 1520*cdf0e10cSrcweir 1521*cdf0e10cSrcweir if( pNumType ) 1522*cdf0e10cSrcweir { 1523*cdf0e10cSrcweir OSL_ENSURE(sal_False, "OFieldDescControl::DisplayData: invalid num type!"); 1524*cdf0e10cSrcweir } 1525*cdf0e10cSrcweir 1526*cdf0e10cSrcweir if( pLength ) 1527*cdf0e10cSrcweir pLength->SetText( String::CreateFromInt32(pFieldDescr->GetPrecision()) ); 1528*cdf0e10cSrcweir 1529*cdf0e10cSrcweir if( pScale ) 1530*cdf0e10cSrcweir pScale->SetText( String::CreateFromInt32(pFieldDescr->GetScale()) ); 1531*cdf0e10cSrcweir 1532*cdf0e10cSrcweir if( pFormat ) 1533*cdf0e10cSrcweir UpdateFormatSample(pFieldDescr); 1534*cdf0e10cSrcweir 1535*cdf0e10cSrcweir if(m_pColumnName) 1536*cdf0e10cSrcweir m_pColumnName->SetText(pFieldDescr->GetName()); 1537*cdf0e10cSrcweir 1538*cdf0e10cSrcweir if(m_pType) 1539*cdf0e10cSrcweir { 1540*cdf0e10cSrcweir sal_uInt16 nPos = pFieldType.get() ? m_pType->GetEntryPos(String(pFieldDescr->getTypeInfo()->aUIName)) : LISTBOX_ENTRY_NOTFOUND; 1541*cdf0e10cSrcweir if(nPos == LISTBOX_ENTRY_NOTFOUND) 1542*cdf0e10cSrcweir { 1543*cdf0e10cSrcweir const OTypeInfoMap* pMap = getTypeInfo(); 1544*cdf0e10cSrcweir OTypeInfoMap::const_iterator aIter = pMap->find(pFieldType.get() ? pFieldDescr->getTypeInfo()->nType : pFieldDescr->GetType()); 1545*cdf0e10cSrcweir if(aIter == pMap->end() && !pMap->empty()) 1546*cdf0e10cSrcweir { 1547*cdf0e10cSrcweir aIter = pMap->begin(); 1548*cdf0e10cSrcweir if(pFieldDescr->GetPrecision() > aIter->second->nPrecision) 1549*cdf0e10cSrcweir pFieldDescr->SetPrecision(aIter->second->nPrecision); 1550*cdf0e10cSrcweir if(pFieldDescr->GetScale() > aIter->second->nMaximumScale) 1551*cdf0e10cSrcweir pFieldDescr->SetScale(0); 1552*cdf0e10cSrcweir if(!aIter->second->bNullable && pFieldDescr->IsNullable()) 1553*cdf0e10cSrcweir pFieldDescr->SetIsNullable(ColumnValue::NO_NULLS); 1554*cdf0e10cSrcweir if(!aIter->second->bAutoIncrement && pFieldDescr->IsAutoIncrement()) 1555*cdf0e10cSrcweir pFieldDescr->SetAutoIncrement(sal_False); 1556*cdf0e10cSrcweir } 1557*cdf0e10cSrcweir if ( aIter != pMap->end() ) 1558*cdf0e10cSrcweir { 1559*cdf0e10cSrcweir pFieldDescr->SetType(aIter->second); 1560*cdf0e10cSrcweir } 1561*cdf0e10cSrcweir } 1562*cdf0e10cSrcweir m_pType->SelectEntry(pFieldDescr->getTypeInfo()->aUIName); 1563*cdf0e10cSrcweir } 1564*cdf0e10cSrcweir 1565*cdf0e10cSrcweir 1566*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1567*cdf0e10cSrcweir // Controls Enablen/Disablen 1568*cdf0e10cSrcweir sal_Bool bRead(IsReadOnly()); 1569*cdf0e10cSrcweir 1570*cdf0e10cSrcweir 1571*cdf0e10cSrcweir ArrangeAggregates(); 1572*cdf0e10cSrcweir CheckScrollBars(); 1573*cdf0e10cSrcweir ScrollAllAggregates(); 1574*cdf0e10cSrcweir 1575*cdf0e10cSrcweir SetReadOnly( bRead ); 1576*cdf0e10cSrcweir } 1577*cdf0e10cSrcweir //------------------------------------------------------------------------ 1578*cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, DelayedGrabFocus, Control**, ppControl) 1579*cdf0e10cSrcweir { 1580*cdf0e10cSrcweir nDelayedGrabFocusEvent = 0; 1581*cdf0e10cSrcweir if (*ppControl) 1582*cdf0e10cSrcweir (*ppControl)->GrabFocus(); 1583*cdf0e10cSrcweir 1584*cdf0e10cSrcweir return 0L; 1585*cdf0e10cSrcweir } 1586*cdf0e10cSrcweir 1587*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1588*cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnControlFocusGot, Control*, pControl ) 1589*cdf0e10cSrcweir { 1590*cdf0e10cSrcweir String strHelpText; 1591*cdf0e10cSrcweir OPropNumericEditCtrl* pNumeric = dynamic_cast< OPropNumericEditCtrl* >( pControl ); 1592*cdf0e10cSrcweir if ( pNumeric ) 1593*cdf0e10cSrcweir { 1594*cdf0e10cSrcweir pNumeric->SaveValue(); 1595*cdf0e10cSrcweir strHelpText = pNumeric->GetHelp(); 1596*cdf0e10cSrcweir } 1597*cdf0e10cSrcweir 1598*cdf0e10cSrcweir OPropColumnEditCtrl* pColumn = dynamic_cast< OPropColumnEditCtrl* >( pControl ); 1599*cdf0e10cSrcweir if ( pColumn ) 1600*cdf0e10cSrcweir { 1601*cdf0e10cSrcweir pColumn->SaveValue(); 1602*cdf0e10cSrcweir strHelpText = pColumn->GetHelp(); 1603*cdf0e10cSrcweir } 1604*cdf0e10cSrcweir 1605*cdf0e10cSrcweir OPropEditCtrl* pEdit = dynamic_cast< OPropEditCtrl* >( pControl ); 1606*cdf0e10cSrcweir if ( pEdit ) 1607*cdf0e10cSrcweir { 1608*cdf0e10cSrcweir pEdit->SaveValue(); 1609*cdf0e10cSrcweir strHelpText = pEdit->GetHelp(); 1610*cdf0e10cSrcweir } 1611*cdf0e10cSrcweir 1612*cdf0e10cSrcweir OPropListBoxCtrl* pListBox = dynamic_cast< OPropListBoxCtrl* >( pControl ); 1613*cdf0e10cSrcweir if ( pListBox ) 1614*cdf0e10cSrcweir { 1615*cdf0e10cSrcweir pListBox->SaveValue(); 1616*cdf0e10cSrcweir strHelpText = pListBox->GetHelp(); 1617*cdf0e10cSrcweir } 1618*cdf0e10cSrcweir 1619*cdf0e10cSrcweir if (pControl == pFormat) 1620*cdf0e10cSrcweir strHelpText =String(ModuleRes(STR_HELP_FORMAT_BUTTON)); 1621*cdf0e10cSrcweir 1622*cdf0e10cSrcweir if (strHelpText.Len() && (pHelp != NULL)) 1623*cdf0e10cSrcweir pHelp->SetHelpText(strHelpText); 1624*cdf0e10cSrcweir 1625*cdf0e10cSrcweir m_pActFocusWindow = pControl; 1626*cdf0e10cSrcweir 1627*cdf0e10cSrcweir return 0L; 1628*cdf0e10cSrcweir } 1629*cdf0e10cSrcweir 1630*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1631*cdf0e10cSrcweir IMPL_LINK(OFieldDescControl, OnControlFocusLost, Control*, pControl ) 1632*cdf0e10cSrcweir { 1633*cdf0e10cSrcweir if ((pControl == pLength) || (pControl == pTextLen) || (pControl == pScale)) 1634*cdf0e10cSrcweir { 1635*cdf0e10cSrcweir OPropNumericEditCtrl* pConverted = (OPropNumericEditCtrl*)pControl; 1636*cdf0e10cSrcweir if (pConverted->IsModified()) 1637*cdf0e10cSrcweir CellModified(-1, pConverted->GetPos()); 1638*cdf0e10cSrcweir } 1639*cdf0e10cSrcweir if(pControl == m_pColumnName) 1640*cdf0e10cSrcweir { 1641*cdf0e10cSrcweir OPropColumnEditCtrl* pConverted = (OPropColumnEditCtrl*)pControl; 1642*cdf0e10cSrcweir if (pConverted->IsModified()) 1643*cdf0e10cSrcweir CellModified(-1, pConverted->GetPos()); 1644*cdf0e10cSrcweir } 1645*cdf0e10cSrcweir else if ((pControl == pDefault) || (pControl == pFormatSample) || (pControl == m_pAutoIncrementValue) ) 1646*cdf0e10cSrcweir { 1647*cdf0e10cSrcweir OPropEditCtrl* pConverted = (OPropEditCtrl*)pControl; 1648*cdf0e10cSrcweir if (pConverted->IsModified()) 1649*cdf0e10cSrcweir CellModified(-1, pConverted->GetPos()); 1650*cdf0e10cSrcweir } 1651*cdf0e10cSrcweir else if ((pControl == pRequired) || (pControl == pNumType) || (pControl == pAutoIncrement) || (pControl == pBoolDefault) || (pControl == m_pType)) 1652*cdf0e10cSrcweir { 1653*cdf0e10cSrcweir OPropListBoxCtrl* pConverted = (OPropListBoxCtrl*)pControl; 1654*cdf0e10cSrcweir if (pConverted->IsModified()) 1655*cdf0e10cSrcweir CellModified(-1, pConverted->GetPos()); 1656*cdf0e10cSrcweir } 1657*cdf0e10cSrcweir 1658*cdf0e10cSrcweir if (pControl == pDefault) 1659*cdf0e10cSrcweir UpdateFormatSample(pActFieldDescr); 1660*cdf0e10cSrcweir 1661*cdf0e10cSrcweir implFocusLost(pControl); 1662*cdf0e10cSrcweir 1663*cdf0e10cSrcweir return 0L; 1664*cdf0e10cSrcweir } 1665*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1666*cdf0e10cSrcweir void OFieldDescControl::SaveData( OFieldDescription* pFieldDescr ) 1667*cdf0e10cSrcweir { 1668*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1669*cdf0e10cSrcweir if( !pFieldDescr ) 1670*cdf0e10cSrcweir return; 1671*cdf0e10cSrcweir 1672*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1673*cdf0e10cSrcweir // Controls auslesen 1674*cdf0e10cSrcweir ::rtl::OUString sDefault; 1675*cdf0e10cSrcweir if (pDefault) 1676*cdf0e10cSrcweir { 1677*cdf0e10cSrcweir sDefault = pDefault->GetText(); 1678*cdf0e10cSrcweir } 1679*cdf0e10cSrcweir else if (pBoolDefault) 1680*cdf0e10cSrcweir { 1681*cdf0e10cSrcweir sDefault = BoolStringPersistent(pBoolDefault->GetSelectEntry()); 1682*cdf0e10cSrcweir } 1683*cdf0e10cSrcweir 1684*cdf0e10cSrcweir if ( sDefault.getLength() ) 1685*cdf0e10cSrcweir pFieldDescr->SetControlDefault(makeAny(sDefault)); 1686*cdf0e10cSrcweir else 1687*cdf0e10cSrcweir pFieldDescr->SetControlDefault(Any()); 1688*cdf0e10cSrcweir 1689*cdf0e10cSrcweir if((pRequired && pRequired->GetSelectEntryPos() == 0) || pFieldDescr->IsPrimaryKey() || (pBoolDefault && pBoolDefault->GetEntryCount() == 2)) // yes 1690*cdf0e10cSrcweir pFieldDescr->SetIsNullable( ColumnValue::NO_NULLS ); 1691*cdf0e10cSrcweir else 1692*cdf0e10cSrcweir pFieldDescr->SetIsNullable( ColumnValue::NULLABLE ); 1693*cdf0e10cSrcweir 1694*cdf0e10cSrcweir if ( pAutoIncrement ) 1695*cdf0e10cSrcweir pFieldDescr->SetAutoIncrement( pAutoIncrement->GetSelectEntryPos() == 0 ); 1696*cdf0e10cSrcweir 1697*cdf0e10cSrcweir if( pTextLen ) 1698*cdf0e10cSrcweir pFieldDescr->SetPrecision( static_cast<sal_Int32>(pTextLen->GetValue()) ); 1699*cdf0e10cSrcweir else if( pLength ) 1700*cdf0e10cSrcweir pFieldDescr->SetPrecision( static_cast<sal_Int32>(pLength->GetValue()) ); 1701*cdf0e10cSrcweir if( pScale ) 1702*cdf0e10cSrcweir pFieldDescr->SetScale( static_cast<sal_Int32>(pScale->GetValue()) ); 1703*cdf0e10cSrcweir 1704*cdf0e10cSrcweir if(m_pColumnName) 1705*cdf0e10cSrcweir pFieldDescr->SetName(m_pColumnName->GetText()); 1706*cdf0e10cSrcweir 1707*cdf0e10cSrcweir if ( m_pAutoIncrementValue && isAutoIncrementValueEnabled() ) 1708*cdf0e10cSrcweir pFieldDescr->SetAutoIncrementValue(m_pAutoIncrementValue->GetText()); 1709*cdf0e10cSrcweir } 1710*cdf0e10cSrcweir 1711*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1712*cdf0e10cSrcweir void OFieldDescControl::UpdateFormatSample(OFieldDescription* pFieldDescr) 1713*cdf0e10cSrcweir { 1714*cdf0e10cSrcweir if ( pFieldDescr && pFormatSample ) 1715*cdf0e10cSrcweir pFormatSample->SetText(getControlDefault(pFieldDescr,sal_False)); 1716*cdf0e10cSrcweir } 1717*cdf0e10cSrcweir 1718*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1719*cdf0e10cSrcweir void OFieldDescControl::GetFocus() 1720*cdf0e10cSrcweir { 1721*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1722*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1723*cdf0e10cSrcweir // Setzt den Focus auf das zuletzt aktive Control 1724*cdf0e10cSrcweir TabPage::GetFocus(); 1725*cdf0e10cSrcweir if( pLastFocusWindow ) 1726*cdf0e10cSrcweir { 1727*cdf0e10cSrcweir pLastFocusWindow->GrabFocus(); 1728*cdf0e10cSrcweir pLastFocusWindow = NULL; 1729*cdf0e10cSrcweir } 1730*cdf0e10cSrcweir } 1731*cdf0e10cSrcweir 1732*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1733*cdf0e10cSrcweir void OFieldDescControl::implFocusLost(Window* _pWhich) 1734*cdf0e10cSrcweir { 1735*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1736*cdf0e10cSrcweir DBG_ASSERT(!_pWhich || IsChild(_pWhich), "OFieldDescControl::implFocusLost : invalid window !"); 1737*cdf0e10cSrcweir 1738*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1739*cdf0e10cSrcweir // Das aktive Control merken 1740*cdf0e10cSrcweir if (!pLastFocusWindow) 1741*cdf0e10cSrcweir pLastFocusWindow = _pWhich; 1742*cdf0e10cSrcweir 1743*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////// 1744*cdf0e10cSrcweir // HelpText zuruecksetzen 1745*cdf0e10cSrcweir if (pHelp && !pHelp->HasChildPathFocus()) 1746*cdf0e10cSrcweir pHelp->SetHelpText( String() ); 1747*cdf0e10cSrcweir } 1748*cdf0e10cSrcweir 1749*cdf0e10cSrcweir //------------------------------------------------------------------------------ 1750*cdf0e10cSrcweir void OFieldDescControl::LoseFocus() 1751*cdf0e10cSrcweir { 1752*cdf0e10cSrcweir DBG_CHKTHIS(OFieldDescControl,NULL); 1753*cdf0e10cSrcweir 1754*cdf0e10cSrcweir implFocusLost(NULL); 1755*cdf0e10cSrcweir 1756*cdf0e10cSrcweir TabPage::LoseFocus(); 1757*cdf0e10cSrcweir } 1758*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1759*cdf0e10cSrcweir sal_Bool OFieldDescControl::isCopyAllowed() 1760*cdf0e10cSrcweir { 1761*cdf0e10cSrcweir sal_Bool bAllowed = (m_pActFocusWindow != NULL) && 1762*cdf0e10cSrcweir (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || 1763*cdf0e10cSrcweir m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || 1764*cdf0e10cSrcweir m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || 1765*cdf0e10cSrcweir m_pActFocusWindow == m_pAutoIncrementValue) && 1766*cdf0e10cSrcweir static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0; 1767*cdf0e10cSrcweir 1768*cdf0e10cSrcweir return bAllowed; 1769*cdf0e10cSrcweir } 1770*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1771*cdf0e10cSrcweir sal_Bool OFieldDescControl::isCutAllowed() 1772*cdf0e10cSrcweir { 1773*cdf0e10cSrcweir sal_Bool bAllowed = (m_pActFocusWindow != NULL) && 1774*cdf0e10cSrcweir (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || 1775*cdf0e10cSrcweir m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || 1776*cdf0e10cSrcweir m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || 1777*cdf0e10cSrcweir m_pActFocusWindow == m_pAutoIncrementValue) && 1778*cdf0e10cSrcweir static_cast<Edit*>(m_pActFocusWindow)->GetSelected().Len() != 0; 1779*cdf0e10cSrcweir return bAllowed; 1780*cdf0e10cSrcweir } 1781*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1782*cdf0e10cSrcweir sal_Bool OFieldDescControl::isPasteAllowed() 1783*cdf0e10cSrcweir { 1784*cdf0e10cSrcweir sal_Bool bAllowed = (m_pActFocusWindow != NULL) && 1785*cdf0e10cSrcweir (m_pActFocusWindow == pDefault || m_pActFocusWindow == pFormatSample || 1786*cdf0e10cSrcweir m_pActFocusWindow == pTextLen || m_pActFocusWindow == pLength || 1787*cdf0e10cSrcweir m_pActFocusWindow == pScale || m_pActFocusWindow == m_pColumnName || 1788*cdf0e10cSrcweir m_pActFocusWindow == m_pAutoIncrementValue); 1789*cdf0e10cSrcweir if ( bAllowed ) 1790*cdf0e10cSrcweir { 1791*cdf0e10cSrcweir TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent())); 1792*cdf0e10cSrcweir bAllowed = aTransferData.HasFormat(SOT_FORMAT_STRING); 1793*cdf0e10cSrcweir } 1794*cdf0e10cSrcweir return bAllowed; 1795*cdf0e10cSrcweir } 1796*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1797*cdf0e10cSrcweir void OFieldDescControl::cut() 1798*cdf0e10cSrcweir { 1799*cdf0e10cSrcweir if(isCutAllowed()) 1800*cdf0e10cSrcweir static_cast<Edit*>(m_pActFocusWindow)->Cut(); 1801*cdf0e10cSrcweir } 1802*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1803*cdf0e10cSrcweir void OFieldDescControl::copy() 1804*cdf0e10cSrcweir { 1805*cdf0e10cSrcweir if(isCopyAllowed()) // this only checks if the focus window is valid 1806*cdf0e10cSrcweir static_cast<Edit*>(m_pActFocusWindow)->Copy(); 1807*cdf0e10cSrcweir } 1808*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1809*cdf0e10cSrcweir void OFieldDescControl::paste() 1810*cdf0e10cSrcweir { 1811*cdf0e10cSrcweir if(m_pActFocusWindow) // this only checks if the focus window is valid 1812*cdf0e10cSrcweir static_cast<Edit*>(m_pActFocusWindow)->Paste(); 1813*cdf0e10cSrcweir } 1814*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1815*cdf0e10cSrcweir sal_Bool OFieldDescControl::isTextFormat(const OFieldDescription* _pFieldDescr,sal_uInt32& _nFormatKey) const 1816*cdf0e10cSrcweir { 1817*cdf0e10cSrcweir _nFormatKey = _pFieldDescr->GetFormatKey(); 1818*cdf0e10cSrcweir sal_Bool bTextFormat = sal_True; 1819*cdf0e10cSrcweir 1820*cdf0e10cSrcweir try 1821*cdf0e10cSrcweir { 1822*cdf0e10cSrcweir if (!_nFormatKey) 1823*cdf0e10cSrcweir { 1824*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatTypes> xNumberTypes(GetFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY); 1825*cdf0e10cSrcweir OSL_ENSURE(xNumberTypes.is(),"XNumberFormatTypes is null!"); 1826*cdf0e10cSrcweir 1827*cdf0e10cSrcweir _nFormatKey = ::dbtools::getDefaultNumberFormat( _pFieldDescr->GetType(), 1828*cdf0e10cSrcweir _pFieldDescr->GetScale(), 1829*cdf0e10cSrcweir _pFieldDescr->IsCurrency(), 1830*cdf0e10cSrcweir xNumberTypes, 1831*cdf0e10cSrcweir GetLocale()); 1832*cdf0e10cSrcweir } 1833*cdf0e10cSrcweir sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(GetFormatter(),_nFormatKey); 1834*cdf0e10cSrcweir bTextFormat = (nNumberFormat == ::com::sun::star::util::NumberFormat::TEXT); 1835*cdf0e10cSrcweir } 1836*cdf0e10cSrcweir catch(const Exception&) 1837*cdf0e10cSrcweir { 1838*cdf0e10cSrcweir 1839*cdf0e10cSrcweir } 1840*cdf0e10cSrcweir 1841*cdf0e10cSrcweir return bTextFormat; 1842*cdf0e10cSrcweir } 1843*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1844*cdf0e10cSrcweir String OFieldDescControl::getControlDefault( const OFieldDescription* _pFieldDescr ,sal_Bool _bCheck) const 1845*cdf0e10cSrcweir { 1846*cdf0e10cSrcweir ::rtl::OUString sDefault; 1847*cdf0e10cSrcweir sal_Bool bCheck = !_bCheck || _pFieldDescr->GetControlDefault().hasValue(); 1848*cdf0e10cSrcweir if ( bCheck ) 1849*cdf0e10cSrcweir { 1850*cdf0e10cSrcweir sal_uInt32 nFormatKey; 1851*cdf0e10cSrcweir sal_Bool bTextFormat = sal_False; 1852*cdf0e10cSrcweir double nValue = 0.0; 1853*cdf0e10cSrcweir 1854*cdf0e10cSrcweir try 1855*cdf0e10cSrcweir { 1856*cdf0e10cSrcweir bTextFormat = isTextFormat(_pFieldDescr,nFormatKey); 1857*cdf0e10cSrcweir if ( _pFieldDescr->GetControlDefault() >>= sDefault ) 1858*cdf0e10cSrcweir { 1859*cdf0e10cSrcweir if ( !bTextFormat ) 1860*cdf0e10cSrcweir { 1861*cdf0e10cSrcweir if ( sDefault.getLength() ) 1862*cdf0e10cSrcweir { 1863*cdf0e10cSrcweir try 1864*cdf0e10cSrcweir { 1865*cdf0e10cSrcweir nValue = GetFormatter()->convertStringToNumber(nFormatKey,sDefault); 1866*cdf0e10cSrcweir } 1867*cdf0e10cSrcweir catch(const Exception&) 1868*cdf0e10cSrcweir { 1869*cdf0e10cSrcweir return ::rtl::OUString(); // return empty string for format example 1870*cdf0e10cSrcweir } 1871*cdf0e10cSrcweir } 1872*cdf0e10cSrcweir } 1873*cdf0e10cSrcweir } 1874*cdf0e10cSrcweir else 1875*cdf0e10cSrcweir _pFieldDescr->GetControlDefault() >>= nValue; 1876*cdf0e10cSrcweir 1877*cdf0e10cSrcweir 1878*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatter> xNumberFormatter = GetFormatter(); 1879*cdf0e10cSrcweir Reference<XPropertySet> xFormSet = xNumberFormatter->getNumberFormatsSupplier()->getNumberFormats()->getByKey(nFormatKey); 1880*cdf0e10cSrcweir OSL_ENSURE(xFormSet.is(),"XPropertySet is null!"); 1881*cdf0e10cSrcweir ::rtl::OUString sFormat; 1882*cdf0e10cSrcweir xFormSet->getPropertyValue(::rtl::OUString::createFromAscii("FormatString")) >>= sFormat; 1883*cdf0e10cSrcweir 1884*cdf0e10cSrcweir if ( !bTextFormat ) 1885*cdf0e10cSrcweir { 1886*cdf0e10cSrcweir Locale aLocale; 1887*cdf0e10cSrcweir ::comphelper::getNumberFormatProperty(xNumberFormatter,nFormatKey,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Locale"))) >>= aLocale; 1888*cdf0e10cSrcweir 1889*cdf0e10cSrcweir sal_Int32 nNumberFormat = ::comphelper::getNumberFormatType(xNumberFormatter,nFormatKey); 1890*cdf0e10cSrcweir if( (nNumberFormat & ::com::sun::star::util::NumberFormat::DATE) == ::com::sun::star::util::NumberFormat::DATE 1891*cdf0e10cSrcweir || (nNumberFormat & ::com::sun::star::util::NumberFormat::DATETIME) == ::com::sun::star::util::NumberFormat::DATETIME ) 1892*cdf0e10cSrcweir { 1893*cdf0e10cSrcweir nValue = DBTypeConversion::toNullDate(DBTypeConversion::getNULLDate(xNumberFormatter->getNumberFormatsSupplier()),nValue); 1894*cdf0e10cSrcweir } 1895*cdf0e10cSrcweir 1896*cdf0e10cSrcweir 1897*cdf0e10cSrcweir 1898*cdf0e10cSrcweir Reference< ::com::sun::star::util::XNumberFormatPreviewer> xPreViewer(xNumberFormatter,UNO_QUERY); 1899*cdf0e10cSrcweir OSL_ENSURE(xPreViewer.is(),"XNumberFormatPreviewer is null!"); 1900*cdf0e10cSrcweir sDefault = xPreViewer->convertNumberToPreviewString(sFormat,nValue,aLocale,sal_True); 1901*cdf0e10cSrcweir } 1902*cdf0e10cSrcweir else if ( !_bCheck || (sDefault.getLength() != 0) ) 1903*cdf0e10cSrcweir sDefault = xNumberFormatter->formatString(nFormatKey,(sDefault.getLength() != 0 )? sDefault : sFormat); 1904*cdf0e10cSrcweir } 1905*cdf0e10cSrcweir catch(const Exception&) 1906*cdf0e10cSrcweir { 1907*cdf0e10cSrcweir 1908*cdf0e10cSrcweir } 1909*cdf0e10cSrcweir } 1910*cdf0e10cSrcweir 1911*cdf0e10cSrcweir return sDefault; 1912*cdf0e10cSrcweir } 1913*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 1914