LibreOffice Module oox (master) 1
propertymap.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_OOX_HELPER_PROPERTYMAP_HXX
21#define INCLUDED_OOX_HELPER_PROPERTYMAP_HXX
22
23#include <map>
24#include <utility>
25#include <vector>
26
27#include <com/sun/star/uno/Any.hxx>
28#include <com/sun/star/uno/Reference.hxx>
29#include <com/sun/star/uno/Sequence.hxx>
30#include <oox/dllapi.h>
31#include <rtl/ustring.hxx>
32#include <sal/types.h>
33
34namespace com::sun::star::beans {
35 struct PropertyValue;
36 class XPropertySet;
37}
38
39namespace oox {
40
41
42typedef ::std::map< OUString, css::uno::Any > PropertyNameMap;
43
52{
53public:
55
57 static const OUString& getPropertyName( sal_Int32 nPropId );
58
60 static sal_Int32 getPropertyId( std::u16string_view sPropName );
61
63 bool hasProperty( sal_Int32 nPropId ) const;
64
67 bool setAnyProperty( sal_Int32 nPropId, const css::uno::Any& rValue );
68
71 template< typename Type >
72 bool setProperty( sal_Int32 nPropId, Type&& rValue )
73 {
74 if( nPropId < 0 )
75 return false;
76
77 maProperties[ nPropId ] <<= std::forward<Type>(rValue);
78 return true;
79 }
80
82 bool setProperty( sal_Int32, const css::uno::Any& ) = delete;
83
84 css::uno::Any getProperty( sal_Int32 nPropId );
85
86 void erase( sal_Int32 nPropId );
87
88 bool empty() const;
89
91 void assignUsed( const PropertyMap& rPropMap );
92
94 void assignAll( const PropertyMap& rPropMap );
95
97 css::uno::Sequence< css::beans::PropertyValue >
98 makePropertyValueSequence() const;
99
101 void fillSequences(
102 css::uno::Sequence< OUString >& rNames,
103 css::uno::Sequence< css::uno::Any >& rValues ) const;
104
105 void fillPropertyNameMap(PropertyNameMap& rMap) const;
106
108 css::uno::Reference< css::beans::XPropertySet >
109 makePropertySet() const;
110
111#if OSL_DEBUG_LEVEL > 0
112#ifdef DBG_UTIL
113 static void dump( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
114#endif
115 static void dumpCode( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet);
116 static void dumpData( const css::uno::Reference<css::beans::XPropertySet>& rXPropSet);
117#endif
118private:
119 const std::vector<OUString>* mpPropNames;
120 std::map< sal_Int32, css::uno::Any > maProperties;
121};
122
123
124} // namespace oox
125
126#endif
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
A helper that maps property identifiers to property values.
Definition: propertymap.hxx:52
const std::vector< OUString > * mpPropNames
std::map< sal_Int32, css::uno::Any > maProperties
bool setProperty(sal_Int32, const css::uno::Any &)=delete
setAnyProperty should be used
bool setProperty(sal_Int32 nPropId, Type &&rValue)
Sets the specified property to the passed value.
Definition: propertymap.hxx:72
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
SvGenericNameContainerMapImpl maProperties
VCL_DLLPUBLIC void dump(const SkBitmap &bitmap, const char *file)
class SAL_NO_VTABLE XPropertySet
bool hasProperty(const OUString &_rName, const Reference< XPropertySet > &_rxSet)
Type
::std::map< OUString, css::uno::Any > PropertyNameMap
Definition: propertymap.hxx:42
OUString getPropertyName(sal_Int32 nPropertyType)
SVX_DLLPUBLIC OUString getProperty(css::uno::Reference< css::beans::XPropertyContainer > const &rxPropertyContainer, OUString const &rName)