Bump version to 6.4-15
[LibreOffice.git] / include / unotools / compatibility.hxx
blob812b8cc480bdc79b9d6ee7e1c7c025d04f6c8833
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <memory>
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
37 public:
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 *//*-*************************************************************************************************************/
43 enum class Index
45 /* Should be in the start. Do not remove it. */
46 Name,
47 Module,
49 /* Editable list of compatibility options. */
50 UsePrtMetrics,
51 AddSpacing,
52 AddSpacingAtPages,
53 UseOurTabStops,
54 NoExtLeading,
55 UseLineSpacing,
56 AddTableSpacing,
57 UseObjectPositioning,
58 UseOurTextWrapping,
59 ConsiderWrappingStyle,
60 ExpandWordSpace,
61 ProtectForm,
62 MsWordTrailingBlanks,
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!
68 AddTableLineSpacing,
70 /* Should be at the end. Do not remove it. */
71 INVALID
74 SvtCompatibilityEntry();
76 static OUString getName( const Index rIdx );
78 static OUString getUserEntryName()
80 return "_user";
83 static OUString getDefaultEntryName()
85 return "_default";
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 )
92 return Index(i);
94 /* SvtCompatibilityEntry::getIndex() Undeclared compatibility property name */
95 assert(false);
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) ];
110 } else
112 /* Wrong index. */
113 assert( false );
114 return css::uno::Any();
118 template<typename T>
119 T getValue( const Index rIdx ) const
121 T aValue = T();
123 if ( static_cast<size_t>(rIdx) < getElementCount() )
125 m_aPropertyValue[ static_cast<int>(rIdx) ] >>= aValue;
126 } else
128 /* Wrong index. */
129 assert( false );
132 return 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;
140 } else
142 /* Wrong index. */
143 assert( false );
147 template<typename T>
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);
153 } else
155 /* Wrong index. */
156 assert( false );
160 bool isDefaultEntry() const
162 return m_bDefaultEntry;
165 void setDefaultEntry( bool rValue )
167 m_bDefaultEntry = rValue;
170 private:
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
190 public:
191 SvtCompatibilityOptions();
192 virtual ~SvtCompatibilityOptions() override;
194 /*-****************************************************************************************************
195 @short append a new item
196 @descr
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 *//*-*****************************************************************************************************/
208 void Clear();
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;
223 private:
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: */