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_UNOTOOLS_COMPATIBILITY_HXX
20 #define INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
22 #include <com/sun/star/uno/Any.hxx>
23 #include <unotools/options.hxx>
24 #include <unotools/unotoolsdllapi.h>
25 #include <rtl/ustring.hxx>
29 namespace osl
{ class Mutex
; }
31 /*-************************************************************************************************************
32 @descr Struct to hold information about one compatibility entry
33 *//*-*************************************************************************************************************/
34 class SvtCompatibilityEntry
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 *//*-*************************************************************************************************************/
44 /* Should be in the start. Do not remove it. */
48 /* Editable list of compatibility options. */
57 ConsiderWrappingStyle
,
61 SubtractFlysAnchoredAtFlys
,
62 EmptyDbFieldHidesPara
,
64 /// special entry: optcomp.cxx converts the other values to
65 /// integers but not this one because it doesn't have its own
66 /// checkbox, so keep it at the end!
69 /* Should be at the end. Do not remove it. */
73 SvtCompatibilityEntry();
75 static OUString
getName( const Index rIdx
);
77 static constexpr OUStringLiteral USER_ENTRY_NAME
= u
"_user";
78 static constexpr OUStringLiteral DEFAULT_ENTRY_NAME
= u
"_default";
80 static size_t getElementCount()
82 return static_cast<size_t>(Index::INVALID
);
85 css::uno::Any
getValue( const Index rIdx
) const
87 if ( static_cast<size_t>(rIdx
) < getElementCount() )
89 return m_aPropertyValue
[ static_cast<int>(rIdx
) ];
94 return css::uno::Any();
99 T
getValue( const Index rIdx
) const
103 if ( static_cast<size_t>(rIdx
) < getElementCount() )
105 m_aPropertyValue
[ static_cast<int>(rIdx
) ] >>= aValue
;
115 void setValue( const Index rIdx
, css::uno::Any
const & rValue
)
117 if ( static_cast<size_t>(rIdx
) < getElementCount() )
119 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = rValue
;
128 void setValue( const Index rIdx
, T rValue
)
130 setValue(rIdx
, css::uno::Any(rValue
));
134 std::vector
<css::uno::Any
> m_aPropertyValue
;
137 /*-************************************************************************************************************
138 @short forward declaration to our private date container implementation
139 @descr We use these class as internal member to support small memory requirements.
140 You can create the container if it is necessary. The class which use these mechanism
141 is faster and smaller then a complete implementation!
142 *//*-*************************************************************************************************************/
143 class SvtCompatibilityOptions_Impl
;
145 /*-************************************************************************************************************
146 @short collect information about dynamic menus
147 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
148 @devstatus ready to use
149 *//*-*************************************************************************************************************/
150 class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final
: public utl::detail::Options
153 SvtCompatibilityOptions();
154 virtual ~SvtCompatibilityOptions() override
;
156 /*-****************************************************************************************************
157 @short append a new item
160 @seealso method Clear()
162 @param "aItem" SvtCompatibilityEntry
163 *//*-*****************************************************************************************************/
164 void AppendItem( const SvtCompatibilityEntry
& aItem
);
166 /*-****************************************************************************************************
167 @short clear complete specified list
168 @descr Call this methods to clear the whole list.
169 *//*-*****************************************************************************************************/
172 void SetDefault( SvtCompatibilityEntry::Index rIdx
, bool rValue
);
173 bool GetDefault( SvtCompatibilityEntry::Index rIdx
) const;
175 /*-****************************************************************************************************
176 @short return complete specified list
177 @descr Call it to get all entries of compatibility options.
178 We return a list of all nodes with its names and properties.
179 @return A list of compatibility options is returned.
181 @onerror We return an empty list.
182 *//*-*****************************************************************************************************/
183 std::vector
< SvtCompatibilityEntry
> GetList() const;
186 std::shared_ptr
<SvtCompatibilityOptions_Impl
> m_pImpl
;
188 /*-****************************************************************************************************
189 @short return a reference to a static mutex
190 @descr These class is partially threadsafe (for de-/initialization only).
191 All access methods aren't safe!
192 We create a static mutex only for one ime and use at different times.
193 @return A reference to a static mutex member.
194 *//*-*****************************************************************************************************/
195 UNOTOOLS_DLLPRIVATE
static osl::Mutex
& GetOwnStaticMutex();
198 #endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */