1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
#define INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XLocalizable.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <cppuhelper/implbase.hxx>
#include <xmloff/attrlist.hxx>
#include <tools/resmgr.hxx>
namespace T602ImportFilter {
typedef enum {L2,KAM,KOI} tcode;
typedef enum {
standard, // default
fat, // bold
cursive, // italic
bold, // wide
tall, // high
big, // big
lindex, // lower index
hindex, // upper index
err, // not set yet
chngul // change underline
} fonts;
typedef enum {START,READCH,EOL,POCMD,EXPCMD,SETCMD,SETCH,WRITE,EEND,QUIT} tnode;
OUString getImplementationName()
throw ( css::uno::RuntimeException );
css::uno::Sequence < OUString > getSupportedServiceNames()
throw ( css::uno::RuntimeException );
css::uno::Reference < css::uno::XInterface > SAL_CALL
CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > &r)
throw ( css::uno::Exception );
// class T602ImportFilter
struct inistruct
{
bool showcomm; // true show comment lines
bool forcecode; // false the user has changed the encoding with something else than @CT
tcode xcode; // KAM encoding set - forced
bool ruscode; // false Russian tables turned on
bool reformatpars; // false Reformat paragraphs (whitespaces and line breaks)
sal_Int16 fontsize; // font size in points
inistruct()
: showcomm( true )
, forcecode( false )
, xcode ( KAM )
, ruscode ( false )
, reformatpars ( false )
, fontsize (10)
{
};
};
class T602ImportFilterDialog : public cppu::WeakImplHelper <
css::ui::dialogs::XExecutableDialog,
css::lang::XLocalizable,
css::lang::XServiceInfo,
css::beans::XPropertyAccess
>
{
css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
css::lang::Locale meLocale;
ResMgr *mpResMgr;
bool OptionsDlg();
ResMgr* getResMgr();
OUString getResStr( sal_Int16 resid );
void initLocale();
virtual ~T602ImportFilterDialog();
// XExecutableDialog
virtual void SAL_CALL setTitle( const OUString& aTitle )
throw (css::uno::RuntimeException, std::exception) override;
virtual sal_Int16 SAL_CALL execute()
throw (css::uno::RuntimeException, std::exception) override;
// XLocalizable
virtual void SAL_CALL setLocale( const css::lang::Locale& eLocale )
throw(css::uno::RuntimeException, std::exception) override;
virtual css::lang::Locale SAL_CALL getLocale()
throw(css::uno::RuntimeException, std::exception) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
throw (css::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (css::uno::RuntimeException, std::exception) override;
// XPropertyAccess
virtual css::uno::Sequence< css::beans::PropertyValue >
SAL_CALL getPropertyValues() throw (css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL setPropertyValues( const css::uno::Sequence<
css::beans::PropertyValue >& aProps )
throw (css::beans::UnknownPropertyException,
css::beans::PropertyVetoException,
css::lang::IllegalArgumentException,
css::lang::WrappedTargetException,
css::uno::RuntimeException, std::exception) override;
public:
explicit T602ImportFilterDialog(const css::uno::Reference<css::lang::XMultiServiceFactory > &r );
};
class T602ImportFilter : public cppu::WeakImplHelper <
css::document::XFilter,
css::document::XImporter,
css::document::XExtendedFilterDetection,
css::lang::XInitialization,
css::lang::XServiceInfo
>
{
private:
// css::uno::Reference<css::io::XInputStream> xInputStream;
css::uno::Reference<css::xml::sax::XDocumentHandler> mxHandler;
css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
css::uno::Reference< css::lang::XComponent > mxDoc;
css::uno::Reference < css::io::XInputStream > mxInputStream;
OUString msFilterName;
SvXMLAttributeList *mpAttrList;
tnode node; // START
struct format602struct
{
sal_Int16 mt; // row for header
sal_Int16 mb; // row for footer
sal_Int16 tb; // tabs
sal_Int16 ct; // encoding (0-kamenik, 1-latin2, 2-koi8)
sal_Int16 pn; // from page number
sal_Int16 lh; // linespacing 3-2x, 4-1.5x, 6-1x
sal_Int16 lm; // left border
sal_Int16 rm; // right border
sal_Int16 pl; // page length
format602struct()
: mt(0)
, mb(0)
, tb(0)
, ct(0)
, pn(0)
, lh(0)
, lm(0)
, rm(0)
, pl(0)
{
}
};
format602struct format602;
// Initialisation constants - they are not changed during the conversion
inistruct ini;
// Font state - changes based on font
struct fststruct
{
fonts nowfnt; // current font
fonts oldfnt; // previous font
bool uline; // underlined
bool olduline; // previous value of uline (font change)
fststruct()
: nowfnt(standard)
, oldfnt(standard)
, uline(false)
, olduline(false)
{
}
};
fststruct fst;
// Paragraph state
struct pststruct
{
sal_Int16 pars; // the number of line endings times linespacing on the current page
bool comment; // in comments
sal_Int16 wasspace; // 0 there was a space - for reformatting
bool wasfdash; // 0 formatting dash
bool ccafterln; // false
bool willbeeop; // false
bool waspar; // false
pststruct()
: pars(0)
, comment(false)
, wasspace(0)
, wasfdash(false)
, ccafterln(false)
, willbeeop(false)
, waspar(false)
{
}
};
pststruct pst;
void Reset602();
unsigned char Readchar602();
void Read602();
void par602(bool endofpage);
void inschr(unsigned char ch);
void inschrdef(unsigned char ch);
unsigned char Setformat602(char *cmd);
sal_Int16 readnum(unsigned char *ch, bool show);
tnode PointCmd602(unsigned char *ch);
void setfnt(fonts fnt,bool mustwrite);
void wrtfnt();
bool SAL_CALL importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor )
throw (css::uno::RuntimeException);
public:
explicit T602ImportFilter(const css::uno::Reference<css::lang::XMultiServiceFactory > &r );
explicit T602ImportFilter(css::uno::Reference<css::io::XInputStream> xInputStream);
virtual ~T602ImportFilter();
// XFilter
virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor )
throw (css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL cancel( )
throw (css::uno::RuntimeException, std::exception) override {};
// XImporter
virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc )
throw (css::lang::IllegalArgumentException, css::uno::RuntimeException, std::exception) override;
// XExtendedTypeDetection
virtual OUString SAL_CALL detect(
css::uno::Sequence< css::beans::PropertyValue >& Descriptor )
throw( css::uno::RuntimeException, std::exception ) override;
// XInitialization
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
throw (css::uno::RuntimeException, std::exception) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (css::uno::RuntimeException, std::exception) override;
bool SAL_CALL test();
};
OUString T602ImportFilter_getImplementationName()
throw ( css::uno::RuntimeException );
bool SAL_CALL T602ImportFilter_supportsService( const OUString& ServiceName )
throw ( css::uno::RuntimeException );
css::uno::Sequence< OUString > SAL_CALL T602ImportFilter_getSupportedServiceNames( )
throw ( css::uno::RuntimeException );
css::uno::Reference< css::uno::XInterface >
SAL_CALL T602ImportFilter_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr)
throw ( css::uno::Exception );
OUString T602ImportFilterDialog_getImplementationName()
throw ( css::uno::RuntimeException );
bool SAL_CALL T602ImportFilterDialog_supportsService( const OUString& ServiceName )
throw ( css::uno::RuntimeException );
css::uno::Sequence< OUString > SAL_CALL T602ImportFilterDialog_getSupportedServiceNames( )
throw ( css::uno::RuntimeException );
css::uno::Reference< css::uno::XInterface >
SAL_CALL T602ImportFilterDialog_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & rSMgr)
throw ( css::uno::Exception );
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|