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