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 #ifndef _DBAUI_PARAMDIALOG_HXX_ 32*cdf0e10cSrcweir #include "paramdialog.hxx" 33*cdf0e10cSrcweir #endif 34*cdf0e10cSrcweir #ifndef _DBAUI_PARAMDIALOG_HRC_ 35*cdf0e10cSrcweir #include "paramdialog.hrc" 36*cdf0e10cSrcweir #endif 37*cdf0e10cSrcweir #ifndef _DBU_DLG_HRC_ 38*cdf0e10cSrcweir #include "dbu_dlg.hrc" 39*cdf0e10cSrcweir #endif 40*cdf0e10cSrcweir #ifndef _DBAUI_COMMON_TYPES_HXX_ 41*cdf0e10cSrcweir #include "commontypes.hxx" 42*cdf0e10cSrcweir #endif 43*cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 44*cdf0e10cSrcweir #include "moduledbu.hxx" 45*cdf0e10cSrcweir #endif 46*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_ 47*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp> 48*cdf0e10cSrcweir #endif 49*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ 50*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp> 51*cdf0e10cSrcweir #endif 52*cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 53*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 54*cdf0e10cSrcweir #endif 55*cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 56*cdf0e10cSrcweir #include "dbustrings.hrc" 57*cdf0e10cSrcweir #endif 58*cdf0e10cSrcweir #ifndef _SV_SVAPP_HXX 59*cdf0e10cSrcweir #include <vcl/svapp.hxx> 60*cdf0e10cSrcweir #endif 61*cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX 62*cdf0e10cSrcweir #include <vcl/msgbox.hxx> 63*cdf0e10cSrcweir #endif 64*cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX 65*cdf0e10cSrcweir #include <tools/debug.hxx> 66*cdf0e10cSrcweir #endif 67*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 68*cdf0e10cSrcweir #ifndef _DBAUI_LOCALRESACCESS_HXX_ 69*cdf0e10cSrcweir #include "localresaccess.hxx" 70*cdf0e10cSrcweir #endif 71*cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_SYSLOCALE_HXX 72*cdf0e10cSrcweir #include <unotools/syslocale.hxx> 73*cdf0e10cSrcweir #endif 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir #define EF_VISITED 0x0001 76*cdf0e10cSrcweir #define EF_DIRTY 0x0002 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir //......................................................................... 79*cdf0e10cSrcweir namespace dbaui 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir //......................................................................... 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 84*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 85*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 86*cdf0e10cSrcweir using namespace ::com::sun::star::container; 87*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 88*cdf0e10cSrcweir using namespace ::com::sun::star::util; 89*cdf0e10cSrcweir using namespace ::connectivity; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir //================================================================== 92*cdf0e10cSrcweir //= OParameterDialog 93*cdf0e10cSrcweir //================================================================== 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //------------------------------------------------------------------------------ 96*cdf0e10cSrcweir #define INIT_MEMBERS() \ 97*cdf0e10cSrcweir :ModalDialog( pParent, ModuleRes(DLG_PARAMETERS)) \ 98*cdf0e10cSrcweir ,m_aNamesFrame (this, ModuleRes(FL_PARAMS)) \ 99*cdf0e10cSrcweir ,m_aAllParams (this, ModuleRes(LB_ALLPARAMS)) \ 100*cdf0e10cSrcweir ,m_aValueFrame (this, ModuleRes(FT_VALUE)) \ 101*cdf0e10cSrcweir ,m_aParam (this, ModuleRes(ET_PARAM)) \ 102*cdf0e10cSrcweir ,m_aTravelNext (this, ModuleRes(BT_TRAVELNEXT)) \ 103*cdf0e10cSrcweir ,m_aOKBtn (this, ModuleRes(BT_OK)) \ 104*cdf0e10cSrcweir ,m_aCancelBtn (this, ModuleRes(BT_CANCEL)) \ 105*cdf0e10cSrcweir ,m_nCurrentlySelected(LISTBOX_ENTRY_NOTFOUND) \ 106*cdf0e10cSrcweir ,m_xConnection(_rxConnection) \ 107*cdf0e10cSrcweir ,m_aPredicateInput( _rxORB, _rxConnection, getParseContext() ) \ 108*cdf0e10cSrcweir ,m_bNeedErrorOnCurrent(sal_True) \ 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir //------------------------------------------------------------------------------ 112*cdf0e10cSrcweir DBG_NAME(OParameterDialog) 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir OParameterDialog::OParameterDialog( 115*cdf0e10cSrcweir Window* pParent, const Reference< XIndexAccess > & rParamContainer, 116*cdf0e10cSrcweir const Reference< XConnection > & _rxConnection, const Reference< XMultiServiceFactory >& _rxORB) 117*cdf0e10cSrcweir INIT_MEMBERS() 118*cdf0e10cSrcweir { 119*cdf0e10cSrcweir DBG_CTOR(OParameterDialog,NULL); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir if (_rxORB.is()) 122*cdf0e10cSrcweir m_xFormatter = Reference< XNumberFormatter>(_rxORB->createInstance( 123*cdf0e10cSrcweir ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.NumberFormatter"))), UNO_QUERY); 124*cdf0e10cSrcweir else { 125*cdf0e10cSrcweir DBG_ERROR("OParameterDialog::OParameterDialog: need a service factory!"); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir Reference< XNumberFormatsSupplier > xNumberFormats = ::dbtools::getNumberFormats(m_xConnection, sal_True); 129*cdf0e10cSrcweir if (!xNumberFormats.is()) 130*cdf0e10cSrcweir ::comphelper::disposeComponent(m_xFormatter); 131*cdf0e10cSrcweir else if (m_xFormatter.is()) 132*cdf0e10cSrcweir m_xFormatter->attachNumberFormatsSupplier(xNumberFormats); 133*cdf0e10cSrcweir try 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir DBG_ASSERT(rParamContainer->getCount(), "OParameterDialog::OParameterDialog : can't handle empty containers !"); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir m_aFinalValues.realloc(rParamContainer->getCount()); 138*cdf0e10cSrcweir PropertyValue* pValues = m_aFinalValues.getArray(); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir for (sal_Int32 i = 0, nCount = rParamContainer->getCount(); i<nCount; ++i, ++pValues) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir Reference< XPropertySet > xParamAsSet; 143*cdf0e10cSrcweir rParamContainer->getByIndex(i) >>= xParamAsSet; 144*cdf0e10cSrcweir OSL_ENSURE(xParamAsSet.is(),"Parameter is null!"); 145*cdf0e10cSrcweir if(!xParamAsSet.is()) 146*cdf0e10cSrcweir continue; 147*cdf0e10cSrcweir pValues->Name = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME)); 148*cdf0e10cSrcweir m_aAllParams.InsertEntry(pValues->Name); 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir if (!pValues->Value.hasValue()) 151*cdf0e10cSrcweir // it won't have a value, 'cause it's default constructed. But may be later we support 152*cdf0e10cSrcweir // initializing this dialog with values 153*cdf0e10cSrcweir pValues->Value = makeAny(::rtl::OUString()); 154*cdf0e10cSrcweir // default the values to an empty string 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir m_aVisitedParams.push_back(0); 157*cdf0e10cSrcweir // not visited, not dirty 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir m_xParams = rParamContainer; 161*cdf0e10cSrcweir } 162*cdf0e10cSrcweir catch(Exception&) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir Construct(); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir m_aResetVisitFlag.SetTimeoutHdl(LINK(this, OParameterDialog, OnVisitedTimeout)); 171*cdf0e10cSrcweir 172*cdf0e10cSrcweir FreeResource(); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir //------------------------------------------------------------------------------ 176*cdf0e10cSrcweir OParameterDialog::~OParameterDialog() 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir if (m_aResetVisitFlag.IsActive()) 179*cdf0e10cSrcweir m_aResetVisitFlag.Stop(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir DBG_DTOR(OParameterDialog,NULL); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir //------------------------------------------------------------------------------ 185*cdf0e10cSrcweir void OParameterDialog::Construct() 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir m_aAllParams.SetSelectHdl(LINK(this, OParameterDialog, OnEntrySelected)); 188*cdf0e10cSrcweir m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus)); 189*cdf0e10cSrcweir m_aParam.SetModifyHdl(LINK(this, OParameterDialog, OnValueModified)); 190*cdf0e10cSrcweir m_aTravelNext.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); 191*cdf0e10cSrcweir m_aOKBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); 192*cdf0e10cSrcweir m_aCancelBtn.SetClickHdl(LINK(this, OParameterDialog, OnButtonClicked)); 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir if (m_aAllParams.GetEntryCount()) 195*cdf0e10cSrcweir { 196*cdf0e10cSrcweir m_aAllParams.SelectEntryPos(0); 197*cdf0e10cSrcweir LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams); 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir if (m_aAllParams.GetEntryCount() == 1) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir m_aTravelNext.Enable(sal_False); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir if (m_aAllParams.GetEntryCount() > 1) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() & ~WB_DEFBUTTON); 207*cdf0e10cSrcweir m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() | WB_DEFBUTTON); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir 211*cdf0e10cSrcweir m_aParam.GrabFocus(); 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir //------------------------------------------------------------------------------ 215*cdf0e10cSrcweir IMPL_LINK(OParameterDialog, OnValueLoseFocus, Control*, /*pSource*/) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir if ( ( m_aVisitedParams[ m_nCurrentlySelected ] & EF_DIRTY ) == 0 ) 220*cdf0e10cSrcweir // nothing to do, the value isn't dirty 221*cdf0e10cSrcweir return 0L; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir // transform the current string according to the param field type 225*cdf0e10cSrcweir ::rtl::OUString sTransformedText(m_aParam.GetText()); 226*cdf0e10cSrcweir Reference< XPropertySet > xParamAsSet; 227*cdf0e10cSrcweir m_xParams->getByIndex(m_nCurrentlySelected) >>= xParamAsSet; 228*cdf0e10cSrcweir if (xParamAsSet.is()) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir if (m_xConnection.is() && m_xFormatter.is()) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir ::rtl::OUString sParamValue( m_aParam.GetText() ); 233*cdf0e10cSrcweir sal_Bool bValid = m_aPredicateInput.normalizePredicateString( sParamValue, xParamAsSet ); 234*cdf0e10cSrcweir m_aParam.SetText( sParamValue ); 235*cdf0e10cSrcweir if ( bValid ) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir // with this the value isn't dirty anymore 238*cdf0e10cSrcweir if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) 239*cdf0e10cSrcweir m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir if (!m_bNeedErrorOnCurrent) 244*cdf0e10cSrcweir return 1L; 245*cdf0e10cSrcweir 246*cdf0e10cSrcweir m_bNeedErrorOnCurrent = sal_False; // will be reset in OnValueModified 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir ::rtl::OUString sName; 249*cdf0e10cSrcweir try 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir sName = ::comphelper::getString(xParamAsSet->getPropertyValue(PROPERTY_NAME)); 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir catch(Exception&) 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 256*cdf0e10cSrcweir } 257*cdf0e10cSrcweir 258*cdf0e10cSrcweir String sMessage; 259*cdf0e10cSrcweir { 260*cdf0e10cSrcweir LocalResourceAccess aDummy(DLG_PARAMETERS, RSC_MODALDIALOG); 261*cdf0e10cSrcweir sMessage = String(ModuleRes(STR_COULD_NOT_CONVERT_PARAM)); 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir sMessage.SearchAndReplaceAll(String::CreateFromAscii("$name$"), sName.getStr()); 264*cdf0e10cSrcweir ErrorBox(NULL, WB_OK, sMessage).Execute(); 265*cdf0e10cSrcweir m_aParam.GrabFocus(); 266*cdf0e10cSrcweir return 1L; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir return 0L; 272*cdf0e10cSrcweir } 273*cdf0e10cSrcweir 274*cdf0e10cSrcweir //------------------------------------------------------------------------------ 275*cdf0e10cSrcweir IMPL_LINK(OParameterDialog, OnButtonClicked, PushButton*, pButton) 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if (&m_aCancelBtn == pButton) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir // no interpreting of the given values anymore .... 280*cdf0e10cSrcweir m_aParam.SetLoseFocusHdl(Link()); // no direct call from the control anymore ... 281*cdf0e10cSrcweir m_bNeedErrorOnCurrent = sal_False; // in case of any indirect calls -> no error message 282*cdf0e10cSrcweir m_aCancelBtn.SetClickHdl(Link()); 283*cdf0e10cSrcweir m_aCancelBtn.Click(); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir else if (&m_aOKBtn == pButton) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir // transfer the current values into the Any 288*cdf0e10cSrcweir if (LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams) != 0L) 289*cdf0e10cSrcweir { // there was an error interpreting the current text 290*cdf0e10cSrcweir m_bNeedErrorOnCurrent = sal_True; 291*cdf0e10cSrcweir // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, 292*cdf0e10cSrcweir // so the next time it is called we need an error message, again .... 293*cdf0e10cSrcweir // (TODO : there surely are better solutions for this ...) 294*cdf0e10cSrcweir return 1L; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir if (m_xParams.is()) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir // write the parameters 300*cdf0e10cSrcweir try 301*cdf0e10cSrcweir { 302*cdf0e10cSrcweir ::rtl::OUString sError; 303*cdf0e10cSrcweir PropertyValue* pValues = m_aFinalValues.getArray(); 304*cdf0e10cSrcweir for (sal_Int32 i = 0, nCount = m_xParams->getCount(); i<nCount; ++i, ++pValues) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir Reference< XPropertySet > xParamAsSet; 307*cdf0e10cSrcweir m_xParams->getByIndex(i) >>= xParamAsSet; 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir ::rtl::OUString sValue; 310*cdf0e10cSrcweir pValues->Value >>= sValue; 311*cdf0e10cSrcweir pValues->Value <<= ::rtl::OUString( m_aPredicateInput.getPredicateValue( sValue, xParamAsSet, sal_False ) ); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir catch(Exception&) 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir // to close the dialog (which is more code than a simple EndDialog) 321*cdf0e10cSrcweir m_aOKBtn.SetClickHdl(Link()); 322*cdf0e10cSrcweir m_aOKBtn.Click(); 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir else if (&m_aTravelNext == pButton) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir sal_uInt16 nCurrent = m_aAllParams.GetSelectEntryPos(); 327*cdf0e10cSrcweir sal_uInt16 nCount = m_aAllParams.GetEntryCount(); 328*cdf0e10cSrcweir DBG_ASSERT(nCount == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !"); 329*cdf0e10cSrcweir 330*cdf0e10cSrcweir // search the next entry in list we haven't visited yet 331*cdf0e10cSrcweir sal_uInt16 nNext = (nCurrent + 1) % nCount; 332*cdf0e10cSrcweir while ((nNext != nCurrent) && ( m_aVisitedParams[nNext] & EF_VISITED )) 333*cdf0e10cSrcweir nNext = (nNext + 1) % nCount; 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir if ( m_aVisitedParams[nNext] & EF_VISITED ) 336*cdf0e10cSrcweir // there is no such "not visited yet" entry -> simpy take the next one 337*cdf0e10cSrcweir nNext = (nCurrent + 1) % nCount; 338*cdf0e10cSrcweir 339*cdf0e10cSrcweir m_aAllParams.SelectEntryPos(nNext); 340*cdf0e10cSrcweir LINK(this, OParameterDialog, OnEntrySelected).Call(&m_aAllParams); 341*cdf0e10cSrcweir m_bNeedErrorOnCurrent = sal_True; 342*cdf0e10cSrcweir // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, 343*cdf0e10cSrcweir // so the next time it is called we need an error message, again .... 344*cdf0e10cSrcweir // (TODO : there surely are better solutions for this ...) 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir return 0L; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir //------------------------------------------------------------------------------ 351*cdf0e10cSrcweir IMPL_LINK(OParameterDialog, OnEntrySelected, ListBox*, /*pList*/) 352*cdf0e10cSrcweir { 353*cdf0e10cSrcweir if (m_aResetVisitFlag.IsActive()) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir LINK(this, OParameterDialog, OnVisitedTimeout).Call(&m_aResetVisitFlag); 356*cdf0e10cSrcweir m_aResetVisitFlag.Stop(); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir // save the old values 359*cdf0e10cSrcweir if (m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir // do the transformation of the current text 362*cdf0e10cSrcweir if (LINK(this, OParameterDialog, OnValueLoseFocus).Call(&m_aParam) != 0L) 363*cdf0e10cSrcweir { // there was an error interpreting the text 364*cdf0e10cSrcweir m_aAllParams.SelectEntryPos(m_nCurrentlySelected); 365*cdf0e10cSrcweir return 1L; 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir m_aFinalValues[m_nCurrentlySelected].Value <<= ::rtl::OUString(m_aParam.GetText()); 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir // initialize the controls with the new values 372*cdf0e10cSrcweir sal_uInt16 nSelected = m_aAllParams.GetSelectEntryPos(); 373*cdf0e10cSrcweir DBG_ASSERT(nSelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnEntrySelected : no current entry !"); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir m_aParam.SetText(::comphelper::getString(m_aFinalValues[nSelected].Value)); 376*cdf0e10cSrcweir m_nCurrentlySelected = nSelected; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir // with this the value isn't dirty 379*cdf0e10cSrcweir DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnEntrySelected : invalid current entry !"); 380*cdf0e10cSrcweir m_aVisitedParams[m_nCurrentlySelected] &= ~EF_DIRTY; 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir m_aResetVisitFlag.SetTimeout(1000); 383*cdf0e10cSrcweir m_aResetVisitFlag.Start(); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir return 0L; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir //------------------------------------------------------------------------------ 389*cdf0e10cSrcweir IMPL_LINK(OParameterDialog, OnVisitedTimeout, Timer*, /*pTimer*/) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir DBG_ASSERT(m_nCurrentlySelected != LISTBOX_ENTRY_NOTFOUND, "OParameterDialog::OnVisitedTimeout : invalid call !"); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // mark the currently selected entry as visited 394*cdf0e10cSrcweir DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnVisitedTimeout : invalid entry !"); 395*cdf0e10cSrcweir m_aVisitedParams[m_nCurrentlySelected] |= EF_VISITED; 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // was it the last "not visited yet" entry ? 398*cdf0e10cSrcweir ConstByteVectorIterator aIter; 399*cdf0e10cSrcweir for ( aIter = m_aVisitedParams.begin(); 400*cdf0e10cSrcweir aIter < m_aVisitedParams.end(); 401*cdf0e10cSrcweir ++aIter 402*cdf0e10cSrcweir ) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir if (((*aIter) & EF_VISITED) == 0) 405*cdf0e10cSrcweir break; 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir if (aIter == m_aVisitedParams.end()) 408*cdf0e10cSrcweir { // yes, there isn't another one -> change the "default button" 409*cdf0e10cSrcweir m_aTravelNext.SetStyle(m_aTravelNext.GetStyle() & ~WB_DEFBUTTON); 410*cdf0e10cSrcweir m_aOKBtn.SetStyle(m_aOKBtn.GetStyle() | WB_DEFBUTTON); 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir // set to focus to one of the buttons temporary (with this their "default"-state is really updated) 413*cdf0e10cSrcweir Window* pOldFocus = Application::GetFocusWindow(); 414*cdf0e10cSrcweir 415*cdf0e10cSrcweir // if the old focus window is the value edit do some preparations ... 416*cdf0e10cSrcweir Selection aSel; 417*cdf0e10cSrcweir if (pOldFocus == &m_aParam) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir m_aParam.SetLoseFocusHdl(Link()); 420*cdf0e10cSrcweir aSel = m_aParam.GetSelection(); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir m_aTravelNext.GrabFocus(); 423*cdf0e10cSrcweir if (pOldFocus) 424*cdf0e10cSrcweir pOldFocus->GrabFocus(); 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir // restore the settings for the value edit 427*cdf0e10cSrcweir if (pOldFocus == &m_aParam) 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir m_aParam.SetLoseFocusHdl(LINK(this, OParameterDialog, OnValueLoseFocus)); 430*cdf0e10cSrcweir m_aParam.SetSelection(aSel); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir return 0L; 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir 437*cdf0e10cSrcweir //------------------------------------------------------------------------------ 438*cdf0e10cSrcweir IMPL_LINK(OParameterDialog, OnValueModified, Control*, /*pBox*/) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir // mark the currently selected entry as dirty 441*cdf0e10cSrcweir DBG_ASSERT(m_nCurrentlySelected < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !"); 442*cdf0e10cSrcweir m_aVisitedParams[m_nCurrentlySelected] |= EF_DIRTY; 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir m_bNeedErrorOnCurrent = sal_True; 445*cdf0e10cSrcweir 446*cdf0e10cSrcweir return 0L; 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir //......................................................................... 451*cdf0e10cSrcweir } // namespace dbaui 452*cdf0e10cSrcweir //......................................................................... 453