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