Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _IODETECT_HXX_
30 : : #define _IODETECT_HXX_
31 : :
32 : : #include <sfx2/docfilt.hxx>
33 : : #include <sfx2/docfile.hxx>
34 : : #include <sfx2/fcontnr.hxx>
35 : : #include <osl/endian.h>
36 : : #include <tools/string.hxx>
37 : : #include <swddllapi.h>
38 : :
39 : : #define FILTER_RTF "RTF" // RTF filter
40 : : #define sRtfWH "WH_RTF"
41 : : #define FILTER_TEXT "TEXT" // text filter with default codeset
42 : : #define FILTER_BAS "BAS" // StarBasic (identical to ANSI)
43 : : #define FILTER_WW8 "CWW8" // WinWord 97 filter
44 : : #define FILTER_TEXT_DLG "TEXT_DLG" // text filter with encoding dialog
45 : : #define FILTER_XML "CXML" // XML filter
46 : : #define FILTER_XMLV "CXMLV" // XML filter
47 : : #define FILTER_XMLVW "CXMLVWEB" // XML filter
48 : : #define sHTML "HTML"
49 : : #define sWW1 "WW1"
50 : : #define sWW5 "WW6"
51 : : #define sWW6 "CWW6"
52 : :
53 : : #define sSWRITER "swriter"
54 : : #define sSWRITERWEB "swriter/web"
55 : :
56 : : struct SwIoDetect
57 : : {
58 : : const sal_Char* pName;
59 : : sal_uInt16 nLen;
60 : :
61 : 825 : inline SwIoDetect( const sal_Char *pN, sal_uInt16 nL )
62 : 825 : : pName( pN ), nLen( nL )
63 : 825 : {}
64 : :
65 : 105522 : inline int IsFilter( const String& rNm ) const
66 : : {
67 [ + - ][ + + ]: 105522 : return pName && rNm.EqualsAscii( pName, 0, nLen );
68 : : }
69 : :
70 : : const sal_Char* IsReader( const sal_Char* pHeader, sal_uLong nLen_,
71 : : const String &rFileName, const String& rUserData ) const;
72 : : };
73 : :
74 : : enum ReaderWriterEnum {
75 : : READER_WRITER_RTF,
76 : : READER_WRITER_BAS,
77 : : READER_WRITER_WW6,
78 : : READER_WRITER_WW8,
79 : : READER_WRITER_RTF_WH,
80 : : READER_WRITER_HTML,
81 : : READER_WRITER_WW1,
82 : : READER_WRITER_WW5,
83 : : READER_WRITER_XML,
84 : : READER_WRITER_TEXT_DLG,
85 : : READER_WRITER_TEXT,
86 : : MAXFILTER
87 : : };
88 : :
89 : : extern SWD_DLLPUBLIC SwIoDetect aFilterDetect[];
90 : :
91 : : // The following class is a wrapper for basic i/o functions of Writer 3.0.
92 : : // Everything is static. All filter names mentioned are Writer-internal
93 : : // names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
94 : : // or ASCII.
95 : :
96 : : class SwIoSystem
97 : : {
98 : : public:
99 : : // find for an internal format name the corresponding filter entry
100 : : SWD_DLLPUBLIC static const SfxFilter*
101 : : GetFilterOfFormat( const String& rFormat,
102 : : const SfxFilterContainer* pCnt = 0 );
103 : :
104 : : // Detect for the given file which filter should be used. The filter name
105 : : // is returned. If no filter could be found, the name of the ASCII filter
106 : : // is returned!
107 : : SWD_DLLPUBLIC static const SfxFilter*
108 : : GetFileFilter( const String& rFileName,
109 : : const String& rPrefFltName,
110 : : SfxMedium* pMedium = 0 );
111 : :
112 : : // Detect whether the given file is in the given format.
113 : : // For now, only our own filters are supported!
114 : : static sal_Bool IsFileFilter( SfxMedium& rMedium, const String& rFmtName,
115 : : const SfxFilter** ppFlt = 0 );
116 : :
117 : : static sal_Bool IsValidStgFilter( SotStorage& , const SfxFilter& );
118 : : static sal_Bool IsValidStgFilter( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rStg, const SfxFilter& rFilter);
119 : :
120 : : SWD_DLLPUBLIC static bool
121 : : IsDetectableText( const sal_Char* pBuf, sal_uLong &rLen,
122 : : CharSet *pCharSet=0, bool *pSwap=0, LineEnd *pLineEnd=0, bool bEncodedFilter = false );
123 : :
124 : : static const SfxFilter* GetTextFilter( const sal_Char* pBuf, sal_uLong nLen );
125 : :
126 : : SWD_DLLPUBLIC static const String
127 : : GetSubStorageName( const SfxFilter& rFltr );
128 : : };
129 : :
130 : : #endif
131 : :
132 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|