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/.
16 #include <librevenge/librevenge.h>
18 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
20 #include <cppuhelper/implbase.hxx>
21 #include <rtl/ref.hxx>
22 #include <tools/gen.hxx>
24 #include "xmlictxt.hxx"
26 namespace com::sun::star
34 class XComponentContext
;
38 class XUriReferenceFactory
;
42 namespace writerperfect::exp
44 class XMLImportContext
;
46 /// Contains info about a fixed-layout page.
47 struct FixedLayoutPage
49 css::uno::Sequence
<sal_Int8
> aMetafile
;
51 std::vector
<OUString
> aChapterNames
;
54 /// States describing the result of a link -> popup conversion.
57 /// Conversion did not happen yet.
59 /// The relative link was converted to a popup.
61 /// The absolute link was not handled.
63 /// The relative link is invalid and should be ignored.
67 /// ODT export feeds this class to make librevenge calls.
68 class XMLImport
: public cppu::WeakImplHelper
<css::xml::sax::XDocumentHandler
>
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
;
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
;
95 const std::vector
<FixedLayoutPage
>& mrPageMetafiles
;
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
);
103 rtl::Reference
<XMLImportContext
>
104 CreateContext(std::u16string_view rName
,
105 const css::uno::Reference
<css::xml::sax::XAttributeList
>& xAttribs
);
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;
130 bool GetIsInPageSpan() const { return mbIsInPageSpan
; }
131 void HandlePageSpan(const librevenge::RVNGPropertyList
& rPropertyList
);
134 void SAL_CALL
startDocument() override
;
135 void SAL_CALL
endDocument() override
;
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
;
144 setDocumentLocator(const css::uno::Reference
<css::xml::sax::XLocator
>& xLocator
) override
;
147 } // namespace writerperfect::exp
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */