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/Sequence.h>
23 #include <com/sun/star/uno/Any.hxx>
24 #include <unotools/options.hxx>
25 #include <unotools/unotoolsdllapi.h>
26 #include <rtl/ustring.hxx>
30 namespace com::sun::star::beans
{ struct PropertyValue
; }
31 namespace osl
{ class Mutex
; }
33 /*-************************************************************************************************************
34 @descr Struct to hold information about one compatibility entry
35 *//*-*************************************************************************************************************/
36 class SvtCompatibilityEntry
39 /*-************************************************************************************************************
40 @descr The method SvtCompatibilityOptions::GetList() returns a list of property values.
41 Use follow enum class to separate values by names.
42 Sync it with sPropertyName in SvtCompatibilityEntry::getName()
43 *//*-*************************************************************************************************************/
46 /* Should be in the start. Do not remove it. */
50 /* Editable list of compatibility options. */
60 ConsiderWrappingStyle
,
64 SubtractFlysAnchoredAtFlys
,
65 EmptyDbFieldHidesPara
,
66 /// special entry: optcomp.cxx converts the other values to
67 /// integers but not this one because it doesn't have its own
68 /// checkbox, so keep it at the end!
71 /* Should be at the end. Do not remove it. */
75 SvtCompatibilityEntry();
77 static OUString
getName( const Index rIdx
);
79 static constexpr OUStringLiteral USER_ENTRY_NAME
= u
"_user";
80 static constexpr OUStringLiteral DEFAULT_ENTRY_NAME
= u
"_default";
82 static size_t getElementCount()
84 return static_cast<size_t>(Index::INVALID
);
87 css::uno::Any
getValue( const Index rIdx
) const
89 if ( static_cast<size_t>(rIdx
) < getElementCount() )
91 return m_aPropertyValue
[ static_cast<int>(rIdx
) ];
96 return css::uno::Any();
101 T
getValue( const Index rIdx
) const
105 if ( static_cast<size_t>(rIdx
) < getElementCount() )
107 m_aPropertyValue
[ static_cast<int>(rIdx
) ] >>= aValue
;
117 void setValue( const Index rIdx
, css::uno::Any
const & rValue
)
119 if ( static_cast<size_t>(rIdx
) < getElementCount() )
121 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = rValue
;
130 void setValue( const Index rIdx
, T rValue
)
132 setValue(rIdx
, css::uno::Any(rValue
));
135 bool isDefaultEntry() const
137 return m_bDefaultEntry
;
140 void setDefaultEntry( bool rValue
)
142 m_bDefaultEntry
= rValue
;
146 std::vector
<css::uno::Any
> m_aPropertyValue
;
147 bool m_bDefaultEntry
;
150 /*-************************************************************************************************************
151 @short forward declaration to our private date container implementation
152 @descr We use these class as internal member to support small memory requirements.
153 You can create the container if it is necessary. The class which use these mechanism
154 is faster and smaller then a complete implementation!
155 *//*-*************************************************************************************************************/
156 class SvtCompatibilityOptions_Impl
;
158 /*-************************************************************************************************************
159 @short collect information about dynamic menus
160 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
161 @devstatus ready to use
162 *//*-*************************************************************************************************************/
163 class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final
: public utl::detail::Options
166 SvtCompatibilityOptions();
167 virtual ~SvtCompatibilityOptions() override
;
169 /*-****************************************************************************************************
170 @short append a new item
173 @seealso method Clear()
175 @param "aItem" SvtCompatibilityEntry
176 *//*-*****************************************************************************************************/
177 void AppendItem( const SvtCompatibilityEntry
& aItem
);
179 /*-****************************************************************************************************
180 @short clear complete specified list
181 @descr Call this methods to clear the whole list.
182 *//*-*****************************************************************************************************/
185 void SetDefault( SvtCompatibilityEntry::Index rIdx
, bool rValue
);
186 bool GetDefault( SvtCompatibilityEntry::Index rIdx
) const;
188 /*-****************************************************************************************************
189 @short return complete specified list
190 @descr Call it to get all entries of compatibility options.
191 We return a list of all nodes with its names and properties.
192 @return A list of compatibility options is returned.
194 @onerror We return an empty list.
195 *//*-*****************************************************************************************************/
196 std::vector
< SvtCompatibilityEntry
> GetList() const;
199 std::shared_ptr
<SvtCompatibilityOptions_Impl
> m_pImpl
;
201 /*-****************************************************************************************************
202 @short return a reference to a static mutex
203 @descr These class is partially threadsafe (for de-/initialization only).
204 All access methods aren't safe!
205 We create a static mutex only for one ime and use at different times.
206 @return A reference to a static mutex member.
207 *//*-*****************************************************************************************************/
208 UNOTOOLS_DLLPRIVATE
static osl::Mutex
& GetOwnStaticMutex();
211 #endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */