LibreOffice Module oox (master) 1
attributelist.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_ATTRIBUTELIST_HXX
21#define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
22
23#include <sal/config.h>
24
25#include <string_view>
26#include <vector>
27
28#include <com/sun/star/uno/Reference.hxx>
29#include <com/sun/star/util/DateTime.hpp>
30#include <oox/helper/helper.hxx>
31#include <oox/dllapi.h>
32#include <rtl/ustring.hxx>
33#include <sal/types.h>
35
36namespace com::sun::star {
37 namespace xml::sax { class XFastAttributeList; }
38}
39
40namespace sax_fastparser {
41 class FastAttributeList;
42};
43
44namespace oox {
45
46 /* Get the color tokens from their string representatives. */
47 sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName);
48
53{
54public:
56 static sal_Int32 decodeToken( std::u16string_view rValue );
57
60 static OUString decodeXString( const OUString& rValue );
61
63 static sal_Int32 decodeInteger( std::u16string_view rValue );
64
66 static sal_uInt32 decodeUnsigned( std::u16string_view rValue );
67
69 static sal_Int64 decodeHyper( std::u16string_view rValue );
70
72 static sal_Int32 decodeIntegerHex( std::u16string_view rValue );
73};
74
75
83{
84public:
85 explicit AttributeList(
86 const css::uno::Reference< css::xml::sax::XFastAttributeList >& rxAttribs );
87
89 const css::uno::Reference< css::xml::sax::XFastAttributeList >&
90 getFastAttributeList() const { return mxAttribs; }
91
93 bool hasAttribute( sal_Int32 nAttrToken ) const;
94
95 // optional return values -------------------------------------------------
96
98 std::optional< sal_Int32 > getToken( sal_Int32 nAttrToken ) const;
99
101 oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const;
102
104 std::optional< OUString > getString( sal_Int32 nAttrToken ) const;
105
107 OUString getStringDefaulted( sal_Int32 nAttrToken ) const;
108
111 std::optional< OUString > getXString( sal_Int32 nAttrToken ) const;
112
114 std::optional< double > getDouble( sal_Int32 nAttrToken ) const;
115
117 std::optional< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const;
118
120 std::optional< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const;
121
123 std::optional< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const;
124
126 std::optional< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const;
127
129 std::optional< bool > getBool( sal_Int32 nAttrToken ) const;
130
132 std::optional< css::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const;
133
134 // defaulted return values ------------------------------------------------
135
138 sal_Int32 getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
139
142 OUString getString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
143
146 OUString getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
147
148 std::string_view getView( sal_Int32 nAttrToken ) const;
149
150
153 double getDouble( sal_Int32 nAttrToken, double fDefault ) const;
154
157 sal_Int32 getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
158
161 sal_uInt32 getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
162
165 sal_Int64 getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
166
169 sal_Int32 getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
170
171 sal_uInt32 getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
172
175 bool getBool( sal_Int32 nAttrToken, bool bDefault ) const;
176
179 css::util::DateTime getDateTime( sal_Int32 nAttrToken, const css::util::DateTime& rDefault ) const;
180
181 std::vector<sal_Int32> getTokenList(sal_Int32 nAttrToken) const;
182
183private:
184 css::uno::Reference< css::xml::sax::XFastAttributeList >
187 sax_fastparser::FastAttributeList *getAttribList() const;
188};
189
190
191} // namespace oox
192
193#endif
194
195/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Static helpers for conversion of strings to attribute values of various different data types.
Provides access to attribute values of an element.
css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttribs
sax_fastparser::FastAttributeList * mpAttribList
AttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
css::util::DateTime getDateTime(sal_Int32 nAttrToken, const css::util::DateTime &rDefault) const
Returns the date/time value of the specified attribute, or the default value if the attribute is miss...
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
sal_Int32 getToken(const Context &rContext, const char *pToken)
double getDouble(const Any &_rAny)
OUString getString(const Any &_rAny)
SwView * getView(const uno::Reference< frame::XModel > &xModel)
sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName)