LCOV - code coverage report
Current view: top level - include/oox/helper - attributelist.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 2 0.0 %
Date: 2014-04-14 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          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             : #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
      21             : #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
      22             : 
      23             : #include <com/sun/star/util/DateTime.hpp>
      24             : #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
      25             : #include <oox/helper/helper.hxx>
      26             : #include <oox/token/namespaces.hxx>
      27             : #include <oox/token/tokens.hxx>
      28             : #include <oox/dllapi.h>
      29             : 
      30             : namespace sax_fastparser {
      31             :     class FastAttributeList;
      32             : };
      33             : 
      34             : namespace oox {
      35             : 
      36             : 
      37             : 
      38             : /** Static helpers for conversion of strings to attribute values of various
      39             :     different data types.
      40             :  */
      41             : class OOX_DLLPUBLIC AttributeConversion
      42             : {
      43             : public:
      44             :     /** Returns the XML token identifier from the passed string. */
      45             :     static sal_Int32    decodeToken( const OUString& rValue );
      46             : 
      47             :     /** Returns the decoded string value. All characters in the format
      48             :         '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
      49             :     static OUString decodeXString( const OUString& rValue );
      50             : 
      51             :     /** Returns the 32-bit signed integer value from the passed string (decimal). */
      52             :     static sal_Int32    decodeInteger( const OUString& rValue );
      53             : 
      54             :     /** Returns the 32-bit unsigned integer value from the passed string (decimal). */
      55             :     static sal_uInt32   decodeUnsigned( const OUString& rValue );
      56             : 
      57             :     /** Returns the 64-bit signed integer value from the passed string (decimal). */
      58             :     static sal_Int64    decodeHyper( const OUString& rValue );
      59             : 
      60             :     /** Returns the 32-bit signed integer value from the passed string (hexadecimal). */
      61             :     static sal_Int32    decodeIntegerHex( const OUString& rValue );
      62             : };
      63             : 
      64             : 
      65             : 
      66             : /** Provides access to attribute values of an element.
      67             : 
      68             :     Wraps a com.sun.star.xml.sax.XFastAttributeList object. Provides
      69             :     convenience functions that convert the string value of an attribute to
      70             :     various other data types.
      71             :  */
      72           0 : class OOX_DLLPUBLIC AttributeList
      73             : {
      74             : public:
      75             :     explicit            AttributeList(
      76             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs );
      77             : 
      78             :     /** Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object. */
      79             :     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >
      80           0 :                         getFastAttributeList() const { return mxAttribs; }
      81             : 
      82             :     /** Returns true, if the specified attribute is present. */
      83             :     bool                hasAttribute( sal_Int32 nAttrToken ) const;
      84             : 
      85             :     // optional return values -------------------------------------------------
      86             : 
      87             :     /** Returns the token identifier of the value of the specified attribute. */
      88             :     OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const;
      89             : 
      90             :     /** Returns the string value of the specified attribute. */
      91             :     OptValue< OUString > getString( sal_Int32 nAttrToken ) const;
      92             : 
      93             :     /** Returns the string value of the specified attribute. All characters in
      94             :         the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */
      95             :     OptValue< OUString > getXString( sal_Int32 nAttrToken ) const;
      96             : 
      97             :     /** Returns the double value of the specified attribute. */
      98             :     OptValue< double >  getDouble( sal_Int32 nAttrToken ) const;
      99             : 
     100             :     /** Returns the 32-bit signed integer value of the specified attribute (decimal). */
     101             :     OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const;
     102             : 
     103             :     /** Returns the 32-bit unsigned integer value of the specified attribute (decimal). */
     104             :     OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const;
     105             : 
     106             :     /** Returns the 64-bit signed integer value of the specified attribute (decimal). */
     107             :     OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const;
     108             : 
     109             :     /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal). */
     110             :     OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const;
     111             : 
     112             :     /** Returns the boolean value of the specified attribute. */
     113             :     OptValue< bool >    getBool( sal_Int32 nAttrToken ) const;
     114             : 
     115             :     /** Returns the date/time value of the specified attribute. */
     116             :     OptValue< ::com::sun::star::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const;
     117             : 
     118             :     // defaulted return values ------------------------------------------------
     119             : 
     120             :     /** Returns the token identifier of the value of the specified attribute,
     121             :         or the passed default identifier if the attribute is missing. */
     122             :     sal_Int32           getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
     123             : 
     124             :     /** Returns the string value of the specified attribute, or the passed
     125             :         default string if the attribute is missing. */
     126             :     OUString     getString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
     127             : 
     128             :     /** Returns the decoded string value of the specified attribute, or the
     129             :         passed default string if the attribute is missing. */
     130             :     OUString     getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const;
     131             : 
     132             :     const char* getChar( sal_Int32 nAttrToken ) const;
     133             : 
     134             : 
     135             :     /** Returns the double value of the specified attribute, or the passed
     136             :         default value if the attribute is missing or not convertible to a double. */
     137             :     double              getDouble( sal_Int32 nAttrToken, double fDefault ) const;
     138             : 
     139             :     /** Returns the 32-bit signed integer value of the specified attribute, or the
     140             :         passed default value if the attribute is missing or not convertible to integer. */
     141             :     sal_Int32           getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
     142             : 
     143             :     /** Returns the 32-bit unsigned integer value of the specified attribute, or the
     144             :         passed default value if the attribute is missing or not convertible to unsigned. */
     145             :     sal_uInt32          getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const;
     146             : 
     147             :     /** Returns the 64-bit signed integer value of the specified attribute, or the
     148             :         passed default value if the attribute is missing or not convertible to integer. */
     149             :     sal_Int64           getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const;
     150             : 
     151             :     /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal),
     152             :         or the passed default value if the attribute is missing or not convertible. */
     153             :     sal_Int32           getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const;
     154             : 
     155             :     /** Returns the boolean value of the specified attribute, or the passed
     156             :         default value if the attribute is missing or not convertible to bool. */
     157             :     bool                getBool( sal_Int32 nAttrToken, bool bDefault ) const;
     158             : 
     159             :     /** Returns the date/time value of the specified attribute, or the default
     160             :         value if the attribute is missing or not convertible to a date/time value. */
     161             :     ::com::sun::star::util::DateTime getDateTime( sal_Int32 nAttrToken, const ::com::sun::star::util::DateTime& rDefault ) const;
     162             : 
     163             : private:
     164             :     ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >
     165             :                         mxAttribs;
     166             :     mutable sax_fastparser::FastAttributeList *mpAttribList;
     167             :     sax_fastparser::FastAttributeList *getAttribList() const;
     168             : };
     169             : 
     170             : 
     171             : 
     172             : } // namespace oox
     173             : 
     174             : #endif
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10