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 <sal/config.h>
28 #include <rtl/ustring.hxx>
29 #include <sal/alloca.h>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <com/sun/star/lang/XComponent.hpp>
33 #include <com/sun/star/io/XInputStream.hpp>
34 #include <com/sun/star/document/XFilter.hpp>
35 #include <com/sun/star/document/XImporter.hpp>
36 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
39 #include <com/sun/star/io/XActiveDataSink.hpp>
40 #include <com/sun/star/io/XActiveDataControl.hpp>
41 #include <com/sun/star/io/XStreamListener.hpp>
42 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
44 #include <cppuhelper/factory.hxx>
45 #include <cppuhelper/implbase.hxx>
46 #include <cppuhelper/supportsservice.hxx>
47 #include <cppuhelper/weak.hxx>
50 using namespace ::cppu
;
51 using namespace ::com::sun::star::lang
;
52 using namespace ::com::sun::star::uno
;
53 using namespace ::com::sun::star::io
;
54 using namespace ::com::sun::star::registry
;
55 using namespace ::com::sun::star::document
;
56 using namespace ::com::sun::star::beans
;
57 using namespace ::com::sun::star::xml::sax
;
61 #include <unotools/mediadescriptor.hxx>
67 #include "hstream.hxx"
69 #include "attributes.hxx"
71 inline constexpr OUStringLiteral WRITER_IMPORTER_NAME
= u
"com.sun.star.comp.Writer.XMLImporter";
73 struct HwpReaderPrivate
;
75 * This class implements the external Parser interface
77 class HwpReader
: public WeakImplHelper
<XFilter
>
81 virtual ~HwpReader() override
;
85 * parseStream does Parser-startup initializations
87 virtual sal_Bool SAL_CALL
filter(const Sequence
<PropertyValue
>& aDescriptor
) override
;
88 virtual void SAL_CALL
cancel() override
{}
89 void setDocumentHandler(Reference
<XDocumentHandler
> const& xHandler
)
91 m_rxDocumentHandler
= xHandler
;
94 bool importHStream(std::unique_ptr
<HStream
> stream
);
97 Reference
<XDocumentHandler
> m_rxDocumentHandler
;
98 rtl::Reference
<AttributeListImpl
> mxList
;
100 std::unique_ptr
<HwpReaderPrivate
> d
;
103 /* -------- Document Parsing --------- */
106 void makeDrawMiscStyle(HWPDrawingObject
*);
107 void makeAutoStyles();
108 void makeMasterStyles();
111 void makeTextDecls();
113 /* -------- Paragraph Parsing --------- */
114 void parsePara(HWPPara
* para
);
115 void make_text_p0(HWPPara
* para
, bool bParaStart
);
116 void make_text_p1(HWPPara
* para
, bool bParaStart
);
117 void make_text_p3(HWPPara
* para
, bool bParaStart
);
119 /* -------- rDocument->characters(x) --------- */
120 void makeChars(hchar_string
& rStr
);
122 /* -------- Special Char Parsing --------- */
123 void makeFieldCode(hchar_string
const& rStr
, FieldCode
const* hbox
); //6
124 void makeBookmark(Bookmark
const* hbox
); //6
125 void makeDateFormat(DateCode
* hbox
); //7
126 void makeDateCode(DateCode
* hbox
); //8
128 void makeTable(TxtBox
* hbox
);
129 void makeTextBox(TxtBox
* hbox
);
130 void makeFormula(TxtBox
* hbox
);
131 void makeHyperText(TxtBox
* hbox
);
132 void makePicture(Picture
* hbox
);
133 void makePictureDRAW(HWPDrawingObject
* drawobj
, const Picture
* hbox
);
135 void makeHidden(Hidden
* hbox
);
136 void makeFootnote(Footnote
* hbox
);
137 void makeAutoNum(AutoNum
const* hbox
);
138 void makeShowPageNum();
139 void makeMailMerge(MailMerge
* hbox
);
140 void makeOutline(Outline
const* hbox
);
142 /* --------- Styles Parsing ------------ */
143 void makePageStyle();
144 void makeColumns(ColumnDef
const*);
145 void makeTStyle(CharShape
const*);
146 void makePStyle(ParaShape
const*);
147 void makeFStyle(FBoxStyle
*);
148 void makeCaptionStyle(FBoxStyle
*);
149 void makeDrawStyle(HWPDrawingObject
*, FBoxStyle
*);
150 void makeTableStyle(Table
*);
151 void parseCharShape(CharShape
const*);
152 void parseParaShape(ParaShape
const*);
153 static OUString
getTStyleName(int);
154 static OUString
getPStyleName(int);
156 void startEl(const OUString
& el
);
157 void endEl(const OUString
& el
);
158 void chars(const OUString
& s
);
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */