Files
libreoffice/include/xmloff/nmspmap.hxx

161 lines
6.0 KiB
C++
Raw Normal View History

2010-10-27 13:11:31 +01:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
2012-11-12 17:21:24 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_XMLOFF_NMSPMAP_HXX
#define INCLUDED_XMLOFF_NMSPMAP_HXX
#include <sal/config.h>
2012-01-31 11:32:02 +01:00
#include <map>
#include <unordered_map>
2012-01-31 11:32:02 +01:00
#include <utility>
#include <xmloff/dllapi.h>
#include <sal/types.h>
#include <rtl/ustring.hxx>
2010-10-15 12:10:06 -05:00
#include <rtl/ref.hxx>
#include <cppuhelper/weak.hxx>
#include <limits.h>
const sal_uInt16 XML_NAMESPACE_XMLNS = (USHRT_MAX-2);
const sal_uInt16 XML_NAMESPACE_NONE = (USHRT_MAX-1);
const sal_uInt16 XML_NAMESPACE_UNKNOWN = (USHRT_MAX);
const sal_uInt16 XML_NAMESPACE_UNKNOWN_FLAG = 0x8000;
class NameSpaceEntry : public cppu::OWeakObject
{
public:
// sName refers to the full namespace name
OUString sName;
// sPrefix is the prefix used to declare a given item to be from a given namespace
OUString sPrefix;
// nKey is the unique identifier of a namespace
sal_uInt16 nKey;
};
struct uInt32lt
{
bool operator()( const sal_uInt32 &r1, const sal_uInt32 &r2) const
{
return r1 < r2;
}
};
typedef ::std::pair < sal_uInt16, OUString > QNamePair;
struct QNamePairHash
{
size_t operator()( const QNamePair &r1 ) const
{
2012-01-31 11:32:02 +01:00
return (size_t) r1.second.hashCode() + r1.first;
}
};
typedef std::unordered_map < QNamePair, OUString, QNamePairHash > QNameCache;
typedef std::unordered_map < OUString, ::rtl::Reference <NameSpaceEntry >, OUStringHash > NameSpaceHash;
typedef std::map < sal_uInt16, ::rtl::Reference < NameSpaceEntry >, uInt32lt > NameSpaceMap;
class XMLOFF_DLLPUBLIC SvXMLNamespaceMap
{
const OUString sXMLNS;
const OUString sEmpty;
2012-01-31 11:32:02 +01:00
NameSpaceHash aNameHash;
mutable NameSpaceHash aNameCache;
NameSpaceMap aNameMap;
2012-01-31 11:32:02 +01:00
mutable QNameCache aQNameCache;
SAL_DLLPRIVATE sal_uInt16 _Add( const OUString& rPrefix, const OUString &rName, sal_uInt16 nKey );
public:
SvXMLNamespaceMap();
~SvXMLNamespaceMap();
SvXMLNamespaceMap( const SvXMLNamespaceMap& );
void operator =( const SvXMLNamespaceMap& rCmp );
bool operator ==( const SvXMLNamespaceMap& rCmp ) const;
sal_uInt16 Add( const OUString& rPrefix,
const OUString& rName,
sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN );
sal_uInt16 AddIfKnown( const OUString& rPrefix,
const OUString& rName );
sal_uInt16 GetKeyByName( const OUString& rName ) const;
const OUString& GetNameByKey( sal_uInt16 nKey ) const;
sal_uInt16 GetKeyByPrefix( const OUString& rPrefix ) const;
const OUString& GetPrefixByKey( sal_uInt16 nKey ) const;
OUString GetQNameByKey( sal_uInt16 nKey,
const OUString& rLocalName,
bool bCache = true) const;
OUString GetAttrNameByKey( sal_uInt16 nKey ) const;
/* This will replace the version with the unused 5th default parameter */
sal_uInt16 _GetKeyByAttrName( const OUString& rAttrName,
OUString *pPrefix,
OUString *pLocalName,
OUString *pNamespace = 0,
bool bCache = true) const;
/* This will replace the version with the unused 3rd default parameter */
sal_uInt16 _GetKeyByAttrName( const OUString& rAttrName,
OUString *pLocalName = 0,
bool bCache = true) const;
sal_uInt16 GetFirstKey() const;
sal_uInt16 GetNextKey( sal_uInt16 nOldKey ) const;
CWS-TOOLING: integrate CWS calcsheetdata 2009-08-13 16:18:48 +0200 nn r274950 : #i102616# shared/remote files, better handling of formula results 2009-08-12 11:17:30 +0200 nn r274884 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274622 (milestone: DEV300:m54) 2009-08-12 10:30:47 +0200 nn r274881 : #i102616# some clean-up 2009-08-11 19:01:18 +0200 nn r274876 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-11 19:00:49 +0200 nn r274875 : #i102616# store loaded namespaces, so prefixes remain valid 2009-08-10 19:12:04 +0200 nn r274835 : #i102616# detective, notes, encoding, error handling 2009-08-07 11:18:46 +0200 nn r274751 : #i102616# use new method SvXMLAutoStylePoolP::AddNamed 2009-08-07 11:18:15 +0200 nn r274750 : #i102616# new method SvXMLAutoStylePoolP::AddNamed 2009-08-06 18:02:42 +0200 nn r274740 : #i102616# modification: shapes, notes, pending row heights; skip sheets in export iterator 2009-08-05 18:41:59 +0200 nn r274694 : #i102616# handle text styles in notes 2009-08-03 18:55:59 +0200 nn r274594 : #i102616# handle text styles in cells 2009-07-31 19:00:06 +0200 nn r274548 : #i102616# handle styles for notes 2009-07-28 16:46:20 +0200 nn r274414 : missed a conflict 2009-07-28 14:01:56 +0200 nn r274404 : CWS-TOOLING: rebase CWS calcsheetdata to trunk@274203 (milestone: DEV300:m53) 2009-07-23 18:28:47 +0200 nn r274278 : #i102616# handle table styles 2009-07-22 15:40:24 +0200 nn r274244 : #i102616# handle row styles 2009-07-21 20:09:37 +0200 nn r274211 : #i102616# handle column styles 2009-07-16 13:00:18 +0200 nn r274043 : #i102616# invalidate all stream positions when inserting/deleting sheets 2009-07-15 17:41:15 +0200 nn r274021 : #i102616# don't collect cell styles twice for copied sheets 2009-07-14 18:36:11 +0200 nn r273985 : #i102616# allow to query stream position, clear buffer 2009-07-14 18:32:10 +0200 nn r273984 : #i102616# allow to specify a name for an autostyle 2009-07-09 22:01:23 +0200 nn r273870 : #i102616# copy stream for unchanged sheets 2009-07-08 18:11:42 +0200 nn r273844 : #i102616# store stream positions of sheets 2009-06-24 19:08:18 +0200 nn r273363 : #i102616# detect changed sheets since loading 2009-06-09 15:53:32 +0200 nn r272774 : #i102616# store automatic cell style information after loading
2009-09-07 15:38:19 +00:00
/* Give access to all namespace definitions, including multiple entries
for the same key (needed for saving sheets separately in Calc).
This might be replaced by a better interface later. */
const NameSpaceHash& GetAllEntries() const { return aNameHash; }
static bool NormalizeOasisURN( OUString& rName );
static bool NormalizeW3URI( OUString& rName );
static bool NormalizeURI( OUString& rName );
/* deprecated */ bool AddAtIndex( sal_uInt16 nIdx, const OUString& rPrefix,
const OUString& rName, sal_uInt16 nKey = XML_NAMESPACE_UNKNOWN );
/* deprecated */ static sal_uInt16 GetIndexByKey( sal_uInt16 nKey );
/* deprecated */ sal_uInt16 GetIndexByPrefix( const OUString& rPrefix ) const;
/* deprecated */ sal_uInt16 GetFirstIndex() const;
/* deprecated */ sal_uInt16 GetNextIndex( sal_uInt16 nOldIdx ) const;
/* deprecated */ const OUString& GetPrefixByIndex( sal_uInt16 nIdx ) const;
/* deprecated */ const OUString& GetNameByIndex( sal_uInt16 nIdx ) const;
/* deprecated */ OUString GetAttrNameByIndex( sal_uInt16 nIdx ) const;
/* deprecated */ OUString GetQNameByIndex( sal_uInt16 nIdx,
const OUString& rLocalName ) const;
/* deprecated */ sal_uInt16 GetKeyByAttrName( const OUString& rAttrName,
OUString *pPrefix,
OUString *pLocalName,
OUString *pNamespace=0,
sal_uInt16 nIdxGuess = USHRT_MAX ) const;
/* deprecated */ sal_uInt16 GetKeyByAttrName( const OUString& rAttrName,
OUString *pLocalName = 0,
sal_uInt16 nIdxGuess = USHRT_MAX ) const;
};
#endif // INCLUDED_XMLOFF_NMSPMAP_HXX
2010-10-27 13:11:31 +01:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */