fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / include / sfx2 / sidebar / EnumContext.hxx
blobb24a8b274acbcc36b306abbfa1eead7ec931bd9f
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #ifndef SFX_SIDEBAR_ENUM_CONTEXT_HXX
19 #define SFX_SIDEBAR_ENUM_CONTEXT_HXX
21 #include "sfx2/dllapi.h"
23 #include <rtl/ustring.hxx>
25 #include <vector>
28 namespace sfx2 { namespace sidebar {
30 class SFX2_DLLPUBLIC EnumContext
32 public:
33 enum Application
35 Application_Writer,
36 Application_WriterGlobal,
37 Application_WriterWeb,
38 Application_WriterXML,
39 Application_WriterForm,
40 Application_WriterReport,
41 Application_Calc,
42 Application_Draw,
43 Application_Impress,
45 // For your convenience to avoid duplicate code in the common
46 // case that Draw and Impress use identical context configurations.
47 Application_DrawImpress,
49 // Also for your convenience for the different variants of Writer documents.
50 Application_WriterVariants,
52 // Used only by deck or panel descriptors. Matches any
53 // application.
54 Application_Any,
56 // Use this only in special circumstances. One might be the
57 // wish to disable a deck or panel during debugging.
58 Application_None,
60 __LastApplicationEnum = Application_None
62 enum Context
64 Context_3DObject,
65 Context_Annotation,
66 Context_Auditing,
67 Context_Cell,
68 Context_Chart,
69 Context_Draw,
70 Context_DrawPage,
71 Context_DrawText,
72 Context_EditCell,
73 Context_Form,
74 Context_Frame,
75 Context_Graphic,
76 Context_HandoutPage,
77 Context_MasterPage,
78 Context_Media,
79 Context_MultiObject,
80 Context_NotesPage,
81 Context_OLE,
82 Context_OutlineText,
83 Context_Pivot,
84 Context_SlidesorterPage,
85 Context_Table,
86 Context_Text,
87 Context_TextObject,
89 // Default context of an application. Do we need this?
90 Context_Default,
92 // Used only by deck or panel descriptors. Matches any context.
93 Context_Any,
95 // Special context name that is only used when a deck would
96 // otherwise be empty.
97 Context_Empty,
99 Context_Unknown,
101 __LastContextEnum = Context_Unknown
104 EnumContext (void);
105 EnumContext (
106 const Application eApplication,
107 const Context eContext);
108 EnumContext (
109 const ::rtl::OUString& rsApplicationName,
110 const ::rtl::OUString& rsContextName);
112 /** Return a number that encodes both the application and context
113 enums.
114 Use the CombinedEnumContext macro in switch() statements and comparisons.
116 sal_Int32 GetCombinedContext(void) const;
118 /** This variant of the GetCombinedContext() method treats some
119 application names as identical to each other. Replacements
120 made are:
121 Draw or Impress -> DrawImpress
122 Writer or WriterWeb -> WriterAndWeb
123 Use the Application_DrawImpress or Application_WriterAndWeb values in the CombinedEnumContext macro.
125 sal_Int32 GetCombinedContext_DI(void) const;
127 const ::rtl::OUString& GetApplicationName (void) const;
128 Application GetApplication (void) const;
129 Application GetApplication_DI (void) const;
131 const ::rtl::OUString& GetContextName (void) const;
132 Context GetContext (void) const;
134 bool operator == (const EnumContext aOther);
135 bool operator != (const EnumContext aOther);
137 /** When two contexts are matched against each other then
138 application or context name may have the wildcard value 'any'.
139 In order to prefer matches without wildcards over matches with
140 wildcards we introduce a integer evaluation for matches.
142 const static sal_Int32 NoMatch;
143 const static sal_Int32 OptimalMatch;
145 /** Return the numeric value that describes how good the match
146 between two contexts is.
147 Smaller values represent better matches.
149 sal_Int32 EvaluateMatch (const EnumContext& rOther) const;
151 /** Return the best match against the given list of contexts.
153 sal_Int32 EvaluateMatch (const ::std::vector<EnumContext>& rOthers) const;
155 static Application GetApplicationEnum (const ::rtl::OUString& rsApplicationName);
156 static const ::rtl::OUString& GetApplicationName (const Application eApplication);
158 static Context GetContextEnum (const ::rtl::OUString& rsContextName);
159 static const ::rtl::OUString& GetContextName (const Context eContext);
161 private:
162 Application meApplication;
163 Context meContext;
165 static void ProvideApplicationContainers (void);
166 static void ProvideContextContainers (void);
167 static void AddEntry (const ::rtl::OUString& rsName, const Application eApplication);
168 static void AddEntry (const ::rtl::OUString& rsName, const Context eContext);
172 #define CombinedEnumContext(a,e) ((static_cast<sal_uInt16>(::sfx2::sidebar::EnumContext::a)<<16)\
173 | static_cast<sal_uInt16>(::sfx2::sidebar::EnumContext::e))
175 } } // end of namespace sfx2::sidebar
177 #endif