tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sw / inc / iodetect.hxx
blobcb47a7b7f3b26003b50c209dcc3c7f3fe79713fc
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 <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"
32 inline constexpr OUString FILTER_RTF = u"RTF"_ustr; ///< RTF filter
33 inline constexpr OUString sRtfWH = u"WH_RTF"_ustr;
34 inline constexpr OUString FILTER_TEXT = u"TEXT"_ustr; ///< text filter with default codeset
35 inline constexpr OUString FILTER_BAS = u"BAS"_ustr; ///< StarBasic (identical to ANSI)
36 inline constexpr OUString FILTER_WW8 = u"CWW8"_ustr; ///< WinWord 97 filter
37 inline constexpr OUString FILTER_TEXT_DLG = u"TEXT_DLG"_ustr; ///< text filter with encoding dialog
38 inline constexpr OUString FILTER_XML = u"CXML"_ustr; ///< XML filter
39 #define FILTER_XMLV "CXMLV" ///< XML filter
40 #define FILTER_XMLVW "CXMLVWEB" ///< XML filter
41 inline constexpr OUString FILTER_DOCX = u"OXML"_ustr;
42 inline constexpr OUString sHTML = u"HTML"_ustr;
43 inline constexpr OUString sWW5 = u"WW6"_ustr;
44 inline constexpr OUString sWW6 = u"CWW6"_ustr;
46 inline constexpr OUString sSWRITER = u"swriter"_ustr;
47 inline constexpr OUString sSWRITERWEB = u"swriter/web"_ustr;
49 class SfxFilter;
50 class SfxFilterContainer;
51 class SotStorage;
52 class SvStream;
53 namespace com::sun::star::embed { class XStorage; }
54 namespace com::sun::star::uno { template <typename> class Reference; }
56 struct SwIoDetect
58 const OUString sName;
60 SwIoDetect(OUString aN)
61 : sName(std::move(aN))
65 bool IsFilter( std::u16string_view rNm ) const
67 return o3tl::starts_with(rNm, sName);
71 enum ReaderWriterEnum {
72 READER_WRITER_RTF,
73 READER_WRITER_BAS,
74 READER_WRITER_WW6,
75 READER_WRITER_WW8,
76 READER_WRITER_RTF_WH,
77 READER_WRITER_HTML,
78 READER_WRITER_WW5,
79 READER_WRITER_XML,
80 READER_WRITER_TEXT_DLG,
81 READER_WRITER_TEXT,
82 READER_WRITER_DOCX,
83 MAXFILTER
86 extern SwIoDetect aFilterDetect[];
88 /** The following class is a wrapper for basic i/o functions of Writer 3.0.
89 Everything is static. All filter names mentioned are Writer-internal
90 names, i.e. the names in front of the equality sign in INSTALL.INI, like SWG
91 or ASCII.*/
93 class SwIoSystem
95 public:
96 /// find for an internal format name the corresponding filter entry
97 SW_DLLPUBLIC static std::shared_ptr<const SfxFilter>
98 GetFilterOfFormat( std::u16string_view rFormat,
99 const SfxFilterContainer* pCnt = nullptr );
101 /** Detect for the given file which filter should be used. The filter name
102 is returned. If no filter could be found, the name of the ASCII filter
103 is returned! */
104 static std::shared_ptr<const SfxFilter> GetFileFilter(const OUString& rFileName);
106 static bool IsValidStgFilter( SotStorage& , const SfxFilter& );
107 static bool IsValidStgFilter( const css::uno::Reference < css::embed::XStorage >& rStg, const SfxFilter& rFilter);
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);
114 static OUString GetSubStorageName( const SfxFilter& rFltr );
117 extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportFODT(SvStream &rStream);
118 extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestPDFExportFODT(SvStream &rStream);
120 #endif
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */