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>
34 #include <oox/drawingml/color.hxx>
35 
36 namespace com::sun::star {
37  namespace xml::sax { class XFastAttributeList; }
38 }
39 
40 namespace sax_fastparser {
41  class FastAttributeList;
42 };
43 
44 namespace oox {
45 
46  /* Get the color tokens from their string representatives. */
47  sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName);
48 
53 {
54 public:
56  static sal_Int32 decodeToken( std::u16string_view rValue );
57 
60  static OUString decodeXString( const OUString& rValue );
61 
63  static sal_Int32 decodeInteger( const OUString& rValue );
64 
66  static sal_uInt32 decodeUnsigned( const OUString& rValue );
67 
69  static sal_Int64 decodeHyper( const OUString& rValue );
70 
72  static sal_Int32 decodeIntegerHex( const OUString& rValue );
73 };
74 
75 
83 {
84 public:
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  OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const;
99 
101  oox::drawingml::Color getHighlightColor(sal_Int32 nAttrToken) const;
102 
104  OptValue< OUString > getString( sal_Int32 nAttrToken ) const;
105 
108  OptValue< OUString > getXString( sal_Int32 nAttrToken ) const;
109 
111  OptValue< double > getDouble( sal_Int32 nAttrToken ) const;
112 
114  OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const;
115 
117  OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const;
118 
120  OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const;
121 
123  OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const;
124 
126  OptValue< bool > getBool( sal_Int32 nAttrToken ) const;
127 
129  OptValue< css::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const;
130 
131  // defaulted return values ------------------------------------------------
132 
135  sal_Int32 getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
136 
139  OUString getString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
140 
143  OUString getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
144 
145  const char* getChar( sal_Int32 nAttrToken ) const;
146 
147 
150  double getDouble( sal_Int32 nAttrToken, double fDefault ) const;
151 
154  sal_Int32 getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
155 
158  sal_uInt32 getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
159 
162  sal_Int64 getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
163 
166  sal_Int32 getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
167 
168  sal_uInt32 getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
169 
172  bool getBool( sal_Int32 nAttrToken, bool bDefault ) const;
173 
176  css::util::DateTime getDateTime( sal_Int32 nAttrToken, const css::util::DateTime& rDefault ) const;
177 
178  std::vector<sal_Int32> getTokenList(sal_Int32 nAttrToken) const;
179 
180 private:
181  css::uno::Reference< css::xml::sax::XFastAttributeList >
184  sax_fastparser::FastAttributeList *getAttribList() const;
185 };
186 
187 
188 } // namespace oox
189 
190 #endif
191 
192 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::xml::sax::XFastAttributeList > mxAttribs
css::uno::Any const & rValue
sal_Int32 getHighlightColorTokenFromString(std::u16string_view sColorName)
sax_fastparser::FastAttributeList * mpAttribList
Provides access to attribute values of an element.
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object.
double getDouble(const Any &_rAny)
sal_Int32 getToken(const Context &rContext, const char *pToken)
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
OUString getString(const Any &_rAny)
Static helpers for conversion of strings to attribute values of various different data types...