LibreOffice Module sw (master) 1
iodetect.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_SW_INC_IODETECT_HXX
21#define INCLUDED_SW_INC_IODETECT_HXX
22
23#include <memory>
24#include <string_view>
25#include <o3tl/string_view.hxx>
26#include <rtl/ustring.hxx>
27#include <tools/lineend.hxx>
28#include <utility>
29#include <tools/solar.h>
30#include "swdllapi.h"
31
32inline constexpr OUStringLiteral FILTER_RTF = u"RTF";
33inline constexpr OUStringLiteral sRtfWH = u"WH_RTF";
34inline constexpr OUStringLiteral FILTER_TEXT = u"TEXT";
35inline constexpr OUStringLiteral FILTER_BAS = u"BAS";
36inline constexpr OUStringLiteral FILTER_WW8 = u"CWW8";
37inline constexpr OUStringLiteral FILTER_TEXT_DLG = u"TEXT_DLG";
38inline constexpr OUStringLiteral FILTER_XML = u"CXML";
39#define FILTER_XMLV "CXMLV"
40#define FILTER_XMLVW "CXMLVWEB"
41inline constexpr OUStringLiteral FILTER_DOCX = u"OXML";
42inline constexpr OUStringLiteral sHTML = u"HTML";
43inline constexpr OUStringLiteral sWW5 = u"WW6";
44inline constexpr OUStringLiteral sWW6 = u"CWW6";
45
46inline constexpr OUStringLiteral sSWRITER = u"swriter";
47inline constexpr OUStringLiteral sSWRITERWEB = u"swriter/web";
48
49class SfxFilter;
51class SotStorage;
52class SvStream;
53namespace com::sun::star::embed { class XStorage; }
54namespace com::sun::star::uno { template <typename> class Reference; }
55
57{
58 const OUString sName;
59
60 SwIoDetect(OUString aN)
61 : sName(std::move(aN))
62 {
63 }
64
65 bool IsFilter( std::u16string_view rNm ) const
66 {
67 return o3tl::starts_with(rNm, sName);
68 }
69};
70
84};
85
87
94{
95public:
97 SW_DLLPUBLIC static std::shared_ptr<const SfxFilter>
98 GetFilterOfFormat( std::u16string_view rFormat,
99 const SfxFilterContainer* pCnt = nullptr );
100
104 static std::shared_ptr<const SfxFilter> GetFileFilter(const OUString& rFileName);
105
106 static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
107 static bool IsValidStgFilter( const css::uno::Reference < css::embed::XStorage >& rStg, const SfxFilter& rFilter);
108
109 // tdf#106899 - wrapper around IsDetectableText to retrieve the text encoding for a given stream
110 SW_DLLPUBLIC static rtl_TextEncoding GetTextEncoding(SvStream&);
111 static bool IsDetectableText( const char* pBuf, sal_uLong &rLen,
112 rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool *pBom);
113
114 static OUString GetSubStorageName( const SfxFilter& rFltr );
115};
116
117extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream);
118extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestPDFExportFODT(SvStream &rStream);
119
120#endif
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
The following class is a wrapper for basic i/o functions of Writer 3.0.
Definition: iodetect.hxx:94
static std::shared_ptr< const SfxFilter > GetFileFilter(const OUString &rFileName)
Detect for the given file which filter should be used.
Definition: iodetect.cxx:149
static bool IsDetectableText(const char *pBuf, sal_uLong &rLen, rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool *pBom)
Definition: iodetect.cxx:257
static OUString GetSubStorageName(const SfxFilter &rFltr)
Definition: iodetect.cxx:55
static SW_DLLPUBLIC std::shared_ptr< const SfxFilter > GetFilterOfFormat(std::u16string_view rFormat, const SfxFilterContainer *pCnt=nullptr)
find for an internal format name the corresponding filter entry
Definition: iodetect.cxx:68
static bool IsValidStgFilter(SotStorage &, const SfxFilter &)
Definition: iodetect.cxx:112
static SW_DLLPUBLIC rtl_TextEncoding GetTextEncoding(SvStream &)
Definition: iodetect.cxx:241
float u
constexpr OUStringLiteral FILTER_WW8
WinWord 97 filter.
Definition: iodetect.hxx:36
constexpr OUStringLiteral FILTER_TEXT_DLG
text filter with encoding dialog
Definition: iodetect.hxx:37
constexpr OUStringLiteral sRtfWH
Definition: iodetect.hxx:33
constexpr OUStringLiteral FILTER_RTF
RTF filter.
Definition: iodetect.hxx:32
SwIoDetect aFilterDetect[]
Definition: iodetect.cxx:40
constexpr OUStringLiteral FILTER_XML
XML filter.
Definition: iodetect.hxx:38
constexpr OUStringLiteral FILTER_BAS
StarBasic (identical to ANSI)
Definition: iodetect.hxx:35
constexpr OUStringLiteral sWW5
Definition: iodetect.hxx:43
constexpr OUStringLiteral FILTER_DOCX
Definition: iodetect.hxx:41
constexpr OUStringLiteral sSWRITERWEB
Definition: iodetect.hxx:47
SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestPDFExportFODT(SvStream &rStream)
Definition: xmlimp.cxx:1786
SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream)
Definition: xmlimp.cxx:1733
constexpr OUStringLiteral sWW6
Definition: iodetect.hxx:44
constexpr OUStringLiteral sSWRITER
Definition: iodetect.hxx:46
constexpr OUStringLiteral sHTML
Definition: iodetect.hxx:42
constexpr OUStringLiteral FILTER_TEXT
text filter with default codeset
Definition: iodetect.hxx:34
ReaderWriterEnum
Definition: iodetect.hxx:71
@ READER_WRITER_XML
Definition: iodetect.hxx:79
@ MAXFILTER
Definition: iodetect.hxx:83
@ READER_WRITER_DOCX
Definition: iodetect.hxx:82
@ READER_WRITER_TEXT
Definition: iodetect.hxx:81
@ READER_WRITER_BAS
Definition: iodetect.hxx:73
@ READER_WRITER_WW6
Definition: iodetect.hxx:74
@ READER_WRITER_WW5
Definition: iodetect.hxx:78
@ READER_WRITER_HTML
Definition: iodetect.hxx:77
@ READER_WRITER_TEXT_DLG
Definition: iodetect.hxx:80
@ READER_WRITER_WW8
Definition: iodetect.hxx:75
@ READER_WRITER_RTF
Definition: iodetect.hxx:72
@ READER_WRITER_RTF_WH
Definition: iodetect.hxx:76
LineEnd
Reference
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
sal_uIntPtr sal_uLong
const OUString sName
Definition: iodetect.hxx:58
SwIoDetect(OUString aN)
Definition: iodetect.hxx:60
bool IsFilter(std::u16string_view rNm) const
Definition: iodetect.hxx:65
#define SW_DLLPUBLIC
Definition: swdllapi.h:28