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