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