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>
29 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ struct PropertyValue
; } } } }
30 namespace osl
{ class Mutex
; }
32 /*-************************************************************************************************************
33 @descr Struct to hold information about one compatibility entry
34 *//*-*************************************************************************************************************/
35 class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
38 /*-************************************************************************************************************
39 @descr The method SvtCompatibilityOptions::GetList() returns a list of property values.
40 Use follow enum class to separate values by names.
41 Sync it with sPropertyName in SvtCompatibilityEntry::getName()
42 *//*-*************************************************************************************************************/
45 /* Should be in the start. Do not remove it. */
49 /* Editable list of compatibility options. */
59 ConsiderWrappingStyle
,
63 SubtractFlysAnchoredAtFlys
,
64 EmptyDbFieldHidesPara
,
65 /// special entry: optcomp.cxx converts the other values to
66 /// integers but not this one because it doesn't have its own
67 /// checkbox, so keep it at the end!
70 /* Should be at the end. Do not remove it. */
74 SvtCompatibilityEntry();
76 static OUString
getName( const Index rIdx
);
78 static OUString
getUserEntryName()
83 static OUString
getDefaultEntryName()
88 static Index
getIndex( const OUString
& rName
)
90 for ( int i
= static_cast<int>(Index::Name
); i
< static_cast<int>(Index::INVALID
); ++i
)
91 if ( getName( Index(i
) ) == rName
)
94 /* SvtCompatibilityEntry::getIndex() Undeclared compatibility property name */
97 return Index::INVALID
;
100 static size_t getElementCount()
102 return static_cast<size_t>(Index::INVALID
);
105 css::uno::Any
getValue( const Index rIdx
) const
107 if ( static_cast<size_t>(rIdx
) < getElementCount() )
109 return m_aPropertyValue
[ static_cast<int>(rIdx
) ];
114 return css::uno::Any();
119 T
getValue( const Index rIdx
) const
123 if ( static_cast<size_t>(rIdx
) < getElementCount() )
125 m_aPropertyValue
[ static_cast<int>(rIdx
) ] >>= aValue
;
135 void setValue( const Index rIdx
, css::uno::Any
const & rValue
)
137 if ( static_cast<size_t>(rIdx
) < getElementCount() )
139 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = rValue
;
148 void setValue( const Index rIdx
, T rValue
)
150 if ( static_cast<size_t>(rIdx
) < getElementCount() )
152 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = css::uno::Any(rValue
);
160 bool isDefaultEntry() const
162 return m_bDefaultEntry
;
165 void setDefaultEntry( bool rValue
)
167 m_bDefaultEntry
= rValue
;
171 std::vector
<css::uno::Any
> m_aPropertyValue
;
172 bool m_bDefaultEntry
;
175 /*-************************************************************************************************************
176 @short forward declaration to our private date container implementation
177 @descr We use these class as internal member to support small memory requirements.
178 You can create the container if it is necessary. The class which use these mechanism
179 is faster and smaller then a complete implementation!
180 *//*-*************************************************************************************************************/
181 class SvtCompatibilityOptions_Impl
;
183 /*-************************************************************************************************************
184 @short collect information about dynamic menus
185 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
186 @devstatus ready to use
187 *//*-*************************************************************************************************************/
188 class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final
: public utl::detail::Options
191 SvtCompatibilityOptions();
192 virtual ~SvtCompatibilityOptions() override
;
194 /*-****************************************************************************************************
195 @short append a new item
198 @seealso method Clear()
200 @param "aItem" SvtCompatibilityEntry
201 *//*-*****************************************************************************************************/
202 void AppendItem( const SvtCompatibilityEntry
& aItem
);
204 /*-****************************************************************************************************
205 @short clear complete specified list
206 @descr Call this methods to clear the whole list.
207 *//*-*****************************************************************************************************/
210 void SetDefault( SvtCompatibilityEntry::Index rIdx
, bool rValue
);
211 bool GetDefault( SvtCompatibilityEntry::Index rIdx
) const;
213 /*-****************************************************************************************************
214 @short return complete specified list
215 @descr Call it to get all entries of compatibility options.
216 We return a list of all nodes with its names and properties.
217 @return A list of compatibility options is returned.
219 @onerror We return an empty list.
220 *//*-*****************************************************************************************************/
221 css::uno::Sequence
< css::uno::Sequence
< css::beans::PropertyValue
> > GetList() const;
224 std::shared_ptr
<SvtCompatibilityOptions_Impl
> m_pImpl
;
226 /*-****************************************************************************************************
227 @short return a reference to a static mutex
228 @descr These class is partially threadsafe (for de-/initialization only).
229 All access methods aren't safe!
230 We create a static mutex only for one ime and use at different times.
231 @return A reference to a static mutex member.
232 *//*-*****************************************************************************************************/
233 UNOTOOLS_DLLPRIVATE
static osl::Mutex
& GetOwnStaticMutex();
236 #endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */