LibreOffice Module hwpfilter (master) 1
hwpreader.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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <errno.h>
25#include <stdio.h>
26#include <string.h>
27
28#include <rtl/ustring.hxx>
29#include <sal/alloca.h>
30
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>
38
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>
43
47#include <cppuhelper/weak.hxx>
48#include <memory>
49
50using namespace ::cppu;
51using namespace ::com::sun::star::lang;
52using namespace ::com::sun::star::uno;
53using namespace ::com::sun::star::io;
54using namespace ::com::sun::star::registry;
55using namespace ::com::sun::star::document;
56using namespace ::com::sun::star::beans;
57using namespace ::com::sun::star::xml::sax;
58
59#include <assert.h>
60
62
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"
70
71inline constexpr OUStringLiteral WRITER_IMPORTER_NAME = u"com.sun.star.comp.Writer.XMLImporter";
72
73struct HwpReaderPrivate;
77class HwpReader : public WeakImplHelper<XFilter>
78{
79public:
80 HwpReader();
81 virtual ~HwpReader() override;
82
83public:
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)
90 {
91 m_rxDocumentHandler = xHandler;
92 }
93
94 bool importHStream(std::unique_ptr<HStream> stream);
95
96private:
97 Reference<XDocumentHandler> m_rxDocumentHandler;
100 std::unique_ptr<HwpReaderPrivate> d;
101
102private:
103 /* -------- Document Parsing --------- */
104 void makeMeta();
105 void makeStyles();
107 void makeAutoStyles();
108 void makeMasterStyles();
109 void makeBody();
110
111 void makeTextDecls();
112
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);
118
119 /* -------- rDocument->characters(x) --------- */
120 void makeChars(hchar_string& rStr);
121
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);
141
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*);
150 void makeTableStyle(Table*);
151 void parseCharShape(CharShape const*);
152 void parseParaShape(ParaShape const*);
153 static OUString getTStyleName(int);
154 static OUString getPStyleName(int);
155
156 void startEl(const OUString& el);
157 void endEl(const OUString& el);
158 void chars(const OUString& s);
159};
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The HWPFile class is the main class of hwp for reading file information from stream.
Definition: hwpfile.h:98
It represents the paragraph.
Definition: hpara.h:69
This class implements the external Parser interface.
Definition: hwpreader.hxx:78
static OUString getTStyleName(int)
Definition: hwpreader.cxx:2600
bool importHStream(std::unique_ptr< HStream > stream)
Definition: hwpreader.cxx:115
void makeStyles()
Definition: hwpreader.cxx:625
void makeFormula(TxtBox *hbox)
It must be converted into MathML.
Definition: hwpreader.cxx:3597
virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue > &aDescriptor) override
parseStream does Parser-startup initializations
Definition: hwpreader.cxx:159
void parseParaShape(ParaShape const *)
Create the properties that correspond to the real Paragraph.
Definition: hwpreader.cxx:1340
void makeColumns(ColumnDef const *)
Definition: hwpreader.cxx:1739
void makeTab()
Definition: hwpreader.cxx:3376
void makeOutline(Outline const *hbox)
Definition: hwpreader.cxx:4641
void make_text_p1(HWPPara *para, bool bParaStart)
Definition: hwpreader.cxx:2690
void makeTStyle(CharShape const *)
Definition: hwpreader.cxx:1789
void makePictureDRAW(HWPDrawingObject *drawobj, const Picture *hbox)
Definition: hwpreader.cxx:3898
void makeTable(TxtBox *hbox)
Definition: hwpreader.cxx:3383
void makeCaptionStyle(FBoxStyle *)
Definition: hwpreader.cxx:2138
void makeAutoStyles()
parse automatic styles from hwpfile Define a style that is automatically reflected.
Definition: hwpreader.cxx:749
void makeBookmark(Bookmark const *hbox)
Completed In LibreOffice, refer bookmarks as reference, but hwp doesn't have the sort of feature.
Definition: hwpreader.cxx:3191
virtual ~HwpReader() override
Definition: hwpreader.cxx:87
void make_text_p0(HWPPara *para, bool bParaStart)
If no special characters in the paragraph and all characters use the same CharShape.
Definition: hwpreader.cxx:2622
void parsePara(HWPPara *para)
Definition: hwpreader.cxx:4648
HWPFile hwpfile
Definition: hwpreader.hxx:99
void makeLine()
Definition: hwpreader.cxx:4460
void setDocumentHandler(Reference< XDocumentHandler > const &xHandler)
Definition: hwpreader.hxx:89
void make_text_p3(HWPPara *para, bool bParaStart)
Special characters are in the paragraph and characters use different CharShapes.
Definition: hwpreader.cxx:2775
void makeTextDecls()
make text decls
Definition: hwpreader.cxx:202
void startEl(const OUString &el)
Definition: hwpreader.cxx:4697
Reference< XDocumentHandler > m_rxDocumentHandler
Definition: hwpreader.hxx:97
void makeDateFormat(DateCode *hbox)
Definition: hwpreader.cxx:3217
void makeHidden(Hidden *hbox)
Input-comment-hidden description: shows a hidden explanation to the users.
Definition: hwpreader.cxx:4471
void makeAutoNum(AutoNum const *hbox)
page/footnote/endnote/picture/table/formula number
Definition: hwpreader.cxx:4546
void makeDrawStyle(HWPDrawingObject *, FBoxStyle *)
Definition: hwpreader.cxx:1962
void makeFootnote(Footnote *hbox)
Converts footnote to text:footnote, endnote to text:endnote.
Definition: hwpreader.cxx:4506
void endEl(const OUString &el)
Definition: hwpreader.cxx:4704
void makeBody()
make office:body
Definition: hwpreader.cxx:187
void makePicture(Picture *hbox)
Read the platform information.
Definition: hwpreader.cxx:3695
void makePageStyle()
Create a style for the page.
Definition: hwpreader.cxx:1474
void makeMasterStyles()
Definition: hwpreader.cxx:880
void makeFStyle(FBoxStyle *)
Create a style for the Floating objects.
Definition: hwpreader.cxx:2348
void chars(const OUString &s)
Definition: hwpreader.cxx:4711
static OUString getPStyleName(int)
Definition: hwpreader.cxx:2606
rtl::Reference< AttributeListImpl > mxList
Definition: hwpreader.hxx:98
void makeMeta()
make office:meta Completed
Definition: hwpreader.cxx:233
void makeTableStyle(Table *)
Definition: hwpreader.cxx:1803
void parseCharShape(CharShape const *)
Create the properties for text styles.
Definition: hwpreader.cxx:1268
void makeFieldCode(hchar_string const &rStr, FieldCode const *hbox)
Definition: hwpreader.cxx:3067
virtual void SAL_CALL cancel() override
Definition: hwpreader.hxx:88
void makeHyperText(TxtBox *hbox)
Read the platform information.
Definition: hwpreader.cxx:3647
std::unique_ptr< HwpReaderPrivate > d
Definition: hwpreader.hxx:100
void makeChars(hchar_string &rStr)
Definition: hwpreader.cxx:2612
void makeShowPageNum()
Definition: hwpreader.cxx:4580
void makeDrawMiscStyle(HWPDrawingObject *)
Definition: hwpreader.cxx:397
void makeMailMerge(MailMerge *hbox)
mail merge operation using hwp addressbook and hwp data form.
Definition: hwpreader.cxx:4634
void makeTextBox(TxtBox *hbox)
Parses the text boxes and tables.
Definition: hwpreader.cxx:3454
void makePStyle(ParaShape const *)
Make the style of the Paragraph.
Definition: hwpreader.cxx:1403
void makeDateCode(DateCode *hbox)
Definition: hwpreader.cxx:3365
Number and format of title.
Definition: hbox.h:947
float u
::std::basic_string< hchar > hchar_string
Definition: hwplib.h:44
constexpr OUStringLiteral WRITER_IMPORTER_NAME
Definition: hwpreader.hxx:71
Input current index of page,comment,table and picture.
Definition: hbox.h:757
Class for BOOKMARK.
Definition: hbox.h:113
Style of character.
Definition: hinfo.h:213
Column properties.
Definition: hinfo.h:257
Class for current date and time with specified format.
Definition: hbox.h:142
Style for floating object.
Definition: hbox.h:238
Definition: hbox.h:82
Both footnote and endnote are comment.
Definition: hbox.h:711
Common header for drawing object.
Definition: drawdef.h:202
Hidden section.
Definition: hbox.h:664
Generates the mailing list automatically using address book and mail body format.
Definition: hbox.h:830
Style of paragraph.
Definition: hinfo.h:276
There are four kinds of image.
Definition: hbox.h:593
Definition: hbox.h:511
The TxtBox class saves object properties about table, textbox, equalizer or button.
Definition: hbox.h:327
unsigned char sal_Bool