xref: /AOO41X/main/xmloff/source/text/XMLIndexTOCContext.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #include "XMLIndexTOCContext.hxx"
33*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/text/XTextContent.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/text/XTextSection.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/text/XRelativeTextContentInsert.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
40*cdf0e10cSrcweir #include "XMLIndexTOCSourceContext.hxx"
41*cdf0e10cSrcweir #include "XMLIndexObjectSourceContext.hxx"
42*cdf0e10cSrcweir #include "XMLIndexAlphabeticalSourceContext.hxx"
43*cdf0e10cSrcweir #include "XMLIndexUserSourceContext.hxx"
44*cdf0e10cSrcweir #include "XMLIndexBibliographySourceContext.hxx"
45*cdf0e10cSrcweir #include "XMLIndexTableSourceContext.hxx"
46*cdf0e10cSrcweir #include "XMLIndexIllustrationSourceContext.hxx"
47*cdf0e10cSrcweir #include "XMLIndexBodyContext.hxx"
48*cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
49*cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
50*cdf0e10cSrcweir #include <xmloff/txtimp.hxx>
51*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
52*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
53*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
54*cdf0e10cSrcweir #include <xmloff/prstylei.hxx>
55*cdf0e10cSrcweir #include "xmloff/xmlerror.hxx"
56*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
57*cdf0e10cSrcweir #include <rtl/ustring.hxx>
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
61*cdf0e10cSrcweir using namespace ::com::sun::star::text;
62*cdf0e10cSrcweir using namespace ::xmloff::token;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using ::rtl::OUString;
65*cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet;
66*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
67*cdf0e10cSrcweir using ::com::sun::star::xml::sax::XAttributeList;
68*cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory;
69*cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir TYPEINIT1(XMLIndexTOCContext, SvXMLImportContext);
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir static const sal_Char* aIndexServiceMap[] =
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	"com.sun.star.text.ContentIndex",
77*cdf0e10cSrcweir 	"com.sun.star.text.DocumentIndex",
78*cdf0e10cSrcweir 	"com.sun.star.text.TableIndex",
79*cdf0e10cSrcweir 	"com.sun.star.text.ObjectIndex",
80*cdf0e10cSrcweir 	"com.sun.star.text.Bibliography",
81*cdf0e10cSrcweir 	"com.sun.star.text.UserIndex",
82*cdf0e10cSrcweir 	"com.sun.star.text.IllustrationsIndex"
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir static const XMLTokenEnum aIndexSourceElementMap[] =
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir 	XML_TABLE_OF_CONTENT_SOURCE,
88*cdf0e10cSrcweir 	XML_ALPHABETICAL_INDEX_SOURCE,
89*cdf0e10cSrcweir 	XML_TABLE_INDEX_SOURCE,
90*cdf0e10cSrcweir 	XML_OBJECT_INDEX_SOURCE,
91*cdf0e10cSrcweir 	XML_BIBLIOGRAPHY_SOURCE,
92*cdf0e10cSrcweir 	XML_USER_INDEX_SOURCE,
93*cdf0e10cSrcweir 	XML_ILLUSTRATION_INDEX_SOURCE
94*cdf0e10cSrcweir };
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir SvXMLEnumMapEntry __READONLY_DATA aIndexTypeMap[] =
97*cdf0e10cSrcweir {
98*cdf0e10cSrcweir 	{ XML_TABLE_OF_CONTENT,	    TEXT_INDEX_TOC },
99*cdf0e10cSrcweir 	{ XML_ALPHABETICAL_INDEX,	TEXT_INDEX_ALPHABETICAL },
100*cdf0e10cSrcweir 	{ XML_TABLE_INDEX, 		    TEXT_INDEX_TABLE },
101*cdf0e10cSrcweir 	{ XML_OBJECT_INDEX,		    TEXT_INDEX_OBJECT },
102*cdf0e10cSrcweir 	{ XML_BIBLIOGRAPHY,		    TEXT_INDEX_BIBLIOGRAPHY },
103*cdf0e10cSrcweir 	{ XML_USER_INDEX,			TEXT_INDEX_USER },
104*cdf0e10cSrcweir 	{ XML_ILLUSTRATION_INDEX,	TEXT_INDEX_ILLUSTRATION },
105*cdf0e10cSrcweir 	{ XML_TOKEN_INVALID,        0 }
106*cdf0e10cSrcweir };
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir XMLIndexTOCContext::XMLIndexTOCContext(
110*cdf0e10cSrcweir 	SvXMLImport& rImport,
111*cdf0e10cSrcweir 	sal_uInt16 nPrfx,
112*cdf0e10cSrcweir 	const OUString& rLocalName )
113*cdf0e10cSrcweir :	SvXMLImportContext(rImport, nPrfx, rLocalName)
114*cdf0e10cSrcweir ,	sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
115*cdf0e10cSrcweir ,	sIsProtected(RTL_CONSTASCII_USTRINGPARAM("IsProtected"))
116*cdf0e10cSrcweir ,	sName(RTL_CONSTASCII_USTRINGPARAM("Name"))
117*cdf0e10cSrcweir ,	bValid(sal_False)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir 	if (XML_NAMESPACE_TEXT == nPrfx)
120*cdf0e10cSrcweir 	{
121*cdf0e10cSrcweir 		sal_uInt16 nTmp;
122*cdf0e10cSrcweir 		if (SvXMLUnitConverter::convertEnum(nTmp, rLocalName, aIndexTypeMap))
123*cdf0e10cSrcweir 		{
124*cdf0e10cSrcweir 			// check for array index:
125*cdf0e10cSrcweir 			OSL_ENSURE(nTmp < (sizeof(aIndexServiceMap)/sizeof(sal_Char*)), "index out of range");
126*cdf0e10cSrcweir 			OSL_ENSURE(sizeof(aIndexServiceMap) ==
127*cdf0e10cSrcweir 					   sizeof(aIndexSourceElementMap),
128*cdf0e10cSrcweir 					   "service and source element maps must be same size");
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 			eIndexType = static_cast<IndexTypeEnum>(nTmp);
131*cdf0e10cSrcweir 			bValid = sal_True;
132*cdf0e10cSrcweir 		}
133*cdf0e10cSrcweir 	}
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir XMLIndexTOCContext::~XMLIndexTOCContext()
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir void XMLIndexTOCContext::StartElement(
141*cdf0e10cSrcweir 	const Reference<XAttributeList> & xAttrList)
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir 	if (bValid)
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         // find text:style-name attribute and set section style
146*cdf0e10cSrcweir         // find text:protected and set value
147*cdf0e10cSrcweir         // find text:name and set value (if not empty)
148*cdf0e10cSrcweir         sal_Int16 nCount = xAttrList->getLength();
149*cdf0e10cSrcweir         sal_Bool bProtected = sal_False;
150*cdf0e10cSrcweir         OUString sIndexName;
151*cdf0e10cSrcweir         OUString sXmlId;
152*cdf0e10cSrcweir         XMLPropStyleContext* pStyle(NULL);
153*cdf0e10cSrcweir         for(sal_Int16 nAttr = 0; nAttr < nCount; nAttr++)
154*cdf0e10cSrcweir         {
155*cdf0e10cSrcweir             OUString sLocalName;
156*cdf0e10cSrcweir             sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
157*cdf0e10cSrcweir                 GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
158*cdf0e10cSrcweir                                   &sLocalName );
159*cdf0e10cSrcweir             if ( XML_NAMESPACE_TEXT == nPrefix)
160*cdf0e10cSrcweir             {
161*cdf0e10cSrcweir                 if ( IsXMLToken( sLocalName, XML_STYLE_NAME ) )
162*cdf0e10cSrcweir                 {
163*cdf0e10cSrcweir                     pStyle = GetImport().GetTextImport()->FindSectionStyle(
164*cdf0e10cSrcweir                                 xAttrList->getValueByIndex(nAttr));
165*cdf0e10cSrcweir                 }
166*cdf0e10cSrcweir                 else if ( IsXMLToken( sLocalName, XML_PROTECTED ) )
167*cdf0e10cSrcweir                 {
168*cdf0e10cSrcweir                     sal_Bool bTmp;
169*cdf0e10cSrcweir                     if ( SvXMLUnitConverter::convertBool(
170*cdf0e10cSrcweir                          bTmp, xAttrList->getValueByIndex(nAttr) ) )
171*cdf0e10cSrcweir                     {
172*cdf0e10cSrcweir                         bProtected = bTmp;
173*cdf0e10cSrcweir                     }
174*cdf0e10cSrcweir                 }
175*cdf0e10cSrcweir                 else if ( IsXMLToken( sLocalName, XML_NAME ) )
176*cdf0e10cSrcweir                 {
177*cdf0e10cSrcweir                     sIndexName = xAttrList->getValueByIndex(nAttr);
178*cdf0e10cSrcweir                 }
179*cdf0e10cSrcweir             }
180*cdf0e10cSrcweir             else if ( XML_NAMESPACE_XML == nPrefix)
181*cdf0e10cSrcweir             {
182*cdf0e10cSrcweir                 if ( IsXMLToken( sLocalName, XML_ID ) )
183*cdf0e10cSrcweir                 {
184*cdf0e10cSrcweir                     sXmlId = xAttrList->getValueByIndex(nAttr);
185*cdf0e10cSrcweir                 }
186*cdf0e10cSrcweir             }
187*cdf0e10cSrcweir         }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir 		// create table of content (via MultiServiceFactory)
190*cdf0e10cSrcweir 		Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),
191*cdf0e10cSrcweir 												 UNO_QUERY);
192*cdf0e10cSrcweir         if( xFactory.is() )
193*cdf0e10cSrcweir         {
194*cdf0e10cSrcweir             Reference<XInterface> xIfc =
195*cdf0e10cSrcweir 				xFactory->createInstance(
196*cdf0e10cSrcweir 					OUString::createFromAscii(aIndexServiceMap[eIndexType]));
197*cdf0e10cSrcweir 			if( xIfc.is() )
198*cdf0e10cSrcweir 			{
199*cdf0e10cSrcweir 				// get Property set
200*cdf0e10cSrcweir 				Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY);
201*cdf0e10cSrcweir 				xTOCPropertySet = xPropSet;
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir 				// insert section
204*cdf0e10cSrcweir 				// a) insert section
205*cdf0e10cSrcweir 				//    The inserted index consists of an empty paragraph
206*cdf0e10cSrcweir 				//    only, as well as an empty paragraph *after* the index
207*cdf0e10cSrcweir 				// b) insert marker after index, and put Cursor inside of the
208*cdf0e10cSrcweir 				//    index
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 				// preliminaries
211*cdf0e10cSrcweir #ifndef DBG_UTIL
212*cdf0e10cSrcweir 				OUString sMarker(RTL_CONSTASCII_USTRINGPARAM(" "));
213*cdf0e10cSrcweir #else
214*cdf0e10cSrcweir 				OUString sMarker(RTL_CONSTASCII_USTRINGPARAM("Y"));
215*cdf0e10cSrcweir #endif
216*cdf0e10cSrcweir 				UniReference<XMLTextImportHelper> rImport =
217*cdf0e10cSrcweir 					GetImport().GetTextImport();
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 				// a) insert index
220*cdf0e10cSrcweir 				Reference<XTextContent> xTextContent(xIfc, UNO_QUERY);
221*cdf0e10cSrcweir                 try
222*cdf0e10cSrcweir                 {
223*cdf0e10cSrcweir                     GetImport().GetTextImport()->InsertTextContent(
224*cdf0e10cSrcweir                         xTextContent);
225*cdf0e10cSrcweir                 }
226*cdf0e10cSrcweir                 catch( IllegalArgumentException e )
227*cdf0e10cSrcweir                 {
228*cdf0e10cSrcweir                     // illegal argument? Then we can't accept indices here!
229*cdf0e10cSrcweir                     Sequence<OUString> aSeq(1);
230*cdf0e10cSrcweir                     aSeq[0] = GetLocalName();
231*cdf0e10cSrcweir                     GetImport().SetError(
232*cdf0e10cSrcweir                         XMLERROR_FLAG_ERROR | XMLERROR_NO_INDEX_ALLOWED_HERE,
233*cdf0e10cSrcweir                         aSeq, e.Message, NULL );
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir                     // set bValid to false, and return prematurely
236*cdf0e10cSrcweir                     bValid = false;
237*cdf0e10cSrcweir                     return;
238*cdf0e10cSrcweir                 }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir                 // xml:id for RDF metadata
241*cdf0e10cSrcweir                 GetImport().SetXmlId(xIfc, sXmlId);
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir 				// b) insert marker and move cursor
244*cdf0e10cSrcweir 				rImport->InsertString(sMarker);
245*cdf0e10cSrcweir 				rImport->GetCursor()->goLeft(2, sal_False);
246*cdf0e10cSrcweir 			}
247*cdf0e10cSrcweir 		}
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir         // finally, check for redlines that should start at
250*cdf0e10cSrcweir         // the section start node
251*cdf0e10cSrcweir         if( bValid )
252*cdf0e10cSrcweir             GetImport().GetTextImport()->
253*cdf0e10cSrcweir                 RedlineAdjustStartNodeCursor(sal_True);
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir         if (pStyle != NULL)
256*cdf0e10cSrcweir         {
257*cdf0e10cSrcweir             pStyle->FillPropertySet( xTOCPropertySet );
258*cdf0e10cSrcweir         }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir         Any aAny;
261*cdf0e10cSrcweir         aAny.setValue( &bProtected, ::getBooleanCppuType() );
262*cdf0e10cSrcweir         xTOCPropertySet->setPropertyValue( sIsProtected, aAny );
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         if (sIndexName.getLength() > 0)
265*cdf0e10cSrcweir         {
266*cdf0e10cSrcweir             aAny <<= sIndexName;
267*cdf0e10cSrcweir             xTOCPropertySet->setPropertyValue( sName, aAny );
268*cdf0e10cSrcweir         }
269*cdf0e10cSrcweir     }
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir void XMLIndexTOCContext::EndElement()
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir     // complete import of index by removing the markers (if the index
275*cdf0e10cSrcweir     // was actually inserted, that is)
276*cdf0e10cSrcweir     if( bValid )
277*cdf0e10cSrcweir     {
278*cdf0e10cSrcweir         // preliminaries
279*cdf0e10cSrcweir         OUString sEmpty;
280*cdf0e10cSrcweir         UniReference<XMLTextImportHelper> rHelper= GetImport().GetTextImport();
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir         // get rid of last paragraph (unless it's the only paragraph)
283*cdf0e10cSrcweir         rHelper->GetCursor()->goRight(1, sal_False);
284*cdf0e10cSrcweir         if( xBodyContextRef.Is() &&
285*cdf0e10cSrcweir             ((XMLIndexBodyContext*)&xBodyContextRef)->HasContent() )
286*cdf0e10cSrcweir         {
287*cdf0e10cSrcweir             rHelper->GetCursor()->goLeft(1, sal_True);
288*cdf0e10cSrcweir             rHelper->GetText()->insertString(rHelper->GetCursorAsRange(),
289*cdf0e10cSrcweir                                              sEmpty, sal_True);
290*cdf0e10cSrcweir         }
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir         // and delete second marker
293*cdf0e10cSrcweir         rHelper->GetCursor()->goRight(1, sal_True);
294*cdf0e10cSrcweir         rHelper->GetText()->insertString(rHelper->GetCursorAsRange(),
295*cdf0e10cSrcweir                                          sEmpty, sal_True);
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir         // check for Redlines on our end node
298*cdf0e10cSrcweir         GetImport().GetTextImport()->RedlineAdjustStartNodeCursor(sal_False);
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir }
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir SvXMLImportContext* XMLIndexTOCContext::CreateChildContext(
303*cdf0e10cSrcweir 	sal_uInt16 nPrefix,
304*cdf0e10cSrcweir 	const OUString& rLocalName,
305*cdf0e10cSrcweir 	const Reference<XAttributeList> & xAttrList )
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir 	SvXMLImportContext* pContext = NULL;
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir 	if (bValid)
310*cdf0e10cSrcweir 	{
311*cdf0e10cSrcweir 		if (XML_NAMESPACE_TEXT == nPrefix)
312*cdf0e10cSrcweir 		{
313*cdf0e10cSrcweir 			if ( IsXMLToken( rLocalName, XML_INDEX_BODY ) )
314*cdf0e10cSrcweir 			{
315*cdf0e10cSrcweir 				pContext = new XMLIndexBodyContext(GetImport(), nPrefix,
316*cdf0e10cSrcweir 												   rLocalName);
317*cdf0e10cSrcweir                 if ( !xBodyContextRef.Is() ||
318*cdf0e10cSrcweir                      !((XMLIndexBodyContext*)&xBodyContextRef)->HasContent() )
319*cdf0e10cSrcweir                 {
320*cdf0e10cSrcweir                     xBodyContextRef = pContext;
321*cdf0e10cSrcweir                 }
322*cdf0e10cSrcweir 			}
323*cdf0e10cSrcweir 			else if (IsXMLToken(rLocalName, aIndexSourceElementMap[eIndexType]))
324*cdf0e10cSrcweir 			{
325*cdf0e10cSrcweir 				// instantiate source context for the appropriate index type
326*cdf0e10cSrcweir 				switch (eIndexType)
327*cdf0e10cSrcweir 				{
328*cdf0e10cSrcweir 					case TEXT_INDEX_TOC:
329*cdf0e10cSrcweir 						pContext = new XMLIndexTOCSourceContext(
330*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
331*cdf0e10cSrcweir 						break;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir 					case TEXT_INDEX_OBJECT:
334*cdf0e10cSrcweir 						pContext = new XMLIndexObjectSourceContext(
335*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
336*cdf0e10cSrcweir 						break;
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 					case TEXT_INDEX_ALPHABETICAL:
339*cdf0e10cSrcweir 						pContext = new XMLIndexAlphabeticalSourceContext(
340*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
341*cdf0e10cSrcweir 						break;
342*cdf0e10cSrcweir 
343*cdf0e10cSrcweir 					case TEXT_INDEX_USER:
344*cdf0e10cSrcweir 						pContext = new XMLIndexUserSourceContext(
345*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
346*cdf0e10cSrcweir 						break;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir 					case TEXT_INDEX_BIBLIOGRAPHY:
349*cdf0e10cSrcweir 						pContext = new XMLIndexBibliographySourceContext(
350*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
351*cdf0e10cSrcweir 						break;
352*cdf0e10cSrcweir 
353*cdf0e10cSrcweir 					case TEXT_INDEX_TABLE:
354*cdf0e10cSrcweir 						pContext = new XMLIndexTableSourceContext(
355*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
356*cdf0e10cSrcweir 						break;
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 					case TEXT_INDEX_ILLUSTRATION:
359*cdf0e10cSrcweir 						pContext = new XMLIndexIllustrationSourceContext(
360*cdf0e10cSrcweir 							GetImport(), nPrefix, rLocalName, xTOCPropertySet);
361*cdf0e10cSrcweir 						break;
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 					default:
364*cdf0e10cSrcweir 						OSL_ENSURE(false, "index type not implemented");
365*cdf0e10cSrcweir 						break;
366*cdf0e10cSrcweir 				}
367*cdf0e10cSrcweir 			}
368*cdf0e10cSrcweir 			// else: ignore
369*cdf0e10cSrcweir 		}
370*cdf0e10cSrcweir 		// else: no text: namespace -> ignore
371*cdf0e10cSrcweir 	}
372*cdf0e10cSrcweir 	// else: not valid -> ignore
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 	// default: ignore
375*cdf0e10cSrcweir 	if (pContext == NULL)
376*cdf0e10cSrcweir 	{
377*cdf0e10cSrcweir 		pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
378*cdf0e10cSrcweir 														  xAttrList);
379*cdf0e10cSrcweir 	}
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	return pContext;
382*cdf0e10cSrcweir }
383