1*40df464eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*40df464eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*40df464eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*40df464eSAndrew Rist * distributed with this work for additional information 6*40df464eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*40df464eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*40df464eSAndrew Rist * "License"); you may not use this file except in compliance 9*40df464eSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*40df464eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*40df464eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*40df464eSAndrew Rist * software distributed under the License is distributed on an 15*40df464eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*40df464eSAndrew Rist * KIND, either express or implied. See the License for the 17*40df464eSAndrew Rist * specific language governing permissions and limitations 18*40df464eSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*40df464eSAndrew Rist *************************************************************/ 21*40df464eSAndrew Rist 22*40df464eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svl.hxx" 26cdf0e10cSrcweir #ifndef GCC 27cdf0e10cSrcweir #endif 28cdf0e10cSrcweir 29cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <tools/color.hxx> 32cdf0e10cSrcweir #include <tools/debug.hxx> 33cdf0e10cSrcweir #include <vos/mutex.hxx> 34cdf0e10cSrcweir #include <osl/mutex.hxx> 35cdf0e10cSrcweir #include <rtl/uuid.h> 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include <svl/numuno.hxx> 38cdf0e10cSrcweir #include "numfmuno.hxx" 39cdf0e10cSrcweir #include <svl/zforlist.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir using namespace com::sun::star; 42cdf0e10cSrcweir 43cdf0e10cSrcweir //------------------------------------------------------------------------ 44cdf0e10cSrcweir 45cdf0e10cSrcweir class SvNumFmtSuppl_Impl 46cdf0e10cSrcweir { 47cdf0e10cSrcweir public: 48cdf0e10cSrcweir SvNumberFormatter* pFormatter; 49cdf0e10cSrcweir mutable ::comphelper::SharedMutex aMutex; 50cdf0e10cSrcweir 51cdf0e10cSrcweir SvNumFmtSuppl_Impl(SvNumberFormatter* p) : 52cdf0e10cSrcweir pFormatter(p) {} 53cdf0e10cSrcweir }; 54cdf0e10cSrcweir 55cdf0e10cSrcweir //------------------------------------------------------------------------ 56cdf0e10cSrcweir 57cdf0e10cSrcweir // Default-ctor fuer getReflection 58cdf0e10cSrcweir SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir pImpl = new SvNumFmtSuppl_Impl(NULL); 61cdf0e10cSrcweir } 62cdf0e10cSrcweir 63cdf0e10cSrcweir SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter* pForm) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir pImpl = new SvNumFmtSuppl_Impl(pForm); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj() 69cdf0e10cSrcweir { 70cdf0e10cSrcweir delete pImpl; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir ::comphelper::SharedMutex& SvNumberFormatsSupplierObj::getSharedMutex() const 74cdf0e10cSrcweir { 75cdf0e10cSrcweir return pImpl->aMutex; 76cdf0e10cSrcweir } 77cdf0e10cSrcweir 78cdf0e10cSrcweir SvNumberFormatter* SvNumberFormatsSupplierObj::GetNumberFormatter() const 79cdf0e10cSrcweir { 80cdf0e10cSrcweir return pImpl->pFormatter; 81cdf0e10cSrcweir } 82cdf0e10cSrcweir 83cdf0e10cSrcweir void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter* pNew) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir // der alte Numberformatter ist ungueltig geworden, nicht mehr darauf zugreifen! 86cdf0e10cSrcweir pImpl->pFormatter = pNew; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir void SvNumberFormatsSupplierObj::NumberFormatDeleted(sal_uInt32) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir // Basis-Implementierung tut nix... 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir void SvNumberFormatsSupplierObj::SettingsChanged() 95cdf0e10cSrcweir { 96cdf0e10cSrcweir // Basis-Implementierung tut nix... 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir // XNumberFormatsSupplier 100cdf0e10cSrcweir 101cdf0e10cSrcweir uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormatSettings() 102cdf0e10cSrcweir throw(uno::RuntimeException) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir ::osl::MutexGuard aGuard( pImpl->aMutex ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir return new SvNumberFormatSettingsObj( *this, pImpl->aMutex ); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir uno::Reference<util::XNumberFormats> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormats() 110cdf0e10cSrcweir throw(uno::RuntimeException) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir ::osl::MutexGuard aGuard( pImpl->aMutex ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir return new SvNumberFormatsObj( *this, pImpl->aMutex ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir // XUnoTunnel 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_Int64 SAL_CALL SvNumberFormatsSupplierObj::getSomething( 120cdf0e10cSrcweir const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir if ( rId.getLength() == 16 && 123cdf0e10cSrcweir 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 124cdf0e10cSrcweir rId.getConstArray(), 16 ) ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir return 0; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir // static 132cdf0e10cSrcweir const uno::Sequence<sal_Int8>& SvNumberFormatsSupplierObj::getUnoTunnelId() 133cdf0e10cSrcweir { 134cdf0e10cSrcweir static uno::Sequence<sal_Int8> * pSeq = 0; 135cdf0e10cSrcweir if( !pSeq ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); 138cdf0e10cSrcweir if( !pSeq ) 139cdf0e10cSrcweir { 140cdf0e10cSrcweir static uno::Sequence< sal_Int8 > aSeq( 16 ); 141cdf0e10cSrcweir rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True ); 142cdf0e10cSrcweir pSeq = &aSeq; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir } 145cdf0e10cSrcweir return *pSeq; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir // static 149cdf0e10cSrcweir SvNumberFormatsSupplierObj* SvNumberFormatsSupplierObj::getImplementation( 150cdf0e10cSrcweir const uno::Reference<util::XNumberFormatsSupplier> xObj ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir SvNumberFormatsSupplierObj* pRet = NULL; 153cdf0e10cSrcweir uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); 154cdf0e10cSrcweir if (xUT.is()) 155cdf0e10cSrcweir pRet = reinterpret_cast<SvNumberFormatsSupplierObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( getUnoTunnelId() ))); 156cdf0e10cSrcweir return pRet; 157cdf0e10cSrcweir } 158cdf0e10cSrcweir 159cdf0e10cSrcweir 160cdf0e10cSrcweir //------------------------------------------------------------------------ 161cdf0e10cSrcweir 162cdf0e10cSrcweir 163cdf0e10cSrcweir 164