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