android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / config / optpage.cxx
blob329462ac8f739bfbeb0adef50ea4672f0c8110a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <utility>
24 #include <optpage.hxx>
25 #include <doc.hxx>
26 #include <hintids.hxx>
27 #include <cmdid.h>
28 #include <fmtcol.hxx>
29 #include <charatr.hxx>
30 #include <swtypes.hxx>
31 #include <view.hxx>
32 #include <docsh.hxx>
33 #include <IDocumentDeviceAccess.hxx>
34 #include <IDocumentSettingAccess.hxx>
36 #include <swmodule.hxx>
37 #include <wrtsh.hxx>
38 #include <cfgitems.hxx>
39 #include <poolfmt.hxx>
40 #include <uiitems.hxx>
41 #include <printdata.hxx>
42 #include <modcfg.hxx>
43 #include <crstate.hxx>
44 #include <viewopt.hxx>
45 #include <globals.hrc>
46 #include <strings.hrc>
47 #include <swwrtshitem.hxx>
49 #include <editeng/fhgtitem.hxx>
50 #include <editeng/fontitem.hxx>
51 #include <editeng/langitem.hxx>
52 #include <editeng/svxenum.hxx>
53 #include <officecfg/Office/Common.hxx>
54 #include <sal/macros.h>
55 #include <sfx2/dialoghelper.hxx>
56 #include <sfx2/printer.hxx>
57 #include <sfx2/bindings.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <svl/ctloptions.hxx>
60 #include <svl/eitem.hxx>
61 #include <svl/cjkoptions.hxx>
62 #include <svtools/ctrltool.hxx>
63 #include <svtools/unitconv.hxx>
64 #include <sfx2/htmlmode.hxx>
66 #include <vcl/settings.hxx>
67 #include <vcl/svapp.hxx>
69 #include <optload.hxx>
71 using namespace ::com::sun::star;
73 namespace {
75 void drawRect(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect, const Color &rFillColor, const Color &rLineColor)
77 rRenderContext.SetFillColor(rFillColor);
78 rRenderContext.SetLineColor(rLineColor);
79 rRenderContext.DrawRect(rRect);
84 // Tools->Options->Writer->View
85 // Tools->Options->Writer/Web->View
86 SwContentOptPage::SwContentOptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet)
87 : SfxTabPage(pPage, pController, "modules/swriter/ui/viewoptionspage.ui", "ViewOptionsPage", &rCoreSet)
88 , m_xCrossCB(m_xBuilder->weld_check_button("helplines"))
89 , m_xHMetric(m_xBuilder->weld_combo_box("hrulercombobox"))
90 , m_xVRulerCBox(m_xBuilder->weld_check_button("vruler"))
91 , m_xVRulerRightCBox(m_xBuilder->weld_check_button("vrulerright"))
92 , m_xVMetric(m_xBuilder->weld_combo_box("vrulercombobox"))
93 , m_xSmoothCBox(m_xBuilder->weld_check_button("smoothscroll"))
94 , m_xGrfCB(m_xBuilder->weld_check_button("graphics"))
95 , m_xTableCB(m_xBuilder->weld_check_button("tables"))
96 , m_xDrwCB(m_xBuilder->weld_check_button("drawings"))
97 , m_xPostItCB(m_xBuilder->weld_check_button("comments"))
98 , m_xSettingsFrame(m_xBuilder->weld_frame("settingsframe"))
99 , m_xSettingsLabel(m_xBuilder->weld_label("settingslabel"))
100 , m_xMetricLabel(m_xBuilder->weld_label("measureunitlabel"))
101 , m_xMetricLB(m_xBuilder->weld_combo_box("measureunit"))
102 , m_xShowInlineTooltips(m_xBuilder->weld_check_button("changestooltip"))
103 , m_xShowOutlineContentVisibilityButton(m_xBuilder->weld_check_button("outlinecontentvisibilitybutton"))
104 , m_xTreatSubOutlineLevelsAsContent(m_xBuilder->weld_check_button("suboutlinelevelsascontent"))
105 , m_xShowChangesInMargin(m_xBuilder->weld_check_button("changesinmargin"))
106 , m_xFieldHiddenCB(m_xBuilder->weld_check_button("hiddentextfield"))
107 , m_xFieldHiddenParaCB(m_xBuilder->weld_check_button("hiddenparafield"))
109 m_xShowOutlineContentVisibilityButton->connect_toggled(LINK(this, SwContentOptPage, ShowOutlineContentVisibilityButtonHdl));
111 /* This part is visible only with Writer/Web->View dialogue. */
112 const SfxUInt16Item* pItem = rCoreSet.GetItemIfSet(SID_HTML_MODE, false );
113 if (!pItem || !(pItem->GetValue() & HTMLMODE_ON))
115 m_xSettingsFrame->hide();
116 m_xSettingsLabel->hide();
117 m_xMetricLabel->hide();
118 m_xMetricLB->hide();
121 if(!SvtCJKOptions::IsVerticalTextEnabled() )
122 m_xVRulerRightCBox->hide();
123 m_xVRulerCBox->connect_toggled(LINK(this, SwContentOptPage, VertRulerHdl ));
125 for (size_t i = 0; i < SwFieldUnitTable::Count(); ++i)
127 const OUString sMetric = SwFieldUnitTable::GetString(i);
128 FieldUnit eFUnit = SwFieldUnitTable::GetValue(i);
130 switch ( eFUnit )
132 case FieldUnit::MM:
133 case FieldUnit::CM:
134 case FieldUnit::POINT:
135 case FieldUnit::PICA:
136 case FieldUnit::INCH:
137 case FieldUnit::CHAR: // add two units , 'character' and 'line' , their ticks are not fixed
138 case FieldUnit::LINE:
140 // only use these metrics
141 // a horizontal ruler has not the 'line' unit
142 // there isn't 'line' unit in HTML format
143 if (eFUnit != FieldUnit::LINE)
145 m_xMetricLB->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric);
146 m_xHMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric);
148 // a vertical ruler has not the 'character' unit
149 if (eFUnit != FieldUnit::CHAR)
151 m_xVMetric->append(OUString::number(static_cast<sal_uInt32>(eFUnit)), sMetric);
153 break;
155 default:;//prevent warning
160 SwContentOptPage::~SwContentOptPage()
164 std::unique_ptr<SfxTabPage> SwContentOptPage::Create( weld::Container* pPage, weld::DialogController* pController,
165 const SfxItemSet* rAttrSet)
167 return std::make_unique<SwContentOptPage>(pPage, pController, *rAttrSet);
170 static void lcl_SelectMetricLB(weld::ComboBox& rMetric, TypedWhichId<SfxUInt16Item> nSID, const SfxItemSet& rSet)
172 const SfxPoolItem* pItem;
173 if( rSet.GetItemState( nSID, false, &pItem ) >= SfxItemState::DEFAULT )
175 FieldUnit eFieldUnit = static_cast<FieldUnit>(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
176 for (sal_Int32 i = 0, nEntryCount = rMetric.get_count(); i < nEntryCount; ++i)
178 if (rMetric.get_id(i).toUInt32() == static_cast<sal_uInt32>(eFieldUnit))
180 rMetric.set_active(i);
181 break;
185 rMetric.save_value();
188 void SwContentOptPage::Reset(const SfxItemSet* rSet)
190 const SwElemItem* pElemAttr = rSet->GetItemIfSet( FN_PARAM_ELEM , false );
191 if(pElemAttr)
193 m_xTableCB->set_active(pElemAttr->m_bTable);
194 m_xGrfCB->set_active(pElemAttr->m_bGraphic);
195 m_xDrwCB->set_active(pElemAttr->m_bDrawing);
196 m_xPostItCB->set_active(pElemAttr->m_bNotes);
197 m_xCrossCB->set_active(pElemAttr->m_bCrosshair);
198 m_xVRulerCBox->set_active(pElemAttr->m_bVertRuler);
199 m_xVRulerRightCBox->set_active(pElemAttr->m_bVertRulerRight);
200 m_xSmoothCBox->set_active(pElemAttr->m_bSmoothScroll);
201 m_xShowInlineTooltips->set_active(pElemAttr->m_bShowInlineTooltips);
202 m_xShowOutlineContentVisibilityButton->set_active(pElemAttr->m_bShowOutlineContentVisibilityButton);
203 m_xTreatSubOutlineLevelsAsContent->set_active(pElemAttr->m_bTreatSubOutlineLevelsAsContent);
204 m_xTreatSubOutlineLevelsAsContent->set_sensitive(pElemAttr->m_bShowOutlineContentVisibilityButton);
205 m_xShowChangesInMargin->set_active(pElemAttr->m_bShowChangesInMargin);
206 m_xFieldHiddenCB->set_active( pElemAttr->m_bFieldHiddenText );
207 m_xFieldHiddenParaCB->set_active( pElemAttr->m_bShowHiddenPara );
209 m_xMetricLB->set_active(-1);
210 lcl_SelectMetricLB(*m_xMetricLB, SID_ATTR_METRIC, *rSet);
211 lcl_SelectMetricLB(*m_xHMetric, FN_HSCROLL_METRIC, *rSet);
212 lcl_SelectMetricLB(*m_xVMetric, FN_VSCROLL_METRIC, *rSet);
215 bool SwContentOptPage::FillItemSet(SfxItemSet* rSet)
217 const SwElemItem* pOldAttr = GetOldItem(GetItemSet(), FN_PARAM_ELEM);
219 SwElemItem aElem;
220 aElem.m_bTable = m_xTableCB->get_active();
221 aElem.m_bGraphic = m_xGrfCB->get_active();
222 aElem.m_bDrawing = m_xDrwCB->get_active();
223 aElem.m_bNotes = m_xPostItCB->get_active();
224 aElem.m_bCrosshair = m_xCrossCB->get_active();
225 aElem.m_bVertRuler = m_xVRulerCBox->get_active();
226 aElem.m_bVertRulerRight = m_xVRulerRightCBox->get_active();
227 aElem.m_bSmoothScroll = m_xSmoothCBox->get_active();
228 aElem.m_bShowInlineTooltips = m_xShowInlineTooltips->get_active();
229 aElem.m_bShowOutlineContentVisibilityButton = m_xShowOutlineContentVisibilityButton->get_active();
230 aElem.m_bTreatSubOutlineLevelsAsContent = m_xTreatSubOutlineLevelsAsContent->get_active();
231 aElem.m_bShowChangesInMargin = m_xShowChangesInMargin->get_active();
232 aElem.m_bFieldHiddenText = m_xFieldHiddenCB->get_active();
233 aElem.m_bShowHiddenPara = m_xFieldHiddenParaCB->get_active();
235 bool bRet = !pOldAttr || aElem != *pOldAttr;
236 if(bRet)
237 bRet = nullptr != rSet->Put(aElem);
239 sal_Int32 nMPos = m_xMetricLB->get_active();
240 sal_Int32 nGlobalMetricPos = nMPos;
241 if ( m_xMetricLB->get_value_changed_from_saved() )
243 const sal_uInt16 nFieldUnit = m_xMetricLB->get_id(nMPos).toUInt32();
244 rSet->Put( SfxUInt16Item( SID_ATTR_METRIC, nFieldUnit ) );
245 bRet = true;
248 nMPos = m_xHMetric->get_active();
249 if ( m_xHMetric->get_value_changed_from_saved() || nMPos != nGlobalMetricPos )
251 const sal_uInt16 nFieldUnit = m_xHMetric->get_id(nMPos).toUInt32();
252 rSet->Put( SfxUInt16Item( FN_HSCROLL_METRIC, nFieldUnit ) );
253 bRet = true;
255 nMPos = m_xVMetric->get_active();
256 if ( m_xVMetric->get_value_changed_from_saved() || nMPos != nGlobalMetricPos )
258 const sal_uInt16 nFieldUnit = m_xVMetric->get_id(nMPos).toUInt32();
259 rSet->Put( SfxUInt16Item( FN_VSCROLL_METRIC, nFieldUnit ) );
260 bRet = true;
263 return bRet;
266 IMPL_LINK(SwContentOptPage, VertRulerHdl, weld::Toggleable&, rBox, void)
268 m_xVRulerRightCBox->set_sensitive(rBox.get_sensitive() && rBox.get_active());
271 IMPL_LINK(SwContentOptPage, ShowOutlineContentVisibilityButtonHdl, weld::Toggleable&, rBox, void)
273 m_xTreatSubOutlineLevelsAsContent->set_sensitive(rBox.get_active());
276 // TabPage Printer additional settings
277 SwAddPrinterTabPage::SwAddPrinterTabPage(weld::Container* pPage, weld::DialogController* pController,
278 const SfxItemSet& rCoreSet)
279 : SfxTabPage(pPage, pController, "modules/swriter/ui/printoptionspage.ui", "PrintOptionsPage", &rCoreSet)
280 , m_sNone(SwResId(SW_STR_NONE))
281 , m_bAttrModified(false)
282 , m_bPreview(false)
283 , m_xGrfCB(m_xBuilder->weld_check_button("graphics"))
284 , m_xCtrlFieldCB(m_xBuilder->weld_check_button("formcontrols"))
285 , m_xBackgroundCB(m_xBuilder->weld_check_button("background"))
286 , m_xBlackFontCB(m_xBuilder->weld_check_button("inblack"))
287 , m_xPrintHiddenTextCB(m_xBuilder->weld_check_button("hiddentext"))
288 , m_xPrintTextPlaceholderCB(m_xBuilder->weld_check_button("textplaceholder"))
289 , m_xPagesFrame(m_xBuilder->weld_widget("pagesframe"))
290 , m_xLeftPageCB(m_xBuilder->weld_check_button("leftpages"))
291 , m_xRightPageCB(m_xBuilder->weld_check_button("rightpages"))
292 , m_xProspectCB(m_xBuilder->weld_check_button("brochure"))
293 , m_xProspectCB_RTL(m_xBuilder->weld_check_button("rtl"))
294 , m_xCommentsFrame(m_xBuilder->weld_widget("commentsframe"))
295 , m_xNoRB(m_xBuilder->weld_radio_button("none"))
296 , m_xOnlyRB(m_xBuilder->weld_radio_button("only"))
297 , m_xEndRB(m_xBuilder->weld_radio_button("end"))
298 , m_xEndPageRB(m_xBuilder->weld_radio_button("endpage"))
299 , m_xInMarginsRB(m_xBuilder->weld_radio_button("inmargins"))
300 , m_xPrintEmptyPagesCB(m_xBuilder->weld_check_button("blankpages"))
301 , m_xPaperFromSetupCB(m_xBuilder->weld_check_button("papertray"))
302 , m_xFaxLB(m_xBuilder->weld_combo_box("fax"))
304 Link<weld::Toggleable&,void> aLk = LINK( this, SwAddPrinterTabPage, AutoClickHdl);
305 m_xGrfCB->connect_toggled( aLk );
306 m_xRightPageCB->connect_toggled( aLk );
307 m_xLeftPageCB->connect_toggled( aLk );
308 m_xCtrlFieldCB->connect_toggled( aLk );
309 m_xBackgroundCB->connect_toggled( aLk );
310 m_xBlackFontCB->connect_toggled( aLk );
311 m_xPrintHiddenTextCB->connect_toggled( aLk );
312 m_xPrintTextPlaceholderCB->connect_toggled( aLk );
313 m_xProspectCB->connect_toggled( aLk );
314 m_xProspectCB_RTL->connect_toggled( aLk );
315 m_xPaperFromSetupCB->connect_toggled( aLk );
316 m_xPrintEmptyPagesCB->connect_toggled( aLk );
317 m_xEndPageRB->connect_toggled( aLk );
318 m_xInMarginsRB->connect_toggled( aLk );
319 m_xEndRB->connect_toggled( aLk );
320 m_xOnlyRB->connect_toggled( aLk );
321 m_xNoRB->connect_toggled( aLk );
322 m_xFaxLB->connect_changed( LINK( this, SwAddPrinterTabPage, SelectHdl ) );
324 const SfxUInt16Item* pItem = rCoreSet.GetItemIfSet(SID_HTML_MODE, false );
325 if(pItem && pItem->GetValue() & HTMLMODE_ON)
327 m_xLeftPageCB->hide();
328 m_xRightPageCB->hide();
329 m_xPrintHiddenTextCB->hide();
330 m_xPrintTextPlaceholderCB->hide();
331 m_xPrintEmptyPagesCB->hide();
333 m_xProspectCB_RTL->set_sensitive(false);
334 SvtCTLOptions aCTLOptions;
335 m_xProspectCB_RTL->set_visible(SvtCTLOptions::IsCTLFontEnabled());
338 SwAddPrinterTabPage::~SwAddPrinterTabPage()
342 void SwAddPrinterTabPage::SetPreview(bool bPrev)
344 m_bPreview = bPrev;
345 m_xCommentsFrame->set_sensitive(!m_bPreview);
346 m_xPagesFrame->set_sensitive(!m_bPreview);
349 std::unique_ptr<SfxTabPage> SwAddPrinterTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
350 const SfxItemSet* rAttrSet )
352 return std::make_unique<SwAddPrinterTabPage>(pPage, pController, *rAttrSet);
355 bool SwAddPrinterTabPage::FillItemSet( SfxItemSet* rCoreSet )
357 if ( m_bAttrModified )
359 SwAddPrinterItem aAddPrinterAttr;
360 aAddPrinterAttr.m_bPrintGraphic = m_xGrfCB->get_active();
361 aAddPrinterAttr.m_bPrintTable = true; // always enabled since CWS printerpullgpages /*m_xTabCB->get_active();*/
362 aAddPrinterAttr.m_bPrintDraw = m_xGrfCB->get_active(); // UI merged with m_xGrfCB in CWS printerpullgpages
363 aAddPrinterAttr.m_bPrintControl = m_xCtrlFieldCB->get_active();
364 aAddPrinterAttr.m_bPrintPageBackground = m_xBackgroundCB->get_active();
365 aAddPrinterAttr.m_bPrintBlackFont = m_xBlackFontCB->get_active();
366 aAddPrinterAttr.m_bPrintHiddenText = m_xPrintHiddenTextCB->get_active();
367 aAddPrinterAttr.m_bPrintTextPlaceholder = m_xPrintTextPlaceholderCB->get_active();
369 aAddPrinterAttr.m_bPrintLeftPages = m_xLeftPageCB->get_active();
370 aAddPrinterAttr.m_bPrintRightPages = m_xRightPageCB->get_active();
371 aAddPrinterAttr.m_bPrintReverse = false; // handled by vcl itself since CWS printerpullpages /*m_xReverseCB->get_active()*/;
372 aAddPrinterAttr.m_bPrintProspect = m_xProspectCB->get_active();
373 aAddPrinterAttr.m_bPrintProspectRTL = m_xProspectCB_RTL->get_active();
374 aAddPrinterAttr.m_bPaperFromSetup = m_xPaperFromSetupCB->get_active();
375 aAddPrinterAttr.m_bPrintEmptyPages = m_xPrintEmptyPagesCB->get_active();
376 aAddPrinterAttr.m_bPrintSingleJobs = true; // handled by vcl in new print dialog since CWS printerpullpages /*m_xSingleJobsCB->get_active()*/;
378 if (m_xNoRB->get_active()) aAddPrinterAttr.m_nPrintPostIts =
379 SwPostItMode::NONE;
380 if (m_xOnlyRB->get_active()) aAddPrinterAttr.m_nPrintPostIts =
381 SwPostItMode::Only;
382 if (m_xEndRB->get_active()) aAddPrinterAttr.m_nPrintPostIts =
383 SwPostItMode::EndDoc;
384 if (m_xEndPageRB->get_active()) aAddPrinterAttr.m_nPrintPostIts =
385 SwPostItMode::EndPage;
386 if (m_xInMarginsRB->get_active()) aAddPrinterAttr.m_nPrintPostIts =
387 SwPostItMode::InMargins;
389 const OUString sFax = m_xFaxLB->get_active_text();
390 aAddPrinterAttr.m_sFaxName = m_sNone == sFax ? OUString() : sFax;
391 rCoreSet->Put(aAddPrinterAttr);
393 return m_bAttrModified;
396 void SwAddPrinterTabPage::Reset( const SfxItemSet* )
398 const SfxItemSet& rSet = GetItemSet();
400 if( const SwAddPrinterItem* pAddPrinterAttr = rSet.GetItemIfSet( FN_PARAM_ADDPRINTER , false ) )
402 m_xGrfCB->set_active(pAddPrinterAttr->m_bPrintGraphic || pAddPrinterAttr->m_bPrintDraw);
403 m_xCtrlFieldCB->set_active( pAddPrinterAttr->m_bPrintControl);
404 m_xBackgroundCB->set_active( pAddPrinterAttr->m_bPrintPageBackground);
405 m_xBlackFontCB->set_active( pAddPrinterAttr->m_bPrintBlackFont);
406 m_xPrintHiddenTextCB->set_active( pAddPrinterAttr->m_bPrintHiddenText);
407 m_xPrintTextPlaceholderCB->set_active(pAddPrinterAttr->m_bPrintTextPlaceholder);
408 m_xLeftPageCB->set_active( pAddPrinterAttr->m_bPrintLeftPages);
409 m_xRightPageCB->set_active( pAddPrinterAttr->m_bPrintRightPages);
410 m_xPaperFromSetupCB->set_active(pAddPrinterAttr->m_bPaperFromSetup);
411 m_xPrintEmptyPagesCB->set_active(pAddPrinterAttr->m_bPrintEmptyPages);
412 m_xProspectCB->set_active( pAddPrinterAttr->m_bPrintProspect);
413 m_xProspectCB_RTL->set_active( pAddPrinterAttr->m_bPrintProspectRTL);
415 m_xNoRB->set_active(pAddPrinterAttr->m_nPrintPostIts== SwPostItMode::NONE ) ;
416 m_xOnlyRB->set_active(pAddPrinterAttr->m_nPrintPostIts== SwPostItMode::Only ) ;
417 m_xEndRB->set_active(pAddPrinterAttr->m_nPrintPostIts== SwPostItMode::EndDoc ) ;
418 m_xEndPageRB->set_active(pAddPrinterAttr->m_nPrintPostIts== SwPostItMode::EndPage ) ;
419 m_xInMarginsRB->set_active(pAddPrinterAttr->m_nPrintPostIts== SwPostItMode::InMargins ) ;
420 auto nFound = m_xFaxLB->find_text(pAddPrinterAttr->m_sFaxName);
421 if (nFound != -1)
422 m_xFaxLB->set_active(nFound);
423 else if (m_xFaxLB->get_count())
424 m_xFaxLB->set_active(0);
426 if (m_xProspectCB->get_active())
428 m_xProspectCB_RTL->set_sensitive(true);
429 m_xNoRB->set_sensitive( false );
430 m_xOnlyRB->set_sensitive( false );
431 m_xEndRB->set_sensitive( false );
432 m_xEndPageRB->set_sensitive( false );
434 else
435 m_xProspectCB_RTL->set_sensitive( false );
438 IMPL_LINK_NOARG(SwAddPrinterTabPage, AutoClickHdl, weld::Toggleable&, void)
440 m_bAttrModified = true;
441 bool bIsProspect = m_xProspectCB->get_active();
442 if (!bIsProspect)
443 m_xProspectCB_RTL->set_active( false );
444 m_xProspectCB_RTL->set_sensitive( bIsProspect );
445 m_xNoRB->set_sensitive( !bIsProspect );
446 m_xOnlyRB->set_sensitive( !bIsProspect );
447 m_xEndRB->set_sensitive( !bIsProspect );
448 m_xEndPageRB->set_sensitive( !bIsProspect );
449 m_xInMarginsRB->set_sensitive( !bIsProspect );
452 void SwAddPrinterTabPage::SetFax( const std::vector<OUString>& rFaxLst )
454 m_xFaxLB->append_text(m_sNone);
455 for(const auto & i : rFaxLst)
457 m_xFaxLB->append_text(i);
459 m_xFaxLB->set_active(0);
462 IMPL_LINK_NOARG(SwAddPrinterTabPage, SelectHdl, weld::ComboBox&, void)
464 m_bAttrModified=true;
467 void SwAddPrinterTabPage::PageCreated( const SfxAllItemSet& aSet)
469 const SfxBoolItem* pListItem = aSet.GetItem<SfxBoolItem>(SID_FAX_LIST, false);
470 const SfxBoolItem* pPreviewItem = aSet.GetItem<SfxBoolItem>(SID_PREVIEWFLAG_TYPE, false);
471 if (pPreviewItem)
473 SetPreview(pPreviewItem->GetValue());
474 Reset(&aSet);
476 if (pListItem && pListItem->GetValue())
478 std::vector<OUString> aFaxList;
479 const std::vector<OUString>& rPrinters = Printer::GetPrinterQueues();
480 for (const auto & rPrinter : rPrinters)
481 aFaxList.insert(aFaxList.begin(), rPrinter);
482 SetFax( aFaxList );
486 // Tabpage Standardfonts
487 SwStdFontTabPage::SwStdFontTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
488 : SfxTabPage(pPage, pController, "modules/swriter/ui/optfonttabpage.ui", "OptFontTabPage", &rSet)
489 , m_pPrt(nullptr)
490 , m_pFontConfig(nullptr)
491 , m_pWrtShell(nullptr)
492 , m_eLanguage( GetAppLanguage() )
493 , m_bListDefault(false)
494 , m_bSetListDefault(true)
495 , m_bLabelDefault(false)
496 , m_bSetLabelDefault(true)
497 , m_bIdxDefault(false)
498 , m_bSetIdxDefault(true)
499 , m_bDisposePrinter(false)
500 , m_nFontGroup(FONT_GROUP_DEFAULT)
501 , m_sScriptWestern(SwResId(ST_SCRIPT_WESTERN))
502 , m_sScriptAsian(SwResId(ST_SCRIPT_ASIAN))
503 , m_sScriptComplex(SwResId(ST_SCRIPT_CTL))
504 , m_xLabelFT(m_xBuilder->weld_label("label1"))
505 , m_xStandardBox(m_xBuilder->weld_combo_box("standardbox"))
506 , m_xStandardHeightLB(new FontSizeBox(m_xBuilder->weld_combo_box("standardheight")))
507 , m_xTitleBox(m_xBuilder->weld_combo_box("titlebox"))
508 , m_xTitleHeightLB(new FontSizeBox(m_xBuilder->weld_combo_box("titleheight")))
509 , m_xListBox(m_xBuilder->weld_combo_box("listbox"))
510 , m_xListHeightLB(new FontSizeBox(m_xBuilder->weld_combo_box("listheight")))
511 , m_xLabelBox(m_xBuilder->weld_combo_box("labelbox"))
512 , m_xLabelHeightLB(new FontSizeBox(m_xBuilder->weld_combo_box("labelheight")))
513 , m_xIdxBox(m_xBuilder->weld_combo_box("idxbox"))
514 , m_xIndexHeightLB(new FontSizeBox(m_xBuilder->weld_combo_box("indexheight")))
515 , m_xStandardPB(m_xBuilder->weld_button("standard"))
517 m_xStandardBox->make_sorted();
518 m_xTitleBox->make_sorted();
519 m_xListBox->make_sorted();
520 m_xLabelBox->make_sorted();
521 m_xIdxBox->make_sorted();
523 m_xStandardPB->connect_clicked(LINK(this, SwStdFontTabPage, StandardHdl));
524 m_xStandardBox->connect_changed( LINK(this, SwStdFontTabPage, ModifyHdl));
525 m_xListBox->connect_changed( LINK(this, SwStdFontTabPage, ModifyHdl));
526 m_xLabelBox->connect_changed( LINK(this, SwStdFontTabPage, ModifyHdl));
527 m_xIdxBox->connect_changed( LINK(this, SwStdFontTabPage, ModifyHdl));
528 Link<weld::Widget&,void> aFocusLink = LINK( this, SwStdFontTabPage, LoseFocusHdl);
529 m_xStandardBox->connect_focus_out( aFocusLink );
530 m_xTitleBox->connect_focus_out( aFocusLink );
531 m_xListBox->connect_focus_out( aFocusLink );
532 m_xLabelBox->connect_focus_out( aFocusLink );
533 m_xIdxBox->connect_focus_out( aFocusLink );
536 SwStdFontTabPage::~SwStdFontTabPage()
538 m_xIndexHeightLB.reset();
539 m_xLabelHeightLB.reset();
540 m_xListHeightLB.reset();
541 m_xTitleHeightLB.reset();
542 m_xStandardHeightLB.reset();
543 m_pFontList.reset();
544 if (m_bDisposePrinter)
545 m_pPrt.disposeAndClear();
546 else
547 m_pPrt.clear();
550 std::unique_ptr<SfxTabPage> SwStdFontTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
551 const SfxItemSet* rAttrSet )
553 return std::make_unique<SwStdFontTabPage>(pPage, pController, *rAttrSet);
556 static void lcl_SetColl(SwWrtShell* pWrtShell, sal_uInt16 nType,
557 SfxPrinter const * pPrt, const OUString& rStyle,
558 sal_uInt16 nFontWhich)
560 vcl::Font aFont( rStyle, Size( 0, 10 ) );
561 if( pPrt )
562 aFont = pPrt->GetFontMetric( aFont );
563 SwTextFormatColl *pColl = pWrtShell->GetTextCollFromPool(nType);
564 pColl->SetFormatAttr(SvxFontItem(aFont.GetFamilyType(), aFont.GetFamilyName(),
565 OUString(), aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
568 static void lcl_SetColl(SwWrtShell* pWrtShell, sal_uInt16 nType,
569 sal_Int32 nHeight, sal_uInt16 nFontHeightWhich)
571 float fSize = static_cast<float>(nHeight) / 10;
572 nHeight = CalcToUnit( fSize, MapUnit::MapTwip );
573 SwTextFormatColl *pColl = pWrtShell->GetTextCollFromPool(nType);
574 pColl->SetFormatAttr(SvxFontHeightItem(nHeight, 100, nFontHeightWhich));
577 bool SwStdFontTabPage::FillItemSet( SfxItemSet* )
579 SW_MOD()->GetModuleConfig()->SetDefaultFontInCurrDocOnly(false);
581 const OUString sStandard = m_xStandardBox->get_active_text();
582 const OUString sTitle = m_xTitleBox->get_active_text();
583 const OUString sList = m_xListBox->get_active_text();
584 const OUString sLabel = m_xLabelBox->get_active_text();
585 const OUString sIdx = m_xIdxBox->get_active_text();
587 bool bStandardHeightChanged = m_xStandardHeightLB->get_value_changed_from_saved();
588 bool bTitleHeightChanged = m_xTitleHeightLB->get_value_changed_from_saved();
589 bool bListHeightChanged = m_xListHeightLB->get_value_changed_from_saved();
590 bool bLabelHeightChanged = m_xLabelHeightLB->get_value_changed_from_saved();
591 bool bIndexHeightChanged = m_xIndexHeightLB->get_value_changed_from_saved();
593 m_pFontConfig->SetFontStandard(sStandard, m_nFontGroup);
594 m_pFontConfig->SetFontOutline(sTitle, m_nFontGroup);
595 m_pFontConfig->SetFontList(sList, m_nFontGroup);
596 m_pFontConfig->SetFontCaption(sLabel, m_nFontGroup);
597 m_pFontConfig->SetFontIndex(sIdx, m_nFontGroup);
598 if(bStandardHeightChanged)
600 float fSize = static_cast<float>(m_xStandardHeightLB->get_value()) / 10;
601 m_pFontConfig->SetFontHeight( CalcToUnit( fSize, MapUnit::MapTwip ), FONT_STANDARD, m_nFontGroup );
603 if(bTitleHeightChanged)
605 float fSize = static_cast<float>(m_xTitleHeightLB->get_value()) / 10;
606 m_pFontConfig->SetFontHeight( CalcToUnit( fSize, MapUnit::MapTwip ), FONT_OUTLINE, m_nFontGroup );
608 if(bListHeightChanged)
610 float fSize = static_cast<float>(m_xListHeightLB->get_value()) / 10;
611 m_pFontConfig->SetFontHeight( CalcToUnit( fSize, MapUnit::MapTwip ), FONT_LIST, m_nFontGroup );
613 if(bLabelHeightChanged)
615 float fSize = static_cast<float>(m_xLabelHeightLB->get_value()) / 10;
616 m_pFontConfig->SetFontHeight( CalcToUnit( fSize, MapUnit::MapTwip ), FONT_CAPTION, m_nFontGroup );
618 if(bIndexHeightChanged)
620 float fSize = static_cast<float>(m_xIndexHeightLB->get_value()) / 10;
621 m_pFontConfig->SetFontHeight( CalcToUnit( fSize, MapUnit::MapTwip ), FONT_INDEX, m_nFontGroup );
624 if(m_pWrtShell)
626 m_pWrtShell->StartAllAction();
627 SfxPrinter* pPrinter = m_pWrtShell->getIDocumentDeviceAccess().getPrinter( false );
628 bool bMod = false;
629 const sal_uInt16 nFontWhich =
630 m_nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
631 FONT_GROUP_CJK == m_nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT;
632 const sal_uInt16 nFontHeightWhich =
633 m_nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
634 FONT_GROUP_CJK == m_nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE;
635 if(sStandard != m_sShellStd)
637 vcl::Font aFont( sStandard, Size( 0, 10 ) );
638 if( pPrinter )
639 aFont = pPrinter->GetFontMetric( aFont );
640 m_pWrtShell->SetDefault(SvxFontItem(aFont.GetFamilyType(), aFont.GetFamilyName(),
641 OUString(), aFont.GetPitch(), aFont.GetCharSet(), nFontWhich));
642 SwTextFormatColl *pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_STANDARD);
643 pColl->ResetFormatAttr(nFontWhich);
644 bMod = true;
646 if(bStandardHeightChanged)
648 float fSize = static_cast<float>(m_xStandardHeightLB->get_value()) / 10;
649 m_pWrtShell->SetDefault(SvxFontHeightItem( CalcToUnit( fSize, MapUnit::MapTwip ), 100, nFontHeightWhich ) );
650 SwTextFormatColl *pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_STANDARD);
651 pColl->ResetFormatAttr(nFontHeightWhich);
652 bMod = true;
655 if(sTitle != m_sShellTitle )
657 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_HEADLINE_BASE, pPrinter, sTitle, nFontWhich);
658 bMod = true;
660 if(bTitleHeightChanged)
662 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_HEADLINE_BASE,
663 sal::static_int_cast< sal_uInt16, sal_Int64 >(m_xTitleHeightLB->get_value()), nFontHeightWhich);
664 bMod = true;
666 if(sList != m_sShellList && (!m_bListDefault || !m_bSetListDefault ))
668 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_NUMBER_BULLET_BASE, pPrinter, sList, nFontWhich);
669 bMod = true;
671 if(bListHeightChanged)
673 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_NUMBER_BULLET_BASE,
674 sal::static_int_cast< sal_uInt16, sal_Int64 >(m_xListHeightLB->get_value()), nFontHeightWhich);
675 bMod = true;
677 if(sLabel != m_sShellLabel && (!m_bLabelDefault || !m_bSetLabelDefault))
679 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_LABEL, pPrinter, sLabel, nFontWhich);
680 bMod = true;
682 if(bLabelHeightChanged)
684 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_LABEL,
685 sal::static_int_cast< sal_uInt16, sal_Int64 >(m_xLabelHeightLB->get_value()), nFontHeightWhich);
686 bMod = true;
688 if(sIdx != m_sShellIndex && (!m_bIdxDefault || !m_bSetIdxDefault))
690 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_REGISTER_BASE, pPrinter, sIdx, nFontWhich);
691 bMod = true;
693 if(bIndexHeightChanged)
695 lcl_SetColl(m_pWrtShell, RES_POOLCOLL_REGISTER_BASE,
696 sal::static_int_cast< sal_uInt16, sal_Int64 >(m_xIndexHeightLB->get_value()), nFontHeightWhich);
697 bMod = true;
699 if ( bMod )
700 m_pWrtShell->SetModified();
701 m_pWrtShell->EndAllAction();
703 return false;
706 void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
708 const TypedWhichId<SvxLanguageItem> nLangSlot = m_nFontGroup == FONT_GROUP_DEFAULT ? SID_ATTR_LANGUAGE :
709 FONT_GROUP_CJK == m_nFontGroup ? SID_ATTR_CHAR_CJK_LANGUAGE : SID_ATTR_CHAR_CTL_LANGUAGE;
711 if( const SvxLanguageItem* pLang = rSet->GetItemIfSet(nLangSlot, false) )
712 m_eLanguage = pLang->GetValue();
714 OUString sToReplace = m_sScriptWestern;
715 if(FONT_GROUP_CJK == m_nFontGroup )
716 sToReplace = m_sScriptAsian;
717 else if(FONT_GROUP_CTL == m_nFontGroup )
718 sToReplace = m_sScriptComplex;
719 m_xLabelFT->set_label(m_xLabelFT->get_label().replaceFirst("%1", sToReplace));
721 if (m_bDisposePrinter)
723 m_pPrt.disposeAndClear();
724 m_bDisposePrinter = false;
727 if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_PRINTER, false))
729 m_pPrt = static_cast<SfxPrinter*>(pItem->GetValue());
731 else
733 auto pPrinterSet = std::make_unique<SfxItemSetFixed
734 <SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
735 SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC>>( *rSet->GetPool() );
736 m_pPrt = VclPtr<SfxPrinter>::Create(std::move(pPrinterSet));
737 m_bDisposePrinter = true;
739 m_pFontList.reset(new FontList( m_pPrt ));
740 // #i94536# prevent duplication of font entries when 'reset' button is pressed
741 if( !m_xStandardBox->get_count() )
743 // get the set of distinct available family names
744 std::set< OUString > aFontNames;
745 int nFontNames = m_pPrt->GetFontFaceCollectionCount();
746 for( int i = 0; i < nFontNames; i++ )
748 FontMetric aFontMetric( m_pPrt->GetFontMetricFromCollection( i ) );
749 aFontNames.insert( aFontMetric.GetFamilyName() );
752 // insert to listboxes
753 for( const auto& rFontName : aFontNames )
755 m_xStandardBox->append_text( rFontName );
756 m_xTitleBox->append_text( rFontName );
757 m_xListBox->append_text( rFontName );
758 m_xLabelBox->append_text( rFontName );
759 m_xIdxBox->append_text( rFontName );
762 if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_STDFONTS, false))
764 m_pFontConfig = static_cast<SwStdFontConfig*>(pItem->GetValue());
767 if(const SwPtrItem* pItem = rSet->GetItemIfSet(FN_PARAM_WRTSHELL, false))
769 m_pWrtShell = static_cast<SwWrtShell*>(pItem->GetValue());
771 OUString sStdBackup;
772 OUString sOutBackup;
773 OUString sListBackup;
774 OUString sCapBackup;
775 OUString sIdxBackup;
776 sal_Int32 nStandardHeight = -1;
777 sal_Int32 nTitleHeight = -1;
778 sal_Int32 nListHeight = -1;
779 sal_Int32 nLabelHeight = -1;
780 sal_Int32 nIndexHeight = -1;
782 if(!m_pWrtShell)
784 sStdBackup = m_pFontConfig->GetFontStandard(m_nFontGroup);
785 sOutBackup = m_pFontConfig->GetFontOutline(m_nFontGroup);
786 sListBackup= m_pFontConfig->GetFontList(m_nFontGroup);
787 sCapBackup = m_pFontConfig->GetFontCaption(m_nFontGroup);
788 sIdxBackup = m_pFontConfig->GetFontIndex(m_nFontGroup);
789 nStandardHeight = m_pFontConfig->GetFontHeight( FONT_STANDARD, m_nFontGroup, m_eLanguage );
790 nTitleHeight = m_pFontConfig->GetFontHeight( FONT_OUTLINE , m_nFontGroup, m_eLanguage );
791 nListHeight = m_pFontConfig->GetFontHeight( FONT_LIST , m_nFontGroup, m_eLanguage );
792 nLabelHeight = m_pFontConfig->GetFontHeight( FONT_CAPTION , m_nFontGroup, m_eLanguage );
793 nIndexHeight = m_pFontConfig->GetFontHeight( FONT_INDEX , m_nFontGroup, m_eLanguage );
794 if( nStandardHeight <= 0)
795 nStandardHeight = SwStdFontConfig::GetDefaultHeightFor( FONT_STANDARD + m_nFontGroup * FONT_PER_GROUP, m_eLanguage);
796 if( nTitleHeight <= 0)
797 nTitleHeight = SwStdFontConfig::GetDefaultHeightFor( FONT_OUTLINE + m_nFontGroup * FONT_PER_GROUP, m_eLanguage);
798 if( nListHeight <= 0)
799 nListHeight = SwStdFontConfig::GetDefaultHeightFor( FONT_LIST + m_nFontGroup * FONT_PER_GROUP, m_eLanguage);
800 if( nLabelHeight <= 0)
801 nLabelHeight = SwStdFontConfig::GetDefaultHeightFor( FONT_CAPTION + m_nFontGroup * FONT_PER_GROUP, m_eLanguage);
802 if( nIndexHeight <= 0)
803 nIndexHeight = SwStdFontConfig::GetDefaultHeightFor( FONT_INDEX + m_nFontGroup * FONT_PER_GROUP, m_eLanguage);
805 else
807 SwTextFormatColl *pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_STANDARD);
808 const SvxFontItem& rFont = !m_nFontGroup ? pColl->GetFont() :
809 FONT_GROUP_CJK == m_nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
810 m_sShellStd = sStdBackup = rFont.GetFamilyName();
812 const sal_uInt16 nFontHeightWhich =
813 m_nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONTSIZE :
814 FONT_GROUP_CJK == m_nFontGroup ? RES_CHRATR_CJK_FONTSIZE : RES_CHRATR_CTL_FONTSIZE;
815 const SvxFontHeightItem& rFontHeightStandard = static_cast<const SvxFontHeightItem& >(pColl->GetFormatAttr(nFontHeightWhich));
816 nStandardHeight = static_cast<sal_Int32>(rFontHeightStandard.GetHeight());
818 pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_HEADLINE_BASE);
819 const SvxFontItem& rFontHL = !m_nFontGroup ? pColl->GetFont() :
820 FONT_GROUP_CJK == m_nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
821 m_sShellTitle = sOutBackup = rFontHL.GetFamilyName();
823 const SvxFontHeightItem& rFontHeightTitle = static_cast<const SvxFontHeightItem&>(pColl->GetFormatAttr( nFontHeightWhich ));
824 nTitleHeight = static_cast<sal_Int32>(rFontHeightTitle.GetHeight());
826 const sal_uInt16 nFontWhich =
827 m_nFontGroup == FONT_GROUP_DEFAULT ? RES_CHRATR_FONT :
828 FONT_GROUP_CJK == m_nFontGroup ? RES_CHRATR_CJK_FONT : RES_CHRATR_CTL_FONT;
829 pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_NUMBER_BULLET_BASE);
830 const SvxFontItem& rFontLS = !m_nFontGroup ? pColl->GetFont() :
831 FONT_GROUP_CJK == m_nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
832 m_bListDefault = SfxItemState::DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, false);
833 m_sShellList = sListBackup = rFontLS.GetFamilyName();
835 const SvxFontHeightItem& rFontHeightList = static_cast<const SvxFontHeightItem&>(pColl->GetFormatAttr(nFontHeightWhich));
836 nListHeight = static_cast<sal_Int32>(rFontHeightList.GetHeight());
838 pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_LABEL);
839 m_bLabelDefault = SfxItemState::DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, false);
840 const SvxFontItem& rFontCP = !m_nFontGroup ? pColl->GetFont() :
841 FONT_GROUP_CJK == m_nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
842 m_sShellLabel = sCapBackup = rFontCP.GetFamilyName();
843 const SvxFontHeightItem& rFontHeightLabel = static_cast<const SvxFontHeightItem&>(pColl->GetFormatAttr(nFontHeightWhich));
844 nLabelHeight = static_cast<sal_Int32>(rFontHeightLabel.GetHeight());
846 pColl = m_pWrtShell->GetTextCollFromPool(RES_POOLCOLL_REGISTER_BASE);
847 m_bIdxDefault = SfxItemState::DEFAULT == pColl->GetAttrSet().GetItemState(nFontWhich, false);
848 const SvxFontItem& rFontIDX = !m_nFontGroup ? pColl->GetFont() :
849 FONT_GROUP_CJK == m_nFontGroup ? pColl->GetCJKFont() : pColl->GetCTLFont();
850 m_sShellIndex = sIdxBackup = rFontIDX.GetFamilyName();
851 const SvxFontHeightItem& rFontHeightIndex = static_cast<const SvxFontHeightItem&>(pColl->GetFormatAttr(nFontHeightWhich));
852 nIndexHeight = static_cast<sal_Int32>(rFontHeightIndex.GetHeight());
854 m_xStandardBox->set_entry_text(sStdBackup );
855 m_xTitleBox->set_entry_text(sOutBackup );
856 m_xListBox->set_entry_text(sListBackup);
857 m_xLabelBox->set_entry_text(sCapBackup );
858 m_xIdxBox->set_entry_text(sIdxBackup );
860 m_xStandardHeightLB->Fill( m_pFontList.get() );
861 m_xTitleHeightLB->Fill( m_pFontList.get() );
862 m_xListHeightLB->Fill( m_pFontList.get() );
863 m_xLabelHeightLB->Fill( m_pFontList.get() );
864 m_xIndexHeightLB->Fill( m_pFontList.get() );
866 m_xStandardHeightLB->set_value( CalcToPoint( nStandardHeight, MapUnit::MapTwip, 10 ) );
867 m_xTitleHeightLB->set_value( CalcToPoint( nTitleHeight , MapUnit::MapTwip, 10 ) );
868 m_xListHeightLB->set_value( CalcToPoint( nListHeight , MapUnit::MapTwip, 10 ) );
869 m_xLabelHeightLB->set_value( CalcToPoint( nLabelHeight , MapUnit::MapTwip, 10 ));
870 m_xIndexHeightLB->set_value( CalcToPoint( nIndexHeight , MapUnit::MapTwip, 10 ));
872 m_xStandardBox->save_value();
873 m_xTitleBox->save_value();
874 m_xListBox->save_value();
875 m_xLabelBox->save_value();
876 m_xIdxBox->save_value();
878 m_xStandardHeightLB->save_value();
879 m_xTitleHeightLB->save_value();
880 m_xListHeightLB->save_value();
881 m_xLabelHeightLB->save_value();
882 m_xIndexHeightLB->save_value();
885 IMPL_LINK_NOARG(SwStdFontTabPage, StandardHdl, weld::Button&, void)
887 sal_uInt8 nFontOffset = m_nFontGroup * FONT_PER_GROUP;
888 m_xStandardBox->set_entry_text(SwStdFontConfig::GetDefaultFor(FONT_STANDARD + nFontOffset, m_eLanguage));
889 m_xTitleBox->set_entry_text(SwStdFontConfig::GetDefaultFor(FONT_OUTLINE + nFontOffset, m_eLanguage));
890 m_xListBox->set_entry_text(SwStdFontConfig::GetDefaultFor(FONT_LIST + nFontOffset, m_eLanguage));
891 m_xLabelBox->set_entry_text(SwStdFontConfig::GetDefaultFor(FONT_CAPTION + nFontOffset, m_eLanguage));
892 m_xIdxBox->set_entry_text(SwStdFontConfig::GetDefaultFor(FONT_INDEX + nFontOffset, m_eLanguage));
894 m_xStandardBox->save_value();
895 m_xTitleBox->save_value();
896 m_xListBox->save_value();
897 m_xLabelBox->save_value();
898 m_xIdxBox->save_value();
900 m_xStandardHeightLB->set_value( CalcToPoint(
901 SwStdFontConfig::GetDefaultHeightFor(FONT_STANDARD + nFontOffset, m_eLanguage),
902 MapUnit::MapTwip, 10 ));
903 m_xTitleHeightLB->set_value(CalcToPoint(
904 SwStdFontConfig::GetDefaultHeightFor(FONT_OUTLINE +
905 nFontOffset, m_eLanguage), MapUnit::MapTwip, 10 ));
906 m_xListHeightLB->set_value(CalcToPoint(
907 SwStdFontConfig::GetDefaultHeightFor(FONT_LIST + nFontOffset, m_eLanguage),
908 MapUnit::MapTwip, 10 ));
909 m_xLabelHeightLB->set_value(CalcToPoint(
910 SwStdFontConfig::GetDefaultHeightFor(FONT_CAPTION + nFontOffset, m_eLanguage),
911 MapUnit::MapTwip, 10 ));
912 m_xIndexHeightLB->set_value(CalcToPoint(
913 SwStdFontConfig::GetDefaultHeightFor(FONT_INDEX + nFontOffset, m_eLanguage),
914 MapUnit::MapTwip, 10 ));
917 IMPL_LINK( SwStdFontTabPage, ModifyHdl, weld::ComboBox&, rBox, void )
919 if (&rBox == m_xStandardBox.get())
921 const OUString sEntry = rBox.get_active_text();
922 if(m_bSetListDefault && m_bListDefault)
923 m_xListBox->set_entry_text(sEntry);
924 if(m_bSetLabelDefault && m_bLabelDefault)
925 m_xLabelBox->set_entry_text(sEntry);
926 if(m_bSetIdxDefault && m_bIdxDefault)
927 m_xIdxBox->set_entry_text(sEntry);
929 else if (&rBox == m_xListBox.get())
931 m_bSetListDefault = false;
933 else if (&rBox == m_xLabelBox.get())
935 m_bSetLabelDefault = false;
937 else if (&rBox == m_xIdxBox.get())
939 m_bSetIdxDefault = false;
943 IMPL_LINK( SwStdFontTabPage, LoseFocusHdl, weld::Widget&, rControl, void )
945 weld::ComboBox& rBox = dynamic_cast<weld::ComboBox&>(rControl);
946 FontSizeBox* pHeightLB = nullptr;
948 if (&rBox == m_xStandardBox.get())
950 pHeightLB = m_xStandardHeightLB.get();
952 else if (&rBox == m_xTitleBox.get())
954 pHeightLB = m_xTitleHeightLB.get();
956 else if (&rBox == m_xListBox.get())
958 pHeightLB = m_xListHeightLB.get();
960 else if (&rBox == m_xLabelBox.get())
962 pHeightLB = m_xLabelHeightLB.get();
964 else /*if (&rBox == m_xIndexHeightLB.get())*/
966 pHeightLB = m_xIndexHeightLB.get();
969 pHeightLB->Fill( m_pFontList.get() );
972 void SwStdFontTabPage::PageCreated( const SfxAllItemSet& aSet)
974 const SfxUInt16Item* pFlagItem = aSet.GetItem<SfxUInt16Item>(SID_FONTMODE_TYPE, false);
975 if (pFlagItem)
976 m_nFontGroup = sal::static_int_cast< sal_uInt8, sal_uInt16>( pFlagItem->GetValue() );
979 SwTableOptionsTabPage::SwTableOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
980 : SfxTabPage(pPage, pController, "modules/swriter/ui/opttablepage.ui", "OptTablePage", &rSet)
981 , m_pWrtShell(nullptr)
982 , m_bHTMLMode(false)
983 , m_xHeaderCB(m_xBuilder->weld_check_button("header"))
984 , m_xRepeatHeaderCB(m_xBuilder->weld_check_button("repeatheader"))
985 , m_xDontSplitCB(m_xBuilder->weld_check_button("dontsplit"))
986 , m_xBorderCB(m_xBuilder->weld_check_button("border"))
987 , m_xNumFormattingCB(m_xBuilder->weld_check_button("numformatting"))
988 , m_xNumFormatFormattingCB(m_xBuilder->weld_check_button("numfmtformatting"))
989 , m_xNumAlignmentCB(m_xBuilder->weld_check_button("numalignment"))
990 , m_xRowMoveMF(m_xBuilder->weld_metric_spin_button("rowmove", FieldUnit::CM))
991 , m_xColMoveMF(m_xBuilder->weld_metric_spin_button("colmove", FieldUnit::CM))
992 , m_xRowInsertMF(m_xBuilder->weld_metric_spin_button("rowinsert", FieldUnit::CM))
993 , m_xColInsertMF(m_xBuilder->weld_metric_spin_button("colinsert", FieldUnit::CM))
994 , m_xFixRB(m_xBuilder->weld_radio_button("fix"))
995 , m_xFixPropRB(m_xBuilder->weld_radio_button("fixprop"))
996 , m_xVarRB(m_xBuilder->weld_radio_button("var"))
998 Link<weld::Toggleable&,void> aLnk(LINK(this, SwTableOptionsTabPage, CheckBoxHdl));
999 m_xNumFormattingCB->connect_toggled(aLnk);
1000 m_xNumFormatFormattingCB->connect_toggled(aLnk);
1001 m_xHeaderCB->connect_toggled(aLnk);
1004 SwTableOptionsTabPage::~SwTableOptionsTabPage()
1008 std::unique_ptr<SfxTabPage> SwTableOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
1009 const SfxItemSet* rAttrSet )
1011 return std::make_unique<SwTableOptionsTabPage>(pPage, pController, *rAttrSet);
1014 bool SwTableOptionsTabPage::FillItemSet( SfxItemSet* )
1016 bool bRet = false;
1017 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1019 if (m_xRowMoveMF->get_value_changed_from_saved())
1020 pModOpt->SetTableHMove( o3tl::narrowing<sal_uInt16>(m_xRowMoveMF->denormalize( m_xRowMoveMF->get_value(FieldUnit::TWIP))));
1022 if (m_xColMoveMF->get_value_changed_from_saved())
1023 pModOpt->SetTableVMove( o3tl::narrowing<sal_uInt16>(m_xColMoveMF->denormalize( m_xColMoveMF->get_value(FieldUnit::TWIP))));
1025 if (m_xRowInsertMF->get_value_changed_from_saved())
1026 pModOpt->SetTableHInsert(o3tl::narrowing<sal_uInt16>(m_xRowInsertMF->denormalize( m_xRowInsertMF->get_value(FieldUnit::TWIP))));
1028 if (m_xColInsertMF->get_value_changed_from_saved())
1029 pModOpt->SetTableVInsert(o3tl::narrowing<sal_uInt16>(m_xColInsertMF->denormalize( m_xColInsertMF->get_value(FieldUnit::TWIP))));
1031 TableChgMode eMode;
1032 if (m_xFixRB->get_active())
1033 eMode = TableChgMode::FixedWidthChangeAbs;
1034 else if(m_xFixPropRB->get_active())
1035 eMode = TableChgMode::FixedWidthChangeProp;
1036 else
1037 eMode = TableChgMode::VarWidthChangeAbs;
1038 if(eMode != pModOpt->GetTableMode())
1040 pModOpt->SetTableMode(eMode);
1041 // the table-keyboard-mode has changed, now the current
1042 // table should know about that too.
1043 if(m_pWrtShell && SelectionType::Table & m_pWrtShell->GetSelectionType())
1045 m_pWrtShell->SetTableChgMode(eMode);
1046 static sal_uInt16 aInva[] =
1047 { FN_TABLE_MODE_FIX,
1048 FN_TABLE_MODE_FIX_PROP,
1049 FN_TABLE_MODE_VARIABLE,
1052 m_pWrtShell->GetView().GetViewFrame().GetBindings().Invalidate( aInva );
1055 bRet = true;
1058 SwInsertTableOptions aInsOpts( SwInsertTableFlags::NONE, 0 );
1060 if (m_xHeaderCB->get_active())
1061 aInsOpts.mnInsMode |= SwInsertTableFlags::Headline;
1063 if (m_xRepeatHeaderCB->get_sensitive())
1064 aInsOpts.mnRowsToRepeat = m_xRepeatHeaderCB->get_active() ? 1 : 0;
1066 if (!m_xDontSplitCB->get_active())
1067 aInsOpts.mnInsMode |= SwInsertTableFlags::SplitLayout;
1069 if (m_xBorderCB->get_active())
1070 aInsOpts.mnInsMode |= SwInsertTableFlags::DefaultBorder;
1072 if (m_xHeaderCB->get_state_changed_from_saved() ||
1073 m_xRepeatHeaderCB->get_state_changed_from_saved() ||
1074 m_xDontSplitCB->get_state_changed_from_saved() ||
1075 m_xBorderCB->get_state_changed_from_saved())
1077 pModOpt->SetInsTableFlags(m_bHTMLMode, aInsOpts);
1080 if (m_xNumFormattingCB->get_state_changed_from_saved())
1082 pModOpt->SetInsTableFormatNum(m_bHTMLMode, m_xNumFormattingCB->get_active());
1083 bRet = true;
1086 if (m_xNumFormatFormattingCB->get_state_changed_from_saved())
1088 pModOpt->SetInsTableChangeNumFormat(m_bHTMLMode, m_xNumFormatFormattingCB->get_active());
1089 bRet = true;
1092 if (m_xNumAlignmentCB->get_state_changed_from_saved())
1094 pModOpt->SetInsTableAlignNum(m_bHTMLMode, m_xNumAlignmentCB->get_active());
1095 bRet = true;
1098 return bRet;
1101 void SwTableOptionsTabPage::Reset( const SfxItemSet* rSet)
1103 const SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
1104 if ( rSet->GetItemState( SID_ATTR_METRIC ) >= SfxItemState::DEFAULT )
1106 const SfxUInt16Item& rItem = rSet->Get( SID_ATTR_METRIC );
1107 FieldUnit eFieldUnit = static_cast<FieldUnit>(rItem.GetValue());
1108 ::SetFieldUnit( *m_xRowMoveMF, eFieldUnit );
1109 ::SetFieldUnit( *m_xColMoveMF, eFieldUnit );
1110 ::SetFieldUnit( *m_xRowInsertMF, eFieldUnit );
1111 ::SetFieldUnit( *m_xColInsertMF, eFieldUnit );
1114 m_xRowMoveMF->set_value(m_xRowMoveMF->normalize(pModOpt->GetTableHMove()), FieldUnit::TWIP);
1115 m_xColMoveMF->set_value(m_xColMoveMF->normalize(pModOpt->GetTableVMove()), FieldUnit::TWIP);
1116 m_xRowInsertMF->set_value(m_xRowInsertMF->normalize(pModOpt->GetTableHInsert()), FieldUnit::TWIP);
1117 m_xColInsertMF->set_value(m_xColInsertMF->normalize(pModOpt->GetTableVInsert()), FieldUnit::TWIP);
1119 switch(pModOpt->GetTableMode())
1121 case TableChgMode::FixedWidthChangeAbs: m_xFixRB->set_active(true); break;
1122 case TableChgMode::FixedWidthChangeProp: m_xFixPropRB->set_active(true); break;
1123 case TableChgMode::VarWidthChangeAbs: m_xVarRB->set_active(true); break;
1125 if(const SfxUInt16Item* pItem = rSet->GetItemIfSet(SID_HTML_MODE, false))
1127 m_bHTMLMode = 0 != (pItem->GetValue() & HTMLMODE_ON);
1130 // hide certain controls for html
1131 if (m_bHTMLMode)
1133 m_xRepeatHeaderCB->hide();
1134 m_xDontSplitCB->hide();
1137 SwInsertTableOptions aInsOpts = pModOpt->GetInsTableFlags(m_bHTMLMode);
1138 const SwInsertTableFlags nInsTableFlags = aInsOpts.mnInsMode;
1140 m_xHeaderCB->set_active(bool(nInsTableFlags & SwInsertTableFlags::Headline));
1141 m_xRepeatHeaderCB->set_active((!m_bHTMLMode) && (aInsOpts.mnRowsToRepeat > 0));
1142 m_xDontSplitCB->set_active(!(nInsTableFlags & SwInsertTableFlags::SplitLayout));
1143 m_xBorderCB->set_active(bool(nInsTableFlags & SwInsertTableFlags::DefaultBorder));
1145 m_xNumFormattingCB->set_active(pModOpt->IsInsTableFormatNum(m_bHTMLMode));
1146 m_xNumFormatFormattingCB->set_active(pModOpt->IsInsTableChangeNumFormat(m_bHTMLMode));
1147 m_xNumAlignmentCB->set_active(pModOpt->IsInsTableAlignNum(m_bHTMLMode));
1149 m_xHeaderCB->save_state();
1150 m_xRepeatHeaderCB->save_state();
1151 m_xDontSplitCB->save_state();
1152 m_xBorderCB->save_state();
1153 m_xNumFormattingCB->save_state();
1154 m_xNumFormatFormattingCB->save_state();
1155 m_xNumAlignmentCB->save_state();
1156 m_xRowMoveMF->save_value();
1157 m_xColMoveMF->save_value();
1158 m_xRowInsertMF->save_value();
1159 m_xColInsertMF->save_value();
1161 CheckBoxHdl(*m_xHeaderCB);
1164 IMPL_LINK_NOARG(SwTableOptionsTabPage, CheckBoxHdl, weld::Toggleable&, void)
1166 m_xNumFormatFormattingCB->set_sensitive(m_xNumFormattingCB->get_active());
1167 m_xNumAlignmentCB->set_sensitive(m_xNumFormattingCB->get_active());
1168 m_xRepeatHeaderCB->set_sensitive(m_xHeaderCB->get_active());
1171 void SwTableOptionsTabPage::PageCreated( const SfxAllItemSet& aSet)
1173 const SwWrtShellItem* pWrtSh = aSet.GetItem<SwWrtShellItem>(SID_WRT_SHELL, false);
1174 if (pWrtSh)
1175 m_pWrtShell = pWrtSh->GetValue();
1178 SwShdwCursorOptionsTabPage::SwShdwCursorOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1179 : SfxTabPage(pPage, pController, "modules/swriter/ui/optformataidspage.ui", "OptFormatAidsPage", &rSet)
1180 , m_pWrtShell(nullptr)
1181 , m_xParaCB(m_xBuilder->weld_check_button("paragraph"))
1182 , m_xSHyphCB(m_xBuilder->weld_check_button("hyphens"))
1183 , m_xSpacesCB(m_xBuilder->weld_check_button("spaces"))
1184 , m_xHSpacesCB(m_xBuilder->weld_check_button("nonbreak"))
1185 , m_xTabCB(m_xBuilder->weld_check_button("tabs"))
1186 , m_xTabLabel(m_xBuilder->weld_label("tabs_label"))
1187 , m_xBreakCB(m_xBuilder->weld_check_button("break"))
1188 , m_xCharHiddenCB(m_xBuilder->weld_check_button("hiddentext"))
1189 , m_xBookmarkCB(m_xBuilder->weld_check_button("bookmarks"))
1190 , m_xBookmarkLabel(m_xBuilder->weld_label("bookmarks_label"))
1191 , m_xDirectCursorFrame(m_xBuilder->weld_frame("directcrsrframe"))
1192 , m_xOnOffCB(m_xBuilder->weld_check_button("cursoronoff"))
1193 , m_xDirectCursorFillMode(m_xBuilder->weld_combo_box("cxDirectCursorFillMode"))
1194 , m_xCursorProtFrame(m_xBuilder->weld_frame("crsrprotframe"))
1195 , m_xImageFrame(m_xBuilder->weld_frame("frmImage"))
1196 , m_xCursorInProtCB(m_xBuilder->weld_check_button("cursorinprot"))
1197 , m_xDefaultAnchorType(m_xBuilder->weld_combo_box("cxDefaultAnchor"))
1198 , m_xMathBaselineAlignmentCB(m_xBuilder->weld_check_button("mathbaseline"))
1200 SwFillMode eMode = SwFillMode::Tab;
1201 bool bIsOn = false;
1203 if( const SwShadowCursorItem* pItem = rSet.GetItemIfSet( FN_PARAM_SHADOWCURSOR, false ))
1205 eMode = pItem->GetMode();
1206 bIsOn = pItem->IsOn();
1208 m_xOnOffCB->set_active( bIsOn );
1210 m_xDirectCursorFillMode->set_active( static_cast<int>(eMode) );
1211 const SfxUInt16Item* pHtmlModeItem = rSet.GetItemIfSet(SID_HTML_MODE, false);
1212 if(!pHtmlModeItem || !(pHtmlModeItem->GetValue() & HTMLMODE_ON))
1213 return;
1215 m_xTabCB->hide();
1216 m_xTabLabel->hide();
1217 m_xCharHiddenCB->hide();
1218 m_xBookmarkCB->hide();
1219 m_xBookmarkLabel->hide();
1221 m_xDirectCursorFrame->hide();
1222 m_xOnOffCB->hide();
1223 m_xDirectCursorFillMode->hide();
1224 m_xCursorProtFrame->hide();
1225 m_xCursorInProtCB->hide();
1226 m_xImageFrame->hide();
1229 SwShdwCursorOptionsTabPage::~SwShdwCursorOptionsTabPage()
1233 std::unique_ptr<SfxTabPage> SwShdwCursorOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
1235 return std::make_unique<SwShdwCursorOptionsTabPage>(pPage, pController, *rSet);
1238 void SwShdwCursorOptionsTabPage::PageCreated( const SfxAllItemSet& aSet )
1240 const SwWrtShellItem* pWrtSh = aSet.GetItem<SwWrtShellItem>(SID_WRT_SHELL, false);
1241 if (pWrtSh)
1242 m_pWrtShell = pWrtSh->GetValue();
1245 bool SwShdwCursorOptionsTabPage::FillItemSet( SfxItemSet* rSet )
1247 SwShadowCursorItem aOpt;
1248 aOpt.SetOn( m_xOnOffCB->get_active() );
1250 SwFillMode eMode = static_cast<SwFillMode>(m_xDirectCursorFillMode->get_active());
1251 aOpt.SetMode( eMode );
1253 bool bRet = false;
1254 const SwShadowCursorItem* pShadowCursorItem = rSet->GetItemIfSet( FN_PARAM_SHADOWCURSOR, false );
1255 if( !pShadowCursorItem || *pShadowCursorItem != aOpt )
1257 rSet->Put( aOpt );
1258 bRet = true;
1261 if (m_pWrtShell) {
1262 m_pWrtShell->GetDoc()->getIDocumentSettingAccess().set( DocumentSettingId::MATH_BASELINE_ALIGNMENT,
1263 m_xMathBaselineAlignmentCB->get_active() );
1264 bRet |= m_xMathBaselineAlignmentCB->get_state_changed_from_saved();
1267 if( m_xCursorInProtCB->get_state_changed_from_saved())
1269 rSet->Put(SfxBoolItem(FN_PARAM_CRSR_IN_PROTECTED, m_xCursorInProtCB->get_active()));
1270 bRet = true;
1273 const SwDocDisplayItem* pOldAttr = GetOldItem(GetItemSet(), FN_PARAM_DOCDISP);
1275 SwDocDisplayItem aDisp;
1277 aDisp.m_bParagraphEnd = m_xParaCB->get_active();
1278 aDisp.m_bTab = m_xTabCB->get_active();
1279 aDisp.m_bSpace = m_xSpacesCB->get_active();
1280 aDisp.m_bNonbreakingSpace = m_xHSpacesCB->get_active();
1281 aDisp.m_bSoftHyphen = m_xSHyphCB->get_active();
1282 aDisp.m_bCharHiddenText = m_xCharHiddenCB->get_active();
1283 aDisp.m_bBookmarks = m_xBookmarkCB->get_active();
1284 aDisp.m_bManualBreak = m_xBreakCB->get_active();
1285 aDisp.m_xDefaultAnchor = m_xDefaultAnchorType->get_active();
1287 bRet |= (!pOldAttr || aDisp != *pOldAttr);
1288 if(bRet)
1289 bRet = nullptr != rSet->Put(aDisp);
1291 return bRet;
1294 void SwShdwCursorOptionsTabPage::Reset( const SfxItemSet* rSet )
1296 SwFillMode eMode = SwFillMode::Tab;
1297 bool bIsOn = false;
1299 if( const SwShadowCursorItem* pItem = rSet->GetItemIfSet( FN_PARAM_SHADOWCURSOR, false ))
1301 eMode = pItem->GetMode();
1302 bIsOn = pItem->IsOn();
1304 m_xOnOffCB->set_active( bIsOn );
1306 m_xDirectCursorFillMode->set_active( static_cast<int>(eMode) );
1307 if (m_pWrtShell) {
1308 m_xMathBaselineAlignmentCB->set_active( m_pWrtShell->GetDoc()->getIDocumentSettingAccess().get( DocumentSettingId::MATH_BASELINE_ALIGNMENT ) );
1309 m_xMathBaselineAlignmentCB->save_state();
1310 } else {
1311 m_xMathBaselineAlignmentCB->hide();
1314 if( const SfxBoolItem* pItem = rSet->GetItemIfSet( FN_PARAM_CRSR_IN_PROTECTED, false ) )
1315 m_xCursorInProtCB->set_active(pItem->GetValue());
1316 m_xCursorInProtCB->save_state();
1318 const SwDocDisplayItem* pDocDisplayAttr = rSet->GetItemIfSet( FN_PARAM_DOCDISP, false );
1319 if(pDocDisplayAttr)
1321 m_xParaCB->set_active( pDocDisplayAttr->m_bParagraphEnd );
1322 m_xTabCB->set_active( pDocDisplayAttr->m_bTab );
1323 m_xSpacesCB->set_active( pDocDisplayAttr->m_bSpace );
1324 m_xHSpacesCB->set_active( pDocDisplayAttr->m_bNonbreakingSpace );
1325 m_xSHyphCB->set_active( pDocDisplayAttr->m_bSoftHyphen );
1326 m_xCharHiddenCB->set_active( pDocDisplayAttr->m_bCharHiddenText );
1327 m_xBookmarkCB->set_active(pDocDisplayAttr->m_bBookmarks);
1328 m_xBreakCB->set_active( pDocDisplayAttr->m_bManualBreak );
1329 m_xDefaultAnchorType->set_active( pDocDisplayAttr->m_xDefaultAnchor );
1333 namespace {
1335 // TabPage for Redlining
1336 struct CharAttr
1338 sal_uInt16 nItemId;
1339 sal_uInt16 nAttr;
1344 // Edit corresponds to Paste-attributes
1345 CharAttr const aRedlineAttr[] =
1347 { SID_ATTR_CHAR_CASEMAP, sal_uInt16(SvxCaseMap::NotMapped) },
1348 { SID_ATTR_CHAR_WEIGHT, WEIGHT_BOLD },
1349 { SID_ATTR_CHAR_POSTURE, ITALIC_NORMAL },
1350 { SID_ATTR_CHAR_UNDERLINE, LINESTYLE_SINGLE },
1351 { SID_ATTR_CHAR_UNDERLINE, LINESTYLE_DOUBLE },
1352 { SID_ATTR_CHAR_STRIKEOUT, STRIKEOUT_SINGLE },
1353 { SID_ATTR_CHAR_CASEMAP, sal_uInt16(SvxCaseMap::Uppercase) },
1354 { SID_ATTR_CHAR_CASEMAP, sal_uInt16(SvxCaseMap::Lowercase) },
1355 { SID_ATTR_CHAR_CASEMAP, sal_uInt16(SvxCaseMap::SmallCaps) },
1356 { SID_ATTR_CHAR_CASEMAP, sal_uInt16(SvxCaseMap::Capitalize) },
1357 { SID_ATTR_BRUSH, 0 }
1359 // Items from aRedlineAttr relevant for InsertAttr: strikethrough is
1360 // not used
1361 static sal_uInt16 aInsertAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 };
1363 // Items from aRedlineAttr relevant for DeleteAttr: underline and
1364 // double underline is not used
1365 static sal_uInt16 aDeletedAttrMap[] = { 0, 1, 2, 5, 6, 7, 8, 9, 10 };
1367 // Items from aRedlineAttr relevant for ChangeAttr: strikethrough is
1368 // not used
1369 static sal_uInt16 aChangedAttrMap[] = { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10 };
1371 // Preview of selection
1372 SwMarkPreview::SwMarkPreview()
1373 : m_aTransCol(COL_TRANSPARENT)
1374 , m_aMarkCol(COL_LIGHTRED)
1375 , m_nMarkPos(0)
1378 InitColors();
1381 SwMarkPreview::~SwMarkPreview()
1385 void SwMarkPreview::InitColors()
1387 // m_aTransCol and m_aMarkCol are _not_ changed because they are set from outside!
1389 const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
1390 m_aBgCol = rSettings.GetWindowColor();
1392 bool bHC = rSettings.GetHighContrastMode();
1393 const Color& rFontColor = SwViewOption::GetCurrentViewOptions().GetFontColor();
1394 m_aLineCol = bHC? rFontColor : COL_BLACK;
1395 m_aShadowCol = bHC? m_aBgCol : rSettings.GetShadowColor();
1396 m_aTextCol = bHC? rFontColor : COL_GRAY;
1397 m_aPrintAreaCol = m_aTextCol;
1400 void SwMarkPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle &/*rRect*/)
1402 const Size aSz(GetOutputSizePixel());
1404 // Page
1405 m_aPage.SetSize(Size(aSz.Width() - 3, aSz.Height() - 3));
1407 const tools::Long nOutWPix = m_aPage.GetWidth();
1408 const tools::Long nOutHPix = m_aPage.GetHeight();
1410 // PrintArea
1411 const tools::Long nLBorder = 8;
1412 const tools::Long nRBorder = 8;
1413 const tools::Long nTBorder = 4;
1414 const tools::Long nBBorder = 4;
1416 m_aLeftPagePrtArea = tools::Rectangle(Point(nLBorder, nTBorder), Point((nOutWPix - 1) - nRBorder, (nOutHPix - 1) - nBBorder));
1417 const tools::Long nWidth = m_aLeftPagePrtArea.GetWidth();
1418 const tools::Long nCorr = (nWidth & 1) != 0 ? 0 : 1;
1419 m_aLeftPagePrtArea.SetSize(Size(nWidth / 2 - (nLBorder + nRBorder) / 2 + nCorr, m_aLeftPagePrtArea.GetHeight()));
1421 m_aRightPagePrtArea = m_aLeftPagePrtArea;
1422 m_aRightPagePrtArea.Move(m_aLeftPagePrtArea.GetWidth() + nLBorder + nRBorder + 1, 0);
1424 // draw shadow
1425 tools::Rectangle aShadow(m_aPage);
1426 aShadow += Point(3, 3);
1427 drawRect(rRenderContext, aShadow, m_aShadowCol, m_aTransCol);
1429 // draw page
1430 drawRect(rRenderContext, m_aPage, m_aBgCol, m_aLineCol);
1432 // draw separator
1433 tools::Rectangle aPageSeparator(m_aPage);
1434 aPageSeparator.SetSize(Size(2, aPageSeparator.GetHeight()));
1435 aPageSeparator.Move(m_aPage.GetWidth() / 2 - 1, 0);
1436 drawRect(rRenderContext, aPageSeparator, m_aLineCol, m_aTransCol);
1438 PaintPage(rRenderContext, m_aLeftPagePrtArea);
1439 PaintPage(rRenderContext, m_aRightPagePrtArea);
1441 tools::Rectangle aLeftMark(Point(m_aPage.Left() + 2, m_aLeftPagePrtArea.Top() + 4), Size(m_aLeftPagePrtArea.Left() - 4, 2));
1442 tools::Rectangle aRightMark(Point(m_aRightPagePrtArea.Right() + 2, m_aRightPagePrtArea.Bottom() - 6), Size(m_aLeftPagePrtArea.Left() - 4, 2));
1444 switch (m_nMarkPos)
1446 case 1: // left
1447 aRightMark.SetPos(Point(m_aRightPagePrtArea.Left() - 2 - aRightMark.GetWidth(), aRightMark.Top()));
1448 break;
1450 case 2: // right
1451 aLeftMark.SetPos(Point(m_aLeftPagePrtArea.Right() + 2, aLeftMark.Top()));
1452 break;
1454 case 3: // outside
1455 break;
1457 case 4: // inside
1458 aLeftMark.SetPos(Point(m_aLeftPagePrtArea.Right() + 2, aLeftMark.Top()));
1459 aRightMark.SetPos(Point(m_aRightPagePrtArea.Left() - 2 - aRightMark.GetWidth(), aRightMark.Top()));
1460 break;
1462 case 0: // none
1463 default:
1464 return;
1466 drawRect(rRenderContext, aLeftMark, m_aMarkCol, m_aTransCol);
1467 drawRect(rRenderContext, aRightMark, m_aMarkCol, m_aTransCol);
1470 void SwMarkPreview::PaintPage(vcl::RenderContext& rRenderContext, const tools::Rectangle &rRect)
1472 // draw PrintArea
1473 drawRect(rRenderContext, rRect, m_aTransCol, m_aPrintAreaCol);
1475 // draw Testparagraph
1477 tools::Rectangle aTextLine = rRect;
1478 aTextLine.SetSize(Size(aTextLine.GetWidth(), 2));
1479 aTextLine.AdjustLeft(4 );
1480 aTextLine.AdjustRight( -4 );
1481 aTextLine.Move(0, 4);
1483 const tools::Long nStep = aTextLine.GetHeight() + 2;
1484 const tools::Long nLines = rRect.GetHeight() / (aTextLine.GetHeight() + 2) - 1;
1486 // simulate text
1487 for (tools::Long i = 0; i < nLines; ++i)
1489 if (i == (nLines - 1))
1490 aTextLine.SetSize(Size(aTextLine.GetWidth() / 2, aTextLine.GetHeight()));
1492 if (m_aPage.Contains(aTextLine))
1493 drawRect(rRenderContext, aTextLine, m_aTextCol, m_aTransCol);
1495 aTextLine.Move(0, nStep);
1497 aTextLine.Move(0, -nStep);
1500 void SwMarkPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea)
1502 Size aInitialSize = getPreviewOptionsSize(pDrawingArea->get_ref_device());
1503 pDrawingArea->set_size_request(aInitialSize.Width(), aInitialSize.Height());
1504 weld::CustomWidgetController::SetDrawingArea(pDrawingArea);
1505 SetOutputSizePixel(aInitialSize);
1508 namespace
1510 void lcl_FillRedlineAttrListBox(
1511 weld::ComboBox& rLB, const AuthorCharAttr& rAttrToSelect,
1512 const sal_uInt16* pAttrMap, const size_t nAttrMapSize)
1514 for (size_t i = 0; i != nAttrMapSize; ++i)
1516 CharAttr const & rAttr(aRedlineAttr[pAttrMap[i]]);
1517 rLB.set_id(i, weld::toId(&rAttr));
1518 if (rAttr.nItemId == rAttrToSelect.m_nItemId &&
1519 rAttr.nAttr == rAttrToSelect.m_nAttr)
1520 rLB.set_active(i);
1525 SwRedlineOptionsTabPage::SwRedlineOptionsTabPage(weld::Container* pPage, weld::DialogController* pController,
1526 const SfxItemSet& rSet)
1527 : SfxTabPage(pPage, pController, "modules/swriter/ui/optredlinepage.ui", "OptRedLinePage", &rSet)
1528 , m_xInsertLB(m_xBuilder->weld_combo_box("insert"))
1529 , m_xInsertColorLB(new ColorListBox(m_xBuilder->weld_menu_button("insertcolor"),
1530 [this]{ return GetDialogController()->getDialog(); }))
1531 , m_xInsertedPreviewWN(new SvxFontPrevWindow)
1532 , m_xInsertedPreview(new weld::CustomWeld(*m_xBuilder, "insertedpreview", *m_xInsertedPreviewWN))
1533 , m_xDeletedLB(m_xBuilder->weld_combo_box("deleted"))
1534 , m_xDeletedColorLB(new ColorListBox(m_xBuilder->weld_menu_button("deletedcolor"),
1535 [this]{ return GetDialogController()->getDialog(); }))
1536 , m_xDeletedPreviewWN(new SvxFontPrevWindow)
1537 , m_xDeletedPreview(new weld::CustomWeld(*m_xBuilder, "deletedpreview", *m_xDeletedPreviewWN))
1538 , m_xChangedLB(m_xBuilder->weld_combo_box("changed"))
1539 , m_xChangedColorLB(new ColorListBox(m_xBuilder->weld_menu_button("changedcolor"),
1540 [this]{ return GetDialogController()->getDialog(); }))
1541 , m_xChangedPreviewWN(new SvxFontPrevWindow)
1542 , m_xChangedPreview(new weld::CustomWeld(*m_xBuilder, "changedpreview", *m_xChangedPreviewWN))
1543 , m_xMarkPosLB(m_xBuilder->weld_combo_box("markpos"))
1544 , m_xMarkColorLB(new ColorListBox(m_xBuilder->weld_menu_button("markcolor"),
1545 [this]{ return GetDialogController()->getDialog(); }))
1546 , m_xMarkPreviewWN(new SwMarkPreview)
1547 , m_xMarkPreview(new weld::CustomWeld(*m_xBuilder, "markpreview", *m_xMarkPreviewWN))
1549 Size aPreviewSize(getPreviewOptionsSize(m_xMarkPreviewWN->GetDrawingArea()->get_ref_device()));
1551 m_xInsertColorLB->SetSlotId(SID_AUTHOR_COLOR, true);
1552 m_xDeletedColorLB->SetSlotId(SID_AUTHOR_COLOR, true);
1553 m_xChangedColorLB->SetSlotId(SID_AUTHOR_COLOR, true);
1555 m_xInsertedPreviewWN->set_size_request(aPreviewSize.Width(), aPreviewSize.Height());
1556 m_xDeletedPreviewWN->set_size_request(aPreviewSize.Width(), aPreviewSize.Height());
1557 m_xChangedPreviewWN->set_size_request(aPreviewSize.Width(), aPreviewSize.Height());
1558 m_xMarkPreviewWN->set_size_request(aPreviewSize.Width(), aPreviewSize.Height());
1560 for (sal_Int32 i = 0, nEntryCount = m_xInsertLB->get_count(); i < nEntryCount; ++i)
1562 const OUString sEntry(m_xInsertLB->get_text(i));
1563 m_xDeletedLB->append_text(sEntry);
1564 m_xChangedLB->append_text(sEntry);
1567 // remove strikethrough from insert and change and underline + double
1568 // underline from delete
1569 m_xInsertLB->remove(5);
1570 m_xChangedLB->remove(5);
1571 m_xDeletedLB->remove(4);
1572 m_xDeletedLB->remove(3);
1574 Link<weld::ComboBox&,void> aLk = LINK(this, SwRedlineOptionsTabPage, AttribHdl);
1575 m_xInsertLB->connect_changed( aLk );
1576 m_xDeletedLB->connect_changed( aLk );
1577 m_xChangedLB->connect_changed( aLk );
1579 Link<ColorListBox&,void> aLk2 = LINK(this, SwRedlineOptionsTabPage, ColorHdl);
1580 m_xInsertColorLB->SetSelectHdl( aLk2 );
1581 m_xDeletedColorLB->SetSelectHdl( aLk2 );
1582 m_xChangedColorLB->SetSelectHdl( aLk2 );
1584 m_xMarkPosLB->connect_changed(LINK(this, SwRedlineOptionsTabPage, ChangedMaskPrevHdl));
1585 m_xMarkColorLB->SetSelectHdl(LINK(this, SwRedlineOptionsTabPage, ChangedMaskColorPrevHdl));
1588 SwRedlineOptionsTabPage::~SwRedlineOptionsTabPage()
1590 m_xInsertColorLB.reset();
1591 m_xInsertedPreview.reset();
1592 m_xInsertedPreviewWN.reset();
1593 m_xDeletedColorLB.reset();
1594 m_xDeletedPreview.reset();
1595 m_xDeletedPreviewWN.reset();
1596 m_xChangedColorLB.reset();
1597 m_xChangedPreview.reset();
1598 m_xChangedPreviewWN.reset();
1599 m_xMarkColorLB.reset();
1600 m_xMarkPreview.reset();
1601 m_xMarkPreviewWN.reset();
1604 std::unique_ptr<SfxTabPage> SwRedlineOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1606 return std::make_unique<SwRedlineOptionsTabPage>(pPage, pController, *rSet);
1609 bool SwRedlineOptionsTabPage::FillItemSet( SfxItemSet* )
1611 CharAttr *pAttr;
1612 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
1614 AuthorCharAttr aInsertedAttr;
1615 AuthorCharAttr aDeletedAttr;
1616 AuthorCharAttr aChangedAttr;
1618 AuthorCharAttr aOldInsertAttr(pOpt->GetInsertAuthorAttr());
1619 AuthorCharAttr aOldDeletedAttr(pOpt->GetDeletedAuthorAttr());
1620 AuthorCharAttr aOldChangedAttr(pOpt->GetFormatAuthorAttr());
1622 Color nOldMarkColor = pOpt->GetMarkAlignColor();
1623 sal_uInt16 nOldMarkMode = pOpt->GetMarkAlignMode();
1625 sal_Int32 nPos = m_xInsertLB->get_active();
1626 if (nPos != -1)
1628 pAttr = weld::fromId<CharAttr*>(m_xInsertLB->get_id(nPos));
1629 aInsertedAttr.m_nItemId = pAttr->nItemId;
1630 aInsertedAttr.m_nAttr = pAttr->nAttr;
1631 aInsertedAttr.m_nColor = m_xInsertColorLB->GetSelectEntryColor();
1632 pOpt->SetInsertAuthorAttr(aInsertedAttr);
1635 nPos = m_xDeletedLB->get_active();
1636 if (nPos != -1)
1638 pAttr = weld::fromId<CharAttr*>(m_xDeletedLB->get_id(nPos));
1639 aDeletedAttr.m_nItemId = pAttr->nItemId;
1640 aDeletedAttr.m_nAttr = pAttr->nAttr;
1641 aDeletedAttr.m_nColor = m_xDeletedColorLB->GetSelectEntryColor();
1642 pOpt->SetDeletedAuthorAttr(aDeletedAttr);
1645 nPos = m_xChangedLB->get_active();
1646 if (nPos != -1)
1648 pAttr = weld::fromId<CharAttr*>(m_xChangedLB->get_id(nPos));
1649 aChangedAttr.m_nItemId = pAttr->nItemId;
1650 aChangedAttr.m_nAttr = pAttr->nAttr;
1651 aChangedAttr.m_nColor = m_xChangedColorLB->GetSelectEntryColor();
1652 pOpt->SetFormatAuthorAttr(aChangedAttr);
1655 nPos = 0;
1656 switch (m_xMarkPosLB->get_active())
1658 case 0: nPos = text::HoriOrientation::NONE; break;
1659 case 1: nPos = text::HoriOrientation::LEFT; break;
1660 case 2: nPos = text::HoriOrientation::RIGHT; break;
1661 case 3: nPos = text::HoriOrientation::OUTSIDE; break;
1662 case 4: nPos = text::HoriOrientation::INSIDE; break;
1664 pOpt->SetMarkAlignMode(nPos);
1665 pOpt->SetMarkAlignColor(m_xMarkColorLB->GetSelectEntryColor());
1667 if (!(aInsertedAttr == aOldInsertAttr) ||
1668 !(aDeletedAttr == aOldDeletedAttr) ||
1669 !(aChangedAttr == aOldChangedAttr) ||
1670 nOldMarkColor != pOpt->GetMarkAlignColor() ||
1671 nOldMarkMode != pOpt->GetMarkAlignMode() )
1673 // update all documents
1674 SwDocShell* pDocShell = static_cast<SwDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<SwDocShell>));
1676 while( pDocShell )
1678 pDocShell->GetWrtShell()->UpdateRedlineAttr();
1679 pDocShell = static_cast<SwDocShell*>(SfxObjectShell::GetNext(*pDocShell, checkSfxObjectShell<SwDocShell>));
1683 return false;
1686 void SwRedlineOptionsTabPage::Reset( const SfxItemSet* )
1688 const SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
1690 const AuthorCharAttr &rInsertAttr = pOpt->GetInsertAuthorAttr();
1691 const AuthorCharAttr &rDeletedAttr = pOpt->GetDeletedAuthorAttr();
1692 const AuthorCharAttr &rChangedAttr = pOpt->GetFormatAuthorAttr();
1694 // initialise preview
1695 InitFontStyle(*m_xInsertedPreviewWN, SwResId(STR_OPT_PREVIEW_INSERTED));
1696 InitFontStyle(*m_xDeletedPreviewWN, SwResId(STR_OPT_PREVIEW_DELETED));
1697 InitFontStyle(*m_xChangedPreviewWN, SwResId(STR_OPT_PREVIEW_CHANGED));
1699 Color nColor = rInsertAttr.m_nColor;
1700 m_xInsertColorLB->SelectEntry(nColor);
1702 nColor = rDeletedAttr.m_nColor;
1703 m_xDeletedColorLB->SelectEntry(nColor);
1705 nColor = rChangedAttr.m_nColor;
1706 m_xChangedColorLB->SelectEntry(nColor);
1708 m_xMarkColorLB->SelectEntry(pOpt->GetMarkAlignColor());
1710 m_xInsertLB->set_active(0);
1711 m_xDeletedLB->set_active(0);
1712 m_xChangedLB->set_active(0);
1714 lcl_FillRedlineAttrListBox(*m_xInsertLB, rInsertAttr, aInsertAttrMap, SAL_N_ELEMENTS(aInsertAttrMap));
1715 lcl_FillRedlineAttrListBox(*m_xDeletedLB, rDeletedAttr, aDeletedAttrMap, SAL_N_ELEMENTS(aDeletedAttrMap));
1716 lcl_FillRedlineAttrListBox(*m_xChangedLB, rChangedAttr, aChangedAttrMap, SAL_N_ELEMENTS(aChangedAttrMap));
1718 sal_Int32 nPos = 0;
1719 switch (pOpt->GetMarkAlignMode())
1721 case text::HoriOrientation::NONE: nPos = 0; break;
1722 case text::HoriOrientation::LEFT: nPos = 1; break;
1723 case text::HoriOrientation::RIGHT: nPos = 2; break;
1724 case text::HoriOrientation::OUTSIDE: nPos = 3; break;
1725 case text::HoriOrientation::INSIDE: nPos = 4; break;
1727 m_xMarkPosLB->set_active(nPos);
1729 // show settings in preview
1730 AttribHdl(*m_xInsertLB);
1731 ColorHdl(*m_xInsertColorLB);
1732 AttribHdl(*m_xDeletedLB);
1733 ColorHdl(*m_xInsertColorLB);
1734 AttribHdl(*m_xChangedLB);
1735 ColorHdl(*m_xChangedColorLB);
1737 ChangedMaskPrev();
1740 IMPL_LINK( SwRedlineOptionsTabPage, AttribHdl, weld::ComboBox&, rLB, void )
1742 SvxFontPrevWindow *pPrev = nullptr;
1743 ColorListBox *pColorLB;
1745 if (&rLB == m_xInsertLB.get())
1747 pColorLB = m_xInsertColorLB.get();
1748 pPrev = m_xInsertedPreviewWN.get();
1750 else if (&rLB == m_xDeletedLB.get())
1752 pColorLB = m_xDeletedColorLB.get();
1753 pPrev = m_xDeletedPreviewWN.get();
1755 else
1757 pColorLB = m_xChangedColorLB.get();
1758 pPrev = m_xChangedPreviewWN.get();
1761 SvxFont& rFont = pPrev->GetFont();
1762 SvxFont& rCJKFont = pPrev->GetCJKFont();
1764 rFont.SetWeight(WEIGHT_NORMAL);
1765 rCJKFont.SetWeight(WEIGHT_NORMAL);
1766 rFont.SetItalic(ITALIC_NONE);
1767 rCJKFont.SetItalic(ITALIC_NONE);
1768 rFont.SetUnderline(LINESTYLE_NONE);
1769 rCJKFont.SetUnderline(LINESTYLE_NONE);
1770 rFont.SetStrikeout(STRIKEOUT_NONE);
1771 rCJKFont.SetStrikeout(STRIKEOUT_NONE);
1772 rFont.SetCaseMap(SvxCaseMap::NotMapped);
1773 rCJKFont.SetCaseMap(SvxCaseMap::NotMapped);
1775 Color aColor = pColorLB->GetSelectEntryColor();
1777 if (aColor == COL_NONE_COLOR)
1779 rFont.SetColor( COL_BLACK );
1780 rCJKFont.SetColor( COL_BLACK );
1782 else if (aColor == COL_TRANSPARENT)
1784 rFont.SetColor( COL_RED );
1785 rCJKFont.SetColor( COL_RED );
1787 else
1789 rFont.SetColor(aColor);
1790 rCJKFont.SetColor(aColor);
1793 sal_Int32 nPos = rLB.get_active();
1794 if( nPos == -1)
1795 nPos = 0;
1797 CharAttr* pAttr = weld::fromId<CharAttr*>(rLB.get_id(nPos));
1798 //switch off preview background color
1799 pPrev->ResetColor();
1800 switch (pAttr->nItemId)
1802 case SID_ATTR_CHAR_WEIGHT:
1803 rFont.SetWeight( static_cast<FontWeight>(pAttr->nAttr) );
1804 rCJKFont.SetWeight( static_cast<FontWeight>(pAttr->nAttr) );
1805 break;
1807 case SID_ATTR_CHAR_POSTURE:
1808 rFont.SetItalic( static_cast<FontItalic>(pAttr->nAttr) );
1809 rCJKFont.SetItalic( static_cast<FontItalic>(pAttr->nAttr) );
1810 break;
1812 case SID_ATTR_CHAR_UNDERLINE:
1813 rFont.SetUnderline( static_cast<FontLineStyle>(pAttr->nAttr) );
1814 rCJKFont.SetUnderline( static_cast<FontLineStyle>(pAttr->nAttr) );
1815 break;
1817 case SID_ATTR_CHAR_STRIKEOUT:
1818 rFont.SetStrikeout( static_cast<FontStrikeout>(pAttr->nAttr) );
1819 rCJKFont.SetStrikeout( static_cast<FontStrikeout>(pAttr->nAttr) );
1820 break;
1822 case SID_ATTR_CHAR_CASEMAP:
1823 rFont.SetCaseMap( static_cast<SvxCaseMap>(pAttr->nAttr) );
1824 rCJKFont.SetCaseMap( static_cast<SvxCaseMap>(pAttr->nAttr) );
1825 break;
1827 case SID_ATTR_BRUSH:
1829 Color aBgColor = pColorLB->GetSelectEntryColor();
1830 if (aBgColor != COL_NONE_COLOR)
1831 pPrev->SetColor(aBgColor);
1832 else
1833 pPrev->SetColor(COL_LIGHTGRAY);
1834 rFont.SetColor( COL_BLACK );
1835 rCJKFont.SetColor( COL_BLACK );
1837 break;
1840 pPrev->Invalidate();
1843 IMPL_LINK(SwRedlineOptionsTabPage, ColorHdl, ColorListBox&, rListBox, void)
1845 ColorListBox* pColorLB = &rListBox;
1846 SvxFontPrevWindow *pPrev = nullptr;
1847 weld::ComboBox* pLB;
1849 if (pColorLB == m_xInsertColorLB.get())
1851 pLB = m_xInsertLB.get();
1852 pPrev = m_xInsertedPreviewWN.get();
1854 else if (pColorLB == m_xDeletedColorLB.get())
1856 pLB = m_xDeletedLB.get();
1857 pPrev = m_xDeletedPreviewWN.get();
1859 else
1861 pLB = m_xChangedLB.get();
1862 pPrev = m_xChangedPreviewWN.get();
1865 SvxFont& rFont = pPrev->GetFont();
1866 SvxFont& rCJKFont = pPrev->GetCJKFont();
1867 sal_Int32 nPos = pLB->get_active();
1868 if( nPos == -1)
1869 nPos = 0;
1871 CharAttr* pAttr = weld::fromId<CharAttr*>(pLB->get_id(nPos));
1873 if( pAttr->nItemId == SID_ATTR_BRUSH )
1875 rFont.SetColor( COL_BLACK );
1876 rCJKFont.SetColor( COL_BLACK );
1878 Color aBgColor = pColorLB->GetSelectEntryColor();
1879 if (aBgColor != COL_NONE_COLOR)
1880 pPrev->SetColor(aBgColor);
1881 else
1882 pPrev->SetColor(COL_LIGHTGRAY);
1884 else
1886 Color aColor = pColorLB->GetSelectEntryColor();
1888 if (aColor == COL_NONE_COLOR)
1890 rFont.SetColor( COL_BLACK );
1891 rCJKFont.SetColor( COL_BLACK );
1893 else if (aColor == COL_TRANSPARENT)
1895 rFont.SetColor( COL_RED );
1896 rCJKFont.SetColor( COL_RED );
1898 else
1900 rFont.SetColor(aColor);
1901 rCJKFont.SetColor(aColor);
1905 pPrev->Invalidate();
1908 void SwRedlineOptionsTabPage::ChangedMaskPrev()
1910 m_xMarkPreviewWN->SetMarkPos(m_xMarkPosLB->get_active());
1911 m_xMarkPreviewWN->SetColor(m_xMarkColorLB->GetSelectEntryColor());
1913 m_xMarkPreviewWN->Invalidate();
1916 IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskPrevHdl, weld::ComboBox&, void)
1918 ChangedMaskPrev();
1921 IMPL_LINK_NOARG(SwRedlineOptionsTabPage, ChangedMaskColorPrevHdl, ColorListBox&, void)
1923 ChangedMaskPrev();
1926 void SwRedlineOptionsTabPage::InitFontStyle(SvxFontPrevWindow& rExampleWin, const OUString& rText)
1928 const AllSettings& rAllSettings = Application::GetSettings();
1929 LanguageType eLangType = rAllSettings.GetUILanguageTag().getLanguageType();
1930 Color aBackCol( rAllSettings.GetStyleSettings().GetWindowColor() );
1931 SvxFont& rFont = rExampleWin.GetFont();
1932 SvxFont& rCJKFont = rExampleWin.GetCJKFont();
1933 SvxFont& rCTLFont = rExampleWin.GetCTLFont();
1935 OutputDevice& rDevice = rExampleWin.GetDrawingArea()->get_ref_device();
1937 vcl::Font aFont( OutputDevice::GetDefaultFont( DefaultFontType::SERIF, eLangType,
1938 GetDefaultFontFlags::OnlyOne, &rDevice ) );
1939 vcl::Font aCJKFont( OutputDevice::GetDefaultFont( DefaultFontType::CJK_TEXT, eLangType,
1940 GetDefaultFontFlags::OnlyOne, &rDevice ) );
1941 vcl::Font aCTLFont( OutputDevice::GetDefaultFont( DefaultFontType::CTL_TEXT, eLangType,
1942 GetDefaultFontFlags::OnlyOne, &rDevice ) );
1943 const Size aDefSize( 0, 12 );
1944 aFont.SetFontSize( aDefSize );
1945 aCJKFont.SetFontSize( aDefSize );
1946 aCTLFont.SetFontSize( aDefSize );
1948 aFont.SetFillColor( aBackCol );
1949 aCJKFont.SetFillColor( aBackCol );
1950 aCTLFont.SetFillColor( aBackCol );
1952 aFont.SetWeight( WEIGHT_NORMAL );
1953 aCJKFont.SetWeight( WEIGHT_NORMAL );
1954 aCTLFont.SetWeight( WEIGHT_NORMAL );
1956 rFont = aFont;
1957 rCJKFont = aCJKFont;
1958 rCTLFont = aCTLFont;
1960 const Size aNewSize( 0, rExampleWin.GetOutputSizePixel().Height() * 2 / 3 );
1961 rFont.SetFontSize( aNewSize );
1962 rCJKFont.SetFontSize( aNewSize );
1964 rExampleWin.SetFont( rFont, rCJKFont,rCTLFont );
1965 rExampleWin.SetPreviewText(rText);
1968 SwCompareOptionsTabPage::SwCompareOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
1969 : SfxTabPage(pPage, pController, "modules/swriter/ui/optcomparison.ui", "OptComparison", &rSet)
1970 , m_xAutoRB(m_xBuilder->weld_radio_button("auto"))
1971 , m_xWordRB(m_xBuilder->weld_radio_button("byword"))
1972 , m_xCharRB(m_xBuilder->weld_radio_button("bycharacter"))
1973 , m_xRsidCB(m_xBuilder->weld_check_button("useRSID"))
1974 , m_xIgnoreCB(m_xBuilder->weld_check_button("ignore"))
1975 , m_xLenNF(m_xBuilder->weld_spin_button("ignorelen"))
1976 , m_xStoreRsidCB(m_xBuilder->weld_check_button("storeRSID"))
1978 Link<weld::Toggleable&,void> aLnk( LINK( this, SwCompareOptionsTabPage, ComparisonHdl ) );
1979 m_xAutoRB->connect_toggled( aLnk );
1980 m_xWordRB->connect_toggled( aLnk );
1981 m_xCharRB->connect_toggled( aLnk );
1983 m_xIgnoreCB->connect_toggled( LINK( this, SwCompareOptionsTabPage, IgnoreHdl) );
1986 SwCompareOptionsTabPage::~SwCompareOptionsTabPage()
1990 std::unique_ptr<SfxTabPage> SwCompareOptionsTabPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrSet )
1992 return std::make_unique<SwCompareOptionsTabPage>(pPage, pController, *rAttrSet);
1995 bool SwCompareOptionsTabPage::FillItemSet( SfxItemSet* )
1997 bool bRet = false;
1998 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
2000 if( m_xAutoRB->get_state_changed_from_saved() ||
2001 m_xWordRB->get_state_changed_from_saved() ||
2002 m_xCharRB->get_state_changed_from_saved() )
2004 SwCompareMode eCmpMode = SwCompareMode::Auto;
2006 if ( m_xAutoRB->get_active() ) eCmpMode = SwCompareMode::Auto;
2007 if ( m_xWordRB->get_active() ) eCmpMode = SwCompareMode::ByWord;
2008 if ( m_xCharRB->get_active() ) eCmpMode = SwCompareMode::ByChar;
2010 pOpt->SetCompareMode( eCmpMode );
2011 bRet = true;
2014 if( m_xRsidCB->get_state_changed_from_saved() )
2016 pOpt->SetUseRsid( m_xRsidCB->get_active() );
2017 bRet = true;
2020 if( m_xIgnoreCB->get_state_changed_from_saved() )
2022 pOpt->SetIgnorePieces( m_xIgnoreCB->get_active() );
2023 bRet = true;
2026 if( m_xLenNF->get_value_changed_from_saved() )
2028 pOpt->SetPieceLen( m_xLenNF->get_value() );
2029 bRet = true;
2032 if (m_xStoreRsidCB->get_state_changed_from_saved())
2034 pOpt->SetStoreRsid(m_xStoreRsidCB->get_active());
2035 bRet = true;
2038 return bRet;
2041 void SwCompareOptionsTabPage::Reset( const SfxItemSet* )
2043 SwModuleOptions *pOpt = SW_MOD()->GetModuleConfig();
2045 SwCompareMode eCmpMode = pOpt->GetCompareMode();
2046 if( eCmpMode == SwCompareMode::Auto )
2048 m_xAutoRB->set_active(true);
2049 m_xRsidCB->set_sensitive(false);
2050 m_xIgnoreCB->set_sensitive(false);
2051 m_xLenNF->set_sensitive(false);
2053 else if( eCmpMode == SwCompareMode::ByWord )
2055 m_xWordRB->set_active(true);
2056 m_xRsidCB->set_sensitive(true);
2057 m_xIgnoreCB->set_sensitive(true);
2058 m_xLenNF->set_sensitive(true);
2060 else if( eCmpMode == SwCompareMode::ByChar)
2062 m_xCharRB->set_active(true);
2063 m_xRsidCB->set_sensitive(true);
2064 m_xIgnoreCB->set_sensitive(true);
2065 m_xLenNF->set_sensitive(true);
2067 m_xAutoRB->save_state();
2068 m_xWordRB->save_state();
2069 m_xCharRB->save_state();
2071 m_xRsidCB->set_active( pOpt->IsUseRsid() );
2072 m_xRsidCB->save_state();
2074 m_xIgnoreCB->set_active( pOpt->IsIgnorePieces() );
2075 m_xIgnoreCB->save_state();
2077 m_xLenNF->set_sensitive( m_xIgnoreCB->get_active() && eCmpMode != SwCompareMode::Auto );
2079 m_xLenNF->set_value( pOpt->GetPieceLen() );
2080 m_xLenNF->save_value();
2082 m_xStoreRsidCB->set_active(pOpt->IsStoreRsid());
2083 m_xStoreRsidCB->save_state();
2086 IMPL_LINK(SwCompareOptionsTabPage, ComparisonHdl, weld::Toggleable&, rButton, void)
2088 if (!rButton.get_active())
2089 return;
2091 bool bChecked = !m_xAutoRB->get_active();
2092 m_xRsidCB->set_sensitive( bChecked );
2093 m_xIgnoreCB->set_sensitive( bChecked );
2094 m_xLenNF->set_sensitive( bChecked && m_xIgnoreCB->get_active() );
2097 IMPL_LINK_NOARG(SwCompareOptionsTabPage, IgnoreHdl, weld::Toggleable&, void)
2099 m_xLenNF->set_sensitive(m_xIgnoreCB->get_active());
2102 #ifdef DBG_UTIL
2104 SwTestTabPage::SwTestTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rCoreSet)
2105 : SfxTabPage(pPage, pController, "modules/swriter/ui/opttestpage.ui", "OptTestPage", &rCoreSet)
2106 , m_bAttrModified( false )
2107 , m_xTest1CBox(m_xBuilder->weld_check_button("unused"))
2108 , m_xTest2CBox(m_xBuilder->weld_check_button("dynamic"))
2109 , m_xTest3CBox(m_xBuilder->weld_check_button("nocalm"))
2110 , m_xTest4CBox(m_xBuilder->weld_check_button("wysiwygdbg"))
2111 , m_xTest5CBox(m_xBuilder->weld_check_button("noidle"))
2112 , m_xTest6CBox(m_xBuilder->weld_check_button("noscreenadj"))
2113 , m_xTest7CBox(m_xBuilder->weld_check_button("winformat"))
2114 , m_xTest8CBox(m_xBuilder->weld_check_button("noscroll"))
2115 , m_xTest9CBox(m_xBuilder->weld_check_button("DrawingLayerNotLoading"))
2116 , m_xTest10CBox(m_xBuilder->weld_check_button("AutoFormatByInput"))
2118 Init();
2121 SwTestTabPage::~SwTestTabPage()
2125 std::unique_ptr<SfxTabPage> SwTestTabPage::Create( weld::Container* pPage, weld::DialogController* pController,
2126 const SfxItemSet* rAttrSet )
2128 return std::make_unique<SwTestTabPage>(pPage, pController, *rAttrSet);
2131 bool SwTestTabPage::FillItemSet( SfxItemSet* rCoreSet )
2134 if ( m_bAttrModified )
2136 SwTestItem aTestItem;
2137 aTestItem.m_bTest1=m_xTest1CBox->get_active();
2138 aTestItem.m_bTest2=m_xTest2CBox->get_active();
2139 aTestItem.m_bTest3=m_xTest3CBox->get_active();
2140 aTestItem.m_bTest4=m_xTest4CBox->get_active();
2141 aTestItem.m_bTest5=m_xTest5CBox->get_active();
2142 aTestItem.m_bTest6=m_xTest6CBox->get_active();
2143 aTestItem.m_bTest7=m_xTest7CBox->get_active();
2144 aTestItem.m_bTest8=m_xTest8CBox->get_active();
2145 aTestItem.m_bTest9=m_xTest9CBox->get_active();
2146 aTestItem.m_bTest10=m_xTest10CBox->get_active();
2147 rCoreSet->Put(aTestItem);
2149 return m_bAttrModified;
2152 void SwTestTabPage::Reset( const SfxItemSet* )
2154 const SfxItemSet& rSet = GetItemSet();
2155 const SwTestItem* pTestAttr = rSet.GetItemIfSet( FN_PARAM_SWTEST, false );
2156 if(!pTestAttr)
2157 return;
2159 m_xTest1CBox->set_active(pTestAttr->m_bTest1);
2160 m_xTest2CBox->set_active(pTestAttr->m_bTest2);
2161 m_xTest3CBox->set_active(pTestAttr->m_bTest3);
2162 m_xTest4CBox->set_active(pTestAttr->m_bTest4);
2163 m_xTest5CBox->set_active(pTestAttr->m_bTest5);
2164 m_xTest6CBox->set_active(pTestAttr->m_bTest6);
2165 m_xTest7CBox->set_active(pTestAttr->m_bTest7);
2166 m_xTest8CBox->set_active(pTestAttr->m_bTest8);
2167 m_xTest9CBox->set_active(pTestAttr->m_bTest9);
2168 m_xTest10CBox->set_active(pTestAttr->m_bTest10);
2171 void SwTestTabPage::Init()
2173 // handler
2174 Link<weld::Toggleable&,void> aLk = LINK( this, SwTestTabPage, AutoClickHdl );
2175 m_xTest1CBox->connect_toggled( aLk );
2176 m_xTest2CBox->connect_toggled( aLk );
2177 m_xTest3CBox->connect_toggled( aLk );
2178 m_xTest4CBox->connect_toggled( aLk );
2179 m_xTest5CBox->connect_toggled( aLk );
2180 m_xTest6CBox->connect_toggled( aLk );
2181 m_xTest7CBox->connect_toggled( aLk );
2182 m_xTest8CBox->connect_toggled( aLk );
2183 m_xTest9CBox->connect_toggled( aLk );
2184 m_xTest10CBox->connect_toggled( aLk );
2187 IMPL_LINK_NOARG(SwTestTabPage, AutoClickHdl, weld::Toggleable&, void)
2189 m_bAttrModified = true;
2192 #endif
2194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */