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 #pragma once
20 
21 #include <rtl/ustring.hxx>
22 #include "XMLTextFrameContext.hxx"
25 
26 #define XML_HINT_STYLE 1
27 #define XML_HINT_REFERENCE 2
28 #define XML_HINT_HYPERLINK 3
29 #define XML_HINT_INDEX_MARK 5
30 #define XML_HINT_TEXT_FRAME 6
31 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
32 #define XML_HINT_DRAW 7
33 
35 {
36  css::uno::Reference < css::text::XTextRange > xStart;
37  css::uno::Reference < css::text::XTextRange > xEnd;
38 
40 
41 public:
42 
44  const css::uno::Reference < css::text::XTextRange > & rS,
45  const css::uno::Reference < css::text::XTextRange > & rE ) :
46  xStart( rS ),
47  xEnd( rE ),
48  nType( nTyp )
49  {
50  }
51 
52  virtual ~XMLHint_Impl() {}
53 
54  const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
55  const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
56  void SetEnd( const css::uno::Reference < css::text::XTextRange > & rPos ) { xEnd = rPos; }
57 
58  // We don't use virtual methods to differ between the sub classes,
59  // because this seems to be too expensive if compared to inline methods.
60  sal_uInt8 GetType() const { return nType; }
61  bool IsReference() const { return XML_HINT_REFERENCE==nType; }
62 };
63 
65 {
66  OUString sStyleName;
67 
68 public:
69 
70  XMLStyleHint_Impl( const OUString& rStyleName,
71  const css::uno::Reference < css::text::XTextRange > & rPos ) :
72  XMLHint_Impl( XML_HINT_STYLE, rPos, rPos ),
73  sStyleName( rStyleName )
74  {
75  }
76 
77  const OUString& GetStyleName() const { return sStyleName; }
78 };
79 
81 {
82  OUString sRefName;
83 
84 public:
85 
86  XMLReferenceHint_Impl( const OUString& rRefName,
87  const css::uno::Reference < css::text::XTextRange > & rPos ) :
88  XMLHint_Impl( XML_HINT_REFERENCE, rPos, rPos ),
89  sRefName( rRefName )
90  {
91  }
92 
93  const OUString& GetRefName() const { return sRefName; }
94 };
95 
97 {
98  OUString sHRef;
99  OUString sName;
101  OUString sStyleName;
104 
105 public:
106 
107  XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
108  XMLHint_Impl( XML_HINT_HYPERLINK, rPos, rPos )
109  {
110  }
111 
112  void SetHRef( const OUString& s ) { sHRef = s; }
113  const OUString& GetHRef() const { return sHRef; }
114  void SetName( const OUString& s ) { sName = s; }
115  const OUString& GetName() const { return sName; }
116  void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
117  const OUString& GetTargetFrameName() const { return sTargetFrameName; }
118  void SetStyleName( const OUString& s ) { sStyleName = s; }
119  const OUString& GetStyleName() const { return sStyleName; }
120  void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
121  const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
123  {
124  return mxEvents.get();
125  }
127  {
128  mxEvents.set(pCtxt);
129  }
130 };
131 
133 {
134  const css::uno::Reference<css::beans::XPropertySet> xIndexMarkPropSet;
135 
136  const OUString sID;
137 
138 public:
139 
140  XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
141  const css::uno::Reference < css::text::XTextRange > & rPos ) :
142  XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
143  xIndexMarkPropSet( rPropSet ),
144  sID()
145  {
146  }
147 
148  XMLIndexMarkHint_Impl( const css::uno::Reference < css::beans::XPropertySet > & rPropSet,
149  const css::uno::Reference < css::text::XTextRange > & rPos,
150  const OUString& sIDString) :
151  XMLHint_Impl( XML_HINT_INDEX_MARK, rPos, rPos ),
152  xIndexMarkPropSet( rPropSet ),
153  sID(sIDString)
154  {
155  }
156 
157  const css::uno::Reference<css::beans::XPropertySet> & GetMark() const
158  { return xIndexMarkPropSet; }
159  const OUString& GetID() const { return sID; }
160 };
161 
163 {
164  // OD 2004-04-20 #i26791#
166 
167 public:
168 
170  const css::uno::Reference < css::text::XTextRange > & rPos ) :
171  XMLHint_Impl( XML_HINT_TEXT_FRAME, rPos, rPos ),
172  xContext( pContext )
173  {
174  }
175 
176  css::uno::Reference < css::text::XTextContent > GetTextContent() const
177  {
178  css::uno::Reference < css::text::XTextContent > xTxt;
179  SvXMLImportContext *pContext = xContext.get();
180  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
181  xTxt = pFrameContext->GetTextContent();
182  else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
183  xTxt = pLinkContext->GetTextContent();
184 
185  return xTxt;
186  }
187 
188  // Frame "to character": anchor moves from first to last char after saving (#i33242#)
189  css::uno::Reference < css::drawing::XShape > GetShape() const
190  {
191  css::uno::Reference < css::drawing::XShape > xShape;
192  SvXMLImportContext *pContext = xContext.get();
193  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
194  xShape = pFrameContext->GetShape();
195  else if(XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
196  xShape = pLinkContext->GetShape();
197 
198  return xShape;
199  }
200 
201  bool IsBoundAtChar() const
202  {
203  bool bRet = false;
204  SvXMLImportContext *pContext = xContext.get();
205  if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
206  bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
207  pFrameContext->GetAnchorType();
208  else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
209  bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
210  pLinkContext->GetAnchorType();
211  return bRet;
212  }
213 };
214 
215 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
217 {
219 
220 public:
221 
223  const css::uno::Reference < css::text::XTextRange > & rPos ) :
224  XMLHint_Impl( XML_HINT_DRAW, rPos, rPos ),
225  xContext( pContext )
226  {
227  }
228 
229  // Frame "to character": anchor moves from first to last char after saving (#i33242#)
230  css::uno::Reference < css::drawing::XShape > const & GetShape() const
231  {
232  return static_cast<SvXMLShapeContext*>(xContext.get())->getShape();
233  }
234 };
235 
236 /* 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
Used for hyperlinks attached to objects (drawing objects, text boxes, Writer frames) ...
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