update dev300-m58
[ooovba.git] / xmloff / source / text / txtparaimphint.hxx
blobff8ab8746e73e0376e3794f766b5af0b620522f5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtparaimphint.hxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _XMLOFF_TXTPARAIMPHINT_HXX
31 #define _XMLOFF_TXTPARAIMPHINT_HXX
33 #include <rtl/ustring.hxx>
34 #include <rtl/ustrbuf.hxx>
35 #include <tools/debug.hxx>
36 #include <svtools/svarray.hxx>
37 #include <xmloff/xmlimp.hxx>
38 #include "XMLTextFrameContext.hxx"
39 #include <xmloff/XMLEventsImportContext.hxx>
41 using ::rtl::OUString;
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::text;
45 using namespace ::xmloff::token;
47 // ---------------------------------------------------------------------
49 #define XML_HINT_STYLE 1
50 #define XML_HINT_REFERENCE 2
51 #define XML_HINT_HYPERLINK 3
52 #define XML_HINT_RUBY 4
53 #define XML_HINT_INDEX_MARK 5
54 #define XML_HINT_TEXT_FRAME 6
55 // --> DVO, OD 2004-07-14 #i26791#
56 #define XML_HINT_DRAW 7
57 // <--
59 class XMLHint_Impl
61 Reference < XTextRange > xStart;
62 Reference < XTextRange > xEnd;
64 sal_uInt8 nType;
66 public:
68 XMLHint_Impl( sal_uInt8 nTyp,
69 const Reference < XTextRange > & rS,
70 const Reference < XTextRange > & rE ) :
71 xStart( rS ),
72 xEnd( rE ),
73 nType( nTyp )
77 XMLHint_Impl( sal_uInt8 nTyp,
78 const Reference < XTextRange > & rS ) :
79 xStart( rS ),
80 nType( nTyp )
84 virtual ~XMLHint_Impl() {}
86 const Reference < XTextRange > & GetStart() const { return xStart; }
87 const Reference < XTextRange > & GetEnd() const { return xEnd; }
88 void SetEnd( const Reference < XTextRange > & rPos ) { xEnd = rPos; }
90 // We don't use virtual methods to differ between the sub classes,
91 // because this seems to be to expensive if compared to inline methods.
92 sal_uInt8 GetType() const { return nType; }
93 sal_Bool IsStyle() { return XML_HINT_STYLE==nType; }
94 sal_Bool IsReference() { return XML_HINT_REFERENCE==nType; }
95 sal_Bool IsHyperlink() { return XML_HINT_HYPERLINK==nType; }
96 sal_Bool IsIndexMark() { return XML_HINT_INDEX_MARK==nType; }
99 class XMLStyleHint_Impl : public XMLHint_Impl
101 OUString sStyleName;
103 public:
105 XMLStyleHint_Impl( const OUString& rStyleName,
106 const Reference < XTextRange > & rPos ) :
107 XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
108 sStyleName( rStyleName )
111 virtual ~XMLStyleHint_Impl() {}
113 const OUString& GetStyleName() const { return sStyleName; }
116 class XMLReferenceHint_Impl : public XMLHint_Impl
118 OUString sRefName;
120 public:
122 XMLReferenceHint_Impl( const OUString& rRefName,
123 const Reference < XTextRange > & rPos ) :
124 XMLHint_Impl( XML_HINT_REFERENCE, rPos, rPos ),
125 sRefName( rRefName )
129 virtual ~XMLReferenceHint_Impl() {}
131 const OUString& GetRefName() const { return sRefName; }
134 class XMLHyperlinkHint_Impl : public XMLHint_Impl
136 OUString sHRef;
137 OUString sName;
138 OUString sTargetFrameName;
139 OUString sStyleName;
140 OUString sVisitedStyleName;
141 XMLEventsImportContext* pEvents;
143 public:
145 XMLHyperlinkHint_Impl( const Reference < XTextRange > & rPos ) :
146 XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos ),
147 pEvents( NULL )
151 virtual ~XMLHyperlinkHint_Impl()
153 if (NULL != pEvents)
154 pEvents->ReleaseRef();
157 void SetHRef( const OUString& s ) { sHRef = s; }
158 const OUString& GetHRef() const { return sHRef; }
159 void SetName( const OUString& s ) { sName = s; }
160 const OUString& GetName() const { return sName; }
161 void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
162 const OUString& GetTargetFrameName() const { return sTargetFrameName; }
163 void SetStyleName( const OUString& s ) { sStyleName = s; }
164 const OUString& GetStyleName() const { return sStyleName; }
165 void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
166 const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
167 XMLEventsImportContext* GetEventsContext() const
169 return pEvents;
171 void SetEventsContext( XMLEventsImportContext* pCtxt )
173 pEvents = pCtxt;
174 if (pEvents != NULL)
175 pEvents->AddRef();
180 class XMLIndexMarkHint_Impl : public XMLHint_Impl
182 const Reference<beans::XPropertySet> xIndexMarkPropSet;
184 const OUString sID;
186 public:
188 XMLIndexMarkHint_Impl( const Reference < beans::XPropertySet > & rPropSet,
189 const Reference < XTextRange > & rPos ) :
190 XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
191 xIndexMarkPropSet( rPropSet ),
192 sID()
196 XMLIndexMarkHint_Impl( const Reference < beans::XPropertySet > & rPropSet,
197 const Reference < XTextRange > & rPos,
198 OUString sIDString) :
199 XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
200 xIndexMarkPropSet( rPropSet ),
201 sID(sIDString)
205 virtual ~XMLIndexMarkHint_Impl() {}
207 const Reference<beans::XPropertySet> & GetMark() const
208 { return xIndexMarkPropSet; }
209 const OUString& GetID() const { return sID; }
212 class XMLRubyHint_Impl : public XMLHint_Impl
214 OUString sStyleName;
215 OUString sTextStyleName;
216 OUString sText;
218 public:
220 XMLRubyHint_Impl( const Reference < XTextRange > & rPos ) :
221 XMLHint_Impl( XML_HINT_RUBY, rPos, rPos )
225 virtual ~XMLRubyHint_Impl() {}
227 void SetStyleName( const OUString& s ) { sStyleName = s; }
228 const OUString& GetStyleName() const { return sStyleName; }
229 void SetTextStyleName( const OUString& s ) { sTextStyleName = s; }
230 const OUString& GetTextStyleName() const { return sTextStyleName; }
231 void AppendText( const OUString& s ) { sText += s; }
232 const OUString& GetText() const { return sText; }
235 class XMLTextFrameHint_Impl : public XMLHint_Impl
237 // OD 2004-04-20 #i26791#
238 SvXMLImportContextRef xContext;
240 public:
242 XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
243 const Reference < XTextRange > & rPos ) :
244 XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
245 xContext( pContext )
249 virtual ~XMLTextFrameHint_Impl()
253 Reference < XTextContent > GetTextContent() const
255 Reference <XTextContent > xTxt;
256 SvXMLImportContext *pContext = &xContext;
257 if( pContext->ISA( XMLTextFrameContext ) )
258 xTxt = PTR_CAST( XMLTextFrameContext, pContext )->GetTextContent();
259 else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
260 xTxt = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
261 ->GetTextContent();
263 return xTxt;
266 // --> OD 2004-08-24 #i33242#
267 Reference < drawing::XShape > GetShape() const
269 Reference < drawing::XShape > xShape;
270 SvXMLImportContext *pContext = &xContext;
271 if( pContext->ISA( XMLTextFrameContext ) )
272 xShape = PTR_CAST( XMLTextFrameContext, pContext )->GetShape();
273 else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
274 xShape = PTR_CAST( XMLTextFrameHyperlinkContext, pContext )->GetShape();
276 return xShape;
278 // <--
280 sal_Bool IsBoundAtChar() const
282 sal_Bool bRet = sal_False;
283 SvXMLImportContext *pContext = &xContext;
284 if( pContext->ISA( XMLTextFrameContext ) )
285 bRet = TextContentAnchorType_AT_CHARACTER ==
286 PTR_CAST( XMLTextFrameContext, pContext )
287 ->GetAnchorType();
288 else if( pContext->ISA( XMLTextFrameHyperlinkContext ) )
289 bRet = TextContentAnchorType_AT_CHARACTER ==
290 PTR_CAST( XMLTextFrameHyperlinkContext, pContext )
291 ->GetAnchorType();
292 return bRet;
296 // --> DVO, OD 2004-07-14 #i26791#
297 class XMLDrawHint_Impl : public XMLHint_Impl
299 SvXMLImportContextRef xContext;
301 public:
303 XMLDrawHint_Impl( SvXMLShapeContext* pContext,
304 const Reference < XTextRange > & rPos ) :
305 XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
306 xContext( pContext )
310 virtual ~XMLDrawHint_Impl()
314 // --> OD 2004-08-24 #i33242#
315 Reference < drawing::XShape > GetShape() const
317 return static_cast<SvXMLShapeContext*>(&xContext)->getShape();
319 // <--
321 // <--
322 #endif