Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/writerperfect/source/writer/exp/xmlimp.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
10
#pragma once
11
12
#include <map>
13
#include <stack>
14
#include <vector>
15
16
#include <librevenge/librevenge.h>
17
18
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
19
20
#include <cppuhelper/implbase.hxx>
21
#include <rtl/ref.hxx>
22
#include <tools/gen.hxx>
23
24
#include "xmlictxt.hxx"
25
26
namespace com::sun::star
27
{
28
namespace beans
29
{
30
struct PropertyValue;
31
}
32
namespace uno
33
{
34
class XComponentContext;
35
}
36
namespace uri
37
{
38
class XUriReferenceFactory;
39
}
40
}
41
42
namespace writerperfect::exp
43
{
44
/// Contains info about a fixed-layout page.
45
struct FixedLayoutPage
46
{
47
    css::uno::Sequence<sal_Int8> aMetafile;
48
    Size aCssPixels;
49
    std::vector<OUString> aChapterNames;
50
};
51
52
/// States describing the result of a link -> popup conversion.
53
enum class PopupState
54
{
55
    /// Conversion did not happen yet.
56
    NONE,
57
    /// The relative link was converted to a popup.
58
    Consumed,
59
    /// The absolute link was not handled.
60
    NotConsumed,
61
    /// The relative link is invalid and should be ignored.
62
    Ignore
63
};
64
65
/// ODT export feeds this class to make librevenge calls.
66
class XMLImport : public cppu::WeakImplHelper<css::xml::sax::XDocumentHandler>
67
{
68
    librevenge::RVNGTextInterface& mrGenerator;
69
    std::stack<rtl::Reference<XMLImportContext>> maContexts;
70
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTextStyles;
71
    std::map<OUString, librevenge::RVNGPropertyList> maTextStyles;
72
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticParagraphStyles;
73
    std::map<OUString, librevenge::RVNGPropertyList> maParagraphStyles;
74
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticCellStyles;
75
    std::map<OUString, librevenge::RVNGPropertyList> maCellStyles;
76
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticColumnStyles;
77
    std::map<OUString, librevenge::RVNGPropertyList> maColumnStyles;
78
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticRowStyles;
79
    std::map<OUString, librevenge::RVNGPropertyList> maRowStyles;
80
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTableStyles;
81
    std::map<OUString, librevenge::RVNGPropertyList> maTableStyles;
82
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticGraphicStyles;
83
    std::map<OUString, librevenge::RVNGPropertyList> maGraphicStyles;
84
    std::map<OUString, librevenge::RVNGPropertyList> maAutomaticListStyles;
85
    std::map<OUString, librevenge::RVNGPropertyList> maListStyles;
86
    std::map<OUString, librevenge::RVNGPropertyList> maPageLayouts;
87
    std::map<OUString, librevenge::RVNGPropertyList> maMasterStyles;
88
    librevenge::RVNGPropertyListVector maCoverImages;
89
    /// Author, date, etc -- overwrites what would be from the document out of the box.
90
    librevenge::RVNGPropertyList maMetaData;
91
    const css::uno::Reference<css::uno::XComponentContext>& mxContext;
92
    css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory;
93
    OUString maMediaDir;
94
    bool mbIsInPageSpan;
95
    const std::vector<FixedLayoutPage>& mrPageMetafiles;
96
97
public:
98
    XMLImport(const css::uno::Reference<css::uno::XComponentContext>& xContext,
99
              librevenge::RVNGTextInterface& rGenerator, const OUString& rURL,
100
              const css::uno::Sequence<css::beans::PropertyValue>& rDescriptor,
101
              const std::vector<FixedLayoutPage>& rPageMetafiles);
102
103
    rtl::Reference<XMLImportContext>
104
    CreateContext(std::u16string_view rName,
105
                  const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs);
106
107
    librevenge::RVNGTextInterface& GetGenerator() const;
108
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticTextStyles();
109
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticParagraphStyles();
110
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticCellStyles();
111
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticColumnStyles();
112
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticRowStyles();
113
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticTableStyles();
114
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticGraphicStyles();
115
    std::map<OUString, librevenge::RVNGPropertyList>& GetAutomaticListStyles();
116
    std::map<OUString, librevenge::RVNGPropertyList>& GetTextStyles();
117
    std::map<OUString, librevenge::RVNGPropertyList>& GetParagraphStyles();
118
    std::map<OUString, librevenge::RVNGPropertyList>& GetCellStyles();
119
    std::map<OUString, librevenge::RVNGPropertyList>& GetColumnStyles();
120
    std::map<OUString, librevenge::RVNGPropertyList>& GetRowStyles();
121
    std::map<OUString, librevenge::RVNGPropertyList>& GetTableStyles();
122
    std::map<OUString, librevenge::RVNGPropertyList>& GetGraphicStyles();
123
    std::map<OUString, librevenge::RVNGPropertyList>& GetListStyles();
124
    std::map<OUString, librevenge::RVNGPropertyList>& GetPageLayouts();
125
    std::map<OUString, librevenge::RVNGPropertyList>& GetMasterStyles();
126
    const librevenge::RVNGPropertyListVector& GetCoverImages() const;
127
    const librevenge::RVNGPropertyList& GetMetaData() const;
128
    PopupState FillPopupData(const OUString& rURL, librevenge::RVNGPropertyList& rPropList);
129
    const std::vector<FixedLayoutPage>& GetPageMetafiles() const;
130
    const css::uno::Reference<css::uno::XComponentContext>& GetComponentContext() const;
131
132
0
    bool GetIsInPageSpan() const { return mbIsInPageSpan; }
133
    void HandlePageSpan(const librevenge::RVNGPropertyList& rPropertyList);
134
135
    // XDocumentHandler
136
    void SAL_CALL startDocument() override;
137
    void SAL_CALL endDocument() override;
138
    void SAL_CALL
139
    startElement(const OUString& rName,
140
                 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
141
    void SAL_CALL endElement(const OUString& rName) override;
142
    void SAL_CALL characters(const OUString& rChars) override;
143
    void SAL_CALL ignorableWhitespace(const OUString& rWhitespaces) override;
144
    void SAL_CALL processingInstruction(const OUString& rTarget, const OUString& rData) override;
145
    void SAL_CALL
146
    setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator) override;
147
};
148
149
} // namespace writerperfect::exp
150
151
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */