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 .
20 #include <com/sun/star/lang/XTypeProvider.hpp>
21 #include <cppuhelper/weakref.hxx>
22 #include <xmloff/SinglePropertySetInfoCache.hxx>
24 using namespace ::com::sun::star::uno
;
25 using ::com::sun::star::lang::XTypeProvider
;
26 using ::com::sun::star::beans::XPropertySet
;
27 using ::com::sun::star::beans::XPropertySetInfo
;
29 sal_Bool
SinglePropertySetInfoCache::hasProperty(
30 const Reference
< XPropertySet
>& rPropSet
,
31 Reference
< XPropertySetInfo
>& rPropSetInfo
)
33 if( !rPropSetInfo
.is() )
34 rPropSetInfo
= rPropSet
->getPropertySetInfo();
35 sal_Bool bRet
= sal_False
, bValid
= sal_False
;
36 Reference
< XTypeProvider
> xTypeProv( rPropSet
, UNO_QUERY
);
37 Sequence
< sal_Int8
> aImplId
;
40 aImplId
= xTypeProv
->getImplementationId();
41 if( aImplId
.getLength() == 16 )
43 // The key must not be created outside this block, because it
44 // keeps a reference to the property set info.
45 PropertySetInfoKey
aKey( rPropSetInfo
, aImplId
);
46 iterator aIter
= find( aKey
);
49 bRet
= (*aIter
).second
;
56 bRet
= rPropSetInfo
->hasPropertyByName( sName
);
57 if( xTypeProv
.is() && aImplId
.getLength() == 16 )
59 // Check whether the property set info is destroyed if it is
60 // assigned to a weak reference only. If it is destroyed, then
61 // every instance of getPropertySetInfo returns a new object.
62 // Such property set infos must not be cached.
63 WeakReference
< XPropertySetInfo
> xWeakInfo( rPropSetInfo
);
65 rPropSetInfo
= xWeakInfo
;
66 if( rPropSetInfo
.is() )
68 PropertySetInfoKey
aKey( rPropSetInfo
, aImplId
);
69 value_type
aValue( aKey
, bRet
);
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */