merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / numbers / numuno.cxx
blob417dbe78f22d52c1230819a860a3cecb60b327bc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: numuno.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #ifndef GCC
34 #endif
36 #define _ZFORLIST_DECLARE_TABLE
38 #include <vcl/svapp.hxx>
39 #include <tools/color.hxx>
40 #include <tools/debug.hxx>
41 #include <vos/mutex.hxx>
42 #include <osl/mutex.hxx>
43 #include <rtl/uuid.h>
45 #include "numuno.hxx"
46 #include "numfmuno.hxx"
47 #include <svtools/zforlist.hxx>
49 using namespace com::sun::star;
51 //------------------------------------------------------------------------
53 class SvNumFmtSuppl_Impl
55 public:
56 SvNumberFormatter* pFormatter;
57 mutable ::comphelper::SharedMutex aMutex;
59 SvNumFmtSuppl_Impl(SvNumberFormatter* p) :
60 pFormatter(p) {}
63 //------------------------------------------------------------------------
65 // Default-ctor fuer getReflection
66 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj()
68 pImpl = new SvNumFmtSuppl_Impl(NULL);
71 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter* pForm)
73 pImpl = new SvNumFmtSuppl_Impl(pForm);
76 SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj()
78 delete pImpl;
81 ::comphelper::SharedMutex& SvNumberFormatsSupplierObj::getSharedMutex() const
83 return pImpl->aMutex;
86 SvNumberFormatter* SvNumberFormatsSupplierObj::GetNumberFormatter() const
88 return pImpl->pFormatter;
91 void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter* pNew)
93 // der alte Numberformatter ist ungueltig geworden, nicht mehr darauf zugreifen!
94 pImpl->pFormatter = pNew;
97 void SvNumberFormatsSupplierObj::NumberFormatDeleted(sal_uInt32)
99 // Basis-Implementierung tut nix...
102 void SvNumberFormatsSupplierObj::SettingsChanged()
104 // Basis-Implementierung tut nix...
107 // XNumberFormatsSupplier
109 uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormatSettings()
110 throw(uno::RuntimeException)
112 ::osl::MutexGuard aGuard( pImpl->aMutex );
114 return new SvNumberFormatSettingsObj( *this, pImpl->aMutex );
117 uno::Reference<util::XNumberFormats> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormats()
118 throw(uno::RuntimeException)
120 ::osl::MutexGuard aGuard( pImpl->aMutex );
122 return new SvNumberFormatsObj( *this, pImpl->aMutex );
125 // XUnoTunnel
127 sal_Int64 SAL_CALL SvNumberFormatsSupplierObj::getSomething(
128 const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
130 if ( rId.getLength() == 16 &&
131 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
132 rId.getConstArray(), 16 ) )
134 return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
136 return 0;
139 // static
140 const uno::Sequence<sal_Int8>& SvNumberFormatsSupplierObj::getUnoTunnelId()
142 static uno::Sequence<sal_Int8> * pSeq = 0;
143 if( !pSeq )
145 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
146 if( !pSeq )
148 static uno::Sequence< sal_Int8 > aSeq( 16 );
149 rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
150 pSeq = &aSeq;
153 return *pSeq;
156 // static
157 SvNumberFormatsSupplierObj* SvNumberFormatsSupplierObj::getImplementation(
158 const uno::Reference<util::XNumberFormatsSupplier> xObj )
160 SvNumberFormatsSupplierObj* pRet = NULL;
161 uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
162 if (xUT.is())
163 pRet = reinterpret_cast<SvNumberFormatsSupplierObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( getUnoTunnelId() )));
164 return pRet;
168 //------------------------------------------------------------------------