LCOV - code coverage report
Current view: top level - sw/inc - iodetect.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 5 6 83.3 %
Date: 2014-04-11 Functions: 2 3 66.7 %
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_SW_INC_IODETECT_HXX
      21             : #define INCLUDED_SW_INC_IODETECT_HXX
      22             : 
      23             : #include <osl/endian.h>
      24             : #include <rtl/ustring.hxx>
      25             : #include <sfx2/docfilt.hxx>
      26             : #include <sfx2/docfile.hxx>
      27             : #include <sfx2/fcontnr.hxx>
      28             : #include <swddllapi.h>
      29             : 
      30             : #define FILTER_RTF      "RTF"       ///< RTF filter
      31             : #define sRtfWH          "WH_RTF"
      32             : #define FILTER_TEXT     "TEXT"      ///< text filter with default codeset
      33             : #define FILTER_BAS      "BAS"       ///< StarBasic (identical to ANSI)
      34             : #define FILTER_WW8      "CWW8"      ///< WinWord 97 filter
      35             : #define FILTER_TEXT_DLG "TEXT_DLG"  ///< text filter with encoding dialog
      36             : #define FILTER_XML      "CXML"      ///< XML filter
      37             : #define FILTER_XMLV     "CXMLV"     ///< XML filter
      38             : #define FILTER_XMLVW    "CXMLVWEB"  ///< XML filter
      39             : #define sHTML           "HTML"
      40             : #define sWW1            "WW1"
      41             : #define sWW5            "WW6"
      42             : #define sWW6            "CWW6"
      43             : 
      44             : #define sSWRITER        "swriter"
      45             : #define sSWRITERWEB     "swriter/web"
      46             : 
      47           0 : struct SwIoDetect
      48             : {
      49             :     const OUString sName;
      50             : 
      51         418 :     SwIoDetect(const OUString &rN)
      52         418 :         : sName(rN)
      53             :     {
      54         418 :     }
      55             : 
      56       69712 :     bool IsFilter( const OUString& rNm ) const
      57             :     {
      58       69712 :         return rNm.startsWith(sName);
      59             :     }
      60             : 
      61             :     OUString IsReader(const sal_Char* pHeader, sal_uLong nLen_) const;
      62             : };
      63             : 
      64             : enum ReaderWriterEnum {
      65             :     READER_WRITER_RTF,
      66             :     READER_WRITER_BAS,
      67             :     READER_WRITER_WW6,
      68             :     READER_WRITER_WW8,
      69             :     READER_WRITER_RTF_WH,
      70             :     READER_WRITER_HTML,
      71             :     READER_WRITER_WW1,
      72             :     READER_WRITER_WW5,
      73             :     READER_WRITER_XML,
      74             :     READER_WRITER_TEXT_DLG,
      75             :     READER_WRITER_TEXT,
      76             :     MAXFILTER
      77             : };
      78             : 
      79             : extern SWD_DLLPUBLIC SwIoDetect aFilterDetect[];
      80             : 
      81             : /** The following class is a wrapper for basic i/o functions of Writer 3.0.
      82             :  Everything is static. All filter names mentioned are Writer-internal
      83             :  names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
      84             :  or ASCII.*/
      85             : 
      86             : class SwIoSystem
      87             : {
      88             : public:
      89             :     /// find for an internal format name the corresponding filter entry
      90             :     SWD_DLLPUBLIC static const SfxFilter*
      91             :         GetFilterOfFormat( const OUString& rFormat,
      92             :             const SfxFilterContainer* pCnt = 0 );
      93             : 
      94             :     /** Detect for the given file which filter should be used. The filter name
      95             :      is returned. If no filter could be found, the name of the ASCII filter
      96             :      is returned! */
      97             :     SWD_DLLPUBLIC static const SfxFilter*
      98             :         GetFileFilter( const OUString& rFileName,
      99             :             const OUString& rPrefFltName,
     100             :             SfxMedium* pMedium = 0 );
     101             : 
     102             :     /** Detect whether the given file is in the given format.
     103             :      For now, only our own filters are supported! */
     104             :     static sal_Bool IsFileFilter(SfxMedium& rMedium, const OUString& rFmtName);
     105             : 
     106             :     static sal_Bool IsValidStgFilter( SotStorage& , const SfxFilter& );
     107             :     static sal_Bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
     108             : 
     109             :     SWD_DLLPUBLIC static bool
     110             :         IsDetectableText( const sal_Char* pBuf, sal_uLong &rLen,
     111             :             rtl_TextEncoding *pCharSet=0, bool *pSwap=0, LineEnd *pLineEnd=0, bool bEncodedFilter = false );
     112             : 
     113             :     static const SfxFilter* GetTextFilter( const sal_Char* pBuf, sal_uLong nLen );
     114             : 
     115             :     SWD_DLLPUBLIC static const OUString
     116             :         GetSubStorageName( const SfxFilter& rFltr );
     117             : };
     118             : 
     119             : #endif
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10