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 explicit SvNumFmtSuppl_Impl(SvNumberFormatter
* p
) :
41 // Default ctor for getReflection
42 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj()
43 : pImpl( new SvNumFmtSuppl_Impl(nullptr) )
47 SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter
* pForm
)
48 : pImpl( new SvNumFmtSuppl_Impl(pForm
) )
52 SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj()
56 ::comphelper::SharedMutex
& SvNumberFormatsSupplierObj::getSharedMutex() const
61 SvNumberFormatter
* SvNumberFormatsSupplierObj::GetNumberFormatter() const
63 return pImpl
->pFormatter
;
66 void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter
* pNew
)
68 // The old Numberformatter has been retired, do not access it anymore!
69 pImpl
->pFormatter
= pNew
;
72 // XNumberFormatsSupplier
74 uno::Reference
<beans::XPropertySet
> SAL_CALL
SvNumberFormatsSupplierObj::getNumberFormatSettings()
76 ::osl::MutexGuard
aGuard( pImpl
->aMutex
);
78 return new SvNumberFormatSettingsObj( *this, pImpl
->aMutex
);
81 uno::Reference
<util::XNumberFormats
> SAL_CALL
SvNumberFormatsSupplierObj::getNumberFormats()
83 ::osl::MutexGuard
aGuard( pImpl
->aMutex
);
85 return new SvNumberFormatsObj( *this, pImpl
->aMutex
);
90 sal_Int64 SAL_CALL
SvNumberFormatsSupplierObj::getSomething(
91 const uno::Sequence
<sal_Int8
>& rId
)
93 if ( rId
.getLength() == 16 &&
94 0 == memcmp( getUnoTunnelId().getConstArray(),
95 rId
.getConstArray(), 16 ) )
97 return sal::static_int_cast
<sal_Int64
>(reinterpret_cast<sal_IntPtr
>(this));
104 class theSvNumberFormatsSupplierObjUnoTunnelId
: public rtl::Static
< UnoTunnelIdInit
, theSvNumberFormatsSupplierObjUnoTunnelId
> {};
108 const uno::Sequence
<sal_Int8
>& SvNumberFormatsSupplierObj::getUnoTunnelId()
110 return theSvNumberFormatsSupplierObjUnoTunnelId::get().getSeq();
114 SvNumberFormatsSupplierObj
* SvNumberFormatsSupplierObj::getImplementation(
115 const uno::Reference
<util::XNumberFormatsSupplier
>& rObj
)
117 SvNumberFormatsSupplierObj
* pRet
= nullptr;
118 uno::Reference
<lang::XUnoTunnel
> xUT(rObj
, uno::UNO_QUERY
);
120 pRet
= reinterpret_cast<SvNumberFormatsSupplierObj
*>(sal::static_int_cast
<sal_IntPtr
>(xUT
->getSomething( getUnoTunnelId() )));
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */