/src/libreoffice/include/sfx2/docfilt.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SFX2_DOCFILT_HXX |
20 | | #define INCLUDED_SFX2_DOCFILT_HXX |
21 | | |
22 | | #include <comphelper/documentconstants.hxx> |
23 | | #include <rtl/ustring.hxx> |
24 | | #include <sal/config.h> |
25 | | #include <sal/types.h> |
26 | | #include <sot/formats.hxx> |
27 | | #include <sfx2/dllapi.h> |
28 | | #include <tools/wldcrd.hxx> |
29 | | |
30 | | #include <memory> |
31 | | #include <string_view> |
32 | | |
33 | | namespace com::sun::star::embed { class XStorage; } |
34 | | namespace com::sun::star::uno { template <typename > class Reference; } |
35 | | |
36 | | class SotStorage; |
37 | | |
38 | | class SFX2_DLLPUBLIC SfxFilter |
39 | | { |
40 | | friend class SfxFilterContainer; |
41 | | |
42 | | WildCard aWildCard; |
43 | | |
44 | | OUString aTypeName; |
45 | | OUString aUserData; |
46 | | OUString aServiceName; |
47 | | OUString aMimeType; |
48 | | OUString maFilterName; |
49 | | OUString aUIName; |
50 | | OUString aDefaultTemplate; |
51 | | |
52 | | /** |
53 | | * Custom provider name in case the filter is provided via external |
54 | | * libraries. Empty for conventional filter types. |
55 | | */ |
56 | | OUString maProvider; |
57 | | |
58 | | SfxFilterFlags nFormatType; |
59 | | sal_Int32 nVersion; |
60 | | SotClipboardFormatId lFormat; |
61 | | bool mbEnabled; |
62 | | |
63 | | public: |
64 | | SfxFilter( OUString aProvider, OUString aFilterName ); |
65 | | |
66 | | SfxFilter( OUString aName, |
67 | | std::u16string_view rWildCard, |
68 | | SfxFilterFlags nFormatType, |
69 | | SotClipboardFormatId lFormat, |
70 | | OUString aTypeName, |
71 | | OUString aMimeType, |
72 | | OUString aUserData, |
73 | | OUString aServiceName, |
74 | | bool bEnabled = true ); |
75 | | ~SfxFilter(); |
76 | | |
77 | 0 | bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); } |
78 | 0 | bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); } |
79 | | /// If the filter supports digital signatures. |
80 | 0 | bool GetSupportsSigning() const { return bool(nFormatType & SfxFilterFlags::SUPPORTSSIGNING); } |
81 | 0 | bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); } |
82 | | bool IsMSOFormat() const |
83 | 0 | { |
84 | 0 | return aTypeName.startsWith("MS") || aTypeName.startsWith("Office Open XML "); |
85 | 0 | } |
86 | | /// not our built-in format |
87 | 0 | bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); } |
88 | | /// an unusual/legacy file to be loading |
89 | 0 | bool IsExoticFormat() const { return bool(nFormatType & SfxFilterFlags::EXOTIC); } |
90 | 0 | bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); } |
91 | 0 | bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); } |
92 | 0 | SfxFilterFlags GetFilterFlags() const { return nFormatType; } |
93 | 0 | const OUString& GetFilterName() const { return maFilterName; } |
94 | 0 | const OUString& GetMimeType() const { return aMimeType; } |
95 | 0 | const OUString& GetName() const { return maFilterName; } |
96 | 0 | const WildCard& GetWildcard() const { return aWildCard; } |
97 | 0 | const OUString& GetRealTypeName() const { return aTypeName; } |
98 | 0 | SotClipboardFormatId GetFormat() const { return lFormat; } |
99 | 0 | const OUString& GetTypeName() const { return aTypeName; } |
100 | 0 | const OUString& GetUIName() const { return aUIName; } |
101 | 0 | const OUString& GetUserData() const { return aUserData; } |
102 | 0 | const OUString& GetDefaultTemplate() const { return aDefaultTemplate; } |
103 | 0 | void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; } |
104 | 0 | bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; } |
105 | 0 | void SetUIName( const OUString& rName ) { aUIName = rName; } |
106 | 0 | void SetVersion( sal_Int32 nVersionP ) { nVersion = nVersionP; } |
107 | 0 | sal_Int32 GetVersion() const { return nVersion; } |
108 | | OUString GetSuffixes() const; |
109 | | OUString GetDefaultExtension() const; |
110 | 0 | const OUString& GetServiceName() const { return aServiceName; } |
111 | 0 | const OUString& GetProviderName() const { return maProvider;} |
112 | | |
113 | | static std::shared_ptr<const SfxFilter> GetDefaultFilter( std::u16string_view rName ); |
114 | | static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName ); |
115 | | static std::shared_ptr<const SfxFilter> GetDefaultFilterFromFactory( const OUString& rServiceName ); |
116 | | |
117 | | static OUString GetTypeFromStorage( const SotStorage& rStg ); |
118 | | /// @throws css::beans::UnknownPropertyException |
119 | | /// @throws css::lang::WrappedTargetException |
120 | | /// @throws css::uno::RuntimeException |
121 | | static OUString GetTypeFromStorage( |
122 | | const css::uno::Reference<css::embed::XStorage>& xStorage ); |
123 | 0 | bool IsEnabled() const { return mbEnabled; } |
124 | | }; |
125 | | |
126 | | #endif |
127 | | |
128 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |