tdf#156866 use mSize instead of mPixelSize for inverted surface
[LibreOffice.git] / hwpfilter / source / hwpreader.hxx
blobd99099f2b31cbeb4497ef0040ee95fb06cb4d115
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <sal/config.h>
24 #include <errno.h>
25 #include <stdio.h>
26 #include <string.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>
48 #include <memory>
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;
59 #include <assert.h>
61 #include <unotools/mediadescriptor.hxx>
63 #include "hwpfile.h"
64 #include "hcode.h"
65 #include "hbox.h"
66 #include "htags.h"
67 #include "hstream.hxx"
68 #include "drawdef.h"
69 #include "attributes.hxx"
71 inline constexpr OUStringLiteral WRITER_IMPORTER_NAME = u"com.sun.star.comp.Writer.XMLImporter";
73 struct HwpReaderPrivate;
74 /**
75 * This class implements the external Parser interface
77 class HwpReader : public WeakImplHelper<XFilter>
79 public:
80 HwpReader();
81 virtual ~HwpReader() override;
83 public:
84 /**
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);
96 private:
97 Reference<XDocumentHandler> m_rxDocumentHandler;
98 rtl::Reference<AttributeListImpl> mxList;
99 HWPFile hwpfile;
100 std::unique_ptr<HwpReaderPrivate> d;
102 private:
103 /* -------- Document Parsing --------- */
104 void makeMeta();
105 void makeStyles();
106 void makeDrawMiscStyle(HWPDrawingObject*);
107 void makeAutoStyles();
108 void makeMasterStyles();
109 void makeBody();
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
127 void makeTab(); //9
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);
134 void makeLine();
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: */