xref: /core/include/vcl/EnumContext.hxx (revision 1160d5b29a9cdae5ec6126663e888b8e5c76aba4)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_VCL_ENUMCONTEXT_HXX
20 #define INCLUDED_VCL_ENUMCONTEXT_HXX
21 
22 #include <vcl/dllapi.h>
23 
24 #include <rtl/ustring.hxx>
25 
26 
27 namespace vcl {
28 
29 class VCL_DLLPUBLIC EnumContext
30 {
31 public:
32     enum class Application
33     {
34         Writer,
35         WriterGlobal,
36         WriterWeb,
37         WriterXML,
38         WriterForm,
39         WriterReport,
40         Calc,
41         Chart,
42         Draw,
43         Impress,
44         Formula,
45         Base,
46 
47         // For your convenience to avoid duplicate code in the common
48         // case that Draw and Impress use identical context configurations.
49         DrawImpress,
50 
51         // Also for your convenience for the different variants of Writer documents.
52         WriterVariants,
53 
54         // Used only by deck or panel descriptors.  Matches any
55         // application.
56         Any,
57 
58         // Use this only in special circumstances.  One might be the
59         // wish to disable a deck or panel during debugging.
60         NONE,
61 
62         LAST = Application::NONE
63     };
64     enum class Context
65     {
66         ThreeDObject,
67         Annotation,
68         Auditing,
69         Axis,
70         Cell,
71         Chart,
72         ChartLabel,
73         ChartLegend,
74         ChartTitle,
75         ChartElements,
76         Draw,
77         DrawFontwork,
78         DrawLine,
79         DrawPage,
80         DrawText,
81         EditCell,
82         ErrorBar,
83         Form,
84         Frame,
85         Graphic,
86         Grid,
87         HandoutPage,
88         MasterPage,
89         Math,
90         Media,
91         MultiObject,
92         NotesPage,
93         OLE,
94         OutlineText,
95         Pivot,
96         Printpreview,
97         Series,
98         SlidesorterPage,
99         Table,
100         Text,
101         TextObject,
102         Trendline,
103         Sparkline,
104 
105         // Default context of an application.  Do we need this?
106         Default,
107 
108         // Used only by deck or panel descriptors.  Matches any context.
109         Any,
110 
111         // Special context name that is only used when a deck would
112         // otherwise be empty.
113         Empty,
114 
115         Unknown,
116 
117         LAST = Unknown
118     };
119 
120     EnumContext();
121     EnumContext (
122         const Application eApplication,
123         const Context eContext);
124 
125     /** This variant of the GetCombinedContext() method treats some
126         application names as identical to each other.  Replacements
127         made are:
128             Draw or Impress     -> DrawImpress
129             Writer or WriterWeb -> WriterAndWeb
130         Use the Application::DrawImpress or Application::WriterAndWeb values in the CombinedEnumContext macro.
131     */
132     sal_Int32 GetCombinedContext_DI() const;
133 
134     Application GetApplication() const;
GetContext() const135     Context GetContext() const {return meContext;}
136 
137     SAL_DLLPRIVATE Application GetApplication_DI() const;
138 
139     bool operator == (const EnumContext& rOther) const;
140     bool operator != (const EnumContext& rOther) const;
141 
142     /** When two contexts are matched against each other, then
143         application or context name may have the wildcard value 'any'.
144         In order to prefer matches without wildcards over matches with
145         wildcards we introduce an integer evaluation for matches.
146     */
147     const static sal_Int32 NoMatch;
148 
149     static Application GetApplicationEnum (const OUString& rsApplicationName);
150     static const OUString& GetApplicationName (const Application eApplication);
151 
152     static Context GetContextEnum (const OUString& rsContextName);
153     static const OUString& GetContextName (const Context eContext);
154 
155 private:
156     Application meApplication;
157     Context meContext;
158 
159     SAL_DLLPRIVATE static void ProvideApplicationContainers();
160     SAL_DLLPRIVATE static void ProvideContextContainers();
161     SAL_DLLPRIVATE static void AddEntry (const OUString& rsName, const Application eApplication);
162     SAL_DLLPRIVATE static void AddEntry (const OUString& rsName, const Context eContext);
163 };
164 
165 
166 #define CombinedEnumContext(a,e) ((static_cast<sal_uInt16>(::vcl::EnumContext::a)<<16)\
167         | static_cast<sal_uInt16>(::vcl::EnumContext::e))
168 
169 } // end of namespace vcl
170 
171 #endif
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
174