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_forms.hxx" 30*cdf0e10cSrcweir #include "limitedformats.hxx" 31*cdf0e10cSrcweir #include "services.hxx" 32*cdf0e10cSrcweir #include <osl/diagnose.h> 33*cdf0e10cSrcweir #include <comphelper/types.hxx> 34*cdf0e10cSrcweir #include <comphelper/extract.hxx> 35*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir //......................................................................... 38*cdf0e10cSrcweir namespace frm 39*cdf0e10cSrcweir { 40*cdf0e10cSrcweir //......................................................................... 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 43*cdf0e10cSrcweir using namespace ::com::sun::star::util; 44*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 45*cdf0e10cSrcweir using namespace ::com::sun::star::form; 46*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir sal_Int32 OLimitedFormats::s_nInstanceCount(0); 49*cdf0e10cSrcweir ::osl::Mutex OLimitedFormats::s_aMutex; 50*cdf0e10cSrcweir Reference< XNumberFormatsSupplier > OLimitedFormats::s_xStandardFormats; 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir //===================================================================== 53*cdf0e10cSrcweir //= 54*cdf0e10cSrcweir //===================================================================== 55*cdf0e10cSrcweir //--------------------------------------------------------------------- 56*cdf0e10cSrcweir enum LocaleType 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir ltEnglishUS, 59*cdf0e10cSrcweir ltGerman, 60*cdf0e10cSrcweir ltSystem 61*cdf0e10cSrcweir }; 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir //--------------------------------------------------------------------- 64*cdf0e10cSrcweir static const Locale& getLocale(LocaleType _eType) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir static const Locale s_aEnglishUS( ::rtl::OUString::createFromAscii("en"), ::rtl::OUString::createFromAscii("us"), ::rtl::OUString() ); 67*cdf0e10cSrcweir static const Locale s_aGerman( ::rtl::OUString::createFromAscii("de"), ::rtl::OUString::createFromAscii("DE"), ::rtl::OUString() ); 68*cdf0e10cSrcweir static const ::rtl::OUString s_sEmptyString; 69*cdf0e10cSrcweir static const Locale s_aSystem( s_sEmptyString, s_sEmptyString, s_sEmptyString ); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir switch (_eType) 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir case ltEnglishUS: 74*cdf0e10cSrcweir return s_aEnglishUS; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir case ltGerman: 77*cdf0e10cSrcweir return s_aGerman; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir case ltSystem: 80*cdf0e10cSrcweir return s_aSystem; 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir OSL_ENSURE(sal_False, "getLocale: invalid enum value!"); 84*cdf0e10cSrcweir return s_aSystem; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir //--------------------------------------------------------------------- 88*cdf0e10cSrcweir struct FormatEntry 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir const sal_Char* pDescription; 91*cdf0e10cSrcweir sal_Int32 nKey; 92*cdf0e10cSrcweir LocaleType eLocale; 93*cdf0e10cSrcweir }; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir //--------------------------------------------------------------------- 96*cdf0e10cSrcweir static const FormatEntry* lcl_getFormatTable(sal_Int16 nTableId) 97*cdf0e10cSrcweir { 98*cdf0e10cSrcweir switch (nTableId) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir case FormComponentType::TIMEFIELD: 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir static FormatEntry s_aFormats[] = { 103*cdf0e10cSrcweir { "HH:MM", -1, ltEnglishUS }, 104*cdf0e10cSrcweir { "HH:MM:SS", -1, ltEnglishUS }, 105*cdf0e10cSrcweir { "HH:MM AM/PM", -1, ltEnglishUS }, 106*cdf0e10cSrcweir { "HH:MM:SS AM/PM", -1, ltEnglishUS }, 107*cdf0e10cSrcweir { NULL, -1, ltSystem } 108*cdf0e10cSrcweir }; 109*cdf0e10cSrcweir // don't switch this table here to const. The compiler could be tempted to really place this 110*cdf0e10cSrcweir // in a non-writeable segment, but we want to fill in the format keys later .... 111*cdf0e10cSrcweir return s_aFormats; 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir case FormComponentType::DATEFIELD: 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir static FormatEntry s_aFormats[] = { 116*cdf0e10cSrcweir { "T-M-JJ", -1, ltGerman }, 117*cdf0e10cSrcweir { "TT-MM-JJ", -1, ltGerman }, 118*cdf0e10cSrcweir { "TT-MM-JJJJ", -1, ltGerman }, 119*cdf0e10cSrcweir { "NNNNT. MMMM JJJJ", -1, ltGerman }, 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir { "DD/MM/YY", -1, ltEnglishUS }, 122*cdf0e10cSrcweir { "MM/DD/YY", -1, ltEnglishUS }, 123*cdf0e10cSrcweir { "YY/MM/DD", -1, ltEnglishUS }, 124*cdf0e10cSrcweir { "DD/MM/YYYY", -1, ltEnglishUS }, 125*cdf0e10cSrcweir { "MM/DD/YYYY", -1, ltEnglishUS }, 126*cdf0e10cSrcweir { "YYYY/MM/DD", -1, ltEnglishUS }, 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir { "JJ-MM-TT", -1, ltGerman }, 129*cdf0e10cSrcweir { "JJJJ-MM-TT", -1, ltGerman }, 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir { NULL, -1, ltSystem } 132*cdf0e10cSrcweir }; 133*cdf0e10cSrcweir return s_aFormats; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir OSL_ENSURE(sal_False, "lcl_getFormatTable: invalid id!"); 138*cdf0e10cSrcweir return NULL; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir //===================================================================== 142*cdf0e10cSrcweir //= OLimitedFormats 143*cdf0e10cSrcweir //===================================================================== 144*cdf0e10cSrcweir //--------------------------------------------------------------------- 145*cdf0e10cSrcweir OLimitedFormats::OLimitedFormats(const Reference< XMultiServiceFactory >& _rxORB, const sal_Int16 _nClassId) 146*cdf0e10cSrcweir :m_nFormatEnumPropertyHandle(-1) 147*cdf0e10cSrcweir ,m_nTableId(_nClassId) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir OSL_ENSURE(_rxORB.is(), "OLimitedFormats::OLimitedFormats: invalid service factory!"); 150*cdf0e10cSrcweir acquireSupplier(_rxORB); 151*cdf0e10cSrcweir ensureTableInitialized(m_nTableId); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir //--------------------------------------------------------------------- 155*cdf0e10cSrcweir OLimitedFormats::~OLimitedFormats() 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir releaseSupplier(); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir //--------------------------------------------------------------------- 161*cdf0e10cSrcweir void OLimitedFormats::ensureTableInitialized(const sal_Int16 _nTableId) 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir const FormatEntry* pFormatTable = lcl_getFormatTable(_nTableId); 164*cdf0e10cSrcweir if (-1 == pFormatTable->nKey) 165*cdf0e10cSrcweir { 166*cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 167*cdf0e10cSrcweir if (-1 == pFormatTable->nKey) 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir // initialize the keys 170*cdf0e10cSrcweir Reference<XNumberFormats> xStandardFormats; 171*cdf0e10cSrcweir if (s_xStandardFormats.is()) 172*cdf0e10cSrcweir xStandardFormats = s_xStandardFormats->getNumberFormats(); 173*cdf0e10cSrcweir OSL_ENSURE(xStandardFormats.is(), "OLimitedFormats::ensureTableInitialized: don't have a formats supplier!"); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir if (xStandardFormats.is()) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir // loop through the table 178*cdf0e10cSrcweir FormatEntry* pLoopFormats = const_cast<FormatEntry*>(pFormatTable); 179*cdf0e10cSrcweir while (pLoopFormats->pDescription) 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir // get the key for the description 182*cdf0e10cSrcweir pLoopFormats->nKey = xStandardFormats->queryKey( 183*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pLoopFormats->pDescription), 184*cdf0e10cSrcweir getLocale(pLoopFormats->eLocale), 185*cdf0e10cSrcweir sal_False 186*cdf0e10cSrcweir ); 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir if (-1 == pLoopFormats->nKey) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir pLoopFormats->nKey = xStandardFormats->addNew( 191*cdf0e10cSrcweir ::rtl::OUString::createFromAscii(pLoopFormats->pDescription), 192*cdf0e10cSrcweir getLocale(pLoopFormats->eLocale) 193*cdf0e10cSrcweir ); 194*cdf0e10cSrcweir #ifdef DBG_UTIL 195*cdf0e10cSrcweir try 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir xStandardFormats->getByKey(pLoopFormats->nKey); 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir catch(const Exception&) 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir OSL_ENSURE(sal_False, "OLimitedFormats::ensureTableInitialized: adding the key to the formats collection failed!"); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir #endif 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir // next 207*cdf0e10cSrcweir ++pLoopFormats; 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir } 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir //--------------------------------------------------------------------- 215*cdf0e10cSrcweir void OLimitedFormats::clearTable(const sal_Int16 _nTableId) 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 218*cdf0e10cSrcweir const FormatEntry* pFormats = lcl_getFormatTable(_nTableId); 219*cdf0e10cSrcweir FormatEntry* pResetLoop = const_cast<FormatEntry*>(pFormats); 220*cdf0e10cSrcweir while (pResetLoop->pDescription) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir pResetLoop->nKey = -1; 223*cdf0e10cSrcweir ++pResetLoop; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir //--------------------------------------------------------------------- 228*cdf0e10cSrcweir void OLimitedFormats::setAggregateSet(const Reference< XFastPropertySet >& _rxAggregate, sal_Int32 _nOriginalPropertyHandle) 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir // changes (NULL -> not NULL) and (not NULL -> NULL) are allowed 231*cdf0e10cSrcweir OSL_ENSURE(!m_xAggregate.is() || !_rxAggregate.is(), "OLimitedFormats::setAggregateSet: already have an aggregate!"); 232*cdf0e10cSrcweir OSL_ENSURE(_rxAggregate.is() || m_xAggregate.is(), "OLimitedFormats::setAggregateSet: invalid new aggregate!"); 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir m_xAggregate = _rxAggregate; 235*cdf0e10cSrcweir m_nFormatEnumPropertyHandle = _nOriginalPropertyHandle; 236*cdf0e10cSrcweir #ifdef DBG_UTIL 237*cdf0e10cSrcweir if (m_xAggregate.is()) 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir try 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir catch(const Exception&) 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir OSL_ENSURE(sal_False, "OLimitedFormats::setAggregateSet: invalid handle!"); 246*cdf0e10cSrcweir } 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir #endif 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir //--------------------------------------------------------------------- 252*cdf0e10cSrcweir void OLimitedFormats::getFormatKeyPropertyValue( Any& _rValue ) const 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir _rValue.clear(); 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::getFormatKeyPropertyValue: not initialized!"); 257*cdf0e10cSrcweir if (m_xAggregate.is()) 258*cdf0e10cSrcweir { 259*cdf0e10cSrcweir // get the aggregate's enum property value 260*cdf0e10cSrcweir Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); 261*cdf0e10cSrcweir sal_Int32 nValue = -1; 262*cdf0e10cSrcweir ::cppu::enum2int(nValue, aEnumPropertyValue); 263*cdf0e10cSrcweir 264*cdf0e10cSrcweir // get the translation table 265*cdf0e10cSrcweir const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir // seek to the nValue'th entry 268*cdf0e10cSrcweir sal_Int32 nLookup = 0; 269*cdf0e10cSrcweir for ( ; 270*cdf0e10cSrcweir (NULL != pFormats->pDescription) && (nLookup < nValue); 271*cdf0e10cSrcweir ++pFormats, ++nLookup 272*cdf0e10cSrcweir ) 273*cdf0e10cSrcweir ; 274*cdf0e10cSrcweir OSL_ENSURE(NULL != pFormats->pDescription, "OLimitedFormats::getFormatKeyPropertyValue: did not find the value!"); 275*cdf0e10cSrcweir if (pFormats->pDescription) 276*cdf0e10cSrcweir _rValue <<= pFormats->nKey; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir // TODO: should use a standard format for the control type we're working for 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir //--------------------------------------------------------------------- 283*cdf0e10cSrcweir sal_Bool OLimitedFormats::convertFormatKeyPropertyValue(Any& _rConvertedValue, Any& _rOldValue, const Any& _rNewValue) 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::convertFormatKeyPropertyValue: not initialized!"); 286*cdf0e10cSrcweir 287*cdf0e10cSrcweir if (m_xAggregate.is()) 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir // the new format key to set 290*cdf0e10cSrcweir sal_Int32 nNewFormat = 0; 291*cdf0e10cSrcweir if (!(_rNewValue >>= nNewFormat)) 292*cdf0e10cSrcweir throw IllegalArgumentException(); 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // get the old (enum) value from the aggregate 295*cdf0e10cSrcweir Any aEnumPropertyValue = m_xAggregate->getFastPropertyValue(m_nFormatEnumPropertyHandle); 296*cdf0e10cSrcweir sal_Int32 nOldEnumValue = -1; 297*cdf0e10cSrcweir ::cppu::enum2int(nOldEnumValue, aEnumPropertyValue); 298*cdf0e10cSrcweir 299*cdf0e10cSrcweir // get the translation table 300*cdf0e10cSrcweir const FormatEntry* pFormats = lcl_getFormatTable(m_nTableId); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir _rOldValue.clear(); 303*cdf0e10cSrcweir _rConvertedValue.clear(); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir // look for the entry with the given format key 306*cdf0e10cSrcweir sal_Int32 nTablePosition = 0; 307*cdf0e10cSrcweir for ( ; 308*cdf0e10cSrcweir (NULL != pFormats->pDescription) && (nNewFormat != pFormats->nKey); 309*cdf0e10cSrcweir ++pFormats, ++nTablePosition 310*cdf0e10cSrcweir ) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir if (nTablePosition == nOldEnumValue) 313*cdf0e10cSrcweir _rOldValue <<= pFormats->nKey; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir sal_Bool bFoundIt = (NULL != pFormats->pDescription); 317*cdf0e10cSrcweir sal_Bool bModified = sal_False; 318*cdf0e10cSrcweir if (bFoundIt) 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir _rConvertedValue <<= (sal_Int16)nTablePosition; 321*cdf0e10cSrcweir bModified = nTablePosition != nOldEnumValue; 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir if (!_rOldValue.hasValue()) 325*cdf0e10cSrcweir { // did not reach the end of the table (means we found nNewFormat) 326*cdf0e10cSrcweir // -> go to the end to ensure that _rOldValue is set 327*cdf0e10cSrcweir while (pFormats->pDescription) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if (nTablePosition == nOldEnumValue) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir _rOldValue <<= pFormats->nKey; 332*cdf0e10cSrcweir break; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir ++pFormats; 336*cdf0e10cSrcweir ++nTablePosition; 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir OSL_ENSURE(_rOldValue.hasValue(), "OLimitedFormats::convertFormatKeyPropertyValue: did not find the old enum value in the table!"); 341*cdf0e10cSrcweir 342*cdf0e10cSrcweir if (!bFoundIt) 343*cdf0e10cSrcweir { // somebody gave us an format which we can't translate 344*cdf0e10cSrcweir ::rtl::OUString sMessage = ::rtl::OUString::createFromAscii("This control supports only a very limited number of formats."); 345*cdf0e10cSrcweir throw IllegalArgumentException(sMessage, NULL, 2); 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir return bModified; 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir return sal_False; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir //--------------------------------------------------------------------- 355*cdf0e10cSrcweir void OLimitedFormats::setFormatKeyPropertyValue( const Any& _rNewValue ) 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir OSL_ENSURE(m_xAggregate.is() && (-1 != m_nFormatEnumPropertyHandle), "OLimitedFormats::setFormatKeyPropertyValue: not initialized!"); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir if (m_xAggregate.is()) 360*cdf0e10cSrcweir { // this is to be called after convertFormatKeyPropertyValue, where 361*cdf0e10cSrcweir // we translated the format key into a enum value. 362*cdf0e10cSrcweir // So now we can simply forward this enum value to our aggreate 363*cdf0e10cSrcweir m_xAggregate->setFastPropertyValue(m_nFormatEnumPropertyHandle, _rNewValue); 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir //--------------------------------------------------------------------- 368*cdf0e10cSrcweir void OLimitedFormats::acquireSupplier(const Reference< XMultiServiceFactory >& _rxORB) 369*cdf0e10cSrcweir { 370*cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 371*cdf0e10cSrcweir if ((1 == ++s_nInstanceCount) && _rxORB.is()) 372*cdf0e10cSrcweir { // create the standard formatter 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir Sequence< Any > aInit(1); 375*cdf0e10cSrcweir aInit[0] <<= getLocale(ltEnglishUS); 376*cdf0e10cSrcweir 377*cdf0e10cSrcweir Reference< XInterface > xSupplier = _rxORB->createInstanceWithArguments(FRM_NUMBER_FORMATS_SUPPLIER, aInit); 378*cdf0e10cSrcweir OSL_ENSURE(xSupplier.is(), "OLimitedFormats::OLimitedFormats: could not create a formats supplier!"); 379*cdf0e10cSrcweir 380*cdf0e10cSrcweir s_xStandardFormats = Reference< XNumberFormatsSupplier >(xSupplier, UNO_QUERY); 381*cdf0e10cSrcweir OSL_ENSURE(s_xStandardFormats.is() || !xSupplier.is(), "OLimitedFormats::OLimitedFormats: missing an interface!"); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir //--------------------------------------------------------------------- 386*cdf0e10cSrcweir void OLimitedFormats::releaseSupplier() 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir ::osl::MutexGuard aGuard(s_aMutex); 389*cdf0e10cSrcweir if (0 == --s_nInstanceCount) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir ::comphelper::disposeComponent(s_xStandardFormats); 392*cdf0e10cSrcweir s_xStandardFormats = NULL; 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir clearTable(FormComponentType::TIMEFIELD); 395*cdf0e10cSrcweir clearTable(FormComponentType::DATEFIELD); 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir } 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir //......................................................................... 400*cdf0e10cSrcweir } // namespace frm 401*cdf0e10cSrcweir //......................................................................... 402*cdf0e10cSrcweir 403