LibreOffice Module unotools (master) 1
compatibility.hxx
Go to the documentation of this file.
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_UNOTOOLS_COMPATIBILITY_HXX
20#define INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
21
22#include <com/sun/star/uno/Any.hxx>
23#include <unotools/options.hxx>
25#include <rtl/ustring.hxx>
26#include <memory>
27#include <vector>
28
29namespace osl { class Mutex; }
30
31/*-************************************************************************************************************
32 @descr Struct to hold information about one compatibility entry
33*//*-*************************************************************************************************************/
35{
36 public:
37 /*-************************************************************************************************************
38 @descr The method SvtCompatibilityOptions::GetList() returns a list of property values.
39 Use follow enum class to separate values by names.
40 Sync it with sPropertyName in SvtCompatibilityEntry::getName()
41 *//*-*************************************************************************************************************/
42 enum class Index
43 {
44 /* Should be in the start. Do not remove it. */
45 Name,
46 Module,
47
48 /* Editable list of compatibility options. */
49 AddSpacing,
50 AddSpacingAtPages,
51 UseOurTabStops,
52 NoExtLeading,
53 UseLineSpacing,
54 AddTableSpacing,
55 UseObjectPositioning,
56 UseOurTextWrapping,
57 ConsiderWrappingStyle,
58 ExpandWordSpace,
59 ProtectForm,
60 MsWordTrailingBlanks,
61 SubtractFlysAnchoredAtFlys,
62 EmptyDbFieldHidesPara,
63 UseVariableWidthNBSP,
64
68 AddTableLineSpacing,
69
70 /* Should be at the end. Do not remove it. */
72 };
73
75
76 static OUString getName( const Index rIdx );
77
78 static constexpr OUStringLiteral USER_ENTRY_NAME = u"_user";
79 static constexpr OUStringLiteral DEFAULT_ENTRY_NAME = u"_default";
80
81 static size_t getElementCount()
82 {
83 return static_cast<size_t>(Index::INVALID);
84 }
85
86 css::uno::Any getValue( const Index rIdx ) const
87 {
88 if ( static_cast<size_t>(rIdx) < getElementCount() )
89 {
90 return m_aPropertyValue[ static_cast<int>(rIdx) ];
91 } else
92 {
93 /* Wrong index. */
94 assert( false );
95 return css::uno::Any();
96 }
97 }
98
99 template<typename T>
100 T getValue( const Index rIdx ) const
101 {
102 T aValue = T();
103
104 if ( static_cast<size_t>(rIdx) < getElementCount() )
105 {
106 m_aPropertyValue[ static_cast<int>(rIdx) ] >>= aValue;
107 } else
108 {
109 /* Wrong index. */
110 assert( false );
111 }
112
113 return aValue;
114 }
115
116 void setValue( const Index rIdx, css::uno::Any const & rValue )
117 {
118 if ( static_cast<size_t>(rIdx) < getElementCount() )
119 {
120 m_aPropertyValue[ static_cast<int>(rIdx) ] = rValue;
121 } else
122 {
123 /* Wrong index. */
124 assert( false );
125 }
126 }
127
128 template<typename T>
129 void setValue( const Index rIdx, T rValue )
130 {
131 setValue(rIdx, css::uno::Any(rValue));
132 }
133
134 private:
135 std::vector<css::uno::Any> m_aPropertyValue;
136};
137
138/*-************************************************************************************************************
139 @short forward declaration to our private date container implementation
140 @descr We use these class as internal member to support small memory requirements.
141 You can create the container if it is necessary. The class which use these mechanism
142 is faster and smaller then a complete implementation!
143*//*-*************************************************************************************************************/
145
146/*-************************************************************************************************************
147 @short collect information about dynamic menus
148 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
149 @devstatus ready to use
150*//*-*************************************************************************************************************/
152{
153 public:
155 virtual ~SvtCompatibilityOptions() override;
156
157 /*-****************************************************************************************************
158 @short append a new item
159 @descr
160
161 @seealso method Clear()
162
163 @param "aItem" SvtCompatibilityEntry
164 *//*-*****************************************************************************************************/
165 void AppendItem( const SvtCompatibilityEntry& aItem );
166
167 /*-****************************************************************************************************
168 @short clear complete specified list
169 @descr Call this methods to clear the whole list.
170 *//*-*****************************************************************************************************/
171 void Clear();
172
173 void SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue );
174 bool GetDefault( SvtCompatibilityEntry::Index rIdx ) const;
175
176 /*-****************************************************************************************************
177 @short return complete specified list
178 @descr Call it to get all entries of compatibility options.
179 We return a list of all nodes with its names and properties.
180 @return A list of compatibility options is returned.
181
182 @onerror We return an empty list.
183 *//*-*****************************************************************************************************/
184 std::vector< SvtCompatibilityEntry > GetList() const;
185
186 private:
187 std::shared_ptr<SvtCompatibilityOptions_Impl> m_pImpl;
188
189 /*-****************************************************************************************************
190 @short return a reference to a static mutex
191 @descr These class is partially threadsafe (for de-/initialization only).
192 All access methods aren't safe!
193 We create a static mutex only for one ime and use at different times.
194 @return A reference to a static mutex member.
195 *//*-*****************************************************************************************************/
196 UNOTOOLS_DLLPRIVATE static osl::Mutex& GetOwnStaticMutex();
197};
198
199#endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
static constexpr OUStringLiteral DEFAULT_ENTRY_NAME
static OUString getName(const Index rIdx)
css::uno::Any getValue(const Index rIdx) const
T getValue(const Index rIdx) const
static constexpr OUStringLiteral USER_ENTRY_NAME
void setValue(const Index rIdx, T rValue)
static size_t getElementCount()
void setValue(const Index rIdx, css::uno::Any const &rValue)
std::vector< css::uno::Any > m_aPropertyValue
std::shared_ptr< SvtCompatibilityOptions_Impl > m_pImpl
float u
static std::mutex & GetOwnStaticMutex()
Definition: eventcfg.cxx:83
std::vector< HistoryItem > GetList(EHistoryType eHistory)
void AppendItem(EHistoryType eHistory, const OUString &sURL, const OUString &sFilter, const OUString &sTitle, const std::optional< OUString > &sThumbnail, ::std::optional< bool > const oIsReadOnly)
INVALID
OUString Name
#define UNOTOOLS_DLLPRIVATE
#define UNOTOOLS_DLLPUBLIC