1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #include "t602filter.hxx"
21 #include <strings.hrc>
22
23 #include <stdio.h>
24
25 #include <cppuhelper/factory.hxx>
26 #include <cppuhelper/bootstrap.hxx>
27 #include <cppuhelper/supportsservice.hxx>
28 #include <com/sun/star/awt/Toolkit.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/awt/UnoControlDialog.hpp>
32 #include <com/sun/star/awt/XControl.hpp>
33 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <osl/diagnose.h>
36 #include <rtl/ref.hxx>
37 #include <rtl/character.hxx>
38 #include <unotools/resmgr.hxx>
39 #include <unotools/streamwrap.hxx>
40
41 using namespace ::cppu;
42 using namespace ::osl;
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::registry;
47 using namespace ::com::sun::star::container;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::awt;
50 using namespace ::com::sun::star::xml::sax;
51 using namespace ::com::sun::star::document;
52 using com::sun::star::io::XInputStream;
53
54 namespace T602ImportFilter {
55
56 unsigned char const kam2lat[129] =
57 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
58 "\xAC\x81\x82\xD4\x84\xD2\x9B\x9F\xD8\xB7\x91\xD6\x96\x92\x8E\xB5" // 8
59 "\x90\xA7\xA6\x93\x94\xE0\x85\xE9\xEC\x99\x9A\xE6\x95\xED\xFC\x9C" // 9
60 "\xA0\xA1\xA2\xA3\xE5\xD5\xDE\xE2\xE7\xFD\xEA\xE8\xCE\xF5\xAE\xAF" // A
61 "\x80\x80\x83\xB3\xB4\xE1\x87\x88\x89\x8A\x8B\x8C\x8F\x97\x8D\xBF" // B
62 "\xC0\xC1\xC2\xC3\xC4\xC5\xCF\x98\x9D\x9E\xA4\xA5\xA8\xA9\x86\xF3" // C
63 "\xCD\xB1\xB2\xB6\xB8\xB9\xBA\xBB\xF7\xD9\xDA\xDB\xDC\xF8\xF9\xDF" // D
64 "\xD0\xD1\xD3\xD7\xAA\xAB\xDD\xB0\xE3\xE4\xEB\xEE\xEF\xF0\xF2\xF4" // E
65 "\xBC\xBD\xBE\xC6\xC7\xC8\xF6\xC9\xCA\xFA\xFB\xCB\xF1\xCC\xFE\xFF"; // F
66
67 unsigned char const koi2lat[129] =
68 // 0 1 2 3 4 5 6 7 8 9 A B C D E F
69 "\x80\x83\x86\xF5\xE1\x87\x88\x89\x8A\x8B\x8C\x8F\x97\xCF\xCF\x98" // 8
70 "\x9D\x9E\xA4\xA5\xA8\xA9\xDB\xDC\xDF\xB1\xB2\xB6\xB8\xB9\xBA\xBB" // 9
71 "\xBC\xBD\xBE\xC6\xC7\xC8\xF6\xC9\xCA\xCB\xCC\xCD\xCE\xAD\xAE\xAF" // A
72 "\xD0\xD1\xD3\xD7\xAA\xAB\xDD\xB0\xE3\xE4\xEB\xEE\xEF\xF0\xF2\xF4" // B
73 "\xDA\xA0\xC0\x9F\xD4\xD8\xEA\xC4\x81\xA1\x85\x92\x96\x94\xE5\xA2" // C
74 "\x93\x84\xFD\xE7\x9C\xA3\xC3\x82\xF7\xEC\xA7\xC2\xF3\xF8\xF9\xC5" // D
75 "\xBF\xB5\xD9\xAC\xD2\xB7\xE8\xB3\x9A\xD6\xDE\x91\x95\x99\xD5\xE0" // E
76 "\xE2\x8E\xFC\xE6\x9B\xE9\xB4\x90\xFA\xED\xA6\xC1\xF1\xFB\xFE\xFF"; // F
77
78 unsigned char const lat2UNC[257] =
79 // 0 1 2 3 4 5 6 7
80 // 8 9 A B C D E F
81 "\x00\xe7\x00\xfc\x00\xe9\x00\xf9\x00\xe4\x01\x6f\x00\xe8\x00\xa3" // 8
82 "\x00\xc6\x00\xd8\x00\xc5\x00\xe6\x00\xf8\x00\xc4\x00\xc4\x00\xe5"
83 "\x00\xc9\x01\x39\x00\xf4\x00\xf4\x00\xf6\x01\x3d\x01\x3e\x00\x20" // 9
84 "\x00\xf2\x00\xd6\x00\xdc\x01\x64\x01\x65\x00\xec\x20\xa7\x01\x0d"
85 "\x00\xe1\x00\xed\x00\xf3\x00\xfa\x00\xa1\x00\xd1\x01\x7d\x01\x7e" // A
86 "\x00\xbf\x00\xf1\x22\x11\x03\xc3\x01\x0c\x00\xa7\x00\xbb\x00\xab"
87 "\x25\x91\x25\x92\x25\x93\x25\x02\x25\x24\x00\xc1\x00\xc2\x01\x1a" // B
88 "\x00\x20\x00\x20\x00\x20\x00\x20\x22\x61\x00\xb1\x22\x65\x25\x10"
89 "\x25\x14\x25\x34\x25\x2c\x25\x1c\x25\x00\x25\x3c\x22\x64\x23\x20" // C
90 "\x23\x21\x22\x48\x00\xba\x22\x1a\x00\xb2\x00\xbd\x00\xbc\x00\xa4"
91 "\x03\xb1\x03\xb2\x01\x0e\x03\x93\x01\x0f\x01\x47\x00\xcd\x03\xc0" // D
92 "\x01\x1b\x25\x18\x25\x0c\x25\x88\x25\x84\x00\xb5\x01\x6e\x25\x80"
93 "\x00\xd3\x00\xdf\x00\xd4\x03\xa6\x03\x98\x01\x48\x01\x60\x01\x61" // E
94 "\x01\x54\x00\xda\x01\x55\x03\xa9\x00\xfd\x00\xdd\x03\xb4\x22\x1e"
95 "\x00\xf8\x02\xdd\x03\xb5\x02\xc7\x22\x29\x00\xa7\x00\xf7\x00\xe0" // F
96 "\x00\xb4\x00\xb0\x00\xc0\x02\xc6\x01\x58\x01\x59\x00\x20\x00\x20";
97
98 unsigned char const rus2UNC[257] =
99 // 0 1 2 3 4 5 6 7
100 // 8 9 A B C D E F
101 "\x04\x11\x00\xfc\x00\xe9\x04\x12\x00\xe4\x01\x6f\x04\x13\x04\x14" // 8
102 "\x04\x01\x04\x16\x04\x17\x04\x18\x04\x19\x00\xc4\x00\xc4\x04\x1a"
103 "\x00\xc9\x01\x39\x01\x3a\x00\xf4\x00\xf6\x01\x3d\x01\x3e\x00\x20" // 9
104 "\x04\x1c\x00\xd6\x00\xdc\x01\x64\x01\x65\x04\x1d\x04\x1f\x01\x0a"
105 "\x00\xe1\x00\xed\x00\xf3\x00\xfa\x04\x20\x04\x22\x01\x7d\x01\x7e" // A
106 "\x04\x23\x04\x24\x04\x43\x04\x44\x01\x0c\x00\xa7\x04\x3b\x04\x3c"
107 "\x04\x47\x04\x26\x04\x27\x25\x02\x25\x24\x00\xc1\x04\x28\x01\x1a" // B
108 "\x04\x29\x04\x2a\x04\x2b\x04\x2c\x04\x2d\x04\x2e\x04\x2f\x25\x10"
109 "\x25\x14\x25\x34\x25\x2c\x25\x1c\x25\x00\x25\x3c\x04\x31\x04\x32" // C
110 "\x04\x33\x04\x51\x04\x36\x04\x37\x04\x38\x04\x39\x04\x3a\x04\x1b"
111 "\x04\x3d\x04\x3f\x01\x0e\x04\x40\x01\x0f\x01\x47\x00\xcd\x04\x42" // D
112 "\x01\x1b\x25\x18\x25\x0c\x25\x88\x25\x84\x04\x46\x01\x6e\x25\x80"
113 "\x00\xd3\x00\xdf\x00\xd4\x04\x48\x04\x49\x01\x48\x01\x60\x01\x61" // E
114 "\x01\x54\x00\xda\x01\x55\x04\x4a\x00\xfd\x00\xdd\x04\x4b\x04\x4c"
115 "\x04\x4d\x02\xdd\x04\x4e\x02\xc7\x04\x4f\x00\xa7\x04\x34\x00\xe0" // F
116 "\x00\xb4\x00\xb0\x00\xc0\x02\xc6\x01\x58\x01\x59\x00\x20\x00\x20";
117
118 #define Start_(_nam) \
119 if (mxHandler.is()) \
120 { \
121 mxHandler->startElement(_nam, xAttrList); \
122 if (mpAttrList) \
123 mpAttrList->Clear(); \
124 }
125
126 #define End_(_nam) \
127 if (mxHandler.is()) \
128 { \
129 mxHandler->endElement(_nam); \
130 }
131
132 static inistruct ini;
133
T602ImportFilter(const css::uno::Reference<css::uno::XComponentContext> & r)134 T602ImportFilter::T602ImportFilter(const css::uno::Reference<css::uno::XComponentContext > &r )
135 : mxContext(r)
136 , node(tnode::START)
137 {
138 }
139
T602ImportFilter(css::uno::Reference<css::io::XInputStream> const & xInputStream)140 T602ImportFilter::T602ImportFilter(css::uno::Reference<css::io::XInputStream> const & xInputStream)
141 : mxInputStream(xInputStream)
142 , node(tnode::START)
143 {
144 }
145
146
~T602ImportFilter()147 T602ImportFilter::~T602ImportFilter()
148 {
149 }
150
151 // XExtendedTypeDetection
detect(Sequence<PropertyValue> & Descriptor)152 OUString T602ImportFilter::detect( Sequence<PropertyValue>& Descriptor)
153 {
154 sal_Int32 nLength = Descriptor.getLength();
155 const PropertyValue * pValue = Descriptor.getConstArray();
156 for ( sal_Int32 i = 0 ; i < nLength; i++)
157 {
158 if ( pValue[i].Name == "InputStream" )
159 pValue[i].Value >>= mxInputStream;
160 }
161
162 if (!mxInputStream.is())
163 return OUString();
164
165 css::uno::Sequence< sal_Int8 > aData;
166 const size_t numBytes = 4;
167 size_t numBytesRead = mxInputStream->readSomeBytes (aData, numBytes);
168
169 if ((numBytesRead != numBytes) || (aData[0] != '@') ||
170 (aData[1] != 'C') || (aData[2] != 'T') || (aData[3] != ' '))
171 return OUString();
172
173 return "writer_T602_Document";
174 }
175
176 // XFilter
filter(const Sequence<css::beans::PropertyValue> & aDescriptor)177 sal_Bool SAL_CALL T602ImportFilter::filter( const Sequence< css::beans::PropertyValue >& aDescriptor )
178 {
179 return importImpl ( aDescriptor );
180 }
181
182 // XImporter
setTargetDocument(const Reference<css::lang::XComponent> & xDoc)183 void SAL_CALL T602ImportFilter::setTargetDocument( const Reference< css::lang::XComponent >& xDoc )
184 {
185 mxDoc = xDoc;
186 }
187
188 // XInitialization
initialize(const Sequence<Any> &)189 void SAL_CALL T602ImportFilter::initialize( const Sequence< Any >& /*aArguments*/ )
190 {
191 }
192
193 // Other functions
194
inschr(unsigned char ch)195 void T602ImportFilter::inschr(unsigned char ch)
196 {
197 Reference < XAttributeList > xAttrList ( mpAttrList );
198
199 if(!ini.showcomm&&pst.comment) return;
200
201 if(ch==' ') {
202 setfnt(chngul,true);
203 pst.wasspace++;
204 return;
205 }
206
207 if(pst.wasspace > 0) {
208 if(ini.reformatpars) {
209 if(!pst.wasfdash)
210 inschrdef(' ');
211 pst.wasfdash = false;
212 } else {
213 char s[20];
214 sprintf(s,"%i",pst.wasspace);
215 if (mpAttrList)
216 mpAttrList->AddAttribute("text:c",OUString::createFromAscii(s));
217 Start_("text:s");
218 End_("text:s");
219 }
220 }
221
222 pst.wasspace = 0;
223 setfnt(chngul,true);
224 inschrdef(ch);
225 }
226
importImpl(const Sequence<css::beans::PropertyValue> & aDescriptor)227 bool T602ImportFilter::importImpl( const Sequence< css::beans::PropertyValue >& aDescriptor )
228 {
229 Reset602();
230
231 sal_Int32 nLength = aDescriptor.getLength();
232 const PropertyValue * pValue = aDescriptor.getConstArray();
233 for ( sal_Int32 i = 0 ; i < nLength; i++)
234 {
235 if ( pValue[i].Name == "InputStream" )
236 pValue[i].Value >>= mxInputStream;
237 }
238
239 if ( !mxInputStream.is() )
240 {
241 OSL_ASSERT( false );
242 return false;
243 }
244
245 // An XML import service: what we push sax messages to...
246 mxHandler.set( mxContext->getServiceManager()->createInstanceWithContext( "com.sun.star.comp.Writer.XMLImporter", mxContext ), UNO_QUERY );
247
248 // The XImporter sets up an empty target document for XDocumentHandler to write to...
249 Reference < XImporter > xImporter(mxHandler, UNO_QUERY);
250 xImporter->setTargetDocument(mxDoc);
251
252 char fs[32], fs2[32];
253 sprintf(fs, "%ipt", inistruct::fontsize);
254 sprintf(fs2,"%ipt", 2*inistruct::fontsize);
255
256 mpAttrList = new SvXMLAttributeList;
257
258 Reference < XAttributeList > xAttrList ( mpAttrList );
259
260 mxHandler->startDocument();
261
262 mpAttrList->AddAttribute("xmlns:office", "http://openoffice.org/2000/office");
263 mpAttrList->AddAttribute("xmlns:style", "http://openoffice.org/2000/style");
264 mpAttrList->AddAttribute("xmlns:text", "http://openoffice.org/2000/text");
265 mpAttrList->AddAttribute("xmlns:table", "http://openoffice.org/2000/table");
266 mpAttrList->AddAttribute("xmlns:draw", "http://openoffice.org/2000/draw");
267 mpAttrList->AddAttribute("xmlns:fo", "http://www.w3.org/1999/XSL/Format");
268 mpAttrList->AddAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
269 mpAttrList->AddAttribute("xmlns:number", "http://openoffice.org/2000/datastyle");
270 mpAttrList->AddAttribute("xmlns:svg", "http://www.w3.org/2000/svg");
271 mpAttrList->AddAttribute("xmlns:chart", "http://openoffice.org/2000/chart");
272 mpAttrList->AddAttribute("xmlns:dr3d", "http://openoffice.org/2000/dr3d");
273 mpAttrList->AddAttribute("xmlns:math", "http://www.w3.org/1998/Math/MathML");
274 mpAttrList->AddAttribute("xmlns:form", "http://openoffice.org/2000/form");
275 mpAttrList->AddAttribute("xmlns:script", "http://openoffice.org/2000/script");
276 mpAttrList->AddAttribute("office:class", "text");
277 mpAttrList->AddAttribute("office:version", "1.0");
278 Start_("office:document-content");
279
280 Start_("office:font-decls");
281 mpAttrList->AddAttribute("style:name","Courier New");
282 mpAttrList->AddAttribute("fo:font-family","Courier New");
283 mpAttrList->AddAttribute("style:font-pitch","fixed");
284 Start_("style:font-decl");
285 End_("style:font-decl");
286 End_("office:font-decls");
287
288 Start_("office:automatic-styles");
289
290 // Standardni text
291 mpAttrList->AddAttribute("style:name","P1");
292 mpAttrList->AddAttribute("style:family","paragraph");
293 mpAttrList->AddAttribute("style:parent-style-name","Standard");
294 Start_("style:style");
295 mpAttrList->AddAttribute("style:font-name","Courier New");
296 mpAttrList->AddAttribute("fo:font-size",OUString::createFromAscii(fs));
297 Start_("style:properties");
298 End_("style:properties");
299 End_("style:style");
300
301 // Standardni text - konec stranky
302 mpAttrList->AddAttribute("style:name","P2");
303 mpAttrList->AddAttribute("style:family","paragraph");
304 mpAttrList->AddAttribute("style:parent-style-name","Standard");
305 Start_("style:style");
306 mpAttrList->AddAttribute("style:font-name","Courier New");
307 mpAttrList->AddAttribute("fo:font-size",OUString::createFromAscii(fs));
308 mpAttrList->AddAttribute("fo:break-before","page");
309 Start_("style:properties");
310 End_("style:properties");
311 End_("style:style");
312
313 // T1 Normalni text
314 mpAttrList->AddAttribute("style:name","T1");
315 mpAttrList->AddAttribute("style:family","text");
316 Start_("style:style");
317 Start_("style:properties");
318 End_("style:properties");
319 End_("style:style");
320
321 // T2 Tucny text
322 mpAttrList->AddAttribute("style:name","T2");
323 mpAttrList->AddAttribute("style:family","text");
324 Start_("style:style");
325 mpAttrList->AddAttribute("fo:font-weight","bold");
326 Start_("style:properties");
327 End_("style:properties");
328 End_("style:style");
329
330 // T3 Kurziva
331 mpAttrList->AddAttribute("style:name","T3");
332 mpAttrList->AddAttribute("style:family","text");
333 Start_("style:style");
334 mpAttrList->AddAttribute("fo:font-style","italic");
335 Start_("style:properties");
336 End_("style:properties");
337 End_("style:style");
338
339 // T4 Siroky text
340 mpAttrList->AddAttribute("style:name","T4");
341 mpAttrList->AddAttribute("style:family","text");
342 Start_("style:style");
343 mpAttrList->AddAttribute("fo:font-weight","bold");
344 mpAttrList->AddAttribute("style:text-scale","200%");
345 Start_("style:properties");
346 End_("style:properties");
347 End_("style:style");
348
349 // T5 Vysoky text
350 mpAttrList->AddAttribute("style:name","T5");
351 mpAttrList->AddAttribute("style:family","text");
352 Start_("style:style");
353 mpAttrList->AddAttribute("fo:font-size",OUString::createFromAscii(fs2));
354 mpAttrList->AddAttribute("fo:font-weight","bold");
355 mpAttrList->AddAttribute("style:text-scale","50%");
356 Start_("style:properties");
357 End_("style:properties");
358 End_("style:style");
359
360 // T6 Velky text
361 mpAttrList->AddAttribute("style:name","T6");
362 mpAttrList->AddAttribute("style:family","text");
363 Start_("style:style");
364 mpAttrList->AddAttribute("fo:font-size",OUString::createFromAscii(fs2));
365 mpAttrList->AddAttribute("fo:font-weight","bold");
366 Start_("style:properties");
367 End_("style:properties");
368 End_("style:style");
369
370 // T7 Podtrzeny text
371 mpAttrList->AddAttribute("style:name","T7");
372 mpAttrList->AddAttribute("style:family","text");
373 Start_("style:style");
374 mpAttrList->AddAttribute("style:text-underline","single");
375 Start_("style:properties");
376 End_("style:properties");
377 End_("style:style");
378
379 // T8 Podtrzena tucny text
380 mpAttrList->AddAttribute("style:name","T8");
381 mpAttrList->AddAttribute("style:family","text");
382 Start_("style:style");
383 mpAttrList->AddAttribute("fo:font-weight","bold");
384 mpAttrList->AddAttribute("style:text-underline","single");
385 Start_("style:properties");
386 End_("style:properties");
387 End_("style:style");
388
389 // T9 Podtrzena kurziva
390 mpAttrList->AddAttribute("style:name","T9");
391 mpAttrList->AddAttribute("style:family","text");
392 Start_("style:style");
393 mpAttrList->AddAttribute("fo:font-style","italic");
394 mpAttrList->AddAttribute("style:text-underline","single");
395 Start_("style:properties");
396 End_("style:properties");
397 End_("style:style");
398
399 // T10 Horni index
400 mpAttrList->AddAttribute("style:name","T10");
401 mpAttrList->AddAttribute("style:family","text");
402 Start_("style:style");
403 mpAttrList->AddAttribute("style:text-position","27% 100%");
404 Start_("style:properties");
405 End_("style:properties");
406 End_("style:style");
407
408 // T11 Dolni index
409 mpAttrList->AddAttribute("style:name","T11");
410 mpAttrList->AddAttribute("style:family","text");
411 Start_("style:style");
412 mpAttrList->AddAttribute("style:text-position","-27% 100%");
413 Start_("style:properties");
414 End_("style:properties");
415 End_("style:style");
416
417 End_("office:automatic-styles");
418
419 Start_("office:styles");
420 End_("office:styles");
421
422 Start_("office:body");
423
424 Read602();
425
426 End_("office:body");
427 End_("office:document-content");
428
429 mxHandler->endDocument();
430
431 return true;
432 }
433
test()434 void T602ImportFilter::test()
435 {
436 Reset602();
437 Read602();
438 }
439
Reset602()440 void T602ImportFilter::Reset602()
441 {
442 node = tnode::START;
443
444 format602.mt = 0;
445 format602.mb = 0;
446 format602.tb = 0;
447 format602.ct = 0;
448 format602.pn = 1;
449 format602.lh = 1;
450 format602.lm = 6;
451 format602.rm = 60;
452 format602.pl = 60;
453
454 ini.showcomm = false;
455 ini.forcecode = false;
456 ini.xcode = KAM;
457 ini.ruscode = false;
458 ini.reformatpars= false;
459
460 fst.nowfnt = fst.oldfnt = standard;
461 fst.uline = fst.olduline = false;
462
463 pst.pars = 0;
464 pst.comment = false;
465 pst.wasspace = 0;
466 pst.ccafterln = false;
467 pst.willbeeop = false;
468 pst.waspar = false;
469 pst.wasfdash = false;
470 }
471
inschrdef(unsigned char ch)472 void T602ImportFilter::inschrdef(unsigned char ch)
473 {
474 sal_Unicode xch;
475
476 if(ch > 127) {
477
478 switch(ini.xcode) {
479 case L2 : break;
480 case KOI: ch = koi2lat[ch-128]; break;
481 case KAM: ch = kam2lat[ch-128]; break;
482 default : ch = kam2lat[ch-128];
483 }
484
485 if(ini.ruscode)
486 xch = (rus2UNC[(ch-128)*2] << 8) + rus2UNC[(ch-128)*2+1];
487 else
488 xch = (lat2UNC[(ch-128)*2] << 8) + lat2UNC[(ch-128)*2+1];
489 } else
490 xch = ch;
491
492 pst.waspar = false;
493 if (mxHandler.is())
494 mxHandler->characters(OUString(xch));
495 }
496
wrtfnt()497 void T602ImportFilter::wrtfnt()
498 {
499 Reference < XAttributeList > xAttrList ( mpAttrList );
500 const char *style = "P1";
501
502 switch(fst.nowfnt) {
503 case standard : style = fst.uline ? "T7" : "T1"; break;
504 case fat : style = fst.uline ? "T8" : "T2"; break;
505 case cursive : style = fst.uline ? "T9" : "T3"; break;
506 case bold : style = "T4"; break;
507 case tall : style = "T5"; break;
508 case big : style = "T6"; break;
509 case lindex : style = "T11";break;
510 case hindex : style = "T10";break;
511 default : style = "T1"; break;
512 }
513
514 End_("text:span");
515 if (mpAttrList)
516 mpAttrList->AddAttribute(
517 "text:style-name", OUString::createFromAscii(style));
518 Start_("text:span");
519 }
520
setfnt(fonts fnt,bool mustwrite)521 void T602ImportFilter::setfnt(fonts fnt,bool mustwrite)
522 {
523 if (fnt == fst.oldfnt && fnt == fst.nowfnt && !mustwrite)
524 fst.nowfnt = standard;
525 else if (fnt != chngul)
526 fst.nowfnt = fnt;
527
528 if (mustwrite && (fst.oldfnt != fst.nowfnt || fst.olduline != fst.uline))
529 {
530 wrtfnt();
531 fst.oldfnt = fst.nowfnt;
532 fst.olduline = fst.uline;
533 }
534 }
535
Readchar602()536 unsigned char T602ImportFilter::Readchar602()
537 {
538 static Sequence< sal_Int8 > aData;
539
540 return (mxInputStream->readBytes(aData, 1) > 0) ?
541 reinterpret_cast<unsigned char const *>(aData.getConstArray())[0] : 0;
542 }
543
par602(bool endofpage)544 void T602ImportFilter::par602(bool endofpage)
545 {
546 sal_Int16 endp;
547 Reference < XAttributeList > xAttrList ( mpAttrList );
548
549 if(!endofpage || !pst.waspar) {
550 if(ini.showcomm||!pst.comment) {
551 if(pst.waspar||ini.reformatpars) {
552 End_("text:span");
553 End_("text:p");
554 if (mpAttrList)
555 mpAttrList->AddAttribute("text:style-name", "P1");
556 Start_("text:p");
557 Start_("text:span");
558 wrtfnt();
559 } else {
560 Start_("text:line-break");
561 End_("text:line-break");
562 }
563 }
564
565 pst.waspar = true;
566 }
567
568 if(pst.comment)
569 return;
570
571 switch(format602.lh) {
572 case 3: pst.pars += 4; break;
573 case 4: pst.pars += 3; break;
574 case 6: pst.pars += 2; break;
575 default: pst.pars +=2; break;
576 }
577 endp = format602.pl-format602.mt-format602.mb;
578 if(!(((pst.pars+1)/2) >= endp || endofpage)) return;
579
580 pst.pars = 0;
581 if(!ini.reformatpars) {
582 End_("text:span");
583 End_("text:p");
584 if (mpAttrList)
585 mpAttrList->AddAttribute("text:style-name", "P2");
586 Start_("text:p");
587 Start_("text:span");
588 wrtfnt();
589 }
590 }
591
readnum(unsigned char * ch,bool show)592 sal_Int16 T602ImportFilter::readnum(unsigned char *ch, bool show)
593 {
594 unsigned char buff[21];
595 sal_Int16 i=0;
596
597 while((i<20) && *ch && (*ch!='\n') && (*ch!=','))
598 {
599 *ch = Readchar602();
600 if(show) inschr(*ch);
601 buff[i++] = *ch;
602 }
603 buff[i]='\0';
604
605 // mba: cast from unsigned char via int to sal_Int16 seems to be safe
606 return static_cast<sal_Int16>(atoi(reinterpret_cast<char const *>(buff)));
607 }
608
Setformat602(const char * cmd)609 unsigned char T602ImportFilter::Setformat602(const char *cmd)
610 {
611 unsigned char ch;
612
613 ch = Readchar602();
614
615 if (cmd[0]=='M' && cmd[1]=='T') format602.mt = readnum(&ch,false);
616 else if (cmd[0]=='M' && cmd[1]=='B') format602.mb = readnum(&ch,false);
617 // else if (cmd[0]=='T' && cmd[1]=='B') {}
618 // else if (cmd[0]=='H' && cmd[1]=='E') {}
619 // else if (cmd[0]=='F' && cmd[1]=='O') {}
620 else if (cmd[0]=='C' && cmd[1]=='T') {
621 format602.ct = readnum(&ch,false);
622 if (!ini.forcecode)
623 switch(format602.ct) {
624 case 0: ini.xcode = KAM; break;
625 case 1: ini.xcode = L2; break;
626 case 2: ini.xcode = KOI; break;
627 default: ini.xcode = KAM; break;
628 }
629 }
630 else if (cmd[0]=='P' && cmd[1]=='N') format602.pn = readnum(&ch,false);
631 else if (cmd[0]=='L' && cmd[1]=='H') format602.lh = readnum(&ch,false);
632 // else if(cmd[0]=='S' && cmd[1]=='T') {} //styl
633 else if (cmd[0]=='L' && cmd[1]=='M') format602.lm = readnum(&ch,false);
634 else if (cmd[0]=='R' && cmd[1]=='M') format602.rm = readnum(&ch,false);
635 else if (cmd[0]=='P' && cmd[1]=='L') format602.pl = readnum(&ch,false);
636 else if (cmd[0]=='P' && cmd[1]=='A') { if(pst.pars) par602(true); }
637 else if (cmd[0]=='C' && cmd[1]=='P') {
638 sal_Int16 i = readnum(&ch,false);
639 if ((i+pst.pars/2) > (format602.pl-format602.mt-format602.mb))
640 if(pst.pars) par602(true);
641 }
642 while (ch && (ch != '\n')) ch = Readchar602();
643 return ch;
644 }
645
PointCmd602(unsigned char * ch)646 tnode T602ImportFilter::PointCmd602(unsigned char *ch)
647 {
648 char pcmd[2];
649
650 // warning: uChar -> char
651 pcmd[0] = static_cast<char>(rtl::toAsciiUpperCase(*ch)); inschr(*ch);
652 *ch = Readchar602();
653 if (!*ch) return tnode::EEND;
654 if (*ch=='\n') return tnode::EOL;
655 if (!rtl::isAsciiAlpha(*ch)) return (*ch<32) ? tnode::SETCH : tnode::WRITE;
656
657 // warning: uChar -> char
658 pcmd[1] = static_cast<char>(rtl::toAsciiUpperCase(*ch)); inschr(*ch);
659
660 if (pcmd[0]=='P' && pcmd[1]=='A') { if (pst.pars) pst.willbeeop = true; }
661 else if (pcmd[0]=='C' && pcmd[1]=='P') { if (pst.pars) pst.willbeeop = true; }
662 else if (pcmd[0]=='P' && pcmd[1]=='I') {
663 while (*ch && (*ch != '\n') && (*ch != ','))
664 { *ch = Readchar602(); inschr(*ch); }
665 if (!*ch) return tnode::EEND;
666 if (*ch=='\n') return tnode::EOL;
667 if (*ch==',') { *ch = Readchar602(); inschr(*ch); }
668 pst.pars += (readnum(ch,true)*2);
669 if (!*ch) return tnode::EEND;
670 if (*ch=='\n') return tnode::EOL;
671 }
672 // else if(pcmd[0]=='K'&&pcmd[1]=='P') {}
673 // else if(pcmd[0]=='H'&&pcmd[1]=='E') {}
674 // else if(pcmd[0]=='F'&&pcmd[1]=='O') {}
675
676 return tnode::READCH;
677 }
678
679
Read602()680 void T602ImportFilter::Read602()
681 {
682 unsigned char ch=0;
683 char cmd602[3] = {0};
684
685 Reference < XAttributeList > xAttrList ( mpAttrList );
686
687 if (node==tnode::QUIT) return;
688
689 if (mpAttrList)
690 mpAttrList->AddAttribute("text:style-name", "P1");
691 Start_("text:p");
692 if (mpAttrList)
693 mpAttrList->AddAttribute("text:style-name", "T1");
694 Start_("text:span");
695
696 if (node==tnode::START) { node = tnode::EOL; }
697
698 while (node != tnode::EEND) {
699 switch (node) {
700 case tnode::READCH:
701 ch = Readchar602();
702 if (ch == 0) node = tnode::EEND;
703 else if (ch == '\n') {
704 if(!pst.willbeeop) par602(false);
705 node = tnode::EOL;
706 } else if (ch < 32) node = tnode::SETCH;
707 else node = tnode::WRITE;
708 break;
709 case tnode::EOL:
710 ch = Readchar602();
711 pst.comment = false;
712 if (pst.willbeeop) par602(true);
713 pst.willbeeop = false;
714 if(ch == 0) node = tnode::EEND;
715 else if (ch == '@') node = tnode::EXPCMD;
716 else if (ch == '\n') { par602(false); node = tnode::EOL; }
717 else if (ch < 32) {pst.ccafterln = true; node = tnode::SETCH; break;}
718 else node = tnode::WRITE;
719 if (ch == '.') { pst.comment = true; node = tnode::POCMD; }
720 pst.ccafterln = false;
721 break;
722
723 case tnode::POCMD: inschr('.');
724 ch = Readchar602();
725 if(ch == 0) node = tnode::EEND;
726 else if(rtl::isAsciiAlpha(ch)) node = PointCmd602(&ch);
727 else if(ch <32) node=tnode::SETCH;
728 else node = tnode::WRITE;
729 break;
730
731 case tnode::EXPCMD: ch = Readchar602();
732 if(ch == 0) {inschr('@'); node = tnode::EEND; }
733 else if(rtl::isAsciiUpperCase(ch)) {
734 cmd602[0] = ch;
735 ch = Readchar602();
736 cmd602[1] = ch;
737 cmd602[2] = '\0';
738 if(rtl::isAsciiUpperCase(ch))
739 node = tnode::SETCMD; //nedodelano
740 else {
741 inschr('@');
742 if (mxHandler.is())
743 mxHandler->characters(OUString::createFromAscii(cmd602));
744 node = tnode::READCH;
745 }
746 } else {
747 inschr('@');
748 if(ch<32) node = tnode::SETCH;
749 else node = tnode::WRITE;}
750 break;
751
752 case tnode::SETCMD:
753 ch = Setformat602(cmd602);
754 if(ch == 0) node = tnode::EEND;
755 else if(ch == '\n') node = tnode::EOL;
756 else node = tnode::READCH;
757 break;
758
759 case tnode::SETCH :
760 // warning: potentially uninitialized
761 switch(ch) {
762 case '\t' : Start_("text:tab-stop");
763 End_("text:tab-stop");
764 break;
765 case 0x03 : break; //condensed
766 case 0x01 : break; //elite
767 case 0x11 : break; //uzv1
768 case 0x12 : break; //uzv2
769 case 0x15 : break; //uzv3
770 case 0x17 : break; //uzv4
771 case 0x18 : break; //uzv5
772 case 0x19 : break; //uzv6
773 case 0x13 : fst.uline = !fst.uline;break;
774 case 0x02 : setfnt(fat,false); break;
775 case 0x04 : setfnt(cursive,false); break;
776 case 0x0f : setfnt(bold,false); break;
777 case 0x10 : setfnt(tall,false); break;
778 case 0x1d : setfnt(big,false); break;
779 case 0x14 : setfnt(hindex,false); break;
780 case 0x16 : setfnt(lindex,false); break;
781 default : break;
782 }
783 if(pst.ccafterln) node = tnode::EOL;
784 else node = tnode::READCH;
785 break;
786
787 case tnode::WRITE :
788 switch(ch) {
789 case 0x8d:
790 ch = Readchar602();
791 if( ch == 0x0a) {
792 if(ini.reformatpars) inschr(' ');
793 else par602(false); //formatovaci radek
794 node = tnode::EOL;
795 } else {
796 inschr(0x8d);//inschr(' ');
797 if(ch == 0) node = tnode::EEND;
798 else if(ch < 32) node = tnode::SETCH;
799 else node = tnode::WRITE;
800 }
801 break;
802 case 0xfe:
803 if (ini.showcomm||!pst.comment) inschr(' ');
804 node = tnode::READCH;
805 break;
806 case 0xad:
807 ch = Readchar602();
808 if( ch==0x8d ) {
809 if(ini.showcomm||!pst.comment) { //formatovaci pomlcka
810 if(!ini.reformatpars)
811 inschr('-');
812 else {
813 pst.wasspace--;
814 pst.wasfdash = true;
815 }
816 }
817 node=tnode::WRITE;
818 } else {
819 inschr(0xad);
820 if(ch == 0) node = tnode::EEND;
821 else if(ch == '\n') {
822 if(!pst.willbeeop) par602(false);
823 node = tnode::EOL; }
824 else if(ch < 32) node = tnode::SETCH;
825 else node = tnode::WRITE;
826 }
827 break;
828 default:
829 inschr(ch);
830 node = tnode::READCH;
831 break;
832 }
833 break;
834 default: break;
835 }
836 }
837
838 End_("text:span");
839 End_("text:p");
840 node = tnode::QUIT;
841 }
842
843 // XServiceInfo
getImplementationName()844 OUString SAL_CALL T602ImportFilter::getImplementationName( )
845 {
846 return "com.sun.star.comp.Writer.T602ImportFilter";
847 }
848
supportsService(const OUString & rServiceName)849 sal_Bool SAL_CALL T602ImportFilter::supportsService( const OUString& rServiceName )
850 {
851 return cppu::supportsService( this, rServiceName );
852 }
853
getSupportedServiceNames()854 Sequence< OUString > SAL_CALL T602ImportFilter::getSupportedServiceNames( )
855 {
856 return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExtendedTypeDetection" };
857 }
858
T602ImportFilterDialog()859 T602ImportFilterDialog::T602ImportFilterDialog()
860 : maLocale(SvtSysLocale().GetUILanguageTag())
861 , maResLocale(Translate::Create("flt"))
862 {
863 }
864
~T602ImportFilterDialog()865 T602ImportFilterDialog::~T602ImportFilterDialog()
866 {
867 }
868
869 // XLocalizable
870
setLocale(const Locale & rLocale)871 void SAL_CALL T602ImportFilterDialog::setLocale(const Locale& rLocale)
872 {
873 LanguageTag aLocale(rLocale);
874 if (maLocale != aLocale)
875 {
876 maLocale = aLocale;
877 maResLocale = Translate::Create("flt", maLocale);
878 }
879 }
880
getLocale()881 Locale SAL_CALL T602ImportFilterDialog::getLocale()
882 {
883 return maLocale.getLocale(false);
884 }
885
OptionsDlg()886 bool T602ImportFilterDialog::OptionsDlg()
887 {
888 Any any;
889 #define propInt_(_prop,_nam,_val) \
890 any <<= static_cast<sal_Int32>(_val);\
891 _prop->setPropertyValue(_nam, any);
892 #define propShort_(_prop,_nam,_val) \
893 any <<= static_cast<sal_Int16>(_val);\
894 _prop->setPropertyValue(_nam, any);
895 #define propBool_(_prop,_nam,_val) \
896 any <<= _val;\
897 _prop->setPropertyValue(_nam, any);
898 #define propString_(_prop,_nam,_val) \
899 any <<= OUString(_val);\
900 _prop->setPropertyValue(_nam, any);
901 #define propStringFromResId_(_prop,_nam,_val) \
902 any <<= getResStr(_val);\
903 _prop->setPropertyValue(_nam, any);
904 #define propGet_(_prop,_nam) \
905 _prop->getPropertyValue(_nam);
906 #define Inst_(_path)\
907 xMultiServiceFactory->createInstance(_path);
908 #define Insert_(_cont,_nam,_obj) \
909 any <<= _obj;\
910 _cont->insertByName( _nam, any );
911
912 Reference < XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext();
913 Reference < XMultiComponentFactory > rServiceManager = rComponentContext->getServiceManager();
914 Reference < XInterface > rInstance = rServiceManager->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", rComponentContext );
915
916 Reference <XMultiServiceFactory> xMultiServiceFactory (rInstance,UNO_QUERY);
917
918 Reference < XPropertySet > xPSetDialog( rInstance, UNO_QUERY );
919 propInt_(xPSetDialog,"PositionX",100);
920 propInt_(xPSetDialog,"PositionY",100);
921 propInt_(xPSetDialog,"Width",130);
922 propInt_(xPSetDialog,"Height",90);
923 propStringFromResId_(xPSetDialog,"Title", T602FILTER_STR_IMPORT_DIALOG_TITLE);
924
925 #define T602DLG_OK_BUTTON "ok_button"
926 #define T602DLG_CANCEL_BUTTON "cancel_button"
927 #define T602DLG_CODE_LB "code_lb"
928 #define T602DLG_AZBUKA_CB "azbuka_cb"
929 #define T602DLG_COMMENT_CB "comment_cb"
930 #define T602DLG_REFORMAT_CB "reformat_cb"
931 #define T602DLG_CODE_TXT "code_txt"
932
933 Reference < XInterface > TextModel = Inst_("com.sun.star.awt.UnoControlFixedTextModel");
934 Reference < XPropertySet > xPSetText( TextModel, UNO_QUERY );
935 propInt_(xPSetText,"PositionX",10);
936 propInt_(xPSetText,"PositionY",8);
937 propInt_(xPSetText,"Width",30);
938 propInt_(xPSetText,"Height",14);
939 propString_(xPSetText,"Name",T602DLG_CODE_TXT);
940 propStringFromResId_(xPSetText,"Label",T602FILTER_STR_ENCODING_LABEL);
941
942 Reference < XInterface > ListBoxModel = Inst_("com.sun.star.awt.UnoControlListBoxModel");
943 Reference < XPropertySet > xPSetCodeLB( ListBoxModel, UNO_QUERY );
944 propInt_(xPSetCodeLB,"PositionX",40);
945 propInt_(xPSetCodeLB,"PositionY",5);
946 propInt_(xPSetCodeLB,"Width",85);
947 propInt_(xPSetCodeLB,"Height",14);
948 propString_(xPSetCodeLB,"Name",T602DLG_CODE_LB);
949 propShort_(xPSetCodeLB,"TabIndex",1);
950 propBool_(xPSetCodeLB,"Dropdown",true);
951 propBool_(xPSetCodeLB,"MultiSelection",false);
952
953 Sequence< OUString > ous
954 {
955 getResStr(T602FILTER_STR_ENCODING_AUTO),
956 getResStr(T602FILTER_STR_ENCODING_CP852),
957 getResStr(T602FILTER_STR_ENCODING_CP895),
958 getResStr(T602FILTER_STR_ENCODING_KOI8CS2)
959 };
960 any <<= ous;
961 xPSetCodeLB->setPropertyValue("StringItemList", any);
962
963 Sequence < sal_Int16 > shr(1);
964 shr[0] = ini.forcecode ? static_cast<sal_Int16>(ini.xcode) + 1 : 0;
965 any <<= shr;
966 xPSetCodeLB->setPropertyValue("SelectedItems", any);
967
968 Reference < XInterface > AzbCheckBoxModel = Inst_("com.sun.star.awt.UnoControlCheckBoxModel");
969 Reference < XPropertySet > xPSetAzbukaCB( AzbCheckBoxModel, UNO_QUERY );
970 propInt_(xPSetAzbukaCB,"PositionX",10);
971 propInt_(xPSetAzbukaCB,"PositionY",25);
972 propInt_(xPSetAzbukaCB,"Width",100);
973 propInt_(xPSetAzbukaCB,"Height",14);
974 propString_(xPSetAzbukaCB,"Name",T602DLG_AZBUKA_CB);
975 propShort_(xPSetAzbukaCB,"TabIndex",2);
976 propStringFromResId_(xPSetAzbukaCB,"Label",T602FILTER_STR_CYRILLIC_MODE);
977 propShort_(xPSetAzbukaCB,"State",ini.ruscode);
978
979 Reference < XInterface > RefCheckBoxModel = Inst_("com.sun.star.awt.UnoControlCheckBoxModel");
980 Reference < XPropertySet > xPSetRefCB( RefCheckBoxModel, UNO_QUERY );
981 propInt_(xPSetRefCB,"PositionX",10);
982 propInt_(xPSetRefCB,"PositionY",40);
983 propInt_(xPSetRefCB,"Width",100);
984 propInt_(xPSetRefCB,"Height",14);
985 propString_(xPSetRefCB,"Name",T602DLG_REFORMAT_CB);
986 propShort_(xPSetRefCB,"TabIndex",3);
987 propStringFromResId_(xPSetRefCB,"Label",T602FILTER_STR_REFORMAT_TEXT);
988 propShort_(xPSetRefCB,"State",ini.reformatpars);
989
990 Reference < XInterface > CommCheckBoxModel = Inst_("com.sun.star.awt.UnoControlCheckBoxModel");
991 Reference < XPropertySet > xPSetCommCB( CommCheckBoxModel, UNO_QUERY );
992 propInt_(xPSetCommCB,"PositionX",10);
993 propInt_(xPSetCommCB,"PositionY",55);
994 propInt_(xPSetCommCB,"Width",100);
995 propInt_(xPSetCommCB,"Height",14);
996 propString_(xPSetCommCB,"Name",T602DLG_COMMENT_CB);
997 propShort_(xPSetCommCB,"TabIndex",4);
998 propStringFromResId_(xPSetCommCB,"Label",T602FILTER_STR_DOT_COMMANDS);
999 propShort_(xPSetCommCB,"State",ini.showcomm);
1000
1001 Reference < XInterface > CancelButtonModel = Inst_("com.sun.star.awt.UnoControlButtonModel");
1002 Reference < XPropertySet > xPSetCancelButton( CancelButtonModel, UNO_QUERY );
1003 propInt_(xPSetCancelButton,"PositionX",10);
1004 propInt_(xPSetCancelButton,"PositionY",70);
1005 propInt_(xPSetCancelButton,"Width",50);
1006 propInt_(xPSetCancelButton,"Height",14);
1007 propString_(xPSetCancelButton,"Name",T602DLG_CANCEL_BUTTON);
1008 propShort_(xPSetCancelButton,"TabIndex",5);
1009 propShort_(xPSetCancelButton,"PushButtonType",2);
1010 propStringFromResId_(xPSetCancelButton,"Label",T602FILTER_STR_CANCEL_BUTTON);
1011
1012 Reference < XInterface > OkButtonModel = Inst_("com.sun.star.awt.UnoControlButtonModel");
1013 Reference < XPropertySet > xPSetOkButton( OkButtonModel, UNO_QUERY );
1014 propInt_(xPSetOkButton,"PositionX",70);
1015 propInt_(xPSetOkButton,"PositionY",70);
1016 propInt_(xPSetOkButton,"Width",50);
1017 propInt_(xPSetOkButton,"Height",14);
1018 propString_(xPSetOkButton,"Name",T602DLG_OK_BUTTON);
1019 propShort_(xPSetOkButton,"TabIndex",0);
1020 propShort_(xPSetOkButton,"PushButtonType",1);
1021 propStringFromResId_(xPSetOkButton,"Label",T602FILTER_STR_OK_BUTTON);
1022 propBool_(xPSetOkButton,"DefaultButton",true);
1023
1024 Reference < XNameContainer > xNameCont (rInstance,UNO_QUERY);
1025
1026 Insert_(xNameCont, T602DLG_OK_BUTTON, OkButtonModel);
1027 Insert_(xNameCont, T602DLG_CANCEL_BUTTON, CancelButtonModel);
1028 Insert_(xNameCont, T602DLG_AZBUKA_CB, AzbCheckBoxModel);
1029 Insert_(xNameCont, T602DLG_REFORMAT_CB, RefCheckBoxModel);
1030 Insert_(xNameCont, T602DLG_COMMENT_CB, CommCheckBoxModel);
1031 Insert_(xNameCont, T602DLG_CODE_LB, ListBoxModel);
1032 Insert_(xNameCont, T602DLG_CODE_TXT, TextModel);
1033
1034 Reference< XUnoControlDialog > dialog = UnoControlDialog::create(rComponentContext);
1035
1036 Reference < XControlModel > xControlModel (rInstance,UNO_QUERY);
1037
1038 dialog->setModel( xControlModel );
1039
1040 Reference < XToolkit > xToolkit = Toolkit::create( rComponentContext );
1041
1042 dialog->setVisible( false );
1043 dialog->createPeer( xToolkit, nullptr );
1044
1045 bool ret = ( dialog->execute() != 0 );
1046 if ( ret ) {
1047
1048 sal_Int16 tt = 0;
1049
1050 any = propGet_(xPSetAzbukaCB, "State"); any >>= tt; ini.ruscode = tt;
1051 any = propGet_(xPSetRefCB, "State"); any >>= tt; ini.reformatpars = tt;
1052 any = propGet_(xPSetCommCB, "State"); any >>= tt; ini.showcomm = tt;
1053
1054 any = propGet_(xPSetCodeLB, "SelectedItems"); any >>= shr;
1055
1056 if( shr[0] > 0 ) {
1057 ini.xcode = static_cast<tcode>(shr[0]-1);
1058 ini.forcecode = true;
1059 } else {
1060 ini.forcecode = false;
1061 }
1062 }
1063
1064 Reference<XControl>(dialog)->dispose();
1065
1066 return ret;
1067 }
1068
setTitle(const OUString &)1069 void SAL_CALL T602ImportFilterDialog::setTitle( const OUString& )
1070 {
1071 }
1072
execute()1073 sal_Int16 SAL_CALL T602ImportFilterDialog::execute()
1074 {
1075 if (OptionsDlg())
1076 return css::ui::dialogs::ExecutableDialogResults::OK;
1077 else
1078 return css::ui::dialogs::ExecutableDialogResults::CANCEL;
1079 }
1080
getResStr(const char * resid)1081 OUString T602ImportFilterDialog::getResStr(const char* resid)
1082 {
1083 return Translate::get(resid, maResLocale);
1084 }
1085
getPropertyValues()1086 uno::Sequence<beans::PropertyValue> SAL_CALL T602ImportFilterDialog::getPropertyValues()
1087 {
1088 return uno::Sequence<beans::PropertyValue>();
1089 }
1090
setPropertyValues(const uno::Sequence<beans::PropertyValue> &)1091 void SAL_CALL T602ImportFilterDialog::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
1092 {
1093 }
1094
1095
1096 // XServiceInfo
getImplementationName()1097 OUString SAL_CALL T602ImportFilterDialog::getImplementationName( )
1098 {
1099 return "com.sun.star.comp.Writer.T602ImportFilterDialog";
1100 }
1101
supportsService(const OUString & rServiceName)1102 sal_Bool SAL_CALL T602ImportFilterDialog::supportsService( const OUString& rServiceName )
1103 {
1104 return cppu::supportsService( this, rServiceName );
1105 }
1106
getSupportedServiceNames()1107 Sequence< OUString > SAL_CALL T602ImportFilterDialog::getSupportedServiceNames( )
1108 {
1109 return { "com.sun.star.ui.dialogs.FilterOptionsDialog" };
1110 }
1111
1112 }
1113
1114 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
filter_T602ImportFilterDialog_get_implementation(css::uno::XComponentContext *,css::uno::Sequence<css::uno::Any> const &)1115 filter_T602ImportFilterDialog_get_implementation(
1116 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
1117 {
1118 return cppu::acquire(new T602ImportFilter::T602ImportFilterDialog());
1119 }
1120
1121 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
filter_T602ImportFilter_get_implementation(css::uno::XComponentContext * context,css::uno::Sequence<css::uno::Any> const &)1122 filter_T602ImportFilter_get_implementation(
1123 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
1124 {
1125 return cppu::acquire(new T602ImportFilter::T602ImportFilter(context));
1126 }
1127
TestImport602(SvStream & rStream)1128 extern "C" SAL_DLLPUBLIC_EXPORT bool TestImport602(SvStream &rStream)
1129 {
1130 css::uno::Reference<io::XInputStream> xStream(new utl::OSeekableInputStreamWrapper(rStream));
1131 rtl::Reference<T602ImportFilter::T602ImportFilter> aImport(
1132 new T602ImportFilter::T602ImportFilter(xStream));
1133 aImport->test();
1134 return true;
1135 }
1136
1137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1138