tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / xmloff / source / text / txtparaimphint.hxx
blobf244eb5719185b9886175c6d9bd92bafcfd81da9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
21 #include <rtl/ustring.hxx>
22 #include "XMLTextFrameContext.hxx"
23 #include "XMLTextFrameHyperlinkContext.hxx"
24 #include <utility>
25 #include <xmloff/XMLEventsImportContext.hxx>
27 enum class XMLHintType
29 XML_HINT_STYLE = 1,
30 XML_HINT_REFERENCE = 2,
31 XML_HINT_HYPERLINK = 3,
32 // There is no 4 defined here
33 XML_HINT_INDEX_MARK = 5,
34 XML_HINT_TEXT_FRAME = 6,
35 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
36 XML_HINT_DRAW = 7
39 class XMLHint_Impl
41 css::uno::Reference < css::text::XTextRange > xStart;
42 css::uno::Reference < css::text::XTextRange > xEnd;
44 XMLHintType nType;
46 public:
48 XMLHint_Impl( XMLHintType nTyp,
49 css::uno::Reference < css::text::XTextRange > xS,
50 css::uno::Reference < css::text::XTextRange > xE ) :
51 xStart(std::move( xS )),
52 xEnd(std::move( xE )),
53 nType( nTyp )
57 virtual ~XMLHint_Impl() {}
59 const css::uno::Reference < css::text::XTextRange > & GetStart() const { return xStart; }
60 const css::uno::Reference < css::text::XTextRange > & GetEnd() const { return xEnd; }
61 void SetEnd( const css::uno::Reference < css::text::XTextRange > & rPos ) { xEnd = rPos; }
63 // We don't use virtual methods to differ between the sub classes,
64 // because this seems to be too expensive if compared to inline methods.
65 XMLHintType GetType() const { return nType; }
66 bool IsReference() const { return XMLHintType::XML_HINT_REFERENCE==nType; }
69 class XMLStyleHint_Impl : public XMLHint_Impl
71 OUString sStyleName;
73 public:
75 XMLStyleHint_Impl( OUString aStyleName,
76 const css::uno::Reference < css::text::XTextRange > & rPos ) :
77 XMLHint_Impl( XMLHintType::XML_HINT_STYLE, rPos, rPos ),
78 sStyleName(std::move( aStyleName ))
82 const OUString& GetStyleName() const { return sStyleName; }
85 class XMLReferenceHint_Impl : public XMLHint_Impl
87 OUString sRefName;
89 public:
91 XMLReferenceHint_Impl( OUString aRefName,
92 const css::uno::Reference < css::text::XTextRange > & rPos ) :
93 XMLHint_Impl( XMLHintType::XML_HINT_REFERENCE, rPos, rPos ),
94 sRefName(std::move( aRefName ))
98 const OUString& GetRefName() const { return sRefName; }
101 class XMLHyperlinkHint_Impl : public XMLHint_Impl
103 OUString sHRef;
104 OUString sName;
105 OUString sTargetFrameName;
106 OUString sStyleName;
107 OUString sVisitedStyleName;
108 rtl::Reference<XMLEventsImportContext> mxEvents;
110 public:
112 XMLHyperlinkHint_Impl( const css::uno::Reference < css::text::XTextRange > & rPos ) :
113 XMLHint_Impl( XMLHintType::XML_HINT_HYPERLINK, rPos, rPos )
117 void SetHRef( const OUString& s ) { sHRef = s; }
118 const OUString& GetHRef() const { return sHRef; }
119 void SetName( const OUString& s ) { sName = s; }
120 const OUString& GetName() const { return sName; }
121 void SetTargetFrameName( const OUString& s ) { sTargetFrameName = s; }
122 const OUString& GetTargetFrameName() const { return sTargetFrameName; }
123 void SetStyleName( const OUString& s ) { sStyleName = s; }
124 const OUString& GetStyleName() const { return sStyleName; }
125 void SetVisitedStyleName( const OUString& s ) { sVisitedStyleName = s; }
126 const OUString& GetVisitedStyleName() const { return sVisitedStyleName; }
127 XMLEventsImportContext* GetEventsContext() const
129 return mxEvents.get();
131 void SetEventsContext( XMLEventsImportContext* pCtxt )
133 mxEvents.set(pCtxt);
137 class XMLIndexMarkHint_Impl : public XMLHint_Impl
139 const css::uno::Reference<css::beans::XPropertySet> xIndexMarkPropSet;
141 const OUString sID;
143 public:
145 XMLIndexMarkHint_Impl( css::uno::Reference < css::beans::XPropertySet > xPropSet,
146 const css::uno::Reference < css::text::XTextRange > & rPos ) :
147 XMLHint_Impl( XMLHintType::XML_HINT_INDEX_MARK, rPos, rPos ),
148 xIndexMarkPropSet(std::move( xPropSet )),
149 sID()
153 XMLIndexMarkHint_Impl( css::uno::Reference < css::beans::XPropertySet > xPropSet,
154 const css::uno::Reference < css::text::XTextRange > & rPos,
155 OUString sIDString) :
156 XMLHint_Impl( XMLHintType::XML_HINT_INDEX_MARK, rPos, rPos ),
157 xIndexMarkPropSet(std::move( xPropSet )),
158 sID(std::move(sIDString))
162 const css::uno::Reference<css::beans::XPropertySet> & GetMark() const
163 { return xIndexMarkPropSet; }
164 const OUString& GetID() const { return sID; }
167 class XMLTextFrameHint_Impl : public XMLHint_Impl
169 // OD 2004-04-20 #i26791#
170 SvXMLImportContextRef xContext;
172 public:
174 XMLTextFrameHint_Impl( SvXMLImportContext* pContext,
175 const css::uno::Reference < css::text::XTextRange > & rPos ) :
176 XMLHint_Impl( XMLHintType::XML_HINT_TEXT_FRAME, rPos, rPos ),
177 xContext( pContext )
181 css::uno::Reference < css::text::XTextContent > GetTextContent() const
183 css::uno::Reference < css::text::XTextContent > xTxt;
184 SvXMLImportContext *pContext = xContext.get();
185 if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
186 xTxt = pFrameContext->GetTextContent();
187 else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
188 xTxt = pLinkContext->GetTextContent();
190 return xTxt;
193 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
194 css::uno::Reference < css::drawing::XShape > GetShape() const
196 css::uno::Reference < css::drawing::XShape > xShape;
197 SvXMLImportContext *pContext = xContext.get();
198 if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
199 xShape = pFrameContext->GetShape();
200 else if(XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
201 xShape = pLinkContext->GetShape();
203 return xShape;
206 bool IsBoundAtChar() const
208 bool bRet = false;
209 SvXMLImportContext *pContext = xContext.get();
210 if (XMLTextFrameContext *pFrameContext = dynamic_cast<XMLTextFrameContext*>(pContext))
211 bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
212 pFrameContext->GetAnchorType();
213 else if (XMLTextFrameHyperlinkContext *pLinkContext = dynamic_cast<XMLTextFrameHyperlinkContext*>(pContext))
214 bRet = css::text::TextContentAnchorType_AT_CHARACTER ==
215 pLinkContext->GetAnchorType();
216 return bRet;
220 // Core impl. of the unification of drawing objects and Writer fly frames (#i26791#)
221 class XMLDrawHint_Impl : public XMLHint_Impl
223 rtl::Reference<SvXMLShapeContext> xContext;
225 public:
227 XMLDrawHint_Impl( SvXMLShapeContext* pContext,
228 const css::uno::Reference < css::text::XTextRange > & rPos ) :
229 XMLHint_Impl( XMLHintType::XML_HINT_DRAW, rPos, rPos ),
230 xContext( pContext )
234 // Frame "to character": anchor moves from first to last char after saving (#i33242#)
235 css::uno::Reference < css::drawing::XShape > const & GetShape() const
237 return xContext->getShape();
241 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */