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 
68 
70 
75  css::uno::Reference< css::container::XNameContainer >
77 
78  SfxStyleFamily m_nStyleFamilyMask;// Mask of styles to load
79  bool m_bLoadDoc : 1; // Load doc or styles only
80  bool m_bInsert : 1; // Insert mode. If styles are
81  // loaded only false means that
82  // existing styles will be
83  // overwritten.
84  bool m_bBlock : 1; // Load text block
85  bool m_bOrganizerMode : 1;
87 
88  SwDoc* m_pDoc; // cached for getDoc()
89 
90  void InitItemImport();
91  void FinitItemImport();
92  void UpdateTextCollConditions( SwDoc *pDoc );
93 
94  void setTextInsertMode(
95  const css::uno::Reference< css::text::XTextRange > & rInsertPos );
96  void setStyleInsertMode( SfxStyleFamily nFamilies,
97  bool bOverwrite );
98 
99 protected:
100 
101  virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
102  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
103 
104  virtual XMLTextImportHelper* CreateTextImport() override;
105 
106  virtual XMLShapeImportHelper* CreateShapeImport() override;
107 
108 public:
109  SwXMLImport(
110  const css::uno::Reference< css::uno::XComponentContext >& rContext,
111  OUString const & implementationName, SvXMLImportFlags nImportFlags);
112 
113  virtual ~SwXMLImport() noexcept override;
114 
115  // css::xml::sax::XDocumentHandler
116  virtual void SAL_CALL startDocument() override;
117  virtual void SAL_CALL endDocument() override;
118 
119  // XUnoTunnel
120  static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept;
121  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
122 
123  // XInitialization
124  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
125 
126  void InsertStyles( bool bAuto );
127  void FinishStyles();
128 
129  // namespace office
130 
131  // NB: in contrast to other CreateFooContexts, this particular one handles
132  // the root element (i.e. office:document-meta)
133  SvXMLImportContext *CreateMetaContext( const sal_Int32 nElement );
140  bool IsInsertMode() const { return m_bInsert; }
141  bool IsStylesOnlyMode() const { return !m_bLoadDoc; }
142  bool IsBlockMode() const { return m_bBlock; }
143 
144  inline const SvXMLImportItemMapper& GetTableItemMapper() const;
147  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
148  XmlStyleFamily nSubFamily, SfxItemSet& rItemSet );
149 
150  bool FindAutomaticStyle( XmlStyleFamily nFamily,
151  const OUString& rName,
152  const SfxItemSet **ppItemSet ) const;
154 
155  virtual void SetStatistics(
156  const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
157  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
158  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
159  virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
160  const css::uno::Sequence<css::beans::PropertyValue>& _rSettings) override;
161 
162  // initialize XForms
163  virtual void initXForms() override;
164 
165  // get the document properties, but only if they actually need importing
166  css::uno::Reference<css::document::XDocumentProperties>
167  GetDocumentProperties() const;
168 
169  virtual void NotifyContainsEmbeddedFont() override;
170 
171  const SwDoc* getDoc() const;
172  SwDoc* getDoc();
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: */
rtl::Reference< SvXMLEmbeddedObjectHelper > m_xEmbeddedResolver
Definition: xmlimp.hxx:69
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:1704
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: xmlimp.cxx:1231
bool FindAutomaticStyle(XmlStyleFamily nFamily, const OUString &rName, const SfxItemSet **ppItemSet) const
Definition: xmlfmt.cxx:1042
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlimp.cxx:1149
void FinishStyles()
Definition: xmlfmt.cxx:1001
rtl::Reference< SvXMLGraphicHelper > m_xGraphicStorageHandler
Definition: xmlimp.hxx:67
bool m_bLoadDoc
Definition: xmlimp.hxx:79
signed char sal_Int8
SvXMLImportContext * CreateMasterStylesContext()
Definition: xmlfmt.cxx:984
SvXMLItemMapEntriesRef m_xTableCellItemMap
Definition: xmlimp.hxx:74
bool IsBlockMode() const
Definition: xmlimp.hxx:142
Definition: doc.hxx:187
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlimp.cxx:1144
css::uno::Reference< css::container::XNameContainer > m_xLateInitSettings
Definition: xmlimp.hxx:76
void setStyleInsertMode(SfxStyleFamily nFamilies, bool bOverwrite)
Definition: xmlimp.cxx:354
SwXMLImport(const css::uno::Reference< css::uno::XComponentContext > &rContext, OUString const &implementationName, SvXMLImportFlags nImportFlags)
Definition: xmlimp.cxx:318
const SvXMLImportItemMapper & GetTableItemMapper() const
Definition: xmlimp.hxx:175
SvXMLItemMapEntriesRef m_xTableRowItemMap
Definition: xmlimp.hxx:73
bool m_bInsert
Definition: xmlimp.hxx:80
bool m_bInititedXForms
Definition: xmlimp.hxx:86
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: xmlimp.cxx:1641
XmlStyleFamily
bool IsStylesOnlyMode() const
Definition: xmlimp.hxx:141
SvXMLImportFlags
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:389
virtual ~SwXMLImport() noexcept override
Definition: xmlimp.cxx:333
SvXMLItemMapEntriesRef m_xTableItemMap
Definition: xmlimp.hxx:71
SfxStyleFamily
bool m_bOrganizerMode
Definition: xmlimp.hxx:85
bool m_bBlock
Definition: xmlimp.hxx:84
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlimp.cxx:288
std::unique_ptr< SvXMLImportItemMapper > m_pTableItemMapper
Definition: xmlimp.hxx:65
void FinitItemImport()
Definition: xmlitemi.cxx:239
void UpdateTextCollConditions(SwDoc *pDoc)
Definition: xmlfmt.cxx:1007
Marks a node in the document model.
Definition: ndindex.hxx:31
void InsertStyles(bool bAuto)
Definition: xmlfmt.cxx:993
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: xmlmeta.cxx:104
virtual void NotifyContainsEmbeddedFont() override
Definition: xmlfonte.cxx:87
SfxStyleFamily GetStyleFamilyMask() const
Definition: xmlimp.hxx:139
SvXMLImportContext * CreateScriptContext()
Definition: xmlscript.cxx:25
SvXMLImportContext * CreateTableItemImportContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XmlStyleFamily nSubFamily, SfxItemSet &rItemSet)
Definition: xmlitemi.cxx:245
SfxStyleFamily m_nStyleFamilyMask
Definition: xmlimp.hxx:78
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: xmlimp.cxx:368
css::uno::Reference< css::document::XDocumentProperties > GetDocumentProperties() const
Definition: xmlmeta.cxx:41
SvXMLImportContext * CreateBodyContentContext()
Definition: xmltext.cxx:67
void MergeListsAtDocumentInsertPosition(SwDoc *pDoc)
Definition: xmlimp.cxx:952
void InitItemImport()
Definition: xmlitemi.cxx:225
virtual void SetDocumentSpecificSettings(const OUString &_rSettingsGroupName, const css::uno::Sequence< css::beans::PropertyValue > &_rSettings) override
Definition: xmlimp.cxx:1612
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:625
SvXMLItemMapEntriesRef m_xTableColItemMap
Definition: xmlimp.hxx:72
void setTextInsertMode(const css::uno::Reference< css::text::XTextRange > &rInsertPos)
Definition: xmlimp.cxx:343
SwDoc * m_pDoc
Definition: xmlimp.hxx:88
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: xmlimp.cxx:1157
SvXMLImportContext * CreateStylesContext(bool bAuto)
Definition: xmlfmt.cxx:972
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlmeta.cxx:53
SwDoc * GetDocFromXMLImport(SvXMLImport const &)
Definition: xmlimp.cxx:1661
virtual XMLTextImportHelper * CreateTextImport() override
Definition: xmlimp.cxx:1136
virtual void initXForms() override
Definition: xmlimp.cxx:1671
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId() noexcept
Definition: xmlimp.cxx:362
bool IsInsertMode() const
Definition: xmlimp.hxx:140