Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / editeng / source / misc / acorrcfg.cxx
blobf1f1825c523a8991a30673097941069082f069d1
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 .
20 #include <comphelper/processfactory.hxx>
21 #include <editeng/acorrcfg.hxx>
22 #include <o3tl/any.hxx>
23 #include <tools/debug.hxx>
24 #include <tools/urlobj.hxx>
25 #include <comphelper/diagnose_ex.hxx>
26 #include <ucbhelper/content.hxx>
27 #include <unotools/pathoptions.hxx>
28 #include <unotools/ucbhelper.hxx>
29 #include <svtools/langtab.hxx>
30 #include <com/sun/star/sdbc/XResultSet.hpp>
31 #include <com/sun/star/sdbc/XRow.hpp>
33 #include <editeng/svxacorr.hxx>
34 #include <com/sun/star/uno/Sequence.hxx>
36 using namespace utl;
37 using namespace com::sun::star;
38 using namespace com::sun::star::uno;
41 /** An autocorrection file dropped into such directory may create a language
42 list entry if one didn't exist already.
44 static void scanAutoCorrectDirForLanguageTags( const OUString& rURL )
46 // Silently ignore all errors.
47 try
49 ::ucbhelper::Content aContent( rURL,
50 uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext());
51 if (aContent.isFolder())
53 // Title is file name here.
54 uno::Reference<sdbc::XResultSet> xResultSet = aContent.createCursor(
55 {u"Title"_ustr}, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY);
56 uno::Reference<sdbc::XRow> xRow( xResultSet, UNO_QUERY);
57 if (xResultSet.is() && xRow.is())
59 while (xResultSet->next())
61 try
63 const OUString aTitle( xRow->getString(1));
64 if (aTitle.getLength() <= 9 || !(aTitle.startsWith("acor_") && aTitle.endsWith(".dat")))
65 continue;
67 const OUString aBcp47( aTitle.copy( 5, aTitle.getLength() - 9));
68 // Ignore invalid langtags and canonicalize for good,
69 // allow private-use tags.
70 const LanguageTag aLanguageTag (aBcp47, true);
71 if (!aLanguageTag.isValidBcp47())
72 continue;
74 if (SvtLanguageTable::HasLanguageType( aLanguageTag.getLanguageType()))
75 continue;
77 // Insert language(-script)-only tags only if there is
78 // no known matching fallback locale, otherwise we'd
79 // end up with unwanted entries where a language
80 // autocorrection file covers several locales. We do
81 // know a few art-x-... though so exclude those and any
82 // other private-use tag (which should not fallback,
83 // but avoid).
84 if (aLanguageTag.getCountry().isEmpty()
85 && LanguageTag::isValidBcp47( aLanguageTag.getBcp47(), nullptr,
86 LanguageTag::PrivateUse::DISALLOW))
88 LanguageTag aFallback( aLanguageTag);
89 aFallback.makeFallback();
90 if (aFallback.getLanguageAndScript() == aLanguageTag.getLanguageAndScript())
91 continue;
94 // Finally add this one.
95 SvtLanguageTable::AddLanguageTag( aLanguageTag);
97 catch (const uno::Exception&)
99 TOOLS_WARN_EXCEPTION("editeng", "Unable to get a directory entry from '" << rURL << "'");
105 catch (const uno::Exception&)
107 TOOLS_WARN_EXCEPTION("editeng", "Unable to iterate directory '" << rURL << "'");
111 SvxAutoCorrCfg::SvxAutoCorrCfg() :
112 aBaseConfig(*this),
113 aSwConfig(*this),
114 bFileRel(true),
115 bNetRel(true),
116 bAutoTextTip(true),
117 bAutoTextPreview(false),
118 bAutoFmtByInput(true),
119 bSearchInAllCategories(false)
121 SvtPathOptions aPathOpt;
122 OUString sSharePath, sUserPath;
123 OUString const & sAutoPath( aPathOpt.GetAutoCorrectPath() );
125 sSharePath = sAutoPath.getToken(0, ';');
126 sUserPath = sAutoPath.getToken(1, ';');
128 //fdo#67743 ensure the userdir exists so that any later attempt to copy the
129 //shared autocorrect file into the user dir will succeed
130 ::ucbhelper::Content aContent;
131 Reference < ucb::XCommandEnvironment > xEnv;
132 ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, sUserPath, aContent);
134 for( OUString* pS : { &sSharePath, &sUserPath } )
136 INetURLObject aPath( *pS );
137 scanAutoCorrectDirForLanguageTags( aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri));
138 aPath.insertName(u"acor");
139 *pS = aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
141 pAutoCorrect.reset( new SvxAutoCorrect( sSharePath, sUserPath ) );
143 aBaseConfig.Load(true);
144 aSwConfig.Load(true);
147 SvxAutoCorrCfg::~SvxAutoCorrCfg()
151 void SvxAutoCorrCfg::SetAutoCorrect(SvxAutoCorrect *const pNew)
153 if (pNew != pAutoCorrect.get())
155 if (pNew && (pAutoCorrect->GetFlags() != pNew->GetFlags()))
157 aBaseConfig.SetModified();
158 aSwConfig.SetModified();
160 pAutoCorrect.reset( pNew );
164 Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames()
166 static constexpr OUString aPropNames[]
168 u"Exceptions/TwoCapitalsAtStart"_ustr, // 0
169 u"Exceptions/CapitalAtStartSentence"_ustr, // 1
170 u"UseReplacementTable"_ustr, // 2
171 u"TwoCapitalsAtStart"_ustr, // 3
172 u"CapitalAtStartSentence"_ustr, // 4
173 u"ChangeUnderlineWeight"_ustr, // 5
174 u"SetInetAttribute"_ustr, // 6
175 u"ChangeOrdinalNumber"_ustr, // 7
176 u"AddNonBreakingSpace"_ustr, // 8
177 u"ChangeDash"_ustr, // 9
178 u"RemoveDoubleSpaces"_ustr, // 10
179 u"ReplaceSingleQuote"_ustr, // 11
180 u"SingleQuoteAtStart"_ustr, // 12
181 u"SingleQuoteAtEnd"_ustr, // 13
182 u"ReplaceDoubleQuote"_ustr, // 14
183 u"DoubleQuoteAtStart"_ustr, // 15
184 u"DoubleQuoteAtEnd"_ustr, // 16
185 u"CorrectAccidentalCapsLock"_ustr, // 17
186 u"TransliterateRTL"_ustr, // 18
187 u"ChangeAngleQuotes"_ustr, // 19
188 u"SetDOIAttribute"_ustr, // 20
190 const int nCount = 21;
191 Sequence<OUString> aNames(nCount);
192 OUString* pNames = aNames.getArray();
193 for(int i = 0; i < nCount; i++)
194 pNames[i] = aPropNames[i];
195 return aNames;
198 void SvxBaseAutoCorrCfg::Load(bool bInit)
200 Sequence<OUString> aNames = GetPropertyNames();
201 Sequence<Any> aValues = GetProperties(aNames);
202 if(bInit)
203 EnableNotification(aNames);
204 const Any* pValues = aValues.getConstArray();
205 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
206 if(aValues.getLength() != aNames.getLength())
207 return;
209 ACFlags nFlags = ACFlags::NONE; // default all off
210 sal_Int32 nTemp = 0;
211 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
213 if(pValues[nProp].hasValue())
215 switch(nProp)
217 case 0:
218 if(*o3tl::doAccess<bool>(pValues[nProp]))
219 nFlags |= ACFlags::SaveWordCplSttLst;
220 break;//"Exceptions/TwoCapitalsAtStart",
221 case 1:
222 if(*o3tl::doAccess<bool>(pValues[nProp]))
223 nFlags |= ACFlags::SaveWordWordStartLst;
224 break;//"Exceptions/CapitalAtStartSentence",
225 case 2:
226 if(*o3tl::doAccess<bool>(pValues[nProp]))
227 nFlags |= ACFlags::Autocorrect;
228 break;//"UseReplacementTable",
229 case 3:
230 if(*o3tl::doAccess<bool>(pValues[nProp]))
231 nFlags |= ACFlags::CapitalStartWord;
232 break;//"TwoCapitalsAtStart",
233 case 4:
234 if(*o3tl::doAccess<bool>(pValues[nProp]))
235 nFlags |= ACFlags::CapitalStartSentence;
236 break;//"CapitalAtStartSentence",
237 case 5:
238 if(*o3tl::doAccess<bool>(pValues[nProp]))
239 nFlags |= ACFlags::ChgWeightUnderl;
240 break;//"ChangeUnderlineWeight",
241 case 6:
242 if(*o3tl::doAccess<bool>(pValues[nProp]))
243 nFlags |= ACFlags::SetINetAttr;
244 break;//"SetInetAttribute",
245 case 7:
246 if(*o3tl::doAccess<bool>(pValues[nProp]))
247 nFlags |= ACFlags::ChgOrdinalNumber;
248 break;//"ChangeOrdinalNumber",
249 case 8:
250 if(*o3tl::doAccess<bool>(pValues[nProp]))
251 nFlags |= ACFlags::AddNonBrkSpace;
252 break;//"AddNonBreakingSpace"
253 case 9:
254 if(*o3tl::doAccess<bool>(pValues[nProp]))
255 nFlags |= ACFlags::ChgToEnEmDash;
256 break;//"ChangeDash",
257 case 10:
258 if(*o3tl::doAccess<bool>(pValues[nProp]))
259 nFlags |= ACFlags::IgnoreDoubleSpace;
260 break;//"RemoveDoubleSpaces",
261 case 11:
262 if(*o3tl::doAccess<bool>(pValues[nProp]))
263 nFlags |= ACFlags::ChgSglQuotes;
264 break;//"ReplaceSingleQuote",
265 case 12:
266 pValues[nProp] >>= nTemp;
267 rParent.pAutoCorrect->SetStartSingleQuote(
268 sal::static_int_cast< sal_Unicode >( nTemp ) );
269 break;//"SingleQuoteAtStart",
270 case 13:
271 pValues[nProp] >>= nTemp;
272 rParent.pAutoCorrect->SetEndSingleQuote(
273 sal::static_int_cast< sal_Unicode >( nTemp ) );
274 break;//"SingleQuoteAtEnd",
275 case 14:
276 if(*o3tl::doAccess<bool>(pValues[nProp]))
277 nFlags |= ACFlags::ChgQuotes;
278 break;//"ReplaceDoubleQuote",
279 case 15:
280 pValues[nProp] >>= nTemp;
281 rParent.pAutoCorrect->SetStartDoubleQuote(
282 sal::static_int_cast< sal_Unicode >( nTemp ) );
283 break;//"DoubleQuoteAtStart",
284 case 16:
285 pValues[nProp] >>= nTemp;
286 rParent.pAutoCorrect->SetEndDoubleQuote(
287 sal::static_int_cast< sal_Unicode >( nTemp ) );
288 break;//"DoubleQuoteAtEnd"
289 case 17:
290 if(*o3tl::doAccess<bool>(pValues[nProp]))
291 nFlags |= ACFlags::CorrectCapsLock;
292 break;//"CorrectAccidentalCapsLock"
293 case 18:
294 if(*o3tl::doAccess<bool>(pValues[nProp]))
295 nFlags |= ACFlags::TransliterateRTL;
296 break;//"TransliterateRTL"
297 case 19:
298 if(*o3tl::doAccess<bool>(pValues[nProp]))
299 nFlags |= ACFlags::ChgAngleQuotes;
300 break;//"ChangeAngleQuotes"
301 case 20:
302 if(*o3tl::doAccess<bool>(pValues[nProp]))
303 nFlags |= ACFlags::SetDOIAttr;
304 break;//"SetDOIAttr",
308 if( nFlags != ACFlags::NONE )
309 rParent.pAutoCorrect->SetAutoCorrFlag( nFlags );
310 rParent.pAutoCorrect->SetAutoCorrFlag( ( static_cast<ACFlags>(0xffff) & ~nFlags ), false );
313 SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) :
314 utl::ConfigItem(u"Office.Common/AutoCorrect"_ustr),
315 rParent(rPar)
319 SvxBaseAutoCorrCfg::~SvxBaseAutoCorrCfg()
323 void SvxBaseAutoCorrCfg::ImplCommit()
325 const ACFlags nFlags = rParent.pAutoCorrect->GetFlags();
326 PutProperties(
327 GetPropertyNames(),
328 {css::uno::Any(bool(nFlags & ACFlags::SaveWordCplSttLst)),
329 // "Exceptions/TwoCapitalsAtStart"
330 css::uno::Any(bool(nFlags & ACFlags::SaveWordWordStartLst)),
331 // "Exceptions/CapitalAtStartSentence"
332 css::uno::Any(bool(nFlags & ACFlags::Autocorrect)), // "UseReplacementTable"
333 css::uno::Any(bool(nFlags & ACFlags::CapitalStartWord)),
334 // "TwoCapitalsAtStart"
335 css::uno::Any(bool(nFlags & ACFlags::CapitalStartSentence)),
336 // "CapitalAtStartSentence"
337 css::uno::Any(bool(nFlags & ACFlags::ChgWeightUnderl)),
338 // "ChangeUnderlineWeight"
339 css::uno::Any(bool(nFlags & ACFlags::SetINetAttr)), // "SetInetAttribute"
340 css::uno::Any(bool(nFlags & ACFlags::ChgOrdinalNumber)),
341 // "ChangeOrdinalNumber"
342 css::uno::Any(bool(nFlags & ACFlags::AddNonBrkSpace)), // "AddNonBreakingSpace"
343 css::uno::Any(bool(nFlags & ACFlags::ChgToEnEmDash)), // "ChangeDash"
344 css::uno::Any(bool(nFlags & ACFlags::IgnoreDoubleSpace)),
345 // "RemoveDoubleSpaces"
346 css::uno::Any(bool(nFlags & ACFlags::ChgSglQuotes)), // "ReplaceSingleQuote"
347 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartSingleQuote())),
348 // "SingleQuoteAtStart"
349 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndSingleQuote())),
350 // "SingleQuoteAtEnd"
351 css::uno::Any(bool(nFlags & ACFlags::ChgQuotes)), // "ReplaceDoubleQuote"
352 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartDoubleQuote())),
353 // "DoubleQuoteAtStart"
354 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndDoubleQuote())),
355 // "DoubleQuoteAtEnd"
356 css::uno::Any(bool(nFlags & ACFlags::CorrectCapsLock)),
357 // "CorrectAccidentalCapsLock"
358 css::uno::Any(bool(nFlags & ACFlags::TransliterateRTL)),
359 // "TransliterateRTL"
360 css::uno::Any(bool(nFlags & ACFlags::ChgAngleQuotes)),
361 // "ChangeAngleQuotes"
362 css::uno::Any(bool(nFlags & ACFlags::SetDOIAttr)), // "SetDOIAttribute"
366 void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */)
368 Load(false);
371 Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames()
373 static constexpr OUString aPropNames[]
375 u"Text/FileLinks"_ustr, // 0
376 u"Text/InternetLinks"_ustr, // 1
377 u"Text/ShowPreview"_ustr, // 2
378 u"Text/ShowToolTip"_ustr, // 3
379 u"Text/SearchInAllCategories"_ustr, // 4
380 u"Format/Option/UseReplacementTable"_ustr, // 5
381 u"Format/Option/TwoCapitalsAtStart"_ustr, // 6
382 u"Format/Option/CapitalAtStartSentence"_ustr, // 7
383 u"Format/Option/ChangeUnderlineWeight"_ustr, // 8
384 u"Format/Option/SetInetAttribute"_ustr, // 9
385 u"Format/Option/ChangeOrdinalNumber"_ustr, //10
386 u"Format/Option/AddNonBreakingSpace"_ustr, //11
387 u"Format/Option/ChangeDash"_ustr, //12
388 u"Format/Option/DelEmptyParagraphs"_ustr, //13
389 u"Format/Option/ReplaceUserStyle"_ustr, //14
390 u"Format/Option/ChangeToBullets/Enable"_ustr, //15
391 u"Format/Option/ChangeToBullets/SpecialCharacter/Char"_ustr, //16
392 u"Format/Option/ChangeToBullets/SpecialCharacter/Font"_ustr, //17
393 u"Format/Option/ChangeToBullets/SpecialCharacter/FontFamily"_ustr, //18
394 u"Format/Option/ChangeToBullets/SpecialCharacter/FontCharset"_ustr, //19
395 u"Format/Option/ChangeToBullets/SpecialCharacter/FontPitch"_ustr, //20
396 u"Format/Option/CombineParagraphs"_ustr, //21
397 u"Format/Option/CombineValue"_ustr, //22
398 u"Format/Option/DelSpacesAtStartEnd"_ustr, //23
399 u"Format/Option/DelSpacesBetween"_ustr, //24
400 u"Format/ByInput/Enable"_ustr, //25
401 u"Format/ByInput/ChangeDash"_ustr, //26
402 u"Format/ByInput/ApplyNumbering/Enable"_ustr, //27
403 u"Format/ByInput/ChangeToBorders"_ustr, //28
404 u"Format/ByInput/ChangeToTable"_ustr, //29
405 u"Format/ByInput/ReplaceStyle"_ustr, //30
406 u"Format/ByInput/DelSpacesAtStartEnd"_ustr, //31
407 u"Format/ByInput/DelSpacesBetween"_ustr, //32
408 u"Completion/Enable"_ustr, //33
409 u"Completion/MinWordLen"_ustr, //34
410 u"Completion/MaxListLen"_ustr, //35
411 u"Completion/CollectWords"_ustr, //36
412 u"Completion/EndlessList"_ustr, //37
413 u"Completion/AppendBlank"_ustr, //38
414 u"Completion/ShowAsTip"_ustr, //39
415 u"Completion/AcceptKey"_ustr, //40
416 u"Completion/KeepList"_ustr, //41
417 u"Format/ByInput/ApplyNumbering/SpecialCharacter/Char"_ustr, //42
418 u"Format/ByInput/ApplyNumbering/SpecialCharacter/Font"_ustr, //43
419 u"Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily"_ustr, //44
420 u"Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset"_ustr, //45
421 u"Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch"_ustr, //46
422 u"Format/Option/SetDOIAttribute"_ustr, //47
423 u"Format/ByInput/ApplyBulletsAfterSpace"_ustr, //48
425 const int nCount = 49;
426 Sequence<OUString> aNames(nCount);
427 OUString* pNames = aNames.getArray();
428 for(int i = 0; i < nCount; i++)
429 pNames[i] = aPropNames[i];
430 return aNames;
433 void SvxSwAutoCorrCfg::Load(bool bInit)
435 Sequence<OUString> aNames = GetPropertyNames();
436 Sequence<Any> aValues = GetProperties(aNames);
437 if(bInit)
438 EnableNotification(aNames);
439 const Any* pValues = aValues.getConstArray();
440 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
441 if(aValues.getLength() != aNames.getLength())
442 return;
444 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
445 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
447 if(pValues[nProp].hasValue())
449 switch(nProp)
451 case 0: rParent.bFileRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/FileLinks",
452 case 1: rParent.bNetRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/InternetLinks",
453 case 2: rParent.bAutoTextPreview = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowPreview",
454 case 3: rParent.bAutoTextTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowToolTip",
455 case 4: rParent.bSearchInAllCategories = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Text/SearchInAllCategories"
456 case 5: rSwFlags.bAutoCorrect = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/UseReplacementTable",
457 case 6: rSwFlags.bCapitalStartSentence = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/TwoCapitalsAtStart",
458 case 7: rSwFlags.bCapitalStartWord = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CapitalAtStartSentence",
459 case 8: rSwFlags.bChgWeightUnderl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeUnderlineWeight",
460 case 9: rSwFlags.bSetINetAttr = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/SetInetAttribute",
461 case 10: rSwFlags.bChgOrdinalNumber = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeOrdinalNumber",
462 case 11: rSwFlags.bAddNonBrkSpace = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/AddNonBreakingSpace",
463 // it doesn't exist here - the common flags are used for that -> LM
464 // case 12: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeDash",
465 case 13: rSwFlags.bDelEmptyNode = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelEmptyParagraphs",
466 case 14: rSwFlags.bChgUserColl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ReplaceUserStyle",
467 case 15: rSwFlags.bChgEnumNum = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeToBullets/Enable",
468 case 16:
470 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
471 rSwFlags.cBullet =
472 sal::static_int_cast< sal_Unicode >(nVal);
474 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
475 case 17:
477 OUString sTemp; pValues[nProp] >>= sTemp;
478 rSwFlags.aBulletFont.SetFamilyName(sTemp);
480 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
481 case 18:
483 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
484 rSwFlags.aBulletFont.SetFamily(FontFamily(nVal));
486 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
487 case 19:
489 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
490 rSwFlags.aBulletFont.SetCharSet(rtl_TextEncoding(nVal));
492 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
493 case 20:
495 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
496 rSwFlags.aBulletFont.SetPitch(FontPitch(nVal));
498 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
499 case 21: rSwFlags.bRightMargin = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CombineParagraphs",
500 case 22:
502 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
503 rSwFlags.nRightMargin =
504 sal::static_int_cast< sal_uInt8 >(nVal);
506 break; // "Format/Option/CombineValue",
507 case 23: rSwFlags.bAFormatDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesAtStartEnd",
508 case 24: rSwFlags.bAFormatDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesBetween",
509 case 25: rParent.bAutoFmtByInput = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/Enable",
510 case 26: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeDash",
511 case 27: rSwFlags.bSetNumRule = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumbering/Enable",
512 case 28: rSwFlags.bSetBorder = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToBorders",
513 case 29: rSwFlags.bCreateTable = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToTable",
514 case 30: rSwFlags.bReplaceStyles = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ReplaceStyle",
515 case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesAtStartEnd",
516 case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesBetween",
517 case 33: rSwFlags.bAutoCompleteWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/Enable",
518 case 34:
520 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
521 rSwFlags.nAutoCmpltWordLen =
522 sal::static_int_cast< sal_uInt16 >(nVal);
524 break; // "Completion/MinWordLen",
525 case 35:
527 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
528 rSwFlags.nAutoCmpltListLen =
529 sal::static_int_cast< sal_uInt32 >(nVal);
531 break; // "Completion/MaxListLen",
532 case 36: rSwFlags.bAutoCmpltCollectWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/CollectWords",
533 case 37: rSwFlags.bAutoCmpltEndless = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/EndlessList",
534 case 38: rSwFlags.bAutoCmpltAppendBlank = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/AppendBlank",
535 case 39: rSwFlags.bAutoCmpltShowAsTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/ShowAsTip",
536 case 40:
538 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
539 rSwFlags.nAutoCmpltExpandKey =
540 sal::static_int_cast< sal_uInt16 >(nVal);
542 break; // "Completion/AcceptKey"
543 case 41 :rSwFlags.bAutoCmpltKeepList = *o3tl::doAccess<bool>(pValues[nProp]); break;//"Completion/KeepList"
544 case 42 :
546 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
547 rSwFlags.cByInputBullet =
548 sal::static_int_cast< sal_Unicode >(nVal);
550 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
551 case 43 :
553 OUString sTemp; pValues[nProp] >>= sTemp;
554 rSwFlags.aByInputBulletFont.SetFamilyName(sTemp);
556 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
557 case 44 :
559 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
560 rSwFlags.aByInputBulletFont.SetFamily(FontFamily(nVal));
562 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
563 case 45 :
565 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
566 rSwFlags.aByInputBulletFont.SetCharSet(rtl_TextEncoding(nVal));
568 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
569 case 46 :
571 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
572 rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal));
574 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
575 case 47: rSwFlags.bSetDOIAttr = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/SetDOIAttribute",
576 case 48 : rSwFlags.bSetNumRuleAfterSpace = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumberingAfterSpace",
582 SvxSwAutoCorrCfg::SvxSwAutoCorrCfg(SvxAutoCorrCfg& rPar) :
583 utl::ConfigItem(u"Office.Writer/AutoFunction"_ustr),
584 rParent(rPar)
588 SvxSwAutoCorrCfg::~SvxSwAutoCorrCfg()
592 void SvxSwAutoCorrCfg::ImplCommit()
594 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
595 PutProperties(
596 GetPropertyNames(),
597 {css::uno::Any(rParent.bFileRel), // "Text/FileLinks"
598 css::uno::Any(rParent.bNetRel), // "Text/InternetLinks"
599 css::uno::Any(rParent.bAutoTextPreview), // "Text/ShowPreview"
600 css::uno::Any(rParent.bAutoTextTip), // "Text/ShowToolTip"
601 css::uno::Any(rParent.bSearchInAllCategories),
602 // "Text/SearchInAllCategories"
603 css::uno::Any(rSwFlags.bAutoCorrect),
604 // "Format/Option/UseReplacementTable"
605 css::uno::Any(rSwFlags.bCapitalStartSentence),
606 // "Format/Option/TwoCapitalsAtStart"
607 css::uno::Any(rSwFlags.bCapitalStartWord),
608 // "Format/Option/CapitalAtStartSentence"
609 css::uno::Any(rSwFlags.bChgWeightUnderl),
610 // "Format/Option/ChangeUnderlineWeight"
611 css::uno::Any(rSwFlags.bSetINetAttr),
612 // "Format/Option/SetInetAttribute"
613 css::uno::Any(rSwFlags.bChgOrdinalNumber),
614 // "Format/Option/ChangeOrdinalNumber"
615 css::uno::Any(rSwFlags.bAddNonBrkSpace),
616 // "Format/Option/AddNonBreakingSpace"
617 css::uno::Any(true),
618 // "Format/Option/ChangeDash"; it doesn't exist here - the common
619 // flags are used for that -> LM
620 css::uno::Any(rSwFlags.bDelEmptyNode),
621 // "Format/Option/DelEmptyParagraphs"
622 css::uno::Any(rSwFlags.bChgUserColl),
623 // "Format/Option/ReplaceUserStyle"
624 css::uno::Any(rSwFlags.bChgEnumNum),
625 // "Format/Option/ChangeToBullets/Enable"
626 css::uno::Any(sal_Int32(rSwFlags.cBullet)),
627 // "Format/Option/ChangeToBullets/SpecialCharacter/Char"
628 css::uno::Any(rSwFlags.aBulletFont.GetFamilyName()),
629 // "Format/Option/ChangeToBullets/SpecialCharacter/Font"
630 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetFamilyType())),
631 // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily"
632 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetCharSet())),
633 // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset"
634 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetPitch())),
635 // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch"
636 css::uno::Any(rSwFlags.bRightMargin),
637 // "Format/Option/CombineParagraphs"
638 css::uno::Any(sal_Int32(rSwFlags.nRightMargin)),
639 // "Format/Option/CombineValue"
640 css::uno::Any(rSwFlags.bAFormatDelSpacesAtSttEnd),
641 // "Format/Option/DelSpacesAtStartEnd"
642 css::uno::Any(rSwFlags.bAFormatDelSpacesBetweenLines),
643 // "Format/Option/DelSpacesBetween"
644 css::uno::Any(rParent.bAutoFmtByInput), // "Format/ByInput/Enable"
645 css::uno::Any(rSwFlags.bChgToEnEmDash), // "Format/ByInput/ChangeDash"
646 css::uno::Any(rSwFlags.bSetNumRule),
647 // "Format/ByInput/ApplyNumbering/Enable"
648 css::uno::Any(rSwFlags.bSetBorder), // "Format/ByInput/ChangeToBorders"
649 css::uno::Any(rSwFlags.bCreateTable), // "Format/ByInput/ChangeToTable"
650 css::uno::Any(rSwFlags.bReplaceStyles),
651 // "Format/ByInput/ReplaceStyle"
652 css::uno::Any(rSwFlags.bAFormatByInpDelSpacesAtSttEnd),
653 // "Format/ByInput/DelSpacesAtStartEnd"
654 css::uno::Any(rSwFlags.bAFormatByInpDelSpacesBetweenLines),
655 // "Format/ByInput/DelSpacesBetween"
656 css::uno::Any(rSwFlags.bAutoCompleteWords), // "Completion/Enable"
657 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltWordLen)),
658 // "Completion/MinWordLen"
659 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltListLen)),
660 // "Completion/MaxListLen"
661 css::uno::Any(rSwFlags.bAutoCmpltCollectWords),
662 // "Completion/CollectWords"
663 css::uno::Any(rSwFlags.bAutoCmpltEndless), // "Completion/EndlessList"
664 css::uno::Any(rSwFlags.bAutoCmpltAppendBlank),
665 // "Completion/AppendBlank"
666 css::uno::Any(rSwFlags.bAutoCmpltShowAsTip), // "Completion/ShowAsTip"
667 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltExpandKey)),
668 // "Completion/AcceptKey"
669 css::uno::Any(rSwFlags.bAutoCmpltKeepList), // "Completion/KeepList"
670 css::uno::Any(sal_Int32(rSwFlags.cByInputBullet)),
671 // "Format/ByInput/ApplyNumbering/SpecialCharacter/Char"
672 css::uno::Any(rSwFlags.aByInputBulletFont.GetFamilyName()),
673 // "Format/ByInput/ApplyNumbering/SpecialCharacter/Font"
674 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetFamilyType())),
675 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily"
676 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetCharSet())),
677 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset"
678 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch())),
679 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch"
680 css::uno::Any(rSwFlags.bSetDOIAttr),
681 css::uno::Any(rSwFlags.bSetNumRuleAfterSpace), // "Format/ByInput/ApplyNumberingAfterSpace"
683 // "Format/Option/SetDOIAttribute"
686 void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ )
688 Load(false);
691 SvxAutoCorrCfg& SvxAutoCorrCfg::Get()
693 static SvxAutoCorrCfg theSvxAutoCorrCfg;
694 return theSvxAutoCorrCfg;
697 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */