Bump version to 21.06.18.1
[LibreOffice.git] / sw / inc / iodetect.hxx
blob53abd687248661239a2eaa48e8a8808bad3e4828
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 INCLUDED_SW_INC_IODETECT_HXX
21 #define INCLUDED_SW_INC_IODETECT_HXX
23 #include <memory>
24 #include <rtl/ustring.hxx>
25 #include <tools/lineend.hxx>
26 #include <tools/solar.h>
27 #include "swdllapi.h"
29 #define FILTER_RTF "RTF" ///< RTF filter
30 #define sRtfWH "WH_RTF"
31 #define FILTER_TEXT "TEXT" ///< text filter with default codeset
32 #define FILTER_BAS "BAS" ///< StarBasic (identical to ANSI)
33 #define FILTER_WW8 "CWW8" ///< WinWord 97 filter
34 #define FILTER_TEXT_DLG "TEXT_DLG" ///< text filter with encoding dialog
35 #define FILTER_XML "CXML" ///< XML filter
36 #define FILTER_XMLV "CXMLV" ///< XML filter
37 #define FILTER_XMLVW "CXMLVWEB" ///< XML filter
38 #define FILTER_DOCX "OXML"
39 #define sHTML "HTML"
40 #define sWW5 "WW6"
41 #define sWW6 "CWW6"
43 #define sSWRITER "swriter"
44 #define sSWRITERWEB "swriter/web"
46 class SfxFilter;
47 class SfxFilterContainer;
48 class SotStorage;
49 class SvStream;
50 namespace com::sun::star::embed { class XStorage; }
51 namespace com::sun::star::uno { template <typename> class Reference; }
53 struct SwIoDetect
55 const OUString sName;
57 SwIoDetect(const OUString &rN)
58 : sName(rN)
62 bool IsFilter( const OUString& rNm ) const
64 return rNm.startsWith(sName);
68 enum ReaderWriterEnum {
69 READER_WRITER_RTF,
70 READER_WRITER_BAS,
71 READER_WRITER_WW6,
72 READER_WRITER_WW8,
73 READER_WRITER_RTF_WH,
74 READER_WRITER_HTML,
75 READER_WRITER_WW5,
76 READER_WRITER_XML,
77 READER_WRITER_TEXT_DLG,
78 READER_WRITER_TEXT,
79 READER_WRITER_DOCX,
80 MAXFILTER
83 extern SwIoDetect aFilterDetect[];
85 /** The following class is a wrapper for basic i/o functions of Writer 3.0.
86 Everything is static. All filter names mentioned are Writer-internal
87 names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
88 or ASCII.*/
90 class SwIoSystem
92 public:
93 /// find for an internal format name the corresponding filter entry
94 SW_DLLPUBLIC static std::shared_ptr<const SfxFilter>
95 GetFilterOfFormat( const OUString& rFormat,
96 const SfxFilterContainer* pCnt = nullptr );
98 /** Detect for the given file which filter should be used. The filter name
99 is returned. If no filter could be found, the name of the ASCII filter
100 is returned! */
101 static std::shared_ptr<const SfxFilter> GetFileFilter(const OUString& rFileName);
103 static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
104 static bool IsValidStgFilter( const css::uno::Reference < css::embed::XStorage >& rStg, const SfxFilter& rFilter);
106 static bool IsDetectableText( const char* pBuf, sal_uLong &rLen,
107 rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd );
109 static OUString GetSubStorageName( const SfxFilter& rFltr );
112 extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream);
114 #endif
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */