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 // Optimization for new table name lookup
88 OUString m_sDefTableName; // See STR_TABLE_DEFNAME
89 std::map<OUString, sal_uInt32> m_aTableNameMap; // Last used indices for duplicating table names
90
91 void InitItemImport();
92 void FinitItemImport();
93 void UpdateTextCollConditions( SwDoc *pDoc );
94
96 const css::uno::Reference< css::text::XTextRange > & rInsertPos );
97 void setStyleInsertMode( SfxStyleFamily nFamilies,
98 bool bOverwrite );
99
100protected:
101
102 virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
103 const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
104
105 virtual XMLTextImportHelper* CreateTextImport() override;
106
107 virtual XMLShapeImportHelper* CreateShapeImport() override;
108
109public:
111 const css::uno::Reference< css::uno::XComponentContext >& rContext,
112 OUString const & implementationName, SvXMLImportFlags nImportFlags);
113
114 virtual ~SwXMLImport() noexcept override;
115
116 // css::xml::sax::XDocumentHandler
117 virtual void SAL_CALL startDocument() override;
118 virtual void SAL_CALL endDocument() override;
119
120 // XInitialization
121 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
122
123 void InsertStyles( bool bAuto );
124 void FinishStyles();
125
126 // namespace office
127
128 // NB: in contrast to other CreateFooContexts, this particular one handles
129 // the root element (i.e. office:document-meta)
130 SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement );
137 bool IsInsertMode() const { return m_bInsert; }
138 bool IsStylesOnlyMode() const { return !m_bLoadDoc; }
139 bool IsBlockMode() const { return m_bBlock; }
140
141 inline const SvXMLImportItemMapper& GetTableItemMapper() const;
144 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
145 XmlStyleFamily nSubFamily, SfxItemSet& rItemSet );
146
148 const OUString& rName,
149 const SfxItemSet **ppItemSet ) const;
151
152 virtual void SetStatistics(
153 const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
154 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
155 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
156 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
157 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings) override;
158
159 // initialize XForms
160 virtual void initXForms() override;
161
162 // get the document properties, but only if they actually need importing
163 css::uno::Reference<css::document::XDocumentProperties>
164 GetDocumentProperties() const;
165
166 virtual void NotifyContainsEmbeddedFont() override;
167
168 const SwDoc* getDoc() const;
169 SwDoc* getDoc();
170
171 const OUString& GetDefTableName() { return m_sDefTableName; }
172 std::map<OUString, sal_uInt32>& GetTableNameMap() { return m_aTableNameMap; }
173};
174
176{
177 return *m_pTableItemMapper;
178}
179
181{
182 return *m_pTableItemMapper;
183}
184
185#endif // _XMLIMP_HXX
186
187/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: doc.hxx:197
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:613
std::map< OUString, sal_uInt32 > & GetTableNameMap()
Definition: xmlimp.hxx:172
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:1604
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1683
virtual ~SwXMLImport() noexcept override
Definition: xmlimp.cxx:338
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:53
OUString m_sDefTableName
Definition: xmlimp.hxx:88
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:1133
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:292
SvXMLItemMapEntriesRef m_xTableRowItemMap
Definition: xmlimp.hxx:70
SwXMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Definition: xmlimp.cxx:322
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:377
const SvXMLImportItemMapper & GetTableItemMapper() const
Definition: xmlimp.hxx:175
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:1633
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:136
bool IsBlockMode() const
Definition: xmlimp.hxx:139
virtual void initXForms() override
Definition: xmlimp.cxx:1653
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:351
virtual void NotifyContainsEmbeddedFont() override
Definition: xmlfonte.cxx:93
bool m_bInsert
Definition: xmlimp.hxx:77
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1125
std::map< OUString, sal_uInt32 > m_aTableNameMap
Definition: xmlimp.hxx:89
bool m_bOrganizerMode
Definition: xmlimp.hxx:82
SvXMLImportContext * CreateMasterStylesContext()
Definition: xmlfmt.cxx:985
const OUString & GetDefTableName()
Definition: xmlimp.hxx:171
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:362
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1146
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:941
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:137
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:138
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1138
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1220
SvXMLItemMapEntriesRef m_xTableColItemMap
Definition: xmlimp.hxx:69
void FinishStyles()
Definition: xmlfmt.cxx:1002
XmlStyleFamily
SfxStyleFamily
SvXMLImportFlags