diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /include/comphelper/mimeconfighelper.hxx | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/comphelper/mimeconfighelper.hxx')
-rw-r--r-- | include/comphelper/mimeconfighelper.hxx | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/include/comphelper/mimeconfighelper.hxx b/include/comphelper/mimeconfighelper.hxx new file mode 100644 index 000000000..5dd99664a --- /dev/null +++ b/include/comphelper/mimeconfighelper.hxx @@ -0,0 +1,142 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX +#define INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX + +#include <com/sun/star/uno/Reference.hxx> +#include <comphelper/comphelperdllapi.h> +#include <mutex> + +namespace com::sun::star::beans { struct NamedValue; } +namespace com::sun::star::beans { struct PropertyValue; } +namespace com::sun::star::container { class XContainerQuery; } +namespace com::sun::star::container { class XNameAccess; } +namespace com::sun::star::embed { struct VerbDescriptor; } +namespace com::sun::star::lang { class XMultiServiceFactory; } +namespace com::sun::star::uno { class XComponentContext; } + +enum class SfxFilterFlags; + +namespace comphelper { + +class COMPHELPER_DLLPUBLIC MimeConfigurationHelper +{ + std::mutex m_aMutex; + css::uno::Reference< css::uno::XComponentContext > m_xContext; + css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider; + + css::uno::Reference< css::container::XNameAccess > m_xObjectConfig; + css::uno::Reference< css::container::XNameAccess > m_xVerbsConfig; + css::uno::Reference< css::container::XNameAccess > m_xMediaTypeConfig; + + css::uno::Reference< css::container::XNameAccess > m_xFilterFactory; + +public: + + MimeConfigurationHelper( css::uno::Reference< css::uno::XComponentContext > xContext ); + + + static OUString GetStringClassIDRepresentation( const css::uno::Sequence< sal_Int8 >& aClassID ); + + static css::uno::Sequence< sal_Int8 > GetSequenceClassIDRepresentation( std::u16string_view aClassID ); + + + css::uno::Reference< css::container::XNameAccess > GetObjConfiguration(); + css::uno::Reference< css::container::XNameAccess > GetVerbsConfiguration(); + css::uno::Reference< css::container::XNameAccess > GetMediaTypeConfiguration(); + + + OUString GetDocServiceNameFromFilter( const OUString& aFilterName ); + + OUString GetDocServiceNameFromMediaType( const OUString& aMediaType ); + + css::uno::Sequence< css::beans::NamedValue > GetObjPropsFromConfigEntry( + const css::uno::Sequence< sal_Int8 >& aClassID, + const css::uno::Reference< css::container::XNameAccess >& xObjectProps ); + + bool GetVerbByShortcut( const OUString& aVerbShortcut, + css::embed::VerbDescriptor& aDescriptor ); + + OUString GetExplicitlyRegisteredObjClassID( const OUString& aMediaType ); + + + // retrieving object description from configuration + css::uno::Sequence< css::beans::NamedValue > GetObjectPropsByStringClassID( + const OUString& aStringClassID ); + + css::uno::Sequence< css::beans::NamedValue > GetObjectPropsByClassID( + const css::uno::Sequence< sal_Int8 >& aClassID ); + + css::uno::Sequence< css::beans::NamedValue > GetObjectPropsByMediaType( + const OUString& aMediaType ); + + css::uno::Sequence< css::beans::NamedValue > GetObjectPropsByFilter( + const OUString& aFilterName ); + + css::uno::Sequence< css::beans::NamedValue > GetObjectPropsByDocumentName( + std::u16string_view aDocumentName ); + + // retrieving object factory from configuration + OUString GetFactoryNameByStringClassID( const OUString& aStringClassID ); + OUString GetFactoryNameByClassID( const css::uno::Sequence< sal_Int8 >& aClassID ); + OUString GetFactoryNameByDocumentName( std::u16string_view aDocName ); + OUString GetFactoryNameByMediaType( const OUString& aMediaType ); + + // typedetection related + css::uno::Reference< css::container::XNameAccess > GetFilterFactory(); + + OUString UpdateMediaDescriptorWithFilterName( + css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr, + bool bIgnoreType ); + OUString UpdateMediaDescriptorWithFilterName( + css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr, + css::uno::Sequence< css::beans::NamedValue >& aObject ); +#ifdef _WIN32 + SfxFilterFlags GetFilterFlags( const OUString& aFilterName ); + + bool AddFilterNameCheckOwnFile( + css::uno::Sequence< css::beans::PropertyValue >& aMediaDescr ); +#endif + + OUString GetDefaultFilterFromServiceName( const OUString& aServName, sal_Int32 nVersion ); + + OUString GetExportFilterFromImportFilter( const OUString& aImportFilterName ); + + static css::uno::Sequence< css::beans::PropertyValue > SearchForFilter( + const css::uno::Reference< css::container::XContainerQuery >& xFilterQuery, + const css::uno::Sequence< css::beans::NamedValue >& aSearchRequest, + SfxFilterFlags nMustFlags, + SfxFilterFlags nDontFlags ); + + static bool ClassIDsEqual( const css::uno::Sequence< sal_Int8 >& aClassID1, + const css::uno::Sequence< sal_Int8 >& aClassID2 ); + static css::uno::Sequence< sal_Int8 > GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3, + sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11, + sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15 ); +private: + css::uno::Reference< css::container::XNameAccess > + GetConfigurationByPathImpl( const OUString& aPath ); +}; + +} + +#endif // INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |