Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : :
21 : : #include <comphelper/servicehelper.hxx>
22 : :
23 : : #include <svl/numuno.hxx>
24 : : #include "numfmuno.hxx"
25 : : #include <svl/zforlist.hxx>
26 : :
27 : : using namespace com::sun::star;
28 : :
29 : : //------------------------------------------------------------------------
30 : :
31 : 1448 : class SvNumFmtSuppl_Impl
32 : : {
33 : : public:
34 : : SvNumberFormatter* pFormatter;
35 : : mutable ::comphelper::SharedMutex aMutex;
36 : :
37 : 1762 : SvNumFmtSuppl_Impl(SvNumberFormatter* p) :
38 : 1762 : pFormatter(p) {}
39 : : };
40 : :
41 : : //------------------------------------------------------------------------
42 : :
43 : : // Default-ctor fuer getReflection
44 : 227 : SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj()
45 : : {
46 [ + - ][ + - ]: 227 : pImpl = new SvNumFmtSuppl_Impl(NULL);
47 : 227 : }
48 : :
49 : 1535 : SvNumberFormatsSupplierObj::SvNumberFormatsSupplierObj(SvNumberFormatter* pForm)
50 : : {
51 [ + - ][ + - ]: 1535 : pImpl = new SvNumFmtSuppl_Impl(pForm);
52 : 1535 : }
53 : :
54 : 1448 : SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj()
55 : : {
56 [ + - ][ + - ]: 1448 : delete pImpl;
57 [ - + ]: 2669 : }
58 : :
59 : 679 : ::comphelper::SharedMutex& SvNumberFormatsSupplierObj::getSharedMutex() const
60 : : {
61 : 679 : return pImpl->aMutex;
62 : : }
63 : :
64 : 22857 : SvNumberFormatter* SvNumberFormatsSupplierObj::GetNumberFormatter() const
65 : : {
66 : 22857 : return pImpl->pFormatter;
67 : : }
68 : :
69 : 3881 : void SvNumberFormatsSupplierObj::SetNumberFormatter(SvNumberFormatter* pNew)
70 : : {
71 : : // der alte Numberformatter ist ungueltig geworden, nicht mehr darauf zugreifen!
72 : 3881 : pImpl->pFormatter = pNew;
73 : 3881 : }
74 : :
75 : 0 : void SvNumberFormatsSupplierObj::NumberFormatDeleted(sal_uInt32)
76 : : {
77 : : // Basis-Implementierung tut nix...
78 : 0 : }
79 : :
80 : 24 : void SvNumberFormatsSupplierObj::SettingsChanged()
81 : : {
82 : : // Basis-Implementierung tut nix...
83 : 24 : }
84 : :
85 : : // XNumberFormatsSupplier
86 : :
87 : 122 : uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormatSettings()
88 : : throw(uno::RuntimeException)
89 : : {
90 [ + - ][ + - ]: 122 : ::osl::MutexGuard aGuard( pImpl->aMutex );
91 : :
92 [ + - ][ + - ]: 122 : return new SvNumberFormatSettingsObj( *this, pImpl->aMutex );
[ + - ][ + - ]
93 : : }
94 : :
95 : 6503 : uno::Reference<util::XNumberFormats> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormats()
96 : : throw(uno::RuntimeException)
97 : : {
98 [ + - ][ + - ]: 6503 : ::osl::MutexGuard aGuard( pImpl->aMutex );
99 : :
100 [ + - ][ + - ]: 6503 : return new SvNumberFormatsObj( *this, pImpl->aMutex );
[ + - ][ + - ]
101 : : }
102 : :
103 : : // XUnoTunnel
104 : :
105 : 14861 : sal_Int64 SAL_CALL SvNumberFormatsSupplierObj::getSomething(
106 : : const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
107 : : {
108 [ + - + - ]: 29722 : if ( rId.getLength() == 16 &&
[ + - ]
109 : 14861 : 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
110 : 29722 : rId.getConstArray(), 16 ) )
111 : : {
112 : 14861 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
113 : : }
114 : 14861 : return 0;
115 : : }
116 : :
117 : : namespace
118 : : {
119 : : class theSvNumberFormatsSupplierObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSvNumberFormatsSupplierObjUnoTunnelId > {};
120 : : }
121 : :
122 : : // static
123 : 39642 : const uno::Sequence<sal_Int8>& SvNumberFormatsSupplierObj::getUnoTunnelId()
124 : : {
125 : 39642 : return theSvNumberFormatsSupplierObjUnoTunnelId::get().getSeq();
126 : : }
127 : :
128 : : // static
129 : 9942 : SvNumberFormatsSupplierObj* SvNumberFormatsSupplierObj::getImplementation(
130 : : const uno::Reference<util::XNumberFormatsSupplier> xObj )
131 : : {
132 : 9942 : SvNumberFormatsSupplierObj* pRet = NULL;
133 [ + - ]: 9942 : uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
134 [ + - ]: 9942 : if (xUT.is())
135 [ + - ][ + - ]: 9942 : pRet = reinterpret_cast<SvNumberFormatsSupplierObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( getUnoTunnelId() )));
[ + - ]
136 : 9942 : return pRet;
137 : : }
138 : :
139 : :
140 : : //------------------------------------------------------------------------
141 : :
142 : :
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|