LibreOffice Module xmloff (master) 1
txtimp.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_TXTIMP_HXX
20#define INCLUDED_XMLOFF_TXTIMP_HXX
21
22#include <sal/config.h>
23#include <xmloff/dllapi.h>
24#include <sal/types.h>
25#include <rtl/ustring.hxx>
26#include <com/sun/star/uno/Reference.h>
27#include <com/sun/star/uno/Sequence.hxx>
28
29#include <map>
30#include <memory>
31
33
36class SvXMLTokenMap;
38class SvXMLImport;
42class SvI18NMap;
43template<class A> class XMLPropertyBackpatcher;
45
46namespace xmloff {
47 struct ParsedRDFaAttributes;
48}
49
50namespace com::sun::star {
51namespace text {
52 class XText;
53 class XTextCursor;
54 class XTextRange;
55 class XTextContent;
56 class XFormField;
57}
58namespace frame { class XModel; }
59namespace container { class XNameContainer; class XIndexReplace; }
60namespace beans { class XPropertySet; }
61namespace xml::sax { class XAttributeList; }
62namespace xml::sax { class XFastAttributeList; }
63namespace util { struct DateTime; }
64}
65
66namespace rtl { template <class reference_type> class Reference; }
67
69{
78};
79
82{
86 // see following NOTE!
87};
88
89// NOTE: these values must be distinct from any in "enum VarType" because they
90// are used as keys to SvI18NMap::Add()
91#define XML_TEXT_RENAME_TYPE_FRAME 10
92#define XML_TEXT_RENAME_TYPE_TABLE 20
93
95{
96private:
99
100 struct Impl;
101 std::unique_ptr<Impl> m_xImpl;
103 struct BackpatcherImpl;
104 std::shared_ptr<BackpatcherImpl> m_xBackpatcherImpl;
105 static std::shared_ptr<BackpatcherImpl> MakeBackpatcherImpl();
106
107protected:
108 virtual SvXMLImportContext *CreateTableChildContext(
109 SvXMLImport& rImport,
110 sal_Int32 nElement,
111 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
112
113 // access, lazy initialization and destruction of backpatchers
114 // Code is implemented in XMLPropertyBackpatcher.cxx
115 inline XMLPropertyBackpatcher<sal_Int16>& GetFootnoteBP();
116 inline XMLPropertyBackpatcher<sal_Int16>& GetSequenceIdBP();
117 inline XMLPropertyBackpatcher< OUString> & GetSequenceNameBP();
118
119public:
120
122 css::uno::Reference< css::frame::XModel > const& rModel,
123 SvXMLImport& rImport,
124 bool const bInsertMode = false, bool const bStylesOnlyMode = false,
125 bool const bProgress = false, bool const bBlockMode = false,
126 bool const bOrganizerMode = false);
127
128 virtual ~XMLTextImportHelper() override;
129
130 void dispose();
131
132 void SetCursor(
133 const css::uno::Reference< css::text::XTextCursor >& rCursor );
134 void ResetCursor();
135
136 void SetAutoStyles( SvXMLStylesContext *pStyles );
137
139 SvXMLImport& rImport,
140 sal_Int32 nElement,
141 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
143
144 css::uno::Reference< css::text::XText > & GetText();
145 css::uno::Reference< css::text::XTextCursor > & GetCursor();
146 css::uno::Reference< css::text::XTextRange > & GetCursorAsRange();
147
148 bool IsInsertMode() const;
149 bool IsStylesOnlyMode() const;
150 bool IsBlockMode() const;
151 bool IsOrganizerMode() const;
152 bool IsProgress() const;
153
154 OUString ConvertStarFonts( const OUString& rChars,
155 const OUString& rStyleName,
156 sal_uInt8& rFlags,
157 bool bPara,
158 SvXMLImport& rImport ) const;
159 // insert a string without special whitespace processing enabled
160 void InsertString( const OUString& rChars );
161 // insert a string with special whitespace processing enabled
162 void InsertString( std::u16string_view rChars,
163 bool& rIgnoreLeadingSpace );
164 // Delete current paragraph
165 void DeleteParagraph();
166
167 void InsertControlCharacter( sal_Int16 nControl );
168 void InsertTextContent( css::uno::Reference< css::text::XTextContent > const & xContent);
169
170 // Add parameter <bOutlineLevelAttrFound> (#i73509#)
171 // Add parameter <bSetListAttrs> in order to suppress the handling of the list attributes (#i80724#)
172 OUString SetStyleAndAttrs(
173 SvXMLImport const & rImport,
174 const css::uno::Reference< css::text::XTextCursor >& rCursor,
175 const OUString& rStyleName,
176 bool bPara,
177 bool bOutlineLevelAttrFound = false,
178 sal_Int8 nOutlineLevel = -1,
179 bool bSetListAttrs = true,
180 bool bOutlineContentVisible = true);
181
186 // Adjust 2nd parameter (#i69629#)
187 void FindOutlineStyleName( OUString& rStyleName,
188 sal_Int8 nOutlineLevel );
189
190 // Change method name to reflect change of data structure (#i69629#)
191 void AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel,
192 const OUString& rStyleName );
193
194 void SetOutlineStyles( bool bSetEmpty );
195
196 void SetHyperlink(
197 SvXMLImport const & rImport,
198 const css::uno::Reference< css::text::XTextCursor >& rCursor,
199 const OUString& rHRef,
200 const OUString& rName,
201 const OUString& rTargetFrameName,
202 const OUString& rStyleName,
203 const OUString& rVisitedStyleName,
204 XMLEventsImportContext* pEvents);
205 void SetRuby(
206 SvXMLImport const & rImport,
207 const css::uno::Reference< css::text::XTextCursor >& rCursor,
208 const OUString& rStyleName,
209 const OUString& rTextStyleName,
210 const OUString& rText );
211
215 sal_Int32 GetDataStyleKey( const OUString& sStyleName,
216 bool* pIsSystemLanguage = nullptr );
217
218 const SvxXMLListStyleContext *FindAutoListStyle(
219 const OUString& rName ) const;
220 XMLPropStyleContext *FindAutoFrameStyle(
221 const OUString& rName ) const;
222 XMLPropStyleContext* FindSectionStyle(
223 const OUString& rName ) const;
224 XMLPropStyleContext* FindPageMaster(
225 const OUString& rName ) const;
226 XMLPropStyleContext* FindDrawingPage(OUString const& rName) const;
227
228 const css::uno::Reference< css::container::XNameContainer> & GetParaStyles() const;
229
230 const css::uno::Reference< css::container::XNameContainer> & GetTextStyles() const;
231
232 const css::uno::Reference< css::container::XNameContainer> &
233 GetNumberingStyles() const;
234
235 const css::uno::Reference< css::container::XNameContainer> & GetFrameStyles() const;
236
237 const css::uno::Reference< css::container::XNameContainer> & GetPageStyles() const;
238
239 const css::uno::Reference< css::container::XNameContainer> & GetCellStyles() const;
240
241 const css::uno::Reference< css::container::XIndexReplace > &
242 GetChapterNumbering() const;
243
244 bool HasFrameByName( const OUString& rName ) const;
245
246 bool IsDuplicateFrame(const OUString& sName, sal_Int32 nX, sal_Int32 nY, sal_Int32 nWidth, sal_Int32 nHeight) const;
247 void StoreLastImportedFrameName(const OUString& rName);
248 void ClearLastImportedTextFrameName();
249
250 void ConnectFrameChains( const OUString& rFrmName,
251 const OUString& rNextFrmName,
252 const css::uno::Reference< css::beans::XPropertySet >& rFrmPropSet );
253
255 GetParaImportPropertySetMapper() const;
257 GetTextImportPropertySetMapper() const;
259 GetSectionImportPropertySetMapper() const;
261 GetRubyImportPropertySetMapper() const;
262
263 static SvXMLImportPropertyMapper *CreateShapeExtPropMapper(SvXMLImport&);
264 static SvXMLImportPropertyMapper *CreateParaExtPropMapper(SvXMLImport&);
265 static SvXMLImportPropertyMapper* CreateParaDefaultExtPropMapper(SvXMLImport&);
266 static SvXMLImportPropertyMapper* CreateTableDefaultExtPropMapper(SvXMLImport&);
267 static SvXMLImportPropertyMapper* CreateTableRowDefaultExtPropMapper(SvXMLImport&);
268 static SvXMLImportPropertyMapper* CreateTableCellExtPropMapper(SvXMLImport&);
269 static SvXMLImportPropertyMapper* CreateDrawingPageExtPropMapper(SvXMLImport&);
270
271 SvI18NMap& GetRenameMap();
272
274 void InsertBookmarkStartRange(
275 const OUString & sName,
276 const css::uno::Reference< css::text::XTextRange> & rRange,
277 OUString const& i_rXmlId,
278 std::shared_ptr< ::xmloff::ParsedRDFaAttributes > &
279 i_rpRDFaAttributes);
280
282 bool FindAndRemoveBookmarkStartRange(
283 const OUString & sName,
284 css::uno::Reference< css::text::XTextRange> & o_rRange,
285 OUString & o_rXmlId,
286 std::shared_ptr< ::xmloff::ParsedRDFaAttributes > & o_rpRDFaAttributes);
287
288 void pushFieldCtx( const OUString& name, const OUString& type );
289 css::uno::Reference<css::text::XFormField> popFieldCtx();
290 void addFieldParam( const OUString& name, const OUString& value );
291 void setCurrentFieldParamsTo(css::uno::Reference< css::text::XFormField> const &xFormField);
292 ::std::pair<OUString, OUString> getCurrentFieldType() const;
293 css::uno::Reference<css::text::XTextRange> getCurrentFieldStart() const;
294 bool hasCurrentFieldSeparator() const;
295 bool hasCurrentFieldCtx() const;
296
297
300 // Code is implemented in XMLPropertyBackpatcher.cxx
301 void InsertFootnoteID(const OUString& sXMLId, sal_Int16 nAPIId);
302
305 // Code is implemented in XMLPropertyBackpatcher.cxx
306 void ProcessFootnoteReference(
307 const OUString& sXMLId,
308 const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
309
312 // Code is implemented in XMLPropertyBackpatcher.cxx
313 void InsertSequenceID(const OUString& sXMLId,
314 const OUString& sName,
315 sal_Int16 nAPIId);
316
318 // Code is implemented in XMLPropertyBackpatcher.cxx
319 void ProcessSequenceReference(
320 const OUString& sXMLId,
321 const css::uno::Reference< css::beans::XPropertySet> & xPropSet);
322
323 bool IsInFrame() const;
324 virtual bool IsInHeaderFooter() const;
325
326 virtual css::uno::Reference< css::beans::XPropertySet>
327 createAndInsertOLEObject( SvXMLImport& rImport,
328 const OUString& rHRef,
329 const OUString &rStyleName,
330 const OUString &rTblName,
331 sal_Int32 nWidth, sal_Int32 nHeight );
332
333 virtual css::uno::Reference< css::beans::XPropertySet>
334 createAndInsertOOoLink( SvXMLImport& rImport,
335 const OUString& rHRef,
336 const OUString &rStyleName,
337 const OUString &rTblName,
338 sal_Int32 nWidth, sal_Int32 nHeight );
339
340 virtual css::uno::Reference< css::beans::XPropertySet>
341 createAndInsertApplet(
342 const OUString &rName,
343 const OUString &rCode,
344 bool bMayScript,
345 const OUString& rHRef,
346 sal_Int32 nWidth, sal_Int32 nHeight );
347
348 virtual css::uno::Reference< css::beans::XPropertySet>
349 createAndInsertPlugin(
350 const OUString &rMimeType,
351 const OUString& rHRef,
352 sal_Int32 nWidth, sal_Int32 nHeight );
353
354 virtual css::uno::Reference< css::beans::XPropertySet>
355 createAndInsertFloatingFrame(
356 const OUString &rName,
357 const OUString &rHRef,
358 const OUString &rStyleName,
359 sal_Int32 nWidth, sal_Int32 nHeight );
360
361 virtual void endAppletOrPlugin(
362 const css::uno::Reference< css::beans::XPropertySet> &rPropSet,
363 ::std::map < const OUString, OUString > &rParamMap );
364
365 // applet helper methods
366 // implemented in sw/filter/xml/txtparai.hxx
367
368 // redlining helper methods
369 // (to be implemented in sw/filter/xml/txtparai.hxx)
370
371 virtual void RedlineAdd(
373 const OUString& rType,
375 const OUString& rId,
377 const OUString& rAuthor,
379 const OUString& rComment,
381 const css::util::DateTime& rDateTime,
383 bool bMergeLastParagraph);
384
385 virtual css::uno::Reference< css::text::XTextCursor> RedlineCreateText(
387 css::uno::Reference< css::text::XTextCursor > & rOldCursor,
389 const OUString& rId);
390
391 virtual void RedlineSetCursor(
393 const OUString& rId,
395 bool bStart,
397 bool bIsOutsideOfParagraph);
398
399 virtual void RedlineAdjustStartNodeCursor();
400 virtual void SetShowChanges( bool bShowChanges );
401 virtual void SetRecordChanges( bool bRecordChanges );
402 virtual void SetChangesProtectionKey(
403 const css::uno::Sequence<sal_Int8> & rProtectionKey );
404
406 OUString const & GetOpenRedlineId() const;
408 void SetOpenRedlineId( OUString const & rId);
410 void ResetOpenRedlineId();
411
414 void SetInsideDeleteContext(bool const bNew);
417 bool IsInsideDeleteContext() const;
418
419 SvXMLImport & GetXMLImport();
420
421 XMLTextListsHelper & GetTextListHelper();
422
423 // forwards to TextListHelper; these are used in many places
425 void PushListContext();
427 void PopListContext();
428
429 void SetCellParaStyleDefault(OUString const& rNewValue);
430 OUString const& GetCellParaStyleDefault() const;
431
432 void AddCrossRefHeadingMapping(OUString const& rFrom, OUString const& rTo);
433 void MapCrossRefHeadingFieldsHorribly();
434
435 void setBookmarkAttributes(OUString const& bookmark, bool hidden, OUString const& condition);
436 bool getBookmarkHidden(OUString const& bookmark) const;
437 const OUString& getBookmarkCondition(OUString const& bookmark) const;
438
439};
440
441#endif
442
443/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
Import <script:events> element.
This class maintains an OUString->sal_Int16 mapping for cases in which an XPropertySet needs to be fi...
XMLTextImportHelper(css::uno::Reference< css::frame::XModel > const &rModel, SvXMLImport &rImport, bool const bInsertMode=false, bool const bStylesOnlyMode=false, bool const bProgress=false, bool const bBlockMode=false, bool const bOrganizerMode=false)
XMLTextImportHelper & operator=(const XMLTextImportHelper &)=delete
XMLTextImportHelper(const XMLTextImportHelper &)=delete
std::unique_ptr< Impl > m_xImpl
Definition: txtimp.hxx:100
std::shared_ptr< BackpatcherImpl > m_xBackpatcherImpl
Definition: txtimp.hxx:103
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
def text(shape, orig_st)
class SAL_NO_VTABLE XPropertySet
Reference
void dispose()
ww8::ParaStyles GetParaStyles(const SwDoc &rDoc)
rtl::Reference< XMLImportContext > CreateTextChildContext(XMLImport &rImport, std::u16string_view rName, bool bTopLevel=false)
VarType
variable type (for XMLSetVarFieldImportContext)
Definition: txtimp.hxx:82
@ VarTypeSequence
Definition: txtimp.hxx:85
@ VarTypeSimple
Definition: txtimp.hxx:83
@ VarTypeUserField
Definition: txtimp.hxx:84
XMLTextType
Definition: txtimp.hxx:69
@ Body
Definition: txtimp.hxx:70
@ Shape
Definition: txtimp.hxx:72
@ Section
Definition: txtimp.hxx:75
@ Cell
Definition: txtimp.hxx:71
@ ChangedRegion
Definition: txtimp.hxx:77
@ TextBox
Definition: txtimp.hxx:73
@ Footnote
Definition: txtimp.hxx:76
@ HeaderFooter
Definition: txtimp.hxx:74
unsigned char sal_uInt8
signed char sal_Int8