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