1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_SFX2_SIDEBAR_ENUMCONTEXT_HXX
20 #define INCLUDED_SFX2_SIDEBAR_ENUMCONTEXT_HXX
22 #include <sfx2/dllapi.h>
24 #include <rtl/ustring.hxx>
29 namespace sfx2
{ namespace sidebar
{
31 class SFX2_DLLPUBLIC EnumContext
37 Application_WriterGlobal
,
38 Application_WriterWeb
,
39 Application_WriterXML
,
40 Application_WriterForm
,
41 Application_WriterReport
,
46 // For your convenience to avoid duplicate code in the common
47 // case that Draw and Impress use identical context configurations.
48 Application_DrawImpress
,
50 // Also for your convenience for the different variants of Writer documents.
51 Application_WriterVariants
,
53 // Used only by deck or panel descriptors. Matches any
57 // Use this only in special circumstances. One might be the
58 // wish to disable a deck or panel during debugging.
61 __LastApplicationEnum
= Application_None
85 Context_SlidesorterPage
,
90 // Default context of an application. Do we need this?
93 // Used only by deck or panel descriptors. Matches any context.
96 // Special context name that is only used when a deck would
97 // otherwise be empty.
102 __LastContextEnum
= Context_Unknown
107 const Application eApplication
,
108 const Context eContext
);
110 const ::rtl::OUString
& rsApplicationName
,
111 const ::rtl::OUString
& rsContextName
);
113 /** This variant of the GetCombinedContext() method treats some
114 application names as identical to each other. Replacements
116 Draw or Impress -> DrawImpress
117 Writer or WriterWeb -> WriterAndWeb
118 Use the Application_DrawImpress or Application_WriterAndWeb values in the CombinedEnumContext macro.
120 sal_Int32
GetCombinedContext_DI(void) const;
122 const ::rtl::OUString
& GetApplicationName (void) const;
123 Application
GetApplication_DI (void) const;
125 const ::rtl::OUString
& GetContextName (void) const;
126 Context
GetContext (void) const;
128 bool operator == (const EnumContext aOther
);
129 bool operator != (const EnumContext aOther
);
131 /** When two contexts are matched against each other then
132 application or context name may have the wildcard value 'any'.
133 In order to prefer matches without wildcards over matches with
134 wildcards we introduce a integer evaluation for matches.
136 const static sal_Int32 NoMatch
;
137 const static sal_Int32 OptimalMatch
;
139 /** Return the numeric value that describes how good the match
140 between two contexts is.
141 Smaller values represent better matches.
143 sal_Int32
EvaluateMatch (const EnumContext
& rOther
) const;
145 /** Return the best match against the given list of contexts.
147 sal_Int32
EvaluateMatch (const ::std::vector
<EnumContext
>& rOthers
) const;
149 static Application
GetApplicationEnum (const ::rtl::OUString
& rsApplicationName
);
150 static const ::rtl::OUString
& GetApplicationName (const Application eApplication
);
152 static Context
GetContextEnum (const ::rtl::OUString
& rsContextName
);
153 static const ::rtl::OUString
& GetContextName (const Context eContext
);
156 Application meApplication
;
159 static void ProvideApplicationContainers (void);
160 static void ProvideContextContainers (void);
161 static void AddEntry (const ::rtl::OUString
& rsName
, const Application eApplication
);
162 static void AddEntry (const ::rtl::OUString
& rsName
, const Context eContext
);
166 #define CombinedEnumContext(a,e) ((static_cast<sal_uInt16>(::sfx2::sidebar::EnumContext::a)<<16)\
167 | static_cast<sal_uInt16>(::sfx2::sidebar::EnumContext::e))
169 } } // end of namespace sfx2::sidebar
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */