bump product version to 7.6.3.2-android
[LibreOffice.git] / filter / source / t602 / t602filter.hxx
blob93efc45c28ed638f5414472eb8ae73284dd3aeac
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 <com/sun/star/document/XFilter.hpp>
23 #include <com/sun/star/document/XImporter.hpp>
24 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
25 #include <com/sun/star/io/XInputStream.hpp>
26 #include <com/sun/star/lang/XInitialization.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/beans/XPropertyAccess.hpp>
29 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
30 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
31 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <comphelper/attributelist.hxx>
33 #include <cppuhelper/implbase.hxx>
34 #include <rtl/ref.hxx>
36 namespace T602ImportFilter {
38 typedef enum {L2,KAM,KOI} tcode;
40 typedef enum {
41 standard, // default
42 fat, // bold
43 cursive, // italic
44 bold, // wide
45 tall, // high
46 big, // big
47 lindex, // lower index
48 hindex, // upper index
49 err, // not set yet
50 chngul // change underline
51 } fonts;
53 enum class tnode {START,READCH,EOL,POCMD,EXPCMD,SETCMD,SETCH,WRITE,EEND,QUIT};
57 struct inistruct
59 bool showcomm; // true show comment lines
60 bool forcecode; // false the user has changed the encoding with something else than @CT
61 tcode xcode; // KAM encoding set - forced
62 bool ruscode; // false Russian tables turned on
63 bool reformatpars; // false Reformat paragraphs (whitespaces and line breaks)
64 static const sal_Int16 fontsize = 10; // font size in points
66 inistruct()
67 : showcomm( true )
68 , forcecode( false )
69 , xcode ( KAM )
70 , ruscode ( false )
71 , reformatpars ( false )
76 class T602ImportFilterDialog : public cppu::WeakImplHelper <
77 css::ui::dialogs::XExecutableDialog,
78 css::lang::XServiceInfo,
79 css::beans::XPropertyAccess
82 static bool OptionsDlg();
84 virtual ~T602ImportFilterDialog() override;
86 // XExecutableDialog
87 virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
88 virtual sal_Int16 SAL_CALL execute() override;
90 // XServiceInfo
91 virtual OUString SAL_CALL getImplementationName( ) override;
92 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
93 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
95 // XPropertyAccess
96 virtual css::uno::Sequence< css::beans::PropertyValue >
97 SAL_CALL getPropertyValues() override;
98 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence<
99 css::beans::PropertyValue >& aProps ) override;
101 public:
102 explicit T602ImportFilterDialog();
107 class T602ImportFilter : public cppu::WeakImplHelper <
108 css::document::XFilter,
109 css::document::XImporter,
110 css::document::XExtendedFilterDetection,
111 css::lang::XInitialization,
112 css::lang::XServiceInfo
115 private:
116 css::uno::Reference<css::xml::sax::XDocumentHandler> mxHandler;
117 css::uno::Reference< css::uno::XComponentContext > mxContext;
118 css::uno::Reference< css::lang::XComponent > mxDoc;
119 css::uno::Reference < css::io::XInputStream > mxInputStream;
121 rtl::Reference<comphelper::AttributeList> mpAttrList;
123 tnode node; // START
125 struct format602struct
127 sal_Int16 mt; // row for header
128 sal_Int16 mb; // row for footer
129 sal_Int16 tb; // tabs
130 sal_Int16 ct; // encoding (0-kamenik, 1-latin2, 2-koi8)
131 sal_Int16 pn; // from page number
132 sal_Int16 lh; // linespacing 3-2x, 4-1.5x, 6-1x
133 sal_Int16 lm; // left border
134 sal_Int16 rm; // right border
135 sal_Int16 pl; // page length
136 format602struct()
137 : mt(0)
138 , mb(0)
139 , tb(0)
140 , ct(0)
141 , pn(0)
142 , lh(0)
143 , lm(0)
144 , rm(0)
145 , pl(0)
150 format602struct format602;
152 // Initialisation constants - they are not changed during the conversion
154 inistruct ini;
156 // Font state - changes based on font
158 struct fststruct
160 fonts nowfnt; // current font
161 fonts oldfnt; // previous font
162 bool uline; // underlined
163 bool olduline; // previous value of uline (font change)
164 fststruct()
165 : nowfnt(standard)
166 , oldfnt(standard)
167 , uline(false)
168 , olduline(false)
173 fststruct fst;
175 // Paragraph state
177 struct pststruct
179 sal_Int16 pars; // the number of line endings times linespacing on the current page
180 bool comment; // in comments
181 sal_Int16 wasspace; // 0 there was a space - for reformatting
182 bool wasfdash; // 0 formatting dash
183 bool ccafterln; // false
184 bool willbeeop; // false
185 bool waspar; // false
186 pststruct()
187 : pars(0)
188 , comment(false)
189 , wasspace(0)
190 , wasfdash(false)
191 , ccafterln(false)
192 , willbeeop(false)
193 , waspar(false)
198 pststruct pst;
200 void Reset602();
201 unsigned char Readchar602();
202 void Read602();
203 void par602(bool endofpage);
204 void inschr(unsigned char ch);
205 void inschrdef(unsigned char ch);
206 unsigned char Setformat602(const char *cmd);
207 sal_Int16 readnum(unsigned char *ch, bool show);
208 tnode PointCmd602(unsigned char *ch);
209 void setfnt(fonts fnt,bool mustwrite);
210 void wrtfnt();
212 /// @throws css::uno::RuntimeException
213 bool importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor );
215 public:
216 explicit T602ImportFilter(css::uno::Reference<css::uno::XComponentContext > x );
217 explicit T602ImportFilter(css::uno::Reference<css::io::XInputStream> xInputStream);
218 virtual ~T602ImportFilter() override;
220 // XFilter
221 virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
222 virtual void SAL_CALL cancel( ) override {};
224 // XImporter
225 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
227 // XExtendedTypeDetection
228 virtual OUString SAL_CALL detect(
229 css::uno::Sequence< css::beans::PropertyValue >& Descriptor ) override;
231 // XInitialization
232 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
234 // XServiceInfo
235 virtual OUString SAL_CALL getImplementationName( ) override;
236 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
237 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
239 void test();
244 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */