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(m_xReplaceTLB->get_text(rIter, 0),
806  m_xReplaceTLB->get_text(rIter, 1)));
807  DoubleString& rDouble = pArray->back();
808  rDouble.pUserData = reinterpret_cast<void*>(m_xReplaceTLB->get_id(rIter).toInt64());
809  return false;
810  });
811  }
812 
813  if( !bSWriter )
814  aFormatText.clear();
815 
816  if (aDoubleStringTable.find(eLang) != aDoubleStringTable.end())
817  {
818  DoubleStringArray& rArray = aDoubleStringTable[eNewLanguage];
819 
820  m_xReplaceTLB->bulk_insert_for_each(rArray.size(), [this, &rArray](weld::TreeIter& rIter, int nIndex) {
821  DoubleString &rDouble = rArray[nIndex];
822  bool bTextOnly = nullptr == rDouble.pUserData;
823  // formatted text is only in Writer
824  if (bSWriter || bTextOnly)
825  {
826  if (!bTextOnly)
827  {
828  // that means: with format info or even with selection text
829  OUString sId = OUString::number(reinterpret_cast<sal_Int64>(rDouble.pUserData));
830  m_xReplaceTLB->set_id(rIter, sId);
831  }
832  m_xReplaceTLB->set_text(rIter, rDouble.sShort, 0);
833  m_xReplaceTLB->set_text(rIter, rDouble.sLong, 1);
834  }
835  else
836  {
837  aFormatText.insert(rDouble.sShort);
838  }
839  }, nullptr, &m_aReplaceFixedWidths);
840  }
841  else
842  {
844  SvxAutocorrWordList* pWordList = pAutoCorrect->LoadAutocorrWordList(eLang);
845  const SvxAutocorrWordList::AutocorrWordSetType & rContent = pWordList->getSortedContent();
846  m_xReplaceTLB->bulk_insert_for_each(rContent.size(), [this, rContent](weld::TreeIter& rIter, int nIndex) {
847  auto const& elem = rContent[nIndex];
848  bool bTextOnly = elem.IsTextOnly();
849  // formatted text is only in Writer
850  if (bSWriter || bTextOnly)
851  {
852  if (!bTextOnly)
853  {
854  // that means: with format info or even with selection text
855  OUString sId = OUString::number(reinterpret_cast<sal_Int64>(m_xTextOnlyCB.get()));
856  m_xReplaceTLB->set_id(rIter, sId);
857  }
858  m_xReplaceTLB->set_text(rIter, elem.GetShort(), 0);
859  m_xReplaceTLB->set_text(rIter, elem.GetLong(), 1);
860  }
861  else
862  {
863  aFormatText.insert(elem.GetShort());
864  }
865  }, nullptr, &m_aReplaceFixedWidths);
866  m_xNewReplacePB->set_sensitive(false);
867  m_xDeleteReplacePB->set_sensitive(false);
868  }
869 
870  SfxViewShell* pViewShell = SfxViewShell::Current();
871  if (pViewShell && pViewShell->HasSelection())
872  {
873  bHasSelectionText = true;
874  const OUString sSelection( pViewShell->GetSelectionText() );
875  m_xReplaceED->set_text(sSelection);
876  m_xTextOnlyCB->set_active(!bSWriter);
877  m_xTextOnlyCB->set_sensitive(bSWriter && !sSelection.isEmpty());
878  }
879  else
880  {
881  m_xTextOnlyCB->set_active(true);
882  m_xTextOnlyCB->set_sensitive(false);
883  }
884 }
885 
887 {
888  RefillReplaceBox(true, eLang, eLang);
889  m_xShortED->grab_focus();
890 }
891 
893 {
894  //save old settings and refill
895  if(eSet != eLang)
896  {
897  RefillReplaceBox(false, eLang, eSet);
898  eLastDialogLanguage = eSet;
899 
900  LanguageTag aLanguageTag( eLastDialogLanguage );
902  pCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 );
903  pCharClass.reset( new CharClass( aLanguageTag ) );
904  ModifyHdl(*m_xShortED);
905  }
906 }
907 
909 {
910  if(!bFirstSelect || !bHasSelectionText)
911  {
912  int nEntry = rBox.get_selected_index();
913  OUString sTmpShort(rBox.get_text(nEntry, 0));
914  // if the text is set via ModifyHdl, the cursor is always at the beginning
915  // of a word, although you're editing here
916  bool bSameContent = 0 == pCompareClass->compareString(sTmpShort, m_xShortED->get_text());
917  int nStartPos, nEndPos;
918  m_xShortED->get_selection_bounds(nStartPos, nEndPos);
919  if (m_xShortED->get_text() != sTmpShort)
920  {
921  m_xShortED->set_text(sTmpShort);
922  // if it was only a different notation, the selection has to be set again
923  if (bSameContent)
924  {
925  m_xShortED->select_region(nStartPos, nEndPos);
926  }
927  }
928  m_xReplaceED->set_text(rBox.get_text(nEntry, 1));
929  // with UserData there is a Formatinfo
930  m_xTextOnlyCB->set_active(rBox.get_id(nEntry).isEmpty());
931  }
932  else
933  {
934  bFirstSelect = false;
935  }
936 
937  m_xNewReplacePB->set_sensitive(false);
938  m_xDeleteReplacePB->set_sensitive(true);
939 };
940 
941 void OfaAutocorrReplacePage::NewEntry(const OUString& sShort, const OUString& sLong, bool bKeepSourceFormatting)
942 {
943  DoubleStringArray& rNewArray = aChangesTable[eLang].aNewEntries;
944  for (size_t i = 0; i < rNewArray.size(); i++)
945  {
946  if (rNewArray[i].sShort == sShort)
947  {
948  rNewArray.erase(rNewArray.begin() + i);
949  break;
950  }
951  }
952 
953  DoubleStringArray& rDeletedArray = aChangesTable[eLang].aDeletedEntries;
954  for (size_t i = 0; i < rDeletedArray.size(); i++)
955  {
956  if (rDeletedArray[i].sShort == sShort)
957  {
958  rDeletedArray.erase(rDeletedArray.begin() + i);
959  break;
960  }
961  }
962 
963  DoubleString aNewString(sShort, sLong);
964  rNewArray.push_back(aNewString);
965  if (bKeepSourceFormatting)
966  rNewArray.back().pUserData = &bHasSelectionText;
967 }
968 
969 void OfaAutocorrReplacePage::DeleteEntry(const OUString& sShort, const OUString& sLong)
970 {
971  DoubleStringArray& rNewArray = aChangesTable[eLang].aNewEntries;
972  for (size_t i = 0; i < rNewArray.size(); i++)
973  {
974  if (rNewArray[i].sShort == sShort)
975  {
976  rNewArray.erase(rNewArray.begin() + i);
977  break;
978  }
979  }
980 
981  DoubleStringArray& rDeletedArray = aChangesTable[eLang].aDeletedEntries;
982  for (size_t i = 0; i < rDeletedArray.size(); i++)
983  {
984  if (rDeletedArray[i].sShort == sShort)
985  {
986  rDeletedArray.erase(rDeletedArray.begin() + i);
987  break;
988  }
989  }
990 
991  DoubleString aDeletedString(sShort, sLong);
992  rDeletedArray.push_back(aDeletedString);
993 }
994 
995 IMPL_LINK(OfaAutocorrReplacePage, NewDelButtonHdl, weld::Button&, rBtn, void)
996 {
997  NewDelHdl(&rBtn);
998 }
999 
1000 IMPL_LINK(OfaAutocorrReplacePage, NewDelActionHdl, weld::Entry&, rEdit, bool)
1001 {
1002  return NewDelHdl(&rEdit);
1003 }
1004 
1005 IMPL_LINK_NOARG(OfaAutocorrReplacePage, EntrySizeAllocHdl, const Size&, void)
1006 {
1007  m_aReplaceFixedWidths.clear();
1008  int x, y, width, height;
1009  if (m_xReplaceED->get_extents_relative_to(*m_xReplaceTLB, x, y, width, height))
1010  {
1011  m_aReplaceFixedWidths.push_back(x);
1012  m_aReplaceFixedWidths.push_back(width - 1);
1013  m_xReplaceTLB->set_column_fixed_widths(m_aReplaceFixedWidths);
1014  }
1015 }
1016 
1018 {
1019  int nEntry = m_xReplaceTLB->get_selected_index();
1020  if (pBtn == m_xDeleteReplacePB.get())
1021  {
1022  DBG_ASSERT( nEntry != -1, "no entry selected" );
1023  if (nEntry != -1)
1024  {
1025  DeleteEntry(m_xReplaceTLB->get_text(nEntry, 0), m_xReplaceTLB->get_text(nEntry, 1));
1026  m_xReplaceTLB->remove(nEntry);
1027  ModifyHdl(*m_xShortED);
1028  return true;
1029  }
1030  }
1031 
1032  if (pBtn == m_xNewReplacePB.get() || m_xNewReplacePB->get_sensitive())
1033  {
1034  OUString sEntry(m_xShortED->get_text());
1035  if (!sEntry.isEmpty() && (!m_xReplaceED->get_text().isEmpty() ||
1036  ( bHasSelectionText && bSWriter ) ))
1037  {
1038  bool bKeepSourceFormatting = !bReplaceEditChanged && !m_xTextOnlyCB->get_active();
1039 
1040  NewEntry(m_xShortED->get_text(), m_xReplaceED->get_text(), bKeepSourceFormatting);
1041  m_xReplaceTLB->freeze();
1042  int nPos = -1;
1043  if (nEntry != -1)
1044  {
1045  nPos = nEntry;
1046  m_xReplaceTLB->remove(nEntry);
1047  }
1048  else
1049  {
1050  int j;
1051  int nCount = m_xReplaceTLB->n_children();
1052  for (j = 0; j < nCount; ++j)
1053  {
1054  if (0 >= pCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0)))
1055  break;
1056  }
1057  nPos = j;
1058  }
1059 
1060  OUString sId;
1061  if (bKeepSourceFormatting)
1062  {
1063  sId = OUString::number(reinterpret_cast<sal_Int64>(&bHasSelectionText)); // new formatted text
1064  }
1065 
1066  m_xReplaceTLB->insert(nPos, sEntry, &sId, nullptr, nullptr);
1067  m_xReplaceTLB->set_text(nPos, m_xReplaceED->get_text(), 1);
1068  m_xReplaceTLB->thaw();
1069  m_xReplaceTLB->scroll_to_row(nPos);
1070  // if the request came from the ReplaceEdit, give focus to the ShortEdit
1071  if (m_xReplaceED->has_focus())
1072  {
1073  m_xShortED->grab_focus();
1074  }
1075  }
1076  }
1077  else
1078  {
1079  // this can only be an enter in one of the two edit fields
1080  // which means EndDialog() - has to be evaluated in KeyInput
1081  return false;
1082  }
1083  ModifyHdl(*m_xShortED);
1084  return true;
1085 }
1086 
1088 {
1089  std::unique_ptr<weld::TreeIter> xFirstSel(m_xReplaceTLB->make_iterator());
1090  bool bFirstSelIterSet = m_xReplaceTLB->get_selected(xFirstSel.get());
1091  bool bShort = &rEdt == m_xShortED.get();
1092  const OUString rEntry = rEdt.get_text();
1093  const OUString rRepString = m_xReplaceED->get_text();
1094  OUString aWordStr(pCharClass->lowercase(rEntry));
1095 
1096  if(bShort)
1097  {
1098  if(!rEntry.isEmpty())
1099  {
1100  bool bFound = false;
1101  bool bTmpSelEntry=false;
1102 
1103  m_xReplaceTLB->all_foreach([this, &rEntry, &rRepString, &bFound,
1104  &bTmpSelEntry, &bFirstSelIterSet,
1105  &xFirstSel, &aWordStr](weld::TreeIter& rIter){
1106  OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0);
1107  if( pCompareClass->compareString(rEntry, aTestStr ) == 0 )
1108  {
1109  if (!rRepString.isEmpty())
1110  bFirstSelect = true;
1111  m_xReplaceTLB->set_cursor(rIter);
1112  m_xReplaceTLB->copy_iterator(rIter, *xFirstSel);
1113  bFirstSelIterSet = true;
1114  m_xNewReplacePB->set_label(sModify);
1115  bFound = true;
1116  return true;
1117  }
1118  else
1119  {
1120  aTestStr = pCharClass->lowercase( aTestStr );
1121  if( aTestStr.startsWith(aWordStr) && !bTmpSelEntry )
1122  {
1123  m_xReplaceTLB->scroll_to_row(rIter);
1124  bTmpSelEntry = true;
1125  }
1126  }
1127  return false;
1128  });
1129  if( !bFound )
1130  {
1131  m_xReplaceTLB->select(-1);
1132  bFirstSelIterSet = false;
1133  m_xNewReplacePB->set_label(sNew);
1134  if( bReplaceEditChanged )
1135  m_xTextOnlyCB->set_sensitive(false);
1136  }
1137  m_xDeleteReplacePB->set_sensitive(bFound);
1138  }
1139  else if (m_xReplaceTLB->n_children() > 0)
1140  {
1141  m_xReplaceTLB->scroll_to_row(0);
1142  }
1143 
1144  }
1145  else if( !bShort )
1146  {
1147  bReplaceEditChanged = true;
1148  if (bFirstSelIterSet)
1149  {
1150  m_xNewReplacePB->set_label(sModify);
1151  }
1152  }
1153 
1154  const OUString& rShortTxt = m_xShortED->get_text();
1155  bool bEnableNew = !rShortTxt.isEmpty() &&
1156  ( !rRepString.isEmpty() ||
1157  ( bHasSelectionText && bSWriter )) &&
1158  ( !bFirstSelIterSet || rRepString !=
1159  m_xReplaceTLB->get_text(*xFirstSel, 1) );
1160  if( bEnableNew )
1161  {
1162  for (auto const& elem : aFormatText)
1163  {
1164  if(elem == rShortTxt)
1165  {
1166  bEnableNew = false;
1167  break;
1168  }
1169  }
1170  }
1171  m_xNewReplacePB->set_sensitive(bEnableNew);
1172 }
1173 
1174 static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view rString)
1175 {
1176  for (auto const& elem : rStrings)
1177  {
1178  if(elem == rString)
1179  {
1180  return true;
1181  }
1182  }
1183  return false;
1184 }
1185 
1187  : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet)
1188  , eLang(eLastDialogLanguage)
1189  , m_xAbbrevED(m_xBuilder->weld_entry("abbrev"))
1190  , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist"))
1191  , m_xNewAbbrevPB(m_xBuilder->weld_button("newabbrev"))
1192  , m_xDelAbbrevPB(m_xBuilder->weld_button("delabbrev"))
1193  , m_xAutoAbbrevCB(m_xBuilder->weld_check_button("autoabbrev"))
1194  , m_xDoubleCapsED(m_xBuilder->weld_entry("double"))
1195  , m_xDoubleCapsLB(m_xBuilder->weld_tree_view("doublelist"))
1196  , m_xNewDoublePB(m_xBuilder->weld_button("newdouble"))
1197  , m_xDelDoublePB(m_xBuilder->weld_button("deldouble"))
1198  , m_xAutoCapsCB(m_xBuilder->weld_check_button("autodouble"))
1199 {
1200  m_xAbbrevLB->make_sorted();
1201  m_xAbbrevLB->set_size_request(-1, m_xAbbrevLB->get_height_rows(6));
1202 
1203  m_xDoubleCapsLB->make_sorted();
1204  m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6));
1205 
1206  css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage ));
1208  pCompareClass->loadDefaultCollator( aLcl, 0 );
1209 
1210  m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1211  m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1212  m_xNewDoublePB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1213  m_xDelDoublePB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl));
1214 
1215  m_xAbbrevLB->connect_changed(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1216  m_xDoubleCapsLB->connect_changed(LINK(this, OfaAutocorrExceptPage, SelectHdl));
1217  m_xAbbrevED->connect_changed(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1218  m_xDoubleCapsED->connect_changed(LINK(this, OfaAutocorrExceptPage, ModifyHdl));
1219 
1220  m_xAbbrevED->connect_activate(LINK(this, OfaAutocorrExceptPage, NewDelActionHdl));
1221  m_xDoubleCapsED->connect_activate(LINK(this, OfaAutocorrExceptPage, NewDelActionHdl));
1222 }
1223 
1225 {
1226  aStringsTable.clear();
1227  pCompareClass.reset();
1228 }
1229 
1230 std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController,
1231  const SfxItemSet* rSet)
1232 {
1233  return std::make_unique<OfaAutocorrExceptPage>(pPage, pController, *rSet);
1234 }
1235 
1237 {
1238  if(eLang != eLastDialogLanguage)
1239  SetLanguage(eLastDialogLanguage);
1240  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(true);
1241 }
1242 
1244 {
1245  return DeactivateRC::LeavePage;
1246 }
1247 
1249 {
1251  for(StringsTable::reverse_iterator it1 = aStringsTable.rbegin(); it1 != aStringsTable.rend(); ++it1)
1252  {
1253  LanguageType eCurLang = it1->first;
1254  StringsArrays& rArrays = it1->second;
1255  if(eCurLang != eLang) // current language is treated later
1256  {
1257  SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eCurLang);
1258 
1259  if(pWrdList)
1260  {
1261  size_t nCount = pWrdList->size();
1262  size_t i;
1263  for( i = nCount; i; )
1264  {
1265  OUString aString = (*pWrdList)[ --i ];
1266 
1267  if( !lcl_FindInArray(rArrays.aDoubleCapsStrings, aString))
1268  {
1269  pWrdList->erase_at(i);
1270  }
1271  }
1272 
1273  for (auto const& elem : rArrays.aDoubleCapsStrings)
1274  {
1275  pWrdList->insert(elem);
1276  }
1277  pAutoCorrect->SaveWrdSttExceptList(eCurLang);
1278  }
1279 
1280  SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eCurLang);
1281 
1282  if(pCplList)
1283  {
1284  size_t nCount = pCplList->size();
1285  size_t i;
1286  for( i = nCount; i; )
1287  {
1288  OUString aString = (*pCplList)[ --i ];
1289  if( !lcl_FindInArray(rArrays.aAbbrevStrings, aString))
1290  {
1291  pCplList->erase_at(i);
1292  }
1293  }
1294 
1295  for (auto const& elem : rArrays.aAbbrevStrings)
1296  {
1297  pCplList->insert(elem);
1298  }
1299 
1300  pAutoCorrect->SaveCplSttExceptList(eCurLang);
1301  }
1302  }
1303  }
1304  aStringsTable.clear();
1305 
1306  SvStringsISortDtor* pWrdList = pAutoCorrect->LoadWrdSttExceptList(eLang);
1307 
1308  if(pWrdList)
1309  {
1310  size_t nCount = pWrdList->size();
1311  size_t i;
1312  for( i = nCount; i; )
1313  {
1314  OUString aString = (*pWrdList)[ --i ];
1315  if (m_xDoubleCapsLB->find_text(aString) == -1)
1316  {
1317  pWrdList->erase_at(i);
1318  }
1319  }
1320  nCount = m_xDoubleCapsLB->n_children();
1321  for( i = 0; i < nCount; ++i )
1322  {
1323  pWrdList->insert(m_xDoubleCapsLB->get_text(i));
1324  }
1325  pAutoCorrect->SaveWrdSttExceptList(eLang);
1326  }
1327 
1328  SvStringsISortDtor* pCplList = pAutoCorrect->LoadCplSttExceptList(eLang);
1329 
1330  if(pCplList)
1331  {
1332  size_t nCount = pCplList->size();
1333  for( size_t i = nCount; i; )
1334  {
1335  OUString aString = (*pCplList)[ --i ];
1336  if (m_xAbbrevLB->find_text(aString) == -1)
1337  {
1338  pCplList->erase_at(i);
1339  }
1340  }
1341  sal_Int32 nAbbrevCount = m_xAbbrevLB->n_children();
1342  for( sal_Int32 ia = 0; ia < nAbbrevCount; ++ia )
1343  {
1344  pCplList->insert(m_xAbbrevLB->get_text(ia));
1345  }
1346  pAutoCorrect->SaveCplSttExceptList(eLang);
1347  }
1348  if (m_xAutoAbbrevCB->get_state_changed_from_saved())
1349  pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordCplSttLst, m_xAutoAbbrevCB->get_active());
1350  if (m_xAutoCapsCB->get_state_changed_from_saved())
1351  pAutoCorrect->SetAutoCorrFlag( ACFlags::SaveWordWrdSttLst, m_xAutoCapsCB->get_active());
1352  return false;
1353 }
1354 
1356 {
1357  if(eLang != eSet)
1358  {
1359  // save old settings and fill anew
1360  RefillReplaceBoxes(false, eLang, eSet);
1361  eLastDialogLanguage = eSet;
1363  pCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 );
1364  ModifyHdl(*m_xAbbrevED);
1365  ModifyHdl(*m_xDoubleCapsED);
1366  }
1367 }
1368 
1370  LanguageType eOldLanguage,
1371  LanguageType eNewLanguage)
1372 {
1373  eLang = eNewLanguage;
1374  if(bFromReset)
1375  {
1376  aStringsTable.clear();
1377  }
1378  else
1379  {
1380  StringsArrays* pArrays;
1381  if(aStringsTable.find(eOldLanguage) != aStringsTable.end())
1382  {
1383  pArrays = &aStringsTable[eOldLanguage];
1384  pArrays->aAbbrevStrings.clear();
1385  pArrays->aDoubleCapsStrings.clear();
1386  }
1387  else
1388  {
1389  pArrays = &aStringsTable[eOldLanguage]; // create new array
1390  }
1391 
1392  sal_Int32 i, nCount;
1393  nCount = m_xAbbrevLB->n_children();
1394  for(i = 0; i < nCount; i++)
1395  pArrays->aAbbrevStrings.push_back(m_xAbbrevLB->get_text(i));
1396 
1397  nCount = m_xDoubleCapsLB->n_children();
1398  for(i = 0; i < nCount; i++)
1399  pArrays->aDoubleCapsStrings.push_back(m_xDoubleCapsLB->get_text(i));
1400  }
1401  m_xDoubleCapsLB->clear();
1402  m_xAbbrevLB->clear();
1403  m_xAbbrevED->set_text("");
1404  m_xDoubleCapsED->set_text("");
1405 
1406  if(aStringsTable.find(eLang) != aStringsTable.end())
1407  {
1408  StringsArrays& rArrays = aStringsTable[eLang];
1409  for (auto const& elem : rArrays.aAbbrevStrings)
1410  m_xAbbrevLB->append_text(elem);
1411 
1412  for (auto const& elem : rArrays.aDoubleCapsStrings)
1413  m_xDoubleCapsLB->append_text(elem);
1414  }
1415  else
1416  {
1418  const SvStringsISortDtor* pCplList = pAutoCorrect->GetCplSttExceptList(eLang);
1419  const SvStringsISortDtor* pWrdList = pAutoCorrect->GetWrdSttExceptList(eLang);
1420  size_t i;
1421  for( i = 0; i < pCplList->size(); i++ )
1422  {
1423  m_xAbbrevLB->append_text((*pCplList)[i]);
1424  }
1425  for( i = 0; i < pWrdList->size(); i++ )
1426  {
1427  m_xDoubleCapsLB->append_text((*pWrdList)[i]);
1428  }
1429  }
1430 }
1431 
1433 {
1435  RefillReplaceBoxes(true, eLang, eLang);
1436  m_xAutoAbbrevCB->set_active(pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordCplSttLst));
1437  m_xAutoCapsCB->set_active(pAutoCorrect->IsAutoCorrFlag( ACFlags::SaveWordWrdSttLst));
1438  m_xAutoAbbrevCB->save_state();
1439  m_xAutoCapsCB->save_state();
1440 }
1441 
1442 IMPL_LINK(OfaAutocorrExceptPage, NewDelButtonHdl, weld::Button&, rBtn, void)
1443 {
1444  NewDelHdl(&rBtn);
1445 }
1446 
1447 IMPL_LINK(OfaAutocorrExceptPage, NewDelActionHdl, weld::Entry&, rEdit, bool)
1448 {
1449  return NewDelHdl(&rEdit);
1450 }
1451 
1453 {
1454  if ((pBtn == m_xNewAbbrevPB.get() || pBtn == m_xAbbrevED.get())
1455  && !m_xAbbrevED->get_text().isEmpty() && m_xNewAbbrevPB->get_sensitive())
1456  {
1457  m_xAbbrevLB->append_text(m_xAbbrevED->get_text());
1458  ModifyHdl(*m_xAbbrevED);
1459  }
1460  else if(pBtn == m_xDelAbbrevPB.get())
1461  {
1462  m_xAbbrevLB->remove_text(m_xAbbrevED->get_text());
1463  ModifyHdl(*m_xAbbrevED);
1464  }
1465  else if((pBtn == m_xNewDoublePB.get() || pBtn == m_xDoubleCapsED.get() )
1466  && !m_xDoubleCapsED->get_text().isEmpty() && m_xNewDoublePB->get_sensitive())
1467  {
1468  m_xDoubleCapsLB->append_text(m_xDoubleCapsED->get_text());
1469  ModifyHdl(*m_xDoubleCapsED);
1470  }
1471  else if (pBtn == m_xDelDoublePB.get())
1472  {
1473  m_xDoubleCapsLB->remove_text(m_xDoubleCapsED->get_text());
1474  ModifyHdl(*m_xDoubleCapsED);
1475  }
1476  else
1477  {
1478  // we didn't do anything, if this was because of 'activate' in an
1479  // entry then let it continue to close the dialog like the replace
1480  // page does
1481  return false;
1482  }
1483  return true;
1484 }
1485 
1487 {
1488  if (&rBox == m_xAbbrevLB.get())
1489  {
1490  m_xAbbrevED->set_text(rBox.get_selected_text());
1491  m_xNewAbbrevPB->set_sensitive(false);
1492  m_xDelAbbrevPB->set_sensitive(true);
1493  }
1494  else
1495  {
1496  m_xDoubleCapsED->set_text(rBox.get_selected_text());
1497  m_xNewDoublePB->set_sensitive(false);
1498  m_xDelDoublePB->set_sensitive(true);
1499  }
1500 }
1501 
1503 {
1504  const OUString& sEntry = rEdt.get_text();
1505  bool bEntryLen = !sEntry.isEmpty();
1506  if (&rEdt == m_xAbbrevED.get())
1507  {
1508  bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *pCompareClass);
1509  if(bSame && sEntry != m_xAbbrevLB->get_selected_text())
1510  rEdt.set_text(m_xAbbrevLB->get_selected_text());
1511  m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen);
1512  m_xDelAbbrevPB->set_sensitive(bSame && bEntryLen);
1513  }
1514  else
1515  {
1516  bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *pCompareClass);
1517  if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text())
1518  rEdt.set_text(m_xDoubleCapsLB->get_selected_text());
1519  m_xNewDoublePB->set_sensitive(!bSame && bEntryLen);
1520  m_xDelDoublePB->set_sensitive(bSame && bEntryLen);
1521  }
1522 }
1523 
1524 namespace {
1525 
1527 {
1528  ADD_NONBRK_SPACE,
1529  REPLACE_1ST,
1530  TRANSLITERATE_RTL,
1531  REPLACE_ANGLE_QUOTES
1532 };
1533 
1534 }
1535 
1536 void OfaQuoteTabPage::CreateEntry(weld::TreeView& rCheckLB, const OUString& rTxt, sal_uInt16 nCol, sal_uInt16 nTextCol)
1537 {
1538  rCheckLB.append();
1539  const int nRow = rCheckLB.n_children() - 1;
1540  if (nCol == CBCOL_FIRST || nCol == CBCOL_BOTH)
1541  rCheckLB.set_toggle(nRow, TRISTATE_FALSE, CBCOL_FIRST);
1542  if (nCol == CBCOL_SECOND || nCol == CBCOL_BOTH)
1543  rCheckLB.set_toggle(nRow, TRISTATE_FALSE, CBCOL_SECOND);
1544  rCheckLB.set_text(nRow, rTxt, nTextCol);
1545 }
1546 
1548  : SfxTabPage(pPage, pController, "cui/ui/applylocalizedpage.ui", "ApplyLocalizedPage", &rSet)
1549  , sNonBrkSpace(CuiResId(RID_SVXSTR_NON_BREAK_SPACE))
1550  , sOrdinal(CuiResId(RID_SVXSTR_ORDINAL))
1551  , sTransliterateRTL(CuiResId(RID_SVXSTR_OLD_HUNGARIAN))
1552  , sAngleQuotes(CuiResId(RID_SVXSTR_ANGLE_QUOTES))
1553  , cSglStartQuote(0)
1554  , cSglEndQuote(0)
1555  , cStartQuote(0)
1556  , cEndQuote(0)
1557  , m_xSingleTypoCB(m_xBuilder->weld_check_button("singlereplace"))
1558  , m_xSglStartQuotePB(m_xBuilder->weld_button("startsingle"))
1559  , m_xSglStartExFT(m_xBuilder->weld_label("singlestartex"))
1560  , m_xSglEndQuotePB(m_xBuilder->weld_button("endsingle"))
1561  , m_xSglEndExFT(m_xBuilder->weld_label("singleendex"))
1562  , m_xSglStandardPB(m_xBuilder->weld_button("defaultsingle"))
1563  , m_xDoubleTypoCB(m_xBuilder->weld_check_button("doublereplace"))
1564  , m_xDblStartQuotePB(m_xBuilder->weld_button("startdouble"))
1565  , m_xDblStartExFT(m_xBuilder->weld_label("doublestartex"))
1566  , m_xDblEndQuotePB(m_xBuilder->weld_button("enddouble"))
1567  , m_xDblEndExFT(m_xBuilder->weld_label("doubleendex"))
1568  , m_xDblStandardPB(m_xBuilder->weld_button("defaultdouble"))
1569  , m_sStandard(m_xSglStartExFT->get_label())
1570  , m_xCheckLB(m_xBuilder->weld_tree_view("checklist"))
1571  , m_xSwCheckLB(m_xBuilder->weld_tree_view("list"))
1572 {
1573  m_xSwCheckLB->set_size_request(m_xSwCheckLB->get_approximate_digit_width() * 50,
1574  m_xSwCheckLB->get_height_rows(6));
1575 
1576  bool bShowSWOptions = false;
1577 
1578  const SfxBoolItem* pItem = rSet.GetItem<SfxBoolItem>(SID_AUTO_CORRECT_DLG, false);
1579  if ( pItem && pItem->GetValue() )
1580  bShowSWOptions = true;
1581 
1582  if ( bShowSWOptions )
1583  {
1584  m_xSwCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
1585  std::vector<int> aWidths;
1586  aWidths.push_back(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(0)).Width() * 2);
1587  aWidths.push_back(m_xSwCheckLB->get_pixel_size(m_xSwCheckLB->get_column_title(1)).Width() * 2);
1588  m_xSwCheckLB->set_column_fixed_widths(aWidths);
1589  m_xCheckLB->hide();
1590  }
1591  else
1592  {
1593  m_xCheckLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
1594  m_xSwCheckLB->hide();
1595  }
1596 
1597  m_xDblStartQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1598  m_xDblEndQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1599  m_xSglStartQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1600  m_xSglEndQuotePB->connect_clicked(LINK(this, OfaQuoteTabPage, QuoteHdl));
1601  m_xDblStandardPB->connect_clicked(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1602  m_xSglStandardPB->connect_clicked(LINK(this, OfaQuoteTabPage, StdQuoteHdl));
1603 }
1604 
1606 {
1607 }
1608 
1609 std::unique_ptr<SfxTabPage> OfaQuoteTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1610  const SfxItemSet* rAttrSet)
1611 {
1612  return std::make_unique<OfaQuoteTabPage>(pPage, pController, *rAttrSet);
1613 }
1614 
1616 {
1618 
1619  ACFlags nFlags = pAutoCorrect->GetFlags();
1620 
1621  if (m_xCheckLB->get_visible())
1622  {
1623  int nPos = 0;
1624  pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1625  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1626  pAutoCorrect->SetAutoCorrFlag(ACFlags::TransliterateRTL, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1627  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgAngleQuotes, m_xCheckLB->get_toggle(nPos++) == TRISTATE_TRUE);
1628  }
1629 
1630  bool bModified = false;
1631  if (m_xSwCheckLB->get_visible())
1632  {
1633  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1634 
1635  bool bCheck = m_xSwCheckLB->get_toggle(ADD_NONBRK_SPACE, CBCOL_FIRST) == TRISTATE_TRUE;
1636  bModified |= pOpt->bAddNonBrkSpace != bCheck;
1637  pOpt->bAddNonBrkSpace = bCheck;
1638  pAutoCorrect->SetAutoCorrFlag(ACFlags::AddNonBrkSpace,
1639  m_xSwCheckLB->get_toggle(ADD_NONBRK_SPACE, CBCOL_SECOND) == TRISTATE_TRUE);
1640 
1641  bCheck = m_xSwCheckLB->get_toggle(REPLACE_1ST, CBCOL_FIRST) == TRISTATE_TRUE;
1642  bModified |= pOpt->bChgOrdinalNumber != bCheck;
1643  pOpt->bChgOrdinalNumber = bCheck;
1644  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgOrdinalNumber,
1645  m_xSwCheckLB->get_toggle(REPLACE_1ST, CBCOL_SECOND) == TRISTATE_TRUE);
1646 
1647  bCheck = m_xSwCheckLB->get_toggle(TRANSLITERATE_RTL, CBCOL_FIRST) == TRISTATE_TRUE;
1648  bModified |= pOpt->bTransliterateRTL != bCheck;
1649  pOpt->bTransliterateRTL = bCheck;
1650  pAutoCorrect->SetAutoCorrFlag(ACFlags::TransliterateRTL,
1651  m_xSwCheckLB->get_toggle(TRANSLITERATE_RTL, CBCOL_SECOND) == TRISTATE_TRUE);
1652 
1653  bCheck = m_xSwCheckLB->get_toggle(REPLACE_ANGLE_QUOTES, CBCOL_FIRST) == TRISTATE_TRUE;
1654  bModified |= pOpt->bChgAngleQuotes != bCheck;
1655  pOpt->bChgAngleQuotes = bCheck;
1656  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgAngleQuotes,
1657  m_xSwCheckLB->get_toggle(REPLACE_ANGLE_QUOTES, CBCOL_SECOND) == TRISTATE_TRUE);
1658  }
1659 
1660  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgQuotes, m_xDoubleTypoCB->get_active());
1661  pAutoCorrect->SetAutoCorrFlag(ACFlags::ChgSglQuotes, m_xSingleTypoCB->get_active());
1662  bool bReturn = nFlags != pAutoCorrect->GetFlags();
1663  if(cStartQuote != pAutoCorrect->GetStartDoubleQuote())
1664  {
1665  bReturn = true;
1666  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cStartQuote); //TODO
1667  pAutoCorrect->SetStartDoubleQuote(cUCS2);
1668  }
1669  if(cEndQuote != pAutoCorrect->GetEndDoubleQuote())
1670  {
1671  bReturn = true;
1672  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cEndQuote); //TODO
1673  pAutoCorrect->SetEndDoubleQuote(cUCS2);
1674  }
1675  if(cSglStartQuote != pAutoCorrect->GetStartSingleQuote())
1676  {
1677  bReturn = true;
1678  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglStartQuote); //TODO
1679  pAutoCorrect->SetStartSingleQuote(cUCS2);
1680  }
1681  if(cSglEndQuote != pAutoCorrect->GetEndSingleQuote())
1682  {
1683  bReturn = true;
1684  sal_Unicode cUCS2 = static_cast<sal_Unicode>(cSglEndQuote); //TODO
1685  pAutoCorrect->SetEndSingleQuote(cUCS2);
1686  }
1687 
1688  if( bModified || bReturn )
1689  {
1691  rCfg.SetModified();
1692  rCfg.Commit();
1693  }
1694  return bReturn;
1695 }
1696 
1698 {
1699  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage(false);
1700 }
1701 
1703 {
1705  const ACFlags nFlags = pAutoCorrect->GetFlags();
1706 
1707  // Initialize the Sw options
1708  if (m_xSwCheckLB->get_visible())
1709  {
1710  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1711 
1712  m_xSwCheckLB->freeze();
1713  m_xSwCheckLB->clear();
1714 
1719 
1720  m_xSwCheckLB->set_toggle(ADD_NONBRK_SPACE, pOpt->bAddNonBrkSpace ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1721  m_xSwCheckLB->set_toggle(ADD_NONBRK_SPACE, bool(nFlags & ACFlags::AddNonBrkSpace) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1722  m_xSwCheckLB->set_toggle(REPLACE_1ST, pOpt->bChgOrdinalNumber ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1723  m_xSwCheckLB->set_toggle(REPLACE_1ST, bool(nFlags & ACFlags::ChgOrdinalNumber) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1724  m_xSwCheckLB->set_toggle(TRANSLITERATE_RTL, pOpt->bTransliterateRTL ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1725  m_xSwCheckLB->set_toggle(TRANSLITERATE_RTL, bool(nFlags & ACFlags::TransliterateRTL) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1726  m_xSwCheckLB->set_toggle(REPLACE_ANGLE_QUOTES, pOpt->bChgAngleQuotes ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_FIRST);
1727  m_xSwCheckLB->set_toggle(REPLACE_ANGLE_QUOTES, bool(nFlags & ACFlags::ChgAngleQuotes) ? TRISTATE_TRUE : TRISTATE_FALSE, CBCOL_SECOND);
1728 
1729  m_xSwCheckLB->thaw();
1730  }
1731 
1732  // Initialize the non Sw options
1733  if (m_xCheckLB->get_visible())
1734  {
1735  m_xCheckLB->freeze();
1736  m_xCheckLB->clear();
1737 
1738  int nPos = 0;
1739  m_xCheckLB->append();
1740  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::AddNonBrkSpace) ? TRISTATE_TRUE : TRISTATE_FALSE);
1741  m_xCheckLB->set_text(nPos++, sNonBrkSpace, 0);
1742  m_xCheckLB->append();
1743  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::ChgOrdinalNumber) ? TRISTATE_TRUE : TRISTATE_FALSE);
1744  m_xCheckLB->set_text(nPos++, sOrdinal, 0);
1745  m_xCheckLB->append();
1746  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::TransliterateRTL) ? TRISTATE_TRUE : TRISTATE_FALSE);
1747  m_xCheckLB->set_text(nPos++, sTransliterateRTL, 0);
1748  m_xCheckLB->append();
1749  m_xCheckLB->set_toggle(nPos, bool(nFlags & ACFlags::ChgAngleQuotes) ? TRISTATE_TRUE : TRISTATE_FALSE);
1750  m_xCheckLB->set_text(nPos++, sAngleQuotes, 0);
1751 
1752  m_xCheckLB->thaw();
1753  }
1754 
1755  // Initialize the quote stuffs
1756  m_xDoubleTypoCB->set_active(bool(nFlags & ACFlags::ChgQuotes));
1757  m_xSingleTypoCB->set_active(bool(nFlags & ACFlags::ChgSglQuotes));
1758  m_xDoubleTypoCB->save_state();
1759  m_xSingleTypoCB->save_state();
1760 
1761  cStartQuote = pAutoCorrect->GetStartDoubleQuote();
1762  cEndQuote = pAutoCorrect->GetEndDoubleQuote();
1763  cSglStartQuote = pAutoCorrect->GetStartSingleQuote();
1764  cSglEndQuote = pAutoCorrect->GetEndSingleQuote();
1765 
1770 }
1771 
1772 #define SGL_START 0
1773 #define DBL_START 1
1774 #define SGL_END 2
1775 #define DBL_END 3
1776 
1777 
1778 IMPL_LINK(OfaQuoteTabPage, QuoteHdl, weld::Button&, rBtn, void)
1779 {
1780  sal_uInt16 nMode = SGL_START;
1781  if (&rBtn == m_xSglEndQuotePB.get())
1782  nMode = SGL_END;
1783  else if (&rBtn == m_xDblStartQuotePB.get())
1784  nMode = DBL_START;
1785  else if (&rBtn == m_xDblEndQuotePB.get())
1786  nMode = DBL_END;
1787  // start character selection dialog
1788  SvxCharacterMap aMap(GetFrameWeld(), nullptr, nullptr);
1789  aMap.SetCharFont( OutputDevice::GetDefaultFont(DefaultFontType::LATIN_TEXT,
1790  LANGUAGE_ENGLISH_US, GetDefaultFontFlags::OnlyOne ));
1791  aMap.set_title(nMode < SGL_END ? CuiResId(RID_SVXSTR_STARTQUOTE) : CuiResId(RID_SVXSTR_ENDQUOTE));
1792  sal_UCS4 cDlg;
1795  switch( nMode )
1796  {
1797  case SGL_START:
1798  cDlg = cSglStartQuote;
1799  if(cDlg == 0)
1800  cDlg = pAutoCorrect->GetQuote('\'', true, eLang);
1801  break;
1802  case SGL_END:
1803  cDlg = cSglEndQuote;
1804  if(cDlg == 0)
1805  cDlg = pAutoCorrect->GetQuote('\'', false, eLang);
1806  break;
1807  case DBL_START:
1808  cDlg = cStartQuote;
1809  if(cDlg == 0)
1810  cDlg = pAutoCorrect->GetQuote('\"', true, eLang);
1811  break;
1812  case DBL_END:
1813  cDlg = cEndQuote;
1814  if(cDlg == 0)
1815  cDlg = pAutoCorrect->GetQuote('\"', false, eLang);
1816  break;
1817  default:
1818  OSL_FAIL("svx::OfaQuoteTabPage::QuoteHdl(), how to initialize cDlg?" );
1819  cDlg = 0;
1820  break;
1821 
1822  }
1823  aMap.SetChar( cDlg );
1824  aMap.DisableFontSelection();
1825  if (aMap.run() != RET_OK)
1826  return;
1827 
1828  sal_UCS4 cNewChar = aMap.GetChar();
1829  switch( nMode )
1830  {
1831  case SGL_START:
1832  cSglStartQuote = cNewChar;
1833  m_xSglStartExFT->set_label(ChangeStringExt_Impl(cNewChar));
1834  break;
1835  case SGL_END:
1836  cSglEndQuote = cNewChar;
1837  m_xSglEndExFT->set_label(ChangeStringExt_Impl(cNewChar));
1838  break;
1839  case DBL_START:
1840  cStartQuote = cNewChar;
1841  m_xDblStartExFT->set_label(ChangeStringExt_Impl(cNewChar));
1842  break;
1843  case DBL_END:
1844  cEndQuote = cNewChar;
1845  m_xDblEndExFT->set_label(ChangeStringExt_Impl(cNewChar));
1846  break;
1847  }
1848 }
1849 
1850 IMPL_LINK(OfaQuoteTabPage, StdQuoteHdl, weld::Button&, rBtn, void)
1851 {
1852  if (&rBtn == m_xDblStandardPB.get())
1853  {
1854  cStartQuote = 0;
1855  m_xDblStartExFT->set_label(ChangeStringExt_Impl(0));
1856  cEndQuote = 0;
1857  m_xDblEndExFT->set_label(ChangeStringExt_Impl(0));
1858 
1859  }
1860  else
1861  {
1862  cSglStartQuote = 0;
1863  m_xSglStartExFT->set_label(ChangeStringExt_Impl(0));
1864  cSglEndQuote = 0;
1865  m_xSglEndExFT->set_label(ChangeStringExt_Impl(0));
1866  }
1867 }
1868 
1870 {
1871  if (!cChar)
1872  return m_sStandard;
1873 
1874  // convert codepoint value to unicode-hex string
1875  sal_UCS4 aStrCodes[32] = { 0, ' ', '(', 'U', '+', '0' };
1876  aStrCodes[0] = cChar;
1877  int nFullLen = 5;
1878  int nHexLen = 4;
1879  while( (cChar >> (4*nHexLen)) != 0 )
1880  ++nHexLen;
1881  for( int i = nHexLen; --i >= 0;)
1882  {
1883  sal_UCS4 cHexDigit = ((cChar >> (4*i)) & 0x0f) + '0';
1884  if( cHexDigit > '9' )
1885  cHexDigit += 'A' - ('9' + 1);
1886  aStrCodes[ nFullLen++ ] = cHexDigit;
1887  }
1888  aStrCodes[ nFullLen++ ] = ')';
1889  // using the new UCS4 constructor
1890  OUString aOUStr( aStrCodes, nFullLen );
1891  return aOUStr;
1892 }
1893 
1895  const SfxItemSet& rSet)
1896  : SfxTabPage(pPage, pController, "cui/ui/wordcompletionpage.ui",
1897  "WordCompletionPage", &rSet)
1898  , m_pAutoCompleteList(nullptr)
1899  , m_nAutoCmpltListCnt(0)
1900  , m_xCBActiv(m_xBuilder->weld_check_button("enablewordcomplete"))
1901  , m_xCBAppendSpace(m_xBuilder->weld_check_button("appendspace"))
1902  , m_xCBAsTip(m_xBuilder->weld_check_button("showastip"))
1903  , m_xCBCollect(m_xBuilder->weld_check_button("collectwords"))
1904  , m_xCBRemoveList(m_xBuilder->weld_check_button("whenclosing"))
1905  , m_xDCBExpandKey(m_xBuilder->weld_combo_box("acceptwith"))
1906  , m_xNFMinWordlen(m_xBuilder->weld_spin_button("minwordlen"))
1907  , m_xNFMaxEntries(m_xBuilder->weld_spin_button("maxentries"))
1908  , m_xLBEntries(m_xBuilder->weld_tree_view("entries"))
1909  , m_xPBEntries(m_xBuilder->weld_button("delete"))
1910 {
1911  //fdo#65595, we need height-for-width support here, but for now we can
1912  //bodge it
1913  Size aPrefSize(m_xCBRemoveList->get_preferred_size());
1914  int nMaxWidth = m_xCBRemoveList->get_approximate_digit_width() * 40;
1915  if (aPrefSize.Width() > nMaxWidth)
1916  {
1917  m_xCBRemoveList->set_label_wrap(true);
1918  m_xCBRemoveList->set_size_request(nMaxWidth, -1);
1919  }
1920 
1921  m_xLBEntries->set_size_request(m_xLBEntries->get_approximate_digit_width() * 30,
1922  m_xLBEntries->get_height_rows(10));
1923 
1924  // the defined KEYs
1925  static const sal_uInt16 aKeyCodes[] = {
1926  KEY_END,
1927  KEY_RETURN,
1928  KEY_SPACE,
1929  KEY_RIGHT,
1930  KEY_TAB,
1931  0
1932  };
1933 
1934  for( const sal_uInt16* pKeys = aKeyCodes; *pKeys; ++pKeys )
1935  {
1936  vcl::KeyCode aKCode(*pKeys);
1937  m_xDCBExpandKey->append(OUString::number(static_cast<sal_Int32>(*pKeys)), aKCode.GetName());
1938  if (KEY_RETURN == *pKeys) // default to RETURN
1939  m_xDCBExpandKey->set_active(std::distance(aKeyCodes, pKeys));
1940  }
1941 
1942  m_xPBEntries->connect_clicked(LINK(this, OfaAutoCompleteTabPage, DeleteHdl));
1943  m_xCBActiv->connect_toggled(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
1944  m_xCBCollect->connect_toggled(LINK(this, OfaAutoCompleteTabPage, CheckHdl));
1945  m_xLBEntries->connect_key_release(LINK(this, OfaAutoCompleteTabPage, KeyReleaseHdl));
1946 }
1947 
1949 {
1950 }
1951 
1952 std::unique_ptr<SfxTabPage> OfaAutoCompleteTabPage::Create(weld::Container* pPage, weld::DialogController* pController,
1953  const SfxItemSet* rSet)
1954 {
1955  return std::make_unique<OfaAutoCompleteTabPage>(pPage, pController, *rSet);
1956 }
1957 
1959 {
1960  bool bModified = false, bCheck;
1962  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
1963  sal_uInt16 nVal;
1964 
1965  bCheck = m_xCBActiv->get_active();
1966  bModified |= pOpt->bAutoCompleteWords != bCheck;
1967  pOpt->bAutoCompleteWords = bCheck;
1968  bCheck = m_xCBCollect->get_active();
1969  bModified |= pOpt->bAutoCmpltCollectWords != bCheck;
1970  pOpt->bAutoCmpltCollectWords = bCheck;
1971  bCheck = !m_xCBRemoveList->get_active(); // inverted value!
1972  bModified |= pOpt->bAutoCmpltKeepList != bCheck;
1973  pOpt->bAutoCmpltKeepList = bCheck;
1974  bCheck = m_xCBAppendSpace->get_active();
1975  bModified |= pOpt->bAutoCmpltAppendBlank != bCheck;
1976  pOpt->bAutoCmpltAppendBlank = bCheck;
1977  bCheck = m_xCBAsTip->get_active();
1978  bModified |= pOpt->bAutoCmpltShowAsTip != bCheck;
1979  pOpt->bAutoCmpltShowAsTip = bCheck;
1980 
1981  nVal = static_cast<sal_uInt16>(m_xNFMinWordlen->get_value());
1982  bModified |= nVal != pOpt->nAutoCmpltWordLen;
1983  pOpt->nAutoCmpltWordLen = nVal;
1984 
1985  nVal = static_cast<sal_uInt16>(m_xNFMaxEntries->get_value());
1986  bModified |= nVal != pOpt->nAutoCmpltListLen;
1987  pOpt->nAutoCmpltListLen = nVal;
1988 
1989  const int nPos = m_xDCBExpandKey->get_active();
1990  if (nPos != -1)
1991  {
1992  sal_Int32 nKey = m_xDCBExpandKey->get_id(nPos).toInt32();
1993  bModified |= nKey != pOpt->nAutoCmpltExpandKey;
1994  pOpt->nAutoCmpltExpandKey = static_cast<sal_uInt16>(nKey);
1995  }
1996 
1997  if (m_pAutoCompleteList && m_nAutoCmpltListCnt != m_xLBEntries->n_children())
1998  {
1999  bModified = true;
2001  }
2002  if( bModified )
2003  {
2005  rCfg.SetModified();
2006  rCfg.Commit();
2007  }
2008  return true;
2009 }
2010 
2012 {
2014  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2015 
2016  m_xCBActiv->set_active( pOpt->bAutoCompleteWords );
2017  m_xCBCollect->set_active( pOpt->bAutoCmpltCollectWords );
2018  m_xCBRemoveList->set_active( !pOpt->bAutoCmpltKeepList ); //inverted value!
2019  m_xCBAppendSpace->set_active( pOpt->bAutoCmpltAppendBlank );
2020  m_xCBAsTip->set_active( pOpt->bAutoCmpltShowAsTip );
2021 
2022  m_xNFMinWordlen->set_value( pOpt->nAutoCmpltWordLen );
2023  m_xNFMaxEntries->set_value( pOpt->nAutoCmpltListLen );
2024 
2025  // select the specific KeyCode:
2026  {
2027  sal_Int32 nKey = pOpt->nAutoCmpltExpandKey;
2028  for (int n = 0, nCnt = m_xDCBExpandKey->get_count(); n < nCnt; ++n)
2029  {
2030  if (nKey == m_xDCBExpandKey->get_id(n).toInt32())
2031  {
2032  m_xDCBExpandKey->set_active(n);
2033  break;
2034  }
2035  }
2036  }
2037 
2038  if (pOpt->m_pAutoCompleteList && !pOpt->m_pAutoCompleteList->empty())
2039  {
2041  pOpt->m_pAutoCompleteList);
2042  pOpt->m_pAutoCompleteList = nullptr;
2044  for (size_t n = 0; n < m_nAutoCmpltListCnt; ++n)
2045  {
2046  const OUString* pStr =
2047  &(*m_pAutoCompleteList)[n]->GetAutoCompleteString();
2048  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pStr)));
2049  m_xLBEntries->append(sId, *pStr);
2050  }
2051  }
2052  else
2053  {
2054  m_xLBEntries->set_sensitive(false);
2055  m_xPBEntries->set_sensitive(false);
2056  }
2057 
2058  CheckHdl(*m_xCBActiv);
2059  CheckHdl(*m_xCBCollect);
2060 }
2061 
2063 {
2064  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage( false );
2065 }
2066 
2068 {
2069  auto rows = m_xLBEntries->get_selected_rows();
2070  std::sort(rows.begin(), rows.end());
2071  while (!rows.empty())
2072  {
2073  sal_Int32 nPos = rows.back();
2074  OUString* pStr = reinterpret_cast<OUString*>(m_xLBEntries->get_id(nPos).toInt64());
2075  m_xLBEntries->remove(nPos);
2076  editeng::IAutoCompleteString hack(*pStr); // UGLY
2077  m_pAutoCompleteList->erase(&hack);
2078  rows.pop_back();
2079  }
2080 }
2081 
2083 {
2084  bool bEnable = rBox.get_active();
2085  if (&rBox == m_xCBActiv.get())
2086  {
2087  m_xCBAppendSpace->set_sensitive(bEnable);
2088  m_xCBAppendSpace->set_sensitive(bEnable);
2089  m_xCBAsTip->set_sensitive(bEnable);
2090  m_xDCBExpandKey->set_sensitive(bEnable);
2091  }
2092  else if (&rBox == m_xCBCollect.get())
2093  m_xCBRemoveList->set_sensitive(bEnable);
2094 }
2095 
2097 {
2098  auto rows = m_xLBEntries->get_selected_rows();
2099  if (!m_pAutoCompleteList || rows.empty())
2100  return;
2101 
2103 
2104  OStringBuffer sData;
2105 
2106  rtl_TextEncoding nEncode = osl_getThreadTextEncoding();
2107 
2108  for (auto a : rows)
2109  {
2110  sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode));
2111 #if defined(_WIN32)
2112  sData.append("\015\012");
2113 #else
2114  sData.append("\012");
2115 #endif
2116  }
2117  pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() );
2118  pCntnr->CopyToClipboard(m_xLBEntries->get_clipboard());
2119 }
2120 
2121 IMPL_LINK(OfaAutoCompleteTabPage, KeyReleaseHdl, const KeyEvent&, rEvent, bool)
2122 {
2123  bool bHandled = false;
2124  const vcl::KeyCode& rKeyCode = rEvent.GetKeyCode();
2125  switch (rKeyCode.GetModifier() | rKeyCode.GetCode())
2126  {
2127  case KEY_DELETE:
2128  DeleteHdl(*m_xPBEntries);
2129  bHandled = true;
2130  break;
2131  default:
2132  if (KeyFuncType::COPY == rKeyCode.GetFunction())
2133  {
2134  CopyToClipboard();
2135  bHandled = true;
2136  }
2137  break;
2138  }
2139  return bHandled;
2140 }
2141 
2142 // class OfaSmartTagOptionsTabPage ---------------------------------------------
2143 
2145  const SfxItemSet& rSet )
2146  : SfxTabPage(pPage, pController, "cui/ui/smarttagoptionspage.ui", "SmartTagOptionsPage", &rSet)
2147  , m_xMainCB(m_xBuilder->weld_check_button("main"))
2148  , m_xSmartTagTypesLB(m_xBuilder->weld_tree_view("list"))
2149  , m_xPropertiesPB(m_xBuilder->weld_button("properties"))
2150 {
2151  m_xSmartTagTypesLB->set_size_request(m_xSmartTagTypesLB->get_approximate_digit_width() * 50,
2152  m_xSmartTagTypesLB->get_height_rows(6));
2153 
2154  m_xSmartTagTypesLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
2155 
2156  // set the handlers:
2157  m_xMainCB->connect_toggled(LINK(this, OfaSmartTagOptionsTabPage, CheckHdl));
2158  m_xPropertiesPB->connect_clicked(LINK(this, OfaSmartTagOptionsTabPage, ClickHdl));
2159  m_xSmartTagTypesLB->connect_changed(LINK(this, OfaSmartTagOptionsTabPage, SelectHdl));
2160 }
2161 
2163 {
2164 }
2165 
2166 std::unique_ptr<SfxTabPage> OfaSmartTagOptionsTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2167 {
2168  return std::make_unique<OfaSmartTagOptionsTabPage>(pPage, pController, *rSet);
2169 }
2170 
2171 namespace {
2172 
2175 struct ImplSmartTagLBUserData
2176 {
2177  OUString maSmartTagType;
2178  uno::Reference< smarttags::XSmartTagRecognizer > mxRec;
2179  sal_Int32 mnSmartTagIdx;
2180 
2181  ImplSmartTagLBUserData( const OUString& rSmartTagType,
2182  uno::Reference< smarttags::XSmartTagRecognizer > const & xRec,
2183  sal_Int32 nSmartTagIdx ) :
2184  maSmartTagType( rSmartTagType ),
2185  mxRec( xRec ),
2186  mnSmartTagIdx( nSmartTagIdx ) {}
2187 };
2188 
2189 }
2190 
2194 {
2195  const int nCount = m_xSmartTagTypesLB->n_children();
2196  for (int i = 0; i < nCount; ++i)
2197  {
2198  const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64());
2199  delete pUserData;
2200  }
2201 
2202  m_xSmartTagTypesLB->clear();
2203 }
2204 
2208 {
2209  // first we have to clear the list box:
2210  ClearListBox();
2211 
2212  // fill list box:
2213  const sal_uInt32 nNumberOfRecognizers = rSmartTagMgr.NumberOfRecognizers();
2214  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2215 
2216  for ( sal_uInt32 i = 0; i < nNumberOfRecognizers; ++i )
2217  {
2218  const uno::Reference< smarttags::XSmartTagRecognizer >& xRec = rSmartTagMgr.GetRecognizer(i);
2219 
2220  const OUString aName = xRec->getName( aLocale );
2221  const sal_Int32 nNumberOfSupportedSmartTags = xRec->getSmartTagCount();
2222 
2223  for ( sal_Int32 j = 0; j < nNumberOfSupportedSmartTags; ++j )
2224  {
2225  const OUString aSmartTagType = xRec->getSmartTagName(j);
2226  OUString aSmartTagCaption = rSmartTagMgr.GetSmartTagCaption( aSmartTagType, aLocale );
2227 
2228  if ( aSmartTagCaption.isEmpty() )
2229  aSmartTagCaption = aSmartTagType;
2230 
2231  const OUString aLBEntry = aSmartTagCaption + " (" + aName + ")";
2232 
2233  m_xSmartTagTypesLB->append();
2234  const int nRow = m_xSmartTagTypesLB->n_children() - 1;
2235  const bool bCheck = rSmartTagMgr.IsSmartTagTypeEnabled( aSmartTagType );
2236  m_xSmartTagTypesLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE);
2237  m_xSmartTagTypesLB->set_text(nRow, aLBEntry, 0);
2238  m_xSmartTagTypesLB->set_id(nRow, OUString::number(reinterpret_cast<sal_Int64>(new ImplSmartTagLBUserData(aSmartTagType, xRec, j))));
2239  }
2240  }
2241 }
2242 
2246 {
2247  const int nPos = m_xSmartTagTypesLB->get_selected_index();
2248  const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64());
2249  uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2250  const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2251 
2252  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2253  if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
2254  xRec->displayPropertyPage( nSmartTagIdx, aLocale );
2255 }
2256 
2260 {
2261  const bool bEnable = m_xMainCB->get_active();
2262  m_xSmartTagTypesLB->set_sensitive(bEnable);
2263  m_xPropertiesPB->set_sensitive(false);
2264 
2265  // if the controls are currently enabled, we still have to check
2266  // if the properties button should be disabled because the currently
2267  // selected smart tag type does not have a properties dialog.
2268  // We do this by calling SelectHdl:
2269  if (bEnable)
2270  SelectHdl(*m_xSmartTagTypesLB);
2271 }
2272 
2276 {
2277  const int nPos = m_xSmartTagTypesLB->get_selected_index();
2278  if (nPos == -1)
2279  return;
2280  const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(nPos).toInt64());
2281  uno::Reference< smarttags::XSmartTagRecognizer > xRec = pUserData->mxRec;
2282  const sal_Int32 nSmartTagIdx = pUserData->mnSmartTagIdx;
2283 
2284  const lang::Locale aLocale( LanguageTag::convertToLocale( eLastDialogLanguage ) );
2285  if ( xRec->hasPropertyPage( nSmartTagIdx, aLocale ) )
2286  m_xPropertiesPB->set_sensitive(true);
2287  else
2288  m_xPropertiesPB->set_sensitive(false);
2289 }
2290 
2294 {
2296  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2297  SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2298 
2299  // robust!
2300  if ( !pSmartTagMgr )
2301  return false;
2302 
2303  bool bModifiedSmartTagTypes = false;
2304  std::vector< OUString > aDisabledSmartTagTypes;
2305 
2306  const int nCount = m_xSmartTagTypesLB->n_children();
2307 
2308  for (int i = 0; i < nCount; ++i)
2309  {
2310  const ImplSmartTagLBUserData* pUserData = reinterpret_cast<ImplSmartTagLBUserData*>(m_xSmartTagTypesLB->get_id(i).toInt64());
2311  const bool bChecked = m_xSmartTagTypesLB->get_toggle(i) == TRISTATE_TRUE;
2312  const bool bIsCurrentlyEnabled = pSmartTagMgr->IsSmartTagTypeEnabled( pUserData->maSmartTagType );
2313 
2314  bModifiedSmartTagTypes = bModifiedSmartTagTypes || ( !bChecked != !bIsCurrentlyEnabled );
2315 
2316  if ( !bChecked )
2317  aDisabledSmartTagTypes.push_back( pUserData->maSmartTagType );
2318 
2319  delete pUserData;
2320  }
2321 
2322  const bool bModifiedRecognize = ( !m_xMainCB->get_active() != !pSmartTagMgr->IsLabelTextWithSmartTags() );
2323  if ( bModifiedSmartTagTypes || bModifiedRecognize )
2324  {
2325  bool bLabelTextWithSmartTags = m_xMainCB->get_active();
2326  pSmartTagMgr->WriteConfiguration( bModifiedRecognize ? &bLabelTextWithSmartTags : nullptr,
2327  bModifiedSmartTagTypes ? &aDisabledSmartTagTypes : nullptr );
2328  }
2329 
2330  return true;
2331 }
2332 
2336 {
2338  SvxSwAutoFormatFlags *pOpt = &pAutoCorrect->GetSwFlags();
2339  const SmartTagMgr* pSmartTagMgr = pOpt->pSmartTagMgr;
2340 
2341  // robust, should not happen!
2342  if ( !pSmartTagMgr )
2343  return;
2344 
2345  FillListBox(*pSmartTagMgr);
2346  m_xSmartTagTypesLB->select(0);
2347  m_xMainCB->set_active(pSmartTagMgr->IsLabelTextWithSmartTags());
2348  CheckHdl(*m_xMainCB);
2349 }
2350 
2352 {
2353  static_cast<OfaAutoCorrDlg*>(GetDialogController())->EnableLanguage( false );
2354 }
2355 
2356 /* 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:1775
sal_Unicode GetEndDoubleQuote() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:1432
#define LANGUAGE_NONE
std::unique_ptr< weld::TreeView > m_xDoubleCapsLB
Definition: autocdlg.hxx:239
OUString sReplaceTemplates
Definition: autocdlg.hxx:99
static vcl::Font GetDefaultFont(DefaultFontType nType, LanguageType eLang, GetDefaultFontFlags nFlags, const OutputDevice *pOutDev=nullptr)
bool NewDelHdl(const weld::Widget *)
Definition: autocdlg.cxx:1017
FieldUnit
sal_Int32 nIndex
std::unique_ptr< weld::CheckButton > m_xCBAppendSpace
Append space.
Definition: autocdlg.hxx:331
std::unique_ptr< weld::CheckButton > m_xAutoCapsCB
Definition: autocdlg.hxx:242
bool bAFormatByInpDelSpacesBetweenLines
static SvxAutoCorrCfg & Get()
virtual ~OfaSwAutoFmtOptionsPage() override
Definition: autocdlg.cxx:397
std::unique_ptr< weld::Button > m_xDeleteReplacePB
Definition: autocdlg.hxx:184
bool IsAutoCorrFlag(ACFlags nFlag) const
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
LanguageType eLang
Definition: autocdlg.hxx:170
sal_uInt32 sal_UCS4
virtual bool FillItemSet(SfxItemSet *rSet) override
Propagates the current settings to the smart tag manager.
Definition: autocdlg.cxx:2293
#define LANGUAGE_ENGLISH_US
std::unique_ptr< weld::CheckButton > m_xMainCB
Definition: autocdlg.hxx:371
std::unique_ptr< weld::Entry > m_xShortED
Definition: autocdlg.hxx:179
std::unique_ptr< weld::CheckButton > m_xSingleTypoCB
Definition: autocdlg.hxx:284
void ClearListBox()
Clears the m_aSmartTagTypesLB.
Definition: autocdlg.cxx:2193
void NewEntry(const OUString &sShort, const OUString &sLong, bool bKeepSourceFormatting)
Definition: autocdlg.cxx:941
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:1236
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:339
sal_uInt16 nAutoCmpltExpandKey
std::unique_ptr< weld::Button > m_xNewAbbrevPB
Definition: autocdlg.hxx:234
const SvStringsISortDtor * GetCplSttExceptList(LanguageType eLang)
static const AllSettings & GetSettings()
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:2011
virtual ~OfaAutoCompleteTabPage() override
Definition: autocdlg.cxx:1948
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:292
std::unique_ptr< weld::ComboBox > m_xDCBExpandKey
Definition: autocdlg.hxx:337
virtual ~OfaAutocorrReplacePage() override
Definition: autocdlg.cxx:715
void RemoveTabPage(const OString &rName)
std::vector< SvxAutocorrWord > AutocorrWordSetType
std::vector< OUString > aAbbrevStrings
Definition: autocdlg.hxx:218
static SfxModule * GetActiveModule(SfxViewFrame *pFrame=nullptr)
sal_uInt16 GetCode() const
OUString sCapitalStartSentence
Definition: autocdlg.hxx:87
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:724
const vcl::Font & GetCharFont() const
Definition: cuicharmap.hxx:161
static SfxObjectShell * Current()
std::unique_ptr< CollatorWrapper > pCompareClass
Definition: autocdlg.hxx:168
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:2351
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:1230
#define SGL_START
Definition: autocdlg.cxx:1772
static bool lcl_FindInArray(std::vector< OUString > &rStrings, std::u16string_view rString)
Definition: autocdlg.cxx:1174
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:183
std::unique_ptr< weld::CheckButton > m_xDoubleTypoCB
Definition: autocdlg.hxx:290
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:289
static bool lcl_FindEntry(weld::TreeView &rLB, const OUString &rEntry, CollatorWrapper const &rCmpClass)
Definition: autocdlg.cxx:141
OUString CuiResId(std::string_view aKey)
Definition: cuiresmgr.cxx:23
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:340
OUString sShort
Definition: autocdlg.hxx:135
std::unique_ptr< weld::Label > m_xDblEndExFT
Definition: autocdlg.hxx:294
void SaveWrdSttExceptList(LanguageType eLang)
static void CreateEntry(weld::TreeView &rLstBox, const OUString &rTxt, sal_uInt16 nCol, sal_uInt16 nTextCol)
Definition: autocdlg.cxx:1536
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:180
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:211
void SetEndDoubleQuote(const sal_Unicode cEnd)
void SetLanguage(LanguageType eSet)
Definition: autocdlg.cxx:892
int nCount
virtual int n_children() const =0
sal_uInt16 m_nAutoCmpltListCnt
Definition: autocdlg.hxx:328
static SfxViewShell * Current()
SvxSwAutoFormatFlags & GetSwFlags()
std::unique_ptr< weld::Label > m_xSglEndExFT
Definition: autocdlg.hxx:288
bool NewDelHdl(const weld::Widget *)
Definition: autocdlg.cxx:1452
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:298
std::unique_ptr< weld::Button > m_xNewReplacePB
Definition: autocdlg.hxx:182
const AutocorrWordSetType & getSortedContent() const
void SetModified()
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:2062
const editeng::SortedAutoCompleteStrings * m_pAutoCompleteList
OUString sTransliterateRTL
Definition: autocdlg.hxx:275
const LanguageTag & GetLanguageTag() const
float y
virtual ~OfaSmartTagOptionsTabPage() override
Definition: autocdlg.cxx:2162
OUString sAngleQuotes
Definition: autocdlg.hxx:276
StringChangeTable aChangesTable
Definition: autocdlg.hxx:160
sal_Unicode GetQuote(sal_Unicode cInsChar, bool bSttQuote, LanguageType eLang) const
sal_uInt16 nAutoCmpltWordLen
OfaAutocorrReplacePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:662
std::unique_ptr< weld::Entry > m_xAbbrevED
Definition: autocdlg.hxx:232
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:886
#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:1547
DoubleStringArray aNewEntries
Definition: autocdlg.hxx:150
std::unique_ptr< weld::CheckButton > m_xCBActiv
Enable word completion.
Definition: autocdlg.hxx:330
std::unique_ptr< weld::Button > m_xPropertiesPB
Definition: autocdlg.hxx:373
OUString sOrdinal
Definition: autocdlg.hxx:274
IMPL_LINK(OfaSwAutoFmtOptionsPage, SelectHdl, weld::TreeView &, rBox, void)
Definition: autocdlg.cxx:613
virtual ~OfaQuoteTabPage() override
Definition: autocdlg.cxx:1605
sal_uInt16 nAutoCmpltListLen
std::vector< OUString > aDoubleCapsStrings
Definition: autocdlg.hxx:219
virtual int get_selected_index() const =0
#define LANGUAGE_SYSTEM
SmartTagMgr * pSmartTagMgr
std::unique_ptr< weld::Button > m_xDelDoublePB
Definition: autocdlg.hxx:241
void WriteConfiguration(const bool *bLabelTextWithSmartTags, const std::vector< OUString > *pDisabledTypes) const
editeng::SortedAutoCompleteStrings * m_pAutoCompleteList
Definition: autocdlg.hxx:327
OfaAutoCorrDlg(weld::Window *pParent, const SfxItemSet *pSet)
Definition: autocdlg.cxx:56
virtual void set_toggle(int row, TriState eState, int col=-1)=0
OUString m_sStandard
Definition: autocdlg.hxx:296
OUString m_sBoldUnderline
Definition: autocdlg.hxx:57
SvxAutoCorrect * GetAutoCorrect()
LanguageType eLang
Definition: autocdlg.hxx:230
void DeleteEntry(const OUString &sShort, const OUString &sLong)
Definition: autocdlg.cxx:969
TRISTATE_FALSE
sal_Unicode GetStartDoubleQuote() const
std::unique_ptr< weld::Button > m_xSglStartQuotePB
Definition: autocdlg.hxx:285
sal_UCS4 cEndQuote
Definition: autocdlg.hxx:282
virtual void ActivatePage(const SfxItemSet &) override
Definition: autocdlg.cxx:1697
SvxAutocorrWordList * LoadAutocorrWordList(LanguageType eLang)
std::unique_ptr< weld::TreeView > m_xSwCheckLB
Just for writer.
Definition: autocdlg.hxx:300
std::vector< int > m_aReplaceFixedWidths
Definition: autocdlg.hxx:177
void * pUserData
CheckBox -> form. Text Bool -> selection text.
Definition: autocdlg.hxx:137
#define CBCOL_FIRST
Definition: autocdlg.cxx: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:2144
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:1186
sal_UCS4 cSglEndQuote
Definition: autocdlg.hxx:279
vcl::Font aByInputBulletFont
std::unique_ptr< weld::Label > m_xSglStartExFT
Definition: autocdlg.hxx:286
void SetAutoCorrFlag(ACFlags nFlag, bool bOn=true)
void SaveCplSttExceptList(LanguageType eLang)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: autocdlg.cxx:736
KeyFuncType GetFunction() const
virtual void Reset(const SfxItemSet *rSet) override
Sets the controls based on the current settings at SmartTagMgr.
Definition: autocdlg.cxx:2335
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:1952
OUString sNonBrkSpace
Definition: autocdlg.hxx:273
void CopyToClipboard() const
Definition: autocdlg.cxx:2096
std::unique_ptr< weld::Button > m_xDelAbbrevPB
Definition: autocdlg.hxx:235
std::unique_ptr< weld::Button > m_xEditPB
Definition: autocdlg.hxx:112
css::uno::Reference< css::smarttags::XSmartTagRecognizer > const & GetRecognizer(sal_uInt32 i) const
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:531
constexpr sal_uInt16 KEY_RETURN
std::unique_ptr< weld::CheckButton > m_xCBAsTip
Show as tip.
Definition: autocdlg.hxx:332
constexpr T & temporary(T &&x)
virtual short run() override
Definition: cuicharmap.cxx:184
constexpr sal_uInt16 KEY_RIGHT
std::unique_ptr< weld::Button > m_xDblStartQuotePB
Definition: autocdlg.hxx:291
std::unique_ptr< weld::CheckButton > m_xCBCollect
Collect words.
Definition: autocdlg.hxx:334
void SetEndSingleQuote(const sal_Unicode cEnd)
OUString sLong
Definition: autocdlg.hxx:136
#define SGL_END
Definition: autocdlg.cxx:1774
virtual ~OfaAutoCorrDlg() override
Definition: autocdlg.cxx:132
std::unique_ptr< weld::TreeView > m_xAbbrevLB
Definition: autocdlg.hxx:233
void RefillReplaceBoxes(bool bFromReset, LanguageType eOldLanguage, LanguageType eNewLanguage)
Box filled with new language.
Definition: autocdlg.cxx:1369
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:2166
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:155
void SetStartDoubleQuote(const sal_Unicode cStart)
std::vector< DoubleString > DoubleStringArray
Definition: autocdlg.hxx:146
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: autocdlg.cxx:1609
virtual void select(int pos)=0
SvStringsISortDtor * LoadWrdSttExceptList(LanguageType eLang)
#define DBL_START
Definition: autocdlg.cxx:1773
std::unique_ptr< CharClass > pCharClass
Definition: autocdlg.hxx:169
virtual ~OfaAutocorrOptionsPage() override
Definition: autocdlg.cxx:197
void FillListBox(const SmartTagMgr &rSmartTagMgr)
Inserts items into m_aSmartTagTypesLB.
Definition: autocdlg.cxx:2207
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:1224
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:338
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:1248
DoubleStringArray aDeletedEntries
Definition: autocdlg.hxx:151
SvStringsISortDtor * LoadCplSttExceptList(LanguageType eLang)
virtual void Reset(const SfxItemSet *rSet) override
Definition: autocdlg.cxx:1702
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:1615
bool IsSmartTagTypeEnabled(const OUString &rSmartTagType) const
std::unique_ptr< CollatorWrapper > pCompareClass
Definition: autocdlg.hxx:229
SvxLanguageListFlags
Reference< XComponentContext > getProcessComponentContext()
SfxOkDialogController * GetDialogController() const
void SetCharFont(const vcl::Font &rFont)
Definition: cuicharmap.cxx:598
std::unique_ptr< weld::TreeView > m_xSmartTagTypesLB
Definition: autocdlg.hxx:372
void SetLanguage(LanguageType eSet)
Definition: autocdlg.cxx:1355
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:240
std::unique_ptr< weld::TreeView > m_xReplaceTLB
Definition: autocdlg.hxx:181
std::unique_ptr< weld::Button > m_xDblEndQuotePB
Definition: autocdlg.hxx:293
DeactivateRC
void append(TreeIter *pRet=nullptr)
OfaAutoCompleteTabPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: autocdlg.cxx:1894
OUString sId
StringsTable aStringsTable
Definition: autocdlg.hxx:228
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: autocdlg.cxx:1243
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:76
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:287
vcl::Font aByInputBulletFont
Definition: autocdlg.hxx:108
sal_UCS4 cSglStartQuote
Definition: autocdlg.hxx:278
virtual bool HasSelection(bool bText=true) const
std::unique_ptr< weld::Button > m_xDblStandardPB
Definition: autocdlg.hxx:295
sal_uInt32 NumberOfRecognizers() const
ACFlags GetFlags() const
OfaAutoFmtOptions
Definition: autocdlg.cxx:325
Smart tag options tab page.
Definition: autocdlg.hxx:366
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
std::unique_ptr< weld::Entry > m_xDoubleCapsED
Definition: autocdlg.hxx:238
std::map< LanguageType, DoubleStringArray > aDoubleStringTable
Definition: autocdlg.hxx:167
sal_UCS4 cStartQuote
Definition: autocdlg.hxx:281
OfaQuoteOptions
Definition: autocdlg.cxx:1526
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
std::set< OUString > aFormatText
Definition: autocdlg.hxx:165
OUString sDelSpaceBetweenLines
Definition: autocdlg.hxx:101
static SfxModule * GetModule(SfxToolsModule nSharedLib)
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: autocdlg.cxx:1958
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:335
std::unique_ptr< weld::CheckButton > m_xAutoAbbrevCB
Definition: autocdlg.hxx:236
std::unique_ptr< weld::Button > m_xPBEntries
Definition: autocdlg.hxx:341
constexpr sal_uInt16 KEY_TAB
std::unique_ptr< weld::Container > m_xButtonBox
Definition: autocdlg.hxx:185
std::unique_ptr< weld::TreeView > m_xCheckLB
Definition: autocdlg.hxx:111
void SetCurPageId(const OString &rName)
OUString ChangeStringExt_Impl(sal_UCS4)
Definition: autocdlg.cxx:1869
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
std::unique_ptr< weld::CheckButton > m_xTextOnlyCB
Definition: autocdlg.hxx:178