LCOV - code coverage report
Current view: top level - filter/source/t602 - t602filter.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 14 85.7 %
Date: 2015-06-13 12:38:46 Functions: 4 5 80.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             : #ifndef INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
      21             : #define INCLUDED_FILTER_SOURCE_T602_T602FILTER_HXX
      22             : 
      23             : #include <com/sun/star/document/XFilter.hpp>
      24             : #include <com/sun/star/document/XImporter.hpp>
      25             : #include <com/sun/star/document/XExtendedFilterDetection.hpp>
      26             : #include <com/sun/star/io/XInputStream.hpp>
      27             : #include <com/sun/star/lang/XInitialization.hpp>
      28             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <com/sun/star/lang/XLocalizable.hpp>
      31             : #include <com/sun/star/beans/XPropertyAccess.hpp>
      32             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      33             : #include <cppuhelper/implbase5.hxx>
      34             : #include <cppuhelper/implbase4.hxx>
      35             : #include <xmloff/attrlist.hxx>
      36             : #include <tools/resmgr.hxx>
      37             : 
      38             : namespace T602ImportFilter {
      39             : 
      40             : typedef enum {L2,KAM,KOI} tcode;
      41             : 
      42             : typedef enum {
      43             :         standard,   // default
      44             :         fat,        // bold
      45             :         cursive,    // italic
      46             :         bold,       // wide
      47             :         tall,       // high
      48             :         big,        // big
      49             :         lindex,     // lower index
      50             :         hindex,     // upper index
      51             :         err,        // not set yet
      52             :         chngul      // change underline
      53             : } fonts;
      54             : 
      55             : typedef enum {START,READCH,EOL,POCMD,EXPCMD,SETCMD,SETCH,WRITE,EEND,QUIT} tnode;
      56             : 
      57             : OUString getImplementationName()
      58             :     throw ( ::com::sun::star::uno::RuntimeException );
      59             : 
      60             : ::com::sun::star::uno::Sequence < OUString > getSupportedServiceNames()
      61             :     throw ( ::com::sun::star::uno::RuntimeException );
      62             : 
      63             : 
      64             : ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > SAL_CALL
      65             :     CreateInstance( const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > &r)
      66             :     throw ( ::com::sun::star::uno::Exception );
      67             : 
      68             : 
      69             : 
      70             : // class T602ImportFilter
      71             : 
      72             : 
      73             : struct inistruct
      74             : {
      75             :         bool showcomm;      // true   show comment lines
      76             :         bool forcecode;     // false  the user has changed the encoding with something else than @CT
      77             :         tcode xcode;        // KAM    encoding set - forced
      78             :         bool ruscode;       // false  Russian tables turned on
      79             :         bool reformatpars;  // false  Reformat paragraphs (whitespaces and line breaks)
      80             :         sal_Int16 fontsize;       // font size in points
      81             : 
      82          96 :         inistruct()
      83             :             : showcomm( true )
      84             :             , forcecode( false )
      85             :             , xcode ( KAM )
      86             :             , ruscode ( false )
      87             :             , reformatpars ( false )
      88          96 :             , fontsize (10)
      89             :         {
      90          96 :         };
      91             : };
      92             : 
      93             : class T602ImportFilterDialog : public cppu::WeakImplHelper4 <
      94             :         com::sun::star::ui::dialogs::XExecutableDialog,
      95             :         com::sun::star::lang::XLocalizable,
      96             :         com::sun::star::lang::XServiceInfo,
      97             :         com::sun::star::beans::XPropertyAccess
      98             : >
      99             : {
     100             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
     101             :     com::sun::star::lang::Locale meLocale;
     102             :     ResMgr *mpResMgr;
     103             :     bool OptionsDlg();
     104             :     ResMgr* getResMgr();
     105             :     OUString getResStr( sal_Int16 resid );
     106             :     void initLocale();
     107             : 
     108             :     virtual ~T602ImportFilterDialog();
     109             : 
     110             :     // XExecutableDialog
     111             :        virtual void SAL_CALL setTitle( const OUString& aTitle )
     112             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     113             :        virtual sal_Int16 SAL_CALL execute()
     114             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     115             : 
     116             :     // XLocalizable
     117             :         virtual void SAL_CALL setLocale( const com::sun::star::lang::Locale& eLocale )
     118             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     119             :         virtual com::sun::star::lang::Locale SAL_CALL getLocale()
     120             :             throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     121             : 
     122             :     // XServiceInfo
     123             :         virtual OUString SAL_CALL getImplementationName(  )
     124             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     125             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     126             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     127             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
     128             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             : 
     130             :     // XPropertyAccess
     131             :         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >
     132             :                             SAL_CALL getPropertyValues() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             :         virtual void SAL_CALL   setPropertyValues( const ::com::sun::star::uno::Sequence<
     134             :                                     ::com::sun::star::beans::PropertyValue >& aProps )
     135             :                                 throw (::com::sun::star::beans::UnknownPropertyException,
     136             :                                         ::com::sun::star::beans::PropertyVetoException,
     137             :                                         ::com::sun::star::lang::IllegalArgumentException,
     138             :                                         ::com::sun::star::lang::WrappedTargetException,
     139             :                                         ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     140             : 
     141             : public:
     142             :     T602ImportFilterDialog(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r );
     143             : 
     144             : };
     145             : 
     146             : 
     147             : class T602ImportFilter : public cppu::WeakImplHelper5 <
     148             :     com::sun::star::document::XFilter,
     149             :     com::sun::star::document::XImporter,
     150             :     com::sun::star::document::XExtendedFilterDetection,
     151             :     com::sun::star::lang::XInitialization,
     152             :     com::sun::star::lang::XServiceInfo
     153             : >
     154             : {
     155             : private:
     156             : //    ::com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
     157             :     ::com::sun::star::uno::Reference<com::sun::star::xml::sax::XDocumentHandler> mxHandler;
     158             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF;
     159             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
     160             :     ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > mxInputStream;
     161             :     OUString msFilterName;
     162             : 
     163             :     SvXMLAttributeList *mpAttrList;
     164             : 
     165             :     tnode node;         // START
     166             : 
     167             :     struct format602struct
     168             :     {
     169             :         sal_Int16   mt;       // row for header
     170             :         sal_Int16   mb;       // row for footer
     171             :         sal_Int16   tb;       // tabs
     172             :         sal_Int16   ct;       // encoding (0-kamenik, 1-latin2, 2-koi8)
     173             :         sal_Int16   pn;       // from page number
     174             :         sal_Int16   lh;       // linespacing 3-2x, 4-1.5x, 6-1x
     175             :         sal_Int16   lm;       // left border
     176             :         sal_Int16   rm;       // right border
     177             :         sal_Int16   pl;       // page length
     178          92 :         format602struct()
     179             :             : mt(0)
     180             :             , mb(0)
     181             :             , tb(0)
     182             :             , ct(0)
     183             :             , pn(0)
     184             :             , lh(0)
     185             :             , lm(0)
     186             :             , rm(0)
     187          92 :             , pl(0)
     188             :         {
     189          92 :         }
     190             :     };
     191             : 
     192             :     format602struct format602;
     193             : 
     194             :     // Initialisation constants - they are not changed during the conversion
     195             : 
     196             :     inistruct ini;
     197             : 
     198             :     // Font state - changes based on font
     199             : 
     200             :     struct fststruct
     201             :     {
     202             :         fonts nowfnt;     // current font
     203             :         fonts oldfnt;     // previous font
     204             :         bool uline;       // underlined
     205             :         bool olduline;    // previous value of uline (font change)
     206          92 :         fststruct()
     207             :             : nowfnt(standard)
     208             :             , oldfnt(standard)
     209             :             , uline(false)
     210          92 :             , olduline(false)
     211             :         {
     212          92 :         }
     213             :     };
     214             : 
     215             :     fststruct fst;
     216             : 
     217             :     // Paragraph state
     218             : 
     219             :     struct pststruct
     220             :     {
     221             :         sal_Int16 pars;            //       the number of line endings times linespacing on the current page
     222             :         bool comment;        //       in comments
     223             :         sal_Int16 wasspace;        // 0     there was a space - for reformatting
     224             :         bool wasfdash;       // 0     formatting dash
     225             :         bool ccafterln;      // false
     226             :         bool willbeeop;      // false
     227             :         bool waspar;         // false
     228          92 :         pststruct()
     229             :             : pars(0)
     230             :             , comment(false)
     231             :             , wasspace(0)
     232             :             , wasfdash(false)
     233             :             , ccafterln(false)
     234             :             , willbeeop(false)
     235          92 :             , waspar(false)
     236             :         {
     237          92 :         }
     238             :     };
     239             : 
     240             :     pststruct pst;
     241             : 
     242             :     void Reset602();
     243             :     unsigned char Readchar602();
     244             :     void Read602();
     245             :     void par602(bool endofpage);
     246             :     void inschr(unsigned char ch);
     247             :     void inschrdef(unsigned char ch);
     248             :     unsigned char Setformat602(char *cmd);
     249             :     sal_Int16 readnum(unsigned char *ch, bool show);
     250             :     tnode PointCmd602(unsigned char *ch);
     251             :     void setfnt(fonts fnt,bool mustwrite);
     252             :     void wrtfnt();
     253             : 
     254             :     bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
     255             :         throw (::com::sun::star::uno::RuntimeException);
     256             : 
     257             :     public:
     258             :         T602ImportFilter(const ::com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory > &r );
     259             :         virtual ~T602ImportFilter();
     260             : 
     261             :     // XFilter
     262             :         virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
     263             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     264           0 :         virtual void SAL_CALL cancel(  )
     265           0 :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE {};
     266             : 
     267             :     // XImporter
     268             :         virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
     269             :             throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     270             : 
     271             :     // XExtendedTypeDetection
     272             :         virtual OUString SAL_CALL detect(
     273             :             com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
     274             :             throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
     275             : 
     276             :     // XInitialization
     277             :         virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     278             :             throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     279             : 
     280             :     // XServiceInfo
     281             :         virtual OUString SAL_CALL getImplementationName(  )
     282             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     283             :         virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
     284             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     285             :         virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  )
     286             :             throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     287             : };
     288             : 
     289             : OUString T602ImportFilter_getImplementationName()
     290             :     throw ( ::com::sun::star::uno::RuntimeException );
     291             : 
     292             : bool SAL_CALL T602ImportFilter_supportsService( const OUString& ServiceName )
     293             :     throw ( ::com::sun::star::uno::RuntimeException );
     294             : 
     295             : ::com::sun::star::uno::Sequence< OUString > SAL_CALL T602ImportFilter_getSupportedServiceNames(  )
     296             :     throw ( ::com::sun::star::uno::RuntimeException );
     297             : 
     298             : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     299             : SAL_CALL T602ImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
     300             :     throw ( ::com::sun::star::uno::Exception );
     301             : 
     302             : OUString T602ImportFilterDialog_getImplementationName()
     303             :     throw ( ::com::sun::star::uno::RuntimeException );
     304             : 
     305             : bool SAL_CALL T602ImportFilterDialog_supportsService( const OUString& ServiceName )
     306             :     throw ( ::com::sun::star::uno::RuntimeException );
     307             : 
     308             : ::com::sun::star::uno::Sequence< OUString > SAL_CALL T602ImportFilterDialog_getSupportedServiceNames(  )
     309             :     throw ( ::com::sun::star::uno::RuntimeException );
     310             : 
     311             : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     312             : SAL_CALL T602ImportFilterDialog_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
     313             :     throw ( ::com::sun::star::uno::Exception );
     314             : 
     315             : }
     316             : 
     317             : #endif
     318             : 
     319             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11