Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / xmloff / xmlprmap.hxx
blobab1690da70786f18f0c19fc4bb5c7935db345d06
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 <rtl/ref.hxx>
24 #include <xmloff/dllapi.h>
25 #include <unotools/saveopt.hxx>
26 #include <rtl/ustring.hxx>
28 #include <salhelper/simplereferenceobject.hxx>
29 #include <memory>
31 class SvXMLUnitConverter;
32 class XMLPropertyHandler;
33 class XMLPropertyHandlerFactory;
34 struct XMLPropertyMapEntry;
35 struct XMLPropertyState;
37 class XMLOFF_DLLPUBLIC XMLPropertySetMapper : public salhelper::SimpleReferenceObject
39 struct Impl;
41 std::unique_ptr<Impl> mpImpl;
43 XMLPropertySetMapper( const XMLPropertySetMapper& ) = delete;
44 XMLPropertySetMapper& operator= ( const XMLPropertySetMapper& ) = delete;
46 public:
47 /** The last element of the XMLPropertyMapEntry-array must contain NULL-values.
49 @param bForExport
50 If TRUE, only entries that have the mbImportOnly flag not set
51 will be in the mappings.
53 XMLPropertySetMapper(
54 const XMLPropertyMapEntry* pEntries,
55 const rtl::Reference<XMLPropertyHandlerFactory>& rFactory,
56 bool bForExport );
58 virtual ~XMLPropertySetMapper() override;
60 void AddMapperEntry( const rtl::Reference < XMLPropertySetMapper >& rMapper );
62 /** Return number of entries in input-array */
63 sal_Int32 GetEntryCount() const;
65 /** Returns the flags of an entry */
66 sal_uInt32 GetEntryFlags( sal_Int32 nIndex ) const;
68 /** Returns the type of an entry */
69 sal_uInt32 GetEntryType( sal_Int32 nIndex ) const;
71 /** Returns the namespace-key of an entry */
72 sal_uInt16 GetEntryNameSpace( sal_Int32 nIndex ) const;
74 /** Returns the 'local' XML-name of the entry */
75 const OUString& GetEntryXMLName( sal_Int32 nIndex ) const;
77 /** Returns the entry API name */
78 const OUString& GetEntryAPIName( sal_Int32 nIndex ) const;
80 /** returns the entry context id. -1 is a valid index here. */
81 sal_Int16 GetEntryContextId( sal_Int32 nIndex ) const;
83 /** returns the earliest odf version for which this property should be exported. */
84 SvtSaveOptions::ODFDefaultVersion GetEarliestODFVersionForExport( sal_Int32 nIndex ) const;
86 /** Returns the index of an entry with the given XML-name and namespace
87 If there is no matching entry the method returns -1 */
88 sal_Int32 GetEntryIndex(
89 sal_uInt16 nNamespace, const OUString& rStrName, sal_uInt32 nPropType,
90 sal_Int32 nStartAt = -1 ) const;
92 /** Retrieves a PropertyHandler for that property which placed at nIndex in the XMLPropertyMapEntry-array */
93 const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nIndex ) const;
95 /** import/export
96 This methods calls the respective im/export-method of the respective PropertyHandler. */
97 bool exportXML(
98 OUString& rStrExpValue, const XMLPropertyState& rProperty,
99 const SvXMLUnitConverter& rUnitConverter ) const;
101 bool importXML(
102 const OUString& rStrImpValue, XMLPropertyState& rProperty,
103 const SvXMLUnitConverter& rUnitConverter ) const;
105 /** searches for an entry that matches the given api name, namespace and local name or -1 if nothing found */
106 sal_Int32 FindEntryIndex(
107 const sal_Char* sApiName, sal_uInt16 nNameSpace, const OUString& sXMLName ) const;
109 /** searches for an entry that matches the given ContextId or gives -1 if nothing found */
110 sal_Int32 FindEntryIndex( const sal_Int16 nContextId ) const;
112 /** Remove an entry */
113 void RemoveEntry( sal_Int32 nIndex );
116 #endif // INCLUDED_XMLOFF_XMLPRMAP_HXX
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */