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 <com/sun/star/uno/Sequence.hxx>
26 #include <com/sun/star/beans/NamedValue.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <svl/poolitem.hxx>
29 #include <vcl/window.hxx>
31 #include <sfx2/docfilt.hxx>
33 #include <tools/ref.hxx>
36 namespace vcl
{ class Window
; }
38 class SfxObjectFactory
;
40 class SfxFilterContainer_Impl
;
44 typedef sal_uIntPtr (*SfxDetectFilter
)( SfxMedium
& rMedium
, const SfxFilter
**, SfxFilterFlags nMust
, SfxFilterFlags nDont
);
46 class SFX2_DLLPUBLIC SfxFilterContainer
48 std::unique_ptr
<SfxFilterContainer_Impl
> pImpl
;
51 SfxFilterContainer( const OUString
& rName
);
52 ~SfxFilterContainer();
55 const OUString
GetName() const;
57 std::shared_ptr
<const SfxFilter
> GetAnyFilter( SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
58 std::shared_ptr
<const SfxFilter
> GetFilter4EA( const OUString
& rEA
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
59 std::shared_ptr
<const SfxFilter
> GetFilter4Extension( const OUString
& rExt
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
60 std::shared_ptr
<const SfxFilter
> GetFilter4FilterName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
62 SAL_DLLPRIVATE
static void ReadFilters_Impl( bool bUpdate
=false );
63 SAL_DLLPRIVATE
static void ReadSingleFilter_Impl( const OUString
& rName
,
64 const css::uno::Reference
< css::container::XNameAccess
>& xTypeCFG
,
65 const css::uno::Reference
< css::container::XNameAccess
>& xFilterCFG
,
67 SAL_DLLPRIVATE
static std::shared_ptr
<const SfxFilter
> GetDefaultFilter_Impl( const OUString
& );
70 class SfxFilterMatcher_Impl
;
72 class SFX2_DLLPUBLIC SfxFilterMatcher
74 friend class SfxFilterMatcherIter
;
75 SfxFilterMatcher_Impl
&m_rImpl
;
77 SfxFilterMatcher( const OUString
& rFact
);
80 SfxFilterMatcher(const SfxFilterMatcher
&) = delete;
81 SfxFilterMatcher
& operator=( const SfxFilterMatcher
& ) = delete;
83 SAL_DLLPRIVATE
static bool IsFilterInstalled_Impl( const std::shared_ptr
<const SfxFilter
>& pFilter
);
84 DECL_DLLPRIVATE_LINK_TYPED( MaybeFileHdl_Impl
, OUString
*, bool );
86 sal_uInt32
GuessFilterIgnoringContent( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>& ) const;
87 sal_uInt32
GuessFilter( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>& , SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
88 sal_uInt32
GuessFilterControlDefaultUI( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>&, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
89 sal_uInt32
DetectFilter( SfxMedium
& rMedium
, std::shared_ptr
<const SfxFilter
>& ) const;
91 std::shared_ptr
<const SfxFilter
> GetFilter4Mime( const OUString
& rMime
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
92 std::shared_ptr
<const SfxFilter
> GetFilter4ClipBoardId( SotClipboardFormatId nId
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
93 std::shared_ptr
<const SfxFilter
> GetFilter4EA( const OUString
& rEA
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
94 std::shared_ptr
<const SfxFilter
> GetFilter4Extension( const OUString
& rExt
, SfxFilterFlags nMust
= SfxFilterFlags::IMPORT
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
95 std::shared_ptr
<const SfxFilter
> GetFilter4FilterName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
96 std::shared_ptr
<const SfxFilter
> GetFilter4UIName( const OUString
& rName
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
97 std::shared_ptr
<const SfxFilter
> GetFilterForProps( const css::uno::Sequence
< css::beans::NamedValue
>& aSeq
, SfxFilterFlags nMust
= SfxFilterFlags::NONE
, SfxFilterFlags nDont
= SFX_FILTER_NOTINSTALLED
) const;
98 std::shared_ptr
<const SfxFilter
> GetAnyFilter( SfxFilterFlags nMust
=SfxFilterFlags::NONE
, SfxFilterFlags nDont
=SFX_FILTER_NOTINSTALLED
) const;
101 class SfxFilterContainer_Impl
;
102 class SFX2_DLLPUBLIC SfxFilterMatcherIter
105 SfxFilterFlags nOrMask
;
106 SfxFilterFlags nAndMask
;
108 const SfxFilterMatcher_Impl
&m_rMatch
;
110 SAL_DLLPRIVATE
std::shared_ptr
<const SfxFilter
> Find_Impl();
113 SfxFilterMatcherIter( const SfxFilterMatcher
& rMatcher
, SfxFilterFlags nMask
= SfxFilterFlags::NONE
, SfxFilterFlags nNotMask
= SFX_FILTER_NOTINSTALLED
);
114 SfxFilterMatcherIter(const SfxFilterMatcherIter
&) = delete;
115 SfxFilterMatcherIter
& operator=( const SfxFilterMatcherIter
& ) = delete;
116 std::shared_ptr
<const SfxFilter
> First();
117 std::shared_ptr
<const SfxFilter
> Next();
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */