Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/draw/sdxmlimp_impl.hxx
Line
Count
Source
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/drawing/XDrawPages2.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;
35
class SdXMLMasterStylesContext;
36
37
struct DateTimeDeclContextImpl
38
{
39
    OUString maStrText;
40
    bool mbFixed;
41
    OUString maStrDateTimeFormat;
42
43
40
    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::drawing::XDrawPages2 > 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
57
    rtl::Reference<SdXMLMasterStylesContext> mxMasterStylesContext;
58
59
    sal_Int32                   mnNewPageCount;
60
    sal_Int32                   mnNewMasterPageCount;
61
62
    bool                        mbIsDraw;
63
    bool                        mbLoadDoc;
64
    bool                        mbPreview;
65
66
    static constexpr OUString gsPageLayouts = u"PageLayouts"_ustr;
67
    static constexpr OUString gsPreview = u"Preview"_ustr;
68
69
    HeaderFooterDeclMap         maHeaderDeclsMap;
70
    HeaderFooterDeclMap         maFooterDeclsMap;
71
    DateTimeDeclMap             maDateTimeDeclsMap;
72
73
    // Storage for page shape references that need to be resolved in endDocument()
74
    // when all pages have been imported
75
    struct PageShapeRef
76
    {
77
        css::uno::Reference<css::drawing::XShape> mxShape;
78
        sal_Int32 mnPageNumber;
79
    };
80
    std::vector<PageShapeRef> maPageShapeRefs;
81
82
protected:
83
    // This method is called after the namespace map has been updated, but
84
    // before a context for the current element has been pushed.
85
    virtual SvXMLImportContext *CreateFastContext( sal_Int32 nElement,
86
        const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList ) override;
87
88
public:
89
    SdXMLImport(
90
        const css::uno::Reference< css::uno::XComponentContext >& xContext,
91
        OUString const & implementationName,
92
        bool bIsDraw, SvXMLImportFlags nImportFlags );
93
94
    // XImporter
95
    virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
96
97
    // XInitialization
98
    virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
99
100
    virtual void SAL_CALL endDocument() override;
101
    virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps) override;
102
    virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps) override;
103
104
    // namespace office
105
    // NB: in contrast to other CreateFooContexts, this particular one handles
106
    //     the root element (i.e. office:document-meta)
107
    SvXMLImportContext* CreateMetaContext(const sal_Int32 nElement,
108
        const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList);
109
    SvXMLStylesContext* CreateStylesContext();
110
    SvXMLStylesContext* CreateAutoStylesContext();
111
    SvXMLImportContext* CreateMasterStylesContext();
112
    SvXMLImportContext *CreateFontDeclsContext();
113
114
    // export local parameters concerning page access and similar
115
471
    const css::uno::Reference< css::container::XNameAccess >& GetLocalDocStyleFamilies() const { return mxDocStyleFamilies; }
116
1.47k
    const css::uno::Reference< css::drawing::XDrawPages2 >& GetLocalMasterPages() const { return mxDocMasterPages; }
117
65
    const css::uno::Reference< css::container::XIndexAccess >& GetLocalDrawPages() const { return mxDocDrawPages; }
118
119
186
    sal_Int32 GetNewPageCount() const { return mnNewPageCount; }
120
65
    void IncrementNewPageCount() { mnNewPageCount++; }
121
44
    sal_Int32 GetNewMasterPageCount() const { return mnNewMasterPageCount; }
122
44
    void IncrementNewMasterPageCount() { mnNewMasterPageCount++; }
123
124
48
    const css::uno::Reference< css::container::XNameAccess >& getPageLayouts() const { return mxPageLayouts; }
125
126
94
    bool IsDraw() const { return mbIsDraw; }
127
192
    bool IsImpress() const { return !mbIsDraw; }
128
129
    virtual void SetStatistics(
130
        const css::uno::Sequence< css::beans::NamedValue> & i_rStats) override;
131
132
9
    bool IsPreview() const { return mbPreview; }
133
134
    void AddHeaderDecl( const OUString& rName, const OUString& rText );
135
    void AddFooterDecl( const OUString& rName, const OUString& rText );
136
    void AddDateTimeDecl( const OUString& rName, const OUString& rText, bool bFixed, const OUString& rDateTimeFormat );
137
    void AddPageShapePageNum(const css::uno::Reference<css::drawing::XShape>& rxShape,
138
                         sal_Int32 nPageNumber);
139
140
    OUString GetHeaderDecl( const OUString& rName ) const;
141
    OUString GetFooterDecl( const OUString& rName ) const;
142
    OUString GetDateTimeDecl( const OUString& rName, bool& rbFixed, OUString& rDateTimeFormat );
143
144
    virtual void NotifyContainsEmbeddedFont() override;
145
};
146
147
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */