LibreOffice Module cui (master)  1
autocdlg.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include <i18nutil/unicode.hxx>
21 #include <o3tl/safeint.hxx>
22 #include <vcl/event.hxx>
23 #include <vcl/keycodes.hxx>
24 #include <vcl/settings.hxx>
25 #include <vcl/transfer.hxx>
26 #include <sfx2/app.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <sfx2/viewsh.hxx>
29 #include <unotools/charclass.hxx>
32 #include <vcl/svapp.hxx>
33 #include <sfx2/module.hxx>
34 #include <svl/eitem.hxx>
35 #include <svl/cjkoptions.hxx>
36 #include <svl/ctloptions.hxx>
37 #include <svx/SmartTagMgr.hxx>
38 #include <com/sun/star/smarttags/XSmartTagRecognizer.hpp>
39 #include <rtl/strbuf.hxx>
40 #include <o3tl/temporary.hxx>
41 #include <osl/diagnose.h>
42 #include <tools/debug.hxx>
43 
44 #include <autocdlg.hxx>
45 #include <editeng/acorrcfg.hxx>
46 #include <editeng/svxacorr.hxx>
47 #include <cui/cuicharmap.hxx>
48 #include <strings.hrc>
49 #include <dialmgr.hxx>
50 #include <svx/svxids.hrc>
51 
53 
54 using namespace ::com::sun::star::util;
55 using namespace ::com::sun::star;
56 
58  : SfxTabDialogController(pParent, "cui/ui/autocorrectdialog.ui", "AutoCorrectDialog", _pSet)
59  , m_xLanguageBox(m_xBuilder->weld_widget("langbox"))
60  , m_xLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("lang")))
61 {
62  bool bShowSWOptions = false;
63  bool bOpenSmartTagOptions = false;
64 
65  if ( _pSet )
66  {
67  const SfxBoolItem* pItem = SfxItemSet::GetItem<SfxBoolItem>(_pSet, SID_AUTO_CORRECT_DLG, false);
68  if ( pItem && pItem->GetValue() )
69  bShowSWOptions = true;
70 
71  const SfxBoolItem* pItem2 = SfxItemSet::GetItem<SfxBoolItem>(_pSet, SID_OPEN_SMARTTAGOPTIONS, false);
72  if ( pItem2 && pItem2->GetValue() )
73  bOpenSmartTagOptions = true;
74  }
75 
76  AddTabPage("options", OfaAutocorrOptionsPage::Create, nullptr);
77  AddTabPage("applypage", OfaSwAutoFmtOptionsPage::Create, nullptr);
78  AddTabPage("wordcompletion", OfaAutoCompleteTabPage::Create, nullptr);
79  AddTabPage("smarttags", OfaSmartTagOptionsTabPage::Create, nullptr);
80 
81  if (!bShowSWOptions)
82  {
83  RemoveTabPage("applypage");
84  RemoveTabPage("wordcompletion");
85  RemoveTabPage("smarttags");
86  }
87  else
88  {
89  // remove smart tag tab page if no extensions are installed
91  SvxSwAutoFormatFlags& rOpt = pAutoCorrect->GetSwFlags();
92  if (!rOpt.pSmartTagMgr || 0 == rOpt.pSmartTagMgr->NumberOfRecognizers())
93  RemoveTabPage("smarttags");
94 
95  RemoveTabPage("options");
96  }
97 
98  AddTabPage("replace", OfaAutocorrReplacePage::Create, nullptr);
99  AddTabPage("exceptions", OfaAutocorrExceptPage::Create, nullptr);
100  AddTabPage("localized", OfaQuoteTabPage::Create, nullptr);
101 
102  // initialize languages
105  SvxLanguageListFlags nLangList = SvxLanguageListFlags::WESTERN;
106 
107  if( SvtCTLOptions().IsCTLFontEnabled() )
108  nLangList |= SvxLanguageListFlags::CTL;
110  nLangList |= SvxLanguageListFlags::CJK;
111  m_xLanguageLB->SetLanguageList( nLangList, true, true );
112  m_xLanguageLB->set_active_id( LANGUAGE_NONE );
113  int nPos = m_xLanguageLB->get_active();
114  DBG_ASSERT(nPos != -1, "listbox entry missing" );
115  m_xLanguageLB->set_id(nPos, LANGUAGE_UNDETERMINED);
116 
117  // Initializing doesn't work for static on linux - therefore here
118  if (LANGUAGE_SYSTEM == eLastDialogLanguage)
119  eLastDialogLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
120 
121  LanguageType nSelectLang = LANGUAGE_UNDETERMINED;
122  nPos = m_xLanguageLB->find_id(eLastDialogLanguage);
123  if (nPos != -1)
124  nSelectLang = eLastDialogLanguage;
125  m_xLanguageLB->set_active_id(nSelectLang);
126 
127  m_xLanguageLB->connect_changed(LINK(this, OfaAutoCorrDlg, SelectLanguageHdl));
128 
129  if ( bOpenSmartTagOptions )
130  SetCurPageId("smarttags");
131 }
132 
134 {
135 }
136 
138 {
139  m_xLanguageBox->set_sensitive(bEnable);
140 }
141 
142 static bool lcl_FindEntry(weld::TreeView& rLB, const OUString& rEntry,
143  CollatorWrapper const & rCmpClass)
144 {
145  int nCount = rLB.n_children();
146  int nSelPos = rLB.get_selected_index();
147  for (int i = 0; i < nCount; i++)
148  {
149  if (0 == rCmpClass.compareString(rEntry, rLB.get_text(i)))
150  {
151  rLB.select(i);
152  return true;
153  }
154  }
155  if (nSelPos != -1)
156  rLB.unselect(nSelPos);
157  return false;
158 }
159 
160 IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox&, void)
161 {
162  LanguageType eNewLang = m_xLanguageLB->get_active_id();
163  // save old settings and fill anew
164  if(eNewLang == eLastDialogLanguage)
165  return;
166 
167  OString sPageId = GetCurPageId();
168  if (sPageId == "replace")
169  {
170  OfaAutocorrReplacePage* pPage = static_cast<OfaAutocorrReplacePage*>(GetTabPage(sPageId));
171  assert(pPage);
172  pPage->SetLanguage(eNewLang);
173  }
174  else if (sPageId == "exceptions")
175  {
176  OfaAutocorrExceptPage* pPage = static_cast<OfaAutocorrExceptPage*>(GetTabPage(sPageId));
177  assert(pPage);
178  pPage->SetLanguage(eNewLang);
179  }
180 }
181 
183  : SfxTabPage(pPage, pController, "cui/ui/acoroptionspage.ui", "AutocorrectOptionsPage", &rSet)
184  , m_sInput(CuiResId(RID_CUISTR_USE_REPLACE))
185  , m_sDoubleCaps(CuiResId(RID_CUISTR_CPTL_STT_WORD))
186  , m_sStartCap(CuiResId(RID_CUISTR_CPTL_STT_SENT))
187  , m_sBoldUnderline(CuiResId(RID_CUISTR_BOLD_UNDER))
188  , m_sURL(CuiResId(RID_CUISTR_DETECT_URL))
189  , m_sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES))
190  , m_sDash(CuiResId(RID_CUISTR_DASH))
191  , m_sAccidentalCaps(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK))
192  , m_xCheckLB(m_xBuilder->weld_tree_view("checklist"))
193 {
194  m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
195  m_xCheckLB->set_size_request(-1, m_xCheckLB->get_height_rows(10));
196 }
197 
199 {
200 }
201 
202 std::unique_ptr<SfxTabPage> OfaAutocorrOptionsPage::Create(weld::Container* pPage, weld::DialogController* pController,
203  const SfxItemSet* rSet)
204 {
205  return std::make_unique<OfaAutocorrOptionsPage>(pPage, pController, *rSet);
206 }
207 
208 #define CBCOL_FIRST 0
209 #define CBCOL_SECOND 1
210 #define CBCOL_BOTH 2
211 
213 {
215  ACFlags nFlags = pAutoCorrect->GetFlags();
216 
217  int nPos = 0;
218  pAutoCorrect->SetAutoCorrFlag(ACFlags::Autocorrect, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
219  pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartWord, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
220  pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
221  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
222  pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
223  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
224  pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
225  pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
226 
227  bool bReturn = nFlags != pAutoCorrect->GetFlags();
228  if(bReturn )
229  {
231  rCfg.SetModified();
232  rCfg.Commit();
233  }
234  return bReturn;
235 }
236 
238 {
239  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(false);
240 }
241 
242 void OfaAutocorrOptionsPage::InsertEntry(const OUString& rTxt)
243 {
244  m_xCheckLB->append();
245  const int nRow = m_xCheckLB->n_children() - 1;
246  m_xCheckLB->set_toggle(nRow, TRISTATE_FALSE);
247  m_xCheckLB->set_text(nRow, rTxt, 0);
248 }
249 
251 {
253  const ACFlags nFlags = pAutoCorrect->GetFlags();
254 
255  m_xCheckLB->freeze();
256  m_xCheckLB->clear();
257 
266 
267  int nPos = 0;
268  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::Autocorrect) ? TRISTATE_TRUE : TRISTATE_FALSE );
269  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CapitalStartWord) ? TRISTATE_TRUE : TRISTATE_FALSE );
270  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CapitalStartSentence) ? TRISTATE_TRUE : TRISTATE_FALSE );
271  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE );
272  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE );
273  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE );
274  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE );
275  m_xCheckLB->set_toggle( nPos++, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE );
276 
277  m_xCheckLB->thaw();
278 }
279 
280 /*********************************************************************/
281 /* */
282 /* helping struct for dUserData of the Checklistbox */
283 /* */
284 /*********************************************************************/
285 
286 namespace {
287 
288 struct ImpUserData
289 {
290  OUString *pString;
291  vcl::Font *pFont;
292 
293  ImpUserData(OUString* pText, vcl::Font* pFnt)
294  { pString = pText; pFont = pFnt;}
295 };
296 
297 
298 /*********************************************************************/
299 /* */
300 /* dialog for per cent settings */
301 /* */
302 /*********************************************************************/
303 
304 class OfaAutoFmtPrcntSet : public weld::GenericDialogController
305 {
306  std::unique_ptr<weld::MetricSpinButton> m_xPrcntMF;
307 public:
308  explicit OfaAutoFmtPrcntSet(weld::Window* pParent)
309  : GenericDialogController(pParent, "cui/ui/percentdialog.ui", "PercentDialog")
310  , m_xPrcntMF(m_xBuilder->weld_metric_spin_button("margin", FieldUnit::PERCENT))
311  {
312  }
313 
314  weld::MetricSpinButton& GetPrcntFld()
315  {
316  return *m_xPrcntMF;
317  }
318 };
319 
320 /*********************************************************************/
321 /* */
322 /* use TabPage autoformat */
323 /* */
324 /*********************************************************************/
325 
327 {
328  USE_REPLACE_TABLE,
329  CORR_UPPER,
330  BEGIN_UPPER,
331  BOLD_UNDERLINE,
332  DETECT_URL,
333  REPLACE_DASHES,
334  DEL_SPACES_AT_STT_END,
335  DEL_SPACES_BETWEEN_LINES,
336  IGNORE_DBLSPACE,
337  CORRECT_CAPS_LOCK,
338  APPLY_NUMBERING,
339  INSERT_BORDER,
340  CREATE_TABLE,
341  REPLACE_STYLES,
342  DEL_EMPTY_NODE,
343  REPLACE_USER_COLL,
344  REPLACE_BULLETS,
345  MERGE_SINGLE_LINE_PARA
346 };
347 
348 }
349 
351  const SfxItemSet& rSet )
352  : SfxTabPage(pPage, pController, "cui/ui/applyautofmtpage.ui", "ApplyAutoFmtPage", &rSet)
353  , sDeleteEmptyPara(CuiResId(RID_CUISTR_DEL_EMPTY_PARA))
354  , sUseReplaceTbl(CuiResId(RID_CUISTR_USE_REPLACE))
355  , sCapitalStartWord(CuiResId(RID_CUISTR_CPTL_STT_WORD))
356  , sCapitalStartSentence(CuiResId(RID_CUISTR_CPTL_STT_SENT))
357  , sUserStyle(CuiResId(RID_CUISTR_USER_STYLE))
358  , sBullet(CuiResId(RID_CUISTR_BULLET))
359  , sBoldUnder(CuiResId(RID_CUISTR_BOLD_UNDER))
360  , sNoDblSpaces(CuiResId(RID_CUISTR_NO_DBL_SPACES))
361  , sCorrectCapsLock(CuiResId(RID_CUISTR_CORRECT_ACCIDENTAL_CAPS_LOCK))
362  , sDetectURL(CuiResId(RID_CUISTR_DETECT_URL))
363  , sDash(CuiResId(RID_CUISTR_DASH))
364  , sRightMargin(CuiResId(RID_CUISTR_RIGHT_MARGIN))
365  , sNum(CuiResId(RID_CUISTR_NUM))
366  , sBorder(CuiResId(RID_CUISTR_BORDER))
367  , sTable(CuiResId(RID_CUISTR_CREATE_TABLE))
368  , sReplaceTemplates(CuiResId(RID_CUISTR_REPLACE_TEMPLATES))
369  , sDelSpaceAtSttEnd(CuiResId(RID_CUISTR_DEL_SPACES_AT_STT_END))
370  , sDelSpaceBetweenLines(CuiResId(RID_CUISTR_DEL_SPACES_BETWEEN_LINES))
371  , nPercent(50)
372  , m_xCheckLB(m_xBuilder->weld_tree_view("list"))
373  , m_xEditPB(m_xBuilder->weld_button("edit"))
374 {
375  m_xCheckLB->connect_changed(LINK(this, OfaSwAutoFmtOptionsPage, SelectHdl));
376  m_xCheckLB->connect_row_activated(LINK(this, OfaSwAutoFmtOptionsPage, DoubleClickEditHdl));
377  m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
378 
379  std::vector<int> aWidths
380  {
381  o3tl::narrowing<int>(m_xCheckLB->get_pixel_size(m_xCheckLB->get_column_title(0)).Width() * 2),
382  o3tl::narrowing<int>(m_xCheckLB->get_pixel_size(m_xCheckLB->get_column_title(1)).Width() * 2)
383  };
384  m_xCheckLB->set_column_fixed_widths(aWidths);
385 
386  m_xEditPB->connect_clicked(LINK(this, OfaSwAutoFmtOptionsPage, EditHdl));
387 }
388 
389 void OfaSwAutoFmtOptionsPage::CreateEntry(const OUString& rTxt, sal_uInt16 nCol)
390 {
391  m_xCheckLB->append();
392  const int nRow = m_xCheckLB->n_children() - 1;
393  if (nCol == CBCOL_FIRST || nCol == CBCOL_BOTH)
394  m_xCheckLB->set_toggle(nRow, TRISTATE_FALSE, CBCOL_FIRST);
395  if (nCol == CBCOL_SECOND || nCol == CBCOL_BOTH)
396  m_xCheckLB->set_toggle(nRow, TRISTATE_FALSE, CBCOL_SECOND);
397  m_xCheckLB->set_text(nRow, rTxt, 2);
398 }
399 
401 {
402  delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(REPLACE_BULLETS));
403  delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(APPLY_NUMBERING));
404  delete weld::fromId<ImpUserData*>(m_xCheckLB->get_id(MERGE_SINGLE_LINE_PARA));
405 }
406 
407 std::unique_ptr<SfxTabPage> OfaSwAutoFmtOptionsPage::Create(weld::Container* pPage, weld::DialogController* pController,
408  const SfxItemSet* rAttrSet)
409 {
410  return std::make_unique<OfaSwAutoFmtOptionsPage>(pPage, pController, *rAttrSet);
411 }
412 
414 {
415  bool bModified = false;
417  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
418  ACFlags nFlags = pAutoCorrect->GetFlags();
419 
420  bool bCheck = m_xCheckLB->get_toggle(USE_REPLACE_TABLE, CBCOL_FIRST) == TRISTATE_TRUE;
421  bModified |= pOpt->bAutoCorrect != bCheck;
422  pOpt->bAutoCorrect = bCheck;
423  pAutoCorrect->SetAutoCorrFlag(ACFlags::Autocorrect,
424  m_xCheckLB->get_toggle(USE_REPLACE_TABLE, CBCOL_SECOND) == TRISTATE_TRUE);
425 
426  bCheck = m_xCheckLB->get_toggle(CORR_UPPER, CBCOL_FIRST) == TRISTATE_TRUE;
427  bModified |= pOpt->bCapitalStartWord != bCheck;
428  pOpt->bCapitalStartWord = bCheck;
429  pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartWord,
430  m_xCheckLB->get_toggle(CORR_UPPER, CBCOL_SECOND) == TRISTATE_TRUE);
431 
432  bCheck = m_xCheckLB->get_toggle(BEGIN_UPPER, CBCOL_FIRST) == TRISTATE_TRUE;
433  bModified |= pOpt->bCapitalStartSentence != bCheck;
434  pOpt->bCapitalStartSentence = bCheck;
435  pAutoCorrect->SetAutoCorrFlag(ACFlags::CapitalStartSentence,
436  m_xCheckLB->get_toggle(BEGIN_UPPER, CBCOL_SECOND) == TRISTATE_TRUE);
437 
438  bCheck = m_xCheckLB->get_toggle(BOLD_UNDERLINE, CBCOL_FIRST) == TRISTATE_TRUE;
439  bModified |= pOpt->bChgWeightUnderl != bCheck;
440  pOpt->bChgWeightUnderl = bCheck;
441  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgWeightUnderl,
442  m_xCheckLB->get_toggle(BOLD_UNDERLINE, CBCOL_SECOND) == TRISTATE_TRUE);
443 
444  pAutoCorrect->SetAutoCorrFlag(ACFlags::IgnoreDoubleSpace,
445  m_xCheckLB->get_toggle(IGNORE_DBLSPACE, CBCOL_SECOND) == TRISTATE_TRUE);
446 
447  pAutoCorrect->SetAutoCorrFlag(ACFlags::CorrectCapsLock,
448  m_xCheckLB->get_toggle(CORRECT_CAPS_LOCK, CBCOL_SECOND) == TRISTATE_TRUE);
449 
450  bCheck = m_xCheckLB->get_toggle(DETECT_URL, CBCOL_FIRST) == TRISTATE_TRUE;
451  bModified |= pOpt->bSetINetAttr != bCheck;
452  pOpt->bSetINetAttr = bCheck;
453  pAutoCorrect->SetAutoCorrFlag(ACFlags::SetINetAttr,
454  m_xCheckLB->get_toggle(DETECT_URL, CBCOL_SECOND) == TRISTATE_TRUE);
455 
456  bCheck = m_xCheckLB->get_toggle(DEL_EMPTY_NODE, CBCOL_FIRST) == TRISTATE_TRUE;
457  bModified |= pOpt->bDelEmptyNode != bCheck;
458  pOpt->bDelEmptyNode = bCheck;
459 
460  bCheck = m_xCheckLB->get_toggle(REPLACE_USER_COLL, CBCOL_FIRST) == TRISTATE_TRUE;
461  bModified |= pOpt->bChgUserColl != bCheck;
462  pOpt->bChgUserColl = bCheck;
463 
464  bCheck = m_xCheckLB->get_toggle(REPLACE_BULLETS, CBCOL_FIRST) == TRISTATE_TRUE;
465  bModified |= pOpt->bChgEnumNum != bCheck;
466  pOpt->bChgEnumNum = bCheck;
467  bModified |= aBulletFont != pOpt->aBulletFont;
468  pOpt->aBulletFont = aBulletFont;
469  bModified |= sBulletChar != OUString(&pOpt->cBullet, 1);
470  pOpt->cBullet = sBulletChar.iterateCodePoints(&o3tl::temporary(sal_Int32(0)));
471 
472  bModified |= aByInputBulletFont != pOpt->aByInputBulletFont;
473  bModified |= sByInputBulletChar != OUString(&pOpt->cByInputBullet, 1);
475  pOpt->cByInputBullet = sByInputBulletChar.iterateCodePoints(&o3tl::temporary(sal_Int32(0)));
476 
477  bCheck = m_xCheckLB->get_toggle(MERGE_SINGLE_LINE_PARA, CBCOL_FIRST) == TRISTATE_TRUE;
478  bModified |= pOpt->bRightMargin != bCheck;
479  pOpt->bRightMargin = bCheck;
480  bModified |= nPercent != pOpt->nRightMargin;
481  pOpt->nRightMargin = static_cast<sal_uInt8>(nPercent);
482 
483  bCheck = m_xCheckLB->get_toggle(APPLY_NUMBERING, CBCOL_SECOND) == TRISTATE_TRUE;
484  bModified |= pOpt->bSetNumRule != bCheck;
485  pOpt->bSetNumRule = bCheck;
486 
487  bCheck = m_xCheckLB->get_toggle(INSERT_BORDER, CBCOL_SECOND) == TRISTATE_TRUE;
488  bModified |= pOpt->bSetBorder != bCheck;
489  pOpt->bSetBorder = bCheck;
490 
491  bCheck = m_xCheckLB->get_toggle(CREATE_TABLE, CBCOL_SECOND) == TRISTATE_TRUE;
492  bModified |= pOpt->bCreateTable != bCheck;
493  pOpt->bCreateTable = bCheck;
494 
495  bCheck = m_xCheckLB->get_toggle(REPLACE_STYLES, CBCOL_SECOND) == TRISTATE_TRUE;
496  bModified |= pOpt->bReplaceStyles != bCheck;
497  pOpt->bReplaceStyles = bCheck;
498 
499  bCheck = m_xCheckLB->get_toggle(REPLACE_DASHES, CBCOL_FIRST) == TRISTATE_TRUE;
500  bModified |= pOpt->bChgToEnEmDash != bCheck;
501  pOpt->bChgToEnEmDash = bCheck;
502  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgToEnEmDash,
503  m_xCheckLB->get_toggle(REPLACE_DASHES, CBCOL_SECOND) == TRISTATE_TRUE);
504 
505  bCheck = m_xCheckLB->get_toggle(DEL_SPACES_AT_STT_END, CBCOL_FIRST) == TRISTATE_TRUE;
506  bModified |= pOpt->bAFormatDelSpacesAtSttEnd != bCheck;
507  pOpt->bAFormatDelSpacesAtSttEnd = bCheck;
508  bCheck = m_xCheckLB->get_toggle(DEL_SPACES_AT_STT_END, CBCOL_SECOND) == TRISTATE_TRUE;
509  bModified |= pOpt->bAFormatByInpDelSpacesAtSttEnd != bCheck;
510  pOpt->bAFormatByInpDelSpacesAtSttEnd = bCheck;
511 
512  bCheck = m_xCheckLB->get_toggle(DEL_SPACES_BETWEEN_LINES, CBCOL_FIRST) == TRISTATE_TRUE;
513  bModified |= pOpt->bAFormatDelSpacesBetweenLines != bCheck;
514  pOpt->bAFormatDelSpacesBetweenLines = bCheck;
515  bCheck = m_xCheckLB->get_toggle(DEL_SPACES_BETWEEN_LINES, CBCOL_SECOND) == TRISTATE_TRUE;
516  bModified |= pOpt->bAFormatByInpDelSpacesBetweenLines != bCheck;
517  pOpt->bAFormatByInpDelSpacesBetweenLines = bCheck;
518 
519  if(bModified || nFlags != pAutoCorrect->GetFlags())
520  {
522  rCfg.SetModified();
523  rCfg.Commit();
524  }
525 
526  return true;
527 }
528 
530 {
531  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(false);
532 }
533 
535 {
537  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
538  const ACFlags nFlags = pAutoCorrect->GetFlags();
539 
540  aBulletFont = pOpt->aBulletFont;
541  sBulletChar = OUString(&pOpt->cBullet, 1);
542 
544  sByInputBulletChar = OUString(&pOpt->cByInputBullet, 1);
545 
546  nPercent = pOpt->nRightMargin;
548 
549  m_xCheckLB->freeze();
550  m_xCheckLB->clear();
551 
552  // The following entries have to be inserted in the same order
553  // as in the OfaAutoFmtOptions-enum!
562 
565  CreateEntry(sNum.replaceFirst("%1", sBulletChar), CBCOL_SECOND);
571  CreateEntry(sBullet.replaceFirst("%1", sByInputBulletChar), CBCOL_FIRST);
572  CreateEntry(sRightMargin.replaceFirst("%1", sMargin), CBCOL_FIRST);
573 
574  m_xCheckLB->set_toggle(USE_REPLACE_TABLE, pOpt->bAutoCorrect ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
575  m_xCheckLB->set_toggle(USE_REPLACE_TABLE, bool(nFlags & ACFlags::Autocorrect) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
576  m_xCheckLB->set_toggle(CORR_UPPER, pOpt->bCapitalStartWord ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
577  m_xCheckLB->set_toggle(CORR_UPPER, bool(nFlags & ACFlags::CapitalStartWord) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
578  m_xCheckLB->set_toggle(BEGIN_UPPER, pOpt->bCapitalStartSentence ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
579  m_xCheckLB->set_toggle(BEGIN_UPPER, bool(nFlags & ACFlags::CapitalStartSentence) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
580  m_xCheckLB->set_toggle(BOLD_UNDERLINE, pOpt->bChgWeightUnderl ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
581  m_xCheckLB->set_toggle(BOLD_UNDERLINE, bool(nFlags & ACFlags::ChgWeightUnderl) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
582  m_xCheckLB->set_toggle(DETECT_URL, pOpt->bSetINetAttr ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
583  m_xCheckLB->set_toggle(DETECT_URL, bool(nFlags & ACFlags::SetINetAttr) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
584  m_xCheckLB->set_toggle(REPLACE_DASHES, pOpt->bChgToEnEmDash ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
585  m_xCheckLB->set_toggle(REPLACE_DASHES, bool(nFlags & ACFlags::ChgToEnEmDash) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
586  m_xCheckLB->set_toggle(DEL_SPACES_AT_STT_END, pOpt->bAFormatDelSpacesAtSttEnd ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
587  m_xCheckLB->set_toggle(DEL_SPACES_AT_STT_END, pOpt->bAFormatByInpDelSpacesAtSttEnd ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
588  m_xCheckLB->set_toggle(DEL_SPACES_BETWEEN_LINES, pOpt->bAFormatDelSpacesBetweenLines ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
589  m_xCheckLB->set_toggle(DEL_SPACES_BETWEEN_LINES, pOpt->bAFormatByInpDelSpacesBetweenLines ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
590  m_xCheckLB->set_toggle(IGNORE_DBLSPACE, bool(nFlags & ACFlags::IgnoreDoubleSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
591  m_xCheckLB->set_toggle(CORRECT_CAPS_LOCK, bool(nFlags & ACFlags::CorrectCapsLock) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
592  m_xCheckLB->set_toggle(APPLY_NUMBERING, pOpt->bSetNumRule ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
593  m_xCheckLB->set_toggle(INSERT_BORDER, pOpt->bSetBorder ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
594  m_xCheckLB->set_toggle(CREATE_TABLE, pOpt->bCreateTable ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
595  m_xCheckLB->set_toggle(REPLACE_STYLES, pOpt->bReplaceStyles ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
596  m_xCheckLB->set_toggle(DEL_EMPTY_NODE, pOpt->bDelEmptyNode ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
597  m_xCheckLB->set_toggle(REPLACE_USER_COLL, pOpt->bChgUserColl ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
598  m_xCheckLB->set_toggle(REPLACE_BULLETS, pOpt->bChgEnumNum ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
599  m_xCheckLB->set_toggle(MERGE_SINGLE_LINE_PARA, pOpt->bRightMargin ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
600 
601  ImpUserData* pUserData = new ImpUserData(&sBulletChar, &aBulletFont);
602  OUString sId(weld::toId(pUserData));
603  m_xCheckLB->set_id(REPLACE_BULLETS, sId);
604 
605  pUserData = new ImpUserData(&sMargin, nullptr);
606  sId = weld::toId(pUserData);
607  m_xCheckLB->set_id(MERGE_SINGLE_LINE_PARA, sId);
608 
609  ImpUserData* pUserData2 = new ImpUserData(&sByInputBulletChar, &aByInputBulletFont);
610  sId = weld::toId(pUserData2);
611  m_xCheckLB->set_id(APPLY_NUMBERING, sId);
612 
613  m_xCheckLB->thaw();
614 }
615 
617 {
618  m_xEditPB->set_sensitive(rBox.get_selected_id().toInt64() != 0);
619 }
620 
622 {
623  EditHdl(*m_xEditPB);
624  return true;
625 }
626 
628 {
629  int nSelEntryPos = m_xCheckLB->get_selected_index();
630  if (nSelEntryPos == REPLACE_BULLETS || nSelEntryPos == APPLY_NUMBERING)
631  {
632  SvxCharacterMap aMapDlg(GetFrameWeld(), nullptr, nullptr);
633  ImpUserData* pUserData = weld::fromId<ImpUserData*>(m_xCheckLB->get_id(nSelEntryPos));
634  aMapDlg.SetCharFont(*pUserData->pFont);
635  aMapDlg.SetChar( (*pUserData->pString)[0] );
636  if (RET_OK == aMapDlg.run())
637  {
638  const vcl::Font& aFont(aMapDlg.GetCharFont());
639  *pUserData->pFont = aFont;
640  sal_UCS4 aChar = aMapDlg.GetChar();
641  // using the UCS4 constructor
642  OUString aOUStr( &aChar, 1 );
643  *pUserData->pString = aOUStr;
644  if (nSelEntryPos == REPLACE_BULLETS)
645  m_xCheckLB->set_text(nSelEntryPos, sNum.replaceFirst("%1", aOUStr), 2);
646  else
647  m_xCheckLB->set_text(nSelEntryPos, sBullet.replaceFirst("%1", aOUStr), 2);
648  }
649  }
650  else if( MERGE_SINGLE_LINE_PARA == nSelEntryPos )
651  {
652  // dialog for per cent settings
653  OfaAutoFmtPrcntSet aDlg(GetFrameWeld());
654  aDlg.GetPrcntFld().set_value(nPercent, FieldUnit::PERCENT);
655  if (aDlg.run() == RET_OK)
656  {
657  nPercent = static_cast<sal_uInt16>(aDlg.GetPrcntFld().get_value(FieldUnit::PERCENT));
659  m_xCheckLB->set_text(nSelEntryPos, sRightMargin.replaceFirst("%1", sMargin), 2);
660  }
661  }
662 }
663 
664 
666  const SfxItemSet& rSet)
667  : SfxTabPage(pPage, pController, "cui/ui/acorreplacepage.ui", "AcorReplacePage", &rSet)
668  , eLang(eLastDialogLanguage)
669  , bHasSelectionText(false)
670  , bFirstSelect(true)
671  , bReplaceEditChanged(false)
672  , bSWriter(true)
673  , m_xTextOnlyCB(m_xBuilder->weld_check_button("textonly"))
674  , m_xShortED(m_xBuilder->weld_entry("origtext"))
675  , m_xReplaceED(m_xBuilder->weld_entry("newtext"))
676  , m_xReplaceTLB(m_xBuilder->weld_tree_view("tabview"))
677  , m_xNewReplacePB(m_xBuilder->weld_button("new"))
678  , m_xReplacePB(m_xBuilder->weld_button("replace"))
679  , m_xDeleteReplacePB(m_xBuilder->weld_button("delete"))
680  , m_xButtonBox(m_xBuilder->weld_container("buttonbox"))
681 {
682  sNew = m_xNewReplacePB->get_label();
683  sModify = m_xReplacePB->get_label();
684 
685  // lock down the width of the button box to its max
686  // desired width
687  auto nMaxWidth = m_xButtonBox->get_preferred_size().Width();
688  m_xButtonBox->set_size_request(nMaxWidth, -1);
689  m_xReplacePB->hide();
690 
691  // tdf#125348 set some small but fixed initial width size, final width will
692  // depend on the size of the entry boxes
693  m_xReplaceTLB->set_size_request(42, m_xReplaceTLB->get_height_rows(10));
694 
695  SfxModule *pMod = SfxApplication::GetModule(SfxToolsModule::Writer);
697 
698  LanguageTag aLanguageTag( eLastDialogLanguage );
700  pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 );
701  pCharClass.reset( new CharClass( aLanguageTag ) );
702 
703  auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32;
704  m_aReplaceFixedWidths.push_back(nColWidth);
705  m_aReplaceFixedWidths.push_back(nColWidth);
706 
707  m_xReplaceTLB->connect_changed( LINK(this, OfaAutocorrReplacePage, SelectHdl) );
708  m_xNewReplacePB->connect_clicked( LINK(this, OfaAutocorrReplacePage, NewDelButtonHdl) );
709  m_xDeleteReplacePB->connect_clicked( LINK(this, OfaAutocorrReplacePage, NewDelButtonHdl) );
710  m_xShortED->connect_changed( LINK(this, OfaAutocorrReplacePage, ModifyHdl) );
711  m_xReplaceED->connect_changed( LINK(this, OfaAutocorrReplacePage, ModifyHdl) );
712  m_xShortED->connect_activate( LINK(this, OfaAutocorrReplacePage, NewDelActionHdl) );
713  m_xReplaceED->connect_activate( LINK(this, OfaAutocorrReplacePage, NewDelActionHdl) );
714  m_xShortED->connect_size_allocate(LINK(this, OfaAutocorrReplacePage, EntrySizeAllocHdl));
715  m_xReplaceED->connect_size_allocate(LINK(this, OfaAutocorrReplacePage, EntrySizeAllocHdl));
716 }
717 
719 {
720  aDoubleStringTable.clear();
721  aChangesTable.clear();
722 
723  pCompareClass.reset();
724  pCharClass.reset();
725 }
726 
727 std::unique_ptr<SfxTabPage> OfaAutocorrReplacePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
728 {
729  return std::make_unique<OfaAutocorrReplacePage>(pPage, pController, *rSet);
730 }
731 
733 {
734  if(eLang != eLastDialogLanguage)
735  SetLanguage(eLastDialogLanguage);
736  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(true);
737 }
738 
740 {
741  return DeactivateRC::LeavePage;
742 }
743 
745 {
747 
748  for (StringChangeTable::reverse_iterator it = aChangesTable.rbegin(); it != aChangesTable.rend(); ++it)
749  {
750  LanguageType eCurrentLang = it->first;
751  StringChangeList& rStringChangeList = it->second;
752  std::vector<SvxAutocorrWord> aDeleteWords;
753  std::vector<SvxAutocorrWord> aNewWords;
754 
755  aDeleteWords.reserve( rStringChangeList.aDeletedEntries.size() );
756  for (const DoubleString & deleteEntry : rStringChangeList.aDeletedEntries)
757  {
758  SvxAutocorrWord aDeleteWord( deleteEntry.sShort, deleteEntry.sLong );
759  aDeleteWords.push_back( aDeleteWord );
760  }
761 
762  aNewWords.reserve( rStringChangeList.aNewEntries.size() );
763  for (const DoubleString & newEntry : rStringChangeList.aNewEntries)
764  {
765  //fdo#67697 if the user data is set then we want to retain the
766  //source formatting of the entry, so don't use the optimized
767  //text-only MakeCombinedChanges for this entry
768  bool bKeepSourceFormatting = newEntry.pUserData == &bHasSelectionText;
769  if (bKeepSourceFormatting)
770  {
771  pAutoCorrect->PutText(newEntry.sShort, *SfxObjectShell::Current(), eCurrentLang);
772  continue;
773  }
774 
775  SvxAutocorrWord aNewWord( newEntry.sShort, newEntry.sLong );
776  aNewWords.push_back( aNewWord );
777  }
778  pAutoCorrect->MakeCombinedChanges( aNewWords, aDeleteWords, eCurrentLang );
779  }
780  aChangesTable.clear();
781  return false;
782 }
783 
785  LanguageType eOldLanguage,
786  LanguageType eNewLanguage)
787 {
788  eLang = eNewLanguage;
789  if(bFromReset)
790  {
791  aDoubleStringTable.clear();
792  aChangesTable.clear();
793  }
794  else
795  {
796  DoubleStringArray* pArray;
797  if(aDoubleStringTable.find(eOldLanguage) != aDoubleStringTable.end())
798  {
799  pArray = &aDoubleStringTable[eOldLanguage];
800  pArray->clear();
801  }
802  else
803  {
804  pArray = &aDoubleStringTable[eOldLanguage]; // create new array
805  }
806 
807  m_xReplaceTLB->all_foreach([this, &pArray](weld::TreeIter& rIter) {
808  pArray->push_back(DoubleString(m_xReplaceTLB->get_text(rIter, 0),
809  m_xReplaceTLB->get_text(rIter, 1)));
810  DoubleString& rDouble = pArray->back();
811  rDouble.pUserData = weld::fromId<void*>(m_xReplaceTLB->get_id(rIter));
812  return false;
813  });
814  }
815 
816  if( !bSWriter )
817  aFormatText.clear();
818 
819  if (aDoubleStringTable.find(eLang) != aDoubleStringTable.end())
820  {
821  DoubleStringArray& rArray = aDoubleStringTable[eNewLanguage];
822 
823  m_xReplaceTLB->bulk_insert_for_each(rArray.size(), [this, &rArray](weld::TreeIter& rIter, int nIndex) {
824  DoubleString &rDouble = rArray[nIndex];
825  bool bTextOnly = nullptr == rDouble.pUserData;
826  // formatted text is only in Writer
827  if (bSWriter || bTextOnly)
828  {
829  if (!bTextOnly)
830  {
831  // that means: with format info or even with selection text
832  OUString sId = weld::toId(rDouble.pUserData);
833  m_xReplaceTLB->set_id(rIter, sId);
834  }
835  m_xReplaceTLB->set_text(rIter, rDouble.sShort, 0);
836  m_xReplaceTLB->set_text(rIter, rDouble.sLong, 1);
837  }
838  else
839  {
840  aFormatText.insert(rDouble.sShort);
841  }
842  }, nullptr, &m_aReplaceFixedWidths);
843  }
844  else
845  {
847  SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
848  const SvxAutocorrWordList::AutocorrWordSetType & rContent = pWordList->getSortedContent();
849  m_xReplaceTLB->bulk_insert_for_each(rContent.size(), [this, rContent](weld::TreeIter& rIter, int nIndex) {
850  auto const& elem = rContent[nIndex];
851  bool bTextOnly = elem.IsTextOnly();
852  // formatted text is only in Writer
853  if (bSWriter || bTextOnly)
854  {
855  if (!bTextOnly)
856  {
857  // that means: with format info or even with selection text
858  OUString sId = weld::toId(m_xTextOnlyCB.get());
859  m_xReplaceTLB->set_id(rIter, sId);
860  }
861  m_xReplaceTLB->set_text(rIter, elem.GetShort(), 0);
862  m_xReplaceTLB->set_text(rIter, elem.GetLong(), 1);
863  }
864  else
865  {
866  aFormatText.insert(elem.GetShort());
867  }
868  }, nullptr, &m_aReplaceFixedWidths);
869  m_xNewReplacePB->set_sensitive(false);
870  m_xDeleteReplacePB->set_sensitive(false);
871  }
872 
873  SfxViewShell* pViewShell = SfxViewShell::Current();
874  if (pViewShell && pViewShell->HasSelection())
875  {
876  bHasSelectionText = true;
877  const OUString sSelection( pViewShell->GetSelectionText() );
878  m_xReplaceED->set_text(sSelection);
879  m_xTextOnlyCB->set_active(!bSWriter);
880  m_xTextOnlyCB->set_sensitive(bSWriter && !sSelection.isEmpty());
881  }
882  else
883  {
884  m_xTextOnlyCB->set_active(true);
885  m_xTextOnlyCB->set_sensitive(false);
886  }
887 }
888 
890 {
891  RefillReplaceBox(true, eLang, eLang);
892  m_xShortED->grab_focus();
893 }
894 
896 {
897  //save old settings and refill
898  if(eSet != eLang)
899  {
900  RefillReplaceBox(false, eLang, eSet);
901  eLastDialogLanguage = eSet;
902 
903  LanguageTag aLanguageTag( eLastDialogLanguage );
905  pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 );
906  pCharClass.reset( new CharClass( aLanguageTag ) );
907  ModifyHdl(*m_xShortED);
908  }
909 }
910 
912 {
913  if(!bFirstSelect || !bHasSelectionText)
914  {
915  int nEntry = rBox.get_selected_index();
916  OUString sTmpShort(rBox.get_text(nEntry, 0));
917  // if the text is set via ModifyHdl, the cursor is always at the beginning
918  // of a word, although you're editing here
919  bool bSameContent = 0 == pCompareClass->compareString(sTmpShort, m_xShortED->get_text());
920  int nStartPos, nEndPos;
921  m_xShortED->get_selection_bounds(nStartPos, nEndPos);
922  if (m_xShortED->get_text() != sTmpShort)
923  {
924  m_xShortED->set_text(sTmpShort);
925  // if it was only a different notation, the selection has to be set again
926  if (bSameContent)
927  {
928  m_xShortED->select_region(nStartPos, nEndPos);
929  }
930  }
931  m_xReplaceED->set_text(rBox.get_text(nEntry, 1));
932  // with UserData there is a Formatinfo
933  m_xTextOnlyCB->set_active(rBox.get_id(nEntry).isEmpty());
934  }
935  else
936  {
937  bFirstSelect = false;
938  }
939 
940  m_xNewReplacePB->set_sensitive(false);
941  m_xDeleteReplacePB->set_sensitive(true);
942 };
943 
944 void OfaAutocorrReplacePage::NewEntry(const OUString& sShort, const OUString& sLong, bool bKeepSourceFormatting)
945 {
946  DoubleStringArray& rNewArray = aChangesTable[eLang].aNewEntries;
947  for (size_t i = 0; i < rNewArray.size(); i++)
948  {
949  if (rNewArray[i].sShort == sShort)
950  {
951  rNewArray.erase(rNewArray.begin() + i);
952  break;
953  }
954  }
955 
956  DoubleStringArray& rDeletedArray = aChangesTable[eLang].aDeletedEntries;
957  for (size_t i = 0; i < rDeletedArray.size(); i++)
958  {
959  if (rDeletedArray[i].sShort == sShort)
960  {
961  rDeletedArray.erase(rDeletedArray.begin() + i);
962  break;
963  }
964  }
965 
966  DoubleString aNewString(sShort, sLong);
967  rNewArray.push_back(aNewString);
968  if (bKeepSourceFormatting)
969  rNewArray.back().pUserData = &bHasSelectionText;
970 }
971 
972 void OfaAutocorrReplacePage::DeleteEntry(const OUString& sShort, const OUString& sLong)
973 {
974  DoubleStringArray& rNewArray = aChangesTable[eLang].aNewEntries;
975  for (size_t i = 0; i < rNewArray.size(); i++)
976  {
977  if (rNewArray[i].sShort == sShort)
978  {
979  rNewArray.erase(rNewArray.begin() + i);
980  break;
981  }
982  }
983 
984  DoubleStringArray& rDeletedArray = aChangesTable[eLang].aDeletedEntries;
985  for (size_t i = 0; i < rDeletedArray.size(); i++)
986  {
987  if (rDeletedArray[i].sShort == sShort)
988  {
989  rDeletedArray.erase(rDeletedArray.begin() + i);
990  break;
991  }
992  }
993 
994  DoubleString aDeletedString(sShort, sLong);
995  rDeletedArray.push_back(aDeletedString);
996 }
997 
998 IMPL_LINK(OfaAutocorrReplacePage, NewDelButtonHdl, weld::Button&, rBtn, void)
999 {
1000  NewDelHdl(&rBtn);
1001 }
1002 
1003 IMPL_LINK(OfaAutocorrReplacePage, NewDelActionHdl, weld::Entry&, rEdit, bool)
1004 {
1005  return NewDelHdl(&rEdit);
1006 }
1007 
1008 IMPL_LINK_NOARG(OfaAutocorrReplacePage, EntrySizeAllocHdl, const Size&, void)
1009 {
1010  m_aReplaceFixedWidths.clear();
1011  int x, y, width, height;
1012  if (m_xReplaceED->get_extents_relative_to(*m_xReplaceTLB, x, y, width, height))
1013  {
1014  m_aReplaceFixedWidths.push_back(x);
1015  m_aReplaceFixedWidths.push_back(width - 1);
1016  m_xReplaceTLB->set_column_fixed_widths(m_aReplaceFixedWidths);
1017  }
1018 }
1019 
1021 {
1022  int nEntry = m_xReplaceTLB->get_selected_index();
1023  if (pBtn == m_xDeleteReplacePB.get())
1024  {
1025  DBG_ASSERT( nEntry != -1, "no entry selected" );
1026  if (nEntry != -1)
1027  {
1028  DeleteEntry(m_xReplaceTLB->get_text(nEntry, 0), m_xReplaceTLB->get_text(nEntry, 1));
1029  m_xReplaceTLB->remove(nEntry);
1030  ModifyHdl(*m_xShortED);
1031  return true;
1032  }
1033  }
1034 
1035  if (pBtn == m_xNewReplacePB.get() || m_xNewReplacePB->get_sensitive())
1036  {
1037  OUString sEntry(m_xShortED->get_text());
1038  if (!sEntry.isEmpty() && (!m_xReplaceED->get_text().isEmpty() ||
1039  ( bHasSelectionText && bSWriter ) ))
1040  {
1041  bool bKeepSourceFormatting = !bReplaceEditChanged && !m_xTextOnlyCB->get_active();
1042 
1043  NewEntry(m_xShortED->get_text(), m_xReplaceED->get_text(), bKeepSourceFormatting);
1044  m_xReplaceTLB->freeze();
1045  int nPos = -1;
1046  if (nEntry != -1)
1047  {
1048  nPos = nEntry;
1049  m_xReplaceTLB->remove(nEntry);
1050  }
1051  else
1052  {
1053  int j;
1054  int nCount = m_xReplaceTLB->n_children();
1055  for (j = 0; j < nCount; ++j)
1056  {
1057  if (0 >= pCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0)))
1058  break;
1059  }
1060  nPos = j;
1061  }
1062 
1063  OUString sId;
1064  if (bKeepSourceFormatting)
1065  {
1066  sId = weld::toId(&bHasSelectionText); // new formatted text
1067  }
1068 
1069  m_xReplaceTLB->insert(nPos, sEntry, &sId, nullptr, nullptr);
1070  m_xReplaceTLB->set_text(nPos, m_xReplaceED->get_text(), 1);
1071  m_xReplaceTLB->thaw();
1072  m_xReplaceTLB->scroll_to_row(nPos);
1073  // if the request came from the ReplaceEdit, give focus to the ShortEdit
1074  if (m_xReplaceED->has_focus())
1075  {
1076  m_xShortED->grab_focus();
1077  }
1078  }
1079  }
1080  else
1081  {
1082  // this can only be an enter in one of the two edit fields
1083  // which means EndDialog() - has to be evaluated in KeyInput
1084  return false;
1085  }
1086  ModifyHdl(*m_xShortED);
1087  return true;
1088 }
1089 
1091 {
1092  std::unique_ptr<weld::TreeIter> xFirstSel(m_xReplaceTLB->make_iterator());
1093  bool bFirstSelIterSet = m_xReplaceTLB->get_selected(xFirstSel.get());
1094  bool bShort = &rEdt == m_xShortED.get();
1095  const OUString rEntry = rEdt.get_text();
1096  const OUString rRepString = m_xReplaceED->get_text();
1097  OUString aWordStr(pCharClass->lowercase(rEntry));
1098 
1099  if(bShort)
1100  {
1101  if(!rEntry.isEmpty())
1102  {
1103  bool bFound = false;
1104  bool bTmpSelEntry=false;
1105 
1106  m_xReplaceTLB->all_foreach([this, &rEntry, &rRepString, &bFound,
1107  &bTmpSelEntry, &bFirstSelIterSet,
1108  &xFirstSel, &aWordStr](weld::TreeIter& rIter){
1109  OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0);
1110  if( pCompareClass->compareString(rEntry, aTestStr ) == 0 )
1111  {
1112  if (!rRepString.isEmpty())
1113  bFirstSelect = true;
1114  m_xReplaceTLB->set_cursor(rIter);
1115  m_xReplaceTLB->copy_iterator(rIter, *xFirstSel);
1116  bFirstSelIterSet = true;
1117  m_xNewReplacePB->set_label(sModify);
1118  bFound = true;
1119  return true;
1120  }
1121  else
1122  {
1123  aTestStr = pCharClass->lowercase( aTestStr );
1124  if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry )
1125  {
1126  m_xReplaceTLB->scroll_to_row(rIter);
1127  bTmpSelEntry = true;
1128  }
1129  }
1130  return false;
1131  });
1132  if( !bFound )
1133  {
1134  m_xReplaceTLB->select(-1);
1135  bFirstSelIterSet = false;
1136  m_xNewReplacePB->set_label(sNew);
1137  if( bReplaceEditChanged )
1138  m_xTextOnlyCB->set_sensitive(false);
1139  }
1140  m_xDeleteReplacePB->set_sensitive(bFound);
1141  }
1142  else if (m_xReplaceTLB->n_children() > 0)
1143  {
1144  m_xReplaceTLB->scroll_to_row(0);
1145  }
1146 
1147  }
1148  else if( !bShort )
1149  {
1150  bReplaceEditChanged = true;
1151  if (bFirstSelIterSet)
1152  {
1153  m_xNewReplacePB->set_label(sModify);
1154  }
1155  }
1156 
1157  const OUString& rShortTxt = m_xShortED->get_text();
1158  bool bEnableNew = !rShortTxt.isEmpty() &&
1159  ( !rRepString.isEmpty() ||
1160  ( bHasSelectionText && bSWriter )) &&
1161  ( !bFirstSelIterSet || rRepString !=
1162  m_xReplaceTLB->get_text(*xFirstSel, 1) );
1163  if( bEnableNew )
1164  {
1165  for (auto const& elem : aFormatText)
1166  {
1167  if(elem == rShortTxt)
1168  {
1169  bEnableNew = false;
1170  break;
1171  }
1172  }
1173  }
1174  m_xNewReplacePB->set_sensitive(bEnableNew);
1175 }
1176 
1177 static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view rString)
1178 {
1179  for (auto const& elem : rStrings)
1180  {
1181  if(elem == rString)
1182  {
1183  return true;
1184  }
1185  }
1186  return false;
1187 }
1188 
1190  : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet)
1191  , eLang(eLastDialogLanguage)
1192  , m_xAbbrevED(m_xBuilder->weld_entry("abbrev"))
1193  , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist"))
1194  , m_xNewAbbrevPB(m_xBuilder->weld_button("newabbrev"))
1195  , m_xDelAbbrevPB(m_xBuilder->weld_button("delabbrev"))
1196  , m_xAutoAbbrevCB(m_xBuilder->weld_check_button("autoabbrev"))
1197  , m_xDoubleCapsED(m_xBuilder->weld_entry("double"))
1198  , m_xDoubleCapsLB(m_xBuilder->weld_tree_view("doublelist"))
1199  , m_xNewDoublePB(m_xBuilder->weld_button("newdouble"))
1200  , m_xDelDoublePB(m_xBuilder->weld_button("deldouble"))
1201  , m_xAutoCapsCB(m_xBuilder->weld_check_button("autodouble"))
1202 {
1203  m_xAbbrevLB->make_sorted();
1204  m_xAbbrevLB->set_size_request(-1, m_xAbbrevLB->get_height_rows(6));
1205 
1206  m_xDoubleCapsLB->make_sorted();
1207  m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6));
1208 
1209  css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage ));
1211  pCompareClass->loadDefaultCollator( aLcl, 0 );
1212 
1213  m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1214  m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1215  m_xNewDoublePB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1216  m_xDelDoublePB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1217 
1218  m_xAbbrevLB->connect_changed(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1219  m_xDoubleCapsLB->connect_changed(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1220  m_xAbbrevED->connect_changed(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1221  m_xDoubleCapsED->connect_changed(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1222 
1223  m_xAbbrevED->connect_activate(LINK(this, OfaAutocorrExceptPage, NewDelActionHdl));
1224  m_xDoubleCapsED->connect_activate(LINK(this, OfaAutocorrExceptPage, NewDelActionHdl));
1225 }
1226 
1228 {
1229  aStringsTable.clear();
1230  pCompareClass.reset();
1231 }
1232 
1233 std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController,
1234  const SfxItemSet* rSet)
1235 {
1236  return std::make_unique<OfaAutocorrExceptPage>(pPage, pController, *rSet);
1237 }
1238 
1240 {
1241  if(eLang != eLastDialogLanguage)
1242  SetLanguage(eLastDialogLanguage);
1243  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(true);
1244 }
1245 
1247 {
1248  return DeactivateRC::LeavePage;
1249 }
1250 
1252 {
1254  for(StringsTable::reverse_iterator it1 = aStringsTable.rbegin(); it1 != aStringsTable.rend(); ++it1)
1255  {
1256  LanguageType eCurLang = it1->first;
1257  StringsArrays& rArrays = it1->second;
1258  if(eCurLang != eLang) // current language is treated later
1259  {
1260  SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWordStartExceptList(eCurLang);
1261 
1262  if(pWrdList)
1263  {
1264  size_t nCount = pWrdList->size();
1265  size_t i;
1266  for( i = nCount; i; )
1267  {
1268  OUString aString = (*pWrdList)[ --i ];
1269 
1270  if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, aString))
1271  {
1272  pWrdList->erase_at(i);
1273  }
1274  }
1275 
1276  for (auto const& elem : rArrays.aDoubleCapsStrings)
1277  {
1278  pWrdList->insert(elem);
1279  }
1280  pAutoCorrect->SaveWordStartExceptList(eCurLang);
1281  }
1282 
1283  SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eCurLang);
1284 
1285  if(pCplList)
1286  {
1287  size_t nCount = pCplList->size();
1288  size_t i;
1289  for( i = nCount; i; )
1290  {
1291  OUString aString = (*pCplList)[ --i ];
1292  if( !lcl_FindInArray(rArrays.aAbbrevStrings, aString))
1293  {
1294  pCplList->erase_at(i);
1295  }
1296  }
1297 
1298  for (auto const& elem : rArrays.aAbbrevStrings)
1299  {
1300  pCplList->insert(elem);
1301  }
1302 
1303  pAutoCorrect->SaveCplSttExceptList(eCurLang);
1304  }
1305  }
1306  }
1307  aStringsTable.clear();
1308 
1309  SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWordStartExceptList(eLang);
1310 
1311  if(pWrdList)
1312  {
1313  size_t nCount = pWrdList->size();
1314  size_t i;
1315  for( i = nCount; i; )
1316  {
1317  OUString aString = (*pWrdList)[ --i ];
1318  if (m_xDoubleCapsLB->find_text(aString) == -1)
1319  {
1320  pWrdList->erase_at(i);
1321  }
1322  }
1323  nCount = m_xDoubleCapsLB->n_children();
1324  for( i = 0; i < nCount; ++i )
1325  {
1326  pWrdList->insert(m_xDoubleCapsLB->get_text(i));
1327  }
1328  pAutoCorrect->SaveWordStartExceptList(eLang);
1329  }
1330 
1331  SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eLang);
1332 
1333  if(pCplList)
1334  {
1335  size_t nCount = pCplList->size();
1336  for( size_t i = nCount; i; )
1337  {
1338  OUString aString = (*pCplList)[ --i ];
1339  if (m_xAbbrevLB->find_text(aString) == -1)
1340  {
1341  pCplList->erase_at(i);
1342  }
1343  }
1344  sal_Int32 nAbbrevCount = m_xAbbrevLB->n_children();
1345  for( sal_Int32 ia = 0; ia < nAbbrevCount; ++ia )
1346  {
1347  pCplList->insert(m_xAbbrevLB->get_text(ia));
1348  }
1349  pAutoCorrect->SaveCplSttExceptList(eLang);
1350  }
1351  if (m_xAutoAbbrevCB->get_state_changed_from_saved())
1352  pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordCplSttLst, m_xAutoAbbrevCB->get_active());
1353  if (m_xAutoCapsCB->get_state_changed_from_saved())
1354  pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordWordStartLst, m_xAutoCapsCB->get_active());
1355  return false;
1356 }
1357 
1359 {
1360  if(eLang != eSet)
1361  {
1362  // save old settings and fill anew
1363  RefillReplaceBoxes(false, eLang, eSet);
1364  eLastDialogLanguage = eSet;
1366  pCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 );
1367  ModifyHdl(*m_xAbbrevED);
1368  ModifyHdl(*m_xDoubleCapsED);
1369  }
1370 }
1371 
1373  LanguageType eOldLanguage,
1374  LanguageType eNewLanguage)
1375 {
1376  eLang = eNewLanguage;
1377  if(bFromReset)
1378  {
1379  aStringsTable.clear();
1380  }
1381  else
1382  {
1383  StringsArrays* pArrays;
1384  if(aStringsTable.find(eOldLanguage) != aStringsTable.end())
1385  {
1386  pArrays = &aStringsTable[eOldLanguage];
1387  pArrays->aAbbrevStrings.clear();
1388  pArrays->aDoubleCapsStrings.clear();
1389  }
1390  else
1391  {
1392  pArrays = &aStringsTable[eOldLanguage]; // create new array
1393  }
1394 
1395  sal_Int32 i, nCount;
1396  nCount = m_xAbbrevLB->n_children();
1397  for(i = 0; i < nCount; i++)
1398  pArrays->aAbbrevStrings.push_back(m_xAbbrevLB->get_text(i));
1399 
1400  nCount = m_xDoubleCapsLB->n_children();
1401  for(i = 0; i < nCount; i++)
1402  pArrays->aDoubleCapsStrings.push_back(m_xDoubleCapsLB->get_text(i));
1403  }
1404  m_xDoubleCapsLB->clear();
1405  m_xAbbrevLB->clear();
1406  m_xAbbrevED->set_text("");
1407  m_xDoubleCapsED->set_text("");
1408 
1409  if(aStringsTable.find(eLang) != aStringsTable.end())
1410  {
1411  StringsArrays& rArrays = aStringsTable[eLang];
1412  for (auto const& elem : rArrays.aAbbrevStrings)
1413  m_xAbbrevLB->append_text(elem);
1414 
1415  for (auto const& elem : rArrays.aDoubleCapsStrings)
1416  m_xDoubleCapsLB->append_text(elem);
1417  }
1418  else
1419  {
1421  const SvStringsISortDtor* pCplList = pAutoCorrect->GetCplSttExceptList(eLang);
1422  const SvStringsISortDtor* pWrdList = pAutoCorrect->GetWordStartExceptList(eLang);
1423  size_t i;
1424  for( i = 0; i < pCplList->size(); i++ )
1425  {
1426  m_xAbbrevLB->append_text((*pCplList)[i]);
1427  }
1428  for( i = 0; i < pWrdList->size(); i++ )
1429  {
1430  m_xDoubleCapsLB->append_text((*pWrdList)[i]);
1431  }
1432  }
1433 }
1434 
1436 {
1438  RefillReplaceBoxes(true, eLang, eLang);
1439  m_xAutoAbbrevCB->set_active(pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordCplSttLst));
1440  m_xAutoCapsCB->set_active(pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordWordStartLst));
1441  m_xAutoAbbrevCB->save_state();
1442  m_xAutoCapsCB->save_state();
1443 }
1444 
1445 IMPL_LINK(OfaAutocorrExceptPage, NewDelButtonHdl, weld::Button&, rBtn, void)
1446 {
1447  NewDelHdl(&rBtn);
1448 }
1449 
1450 IMPL_LINK(OfaAutocorrExceptPage, NewDelActionHdl, weld::Entry&, rEdit, bool)
1451 {
1452  return NewDelHdl(&rEdit);
1453 }
1454 
1456 {
1457  if ((pBtn == m_xNewAbbrevPB.get() || pBtn == m_xAbbrevED.get())
1458  && !m_xAbbrevED->get_text().isEmpty() && m_xNewAbbrevPB->get_sensitive())
1459  {
1460  m_xAbbrevLB->append_text(m_xAbbrevED->get_text());
1461  ModifyHdl(*m_xAbbrevED);
1462  }
1463  else if(pBtn == m_xDelAbbrevPB.get())
1464  {
1465  m_xAbbrevLB->remove_text(m_xAbbrevED->get_text());
1466  ModifyHdl(*m_xAbbrevED);
1467  }
1468  else if((pBtn == m_xNewDoublePB.get() || pBtn == m_xDoubleCapsED.get() )
1469  && !m_xDoubleCapsED->get_text().isEmpty() && m_xNewDoublePB->get_sensitive())
1470  {
1471  m_xDoubleCapsLB->append_text(m_xDoubleCapsED->get_text());
1472  ModifyHdl(*m_xDoubleCapsED);
1473  }
1474  else if (pBtn == m_xDelDoublePB.get())
1475  {
1476  m_xDoubleCapsLB->remove_text(m_xDoubleCapsED->get_text());
1477  ModifyHdl(*m_xDoubleCapsED);
1478  }
1479  else
1480  {
1481  // we didn't do anything, if this was because of 'activate' in an
1482  // entry then let it continue to close the dialog like the replace
1483  // page does
1484  return false;
1485  }
1486  return true;
1487 }
1488 
1490 {
1491  if (&rBox == m_xAbbrevLB.get())
1492  {
1493  m_xAbbrevED->set_text(rBox.get_selected_text());
1494  m_xNewAbbrevPB->set_sensitive(false);
1495  m_xDelAbbrevPB->set_sensitive(true);
1496  }
1497  else
1498  {
1499  m_xDoubleCapsED->set_text(rBox.get_selected_text());
1500  m_xNewDoublePB->set_sensitive(false);
1501  m_xDelDoublePB->set_sensitive(true);
1502  }
1503 }
1504 
1506 {
1507  const OUString& sEntry = rEdt.get_text();
1508  bool bEntryLen = !sEntry.isEmpty();
1509  if (&rEdt == m_xAbbrevED.get())
1510  {
1511  bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *pCompareClass);
1512  if(bSame && sEntry != m_xAbbrevLB->get_selected_text())
1513  rEdt.set_text(m_xAbbrevLB->get_selected_text());
1514  m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen);
1515  m_xDelAbbrevPB->set_sensitive(bSame && bEntryLen);
1516  }
1517  else
1518  {
1519  bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *pCompareClass);
1520  if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text())
1521  rEdt.set_text(m_xDoubleCapsLB->get_selected_text());
1522  m_xNewDoublePB->set_sensitive(!bSame && bEntryLen);
1523  m_xDelDoublePB->set_sensitive(bSame && bEntryLen);
1524  }
1525 }
1526 
1527 namespace {
1528 
1530 {
1531  ADD_NONBRK_SPACE,
1532  REPLACE_1ST,
1533  TRANSLITERATE_RTL,
1534  REPLACE_ANGLE_QUOTES
1535 };
1536 
1537 }
1538 
1539 void OfaQuoteTabPage::CreateEntry(weld::TreeView& rCheckLB, const OUString& rTxt, sal_uInt16 nCol, sal_uInt16 nTextCol)
1540 {
1541  rCheckLB.append();
1542  const int nRow = rCheckLB.n_children() - 1;
1543  if (nCol == CBCOL_FIRST || nCol == CBCOL_BOTH)
1544  rCheckLB.set_toggle(nRow, TRISTATE_FALSE, CBCOL_FIRST);
1545  if (nCol == CBCOL_SECOND || nCol == CBCOL_BOTH)
1546  rCheckLB.set_toggle(nRow, TRISTATE_FALSE, CBCOL_SECOND);
1547  rCheckLB.set_text(nRow, rTxt, nTextCol);
1548 }
1549 
1551  : SfxTabPage(pPage, pController, "cui/ui/applylocalizedpage.ui", "ApplyLocalizedPage", &rSet)
1552  , sNonBrkSpace(CuiResId(RID_CUISTR_NON_BREAK_SPACE))
1553  , sOrdinal(CuiResId(RID_CUISTR_ORDINAL))
1554  , sTransliterateRTL(CuiResId(RID_CUISTR_OLD_HUNGARIAN))
1555  , sAngleQuotes(CuiResId(RID_CUISTR_ANGLE_QUOTES))
1556  , cSglStartQuote(0)
1557  , cSglEndQuote(0)
1558  , cStartQuote(0)
1559  , cEndQuote(0)
1560  , m_xSingleTypoCB(m_xBuilder->weld_check_button("singlereplace"))
1561  , m_xSglStartQuotePB(m_xBuilder->weld_button("startsingle"))
1562  , m_xSglStartExFT(m_xBuilder->weld_label("singlestartex"))
1563  , m_xSglEndQuotePB(m_xBuilder->weld_button("endsingle"))
1564  , m_xSglEndExFT(m_xBuilder->weld_label("singleendex"))
1565  , m_xSglStandardPB(m_xBuilder->weld_button("defaultsingle"))
1566  , m_xDoubleTypoCB(m_xBuilder->weld_check_button("doublereplace"))
1567  , m_xDblStartQuotePB(m_xBuilder->weld_button("startdouble"))
1568  , m_xDblStartExFT(m_xBuilder->weld_label("doublestartex"))
1569  , m_xDblEndQuotePB(m_xBuilder->weld_button("enddouble"))
1570  , m_xDblEndExFT(m_xBuilder->weld_label("doubleendex"))
1571  , m_xDblStandardPB(m_xBuilder->weld_button("defaultdouble"))
1572  , m_sStandard(m_xSglStartExFT->get_label())
1573  , m_xCheckLB(m_xBuilder->weld_tree_view("checklist"))
1574  , m_xSwCheckLB(m_xBuilder->weld_tree_view("list"))
1575 {
1576  m_xSwCheckLB->set_size_request(m_xSwCheckLB->get_approximate_digit_width() * 50,
1577  m_xSwCheckLB->get_height_rows(6));
1578 
1579  bool bShowSWOptions = false;
1580 
1581  const SfxBoolItem* pItem = rSet.GetItem<SfxBoolItem>(SID_AUTO_CORRECT_DLG, false);
1582  if ( pItem && pItem->GetValue() )
1583  bShowSWOptions = true;
1584 
1585  if ( bShowSWOptions )
1586  {
1587  m_xSwCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
1588  std::vector<int> aWidths
1589  {
1590  o3tl::narrowing<int>(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(0)).Width() * 2),
1591  o3tl::narrowing<int>(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(1)).Width() * 2)
1592  };
1593  m_xSwCheckLB->set_column_fixed_widths(aWidths);
1594  m_xCheckLB->hide();
1595  }
1596  else
1597  {
1598  m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
1599  m_xSwCheckLB->hide();
1600  }
1601 
1602  m_xDblStartQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1603  m_xDblEndQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1604  m_xSglStartQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1605  m_xSglEndQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1606  m_xDblStandardPB->connect_clicked(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1607  m_xSglStandardPB->connect_clicked(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1608 }
1609 
1611 {
1612 }
1613 
1614 std::unique_ptr<SfxTabPage> OfaQuoteTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1615  const SfxItemSet* rAttrSet)
1616 {
1617  return std::make_unique<OfaQuoteTabPage>(pPage, pController, *rAttrSet);
1618 }
1619 
1621 {
1623 
1624  ACFlags nFlags = pAutoCorrect->GetFlags();
1625 
1626  if (m_xCheckLB->get_visible())
1627  {
1628  int nPos = 0;
1629  pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1630  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1631  pAutoCorrect->SetAutoCorrFlag(ACFlags::TransliterateRTL, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1632  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgAngleQuotes, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1633  }
1634 
1635  bool bModified = false;
1636  if (m_xSwCheckLB->get_visible())
1637  {
1638  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1639 
1640  bool bCheck = m_xSwCheckLB->get_toggle(ADD_NONBRK_SPACE, CBCOL_FIRST) == TRISTATE_TRUE;
1641  bModified |= pOpt->bAddNonBrkSpace != bCheck;
1642  pOpt->bAddNonBrkSpace = bCheck;
1643  pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace,
1644  m_xSwCheckLB->get_toggle(ADD_NONBRK_SPACE, CBCOL_SECOND) == TRISTATE_TRUE);
1645 
1646  bCheck = m_xSwCheckLB->get_toggle(REPLACE_1ST, CBCOL_FIRST) == TRISTATE_TRUE;
1647  bModified |= pOpt->bChgOrdinalNumber != bCheck;
1648  pOpt->bChgOrdinalNumber = bCheck;
1649  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber,
1650  m_xSwCheckLB->get_toggle(REPLACE_1ST, CBCOL_SECOND) == TRISTATE_TRUE);
1651 
1652  bCheck = m_xSwCheckLB->get_toggle(TRANSLITERATE_RTL, CBCOL_FIRST) == TRISTATE_TRUE;
1653  bModified |= pOpt->bTransliterateRTL != bCheck;
1654  pOpt->bTransliterateRTL = bCheck;
1655  pAutoCorrect->SetAutoCorrFlag(ACFlags::TransliterateRTL,
1656  m_xSwCheckLB->get_toggle(TRANSLITERATE_RTL, CBCOL_SECOND) == TRISTATE_TRUE);
1657 
1658  bCheck = m_xSwCheckLB->get_toggle(REPLACE_ANGLE_QUOTES, CBCOL_FIRST) == TRISTATE_TRUE;
1659  bModified |= pOpt->bChgAngleQuotes != bCheck;
1660  pOpt->bChgAngleQuotes = bCheck;
1661  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgAngleQuotes,
1662  m_xSwCheckLB->get_toggle(REPLACE_ANGLE_QUOTES, CBCOL_SECOND) == TRISTATE_TRUE);
1663  }
1664 
1665  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgQuotes, m_xDoubleTypoCB->get_active());
1666  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgSglQuotes, m_xSingleTypoCB->get_active());
1667  bool bReturn = nFlags != pAutoCorrect->GetFlags();
1668  if(cStartQuote != pAutoCorrect->GetStartDoubleQuote())
1669  {
1670  bReturn = true;
1671  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cStartQuote); //TODO
1672  pAutoCorrect->SetStartDoubleQuote(cUCS2);
1673  }
1674  if(cEndQuote != pAutoCorrect->GetEndDoubleQuote())
1675  {
1676  bReturn = true;
1677  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cEndQuote); //TODO
1678  pAutoCorrect->SetEndDoubleQuote(cUCS2);
1679  }
1680  if(cSglStartQuote != pAutoCorrect->GetStartSingleQuote())
1681  {
1682  bReturn = true;
1683  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglStartQuote); //TODO
1684  pAutoCorrect->SetStartSingleQuote(cUCS2);
1685  }
1686  if(cSglEndQuote != pAutoCorrect->GetEndSingleQuote())
1687  {
1688  bReturn = true;
1689  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglEndQuote); //TODO
1690  pAutoCorrect->SetEndSingleQuote(cUCS2);
1691  }
1692 
1693  if( bModified || bReturn )
1694  {
1696  rCfg.SetModified();
1697  rCfg.Commit();
1698  }
1699  return bReturn;
1700 }
1701 
1703 {
1704  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(false);
1705 }
1706 
1708 {
1710  const ACFlags nFlags = pAutoCorrect->GetFlags();
1711 
1712  // Initialize the Sw options
1713  if (m_xSwCheckLB->get_visible())
1714  {
1715  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1716 
1717  m_xSwCheckLB->freeze();
1718  m_xSwCheckLB->clear();
1719 
1724 
1725  m_xSwCheckLB->set_toggle(ADD_NONBRK_SPACE, pOpt->bAddNonBrkSpace ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1726  m_xSwCheckLB->set_toggle(ADD_NONBRK_SPACE, bool(nFlags & ACFlags::AddNonBrkSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1727  m_xSwCheckLB->set_toggle(REPLACE_1ST, pOpt->bChgOrdinalNumber ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1728  m_xSwCheckLB->set_toggle(REPLACE_1ST, bool(nFlags & ACFlags::ChgOrdinalNumber) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1729  m_xSwCheckLB->set_toggle(TRANSLITERATE_RTL, pOpt->bTransliterateRTL ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1730  m_xSwCheckLB->set_toggle(TRANSLITERATE_RTL, bool(nFlags & ACFlags::TransliterateRTL) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1731  m_xSwCheckLB->set_toggle(REPLACE_ANGLE_QUOTES, pOpt->bChgAngleQuotes ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1732  m_xSwCheckLB->set_toggle(REPLACE_ANGLE_QUOTES, bool(nFlags & ACFlags::ChgAngleQuotes) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1733 
1734  m_xSwCheckLB->thaw();
1735  }
1736 
1737  // Initialize the non Sw options
1738  if (m_xCheckLB->get_visible())
1739  {
1740  m_xCheckLB->freeze();
1741  m_xCheckLB->clear();
1742 
1743  int nPos = 0;
1744  m_xCheckLB->append();
1745  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::AddNonBrkSpace) ? TRISTATE_TRUE : TRISTATE_FALSE);
1746  m_xCheckLB->set_text(nPos++, sNonBrkSpace, 0);
1747  m_xCheckLB->append();
1748  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::ChgOrdinalNumber) ? TRISTATE_TRUE : TRISTATE_FALSE);
1749  m_xCheckLB->set_text(nPos++, sOrdinal, 0);
1750  m_xCheckLB->append();
1751  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::TransliterateRTL) ? TRISTATE_TRUE : TRISTATE_FALSE);
1752  m_xCheckLB->set_text(nPos++, sTransliterateRTL, 0);
1753  m_xCheckLB->append();
1754  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::ChgAngleQuotes) ? TRISTATE_TRUE : TRISTATE_FALSE);
1755  m_xCheckLB->set_text(nPos++, sAngleQuotes, 0);
1756 
1757  m_xCheckLB->thaw();
1758  }
1759 
1760  // Initialize the quote stuffs
1761  m_xDoubleTypoCB->set_active(bool(nFlags & ACFlags::ChgQuotes));
1762  m_xSingleTypoCB->set_active(bool(nFlags & ACFlags::ChgSglQuotes));
1763  m_xDoubleTypoCB->save_state();
1764  m_xSingleTypoCB->save_state();
1765 
1766  cStartQuote = pAutoCorrect->GetStartDoubleQuote();
1767  cEndQuote = pAutoCorrect->GetEndDoubleQuote();
1768  cSglStartQuote = pAutoCorrect->GetStartSingleQuote();
1769  cSglEndQuote = pAutoCorrect->GetEndSingleQuote();
1770 
1775 }
1776 
1777 #define SGL_START 0
1778 #define DBL_START 1
1779 #define SGL_END 2
1780 #define DBL_END 3
1781 
1782 
1783 IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void)
1784 {
1785  sal_uInt16 nMode = SGL_START;
1786  if (&rBtn == m_xSglEndQuotePB.get())
1787  nMode = SGL_END;
1788  else if (&rBtn == m_xDblStartQuotePB.get())
1789  nMode = DBL_START;
1790  else if (&rBtn == m_xDblEndQuotePB.get())
1791  nMode = DBL_END;
1792  // start character selection dialog
1793  SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr);
1794  aMap.SetCharFont( OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT,
1795  LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne ));
1796  aMap.set_title(nMode < SGL_END ? CuiResId(RID_CUISTR_STARTQUOTE) : CuiResId(RID_CUISTR_ENDQUOTE));
1797  sal_UCS4 cDlg;
1800  switch( nMode )
1801  {
1802  case SGL_START:
1803  cDlg = cSglStartQuote;
1804  if(cDlg == 0)
1805  cDlg = pAutoCorrect->GetQuote('\'', true, eLang);
1806  break;
1807  case SGL_END:
1808  cDlg = cSglEndQuote;
1809  if(cDlg == 0)
1810  cDlg = pAutoCorrect->GetQuote('\'', false, eLang);
1811  break;
1812  case DBL_START:
1813  cDlg = cStartQuote;
1814  if(cDlg == 0)
1815  cDlg = pAutoCorrect->GetQuote('\"', true, eLang);
1816  break;
1817  case DBL_END:
1818  cDlg = cEndQuote;
1819  if(cDlg == 0)
1820  cDlg = pAutoCorrect->GetQuote('\"', false, eLang);
1821  break;
1822  default:
1823  OSL_FAIL("svx::OfaQuoteTabPage::QuoteHdl(), how to initialize cDlg?" );
1824  cDlg = 0;
1825  break;
1826 
1827  }
1828  aMap.SetChar( cDlg );
1829  aMap.DisableFontSelection();
1830  if (aMap.run() != RET_OK)
1831  return;
1832 
1833  sal_UCS4 cNewChar = aMap.GetChar();
1834  switch( nMode )
1835  {
1836  case SGL_START:
1837  cSglStartQuote = cNewChar;
1838  m_xSglStartExFT->set_label(ChangeStringExt_Impl(cNewChar));
1839  break;
1840  case SGL_END:
1841  cSglEndQuote = cNewChar;
1842  m_xSglEndExFT->set_label(ChangeStringExt_Impl(cNewChar));
1843  break;
1844  case DBL_START:
1845  cStartQuote = cNewChar;
1846  m_xDblStartExFT->set_label(ChangeStringExt_Impl(cNewChar));
1847  break;
1848  case DBL_END:
1849  cEndQuote = cNewChar;
1850  m_xDblEndExFT->set_label(ChangeStringExt_Impl(cNewChar));
1851  break;
1852  }
1853 }
1854 
1855 IMPL_LINK(OfaQuoteTabPage, StdQuoteHdl, weld::Button&, rBtn, void)
1856 {
1857  if (&rBtn == m_xDblStandardPB.get())
1858  {
1859  cStartQuote = 0;
1860  m_xDblStartExFT->set_label(ChangeStringExt_Impl(0));
1861  cEndQuote = 0;
1862  m_xDblEndExFT->set_label(ChangeStringExt_Impl(0));
1863 
1864  }
1865  else
1866  {
1867  cSglStartQuote = 0;
1868  m_xSglStartExFT->set_label(ChangeStringExt_Impl(0));
1869  cSglEndQuote = 0;
1870  m_xSglEndExFT->set_label(ChangeStringExt_Impl(0));
1871  }
1872 }
1873 
1875 {
1876  if (!cChar)
1877  return m_sStandard;
1878 
1879  // convert codepoint value to unicode-hex string
1880  sal_UCS4 aStrCodes[32] = { 0, ' ', '(', 'U', '+', '0' };
1881  aStrCodes[0] = cChar;
1882  int nFullLen = 5;
1883  int nHexLen = 4;
1884  while( (cChar >> (4*nHexLen)) != 0 )
1885  ++nHexLen;
1886  for( int i = nHexLen; --i >= 0;)
1887  {
1888  sal_UCS4 cHexDigit = ((cChar >> (4*i)) & 0x0f) + '0';
1889  if( cHexDigit > '9' )
1890  cHexDigit += 'A' - ('9' + 1);
1891  aStrCodes[ nFullLen++ ] = cHexDigit;
1892  }
1893  aStrCodes[ nFullLen++ ] = ')';
1894  // using the new UCS4 constructor
1895  OUString aOUStr( aStrCodes, nFullLen );
1896  return aOUStr;
1897 }
1898 
1900  const SfxItemSet& rSet)
1901  : SfxTabPage(pPage, pController, "cui/ui/wordcompletionpage.ui",
1902  "WordCompletionPage", &rSet)
1903  , m_pAutoCompleteList(nullptr)
1904  , m_nAutoCmpltListCnt(0)
1905  , m_xCBActiv(m_xBuilder->weld_check_button("enablewordcomplete"))
1906  , m_xCBAppendSpace(m_xBuilder->weld_check_button("appendspace"))
1907  , m_xCBAsTip(m_xBuilder->weld_check_button("showastip"))
1908  , m_xCBCollect(m_xBuilder->weld_check_button("collectwords"))
1909  , m_xCBRemoveList(m_xBuilder->weld_check_button("whenclosing"))
1910  , m_xDCBExpandKey(m_xBuilder->weld_combo_box("acceptwith"))
1911  , m_xNFMinWordlen(m_xBuilder->weld_spin_button("minwordlen"))
1912  , m_xNFMaxEntries(m_xBuilder->weld_spin_button("maxentries"))
1913  , m_xLBEntries(m_xBuilder->weld_tree_view("entries"))
1914  , m_xPBEntries(m_xBuilder->weld_button("delete"))
1915 {
1916  //fdo#65595, we need height-for-width support here, but for now we can
1917  //bodge it
1918  Size aPrefSize(m_xCBRemoveList->get_preferred_size());
1919  int nMaxWidth = m_xCBRemoveList->get_approximate_digit_width() * 40;
1920  if (aPrefSize.Width() > nMaxWidth)
1921  {
1922  m_xCBRemoveList->set_label_wrap(true);
1923  m_xCBRemoveList->set_size_request(nMaxWidth, -1);
1924  }
1925 
1926  m_xLBEntries->set_size_request(m_xLBEntries->get_approximate_digit_width() * 30,
1927  m_xLBEntries->get_height_rows(10));
1928  m_xLBEntries->set_selection_mode(SelectionMode::Multiple);
1929 
1930  // the defined KEYs
1931  static const sal_uInt16 aKeyCodes[] = {
1932  KEY_END,
1933  KEY_RETURN,
1934  KEY_SPACE,
1935  KEY_RIGHT,
1936  KEY_TAB,
1937  0
1938  };
1939 
1940  for( const sal_uInt16* pKeys = aKeyCodes; *pKeys; ++pKeys )
1941  {
1942  vcl::KeyCode aKCode(*pKeys);
1943  m_xDCBExpandKey->append(OUString::number(static_cast<sal_Int32>(*pKeys)), aKCode.GetName());
1944  if (KEY_RETURN == *pKeys) // default to RETURN
1945  m_xDCBExpandKey->set_active(std::distance(aKeyCodes, pKeys));
1946  }
1947 
1948  m_xPBEntries->connect_clicked(LINK(this, OfaAutoCompleteTabPage, DeleteHdl));
1949  m_xCBActiv->connect_toggled(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
1950  m_xCBCollect->connect_toggled(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
1951  m_xLBEntries->connect_key_release(LINK(this, OfaAutoCompleteTabPage, KeyReleaseHdl));
1952 }
1953 
1955 {
1956 }
1957 
1958 std::unique_ptr<SfxTabPage> OfaAutoCompleteTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1959  const SfxItemSet* rSet)
1960 {
1961  return std::make_unique<OfaAutoCompleteTabPage>(pPage, pController, *rSet);
1962 }
1963 
1965 {
1966  bool bModified = false, bCheck;
1968  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1969  sal_uInt16 nVal;
1970 
1971  bCheck = m_xCBActiv->get_active();
1972  bModified |= pOpt->bAutoCompleteWords != bCheck;
1973  pOpt->bAutoCompleteWords = bCheck;
1974  bCheck = m_xCBCollect->get_active();
1975  bModified |= pOpt->bAutoCmpltCollectWords != bCheck;
1976  pOpt->bAutoCmpltCollectWords = bCheck;
1977  bCheck = !m_xCBRemoveList->get_active(); // inverted value!
1978  bModified |= pOpt->bAutoCmpltKeepList != bCheck;
1979  pOpt->bAutoCmpltKeepList = bCheck;
1980  bCheck = m_xCBAppendSpace->get_active();
1981  bModified |= pOpt->bAutoCmpltAppendBlank != bCheck;
1982  pOpt->bAutoCmpltAppendBlank = bCheck;
1983  bCheck = m_xCBAsTip->get_active();
1984  bModified |= pOpt->bAutoCmpltShowAsTip != bCheck;
1985  pOpt->bAutoCmpltShowAsTip = bCheck;
1986 
1987  nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value());
1988  bModified |= nVal != pOpt->nAutoCmpltWordLen;
1989  pOpt->nAutoCmpltWordLen = nVal;
1990 
1991  nVal = static_cast<sal_uInt16>(m_xNFMaxEntries->get_value());
1992  bModified |= nVal != pOpt->nAutoCmpltListLen;
1993  pOpt->nAutoCmpltListLen = nVal;
1994 
1995  const int nPos = m_xDCBExpandKey->get_active();
1996  if (nPos != -1)
1997  {
1998  sal_Int32 nKey = m_xDCBExpandKey->get_id(nPos).toInt32();
1999  bModified |= nKey != pOpt->nAutoCmpltExpandKey;
2000  pOpt->nAutoCmpltExpandKey = static_cast<sal_uInt16>(nKey);
2001  }
2002 
2003  if (m_pAutoCompleteList && m_nAutoCmpltListCnt != m_xLBEntries->n_children())
2004  {
2005  bModified = true;
2007  }
2008  if( bModified )
2009  {
2011  rCfg.SetModified();
2012  rCfg.Commit();
2013  }
2014  return true;
2015 }
2016 
2018 {
2020  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2021 
2022  m_xCBActiv->set_active( pOpt->bAutoCompleteWords );
2023  m_xCBCollect->set_active( pOpt->bAutoCmpltCollectWords );
2024  m_xCBRemoveList->set_active( !pOpt->bAutoCmpltKeepList ); //inverted value!
2025  m_xCBAppendSpace->set_active( pOpt->bAutoCmpltAppendBlank );
2026  m_xCBAsTip->set_active( pOpt->bAutoCmpltShowAsTip );
2027 
2028  m_xNFMinWordlen->set_value( pOpt->nAutoCmpltWordLen );
2029  m_xNFMaxEntries->set_value( pOpt->nAutoCmpltListLen );
2030 
2031  // select the specific KeyCode:
2032  {
2033  sal_Int32 nKey = pOpt->nAutoCmpltExpandKey;
2034  for (int n = 0, nCnt = m_xDCBExpandKey->get_count(); n < nCnt; ++n)
2035  {
2036  if (nKey == m_xDCBExpandKey->get_id(n).toInt32())
2037  {
2038  m_xDCBExpandKey->set_active(n);
2039  break;
2040  }
2041  }
2042  }
2043 
2044  if (pOpt->m_pAutoCompleteList && !pOpt->m_pAutoCompleteList->empty())
2045  {
2047  pOpt->m_pAutoCompleteList);
2048  pOpt->m_pAutoCompleteList = nullptr;
2050  for (size_t n = 0; n < m_nAutoCmpltListCnt; ++n)
2051  {
2052  const OUString* pStr =
2053  &(*m_pAutoCompleteList)[n]->GetAutoCompleteString();
2054  OUString sId(weld::toId(pStr));
2055  m_xLBEntries->append(sId, *pStr);
2056  }
2057  }
2058  else
2059  {
2060  m_xLBEntries->set_sensitive(false);
2061  m_xPBEntries->set_sensitive(false);
2062  }
2063 
2064  CheckHdl(*m_xCBActiv);
2065  CheckHdl(*m_xCBCollect);
2066 }
2067 
2069 {
2070  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage( false );
2071 }
2072 
2074 {
2075  auto rows = m_xLBEntries->get_selected_rows();
2076  std::sort(rows.begin(), rows.end());
2077  while (!rows.empty())
2078  {
2079  sal_Int32 nPos = rows.back();
2080  OUString* pStr = weld::fromId<OUString*>(m_xLBEntries->get_id(nPos));
2081  m_xLBEntries->remove(nPos);
2082  editeng::IAutoCompleteString hack(*pStr); // UGLY
2083  m_pAutoCompleteList->erase(&hack);
2084  rows.pop_back();
2085  }
2086 }
2087 
2089 {
2090  bool bEnable = rBox.get_active();
2091  if (&rBox == m_xCBActiv.get())
2092  {
2093  m_xCBAppendSpace->set_sensitive(bEnable);
2094  m_xCBAppendSpace->set_sensitive(bEnable);
2095  m_xCBAsTip->set_sensitive(bEnable);
2096  m_xDCBExpandKey->set_sensitive(bEnable);
2097  }
2098  else if (&rBox == m_xCBCollect.get())
2099  m_xCBRemoveList->set_sensitive(bEnable);
2100 }
2101 
2103 {
2104  auto rows = m_xLBEntries->get_selected_rows();
2105  if (!m_pAutoCompleteList || rows.empty())
2106  return;
2107 
2109 
2110  OStringBuffer sData;
2111 
2112  rtl_TextEncoding nEncode = osl_getThreadTextEncoding();
2113 
2114  for (auto a : rows)
2115  {
2116  sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode));
2117 #if defined(_WIN32)
2118  sData.append("\015\012");
2119 #else
2120  sData.append("\012");
2121 #endif
2122  }
2123  pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() );
2124  pCntnr->CopyToClipboard(m_xLBEntries->get_clipboard());
2125 }
2126 
2127 IMPL_LINK(OfaAutoCompleteTabPage, KeyReleaseHdl, const KeyEvent&, rEvent, bool)
2128 {
2129  bool bHandled = false;
2130  const vcl::KeyCode& rKeyCode = rEvent.GetKeyCode();
2131  switch (rKeyCode.GetModifier() | rKeyCode.GetCode())
2132  {
2133  case KEY_DELETE:
2134  DeleteHdl(*m_xPBEntries);
2135  bHandled = true;
2136  break;
2137  default:
2138  if (KeyFuncType::COPY == rKeyCode.GetFunction())
2139  {
2140  CopyToClipboard();
2141  bHandled = true;
2142  }
2143  break;
2144  }
2145  return bHandled;
2146 }
2147 
2148 // class OfaSmartTagOptionsTabPage ---------------------------------------------
2149 
2151  const SfxItemSet& rSet )
2152  : SfxTabPage(pPage, pController, "cui/ui/smarttagoptionspage.ui", "SmartTagOptionsPage", &rSet)
2153  , m_xMainCB(m_xBuilder->weld_check_button("main"))
2154  , m_xSmartTagTypesLB(m_xBuilder->weld_tree_view("list"))
2155  , m_xPropertiesPB(m_xBuilder->weld_button("properties"))
2156 {
2157  m_xSmartTagTypesLB->set_size_request(m_xSmartTagTypesLB->get_approximate_digit_width() * 50,
2158  m_xSmartTagTypesLB->get_height_rows(6));
2159 
2160  m_xSmartTagTypesLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
2161 
2162  // set the handlers:
2163  m_xMainCB->connect_toggled(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl));
2164  m_xPropertiesPB->connect_clicked(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl));
2165  m_xSmartTagTypesLB->connect_changed(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl));
2166 }
2167 
2169 {
2170 }
2171 
2172 std::unique_ptr<SfxTabPage> OfaSmartTagOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2173 {
2174  return std::make_unique<OfaSmartTagOptionsTabPage>(pPage, pController, *rSet);
2175 }
2176 
2177 namespace {
2178 
2181 struct ImplSmartTagLBUserData
2182 {
2183  OUString maSmartTagType;
2184  uno::Reference< smarttags::XSmartTagRecognizer > mxRec;
2185  sal_Int32 mnSmartTagIdx;
2186 
2187  ImplSmartTagLBUserData( const OUString& rSmartTagType,
2188  uno::Reference< smarttags::XSmartTagRecognizer > const & xRec,
2189  sal_Int32 nSmartTagIdx ) :
2190  maSmartTagType( rSmartTagType ),
2191  mxRec( xRec ),
2192  mnSmartTagIdx( nSmartTagIdx ) {}
2193 };
2194 
2195 }
2196 
2200 {
2201  const int nCount = m_xSmartTagTypesLB->n_children();
2202  for (int i = 0; i < nCount; ++i)
2203  {
2204  const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i));
2205  delete pUserData;
2206  }
2207 
2208  m_xSmartTagTypesLB->clear();
2209 }
2210 
2214 {
2215  // first we have to clear the list box:
2216  ClearListBox();
2217 
2218  // fill list box:
2219  const sal_uInt32 nNumberOfRecognizers = rSmartTagMgr.NumberOfRecognizers();
2220  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2221 
2222  for ( sal_uInt32 i = 0; i < nNumberOfRecognizers; ++i )
2223  {
2224  const uno::Reference< smarttags::XSmartTagRecognizer >& xRec = rSmartTagMgr.GetRecognizer(i);
2225 
2226  const OUString aName = xRec->getName( aLocale );
2227  const sal_Int32 nNumberOfSupportedSmartTags = xRec->getSmartTagCount();
2228 
2229  for ( sal_Int32 j = 0; j < nNumberOfSupportedSmartTags; ++j )
2230  {
2231  const OUString aSmartTagType = xRec->getSmartTagName(j);
2232  OUString aSmartTagCaption = rSmartTagMgr.GetSmartTagCaption( aSmartTagType, aLocale );
2233 
2234  if ( aSmartTagCaption.isEmpty() )
2235  aSmartTagCaption = aSmartTagType;
2236 
2237  const OUString aLBEntry = aSmartTagCaption + " (" + aName + ")";
2238 
2239  m_xSmartTagTypesLB->append();
2240  const int nRow = m_xSmartTagTypesLB->n_children() - 1;
2241  const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType );
2242  m_xSmartTagTypesLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE);
2243  m_xSmartTagTypesLB->set_text(nRow, aLBEntry, 0);
2244  m_xSmartTagTypesLB->set_id(nRow, weld::toId(new ImplSmartTagLBUserData(aSmartTagType, xRec, j)));
2245  }
2246  }
2247 }
2248 
2252 {
2253  const int nPos = m_xSmartTagTypesLB->get_selected_index();
2254  const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos));
2255  uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2256  const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2257 
2258  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2259  if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
2260  xRec->displayPropertyPage( nSmartTagIdx, aLocale );
2261 }
2262 
2266 {
2267  const bool bEnable = m_xMainCB->get_active();
2268  m_xSmartTagTypesLB->set_sensitive(bEnable);
2269  m_xPropertiesPB->set_sensitive(false);
2270 
2271  // if the controls are currently enabled, we still have to check
2272  // if the properties button should be disabled because the currently
2273  // selected smart tag type does not have a properties dialog.
2274  // We do this by calling SelectHdl:
2275  if (bEnable)
2276  SelectHdl(*m_xSmartTagTypesLB);
2277 }
2278 
2282 {
2283  const int nPos = m_xSmartTagTypesLB->get_selected_index();
2284  if (nPos == -1)
2285  return;
2286  const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos));
2287  uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2288  const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2289 
2290  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2291  if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
2292  m_xPropertiesPB->set_sensitive(true);
2293  else
2294  m_xPropertiesPB->set_sensitive(false);
2295 }
2296 
2300 {
2302  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2303  SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2304 
2305  // robust!
2306  if ( !pSmartTagMgr )
2307  return false;
2308 
2309  bool bModifiedSmartTagTypes = false;
2310  std::vector< OUString > aDisabledSmartTagTypes;
2311 
2312  const int nCount = m_xSmartTagTypesLB->n_children();
2313 
2314  for (int i = 0; i < nCount; ++i)
2315  {
2316  const ImplSmartTagLBUserData* pUserData = weld::fromId<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i));
2317  const bool bChecked = m_xSmartTagTypesLB->get_toggle(i) == TRISTATE_TRUE;
2318  const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType );
2319 
2320  bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled );
2321 
2322  if ( !bChecked )
2323  aDisabledSmartTagTypes.push_back( pUserData->maSmartTagType );
2324 
2325  delete pUserData;
2326  }
2327 
2328  const bool bModifiedRecognize = ( !m_xMainCB->get_active() != !pSmartTagMgr->IsLabelTextWithSmartTags() );
2329  if ( bModifiedSmartTagTypes || bModifiedRecognize )
2330  {
2331  bool bLabelTextWithSmartTags = m_xMainCB->get_active();
2332  pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : nullptr,
2333  bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : nullptr );
2334  }
2335 
2336  return true;
2337 }
2338 
2342 {
2344  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2345  const SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2346 
2347  // robust, should not happen!
2348  if ( !pSmartTagMgr )
2349  return;
2350 
2351  FillListBox(*pSmartTagMgr);
2352  m_xSmartTagTypesLB->select(0);
2353  m_xMainCB->set_active(pSmartTagMgr->IsLabelTextWithSmartTags());
2354  CheckHdl(*m_xMainCB);
2355 }
2356 
2358 {
2359  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage( false );
2360 }
2361 
2362 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void set_text(int row, const OUString &rText, int col=-1)=0
bool GetValue() const
#define DBL_END
Definition: autocdlg.cxx:1780
sal_Unicode GetEndDoubleQuote() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:1435
#define LANGUAGE_NONE
std::unique_ptr< weld::TreeView > m_xDoubleCapsLB
Definition: autocdlg.hxx:239
OUString sReplaceTemplates
Definition: autocdlg.hxx:99
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
bool NewDelHdl(const weld::Widget *)
Definition: autocdlg.cxx:1020
FieldUnit
sal_Int32 nIndex
std::unique_ptr< weld::CheckButton > m_xCBAppendSpace
Append space.
Definition: autocdlg.hxx:331
std::unique_ptr< weld::CheckButton > m_xAutoCapsCB
Definition: autocdlg.hxx:242
bool bAFormatByInpDelSpacesBetweenLines
static SvxAutoCorrCfg & Get()
virtual ~OfaSwAutoFmtOptionsPage() override
Definition: autocdlg.cxx:400
std::unique_ptr< weld::Button > m_xDeleteReplacePB
Definition: autocdlg.hxx:184
bool IsAutoCorrFlag(ACFlags nFlag) const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
LanguageType eLang
Definition: autocdlg.hxx:170
sal_uInt32 sal_UCS4
virtual bool FillItemSet(SfxItemSet *rSet) override
Propagates the current settings to the smart tag manager.
Definition: autocdlg.cxx:2299
#define LANGUAGE_ENGLISH_US
std::unique_ptr< weld::CheckButton > m_xMainCB
Definition: autocdlg.hxx:371
std::unique_ptr< weld::Entry > m_xShortED
Definition: autocdlg.hxx:179
std::unique_ptr< weld::CheckButton > m_xSingleTypoCB
Definition: autocdlg.hxx:284
bool IsCJKFontEnabled()
void ClearListBox()
Clears the m_aSmartTagTypesLB.
Definition: autocdlg.cxx:2199
void NewEntry(const OUString &sShort, const OUString &sLong, bool bKeepSourceFormatting)
Definition: autocdlg.cxx:944
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:1239
void CreateEntry(const OUString &rTxt, sal_uInt16 nCol)
Definition: autocdlg.cxx:389
LanguageType getLanguageType(bool bResolveSystem=true) const
std::unique_ptr< weld::SpinButton > m_xNFMaxEntries
Definition: autocdlg.hxx:339
SvStringsISortDtor * LoadWordStartExceptList(LanguageType eLang)
sal_uInt16 nAutoCmpltExpandKey
std::unique_ptr< weld::Button > m_xNewAbbrevPB
Definition: autocdlg.hxx:234
void SaveWordStartExceptList(LanguageType eLang)
const SvStringsISortDtor * GetCplSttExceptList(LanguageType eLang)
static const AllSettings & GetSettings()
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:2017
virtual ~OfaAutoCompleteTabPage() override
Definition: autocdlg.cxx:1954
sal_Int64 n
void SetChar(sal_UCS4)
Definition: cuicharmap.cxx:207
constexpr OUStringLiteral PERCENT(u"Percent")
std::unique_ptr< weld::Label > m_xDblStartExFT
Definition: autocdlg.hxx:292
std::unique_ptr< weld::ComboBox > m_xDCBExpandKey
Definition: autocdlg.hxx:337
virtual ~OfaAutocorrReplacePage() override
Definition: autocdlg.cxx:718
void RemoveTabPage(const OString &rName)
std::vector< SvxAutocorrWord > AutocorrWordSetType
std::vector< OUString > aAbbrevStrings
Definition: autocdlg.hxx:218
static SfxModule * GetActiveModule(SfxViewFrame *pFrame=nullptr)
sal_uInt16 GetCode() const
OUString sCapitalStartSentence
Definition: autocdlg.hxx:87
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:727
const vcl::Font & GetCharFont() const
Definition: cuicharmap.hxx:160
static SfxObjectShell * Current()
std::unique_ptr< CollatorWrapper > pCompareClass
Definition: autocdlg.hxx:168
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:2357
virtual OUString GetSelectionText(bool bCompleteWords=false)
constexpr sal_uInt16 KEY_SPACE
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:1233
#define SGL_START
Definition: autocdlg.cxx:1777
static bool lcl_FindInArray(std::vector< OUString > &rStrings, std::u16string_view rString)
Definition: autocdlg.cxx:1177
float x
TRISTATE_TRUE
void SetStartSingleQuote(const sal_Unicode cStart)
static LanguageType eLastDialogLanguage
Definition: autocdlg.cxx:52
std::unique_ptr< weld::Button > m_xReplacePB
Definition: autocdlg.hxx:183
std::unique_ptr< weld::CheckButton > m_xDoubleTypoCB
Definition: autocdlg.hxx:290
void InsertEntry(const OUString &rTxt)
Definition: autocdlg.cxx:242
std::unique_ptr< weld::Widget > m_xLanguageBox
Definition: autocdlg.hxx:37
void RefillReplaceBox(bool bFromReset, LanguageType eOldLanguage, LanguageType eNewLanguage)
Definition: autocdlg.cxx:784
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
std::unique_ptr< weld::Button > m_xSglStandardPB
Definition: autocdlg.hxx:289
static bool lcl_FindEntry(weld::TreeView &rLB, const OUString &rEntry, CollatorWrapper const &rCmpClass)
Definition: autocdlg.cxx:142
bool IsLabelTextWithSmartTags() const
constexpr sal_uInt16 KEY_END
bool bAFormatByInpDelSpacesAtSttEnd
HashMap_OWString_Interface aMap
OUString GetName() const
sal_uInt16 sal_Unicode
std::unique_ptr< weld::TreeView > m_xLBEntries
Definition: autocdlg.hxx:340
OUString sShort
Definition: autocdlg.hxx:135
std::unique_ptr< weld::Label > m_xDblEndExFT
Definition: autocdlg.hxx:294
static void CreateEntry(weld::TreeView &rLstBox, const OUString &rTxt, sal_uInt16 nCol, sal_uInt16 nTextCol)
Definition: autocdlg.cxx:1539
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:744
ACFlags
OfaAutocorrOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:182
sal_Unicode GetStartSingleQuote() const
OfaSwAutoFmtOptionsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:350
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
Definition: autocdlg.hxx:38
std::unique_ptr< weld::Entry > m_xReplaceED
Definition: autocdlg.hxx:180
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:212
void SetEndDoubleQuote(const sal_Unicode cEnd)
void SetLanguage(LanguageType eSet)
Definition: autocdlg.cxx:895
int nCount
virtual int n_children() const =0
sal_uInt16 m_nAutoCmpltListCnt
Definition: autocdlg.hxx:328
static SfxViewShell * Current()
SvxSwAutoFormatFlags & GetSwFlags()
std::unique_ptr< weld::Label > m_xSglEndExFT
Definition: autocdlg.hxx:288
bool NewDelHdl(const weld::Widget *)
Definition: autocdlg.cxx:1455
sal_uInt16 GetModifier() const
#define CBCOL_SECOND
Definition: autocdlg.cxx:209
OUString m_sURL
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: autocdlg.hxx:63
#define LANGUAGE_UNDETERMINED
void MakeCombinedChanges(std::vector< SvxAutocorrWord > &aNewEntries, std::vector< SvxAutocorrWord > &aDeleteEntries, LanguageType eLang)
OUString m_sAccidentalCaps
Definition: autocdlg.hxx:61
std::unique_ptr< weld::TreeView > m_xCheckLB
For anything but writer.
Definition: autocdlg.hxx:298
std::unique_ptr< weld::Button > m_xNewReplacePB
Definition: autocdlg.hxx:182
const AutocorrWordSetType & getSortedContent() const
void SetModified()
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:2068
const editeng::SortedAutoCompleteStrings * m_pAutoCompleteList
OUString sTransliterateRTL
Definition: autocdlg.hxx:275
const LanguageTag & GetLanguageTag() const
float y
virtual ~OfaSmartTagOptionsTabPage() override
Definition: autocdlg.cxx:2168
OUString sAngleQuotes
Definition: autocdlg.hxx:276
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
StringChangeTable aChangesTable
Definition: autocdlg.hxx:160
sal_Unicode GetQuote(sal_Unicode cInsChar, bool bSttQuote, LanguageType eLang) const
sal_uInt16 nAutoCmpltWordLen
OfaAutocorrReplacePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:665
std::unique_ptr< weld::Entry > m_xAbbrevED
Definition: autocdlg.hxx:232
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:889
#define DBG_ASSERT(sCon, aError)
int i
bool bAFormatDelSpacesBetweenLines
uno_Any a
OfaQuoteTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:1550
DoubleStringArray aNewEntries
Definition: autocdlg.hxx:150
std::unique_ptr< weld::CheckButton > m_xCBActiv
Enable word completion.
Definition: autocdlg.hxx:330
std::unique_ptr< weld::Button > m_xPropertiesPB
Definition: autocdlg.hxx:373
OUString sOrdinal
Definition: autocdlg.hxx:274
IMPL_LINK(OfaSwAutoFmtOptionsPage, SelectHdl, weld::TreeView &, rBox, void)
Definition: autocdlg.cxx:616
virtual ~OfaQuoteTabPage() override
Definition: autocdlg.cxx:1610
sal_uInt16 nAutoCmpltListLen
std::vector< OUString > aDoubleCapsStrings
Definition: autocdlg.hxx:219
virtual int get_selected_index() const =0
#define LANGUAGE_SYSTEM
SmartTagMgr * pSmartTagMgr
std::unique_ptr< weld::Button > m_xDelDoublePB
Definition: autocdlg.hxx:241
void WriteConfiguration(const bool *bLabelTextWithSmartTags, const std::vector< OUString > *pDisabledTypes) const
editeng::SortedAutoCompleteStrings * m_pAutoCompleteList
Definition: autocdlg.hxx:327
OfaAutoCorrDlg(weld::Window *pParent, const SfxItemSet *pSet)
Definition: autocdlg.cxx:57
virtual void set_toggle(int row, TriState eState, int col=-1)=0
OUString m_sStandard
Definition: autocdlg.hxx:296
OUString m_sBoldUnderline
Definition: autocdlg.hxx:57
SvxAutoCorrect * GetAutoCorrect()
LanguageType eLang
Definition: autocdlg.hxx:230
void DeleteEntry(const OUString &sShort, const OUString &sLong)
Definition: autocdlg.cxx:972
const SvStringsISortDtor * GetWordStartExceptList(LanguageType eLang)
TRISTATE_FALSE
sal_Unicode GetStartDoubleQuote() const
std::unique_ptr< weld::Button > m_xSglStartQuotePB
Definition: autocdlg.hxx:285
sal_UCS4 cEndQuote
Definition: autocdlg.hxx:282
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:1702
SvxAutocorrWordList * LoadAutocorrWordList(LanguageType eLang)
std::unique_ptr< weld::TreeView > m_xSwCheckLB
Just for writer.
Definition: autocdlg.hxx:300
std::vector< int > m_aReplaceFixedWidths
Definition: autocdlg.hxx:177
void * pUserData
CheckBox -> form. Text Bool -> selection text.
Definition: autocdlg.hxx:137
#define CBCOL_FIRST
Definition: autocdlg.cxx:208
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:407
OfaSmartTagOptionsTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
construction via Create()
Definition: autocdlg.cxx:2150
virtual void unselect(int pos)=0
virtual OUString get_text(int row, int col=-1) const =0
OfaAutocorrExceptPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:1189
sal_UCS4 cSglEndQuote
Definition: autocdlg.hxx:279
vcl::Font aByInputBulletFont
std::unique_ptr< weld::Label > m_xSglStartExFT
Definition: autocdlg.hxx:286
void SetAutoCorrFlag(ACFlags nFlag, bool bOn=true)
void SaveCplSttExceptList(LanguageType eLang)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: autocdlg.cxx:739
KeyFuncType GetFunction() const
virtual void Reset(const SfxItemSet *rSet) override
Sets the controls based on the current settings at SmartTagMgr.
Definition: autocdlg.cxx:2341
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:1958
OUString sNonBrkSpace
Definition: autocdlg.hxx:273
void CopyToClipboard() const
Definition: autocdlg.cxx:2102
std::unique_ptr< weld::Button > m_xDelAbbrevPB
Definition: autocdlg.hxx:235
std::unique_ptr< weld::Button > m_xEditPB
Definition: autocdlg.hxx:112
css::uno::Reference< css::smarttags::XSmartTagRecognizer > const & GetRecognizer(sal_uInt32 i) const
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:534
constexpr sal_uInt16 KEY_RETURN
std::unique_ptr< weld::CheckButton > m_xCBAsTip
Show as tip.
Definition: autocdlg.hxx:332
constexpr T & temporary(T &&x)
virtual short run() override
Definition: cuicharmap.cxx:186
constexpr sal_uInt16 KEY_RIGHT
std::unique_ptr< weld::Button > m_xDblStartQuotePB
Definition: autocdlg.hxx:291
std::unique_ptr< weld::CheckButton > m_xCBCollect
Collect words.
Definition: autocdlg.hxx:334
void SetEndSingleQuote(const sal_Unicode cEnd)
OUString sLong
Definition: autocdlg.hxx:136
#define SGL_END
Definition: autocdlg.cxx:1779
virtual ~OfaAutoCorrDlg() override
Definition: autocdlg.cxx:133
std::unique_ptr< weld::TreeView > m_xAbbrevLB
Definition: autocdlg.hxx:233
void RefillReplaceBoxes(bool bFromReset, LanguageType eOldLanguage, LanguageType eNewLanguage)
Box filled with new language.
Definition: autocdlg.cxx:1372
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:2172
void EnableLanguage(bool bEnable)
Definition: autocdlg.cxx:137
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:250
void set_title(const OUString &rTitle)
Definition: cuicharmap.hxx:154
OUString toId(const void *pValue)
void SetStartDoubleQuote(const sal_Unicode cStart)
std::vector< DoubleString > DoubleStringArray
Definition: autocdlg.hxx:146
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:1614
virtual void select(int pos)=0
weld::Window * GetFrameWeld() const
#define DBL_START
Definition: autocdlg.cxx:1778
std::unique_ptr< CharClass > pCharClass
Definition: autocdlg.hxx:169
virtual ~OfaAutocorrOptionsPage() override
Definition: autocdlg.cxx:198
void FillListBox(const SmartTagMgr &rSmartTagMgr)
Inserts items into m_aSmartTagTypesLB.
Definition: autocdlg.cxx:2213
bool PutText(const OUString &rShort, const OUString &rLong, LanguageType eLang)
static OUString formatPercent(double dNumber, const LanguageTag &rLangTag)
weld::Entry & rEdit
virtual ~OfaAutocorrExceptPage() override
Definition: autocdlg.cxx:1227
IMPL_LINK_NOARG(OfaAutoCorrDlg, SelectLanguageHdl, weld::ComboBox &, void)
Definition: autocdlg.cxx:160
unsigned char sal_uInt8
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:202
std::unique_ptr< weld::SpinButton > m_xNFMinWordlen
Definition: autocdlg.hxx:338
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:1251
DoubleStringArray aDeletedEntries
Definition: autocdlg.hxx:151
SvStringsISortDtor * LoadCplSttExceptList(LanguageType eLang)
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:1707
OUString aName
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:732
const char sBorder[]
sal_Unicode GetEndSingleQuote() const
RET_OK
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:1620
bool IsSmartTagTypeEnabled(const OUString &rSmartTagType) const
std::unique_ptr< CollatorWrapper > pCompareClass
Definition: autocdlg.hxx:229
SvxLanguageListFlags
Reference< XComponentContext > getProcessComponentContext()
SfxOkDialogController * GetDialogController() const
void SetCharFont(const vcl::Font &rFont)
Definition: cuicharmap.cxx:608
std::unique_ptr< weld::TreeView > m_xSmartTagTypesLB
Definition: autocdlg.hxx:372
void SetLanguage(LanguageType eSet)
Definition: autocdlg.cxx:1358
void DisableFontSelection()
Definition: cuicharmap.cxx:218
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:413
OUString sCapitalStartWord
Definition: autocdlg.hxx:86
std::unique_ptr< weld::Button > m_xNewDoublePB
Definition: autocdlg.hxx:240
std::unique_ptr< weld::TreeView > m_xReplaceTLB
Definition: autocdlg.hxx:181
std::unique_ptr< weld::Button > m_xDblEndQuotePB
Definition: autocdlg.hxx:293
DeactivateRC
void append(TreeIter *pRet=nullptr)
OfaAutoCompleteTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:1899
StringsTable aStringsTable
Definition: autocdlg.hxx:228
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: autocdlg.cxx:1246
sal_UCS4 GetChar() const
Definition: cuicharmap.cxx:213
#define CBCOL_BOTH
Definition: autocdlg.cxx:210
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
Definition: cuicharmap.hxx:76
OUString GetSmartTagCaption(const OUString &rSmartTagType, const css::lang::Locale &rLocale) const
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:529
constexpr sal_uInt16 KEY_DELETE
std::unique_ptr< weld::Button > m_xSglEndQuotePB
Definition: autocdlg.hxx:287
vcl::Font aByInputBulletFont
Definition: autocdlg.hxx:108
sal_UCS4 cSglStartQuote
Definition: autocdlg.hxx:278
virtual bool HasSelection(bool bText=true) const
std::unique_ptr< weld::Button > m_xDblStandardPB
Definition: autocdlg.hxx:295
sal_uInt32 NumberOfRecognizers() const
ACFlags GetFlags() const
OfaAutoFmtOptions
Definition: autocdlg.cxx:326
Smart tag options tab page.
Definition: autocdlg.hxx:366
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
std::unique_ptr< weld::Entry > m_xDoubleCapsED
Definition: autocdlg.hxx:238
std::map< LanguageType, DoubleStringArray > aDoubleStringTable
Definition: autocdlg.hxx:167
sal_UCS4 cStartQuote
Definition: autocdlg.hxx:281
OfaQuoteOptions
Definition: autocdlg.cxx:1529
std::set< OUString > aFormatText
Definition: autocdlg.hxx:165
OUString sDelSpaceBetweenLines
Definition: autocdlg.hxx:101
static SfxModule * GetModule(SfxToolsModule nSharedLib)
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:1964
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:237
sal_uInt16 nPos
std::unique_ptr< weld::CheckButton > m_xCBRemoveList
...save the list for later use...
Definition: autocdlg.hxx:335
std::unique_ptr< weld::CheckButton > m_xAutoAbbrevCB
Definition: autocdlg.hxx:236
std::unique_ptr< weld::Button > m_xPBEntries
Definition: autocdlg.hxx:341
constexpr sal_uInt16 KEY_TAB
std::unique_ptr< weld::Container > m_xButtonBox
Definition: autocdlg.hxx:185
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: autocdlg.hxx:111
void SetCurPageId(const OString &rName)
OUString ChangeStringExt_Impl(sal_UCS4)
Definition: autocdlg.cxx:1874
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
bool m_bDetectedRangeSegmentation false
OUString sId
std::unique_ptr< weld::CheckButton > m_xTextOnlyCB
Definition: autocdlg.hxx:178