1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/plugin/PluginDescription.hpp>
23 #include <com/sun/star/embed/XStorage.hpp>
24 #include <com/sun/star/beans/UnknownPropertyException.hpp>
25 #include <com/sun/star/lang/WrappedTargetException.hpp>
26 #include <com/sun/star/uno/RuntimeException.hpp>
27 #include <comphelper/documentconstants.hxx>
28 #include <rtl/ustring.hxx>
29 #include <sal/config.h>
30 #include <sal/types.h>
31 #include <sot/formats.hxx>
32 #include <sfx2/dllapi.h>
33 #include <tools/wldcrd.hxx>
35 class SfxFilterContainer
;
38 class SFX2_DLLPUBLIC SfxFilter
40 friend class SfxFilterContainer
;
46 OUString aServiceName
;
48 OUString maFilterName
;
51 OUString aDefaultTemplate
;
54 * Custom provider name in case the filter is provided via external
55 * libraries. Empty for conventional filter types.
59 SfxFilterFlags nFormatType
;
61 SotClipboardFormatId lFormat
;
65 SfxFilter( const OUString
& rProvider
, const OUString
& rFilterName
);
67 SfxFilter( const OUString
&rName
,
68 const OUString
&rWildCard
,
69 SfxFilterFlags nFormatType
,
70 SotClipboardFormatId lFormat
,
71 const OUString
&rTypeName
,
73 const OUString
&rMimeType
,
74 const OUString
&rUserData
,
75 const OUString
& rServiceName
);
78 bool IsAllowedAsTemplate() const { return bool(nFormatType
& SfxFilterFlags::TEMPLATE
); }
79 bool IsOwnFormat() const { return bool(nFormatType
& SfxFilterFlags::OWN
); }
80 bool IsOwnTemplateFormat() const { return bool(nFormatType
& SfxFilterFlags::TEMPLATEPATH
); }
81 bool IsAlienFormat() const { return bool(nFormatType
& SfxFilterFlags::ALIEN
); }
82 bool CanImport() const { return bool(nFormatType
& SfxFilterFlags::IMPORT
); }
83 bool CanExport() const { return bool(nFormatType
& SfxFilterFlags::EXPORT
); }
84 bool IsInternal() const { return bool(nFormatType
& SfxFilterFlags::INTERNAL
); }
85 SfxFilterFlags
GetFilterFlags() const { return nFormatType
; }
86 const OUString
& GetFilterName() const { return maFilterName
; }
87 const OUString
& GetMimeType() const { return aMimeType
; }
88 const OUString
& GetName() const { return maFilterName
; }
89 const WildCard
& GetWildcard() const { return aWildCard
; }
90 const OUString
& GetRealTypeName() const { return aTypeName
; }
91 SotClipboardFormatId
GetFormat() const { return lFormat
; }
92 const OUString
& GetTypeName() const { return aTypeName
; }
93 const OUString
& GetUIName() const { return aUIName
; }
94 sal_uInt16
GetDocIconId() const { return nDocIcon
; }
95 const OUString
& GetUserData() const { return aUserData
; }
96 const OUString
& GetDefaultTemplate() const { return aDefaultTemplate
; }
97 void SetDefaultTemplate( const OUString
& rStr
) { aDefaultTemplate
= rStr
; }
98 bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE
; }
99 void SetURLPattern( const OUString
& rStr
);
100 OUString
GetURLPattern() const { return aPattern
; }
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 const SfxFilter
* GetDefaultFilter( const OUString
& rName
);
110 static const SfxFilter
* GetFilterByName( const OUString
& rName
);
111 static const SfxFilter
* GetDefaultFilterFromFactory( const OUString
& rServiceName
);
113 static OUString
GetTypeFromStorage( const SotStorage
& rStg
);
114 static OUString
GetTypeFromStorage(
115 const com::sun::star::uno::Reference
<com::sun::star::embed::XStorage
>& xStorage
,
116 bool bTemplate
= false, OUString
* pName
= NULL
)
117 throw ( com::sun::star::beans::UnknownPropertyException
,
118 com::sun::star::lang::WrappedTargetException
,
119 com::sun::star::uno::RuntimeException
);
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */