LibreOffice Module xmloff (master)  1
sdxmlimp_impl.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 #pragma once
21 
22 #include <com/sun/star/drawing/XDrawPage.hpp>
23 #include <com/sun/star/task/XStatusIndicator.hpp>
24 #include <xmloff/xmltkmap.hxx>
25 #include <com/sun/star/container/XNameAccess.hpp>
26 
27 #include <map>
28 #include <memory>
29 #include <vector>
30 #include <xmloff/xmlimp.hxx>
31 
32 class SvXMLUnitConverter;
33 class SvXMLTokenMap;
35 
37 {
38  OUString maStrText;
39  bool mbFixed;
41 
42  DateTimeDeclContextImpl() : mbFixed(true) {}
43 };
44 
45 typedef std::map<OUString, OUString> HeaderFooterDeclMap;
46 typedef std::map<OUString, DateTimeDeclContextImpl> DateTimeDeclMap;
47 
48 class SdXMLImport: public SvXMLImport
49 {
50  css::uno::Reference< css::container::XNameAccess > mxDocStyleFamilies;
51  css::uno::Reference< css::container::XIndexAccess > mxDocMasterPages;
52  css::uno::Reference< css::container::XIndexAccess > mxDocDrawPages;
53  css::uno::Reference< css::container::XNameAccess > mxPageLayouts;
54 
55  // contexts for Style and AutoStyle import
57 
58  sal_Int32 mnNewPageCount;
60 
61  bool mbIsDraw;
62  bool mbLoadDoc;
63  bool mbPreview;
64 
65  static constexpr OUStringLiteral gsPageLayouts = u"PageLayouts";
66  static constexpr OUStringLiteral gsPreview = u"Preview";
67 
71 
72 protected:
73 
74  // This method is called after the namespace map has been updated, but
75  // before a context for the current element has been pushed.
76  virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
77  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
78 
79 public:
81  const css::uno::Reference< css::uno::XComponentContext >& xContext,
82  OUString const & implementationName,
83  bool bIsDraw, SvXMLImportFlags nImportFlags );
84 
85  // XImporter
86  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
87 
88  // XInitialization
89  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
90 
91  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
92  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
93 
94  // namespace office
95  // NB: in contrast to other CreateFooContexts, this particular one handles
96  // the root element (i.e. office:document-meta)
97  SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement,
98  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
103 
104  // export local parameters concerning page access and similar
105  const css::uno::Reference< css::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
106  const css::uno::Reference< css::container::XIndexAccess >& GetLocalMasterPages() const { return mxDocMasterPages; }
107  const css::uno::Reference< css::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
108 
109  sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
110  void IncrementNewPageCount() { mnNewPageCount++; }
111  sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
112  void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
113 
114  const css::uno::Reference< css::container::XNameAccess >& getPageLayouts() const { return mxPageLayouts; }
115 
116  bool IsDraw() const { return mbIsDraw; }
117  bool IsImpress() const { return !mbIsDraw; }
118 
119  virtual void SetStatistics(
120  const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
121 
122  bool IsPreview() const { return mbPreview; }
123 
124  void AddHeaderDecl( const OUString& rName, const OUString& rText );
125  void AddFooterDecl( const OUString& rName, const OUString& rText );
126  void AddDateTimeDecl( const OUString& rName, const OUString& rText, bool bFixed, const OUString& rDateTimeFormat );
127 
128  OUString GetHeaderDecl( const OUString& rName ) const;
129  OUString GetFooterDecl( const OUString& rName ) const;
130  OUString GetDateTimeDecl( const OUString& rName, bool& rbFixed, OUString& rDateTimeFormat );
131 
132  virtual void NotifyContainsEmbeddedFont() override;
133 };
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddFooterDecl(const OUString &rName, const OUString &rText)
Definition: sdxmlimp.cxx:601
const css::uno::Reference< css::container::XNameAccess > & GetLocalDocStyleFamilies() const
static constexpr OUStringLiteral gsPreview
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: sdxmlimp.cxx:399
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:82
bool IsPreview() const
sal_Int32 GetNewMasterPageCount() const
std::map< OUString, DateTimeDeclContextImpl > DateTimeDeclMap
css::uno::Reference< css::container::XIndexAccess > mxDocMasterPages
virtual void SetViewSettings(const css::uno::Sequence< css::beans::PropertyValue > &aViewProps) override
Definition: sdxmlimp.cxx:480
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: sdxmlimp.cxx:321
bool IsDraw() const
const css::uno::Reference< css::container::XNameAccess > & getPageLayouts() const
bool IsImpress() const
std::map< OUString, OUString > HeaderFooterDeclMap
SvXMLImportFlags
Definition: xmlimp.hxx:111
OUString GetHeaderDecl(const OUString &rName) const
Definition: sdxmlimp.cxx:619
css::uno::Reference< css::container::XNameAccess > mxPageLayouts
virtual void NotifyContainsEmbeddedFont() override
Definition: sdxmlimp.cxx:652
HeaderFooterDeclMap maFooterDeclsMap
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Definition: sdxmlimp.cxx:426
sal_Int32 GetNewPageCount() const
SvXMLStylesContext * CreateAutoStylesContext()
Definition: sdxmlimp.cxx:454
SvXMLImportContext * CreateFontDeclsContext()
Definition: sdxmlimp.cxx:472
HeaderFooterDeclMap maHeaderDeclsMap
float u
rtl::Reference< SdXMLMasterStylesContext > mxMasterStylesContext
void IncrementNewMasterPageCount()
void AddDateTimeDecl(const OUString &rName, const OUString &rText, bool bFixed, const OUString &rDateTimeFormat)
Definition: sdxmlimp.cxx:607
const css::uno::Reference< css::container::XIndexAccess > & GetLocalMasterPages() const
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: sdxmlimp.cxx:371
sal_Int32 mnNewPageCount
void AddHeaderDecl(const OUString &rName, const OUString &rText)
Definition: sdxmlimp.cxx:595
SvXMLImportContext * CreateMasterStylesContext()
Definition: sdxmlimp.cxx:465
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
virtual void SetConfigurationSettings(const css::uno::Sequence< css::beans::PropertyValue > &aConfigProps) override
Definition: sdxmlimp.cxx:523
SvXMLStylesContext * CreateStylesContext()
Definition: sdxmlimp.cxx:443
css::uno::Reference< css::container::XNameAccess > mxDocStyleFamilies
OUString GetFooterDecl(const OUString &rName) const
Definition: sdxmlimp.cxx:629
OUString GetDateTimeDecl(const OUString &rName, bool &rbFixed, OUString &rDateTimeFormat)
Definition: sdxmlimp.cxx:639
static constexpr OUStringLiteral gsPageLayouts
const css::uno::Reference< css::container::XIndexAccess > & GetLocalDrawPages() const
css::uno::Reference< css::container::XIndexAccess > mxDocDrawPages
virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > &i_rStats) override
Definition: sdxmlimp.cxx:566
SdXMLImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, OUString const &implementationName, bool bIsDraw, SvXMLImportFlags nImportFlags)
Definition: sdxmlimp.cxx:297
void IncrementNewPageCount()
DateTimeDeclMap maDateTimeDeclsMap
sal_Int32 mnNewMasterPageCount