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 .
20 #ifndef INCLUDED_HWPFILTER_SOURCE_HWPREADER_HXX
21 #define INCLUDED_HWPFILTER_SOURCE_HWPREADER_HXX
26 #include <sal/alloca.h>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/io/XInputStream.hpp>
31 #include <com/sun/star/document/XFilter.hpp>
32 #include <com/sun/star/document/XImporter.hpp>
33 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <com/sun/star/io/XActiveDataSink.hpp>
37 #include <com/sun/star/io/XActiveDataControl.hpp>
38 #include <com/sun/star/io/XStreamListener.hpp>
39 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
41 #include <cppuhelper/factory.hxx>
42 #include <cppuhelper/implbase.hxx>
43 #include <cppuhelper/supportsservice.hxx>
44 #include <cppuhelper/weak.hxx>
47 using namespace ::cppu
;
48 using namespace ::com::sun::star::lang
;
49 using namespace ::com::sun::star::uno
;
50 using namespace ::com::sun::star::io
;
51 using namespace ::com::sun::star::registry
;
52 using namespace ::com::sun::star::document
;
53 using namespace ::com::sun::star::beans
;
54 using namespace ::com::sun::star::xml::sax
;
58 #include <unotools/mediadescriptor.hxx>
64 #include "hstream.hxx"
66 #include "attributes.hxx"
68 #define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter"
70 struct HwpReaderPrivate
;
72 * This class implements the external Parser interface
74 class HwpReader
: public WeakImplHelper
<XFilter
>
79 virtual ~HwpReader() override
;
83 * parseStream does Parser-startup initializations
85 virtual sal_Bool SAL_CALL
filter(const Sequence
< PropertyValue
>& aDescriptor
) override
;
86 virtual void SAL_CALL
cancel() override
{}
87 void setDocumentHandler(Reference
< XDocumentHandler
> const & xHandler
)
89 m_rxDocumentHandler
= xHandler
;
92 Reference
< XDocumentHandler
> m_rxDocumentHandler
;
93 rtl::Reference
<AttributeListImpl
> mxList
;
95 std::unique_ptr
<HwpReaderPrivate
> d
;
97 /* -------- Document Parsing --------- */
100 void makeDrawMiscStyle(HWPDrawingObject
*);
101 void makeAutoStyles();
102 void makeMasterStyles();
105 void makeTextDecls();
107 /* -------- Paragraph Parsing --------- */
108 void parsePara(HWPPara
*para
);
109 void make_text_p0(HWPPara
*para
, bool bParaStart
);
110 void make_text_p1(HWPPara
*para
, bool bParaStart
);
111 void make_text_p3(HWPPara
*para
, bool bParaStart
);
113 /* -------- rDocument->characters(x) --------- */
114 void makeChars(hchar_string
& rStr
);
116 /* -------- Special Char Parsing --------- */
117 void makeFieldCode(hchar_string
const & rStr
, FieldCode
const *hbox
); //6
118 void makeBookmark(Bookmark
const *hbox
); //6
119 void makeDateFormat(DateCode
*hbox
); //7
120 void makeDateCode(DateCode
*hbox
); //8
122 void makeTable(TxtBox
*hbox
);
123 void makeTextBox(TxtBox
*hbox
);
124 void makeFormula(TxtBox
*hbox
);
125 void makeHyperText(TxtBox
*hbox
);
126 void makePicture(Picture
*hbox
);
127 void makePictureDRAW(HWPDrawingObject
*drawobj
, Picture
*hbox
);
129 void makeHidden(Hidden
*hbox
);
130 void makeFootnote(Footnote
*hbox
);
131 void makeAutoNum(AutoNum
const *hbox
);
132 void makeShowPageNum();
133 void makeMailMerge(MailMerge
*hbox
);
134 void makeOutline(Outline
const *hbox
);
136 /* --------- Styles Parsing ------------ */
137 void makePageStyle();
138 void makeColumns(ColumnDef
const *);
139 void makeTStyle(CharShape
const *);
140 void makePStyle(ParaShape
const *);
141 void makeFStyle(FBoxStyle
*);
142 void makeCaptionStyle(FBoxStyle
*);
143 void makeDrawStyle(HWPDrawingObject
*,FBoxStyle
*);
144 void makeTableStyle(Table
*);
145 void parseCharShape(CharShape
const *);
146 void parseParaShape(ParaShape
const *);
147 static char* getTStyleName(int, char *);
148 static char* getPStyleName(int, char *);
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */