1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <comphelper/servicehelper.hxx>
23 #include <svl/numuno.hxx>
24 #include "numfmuno.hxx"
25 #include <svl/zforlist.hxx>
27 using namespace com::sun::star
;
30 class SvNumFmtSuppl_Impl
33 SvNumberFormatter
* pFormatter
;
34 mutable ::comphelper::SharedMutex aMutex
;
36 SvNumFmtSuppl_Impl(SvNumberFormatter
* p
) :
41 // Default ctor for getReflection
42 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj()
44 pImpl
= new SvNumFmtSuppl_Impl(NULL
);
47 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter
* pForm
)
49 pImpl
= new SvNumFmtSuppl_Impl(pForm
);
52 SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj()
57 ::comphelper::SharedMutex
& SvNumberFormatsSupplierObj::getSharedMutex() const
62 SvNumberFormatter
* SvNumberFormatsSupplierObj::GetNumberFormatter() const
64 return pImpl
->pFormatter
;
67 void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter
* pNew
)
69 // The old Numberformatter has been retired, do not access it anymore!
70 pImpl
->pFormatter
= pNew
;
73 void SvNumberFormatsSupplierObj::NumberFormatDeleted(sal_uInt32
)
75 // Base implementation; does nothing
78 void SvNumberFormatsSupplierObj::SettingsChanged()
80 // Base implementation; does nothing
83 // XNumberFormatsSupplier
85 uno::Reference
<beans::XPropertySet
> SAL_CALL
SvNumberFormatsSupplierObj::getNumberFormatSettings()
86 throw(uno::RuntimeException
)
88 ::osl::MutexGuard
aGuard( pImpl
->aMutex
);
90 return new SvNumberFormatSettingsObj( *this, pImpl
->aMutex
);
93 uno::Reference
<util::XNumberFormats
> SAL_CALL
SvNumberFormatsSupplierObj::getNumberFormats()
94 throw(uno::RuntimeException
)
96 ::osl::MutexGuard
aGuard( pImpl
->aMutex
);
98 return new SvNumberFormatsObj( *this, pImpl
->aMutex
);
103 sal_Int64 SAL_CALL
SvNumberFormatsSupplierObj::getSomething(
104 const uno::Sequence
<sal_Int8
>& rId
) throw(uno::RuntimeException
)
106 if ( rId
.getLength() == 16 &&
107 0 == memcmp( getUnoTunnelId().getConstArray(),
108 rId
.getConstArray(), 16 ) )
110 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
117 class theSvNumberFormatsSupplierObjUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSvNumberFormatsSupplierObjUnoTunnelId
> {};
121 const uno::Sequence
<sal_Int8
>& SvNumberFormatsSupplierObj::getUnoTunnelId()
123 return theSvNumberFormatsSupplierObjUnoTunnelId::get().getSeq();
127 SvNumberFormatsSupplierObj
* SvNumberFormatsSupplierObj::getImplementation(
128 const uno::Reference
<util::XNumberFormatsSupplier
> xObj
)
130 SvNumberFormatsSupplierObj
* pRet
= NULL
;
131 uno::Reference
<lang::XUnoTunnel
> xUT( xObj
, uno::UNO_QUERY
);
133 pRet
= reinterpret_cast<SvNumberFormatsSupplierObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething( getUnoTunnelId() )));
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */