xref: /AOO41X/main/xmloff/source/text/txtparai.cxx (revision c45df7c4d83ad42fac597959ca4c329ba5d8db89)
163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
363bba73cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
563bba73cSAndrew Rist  * distributed with this work for additional information
663bba73cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
763bba73cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist  * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
1163bba73cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
1363bba73cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist  * software distributed under the License is distributed on an
1563bba73cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist  * KIND, either express or implied.  See the License for the
1763bba73cSAndrew Rist  * specific language governing permissions and limitations
1863bba73cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
2063bba73cSAndrew Rist  *************************************************************/
2163bba73cSAndrew Rist 
2263bba73cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include "unointerfacetouniqueidentifiermapper.hxx"
27cdf0e10cSrcweir #include <rtl/ustring.hxx>
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir #include <tools/debug.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <tools/string.hxx>
32cdf0e10cSrcweir #include <svl/svarray.hxx>
33cdf0e10cSrcweir #include <com/sun/star/text/XTextFrame.hpp>
34cdf0e10cSrcweir #include <com/sun/star/text/XTextCursor.hpp>
35cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
36cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySetInfo.hpp>
37cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp>
38cdf0e10cSrcweir #include <com/sun/star/container/XIndexReplace.hpp>
39cdf0e10cSrcweir #include <com/sun/star/drawing/XShapes.hpp>
40cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
41cdf0e10cSrcweir #include <com/sun/star/rdf/XMetadatable.hpp>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx>
45cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
46cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
47cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
48cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
49cdf0e10cSrcweir #include <xmloff/txtimp.hxx>
50cdf0e10cSrcweir #include "txtparai.hxx"
51cdf0e10cSrcweir #include "txtfldi.hxx"
52cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
53cdf0e10cSrcweir #include "XMLFootnoteImportContext.hxx"
54cdf0e10cSrcweir #include "XMLTextMarkImportContext.hxx"
55cdf0e10cSrcweir #include "XMLTextFrameContext.hxx"
56cdf0e10cSrcweir #include <xmloff/XMLCharContext.hxx>
57cdf0e10cSrcweir #include "XMLTextFrameHyperlinkContext.hxx"
58cdf0e10cSrcweir #include <xmloff/XMLEventsImportContext.hxx>
59cdf0e10cSrcweir #include "XMLChangeImportContext.hxx"
60cdf0e10cSrcweir #include "txtlists.hxx"
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir // OD 2004-04-21 #i26791#
64cdf0e10cSrcweir #include <txtparaimphint.hxx>
65cdf0e10cSrcweir typedef XMLHint_Impl *XMLHint_ImplPtr;
66cdf0e10cSrcweir SV_DECL_PTRARR_DEL( XMLHints_Impl, XMLHint_ImplPtr, 5, 5 )
67cdf0e10cSrcweir SV_IMPL_PTRARR( XMLHints_Impl, XMLHint_ImplPtr )
68cdf0e10cSrcweir // OD 2004-04-21 #i26791#
69cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using ::rtl::OUString;
72cdf0e10cSrcweir using ::rtl::OUStringBuffer;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir using namespace ::com::sun::star;
75cdf0e10cSrcweir using namespace ::com::sun::star::uno;
76cdf0e10cSrcweir using namespace ::com::sun::star::text;
77cdf0e10cSrcweir using namespace ::com::sun::star::drawing;
78cdf0e10cSrcweir using namespace ::com::sun::star::beans;
79cdf0e10cSrcweir using namespace ::xmloff::token;
80cdf0e10cSrcweir using ::com::sun::star::container::XEnumerationAccess;
81cdf0e10cSrcweir using ::com::sun::star::container::XEnumeration;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
84cdf0e10cSrcweir TYPEINIT1( XMLCharContext, SvXMLImportContext );
85cdf0e10cSrcweir 
XMLCharContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,sal_Unicode c,sal_Bool bCount)86cdf0e10cSrcweir XMLCharContext::XMLCharContext(
87cdf0e10cSrcweir 		SvXMLImport& rImport,
88cdf0e10cSrcweir 		sal_uInt16 nPrfx,
89cdf0e10cSrcweir 		const OUString& rLName,
90cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
91cdf0e10cSrcweir 		sal_Unicode c,
92cdf0e10cSrcweir 		sal_Bool bCount ) :
93cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName )
94cdf0e10cSrcweir     ,m_nControl(0)
95cdf0e10cSrcweir     ,m_nCount(1)
96cdf0e10cSrcweir     ,m_c(c)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	if( bCount )
99cdf0e10cSrcweir 	{
100cdf0e10cSrcweir         const SvXMLNamespaceMap& rMap = GetImport().GetNamespaceMap();
101cdf0e10cSrcweir 		sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
102cdf0e10cSrcweir 		for( sal_Int16 i=0; i < nAttrCount; i++ )
103cdf0e10cSrcweir 		{
104cdf0e10cSrcweir 			const OUString& rAttrName = xAttrList->getNameByIndex( i );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir 			OUString aLocalName;
107cdf0e10cSrcweir 			sal_uInt16 nPrefix =rMap.GetKeyByAttrName( rAttrName,&aLocalName );
108cdf0e10cSrcweir 			if( XML_NAMESPACE_TEXT == nPrefix &&
109cdf0e10cSrcweir 				IsXMLToken( aLocalName, XML_C ) )
110cdf0e10cSrcweir 			{
111cdf0e10cSrcweir 				sal_Int32 nTmp = xAttrList->getValueByIndex(i).toInt32();
112cdf0e10cSrcweir 				if( nTmp > 0L )
113cdf0e10cSrcweir 				{
114cdf0e10cSrcweir 					if( nTmp > USHRT_MAX )
115cdf0e10cSrcweir 						m_nCount = USHRT_MAX;
116cdf0e10cSrcweir 					else
117cdf0e10cSrcweir 						m_nCount = (sal_uInt16)nTmp;
118cdf0e10cSrcweir 				}
119cdf0e10cSrcweir 			}
120cdf0e10cSrcweir 		}
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
XMLCharContext(SvXMLImport & rImp,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> &,sal_Int16 nControl)124cdf0e10cSrcweir XMLCharContext::XMLCharContext(
125cdf0e10cSrcweir 		SvXMLImport& rImp,
126cdf0e10cSrcweir 		sal_uInt16 nPrfx,
127cdf0e10cSrcweir 		const OUString& rLName,
128cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > &,
129cdf0e10cSrcweir 		sal_Int16 nControl ) :
130cdf0e10cSrcweir 	SvXMLImportContext( rImp, nPrfx, rLName )
131cdf0e10cSrcweir     ,m_nControl(nControl)
132cdf0e10cSrcweir     ,m_nCount(0)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
~XMLCharContext()136cdf0e10cSrcweir XMLCharContext::~XMLCharContext()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir }
139cdf0e10cSrcweir // -----------------------------------------------------------------------------
EndElement()140cdf0e10cSrcweir void XMLCharContext::EndElement()
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     if ( !m_nCount )
143cdf0e10cSrcweir         InsertControlCharacter( m_nControl );
144cdf0e10cSrcweir     else
145cdf0e10cSrcweir     {
146cdf0e10cSrcweir         if( 1U == m_nCount )
147cdf0e10cSrcweir 	    {
148cdf0e10cSrcweir 		    OUString sBuff( &m_c, 1 );
149cdf0e10cSrcweir             InsertString(sBuff);
150cdf0e10cSrcweir 	    }
151cdf0e10cSrcweir 	    else
152cdf0e10cSrcweir 	    {
153cdf0e10cSrcweir 		    OUStringBuffer sBuff( m_nCount );
154cdf0e10cSrcweir 		    while( m_nCount-- )
155cdf0e10cSrcweir 			    sBuff.append( &m_c, 1 );
156cdf0e10cSrcweir 
157cdf0e10cSrcweir             InsertString(sBuff.makeStringAndClear() );
158cdf0e10cSrcweir 	    }
159cdf0e10cSrcweir     }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir // -----------------------------------------------------------------------------
InsertControlCharacter(sal_Int16 _nControl)162cdf0e10cSrcweir void XMLCharContext::InsertControlCharacter(sal_Int16   _nControl)
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     GetImport().GetTextImport()->InsertControlCharacter( _nControl );
165cdf0e10cSrcweir }
InsertString(const::rtl::OUString & _sString)166cdf0e10cSrcweir void XMLCharContext::InsertString(const ::rtl::OUString& _sString)
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     GetImport().GetTextImport()->InsertString( _sString );
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir // ---------------------------------------------------------------------
172cdf0e10cSrcweir 
173cdf0e10cSrcweir /** import start of reference (<text:reference-start>) */
174cdf0e10cSrcweir class XMLStartReferenceContext_Impl : public SvXMLImportContext
175cdf0e10cSrcweir {
176cdf0e10cSrcweir public:
177cdf0e10cSrcweir 	TYPEINFO();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	// Do everything in constructor. Well ...
180cdf0e10cSrcweir 	XMLStartReferenceContext_Impl (
181cdf0e10cSrcweir 		SvXMLImport& rImport,
182cdf0e10cSrcweir 		sal_uInt16 nPrefix,
183cdf0e10cSrcweir 		const OUString& rLocalName,
184cdf0e10cSrcweir 		XMLHints_Impl& rHnts,
185cdf0e10cSrcweir 		const Reference<xml::sax::XAttributeList> & xAttrList);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir     static sal_Bool FindName(
188cdf0e10cSrcweir         SvXMLImport& rImport,
189cdf0e10cSrcweir         const Reference<xml::sax::XAttributeList> & xAttrList,
190cdf0e10cSrcweir         OUString& rName);
191cdf0e10cSrcweir };
192cdf0e10cSrcweir 
193cdf0e10cSrcweir TYPEINIT1( XMLStartReferenceContext_Impl, SvXMLImportContext );
194cdf0e10cSrcweir 
XMLStartReferenceContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,XMLHints_Impl & rHints,const Reference<xml::sax::XAttributeList> & xAttrList)195cdf0e10cSrcweir XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
196cdf0e10cSrcweir 	SvXMLImport& rImport,
197cdf0e10cSrcweir 	sal_uInt16 nPrefix,
198cdf0e10cSrcweir 	const OUString& rLocalName,
199cdf0e10cSrcweir 	XMLHints_Impl& rHints,
200cdf0e10cSrcweir 	const Reference<xml::sax::XAttributeList> & xAttrList) :
201cdf0e10cSrcweir 		SvXMLImportContext(rImport, nPrefix, rLocalName)
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	OUString sName;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     if (FindName(GetImport(), xAttrList, sName))
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir 		XMLHint_Impl* pHint = new XMLReferenceHint_Impl(
208cdf0e10cSrcweir 			sName, rImport.GetTextImport()->GetCursor()->getStart() );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 		// degenerates to point reference, if no end is found!
211cdf0e10cSrcweir 		pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 		rHints.Insert(pHint, rHints.Count());
214cdf0e10cSrcweir 	}
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
FindName(SvXMLImport & rImport,const Reference<xml::sax::XAttributeList> & xAttrList,OUString & rName)217cdf0e10cSrcweir sal_Bool XMLStartReferenceContext_Impl::FindName(
218cdf0e10cSrcweir     SvXMLImport& rImport,
219cdf0e10cSrcweir     const Reference<xml::sax::XAttributeList> & xAttrList,
220cdf0e10cSrcweir     OUString& rName)
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     sal_Bool bNameOK( sal_False );
223cdf0e10cSrcweir 
224cdf0e10cSrcweir     // find name attribute first
225cdf0e10cSrcweir     const sal_Int16 nLength( xAttrList->getLength() );
226cdf0e10cSrcweir     for (sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
227cdf0e10cSrcweir     {
228cdf0e10cSrcweir         OUString sLocalName;
229cdf0e10cSrcweir         const sal_uInt16 nPrefix = rImport.GetNamespaceMap().
230cdf0e10cSrcweir             GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
231cdf0e10cSrcweir                               &sLocalName );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir         if ( (XML_NAMESPACE_TEXT == nPrefix) &&
234cdf0e10cSrcweir              IsXMLToken(sLocalName, XML_NAME)   )
235cdf0e10cSrcweir         {
236cdf0e10cSrcweir             rName = xAttrList->getValueByIndex(nAttr);
237cdf0e10cSrcweir             bNameOK = sal_True;
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir     }
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     return bNameOK;
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir // ---------------------------------------------------------------------
245cdf0e10cSrcweir 
246cdf0e10cSrcweir /** import end of reference (<text:reference-end>) */
247cdf0e10cSrcweir class XMLEndReferenceContext_Impl : public SvXMLImportContext
248cdf0e10cSrcweir {
249cdf0e10cSrcweir public:
250cdf0e10cSrcweir 	TYPEINFO();
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	// Do everything in constructor. Well ...
253cdf0e10cSrcweir 	XMLEndReferenceContext_Impl(
254cdf0e10cSrcweir 		SvXMLImport& rImport,
255cdf0e10cSrcweir 		sal_uInt16 nPrefix,
256cdf0e10cSrcweir 		const OUString& rLocalName,
257cdf0e10cSrcweir 		XMLHints_Impl& rHnts,
258cdf0e10cSrcweir 		const Reference<xml::sax::XAttributeList> & xAttrList);
259cdf0e10cSrcweir };
260cdf0e10cSrcweir 
261cdf0e10cSrcweir TYPEINIT1( XMLEndReferenceContext_Impl, SvXMLImportContext );
262cdf0e10cSrcweir 
XMLEndReferenceContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,XMLHints_Impl & rHints,const Reference<xml::sax::XAttributeList> & xAttrList)263cdf0e10cSrcweir XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
264cdf0e10cSrcweir 	SvXMLImport& rImport,
265cdf0e10cSrcweir 	sal_uInt16 nPrefix,
266cdf0e10cSrcweir 	const OUString& rLocalName,
267cdf0e10cSrcweir 	XMLHints_Impl& rHints,
268cdf0e10cSrcweir 	const Reference<xml::sax::XAttributeList> & xAttrList) :
269cdf0e10cSrcweir 		SvXMLImportContext(rImport, nPrefix, rLocalName)
270cdf0e10cSrcweir {
271cdf0e10cSrcweir 	OUString sName;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     // borrow from XMLStartReferenceContext_Impl
274cdf0e10cSrcweir     if (XMLStartReferenceContext_Impl::FindName(GetImport(), xAttrList, sName))
275cdf0e10cSrcweir 	{
276cdf0e10cSrcweir 		// search for reference start
277cdf0e10cSrcweir 		sal_uInt16 nCount = rHints.Count();
278cdf0e10cSrcweir 		for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
279cdf0e10cSrcweir 		{
280cdf0e10cSrcweir 			XMLHint_Impl *pHint = rHints[nPos];
281cdf0e10cSrcweir 			if ( pHint->IsReference() &&
282cdf0e10cSrcweir 				 sName.equals( ((XMLReferenceHint_Impl *)pHint)->GetRefName()) )
283cdf0e10cSrcweir 			{
284cdf0e10cSrcweir 				// set end and stop searching
285cdf0e10cSrcweir 				pHint->SetEnd(GetImport().GetTextImport()->
286cdf0e10cSrcweir 									 GetCursor()->getStart() );
287cdf0e10cSrcweir 				break;
288cdf0e10cSrcweir 			}
289cdf0e10cSrcweir 		}
290cdf0e10cSrcweir 		// else: no start (in this paragraph) -> ignore
291cdf0e10cSrcweir 	}
292cdf0e10cSrcweir }
293cdf0e10cSrcweir 
294cdf0e10cSrcweir // ---------------------------------------------------------------------
295cdf0e10cSrcweir 
296cdf0e10cSrcweir class XMLImpSpanContext_Impl : public SvXMLImportContext
297cdf0e10cSrcweir {
298cdf0e10cSrcweir 	const OUString sTextFrame;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 	XMLHints_Impl&	rHints;
301cdf0e10cSrcweir 	XMLStyleHint_Impl	*pHint;
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	sal_Bool&		rIgnoreLeadingSpace;
304cdf0e10cSrcweir 
305cdf0e10cSrcweir 	sal_uInt8				nStarFontsConvFlags;
306cdf0e10cSrcweir 
307cdf0e10cSrcweir public:
308cdf0e10cSrcweir 
309cdf0e10cSrcweir 	TYPEINFO();
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	XMLImpSpanContext_Impl(
312cdf0e10cSrcweir 			SvXMLImport& rImport,
313cdf0e10cSrcweir 			sal_uInt16 nPrfx,
314cdf0e10cSrcweir 			const OUString& rLName,
315cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList,
316cdf0e10cSrcweir 			XMLHints_Impl& rHnts,
317cdf0e10cSrcweir 			sal_Bool& rIgnLeadSpace
318cdf0e10cSrcweir 	,sal_uInt8				nSFConvFlags
319cdf0e10cSrcweir 						  );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir 	virtual ~XMLImpSpanContext_Impl();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	static SvXMLImportContext *CreateChildContext(
324cdf0e10cSrcweir 			SvXMLImport& rImport,
325cdf0e10cSrcweir 			sal_uInt16 nPrefix, const OUString& rLocalName,
326cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList,
327cdf0e10cSrcweir 			sal_uInt16 nToken, XMLHints_Impl& rHnts,
328cdf0e10cSrcweir 			sal_Bool& rIgnLeadSpace
329cdf0e10cSrcweir 	,sal_uInt8				nStarFontsConvFlags = 0
330cdf0e10cSrcweir 			 );
331cdf0e10cSrcweir 	virtual SvXMLImportContext *CreateChildContext(
332cdf0e10cSrcweir 			sal_uInt16 nPrefix, const OUString& rLocalName,
333cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList );
334cdf0e10cSrcweir 
335cdf0e10cSrcweir 	virtual void Characters( const OUString& rChars );
336cdf0e10cSrcweir };
337cdf0e10cSrcweir // ---------------------------------------------------------------------
338cdf0e10cSrcweir 
339cdf0e10cSrcweir class XMLImpHyperlinkContext_Impl : public SvXMLImportContext
340cdf0e10cSrcweir {
341*c45df7c4SOliver-Rainer Wittmann 	XMLHints_Impl&	mrHints;
342*c45df7c4SOliver-Rainer Wittmann 	XMLHyperlinkHint_Impl	*mpHint;
343cdf0e10cSrcweir 
344*c45df7c4SOliver-Rainer Wittmann 	sal_Bool&		mrbIgnoreLeadingSpace;
345cdf0e10cSrcweir 
346cdf0e10cSrcweir public:
347cdf0e10cSrcweir 
348cdf0e10cSrcweir 	TYPEINFO();
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	XMLImpHyperlinkContext_Impl(
351cdf0e10cSrcweir 			SvXMLImport& rImport,
352cdf0e10cSrcweir 			sal_uInt16 nPrfx,
353cdf0e10cSrcweir 			const OUString& rLName,
354cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList,
355cdf0e10cSrcweir 			XMLHints_Impl& rHnts,
356cdf0e10cSrcweir 			sal_Bool& rIgnLeadSpace );
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	virtual ~XMLImpHyperlinkContext_Impl();
359cdf0e10cSrcweir 
360cdf0e10cSrcweir 	virtual SvXMLImportContext *CreateChildContext(
361cdf0e10cSrcweir 			sal_uInt16 nPrefix, const OUString& rLocalName,
362cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList );
363cdf0e10cSrcweir 
364cdf0e10cSrcweir 	virtual void Characters( const OUString& rChars );
365cdf0e10cSrcweir };
366cdf0e10cSrcweir 
367cdf0e10cSrcweir TYPEINIT1( XMLImpHyperlinkContext_Impl, SvXMLImportContext );
368cdf0e10cSrcweir 
XMLImpHyperlinkContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,XMLHints_Impl & rHnts,sal_Bool & rIgnLeadSpace)369cdf0e10cSrcweir XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
370cdf0e10cSrcweir     SvXMLImport& rImport,
371cdf0e10cSrcweir     sal_uInt16 nPrfx,
372cdf0e10cSrcweir     const OUString& rLName,
373cdf0e10cSrcweir     const Reference< xml::sax::XAttributeList > & xAttrList,
374cdf0e10cSrcweir     XMLHints_Impl& rHnts,
375*c45df7c4SOliver-Rainer Wittmann     sal_Bool& rIgnLeadSpace )
376*c45df7c4SOliver-Rainer Wittmann     : SvXMLImportContext( rImport, nPrfx, rLName )
377*c45df7c4SOliver-Rainer Wittmann     , mrHints( rHnts )
378*c45df7c4SOliver-Rainer Wittmann     , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) )
379*c45df7c4SOliver-Rainer Wittmann     , mrbIgnoreLeadingSpace( rIgnLeadSpace )
380cdf0e10cSrcweir {
381cdf0e10cSrcweir     OUString sShow;
382*c45df7c4SOliver-Rainer Wittmann     const SvXMLTokenMap& rTokenMap = GetImport().GetTextImport()->GetTextHyperlinkAttrTokenMap();
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
385cdf0e10cSrcweir     for ( sal_Int16 i = 0; i < nAttrCount; i++ )
386cdf0e10cSrcweir     {
387cdf0e10cSrcweir         const OUString& rAttrName = xAttrList->getNameByIndex( i );
388cdf0e10cSrcweir         const OUString& rValue = xAttrList->getValueByIndex( i );
389cdf0e10cSrcweir 
390cdf0e10cSrcweir         OUString aLocalName;
391*c45df7c4SOliver-Rainer Wittmann         const sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
392cdf0e10cSrcweir         switch (rTokenMap.Get( nPrefix, aLocalName ))
393cdf0e10cSrcweir         {
394cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_HREF:
395*c45df7c4SOliver-Rainer Wittmann             mpHint->SetHRef( GetImport().GetAbsoluteReference( rValue ) );
396cdf0e10cSrcweir             break;
397cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_NAME:
398*c45df7c4SOliver-Rainer Wittmann             mpHint->SetName( rValue );
399cdf0e10cSrcweir             break;
400cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_TARGET_FRAME:
401*c45df7c4SOliver-Rainer Wittmann             mpHint->SetTargetFrameName( rValue );
402cdf0e10cSrcweir             break;
403cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_SHOW:
404cdf0e10cSrcweir             sShow = rValue;
405cdf0e10cSrcweir             break;
406cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_STYLE_NAME:
407*c45df7c4SOliver-Rainer Wittmann             mpHint->SetStyleName( rValue );
408cdf0e10cSrcweir             break;
409cdf0e10cSrcweir         case XML_TOK_TEXT_HYPERLINK_VIS_STYLE_NAME:
410*c45df7c4SOliver-Rainer Wittmann             mpHint->SetVisitedStyleName( rValue );
411cdf0e10cSrcweir             break;
412cdf0e10cSrcweir         }
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir 
415*c45df7c4SOliver-Rainer Wittmann 	if( sShow.getLength() && !mpHint->GetTargetFrameName().getLength() )
416cdf0e10cSrcweir 	{
417cdf0e10cSrcweir 		if( IsXMLToken( sShow, XML_NEW ) )
418*c45df7c4SOliver-Rainer Wittmann 			mpHint->SetTargetFrameName(
419cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("_blank" ) ) );
420cdf0e10cSrcweir 		else if( IsXMLToken( sShow, XML_REPLACE ) )
421*c45df7c4SOliver-Rainer Wittmann 			mpHint->SetTargetFrameName(
422cdf0e10cSrcweir 					OUString( RTL_CONSTASCII_USTRINGPARAM("_self" ) ) );
423cdf0e10cSrcweir 	}
424*c45df7c4SOliver-Rainer Wittmann 
425*c45df7c4SOliver-Rainer Wittmann     if ( mpHint->GetHRef().isEmpty() )
426*c45df7c4SOliver-Rainer Wittmann     {
427*c45df7c4SOliver-Rainer Wittmann         // hyperlink without an URL is not imported.
428*c45df7c4SOliver-Rainer Wittmann         delete mpHint;
429*c45df7c4SOliver-Rainer Wittmann         mpHint = NULL;
430*c45df7c4SOliver-Rainer Wittmann     }
431*c45df7c4SOliver-Rainer Wittmann     else
432*c45df7c4SOliver-Rainer Wittmann     {
433*c45df7c4SOliver-Rainer Wittmann         mrHints.Insert( mpHint, mrHints.Count() );
434*c45df7c4SOliver-Rainer Wittmann     }
435cdf0e10cSrcweir }
436cdf0e10cSrcweir 
~XMLImpHyperlinkContext_Impl()437cdf0e10cSrcweir XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
438cdf0e10cSrcweir {
439*c45df7c4SOliver-Rainer Wittmann 	if( mpHint != NULL )
440*c45df7c4SOliver-Rainer Wittmann 		mpHint->SetEnd( GetImport().GetTextImport()
441cdf0e10cSrcweir 							->GetCursorAsRange()->getStart() );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)444cdf0e10cSrcweir SvXMLImportContext *XMLImpHyperlinkContext_Impl::CreateChildContext(
445cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
446cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList )
447cdf0e10cSrcweir {
448cdf0e10cSrcweir 	if ( (nPrefix == XML_NAMESPACE_OFFICE) &&
449cdf0e10cSrcweir 		 IsXMLToken(rLocalName, XML_EVENT_LISTENERS) )
450cdf0e10cSrcweir 	{
451cdf0e10cSrcweir 		XMLEventsImportContext* pCtxt = new XMLEventsImportContext(
452cdf0e10cSrcweir 			GetImport(), nPrefix, rLocalName);
453*c45df7c4SOliver-Rainer Wittmann 		mpHint->SetEventsContext(pCtxt);
454cdf0e10cSrcweir 		return pCtxt;
455cdf0e10cSrcweir 	}
456cdf0e10cSrcweir 	else
457cdf0e10cSrcweir 	{
458cdf0e10cSrcweir 		const SvXMLTokenMap& rTokenMap =
459cdf0e10cSrcweir 			GetImport().GetTextImport()->GetTextPElemTokenMap();
460cdf0e10cSrcweir 		sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 		return XMLImpSpanContext_Impl::CreateChildContext(
463cdf0e10cSrcweir 			GetImport(), nPrefix, rLocalName, xAttrList,
464*c45df7c4SOliver-Rainer Wittmann 			nToken, mrHints, mrbIgnoreLeadingSpace );
465cdf0e10cSrcweir 	}
466cdf0e10cSrcweir }
467cdf0e10cSrcweir 
Characters(const OUString & rChars)468cdf0e10cSrcweir void XMLImpHyperlinkContext_Impl::Characters( const OUString& rChars )
469cdf0e10cSrcweir {
470*c45df7c4SOliver-Rainer Wittmann 	GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
471cdf0e10cSrcweir }
472cdf0e10cSrcweir 
473cdf0e10cSrcweir // ---------------------------------------------------------------------
474cdf0e10cSrcweir 
475cdf0e10cSrcweir class XMLImpRubyBaseContext_Impl : public SvXMLImportContext
476cdf0e10cSrcweir {
477cdf0e10cSrcweir 	XMLHints_Impl&	rHints;
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 	sal_Bool&		rIgnoreLeadingSpace;
480cdf0e10cSrcweir 
481cdf0e10cSrcweir public:
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	TYPEINFO();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 	XMLImpRubyBaseContext_Impl(
486cdf0e10cSrcweir 			SvXMLImport& rImport,
487cdf0e10cSrcweir 			sal_uInt16 nPrfx,
488cdf0e10cSrcweir 			const OUString& rLName,
489cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList,
490cdf0e10cSrcweir 			XMLHints_Impl& rHnts,
491cdf0e10cSrcweir 			sal_Bool& rIgnLeadSpace );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir 	virtual ~XMLImpRubyBaseContext_Impl();
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	virtual SvXMLImportContext *CreateChildContext(
496cdf0e10cSrcweir 			sal_uInt16 nPrefix, const OUString& rLocalName,
497cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList );
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 	virtual void Characters( const OUString& rChars );
500cdf0e10cSrcweir };
501cdf0e10cSrcweir 
502cdf0e10cSrcweir TYPEINIT1( XMLImpRubyBaseContext_Impl, SvXMLImportContext );
503cdf0e10cSrcweir 
XMLImpRubyBaseContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> &,XMLHints_Impl & rHnts,sal_Bool & rIgnLeadSpace)504cdf0e10cSrcweir XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
505cdf0e10cSrcweir 		SvXMLImport& rImport,
506cdf0e10cSrcweir 		sal_uInt16 nPrfx,
507cdf0e10cSrcweir 		const OUString& rLName,
508cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > &,
509cdf0e10cSrcweir 		XMLHints_Impl& rHnts,
510cdf0e10cSrcweir 		sal_Bool& rIgnLeadSpace ) :
511cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName ),
512cdf0e10cSrcweir 	rHints( rHnts ),
513cdf0e10cSrcweir 	rIgnoreLeadingSpace( rIgnLeadSpace )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir }
516cdf0e10cSrcweir 
~XMLImpRubyBaseContext_Impl()517cdf0e10cSrcweir XMLImpRubyBaseContext_Impl::~XMLImpRubyBaseContext_Impl()
518cdf0e10cSrcweir {
519cdf0e10cSrcweir }
520cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)521cdf0e10cSrcweir SvXMLImportContext *XMLImpRubyBaseContext_Impl::CreateChildContext(
522cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
523cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
526cdf0e10cSrcweir 		GetImport().GetTextImport()->GetTextPElemTokenMap();
527cdf0e10cSrcweir 	sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
528cdf0e10cSrcweir 
529cdf0e10cSrcweir 	return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), nPrefix,
530cdf0e10cSrcweir 													   rLocalName, xAttrList,
531cdf0e10cSrcweir 							   nToken, rHints, rIgnoreLeadingSpace );
532cdf0e10cSrcweir }
533cdf0e10cSrcweir 
Characters(const OUString & rChars)534cdf0e10cSrcweir void XMLImpRubyBaseContext_Impl::Characters( const OUString& rChars )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir 	GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
537cdf0e10cSrcweir }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir // ---------------------------------------------------------------------
540cdf0e10cSrcweir 
541cdf0e10cSrcweir class XMLImpRubyContext_Impl : public SvXMLImportContext
542cdf0e10cSrcweir {
543cdf0e10cSrcweir     XMLHints_Impl&  rHints;
544cdf0e10cSrcweir 
545cdf0e10cSrcweir     sal_Bool&       rIgnoreLeadingSpace;
546cdf0e10cSrcweir 
547cdf0e10cSrcweir     Reference < XTextRange > m_xStart;
548cdf0e10cSrcweir     OUString        m_sStyleName;
549cdf0e10cSrcweir     OUString        m_sTextStyleName;
550cdf0e10cSrcweir     OUString        m_sText;
551cdf0e10cSrcweir 
552cdf0e10cSrcweir public:
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     TYPEINFO();
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     XMLImpRubyContext_Impl(
557cdf0e10cSrcweir             SvXMLImport& rImport,
558cdf0e10cSrcweir             sal_uInt16 nPrfx,
559cdf0e10cSrcweir             const OUString& rLName,
560cdf0e10cSrcweir             const Reference< xml::sax::XAttributeList > & xAttrList,
561cdf0e10cSrcweir             XMLHints_Impl& rHnts,
562cdf0e10cSrcweir             sal_Bool& rIgnLeadSpace );
563cdf0e10cSrcweir 
564cdf0e10cSrcweir     virtual ~XMLImpRubyContext_Impl();
565cdf0e10cSrcweir 
566cdf0e10cSrcweir     virtual SvXMLImportContext *CreateChildContext(
567cdf0e10cSrcweir             sal_uInt16 nPrefix, const OUString& rLocalName,
568cdf0e10cSrcweir             const Reference< xml::sax::XAttributeList > & xAttrList );
569cdf0e10cSrcweir 
SetTextStyleName(const OUString & s)570cdf0e10cSrcweir     void SetTextStyleName( const OUString& s ) { m_sTextStyleName = s; }
AppendText(const OUString & s)571cdf0e10cSrcweir     void AppendText( const OUString& s ) { m_sText += s; }
572cdf0e10cSrcweir };
573cdf0e10cSrcweir 
574cdf0e10cSrcweir // ---------------------------------------------------------------------
575cdf0e10cSrcweir 
576cdf0e10cSrcweir class XMLImpRubyTextContext_Impl : public SvXMLImportContext
577cdf0e10cSrcweir {
578cdf0e10cSrcweir     XMLImpRubyContext_Impl & m_rRubyContext;
579cdf0e10cSrcweir 
580cdf0e10cSrcweir public:
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 	TYPEINFO();
583cdf0e10cSrcweir 
584cdf0e10cSrcweir 	XMLImpRubyTextContext_Impl(
585cdf0e10cSrcweir 			SvXMLImport& rImport,
586cdf0e10cSrcweir 			sal_uInt16 nPrfx,
587cdf0e10cSrcweir 			const OUString& rLName,
588cdf0e10cSrcweir 			const Reference< xml::sax::XAttributeList > & xAttrList,
589cdf0e10cSrcweir             XMLImpRubyContext_Impl & rParent );
590cdf0e10cSrcweir 
591cdf0e10cSrcweir 	virtual ~XMLImpRubyTextContext_Impl();
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	virtual void Characters( const OUString& rChars );
594cdf0e10cSrcweir };
595cdf0e10cSrcweir 
596cdf0e10cSrcweir TYPEINIT1( XMLImpRubyTextContext_Impl, SvXMLImportContext );
597cdf0e10cSrcweir 
XMLImpRubyTextContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,XMLImpRubyContext_Impl & rParent)598cdf0e10cSrcweir XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
599cdf0e10cSrcweir 		SvXMLImport& rImport,
600cdf0e10cSrcweir 		sal_uInt16 nPrfx,
601cdf0e10cSrcweir 		const OUString& rLName,
602cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
603cdf0e10cSrcweir         XMLImpRubyContext_Impl & rParent )
604cdf0e10cSrcweir     : SvXMLImportContext( rImport, nPrfx, rLName )
605cdf0e10cSrcweir 	, m_rRubyContext( rParent )
606cdf0e10cSrcweir {
607cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
608cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
609cdf0e10cSrcweir 	{
610cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
611cdf0e10cSrcweir 		const OUString& rValue = xAttrList->getValueByIndex( i );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 		OUString aLocalName;
614cdf0e10cSrcweir 		sal_uInt16 nPrefix =
615cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
616cdf0e10cSrcweir 															&aLocalName );
617cdf0e10cSrcweir 		if( XML_NAMESPACE_TEXT == nPrefix &&
618cdf0e10cSrcweir 			IsXMLToken( aLocalName, XML_STYLE_NAME ) )
619cdf0e10cSrcweir 		{
620cdf0e10cSrcweir             m_rRubyContext.SetTextStyleName( rValue );
621cdf0e10cSrcweir 			break;
622cdf0e10cSrcweir 		}
623cdf0e10cSrcweir 	}
624cdf0e10cSrcweir }
625cdf0e10cSrcweir 
~XMLImpRubyTextContext_Impl()626cdf0e10cSrcweir XMLImpRubyTextContext_Impl::~XMLImpRubyTextContext_Impl()
627cdf0e10cSrcweir {
628cdf0e10cSrcweir }
629cdf0e10cSrcweir 
Characters(const OUString & rChars)630cdf0e10cSrcweir void XMLImpRubyTextContext_Impl::Characters( const OUString& rChars )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir     m_rRubyContext.AppendText( rChars );
633cdf0e10cSrcweir }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir // ---------------------------------------------------------------------
636cdf0e10cSrcweir 
637cdf0e10cSrcweir TYPEINIT1( XMLImpRubyContext_Impl, SvXMLImportContext );
638cdf0e10cSrcweir 
XMLImpRubyContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,XMLHints_Impl & rHnts,sal_Bool & rIgnLeadSpace)639cdf0e10cSrcweir XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
640cdf0e10cSrcweir 		SvXMLImport& rImport,
641cdf0e10cSrcweir 		sal_uInt16 nPrfx,
642cdf0e10cSrcweir 		const OUString& rLName,
643cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
644cdf0e10cSrcweir 		XMLHints_Impl& rHnts,
645cdf0e10cSrcweir 		sal_Bool& rIgnLeadSpace ) :
646cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName ),
647cdf0e10cSrcweir 	rHints( rHnts ),
648cdf0e10cSrcweir 	rIgnoreLeadingSpace( rIgnLeadSpace )
649cdf0e10cSrcweir     , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
652cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
653cdf0e10cSrcweir 	{
654cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
655cdf0e10cSrcweir 		const OUString& rValue = xAttrList->getValueByIndex( i );
656cdf0e10cSrcweir 
657cdf0e10cSrcweir 		OUString aLocalName;
658cdf0e10cSrcweir 		sal_uInt16 nPrefix =
659cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
660cdf0e10cSrcweir 															&aLocalName );
661cdf0e10cSrcweir 		if( XML_NAMESPACE_TEXT == nPrefix &&
662cdf0e10cSrcweir 			IsXMLToken( aLocalName, XML_STYLE_NAME ) )
663cdf0e10cSrcweir 		{
664cdf0e10cSrcweir 			m_sStyleName = rValue;
665cdf0e10cSrcweir 			break;
666cdf0e10cSrcweir 		}
667cdf0e10cSrcweir 	}
668cdf0e10cSrcweir }
669cdf0e10cSrcweir 
~XMLImpRubyContext_Impl()670cdf0e10cSrcweir XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl()
671cdf0e10cSrcweir {
672cdf0e10cSrcweir 	const UniReference < XMLTextImportHelper > xTextImport(
673cdf0e10cSrcweir 		GetImport().GetTextImport());
674cdf0e10cSrcweir 	const Reference < XTextCursor > xAttrCursor(
675cdf0e10cSrcweir 		xTextImport->GetText()->createTextCursorByRange( m_xStart ));
676cdf0e10cSrcweir     xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(),
677cdf0e10cSrcweir             sal_True);
678cdf0e10cSrcweir     xTextImport->SetRuby( GetImport(), xAttrCursor,
679cdf0e10cSrcweir          m_sStyleName, m_sTextStyleName, m_sText );
680cdf0e10cSrcweir }
681cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)682cdf0e10cSrcweir SvXMLImportContext *XMLImpRubyContext_Impl::CreateChildContext(
683cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
684cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir 	SvXMLImportContext *pContext;
687cdf0e10cSrcweir 	if( XML_NAMESPACE_TEXT == nPrefix )
688cdf0e10cSrcweir 	{
689cdf0e10cSrcweir 		if( IsXMLToken( rLocalName, XML_RUBY_BASE ) )
690cdf0e10cSrcweir 			pContext = new XMLImpRubyBaseContext_Impl( GetImport(), nPrefix,
691cdf0e10cSrcweir 													   rLocalName,
692cdf0e10cSrcweir 													   xAttrList,
693cdf0e10cSrcweir 													   rHints,
694cdf0e10cSrcweir 													   rIgnoreLeadingSpace );
695cdf0e10cSrcweir 		else if( IsXMLToken( rLocalName, XML_RUBY_TEXT ) )
696cdf0e10cSrcweir 			pContext = new XMLImpRubyTextContext_Impl( GetImport(), nPrefix,
697cdf0e10cSrcweir 													   rLocalName,
698cdf0e10cSrcweir 													   xAttrList,
699cdf0e10cSrcweir 													   *this );
700cdf0e10cSrcweir 		else
701cdf0e10cSrcweir             pContext = new SvXMLImportContext(
702cdf0e10cSrcweir                 GetImport(), nPrefix, rLocalName );
703cdf0e10cSrcweir 	}
704cdf0e10cSrcweir 	else
705cdf0e10cSrcweir 		pContext = SvXMLImportContext::CreateChildContext( nPrefix, rLocalName,
706cdf0e10cSrcweir 															xAttrList );
707cdf0e10cSrcweir 
708cdf0e10cSrcweir 	return pContext;
709cdf0e10cSrcweir }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir // ---------------------------------------------------------------------
712cdf0e10cSrcweir 
713cdf0e10cSrcweir /** for text:meta and text:meta-field
714cdf0e10cSrcweir  */
715cdf0e10cSrcweir class XMLMetaImportContextBase : public SvXMLImportContext
716cdf0e10cSrcweir {
717cdf0e10cSrcweir     XMLHints_Impl&    m_rHints;
718cdf0e10cSrcweir 
719cdf0e10cSrcweir     sal_Bool& m_rIgnoreLeadingSpace;
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     /// start position
722cdf0e10cSrcweir     Reference<XTextRange> m_xStart;
723cdf0e10cSrcweir 
724cdf0e10cSrcweir protected:
725cdf0e10cSrcweir     OUString m_XmlId;
726cdf0e10cSrcweir 
727cdf0e10cSrcweir public:
728cdf0e10cSrcweir     TYPEINFO();
729cdf0e10cSrcweir 
730cdf0e10cSrcweir     XMLMetaImportContextBase(
731cdf0e10cSrcweir         SvXMLImport& i_rImport,
732cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
733cdf0e10cSrcweir         const OUString& i_rLocalName,
734cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
735cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace );
736cdf0e10cSrcweir 
737cdf0e10cSrcweir     virtual ~XMLMetaImportContextBase();
738cdf0e10cSrcweir 
739cdf0e10cSrcweir 	virtual void StartElement(
740cdf0e10cSrcweir             const Reference<xml::sax::XAttributeList> & i_xAttrList);
741cdf0e10cSrcweir 
742cdf0e10cSrcweir     virtual void EndElement();
743cdf0e10cSrcweir 
744cdf0e10cSrcweir     virtual SvXMLImportContext *CreateChildContext(
745cdf0e10cSrcweir             sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
746cdf0e10cSrcweir             const Reference< xml::sax::XAttributeList > & i_xAttrList);
747cdf0e10cSrcweir 
748cdf0e10cSrcweir     virtual void Characters( const OUString& i_rChars );
749cdf0e10cSrcweir 
750cdf0e10cSrcweir     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
751cdf0e10cSrcweir         OUString const & i_rLocalName, OUString const & i_rValue);
752cdf0e10cSrcweir 
753cdf0e10cSrcweir     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange)
754cdf0e10cSrcweir         = 0;
755cdf0e10cSrcweir };
756cdf0e10cSrcweir 
757cdf0e10cSrcweir TYPEINIT1( XMLMetaImportContextBase, SvXMLImportContext );
758cdf0e10cSrcweir 
XMLMetaImportContextBase(SvXMLImport & i_rImport,const sal_uInt16 i_nPrefix,const OUString & i_rLocalName,XMLHints_Impl & i_rHints,sal_Bool & i_rIgnoreLeadingSpace)759cdf0e10cSrcweir XMLMetaImportContextBase::XMLMetaImportContextBase(
760cdf0e10cSrcweir         SvXMLImport& i_rImport,
761cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
762cdf0e10cSrcweir         const OUString& i_rLocalName,
763cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
764cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace )
765cdf0e10cSrcweir     : SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName )
766cdf0e10cSrcweir     , m_rHints( i_rHints )
767cdf0e10cSrcweir     , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
768cdf0e10cSrcweir     , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
769cdf0e10cSrcweir {
770cdf0e10cSrcweir }
771cdf0e10cSrcweir 
~XMLMetaImportContextBase()772cdf0e10cSrcweir XMLMetaImportContextBase::~XMLMetaImportContextBase()
773cdf0e10cSrcweir {
774cdf0e10cSrcweir }
775cdf0e10cSrcweir 
StartElement(const Reference<xml::sax::XAttributeList> & i_xAttrList)776cdf0e10cSrcweir void XMLMetaImportContextBase::StartElement(
777cdf0e10cSrcweir         const Reference<xml::sax::XAttributeList> & i_xAttrList)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir     const sal_Int16 nAttrCount(i_xAttrList.is() ? i_xAttrList->getLength() : 0);
780cdf0e10cSrcweir     for ( sal_Int16 i = 0; i < nAttrCount; ++i )
781cdf0e10cSrcweir     {
782cdf0e10cSrcweir         const OUString& rAttrName( i_xAttrList->getNameByIndex( i ) );
783cdf0e10cSrcweir         const OUString& rValue( i_xAttrList->getValueByIndex( i ) );
784cdf0e10cSrcweir 
785cdf0e10cSrcweir         OUString sLocalName;
786cdf0e10cSrcweir         const sal_uInt16 nPrefix(
787cdf0e10cSrcweir             GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
788cdf0e10cSrcweir                                                             &sLocalName ));
789cdf0e10cSrcweir         ProcessAttribute(nPrefix, sLocalName, rValue);
790cdf0e10cSrcweir     }
791cdf0e10cSrcweir }
792cdf0e10cSrcweir 
EndElement()793cdf0e10cSrcweir void XMLMetaImportContextBase::EndElement()
794cdf0e10cSrcweir {
795cdf0e10cSrcweir     OSL_ENSURE(m_xStart.is(), "no mxStart?");
796cdf0e10cSrcweir     if (!m_xStart.is()) return;
797cdf0e10cSrcweir 
798cdf0e10cSrcweir     const Reference<XTextRange> xEndRange(
799cdf0e10cSrcweir         GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
800cdf0e10cSrcweir 
801cdf0e10cSrcweir     // create range for insertion
802cdf0e10cSrcweir     const Reference<XTextCursor> xInsertionCursor(
803cdf0e10cSrcweir         GetImport().GetTextImport()->GetText()->createTextCursorByRange(
804cdf0e10cSrcweir             xEndRange) );
805cdf0e10cSrcweir     xInsertionCursor->gotoRange(m_xStart, sal_True);
806cdf0e10cSrcweir 
807cdf0e10cSrcweir     const Reference<XTextRange> xInsertionRange(xInsertionCursor, UNO_QUERY);
808cdf0e10cSrcweir 
809cdf0e10cSrcweir     InsertMeta(xInsertionRange);
810cdf0e10cSrcweir }
811cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 i_nPrefix,const OUString & i_rLocalName,const Reference<xml::sax::XAttributeList> & i_xAttrList)812cdf0e10cSrcweir SvXMLImportContext * XMLMetaImportContextBase::CreateChildContext(
813cdf0e10cSrcweir             sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
814cdf0e10cSrcweir             const Reference< xml::sax::XAttributeList > & i_xAttrList )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir     const SvXMLTokenMap& rTokenMap(
817cdf0e10cSrcweir         GetImport().GetTextImport()->GetTextPElemTokenMap() );
818cdf0e10cSrcweir     const sal_uInt16 nToken( rTokenMap.Get( i_nPrefix, i_rLocalName ) );
819cdf0e10cSrcweir 
820cdf0e10cSrcweir     return XMLImpSpanContext_Impl::CreateChildContext( GetImport(), i_nPrefix,
821cdf0e10cSrcweir         i_rLocalName, i_xAttrList, nToken, m_rHints, m_rIgnoreLeadingSpace );
822cdf0e10cSrcweir }
823cdf0e10cSrcweir 
Characters(const OUString & i_rChars)824cdf0e10cSrcweir void XMLMetaImportContextBase::Characters( const OUString& i_rChars )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir     GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
827cdf0e10cSrcweir }
828cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 const i_nPrefix,OUString const & i_rLocalName,OUString const & i_rValue)829cdf0e10cSrcweir void XMLMetaImportContextBase::ProcessAttribute(sal_uInt16 const i_nPrefix,
830cdf0e10cSrcweir     OUString const & i_rLocalName, OUString const & i_rValue)
831cdf0e10cSrcweir {
832cdf0e10cSrcweir     if ( (XML_NAMESPACE_XML == i_nPrefix) && IsXMLToken(i_rLocalName, XML_ID) )
833cdf0e10cSrcweir     {
834cdf0e10cSrcweir         m_XmlId = i_rValue;
835cdf0e10cSrcweir     }
836cdf0e10cSrcweir }
837cdf0e10cSrcweir 
838cdf0e10cSrcweir 
839cdf0e10cSrcweir // ---------------------------------------------------------------------
840cdf0e10cSrcweir 
841cdf0e10cSrcweir /** text:meta */
842cdf0e10cSrcweir class XMLMetaImportContext : public XMLMetaImportContextBase
843cdf0e10cSrcweir {
844cdf0e10cSrcweir     // RDFa
845cdf0e10cSrcweir     bool m_bHaveAbout;
846cdf0e10cSrcweir     ::rtl::OUString m_sAbout;
847cdf0e10cSrcweir     ::rtl::OUString m_sProperty;
848cdf0e10cSrcweir     ::rtl::OUString m_sContent;
849cdf0e10cSrcweir     ::rtl::OUString m_sDatatype;
850cdf0e10cSrcweir 
851cdf0e10cSrcweir public:
852cdf0e10cSrcweir     TYPEINFO();
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     XMLMetaImportContext(
855cdf0e10cSrcweir         SvXMLImport& i_rImport,
856cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
857cdf0e10cSrcweir         const OUString& i_rLocalName,
858cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
859cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace );
860cdf0e10cSrcweir 
861cdf0e10cSrcweir     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
862cdf0e10cSrcweir         OUString const & i_rLocalName, OUString const & i_rValue);
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
865cdf0e10cSrcweir };
866cdf0e10cSrcweir 
867cdf0e10cSrcweir TYPEINIT1( XMLMetaImportContext, XMLMetaImportContextBase );
868cdf0e10cSrcweir 
XMLMetaImportContext(SvXMLImport & i_rImport,const sal_uInt16 i_nPrefix,const OUString & i_rLocalName,XMLHints_Impl & i_rHints,sal_Bool & i_rIgnoreLeadingSpace)869cdf0e10cSrcweir XMLMetaImportContext::XMLMetaImportContext(
870cdf0e10cSrcweir         SvXMLImport& i_rImport,
871cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
872cdf0e10cSrcweir         const OUString& i_rLocalName,
873cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
874cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace )
875cdf0e10cSrcweir     : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
876cdf0e10cSrcweir             i_rHints, i_rIgnoreLeadingSpace )
877cdf0e10cSrcweir     , m_bHaveAbout(false)
878cdf0e10cSrcweir {
879cdf0e10cSrcweir }
880cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 const i_nPrefix,OUString const & i_rLocalName,OUString const & i_rValue)881cdf0e10cSrcweir void XMLMetaImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
882cdf0e10cSrcweir     OUString const & i_rLocalName, OUString const & i_rValue)
883cdf0e10cSrcweir {
884cdf0e10cSrcweir     if ( XML_NAMESPACE_XHTML == i_nPrefix )
885cdf0e10cSrcweir     {
886cdf0e10cSrcweir         // RDFa
887cdf0e10cSrcweir         if ( IsXMLToken( i_rLocalName, XML_ABOUT) )
888cdf0e10cSrcweir         {
889cdf0e10cSrcweir             m_sAbout = i_rValue;
890cdf0e10cSrcweir             m_bHaveAbout = true;
891cdf0e10cSrcweir         }
892cdf0e10cSrcweir         else if ( IsXMLToken( i_rLocalName, XML_PROPERTY) )
893cdf0e10cSrcweir         {
894cdf0e10cSrcweir             m_sProperty = i_rValue;
895cdf0e10cSrcweir         }
896cdf0e10cSrcweir         else if ( IsXMLToken( i_rLocalName, XML_CONTENT) )
897cdf0e10cSrcweir         {
898cdf0e10cSrcweir             m_sContent = i_rValue;
899cdf0e10cSrcweir         }
900cdf0e10cSrcweir         else if ( IsXMLToken( i_rLocalName, XML_DATATYPE) )
901cdf0e10cSrcweir         {
902cdf0e10cSrcweir             m_sDatatype = i_rValue;
903cdf0e10cSrcweir         }
904cdf0e10cSrcweir     }
905cdf0e10cSrcweir     else
906cdf0e10cSrcweir     {
907cdf0e10cSrcweir         XMLMetaImportContextBase::ProcessAttribute(
908cdf0e10cSrcweir             i_nPrefix, i_rLocalName, i_rValue);
909cdf0e10cSrcweir     }
910cdf0e10cSrcweir }
911cdf0e10cSrcweir 
InsertMeta(const Reference<XTextRange> & i_xInsertionRange)912cdf0e10cSrcweir void XMLMetaImportContext::InsertMeta(
913cdf0e10cSrcweir     const Reference<XTextRange> & i_xInsertionRange)
914cdf0e10cSrcweir {
915cdf0e10cSrcweir     OSL_ENSURE(!m_bHaveAbout == !m_sProperty.getLength(),
916cdf0e10cSrcweir         "XMLMetaImportContext::InsertMeta: invalid RDFa?");
917cdf0e10cSrcweir     if (m_XmlId.getLength() || (m_bHaveAbout && m_sProperty.getLength()))
918cdf0e10cSrcweir     {
919cdf0e10cSrcweir         // insert mark
920cdf0e10cSrcweir         const uno::Reference<rdf::XMetadatable> xMeta(
921cdf0e10cSrcweir             XMLTextMarkImportContext::CreateAndInsertMark(
922cdf0e10cSrcweir                 GetImport(),
923cdf0e10cSrcweir                 OUString::createFromAscii(
924cdf0e10cSrcweir                     "com.sun.star.text.InContentMetadata"),
925cdf0e10cSrcweir                 OUString(),
926cdf0e10cSrcweir                 i_xInsertionRange, m_XmlId),
927cdf0e10cSrcweir             uno::UNO_QUERY);
928cdf0e10cSrcweir         OSL_ENSURE(xMeta.is(), "cannot insert Meta?");
929cdf0e10cSrcweir 
930cdf0e10cSrcweir         if (xMeta.is() && m_bHaveAbout)
931cdf0e10cSrcweir         {
932cdf0e10cSrcweir             GetImport().AddRDFa(xMeta,
933cdf0e10cSrcweir                 m_sAbout, m_sProperty, m_sContent, m_sDatatype);
934cdf0e10cSrcweir         }
935cdf0e10cSrcweir     }
936cdf0e10cSrcweir     else
937cdf0e10cSrcweir     {
938cdf0e10cSrcweir         OSL_TRACE("invalid <text:meta>: no xml:id, no valid RDFa");
939cdf0e10cSrcweir     }
940cdf0e10cSrcweir }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir // ---------------------------------------------------------------------
943cdf0e10cSrcweir 
944cdf0e10cSrcweir /** text:meta-field */
945cdf0e10cSrcweir class XMLMetaFieldImportContext : public XMLMetaImportContextBase
946cdf0e10cSrcweir {
947cdf0e10cSrcweir     OUString m_DataStyleName;
948cdf0e10cSrcweir 
949cdf0e10cSrcweir public:
950cdf0e10cSrcweir     TYPEINFO();
951cdf0e10cSrcweir 
952cdf0e10cSrcweir     XMLMetaFieldImportContext(
953cdf0e10cSrcweir         SvXMLImport& i_rImport,
954cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
955cdf0e10cSrcweir         const OUString& i_rLocalName,
956cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
957cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace );
958cdf0e10cSrcweir 
959cdf0e10cSrcweir     virtual void ProcessAttribute(sal_uInt16 const i_nPrefix,
960cdf0e10cSrcweir         OUString const & i_rLocalName, OUString const & i_rValue);
961cdf0e10cSrcweir 
962cdf0e10cSrcweir     virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange);
963cdf0e10cSrcweir };
964cdf0e10cSrcweir 
965cdf0e10cSrcweir TYPEINIT1( XMLMetaFieldImportContext, XMLMetaImportContextBase );
966cdf0e10cSrcweir 
XMLMetaFieldImportContext(SvXMLImport & i_rImport,const sal_uInt16 i_nPrefix,const OUString & i_rLocalName,XMLHints_Impl & i_rHints,sal_Bool & i_rIgnoreLeadingSpace)967cdf0e10cSrcweir XMLMetaFieldImportContext::XMLMetaFieldImportContext(
968cdf0e10cSrcweir         SvXMLImport& i_rImport,
969cdf0e10cSrcweir         const sal_uInt16 i_nPrefix,
970cdf0e10cSrcweir         const OUString& i_rLocalName,
971cdf0e10cSrcweir         XMLHints_Impl& i_rHints,
972cdf0e10cSrcweir         sal_Bool & i_rIgnoreLeadingSpace )
973cdf0e10cSrcweir     : XMLMetaImportContextBase( i_rImport, i_nPrefix, i_rLocalName,
974cdf0e10cSrcweir             i_rHints, i_rIgnoreLeadingSpace )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir }
977cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 const i_nPrefix,OUString const & i_rLocalName,OUString const & i_rValue)978cdf0e10cSrcweir void XMLMetaFieldImportContext::ProcessAttribute(sal_uInt16 const i_nPrefix,
979cdf0e10cSrcweir     OUString const & i_rLocalName, OUString const & i_rValue)
980cdf0e10cSrcweir {
981cdf0e10cSrcweir     if ( XML_NAMESPACE_STYLE == i_nPrefix &&
982cdf0e10cSrcweir          IsXMLToken( i_rLocalName, XML_DATA_STYLE_NAME ) )
983cdf0e10cSrcweir     {
984cdf0e10cSrcweir         m_DataStyleName = i_rValue;
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir     else
987cdf0e10cSrcweir     {
988cdf0e10cSrcweir         XMLMetaImportContextBase::ProcessAttribute(
989cdf0e10cSrcweir             i_nPrefix, i_rLocalName, i_rValue);
990cdf0e10cSrcweir     }
991cdf0e10cSrcweir }
992cdf0e10cSrcweir 
InsertMeta(const Reference<XTextRange> & i_xInsertionRange)993cdf0e10cSrcweir void XMLMetaFieldImportContext::InsertMeta(
994cdf0e10cSrcweir     const Reference<XTextRange> & i_xInsertionRange)
995cdf0e10cSrcweir {
996cdf0e10cSrcweir     if (m_XmlId.getLength()) // valid?
997cdf0e10cSrcweir     {
998cdf0e10cSrcweir         // insert mark
999cdf0e10cSrcweir         const Reference<XPropertySet> xPropertySet(
1000cdf0e10cSrcweir             XMLTextMarkImportContext::CreateAndInsertMark(
1001cdf0e10cSrcweir                 GetImport(),
1002cdf0e10cSrcweir                 OUString::createFromAscii(
1003cdf0e10cSrcweir                     "com.sun.star.text.textfield.MetadataField"),
1004cdf0e10cSrcweir                 OUString(),
1005cdf0e10cSrcweir                 i_xInsertionRange, m_XmlId),
1006cdf0e10cSrcweir             UNO_QUERY);
1007cdf0e10cSrcweir         OSL_ENSURE(xPropertySet.is(), "cannot insert MetaField?");
1008cdf0e10cSrcweir         if (!xPropertySet.is()) return;
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir         if (m_DataStyleName.getLength())
1011cdf0e10cSrcweir         {
1012cdf0e10cSrcweir             sal_Bool isDefaultLanguage(sal_True);
1013cdf0e10cSrcweir 
1014cdf0e10cSrcweir             const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
1015cdf0e10cSrcweir                                    m_DataStyleName, & isDefaultLanguage) );
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir             if (-1 != nKey)
1018cdf0e10cSrcweir             {
1019cdf0e10cSrcweir                 static ::rtl::OUString sPropertyIsFixedLanguage(
1020cdf0e10cSrcweir                     ::rtl::OUString::createFromAscii("IsFixedLanguage") );
1021cdf0e10cSrcweir                 Any any;
1022cdf0e10cSrcweir                 any <<= nKey;
1023cdf0e10cSrcweir                 xPropertySet->setPropertyValue(
1024cdf0e10cSrcweir                     OUString::createFromAscii("NumberFormat"), any);
1025cdf0e10cSrcweir                 if ( xPropertySet->getPropertySetInfo()->
1026cdf0e10cSrcweir                         hasPropertyByName( sPropertyIsFixedLanguage ) )
1027cdf0e10cSrcweir                 {
1028cdf0e10cSrcweir                     any <<= static_cast<bool>(!isDefaultLanguage);
1029cdf0e10cSrcweir                     xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
1030cdf0e10cSrcweir                         any );
1031cdf0e10cSrcweir                 }
1032cdf0e10cSrcweir             }
1033cdf0e10cSrcweir         }
1034cdf0e10cSrcweir     }
1035cdf0e10cSrcweir     else
1036cdf0e10cSrcweir     {
1037cdf0e10cSrcweir         OSL_TRACE("invalid <text:meta-field>: no xml:id");
1038cdf0e10cSrcweir     }
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir 
1042cdf0e10cSrcweir // ---------------------------------------------------------------------
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 
1045cdf0e10cSrcweir /**
1046cdf0e10cSrcweir  * Process index marks.
1047cdf0e10cSrcweir  *
1048cdf0e10cSrcweir  * All *-mark-end index marks should instantiate *this* class (because
1049cdf0e10cSrcweir  * it doesn't process attributes other than ID), while the *-mark and
1050cdf0e10cSrcweir  * *-mark-start classes should instantiate the apporpiate subclasses.
1051cdf0e10cSrcweir  */
1052cdf0e10cSrcweir class XMLIndexMarkImportContext_Impl : public SvXMLImportContext
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir 	const OUString sAlternativeText;
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir 	XMLHints_Impl& rHints;
1057cdf0e10cSrcweir 	const enum XMLTextPElemTokens eToken;
1058cdf0e10cSrcweir 	OUString sID;
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir public:
1061cdf0e10cSrcweir 	TYPEINFO();
1062cdf0e10cSrcweir 
1063cdf0e10cSrcweir 	XMLIndexMarkImportContext_Impl(
1064cdf0e10cSrcweir 		SvXMLImport& rImport,
1065cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1066cdf0e10cSrcweir 		const OUString& rLocalName,
1067cdf0e10cSrcweir 		enum XMLTextPElemTokens nTok,
1068cdf0e10cSrcweir 		XMLHints_Impl& rHnts);
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir 	void StartElement(const Reference<xml::sax::XAttributeList> & xAttrList);
1071cdf0e10cSrcweir 
1072cdf0e10cSrcweir protected:
1073cdf0e10cSrcweir 
1074cdf0e10cSrcweir 	/// process all attributes
1075cdf0e10cSrcweir 	void ProcessAttributes(const Reference<xml::sax::XAttributeList> & xAttrList,
1076cdf0e10cSrcweir 						   Reference<beans::XPropertySet>& rPropSet);
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 	/**
1079cdf0e10cSrcweir 	 * All marks can be created immediatly. Since we don't care about
1080cdf0e10cSrcweir 	 * the element content, ProcessAttribute should set the properties
1081cdf0e10cSrcweir 	 * immediatly.
1082cdf0e10cSrcweir 	 *
1083cdf0e10cSrcweir 	 * This method tolerates an empty PropertySet; subclasses however
1084cdf0e10cSrcweir 	 * are not expected to.
1085cdf0e10cSrcweir 	 */
1086cdf0e10cSrcweir 	virtual void ProcessAttribute(sal_uInt16 nNamespace,
1087cdf0e10cSrcweir 								  OUString sLocalName,
1088cdf0e10cSrcweir 								  OUString sValue,
1089cdf0e10cSrcweir 								  Reference<beans::XPropertySet>& rPropSet);
1090cdf0e10cSrcweir 
1091cdf0e10cSrcweir 	static void GetServiceName(OUString& sServiceName,
1092cdf0e10cSrcweir 							   enum XMLTextPElemTokens nToken);
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 	sal_Bool CreateMark(Reference<beans::XPropertySet>& rPropSet,
1095cdf0e10cSrcweir 						const OUString& rServiceName);
1096cdf0e10cSrcweir };
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir 
1099cdf0e10cSrcweir TYPEINIT1( XMLIndexMarkImportContext_Impl, SvXMLImportContext );
1100cdf0e10cSrcweir 
XMLIndexMarkImportContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,enum XMLTextPElemTokens eTok,XMLHints_Impl & rHnts)1101cdf0e10cSrcweir XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
1102cdf0e10cSrcweir 	SvXMLImport& rImport,
1103cdf0e10cSrcweir 	sal_uInt16 nPrefix,
1104cdf0e10cSrcweir 	const OUString& rLocalName,
1105cdf0e10cSrcweir 	enum XMLTextPElemTokens eTok,
1106cdf0e10cSrcweir 	XMLHints_Impl& rHnts) :
1107cdf0e10cSrcweir 		SvXMLImportContext(rImport, nPrefix, rLocalName),
1108cdf0e10cSrcweir 		sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText")),
1109cdf0e10cSrcweir 		rHints(rHnts),
1110cdf0e10cSrcweir 		eToken(eTok)
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir }
1113cdf0e10cSrcweir 
StartElement(const Reference<xml::sax::XAttributeList> & xAttrList)1114cdf0e10cSrcweir void XMLIndexMarkImportContext_Impl::StartElement(
1115cdf0e10cSrcweir 	const Reference<xml::sax::XAttributeList> & xAttrList)
1116cdf0e10cSrcweir {
1117cdf0e10cSrcweir 	// get Cursor position (needed for all cases)
1118cdf0e10cSrcweir 	Reference<XTextRange> xPos(
1119cdf0e10cSrcweir 		GetImport().GetTextImport()->GetCursor()->getStart());
1120cdf0e10cSrcweir 	Reference<beans::XPropertySet> xMark;
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 	switch (eToken)
1123cdf0e10cSrcweir 	{
1124cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK:
1125cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK:
1126cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1127cdf0e10cSrcweir 		{
1128cdf0e10cSrcweir 			// single mark: create mark and insert
1129cdf0e10cSrcweir 			OUString sService;
1130cdf0e10cSrcweir 			GetServiceName(sService, eToken);
1131cdf0e10cSrcweir 			if (CreateMark(xMark, sService))
1132cdf0e10cSrcweir 			{
1133cdf0e10cSrcweir 				ProcessAttributes(xAttrList, xMark);
1134cdf0e10cSrcweir 				XMLHint_Impl* pHint = new XMLIndexMarkHint_Impl(xMark, xPos);
1135cdf0e10cSrcweir 				rHints.Insert(pHint, rHints.Count());
1136cdf0e10cSrcweir 			}
1137cdf0e10cSrcweir 			// else: can't create mark -> ignore
1138cdf0e10cSrcweir 			break;
1139cdf0e10cSrcweir 		}
1140cdf0e10cSrcweir 
1141cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_START:
1142cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_START:
1143cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1144cdf0e10cSrcweir 		{
1145cdf0e10cSrcweir 			// start: create mark and insert (if ID is found)
1146cdf0e10cSrcweir 			OUString sService;
1147cdf0e10cSrcweir 			GetServiceName(sService, eToken);
1148cdf0e10cSrcweir 			if (CreateMark(xMark, sService))
1149cdf0e10cSrcweir 			{
1150cdf0e10cSrcweir 				ProcessAttributes(xAttrList, xMark);
1151cdf0e10cSrcweir 				if (sID.getLength() > 0)
1152cdf0e10cSrcweir 				{
1153cdf0e10cSrcweir 					// process only if we find an ID
1154cdf0e10cSrcweir 					XMLHint_Impl* pHint =
1155cdf0e10cSrcweir 						new XMLIndexMarkHint_Impl(xMark, xPos, sID);
1156cdf0e10cSrcweir 					rHints.Insert(pHint, rHints.Count());
1157cdf0e10cSrcweir 				}
1158cdf0e10cSrcweir 				// else: no ID -> we'll never find the end -> ignore
1159cdf0e10cSrcweir 			}
1160cdf0e10cSrcweir 			// else: can't create mark -> ignore
1161cdf0e10cSrcweir 			break;
1162cdf0e10cSrcweir 		}
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_END:
1165cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_END:
1166cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1167cdf0e10cSrcweir 		{
1168cdf0e10cSrcweir 			// end: search for ID and set end of mark
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 			// call process attributes with empty XPropertySet:
1171cdf0e10cSrcweir 			ProcessAttributes(xAttrList, xMark);
1172cdf0e10cSrcweir 			if (sID.getLength() > 0)
1173cdf0e10cSrcweir 			{
1174cdf0e10cSrcweir 				// if we have an ID, find the hint and set the end position
1175cdf0e10cSrcweir 				sal_uInt16 nCount = rHints.Count();
1176cdf0e10cSrcweir 				for(sal_uInt16 nPos = 0; nPos < nCount; nPos++)
1177cdf0e10cSrcweir 				{
1178cdf0e10cSrcweir 					XMLHint_Impl *pHint = rHints[nPos];
1179cdf0e10cSrcweir 					if ( pHint->IsIndexMark() &&
1180cdf0e10cSrcweir 						 sID.equals(
1181cdf0e10cSrcweir 							 ((XMLIndexMarkHint_Impl *)pHint)->GetID()) )
1182cdf0e10cSrcweir 					{
1183cdf0e10cSrcweir 						// set end and stop searching
1184cdf0e10cSrcweir 						pHint->SetEnd(xPos);
1185cdf0e10cSrcweir 						break;
1186cdf0e10cSrcweir 					}
1187cdf0e10cSrcweir 				}
1188cdf0e10cSrcweir 			}
1189cdf0e10cSrcweir 			// else: no ID -> ignore
1190cdf0e10cSrcweir 			break;
1191cdf0e10cSrcweir 		}
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 		default:
1194cdf0e10cSrcweir 			DBG_ERROR("unknown index mark type!");
1195cdf0e10cSrcweir 			break;
1196cdf0e10cSrcweir 	}
1197cdf0e10cSrcweir }
1198cdf0e10cSrcweir 
ProcessAttributes(const Reference<xml::sax::XAttributeList> & xAttrList,Reference<beans::XPropertySet> & rPropSet)1199cdf0e10cSrcweir void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1200cdf0e10cSrcweir 	const Reference<xml::sax::XAttributeList> & xAttrList,
1201cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet)
1202cdf0e10cSrcweir {
1203cdf0e10cSrcweir 	// process attributes
1204cdf0e10cSrcweir 	sal_Int16 nLength = xAttrList->getLength();
1205cdf0e10cSrcweir 	for(sal_Int16 i=0; i<nLength; i++)
1206cdf0e10cSrcweir 	{
1207cdf0e10cSrcweir 		OUString sLocalName;
1208cdf0e10cSrcweir 		sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
1209cdf0e10cSrcweir 			GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir 		ProcessAttribute(nPrefix, sLocalName,
1212cdf0e10cSrcweir 						 xAttrList->getValueByIndex(i),
1213cdf0e10cSrcweir 						 rPropSet);
1214cdf0e10cSrcweir 	}
1215cdf0e10cSrcweir }
1216cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 nNamespace,OUString sLocalName,OUString sValue,Reference<beans::XPropertySet> & rPropSet)1217cdf0e10cSrcweir void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1218cdf0e10cSrcweir 	sal_uInt16 nNamespace,
1219cdf0e10cSrcweir 	OUString sLocalName,
1220cdf0e10cSrcweir 	OUString sValue,
1221cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet)
1222cdf0e10cSrcweir {
1223cdf0e10cSrcweir 	// we only know ID + string-value attribute;
1224cdf0e10cSrcweir 	// (former: marks, latter: -start + -end-marks)
1225cdf0e10cSrcweir 	// the remainder is handled in sub-classes
1226cdf0e10cSrcweir 	switch (eToken)
1227cdf0e10cSrcweir 	{
1228cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK:
1229cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK:
1230cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1231cdf0e10cSrcweir 			if ( (XML_NAMESPACE_TEXT == nNamespace) &&
1232cdf0e10cSrcweir 				 IsXMLToken( sLocalName, XML_STRING_VALUE ) )
1233cdf0e10cSrcweir 			{
1234cdf0e10cSrcweir                 rPropSet->setPropertyValue(sAlternativeText, uno::makeAny(sValue));
1235cdf0e10cSrcweir 			}
1236cdf0e10cSrcweir 			// else: ignore!
1237cdf0e10cSrcweir 			break;
1238cdf0e10cSrcweir 
1239cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_START:
1240cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_START:
1241cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1242cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_END:
1243cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_END:
1244cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1245cdf0e10cSrcweir 			if ( (XML_NAMESPACE_TEXT == nNamespace) &&
1246cdf0e10cSrcweir 				 IsXMLToken( sLocalName, XML_ID ) )
1247cdf0e10cSrcweir 			{
1248cdf0e10cSrcweir 				sID = sValue;
1249cdf0e10cSrcweir 			}
1250cdf0e10cSrcweir 			// else: ignore
1251cdf0e10cSrcweir 			break;
1252cdf0e10cSrcweir 
1253cdf0e10cSrcweir 		default:
1254cdf0e10cSrcweir 			DBG_ERROR("unknown index mark type!");
1255cdf0e10cSrcweir 			break;
1256cdf0e10cSrcweir 	}
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir 
1259cdf0e10cSrcweir static const sal_Char sAPI_com_sun_star_text_ContentIndexMark[] =
1260cdf0e10cSrcweir 		"com.sun.star.text.ContentIndexMark";
1261cdf0e10cSrcweir static const sal_Char sAPI_com_sun_star_text_UserIndexMark[] =
1262cdf0e10cSrcweir 		"com.sun.star.text.UserIndexMark";
1263cdf0e10cSrcweir static const sal_Char sAPI_com_sun_star_text_DocumentIndexMark[] =
1264cdf0e10cSrcweir 		"com.sun.star.text.DocumentIndexMark";
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir 
GetServiceName(OUString & sServiceName,enum XMLTextPElemTokens eToken)1267cdf0e10cSrcweir void XMLIndexMarkImportContext_Impl::GetServiceName(
1268cdf0e10cSrcweir 	OUString& sServiceName,
1269cdf0e10cSrcweir 	enum XMLTextPElemTokens eToken)
1270cdf0e10cSrcweir {
1271cdf0e10cSrcweir 	switch (eToken)
1272cdf0e10cSrcweir 	{
1273cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK:
1274cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_START:
1275cdf0e10cSrcweir 		case XML_TOK_TEXT_TOC_MARK_END:
1276cdf0e10cSrcweir 		{
1277cdf0e10cSrcweir 			OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1278cdf0e10cSrcweir 				sAPI_com_sun_star_text_ContentIndexMark));
1279cdf0e10cSrcweir 			sServiceName = sTmp;
1280cdf0e10cSrcweir 			break;
1281cdf0e10cSrcweir 		}
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK:
1284cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_START:
1285cdf0e10cSrcweir 		case XML_TOK_TEXT_USER_INDEX_MARK_END:
1286cdf0e10cSrcweir 		{
1287cdf0e10cSrcweir 			OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1288cdf0e10cSrcweir 				sAPI_com_sun_star_text_UserIndexMark));
1289cdf0e10cSrcweir 			sServiceName = sTmp;
1290cdf0e10cSrcweir 			break;
1291cdf0e10cSrcweir 		}
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1294cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1295cdf0e10cSrcweir 		case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1296cdf0e10cSrcweir 		{
1297cdf0e10cSrcweir 			OUString sTmp(RTL_CONSTASCII_USTRINGPARAM(
1298cdf0e10cSrcweir 				sAPI_com_sun_star_text_DocumentIndexMark));
1299cdf0e10cSrcweir 			sServiceName = sTmp;
1300cdf0e10cSrcweir 			break;
1301cdf0e10cSrcweir 		}
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir 		default:
1304cdf0e10cSrcweir 		{
1305cdf0e10cSrcweir 			DBG_ERROR("unknown index mark type!");
1306cdf0e10cSrcweir 			OUString sTmp;
1307cdf0e10cSrcweir 			sServiceName = sTmp;
1308cdf0e10cSrcweir 			break;
1309cdf0e10cSrcweir 		}
1310cdf0e10cSrcweir 	}
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir 
1313cdf0e10cSrcweir 
CreateMark(Reference<beans::XPropertySet> & rPropSet,const OUString & rServiceName)1314cdf0e10cSrcweir sal_Bool XMLIndexMarkImportContext_Impl::CreateMark(
1315cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet,
1316cdf0e10cSrcweir 	const OUString& rServiceName)
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir 	Reference<lang::XMultiServiceFactory>
1319cdf0e10cSrcweir 		xFactory(GetImport().GetModel(), UNO_QUERY);
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir 	if( xFactory.is() )
1322cdf0e10cSrcweir 	{
1323cdf0e10cSrcweir 		Reference<beans::XPropertySet> xPropSet( xFactory->createInstance(rServiceName), UNO_QUERY );
1324cdf0e10cSrcweir 		if (xPropSet.is())
1325cdf0e10cSrcweir 			rPropSet = xPropSet;
1326cdf0e10cSrcweir 		return sal_True;
1327cdf0e10cSrcweir 	}
1328cdf0e10cSrcweir 
1329cdf0e10cSrcweir 	return sal_False;
1330cdf0e10cSrcweir }
1331cdf0e10cSrcweir 
1332cdf0e10cSrcweir 
1333cdf0e10cSrcweir class XMLTOCMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir 	const OUString sLevel;
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir public:
1338cdf0e10cSrcweir 	TYPEINFO();
1339cdf0e10cSrcweir 
1340cdf0e10cSrcweir 	XMLTOCMarkImportContext_Impl(
1341cdf0e10cSrcweir 		SvXMLImport& rImport,
1342cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1343cdf0e10cSrcweir 		const OUString& rLocalName,
1344cdf0e10cSrcweir 		enum XMLTextPElemTokens nTok,
1345cdf0e10cSrcweir 		XMLHints_Impl& rHnts);
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir protected:
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 	/** process outline level */
1350cdf0e10cSrcweir 	virtual void ProcessAttribute(sal_uInt16 nNamespace,
1351cdf0e10cSrcweir 								  OUString sLocalName,
1352cdf0e10cSrcweir 								  OUString sValue,
1353cdf0e10cSrcweir 								  Reference<beans::XPropertySet>& rPropSet);
1354cdf0e10cSrcweir };
1355cdf0e10cSrcweir 
1356cdf0e10cSrcweir TYPEINIT1( XMLTOCMarkImportContext_Impl, XMLIndexMarkImportContext_Impl );
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 
XMLTOCMarkImportContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,enum XMLTextPElemTokens nTok,XMLHints_Impl & rHnts)1359cdf0e10cSrcweir XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1360cdf0e10cSrcweir 	SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1361cdf0e10cSrcweir 	enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1362cdf0e10cSrcweir 		XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1363cdf0e10cSrcweir 									   nTok, rHnts),
1364cdf0e10cSrcweir 		sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
1365cdf0e10cSrcweir {
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 nNamespace,OUString sLocalName,OUString sValue,Reference<beans::XPropertySet> & rPropSet)1368cdf0e10cSrcweir void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1369cdf0e10cSrcweir 	sal_uInt16 nNamespace,
1370cdf0e10cSrcweir 	OUString sLocalName,
1371cdf0e10cSrcweir 	OUString sValue,
1372cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet)
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir 	DBG_ASSERT(rPropSet.is(), "need PropertySet");
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir 	if ((XML_NAMESPACE_TEXT == nNamespace) &&
1377cdf0e10cSrcweir 		IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) )
1378cdf0e10cSrcweir     {
1379cdf0e10cSrcweir 		// ouline level: set Level property
1380cdf0e10cSrcweir 		sal_Int32 nTmp;
1381cdf0e10cSrcweir         if ( SvXMLUnitConverter::convertNumber( nTmp, sValue )
1382cdf0e10cSrcweir              && nTmp >= 1
1383cdf0e10cSrcweir              && nTmp < GetImport().GetTextImport()->
1384cdf0e10cSrcweir                               GetChapterNumbering()->getCount() )
1385cdf0e10cSrcweir 		{
1386cdf0e10cSrcweir             rPropSet->setPropertyValue(sLevel, uno::makeAny((sal_Int16)(nTmp - 1)));
1387cdf0e10cSrcweir 		}
1388cdf0e10cSrcweir 		// else: value out of range -> ignore
1389cdf0e10cSrcweir 	}
1390cdf0e10cSrcweir 	else
1391cdf0e10cSrcweir 	{
1392cdf0e10cSrcweir 		// else: delegate to superclass
1393cdf0e10cSrcweir 		XMLIndexMarkImportContext_Impl::ProcessAttribute(
1394cdf0e10cSrcweir 			nNamespace, sLocalName, sValue, rPropSet);
1395cdf0e10cSrcweir 	}
1396cdf0e10cSrcweir }
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir class XMLUserIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir 	const OUString sUserIndexName;
1401cdf0e10cSrcweir     const OUString sLevel;
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir public:
1404cdf0e10cSrcweir 	TYPEINFO();
1405cdf0e10cSrcweir 
1406cdf0e10cSrcweir 	XMLUserIndexMarkImportContext_Impl(
1407cdf0e10cSrcweir 		SvXMLImport& rImport,
1408cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1409cdf0e10cSrcweir 		const OUString& rLocalName,
1410cdf0e10cSrcweir 		enum XMLTextPElemTokens nTok,
1411cdf0e10cSrcweir 		XMLHints_Impl& rHnts);
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir protected:
1414cdf0e10cSrcweir 
1415cdf0e10cSrcweir 	/** process index name */
1416cdf0e10cSrcweir 	virtual void ProcessAttribute(sal_uInt16 nNamespace,
1417cdf0e10cSrcweir 								  OUString sLocalName,
1418cdf0e10cSrcweir 								  OUString sValue,
1419cdf0e10cSrcweir 								  Reference<beans::XPropertySet>& rPropSet);
1420cdf0e10cSrcweir };
1421cdf0e10cSrcweir 
1422cdf0e10cSrcweir TYPEINIT1( XMLUserIndexMarkImportContext_Impl, XMLIndexMarkImportContext_Impl);
1423cdf0e10cSrcweir 
XMLUserIndexMarkImportContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,enum XMLTextPElemTokens nTok,XMLHints_Impl & rHnts)1424cdf0e10cSrcweir XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1425cdf0e10cSrcweir 	SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1426cdf0e10cSrcweir 	enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1427cdf0e10cSrcweir 		XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1428cdf0e10cSrcweir 									   nTok, rHnts),
1429cdf0e10cSrcweir 		sUserIndexName(RTL_CONSTASCII_USTRINGPARAM("UserIndexName")),
1430cdf0e10cSrcweir         sLevel(RTL_CONSTASCII_USTRINGPARAM("Level"))
1431cdf0e10cSrcweir {
1432cdf0e10cSrcweir }
1433cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 nNamespace,OUString sLocalName,OUString sValue,Reference<beans::XPropertySet> & rPropSet)1434cdf0e10cSrcweir void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1435cdf0e10cSrcweir 	sal_uInt16 nNamespace, OUString sLocalName, OUString sValue,
1436cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet)
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir 	if ( XML_NAMESPACE_TEXT == nNamespace )
1439cdf0e10cSrcweir     {
1440cdf0e10cSrcweir         if ( IsXMLToken( sLocalName, XML_INDEX_NAME ) )
1441cdf0e10cSrcweir         {
1442cdf0e10cSrcweir             rPropSet->setPropertyValue(sUserIndexName, uno::makeAny(sValue));
1443cdf0e10cSrcweir         }
1444cdf0e10cSrcweir         else if ( IsXMLToken( sLocalName, XML_OUTLINE_LEVEL ) )
1445cdf0e10cSrcweir         {
1446cdf0e10cSrcweir             // ouline level: set Level property
1447cdf0e10cSrcweir             sal_Int32 nTmp;
1448cdf0e10cSrcweir             if (SvXMLUnitConverter::convertNumber(
1449cdf0e10cSrcweir                 nTmp, sValue, 0,
1450cdf0e10cSrcweir                GetImport().GetTextImport()->GetChapterNumbering()->getCount()))
1451cdf0e10cSrcweir             {
1452cdf0e10cSrcweir                 rPropSet->setPropertyValue(sLevel, uno::makeAny(static_cast<sal_Int16>(nTmp - 1)));
1453cdf0e10cSrcweir             }
1454cdf0e10cSrcweir             // else: value out of range -> ignore
1455cdf0e10cSrcweir         }
1456cdf0e10cSrcweir         else
1457cdf0e10cSrcweir         {
1458cdf0e10cSrcweir             // else: unknown text property: delegate to super class
1459cdf0e10cSrcweir             XMLIndexMarkImportContext_Impl::ProcessAttribute(
1460cdf0e10cSrcweir                 nNamespace, sLocalName, sValue, rPropSet);
1461cdf0e10cSrcweir         }
1462cdf0e10cSrcweir     }
1463cdf0e10cSrcweir     else
1464cdf0e10cSrcweir     {
1465cdf0e10cSrcweir         // else: unknown namespace: delegate to super class
1466cdf0e10cSrcweir         XMLIndexMarkImportContext_Impl::ProcessAttribute(
1467cdf0e10cSrcweir             nNamespace, sLocalName, sValue, rPropSet);
1468cdf0e10cSrcweir     }
1469cdf0e10cSrcweir }
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir class XMLAlphaIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1473cdf0e10cSrcweir {
1474cdf0e10cSrcweir 	const OUString sPrimaryKey;
1475cdf0e10cSrcweir 	const OUString sSecondaryKey;
1476cdf0e10cSrcweir     const OUString sTextReading;
1477cdf0e10cSrcweir     const OUString sPrimaryKeyReading;
1478cdf0e10cSrcweir     const OUString sSecondaryKeyReading;
1479cdf0e10cSrcweir     const OUString sMainEntry;
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir public:
1482cdf0e10cSrcweir 	TYPEINFO();
1483cdf0e10cSrcweir 
1484cdf0e10cSrcweir 	XMLAlphaIndexMarkImportContext_Impl(
1485cdf0e10cSrcweir 		SvXMLImport& rImport,
1486cdf0e10cSrcweir 		sal_uInt16 nPrefix,
1487cdf0e10cSrcweir 		const OUString& rLocalName,
1488cdf0e10cSrcweir 		enum XMLTextPElemTokens nTok,
1489cdf0e10cSrcweir 		XMLHints_Impl& rHnts);
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir protected:
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir 	/** process primary + secondary keys */
1494cdf0e10cSrcweir 	virtual void ProcessAttribute(sal_uInt16 nNamespace,
1495cdf0e10cSrcweir 								  OUString sLocalName,
1496cdf0e10cSrcweir 								  OUString sValue,
1497cdf0e10cSrcweir 								  Reference<beans::XPropertySet>& rPropSet);
1498cdf0e10cSrcweir };
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir TYPEINIT1( XMLAlphaIndexMarkImportContext_Impl,
1501cdf0e10cSrcweir 		   XMLIndexMarkImportContext_Impl );
1502cdf0e10cSrcweir 
XMLAlphaIndexMarkImportContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,enum XMLTextPElemTokens nTok,XMLHints_Impl & rHnts)1503cdf0e10cSrcweir XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1504cdf0e10cSrcweir 	SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName,
1505cdf0e10cSrcweir 	enum XMLTextPElemTokens nTok, XMLHints_Impl& rHnts) :
1506cdf0e10cSrcweir 		XMLIndexMarkImportContext_Impl(rImport, nPrefix, rLocalName,
1507cdf0e10cSrcweir 									   nTok, rHnts),
1508cdf0e10cSrcweir 		sPrimaryKey(RTL_CONSTASCII_USTRINGPARAM("PrimaryKey")),
1509cdf0e10cSrcweir 		sSecondaryKey(RTL_CONSTASCII_USTRINGPARAM("SecondaryKey")),
1510cdf0e10cSrcweir         sTextReading(RTL_CONSTASCII_USTRINGPARAM("TextReading")),
1511cdf0e10cSrcweir         sPrimaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("PrimaryKeyReading")),
1512cdf0e10cSrcweir         sSecondaryKeyReading(RTL_CONSTASCII_USTRINGPARAM("SecondaryKeyReading")),
1513cdf0e10cSrcweir         sMainEntry(RTL_CONSTASCII_USTRINGPARAM("IsMainEntry"))
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir }
1516cdf0e10cSrcweir 
ProcessAttribute(sal_uInt16 nNamespace,OUString sLocalName,OUString sValue,Reference<beans::XPropertySet> & rPropSet)1517cdf0e10cSrcweir void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1518cdf0e10cSrcweir 	sal_uInt16 nNamespace, OUString sLocalName, OUString sValue,
1519cdf0e10cSrcweir 	Reference<beans::XPropertySet>& rPropSet)
1520cdf0e10cSrcweir {
1521cdf0e10cSrcweir 	if (XML_NAMESPACE_TEXT == nNamespace)
1522cdf0e10cSrcweir 	{
1523cdf0e10cSrcweir 		if ( IsXMLToken( sLocalName, XML_KEY1 ) )
1524cdf0e10cSrcweir 		{
1525cdf0e10cSrcweir             rPropSet->setPropertyValue(sPrimaryKey, uno::makeAny(sValue));
1526cdf0e10cSrcweir 		}
1527cdf0e10cSrcweir 		else if ( IsXMLToken( sLocalName, XML_KEY2 ) )
1528cdf0e10cSrcweir 		{
1529cdf0e10cSrcweir             rPropSet->setPropertyValue(sSecondaryKey, uno::makeAny(sValue));
1530cdf0e10cSrcweir 		}
1531cdf0e10cSrcweir         else if ( IsXMLToken( sLocalName, XML_KEY1_PHONETIC ) )
1532cdf0e10cSrcweir         {
1533cdf0e10cSrcweir             rPropSet->setPropertyValue(sPrimaryKeyReading, uno::makeAny(sValue));
1534cdf0e10cSrcweir         }
1535cdf0e10cSrcweir         else if ( IsXMLToken( sLocalName, XML_KEY2_PHONETIC ) )
1536cdf0e10cSrcweir         {
1537cdf0e10cSrcweir             rPropSet->setPropertyValue(sSecondaryKeyReading, uno::makeAny(sValue));
1538cdf0e10cSrcweir         }
1539cdf0e10cSrcweir         else if ( IsXMLToken( sLocalName, XML_STRING_VALUE_PHONETIC ) )
1540cdf0e10cSrcweir         {
1541cdf0e10cSrcweir             rPropSet->setPropertyValue(sTextReading, uno::makeAny(sValue));
1542cdf0e10cSrcweir         }
1543cdf0e10cSrcweir         else if ( IsXMLToken( sLocalName, XML_MAIN_ENTRY ) )
1544cdf0e10cSrcweir         {
1545cdf0e10cSrcweir             sal_Bool bMainEntry = sal_False, bTmp;
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir             if (SvXMLUnitConverter::convertBool(bTmp, sValue))
1548cdf0e10cSrcweir                 bMainEntry = bTmp;
1549cdf0e10cSrcweir 
1550cdf0e10cSrcweir             rPropSet->setPropertyValue(sMainEntry, uno::makeAny(bMainEntry));
1551cdf0e10cSrcweir         }
1552cdf0e10cSrcweir 		else
1553cdf0e10cSrcweir 		{
1554cdf0e10cSrcweir 			XMLIndexMarkImportContext_Impl::ProcessAttribute(
1555cdf0e10cSrcweir 				nNamespace, sLocalName, sValue, rPropSet);
1556cdf0e10cSrcweir 		}
1557cdf0e10cSrcweir 	}
1558cdf0e10cSrcweir 	else
1559cdf0e10cSrcweir 	{
1560cdf0e10cSrcweir 		XMLIndexMarkImportContext_Impl::ProcessAttribute(
1561cdf0e10cSrcweir 			nNamespace, sLocalName, sValue, rPropSet);
1562cdf0e10cSrcweir 	}
1563cdf0e10cSrcweir }
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir 
1566cdf0e10cSrcweir // ---------------------------------------------------------------------
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir TYPEINIT1( XMLImpSpanContext_Impl, SvXMLImportContext );
1569cdf0e10cSrcweir 
XMLImpSpanContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,XMLHints_Impl & rHnts,sal_Bool & rIgnLeadSpace,sal_uInt8 nSFConvFlags)1570cdf0e10cSrcweir XMLImpSpanContext_Impl::XMLImpSpanContext_Impl(
1571cdf0e10cSrcweir 		SvXMLImport& rImport,
1572cdf0e10cSrcweir 		sal_uInt16 nPrfx,
1573cdf0e10cSrcweir 		const OUString& rLName,
1574cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
1575cdf0e10cSrcweir 		XMLHints_Impl& rHnts,
1576cdf0e10cSrcweir 		sal_Bool& rIgnLeadSpace
1577cdf0e10cSrcweir 	,sal_uInt8				nSFConvFlags
1578cdf0e10cSrcweir 											  )
1579cdf0e10cSrcweir :	SvXMLImportContext( rImport, nPrfx, rLName )
1580cdf0e10cSrcweir ,	sTextFrame(RTL_CONSTASCII_USTRINGPARAM("TextFrame"))
1581cdf0e10cSrcweir ,	rHints( rHnts )
1582cdf0e10cSrcweir ,	pHint( 0  )
1583cdf0e10cSrcweir ,	rIgnoreLeadingSpace( rIgnLeadSpace )
1584cdf0e10cSrcweir ,	nStarFontsConvFlags( nSFConvFlags & (CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH) )
1585cdf0e10cSrcweir {
1586cdf0e10cSrcweir 	OUString aStyleName;
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1589cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
1590cdf0e10cSrcweir 	{
1591cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir 		OUString aLocalName;
1594cdf0e10cSrcweir 		sal_uInt16 nPrefix =
1595cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
1596cdf0e10cSrcweir 															&aLocalName );
1597cdf0e10cSrcweir 		if( XML_NAMESPACE_TEXT == nPrefix &&
1598cdf0e10cSrcweir 			IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1599cdf0e10cSrcweir 			aStyleName = xAttrList->getValueByIndex( i );
1600cdf0e10cSrcweir 	}
1601cdf0e10cSrcweir 
1602cdf0e10cSrcweir 	if( aStyleName.getLength() )
1603cdf0e10cSrcweir 	{
1604cdf0e10cSrcweir 		pHint = new XMLStyleHint_Impl( aStyleName,
1605cdf0e10cSrcweir 				  GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
1606cdf0e10cSrcweir 			rHints.Insert( pHint, rHints.Count() );
1607cdf0e10cSrcweir 	}
1608cdf0e10cSrcweir }
1609cdf0e10cSrcweir 
~XMLImpSpanContext_Impl()1610cdf0e10cSrcweir XMLImpSpanContext_Impl::~XMLImpSpanContext_Impl()
1611cdf0e10cSrcweir {
1612cdf0e10cSrcweir 	if( pHint )
1613cdf0e10cSrcweir 		pHint->SetEnd( GetImport().GetTextImport()
1614cdf0e10cSrcweir 							->GetCursorAsRange()->getStart() );
1615cdf0e10cSrcweir }
1616cdf0e10cSrcweir 
CreateChildContext(SvXMLImport & rImport,sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList,sal_uInt16 nToken,XMLHints_Impl & rHints,sal_Bool & rIgnoreLeadingSpace,sal_uInt8 nStarFontsConvFlags)1617cdf0e10cSrcweir SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
1618cdf0e10cSrcweir 		SvXMLImport& rImport,
1619cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
1620cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
1621cdf0e10cSrcweir 		sal_uInt16 nToken,
1622cdf0e10cSrcweir 		XMLHints_Impl& rHints,
1623cdf0e10cSrcweir 		sal_Bool& rIgnoreLeadingSpace
1624cdf0e10cSrcweir 	,sal_uInt8				nStarFontsConvFlags
1625cdf0e10cSrcweir 	 )
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir 	SvXMLImportContext *pContext = 0;
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir 	switch( nToken )
1630cdf0e10cSrcweir 	{
1631cdf0e10cSrcweir 	case XML_TOK_TEXT_SPAN:
1632cdf0e10cSrcweir 		pContext = new XMLImpSpanContext_Impl( rImport, nPrefix,
1633cdf0e10cSrcweir 											   rLocalName, xAttrList,
1634cdf0e10cSrcweir 											   rHints,
1635cdf0e10cSrcweir 											   rIgnoreLeadingSpace
1636cdf0e10cSrcweir 											   ,nStarFontsConvFlags
1637cdf0e10cSrcweir 											 );
1638cdf0e10cSrcweir 		break;
1639cdf0e10cSrcweir 
1640cdf0e10cSrcweir 	case XML_TOK_TEXT_TAB_STOP:
1641cdf0e10cSrcweir 		pContext = new XMLCharContext( rImport, nPrefix,
1642cdf0e10cSrcweir 											   rLocalName, xAttrList,
1643cdf0e10cSrcweir 											   0x0009, sal_False );
1644cdf0e10cSrcweir 		rIgnoreLeadingSpace = sal_False;
1645cdf0e10cSrcweir 		break;
1646cdf0e10cSrcweir 
1647cdf0e10cSrcweir 	case XML_TOK_TEXT_LINE_BREAK:
1648cdf0e10cSrcweir 		pContext = new XMLCharContext( rImport, nPrefix,
1649cdf0e10cSrcweir 											   rLocalName, xAttrList,
1650cdf0e10cSrcweir 											   ControlCharacter::LINE_BREAK );
1651cdf0e10cSrcweir 		rIgnoreLeadingSpace = sal_False;
1652cdf0e10cSrcweir 		break;
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir 	case XML_TOK_TEXT_S:
1655cdf0e10cSrcweir 		pContext = new XMLCharContext( rImport, nPrefix,
1656cdf0e10cSrcweir 											   rLocalName, xAttrList,
1657cdf0e10cSrcweir 											   0x0020, sal_True );
1658cdf0e10cSrcweir 		break;
1659cdf0e10cSrcweir 
1660cdf0e10cSrcweir     case XML_TOK_TEXT_HYPERLINK:
1661cdf0e10cSrcweir     {
1662cdf0e10cSrcweir         // test for HyperLinkURL property. If present, insert link as
1663cdf0e10cSrcweir         // text property (StarWriter), else try to insert as text
1664cdf0e10cSrcweir         // field (StarCalc, StarDraw, ...)
1665*c45df7c4SOliver-Rainer Wittmann         Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY );
1666cdf0e10cSrcweir 
1667*c45df7c4SOliver-Rainer Wittmann         static const OUString sHyperLinkURL( RTL_CONSTASCII_USTRINGPARAM( "HyperLinkURL" ) );
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir         if ( xPropSet->getPropertySetInfo()->hasPropertyByName( sHyperLinkURL ) )
1670cdf0e10cSrcweir         {
1671*c45df7c4SOliver-Rainer Wittmann             pContext = new XMLImpHyperlinkContext_Impl(
1672*c45df7c4SOliver-Rainer Wittmann                     rImport,
1673*c45df7c4SOliver-Rainer Wittmann                     nPrefix,
1674*c45df7c4SOliver-Rainer Wittmann                     rLocalName,
1675*c45df7c4SOliver-Rainer Wittmann                     xAttrList,
1676cdf0e10cSrcweir                     rHints,
1677cdf0e10cSrcweir                     rIgnoreLeadingSpace );
1678cdf0e10cSrcweir         }
1679cdf0e10cSrcweir         else
1680cdf0e10cSrcweir         {
1681*c45df7c4SOliver-Rainer Wittmann             pContext = new XMLUrlFieldImportContext( rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName );
1682cdf0e10cSrcweir             //whitespace handling like other fields
1683cdf0e10cSrcweir             rIgnoreLeadingSpace = sal_False;
1684cdf0e10cSrcweir 
1685cdf0e10cSrcweir         }
1686cdf0e10cSrcweir         break;
1687cdf0e10cSrcweir     }
1688cdf0e10cSrcweir 
1689cdf0e10cSrcweir 	case XML_TOK_TEXT_RUBY:
1690cdf0e10cSrcweir 		pContext = new XMLImpRubyContext_Impl( rImport, nPrefix,
1691cdf0e10cSrcweir 											   rLocalName, xAttrList,
1692cdf0e10cSrcweir 											   rHints,
1693cdf0e10cSrcweir 											   rIgnoreLeadingSpace );
1694cdf0e10cSrcweir 		break;
1695cdf0e10cSrcweir 
1696cdf0e10cSrcweir 	case XML_TOK_TEXT_NOTE:
1697cdf0e10cSrcweir #ifndef SVX_LIGHT
1698cdf0e10cSrcweir 		if (rImport.GetTextImport()->IsInFrame())
1699cdf0e10cSrcweir 		{
1700cdf0e10cSrcweir 			// we must not insert footnotes into text frames
1701cdf0e10cSrcweir 			pContext = new SvXMLImportContext( rImport, nPrefix,
1702cdf0e10cSrcweir 											   rLocalName );
1703cdf0e10cSrcweir 		}
1704cdf0e10cSrcweir 		else
1705cdf0e10cSrcweir 		{
1706cdf0e10cSrcweir 			pContext = new XMLFootnoteImportContext( rImport,
1707cdf0e10cSrcweir 													 *rImport.GetTextImport().get(),
1708cdf0e10cSrcweir 													 nPrefix, rLocalName );
1709cdf0e10cSrcweir 		}
1710cdf0e10cSrcweir #else
1711cdf0e10cSrcweir 		// create default context to skip content
1712cdf0e10cSrcweir 		pContext = new SvXMLImportContext( rImport, nPrefix, rLocalName );
1713cdf0e10cSrcweir #endif // #ifndef SVX_LIGHT
1714cdf0e10cSrcweir 		rIgnoreLeadingSpace = sal_False;
1715cdf0e10cSrcweir 		break;
1716cdf0e10cSrcweir 
1717cdf0e10cSrcweir 	case XML_TOK_TEXT_REFERENCE:
1718cdf0e10cSrcweir 	case XML_TOK_TEXT_BOOKMARK:
1719cdf0e10cSrcweir 	case XML_TOK_TEXT_BOOKMARK_START:
1720cdf0e10cSrcweir 	case XML_TOK_TEXT_BOOKMARK_END:
1721cdf0e10cSrcweir 		pContext = new XMLTextMarkImportContext( rImport,
1722cdf0e10cSrcweir 												 *rImport.GetTextImport().get(),
1723cdf0e10cSrcweir 												 nPrefix, rLocalName );
1724cdf0e10cSrcweir 		break;
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir 	case XML_TOK_TEXT_FIELDMARK:
1727cdf0e10cSrcweir 	case XML_TOK_TEXT_FIELDMARK_START:
1728cdf0e10cSrcweir 	case XML_TOK_TEXT_FIELDMARK_END:
1729cdf0e10cSrcweir 		pContext = new XMLTextMarkImportContext( rImport,
1730cdf0e10cSrcweir 												 *rImport.GetTextImport().get(),
1731cdf0e10cSrcweir 												 nPrefix, rLocalName );
1732cdf0e10cSrcweir 		break;
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir 	case XML_TOK_TEXT_REFERENCE_START:
1735cdf0e10cSrcweir 		pContext = new XMLStartReferenceContext_Impl( rImport,
1736cdf0e10cSrcweir 													  nPrefix, rLocalName,
1737cdf0e10cSrcweir 													  rHints, xAttrList );
1738cdf0e10cSrcweir 		break;
1739cdf0e10cSrcweir 
1740cdf0e10cSrcweir 	case XML_TOK_TEXT_REFERENCE_END:
1741cdf0e10cSrcweir 		pContext = new XMLEndReferenceContext_Impl( rImport,
1742cdf0e10cSrcweir 													nPrefix, rLocalName,
1743cdf0e10cSrcweir 													rHints, xAttrList );
1744cdf0e10cSrcweir 		break;
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir 	case XML_TOK_TEXT_FRAME:
1747cdf0e10cSrcweir 		{
1748cdf0e10cSrcweir 			Reference < XTextRange > xAnchorPos =
1749cdf0e10cSrcweir 				rImport.GetTextImport()->GetCursor()->getStart();
1750cdf0e10cSrcweir 			XMLTextFrameContext *pTextFrameContext =
1751cdf0e10cSrcweir 				new XMLTextFrameContext( rImport, nPrefix,
1752cdf0e10cSrcweir 										 rLocalName, xAttrList,
1753cdf0e10cSrcweir 										 TextContentAnchorType_AS_CHARACTER );
1754cdf0e10cSrcweir             // --> OD 2004-08-24 #i33242# - remove check for text content.
1755cdf0e10cSrcweir             // Check for text content is done on the processing of the hint
1756cdf0e10cSrcweir             if( TextContentAnchorType_AT_CHARACTER ==
1757cdf0e10cSrcweir                                             pTextFrameContext->GetAnchorType() )
1758cdf0e10cSrcweir             // <--
1759cdf0e10cSrcweir 			{
1760cdf0e10cSrcweir 				rHints.Insert( new XMLTextFrameHint_Impl(
1761cdf0e10cSrcweir 					pTextFrameContext, xAnchorPos ),
1762cdf0e10cSrcweir 					rHints.Count() );
1763cdf0e10cSrcweir 			}
1764cdf0e10cSrcweir 			pContext = pTextFrameContext;
1765cdf0e10cSrcweir 			rIgnoreLeadingSpace = sal_False;
1766cdf0e10cSrcweir 		}
1767cdf0e10cSrcweir 		break;
1768cdf0e10cSrcweir 	case XML_TOK_DRAW_A:
1769cdf0e10cSrcweir 		{
1770cdf0e10cSrcweir 			Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1771cdf0e10cSrcweir 			pContext =
1772cdf0e10cSrcweir 				new XMLTextFrameHyperlinkContext( rImport, nPrefix,
1773cdf0e10cSrcweir 										rLocalName, xAttrList,
1774cdf0e10cSrcweir 										TextContentAnchorType_AS_CHARACTER );
1775cdf0e10cSrcweir 			XMLTextFrameHint_Impl *pHint =
1776cdf0e10cSrcweir 				new XMLTextFrameHint_Impl( pContext, xAnchorPos);
1777cdf0e10cSrcweir 			rHints.Insert( pHint, rHints.Count() );
1778cdf0e10cSrcweir 		}
1779cdf0e10cSrcweir 		break;
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir 	case XML_TOK_TEXT_TOC_MARK:
1782cdf0e10cSrcweir 	case XML_TOK_TEXT_TOC_MARK_START:
1783cdf0e10cSrcweir 		pContext = new XMLTOCMarkImportContext_Impl(
1784cdf0e10cSrcweir 			rImport, nPrefix, rLocalName,
1785cdf0e10cSrcweir 			(enum XMLTextPElemTokens)nToken, rHints);
1786cdf0e10cSrcweir 		break;
1787cdf0e10cSrcweir 
1788cdf0e10cSrcweir 	case XML_TOK_TEXT_USER_INDEX_MARK:
1789cdf0e10cSrcweir 	case XML_TOK_TEXT_USER_INDEX_MARK_START:
1790cdf0e10cSrcweir 		pContext = new XMLUserIndexMarkImportContext_Impl(
1791cdf0e10cSrcweir 			rImport, nPrefix, rLocalName,
1792cdf0e10cSrcweir 			(enum XMLTextPElemTokens)nToken, rHints);
1793cdf0e10cSrcweir 		break;
1794cdf0e10cSrcweir 
1795cdf0e10cSrcweir 	case XML_TOK_TEXT_ALPHA_INDEX_MARK:
1796cdf0e10cSrcweir 	case XML_TOK_TEXT_ALPHA_INDEX_MARK_START:
1797cdf0e10cSrcweir 		pContext = new XMLAlphaIndexMarkImportContext_Impl(
1798cdf0e10cSrcweir 			rImport, nPrefix, rLocalName,
1799cdf0e10cSrcweir 			(enum XMLTextPElemTokens)nToken, rHints);
1800cdf0e10cSrcweir 		break;
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir 	case XML_TOK_TEXT_TOC_MARK_END:
1803cdf0e10cSrcweir 	case XML_TOK_TEXT_USER_INDEX_MARK_END:
1804cdf0e10cSrcweir 	case XML_TOK_TEXT_ALPHA_INDEX_MARK_END:
1805cdf0e10cSrcweir 		pContext = new XMLIndexMarkImportContext_Impl(
1806cdf0e10cSrcweir 			rImport, nPrefix, rLocalName, (enum XMLTextPElemTokens)nToken,
1807cdf0e10cSrcweir 			rHints);
1808cdf0e10cSrcweir 		break;
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 	case XML_TOK_TEXTP_CHANGE_START:
1811cdf0e10cSrcweir 	case XML_TOK_TEXTP_CHANGE_END:
1812cdf0e10cSrcweir 	case XML_TOK_TEXTP_CHANGE:
1813cdf0e10cSrcweir 		pContext = new XMLChangeImportContext(
1814cdf0e10cSrcweir 			rImport, nPrefix, rLocalName,
1815cdf0e10cSrcweir 			(nToken != XML_TOK_TEXTP_CHANGE_END),
1816cdf0e10cSrcweir 			(nToken != XML_TOK_TEXTP_CHANGE_START),
1817cdf0e10cSrcweir 			sal_False);
1818cdf0e10cSrcweir 		break;
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir     case XML_TOK_TEXT_META:
1821cdf0e10cSrcweir         pContext = new XMLMetaImportContext(rImport, nPrefix, rLocalName,
1822cdf0e10cSrcweir             rHints, rIgnoreLeadingSpace );
1823cdf0e10cSrcweir         break;
1824cdf0e10cSrcweir 
1825cdf0e10cSrcweir     case XML_TOK_TEXT_META_FIELD:
1826cdf0e10cSrcweir         pContext = new XMLMetaFieldImportContext(rImport, nPrefix, rLocalName,
1827cdf0e10cSrcweir             rHints, rIgnoreLeadingSpace );
1828cdf0e10cSrcweir         break;
1829cdf0e10cSrcweir 
1830cdf0e10cSrcweir 	default:
1831cdf0e10cSrcweir 		// none of the above? then it's probably  a text field!
1832cdf0e10cSrcweir 		pContext =
1833cdf0e10cSrcweir 			XMLTextFieldImportContext::CreateTextFieldImportContext(
1834cdf0e10cSrcweir 				rImport, *rImport.GetTextImport().get(), nPrefix, rLocalName,
1835cdf0e10cSrcweir 				nToken);
1836cdf0e10cSrcweir         // #108784# import draw elements (except control shapes in headers)
1837cdf0e10cSrcweir         if( pContext == NULL &&
1838cdf0e10cSrcweir             !( rImport.GetTextImport()->IsInHeaderFooter() &&
1839cdf0e10cSrcweir                nPrefix == XML_NAMESPACE_DRAW &&
1840cdf0e10cSrcweir                IsXMLToken( rLocalName, XML_CONTROL ) ) )
1841cdf0e10cSrcweir         {
1842cdf0e10cSrcweir             Reference < XShapes > xShapes;
1843cdf0e10cSrcweir             SvXMLShapeContext* pShapeContext = rImport.GetShapeImport()->CreateGroupChildContext(
1844cdf0e10cSrcweir                 rImport, nPrefix, rLocalName, xAttrList, xShapes );
1845cdf0e10cSrcweir             pContext = pShapeContext;
1846cdf0e10cSrcweir             // OD 2004-04-20 #i26791# - keep shape in a text frame hint to
1847cdf0e10cSrcweir             // adjust its anchor position, if its at-character anchored
1848cdf0e10cSrcweir             Reference < XTextRange > xAnchorPos =
1849cdf0e10cSrcweir                 rImport.GetTextImport()->GetCursor()->getStart();
1850cdf0e10cSrcweir             rHints.Insert( new XMLDrawHint_Impl( pShapeContext, xAnchorPos ),
1851cdf0e10cSrcweir                            rHints.Count() );
1852cdf0e10cSrcweir         }
1853cdf0e10cSrcweir 		if( !pContext )
1854cdf0e10cSrcweir 		{
1855cdf0e10cSrcweir 			// ignore unknown content
1856cdf0e10cSrcweir 			pContext =
1857cdf0e10cSrcweir 				new SvXMLImportContext( rImport, nPrefix, rLocalName );
1858cdf0e10cSrcweir 		}
1859cdf0e10cSrcweir 		// Behind fields, shapes and any unknown content blanks aren't ignored
1860cdf0e10cSrcweir 		rIgnoreLeadingSpace = sal_False;
1861cdf0e10cSrcweir 	}
1862cdf0e10cSrcweir 
1863cdf0e10cSrcweir 	return pContext;
1864cdf0e10cSrcweir }
1865cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)1866cdf0e10cSrcweir SvXMLImportContext *XMLImpSpanContext_Impl::CreateChildContext(
1867cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
1868cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList )
1869cdf0e10cSrcweir {
1870cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
1871cdf0e10cSrcweir 		GetImport().GetTextImport()->GetTextPElemTokenMap();
1872cdf0e10cSrcweir 	sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
1873cdf0e10cSrcweir 
1874cdf0e10cSrcweir 	return CreateChildContext( GetImport(), nPrefix, rLocalName, xAttrList,
1875cdf0e10cSrcweir 							   nToken, rHints, rIgnoreLeadingSpace
1876cdf0e10cSrcweir 							   ,nStarFontsConvFlags
1877cdf0e10cSrcweir 							 );
1878cdf0e10cSrcweir }
1879cdf0e10cSrcweir 
Characters(const OUString & rChars)1880cdf0e10cSrcweir void XMLImpSpanContext_Impl::Characters( const OUString& rChars )
1881cdf0e10cSrcweir {
1882cdf0e10cSrcweir 	OUString sStyleName;
1883cdf0e10cSrcweir 	if( pHint )
1884cdf0e10cSrcweir 		sStyleName = pHint->GetStyleName();
1885cdf0e10cSrcweir 	OUString sChars =
1886cdf0e10cSrcweir 		GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1887cdf0e10cSrcweir 													   nStarFontsConvFlags,
1888cdf0e10cSrcweir 													   sal_False, GetImport() );
1889cdf0e10cSrcweir 	GetImport().GetTextImport()->InsertString( sChars, rIgnoreLeadingSpace );
1890cdf0e10cSrcweir }
1891cdf0e10cSrcweir 
1892cdf0e10cSrcweir // ---------------------------------------------------------------------
1893cdf0e10cSrcweir 
1894cdf0e10cSrcweir TYPEINIT1( XMLParaContext, SvXMLImportContext );
1895cdf0e10cSrcweir 
XMLParaContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,sal_Bool bHead)1896cdf0e10cSrcweir XMLParaContext::XMLParaContext(
1897cdf0e10cSrcweir 		SvXMLImport& rImport,
1898cdf0e10cSrcweir 		sal_uInt16 nPrfx,
1899cdf0e10cSrcweir 		const OUString& rLName,
1900cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList,
1901cdf0e10cSrcweir 		sal_Bool bHead ) :
1902cdf0e10cSrcweir 	SvXMLImportContext( rImport, nPrfx, rLName ),
1903cdf0e10cSrcweir 	xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1904cdf0e10cSrcweir     m_bHaveAbout(false),
1905cdf0e10cSrcweir 	nOutlineLevel( IsXMLToken( rLName, XML_H ) ? 1 : -1 ),
1906cdf0e10cSrcweir 	pHints( 0 ),
1907cdf0e10cSrcweir     // --> OD 2007-07-25 #i73509#
1908cdf0e10cSrcweir     mbOutlineLevelAttrFound( sal_False ),
1909cdf0e10cSrcweir     // <--
1910cdf0e10cSrcweir 	bIgnoreLeadingSpace( sal_True ),
1911cdf0e10cSrcweir 	bHeading( bHead ),
1912cdf0e10cSrcweir     bIsListHeader( false ),
1913cdf0e10cSrcweir     bIsRestart (false),
1914cdf0e10cSrcweir     nStartValue(0)
1915cdf0e10cSrcweir 	,nStarFontsConvFlags( 0 )
1916cdf0e10cSrcweir {
1917cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
1918cdf0e10cSrcweir 		GetImport().GetTextImport()->GetTextPAttrTokenMap();
1919cdf0e10cSrcweir 
1920cdf0e10cSrcweir     bool bHaveXmlId( false );
1921cdf0e10cSrcweir 	OUString aCondStyleName, sClassNames;
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir 	sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1924cdf0e10cSrcweir 	for( sal_Int16 i=0; i < nAttrCount; i++ )
1925cdf0e10cSrcweir 	{
1926cdf0e10cSrcweir 		const OUString& rAttrName = xAttrList->getNameByIndex( i );
1927cdf0e10cSrcweir 		const OUString& rValue = xAttrList->getValueByIndex( i );
1928cdf0e10cSrcweir 
1929cdf0e10cSrcweir 		OUString aLocalName;
1930cdf0e10cSrcweir 		sal_uInt16 nPrefix =
1931cdf0e10cSrcweir 			GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
1932cdf0e10cSrcweir 															&aLocalName );
1933cdf0e10cSrcweir 		switch( rTokenMap.Get( nPrefix, aLocalName ) )
1934cdf0e10cSrcweir 		{
1935cdf0e10cSrcweir         case XML_TOK_TEXT_P_XMLID:
1936cdf0e10cSrcweir             m_sXmlId = rValue;
1937cdf0e10cSrcweir             bHaveXmlId = true;
1938cdf0e10cSrcweir             break;
1939cdf0e10cSrcweir         case XML_TOK_TEXT_P_ABOUT:
1940cdf0e10cSrcweir             m_sAbout = rValue;
1941cdf0e10cSrcweir             m_bHaveAbout = true;
1942cdf0e10cSrcweir             break;
1943cdf0e10cSrcweir         case XML_TOK_TEXT_P_PROPERTY:
1944cdf0e10cSrcweir             m_sProperty = rValue;
1945cdf0e10cSrcweir             break;
1946cdf0e10cSrcweir         case XML_TOK_TEXT_P_CONTENT:
1947cdf0e10cSrcweir             m_sContent = rValue;
1948cdf0e10cSrcweir             break;
1949cdf0e10cSrcweir         case XML_TOK_TEXT_P_DATATYPE:
1950cdf0e10cSrcweir             m_sDatatype = rValue;
1951cdf0e10cSrcweir             break;
1952cdf0e10cSrcweir         case XML_TOK_TEXT_P_TEXTID:
1953cdf0e10cSrcweir             if (!bHaveXmlId) { m_sXmlId = rValue; }
1954cdf0e10cSrcweir             break;
1955cdf0e10cSrcweir 		case XML_TOK_TEXT_P_STYLE_NAME:
1956cdf0e10cSrcweir 			sStyleName = rValue;
1957cdf0e10cSrcweir 			break;
1958cdf0e10cSrcweir 		case XML_TOK_TEXT_P_CLASS_NAMES:
1959cdf0e10cSrcweir 			sClassNames = rValue;
1960cdf0e10cSrcweir 			break;
1961cdf0e10cSrcweir 		case XML_TOK_TEXT_P_COND_STYLE_NAME:
1962cdf0e10cSrcweir 			aCondStyleName = rValue;
1963cdf0e10cSrcweir 			break;
1964cdf0e10cSrcweir 		case XML_TOK_TEXT_P_LEVEL:
1965cdf0e10cSrcweir 			{
1966cdf0e10cSrcweir 				sal_Int32 nTmp = rValue.toInt32();
1967cdf0e10cSrcweir 				if( nTmp > 0L )
1968cdf0e10cSrcweir 				{
1969cdf0e10cSrcweir 					if( nTmp > 127 )
1970cdf0e10cSrcweir 						nTmp = 127;
1971cdf0e10cSrcweir 					nOutlineLevel = (sal_Int8)nTmp;
1972cdf0e10cSrcweir 				}
1973cdf0e10cSrcweir                 // --> OD 2007-07-25 #i73509#
1974cdf0e10cSrcweir                 mbOutlineLevelAttrFound = sal_True;
1975cdf0e10cSrcweir                 // <--
1976cdf0e10cSrcweir 			}
1977cdf0e10cSrcweir             break;
1978cdf0e10cSrcweir 		case XML_TOK_TEXT_P_IS_LIST_HEADER:
1979cdf0e10cSrcweir 			{
1980cdf0e10cSrcweir                 sal_Bool bBool;
1981cdf0e10cSrcweir                 if( SvXMLUnitConverter::convertBool( bBool, rValue ) )
1982cdf0e10cSrcweir                 {
1983cdf0e10cSrcweir                     bIsListHeader = bBool;
1984cdf0e10cSrcweir                 }
1985cdf0e10cSrcweir 			}
1986cdf0e10cSrcweir             break;
1987cdf0e10cSrcweir         case XML_TOK_TEXT_P_RESTART_NUMBERING:
1988cdf0e10cSrcweir             {
1989cdf0e10cSrcweir                 sal_Bool bBool;
1990cdf0e10cSrcweir                 if (SvXMLUnitConverter::convertBool(bBool, rValue))
1991cdf0e10cSrcweir                 {
1992cdf0e10cSrcweir                     bIsRestart = bBool;
1993cdf0e10cSrcweir                 }
1994cdf0e10cSrcweir             }
1995cdf0e10cSrcweir             break;
1996cdf0e10cSrcweir         case XML_TOK_TEXT_P_START_VALUE:
1997cdf0e10cSrcweir             {
1998cdf0e10cSrcweir                 nStartValue = sal::static_int_cast< sal_Int16 >(
1999cdf0e10cSrcweir                     rValue.toInt32());
2000cdf0e10cSrcweir             }
2001cdf0e10cSrcweir             break;
2002cdf0e10cSrcweir 		}
2003cdf0e10cSrcweir 	}
2004cdf0e10cSrcweir 
2005cdf0e10cSrcweir 	if( aCondStyleName.getLength() )
2006cdf0e10cSrcweir 		sStyleName = aCondStyleName;
2007cdf0e10cSrcweir 	else if( sClassNames.getLength() )
2008cdf0e10cSrcweir 	{
2009cdf0e10cSrcweir 		sal_Int32 nDummy = 0;
2010cdf0e10cSrcweir 		sStyleName = sClassNames.getToken( 0, ' ', nDummy );
2011cdf0e10cSrcweir 	}
2012cdf0e10cSrcweir }
2013cdf0e10cSrcweir 
~XMLParaContext()2014cdf0e10cSrcweir XMLParaContext::~XMLParaContext()
2015cdf0e10cSrcweir {
2016cdf0e10cSrcweir 	UniReference < XMLTextImportHelper > xTxtImport(
2017cdf0e10cSrcweir 		GetImport().GetTextImport());
2018cdf0e10cSrcweir     Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() );
2019cdf0e10cSrcweir     if( !xCrsrRange.is() )
2020cdf0e10cSrcweir         return; // Robust (defect file)
2021cdf0e10cSrcweir 	Reference < XTextRange > xEnd(xCrsrRange->getStart());
2022cdf0e10cSrcweir 
2023cdf0e10cSrcweir 	// if we have an id set for this paragraph, get a cursor for this
2024cdf0e10cSrcweir 	// paragraph and register it with the given identifier
2025cdf0e10cSrcweir     // FIXME: this is just temporary, and should be removed when
2026cdf0e10cSrcweir     // EditEngine paragraphs implement XMetadatable!
2027cdf0e10cSrcweir     if (m_sXmlId.getLength())
2028cdf0e10cSrcweir 	{
2029cdf0e10cSrcweir 		Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) );
2030cdf0e10cSrcweir 		if( xIdCursor.is() )
2031cdf0e10cSrcweir 		{
2032cdf0e10cSrcweir 			xIdCursor->gotoRange( xEnd, sal_True );
2033cdf0e10cSrcweir 			Reference< XInterface > xRef( xIdCursor, UNO_QUERY );
2034cdf0e10cSrcweir             GetImport().getInterfaceToIdentifierMapper().registerReference(
2035cdf0e10cSrcweir                 m_sXmlId, xRef);
2036cdf0e10cSrcweir         }
2037cdf0e10cSrcweir     }
2038cdf0e10cSrcweir 
2039cdf0e10cSrcweir 	// insert a paragraph break
2040cdf0e10cSrcweir 	xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir 	// create a cursor that select the whole last paragraph
2043cdf0e10cSrcweir 	Reference < XTextCursor > xAttrCursor(
2044cdf0e10cSrcweir 		xTxtImport->GetText()->createTextCursorByRange( xStart ));
2045cdf0e10cSrcweir     if( !xAttrCursor.is() )
2046cdf0e10cSrcweir         return; // Robust (defect file)
2047cdf0e10cSrcweir 	xAttrCursor->gotoRange( xEnd, sal_True );
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir     // xml:id for RDF metadata
2050cdf0e10cSrcweir     if (m_sXmlId.getLength() || m_bHaveAbout || m_sProperty.getLength())
2051cdf0e10cSrcweir     {
2052cdf0e10cSrcweir         try {
2053cdf0e10cSrcweir             const uno::Reference<container::XEnumerationAccess> xEA
2054cdf0e10cSrcweir                 (xAttrCursor, uno::UNO_QUERY_THROW);
2055cdf0e10cSrcweir             const uno::Reference<container::XEnumeration> xEnum(
2056cdf0e10cSrcweir                 xEA->createEnumeration(), uno::UNO_QUERY_THROW);
2057cdf0e10cSrcweir             OSL_ENSURE(xEnum->hasMoreElements(), "xml:id: no paragraph?");
2058cdf0e10cSrcweir             if (xEnum->hasMoreElements()) {
2059cdf0e10cSrcweir                 uno::Reference<rdf::XMetadatable> xMeta;
2060cdf0e10cSrcweir                 xEnum->nextElement() >>= xMeta;
2061cdf0e10cSrcweir                 OSL_ENSURE(xMeta.is(), "xml:id: not XMetadatable");
2062cdf0e10cSrcweir                 GetImport().SetXmlId(xMeta, m_sXmlId);
2063cdf0e10cSrcweir                 if (m_bHaveAbout)
2064cdf0e10cSrcweir                 {
2065cdf0e10cSrcweir                     GetImport().AddRDFa(xMeta,
2066cdf0e10cSrcweir                         m_sAbout, m_sProperty, m_sContent, m_sDatatype);
2067cdf0e10cSrcweir                 }
2068cdf0e10cSrcweir                 OSL_ENSURE(!xEnum->hasMoreElements(), "xml:id: > 1 paragraph?");
2069cdf0e10cSrcweir             }
2070cdf0e10cSrcweir         } catch (uno::Exception &) {
2071cdf0e10cSrcweir             OSL_TRACE("XMLParaContext::~XMLParaContext: exception");
2072cdf0e10cSrcweir         }
2073cdf0e10cSrcweir     }
2074cdf0e10cSrcweir 
2075cdf0e10cSrcweir     OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
2076cdf0e10cSrcweir     if( sCellParaStyleName.getLength() > 0 )
2077cdf0e10cSrcweir     {
2078cdf0e10cSrcweir         // --> OD 2007-08-16 #i80724#
2079cdf0e10cSrcweir         // suppress handling of outline and list attributes,
2080cdf0e10cSrcweir         // because of side effects of method <SetStyleAndAttrs(..)>
2081cdf0e10cSrcweir         xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
2082cdf0e10cSrcweir                                       sCellParaStyleName,
2083cdf0e10cSrcweir                                       sal_True,
2084cdf0e10cSrcweir                                       sal_False, -1, // suppress outline handling
2085cdf0e10cSrcweir                                       sal_False );   // suppress list attributes handling
2086cdf0e10cSrcweir         // <--
2087cdf0e10cSrcweir     }
2088cdf0e10cSrcweir 
2089cdf0e10cSrcweir     // #103445# for headings without style name, find the proper style
2090cdf0e10cSrcweir     if( bHeading && (sStyleName.getLength() == 0) )
2091cdf0e10cSrcweir         xTxtImport->FindOutlineStyleName( sStyleName, nOutlineLevel );
2092cdf0e10cSrcweir 
2093cdf0e10cSrcweir 	// set style and hard attributes at the previous paragraph
2094cdf0e10cSrcweir     // --> OD 2007-07-25 #i73509# - add paramter <mbOutlineLevelAttrFound>
2095cdf0e10cSrcweir     sStyleName = xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
2096cdf0e10cSrcweir                                                sStyleName,
2097cdf0e10cSrcweir                                                sal_True,
2098cdf0e10cSrcweir                                                mbOutlineLevelAttrFound,
2099cdf0e10cSrcweir                                                bHeading ? nOutlineLevel : -1 );
2100cdf0e10cSrcweir     // <--
2101cdf0e10cSrcweir 
2102cdf0e10cSrcweir     // handle list style header
2103cdf0e10cSrcweir     if (bHeading && (bIsListHeader || bIsRestart))
2104cdf0e10cSrcweir     {
2105cdf0e10cSrcweir         Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
2106cdf0e10cSrcweir 
2107cdf0e10cSrcweir         if (xPropSet.is())
2108cdf0e10cSrcweir         {
2109cdf0e10cSrcweir             if (bIsListHeader)
2110cdf0e10cSrcweir             {
2111cdf0e10cSrcweir                 OUString sNumberingIsNumber
2112cdf0e10cSrcweir                     (RTL_CONSTASCII_USTRINGPARAM("NumberingIsNumber"));
2113cdf0e10cSrcweir                 if(xPropSet->getPropertySetInfo()->
2114cdf0e10cSrcweir                    hasPropertyByName(sNumberingIsNumber))
2115cdf0e10cSrcweir                 {
2116cdf0e10cSrcweir                     xPropSet->setPropertyValue
2117cdf0e10cSrcweir                         (sNumberingIsNumber, makeAny( false ) );
2118cdf0e10cSrcweir                 }
2119cdf0e10cSrcweir             }
2120cdf0e10cSrcweir             if (bIsRestart)
2121cdf0e10cSrcweir             {
2122cdf0e10cSrcweir                 OUString sParaIsNumberingRestart
2123cdf0e10cSrcweir                     (RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart"));
2124cdf0e10cSrcweir                 OUString sNumberingStartValue
2125cdf0e10cSrcweir                     (RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue"));
2126cdf0e10cSrcweir                 if (xPropSet->getPropertySetInfo()->
2127cdf0e10cSrcweir                     hasPropertyByName(sParaIsNumberingRestart))
2128cdf0e10cSrcweir                 {
2129cdf0e10cSrcweir                     xPropSet->setPropertyValue
2130cdf0e10cSrcweir                         (sParaIsNumberingRestart, makeAny(true));
2131cdf0e10cSrcweir                 }
2132cdf0e10cSrcweir 
2133cdf0e10cSrcweir                 if (xPropSet->getPropertySetInfo()->
2134cdf0e10cSrcweir                     hasPropertyByName(sNumberingStartValue))
2135cdf0e10cSrcweir                 {
2136cdf0e10cSrcweir                     xPropSet->setPropertyValue
2137cdf0e10cSrcweir                         (sNumberingStartValue, makeAny(nStartValue));
2138cdf0e10cSrcweir                 }
2139cdf0e10cSrcweir             }
2140cdf0e10cSrcweir 
2141cdf0e10cSrcweir         }
2142cdf0e10cSrcweir     }
2143cdf0e10cSrcweir 
2144cdf0e10cSrcweir 	if( pHints && pHints->Count() )
2145cdf0e10cSrcweir 	{
2146cdf0e10cSrcweir 		for( sal_uInt16 i=0; i<pHints->Count(); i++ )
2147cdf0e10cSrcweir 		{
2148cdf0e10cSrcweir 			XMLHint_Impl *pHint = (*pHints)[i];
2149cdf0e10cSrcweir 			xAttrCursor->gotoRange( pHint->GetStart(), sal_False );
2150cdf0e10cSrcweir 			xAttrCursor->gotoRange( pHint->GetEnd(), sal_True );
2151cdf0e10cSrcweir 			switch( pHint->GetType() )
2152cdf0e10cSrcweir 			{
2153cdf0e10cSrcweir 			case XML_HINT_STYLE:
2154cdf0e10cSrcweir 				{
2155cdf0e10cSrcweir 					const OUString& rStyleName =
2156cdf0e10cSrcweir 							((XMLStyleHint_Impl *)pHint)->GetStyleName();
2157cdf0e10cSrcweir 					if( rStyleName.getLength() )
2158cdf0e10cSrcweir 						xTxtImport->SetStyleAndAttrs( GetImport(),
2159cdf0e10cSrcweir 													  xAttrCursor, rStyleName,
2160cdf0e10cSrcweir                                                       sal_False );
2161cdf0e10cSrcweir 				}
2162cdf0e10cSrcweir 				break;
2163cdf0e10cSrcweir 			case XML_HINT_REFERENCE:
2164cdf0e10cSrcweir 				{
2165cdf0e10cSrcweir 					const OUString& rRefName =
2166cdf0e10cSrcweir 							((XMLReferenceHint_Impl *)pHint)->GetRefName();
2167cdf0e10cSrcweir 					if( rRefName.getLength() )
2168cdf0e10cSrcweir 					{
2169cdf0e10cSrcweir 						if( !pHint->GetEnd().is() )
2170cdf0e10cSrcweir 							pHint->SetEnd(xEnd);
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir 						// convert XCursor to XTextRange
2173cdf0e10cSrcweir 						Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2174cdf0e10cSrcweir 
2175cdf0e10cSrcweir 						// reference name uses rStyleName member
2176cdf0e10cSrcweir 						// borrow from XMLTextMarkImportContext
2177cdf0e10cSrcweir 						XMLTextMarkImportContext::CreateAndInsertMark(
2178cdf0e10cSrcweir 							GetImport(),
2179cdf0e10cSrcweir 							OUString(
2180cdf0e10cSrcweir 								RTL_CONSTASCII_USTRINGPARAM(
2181cdf0e10cSrcweir 									"com.sun.star.text.ReferenceMark")),
2182cdf0e10cSrcweir 							rRefName,
2183cdf0e10cSrcweir 							xRange);
2184cdf0e10cSrcweir 					}
2185cdf0e10cSrcweir 				}
2186cdf0e10cSrcweir 				break;
2187cdf0e10cSrcweir 			case XML_HINT_HYPERLINK:
2188cdf0e10cSrcweir 				{
2189cdf0e10cSrcweir 					const XMLHyperlinkHint_Impl *pHHint =
2190cdf0e10cSrcweir 						(const XMLHyperlinkHint_Impl *)pHint;
2191cdf0e10cSrcweir 					xTxtImport->SetHyperlink( GetImport(),
2192cdf0e10cSrcweir 											  xAttrCursor,
2193cdf0e10cSrcweir 											  pHHint->GetHRef(),
2194cdf0e10cSrcweir 											  pHHint->GetName(),
2195cdf0e10cSrcweir 											  pHHint->GetTargetFrameName(),
2196cdf0e10cSrcweir 											  pHHint->GetStyleName(),
2197cdf0e10cSrcweir 											  pHHint->GetVisitedStyleName(),
2198cdf0e10cSrcweir 											  pHHint->GetEventsContext() );
2199cdf0e10cSrcweir 				}
2200cdf0e10cSrcweir 				break;
2201cdf0e10cSrcweir 			case XML_HINT_INDEX_MARK:
2202cdf0e10cSrcweir 				{
2203cdf0e10cSrcweir 					Reference<beans::XPropertySet> xMark(
2204cdf0e10cSrcweir 						((const XMLIndexMarkHint_Impl *)pHint)->GetMark());
2205cdf0e10cSrcweir 					Reference<XTextContent> xContent(xMark,	UNO_QUERY);
2206cdf0e10cSrcweir 					Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2207cdf0e10cSrcweir 					xTxtImport->GetText()->insertTextContent(
2208cdf0e10cSrcweir 						xRange, xContent, sal_True );
2209cdf0e10cSrcweir 				}
2210cdf0e10cSrcweir 				break;
2211cdf0e10cSrcweir 			case XML_HINT_TEXT_FRAME:
2212cdf0e10cSrcweir 				{
2213cdf0e10cSrcweir 					const XMLTextFrameHint_Impl *pFHint =
2214cdf0e10cSrcweir 						(const XMLTextFrameHint_Impl *)pHint;
2215cdf0e10cSrcweir                     // --> OD 2004-08-24 #i33242# - check for text content
2216cdf0e10cSrcweir                     Reference < XTextContent > xTextContent =
2217cdf0e10cSrcweir                                                     pFHint->GetTextContent();
2218cdf0e10cSrcweir                     if ( xTextContent.is() )
2219cdf0e10cSrcweir                     {
2220cdf0e10cSrcweir                         // OD 2004-04-20 #i26791#
2221cdf0e10cSrcweir                         Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2222cdf0e10cSrcweir                         if ( pFHint->IsBoundAtChar() )
2223cdf0e10cSrcweir                         {
2224cdf0e10cSrcweir                             xTextContent->attach( xRange );
2225cdf0e10cSrcweir                         }
2226cdf0e10cSrcweir                     }
2227cdf0e10cSrcweir                     // <--
2228cdf0e10cSrcweir                     // --> OD 2004-08-24 #i33242# - consider, that hint can
2229cdf0e10cSrcweir                     // also contain a shape - e.g. drawing object of type 'Text'.
2230cdf0e10cSrcweir                     else
2231cdf0e10cSrcweir                     {
2232cdf0e10cSrcweir                         Reference < XShape > xShape = pFHint->GetShape();
2233cdf0e10cSrcweir                         if ( xShape.is() )
2234cdf0e10cSrcweir                         {
2235cdf0e10cSrcweir                             // determine anchor type
2236cdf0e10cSrcweir                             Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
2237cdf0e10cSrcweir                             TextContentAnchorType eAnchorType =
2238cdf0e10cSrcweir                                             TextContentAnchorType_AT_PARAGRAPH;
2239cdf0e10cSrcweir                             {
2240cdf0e10cSrcweir                                 OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2241cdf0e10cSrcweir                                 Any aAny = xPropSet->getPropertyValue( sAnchorType );
2242cdf0e10cSrcweir                                 aAny >>= eAnchorType;
2243cdf0e10cSrcweir                             }
2244cdf0e10cSrcweir                             if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
2245cdf0e10cSrcweir                             {
2246cdf0e10cSrcweir                                 // set anchor position for at-character anchored objects
2247cdf0e10cSrcweir                                 Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2248cdf0e10cSrcweir                                 Any aPos;
2249cdf0e10cSrcweir                                 aPos <<= xRange;
2250cdf0e10cSrcweir                                 OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) );
2251cdf0e10cSrcweir                                 xPropSet->setPropertyValue(sTextRange, aPos);
2252cdf0e10cSrcweir                             }
2253cdf0e10cSrcweir                         }
2254cdf0e10cSrcweir                     }
2255cdf0e10cSrcweir                     // <--
2256cdf0e10cSrcweir 				}
2257cdf0e10cSrcweir 				break;
2258cdf0e10cSrcweir 			// --> DVO, OD 2004-07-14 #i26791#
2259cdf0e10cSrcweir 			case XML_HINT_DRAW:
2260cdf0e10cSrcweir 				{
2261cdf0e10cSrcweir 					const XMLDrawHint_Impl *pDHint =
2262cdf0e10cSrcweir 						static_cast<const XMLDrawHint_Impl*>(pHint);
2263cdf0e10cSrcweir                     // --> OD 2004-08-24 #i33242# - improvement: hint directly
2264cdf0e10cSrcweir                     // provides the shape.
2265cdf0e10cSrcweir                     Reference < XShape > xShape = pDHint->GetShape();
2266cdf0e10cSrcweir                     if ( xShape.is() )
2267cdf0e10cSrcweir                     {
2268cdf0e10cSrcweir                         // determine anchor type
2269cdf0e10cSrcweir                         Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
2270cdf0e10cSrcweir                         TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
2271cdf0e10cSrcweir                         {
2272cdf0e10cSrcweir                             OUString sAnchorType( RTL_CONSTASCII_USTRINGPARAM( "AnchorType" ) );
2273cdf0e10cSrcweir                             Any aAny = xPropSet->getPropertyValue( sAnchorType );
2274cdf0e10cSrcweir                             aAny >>= eAnchorType;
2275cdf0e10cSrcweir                         }
2276cdf0e10cSrcweir                         if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
2277cdf0e10cSrcweir                         {
2278cdf0e10cSrcweir                             // set anchor position for at-character anchored objects
2279cdf0e10cSrcweir                             Reference<XTextRange> xRange(xAttrCursor, UNO_QUERY);
2280cdf0e10cSrcweir                             Any aPos;
2281cdf0e10cSrcweir                             aPos <<= xRange;
2282cdf0e10cSrcweir                             OUString sTextRange( RTL_CONSTASCII_USTRINGPARAM( "TextRange" ) );
2283cdf0e10cSrcweir                             xPropSet->setPropertyValue(sTextRange, aPos);
2284cdf0e10cSrcweir                         }
2285cdf0e10cSrcweir                     }
2286cdf0e10cSrcweir                     // <--
2287cdf0e10cSrcweir 				}
2288cdf0e10cSrcweir 				break;
2289cdf0e10cSrcweir 			// <--
2290cdf0e10cSrcweir 
2291cdf0e10cSrcweir 			default:
2292cdf0e10cSrcweir 				DBG_ASSERT( !this, "What's this" );
2293cdf0e10cSrcweir 				break;
2294cdf0e10cSrcweir 			}
2295cdf0e10cSrcweir 		}
2296cdf0e10cSrcweir 	}
2297cdf0e10cSrcweir 	delete pHints;
2298cdf0e10cSrcweir }
2299cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList)2300cdf0e10cSrcweir SvXMLImportContext *XMLParaContext::CreateChildContext(
2301cdf0e10cSrcweir 		sal_uInt16 nPrefix, const OUString& rLocalName,
2302cdf0e10cSrcweir 		const Reference< xml::sax::XAttributeList > & xAttrList )
2303cdf0e10cSrcweir {
2304cdf0e10cSrcweir 	const SvXMLTokenMap& rTokenMap =
2305cdf0e10cSrcweir 		GetImport().GetTextImport()->GetTextPElemTokenMap();
2306cdf0e10cSrcweir 	sal_uInt16 nToken = rTokenMap.Get( nPrefix, rLocalName );
2307cdf0e10cSrcweir 	if( !pHints )
2308cdf0e10cSrcweir 		pHints = new XMLHints_Impl;
2309cdf0e10cSrcweir 	return XMLImpSpanContext_Impl::CreateChildContext(
2310cdf0e10cSrcweir 								GetImport(), nPrefix, rLocalName, xAttrList,
2311cdf0e10cSrcweir 							   	nToken, *pHints, bIgnoreLeadingSpace
2312cdf0e10cSrcweir 								, nStarFontsConvFlags
2313cdf0e10cSrcweir 													 );
2314cdf0e10cSrcweir }
2315cdf0e10cSrcweir 
Characters(const OUString & rChars)2316cdf0e10cSrcweir void XMLParaContext::Characters( const OUString& rChars )
2317cdf0e10cSrcweir {
2318cdf0e10cSrcweir 	OUString sChars =
2319cdf0e10cSrcweir 		GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
2320cdf0e10cSrcweir 													   nStarFontsConvFlags,
2321cdf0e10cSrcweir 													   sal_True, GetImport() );
2322cdf0e10cSrcweir 	GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
2323cdf0e10cSrcweir }
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir 
2326cdf0e10cSrcweir 
2327cdf0e10cSrcweir TYPEINIT1( XMLNumberedParaContext, SvXMLImportContext );
2328cdf0e10cSrcweir 
XMLNumberedParaContext(SvXMLImport & i_rImport,sal_uInt16 i_nPrefix,const OUString & i_rLocalName,const Reference<xml::sax::XAttributeList> & i_xAttrList)2329cdf0e10cSrcweir XMLNumberedParaContext::XMLNumberedParaContext(
2330cdf0e10cSrcweir         SvXMLImport& i_rImport,
2331cdf0e10cSrcweir         sal_uInt16 i_nPrefix,
2332cdf0e10cSrcweir         const OUString& i_rLocalName,
2333cdf0e10cSrcweir         const Reference< xml::sax::XAttributeList > & i_xAttrList ) :
2334cdf0e10cSrcweir     SvXMLImportContext( i_rImport, i_nPrefix, i_rLocalName ),
2335cdf0e10cSrcweir     m_Level(0),
2336cdf0e10cSrcweir     m_StartValue(-1),
2337cdf0e10cSrcweir     m_ListId(),
2338cdf0e10cSrcweir     m_xNumRules()
2339cdf0e10cSrcweir {
2340cdf0e10cSrcweir     ::rtl::OUString StyleName;
2341cdf0e10cSrcweir 
2342cdf0e10cSrcweir     const SvXMLTokenMap& rTokenMap(
2343cdf0e10cSrcweir         i_rImport.GetTextImport()->GetTextNumberedParagraphAttrTokenMap() );
2344cdf0e10cSrcweir 
2345cdf0e10cSrcweir     const sal_Int16 nAttrCount( i_xAttrList.is() ?
2346cdf0e10cSrcweir         i_xAttrList->getLength() : 0 );
2347cdf0e10cSrcweir     for ( sal_Int16 i=0; i < nAttrCount; i++ )
2348cdf0e10cSrcweir     {
2349cdf0e10cSrcweir         const ::rtl::OUString& rAttrName( i_xAttrList->getNameByIndex( i )  );
2350cdf0e10cSrcweir         const ::rtl::OUString& rValue   ( i_xAttrList->getValueByIndex( i ) );
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir         ::rtl::OUString aLocalName;
2353cdf0e10cSrcweir         const sal_uInt16 nPrefix(
2354cdf0e10cSrcweir             GetImport().GetNamespaceMap().GetKeyByAttrName(
2355cdf0e10cSrcweir                 rAttrName, &aLocalName ) );
2356cdf0e10cSrcweir         switch( rTokenMap.Get( nPrefix, aLocalName ) )
2357cdf0e10cSrcweir         {
2358cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_XMLID:
2359cdf0e10cSrcweir                 m_XmlId = rValue;
2360cdf0e10cSrcweir //FIXME: there is no UNO API for lists
2361cdf0e10cSrcweir                 break;
2362cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LIST_ID:
2363cdf0e10cSrcweir                 m_ListId = rValue;
2364cdf0e10cSrcweir                 break;
2365cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_LEVEL:
2366cdf0e10cSrcweir                 {
2367cdf0e10cSrcweir                     sal_Int32 nTmp = rValue.toInt32();
2368cdf0e10cSrcweir                     if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2369cdf0e10cSrcweir                         m_Level = static_cast<sal_uInt16>(nTmp) - 1;
2370cdf0e10cSrcweir                     }
2371cdf0e10cSrcweir                 }
2372cdf0e10cSrcweir                 break;
2373cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_STYLE_NAME:
2374cdf0e10cSrcweir                 StyleName = rValue;
2375cdf0e10cSrcweir                 break;
2376cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_CONTINUE_NUMBERING:
2377cdf0e10cSrcweir                 // this attribute is deprecated
2378cdf0e10cSrcweir //                ContinuteNumbering = IsXMLToken(rValue, XML_TRUE);
2379cdf0e10cSrcweir                 break;
2380cdf0e10cSrcweir             case XML_TOK_TEXT_NUMBERED_PARAGRAPH_START_VALUE:
2381cdf0e10cSrcweir                 {
2382cdf0e10cSrcweir                     sal_Int32 nTmp = rValue.toInt32();
2383cdf0e10cSrcweir                     if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2384cdf0e10cSrcweir                         m_StartValue = static_cast<sal_Int16>(nTmp);
2385cdf0e10cSrcweir                     }
2386cdf0e10cSrcweir                 }
2387cdf0e10cSrcweir                 break;
2388cdf0e10cSrcweir         }
2389cdf0e10cSrcweir     }
2390cdf0e10cSrcweir 
2391cdf0e10cSrcweir     XMLTextListsHelper& rTextListsHelper(
2392cdf0e10cSrcweir         i_rImport.GetTextImport()->GetTextListHelper() );
2393cdf0e10cSrcweir     if (!m_ListId.getLength()) {
2394cdf0e10cSrcweir         OSL_ENSURE( ! i_rImport.GetODFVersion().equalsAsciiL(
2395cdf0e10cSrcweir                         RTL_CONSTASCII_STRINGPARAM("1.2") ),
2396cdf0e10cSrcweir             "invalid numbered-paragraph: no list-id (1.2)");
2397cdf0e10cSrcweir         m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level,
2398cdf0e10cSrcweir             StyleName);
2399cdf0e10cSrcweir         OSL_ENSURE(m_ListId.getLength(), "numbered-paragraph: no ListId");
2400cdf0e10cSrcweir         if (!m_ListId.getLength()) {
2401cdf0e10cSrcweir             return;
2402cdf0e10cSrcweir         }
2403cdf0e10cSrcweir     }
2404cdf0e10cSrcweir     m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport,
2405cdf0e10cSrcweir         m_ListId, m_Level, StyleName);
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir     OSL_ENSURE(m_xNumRules.is(), "numbered-paragraph: no NumRules");
2408cdf0e10cSrcweir 
2409cdf0e10cSrcweir     i_rImport.GetTextImport()->GetTextListHelper().PushListContext( this );
2410cdf0e10cSrcweir }
2411cdf0e10cSrcweir 
~XMLNumberedParaContext()2412cdf0e10cSrcweir XMLNumberedParaContext::~XMLNumberedParaContext()
2413cdf0e10cSrcweir {
2414cdf0e10cSrcweir }
2415cdf0e10cSrcweir 
EndElement()2416cdf0e10cSrcweir void XMLNumberedParaContext::EndElement()
2417cdf0e10cSrcweir {
2418cdf0e10cSrcweir     if (m_ListId.getLength()) {
2419cdf0e10cSrcweir         GetImport().GetTextImport()->PopListContext();
2420cdf0e10cSrcweir     }
2421cdf0e10cSrcweir }
2422cdf0e10cSrcweir 
CreateChildContext(sal_uInt16 i_nPrefix,const OUString & i_rLocalName,const Reference<xml::sax::XAttributeList> & i_xAttrList)2423cdf0e10cSrcweir SvXMLImportContext *XMLNumberedParaContext::CreateChildContext(
2424cdf0e10cSrcweir     sal_uInt16 i_nPrefix, const OUString& i_rLocalName,
2425cdf0e10cSrcweir     const Reference< xml::sax::XAttributeList > & i_xAttrList )
2426cdf0e10cSrcweir {
2427cdf0e10cSrcweir     SvXMLImportContext *pContext( 0 );
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir     if ( XML_NAMESPACE_TEXT == i_nPrefix )
2430cdf0e10cSrcweir     {
2431cdf0e10cSrcweir         bool bIsHeader( IsXMLToken( i_rLocalName, XML_H ) );
2432cdf0e10cSrcweir         if ( bIsHeader || IsXMLToken( i_rLocalName, XML_P ) )
2433cdf0e10cSrcweir         {
2434cdf0e10cSrcweir             pContext = new XMLParaContext( GetImport(),
2435cdf0e10cSrcweir                 i_nPrefix, i_rLocalName, i_xAttrList, bIsHeader );
2436cdf0e10cSrcweir // ignore text:number       } else if (IsXMLToken( i_rLocalName, XML_NUMBER )) {
2437cdf0e10cSrcweir         }
2438cdf0e10cSrcweir     }
2439cdf0e10cSrcweir 
2440cdf0e10cSrcweir     if (!pContext) {
2441cdf0e10cSrcweir         pContext = SvXMLImportContext::CreateChildContext(
2442cdf0e10cSrcweir             i_nPrefix, i_rLocalName, i_xAttrList );
2443cdf0e10cSrcweir     }
2444cdf0e10cSrcweir 
2445cdf0e10cSrcweir     return pContext;
2446cdf0e10cSrcweir }
2447