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
,
66 /* Should be at the end. Do not remove it. */
70 SvtCompatibilityEntry();
72 static OUString
getName( const Index rIdx
);
74 static OUString
getUserEntryName()
76 return OUString( "_user" );
79 static OUString
getDefaultEntryName()
81 return OUString( "_default" );
84 static Index
getIndex( const OUString
& rName
)
86 for ( int i
= static_cast<int>(Index::Name
); i
< static_cast<int>(Index::INVALID
); ++i
)
87 if ( getName( Index(i
) ) == rName
)
90 /* SvtCompatibilityEntry::getIndex() Undeclared compatibility property name */
93 return Index::INVALID
;
96 static size_t getElementCount()
98 return static_cast<size_t>(Index::INVALID
);
101 css::uno::Any
getValue( const Index rIdx
) const
103 if ( static_cast<size_t>(rIdx
) < getElementCount() )
105 return m_aPropertyValue
[ static_cast<int>(rIdx
) ];
110 return css::uno::Any();
115 T
getValue( const Index rIdx
) const
119 if ( static_cast<size_t>(rIdx
) < getElementCount() )
121 m_aPropertyValue
[ static_cast<int>(rIdx
) ] >>= aValue
;
131 void setValue( const Index rIdx
, css::uno::Any
const & rValue
)
133 if ( static_cast<size_t>(rIdx
) < getElementCount() )
135 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = rValue
;
144 void setValue( const Index rIdx
, T rValue
)
146 if ( static_cast<size_t>(rIdx
) < getElementCount() )
148 m_aPropertyValue
[ static_cast<int>(rIdx
) ] = css::uno::Any(rValue
);
156 bool isDefaultEntry() const
158 return m_bDefaultEntry
;
161 void setDefaultEntry( bool rValue
)
163 m_bDefaultEntry
= rValue
;
167 std::vector
<css::uno::Any
> m_aPropertyValue
;
168 bool m_bDefaultEntry
;
171 /*-************************************************************************************************************
172 @short forward declaration to our private date container implementation
173 @descr We use these class as internal member to support small memory requirements.
174 You can create the container if it is necessary. The class which use these mechanism
175 is faster and smaller then a complete implementation!
176 *//*-*************************************************************************************************************/
177 class SvtCompatibilityOptions_Impl
;
179 /*-************************************************************************************************************
180 @short collect information about dynamic menus
181 @descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
182 @devstatus ready to use
183 *//*-*************************************************************************************************************/
184 class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions
: public utl::detail::Options
187 SvtCompatibilityOptions();
188 virtual ~SvtCompatibilityOptions() override
;
190 /*-****************************************************************************************************
191 @short append a new item
194 @seealso method Clear()
196 @param "aItem" SvtCompatibilityEntry
197 *//*-*****************************************************************************************************/
198 void AppendItem( const SvtCompatibilityEntry
& aItem
);
200 /*-****************************************************************************************************
201 @short clear complete specified list
202 @descr Call this methods to clear the whole list.
203 *//*-*****************************************************************************************************/
206 void SetDefault( SvtCompatibilityEntry::Index rIdx
, bool rValue
);
207 bool GetDefault( SvtCompatibilityEntry::Index rIdx
) const;
209 /*-****************************************************************************************************
210 @short return complete specified list
211 @descr Call it to get all entries of compatibility options.
212 We return a list of all nodes with its names and properties.
213 @return A list of compatibility options is returned.
215 @onerror We return an empty list.
216 *//*-*****************************************************************************************************/
217 css::uno::Sequence
< css::uno::Sequence
< css::beans::PropertyValue
> > GetList() const;
220 std::shared_ptr
<SvtCompatibilityOptions_Impl
> m_pImpl
;
222 /*-****************************************************************************************************
223 @short return a reference to a static mutex
224 @descr These class is partially threadsafe (for de-/initialization only).
225 All access methods aren't safe!
226 We create a static mutex only for one ime and use at different times.
227 @return A reference to a static mutex member.
228 *//*-*****************************************************************************************************/
229 UNOTOOLS_DLLPRIVATE
static osl::Mutex
& GetOwnStaticMutex();
232 #endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
234 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */