xref: /AOO41X/main/xmloff/source/text/XMLIndexTemplateContext.hxx (revision ecfe53c5d1886e1e0d215b0d140d05282ab1c477)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_
25 #define _XMLOFF_XMLINDEXTEMPLATECONTEXT_HXX_
26 
27 #include <xmloff/xmlictxt.hxx>
28 #include <xmloff/xmltoken.hxx>
29 
30 #include <vector>
31 #include <com/sun/star/uno/Reference.h>
32 #include <com/sun/star/uno/Sequence.h>
33 #include <com/sun/star/beans/PropertyValues.hpp>
34 
35 
36 namespace com { namespace sun { namespace star {
37     namespace xml { namespace sax { class XAttributeList; } }
38     namespace beans { class XPropertySet; }
39 } } }
40 namespace rtl { class OUString; }
41 struct SvXMLEnumMapEntry;
42 
43 
44 // constants for the XMLIndexTemplateContext constructor
45 
46 // TOC and user defined index:
47 extern const SvXMLEnumMapEntry aLevelNameTOCMap[];
48 extern const sal_Char* aLevelStylePropNameTOCMap[];
49 extern const sal_Bool aAllowedTokenTypesTOC[];
50 extern const sal_Bool aAllowedTokenTypesUser[];
51 
52 // alphabetical index:
53 extern const SvXMLEnumMapEntry aLevelNameAlphaMap[];
54 extern const sal_Char* aLevelStylePropNameAlphaMap[];
55 extern const sal_Bool aAllowedTokenTypesAlpha[];
56 
57 // bibliography:
58 extern const SvXMLEnumMapEntry aLevelNameBibliographyMap[];
59 extern const sal_Char* aLevelStylePropNameBibliographyMap[];
60 extern const sal_Bool aAllowedTokenTypesBibliography[];
61 
62 // table, illustration and object tables:
63 extern const SvXMLEnumMapEntry* aLevelNameTableMap; // NULL: no outline-level
64 extern const sal_Char* aLevelStylePropNameTableMap[];
65 extern const sal_Bool aAllowedTokenTypesTable[];
66 
67 
68 /**
69  * Import index entry templates
70  */
71 class XMLIndexTemplateContext : public SvXMLImportContext
72 {
73     // pick up PropertyValues to be turned into a sequence.
74     ::std::vector< ::com::sun::star::beans::PropertyValues > aValueVector;
75 
76     ::rtl::OUString sStyleName;
77 
78     const SvXMLEnumMapEntry* pOutlineLevelNameMap;
79     enum ::xmloff::token::XMLTokenEnum eOutlineLevelAttrName;
80     const sal_Char** pOutlineLevelStylePropMap;
81     const sal_Bool* pAllowedTokenTypesMap;
82 
83     sal_Int32 nOutlineLevel;
84     sal_Bool bStyleNameOK;
85     sal_Bool bOutlineLevelOK;
86     sal_Bool bTOC;
87 
88     // PropertySet of current index
89     ::com::sun::star::uno::Reference<
90         ::com::sun::star::beans::XPropertySet> & rPropertySet;
91 
92 public:
93 
94     // constants made available to other contexts (template entry
95     // contexts, in particular)
96     const ::rtl::OUString sTokenEntryNumber;
97     const ::rtl::OUString sTokenEntryText;
98     const ::rtl::OUString sTokenTabStop;
99     const ::rtl::OUString sTokenText;
100     const ::rtl::OUString sTokenPageNumber;
101     const ::rtl::OUString sTokenChapterInfo;
102     const ::rtl::OUString sTokenHyperlinkStart;
103     const ::rtl::OUString sTokenHyperlinkEnd;
104     const ::rtl::OUString sTokenBibliographyDataField;
105 
106     const ::rtl::OUString sCharacterStyleName;
107     const ::rtl::OUString sTokenType;
108     const ::rtl::OUString sText;
109     const ::rtl::OUString sTabStopRightAligned;
110     const ::rtl::OUString sTabStopPosition;
111     const ::rtl::OUString sTabStopFillCharacter;
112     const ::rtl::OUString sBibliographyDataField;
113     const ::rtl::OUString sChapterFormat;
114     const ::rtl::OUString sChapterLevel;//i53420
115 
116     const ::rtl::OUString sLevelFormat;
117     const ::rtl::OUString sParaStyleLevel;
118 
119 
120     TYPEINFO();
121 
122     XMLIndexTemplateContext(
123         SvXMLImport& rImport,
124         ::com::sun::star::uno::Reference<
125             ::com::sun::star::beans::XPropertySet> & rPropSet,
126         sal_uInt16 nPrfx,
127         const ::rtl::OUString& rLocalName,
128         const SvXMLEnumMapEntry* aLevelNameMap,
129         enum ::xmloff::token::XMLTokenEnum eLevelAttrName,
130         const sal_Char** aLevelStylePropNameMap,
131         const sal_Bool* aAllowedTokenTypes,
132         sal_Bool bTOC=sal_False);
133 
134     ~XMLIndexTemplateContext();
135 
136     /** add template; to be called by child template entry contexts */
137     void addTemplateEntry(
138         const ::com::sun::star::beans::PropertyValues& aValues);
139 
140 protected:
141 
142     virtual void StartElement(
143         const ::com::sun::star::uno::Reference<
144             ::com::sun::star::xml::sax::XAttributeList> & xAttrList);
145 
146     virtual void EndElement();
147 
148     virtual SvXMLImportContext *CreateChildContext(
149         sal_uInt16 nPrefix,
150         const ::rtl::OUString& rLocalName,
151         const ::com::sun::star::uno::Reference<
152             ::com::sun::star::xml::sax::XAttributeList> & xAttrList );
153 };
154 
155 #endif
156