xref: /AOO41X/main/sfx2/source/sidebar/ContextMatcher.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1*7a32b0c8SAndre Fischer /**************************************************************
2*7a32b0c8SAndre Fischer  *
3*7a32b0c8SAndre Fischer  * Licensed to the Apache Software Foundation (ASF) under one
4*7a32b0c8SAndre Fischer  * or more contributor license agreements.  See the NOTICE file
5*7a32b0c8SAndre Fischer  * distributed with this work for additional information
6*7a32b0c8SAndre Fischer  * regarding copyright ownership.  The ASF licenses this file
7*7a32b0c8SAndre Fischer  * to you under the Apache License, Version 2.0 (the
8*7a32b0c8SAndre Fischer  * "License"); you may not use this file except in compliance
9*7a32b0c8SAndre Fischer  * with the License.  You may obtain a copy of the License at
10*7a32b0c8SAndre Fischer  *
11*7a32b0c8SAndre Fischer  *   http://www.apache.org/licenses/LICENSE-2.0
12*7a32b0c8SAndre Fischer  *
13*7a32b0c8SAndre Fischer  * Unless required by applicable law or agreed to in writing,
14*7a32b0c8SAndre Fischer  * software distributed under the License is distributed on an
15*7a32b0c8SAndre Fischer  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*7a32b0c8SAndre Fischer  * KIND, either express or implied.  See the License for the
17*7a32b0c8SAndre Fischer  * specific language governing permissions and limitations
18*7a32b0c8SAndre Fischer  * under the License.
19*7a32b0c8SAndre Fischer  *
20*7a32b0c8SAndre Fischer  *************************************************************/
21*7a32b0c8SAndre Fischer 
22*7a32b0c8SAndre Fischer #ifndef SFX_SIDEBAR_CONTEXT_MATCHER_HXX
23*7a32b0c8SAndre Fischer #define SFX_SIDEBAR_CONTEXT_MATCHER_HXX
24*7a32b0c8SAndre Fischer 
25*7a32b0c8SAndre Fischer #include <sal/types.h>
26*7a32b0c8SAndre Fischer #include <rtl/ustring.hxx>
27*7a32b0c8SAndre Fischer 
28*7a32b0c8SAndre Fischer #include <vector>
29*7a32b0c8SAndre Fischer 
30*7a32b0c8SAndre Fischer 
31*7a32b0c8SAndre Fischer namespace sfx2 { namespace sidebar {
32*7a32b0c8SAndre Fischer 
33*7a32b0c8SAndre Fischer class Context;
34*7a32b0c8SAndre Fischer 
35*7a32b0c8SAndre Fischer 
36*7a32b0c8SAndre Fischer /** Data read from the configuration for matching contexts.
37*7a32b0c8SAndre Fischer */
38*7a32b0c8SAndre Fischer class ContextMatcher
39*7a32b0c8SAndre Fischer {
40*7a32b0c8SAndre Fischer public:
41*7a32b0c8SAndre Fischer     ContextMatcher (void);
42*7a32b0c8SAndre Fischer     ~ContextMatcher (void);
43*7a32b0c8SAndre Fischer 
44*7a32b0c8SAndre Fischer     sal_Int32 EvaluateMatch (
45*7a32b0c8SAndre Fischer         const Context& rContext) const;
46*7a32b0c8SAndre Fischer 
47*7a32b0c8SAndre Fischer     void AddMatcher (
48*7a32b0c8SAndre Fischer         const ::rtl::OUString& rsApplicationName,
49*7a32b0c8SAndre Fischer         const ::std::vector<rtl::OUString>& rContextNames,
50*7a32b0c8SAndre Fischer         const bool mbIsContextListNegated);
51*7a32b0c8SAndre Fischer     void AddMatcher (
52*7a32b0c8SAndre Fischer         const ::rtl::OUString& rsApplicationName,
53*7a32b0c8SAndre Fischer         const ::rtl::OUString& rsContextName);
54*7a32b0c8SAndre Fischer 
55*7a32b0c8SAndre Fischer private:
56*7a32b0c8SAndre Fischer     class Entry
57*7a32b0c8SAndre Fischer     {
58*7a32b0c8SAndre Fischer     public:
59*7a32b0c8SAndre Fischer         ::rtl::OUString msApplicationName;
60*7a32b0c8SAndre Fischer         ::std::vector<rtl::OUString> maContextNames;
61*7a32b0c8SAndre Fischer         bool mbIsContextListNegated;
62*7a32b0c8SAndre Fischer     };
63*7a32b0c8SAndre Fischer     ::std::vector<Entry> maEntries;
64*7a32b0c8SAndre Fischer 
65*7a32b0c8SAndre Fischer     sal_Int32 EvaluateMatch (
66*7a32b0c8SAndre Fischer         const Context& rContext,
67*7a32b0c8SAndre Fischer         const Entry& rEntry) const;
68*7a32b0c8SAndre Fischer 
69*7a32b0c8SAndre Fischer };
70*7a32b0c8SAndre Fischer static bool IsMatchBetterThan (const sal_Int32 nMatchA, const sal_Int32 nMatchB);
71*7a32b0c8SAndre Fischer 
72*7a32b0c8SAndre Fischer 
73*7a32b0c8SAndre Fischer } } // end of namespace sfx2::sidebar
74*7a32b0c8SAndre Fischer 
75*7a32b0c8SAndre Fischer #endif
76