Line data Source code
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 <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>
34 :
35 : class SfxFilterContainer;
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 aPattern;
50 : OUString aUIName;
51 : OUString aDefaultTemplate;
52 :
53 : /**
54 : * Custom provider name in case the filter is provided via external
55 : * libraries. Empty for conventional filter types.
56 : */
57 : OUString maProvider;
58 :
59 : SfxFilterFlags nFormatType;
60 : sal_uIntPtr nVersion;
61 : SotClipboardFormatId lFormat;
62 : sal_uInt16 nDocIcon;
63 :
64 : public:
65 : SfxFilter( const OUString& rProvider, const OUString& rFilterName );
66 :
67 : SfxFilter( const OUString &rName,
68 : const OUString &rWildCard,
69 : SfxFilterFlags nFormatType,
70 : SotClipboardFormatId lFormat,
71 : const OUString &rTypeName,
72 : sal_uInt16 nDocIcon,
73 : const OUString &rMimeType,
74 : const OUString &rUserData,
75 : const OUString& rServiceName );
76 : ~SfxFilter();
77 :
78 0 : bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); }
79 13011 : bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); }
80 3249 : bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); }
81 95098 : bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); }
82 15 : bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); }
83 700 : bool CanExport() const { return bool(nFormatType & SfxFilterFlags::EXPORT); }
84 : bool IsInternal() const { return bool(nFormatType & SfxFilterFlags::INTERNAL); }
85 97003 : SfxFilterFlags GetFilterFlags() const { return nFormatType; }
86 75196694 : const OUString& GetFilterName() const { return maFilterName; }
87 52976 : const OUString& GetMimeType() const { return aMimeType; }
88 3690 : const OUString& GetName() const { return maFilterName; }
89 1071 : const WildCard& GetWildcard() const { return aWildCard; }
90 11 : const OUString& GetRealTypeName() const { return aTypeName; }
91 8762 : SotClipboardFormatId GetFormat() const { return lFormat; }
92 1147 : const OUString& GetTypeName() const { return aTypeName; }
93 0 : const OUString& GetUIName() const { return aUIName; }
94 : sal_uInt16 GetDocIconId() const { return nDocIcon; }
95 621 : const OUString& GetUserData() const { return aUserData; }
96 148 : const OUString& GetDefaultTemplate() const { return aDefaultTemplate; }
97 480 : void SetDefaultTemplate( const OUString& rStr ) { aDefaultTemplate = rStr; }
98 8653 : bool UsesStorage() const { return GetFormat() != SotClipboardFormatId::NONE; }
99 : void SetURLPattern( const OUString& rStr );
100 : OUString GetURLPattern() const { return aPattern; }
101 480 : void SetUIName( const OUString& rName ) { aUIName = rName; }
102 761 : void SetVersion( sal_uIntPtr nVersionP ) { nVersion = nVersionP; }
103 5301 : sal_uIntPtr GetVersion() const { return nVersion; }
104 : OUString GetSuffixes() const;
105 : OUString GetDefaultExtension() const;
106 9257 : const OUString& GetServiceName() const { return aServiceName; }
107 2491 : const OUString& GetProviderName() const { return maProvider;}
108 :
109 : static const SfxFilter* GetDefaultFilter( const OUString& rName );
110 : static const SfxFilter* GetFilterByName( const OUString& rName );
111 : static const SfxFilter* GetDefaultFilterFromFactory( const OUString& rServiceName );
112 :
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 );
120 : };
121 :
122 : #endif
123 :
124 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|