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 INCLUDED_SW_INC_IODETECT_HXX
21 #define INCLUDED_SW_INC_IODETECT_HXX
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>
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 FILTER_DOCX "OXML"
44 #define sSWRITER "swriter"
45 #define sSWRITERWEB "swriter/web"
51 SwIoDetect(const OUString
&rN
)
56 bool IsFilter( const OUString
& rNm
) const
58 return rNm
.startsWith(sName
);
62 enum ReaderWriterEnum
{
71 READER_WRITER_TEXT_DLG
,
77 extern SwIoDetect aFilterDetect
[];
79 /** The following class is a wrapper for basic i/o functions of Writer 3.0.
80 Everything is static. All filter names mentioned are Writer-internal
81 names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
87 /// find for an internal format name the corresponding filter entry
88 SW_DLLPUBLIC
static std::shared_ptr
<const SfxFilter
>
89 GetFilterOfFormat( const OUString
& rFormat
,
90 const SfxFilterContainer
* pCnt
= nullptr );
92 /** Detect for the given file which filter should be used. The filter name
93 is returned. If no filter could be found, the name of the ASCII filter
95 static std::shared_ptr
<const SfxFilter
> GetFileFilter(const OUString
& rFileName
);
97 static bool IsValidStgFilter( SotStorage
& , const SfxFilter
& );
98 static bool IsValidStgFilter( const css::uno::Reference
< css::embed::XStorage
>& rStg
, const SfxFilter
& rFilter
);
100 static bool IsDetectableText( const sal_Char
* pBuf
, sal_uLong
&rLen
,
101 rtl_TextEncoding
*pCharSet
, bool *pSwap
, LineEnd
*pLineEnd
=nullptr );
103 static const OUString
GetSubStorageName( const SfxFilter
& rFltr
);
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */