xref: /AOO41X/main/svtools/source/filter/FilterConfigCache.hxx (revision 01aa44aa134af97080e2cf8e8bf3a0a4cd1cffe0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef _FILTER_CONFIG_CACHE_HXX_
26 #define _FILTER_CONFIG_CACHE_HXX_
27 
28 #include "svtools/svtdllapi.h"
29 #include <tools/string.hxx>
30 #include <com/sun/star/uno/Sequence.h>
31 #include <com/sun/star/uno/Reference.h>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/container/XNameAccess.hpp>
34 
35 #ifndef INCLUDED_VECTOR
36 #include <vector>
37 #define INCLUDED_VECTOR
38 #endif
39 
40 class SVT_DLLPUBLIC FilterConfigCache
41 {
42         struct FilterConfigCacheEntry
43         {
44             ::rtl::OUString sInternalFilterName;
45             ::rtl::OUString sType;
46             ::com::sun::star::uno::Sequence< ::rtl::OUString > lExtensionList;
47             ::rtl::OUString sUIName;
48             ::rtl::OUString sDocumentService;
49             ::rtl::OUString sFilterService;
50             ::rtl::OUString sTemplateName;
51 
52             ::rtl::OUString sMediaType;
53             ::rtl::OUString sFilterType;
54 
55             sal_Int32       nFlags;
56             sal_Int32       nFileFormatVersion;
57 
58             // user data
59             String          sFilterName;
60             sal_Bool        bHasDialog          : 1;
61             sal_Bool        bIsInternalFilter   : 1;
62             sal_Bool        bIsPixelFormat      : 1;
63 
64             sal_Bool        IsValid();
65             sal_Bool        CreateFilterName( const ::rtl::OUString& rUserDataEntry );
66             String          GetShortName( );
67 
68             static const char* InternalPixelFilterNameList[];
69             static const char* InternalVectorFilterNameList[];
70             static const char* ExternalPixelFilterNameList[];
71         };
72 
73         typedef std::vector< FilterConfigCacheEntry > CacheVector;
74 
75 
76         CacheVector         aImport;
77         CacheVector         aExport;
78         sal_Bool            bUseConfig;
79 
80         static sal_Bool   bInitialized;
81         static sal_Int32  nIndType;
82         static sal_Int32  nIndUIName;
83         static sal_Int32  nIndDocumentService;
84         static sal_Int32  nIndFilterService;
85         static sal_Int32  nIndFlags;
86         static sal_Int32  nIndUserData;
87         static sal_Int32  nIndFileFormatVersion;
88         static sal_Int32  nIndTemplateName;
89 
90         static const char*  InternalFilterListForSvxLight[];
91 
92         SVT_DLLPRIVATE void             ImplInit();
93         SVT_DLLPRIVATE void             ImplInitSmart();
94 
95     public :
96 
GetImportFormatCount() const97         sal_uInt16  GetImportFormatCount() const
98         { return sal::static_int_cast< sal_uInt16 >(aImport.size()); };
99         sal_uInt16  GetImportFormatNumber( const String& rFormatName );
100         sal_uInt16  GetImportFormatNumberForMediaType( const String& rMediaType );
101         sal_uInt16  GetImportFormatNumberForShortName( const String& rShortName );
102         sal_uInt16  GetImportFormatNumberForTypeName( const String& rType );
103         String      GetImportFilterName( sal_uInt16 nFormat );
104         String      GetImportFormatName( sal_uInt16 nFormat );
105         String      GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0);
106         String      GetImportFormatMediaType( sal_uInt16 nFormat );
107         String      GetImportFormatShortName( sal_uInt16 nFormat );
108         String      GetImportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
109         String      GetImportFilterType( sal_uInt16 nFormat );
110         String      GetImportFilterTypeName( sal_uInt16 nFormat );
111 
112         sal_Bool    IsImportInternalFilter( sal_uInt16 nFormat );
113         sal_Bool    IsImportPixelFormat( sal_uInt16 nFormat );
114         sal_Bool    IsImportDialog( sal_uInt16 nFormat );
115 
GetExportFormatCount() const116         sal_uInt16  GetExportFormatCount() const
117         { return sal::static_int_cast< sal_uInt16 >(aExport.size()); };
118         sal_uInt16  GetExportFormatNumber( const String& rFormatName );
119         sal_uInt16  GetExportFormatNumberForMediaType( const String& rMediaType );
120         sal_uInt16  GetExportFormatNumberForShortName( const String& rShortName );
121         sal_uInt16  GetExportFormatNumberForTypeName( const String& rType );
122         String      GetExportFilterName( sal_uInt16 nFormat );
123         String      GetExportFormatName( sal_uInt16 nFormat );
124         String      GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0 );
125         String      GetExportFormatMediaType( sal_uInt16 nFormat );
126         String      GetExportFormatShortName( sal_uInt16 nFormat );
127         String      GetExportWildcard( sal_uInt16 nFormat, sal_Int32 nEntry );
128         String      GetExportFilterTypeName( sal_uInt16 nFormat );
129         String      GetExportInternalFilterName( sal_uInt16 nFormat );
130 
131         sal_Bool    IsExportInternalFilter( sal_uInt16 nFormat );
132         sal_Bool    IsExportPixelFormat( sal_uInt16 nFormat );
133         sal_Bool    IsExportDialog( sal_uInt16 nFormat );
134 
135                     FilterConfigCache( sal_Bool bUseConfig );
136                     ~FilterConfigCache();
137 
138 };
139 
140 #endif  // _FILTER_CONFIG_CACHE_HXX_
141 
142