LibreOffice Module writerperfect (master) 1
xmlimp.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
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
21#include <rtl/ref.hxx>
22#include <tools/gen.hxx>
23
24#include "xmlictxt.hxx"
25
26namespace com::sun::star
27{
28namespace beans
29{
30struct PropertyValue;
31}
32namespace uno
33{
34class XComponentContext;
35}
36namespace uri
37{
38class XUriReferenceFactory;
39}
40}
41
42namespace writerperfect::exp
43{
44class XMLImportContext;
45
48{
49 css::uno::Sequence<sal_Int8> aMetafile;
51 std::vector<OUString> aChapterNames;
52};
53
55enum class PopupState
56{
58 NONE,
64 Ignore
65};
66
68class XMLImport : public cppu::WeakImplHelper<css::xml::sax::XDocumentHandler>
69{
70 librevenge::RVNGTextInterface& mrGenerator;
71 std::stack<rtl::Reference<XMLImportContext>> maContexts;
72 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTextStyles;
73 std::map<OUString, librevenge::RVNGPropertyList> maTextStyles;
74 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticParagraphStyles;
75 std::map<OUString, librevenge::RVNGPropertyList> maParagraphStyles;
76 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticCellStyles;
77 std::map<OUString, librevenge::RVNGPropertyList> maCellStyles;
78 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticColumnStyles;
79 std::map<OUString, librevenge::RVNGPropertyList> maColumnStyles;
80 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticRowStyles;
81 std::map<OUString, librevenge::RVNGPropertyList> maRowStyles;
82 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticTableStyles;
83 std::map<OUString, librevenge::RVNGPropertyList> maTableStyles;
84 std::map<OUString, librevenge::RVNGPropertyList> maAutomaticGraphicStyles;
85 std::map<OUString, librevenge::RVNGPropertyList> maGraphicStyles;
86 std::map<OUString, librevenge::RVNGPropertyList> maPageLayouts;
87 std::map<OUString, librevenge::RVNGPropertyList> maMasterStyles;
88 librevenge::RVNGPropertyListVector maCoverImages;
90 librevenge::RVNGPropertyList maMetaData;
91 const css::uno::Reference<css::uno::XComponentContext>& mxContext;
92 css::uno::Reference<css::uri::XUriReferenceFactory> mxUriReferenceFactory;
93 OUString maMediaDir;
95 const std::vector<FixedLayoutPage>& mrPageMetafiles;
96
97public:
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
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>& GetTextStyles();
116 std::map<OUString, librevenge::RVNGPropertyList>& GetParagraphStyles();
117 std::map<OUString, librevenge::RVNGPropertyList>& GetCellStyles();
118 std::map<OUString, librevenge::RVNGPropertyList>& GetColumnStyles();
119 std::map<OUString, librevenge::RVNGPropertyList>& GetRowStyles();
120 std::map<OUString, librevenge::RVNGPropertyList>& GetTableStyles();
121 std::map<OUString, librevenge::RVNGPropertyList>& GetGraphicStyles();
122 std::map<OUString, librevenge::RVNGPropertyList>& GetPageLayouts();
123 std::map<OUString, librevenge::RVNGPropertyList>& GetMasterStyles();
124 const librevenge::RVNGPropertyListVector& GetCoverImages() const;
125 const librevenge::RVNGPropertyList& GetMetaData() const;
126 PopupState FillPopupData(const OUString& rURL, librevenge::RVNGPropertyList& rPropList);
127 const std::vector<FixedLayoutPage>& GetPageMetafiles() const;
128 const css::uno::Reference<css::uno::XComponentContext>& GetComponentContext() const;
129
130 bool GetIsInPageSpan() const { return mbIsInPageSpan; }
131 void HandlePageSpan(const librevenge::RVNGPropertyList& rPropertyList);
132
133 // XDocumentHandler
134 void SAL_CALL startDocument() override;
135 void SAL_CALL endDocument() override;
136 void SAL_CALL
137 startElement(const OUString& rName,
138 const css::uno::Reference<css::xml::sax::XAttributeList>& xAttribs) override;
139 void SAL_CALL endElement(const OUString& rName) override;
140 void SAL_CALL characters(const OUString& rChars) override;
141 void SAL_CALL ignorableWhitespace(const OUString& rWhitespaces) override;
142 void SAL_CALL processingInstruction(const OUString& rTarget, const OUString& rData) override;
143 void SAL_CALL
144 setDocumentLocator(const css::uno::Reference<css::xml::sax::XLocator>& xLocator) override;
145};
146
147} // namespace writerperfect::exp
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ODT export feeds this class to make librevenge calls.
Definition: xmlimp.hxx:69
void SAL_CALL endDocument() override
Definition: xmlimp.cxx:543
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticGraphicStyles
Definition: xmlimp.hxx:84
const css::uno::Reference< css::uno::XComponentContext > & mxContext
Definition: xmlimp.hxx:91
std::map< OUString, librevenge::RVNGPropertyList > maParagraphStyles
Definition: xmlimp.hxx:75
void HandlePageSpan(const librevenge::RVNGPropertyList &rPropertyList)
Definition: xmlimp.cxx:586
XMLImport(const css::uno::Reference< css::uno::XComponentContext > &xContext, librevenge::RVNGTextInterface &rGenerator, const OUString &rURL, const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor, const std::vector< FixedLayoutPage > &rPageMetafiles)
Definition: xmlimp.cxx:345
std::map< OUString, librevenge::RVNGPropertyList > & GetParagraphStyles()
Definition: xmlimp.cxx:504
std::map< OUString, librevenge::RVNGPropertyList > maRowStyles
Definition: xmlimp.hxx:81
std::map< OUString, librevenge::RVNGPropertyList > maTextStyles
Definition: xmlimp.hxx:73
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticRowStyles
Definition: xmlimp.hxx:80
std::map< OUString, librevenge::RVNGPropertyList > & GetPageLayouts()
Definition: xmlimp.cxx:531
void SAL_CALL startElement(const OUString &rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
Definition: xmlimp.cxx:545
css::uno::Reference< css::uri::XUriReferenceFactory > mxUriReferenceFactory
Definition: xmlimp.hxx:92
std::map< OUString, librevenge::RVNGPropertyList > & GetTextStyles()
Definition: xmlimp.cxx:499
std::map< OUString, librevenge::RVNGPropertyList > & GetCellStyles()
Definition: xmlimp.cxx:509
rtl::Reference< XMLImportContext > CreateContext(std::u16string_view rName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs)
Definition: xmlimp.cxx:454
std::map< OUString, librevenge::RVNGPropertyList > & GetColumnStyles()
Definition: xmlimp.cxx:514
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticRowStyles()
Definition: xmlimp.cxx:484
std::map< OUString, librevenge::RVNGPropertyList > maCellStyles
Definition: xmlimp.hxx:77
const librevenge::RVNGPropertyList & GetMetaData() const
Definition: xmlimp.cxx:389
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticTableStyles()
Definition: xmlimp.cxx:489
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticParagraphStyles()
Definition: xmlimp.cxx:469
std::map< OUString, librevenge::RVNGPropertyList > maColumnStyles
Definition: xmlimp.hxx:79
std::map< OUString, librevenge::RVNGPropertyList > & GetTableStyles()
Definition: xmlimp.cxx:521
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticColumnStyles()
Definition: xmlimp.cxx:479
const css::uno::Reference< css::uno::XComponentContext > & GetComponentContext() const
Definition: xmlimp.cxx:448
const std::vector< FixedLayoutPage > & GetPageMetafiles() const
Definition: xmlimp.cxx:446
const std::vector< FixedLayoutPage > & mrPageMetafiles
Definition: xmlimp.hxx:95
void SAL_CALL ignorableWhitespace(const OUString &rWhitespaces) override
Definition: xmlimp.cxx:580
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticColumnStyles
Definition: xmlimp.hxx:78
std::map< OUString, librevenge::RVNGPropertyList > & GetGraphicStyles()
Definition: xmlimp.cxx:526
librevenge::RVNGPropertyList maMetaData
Author, date, etc – overwrites what would be from the document out of the box.
Definition: xmlimp.hxx:90
void SAL_CALL startDocument() override
Definition: xmlimp.cxx:541
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticParagraphStyles
Definition: xmlimp.hxx:74
std::map< OUString, librevenge::RVNGPropertyList > & GetMasterStyles()
Definition: xmlimp.cxx:536
void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:584
std::map< OUString, librevenge::RVNGPropertyList > & GetRowStyles()
Definition: xmlimp.cxx:519
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticCellStyles
Definition: xmlimp.hxx:76
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticCellStyles()
Definition: xmlimp.cxx:474
librevenge::RVNGTextInterface & mrGenerator
Definition: xmlimp.hxx:70
bool GetIsInPageSpan() const
Definition: xmlimp.hxx:130
std::map< OUString, librevenge::RVNGPropertyList > maTableStyles
Definition: xmlimp.hxx:83
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticTextStyles()
Definition: xmlimp.cxx:464
PopupState FillPopupData(const OUString &rURL, librevenge::RVNGPropertyList &rPropList)
Definition: xmlimp.cxx:401
std::map< OUString, librevenge::RVNGPropertyList > & GetAutomaticGraphicStyles()
Definition: xmlimp.cxx:494
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticTextStyles
Definition: xmlimp.hxx:72
std::map< OUString, librevenge::RVNGPropertyList > maPageLayouts
Definition: xmlimp.hxx:86
void SAL_CALL processingInstruction(const OUString &rTarget, const OUString &rData) override
Definition: xmlimp.cxx:582
std::map< OUString, librevenge::RVNGPropertyList > maMasterStyles
Definition: xmlimp.hxx:87
void SAL_CALL characters(const OUString &rChars) override
Definition: xmlimp.cxx:574
void SAL_CALL endElement(const OUString &rName) override
Definition: xmlimp.cxx:563
std::map< OUString, librevenge::RVNGPropertyList > maGraphicStyles
Definition: xmlimp.hxx:85
std::stack< rtl::Reference< XMLImportContext > > maContexts
Definition: xmlimp.hxx:71
librevenge::RVNGPropertyListVector maCoverImages
Definition: xmlimp.hxx:88
std::map< OUString, librevenge::RVNGPropertyList > maAutomaticTableStyles
Definition: xmlimp.hxx:82
const librevenge::RVNGPropertyListVector & GetCoverImages() const
Definition: xmlimp.cxx:384
librevenge::RVNGTextInterface & GetGenerator() const
Definition: xmlimp.cxx:462
NONE
PopupState
States describing the result of a link -> popup conversion.
Definition: xmlimp.hxx:56
@ Consumed
The relative link was converted to a popup.
@ NotConsumed
The absolute link was not handled.
Contains info about a fixed-layout page.
Definition: xmlimp.hxx:48
std::vector< OUString > aChapterNames
Definition: xmlimp.hxx:51
css::uno::Sequence< sal_Int8 > aMetafile
Definition: xmlimp.hxx:49