1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _IODETECT_HXX_
21 #define _IODETECT_HXX_
23 #include <sfx2/docfilt.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <sfx2/fcontnr.hxx>
26 #include <osl/endian.h>
27 #include <tools/string.hxx>
28 #include <swddllapi.h>
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
44 #define sSWRITER "swriter"
45 #define sSWRITERWEB "swriter/web"
49 const sal_Char
* pName
;
52 inline SwIoDetect( const sal_Char
*pN
, sal_uInt16 nL
)
53 : pName( pN
), nLen( nL
)
56 inline int IsFilter( const String
& rNm
) const
58 return pName
&& rNm
.EqualsAscii( pName
, 0, nLen
);
61 const sal_Char
* IsReader( const sal_Char
* pHeader
, sal_uLong nLen_
,
62 const String
&rFileName
, const String
& rUserData
) const;
65 enum ReaderWriterEnum
{
75 READER_WRITER_TEXT_DLG
,
80 extern SWD_DLLPUBLIC SwIoDetect aFilterDetect
[];
82 /** The following class is a wrapper for basic i/o functions of Writer 3.0.
83 Everything is static. All filter names mentioned are Writer-internal
84 names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
90 /// find for an internal format name the corresponding filter entry
91 SWD_DLLPUBLIC
static const SfxFilter
*
92 GetFilterOfFormat( const String
& rFormat
,
93 const SfxFilterContainer
* pCnt
= 0 );
95 /** Detect for the given file which filter should be used. The filter name
96 is returned. If no filter could be found, the name of the ASCII filter
98 SWD_DLLPUBLIC
static const SfxFilter
*
99 GetFileFilter( const String
& rFileName
,
100 const String
& rPrefFltName
,
101 SfxMedium
* pMedium
= 0 );
103 /** Detect whether the given file is in the given format.
104 For now, only our own filters are supported! */
105 static sal_Bool
IsFileFilter(SfxMedium
& rMedium
, const String
& rFmtName
);
107 static sal_Bool
IsValidStgFilter( SotStorage
& , const SfxFilter
& );
108 static sal_Bool
IsValidStgFilter( const com::sun::star::uno::Reference
< com::sun::star::embed::XStorage
>& rStg
, const SfxFilter
& rFilter
);
110 SWD_DLLPUBLIC
static bool
111 IsDetectableText( const sal_Char
* pBuf
, sal_uLong
&rLen
,
112 CharSet
*pCharSet
=0, bool *pSwap
=0, LineEnd
*pLineEnd
=0, bool bEncodedFilter
= false );
114 static const SfxFilter
* GetTextFilter( const sal_Char
* pBuf
, sal_uLong nLen
);
116 SWD_DLLPUBLIC
static const String
117 GetSubStorageName( const SfxFilter
& rFltr
);
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */