1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: t602filter.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _T602FILTER_HXX
32 #define _T602FILTER_HXX
34 #include <com/sun/star/document/XFilter.hpp>
35 #include <com/sun/star/document/XImporter.hpp>
36 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
37 #include <com/sun/star/io/XInputStream.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/lang/XLocalizable.hpp>
41 #include <com/sun/star/beans/XPropertyAccess.hpp>
42 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
43 #include <cppuhelper/implbase5.hxx>
44 #include <cppuhelper/implbase4.hxx>
45 #include <xmloff/attrlist.hxx>
46 #include <tools/resmgr.hxx>
48 namespace T602ImportFilter
{
50 typedef enum {L2
,KAM
,KOI
} tcode
;
59 lindex
, // lower index
60 hindex
, // upper index
62 chngul
// change underline
65 typedef enum {START
,READCH
,EOL
,POCMD
,EXPCMD
,SETCMD
,SETCH
,WRITE
,EEND
,QUIT
} tnode
;
67 ::rtl::OUString
getImplementationName()
68 throw ( ::com::sun::star::uno::RuntimeException
);
70 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames()
71 throw ( ::com::sun::star::uno::RuntimeException
);
74 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
75 CreateInstance( const ::com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
> &r
)
76 throw ( ::com::sun::star::uno::Exception
);
80 // class T602ImportFilter
85 bool showcomm
; // true show comment lines
86 bool forcecode
; // false the user has changed the encoding with something else than @CT
87 tcode xcode
; // KAM encoding set - forced
88 bool ruscode
; // false Russian tables turned on
89 bool reformatpars
; // false Reformat paragraphs (whitespaces and line breaks)
90 sal_Int16 fontsize
; // font size in points
97 , reformatpars ( false )
103 class T602ImportFilterDialog
: public cppu::WeakImplHelper4
<
104 com::sun::star::ui::dialogs::XExecutableDialog
,
105 com::sun::star::lang::XLocalizable
,
106 com::sun::star::lang::XServiceInfo
,
107 com::sun::star::beans::XPropertyAccess
110 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
111 com::sun::star::lang::Locale meLocale
;
113 sal_Bool
OptionsDlg();
115 rtl::OUString
getResStr( sal_Int16 resid
);
118 ~T602ImportFilterDialog();
121 virtual void SAL_CALL
setTitle( const ::rtl::OUString
& aTitle
)
122 throw (::com::sun::star::uno::RuntimeException
);
123 virtual sal_Int16 SAL_CALL
execute()
124 throw (::com::sun::star::uno::RuntimeException
);
127 virtual void SAL_CALL
setLocale( const com::sun::star::lang::Locale
& eLocale
)
128 throw(::com::sun::star::uno::RuntimeException
);
129 virtual com::sun::star::lang::Locale SAL_CALL
getLocale()
130 throw(::com::sun::star::uno::RuntimeException
);
133 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
134 throw (::com::sun::star::uno::RuntimeException
);
135 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
136 throw (::com::sun::star::uno::RuntimeException
);
137 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
138 throw (::com::sun::star::uno::RuntimeException
);
141 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>
142 SAL_CALL
getPropertyValues() throw (::com::sun::star::uno::RuntimeException
);
143 virtual void SAL_CALL
setPropertyValues( const ::com::sun::star::uno::Sequence
<
144 ::com::sun::star::beans::PropertyValue
>& aProps
)
145 throw (::com::sun::star::beans::UnknownPropertyException
,
146 ::com::sun::star::beans::PropertyVetoException
,
147 ::com::sun::star::lang::IllegalArgumentException
,
148 ::com::sun::star::lang::WrappedTargetException
,
149 ::com::sun::star::uno::RuntimeException
);
152 T602ImportFilterDialog(const ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> &r
);
157 class T602ImportFilter
: public cppu::WeakImplHelper5
<
158 com::sun::star::document::XFilter
,
159 com::sun::star::document::XImporter
,
160 com::sun::star::document::XExtendedFilterDetection
,
161 com::sun::star::lang::XInitialization
,
162 com::sun::star::lang::XServiceInfo
166 // ::com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
167 ::com::sun::star::uno::Reference
<com::sun::star::xml::sax::XDocumentHandler
> mxHandler
;
168 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> mxMSF
;
169 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> mxDoc
;
170 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> mxInputStream
;
171 ::rtl::OUString msFilterName
;
173 SvXMLAttributeList
*mpAttrList
;
178 sal_Int16 mt
; // row for header
179 sal_Int16 mb
; // row for footer
180 sal_Int16 tb
; // tabs
181 sal_Int16 ct
; // encoding (0-kamenik, 1-latin2, 2-koi8)
182 sal_Int16 pn
; // from page number
183 sal_Int16 lh
; // linespacing 3-2x, 4-1.5x, 6-1x
184 sal_Int16 lm
; // left border
185 sal_Int16 rm
; // right border
186 sal_Int16 pl
; // page length
189 // Initialisation constants - they are not changed during the conversion
193 // Font state - changes based on font
196 fonts nowfnt
; // current font
197 fonts oldfnt
; // previous font
198 bool uline
; // underlined
199 bool olduline
; // previous value of uline (font change)
205 sal_Int16 pars
; // the number of line endings times linespacing on the current page
206 bool comment
; // in comments
207 sal_Int16 wasspace
; // 0 there was a space - for reformatting
208 bool wasfdash
; // 0 formatting dash
209 bool ccafterln
; // false
210 bool willbeeop
; // false
211 bool waspar
; // false
215 unsigned char Readchar602();
217 void par602(bool endofpage
);
218 void inschr(unsigned char ch
);
219 void inschrdef(unsigned char ch
);
220 unsigned char Setformat602(char *cmd
);
221 sal_Int16
readnum(unsigned char *ch
, bool show
);
222 tnode
PointCmd602(unsigned char *ch
);
223 void setfnt(fonts fnt
,bool mustwrite
);
226 sal_Bool SAL_CALL
importImpl( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
227 throw (::com::sun::star::uno::RuntimeException
);
230 T602ImportFilter(const ::com::sun::star::uno::Reference
<com::sun::star::lang::XMultiServiceFactory
> &r
);
234 virtual sal_Bool SAL_CALL
filter( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aDescriptor
)
235 throw (::com::sun::star::uno::RuntimeException
);
236 virtual void SAL_CALL
cancel( )
237 throw (::com::sun::star::uno::RuntimeException
) {};
240 virtual void SAL_CALL
setTargetDocument( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>& xDoc
)
241 throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
243 // XExtendedTypeDetection
244 virtual ::rtl::OUString SAL_CALL
detect(
245 com::sun::star::uno::Sequence
< com::sun::star::beans::PropertyValue
>& Descriptor
)
246 throw( com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
250 throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
253 virtual ::rtl::OUString SAL_CALL
getImplementationName( )
254 throw (::com::sun::star::uno::RuntimeException
);
255 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
)
256 throw (::com::sun::star::uno::RuntimeException
);
257 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( )
258 throw (::com::sun::star::uno::RuntimeException
);
261 ::rtl::OUString
T602ImportFilter_getImplementationName()
262 throw ( ::com::sun::star::uno::RuntimeException
);
264 sal_Bool SAL_CALL
T602ImportFilter_supportsService( const ::rtl::OUString
& ServiceName
)
265 throw ( ::com::sun::star::uno::RuntimeException
);
267 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
T602ImportFilter_getSupportedServiceNames( )
268 throw ( ::com::sun::star::uno::RuntimeException
);
270 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
271 SAL_CALL
T602ImportFilter_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
)
272 throw ( ::com::sun::star::uno::Exception
);
274 ::rtl::OUString
T602ImportFilterDialog_getImplementationName()
275 throw ( ::com::sun::star::uno::RuntimeException
);
277 sal_Bool SAL_CALL
T602ImportFilterDialog_supportsService( const ::rtl::OUString
& ServiceName
)
278 throw ( ::com::sun::star::uno::RuntimeException
);
280 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
T602ImportFilterDialog_getSupportedServiceNames( )
281 throw ( ::com::sun::star::uno::RuntimeException
);
283 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
284 SAL_CALL
T602ImportFilterDialog_createInstance( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> & rSMgr
)
285 throw ( ::com::sun::star::uno::Exception
);