summaryrefslogtreecommitdiff
path: root/framework/inc/classes/filtercachedata.hxx
blob: 77a87d54c7704f471c51e737c721aa2a1dea42aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/* -*- 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_FRAMEWORK_INC_CLASSES_FILTERCACHEDATA_HXX
#define INCLUDED_FRAMEWORK_INC_CLASSES_FILTERCACHEDATA_HXX

#include <classes/wildcard.hxx>
#include <classes/converter.hxx>
#include <macros/xinterface.hxx>
#include <general.h>

#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/util/XChangesListener.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>

#include <unotools/configitem.hxx>
#include <cppuhelper/weak.hxx>
#include <rtl/ustring.hxx>

#include <iterator>
#include <unordered_map>
#include <vector>

namespace framework{

#define DEFAULT_FILTERCACHE_VERSION                 6                                                                   /// these implmentation of FilterCache support different version of TypeDetection.xml! This define the current set default one.

#define DEFAULT_FILTERCACHE_MODE                    ConfigItemMode::DelayedUpdate | ConfigItemMode::AllLocales                                          /// ConfigItems could run in different modes: supported values are ... { ConfigItemMode::ImmediateUpdate, ConfigItemMode::DelayedUpdate, ConfigItemMode::AllLocales }

enum EModifyState
{
    E_UNTOUCHED ,
    E_ADDED     ,
    E_CHANGED   ,
    E_REMOVED
};

enum EFilterPackage
{
    E_STANDARD  ,
    E_ADDITIONAL
};

// These struct define a type, which present the type of a file.
// He is used for easy filter detection without file stream detection!
// The internal name is the keyname of an item with these structure in our hash map or our configuration set!

struct FileType
{

    // public methods

    public:

        inline               FileType   (                               ) { impl_clear();               }
        inline               FileType   (   const   FileType&   rCopy   ) { impl_copy( rCopy );         }
        inline              ~FileType   (                               ) { impl_clear();               }
        inline FileType&    operator=   (   const   FileType&   rCopy   ) { return impl_copy( rCopy );  }

    private:

        inline void impl_clear()
        {
            bPreferred          = false;
            sName.clear();
            sMediaType.clear();
            sClipboardFormat.clear();
            nDocumentIconID     = 0;
            lUINames.clear();
            lURLPattern.clear();
            lExtensions.clear();
        }

        inline FileType& impl_copy( const FileType& rCopy )
        {
            bPreferred          = rCopy.bPreferred;
            sName               = rCopy.sName;
            lUINames            = rCopy.lUINames;
            sMediaType          = rCopy.sMediaType;
            sClipboardFormat    = rCopy.sClipboardFormat;
            nDocumentIconID     = rCopy.nDocumentIconID;
            lURLPattern         = rCopy.lURLPattern;
            lExtensions         = rCopy.lExtensions;
            return (*this);
        }

    // public member

    public:

        bool                bPreferred;
        OUString            sName;
        OUStringHashMap     lUINames;
        OUString            sMediaType;
        OUString            sClipboardFormat;
        sal_Int32           nDocumentIconID;
        std::vector<OUString> lURLPattern;
        std::vector<OUString> lExtensions;
};

// These struct describe a filter which is registered for one type.
// He hold information about services which present the document himself (like a item) and a filter service which
// filter a file in these document.
// The internal name is the keyname of an item with these structure in our hash map or our configuration set!

struct Filter
{

    // public methods

    public:

        inline           Filter     (                           ) { impl_clear();               }
        inline           Filter     (   const   Filter& rCopy   ) { impl_copy( rCopy );         }
        inline          ~Filter     (                           ) { impl_clear();               }
        inline Filter&  operator=   (   const   Filter& rCopy   ) { return impl_copy( rCopy );  }

    private:

        inline void impl_clear()
        {
            nOrder              = 0;
            sName.clear();
            sType.clear();
            sDocumentService.clear();
            sFilterService.clear();
            sUIComponent.clear();
            nFlags              = 0;
            nFileFormatVersion  = 0;
            sTemplateName.clear();
            lUINames.clear();
            lUserData.clear();
        }

        inline Filter& impl_copy( const Filter& rCopy )
        {
            nOrder              = rCopy.nOrder;
            sName               = rCopy.sName;
            sType               = rCopy.sType;
            lUINames            = rCopy.lUINames;
            sDocumentService    = rCopy.sDocumentService;
            sFilterService      = rCopy.sFilterService;
            sUIComponent        = rCopy.sUIComponent;
            nFlags              = rCopy.nFlags;
            nFileFormatVersion  = rCopy.nFileFormatVersion;
            sTemplateName       = rCopy.sTemplateName;
            lUserData           = rCopy.lUserData;
            return (*this);
        }

    // public member

    public:

        sal_Int32           nOrder;
        OUString     sName;
        OUString     sType;
        OUStringHashMap     lUINames;
        OUString     sDocumentService;
        OUString     sFilterService;
        OUString     sUIComponent;
        sal_Int32           nFlags;
        std::vector<OUString> lUserData;
        sal_Int32           nFileFormatVersion;
        OUString     sTemplateName;
};

// Programmer can register his own services for an content detection of different types.
// The implementation or service name of these is the keyname of an item with these structure
// in our hash map or our configuration set!

struct Detector
{

    // public methods

    public:

        inline               Detector   (                               ) { impl_clear();               }
        inline               Detector   (   const   Detector&   rCopy   ) { impl_copy( rCopy );         }
        inline              ~Detector   (                               ) { impl_clear();               }
        inline Detector&    operator=   (   const   Detector&   rCopy   ) { return impl_copy( rCopy );  }

    private:

        inline void impl_clear()
        {
            sName.clear();
            lTypes.clear();
        }

        inline Detector& impl_copy( const Detector& rCopy )
        {
            sName  = rCopy.sName;
            lTypes = rCopy.lTypes;
            return (*this);
        }

    // public member

    public:

        OUString     sName;
        std::vector<OUString> lTypes;
};

// Programmer can register his own services for loading documents in a frame.
// The implementation or service name of these is the keyname of an item with these structure
// in our hash map or our configuration set!

struct Loader
{

    // public methods

    public:

        inline           Loader     (                           ) { impl_clear();               }
        inline           Loader     (   const   Loader& rCopy   ) { impl_copy( rCopy );         }
        inline          ~Loader     (                           ) { impl_clear();               }
        inline Loader&  operator=   (   const   Loader& rCopy   ) { return impl_copy( rCopy );  }

    private:

        inline void impl_clear()
        {
            sName.clear();
            lUINames.clear();
            lTypes.clear();
        }

        inline Loader& impl_copy( const Loader& rCopy )
        {
            sName       = rCopy.sName;
            lUINames    = rCopy.lUINames;
            lTypes      = rCopy.lTypes;
            return (*this);
        }

    // public member

    public:

        OUString sName;
        OUStringHashMap lUINames;
        std::vector<OUString> lTypes;
};

// Programmer can register his own services to handle a FileType and intercept dispatches.
// Don't forget: It's not a FrameLoader - it's a ContentHandler! (normally without any UI)

struct ContentHandler
{

    // public methods

    public:

        inline                   ContentHandler(                              ) { impl_clear();               }
        inline                   ContentHandler( const ContentHandler& rCopy  ) { impl_copy( rCopy );         }
        inline                  ~ContentHandler(                              ) { impl_clear();               }
        inline ContentHandler&   operator=     ( const ContentHandler& rCopy  ) { return impl_copy( rCopy );  }

    private:

        inline void impl_clear()
        {
            sName.clear();
            lTypes.clear();
        }

        inline ContentHandler& impl_copy( const ContentHandler& rCopy )
        {
            sName  = rCopy.sName;
            lTypes = rCopy.lTypes;
            return (*this);
        }

    // public member

    public:

        OUString     sName;
        std::vector<OUString> lTypes;
};

// We need different hash maps for different tables of our configuration management.
// Follow maps convert <names> to <properties> of type, filter, detector, loader ...
// and could be used in a generic way

template< class HashType >
class SetNodeHash : public std::unordered_map< OUString                    ,
                                               HashType                           ,
                                               OUStringHash >
{
};

// Use these hashes to implement different tables which assign types to frame loader or detect services.
// It's an optimism to find registered services faster!
// The preferred hash maps file extensions to preferred types to find these ones faster.

class PerformanceHash   :   public  std::unordered_map< OUString,
                                                        std::vector<OUString>,
                                                        OUStringHash >
{
};


}       //  namespace framework

#endif // INCLUDED_FRAMEWORK_INC_CLASSES_FILTERCACHEDATA_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */