follow org.freedesktop.appearance.color-scheme setting
[LibreOffice.git] / include / sfx2 / docfilt.hxx
bloba3b350deebe51652eec1bc5be3947a8d8d555eb2
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 .
19 #ifndef INCLUDED_SFX2_DOCFILT_HXX
20 #define INCLUDED_SFX2_DOCFILT_HXX
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>
30 #include <memory>
31 #include <string_view>
33 namespace com::sun::star::embed { class XStorage; }
34 namespace com::sun::star::uno { template <typename > class Reference; }
36 class SotStorage;
38 class SFX2_DLLPUBLIC SfxFilter
40 friend class SfxFilterContainer;
42 WildCard aWildCard;
44 OUString aTypeName;
45 OUString aUserData;
46 OUString aServiceName;
47 OUString aMimeType;
48 OUString maFilterName;
49 OUString aUIName;
50 OUString aDefaultTemplate;
52 /**
53 * Custom provider name in case the filter is provided via external
54 * libraries. Empty for conventional filter types.
56 OUString maProvider;
58 SfxFilterFlags nFormatType;
59 sal_Int32 nVersion;
60 SotClipboardFormatId lFormat;
61 bool mbEnabled;
63 public:
64 SfxFilter( const OUString& rProvider, const OUString& rFilterName );
66 SfxFilter( const OUString &rName,
67 std::u16string_view rWildCard,
68 SfxFilterFlags nFormatType,
69 SotClipboardFormatId lFormat,
70 const OUString &rTypeName,
71 const OUString &rMimeType,
72 const OUString &rUserData,
73 const OUString& rServiceName,
74 bool bEnabled = true );
75 ~SfxFilter();
77 bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); }
78 bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); }
79 /// If the filter supports digital signatures.
80 bool GetSupportsSigning() const { return bool(nFormatType & SfxFilterFlags::SUPPORTSSIGNING); }
81 bool GetGpgEncryption() const { return bool(nFormatType & SfxFilterFlags::GPGENCRYPTION); }
82 bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); }
83 /// not our built-in format
84 bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); }
85 /// an unusual/legacy file to be loading
86 bool IsExoticFormat() const { return bool(nFormatType & SfxFilterFlags::EXOTIC); }
87 bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); }
88 bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); }
89 SfxFilterFlags GetFilterFlags() const { return nFormatType; }
90 const OUString& GetFilterName() const { return maFilterName; }
91 const OUString& GetMimeType() const { return aMimeType; }
92 const OUString& GetName() const { return maFilterName; }
93 const WildCard& GetWildcard() const { return aWildCard; }
94 const OUString& GetRealTypeName() const { return aTypeName; }
95 SotClipboardFormatId GetFormat() const { return lFormat; }
96 const OUString& GetTypeName() const { return aTypeName; }
97 const OUString& GetUIName() const { return aUIName; }
98 const OUString& GetUserData() const { return aUserData; }
99 const OUString& GetDefaultTemplate() const { return aDefaultTemplate; }
100 void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; }
101 bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; }
102 void SetUIName( const OUString& rName ) { aUIName = rName; }
103 void SetVersion( sal_Int32 nVersionP ) { nVersion = nVersionP; }
104 sal_Int32 GetVersion() const { return nVersion; }
105 OUString GetSuffixes() const;
106 OUString GetDefaultExtension() const;
107 const OUString& GetServiceName() const { return aServiceName; }
108 const OUString& GetProviderName() const { return maProvider;}
110 static std::shared_ptr<const SfxFilter> GetDefaultFilter( const OUString& rName );
111 static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName );
112 static std::shared_ptr<const SfxFilter> GetDefaultFilterFromFactory( const OUString& rServiceName );
114 static OUString GetTypeFromStorage( const SotStorage& rStg );
115 /// @throws css::beans::UnknownPropertyException
116 /// @throws css::lang::WrappedTargetException
117 /// @throws css::uno::RuntimeException
118 static OUString GetTypeFromStorage(
119 const css::uno::Reference<css::embed::XStorage>& xStorage );
120 bool IsEnabled() const { return mbEnabled; }
123 #endif
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */