tdf#156769 - Escape the question mark in the storage name
[LibreOffice.git] / editeng / source / misc / acorrcfg.cxx
blobfcafbfca6f0cc4855d8dff43d30b301e00bd5de2
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 {"Title"}, ::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 OUString aCanonicalized;
69 // Ignore invalid langtags and canonicalize for good,
70 // allow private-use tags.
71 if (!LanguageTag::isValidBcp47( aBcp47, &aCanonicalized))
72 continue;
74 const LanguageTag aLanguageTag( aCanonicalized);
75 if (SvtLanguageTable::HasLanguageType( aLanguageTag.getLanguageType()))
76 continue;
78 // Insert language(-script)-only tags only if there is
79 // no known matching fallback locale, otherwise we'd
80 // end up with unwanted entries where a language
81 // autocorrection file covers several locales. We do
82 // know a few art-x-... though so exclude those and any
83 // other private-use tag (which should not fallback,
84 // but avoid).
85 if (aLanguageTag.getCountry().isEmpty()
86 && LanguageTag::isValidBcp47( aCanonicalized, nullptr,
87 LanguageTag::PrivateUse::DISALLOW))
89 LanguageTag aFallback( aLanguageTag);
90 aFallback.makeFallback();
91 if (aFallback.getLanguageAndScript() == aLanguageTag.getLanguageAndScript())
92 continue;
95 // Finally add this one.
96 SvtLanguageTable::AddLanguageTag( aLanguageTag);
98 catch (const uno::Exception&)
100 TOOLS_WARN_EXCEPTION("editeng", "Unable to get a directory entry from '" << rURL << "'");
106 catch (const uno::Exception&)
108 TOOLS_WARN_EXCEPTION("editeng", "Unable to iterate directory '" << rURL << "'");
112 SvxAutoCorrCfg::SvxAutoCorrCfg() :
113 aBaseConfig(*this),
114 aSwConfig(*this),
115 bFileRel(true),
116 bNetRel(true),
117 bAutoTextTip(true),
118 bAutoTextPreview(false),
119 bAutoFmtByInput(true),
120 bSearchInAllCategories(false)
122 SvtPathOptions aPathOpt;
123 OUString sSharePath, sUserPath;
124 OUString const & sAutoPath( aPathOpt.GetAutoCorrectPath() );
126 sSharePath = sAutoPath.getToken(0, ';');
127 sUserPath = sAutoPath.getToken(1, ';');
129 //fdo#67743 ensure the userdir exists so that any later attempt to copy the
130 //shared autocorrect file into the user dir will succeed
131 ::ucbhelper::Content aContent;
132 Reference < ucb::XCommandEnvironment > xEnv;
133 ::utl::UCBContentHelper::ensureFolder(comphelper::getProcessComponentContext(), xEnv, sUserPath, aContent);
135 for( OUString* pS : { &sSharePath, &sUserPath } )
137 INetURLObject aPath( *pS );
138 scanAutoCorrectDirForLanguageTags( aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri));
139 aPath.insertName(u"acor");
140 *pS = aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri);
142 pAutoCorrect.reset( new SvxAutoCorrect( sSharePath, sUserPath ) );
144 aBaseConfig.Load(true);
145 aSwConfig.Load(true);
148 SvxAutoCorrCfg::~SvxAutoCorrCfg()
152 void SvxAutoCorrCfg::SetAutoCorrect(SvxAutoCorrect *const pNew)
154 if (pNew != pAutoCorrect.get())
156 if (pNew && (pAutoCorrect->GetFlags() != pNew->GetFlags()))
158 aBaseConfig.SetModified();
159 aSwConfig.SetModified();
161 pAutoCorrect.reset( pNew );
165 Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames()
167 static const char* aPropNames[] =
169 "Exceptions/TwoCapitalsAtStart", // 0
170 "Exceptions/CapitalAtStartSentence", // 1
171 "UseReplacementTable", // 2
172 "TwoCapitalsAtStart", // 3
173 "CapitalAtStartSentence", // 4
174 "ChangeUnderlineWeight", // 5
175 "SetInetAttribute", // 6
176 "ChangeOrdinalNumber", // 7
177 "AddNonBreakingSpace", // 8
178 "ChangeDash", // 9
179 "RemoveDoubleSpaces", // 10
180 "ReplaceSingleQuote", // 11
181 "SingleQuoteAtStart", // 12
182 "SingleQuoteAtEnd", // 13
183 "ReplaceDoubleQuote", // 14
184 "DoubleQuoteAtStart", // 15
185 "DoubleQuoteAtEnd", // 16
186 "CorrectAccidentalCapsLock", // 17
187 "TransliterateRTL", // 18
188 "ChangeAngleQuotes", // 19
189 "SetDOIAttribute", // 20
191 const int nCount = 21;
192 Sequence<OUString> aNames(nCount);
193 OUString* pNames = aNames.getArray();
194 for(int i = 0; i < nCount; i++)
195 pNames[i] = OUString::createFromAscii(aPropNames[i]);
196 return aNames;
199 void SvxBaseAutoCorrCfg::Load(bool bInit)
201 Sequence<OUString> aNames = GetPropertyNames();
202 Sequence<Any> aValues = GetProperties(aNames);
203 if(bInit)
204 EnableNotification(aNames);
205 const Any* pValues = aValues.getConstArray();
206 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
207 if(aValues.getLength() != aNames.getLength())
208 return;
210 ACFlags nFlags = ACFlags::NONE; // default all off
211 sal_Int32 nTemp = 0;
212 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
214 if(pValues[nProp].hasValue())
216 switch(nProp)
218 case 0:
219 if(*o3tl::doAccess<bool>(pValues[nProp]))
220 nFlags |= ACFlags::SaveWordCplSttLst;
221 break;//"Exceptions/TwoCapitalsAtStart",
222 case 1:
223 if(*o3tl::doAccess<bool>(pValues[nProp]))
224 nFlags |= ACFlags::SaveWordWordStartLst;
225 break;//"Exceptions/CapitalAtStartSentence",
226 case 2:
227 if(*o3tl::doAccess<bool>(pValues[nProp]))
228 nFlags |= ACFlags::Autocorrect;
229 break;//"UseReplacementTable",
230 case 3:
231 if(*o3tl::doAccess<bool>(pValues[nProp]))
232 nFlags |= ACFlags::CapitalStartWord;
233 break;//"TwoCapitalsAtStart",
234 case 4:
235 if(*o3tl::doAccess<bool>(pValues[nProp]))
236 nFlags |= ACFlags::CapitalStartSentence;
237 break;//"CapitalAtStartSentence",
238 case 5:
239 if(*o3tl::doAccess<bool>(pValues[nProp]))
240 nFlags |= ACFlags::ChgWeightUnderl;
241 break;//"ChangeUnderlineWeight",
242 case 6:
243 if(*o3tl::doAccess<bool>(pValues[nProp]))
244 nFlags |= ACFlags::SetINetAttr;
245 break;//"SetInetAttribute",
246 case 7:
247 if(*o3tl::doAccess<bool>(pValues[nProp]))
248 nFlags |= ACFlags::ChgOrdinalNumber;
249 break;//"ChangeOrdinalNumber",
250 case 8:
251 if(*o3tl::doAccess<bool>(pValues[nProp]))
252 nFlags |= ACFlags::AddNonBrkSpace;
253 break;//"AddNonBreakingSpace"
254 case 9:
255 if(*o3tl::doAccess<bool>(pValues[nProp]))
256 nFlags |= ACFlags::ChgToEnEmDash;
257 break;//"ChangeDash",
258 case 10:
259 if(*o3tl::doAccess<bool>(pValues[nProp]))
260 nFlags |= ACFlags::IgnoreDoubleSpace;
261 break;//"RemoveDoubleSpaces",
262 case 11:
263 if(*o3tl::doAccess<bool>(pValues[nProp]))
264 nFlags |= ACFlags::ChgSglQuotes;
265 break;//"ReplaceSingleQuote",
266 case 12:
267 pValues[nProp] >>= nTemp;
268 rParent.pAutoCorrect->SetStartSingleQuote(
269 sal::static_int_cast< sal_Unicode >( nTemp ) );
270 break;//"SingleQuoteAtStart",
271 case 13:
272 pValues[nProp] >>= nTemp;
273 rParent.pAutoCorrect->SetEndSingleQuote(
274 sal::static_int_cast< sal_Unicode >( nTemp ) );
275 break;//"SingleQuoteAtEnd",
276 case 14:
277 if(*o3tl::doAccess<bool>(pValues[nProp]))
278 nFlags |= ACFlags::ChgQuotes;
279 break;//"ReplaceDoubleQuote",
280 case 15:
281 pValues[nProp] >>= nTemp;
282 rParent.pAutoCorrect->SetStartDoubleQuote(
283 sal::static_int_cast< sal_Unicode >( nTemp ) );
284 break;//"DoubleQuoteAtStart",
285 case 16:
286 pValues[nProp] >>= nTemp;
287 rParent.pAutoCorrect->SetEndDoubleQuote(
288 sal::static_int_cast< sal_Unicode >( nTemp ) );
289 break;//"DoubleQuoteAtEnd"
290 case 17:
291 if(*o3tl::doAccess<bool>(pValues[nProp]))
292 nFlags |= ACFlags::CorrectCapsLock;
293 break;//"CorrectAccidentalCapsLock"
294 case 18:
295 if(*o3tl::doAccess<bool>(pValues[nProp]))
296 nFlags |= ACFlags::TransliterateRTL;
297 break;//"TransliterateRTL"
298 case 19:
299 if(*o3tl::doAccess<bool>(pValues[nProp]))
300 nFlags |= ACFlags::ChgAngleQuotes;
301 break;//"ChangeAngleQuotes"
302 case 20:
303 if(*o3tl::doAccess<bool>(pValues[nProp]))
304 nFlags |= ACFlags::SetDOIAttr;
305 break;//"SetDOIAttr",
309 if( nFlags != ACFlags::NONE )
310 rParent.pAutoCorrect->SetAutoCorrFlag( nFlags );
311 rParent.pAutoCorrect->SetAutoCorrFlag( ( static_cast<ACFlags>(0xffff) & ~nFlags ), false );
314 SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) :
315 utl::ConfigItem("Office.Common/AutoCorrect"),
316 rParent(rPar)
320 SvxBaseAutoCorrCfg::~SvxBaseAutoCorrCfg()
324 void SvxBaseAutoCorrCfg::ImplCommit()
326 const ACFlags nFlags = rParent.pAutoCorrect->GetFlags();
327 PutProperties(
328 GetPropertyNames(),
329 {css::uno::Any(bool(nFlags & ACFlags::SaveWordCplSttLst)),
330 // "Exceptions/TwoCapitalsAtStart"
331 css::uno::Any(bool(nFlags & ACFlags::SaveWordWordStartLst)),
332 // "Exceptions/CapitalAtStartSentence"
333 css::uno::Any(bool(nFlags & ACFlags::Autocorrect)), // "UseReplacementTable"
334 css::uno::Any(bool(nFlags & ACFlags::CapitalStartWord)),
335 // "TwoCapitalsAtStart"
336 css::uno::Any(bool(nFlags & ACFlags::CapitalStartSentence)),
337 // "CapitalAtStartSentence"
338 css::uno::Any(bool(nFlags & ACFlags::ChgWeightUnderl)),
339 // "ChangeUnderlineWeight"
340 css::uno::Any(bool(nFlags & ACFlags::SetINetAttr)), // "SetInetAttribute"
341 css::uno::Any(bool(nFlags & ACFlags::ChgOrdinalNumber)),
342 // "ChangeOrdinalNumber"
343 css::uno::Any(bool(nFlags & ACFlags::AddNonBrkSpace)), // "AddNonBreakingSpace"
344 css::uno::Any(bool(nFlags & ACFlags::ChgToEnEmDash)), // "ChangeDash"
345 css::uno::Any(bool(nFlags & ACFlags::IgnoreDoubleSpace)),
346 // "RemoveDoubleSpaces"
347 css::uno::Any(bool(nFlags & ACFlags::ChgSglQuotes)), // "ReplaceSingleQuote"
348 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartSingleQuote())),
349 // "SingleQuoteAtStart"
350 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndSingleQuote())),
351 // "SingleQuoteAtEnd"
352 css::uno::Any(bool(nFlags & ACFlags::ChgQuotes)), // "ReplaceDoubleQuote"
353 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetStartDoubleQuote())),
354 // "DoubleQuoteAtStart"
355 css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndDoubleQuote())),
356 // "DoubleQuoteAtEnd"
357 css::uno::Any(bool(nFlags & ACFlags::CorrectCapsLock)),
358 // "CorrectAccidentalCapsLock"
359 css::uno::Any(bool(nFlags & ACFlags::TransliterateRTL)),
360 // "TransliterateRTL"
361 css::uno::Any(bool(nFlags & ACFlags::ChgAngleQuotes)),
362 // "ChangeAngleQuotes"
363 css::uno::Any(bool(nFlags & ACFlags::SetDOIAttr)), // "SetDOIAttribute"
367 void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */)
369 Load(false);
372 Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames()
374 static const char* aPropNames[] =
376 "Text/FileLinks", // 0
377 "Text/InternetLinks", // 1
378 "Text/ShowPreview", // 2
379 "Text/ShowToolTip", // 3
380 "Text/SearchInAllCategories", // 4
381 "Format/Option/UseReplacementTable", // 5
382 "Format/Option/TwoCapitalsAtStart", // 6
383 "Format/Option/CapitalAtStartSentence", // 7
384 "Format/Option/ChangeUnderlineWeight", // 8
385 "Format/Option/SetInetAttribute", // 9
386 "Format/Option/ChangeOrdinalNumber", //10
387 "Format/Option/AddNonBreakingSpace", //11
388 "Format/Option/ChangeDash", //12
389 "Format/Option/DelEmptyParagraphs", //13
390 "Format/Option/ReplaceUserStyle", //14
391 "Format/Option/ChangeToBullets/Enable", //15
392 "Format/Option/ChangeToBullets/SpecialCharacter/Char", //16
393 "Format/Option/ChangeToBullets/SpecialCharacter/Font", //17
394 "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily", //18
395 "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset", //19
396 "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch", //20
397 "Format/Option/CombineParagraphs", //21
398 "Format/Option/CombineValue", //22
399 "Format/Option/DelSpacesAtStartEnd", //23
400 "Format/Option/DelSpacesBetween", //24
401 "Format/ByInput/Enable", //25
402 "Format/ByInput/ChangeDash", //26
403 "Format/ByInput/ApplyNumbering/Enable", //27
404 "Format/ByInput/ChangeToBorders", //28
405 "Format/ByInput/ChangeToTable", //29
406 "Format/ByInput/ReplaceStyle", //30
407 "Format/ByInput/DelSpacesAtStartEnd", //31
408 "Format/ByInput/DelSpacesBetween", //32
409 "Completion/Enable", //33
410 "Completion/MinWordLen", //34
411 "Completion/MaxListLen", //35
412 "Completion/CollectWords", //36
413 "Completion/EndlessList", //37
414 "Completion/AppendBlank", //38
415 "Completion/ShowAsTip", //39
416 "Completion/AcceptKey", //40
417 "Completion/KeepList", //41
418 "Format/ByInput/ApplyNumbering/SpecialCharacter/Char", //42
419 "Format/ByInput/ApplyNumbering/SpecialCharacter/Font", //43
420 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //44
421 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //45
422 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", //46
423 "Format/Option/SetDOIAttribute", //47
424 "Format/ByInput/ApplyBulletsAfterSpace", //48
426 const int nCount = 49;
427 Sequence<OUString> aNames(nCount);
428 OUString* pNames = aNames.getArray();
429 for(int i = 0; i < nCount; i++)
430 pNames[i] = OUString::createFromAscii(aPropNames[i]);
431 return aNames;
434 void SvxSwAutoCorrCfg::Load(bool bInit)
436 Sequence<OUString> aNames = GetPropertyNames();
437 Sequence<Any> aValues = GetProperties(aNames);
438 if(bInit)
439 EnableNotification(aNames);
440 const Any* pValues = aValues.getConstArray();
441 DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed");
442 if(aValues.getLength() != aNames.getLength())
443 return;
445 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
446 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
448 if(pValues[nProp].hasValue())
450 switch(nProp)
452 case 0: rParent.bFileRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/FileLinks",
453 case 1: rParent.bNetRel = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/InternetLinks",
454 case 2: rParent.bAutoTextPreview = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowPreview",
455 case 3: rParent.bAutoTextTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Text/ShowToolTip",
456 case 4: rParent.bSearchInAllCategories = *o3tl::doAccess<bool>(pValues[nProp]); break; //"Text/SearchInAllCategories"
457 case 5: rSwFlags.bAutoCorrect = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/UseReplacementTable",
458 case 6: rSwFlags.bCapitalStartSentence = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/TwoCapitalsAtStart",
459 case 7: rSwFlags.bCapitalStartWord = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CapitalAtStartSentence",
460 case 8: rSwFlags.bChgWeightUnderl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeUnderlineWeight",
461 case 9: rSwFlags.bSetINetAttr = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/SetInetAttribute",
462 case 10: rSwFlags.bChgOrdinalNumber = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeOrdinalNumber",
463 case 11: rSwFlags.bAddNonBrkSpace = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/AddNonBreakingSpace",
464 // it doesn't exist here - the common flags are used for that -> LM
465 // case 12: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeDash",
466 case 13: rSwFlags.bDelEmptyNode = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelEmptyParagraphs",
467 case 14: rSwFlags.bChgUserColl = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ReplaceUserStyle",
468 case 15: rSwFlags.bChgEnumNum = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/ChangeToBullets/Enable",
469 case 16:
471 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
472 rSwFlags.cBullet =
473 sal::static_int_cast< sal_Unicode >(nVal);
475 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Char",
476 case 17:
478 OUString sTemp; pValues[nProp] >>= sTemp;
479 rSwFlags.aBulletFont.SetFamilyName(sTemp);
481 break; // "Format/Option/ChangeToBullets/SpecialCharacter/Font",
482 case 18:
484 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
485 rSwFlags.aBulletFont.SetFamily(FontFamily(nVal));
487 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily",
488 case 19:
490 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
491 rSwFlags.aBulletFont.SetCharSet(rtl_TextEncoding(nVal));
493 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset",
494 case 20:
496 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
497 rSwFlags.aBulletFont.SetPitch(FontPitch(nVal));
499 break; // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch",
500 case 21: rSwFlags.bRightMargin = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/CombineParagraphs",
501 case 22:
503 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
504 rSwFlags.nRightMargin =
505 sal::static_int_cast< sal_uInt8 >(nVal);
507 break; // "Format/Option/CombineValue",
508 case 23: rSwFlags.bAFormatDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesAtStartEnd",
509 case 24: rSwFlags.bAFormatDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/DelSpacesBetween",
510 case 25: rParent.bAutoFmtByInput = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/Enable",
511 case 26: rSwFlags.bChgToEnEmDash = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeDash",
512 case 27: rSwFlags.bSetNumRule = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumbering/Enable",
513 case 28: rSwFlags.bSetBorder = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToBorders",
514 case 29: rSwFlags.bCreateTable = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ChangeToTable",
515 case 30: rSwFlags.bReplaceStyles = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ReplaceStyle",
516 case 31: rSwFlags.bAFormatByInpDelSpacesAtSttEnd = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesAtStartEnd",
517 case 32: rSwFlags.bAFormatByInpDelSpacesBetweenLines = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/DelSpacesBetween",
518 case 33: rSwFlags.bAutoCompleteWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/Enable",
519 case 34:
521 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
522 rSwFlags.nAutoCmpltWordLen =
523 sal::static_int_cast< sal_uInt16 >(nVal);
525 break; // "Completion/MinWordLen",
526 case 35:
528 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
529 rSwFlags.nAutoCmpltListLen =
530 sal::static_int_cast< sal_uInt32 >(nVal);
532 break; // "Completion/MaxListLen",
533 case 36: rSwFlags.bAutoCmpltCollectWords = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/CollectWords",
534 case 37: rSwFlags.bAutoCmpltEndless = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/EndlessList",
535 case 38: rSwFlags.bAutoCmpltAppendBlank = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/AppendBlank",
536 case 39: rSwFlags.bAutoCmpltShowAsTip = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Completion/ShowAsTip",
537 case 40:
539 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
540 rSwFlags.nAutoCmpltExpandKey =
541 sal::static_int_cast< sal_uInt16 >(nVal);
543 break; // "Completion/AcceptKey"
544 case 41 :rSwFlags.bAutoCmpltKeepList = *o3tl::doAccess<bool>(pValues[nProp]); break;//"Completion/KeepList"
545 case 42 :
547 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
548 rSwFlags.cByInputBullet =
549 sal::static_int_cast< sal_Unicode >(nVal);
551 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Char",
552 case 43 :
554 OUString sTemp; pValues[nProp] >>= sTemp;
555 rSwFlags.aByInputBulletFont.SetFamilyName(sTemp);
557 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/Font",
558 case 44 :
560 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
561 rSwFlags.aByInputBulletFont.SetFamily(FontFamily(nVal));
563 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily",
564 case 45 :
566 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
567 rSwFlags.aByInputBulletFont.SetCharSet(rtl_TextEncoding(nVal));
569 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset",
570 case 46 :
572 sal_Int32 nVal = 0; pValues[nProp] >>= nVal;
573 rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal));
575 break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch",
576 case 47: rSwFlags.bSetDOIAttr = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/SetDOIAttribute",
577 case 48 : rSwFlags.bSetNumRuleAfterSpace = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/ByInput/ApplyNumberingAfterSpace",
583 SvxSwAutoCorrCfg::SvxSwAutoCorrCfg(SvxAutoCorrCfg& rPar) :
584 utl::ConfigItem("Office.Writer/AutoFunction"),
585 rParent(rPar)
589 SvxSwAutoCorrCfg::~SvxSwAutoCorrCfg()
593 void SvxSwAutoCorrCfg::ImplCommit()
595 SvxSwAutoFormatFlags& rSwFlags = rParent.pAutoCorrect->GetSwFlags();
596 PutProperties(
597 GetPropertyNames(),
598 {css::uno::Any(rParent.bFileRel), // "Text/FileLinks"
599 css::uno::Any(rParent.bNetRel), // "Text/InternetLinks"
600 css::uno::Any(rParent.bAutoTextPreview), // "Text/ShowPreview"
601 css::uno::Any(rParent.bAutoTextTip), // "Text/ShowToolTip"
602 css::uno::Any(rParent.bSearchInAllCategories),
603 // "Text/SearchInAllCategories"
604 css::uno::Any(rSwFlags.bAutoCorrect),
605 // "Format/Option/UseReplacementTable"
606 css::uno::Any(rSwFlags.bCapitalStartSentence),
607 // "Format/Option/TwoCapitalsAtStart"
608 css::uno::Any(rSwFlags.bCapitalStartWord),
609 // "Format/Option/CapitalAtStartSentence"
610 css::uno::Any(rSwFlags.bChgWeightUnderl),
611 // "Format/Option/ChangeUnderlineWeight"
612 css::uno::Any(rSwFlags.bSetINetAttr),
613 // "Format/Option/SetInetAttribute"
614 css::uno::Any(rSwFlags.bChgOrdinalNumber),
615 // "Format/Option/ChangeOrdinalNumber"
616 css::uno::Any(rSwFlags.bAddNonBrkSpace),
617 // "Format/Option/AddNonBreakingSpace"
618 css::uno::Any(true),
619 // "Format/Option/ChangeDash"; it doesn't exist here - the common
620 // flags are used for that -> LM
621 css::uno::Any(rSwFlags.bDelEmptyNode),
622 // "Format/Option/DelEmptyParagraphs"
623 css::uno::Any(rSwFlags.bChgUserColl),
624 // "Format/Option/ReplaceUserStyle"
625 css::uno::Any(rSwFlags.bChgEnumNum),
626 // "Format/Option/ChangeToBullets/Enable"
627 css::uno::Any(sal_Int32(rSwFlags.cBullet)),
628 // "Format/Option/ChangeToBullets/SpecialCharacter/Char"
629 css::uno::Any(rSwFlags.aBulletFont.GetFamilyName()),
630 // "Format/Option/ChangeToBullets/SpecialCharacter/Font"
631 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetFamilyType())),
632 // "Format/Option/ChangeToBullets/SpecialCharacter/FontFamily"
633 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetCharSet())),
634 // "Format/Option/ChangeToBullets/SpecialCharacter/FontCharset"
635 css::uno::Any(sal_Int32(rSwFlags.aBulletFont.GetPitch())),
636 // "Format/Option/ChangeToBullets/SpecialCharacter/FontPitch"
637 css::uno::Any(rSwFlags.bRightMargin),
638 // "Format/Option/CombineParagraphs"
639 css::uno::Any(sal_Int32(rSwFlags.nRightMargin)),
640 // "Format/Option/CombineValue"
641 css::uno::Any(rSwFlags.bAFormatDelSpacesAtSttEnd),
642 // "Format/Option/DelSpacesAtStartEnd"
643 css::uno::Any(rSwFlags.bAFormatDelSpacesBetweenLines),
644 // "Format/Option/DelSpacesBetween"
645 css::uno::Any(rParent.bAutoFmtByInput), // "Format/ByInput/Enable"
646 css::uno::Any(rSwFlags.bChgToEnEmDash), // "Format/ByInput/ChangeDash"
647 css::uno::Any(rSwFlags.bSetNumRule),
648 css::uno::Any(rSwFlags.bSetNumRuleAfterSpace),
649 // "Format/ByInput/ApplyNumbering/Enable"
650 css::uno::Any(rSwFlags.bSetBorder), // "Format/ByInput/ChangeToBorders"
651 css::uno::Any(rSwFlags.bCreateTable), // "Format/ByInput/ChangeToTable"
652 css::uno::Any(rSwFlags.bReplaceStyles),
653 // "Format/ByInput/ReplaceStyle"
654 css::uno::Any(rSwFlags.bAFormatByInpDelSpacesAtSttEnd),
655 // "Format/ByInput/DelSpacesAtStartEnd"
656 css::uno::Any(rSwFlags.bAFormatByInpDelSpacesBetweenLines),
657 // "Format/ByInput/DelSpacesBetween"
658 css::uno::Any(rSwFlags.bAutoCompleteWords), // "Completion/Enable"
659 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltWordLen)),
660 // "Completion/MinWordLen"
661 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltListLen)),
662 // "Completion/MaxListLen"
663 css::uno::Any(rSwFlags.bAutoCmpltCollectWords),
664 // "Completion/CollectWords"
665 css::uno::Any(rSwFlags.bAutoCmpltEndless), // "Completion/EndlessList"
666 css::uno::Any(rSwFlags.bAutoCmpltAppendBlank),
667 // "Completion/AppendBlank"
668 css::uno::Any(rSwFlags.bAutoCmpltShowAsTip), // "Completion/ShowAsTip"
669 css::uno::Any(sal_Int32(rSwFlags.nAutoCmpltExpandKey)),
670 // "Completion/AcceptKey"
671 css::uno::Any(rSwFlags.bAutoCmpltKeepList), // "Completion/KeepList"
672 css::uno::Any(sal_Int32(rSwFlags.cByInputBullet)),
673 // "Format/ByInput/ApplyNumbering/SpecialCharacter/Char"
674 css::uno::Any(rSwFlags.aByInputBulletFont.GetFamilyName()),
675 // "Format/ByInput/ApplyNumbering/SpecialCharacter/Font"
676 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetFamilyType())),
677 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily"
678 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetCharSet())),
679 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset"
680 css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch())),
681 // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch"
682 css::uno::Any(rSwFlags.bSetDOIAttr)});
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: */