LibreOffice Module filter (master) 1
t602filter.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 <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>
34#include <rtl/ref.hxx>
35
36namespace T602ImportFilter {
37
38typedef enum {L2,KAM,KOI} tcode;
39
40typedef 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
52
54
55
56
58{
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
65
67 : showcomm( true )
68 , forcecode( false )
69 , xcode ( KAM )
70 , ruscode ( false )
71 , reformatpars ( false )
72 {
73 };
74};
75
76class T602ImportFilterDialog : public cppu::WeakImplHelper <
77 css::ui::dialogs::XExecutableDialog,
78 css::lang::XServiceInfo,
79 css::beans::XPropertyAccess
80>
81{
82 static bool OptionsDlg();
83
84 virtual ~T602ImportFilterDialog() override;
85
86 // XExecutableDialog
87 virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
88 virtual sal_Int16 SAL_CALL execute() override;
89
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;
94
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;
100
101public:
102 explicit T602ImportFilterDialog();
103
104};
105
106
107class T602ImportFilter : public cppu::WeakImplHelper <
108 css::document::XFilter,
109 css::document::XImporter,
110 css::document::XExtendedFilterDetection,
111 css::lang::XInitialization,
112 css::lang::XServiceInfo
113>
114{
115private:
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;
120
122
123 tnode node; // START
124
126 {
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
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)
146 {
147 }
148 };
149
151
152 // Initialisation constants - they are not changed during the conversion
153
155
156 // Font state - changes based on font
157
159 {
160 fonts nowfnt; // current font
161 fonts oldfnt; // previous font
162 bool uline; // underlined
163 bool olduline; // previous value of uline (font change)
165 : nowfnt(standard)
166 , oldfnt(standard)
167 , uline(false)
168 , olduline(false)
169 {
170 }
171 };
172
174
175 // Paragraph state
176
178 {
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
187 : pars(0)
188 , comment(false)
189 , wasspace(0)
190 , wasfdash(false)
191 , ccafterln(false)
192 , willbeeop(false)
193 , waspar(false)
194 {
195 }
196 };
197
199
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();
211
213 bool importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor );
214
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;
219
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 {};
223
224 // XImporter
225 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
226
227 // XExtendedTypeDetection
228 virtual OUString SAL_CALL detect(
229 css::uno::Sequence< css::beans::PropertyValue >& Descriptor ) override;
230
231 // XInitialization
232 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
233
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;
238
239 void test();
240};
241
242}
243
244/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const short QUIT
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< css::beans::PropertyValue > &aProps) override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getPropertyValues() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL setTitle(const OUString &aTitle) override
virtual sal_Int16 SAL_CALL execute() override
rtl::Reference< comphelper::AttributeList > mpAttrList
Definition: t602filter.hxx:121
virtual void SAL_CALL cancel() override
Definition: t602filter.hxx:222
css::uno::Reference< css::io::XInputStream > mxInputStream
Definition: t602filter.hxx:119
css::uno::Reference< css::lang::XComponent > mxDoc
Definition: t602filter.hxx:118
css::uno::Reference< css::xml::sax::XDocumentHandler > mxHandler
Definition: t602filter.hxx:116
css::uno::Reference< css::uno::XComponentContext > mxContext
Definition: t602filter.hxx:117
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
START
static const sal_Int16 fontsize
Definition: t602filter.hxx:64
WRITE
unsigned char sal_Bool