1*ecfe53c5SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ecfe53c5SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ecfe53c5SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ecfe53c5SAndrew Rist  * distributed with this work for additional information
6*ecfe53c5SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ecfe53c5SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ecfe53c5SAndrew Rist  * "License"); you may not use this file except in compliance
9*ecfe53c5SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ecfe53c5SAndrew Rist  *
11*ecfe53c5SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ecfe53c5SAndrew Rist  *
13*ecfe53c5SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ecfe53c5SAndrew Rist  * software distributed under the License is distributed on an
15*ecfe53c5SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ecfe53c5SAndrew Rist  * KIND, either express or implied.  See the License for the
17*ecfe53c5SAndrew Rist  * specific language governing permissions and limitations
18*ecfe53c5SAndrew Rist  * under the License.
19*ecfe53c5SAndrew Rist  *
20*ecfe53c5SAndrew Rist  *************************************************************/
21*ecfe53c5SAndrew Rist 
22*ecfe53c5SAndrew Rist 
23cdf0e10cSrcweir #ifndef _XMLOFF_TXTPARAIMPHINT_HXX
24cdf0e10cSrcweir #define _XMLOFF_TXTPARAIMPHINT_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <rtl/ustring.hxx>
27cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
28cdf0e10cSrcweir #include <tools/debug.hxx>
29cdf0e10cSrcweir #include <svl/svarray.hxx>
30cdf0e10cSrcweir #include <xmloff/xmlimp.hxx>
31cdf0e10cSrcweir #include "XMLTextFrameContext.hxx"
32cdf0e10cSrcweir #include <xmloff/XMLEventsImportContext.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using ::rtl::OUString;
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir using namespace ::com::sun::star::uno;
37cdf0e10cSrcweir using namespace ::com::sun::star::text;
38cdf0e10cSrcweir using namespace ::xmloff::token;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir // ---------------------------------------------------------------------
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define XML_HINT_STYLE 1
43cdf0e10cSrcweir #define XML_HINT_REFERENCE 2
44cdf0e10cSrcweir #define XML_HINT_HYPERLINK 3
45cdf0e10cSrcweir #define XML_HINT_INDEX_MARK 5
46cdf0e10cSrcweir #define XML_HINT_TEXT_FRAME 6
47cdf0e10cSrcweir // --> DVO, OD 2004-07-14 #i26791#
48cdf0e10cSrcweir #define XML_HINT_DRAW 7
49cdf0e10cSrcweir // <--
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class XMLHint_Impl
52cdf0e10cSrcweir {
53cdf0e10cSrcweir 	Reference < XTextRange > xStart;
54cdf0e10cSrcweir 	Reference < XTextRange > xEnd;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 	sal_uInt8 nType;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir public:
59cdf0e10cSrcweir 
XMLHint_Impl(sal_uInt8 nTyp,const Reference<XTextRange> & rS,const Reference<XTextRange> & rE)60cdf0e10cSrcweir 	XMLHint_Impl( sal_uInt8 nTyp,
61cdf0e10cSrcweir 				  const Reference < XTextRange > & rS,
62cdf0e10cSrcweir 				  const Reference < XTextRange > & rE ) :
63cdf0e10cSrcweir 		xStart( rS ),
64cdf0e10cSrcweir 		xEnd( rE ),
65cdf0e10cSrcweir 		nType( nTyp )
66cdf0e10cSrcweir 	{
67cdf0e10cSrcweir 	}
68cdf0e10cSrcweir 
XMLHint_Impl(sal_uInt8 nTyp,const Reference<XTextRange> & rS)69cdf0e10cSrcweir 	XMLHint_Impl( sal_uInt8 nTyp,
70cdf0e10cSrcweir 				  const Reference < XTextRange > & rS ) :
71cdf0e10cSrcweir 		xStart( rS ),
72cdf0e10cSrcweir 		nType( nTyp )
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir 
~XMLHint_Impl()76cdf0e10cSrcweir 	virtual ~XMLHint_Impl() {}
77cdf0e10cSrcweir 
GetStart() const78cdf0e10cSrcweir 	const Reference < XTextRange > & GetStart() const { return xStart; }
GetEnd() const79cdf0e10cSrcweir 	const Reference < XTextRange > & GetEnd() const { return xEnd; }
SetEnd(const Reference<XTextRange> & rPos)80cdf0e10cSrcweir 	void SetEnd( const Reference < XTextRange > & rPos ) { xEnd = rPos; }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	// We don't use virtual methods to differ between the sub classes,
83cdf0e10cSrcweir 	// because this seems to be to expensive if compared to inline methods.
GetType() const84cdf0e10cSrcweir 	sal_uInt8 GetType() const { return nType; }
IsStyle()85cdf0e10cSrcweir 	sal_Bool IsStyle() { return XML_HINT_STYLE==nType; }
IsReference()86cdf0e10cSrcweir 	sal_Bool IsReference() { return XML_HINT_REFERENCE==nType; }
IsHyperlink()87cdf0e10cSrcweir 	sal_Bool IsHyperlink() { return XML_HINT_HYPERLINK==nType; }
IsIndexMark()88cdf0e10cSrcweir 	sal_Bool IsIndexMark() { return XML_HINT_INDEX_MARK==nType; }
89cdf0e10cSrcweir };
90cdf0e10cSrcweir 
91cdf0e10cSrcweir class XMLStyleHint_Impl : public XMLHint_Impl
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	OUString				 sStyleName;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir public:
96cdf0e10cSrcweir 
XMLStyleHint_Impl(const OUString & rStyleName,const Reference<XTextRange> & rPos)97cdf0e10cSrcweir 	XMLStyleHint_Impl( const OUString& rStyleName,
98cdf0e10cSrcweir 				  	   const Reference < XTextRange > & rPos ) :
99cdf0e10cSrcweir 		XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
100cdf0e10cSrcweir 		sStyleName( rStyleName )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 	}
~XMLStyleHint_Impl()103cdf0e10cSrcweir 	virtual ~XMLStyleHint_Impl() {}
104cdf0e10cSrcweir 
GetStyleName() const105cdf0e10cSrcweir 	const OUString& GetStyleName() const { return sStyleName; }
106cdf0e10cSrcweir };
107cdf0e10cSrcweir 
108cdf0e10cSrcweir class XMLReferenceHint_Impl : public XMLHint_Impl
109cdf0e10cSrcweir {
110cdf0e10cSrcweir 	OUString				 sRefName;
111cdf0e10cSrcweir 
112cdf0e10cSrcweir public:
113cdf0e10cSrcweir 
XMLReferenceHint_Impl(const OUString & rRefName,const Reference<XTextRange> & rPos)114cdf0e10cSrcweir 	XMLReferenceHint_Impl( const OUString& rRefName,
115cdf0e10cSrcweir 				  		   const Reference < XTextRange > & rPos ) :
116cdf0e10cSrcweir 		XMLHint_Impl( XML_HINT_REFERENCE, rPos, rPos ),
117cdf0e10cSrcweir 		sRefName( rRefName )
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 	}
120cdf0e10cSrcweir 
~XMLReferenceHint_Impl()121cdf0e10cSrcweir 	virtual ~XMLReferenceHint_Impl() {}
122cdf0e10cSrcweir 
GetRefName() const123cdf0e10cSrcweir 	const OUString& GetRefName() const { return sRefName; }
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir class XMLHyperlinkHint_Impl : public XMLHint_Impl
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	OUString				 sHRef;
129cdf0e10cSrcweir 	OUString				 sName;
130cdf0e10cSrcweir 	OUString				 sTargetFrameName;
131cdf0e10cSrcweir 	OUString				 sStyleName;
132cdf0e10cSrcweir 	OUString				 sVisitedStyleName;
133cdf0e10cSrcweir 	XMLEventsImportContext*	 pEvents;
134cdf0e10cSrcweir 
135cdf0e10cSrcweir public:
136cdf0e10cSrcweir 
XMLHyperlinkHint_Impl(const Reference<XTextRange> & rPos)137cdf0e10cSrcweir 	XMLHyperlinkHint_Impl( const Reference < XTextRange > & rPos ) :
138cdf0e10cSrcweir 		XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos ),
139cdf0e10cSrcweir 		pEvents( NULL )
140cdf0e10cSrcweir 	{
141cdf0e10cSrcweir 	}
142cdf0e10cSrcweir 
~XMLHyperlinkHint_Impl()143cdf0e10cSrcweir 	virtual ~XMLHyperlinkHint_Impl()
144cdf0e10cSrcweir 	{
145cdf0e10cSrcweir 		if (NULL != pEvents)
146cdf0e10cSrcweir 			pEvents->ReleaseRef();
147cdf0e10cSrcweir 	}
148cdf0e10cSrcweir 
SetHRef(const OUString & s)149cdf0e10cSrcweir 	void SetHRef( const OUString& s ) { sHRef = s; }
GetHRef() const150cdf0e10cSrcweir 	const OUString& GetHRef() const { return sHRef; }
SetName(const OUString & s)151cdf0e10cSrcweir 	void SetName( const OUString& s ) { sName = s; }
GetName() const152cdf0e10cSrcweir 	const OUString& GetName() const { return sName; }
SetTargetFrameName(const OUString & s)153cdf0e10cSrcweir 	void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
GetTargetFrameName() const154cdf0e10cSrcweir 	const OUString& GetTargetFrameName() const { return sTargetFrameName; }
SetStyleName(const OUString & s)155cdf0e10cSrcweir 	void SetStyleName( const OUString& s ) { sStyleName = s; }
GetStyleName() const156cdf0e10cSrcweir 	const OUString& GetStyleName() const { return sStyleName; }
SetVisitedStyleName(const OUString & s)157cdf0e10cSrcweir 	void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
GetVisitedStyleName() const158cdf0e10cSrcweir 	const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
GetEventsContext() const159cdf0e10cSrcweir     XMLEventsImportContext* GetEventsContext() const
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         return pEvents;
162cdf0e10cSrcweir     }
SetEventsContext(XMLEventsImportContext * pCtxt)163cdf0e10cSrcweir     void SetEventsContext( XMLEventsImportContext* pCtxt )
164cdf0e10cSrcweir     {
165cdf0e10cSrcweir         pEvents = pCtxt;
166cdf0e10cSrcweir         if (pEvents != NULL)
167cdf0e10cSrcweir             pEvents->AddRef();
168cdf0e10cSrcweir     }
169cdf0e10cSrcweir };
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 
172cdf0e10cSrcweir class XMLIndexMarkHint_Impl : public XMLHint_Impl
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	const Reference<beans::XPropertySet> xIndexMarkPropSet;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	const OUString sID;
177cdf0e10cSrcweir 
178cdf0e10cSrcweir public:
179cdf0e10cSrcweir 
XMLIndexMarkHint_Impl(const Reference<beans::XPropertySet> & rPropSet,const Reference<XTextRange> & rPos)180cdf0e10cSrcweir 	XMLIndexMarkHint_Impl( const Reference < beans::XPropertySet > & rPropSet,
181cdf0e10cSrcweir 						   const Reference < XTextRange > & rPos ) :
182cdf0e10cSrcweir 		XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
183cdf0e10cSrcweir 		xIndexMarkPropSet( rPropSet ),
184cdf0e10cSrcweir 		sID()
185cdf0e10cSrcweir 	{
186cdf0e10cSrcweir 	}
187cdf0e10cSrcweir 
XMLIndexMarkHint_Impl(const Reference<beans::XPropertySet> & rPropSet,const Reference<XTextRange> & rPos,OUString sIDString)188cdf0e10cSrcweir 	XMLIndexMarkHint_Impl( const Reference < beans::XPropertySet > & rPropSet,
189cdf0e10cSrcweir 						   const Reference < XTextRange > & rPos,
190cdf0e10cSrcweir 						   OUString sIDString) :
191cdf0e10cSrcweir 		XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
192cdf0e10cSrcweir 		xIndexMarkPropSet( rPropSet ),
193cdf0e10cSrcweir 		sID(sIDString)
194cdf0e10cSrcweir 	{
195cdf0e10cSrcweir 	}
196cdf0e10cSrcweir 
~XMLIndexMarkHint_Impl()197cdf0e10cSrcweir 	virtual ~XMLIndexMarkHint_Impl() {}
198cdf0e10cSrcweir 
GetMark() const199cdf0e10cSrcweir 	const Reference<beans::XPropertySet> & GetMark() const
200cdf0e10cSrcweir 		{ return xIndexMarkPropSet; }
GetID() const201cdf0e10cSrcweir 	const OUString& GetID() const { return sID; }
202cdf0e10cSrcweir };
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 
205cdf0e10cSrcweir class XMLTextFrameHint_Impl : public XMLHint_Impl
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     // OD 2004-04-20 #i26791#
208cdf0e10cSrcweir     SvXMLImportContextRef xContext;
209cdf0e10cSrcweir 
210cdf0e10cSrcweir public:
211cdf0e10cSrcweir 
XMLTextFrameHint_Impl(SvXMLImportContext * pContext,const Reference<XTextRange> & rPos)212cdf0e10cSrcweir     XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
213cdf0e10cSrcweir                            const Reference < XTextRange > & rPos ) :
214cdf0e10cSrcweir         XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
215cdf0e10cSrcweir         xContext( pContext )
216cdf0e10cSrcweir     {
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir 
~XMLTextFrameHint_Impl()219cdf0e10cSrcweir     virtual ~XMLTextFrameHint_Impl()
220cdf0e10cSrcweir     {
221cdf0e10cSrcweir     }
222cdf0e10cSrcweir 
GetTextContent() const223cdf0e10cSrcweir 	Reference < XTextContent > GetTextContent() const
224cdf0e10cSrcweir 	{
225cdf0e10cSrcweir 		Reference <XTextContent > xTxt;
226cdf0e10cSrcweir 		SvXMLImportContext *pContext = &xContext;
227cdf0e10cSrcweir 		if( pContext->ISA( XMLTextFrameContext ) )
228cdf0e10cSrcweir 			xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
229cdf0e10cSrcweir 		else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
230cdf0e10cSrcweir 			xTxt = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
231cdf0e10cSrcweir 						->GetTextContent();
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 		return xTxt;
234cdf0e10cSrcweir 	}
235cdf0e10cSrcweir 
236cdf0e10cSrcweir     // --> OD 2004-08-24 #i33242#
GetShape() const237cdf0e10cSrcweir     Reference < drawing::XShape > GetShape() const
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         Reference < drawing::XShape > xShape;
240cdf0e10cSrcweir         SvXMLImportContext *pContext = &xContext;
241cdf0e10cSrcweir         if( pContext->ISA( XMLTextFrameContext ) )
242cdf0e10cSrcweir             xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
243cdf0e10cSrcweir         else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
244cdf0e10cSrcweir             xShape = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )->GetShape();
245cdf0e10cSrcweir 
246cdf0e10cSrcweir         return xShape;
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir     // <--
249cdf0e10cSrcweir 
IsBoundAtChar() const250cdf0e10cSrcweir 	sal_Bool IsBoundAtChar() const
251cdf0e10cSrcweir 	{
252cdf0e10cSrcweir 		sal_Bool bRet = sal_False;
253cdf0e10cSrcweir 		SvXMLImportContext *pContext = &xContext;
254cdf0e10cSrcweir 		if( pContext->ISA( XMLTextFrameContext ) )
255cdf0e10cSrcweir 			bRet = TextContentAnchorType_AT_CHARACTER ==
256cdf0e10cSrcweir 				PTR_CAST( XMLTextFrameContext, pContext )
257cdf0e10cSrcweir 					->GetAnchorType();
258cdf0e10cSrcweir 		else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
259cdf0e10cSrcweir 			bRet = TextContentAnchorType_AT_CHARACTER ==
260cdf0e10cSrcweir 				PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
261cdf0e10cSrcweir 					->GetAnchorType();
262cdf0e10cSrcweir 		return bRet;
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir };
265cdf0e10cSrcweir 
266cdf0e10cSrcweir // --> DVO, OD 2004-07-14 #i26791#
267cdf0e10cSrcweir class XMLDrawHint_Impl : public XMLHint_Impl
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     SvXMLImportContextRef xContext;
270cdf0e10cSrcweir 
271cdf0e10cSrcweir public:
272cdf0e10cSrcweir 
XMLDrawHint_Impl(SvXMLShapeContext * pContext,const Reference<XTextRange> & rPos)273cdf0e10cSrcweir     XMLDrawHint_Impl( SvXMLShapeContext* pContext,
274cdf0e10cSrcweir                       const Reference < XTextRange > & rPos ) :
275cdf0e10cSrcweir         XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
276cdf0e10cSrcweir         xContext( pContext )
277cdf0e10cSrcweir     {
278cdf0e10cSrcweir     }
279cdf0e10cSrcweir 
~XMLDrawHint_Impl()280cdf0e10cSrcweir     virtual ~XMLDrawHint_Impl()
281cdf0e10cSrcweir     {
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     // --> OD 2004-08-24 #i33242#
GetShape() const285cdf0e10cSrcweir     Reference < drawing::XShape > GetShape() const
286cdf0e10cSrcweir     {
287cdf0e10cSrcweir         return static_cast<SvXMLShapeContext*>(&xContext)->getShape();
288cdf0e10cSrcweir     }
289cdf0e10cSrcweir     // <--
290cdf0e10cSrcweir };
291cdf0e10cSrcweir // <--
292cdf0e10cSrcweir #endif
293