LibreOffice Module sw (master) 1
xmlimp.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
20#ifndef INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
21#define INCLUDED_SW_SOURCE_FILTER_XML_XMLIMP_HXX
22
23#include <sal/config.h>
24
25#include <memory>
26#include <optional>
27
28#include <com/sun/star/document/XDocumentProperties.hpp>
29
30#include <xmloff/xmlictxt.hxx>
31#include <xmloff/xmlimp.hxx>
32
33#include "xmlitmap.hxx"
35#include <ndindex.hxx>
36
37class SwDoc;
39class SvXMLTokenMap;
41class SfxItemSet;
45enum class SfxStyleFamily;
46
47// define, how many steps ( = paragraphs ) the progress bar should advance
48// for styles, autostyles and settings + meta
49#define PROGRESS_BAR_STEP 20
50
51// we only need this scoped enum to be flags here, in sw
52namespace o3tl
53{
54 template<> struct typed_flags<SfxStyleFamily> : is_typed_flags<SfxStyleFamily, 0xffff> {};
55}
56
57class SwXMLImport: public SvXMLImport
58{
59 std::optional<SwNodeIndex> m_oSttNdIdx;
60
61 std::unique_ptr<SvXMLUnitConverter> m_pTwipUnitConv;
62 std::unique_ptr<SvXMLImportItemMapper> m_pTableItemMapper;// paragraph item import
63
65
67
72 css::uno::Reference< css::container::XNameContainer >
74
75 SfxStyleFamily m_nStyleFamilyMask;// Mask of styles to load
76 bool m_bLoadDoc : 1; // Load doc or styles only
77 bool m_bInsert : 1; // Insert mode. If styles are
78 // loaded only false means that
79 // existing styles will be
80 // overwritten.
81 bool m_bBlock : 1; // Load text block
84
85 SwDoc* m_pDoc; // cached for getDoc()
86
87 void InitItemImport();
88 void FinitItemImport();
89 void UpdateTextCollConditions( SwDoc *pDoc );
90
92 const css::uno::Reference< css::text::XTextRange > & rInsertPos );
93 void setStyleInsertMode( SfxStyleFamily nFamilies,
94 bool bOverwrite );
95
96protected:
97
98 virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
99 const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
100
101 virtual XMLTextImportHelper* CreateTextImport() override;
102
103 virtual XMLShapeImportHelper* CreateShapeImport() override;
104
105public:
107 const css::uno::Reference< css::uno::XComponentContext >& rContext,
108 OUString const & implementationName, SvXMLImportFlags nImportFlags);
109
110 virtual ~SwXMLImport() noexcept override;
111
112 // css::xml::sax::XDocumentHandler
113 virtual void SAL_CALL startDocument() override;
114 virtual void SAL_CALL endDocument() override;
115
116 // XInitialization
117 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
118
119 void InsertStyles( bool bAuto );
120 void FinishStyles();
121
122 // namespace office
123
124 // NB: in contrast to other CreateFooContexts, this particular one handles
125 // the root element (i.e. office:document-meta)
126 SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement );
133 bool IsInsertMode() const { return m_bInsert; }
134 bool IsStylesOnlyMode() const { return !m_bLoadDoc; }
135 bool IsBlockMode() const { return m_bBlock; }
136
137 inline const SvXMLImportItemMapper& GetTableItemMapper() const;
140 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
141 XmlStyleFamily nSubFamily, SfxItemSet& rItemSet );
142
144 const OUString& rName,
145 const SfxItemSet **ppItemSet ) const;
147
148 virtual void SetStatistics(
149 const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
150 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
151 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
152 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
153 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings) override;
154
155 // initialize XForms
156 virtual void initXForms() override;
157
158 // get the document properties, but only if they actually need importing
159 css::uno::Reference<css::document::XDocumentProperties>
160 GetDocumentProperties() const;
161
162 virtual void NotifyContainsEmbeddedFont() override;
163
164 const SwDoc* getDoc() const;
165 SwDoc* getDoc();
166};
167
169{
170 return *m_pTableItemMapper;
171}
172
174{
175 return *m_pTableItemMapper;
176}
177
178#endif // _XMLIMP_HXX
179
180/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:195
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:607
rtl::Reference< SvXMLEmbeddedObjectHelper > m_xEmbeddedResolver
Definition: xmlimp.hxx:66
SvXMLImportContext * CreateScriptContext()
Definition: xmlscript.cxx:25
virtual void SetDocumentSpecificSettings(const OUString &_rSettingsGroupName, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings) override
Definition: xmlimp.cxx:1587
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1666
virtual ~SwXMLImport() noexcept override
Definition: xmlimp.cxx:332
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:53
css::uno::Reference< css::container::XNameContainer > m_xLateInitSettings
Definition: xmlimp.hxx:73
rtl::Reference< SvXMLGraphicHelper > m_xGraphicStorageHandler
Definition: xmlimp.hxx:64
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimp.cxx:1127
SvXMLItemMapEntriesRef m_xTableItemMap
Definition: xmlimp.hxx:68
css::uno::Reference< css::document::XDocumentProperties > GetDocumentProperties() const
Definition: xmlmeta.cxx:41
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: xmlmeta.cxx:104
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlimp.cxx:287
SvXMLItemMapEntriesRef m_xTableRowItemMap
Definition: xmlimp.hxx:70
SwXMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Definition: xmlimp.cxx:317
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:371
const SvXMLImportItemMapper & GetTableItemMapper() const
Definition: xmlimp.hxx:168
SvXMLImportContext * CreateStylesContext(bool bAuto)
Definition: xmlfmt.cxx:973
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1616
std::optional< SwNodeIndex > m_oSttNdIdx
Definition: xmlimp.hxx:59
bool m_bInititedXForms
Definition: xmlimp.hxx:83
void UpdateTextCollConditions(SwDoc *pDoc)
Definition: xmlfmt.cxx:1008
bool m_bLoadDoc
Definition: xmlimp.hxx:76
void InitItemImport()
Definition: xmlitemi.cxx:225
SfxStyleFamily GetStyleFamilyMask() const
Definition: xmlimp.hxx:132
bool IsBlockMode() const
Definition: xmlimp.hxx:135
virtual void initXForms() override
Definition: xmlimp.cxx:1636
SvXMLImportContext * CreateTableItemImportContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XmlStyleFamily nSubFamily, SfxItemSet &rItemSet)
Definition: xmlitemi.cxx:245
void setTextInsertMode(const css::uno::Reference< css::text::XTextRange > &rInsertPos)
Definition: xmlimp.cxx:345
virtual void NotifyContainsEmbeddedFont() override
Definition: xmlfonte.cxx:93
bool m_bInsert
Definition: xmlimp.hxx:77
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1119
bool m_bOrganizerMode
Definition: xmlimp.hxx:82
SvXMLImportContext * CreateMasterStylesContext()
Definition: xmlfmt.cxx:985
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:356
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1140
void InsertStyles(bool bAuto)
Definition: xmlfmt.cxx:994
std::unique_ptr< SvXMLUnitConverter > m_pTwipUnitConv
Definition: xmlimp.hxx:61
std::unique_ptr< SvXMLImportItemMapper > m_pTableItemMapper
Definition: xmlimp.hxx:62
SwDoc * m_pDoc
Definition: xmlimp.hxx:85
void MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
Definition: xmlimp.cxx:935
SvXMLImportContext * CreateBodyContentContext()
Definition: xmltext.cxx:67
SvXMLItemMapEntriesRef m_xTableCellItemMap
Definition: xmlimp.hxx:71
bool m_bBlock
Definition: xmlimp.hxx:81
bool IsInsertMode() const
Definition: xmlimp.hxx:133
SfxStyleFamily m_nStyleFamilyMask
Definition: xmlimp.hxx:75
bool FindAutomaticStyle(XmlStyleFamily nFamily, const OUString &rName, const SfxItemSet **ppItemSet) const
Definition: xmlfmt.cxx:1043
void FinitItemImport()
Definition: xmlitemi.cxx:239
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:134
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1132
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1214
SvXMLItemMapEntriesRef m_xTableColItemMap
Definition: xmlimp.hxx:69
void FinishStyles()
Definition: xmlfmt.cxx:1002
XmlStyleFamily
SfxStyleFamily
SvXMLImportFlags