Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / include / sfx2 / docfilt.hxx
blob0a68d80e92437b9ec002902dd3117bacfdb077bc
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 <com/sun/star/embed/XStorage.hpp>
23 #include <com/sun/star/beans/UnknownPropertyException.hpp>
24 #include <com/sun/star/lang/WrappedTargetException.hpp>
25 #include <com/sun/star/uno/RuntimeException.hpp>
26 #include <comphelper/documentconstants.hxx>
27 #include <rtl/ustring.hxx>
28 #include <sal/config.h>
29 #include <sal/types.h>
30 #include <sot/formats.hxx>
31 #include <sfx2/dllapi.h>
32 #include <tools/wldcrd.hxx>
34 #include <memory>
36 class SfxFilterContainer;
37 class SotStorage;
39 class SFX2_DLLPUBLIC SfxFilter
41 friend class SfxFilterContainer;
43 WildCard aWildCard;
45 OUString aTypeName;
46 OUString aUserData;
47 OUString aServiceName;
48 OUString aMimeType;
49 OUString maFilterName;
50 OUString aPattern;
51 OUString aUIName;
52 OUString aDefaultTemplate;
54 /**
55 * Custom provider name in case the filter is provided via external
56 * libraries. Empty for conventional filter types.
58 OUString maProvider;
60 SfxFilterFlags nFormatType;
61 sal_uIntPtr nVersion;
62 SotClipboardFormatId lFormat;
63 sal_uInt16 nDocIcon;
65 public:
66 SfxFilter( const OUString& rProvider, const OUString& rFilterName );
68 SfxFilter( const OUString &rName,
69 const OUString &rWildCard,
70 SfxFilterFlags nFormatType,
71 SotClipboardFormatId lFormat,
72 const OUString &rTypeName,
73 sal_uInt16 nDocIcon,
74 const OUString &rMimeType,
75 const OUString &rUserData,
76 const OUString& rServiceName );
77 ~SfxFilter();
79 bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); }
80 bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); }
81 /// If the filter supports digital signatures.
82 bool GetSupportsSigning() const { return bool(nFormatType & SfxFilterFlags::SUPPORTSSIGNING); }
83 bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); }
84 bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); }
85 bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); }
86 bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); }
87 SfxFilterFlags GetFilterFlags() const { return nFormatType; }
88 const OUString& GetFilterName() const { return maFilterName; }
89 const OUString& GetMimeType() const { return aMimeType; }
90 const OUString& GetName() const { return maFilterName; }
91 const WildCard& GetWildcard() const { return aWildCard; }
92 const OUString& GetRealTypeName() const { return aTypeName; }
93 SotClipboardFormatId GetFormat() const { return lFormat; }
94 const OUString& GetTypeName() const { return aTypeName; }
95 const OUString& GetUIName() const { return aUIName; }
96 const OUString& GetUserData() const { return aUserData; }
97 const OUString& GetDefaultTemplate() const { return aDefaultTemplate; }
98 void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; }
99 bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; }
100 void SetURLPattern( const OUString& rStr );
101 void SetUIName( const OUString& rName ) { aUIName = rName; }
102 void SetVersion( sal_uIntPtr nVersionP ) { nVersion = nVersionP; }
103 sal_uIntPtr GetVersion() const { return nVersion; }
104 OUString GetSuffixes() const;
105 OUString GetDefaultExtension() const;
106 const OUString& GetServiceName() const { return aServiceName; }
107 const OUString& GetProviderName() const { return maProvider;}
109 static std::shared_ptr<const SfxFilter> GetDefaultFilter( const OUString& rName );
110 static std::shared_ptr<const SfxFilter> GetFilterByName( const OUString& rName );
111 static std::shared_ptr<const SfxFilter> GetDefaultFilterFromFactory( const OUString& rServiceName );
113 static OUString GetTypeFromStorage( const SotStorage& rStg );
114 static OUString GetTypeFromStorage(
115 const css::uno::Reference<css::embed::XStorage>& xStorage,
116 bool bTemplate = false )
117 throw ( css::beans::UnknownPropertyException,
118 css::lang::WrappedTargetException,
119 css::uno::RuntimeException,
120 std::exception );
123 #endif
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */