bump product version to 5.0.4.1
[LibreOffice.git] / xmloff / inc / XMLEventImportHelper.hxx
blob4dca7093f4d1739e238ba2786fa80a73db267e3b
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 <list>
30 namespace com { namespace sun { namespace star {
31 namespace xml { namespace sax { class XAttributeList; } }
32 } } }
33 class XMLEventContextFactory;
34 class XMLEventsImportContext;
35 struct XMLEventNameTranslation;
37 typedef ::std::map< OUString, XMLEventContextFactory* > FactoryMap;
38 typedef ::std::map< XMLEventName, OUString > NameMap;
39 typedef ::std::list< NameMap* > NameMapList;
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 NameMap* pEventNameMap;
63 /// stack of previous aEventNameMap
64 NameMapList aEventNameMapList;
66 public:
67 XMLEventImportHelper();
69 ~XMLEventImportHelper();
71 /// register a handler for a particular language type
72 void RegisterFactory( const OUString& rLanguage,
73 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 ::com::sun::star::uno::Reference<
90 ::com::sun::star::xml::sax::XAttributeList> & xAttrList,
91 XMLEventsImportContext* rEvents,
92 const OUString& rXmlEventName,
93 const OUString& rLanguage);
97 #endif
99 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */