1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _XMLOFF_TXTPARAIMPHINT_HXX
20 #define _XMLOFF_TXTPARAIMPHINT_HXX
22 #include <rtl/ustring.hxx>
23 #include <rtl/ustrbuf.hxx>
24 #include <xmloff/xmlimp.hxx>
25 #include "XMLTextFrameContext.hxx"
26 #include <xmloff/XMLEventsImportContext.hxx>
28 // ---------------------------------------------------------------------
30 #define XML_HINT_STYLE 1
31 #define XML_HINT_REFERENCE 2
32 #define XML_HINT_HYPERLINK 3
33 #define XML_HINT_INDEX_MARK 5
34 #define XML_HINT_TEXT_FRAME 6
35 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
36 #define XML_HINT_DRAW 7
40 css::uno::Reference
< css::text::XTextRange
> xStart
;
41 css::uno::Reference
< css::text::XTextRange
> xEnd
;
47 XMLHint_Impl( sal_uInt8 nTyp
,
48 const css::uno::Reference
< css::text::XTextRange
> & rS
,
49 const css::uno::Reference
< css::text::XTextRange
> & rE
) :
56 XMLHint_Impl( sal_uInt8 nTyp
,
57 const css::uno::Reference
< css::text::XTextRange
> & rS
) :
63 virtual ~XMLHint_Impl() {}
65 const css::uno::Reference
< css::text::XTextRange
> & GetStart() const { return xStart
; }
66 const css::uno::Reference
< css::text::XTextRange
> & GetEnd() const { return xEnd
; }
67 void SetEnd( const css::uno::Reference
< css::text::XTextRange
> & rPos
) { xEnd
= rPos
; }
69 // We don't use virtual methods to differ between the sub classes,
70 // because this seems to be to expensive if compared to inline methods.
71 sal_uInt8
GetType() const { return nType
; }
72 sal_Bool
IsStyle() { return XML_HINT_STYLE
==nType
; }
73 sal_Bool
IsReference() { return XML_HINT_REFERENCE
==nType
; }
74 sal_Bool
IsHyperlink() { return XML_HINT_HYPERLINK
==nType
; }
75 sal_Bool
IsIndexMark() { return XML_HINT_INDEX_MARK
==nType
; }
78 class XMLStyleHint_Impl
: public XMLHint_Impl
84 XMLStyleHint_Impl( const OUString
& rStyleName
,
85 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
86 XMLHint_Impl( XML_HINT_STYLE
, rPos
, rPos
),
87 sStyleName( rStyleName
)
90 virtual ~XMLStyleHint_Impl() {}
92 const OUString
& GetStyleName() const { return sStyleName
; }
95 class XMLReferenceHint_Impl
: public XMLHint_Impl
101 XMLReferenceHint_Impl( const OUString
& rRefName
,
102 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
103 XMLHint_Impl( XML_HINT_REFERENCE
, rPos
, rPos
),
108 virtual ~XMLReferenceHint_Impl() {}
110 const OUString
& GetRefName() const { return sRefName
; }
113 class XMLHyperlinkHint_Impl
: public XMLHint_Impl
117 OUString sTargetFrameName
;
119 OUString sVisitedStyleName
;
120 XMLEventsImportContext
* pEvents
;
124 XMLHyperlinkHint_Impl( const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
125 XMLHint_Impl( XML_HINT_HYPERLINK
, rPos
, rPos
),
130 virtual ~XMLHyperlinkHint_Impl()
133 pEvents
->ReleaseRef();
136 void SetHRef( const OUString
& s
) { sHRef
= s
; }
137 const OUString
& GetHRef() const { return sHRef
; }
138 void SetName( const OUString
& s
) { sName
= s
; }
139 const OUString
& GetName() const { return sName
; }
140 void SetTargetFrameName( const OUString
& s
) { sTargetFrameName
= s
; }
141 const OUString
& GetTargetFrameName() const { return sTargetFrameName
; }
142 void SetStyleName( const OUString
& s
) { sStyleName
= s
; }
143 const OUString
& GetStyleName() const { return sStyleName
; }
144 void SetVisitedStyleName( const OUString
& s
) { sVisitedStyleName
= s
; }
145 const OUString
& GetVisitedStyleName() const { return sVisitedStyleName
; }
146 XMLEventsImportContext
* GetEventsContext() const
150 void SetEventsContext( XMLEventsImportContext
* pCtxt
)
159 class XMLIndexMarkHint_Impl
: public XMLHint_Impl
161 const css::uno::Reference
<css::beans::XPropertySet
> xIndexMarkPropSet
;
167 XMLIndexMarkHint_Impl( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
168 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
169 XMLHint_Impl( XML_HINT_INDEX_MARK
, rPos
, rPos
),
170 xIndexMarkPropSet( rPropSet
),
175 XMLIndexMarkHint_Impl( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
176 const css::uno::Reference
< css::text::XTextRange
> & rPos
,
177 OUString sIDString
) :
178 XMLHint_Impl( XML_HINT_INDEX_MARK
, rPos
, rPos
),
179 xIndexMarkPropSet( rPropSet
),
184 virtual ~XMLIndexMarkHint_Impl() {}
186 const css::uno::Reference
<css::beans::XPropertySet
> & GetMark() const
187 { return xIndexMarkPropSet
; }
188 const OUString
& GetID() const { return sID
; }
192 class XMLTextFrameHint_Impl
: public XMLHint_Impl
194 // OD 2004-04-20 #i26791#
195 SvXMLImportContextRef xContext
;
199 XMLTextFrameHint_Impl( SvXMLImportContext
* pContext
,
200 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
201 XMLHint_Impl( XML_HINT_TEXT_FRAME
, rPos
, rPos
),
206 virtual ~XMLTextFrameHint_Impl()
210 css::uno::Reference
< css::text::XTextContent
> GetTextContent() const
212 css::uno::Reference
< css::text::XTextContent
> xTxt
;
213 SvXMLImportContext
*pContext
= &xContext
;
214 if( pContext
->ISA( XMLTextFrameContext
) )
215 xTxt
= PTR_CAST( XMLTextFrameContext
, pContext
)->GetTextContent();
216 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
217 xTxt
= PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)
223 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
224 css::uno::Reference
< css::drawing::XShape
> GetShape() const
226 css::uno::Reference
< css::drawing::XShape
> xShape
;
227 SvXMLImportContext
*pContext
= &xContext
;
228 if( pContext
->ISA( XMLTextFrameContext
) )
229 xShape
= PTR_CAST( XMLTextFrameContext
, pContext
)->GetShape();
230 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
231 xShape
= PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)->GetShape();
236 sal_Bool
IsBoundAtChar() const
238 sal_Bool bRet
= sal_False
;
239 SvXMLImportContext
*pContext
= &xContext
;
240 if( pContext
->ISA( XMLTextFrameContext
) )
241 bRet
= css::text::TextContentAnchorType_AT_CHARACTER
==
242 PTR_CAST( XMLTextFrameContext
, pContext
)
244 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
245 bRet
= css::text::TextContentAnchorType_AT_CHARACTER
==
246 PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)
252 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
253 class XMLDrawHint_Impl
: public XMLHint_Impl
255 SvXMLImportContextRef xContext
;
259 XMLDrawHint_Impl( SvXMLShapeContext
* pContext
,
260 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
261 XMLHint_Impl( XML_HINT_DRAW
, rPos
, rPos
),
266 virtual ~XMLDrawHint_Impl()
270 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
271 css::uno::Reference
< css::drawing::XShape
> GetShape() const
273 return static_cast<SvXMLShapeContext
*>(&xContext
)->getShape();
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */