1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
49 lindex
, // lower index
50 hindex
, // upper index
52 chngul
// change underline
55 enum class tnode
{START
,READCH
,EOL
,POCMD
,EXPCMD
,SETCMD
,SETCH
,WRITE
,EEND
,QUIT
};
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
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
86 std::locale maResLocale
;
88 OUString
getResStr(const char* resid
);
90 virtual ~T602ImportFilterDialog() override
;
93 virtual void SAL_CALL
setTitle( const OUString
& aTitle
) override
;
94 virtual sal_Int16 SAL_CALL
execute() override
;
97 virtual void SAL_CALL
setLocale( const css::lang::Locale
& eLocale
) override
;
98 virtual css::lang::Locale SAL_CALL
getLocale() override
;
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
;
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
;
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
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
;
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
160 format602struct format602
;
162 // Initialisation constants - they are not changed during the conversion
166 // Font state - changes based on font
170 fonts nowfnt
; // current font
171 fonts oldfnt
; // previous font
172 bool uline
; // underlined
173 bool olduline
; // previous value of uline (font change)
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
211 unsigned char Readchar602();
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
);
222 /// @throws css::uno::RuntimeException
223 bool importImpl( const css::uno::Sequence
< css::beans::PropertyValue
>& aDescriptor
);
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
;
231 virtual sal_Bool SAL_CALL
filter( const css::uno::Sequence
< css::beans::PropertyValue
>& aDescriptor
) override
;
232 virtual void SAL_CALL
cancel( ) override
{};
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
;
242 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
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
;
256 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */