Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / xmloff / inc / XMLEventImportHelper.hxx
blob6e4c8dce9fd628afb8166d1cc86c257a409e4309
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_INC_XMLEVENTIMPORTHELPER_HXX
21 #define INCLUDED_XMLOFF_INC_XMLEVENTIMPORTHELPER_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <xmloff/xmlevent.hxx>
26 #include <map>
27 #include <vector>
28 #include <memory>
31 namespace com { namespace sun { namespace star {
32 namespace xml { namespace sax { class XAttributeList; } }
33 } } }
34 class XMLEventContextFactory;
35 class XMLEventsImportContext;
36 struct XMLEventNameTranslation;
38 typedef ::std::map< OUString, std::unique_ptr<XMLEventContextFactory> > FactoryMap;
39 typedef ::std::map< XMLEventName, OUString > NameMap;
42 /**
43 * Helps the XMLEventsImportContext.
45 * This class stores
46 * a) the translation from XML event names to API event names, and
47 * b) a mapping from script language names to XMLEventContextFactory objects
48 * (that handle particular languages).
50 * Event name translation tables may be added, i.e. they will be joined
51 * together. If different translations are needed (i.e., if the same XML name
52 * needs to be translated to different API names in different contexts), then
53 * translation tables may be saved on a translation table stack.
55 class XMLEventImportHelper
57 /// map of XMLEventContextFactory objects
58 FactoryMap aFactoryMap;
60 /// map from XML to API names
61 std::unique_ptr<NameMap> pEventNameMap;
63 /// stack of previous aEventNameMap
64 std::vector< std::unique_ptr<NameMap> > aEventNameMapVector;
66 public:
67 XMLEventImportHelper();
69 ~XMLEventImportHelper();
71 /// register a handler for a particular language type
72 void RegisterFactory( const OUString& rLanguage,
73 std::unique_ptr<XMLEventContextFactory> aFactory );
75 /// add event name translation to the internal table
76 void AddTranslationTable( const XMLEventNameTranslation* pTransTable );
78 /// save the old translation table on a stack and install an empty table
79 void PushTranslationTable();
81 /// recover the top-most previously saved translation table
82 void PopTranslationTable();
84 /// create an appropriate import context for a particular event
85 SvXMLImportContext* CreateContext(
86 SvXMLImport& rImport,
87 sal_uInt16 nPrefix,
88 const OUString& rLocalName,
89 const css::uno::Reference< css::xml::sax::XAttributeList> & xAttrList,
90 XMLEventsImportContext* rEvents,
91 const OUString& rXmlEventName,
92 const OUString& rLanguage);
96 #endif
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */