merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / iodetect.hxx
blob784a583ed99eb668cbd847830d9316860e41e8d1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iodetect.cxx,v $
10 * $Revision: 1.31 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _IODETECT_HXX_
32 #define _IODETECT_HXX_
34 #include <sfx2/docfilt.hxx>
35 #include <sfx2/docfile.hxx>
36 #include <sfx2/fcontnr.hxx>
37 #include <osl/endian.h>
38 #include <errhdl.hxx> // for ASSERT
39 #include <tools/string.hxx>
40 #include <swdllapi.h>
42 #define FILTER_RTF "RTF" // RTF-Filter
43 #define sRtfWH "WH_RTF"
44 #define FILTER_TEXT "TEXT" // Text-Filter mit Default-CodeSet
45 #define FILTER_BAS "BAS" // StarBasic (identisch mit ANSI)
46 #define FILTER_WW8 "CWW8" // WinWord 97-Filter
47 #define FILTER_TEXT_DLG "TEXT_DLG" // text filter with encoding dialog
48 #define FILTER_XML "CXML" // XML filter
49 #define FILTER_XMLV "CXMLV" // XML filter
50 #define FILTER_XMLVW "CXMLVWEB" // XML filter
51 #define sHTML "HTML"
52 #define sWW1 "WW1"
53 #define sWW5 "WW6"
54 #define sWW6 "CWW6"
56 #define sSWRITER "swriter"
57 #define sSWRITERWEB "swriter/web"
59 struct SwIoDetect
61 const sal_Char* pName;
62 USHORT nLen;
64 inline SwIoDetect( const sal_Char *pN, USHORT nL )
65 : pName( pN ), nLen( nL )
68 inline int IsFilter( const String& rNm ) const
70 return pName && rNm.EqualsAscii( pName, 0, nLen );
73 const sal_Char* IsReader( const sal_Char* pHeader, ULONG nLen_,
74 const String &rFileName, const String& rUserData ) const;
77 enum ReaderWriterEnum {
78 READER_WRITER_RTF,
79 READER_WRITER_BAS,
80 READER_WRITER_WW6,
81 READER_WRITER_WW8,
82 READER_WRITER_RTF_WH,
83 READER_WRITER_HTML,
84 READER_WRITER_WW1,
85 READER_WRITER_WW5,
86 READER_WRITER_XML,
87 READER_WRITER_TEXT_DLG,
88 READER_WRITER_TEXT,
89 MAXFILTER
92 extern SwIoDetect aFilterDetect[];
94 // Die folgende Klasse ist ein Wrappe fuer die Basic-I/O-Funktionen
95 // des Writer 3.0. Alles ist statisch. Alle u.a. Filternamen sind die
96 // Writer-internen Namen, d.h. die namen, die in INSTALL.INI vor dem
97 // Gleichheitszeichen stehen, z.b. SWG oder ASCII.
99 class SwIoSystem
101 public:
102 // suche ueber den internen FormatNamen den Filtereintrag
103 SW_DLLPUBLIC static const SfxFilter* GetFilterOfFormat( const String& rFormat,
104 const SfxFilterContainer* pCnt = 0 );
106 // Feststellen des zu verwendenden Filters fuer die uebergebene
107 // Datei. Der Filtername wird zurueckgeliefert. Konnte kein Filter
108 // zurueckgeliefert werden, wird der Name des ASCII-Filters geliefert!
109 static const SfxFilter* GetFileFilter( const String& rFileName,
110 const String& rPrefFltName,
111 SfxMedium* pMedium = 0 );
113 // Feststellen ob das File in dem vorgegebenen Format vorliegt.
114 // Z.z werden nur unsere eigene Filter unterstuetzt!!
115 static BOOL IsFileFilter( SfxMedium& rMedium, const String& rFmtName,
116 const SfxFilter** ppFlt = 0 );
118 static BOOL IsValidStgFilter( SotStorage& , const SfxFilter& );
119 static BOOL IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
121 static bool IsDetectableText( const sal_Char* pBuf, ULONG &rLen,
122 CharSet *pCharSet=0, bool *pSwap=0, LineEnd *pLineEnd=0, bool bEncodedFilter = false );
123 // static bool IsDetectableW4W(const String& rFileName, const String& rUserData);
125 static const SfxFilter* GetTextFilter( const sal_Char* pBuf, ULONG nLen );
127 static const String GetSubStorageName( const SfxFilter& rFltr );
130 #endif