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 
27 #include <com/sun/star/document/XDocumentProperties.hpp>
28 
29 #include <xmloff/xmlictxt.hxx>
30 #include <xmloff/xmlimp.hxx>
31 
32 #include "xmlitmap.hxx"
33 #include <o3tl/typed_flags_set.hxx>
34 
35 class SwDoc;
36 class SvXMLUnitConverter;
37 class SvXMLTokenMap;
39 class SfxItemSet;
40 class SwNodeIndex;
42 class SvXMLGraphicHelper;
44 enum class SfxStyleFamily;
45 
46 // define, how many steps ( = paragraphs ) the progress bar should advance
47 // for styles, autostyles and settings + meta
48 #define PROGRESS_BAR_STEP 20
49 
50 namespace SwImport {
52 }
53 
54 // we only need this scoped enum to be flags here, in sw
55 namespace o3tl
56 {
57  template<> struct typed_flags<SfxStyleFamily> : is_typed_flags<SfxStyleFamily, 0xffff> {};
58 }
59 
60 class SwXMLImport: public SvXMLImport
61 {
62  std::unique_ptr<SwNodeIndex> m_pSttNdIdx;
63 
64  std::unique_ptr<SvXMLUnitConverter> m_pTwipUnitConv;
65  std::unique_ptr<SvXMLImportItemMapper> m_pTableItemMapper;// paragraph item import
66  std::unique_ptr<SvXMLTokenMap> m_pDocElemTokenMap;
67  std::unique_ptr<SvXMLTokenMap> m_pTableElemTokenMap;
68  std::unique_ptr<SvXMLTokenMap> m_pTableCellAttrTokenMap;
69 
71 
73 
78  css::uno::Reference< css::container::XNameContainer >
80 
81  SfxStyleFamily m_nStyleFamilyMask;// Mask of styles to load
82  bool m_bLoadDoc : 1; // Load doc or styles only
83  bool m_bInsert : 1; // Insert mode. If styles are
84  // loaded only false means that
85  // existing styles will be
86  // overwritten.
87  bool m_bBlock : 1; // Load text block
88  bool m_bOrganizerMode : 1;
90 
91  SwDoc* m_pDoc; // cached for getDoc()
92 
93  void InitItemImport();
94  void FinitItemImport();
95  void UpdateTextCollConditions( SwDoc *pDoc );
96 
97  void setTextInsertMode(
98  const css::uno::Reference< css::text::XTextRange > & rInsertPos );
99  void setStyleInsertMode( SfxStyleFamily nFamilies,
100  bool bOverwrite );
101 
102 protected:
103 
104  virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
105  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
106 
107  virtual XMLTextImportHelper* CreateTextImport() override;
108 
109  virtual XMLShapeImportHelper* CreateShapeImport() override;
110 
111 public:
112  SwXMLImport(
113  const css::uno::Reference< css::uno::XComponentContext >& rContext,
114  OUString const & implementationName, SvXMLImportFlags nImportFlags);
115 
116  virtual ~SwXMLImport() throw() override;
117 
118  // css::xml::sax::XDocumentHandler
119  virtual void SAL_CALL startDocument() override;
120  virtual void SAL_CALL endDocument() override;
121 
122  // XUnoTunnel
123  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() throw();
124  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
125 
126  // XInitialization
127  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
128 
129  void InsertStyles( bool bAuto );
130  void FinishStyles();
131 
132  // namespace office
133 
134  // NB: in contrast to other CreateFooContexts, this particular one handles
135  // the root element (i.e. office:document-meta)
136  SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement );
143  bool IsInsertMode() const { return m_bInsert; }
144  bool IsStylesOnlyMode() const { return !m_bLoadDoc; }
145  bool IsBlockMode() const { return m_bBlock; }
146 
147  inline const SvXMLImportItemMapper& GetTableItemMapper() const;
150  const OUString& rLocalName,
151  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList,
152  sal_uInt16 nSubFamily, SfxItemSet& rItemSet );
153 
157 
158  bool FindAutomaticStyle( sal_uInt16 nFamily,
159  const OUString& rName,
160  const SfxItemSet **ppItemSet ) const;
162 
163  virtual void SetStatistics(
164  const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
165  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
166  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
167  virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
168  const css::uno::Sequence<css::beans::PropertyValue>& _rSettings) override;
169 
170  // initialize XForms
171  virtual void initXForms() override;
172 
173  // get the document properties, but only if they actually need importing
174  css::uno::Reference<css::document::XDocumentProperties>
175  GetDocumentProperties() const;
176 
177  virtual void NotifyEmbeddedFontRead() override;
178 
179  const SwDoc* getDoc() const;
180  SwDoc* getDoc();
181 };
182 
184 {
185  return *m_pTableItemMapper;
186 }
187 
189 {
190  return *m_pTableItemMapper;
191 }
192 
193 #endif // _XMLIMP_HXX
194 
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< SvXMLEmbeddedObjectHelper > m_xEmbeddedResolver
Definition: xmlimp.hxx:72
const SvXMLTokenMap & GetTableElemTokenMap()
Definition: xmltbli.cxx:156
std::unique_ptr< SwNodeIndex > m_pSttNdIdx
Definition: xmlimp.hxx:62
std::unique_ptr< SvXMLUnitConverter > m_pTwipUnitConv
Definition: xmlimp.hxx:64
const SwDoc * getDoc() const
Definition: xmlimp.cxx:1728
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1271
std::unique_ptr< SvXMLTokenMap > m_pTableCellAttrTokenMap
Definition: xmlimp.hxx:68
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1189
void FinishStyles()
Definition: xmlfmt.cxx:972
rtl::Reference< SvXMLGraphicHelper > m_xGraphicStorageHandler
Definition: xmlimp.hxx:70
bool m_bLoadDoc
Definition: xmlimp.hxx:82
signed char sal_Int8
SvXMLImportContext * CreateMasterStylesContext()
Definition: xmlfmt.cxx:955
SvXMLItemMapEntriesRef m_xTableCellItemMap
Definition: xmlimp.hxx:77
bool IsBlockMode() const
Definition: xmlimp.hxx:145
Definition: doc.hxx:186
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimp.cxx:1184
css::uno::Reference< css::container::XNameContainer > m_xLateInitSettings
Definition: xmlimp.hxx:79
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:425
SwXMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Definition: xmlimp.cxx:386
std::unique_ptr< SvXMLTokenMap > m_pTableElemTokenMap
Definition: xmlimp.hxx:67
const SvXMLImportItemMapper & GetTableItemMapper() const
Definition: xmlimp.hxx:183
SvXMLItemMapEntriesRef m_xTableRowItemMap
Definition: xmlimp.hxx:76
bool m_bInsert
Definition: xmlimp.hxx:83
bool m_bInititedXForms
Definition: xmlimp.hxx:89
const SvXMLTokenMap & GetDocElemTokenMap()
Definition: xmlimp.cxx:348
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1665
SvXMLImportContext * CreateTableItemImportContext(sal_uInt16 nPrefix, const OUString &rLocalName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList, sal_uInt16 nSubFamily, SfxItemSet &rItemSet)
Definition: xmlitemi.cxx:336
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:144
SvXMLImportFlags
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:464
SvXMLItemMapEntriesRef m_xTableItemMap
Definition: xmlimp.hxx:74
SfxStyleFamily
bool m_bOrganizerMode
Definition: xmlimp.hxx:88
bool m_bBlock
Definition: xmlimp.hxx:87
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlimp.cxx:356
std::unique_ptr< SvXMLImportItemMapper > m_pTableItemMapper
Definition: xmlimp.hxx:65
void FinitItemImport()
Definition: xmlitemi.cxx:330
bool FindAutomaticStyle(sal_uInt16 nFamily, const OUString &rName, const SfxItemSet **ppItemSet) const
Definition: xmlfmt.cxx:1016
void UpdateTextCollConditions(SwDoc *pDoc)
Definition: xmlfmt.cxx:978
Marks a node in the document model.
Definition: ndindex.hxx:31
void InsertStyles(bool bAuto)
Definition: xmlfmt.cxx:964
std::unique_ptr< SvXMLTokenMap > m_pDocElemTokenMap
Definition: xmlimp.hxx:66
virtual void NotifyEmbeddedFontRead() override
Definition: xmlfonte.cxx:87
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: xmlmeta.cxx:102
SfxStyleFamily GetStyleFamilyMask() const
Definition: xmlimp.hxx:142
SvXMLImportContext * CreateScriptContext()
Definition: xmlscript.cxx:27
SfxStyleFamily m_nStyleFamilyMask
Definition: xmlimp.hxx:81
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: xmlimp.cxx:443
css::uno::Reference< css::document::XDocumentProperties > GetDocumentProperties() const
Definition: xmlmeta.cxx:39
SvXMLImportContext * CreateBodyContentContext()
Definition: xmltext.cxx:77
void MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
Definition: xmlimp.cxx:992
void InitItemImport()
Definition: xmlitemi.cxx:317
const SvXMLTokenMap & GetTableCellAttrTokenMap()
Definition: xmltbli.cxx:164
virtual void SetDocumentSpecificSettings(const OUString &_rSettingsGroupName, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings) override
Definition: xmlimp.cxx:1636
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:701
virtual ~SwXMLImport() override
Definition: xmlimp.cxx:401
SvXMLItemMapEntriesRef m_xTableColItemMap
Definition: xmlimp.hxx:75
void setTextInsertMode(const css::uno::Reference< css::text::XTextRange > &rInsertPos)
Definition: xmlimp.cxx:414
SwDoc * m_pDoc
Definition: xmlimp.hxx:91
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1197
SvXMLImportContext * CreateStylesContext(bool bAuto)
Definition: xmlfmt.cxx:943
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: xmlimp.cxx:438
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:51
SwDoc * GetDocFromXMLImport(SvXMLImport const &)
Definition: xmlimp.cxx:1685
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1176
virtual void initXForms() override
Definition: xmlimp.cxx:1695
bool IsInsertMode() const
Definition: xmlimp.hxx:143