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