Update ooo320-m1
[ooovba.git] / filter / source / t602 / t602filter.hxx
blob7243e468c744d673dd8c12e4bc3adeb968e14312
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: t602filter.hxx,v $
10 * $Revision: 1.3 $
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;
52 typedef enum {
53 standard, // default
54 fat, // bold
55 cursive, // italic
56 bold, // wide
57 tall, // high
58 big, // big
59 lindex, // lower index
60 hindex, // upper index
61 err, // not set yet
62 chngul // change underline
63 } fonts;
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
83 struct inistruct
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
92 inistruct()
93 : showcomm( true )
94 , forcecode( false )
95 , xcode ( KAM )
96 , ruscode ( false )
97 , reformatpars ( false )
98 , fontsize (10)
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;
112 ResMgr *mpResMgr;
113 sal_Bool OptionsDlg();
114 ResMgr* getResMgr();
115 rtl::OUString getResStr( sal_Int16 resid );
116 void initLocale();
118 ~T602ImportFilterDialog();
120 // XExecutableDialog
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);
126 // XLocalizable
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);
132 // XServiceInfo
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);
140 // XPropertyAccess
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);
151 public:
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
165 private:
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;
175 tnode node; // START
177 struct {
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
187 } format602;
189 // Initialisation constants - they are not changed during the conversion
191 inistruct ini;
193 // Font state - changes based on font
195 struct {
196 fonts nowfnt; // current font
197 fonts oldfnt; // previous font
198 bool uline; // underlined
199 bool olduline; // previous value of uline (font change)
200 } fst;
202 // Paragraph state
204 struct {
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
212 } pst;
214 void Reset602();
215 unsigned char Readchar602();
216 void Read602();
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);
224 void wrtfnt();
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);
229 public:
230 T602ImportFilter(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r );
231 ~T602ImportFilter();
233 // XFilter
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) {};
239 // XImporter
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 );
248 // XInitialization
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);
252 // XServiceInfo
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 );
289 #endif