add a SwFrameDeleteGuard to SwSaveFootnoteHeight
[LibreOffice.git] / xmloff / inc / XMLEventImportHelper.hxx
blobccb475ac122de26b7a6b39d727638b6afcf426a6
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 #pragma once
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <xmloff/xmlevent.hxx>
25 #include <map>
26 #include <vector>
27 #include <memory>
30 namespace com::sun::star {
31 namespace xml::sax { class XFastAttributeList; }
33 class XMLEventContextFactory;
34 class XMLEventsImportContext;
35 struct XMLEventNameTranslation;
37 typedef ::std::map< OUString, std::unique_ptr<XMLEventContextFactory> > FactoryMap;
38 typedef ::std::map< XMLEventName, OUString > NameMap;
41 /**
42 * Helps the XMLEventsImportContext.
44 * This class stores
45 * a) the translation from XML event names to API event names, and
46 * b) a mapping from script language names to XMLEventContextFactory objects
47 * (that handle particular languages).
49 * Event name translation tables may be added, i.e. they will be joined
50 * together. If different translations are needed (i.e., if the same XML name
51 * needs to be translated to different API names in different contexts), then
52 * translation tables may be saved on a translation table stack.
54 class XMLEventImportHelper
56 /// map of XMLEventContextFactory objects
57 FactoryMap aFactoryMap;
59 /// map from XML to API names
60 std::unique_ptr<NameMap> pEventNameMap;
62 /// stack of previous aEventNameMap
63 std::vector< std::unique_ptr<NameMap> > aEventNameMapVector;
65 public:
66 XMLEventImportHelper();
68 ~XMLEventImportHelper();
70 /// register a handler for a particular language type
71 void RegisterFactory( const OUString& rLanguage,
72 std::unique_ptr<XMLEventContextFactory> aFactory );
74 /// add event name translation to the internal table
75 void AddTranslationTable( const XMLEventNameTranslation* pTransTable );
77 /// save the old translation table on a stack and install an empty table
78 void PushTranslationTable();
80 /// recover the top-most previously saved translation table
81 void PopTranslationTable();
83 /// create an appropriate import context for a particular event
84 SvXMLImportContext* CreateContext(
85 SvXMLImport& rImport,
86 const css::uno::Reference< css::xml::sax::XFastAttributeList> & xAttrList,
87 XMLEventsImportContext* rEvents,
88 const OUString& rXmlEventName,
89 const OUString& rLanguage);
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */