LibreOffice Module xmloff (master)  1
txtparaimphint.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_XMLOFF_SOURCE_TEXT_TXTPARAIMPHINT_HXX
20 #define INCLUDED_XMLOFF_SOURCE_TEXT_TXTPARAIMPHINT_HXX
21 
22 #include <rtl/ustring.hxx>
23 #include "XMLTextFrameContext.hxx"
26 
27 #define XML_HINT_STYLE 1
28 #define XML_HINT_REFERENCE 2
29 #define XML_HINT_HYPERLINK 3
30 #define XML_HINT_INDEX_MARK 5
31 #define XML_HINT_TEXT_FRAME 6
32 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
33 #define XML_HINT_DRAW 7
34 
36 {
37  css::uno::Reference < css::text::XTextRange > xStart;
38  css::uno::Reference < css::text::XTextRange > xEnd;
39 
41 
42 public:
43 
45  const css::uno::Reference < css::text::XTextRange > & rS,
46  const css::uno::Reference < css::text::XTextRange > & rE ) :
47  xStart( rS ),
48  xEnd( rE ),
49  nType( nTyp )
50  {
51  }
52 
53  virtual ~XMLHint_Impl() {}
54 
55  const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
56  const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
57  void SetEnd( const css::uno::Reference < css::text::XTextRange > & rPos ) { xEnd = rPos; }
58 
59  // We don't use virtual methods to differ between the sub classes,
60  // because this seems to be too expensive if compared to inline methods.
61  sal_uInt8 GetType() const { return nType; }
62  bool IsReference() const { return XML_HINT_REFERENCE==nType; }
63 };
64 
66 {
67  OUString sStyleName;
68 
69 public:
70 
71  XMLStyleHint_Impl( const OUString& rStyleName,
72  const css::uno::Reference < css::text::XTextRange > & rPos ) :
73  XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
74  sStyleName( rStyleName )
75  {
76  }
77 
78  const OUString& GetStyleName() const { return sStyleName; }
79 };
80 
82 {
83  OUString sRefName;
84 
85 public:
86 
87  XMLReferenceHint_Impl( const OUString& rRefName,
88  const css::uno::Reference < css::text::XTextRange > & rPos ) :
89  XMLHint_Impl( XML_HINT_REFERENCE, rPos, rPos ),
90  sRefName( rRefName )
91  {
92  }
93 
94  const OUString& GetRefName() const { return sRefName; }
95 };
96 
98 {
99  OUString sHRef;
100  OUString sName;
102  OUString sStyleName;
105 
106 public:
107 
108  XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
109  XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos )
110  {
111  }
112 
113  void SetHRef( const OUString& s ) { sHRef = s; }
114  const OUString& GetHRef() const { return sHRef; }
115  void SetName( const OUString& s ) { sName = s; }
116  const OUString& GetName() const { return sName; }
117  void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
118  const OUString& GetTargetFrameName() const { return sTargetFrameName; }
119  void SetStyleName( const OUString& s ) { sStyleName = s; }
120  const OUString& GetStyleName() const { return sStyleName; }
121  void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
122  const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
124  {
125  return mxEvents.get();
126  }
128  {
129  mxEvents.set(pCtxt);
130  }
131 };
132 
134 {
135  const css::uno::Reference<css::beans::XPropertySet> xIndexMarkPropSet;
136 
137  const OUString sID;
138 
139 public:
140 
141  XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
142  const css::uno::Reference < css::text::XTextRange > & rPos ) :
143  XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
144  xIndexMarkPropSet( rPropSet ),
145  sID()
146  {
147  }
148 
149  XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
150  const css::uno::Reference < css::text::XTextRange > & rPos,
151  const OUString& sIDString) :
152  XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
153  xIndexMarkPropSet( rPropSet ),
154  sID(sIDString)
155  {
156  }
157 
158  const css::uno::Reference<css::beans::XPropertySet> & GetMark() const
159  { return xIndexMarkPropSet; }
160  const OUString& GetID() const { return sID; }
161 };
162 
164 {
165  // OD 2004-04-20 #i26791#
167 
168 public:
169 
171  const css::uno::Reference < css::text::XTextRange > & rPos ) :
172  XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
173  xContext( pContext )
174  {
175  }
176 
177  css::uno::Reference < css::text::XTextContent > GetTextContent() const
178  {
179  css::uno::Reference < css::text::XTextContent > xTxt;
180  SvXMLImportContext *pContext = xContext.get();
181  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
182  xTxt = pFrameContext->GetTextContent();
183  else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
184  xTxt = pLinkContext->GetTextContent();
185 
186  return xTxt;
187  }
188 
189  // Frame "to character": anchor moves from first to last char after saving (#i33242#)
190  css::uno::Reference < css::drawing::XShape > GetShape() const
191  {
192  css::uno::Reference < css::drawing::XShape > xShape;
193  SvXMLImportContext *pContext = xContext.get();
194  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
195  xShape = pFrameContext->GetShape();
196  else if(XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
197  xShape = pLinkContext->GetShape();
198 
199  return xShape;
200  }
201 
202  bool IsBoundAtChar() const
203  {
204  bool bRet = false;
205  SvXMLImportContext *pContext = xContext.get();
206  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
207  bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
208  pFrameContext->GetAnchorType();
209  else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
210  bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
211  pLinkContext->GetAnchorType();
212  return bRet;
213  }
214 };
215 
216 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
218 {
220 
221 public:
222 
224  const css::uno::Reference < css::text::XTextRange > & rPos ) :
225  XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
226  xContext( pContext )
227  {
228  }
229 
230  // Frame "to character": anchor moves from first to last char after saving (#i33242#)
231  css::uno::Reference < css::drawing::XShape > const & GetShape() const
232  {
233  return static_cast<SvXMLShapeContext*>(xContext.get())->getShape();
234  }
235 };
236 
237 #endif
238 
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::drawing::XShape > const & GetShape() const
void SetStyleName(const OUString &s)
bool IsReference() const
XMLHyperlinkHint_Impl(const css::uno::Reference< css::text::XTextRange > &rPos)
XMLReferenceHint_Impl(const OUString &rRefName, const css::uno::Reference< css::text::XTextRange > &rPos)
const css::uno::Reference< css::beans::XPropertySet > & GetMark() const
const css::uno::Reference< css::text::XTextRange > & GetEnd() const
XMLIndexMarkHint_Impl(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const css::uno::Reference< css::text::XTextRange > &rPos)
void SetTargetFrameName(const OUString &s)
void SetVisitedStyleName(const OUString &s)
SvXMLImportContextRef xContext
const css::uno::Reference< css::text::XTextRange > & GetStart() const
XMLDrawHint_Impl(SvXMLShapeContext *pContext, const css::uno::Reference< css::text::XTextRange > &rPos)
XMLHint_Impl(sal_uInt8 nTyp, const css::uno::Reference< css::text::XTextRange > &rS, const css::uno::Reference< css::text::XTextRange > &rE)
void SetEnd(const css::uno::Reference< css::text::XTextRange > &rPos)
css::uno::Reference< css::text::XTextRange > xStart
SvXMLImportContextRef xContext
css::uno::Reference< css::text::XTextRange > xEnd
sal_uInt8 nType
const OUString & GetStyleName() const
sal_uInt8 GetType() const
#define XML_HINT_HYPERLINK
#define XML_HINT_INDEX_MARK
const OUString & GetTargetFrameName() const
const css::uno::Reference< css::beans::XPropertySet > xIndexMarkPropSet
bool IsBoundAtChar() const
XMLTextFrameHint_Impl(SvXMLImportContext *pContext, const css::uno::Reference< css::text::XTextRange > &rPos)
const OUString & GetID() const
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
const OUString & GetRefName() const
void SetHRef(const OUString &s)
XMLEventsImportContext * GetEventsContext() const
XMLIndexMarkHint_Impl(const css::uno::Reference< css::beans::XPropertySet > &rPropSet, const css::uno::Reference< css::text::XTextRange > &rPos, const OUString &sIDString)
unsigned char sal_uInt8
css::uno::Reference< css::drawing::XShape > GetShape() const
const OUString & GetHRef() const
void SetName(const OUString &s)
const OUString & GetName() const
virtual ~XMLHint_Impl()
void SetEventsContext(XMLEventsImportContext *pCtxt)
XMLStyleHint_Impl(const OUString &rStyleName, const css::uno::Reference< css::text::XTextRange > &rPos)
const OUString & GetVisitedStyleName() const
#define XML_HINT_STYLE
rtl::Reference< XMLEventsImportContext > mxEvents
css::uno::Reference< css::text::XTextContent > GetTextContent() const
#define XML_HINT_TEXT_FRAME
#define XML_HINT_DRAW
#define XML_HINT_REFERENCE
const OUString & GetStyleName() const