sc: filter: rtf: add method "AddFont"
[LibreOffice.git] / include / unotools / compatibility.hxx
blob15f8b59dfee8c443215c1d4ead29f219112949fc
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>
28 #include <vector>
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
38 public:
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 *//*-*************************************************************************************************************/
44 enum class Index
46 /* Should be in the start. Do not remove it. */
47 Name,
48 Module,
50 /* Editable list of compatibility options. */
51 UsePrtMetrics,
52 AddSpacing,
53 AddSpacingAtPages,
54 UseOurTabStops,
55 NoExtLeading,
56 UseLineSpacing,
57 AddTableSpacing,
58 UseObjectPositioning,
59 UseOurTextWrapping,
60 ConsiderWrappingStyle,
61 ExpandWordSpace,
62 ProtectForm,
63 MsWordTrailingBlanks,
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!
69 AddTableLineSpacing,
71 /* Should be at the end. Do not remove it. */
72 INVALID
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) ];
92 } else
94 /* Wrong index. */
95 assert( false );
96 return css::uno::Any();
100 template<typename T>
101 T getValue( const Index rIdx ) const
103 T aValue = T();
105 if ( static_cast<size_t>(rIdx) < getElementCount() )
107 m_aPropertyValue[ static_cast<int>(rIdx) ] >>= aValue;
108 } else
110 /* Wrong index. */
111 assert( false );
114 return 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;
122 } else
124 /* Wrong index. */
125 assert( false );
129 template<typename T>
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;
145 private:
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
165 public:
166 SvtCompatibilityOptions();
167 virtual ~SvtCompatibilityOptions() override;
169 /*-****************************************************************************************************
170 @short append a new item
171 @descr
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 *//*-*****************************************************************************************************/
183 void Clear();
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;
198 private:
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: */