LCOV - code coverage report
Current view: top level - filter/source/t602 - t602filter.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 668 0.0 %
Date: 2014-04-11 Functions: 0 46 0.0 %
Legend: Lines: hit not hit

          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 ::rtl;
      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 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 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 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 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 _AddAtt(_nam, _val) \
     119             :     mpAttrList->AddAttribute(OUString::createFromAscii( _nam ),\
     120             :     OUString::createFromAscii( _val ) );
     121             : 
     122             : #define _Start(_nam) \
     123             :     mxHandler->startElement(OUString::createFromAscii(_nam), mAttrList);\
     124             :     mpAttrList->Clear();
     125             : 
     126             : #define _End(_nam) \
     127             :     mxHandler->endElement(OUString::createFromAscii(_nam));
     128             : 
     129             : #define _Chars(_ch) \
     130             :     mxHandler->characters(OUString::createFromAscii((sal_Char *) _ch) );
     131             : 
     132           0 : inistruct ini;
     133             : 
     134           0 : T602ImportFilter::T602ImportFilter(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r ) :
     135           0 :     mxMSF( r ) {}
     136             : 
     137           0 : T602ImportFilter::~T602ImportFilter()
     138             : {
     139           0 : }
     140             : 
     141             : // XExtendedTypeDetection
     142           0 : OUString T602ImportFilter::detect( Sequence<PropertyValue>& Descriptor)
     143             :     throw(RuntimeException, std::exception)
     144             : {
     145           0 :     sal_Int32 nLength = Descriptor.getLength();
     146           0 :     const PropertyValue * pValue = Descriptor.getConstArray();
     147           0 :     for ( sal_Int32 i = 0 ; i < nLength; i++)
     148             :     {
     149           0 :         if ( pValue[i].Name == "InputStream" )
     150           0 :             pValue[i].Value >>= mxInputStream;
     151             :     }
     152             : 
     153           0 :     if (!mxInputStream.is())
     154           0 :         return OUString();
     155             : 
     156           0 :     ::com::sun::star::uno::Sequence< sal_Int8 > aData;
     157           0 :     const size_t numBytes = 4;
     158           0 :     size_t numBytesRead = 0;
     159             : 
     160           0 :     numBytesRead = mxInputStream->readSomeBytes (aData, numBytes);
     161             : 
     162           0 :     if ((numBytesRead != numBytes) || (aData[0] != '@') ||
     163           0 :         (aData[1] != 'C') || (aData[2] != 'T') || (aData[3] != ' '))
     164           0 :         return OUString();
     165             : 
     166           0 :     return OUString(  "writer_T602_Document"  );
     167             : }
     168             : 
     169             : // XFilter
     170           0 : sal_Bool SAL_CALL T602ImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
     171             :     throw (RuntimeException, std::exception)
     172             : {
     173           0 :     return importImpl ( aDescriptor );
     174             : }
     175             : 
     176             : // XImporter
     177           0 : void SAL_CALL T602ImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
     178             :     throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException, std::exception)
     179             : {
     180           0 :     mxDoc = xDoc;
     181           0 : }
     182             : 
     183             : // XInitialization
     184           0 : void SAL_CALL T602ImportFilter::initialize( const Sequence< Any >& aArguments )
     185             :     throw (Exception, RuntimeException, std::exception)
     186             : {
     187           0 :     Sequence < PropertyValue > aAnySeq;
     188           0 :     sal_Int32 nLength = aArguments.getLength();
     189           0 :     if ( nLength && ( aArguments[0] >>= aAnySeq ) )
     190             :     {
     191           0 :         const PropertyValue * pValue = aAnySeq.getConstArray();
     192           0 :         nLength = aAnySeq.getLength();
     193           0 :         for ( sal_Int32 i = 0 ; i < nLength; i++)
     194             :         {
     195           0 :             if ( pValue[i].Name == "Type" )
     196             :             {
     197           0 :                 pValue[i].Value >>= msFilterName;
     198           0 :                 break;
     199             :             }
     200             :         }
     201           0 :     }
     202           0 : }
     203             : 
     204             : // Other functions
     205             : 
     206           0 : void T602ImportFilter::inschr(unsigned char ch)
     207             : {
     208           0 :     Reference < XAttributeList > mAttrList ( mpAttrList );
     209             : 
     210           0 :     if(!ini.showcomm&&pst.comment) return;
     211             : 
     212           0 :     if(ch==' ') {
     213           0 :         setfnt(chngul,true);
     214           0 :         pst.wasspace++;
     215           0 :         return;
     216             :     }
     217             : 
     218           0 :     if(pst.wasspace > 0) {
     219           0 :         if(ini.reformatpars) {
     220           0 :             if(!pst.wasfdash)
     221           0 :                 inschrdef(' ');
     222           0 :             pst.wasfdash = false;
     223             :         } else {
     224             :             char s[20];
     225           0 :             sprintf(s,"%i",pst.wasspace);
     226           0 :             _AddAtt("text:c",s);
     227           0 :             _Start("text:s");
     228           0 :             _End("text:s");
     229             :         }
     230             :     }
     231             : 
     232           0 :     pst.wasspace = 0;
     233           0 :     setfnt(chngul,true);
     234           0 :     inschrdef(ch);
     235             : }
     236             : 
     237           0 : sal_Bool SAL_CALL T602ImportFilter::importImpl( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
     238             :     throw (RuntimeException)
     239             : {
     240           0 :     Reset602();
     241             : 
     242           0 :     sal_Int32 nLength = aDescriptor.getLength();
     243           0 :     const PropertyValue * pValue = aDescriptor.getConstArray();
     244           0 :     for ( sal_Int32 i = 0 ; i < nLength; i++)
     245             :     {
     246           0 :         if ( pValue[i].Name == "InputStream" )
     247           0 :             pValue[i].Value >>= mxInputStream;
     248             :     }
     249             : 
     250           0 :     if ( !mxInputStream.is() )
     251             :     {
     252             :         OSL_ASSERT( false );
     253           0 :         return sal_False;
     254             :     }
     255             : 
     256             :     // An XML import service: what we push sax messages to..
     257           0 :     OUString sXMLImportService (  "com.sun.star.comp.Writer.XMLImporter"  );
     258             : 
     259           0 :     mxHandler = Reference< XDocumentHandler >( mxMSF->createInstance( sXMLImportService ), UNO_QUERY );
     260             : 
     261             :     // The XImporter sets up an empty target document for XDocumentHandler to write to..
     262           0 :     Reference < XImporter > xImporter(mxHandler, UNO_QUERY);
     263           0 :     xImporter->setTargetDocument(mxDoc);
     264             : 
     265             :     char fs[32], fs2[32];
     266           0 :     sprintf(fs, "%ipt", ini.fontsize);
     267           0 :     sprintf(fs2,"%ipt", 2*ini.fontsize);
     268             : 
     269           0 :     mpAttrList = new SvXMLAttributeList;
     270             : 
     271           0 :     Reference < XAttributeList > mAttrList ( mpAttrList );
     272             : 
     273           0 :     mxHandler->startDocument();
     274             : 
     275           0 :     _AddAtt("xmlns:office", "http://openoffice.org/2000/office");
     276           0 :     _AddAtt("xmlns:style", "http://openoffice.org/2000/style");
     277           0 :     _AddAtt("xmlns:text", "http://openoffice.org/2000/text");
     278           0 :     _AddAtt("xmlns:table", "http://openoffice.org/2000/table");
     279           0 :     _AddAtt("xmlns:draw", "http://openoffice.org/2000/draw");
     280           0 :     _AddAtt("xmlns:fo", "http://www.w3.org/1999/XSL/Format");
     281           0 :     _AddAtt("xmlns:xlink", "http://www.w3.org/1999/xlink");
     282           0 :     _AddAtt("xmlns:number", "http://openoffice.org/2000/datastyle");
     283           0 :     _AddAtt("xmlns:svg", "http://www.w3.org/2000/svg");
     284           0 :     _AddAtt("xmlns:chart", "http://openoffice.org/2000/chart");
     285           0 :     _AddAtt("xmlns:dr3d", "http://openoffice.org/2000/dr3d");
     286           0 :     _AddAtt("xmlns:math", "http://www.w3.org/1998/Math/MathML");
     287           0 :     _AddAtt("xmlns:form", "http://openoffice.org/2000/form");
     288           0 :     _AddAtt("xmlns:script", "http://openoffice.org/2000/script");
     289           0 :     _AddAtt("office:class", "text");
     290           0 :     _AddAtt("office:version", "1.0");
     291           0 :     _Start("office:document-content");
     292             : 
     293           0 :     _Start("office:font-decls");
     294           0 :     _AddAtt("style:name","Courier New");
     295           0 :     _AddAtt("fo:font-family","Courier New");
     296           0 :     _AddAtt("style:font-pitch","fixed");
     297           0 :     _Start("style:font-decl");
     298           0 :     _End("style:font-decl");
     299           0 :     _End("office:font-decls");
     300             : 
     301           0 :     _Start("office:automatic-styles");
     302             : 
     303             :     // Standardni text
     304           0 :     _AddAtt("style:name","P1");
     305           0 :     _AddAtt("style:family","paragraph");
     306           0 :     _AddAtt("style:parent-style-name","Standard");
     307           0 :     _Start("style:style");
     308           0 :     _AddAtt("style:font-name","Courier New");
     309           0 :     _AddAtt("fo:font-size",fs);
     310           0 :     _Start("style:properties");
     311           0 :     _End("style:properties");
     312           0 :     _End("style:style");
     313             : 
     314             :     // Standardni text - konec stranky
     315           0 :     _AddAtt("style:name","P2");
     316           0 :     _AddAtt("style:family","paragraph");
     317           0 :     _AddAtt("style:parent-style-name","Standard");
     318           0 :     _Start("style:style");
     319           0 :     _AddAtt("style:font-name","Courier New");
     320           0 :     _AddAtt("fo:font-size",fs);
     321           0 :     _AddAtt("fo:break-before","page");
     322           0 :     _Start("style:properties");
     323           0 :     _End("style:properties");
     324           0 :     _End("style:style");
     325             : 
     326             :     // T1 Normalni text
     327           0 :     _AddAtt("style:name","T1");
     328           0 :     _AddAtt("style:family","text");
     329           0 :     _Start("style:style");
     330           0 :     _Start("style:properties");
     331           0 :     _End("style:properties");
     332           0 :     _End("style:style");
     333             : 
     334             :     // T2 Tucny text
     335           0 :     _AddAtt("style:name","T2");
     336           0 :     _AddAtt("style:family","text");
     337           0 :     _Start("style:style");
     338           0 :     _AddAtt("fo:font-weight","bold");
     339           0 :     _Start("style:properties");
     340           0 :     _End("style:properties");
     341           0 :     _End("style:style");
     342             : 
     343             :     // T3 Kurziva
     344           0 :     _AddAtt("style:name","T3");
     345           0 :     _AddAtt("style:family","text");
     346           0 :     _Start("style:style");
     347           0 :     _AddAtt("fo:font-style","italic");
     348           0 :     _Start("style:properties");
     349           0 :     _End("style:properties");
     350           0 :     _End("style:style");
     351             : 
     352             :     // T4 Siroky text
     353           0 :     _AddAtt("style:name","T4");
     354           0 :     _AddAtt("style:family","text");
     355           0 :     _Start("style:style");
     356           0 :     _AddAtt("fo:font-weight","bold");
     357           0 :     _AddAtt("style:text-scale","200%");
     358           0 :     _Start("style:properties");
     359           0 :     _End("style:properties");
     360           0 :     _End("style:style");
     361             : 
     362             :     // T5 Vysoky text
     363           0 :     _AddAtt("style:name","T5");
     364           0 :     _AddAtt("style:family","text");
     365           0 :     _Start("style:style");
     366           0 :     _AddAtt("fo:font-size",fs2);
     367           0 :     _AddAtt("fo:font-weight","bold");
     368           0 :     _AddAtt("style:text-scale","50%");
     369           0 :     _Start("style:properties");
     370           0 :     _End("style:properties");
     371           0 :     _End("style:style");
     372             : 
     373             :     // T6 Velky text
     374           0 :     _AddAtt("style:name","T6");
     375           0 :     _AddAtt("style:family","text");
     376           0 :     _Start("style:style");
     377           0 :     _AddAtt("fo:font-size",fs2);
     378           0 :     _AddAtt("fo:font-weight","bold");
     379           0 :     _Start("style:properties");
     380           0 :     _End("style:properties");
     381           0 :     _End("style:style");
     382             : 
     383             :     // T7 Podtrzeny text
     384           0 :     _AddAtt("style:name","T7");
     385           0 :     _AddAtt("style:family","text");
     386           0 :     _Start("style:style");
     387           0 :     _AddAtt("style:text-underline","single");
     388           0 :     _Start("style:properties");
     389           0 :     _End("style:properties");
     390           0 :     _End("style:style");
     391             : 
     392             :     // T8 Podtrzena tucny text
     393           0 :     _AddAtt("style:name","T8");
     394           0 :     _AddAtt("style:family","text");
     395           0 :     _Start("style:style");
     396           0 :     _AddAtt("fo:font-weight","bold");
     397           0 :     _AddAtt("style:text-underline","single");
     398           0 :     _Start("style:properties");
     399           0 :     _End("style:properties");
     400           0 :     _End("style:style");
     401             : 
     402             :     // T9 Podtrzena kurziva
     403           0 :     _AddAtt("style:name","T9");
     404           0 :     _AddAtt("style:family","text");
     405           0 :     _Start("style:style");
     406           0 :     _AddAtt("fo:font-style","italic");
     407           0 :     _AddAtt("style:text-underline","single");
     408           0 :     _Start("style:properties");
     409           0 :     _End("style:properties");
     410           0 :     _End("style:style");
     411             : 
     412             :     // T10 Horni index
     413           0 :     _AddAtt("style:name","T10");
     414           0 :     _AddAtt("style:family","text");
     415           0 :     _Start("style:style");
     416           0 :     _AddAtt("style:text-position","27% 100%");
     417           0 :     _Start("style:properties");
     418           0 :     _End("style:properties");
     419           0 :     _End("style:style");
     420             : 
     421             :     // T11 Dolni index
     422           0 :     _AddAtt("style:name","T11");
     423           0 :     _AddAtt("style:family","text");
     424           0 :     _Start("style:style");
     425           0 :     _AddAtt("style:text-position","-27% 100%");
     426           0 :     _Start("style:properties");
     427           0 :     _End("style:properties");
     428           0 :     _End("style:style");
     429             : 
     430           0 :     _End("office:automatic-styles");
     431             : 
     432           0 :     _Start("office:styles");
     433           0 :     _End("office:styles");
     434             : 
     435           0 :     _Start("office:body");
     436             : 
     437           0 :     Read602();
     438             : 
     439           0 :     _End("office:body");
     440           0 :     _End("office:document-content");
     441             : 
     442           0 :     mxHandler->endDocument();
     443             : 
     444           0 :     return sal_True;
     445             : }
     446             : 
     447           0 : void T602ImportFilter::Reset602()
     448             : {
     449           0 :     node = START;
     450             : 
     451           0 :     format602.mt = 0;
     452           0 :     format602.mb = 0;
     453           0 :     format602.tb = 0;
     454           0 :     format602.ct = 0;
     455           0 :     format602.pn = 1;
     456           0 :     format602.lh = 1;
     457           0 :     format602.lm = 6;
     458           0 :     format602.rm = 60;
     459           0 :     format602.pl = 60;
     460             : 
     461           0 :     ini.showcomm    = false;
     462           0 :     ini.forcecode   = false;
     463           0 :     ini.xcode    = KAM;
     464           0 :     ini.ruscode    = false;
     465           0 :     ini.reformatpars= false;
     466           0 :     ini.fontsize    = 10;
     467             : 
     468           0 :     fst.nowfnt    = fst.oldfnt    = standard;
     469           0 :     fst.uline    = fst.olduline    = false;
     470             : 
     471           0 :     pst.pars    = 0;
     472           0 :     pst.comment    = false;
     473           0 :     pst.wasspace    = 0;
     474           0 :     pst.ccafterln    = false;
     475           0 :     pst.willbeeop    = false;
     476           0 :     pst.waspar    = false;
     477           0 :     pst.wasfdash    = false;
     478           0 : }
     479             : 
     480           0 : void T602ImportFilter::inschrdef(unsigned char ch)
     481             : {
     482             :     static sal_Unicode xch[2];
     483             : 
     484           0 :     xch[1] = 0;
     485             : 
     486           0 :     if(ch > 127) {
     487             : 
     488           0 :         switch(ini.xcode) {
     489           0 :             case L2 : break;
     490           0 :             case KOI: ch = koi2lat[ch-128]; break;
     491           0 :             case KAM: ch = kam2lat[ch-128]; break;
     492           0 :             default : ch = kam2lat[ch-128];
     493             :         }
     494             : 
     495           0 :         if(ini.ruscode)
     496           0 :             xch[0] = (rus2UNC[(ch-128)*2] << 8) + rus2UNC[(ch-128)*2+1];
     497             :         else
     498           0 :             xch[0] = (lat2UNC[(ch-128)*2] << 8) + lat2UNC[(ch-128)*2+1];
     499             :     } else
     500           0 :         xch[0] = ch;
     501             : 
     502           0 :     pst.waspar = false;
     503           0 :     mxHandler->characters(OUString(xch));
     504           0 : }
     505             : 
     506           0 : void T602ImportFilter::wrtfnt()
     507             : {
     508           0 :     Reference < XAttributeList > mAttrList ( mpAttrList );
     509           0 :     const sal_Char *style = "P1";
     510             : 
     511           0 :     switch(fst.nowfnt) {
     512           0 :         case standard : style = (char*)(fst.uline ? "T7" : "T1"); break;
     513           0 :         case fat      : style = (char*)(fst.uline ? "T8" : "T2"); break;
     514           0 :         case cursive  : style = (char*)(fst.uline ? "T9" : "T3"); break;
     515           0 :         case bold     : style = "T4"; break;
     516           0 :         case tall     : style = "T5"; break;
     517           0 :         case big      : style = "T6"; break;
     518           0 :         case lindex   : style = "T11";break;
     519           0 :         case hindex   : style = "T10";break;
     520           0 :         default       : style = "T1"; break;
     521             :     }
     522             : 
     523           0 :     _End("text:span");
     524           0 :     _AddAtt("text:style-name", style);
     525           0 :     _Start("text:span");
     526           0 : }
     527             : 
     528           0 : void T602ImportFilter::setfnt(fonts fnt,bool mustwrite)
     529             : {
     530           0 :     if (fnt == fst.oldfnt && fnt == fst.nowfnt && !mustwrite)
     531           0 :         fst.nowfnt = standard;
     532           0 :     else if (fnt != chngul)
     533           0 :         fst.nowfnt = fnt;
     534             : 
     535           0 :     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           0 : }
     542             : 
     543           0 : unsigned char T602ImportFilter::Readchar602()
     544             : {
     545           0 :     static Sequence< sal_Int8 > aData;
     546             : 
     547           0 :     return (mxInputStream->readBytes(aData, 1) > 0) ?
     548           0 :         ((unsigned char *) aData.getConstArray())[0] : 0;
     549             : }
     550             : 
     551           0 : void T602ImportFilter::par602(bool endofpage)
     552             : {
     553             :     sal_Int16 endp;
     554           0 :     Reference < XAttributeList > mAttrList ( mpAttrList );
     555             : 
     556           0 :     if(!endofpage || !pst.waspar) {
     557           0 :         if(ini.showcomm||!pst.comment) {
     558           0 :             if(pst.waspar||ini.reformatpars) {
     559           0 :                 _End("text:span");
     560           0 :                 _End("text:p");
     561           0 :                 _AddAtt("text:style-name", "P1");
     562           0 :                 _Start("text:p");
     563           0 :                 _Start("text:span");
     564           0 :                 wrtfnt();
     565             :             } else {
     566           0 :                 _Start("text:line-break");
     567           0 :                 _End("text:line-break");
     568             :             }
     569             :         }
     570             : 
     571           0 :         pst.waspar = true;
     572             :     }
     573             : 
     574           0 :     if(!pst.comment) {
     575           0 :         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           0 :             default: pst.pars +=2; break;
     580             :         }
     581           0 :         endp = format602.pl-format602.mt-format602.mb;
     582           0 :         if(((pst.pars+1)/2) >= endp || endofpage) {
     583           0 :             pst.pars = 0;
     584           0 :             if(!ini.reformatpars) {
     585           0 :                 _End("text:span");
     586           0 :                 _End("text:p");
     587           0 :                 _AddAtt("text:style-name", "P2");
     588           0 :                 _Start("text:p");
     589           0 :                 _Start("text:span");
     590           0 :                 wrtfnt();
     591             :             }
     592             :         }
     593           0 :     }
     594           0 : }
     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((char *)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           0 : void T602ImportFilter::Read602()
     686             : {
     687           0 :     unsigned char ch=0;
     688           0 :     char cmd602[3] = {0};
     689             : 
     690           0 :     Reference < XAttributeList > mAttrList ( mpAttrList );
     691             : 
     692           0 :     if (node==QUIT) return;
     693             : 
     694           0 :     _AddAtt("text:style-name", "P1");
     695           0 :     _Start("text:p");
     696           0 :     _AddAtt("text:style-name", "T1");
     697           0 :     _Start("text:span");
     698             : 
     699           0 :     if (node==START) { node = EOL; }
     700             : 
     701           0 :     while (node != EEND) {
     702           0 :         switch (node) {
     703             :         case READCH:
     704           0 :             ch = Readchar602();
     705           0 :             if (ch == 0) node = EEND;
     706           0 :             else if (ch == '\n') {
     707           0 :                 if(!pst.willbeeop) par602(false);
     708           0 :                 node = EOL;
     709           0 :             } else if (ch < 32) node = SETCH;
     710           0 :             else node = WRITE;
     711           0 :             break;
     712             :         case EOL:
     713           0 :             ch = Readchar602();
     714           0 :             pst.comment = false;
     715           0 :             if (pst.willbeeop) par602(true);
     716           0 :             pst.willbeeop = false;
     717           0 :             if(ch == 0) node = EEND;
     718           0 :             else if (ch == '@') node = EXPCMD;
     719           0 :             else if (ch == '\n') { par602(false); node = EOL; }
     720           0 :             else if (ch < 32) {pst.ccafterln = true; node = SETCH; break;}
     721           0 :             else node = WRITE;
     722           0 :             if (ch == '.') { pst.comment = true; node = POCMD; }
     723           0 :             pst.ccafterln = false;
     724           0 :             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           0 :             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           0 :             default   : break;
     779             :             }
     780           0 :             if(pst.ccafterln) node = EOL;
     781           0 :             else node = READCH;
     782           0 :             break;
     783             : 
     784             :         case WRITE :
     785           0 :             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           0 :                 ch = Readchar602();
     805           0 :                 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           0 :                     inschr(0xad);
     817           0 :                     if(ch == 0) node = EEND;
     818           0 :                     else if(ch == '\n') {
     819           0 :                         if(!pst.willbeeop) par602(false);
     820           0 :                         node = EOL; }
     821           0 :                     else if(ch < 32) node = SETCH;
     822           0 :                     else node = WRITE;
     823             :                 }
     824           0 :                 break;
     825             :             default:
     826           0 :                 inschr(ch);
     827           0 :                 node = READCH;
     828           0 :                 break;
     829             :             }
     830           0 :             break;
     831           0 :         default: break;
     832             :         }
     833             :     }
     834             : 
     835           0 :     _End("text:span");
     836           0 :     _End("text:p");
     837           0 :     node = QUIT;
     838             : }
     839             : 
     840             : // XServiceInfo
     841           0 : OUString SAL_CALL T602ImportFilter::getImplementationName(  )
     842             :     throw (RuntimeException, std::exception)
     843             : {
     844           0 :     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           0 : Sequence< OUString > SAL_CALL T602ImportFilter::getSupportedServiceNames(  )
     854             :     throw (RuntimeException, std::exception)
     855             : {
     856           0 :     return T602ImportFilter_getSupportedServiceNames();
     857             : }
     858             : 
     859           0 : OUString T602ImportFilter_getImplementationName ()
     860             :     throw (RuntimeException)
     861             : {
     862           0 :     return OUString ( "com.sun.star.comp.Writer.T602ImportFilter" );
     863             : }
     864             : 
     865           0 : Sequence< OUString > SAL_CALL T602ImportFilter_getSupportedServiceNames(  )
     866             :     throw (RuntimeException)
     867             : {
     868           0 :     Sequence < OUString > aRet(2);
     869           0 :     OUString* pArray = aRet.getArray();
     870           0 :     pArray[0] =  "com.sun.star.document.ImportFilter";
     871           0 :     pArray[1] =  "com.sun.star.document.ExtendedTypeDetection";
     872           0 :     return aRet;
     873             : }
     874             : 
     875           0 : Reference< XInterface > SAL_CALL T602ImportFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
     876             :     throw( Exception )
     877             : {
     878           0 :     return (cppu::OWeakObject*) new T602ImportFilter( rSMgr );
     879             : }
     880             : 
     881           0 : T602ImportFilterDialog::T602ImportFilterDialog(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r ) :
     882           0 :     mxMSF( r ), mpResMgr( NULL ) {}
     883             : 
     884           0 : T602ImportFilterDialog::~T602ImportFilterDialog()
     885             : {
     886           0 :     if (mpResMgr)
     887           0 :         delete mpResMgr;
     888           0 : }
     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 : sal_Bool T602ImportFilterDialog::OptionsDlg()
     906             : {
     907           0 :     Any any;
     908             : #define _propInt(_prop,_nam,_val) \
     909             :     any <<= (sal_Int32)_val;\
     910             :     _prop->setPropertyValue(OUString::createFromAscii(_nam), any);
     911             : #define _propShort(_prop,_nam,_val) \
     912             :     any <<= (sal_Int16)_val;\
     913             :     _prop->setPropertyValue(OUString::createFromAscii(_nam), any);
     914             : #define _propBool(_prop,_nam,_val) \
     915             :     any <<= (sal_Bool)_val;\
     916             :     _prop->setPropertyValue(OUString::createFromAscii(_nam), any);
     917             : #define _propString(_prop,_nam,_val) \
     918             :     any <<= OUString::createFromAscii(_val);\
     919             :     _prop->setPropertyValue(OUString::createFromAscii(_nam), any);
     920             : #define _propStringFromResId(_prop,_nam,_val) \
     921             :     any <<= getResStr(_val);\
     922             :     _prop->setPropertyValue(OUString::createFromAscii(_nam), any);
     923             : #define _propGet(_prop,_nam) \
     924             :     _prop->getPropertyValue(OUString::createFromAscii(_nam));
     925             : #define _InstCtx(_path,_ctx)\
     926             :     rServiceManager->createInstanceWithContext(\
     927             :     OUString::createFromAscii(_path),_ctx);
     928             : #define _Inst(_path)\
     929             :     xMultiServiceFactory->createInstance(OUString::createFromAscii(_path) );
     930             : #define _Insert(_cont,_nam,_obj) \
     931             :     any <<= _obj;\
     932             :     _cont->insertByName( OUString::createFromAscii(_nam), any );
     933             : 
     934           0 :     Reference < XComponentContext > rComponentContext = defaultBootstrap_InitialComponentContext();
     935           0 :     Reference < XMultiComponentFactory > rServiceManager = rComponentContext->getServiceManager();
     936           0 :     Reference < XInterface > rInstance = _InstCtx("com.sun.star.awt.UnoControlDialogModel", rComponentContext );
     937             : 
     938           0 :     Reference <XMultiServiceFactory> xMultiServiceFactory (rInstance,UNO_QUERY);
     939             : 
     940           0 :     Reference < XPropertySet > xPSetDialog( rInstance, UNO_QUERY );
     941           0 :     _propInt(xPSetDialog,"PositionX",100);
     942           0 :     _propInt(xPSetDialog,"PositionY",100);
     943           0 :     _propInt(xPSetDialog,"Width",130);
     944           0 :     _propInt(xPSetDialog,"Height",90);
     945           0 :     _propStringFromResId(xPSetDialog,"Title", T602FILTER_STR_IMPORT_DIALOG_TITLE);
     946             : 
     947             : #define T602DLG_OK_BUTTON    "ok_button"
     948             : #define T602DLG_CANCEL_BUTTON    "cancel_button"
     949             : #define T602DLG_CODE_LB        "code_lb"
     950             : #define T602DLG_AZBUKA_CB    "azbuka_cb"
     951             : #define T602DLG_COMMENT_CB    "comment_cb"
     952             : #define T602DLG_REFORMAT_CB    "reformat_cb"
     953             : #define T602DLG_CODE_TXT    "code_txt"
     954             : 
     955           0 :     Reference < XInterface > TextModel = _Inst("com.sun.star.awt.UnoControlFixedTextModel");
     956           0 :     Reference < XPropertySet > xPSetText( TextModel, UNO_QUERY );
     957           0 :     _propInt(xPSetText,"PositionX",10);
     958           0 :     _propInt(xPSetText,"PositionY",8);
     959           0 :     _propInt(xPSetText,"Width",30);
     960           0 :     _propInt(xPSetText,"Height",14);
     961           0 :     _propString(xPSetText,"Name",T602DLG_CODE_TXT);
     962           0 :     _propStringFromResId(xPSetText,"Label",T602FILTER_STR_ENCODING_LABEL);
     963             : 
     964           0 :     Reference < XInterface > ListBoxModel = _Inst("com.sun.star.awt.UnoControlListBoxModel");
     965           0 :     Reference < XPropertySet > xPSetCodeLB( ListBoxModel, UNO_QUERY );
     966           0 :     _propInt(xPSetCodeLB,"PositionX",40);
     967           0 :     _propInt(xPSetCodeLB,"PositionY",5);
     968           0 :     _propInt(xPSetCodeLB,"Width",85);
     969           0 :     _propInt(xPSetCodeLB,"Height",14);
     970           0 :     _propString(xPSetCodeLB,"Name",T602DLG_CODE_LB);
     971           0 :     _propShort(xPSetCodeLB,"TabIndex",1);
     972           0 :     _propBool(xPSetCodeLB,"Dropdown",true);
     973           0 :     _propBool(xPSetCodeLB,"MultiSelection",false);
     974             : 
     975           0 :     Sequence< OUString > ous(4);
     976           0 :     ous[0] = getResStr(T602FILTER_STR_ENCODING_AUTO);
     977           0 :     ous[1] = getResStr(T602FILTER_STR_ENCODING_CP852);
     978           0 :     ous[2] = getResStr(T602FILTER_STR_ENCODING_CP895);
     979           0 :     ous[3] = getResStr(T602FILTER_STR_ENCODING_KOI8CS2);
     980           0 :     any <<= ous;
     981           0 :     xPSetCodeLB->setPropertyValue("StringItemList", any);
     982             : 
     983           0 :     Sequence < sal_Int16 > shr(1);
     984           0 :     shr[0] = ini.forcecode ? ((sal_Int16) ini.xcode) + 1 : 0;
     985           0 :     any <<= shr;
     986           0 :     xPSetCodeLB->setPropertyValue("SelectedItems", any);
     987             : 
     988           0 :     Reference < XInterface > AzbCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel");
     989           0 :     Reference < XPropertySet > xPSetAzbukaCB( AzbCheckBoxModel, UNO_QUERY );
     990           0 :     _propInt(xPSetAzbukaCB,"PositionX",10);
     991           0 :     _propInt(xPSetAzbukaCB,"PositionY",25);
     992           0 :     _propInt(xPSetAzbukaCB,"Width",100);
     993           0 :     _propInt(xPSetAzbukaCB,"Height",14);
     994           0 :     _propString(xPSetAzbukaCB,"Name",T602DLG_AZBUKA_CB);
     995           0 :     _propShort(xPSetAzbukaCB,"TabIndex",2);
     996           0 :     _propStringFromResId(xPSetAzbukaCB,"Label",T602FILTER_STR_CYRILLIC_MODE);
     997           0 :     _propShort(xPSetAzbukaCB,"State",ini.ruscode);
     998             : 
     999           0 :     Reference < XInterface > RefCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel");
    1000           0 :     Reference < XPropertySet > xPSetRefCB( RefCheckBoxModel, UNO_QUERY );
    1001           0 :     _propInt(xPSetRefCB,"PositionX",10);
    1002           0 :     _propInt(xPSetRefCB,"PositionY",40);
    1003           0 :     _propInt(xPSetRefCB,"Width",100);
    1004           0 :     _propInt(xPSetRefCB,"Height",14);
    1005           0 :     _propString(xPSetRefCB,"Name",T602DLG_REFORMAT_CB);
    1006           0 :     _propShort(xPSetRefCB,"TabIndex",3);
    1007           0 :     _propStringFromResId(xPSetRefCB,"Label",T602FILTER_STR_REFORMAT_TEXT);
    1008           0 :     _propShort(xPSetRefCB,"State",ini.reformatpars);
    1009             : 
    1010           0 :     Reference < XInterface > CommCheckBoxModel = _Inst("com.sun.star.awt.UnoControlCheckBoxModel");
    1011           0 :     Reference < XPropertySet > xPSetCommCB( CommCheckBoxModel, UNO_QUERY );
    1012           0 :     _propInt(xPSetCommCB,"PositionX",10);
    1013           0 :     _propInt(xPSetCommCB,"PositionY",55);
    1014           0 :     _propInt(xPSetCommCB,"Width",100);
    1015           0 :     _propInt(xPSetCommCB,"Height",14);
    1016           0 :     _propString(xPSetCommCB,"Name",T602DLG_COMMENT_CB);
    1017           0 :     _propShort(xPSetCommCB,"TabIndex",4);
    1018           0 :     _propStringFromResId(xPSetCommCB,"Label",T602FILTER_STR_DOT_COMMANDS);
    1019           0 :     _propShort(xPSetCommCB,"State",ini.showcomm);
    1020             : 
    1021           0 :     Reference < XInterface > CancelButtonModel = _Inst("com.sun.star.awt.UnoControlButtonModel");
    1022           0 :     Reference < XPropertySet > xPSetCancelButton( CancelButtonModel, UNO_QUERY );
    1023           0 :     _propInt(xPSetCancelButton,"PositionX",10);
    1024           0 :     _propInt(xPSetCancelButton,"PositionY",70);
    1025           0 :     _propInt(xPSetCancelButton,"Width",50);
    1026           0 :     _propInt(xPSetCancelButton,"Height",14);
    1027           0 :     _propString(xPSetCancelButton,"Name",T602DLG_CANCEL_BUTTON);
    1028           0 :     _propShort(xPSetCancelButton,"TabIndex",5);
    1029           0 :     _propShort(xPSetCancelButton,"PushButtonType",2);
    1030           0 :     _propStringFromResId(xPSetCancelButton,"Label",T602FILTER_STR_CANCEL_BUTTON);
    1031             : 
    1032           0 :     Reference < XInterface > OkButtonModel = _Inst("com.sun.star.awt.UnoControlButtonModel");
    1033           0 :     Reference < XPropertySet > xPSetOkButton( OkButtonModel, UNO_QUERY );
    1034           0 :     _propInt(xPSetOkButton,"PositionX",70);
    1035           0 :     _propInt(xPSetOkButton,"PositionY",70);
    1036           0 :     _propInt(xPSetOkButton,"Width",50);
    1037           0 :     _propInt(xPSetOkButton,"Height",14);
    1038           0 :     _propString(xPSetOkButton,"Name",T602DLG_OK_BUTTON);
    1039           0 :     _propShort(xPSetOkButton,"TabIndex",0);
    1040           0 :     _propShort(xPSetOkButton,"PushButtonType",1);
    1041           0 :     _propStringFromResId(xPSetOkButton,"Label",T602FILTER_STR_OK_BUTTON);
    1042           0 :     _propBool(xPSetOkButton,"DefaultButton",true);
    1043             : 
    1044           0 :     Reference < XNameContainer > xNameCont (rInstance,UNO_QUERY);
    1045             : 
    1046           0 :     _Insert(xNameCont, T602DLG_OK_BUTTON, OkButtonModel);
    1047           0 :     _Insert(xNameCont, T602DLG_CANCEL_BUTTON, CancelButtonModel);
    1048           0 :     _Insert(xNameCont, T602DLG_AZBUKA_CB, AzbCheckBoxModel);
    1049           0 :     _Insert(xNameCont, T602DLG_REFORMAT_CB, RefCheckBoxModel);
    1050           0 :     _Insert(xNameCont, T602DLG_COMMENT_CB, CommCheckBoxModel);
    1051           0 :     _Insert(xNameCont, T602DLG_CODE_LB, ListBoxModel);
    1052           0 :     _Insert(xNameCont, T602DLG_CODE_TXT, TextModel);
    1053             : 
    1054           0 :     Reference< XUnoControlDialog > dialog = UnoControlDialog::create(rComponentContext);
    1055             : 
    1056           0 :     Reference < XControlModel > xControlModel (rInstance,UNO_QUERY);
    1057             : 
    1058           0 :     dialog->setModel( xControlModel );
    1059             : 
    1060           0 :     Reference < XToolkit > xToolkit = Toolkit::create( rComponentContext );
    1061             : 
    1062           0 :     dialog->setVisible( false );
    1063           0 :     dialog->createPeer( xToolkit, NULL );
    1064             : 
    1065           0 :     sal_Bool ret = ( dialog->execute() != 0 );
    1066           0 :     if ( ret ) {
    1067             : 
    1068           0 :         sal_Int16 tt = 0;
    1069             : 
    1070           0 :         any = _propGet(xPSetAzbukaCB, "State"); any >>= tt; ini.ruscode      = tt;
    1071           0 :         any = _propGet(xPSetRefCB,    "State"); any >>= tt; ini.reformatpars = tt;
    1072           0 :         any = _propGet(xPSetCommCB,   "State"); any >>= tt; ini.showcomm     = tt;
    1073             : 
    1074           0 :         any = _propGet(xPSetCodeLB,   "SelectedItems"); any >>= shr;
    1075             : 
    1076           0 :         if( shr[0] > 0 ) {
    1077           0 :             ini.xcode = (tcode)(shr[0]-1);
    1078           0 :             ini.forcecode = true;
    1079             :         } else {
    1080           0 :             ini.forcecode = false;
    1081             :         }
    1082             :     }
    1083             : 
    1084           0 :     Reference<XControl>(dialog)->dispose();
    1085             : 
    1086           0 :     return ret;
    1087             : }
    1088             : 
    1089           0 : void T602ImportFilterDialog::initLocale()
    1090             : {
    1091           0 :     mpResMgr = ResMgr::CreateResMgr( "t602filter", LanguageTag( meLocale) );
    1092           0 : }
    1093             : 
    1094           0 : ResMgr* T602ImportFilterDialog::getResMgr()
    1095             : {
    1096           0 :     if( !mpResMgr )
    1097           0 :         initLocale();
    1098           0 :     return mpResMgr;
    1099             : }
    1100             : 
    1101           0 : void SAL_CALL T602ImportFilterDialog::setTitle( const OUString& )
    1102             :             throw (::com::sun::star::uno::RuntimeException, std::exception)
    1103             : {
    1104           0 : }
    1105             : 
    1106           0 : sal_Int16 SAL_CALL T602ImportFilterDialog::execute()
    1107             :             throw (::com::sun::star::uno::RuntimeException, std::exception)
    1108             : {
    1109           0 :     if (OptionsDlg())
    1110           0 :         return com::sun::star::ui::dialogs::ExecutableDialogResults::OK;
    1111             :     else
    1112           0 :         return com::sun::star::ui::dialogs::ExecutableDialogResults::CANCEL;
    1113             : }
    1114             : 
    1115           0 : OUString T602ImportFilterDialog::getResStr( sal_Int16 resid )
    1116             : {
    1117           0 :     OUString sStr( ResId( resid, *getResMgr() ) );
    1118           0 :     return sStr;
    1119             : }
    1120             : 
    1121           0 : uno::Sequence<beans::PropertyValue> SAL_CALL T602ImportFilterDialog::getPropertyValues() throw(uno::RuntimeException, std::exception)
    1122             : {
    1123           0 :     return uno::Sequence<beans::PropertyValue>();
    1124             : }
    1125             : 
    1126           0 : void SAL_CALL T602ImportFilterDialog::setPropertyValues( const uno::Sequence<beans::PropertyValue>& )
    1127             :                     throw(beans::UnknownPropertyException, beans::PropertyVetoException,
    1128             :                             lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
    1129             : {
    1130           0 : }
    1131             : 
    1132             : 
    1133             : // XServiceInfo
    1134           0 : OUString SAL_CALL T602ImportFilterDialog::getImplementationName(  )
    1135             :     throw (RuntimeException, std::exception)
    1136             : {
    1137           0 :     return T602ImportFilterDialog_getImplementationName();
    1138             : }
    1139             : 
    1140           0 : sal_Bool SAL_CALL T602ImportFilterDialog::supportsService( const OUString& rServiceName )
    1141             :     throw (RuntimeException, std::exception)
    1142             : {
    1143           0 :     return cppu::supportsService( this, rServiceName );
    1144             : }
    1145             : 
    1146           0 : Sequence< OUString > SAL_CALL T602ImportFilterDialog::getSupportedServiceNames(  )
    1147             :     throw (RuntimeException, std::exception)
    1148             : {
    1149           0 :     return T602ImportFilterDialog_getSupportedServiceNames();
    1150             : }
    1151             : 
    1152           0 : OUString T602ImportFilterDialog_getImplementationName ()
    1153             :     throw (RuntimeException)
    1154             : {
    1155           0 :     return OUString ( "com.sun.star.comp.Writer.T602ImportFilterDialog" );
    1156             : }
    1157             : 
    1158           0 : Sequence< OUString > SAL_CALL T602ImportFilterDialog_getSupportedServiceNames(  )
    1159             :     throw (RuntimeException)
    1160             : {
    1161           0 :     Sequence < OUString > aRet(1);
    1162           0 :     OUString* pArray = aRet.getArray();
    1163           0 :     pArray[0] =  "com.sun.star.ui.dialogs.FilterOptionsDialog";
    1164           0 :     return aRet;
    1165             : }
    1166             : 
    1167           0 : Reference< XInterface > SAL_CALL T602ImportFilterDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
    1168             :     throw( Exception )
    1169             : {
    1170           0 :     return (cppu::OWeakObject*) new T602ImportFilterDialog( rSMgr );
    1171             : }
    1172             : 
    1173           0 : }
    1174             : 
    1175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10