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