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 INCLUDED_XMLOFF_SOURCE_TEXT_TXTPARAIMPHINT_HXX
20 #define INCLUDED_XMLOFF_SOURCE_TEXT_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 #define XML_HINT_STYLE 1
29 #define XML_HINT_REFERENCE 2
30 #define XML_HINT_HYPERLINK 3
31 #define XML_HINT_INDEX_MARK 5
32 #define XML_HINT_TEXT_FRAME 6
33 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
34 #define XML_HINT_DRAW 7
38 css::uno::Reference
< css::text::XTextRange
> xStart
;
39 css::uno::Reference
< css::text::XTextRange
> xEnd
;
45 XMLHint_Impl( sal_uInt8 nTyp
,
46 const css::uno::Reference
< css::text::XTextRange
> & rS
,
47 const css::uno::Reference
< css::text::XTextRange
> & rE
) :
54 XMLHint_Impl( sal_uInt8 nTyp
,
55 const css::uno::Reference
< css::text::XTextRange
> & rS
) :
61 virtual ~XMLHint_Impl() {}
63 const css::uno::Reference
< css::text::XTextRange
> & GetStart() const { return xStart
; }
64 const css::uno::Reference
< css::text::XTextRange
> & GetEnd() const { return xEnd
; }
65 void SetEnd( const css::uno::Reference
< css::text::XTextRange
> & rPos
) { xEnd
= rPos
; }
67 // We don't use virtual methods to differ between the sub classes,
68 // because this seems to be to expensive if compared to inline methods.
69 sal_uInt8
GetType() const { return nType
; }
70 bool IsStyle() { return XML_HINT_STYLE
==nType
; }
71 bool IsReference() { return XML_HINT_REFERENCE
==nType
; }
72 bool IsHyperlink() { return XML_HINT_HYPERLINK
==nType
; }
73 bool IsIndexMark() { return XML_HINT_INDEX_MARK
==nType
; }
76 class XMLStyleHint_Impl
: public XMLHint_Impl
82 XMLStyleHint_Impl( const OUString
& rStyleName
,
83 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
84 XMLHint_Impl( XML_HINT_STYLE
, rPos
, rPos
),
85 sStyleName( rStyleName
)
88 virtual ~XMLStyleHint_Impl() {}
90 const OUString
& GetStyleName() const { return sStyleName
; }
93 class XMLReferenceHint_Impl
: public XMLHint_Impl
99 XMLReferenceHint_Impl( const OUString
& rRefName
,
100 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
101 XMLHint_Impl( XML_HINT_REFERENCE
, rPos
, rPos
),
106 virtual ~XMLReferenceHint_Impl() {}
108 const OUString
& GetRefName() const { return sRefName
; }
111 class XMLHyperlinkHint_Impl
: public XMLHint_Impl
115 OUString sTargetFrameName
;
117 OUString sVisitedStyleName
;
118 XMLEventsImportContext
* pEvents
;
122 XMLHyperlinkHint_Impl( const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
123 XMLHint_Impl( XML_HINT_HYPERLINK
, rPos
, rPos
),
128 virtual ~XMLHyperlinkHint_Impl()
131 pEvents
->ReleaseRef();
134 void SetHRef( const OUString
& s
) { sHRef
= s
; }
135 const OUString
& GetHRef() const { return sHRef
; }
136 void SetName( const OUString
& s
) { sName
= s
; }
137 const OUString
& GetName() const { return sName
; }
138 void SetTargetFrameName( const OUString
& s
) { sTargetFrameName
= s
; }
139 const OUString
& GetTargetFrameName() const { return sTargetFrameName
; }
140 void SetStyleName( const OUString
& s
) { sStyleName
= s
; }
141 const OUString
& GetStyleName() const { return sStyleName
; }
142 void SetVisitedStyleName( const OUString
& s
) { sVisitedStyleName
= s
; }
143 const OUString
& GetVisitedStyleName() const { return sVisitedStyleName
; }
144 XMLEventsImportContext
* GetEventsContext() const
148 void SetEventsContext( XMLEventsImportContext
* pCtxt
)
152 pEvents
->AddFirstRef();
156 class XMLIndexMarkHint_Impl
: public XMLHint_Impl
158 const css::uno::Reference
<css::beans::XPropertySet
> xIndexMarkPropSet
;
164 XMLIndexMarkHint_Impl( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
165 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
166 XMLHint_Impl( XML_HINT_INDEX_MARK
, rPos
, rPos
),
167 xIndexMarkPropSet( rPropSet
),
172 XMLIndexMarkHint_Impl( const css::uno::Reference
< css::beans::XPropertySet
> & rPropSet
,
173 const css::uno::Reference
< css::text::XTextRange
> & rPos
,
174 const OUString
& sIDString
) :
175 XMLHint_Impl( XML_HINT_INDEX_MARK
, rPos
, rPos
),
176 xIndexMarkPropSet( rPropSet
),
181 virtual ~XMLIndexMarkHint_Impl() {}
183 const css::uno::Reference
<css::beans::XPropertySet
> & GetMark() const
184 { return xIndexMarkPropSet
; }
185 const OUString
& GetID() const { return sID
; }
188 class XMLTextFrameHint_Impl
: public XMLHint_Impl
190 // OD 2004-04-20 #i26791#
191 SvXMLImportContextRef xContext
;
195 XMLTextFrameHint_Impl( SvXMLImportContext
* pContext
,
196 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
197 XMLHint_Impl( XML_HINT_TEXT_FRAME
, rPos
, rPos
),
202 virtual ~XMLTextFrameHint_Impl()
206 css::uno::Reference
< css::text::XTextContent
> GetTextContent() const
208 css::uno::Reference
< css::text::XTextContent
> xTxt
;
209 SvXMLImportContext
*pContext
= &xContext
;
210 if( pContext
->ISA( XMLTextFrameContext
) )
211 xTxt
= PTR_CAST( XMLTextFrameContext
, pContext
)->GetTextContent();
212 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
213 xTxt
= PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)
219 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
220 css::uno::Reference
< css::drawing::XShape
> GetShape() const
222 css::uno::Reference
< css::drawing::XShape
> xShape
;
223 SvXMLImportContext
*pContext
= &xContext
;
224 if( pContext
->ISA( XMLTextFrameContext
) )
225 xShape
= PTR_CAST( XMLTextFrameContext
, pContext
)->GetShape();
226 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
227 xShape
= PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)->GetShape();
232 bool IsBoundAtChar() const
235 SvXMLImportContext
*pContext
= &xContext
;
236 if( pContext
->ISA( XMLTextFrameContext
) )
237 bRet
= css::text::TextContentAnchorType_AT_CHARACTER
==
238 PTR_CAST( XMLTextFrameContext
, pContext
)
240 else if( pContext
->ISA( XMLTextFrameHyperlinkContext
) )
241 bRet
= css::text::TextContentAnchorType_AT_CHARACTER
==
242 PTR_CAST( XMLTextFrameHyperlinkContext
, pContext
)
248 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
249 class XMLDrawHint_Impl
: public XMLHint_Impl
251 SvXMLImportContextRef xContext
;
255 XMLDrawHint_Impl( SvXMLShapeContext
* pContext
,
256 const css::uno::Reference
< css::text::XTextRange
> & rPos
) :
257 XMLHint_Impl( XML_HINT_DRAW
, rPos
, rPos
),
262 virtual ~XMLDrawHint_Impl()
266 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
267 css::uno::Reference
< css::drawing::XShape
> GetShape() const
269 return static_cast<SvXMLShapeContext
*>(&xContext
)->getShape();
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */