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