1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_XMLOFF_SOURCE_TEXT_XMLINDEXTEMPLATECONTEXT_HXX
21 #define INCLUDED_XMLOFF_SOURCE_TEXT_XMLINDEXTEMPLATECONTEXT_HXX
22 
23 #include <xmloff/xmlictxt.hxx>
24 #include <xmloff/xmltoken.hxx>
25 
26 #include <vector>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/beans/PropertyValues.hpp>
29 
30 
31 namespace com { namespace sun { namespace star {
32     namespace xml { namespace sax { class XAttributeList; } }
33     namespace beans { class XPropertySet; }
34 } } }
35 template<typename EnumT> struct SvXMLEnumMapEntry;
36 
37 
38 // constants for the XMLIndexTemplateContext constructor
39 
40 // TOC and user defined index:
41 extern const SvXMLEnumMapEntry<sal_uInt16> aSvLevelNameTOCMap[];
42 extern const sal_Char* aLevelStylePropNameTOCMap[];
43 extern const bool aAllowedTokenTypesTOC[];
44 extern const bool aAllowedTokenTypesUser[];
45 
46 // alphabetical index:
47 extern const SvXMLEnumMapEntry<sal_uInt16> aLevelNameAlphaMap[];
48 extern const sal_Char* aLevelStylePropNameAlphaMap[];
49 extern const bool aAllowedTokenTypesAlpha[];
50 
51 // bibliography:
52 extern const SvXMLEnumMapEntry<sal_uInt16> aLevelNameBibliographyMap[];
53 extern const sal_Char* aLevelStylePropNameBibliographyMap[];
54 extern const bool aAllowedTokenTypesBibliography[];
55 
56 // table, illustration and object tables:
57 extern const SvXMLEnumMapEntry<sal_uInt16>* aLevelNameTableMap; // NULL: no outline-level
58 extern const sal_Char* aLevelStylePropNameTableMap[];
59 extern const bool aAllowedTokenTypesTable[];
60 
61 
62 /**
63  * Import index entry templates
64  */
65 class XMLIndexTemplateContext : public SvXMLImportContext
66 {
67     // pick up PropertyValues to be turned into a sequence.
68     ::std::vector< css::beans::PropertyValues > aValueVector;
69 
70     OUString sStyleName;
71 
72     const SvXMLEnumMapEntry<sal_uInt16>* pOutlineLevelNameMap;
73     enum ::xmloff::token::XMLTokenEnum const eOutlineLevelAttrName;
74     const sal_Char** pOutlineLevelStylePropMap;
75     const bool* pAllowedTokenTypesMap;
76 
77     sal_Int32 nOutlineLevel;
78     bool bStyleNameOK;
79     bool bOutlineLevelOK;
80     bool const bTOC;
81 
82     // PropertySet of current index
83     css::uno::Reference<css::beans::XPropertySet> & rPropertySet;
84 
85 public:
86     template<typename EnumT>
XMLIndexTemplateContext(SvXMLImport & rImport,css::uno::Reference<css::beans::XPropertySet> & rPropSet,sal_uInt16 nPrfx,const OUString & rLocalName,const SvXMLEnumMapEntry<EnumT> * aLevelNameMap,enum::xmloff::token::XMLTokenEnum eLevelAttrName,const sal_Char ** aLevelStylePropNameMap,const bool * aAllowedTokenTypes,bool bTOC_=false)87     XMLIndexTemplateContext(
88         SvXMLImport& rImport,
89         css::uno::Reference<css::beans::XPropertySet> & rPropSet,
90         sal_uInt16 nPrfx,
91         const OUString& rLocalName,
92         const SvXMLEnumMapEntry<EnumT>* aLevelNameMap,
93         enum ::xmloff::token::XMLTokenEnum eLevelAttrName,
94         const sal_Char** aLevelStylePropNameMap,
95         const bool* aAllowedTokenTypes,
96         bool bTOC_=false)
97         : XMLIndexTemplateContext(rImport,rPropSet,nPrfx,rLocalName,
98                 reinterpret_cast<const SvXMLEnumMapEntry<sal_uInt16>*>(aLevelNameMap),
99                 eLevelAttrName, aLevelStylePropNameMap, aAllowedTokenTypes, bTOC_) {}
100     XMLIndexTemplateContext(
101         SvXMLImport& rImport,
102         css::uno::Reference<css::beans::XPropertySet> & rPropSet,
103         sal_uInt16 nPrfx,
104         const OUString& rLocalName,
105         const SvXMLEnumMapEntry<sal_uInt16>* aLevelNameMap,
106         enum ::xmloff::token::XMLTokenEnum eLevelAttrName,
107         const sal_Char** aLevelStylePropNameMap,
108         const bool* aAllowedTokenTypes,
109         bool bTOC);
110 
111     virtual ~XMLIndexTemplateContext() override;
112 
113     /** add template; to be called by child template entry contexts */
114     void addTemplateEntry(
115         const css::beans::PropertyValues& aValues);
116 
117 protected:
118 
119     virtual void StartElement(
120         const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList) override;
121 
122     virtual void EndElement() override;
123 
124     virtual SvXMLImportContextRef CreateChildContext(
125         sal_uInt16 nPrefix,
126         const OUString& rLocalName,
127         const css::uno::Reference<css::xml::sax::XAttributeList> & xAttrList ) override;
128 };
129 
130 #endif
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
133