1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txtparaimphint.hxx,v $
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
61 Reference
< XTextRange
> xStart
;
62 Reference
< XTextRange
> xEnd
;
68 XMLHint_Impl( sal_uInt8 nTyp
,
69 const Reference
< XTextRange
> & rS
,
70 const Reference
< XTextRange
> & rE
) :
77 XMLHint_Impl( sal_uInt8 nTyp
,
78 const Reference
< XTextRange
> & rS
) :
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
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
122 XMLReferenceHint_Impl( const OUString
& rRefName
,
123 const Reference
< XTextRange
> & rPos
) :
124 XMLHint_Impl( XML_HINT_REFERENCE
, rPos
, rPos
),
129 virtual ~XMLReferenceHint_Impl() {}
131 const OUString
& GetRefName() const { return sRefName
; }
134 class XMLHyperlinkHint_Impl
: public XMLHint_Impl
138 OUString sTargetFrameName
;
140 OUString sVisitedStyleName
;
141 XMLEventsImportContext
* pEvents
;
145 XMLHyperlinkHint_Impl( const Reference
< XTextRange
> & rPos
) :
146 XMLHint_Impl( XML_HINT_HYPERLINK
, rPos
, rPos
),
151 virtual ~XMLHyperlinkHint_Impl()
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
171 void SetEventsContext( XMLEventsImportContext
* pCtxt
)
180 class XMLIndexMarkHint_Impl
: public XMLHint_Impl
182 const Reference
<beans::XPropertySet
> xIndexMarkPropSet
;
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
),
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
),
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
215 OUString sTextStyleName
;
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
;
242 XMLTextFrameHint_Impl( SvXMLImportContext
* pContext
,
243 const Reference
< XTextRange
> & rPos
) :
244 XMLHint_Impl( XML_HINT_TEXT_FRAME
, rPos
, rPos
),
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
)
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();
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
)
288 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
289 bRet
= TextContentAnchorType_AT_CHARACTER
==
290 PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)
296 // --> DVO, OD 2004-07-14 #i26791#
297 class XMLDrawHint_Impl
: public XMLHint_Impl
299 SvXMLImportContextRef xContext
;
303 XMLDrawHint_Impl( SvXMLShapeContext
* pContext
,
304 const Reference
< XTextRange
> & rPos
) :
305 XMLHint_Impl( XML_HINT_DRAW
, rPos
, rPos
),
310 virtual ~XMLDrawHint_Impl()
314 // --> OD 2004-08-24 #i33242#
315 Reference
< drawing::XShape
> GetShape() const
317 return static_cast<SvXMLShapeContext
*>(&xContext
)->getShape();