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 _COMPHELPER_MIMECONFIGHELPER_HXX_
21 #define _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 namespace comphelper
{
37 class COMPHELPER_DLLPUBLIC MimeConfigurationHelper
39 ::osl::Mutex m_aMutex
;
40 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
41 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xConfigProvider
;
43 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xObjectConfig
;
44 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xVerbsConfig
;
45 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xMediaTypeConfig
;
47 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> m_xFilterFactory
;
51 MimeConfigurationHelper( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& rxContext
);
54 static OUString
GetStringClassIDRepresentation( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID
);
56 static ::com::sun::star::uno::Sequence
< sal_Int8
> GetSequenceClassIDRepresentation( const OUString
& aClassID
);
59 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>
60 GetConfigurationByPath( const OUString
& aPath
);
62 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> GetObjConfiguration();
64 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> GetVerbsConfiguration();
65 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> GetMediaTypeConfiguration();
68 OUString
GetDocServiceNameFromFilter( const OUString
& aFilterName
);
70 OUString
GetDocServiceNameFromMediaType( const OUString
& aMediaType
);
72 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjPropsFromConfigEntry(
73 const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID
,
74 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
>& xObjectProps
);
76 sal_Bool
GetVerbByShortcut( const OUString
& aVerbShortcut
,
77 ::com::sun::star::embed::VerbDescriptor
& aDescriptor
);
79 OUString
GetExplicitlyRegisteredObjClassID( const OUString
& aMediaType
);
82 // retrieving object description from configuration
83 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjectPropsByStringClassID(
84 const OUString
& aStringClassID
);
86 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjectPropsByClassID(
87 const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID
);
89 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjectPropsByMediaType(
90 const OUString
& aMediaType
);
92 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjectPropsByFilter(
93 const OUString
& aFilterName
);
95 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
> GetObjectPropsByDocumentName(
96 const OUString
& aDocumentName
);
98 // retrieving object factory from configuration
99 OUString
GetFactoryNameByStringClassID( const OUString
& aStringClassID
);
100 OUString
GetFactoryNameByClassID( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID
);
101 OUString
GetFactoryNameByDocumentName( const OUString
& aDocName
);
102 OUString
GetFactoryNameByMediaType( const OUString
& aMediaType
);
104 // typedetection related
105 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XNameAccess
> GetFilterFactory();
107 OUString
UpdateMediaDescriptorWithFilterName(
108 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aMediaDescr
,
109 sal_Bool bIgnoreType
);
110 OUString
UpdateMediaDescriptorWithFilterName(
111 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aMediaDescr
,
112 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& aObject
);
114 sal_Int32
GetFilterFlags( const OUString
& aFilterName
);
116 sal_Bool
AddFilterNameCheckOwnFile(
117 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aMediaDescr
);
120 OUString
GetDefaultFilterFromServiceName( const OUString
& aServName
, sal_Int32 nVersion
);
122 OUString
GetExportFilterFromImportFilter( const OUString
& aImportFilterName
);
124 static ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
> SearchForFilter(
125 const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerQuery
>& xFilterQuery
,
126 const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::NamedValue
>& aSearchRequest
,
127 sal_Int32 nMustFlags
,
128 sal_Int32 nDontFlags
);
130 static sal_Bool
ClassIDsEqual( const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID1
,
131 const ::com::sun::star::uno::Sequence
< sal_Int8
>& aClassID2
);
132 static ::com::sun::star::uno::Sequence
< sal_Int8
> GetSequenceClassID( sal_uInt32 n1
, sal_uInt16 n2
, sal_uInt16 n3
,
133 sal_uInt8 b8
, sal_uInt8 b9
, sal_uInt8 b10
, sal_uInt8 b11
,
134 sal_uInt8 b12
, sal_uInt8 b13
, sal_uInt8 b14
, sal_uInt8 b15
);
139 #endif // _COMPHELPER_MIMECONFIGHELPER_HXX_
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */