1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XMLEventImportHelper.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _XMLOFF_EVENTIMPORTHELPER_HXX
32 #define _XMLOFF_EVENTIMPORTHELPER_HXX
34 #include <com/sun/star/uno/Reference.hxx>
35 #include <xmloff/xmlevent.hxx>
41 namespace com
{ namespace sun
{ namespace star
{
42 namespace xml
{ namespace sax
{ class XAttributeList
; } }
44 namespace rtl
{ class OUString
; }
45 class XMLEventContextFactory
;
46 class XMLEventsImportContext
;
47 struct XMLEventNameTranslation
;
49 typedef ::std::map
< ::rtl::OUString
, XMLEventContextFactory
* > FactoryMap
;
50 typedef ::std::map
< XMLEventName
, ::rtl::OUString
> NameMap
;
51 typedef ::std::list
< NameMap
* > NameMapList
;
55 * Helps the XMLEventsImportContext.
58 * a) the translation from XML event names to API event names, and
59 * b) a mapping from script language names to XMLEventContextFactory objects
60 * (that handle particular languages).
62 * Event name translation tables may be added, i.e. they will be joined
63 * together. If different translations are needed (i.e., if the same XML name
64 * needs to be translated to different API names in different contexts), then
65 * translation tables may be saved on a translation table stack.
67 class XMLEventImportHelper
69 /// map of XMLEventContextFactory objects
70 FactoryMap aFactoryMap
;
72 /// map from XML to API names
73 NameMap
* pEventNameMap
;
75 /// stack of previous aEventNameMap
76 NameMapList aEventNameMapList
;
79 XMLEventImportHelper();
81 ~XMLEventImportHelper();
83 /// register a handler for a particular language type
84 void RegisterFactory( const ::rtl::OUString
& rLanguage
,
85 XMLEventContextFactory
* aFactory
);
87 /// add event name translation to the internal table
88 void AddTranslationTable( const XMLEventNameTranslation
* pTransTable
);
90 /// save the old translation table on a stack and install an empty table
91 void PushTranslationTable();
93 /// recover the top-most previously saved translation table
94 void PopTranslationTable();
96 /// create an appropriate import context for a particular event
97 SvXMLImportContext
* CreateContext(
100 const ::rtl::OUString
& rLocalName
,
101 const ::com::sun::star::uno::Reference
<
102 ::com::sun::star::xml::sax::XAttributeList
> & xAttrList
,
103 XMLEventsImportContext
* rEvents
,
104 const ::rtl::OUString
& rXmlEventName
,
105 const ::rtl::OUString
& rLanguage
);