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 .
20 #ifndef INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX
21 #define INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <com/sun/star/uno/Sequence.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/container/XNameAccess.hpp>
28 #include <com/sun/star/container/XContainerQuery.hpp>
29 #include <com/sun/star/beans/NamedValue.hpp>
30 #include <com/sun/star/beans/PropertyValue.hpp>
31 #include <com/sun/star/embed/VerbDescriptor.hpp>
32 #include <comphelper/comphelperdllapi.h>
35 enum class SfxFilterFlags
;
37 namespace comphelper
{
39 class COMPHELPER_DLLPUBLIC MimeConfigurationHelper
41 ::osl::Mutex m_aMutex
;
42 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
43 css::uno::Reference
< css::lang::XMultiServiceFactory
> m_xConfigProvider
;
45 css::uno::Reference
< css::container::XNameAccess
> m_xObjectConfig
;
46 css::uno::Reference
< css::container::XNameAccess
> m_xVerbsConfig
;
47 css::uno::Reference
< css::container::XNameAccess
> m_xMediaTypeConfig
;
49 css::uno::Reference
< css::container::XNameAccess
> m_xFilterFactory
;
53 MimeConfigurationHelper( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
56 static OUString
GetStringClassIDRepresentation( const css::uno::Sequence
< sal_Int8
>& aClassID
);
58 static css::uno::Sequence
< sal_Int8
> GetSequenceClassIDRepresentation( const OUString
& aClassID
);
61 css::uno::Reference
< css::container::XNameAccess
>
62 GetConfigurationByPath( const OUString
& aPath
);
64 css::uno::Reference
< css::container::XNameAccess
> GetObjConfiguration();
66 css::uno::Reference
< css::container::XNameAccess
> GetVerbsConfiguration();
67 css::uno::Reference
< css::container::XNameAccess
> GetMediaTypeConfiguration();
70 OUString
GetDocServiceNameFromFilter( const OUString
& aFilterName
);
72 OUString
GetDocServiceNameFromMediaType( const OUString
& aMediaType
);
74 css::uno::Sequence
< css::beans::NamedValue
> GetObjPropsFromConfigEntry(
75 const css::uno::Sequence
< sal_Int8
>& aClassID
,
76 const css::uno::Reference
< css::container::XNameAccess
>& xObjectProps
);
78 bool GetVerbByShortcut( const OUString
& aVerbShortcut
,
79 css::embed::VerbDescriptor
& aDescriptor
);
81 OUString
GetExplicitlyRegisteredObjClassID( const OUString
& aMediaType
);
84 // retrieving object description from configuration
85 css::uno::Sequence
< css::beans::NamedValue
> GetObjectPropsByStringClassID(
86 const OUString
& aStringClassID
);
88 css::uno::Sequence
< css::beans::NamedValue
> GetObjectPropsByClassID(
89 const css::uno::Sequence
< sal_Int8
>& aClassID
);
91 css::uno::Sequence
< css::beans::NamedValue
> GetObjectPropsByMediaType(
92 const OUString
& aMediaType
);
94 css::uno::Sequence
< css::beans::NamedValue
> GetObjectPropsByFilter(
95 const OUString
& aFilterName
);
97 css::uno::Sequence
< css::beans::NamedValue
> GetObjectPropsByDocumentName(
98 const OUString
& aDocumentName
);
100 // retrieving object factory from configuration
101 OUString
GetFactoryNameByStringClassID( const OUString
& aStringClassID
);
102 OUString
GetFactoryNameByClassID( const css::uno::Sequence
< sal_Int8
>& aClassID
);
103 OUString
GetFactoryNameByDocumentName( const OUString
& aDocName
);
104 OUString
GetFactoryNameByMediaType( const OUString
& aMediaType
);
106 // typedetection related
107 css::uno::Reference
< css::container::XNameAccess
> GetFilterFactory();
109 OUString
UpdateMediaDescriptorWithFilterName(
110 css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
,
112 OUString
UpdateMediaDescriptorWithFilterName(
113 css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
,
114 css::uno::Sequence
< css::beans::NamedValue
>& aObject
);
116 SfxFilterFlags
GetFilterFlags( const OUString
& aFilterName
);
118 bool AddFilterNameCheckOwnFile(
119 css::uno::Sequence
< css::beans::PropertyValue
>& aMediaDescr
);
122 OUString
GetDefaultFilterFromServiceName( const OUString
& aServName
, sal_Int32 nVersion
);
124 OUString
GetExportFilterFromImportFilter( const OUString
& aImportFilterName
);
126 static css::uno::Sequence
< css::beans::PropertyValue
> SearchForFilter(
127 const css::uno::Reference
< css::container::XContainerQuery
>& xFilterQuery
,
128 const css::uno::Sequence
< css::beans::NamedValue
>& aSearchRequest
,
129 SfxFilterFlags nMustFlags
,
130 SfxFilterFlags nDontFlags
);
132 static bool ClassIDsEqual( const css::uno::Sequence
< sal_Int8
>& aClassID1
,
133 const css::uno::Sequence
< sal_Int8
>& aClassID2
);
134 static css::uno::Sequence
< sal_Int8
> GetSequenceClassID( sal_uInt32 n1
, sal_uInt16 n2
, sal_uInt16 n3
,
135 sal_uInt8 b8
, sal_uInt8 b9
, sal_uInt8 b10
, sal_uInt8 b11
,
136 sal_uInt8 b12
, sal_uInt8 b13
, sal_uInt8 b14
, sal_uInt8 b15
);
141 #endif // INCLUDED_COMPHELPER_MIMECONFIGHELPER_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */