LCOV - code coverage report
Current view: top level - include/xmloff - nmspmap.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 8 0.0 %
Date: 2014-04-14 Functions: 0 7 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_XMLOFF_NMSPMAP_HXX
      21             : #define INCLUDED_XMLOFF_NMSPMAP_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <map>
      26             : #include <utility>
      27             : 
      28             : #include <xmloff/dllapi.h>
      29             : #include <sal/types.h>
      30             : #include <rtl/ustring.hxx>
      31             : #include <boost/unordered_map.hpp>
      32             : #include <rtl/ref.hxx>
      33             : #include <cppuhelper/weak.hxx>
      34             : 
      35             : #include <limits.h>
      36             : 
      37             : const sal_uInt16 XML_NAMESPACE_XMLNS  = (USHRT_MAX-2);
      38             : const sal_uInt16 XML_NAMESPACE_NONE  = (USHRT_MAX-1);
      39             : const sal_uInt16 XML_NAMESPACE_UNKNOWN  = (USHRT_MAX);
      40             : const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG  = 0x8000;
      41             : 
      42           0 : class NameSpaceEntry : public cppu::OWeakObject
      43             : {
      44             : public:
      45             :     // sName refers to the full namespace name
      46             :     OUString     sName;
      47             :     // sPrefix is the prefix used to declare a given item to be from a given namespace
      48             :     OUString     sPrefix;
      49             :     // nKey is the unique identifier of a namespace
      50             :     sal_uInt16          nKey;
      51             : };
      52             : 
      53             : struct OUStringEqFunc
      54             : {
      55           0 :     bool operator()( const OUString &r1, const OUString &r2) const
      56             :     {
      57           0 :         return r1 == r2;
      58             :     }
      59             : };
      60             : 
      61             : struct uInt32lt
      62             : {
      63           0 :     bool operator()( const sal_uInt32 &r1, const sal_uInt32 &r2) const
      64             :     {
      65           0 :         return r1 < r2;
      66             :     }
      67             : };
      68             : typedef ::std::pair < sal_uInt16, OUString > QNamePair;
      69             : 
      70             : struct QNamePairHash
      71             : {
      72           0 :     size_t operator()( const QNamePair &r1 ) const
      73             :     {
      74           0 :         return (size_t) r1.second.hashCode() + r1.first;
      75             :     }
      76             : };
      77             : 
      78             : typedef ::boost::unordered_map < QNamePair, OUString, QNamePairHash > QNameCache;
      79             : typedef ::boost::unordered_map < OUString, ::rtl::Reference <NameSpaceEntry >, OUStringHash, OUStringEqFunc > NameSpaceHash;
      80             : typedef ::std::map < sal_uInt16, ::rtl::Reference < NameSpaceEntry >, uInt32lt > NameSpaceMap;
      81             : 
      82             : class XMLOFF_DLLPUBLIC SvXMLNamespaceMap
      83             : {
      84             :     const OUString       sXMLNS;
      85             :     const OUString       sEmpty;
      86             : 
      87             :     NameSpaceHash               aNameHash;
      88             :     mutable NameSpaceHash       aNameCache;
      89             :     NameSpaceMap                aNameMap;
      90             :     mutable QNameCache          aQNameCache;
      91             :     SAL_DLLPRIVATE sal_uInt16 _Add( const OUString& rPrefix, const OUString &rName, sal_uInt16 nKey );
      92             : 
      93             : public:
      94             : 
      95             :     SvXMLNamespaceMap();
      96             :     ~SvXMLNamespaceMap();
      97             : 
      98             :     SvXMLNamespaceMap( const SvXMLNamespaceMap& );
      99             : 
     100             :     void operator =( const SvXMLNamespaceMap& rCmp );
     101             :     bool operator ==( const SvXMLNamespaceMap& rCmp ) const;
     102             : 
     103             :     sal_uInt16 Add( const OUString& rPrefix,
     104             :                 const OUString& rName,
     105             :                 sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN );
     106             :     sal_uInt16 AddIfKnown( const OUString& rPrefix,
     107             :                 const OUString& rName );
     108             : 
     109             :     sal_uInt16 GetKeyByName( const OUString& rName ) const;
     110             :     const OUString& GetNameByKey( sal_uInt16 nKey ) const;
     111             : 
     112             :     sal_uInt16 GetKeyByPrefix( const OUString& rPrefix ) const;
     113             :     const OUString& GetPrefixByKey( sal_uInt16 nKey ) const;
     114             : 
     115             :     OUString GetQNameByKey( sal_uInt16 nKey,
     116             :                            const OUString& rLocalName,
     117             :                            bool bCache = true) const;
     118             : 
     119             :     OUString GetAttrNameByKey( sal_uInt16 nKey ) const;
     120             : 
     121             :     /* This will replace the version with the unused 5th default parameter */
     122             :     sal_uInt16 _GetKeyByAttrName( const OUString& rAttrName,
     123             :                              OUString *pPrefix,
     124             :                              OUString *pLocalName,
     125             :                              OUString *pNamespace = 0,
     126             :                              bool bCache = true) const;
     127             : 
     128             :     /* This will replace the version with the unused 3rd default parameter */
     129             :     sal_uInt16 _GetKeyByAttrName( const OUString& rAttrName,
     130             :                              OUString *pLocalName = 0,
     131             :                              bool bCache = true) const;
     132             : 
     133             :     sal_uInt16 GetFirstKey() const;
     134             :     sal_uInt16 GetNextKey( sal_uInt16 nOldKey ) const;
     135             : 
     136             :     /* Give access to all namespace definitions, including multiple entries
     137             :        for the same key (needed for saving sheets separately in Calc).
     138             :        This might be replaced by a better interface later. */
     139           0 :     const NameSpaceHash& GetAllEntries() const { return aNameHash; }
     140             : 
     141             :     static bool NormalizeOasisURN( OUString& rName );
     142             :     static bool NormalizeW3URI( OUString& rName );
     143             :     static bool NormalizeURI( OUString& rName );
     144             : 
     145             : /* deprecated */ bool AddAtIndex( sal_uInt16 nIdx, const OUString& rPrefix,
     146             :                      const OUString& rName, sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN );
     147             : /* deprecated */ sal_uInt16 GetIndexByKey( sal_uInt16 nKey ) const;
     148             : /* deprecated */ sal_uInt16 GetIndexByPrefix( const OUString& rPrefix ) const;
     149             : /* deprecated */ sal_uInt16 GetFirstIndex() const;
     150             : /* deprecated */ sal_uInt16 GetNextIndex( sal_uInt16 nOldIdx ) const;
     151             : /* deprecated */ const OUString& GetPrefixByIndex( sal_uInt16 nIdx ) const;
     152             : /* deprecated */ const OUString& GetNameByIndex( sal_uInt16 nIdx ) const;
     153             : /* deprecated */ OUString GetAttrNameByIndex( sal_uInt16 nIdx ) const;
     154             : /* deprecated */ OUString GetQNameByIndex( sal_uInt16 nIdx,
     155             :                             const OUString& rLocalName ) const;
     156             : /* deprecated */ sal_uInt16 GetKeyByAttrName( const OUString& rAttrName,
     157             :                              OUString *pPrefix,
     158             :                              OUString *pLocalName,
     159             :                              OUString *pNamespace=0,
     160             :                              sal_uInt16 nIdxGuess = USHRT_MAX ) const;
     161             : /* deprecated */ sal_uInt16 GetKeyByAttrName( const OUString& rAttrName,
     162             :                              OUString *pLocalName = 0,
     163             :                              sal_uInt16 nIdxGuess = USHRT_MAX ) const;
     164             : };
     165             : 
     166             : #endif // INCLUDED_XMLOFF_NMSPMAP_HXX
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10