nss: upgrade to release 3.73
[LibreOffice.git] / filter / source / t602 / t602filter.hxx
bloba703da4118306134e9e2d09ecdedd9c7cb37582f
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 #ifndef INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
21 #define INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
23 #include <com/sun/star/document/XFilter.hpp>
24 #include <com/sun/star/document/XImporter.hpp>
25 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
26 #include <com/sun/star/io/XInputStream.hpp>
27 #include <com/sun/star/lang/XInitialization.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XLocalizable.hpp>
30 #include <com/sun/star/beans/XPropertyAccess.hpp>
31 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
32 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
34 #include <cppuhelper/implbase.hxx>
35 #include <xmloff/attrlist.hxx>
36 #include <i18nlangtag/languagetag.hxx>
38 namespace T602ImportFilter {
40 typedef enum {L2,KAM,KOI} tcode;
42 typedef enum {
43 standard, // default
44 fat, // bold
45 cursive, // italic
46 bold, // wide
47 tall, // high
48 big, // big
49 lindex, // lower index
50 hindex, // upper index
51 err, // not set yet
52 chngul // change underline
53 } fonts;
55 enum class tnode {START,READCH,EOL,POCMD,EXPCMD,SETCMD,SETCH,WRITE,EEND,QUIT};
59 struct inistruct
61 bool showcomm; // true show comment lines
62 bool forcecode; // false the user has changed the encoding with something else than @CT
63 tcode xcode; // KAM encoding set - forced
64 bool ruscode; // false Russian tables turned on
65 bool reformatpars; // false Reformat paragraphs (whitespaces and line breaks)
66 static const sal_Int16 fontsize = 10; // font size in points
68 inistruct()
69 : showcomm( true )
70 , forcecode( false )
71 , xcode ( KAM )
72 , ruscode ( false )
73 , reformatpars ( false )
78 class T602ImportFilterDialog : public cppu::WeakImplHelper <
79 css::ui::dialogs::XExecutableDialog,
80 css::lang::XLocalizable,
81 css::lang::XServiceInfo,
82 css::beans::XPropertyAccess
85 LanguageTag maLocale;
86 std::locale maResLocale;
87 bool OptionsDlg();
88 OUString getResStr(const char* resid);
90 virtual ~T602ImportFilterDialog() override;
92 // XExecutableDialog
93 virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
94 virtual sal_Int16 SAL_CALL execute() override;
96 // XLocalizable
97 virtual void SAL_CALL setLocale( const css::lang::Locale& eLocale ) override;
98 virtual css::lang::Locale SAL_CALL getLocale() override;
100 // XServiceInfo
101 virtual OUString SAL_CALL getImplementationName( ) override;
102 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
103 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
105 // XPropertyAccess
106 virtual css::uno::Sequence< css::beans::PropertyValue >
107 SAL_CALL getPropertyValues() override;
108 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence<
109 css::beans::PropertyValue >& aProps ) override;
111 public:
112 explicit T602ImportFilterDialog();
117 class T602ImportFilter : public cppu::WeakImplHelper <
118 css::document::XFilter,
119 css::document::XImporter,
120 css::document::XExtendedFilterDetection,
121 css::lang::XInitialization,
122 css::lang::XServiceInfo
125 private:
126 css::uno::Reference<css::xml::sax::XDocumentHandler> mxHandler;
127 css::uno::Reference< css::uno::XComponentContext > mxContext;
128 css::uno::Reference< css::lang::XComponent > mxDoc;
129 css::uno::Reference < css::io::XInputStream > mxInputStream;
131 SvXMLAttributeList *mpAttrList;
133 tnode node; // START
135 struct format602struct
137 sal_Int16 mt; // row for header
138 sal_Int16 mb; // row for footer
139 sal_Int16 tb; // tabs
140 sal_Int16 ct; // encoding (0-kamenik, 1-latin2, 2-koi8)
141 sal_Int16 pn; // from page number
142 sal_Int16 lh; // linespacing 3-2x, 4-1.5x, 6-1x
143 sal_Int16 lm; // left border
144 sal_Int16 rm; // right border
145 sal_Int16 pl; // page length
146 format602struct()
147 : mt(0)
148 , mb(0)
149 , tb(0)
150 , ct(0)
151 , pn(0)
152 , lh(0)
153 , lm(0)
154 , rm(0)
155 , pl(0)
160 format602struct format602;
162 // Initialisation constants - they are not changed during the conversion
164 inistruct ini;
166 // Font state - changes based on font
168 struct fststruct
170 fonts nowfnt; // current font
171 fonts oldfnt; // previous font
172 bool uline; // underlined
173 bool olduline; // previous value of uline (font change)
174 fststruct()
175 : nowfnt(standard)
176 , oldfnt(standard)
177 , uline(false)
178 , olduline(false)
183 fststruct fst;
185 // Paragraph state
187 struct pststruct
189 sal_Int16 pars; // the number of line endings times linespacing on the current page
190 bool comment; // in comments
191 sal_Int16 wasspace; // 0 there was a space - for reformatting
192 bool wasfdash; // 0 formatting dash
193 bool ccafterln; // false
194 bool willbeeop; // false
195 bool waspar; // false
196 pststruct()
197 : pars(0)
198 , comment(false)
199 , wasspace(0)
200 , wasfdash(false)
201 , ccafterln(false)
202 , willbeeop(false)
203 , waspar(false)
208 pststruct pst;
210 void Reset602();
211 unsigned char Readchar602();
212 void Read602();
213 void par602(bool endofpage);
214 void inschr(unsigned char ch);
215 void inschrdef(unsigned char ch);
216 unsigned char Setformat602(const char *cmd);
217 sal_Int16 readnum(unsigned char *ch, bool show);
218 tnode PointCmd602(unsigned char *ch);
219 void setfnt(fonts fnt,bool mustwrite);
220 void wrtfnt();
222 /// @throws css::uno::RuntimeException
223 bool importImpl( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor );
225 public:
226 explicit T602ImportFilter(const css::uno::Reference<css::uno::XComponentContext > &r );
227 explicit T602ImportFilter(css::uno::Reference<css::io::XInputStream> const & xInputStream);
228 virtual ~T602ImportFilter() override;
230 // XFilter
231 virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
232 virtual void SAL_CALL cancel( ) override {};
234 // XImporter
235 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
237 // XExtendedTypeDetection
238 virtual OUString SAL_CALL detect(
239 css::uno::Sequence< css::beans::PropertyValue >& Descriptor ) override;
241 // XInitialization
242 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
244 // XServiceInfo
245 virtual OUString SAL_CALL getImplementationName( ) override;
246 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
247 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
249 void test();
254 #endif
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */