Branch libreoffice-5-0-4
[LibreOffice.git] / include / xmloff / xmlprmap.hxx
blob569adfa6552b6fecdd6799721de32bf454dc60b0
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>
30 class SvXMLUnitConverter;
31 class XMLPropertyHandler;
32 class XMLPropertyHandlerFactory;
33 struct XMLPropertyMapEntry;
34 struct XMLPropertyState;
36 class XMLOFF_DLLPUBLIC XMLPropertySetMapper : public salhelper::SimpleReferenceObject
38 struct Impl;
40 Impl* mpImpl;
42 XMLPropertySetMapper( const XMLPropertySetMapper& ) SAL_DELETED_FUNCTION;
43 XMLPropertySetMapper& operator= ( const XMLPropertySetMapper& ) SAL_DELETED_FUNCTION;
45 public:
46 /** The last element of the XMLPropertyMapEntry-array must contain NULL-values.
48 @param bForExport
49 If TRUE, only entries that have the mbImportOnly flag not set
50 will be in the mappings.
52 XMLPropertySetMapper(
53 const XMLPropertyMapEntry* pEntries,
54 const rtl::Reference<XMLPropertyHandlerFactory>& rFactory,
55 bool bForExport );
57 virtual ~XMLPropertySetMapper();
59 void AddMapperEntry( const rtl::Reference < XMLPropertySetMapper >& rMapper );
61 /** Return number of entries in input-array */
62 sal_Int32 GetEntryCount() const;
64 /** Returns the flags of an entry */
65 sal_uInt32 GetEntryFlags( sal_Int32 nIndex ) const;
67 /** Returns the type of an entry */
68 sal_uInt32 GetEntryType( sal_Int32 nIndex, bool bWithFlags = true ) const;
70 /** Returns the namespace-key of an entry */
71 sal_uInt16 GetEntryNameSpace( sal_Int32 nIndex ) const;
73 /** Returns the 'local' XML-name of the entry */
74 const OUString& GetEntryXMLName( sal_Int32 nIndex ) const;
76 /** Returns the entry API name */
77 const OUString& GetEntryAPIName( sal_Int32 nIndex ) const;
79 /** returns the entry context id. -1 is a valid index here. */
80 sal_Int16 GetEntryContextId( sal_Int32 nIndex ) const;
82 /** returns the earliest odf version for which this property should be exported. */
83 SvtSaveOptions::ODFDefaultVersion GetEarliestODFVersionForExport( sal_Int32 nIndex ) const;
85 /** Returns the index of an entry with the given XML-name and namespace
86 If there is no matching entry the method returns -1 */
87 sal_Int32 GetEntryIndex(
88 sal_uInt16 nNamespace, const OUString& rStrName, sal_uInt32 nPropType,
89 sal_Int32 nStartAt = -1 ) const;
91 /** Retrieves a PropertyHandler for that property which placed at nIndex in the XMLPropertyMapEntry-array */
92 const XMLPropertyHandler* GetPropertyHandler( sal_Int32 nIndex ) const;
94 /** import/export
95 This methods calls the respective im/export-method of the respective PropertyHandler. */
96 bool exportXML(
97 OUString& rStrExpValue, const XMLPropertyState& rProperty,
98 const SvXMLUnitConverter& rUnitConverter ) const;
100 bool importXML(
101 const OUString& rStrImpValue, XMLPropertyState& rProperty,
102 const SvXMLUnitConverter& rUnitConverter ) const;
104 /** searches for an entry that matches the given api name, namespace and local name or -1 if nothing found */
105 sal_Int32 FindEntryIndex(
106 const sal_Char* sApiName, sal_uInt16 nNameSpace, const OUString& sXMLName ) const;
108 /** searches for an entry that matches the given ContextId or gives -1 if nothing found */
109 sal_Int32 FindEntryIndex( const sal_Int16 nContextId ) const;
111 /** Remove an entry */
112 void RemoveEntry( sal_Int32 nIndex );
115 #endif // INCLUDED_XMLOFF_XMLPRMAP_HXX
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */