1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
30 #include <xmloff/xmlimp.hxx>
32 class SvXMLUnitConverter
;
34 class SdXMLMasterStylesContext
;
36 struct DateTimeDeclContextImpl
40 OUString maStrDateTimeFormat
;
42 DateTimeDeclContextImpl() : mbFixed(true) {}
45 typedef std::map
<OUString
, OUString
> HeaderFooterDeclMap
;
46 typedef std::map
<OUString
, DateTimeDeclContextImpl
> DateTimeDeclMap
;
48 class SdXMLImport
: public SvXMLImport
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
;
55 // contexts for Style and AutoStyle import
56 rtl::Reference
<SdXMLMasterStylesContext
> mxMasterStylesContext
;
58 sal_Int32 mnNewPageCount
;
59 sal_Int32 mnNewMasterPageCount
;
65 static constexpr OUString gsPageLayouts
= u
"PageLayouts"_ustr
;
66 static constexpr OUString gsPreview
= u
"Preview"_ustr
;
68 HeaderFooterDeclMap maHeaderDeclsMap
;
69 HeaderFooterDeclMap maFooterDeclsMap
;
70 DateTimeDeclMap maDateTimeDeclsMap
;
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
;
81 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
82 OUString
const & implementationName
,
83 bool bIsDraw
, SvXMLImportFlags nImportFlags
);
86 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDoc
) override
;
89 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
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
;
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
);
99 SvXMLStylesContext
* CreateStylesContext();
100 SvXMLStylesContext
* CreateAutoStylesContext();
101 SvXMLImportContext
* CreateMasterStylesContext();
102 SvXMLImportContext
*CreateFontDeclsContext();
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
; }
109 sal_Int32
GetNewPageCount() const { return mnNewPageCount
; }
110 void IncrementNewPageCount() { mnNewPageCount
++; }
111 sal_Int32
GetNewMasterPageCount() const { return mnNewMasterPageCount
; }
112 void IncrementNewMasterPageCount() { mnNewMasterPageCount
++; }
114 const css::uno::Reference
< css::container::XNameAccess
>& getPageLayouts() const { return mxPageLayouts
; }
116 bool IsDraw() const { return mbIsDraw
; }
117 bool IsImpress() const { return !mbIsDraw
; }
119 virtual void SetStatistics(
120 const css::uno::Sequence
< css::beans::NamedValue
> & i_rStats
) override
;
122 bool IsPreview() const { return mbPreview
; }
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
);
128 OUString
GetHeaderDecl( const OUString
& rName
) const;
129 OUString
GetFooterDecl( const OUString
& rName
) const;
130 OUString
GetDateTimeDecl( const OUString
& rName
, bool& rbFixed
, OUString
& rDateTimeFormat
);
132 virtual void NotifyContainsEmbeddedFont() override
;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */