Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / xmloff / xmlprmap.hxx
blob2a4b93e8495e6220138a6ca2eb114247f07bd802
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_XMLPRMAP_HXX
21 #define INCLUDED_XMLOFF_XMLPRMAP_HXX
23 #include <xmloff/dllapi.h>
24 #include <unotools/saveopt.hxx>
25 #include <rtl/ustring.hxx>
27 #include <salhelper/simplereferenceobject.hxx>
28 #include <memory>
30 namespace rtl { template <class reference_type> class Reference; }
32 class SvXMLUnitConverter;
33 class XMLPropertyHandler;
34 class XMLPropertyHandlerFactory;
35 struct XMLPropertyMapEntry;
36 struct XMLPropertyState;
38 class XMLOFF_DLLPUBLIC XMLPropertySetMapper : public salhelper::SimpleReferenceObject
40 struct Impl;
42 std::unique_ptr<Impl> mpImpl;
44 XMLPropertySetMapper( const XMLPropertySetMapper& ) = delete;
45 XMLPropertySetMapper& operator= ( const XMLPropertySetMapper& ) = delete;
47 public:
48 /** The last element of the XMLPropertyMapEntry-array must contain NULL-values.
50 @param bForExport
51 If TRUE, only entries that have the mbImportOnly flag not set
52 will be in the mappings.
54 XMLPropertySetMapper(
55 const XMLPropertyMapEntry* pEntries,
56 const rtl::Reference<XMLPropertyHandlerFactory>& rFactory,
57 bool bForExport );
59 virtual ~XMLPropertySetMapper() override;
61 void AddMapperEntry( const rtl::Reference < XMLPropertySetMapper >& rMapper );
63 /** Return number of entries in input-array */
64 sal_Int32 GetEntryCount() const;
66 /** Returns the flags of an entry */
67 sal_uInt32 GetEntryFlags( sal_Int32 nIndex ) const;
69 /** Returns the type of an entry */
70 sal_uInt32 GetEntryType( sal_Int32 nIndex ) const;
72 /** Returns the namespace-key of an entry */
73 sal_uInt16 GetEntryNameSpace( sal_Int32 nIndex ) const;
75 /** Returns the 'local' XML-name of the entry */
76 const OUString& GetEntryXMLName( sal_Int32 nIndex ) const;
78 /** Returns the entry API name */
79 const OUString& GetEntryAPIName( sal_Int32 nIndex ) const;
81 /** returns the entry context id. -1 is a valid index here. */
82 sal_Int16 GetEntryContextId( sal_Int32 nIndex ) const;
84 /** returns the earliest ODF version for which this property should be
85 exported as standard ODF element, which is the earliest ODF version
86 for which the property should not be exported as extension element.
88 SvtSaveOptions::ODFSaneDefaultVersion GetEarliestODFVersionForExport(sal_Int32 nIndex) const;
90 /** Returns the index of an entry with the given XML-name and namespace
91 If there is no matching entry the method returns -1 */
92 sal_Int32 GetEntryIndex(
93 sal_uInt16 nNamespace, std::u16string_view rStrName, sal_uInt32 nPropType,
94 sal_Int32 nStartAt = -1 ) const;
96 /** Returns the index of an entry with the given XML-name and namespace
97 If there is no matching entry the method returns -1 */
98 sal_Int32 GetEntryIndex(
99 sal_Int32 nElement, sal_uInt32 nPropType,
100 sal_Int32 nStartAt = -1 ) const;
102 /** Retrieves a PropertyHandler for that property which placed at nIndex in the XMLPropertyMapEntry-array */
103 const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nIndex ) const;
105 /** import/export
106 This methods calls the respective im/export-method of the respective PropertyHandler. */
107 bool exportXML(
108 OUString& rStrExpValue, const XMLPropertyState& rProperty,
109 const SvXMLUnitConverter& rUnitConverter ) const;
111 bool importXML(
112 const OUString& rStrImpValue, XMLPropertyState& rProperty,
113 const SvXMLUnitConverter& rUnitConverter ) const;
115 /** searches for an entry that matches the given api name, namespace and local name or -1 if nothing found */
116 sal_Int32 FindEntryIndex(
117 const char* sApiName, sal_uInt16 nNameSpace, std::u16string_view sXMLName ) const;
119 /** searches for an entry that matches the given ContextId or gives -1 if nothing found */
120 sal_Int32 FindEntryIndex( const sal_Int16 nContextId ) const;
122 /** Remove an entry */
123 void RemoveEntry( sal_Int32 nIndex );
126 #endif // INCLUDED_XMLOFF_XMLPRMAP_HXX
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */