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 <tools/solar.h>
29 #include "swdllapi.h"
30 
31 #define FILTER_RTF "RTF"
32 #define sRtfWH "WH_RTF"
33 #define FILTER_TEXT u"TEXT"
34 #define FILTER_BAS "BAS"
35 #define FILTER_WW8 "CWW8"
36 #define FILTER_TEXT_DLG "TEXT_DLG"
37 #define FILTER_XML u"CXML"
38 #define FILTER_XMLV "CXMLV"
39 #define FILTER_XMLVW "CXMLVWEB"
40 #define FILTER_DOCX "OXML"
41 #define sHTML "HTML"
42 #define sWW5 "WW6"
43 #define sWW6 "CWW6"
44 
45 #define sSWRITER "swriter"
46 #define sSWRITERWEB "swriter/web"
47 
48 class SfxFilter;
49 class SfxFilterContainer;
50 class SotStorage;
51 class SvStream;
52 namespace com::sun::star::embed { class XStorage; }
53 namespace com::sun::star::uno { template <typename> class Reference; }
54 
55 struct SwIoDetect
56 {
57  const OUString sName;
58 
59  SwIoDetect(const OUString &rN)
60  : sName(rN)
61  {
62  }
63 
64  bool IsFilter( std::u16string_view rNm ) const
65  {
66  return o3tl::starts_with(rNm, sName);
67  }
68 };
69 
83 };
84 
85 extern SwIoDetect aFilterDetect[];
86 
93 {
94 public:
96  SW_DLLPUBLIC static std::shared_ptr<const SfxFilter>
97  GetFilterOfFormat( std::u16string_view rFormat,
98  const SfxFilterContainer* pCnt = nullptr );
99 
103  static std::shared_ptr<const SfxFilter> GetFileFilter(const OUString& rFileName);
104 
105  static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
106  static bool IsValidStgFilter( const css::uno::Reference < css::embed::XStorage >& rStg, const SfxFilter& rFilter);
107 
108  static bool IsDetectableText( const char* pBuf, sal_uLong &rLen,
109  rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool *pBom);
110 
111  static OUString GetSubStorageName( const SfxFilter& rFltr );
112 };
113 
114 extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream);
115 
116 #endif
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsDetectableText(const char *pBuf, sal_uLong &rLen, rtl_TextEncoding *pCharSet, bool *pSwap, LineEnd *pLineEnd, bool *pBom)
Definition: iodetect.cxx:241
sal_uIntPtr sal_uLong
SwIoDetect(const OUString &rN)
Definition: iodetect.hxx:59
bool IsFilter(std::u16string_view rNm) const
Definition: iodetect.hxx:64
ReaderWriterEnum
Definition: iodetect.hxx:70
Reference
const OUString sName
Definition: iodetect.hxx:57
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
static bool IsValidStgFilter(SotStorage &, const SfxFilter &)
Definition: iodetect.cxx:112
SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream)
Definition: xmlimp.cxx:1709
The following class is a wrapper for basic i/o functions of Writer 3.0.
Definition: iodetect.hxx:92
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
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
LineEnd
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 OUString GetSubStorageName(const SfxFilter &rFltr)
Definition: iodetect.cxx:55
SwIoDetect aFilterDetect[]
Definition: iodetect.cxx:40