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_FCONTNR_HXX
20 #define INCLUDED_SFX2_FCONTNR_HXX
22 #include <sal/config.h>
23 #include <sfx2/dllapi.h>
24 #include <sal/types.h>
25 #include <rtl/ustring.hxx>
26 #include <tools/link.hxx>
27 #include <comphelper/documentconstants.hxx>
28 #include <sot/formats.hxx>
32 namespace com::sun::star::beans
{ struct NamedValue
; }
33 namespace com::sun::star::container
{ class XNameAccess
; }
34 namespace com::sun::star::uno
{ template <typename
> class Sequence
; }
35 namespace com::sun::star::uno
{ template <typename
> class Reference
; }
40 class SfxFilterContainer_Impl
;
43 class SFX2_DLLPUBLIC SfxFilterContainer
45 std::unique_ptr
<SfxFilterContainer_Impl
> pImpl
;
48 SfxFilterContainer( const OUString
& rName
);
49 ~SfxFilterContainer();
52 OUString
const & GetName() const;
54 std::shared_ptr
<const SfxFilter
> GetAnyFilter( SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
55 std::shared_ptr
<const SfxFilter
> GetFilter4EA( const OUString
& rEA
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
56 std::shared_ptr
<const SfxFilter
> GetFilter4Extension( const OUString
& rExt
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
57 std::shared_ptr
<const SfxFilter
> GetFilter4FilterName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
59 SAL_DLLPRIVATE
static void ReadFilters_Impl( bool bUpdate
=false );
60 SAL_DLLPRIVATE
static void ReadSingleFilter_Impl( const OUString
& rName
,
61 const css::uno::Reference
< css::container::XNameAccess
>& xTypeCFG
,
62 const css::uno::Reference
< css::container::XNameAccess
>& xFilterCFG
,
64 SAL_DLLPRIVATE
static std::shared_ptr
<const SfxFilter
> GetDefaultFilter_Impl( const OUString
& );
67 class SfxFilterMatcher_Impl
;
69 class SFX2_DLLPUBLIC SfxFilterMatcher
71 friend class SfxFilterMatcherIter
;
72 SfxFilterMatcher_Impl
&m_rImpl
;
74 SfxFilterMatcher( const OUString
& rFact
);
77 SfxFilterMatcher(const SfxFilterMatcher
&) = delete;
78 SfxFilterMatcher
& operator=( const SfxFilterMatcher
& ) = delete;
80 SAL_DLLPRIVATE
static bool IsFilterInstalled_Impl( const std::shared_ptr
<const SfxFilter
>& pFilter
);
81 DECL_DLLPRIVATE_LINK( MaybeFileHdl_Impl
, OUString
*, bool );
83 ErrCode
GuessFilterIgnoringContent( SfxMedium
const & rMedium
, std::shared_ptr
<const SfxFilter
>& ) const;
84 ErrCode
GuessFilter( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>& , SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
85 ErrCode
GuessFilterControlDefaultUI( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>&, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
86 ErrCode
DetectFilter( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>& ) const;
88 std::shared_ptr
<const SfxFilter
> GetFilter4Mime( const OUString
& rMime
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
89 std::shared_ptr
<const SfxFilter
> GetFilter4ClipBoardId( SotClipboardFormatId nId
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
90 std::shared_ptr
<const SfxFilter
> GetFilter4EA( const OUString
& rEA
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
91 std::shared_ptr
<const SfxFilter
> GetFilter4Extension( const OUString
& rExt
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
92 std::shared_ptr
<const SfxFilter
> GetFilter4FilterName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
93 std::shared_ptr
<const SfxFilter
> GetFilter4UIName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
94 std::shared_ptr
<const SfxFilter
> GetFilterForProps( const css::uno::Sequence
< css::beans::NamedValue
>& aSeq
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
95 std::shared_ptr
<const SfxFilter
> GetAnyFilter( SfxFilterFlags nMustg
=SfxFilterFlags::NONE
, SfxFilterFlags nDont
=SFX_FILTER_NOTINSTALLED
) const;
98 class SFX2_DLLPUBLIC SfxFilterMatcherIter
101 SfxFilterFlags nOrMask
;
102 SfxFilterFlags
const nAndMask
;
104 const SfxFilterMatcher_Impl
&m_rMatch
;
106 SAL_DLLPRIVATE
std::shared_ptr
<const SfxFilter
> Find_Impl();
109 SfxFilterMatcherIter( const SfxFilterMatcher
& rMatcher
, SfxFilterFlags nMask
= SfxFilterFlags::NONE
, SfxFilterFlags nNotMask
= SFX_FILTER_NOTINSTALLED
);
110 SfxFilterMatcherIter(const SfxFilterMatcherIter
&) = delete;
111 SfxFilterMatcherIter
& operator=( const SfxFilterMatcherIter
& ) = delete;
112 std::shared_ptr
<const SfxFilter
> First();
113 std::shared_ptr
<const SfxFilter
> Next();
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */