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_FCONTNR_HXX 20 #define INCLUDED_SFX2_FCONTNR_HXX 21 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> 29 30 #include <memory> 31 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; } 36 37 class ErrCode; 38 class SfxFilter; 39 class SfxMedium; 40 class SfxFilterContainer_Impl; 41 42 43 class SFX2_DLLPUBLIC SfxFilterContainer 44 { 45 std::unique_ptr<SfxFilterContainer_Impl> pImpl; 46 47 public: 48 SfxFilterContainer( const OUString& rName ); 49 ~SfxFilterContainer(); 50 51 52 OUString const & GetName() const; 53 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; 58 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, 63 bool bUpdate ); 64 SAL_DLLPRIVATE static std::shared_ptr<const SfxFilter> GetDefaultFilter_Impl( const OUString& ); 65 }; 66 67 class SfxFilterMatcher_Impl; 68 69 class SFX2_DLLPUBLIC SfxFilterMatcher 70 { 71 friend class SfxFilterMatcherIter; 72 SfxFilterMatcher_Impl &m_rImpl; 73 public: 74 SfxFilterMatcher( const OUString& rFact ); 75 SfxFilterMatcher(); 76 ~SfxFilterMatcher(); 77 SfxFilterMatcher(const SfxFilterMatcher&) = delete; 78 SfxFilterMatcher& operator=( const SfxFilterMatcher& ) = delete; 79 80 SAL_DLLPRIVATE static bool IsFilterInstalled_Impl( const std::shared_ptr<const SfxFilter>& pFilter ); 81 DECL_DLLPRIVATE_LINK( MaybeFileHdl_Impl, OUString*, bool ); 82 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; 87 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; 96 }; 97 98 class SFX2_DLLPUBLIC SfxFilterMatcherIter 99 100 { 101 SfxFilterFlags nOrMask; 102 SfxFilterFlags const nAndMask; 103 sal_uInt16 nCurrent; 104 const SfxFilterMatcher_Impl &m_rMatch; 105 106 SAL_DLLPRIVATE std::shared_ptr<const SfxFilter> Find_Impl(); 107 108 public: 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(); 114 }; 115 116 117 #endif 118 119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 120