cid#1636693 COPY_INSTEAD_OF_MOVE
[LibreOffice.git] / include / sfx2 / docfilt.hxx
blob45dd0efb9b2976fd252472de819f9d80cd1c0847
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( OUString aProvider, OUString aFilterName );
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();
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 bool IsMSOFormat() const { return aTypeName.startsWith("MS"); }
84 /// not our built-in format
85 bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); }
86 /// an unusual/legacy file to be loading
87 bool IsExoticFormat() const { return bool(nFormatType & SfxFilterFlags::EXOTIC); }
88 bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); }
89 bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); }
90 SfxFilterFlags GetFilterFlags() const { return nFormatType; }
91 const OUString& GetFilterName() const { return maFilterName; }
92 const OUString& GetMimeType() const { return aMimeType; }
93 const OUString& GetName() const { return maFilterName; }
94 const WildCard& GetWildcard() const { return aWildCard; }
95 const OUString& GetRealTypeName() const { return aTypeName; }
96 SotClipboardFormatId GetFormat() const { return lFormat; }
97 const OUString& GetTypeName() const { return aTypeName; }
98 const OUString& GetUIName() const { return aUIName; }
99 const OUString& GetUserData() const { return aUserData; }
100 const OUString& GetDefaultTemplate() const { return aDefaultTemplate; }
101 void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; }
102 bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; }
103 void SetUIName( const OUString& rName ) { aUIName = rName; }
104 void SetVersion( sal_Int32 nVersionP ) { nVersion = nVersionP; }
105 sal_Int32 GetVersion() const { return nVersion; }
106 OUString GetSuffixes() const;
107 OUString GetDefaultExtension() const;
108 const OUString& GetServiceName() const { return aServiceName; }
109 const OUString& GetProviderName() const { return maProvider;}
111 static std::shared_ptr<const SfxFilter> GetDefaultFilter( std::u16string_view rName );
112 static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName );
113 static std::shared_ptr<const SfxFilter> GetDefaultFilterFromFactory( const OUString& rServiceName );
115 static OUString GetTypeFromStorage( const SotStorage& rStg );
116 /// @throws css::beans::UnknownPropertyException
117 /// @throws css::lang::WrappedTargetException
118 /// @throws css::uno::RuntimeException
119 static OUString GetTypeFromStorage(
120 const css::uno::Reference<css::embed::XStorage>& xStorage );
121 bool IsEnabled() const { return mbEnabled; }
124 #endif
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */