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 _T602FILTER_HXX
21 #define _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 <cppuhelper/implbase5.hxx>
33 #include <cppuhelper/implbase4.hxx>
34 #include <xmloff/attrlist.hxx>
35 #include <tools/resmgr.hxx>
37 namespace T602ImportFilter
{
39 typedef enum {L2
,KAM
,KOI
} tcode
;
48 lindex
, // lower index
49 hindex
, // upper index
51 chngul
// change underline
54 typedef enum {START
,READCH
,EOL
,POCMD
,EXPCMD
,SETCMD
,SETCH
,WRITE
,EEND
,QUIT
} tnode
;
56 OUString
getImplementationName()
57 throw ( ::com::sun::star::uno::RuntimeException
);
59 ::com::sun::star::uno::Sequence
< OUString
> getSupportedServiceNames()
60 throw ( ::com::sun::star::uno::RuntimeException
);
63 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
64 CreateInstance( const ::com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> &r
)
65 throw ( ::com::sun::star::uno::Exception
);
69 // class T602ImportFilter
74 bool showcomm
; // true show comment lines
75 bool forcecode
; // false the user has changed the encoding with something else than @CT
76 tcode xcode
; // KAM encoding set - forced
77 bool ruscode
; // false Russian tables turned on
78 bool reformatpars
; // false Reformat paragraphs (whitespaces and line breaks)
79 sal_Int16 fontsize
; // font size in points
86 , reformatpars ( false )
92 class T602ImportFilterDialog
: public cppu::WeakImplHelper4
<
93 com::sun::star::ui::dialogs::XExecutableDialog
,
94 com::sun::star::lang::XLocalizable
,
95 com::sun::star::lang::XServiceInfo
,
96 com::sun::star::beans::XPropertyAccess
99 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
100 com::sun::star::lang::Locale meLocale
;
102 sal_Bool
OptionsDlg();
104 OUString
getResStr( sal_Int16 resid
);
107 ~T602ImportFilterDialog();
110 virtual void SAL_CALL
setTitle( const OUString
& aTitle
)
111 throw (::com::sun::star::uno::RuntimeException
);
112 virtual sal_Int16 SAL_CALL
execute()
113 throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
setLocale( const com::sun::star::lang::Locale
& eLocale
)
117 throw(::com::sun::star::uno::RuntimeException
);
118 virtual com::sun::star::lang::Locale SAL_CALL
getLocale()
119 throw(::com::sun::star::uno::RuntimeException
);
122 virtual OUString SAL_CALL
getImplementationName( )
123 throw (::com::sun::star::uno::RuntimeException
);
124 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
125 throw (::com::sun::star::uno::RuntimeException
);
126 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( )
127 throw (::com::sun::star::uno::RuntimeException
);
130 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
131 SAL_CALL
getPropertyValues() throw (::com::sun::star::uno::RuntimeException
);
132 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
<
133 ::com::sun::star::beans::PropertyValue
>& aProps
)
134 throw (::com::sun::star::beans::UnknownPropertyException
,
135 ::com::sun::star::beans::PropertyVetoException
,
136 ::com::sun::star::lang::IllegalArgumentException
,
137 ::com::sun::star::lang::WrappedTargetException
,
138 ::com::sun::star::uno::RuntimeException
);
141 T602ImportFilterDialog(const ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> &r
);
146 class T602ImportFilter
: public cppu::WeakImplHelper5
<
147 com::sun::star::document::XFilter
,
148 com::sun::star::document::XImporter
,
149 com::sun::star::document::XExtendedFilterDetection
,
150 com::sun::star::lang::XInitialization
,
151 com::sun::star::lang::XServiceInfo
155 // ::com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
156 ::com::sun::star::uno::Reference
<com::sun::star::xml::sax::XDocumentHandler
> mxHandler
;
157 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
158 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> mxDoc
;
159 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> mxInputStream
;
160 OUString msFilterName
;
162 SvXMLAttributeList
*mpAttrList
;
167 sal_Int16 mt
; // row for header
168 sal_Int16 mb
; // row for footer
169 sal_Int16 tb
; // tabs
170 sal_Int16 ct
; // encoding (0-kamenik, 1-latin2, 2-koi8)
171 sal_Int16 pn
; // from page number
172 sal_Int16 lh
; // linespacing 3-2x, 4-1.5x, 6-1x
173 sal_Int16 lm
; // left border
174 sal_Int16 rm
; // right border
175 sal_Int16 pl
; // page length
178 // Initialisation constants - they are not changed during the conversion
182 // Font state - changes based on font
185 fonts nowfnt
; // current font
186 fonts oldfnt
; // previous font
187 bool uline
; // underlined
188 bool olduline
; // previous value of uline (font change)
194 sal_Int16 pars
; // the number of line endings times linespacing on the current page
195 bool comment
; // in comments
196 sal_Int16 wasspace
; // 0 there was a space - for reformatting
197 bool wasfdash
; // 0 formatting dash
198 bool ccafterln
; // false
199 bool willbeeop
; // false
200 bool waspar
; // false
204 unsigned char Readchar602();
206 void par602(bool endofpage
);
207 void inschr(unsigned char ch
);
208 void inschrdef(unsigned char ch
);
209 unsigned char Setformat602(char *cmd
);
210 sal_Int16
readnum(unsigned char *ch
, bool show
);
211 tnode
PointCmd602(unsigned char *ch
);
212 void setfnt(fonts fnt
,bool mustwrite
);
215 sal_Bool SAL_CALL
importImpl( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
216 throw (::com::sun::star::uno::RuntimeException
);
219 T602ImportFilter(const ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> &r
);
223 virtual sal_Bool SAL_CALL
filter( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
224 throw (::com::sun::star::uno::RuntimeException
);
225 virtual void SAL_CALL
cancel( )
226 throw (::com::sun::star::uno::RuntimeException
) {};
229 virtual void SAL_CALL
setTargetDocument( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& xDoc
)
230 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
232 // XExtendedTypeDetection
233 virtual OUString SAL_CALL
detect(
234 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& Descriptor
)
235 throw( com::sun::star::uno::RuntimeException
);
238 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
239 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
242 virtual OUString SAL_CALL
getImplementationName( )
243 throw (::com::sun::star::uno::RuntimeException
);
244 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
)
245 throw (::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( )
247 throw (::com::sun::star::uno::RuntimeException
);
250 OUString
T602ImportFilter_getImplementationName()
251 throw ( ::com::sun::star::uno::RuntimeException
);
253 sal_Bool SAL_CALL
T602ImportFilter_supportsService( const OUString
& ServiceName
)
254 throw ( ::com::sun::star::uno::RuntimeException
);
256 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
T602ImportFilter_getSupportedServiceNames( )
257 throw ( ::com::sun::star::uno::RuntimeException
);
259 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
260 SAL_CALL
T602ImportFilter_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
)
261 throw ( ::com::sun::star::uno::Exception
);
263 OUString
T602ImportFilterDialog_getImplementationName()
264 throw ( ::com::sun::star::uno::RuntimeException
);
266 sal_Bool SAL_CALL
T602ImportFilterDialog_supportsService( const OUString
& ServiceName
)
267 throw ( ::com::sun::star::uno::RuntimeException
);
269 ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
T602ImportFilterDialog_getSupportedServiceNames( )
270 throw ( ::com::sun::star::uno::RuntimeException
);
272 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
273 SAL_CALL
T602ImportFilterDialog_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
)
274 throw ( ::com::sun::star::uno::Exception
);
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */