LibreOffice Module cui (master)  1
chardlg.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 <vcl/svapp.hxx>
21 #include <vcl/idle.hxx>
22 #include <svtools/ctrltool.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <svx/svxids.hrc>
25 #include <svtools/unitconv.hxx>
26 #include <svl/cjkoptions.hxx>
27 #include <svl/ctloptions.hxx>
28 #include <chardlg.hxx>
29 #include <editeng/fontitem.hxx>
30 #include <editeng/postitem.hxx>
31 #include <editeng/udlnitem.hxx>
33 #include <editeng/contouritem.hxx>
34 #include <editeng/langitem.hxx>
35 #include <editeng/wghtitem.hxx>
36 #include <editeng/fhgtitem.hxx>
37 #include <editeng/shdditem.hxx>
39 #include <editeng/wrlmitem.hxx>
40 #include <editeng/cmapitem.hxx>
41 #include <editeng/kernitem.hxx>
42 #include <editeng/flstitem.hxx>
43 #include <editeng/autokernitem.hxx>
44 #include <editeng/colritem.hxx>
45 #include <dialmgr.hxx>
46 #include <sfx2/htmlmode.hxx>
47 #include <cui/cuicharmap.hxx>
48 #include "chardlg.h"
51 #include <editeng/twolinesitem.hxx>
55 #include <officecfg/Office/Common.hxx>
56 #include <strings.hrc>
57 #include <twolines.hrc>
58 #include <svl/intitem.hxx>
59 #include <svx/flagsdef.hxx>
60 #include <FontFeatures.hxx>
61 #include <FontFeaturesDialog.hxx>
62 #include <sal/log.hxx>
63 #include <osl/diagnose.h>
64 #include <o3tl/unit_conversion.hxx>
65 #include <o3tl/string_view.hxx>
66 
67 using namespace ::com::sun::star;
68 
69 // static ----------------------------------------------------------------
70 
72  SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_WEIGHT,
73  SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_FONTHEIGHT,
74  SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
75  SID_ATTR_CHAR_LANGUAGE, SID_ATTR_CHAR_LANGUAGE,
76  SID_ATTR_CHAR_CJK_FONT, SID_ATTR_CHAR_CJK_WEIGHT,
77  SID_ATTR_CHAR_CTL_FONT, SID_ATTR_CHAR_CTL_WEIGHT
78 >);
79 
81  SID_ATTR_CHAR_SHADOWED, SID_ATTR_CHAR_UNDERLINE,
82  SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
83  SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_CASEMAP,
84  SID_ATTR_FLASH, SID_ATTR_FLASH,
85  SID_ATTR_CHAR_EMPHASISMARK, SID_ATTR_CHAR_EMPHASISMARK,
86  SID_ATTR_CHAR_RELIEF, SID_ATTR_CHAR_RELIEF,
87  SID_ATTR_CHAR_HIDDEN, SID_ATTR_CHAR_HIDDEN,
88  SID_ATTR_CHAR_OVERLINE, SID_ATTR_CHAR_OVERLINE
89 >);
90 
92  SID_ATTR_CHAR_KERNING, SID_ATTR_CHAR_KERNING,
93  SID_ATTR_CHAR_ESCAPEMENT, SID_ATTR_CHAR_ESCAPEMENT,
94  SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_AUTOKERN,
95  SID_ATTR_CHAR_ROTATED, SID_ATTR_CHAR_SCALEWIDTH,
96  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
97 >);
98 
100  SID_ATTR_CHAR_TWO_LINES, SID_ATTR_CHAR_TWO_LINES
101 >);
102 
103 // C-Function ------------------------------------------------------------
104 
105 static bool StateToAttr( TriState aState )
106 {
107  return ( TRISTATE_TRUE == aState );
108 }
109 
110 namespace
111 {
112  void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
113  {
114  _rFont.SetPropr( nProp );
115  _rFont.SetProprRel( nEscProp );
116  _rFont.SetEscapement( nEsc );
117  }
118 }
119 
121 {
122  return m_aPreviewWin.GetFont();
123 }
124 
126 {
127  return m_aPreviewWin.GetCJKFont();
128 }
129 
131 {
132  return m_aPreviewWin.GetCTLFont();
133 }
134 
135 SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemset)
136  : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rItemset)
137  , m_bPreviewBackgroundToCharacter( false )
138 {
139 }
140 
142 {
143 }
144 
146 {
148 }
149 
151 {
152  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
153  if (rSet.GetItemState(nWhich)>=SfxItemState::DEFAULT)
154  {
155  const SvxCharScaleWidthItem &rItem = static_cast<const SvxCharScaleWidthItem&>( rSet.Get( nWhich ) );
156  m_aPreviewWin.SetFontWidthScale(rItem.GetValue());
157  }
158 }
159 
160 void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
161 {
162  setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc);
163  setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc);
164  setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc);
165  m_aPreviewWin.Invalidate();
166 }
167 
168 
169 // SvxCharNamePage_Impl --------------------------------------------------
170 
172 {
173  Idle m_aUpdateIdle { "cui SvxCharNamePage_Impl m_aUpdateIdle" };
174  OUString m_aNoStyleText;
175  std::unique_ptr<FontList> m_pFontList;
178 
180  : m_nExtraEntryPos(std::numeric_limits<int>::max())
181  , m_bInSearchMode(false)
182 
183  {
184  m_aUpdateIdle.SetPriority( TaskPriority::LOWEST );
185  }
186 };
187 
188 // class SvxCharNamePage -------------------------------------------------
189 
191  : SvxCharBasePage(pPage, pController, "cui/ui/charnamepage.ui", "CharNamePage", rInSet)
193  // Western
194  , m_xWestern(m_xBuilder->weld_notebook("nbWestern"))
195  , m_xWestFontNameFT(m_xBuilder->weld_label("lbWestFontname"))
196  , m_xWestFontStyleFT(m_xBuilder->weld_label("lbWestStyle"))
197  , m_xWestFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbWestStyle")))
198  , m_xWestFontSizeFT(m_xBuilder->weld_label("lbWestSize"))
199  , m_xWestFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbWestSize")))
200  , m_xWestFontLanguageFT(m_xBuilder->weld_label("lbWestLanguage"))
201  , m_xWestFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbWestLanguage")))
202  , m_xWestFontFeaturesButton(m_xBuilder->weld_button("btnWestFeatures"))
203  , m_xWestFontTypeFT(m_xBuilder->weld_label("lbWestFontinfo"))
204  , m_xCJK_CTL(m_xBuilder->weld_notebook("nbCJKCTL"))
205  // CJK
206  , m_xEastFontNameFT(m_xBuilder->weld_label("lbCJKFontname"))
207  , m_xEastFontStyleFT(m_xBuilder->weld_label("lbCJKStyle"))
208  , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCJKStyle")))
209  , m_xEastFontSizeFT(m_xBuilder->weld_label("lbCJKSize"))
210  , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCJKSize")))
211  , m_xEastFontLanguageFT(m_xBuilder->weld_label("lbCJKLanguage"))
212  , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCJKLanguage")))
213  , m_xEastFontFeaturesButton(m_xBuilder->weld_button("btnCJKFeatures"))
214  , m_xEastFontTypeFT(m_xBuilder->weld_label("lbCJKFontinfo"))
215  // CTL
216  , m_xCTLFontNameFT(m_xBuilder->weld_label("lbCTLFontname"))
217  // tree
218  , m_xCTLFontStyleFT(m_xBuilder->weld_label("lbCTLStyle"))
219  , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("cbCTLStyle")))
220  , m_xCTLFontSizeFT(m_xBuilder->weld_label("lbCTLSize"))
221  , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("cbCTLSize")))
222  , m_xCTLFontLanguageFT(m_xBuilder->weld_label("lbCTLLanguage"))
223  , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("cbCTLLanguage")))
224  , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("btnCTLFeatures"))
225  , m_xCTLFontTypeFT(m_xBuilder->weld_label("lbCTLFontinfo"))
226 
227  , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT)
228 {
229  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
230 #ifdef IOS
231  m_xPreviewWin->hide();
232 #endif
233  m_pImpl->m_aNoStyleText = CuiResId( RID_CUISTR_CHARNAME_NOSTYLE );
234 
235  std::unique_ptr<weld::EntryTreeView> xWestFontName = m_xBuilder->weld_entry_tree_view("gdWestern", "edWestFontName", "trWestFontName");
236  std::unique_ptr<weld::EntryTreeView> xCJKFontName = m_xBuilder->weld_entry_tree_view("gdCJK", "edCJKFontName", "trCJKFontName");
237  std::unique_ptr<weld::EntryTreeView> xCTLFontName = m_xBuilder->weld_entry_tree_view("gdCTL", "edCTLFontName", "trCTLFontName");
238 
239  // 7 lines in the treeview
240  xWestFontName->set_height_request_by_rows(7);
241  xCJKFontName->set_height_request_by_rows(7);
242  xCTLFontName->set_height_request_by_rows(7);
243 
244  m_xWestFontNameLB = std::move(xWestFontName);
245  m_xEastFontNameLB = std::move(xCJKFontName);
246  m_xCTLFontNameLB = std::move(xCTLFontName);
247 
248  SvtCTLOptions aCTLLanguageOptions;
249  bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled();
250  bool bShowCTL = aCTLLanguageOptions.IsCTLFontEnabled();
251  bool bShowNonWestern = bShowCJK || bShowCTL;
252  if (!bShowNonWestern)
253  {
254  m_xCJK_CTL->hide();
255  m_xWestern->set_show_tabs(false); //hide single tab in case of Western only
256  }
257  else if (!bShowCJK) m_xCJK_CTL->remove_page("nbCJK");
258  else if (!bShowCTL) m_xCJK_CTL->remove_page("nbCTL");
259 
260 
261  //In MacOSX the standard dialogs name font-name, font-style as
262  //Family, Typeface
263  //In GNOME the standard dialogs name font-name, font-style as
264  //Family, Style
265  //In Windows the standard dialogs name font-name, font-style as
266  //Font, Style
267 #ifdef _WIN32
268  OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FONT));
269 #else
270  OUString sFontFamilyString(CuiResId(RID_CUISTR_CHARNAME_FAMILY));
271 #endif
272  m_xWestFontNameFT->set_label(sFontFamilyString);
273  m_xCTLFontNameFT->set_label(sFontFamilyString);
274  m_xEastFontNameFT->set_label(sFontFamilyString);
275 
276 #ifdef MACOSX
277  OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_TYPEFACE));
278 #else
279  OUString sFontStyleString(CuiResId(RID_CUISTR_CHARNAME_STYLE));
280 #endif
281  m_xWestFontStyleFT->set_label(sFontStyleString);
282  m_xEastFontStyleFT->set_label(sFontStyleString);
283  m_xCTLFontStyleFT->set_label(sFontStyleString);
284 
285  m_xWestFontLanguageLB->SetLanguageList(SvxLanguageListFlags::WESTERN, true, false, true, true,
286  LANGUAGE_SYSTEM, css::i18n::ScriptType::LATIN);
287  m_xEastFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CJK, true, false, true, true,
288  LANGUAGE_SYSTEM, css::i18n::ScriptType::ASIAN);
289  m_xCTLFontLanguageLB->SetLanguageList(SvxLanguageListFlags::CTL, true, false, true, true,
290  LANGUAGE_SYSTEM, css::i18n::ScriptType::COMPLEX);
291  int nVisibleChars = 15;
292  // read-only combobox / HasEntry asserts on set_width_char()
293  m_xWestFontLanguageLB->set_width_chars(nVisibleChars);
294  m_xEastFontLanguageLB->set_width_chars(nVisibleChars);
295  m_xCTLFontLanguageLB->set_width_chars(nVisibleChars);
296 
297  Initialize();
298 }
299 
301 {
302  m_pImpl.reset();
303  m_xCTLFontStyleLB.reset();
304  m_xEastFontLanguageLB.reset();
305  m_xWestFontStyleLB.reset();
306  m_xCTLFontSizeLB.reset();
307  m_xEastFontSizeLB.reset();
308  m_xWestFontSizeLB.reset();
309  m_xWestFontLanguageLB.reset();
310  m_xPreviewWin.reset();
311  m_xCTLFontLanguageLB.reset();
312  m_xEastFontLanguageLB.reset();
313 }
314 
316 {
317  // to handle the changes of the other pages
319 
320  Link<weld::ComboBox&,void> aLink = LINK(this, SvxCharNamePage, FontModifyComboBoxHdl_Impl);
321  m_xWestFontNameLB->connect_changed(aLink);
322  m_xWestFontStyleLB->connect_changed(aLink);
323  m_xWestFontSizeLB->connect_changed(aLink);
324  m_xWestFontLanguageLB->connect_changed(aLink);
325 
326  m_xWestFontFeaturesButton->connect_clicked(LINK(this, SvxCharNamePage, FontFeatureButtonClicked));
327 
328  m_xEastFontNameLB->connect_changed(aLink);
329  m_xEastFontStyleLB->connect_changed(aLink);
330  m_xEastFontSizeLB->connect_changed(aLink);
331  m_xEastFontLanguageLB->connect_changed(aLink);
332  m_xEastFontFeaturesButton->connect_clicked(LINK(this, SvxCharNamePage, FontFeatureButtonClicked));
333 
334  m_xCTLFontNameLB->connect_changed(aLink);
335  m_xCTLFontStyleLB->connect_changed(aLink);
336  m_xCTLFontSizeLB->connect_changed(aLink);
337  m_xCTLFontLanguageLB->connect_changed(aLink);
338  m_xCTLFontFeaturesButton->connect_clicked(LINK(this, SvxCharNamePage, FontFeatureButtonClicked));
339 
340  m_pImpl->m_aUpdateIdle.SetInvokeHandler( LINK( this, SvxCharNamePage, UpdateHdl_Impl ) );
341 }
342 
344 {
345  if ( !m_pImpl->m_pFontList )
346  {
348 
349  /* #110771# SvxFontListItem::GetFontList can return NULL */
350  if ( pDocSh )
351  {
352  const SfxPoolItem* pItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
353  if ( pItem != nullptr )
354  {
355  DBG_ASSERT(nullptr != static_cast<const SvxFontListItem*>(pItem)->GetFontList(),
356  "Where is the font list?");
357  m_pImpl->m_pFontList = static_cast<const SvxFontListItem*>(pItem )->GetFontList()->Clone();
358  }
359  }
360  if(!m_pImpl->m_pFontList)
361  {
362  m_pImpl->m_pFontList.reset(new FontList( Application::GetDefaultDevice() ));
363  }
364  }
365 
366  return m_pImpl->m_pFontList.get();
367 }
368 
369 
370 namespace
371 {
372  FontMetric calcFontMetrics( SvxFont& _rFont,
373  SvxCharNamePage const * _pPage,
374  const weld::ComboBox* _pFontNameLB,
375  const FontStyleBox* _pFontStyleLB,
376  const FontSizeBox* _pFontSizeLB,
377  const SvxLanguageBox* _pLanguageLB,
378  const FontList* _pFontList,
379  sal_uInt16 _nFontWhich,
380  sal_uInt16 _nFontHeightWhich)
381  {
382  Size aSize = _rFont.GetFontSize();
383  aSize.setWidth( 0 );
384  FontMetric aFontMetrics;
385  OUString sFontName(_pFontNameLB->get_active_text());
386  bool bFontAvailable = _pFontList->IsAvailable( sFontName );
387  if (bFontAvailable || _pFontNameLB->get_value_changed_from_saved())
388  aFontMetrics = _pFontList->Get(sFontName, _pFontStyleLB->get_active_text());
389  else
390  {
391  //get the font from itemset
392  SfxItemState eState = _pPage->GetItemSet().GetItemState( _nFontWhich );
393  if ( eState >= SfxItemState::DEFAULT )
394  {
395  const SvxFontItem* pFontItem = static_cast<const SvxFontItem*>(&( _pPage->GetItemSet().Get( _nFontWhich ) ));
396  aFontMetrics.SetFamilyName(pFontItem->GetFamilyName());
397  aFontMetrics.SetStyleName(pFontItem->GetStyleName());
398  aFontMetrics.SetFamily(pFontItem->GetFamily());
399  aFontMetrics.SetPitch(pFontItem->GetPitch());
400  aFontMetrics.SetCharSet(pFontItem->GetCharSet());
401  }
402  }
403  if ( _pFontSizeLB->IsRelative() )
404  {
405  DBG_ASSERT( _pPage->GetItemSet().GetParent(), "No parent set" );
406  const SvxFontHeightItem& rOldItem = static_cast<const SvxFontHeightItem&>(_pPage->GetItemSet().GetParent()->Get( _nFontHeightWhich ));
407 
408  // old value, scaled
409  tools::Long nHeight;
410  if ( _pFontSizeLB->IsPtRelative() )
411  nHeight = rOldItem.GetHeight()
412  + o3tl::convert(_pFontSizeLB->get_value(), o3tl::Length::pt,
413  o3tl::Length::twip) / 10;
414  else
415  nHeight = static_cast<tools::Long>(rOldItem.GetHeight() * _pFontSizeLB->get_value() / 100);
416 
417  // conversion twips for the example-window
418  aSize.setHeight(
419  ItemToControl( nHeight, _pPage->GetItemSet().GetPool()->GetMetric( _nFontHeightWhich ), FieldUnit::TWIP ) );
420  }
421  else if ( !_pFontSizeLB->get_active_text().isEmpty() )
422  aSize.setHeight(o3tl::convert(_pFontSizeLB->get_value(), o3tl::Length::pt,
423  o3tl::Length::twip) / 10);
424  else
425  aSize.setHeight( 200 ); // default 10pt
426  aFontMetrics.SetFontSize( aSize );
427 
428  _rFont.SetLanguage(_pLanguageLB->get_active_id());
429 
430  _rFont.SetFamily( aFontMetrics.GetFamilyType() );
431  _rFont.SetFamilyName( aFontMetrics.GetFamilyName() );
432  _rFont.SetStyleName( aFontMetrics.GetStyleName() );
433  _rFont.SetPitch( aFontMetrics.GetPitch() );
434  _rFont.SetCharSet( aFontMetrics.GetCharSet() );
435  _rFont.SetWeight( aFontMetrics.GetWeight() );
436  _rFont.SetItalic( aFontMetrics.GetItalic() );
437  _rFont.SetFontSize( aFontMetrics.GetFontSize() );
438 
439  return aFontMetrics;
440  }
441 }
442 
443 
445 {
446  SvxFont& rFont = GetPreviewFont();
447  SvxFont& rCJKFont = GetPreviewCJKFont();
448  SvxFont& rCTLFont = GetPreviewCTLFont();
449  // Font
450  const FontList* pFontList = GetFontList();
451 
452  FontMetric aWestFontMetric = calcFontMetrics(rFont, this, m_xWestFontNameLB.get(),
454  pFontList, GetWhich(SID_ATTR_CHAR_FONT),
455  GetWhich(SID_ATTR_CHAR_FONTHEIGHT));
456 
457  m_xWestFontTypeFT->set_label(pFontList->GetFontMapText(aWestFontMetric));
458 
459  FontMetric aEastFontMetric = calcFontMetrics(rCJKFont, this, m_xEastFontNameLB.get(),
461  pFontList, GetWhich(SID_ATTR_CHAR_CJK_FONT),
462  GetWhich(SID_ATTR_CHAR_CJK_FONTHEIGHT));
463 
464  m_xEastFontTypeFT->set_label(pFontList->GetFontMapText(aEastFontMetric));
465 
466  FontMetric aCTLFontMetric = calcFontMetrics(rCTLFont,
467  this, m_xCTLFontNameLB.get(), m_xCTLFontStyleLB.get(), m_xCTLFontSizeLB.get(),
468  m_xCTLFontLanguageLB.get(), pFontList, GetWhich(SID_ATTR_CHAR_CTL_FONT),
469  GetWhich(SID_ATTR_CHAR_CTL_FONTHEIGHT));
470 
471  m_xCTLFontTypeFT->set_label(pFontList->GetFontMapText(aCTLFontMetric));
472 
473  m_aPreviewWin.Invalidate();
474 }
476 {
477  OUString sFontName;
478  weld::Button* pButton= nullptr;
479  if (m_xWestFontNameLB.get() == &rNameBox)
480  {
481  sFontName = m_xWestFontNameLB->get_active_text();
482  pButton= m_xWestFontFeaturesButton.get();
483  }
484  else if (m_xEastFontNameLB.get() == &rNameBox)
485  {
486  sFontName = m_xEastFontNameLB->get_active_text();
487  pButton=m_xEastFontFeaturesButton.get();
488  }
489  else if (m_xCTLFontNameLB.get() == &rNameBox)
490  {
491  sFontName = m_xCTLFontNameLB->get_active_text();
492  pButton= m_xCTLFontFeaturesButton.get();
493  }
494  else
495  {
496  SAL_WARN( "cui.tabpages", "invalid font name box" );
497  return;
498  }
499 
500  bool bEnable = !getFontFeatureList(sFontName, *m_xVDev).empty();
501 
502  pButton->set_sensitive(bEnable);
503 }
504 
506 {
507  const FontList* pFontList = GetFontList();
508  DBG_ASSERT( pFontList, "no fontlist" );
509 
510  FontStyleBox* pStyleBox = nullptr;
511  OUString sFontName;
512 
513  if (m_xWestFontNameLB.get() == &rNameBox)
514  {
515  pStyleBox = m_xWestFontStyleLB.get();
516  sFontName = m_xWestFontNameLB->get_active_text();
517  }
518  else if (m_xEastFontNameLB.get() == &rNameBox)
519  {
520  pStyleBox = m_xEastFontStyleLB.get();
521  sFontName = m_xEastFontStyleLB->get_active_text();
522  }
523  else if (m_xCTLFontNameLB.get() == &rNameBox)
524  {
525  pStyleBox = m_xCTLFontStyleLB.get();
526  sFontName = m_xCTLFontNameLB->get_active_text();
527  }
528  else
529  {
530  SAL_WARN( "cui.tabpages", "invalid font name box" );
531  return;
532  }
533 
534  pStyleBox->Fill(sFontName, pFontList);
535 
536  if ( !m_pImpl->m_bInSearchMode )
537  return;
538 
539  // additional entries for the search:
540  // "not bold" and "not italic"
541  OUString aEntry = m_pImpl->m_aNoStyleText;
542  const char sS[] = "%1";
543  aEntry = aEntry.replaceFirst( sS, pFontList->GetBoldStr() );
544  m_pImpl->m_nExtraEntryPos = pStyleBox->get_count();
545  pStyleBox->append_text( aEntry );
546  aEntry = m_pImpl->m_aNoStyleText;
547  aEntry = aEntry.replaceFirst( sS, pFontList->GetItalicStr() );
548  pStyleBox->append_text(aEntry);
549 }
550 
552 {
553  const FontList* pFontList = GetFontList();
554  DBG_ASSERT( pFontList, "no fontlist" );
555 
556  FontSizeBox* pSizeBox = nullptr;
557 
558  if (m_xWestFontNameLB.get() == &rNameBox)
559  {
560  pSizeBox = m_xWestFontSizeLB.get();
561  }
562  else if (m_xEastFontNameLB.get() == &rNameBox)
563  {
564  pSizeBox = m_xEastFontSizeLB.get();
565  }
566  else if (m_xCTLFontNameLB.get() == &rNameBox)
567  {
568  pSizeBox = m_xCTLFontSizeLB.get();
569  }
570  else
571  {
572  SAL_WARN( "cui.tabpages", "invalid font name box" );
573  return;
574  }
575 
576  pSizeBox->Fill( pFontList );
577 }
578 
579 namespace
580 {
581  void FillFontNames(weld::ComboBox& rBox, const FontList& rList)
582  {
583  // insert fonts
584  sal_uInt16 nFontCount = rList.GetFontNameCount();
585  std::vector<weld::ComboBoxEntry> aVector;
586  aVector.reserve(nFontCount);
587  for (sal_uInt16 i = 0; i < nFontCount; ++i)
588  {
589  const FontMetric& rFontMetric = rList.GetFontName(i);
590  aVector.emplace_back(rFontMetric.GetFamilyName());
591  }
592  rBox.insert_vector(aVector, false);
593  }
594 }
595 
597 {
598  weld::ComboBox* pNameBox = nullptr;
599  weld::Label* pStyleLabel = nullptr;
600  FontStyleBox* pStyleBox = nullptr;
601  weld::Label* pSizeLabel = nullptr;
602  FontSizeBox* pSizeBox = nullptr;
603  weld::Label* pLangFT = nullptr;
604  SvxLanguageBox* pLangBox = nullptr;
605  sal_uInt16 nWhich = 0;
606 
607  switch ( eLangGrp )
608  {
609  case Western :
610  pNameBox = m_xWestFontNameLB.get();
611  pStyleLabel = m_xWestFontStyleFT.get();
612  pStyleBox = m_xWestFontStyleLB.get();
613  pSizeLabel = m_xWestFontSizeFT.get();
614  pSizeBox = m_xWestFontSizeLB.get();
615  pLangFT = m_xWestFontLanguageFT.get();
616  pLangBox = m_xWestFontLanguageLB.get();
617  nWhich = GetWhich( SID_ATTR_CHAR_FONT );
618  break;
619 
620  case Asian :
621  pNameBox = m_xEastFontNameLB.get();
622  pStyleLabel = m_xEastFontStyleFT.get();
623  pStyleBox = m_xEastFontStyleLB.get();
624  pSizeLabel = m_xEastFontSizeFT.get();
625  pSizeBox = m_xEastFontSizeLB.get();
626  pLangFT = m_xEastFontLanguageFT.get();
627  pLangBox = m_xEastFontLanguageLB.get();
628  nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONT );
629  break;
630 
631  case Ctl :
632  pNameBox = m_xCTLFontNameLB.get();
633  pStyleLabel = m_xCTLFontStyleFT.get();
634  pStyleBox = m_xCTLFontStyleLB.get();
635  pSizeLabel = m_xCTLFontSizeFT.get();
636  pSizeBox = m_xCTLFontSizeLB.get();
637  pLangFT = m_xCTLFontLanguageFT.get();
638  pLangBox = m_xCTLFontLanguageLB.get();
639  nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONT );
640  break;
641  }
642 
643  const FontList* pFontList = GetFontList();
644  FillFontNames(*pNameBox, *pFontList);
645 
646  const SvxFontItem* pFontItem = nullptr;
647  SfxItemState eState = rSet.GetItemState( nWhich );
648 
649  if ( eState >= SfxItemState::DEFAULT )
650  {
651  pFontItem = static_cast<const SvxFontItem*>(&( rSet.Get( nWhich ) ));
652  const OUString &rName = pFontItem->GetFamilyName();
653  int nIndex = pNameBox->find_text(rName);
654  pNameBox->set_active(nIndex);
655  // tdf#122992 if it didn't exist in the list, set the entry text to it anyway
656  if (nIndex == -1)
657  pNameBox->set_entry_text(rName);
658  }
659  else
660  {
661  pNameBox->set_active_text( OUString() );
662  }
663 
664  FillStyleBox_Impl(*pNameBox);
665 
666  bool bStyle = false;
667  bool bStyleAvailable = true;
668  FontItalic eItalic = ITALIC_NONE;
669  FontWeight eWeight = WEIGHT_NORMAL;
670  switch ( eLangGrp )
671  {
672  case Western : nWhich = GetWhich( SID_ATTR_CHAR_POSTURE ); break;
673  case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_POSTURE ); break;
674  case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_POSTURE ); break;
675  }
676  eState = rSet.GetItemState( nWhich );
677 
678  if ( eState >= SfxItemState::DEFAULT )
679  {
680  const SvxPostureItem& rItem = static_cast<const SvxPostureItem&>(rSet.Get( nWhich ));
681  eItalic = rItem.GetValue();
682  bStyle = true;
683  }
684  bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE);
685 
686  switch ( eLangGrp )
687  {
688  case Western : nWhich = GetWhich( SID_ATTR_CHAR_WEIGHT ); break;
689  case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_WEIGHT ); break;
690  case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_WEIGHT ); break;
691  }
692  eState = rSet.GetItemState( nWhich );
693 
694  if ( eState >= SfxItemState::DEFAULT )
695  {
696  const SvxWeightItem& rItem = static_cast<const SvxWeightItem&>(rSet.Get( nWhich ));
697  eWeight = rItem.GetValue();
698  }
699  else
700  bStyle = false;
701  bStyleAvailable = bStyleAvailable && (eState >= SfxItemState::DONTCARE);
702 
703  // currently chosen font
704  if ( bStyle && pFontItem )
705  {
706  FontMetric aFontMetric = pFontList->Get( pFontItem->GetFamilyName(), eWeight, eItalic );
707  pStyleBox->set_active_text( pFontList->GetStyleName( aFontMetric ) );
708  }
709  else if ( !m_pImpl->m_bInSearchMode || !bStyle )
710  {
711  pStyleBox->set_active_text( OUString() );
712  }
713  else if ( bStyle )
714  {
715  FontMetric aFontMetric = pFontList->Get( OUString(), eWeight, eItalic );
716  pStyleBox->set_active_text( pFontList->GetStyleName( aFontMetric ) );
717  }
718  if (!bStyleAvailable)
719  {
720  pStyleBox->set_sensitive(false);
721  pStyleLabel->set_sensitive(false);
722  }
723 
724  FillSizeBox_Impl(*pNameBox);
725  switch ( eLangGrp )
726  {
727  case Western : nWhich = GetWhich( SID_ATTR_CHAR_FONTHEIGHT ); break;
728  case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ); break;
729  case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ); break;
730  }
731  eState = rSet.GetItemState( nWhich );
732 
733  if ( pSizeBox->IsRelativeMode() )
734  {
735  MapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
736  const SvxFontHeightItem& rItem = static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich ));
737 
738  if( rItem.GetProp() != 100 || MapUnit::MapRelative != rItem.GetPropUnit() )
739  {
740  bool bPtRel = MapUnit::MapPoint == rItem.GetPropUnit();
741  pSizeBox->SetPtRelative( bPtRel );
742  pSizeBox->set_value( bPtRel ? static_cast<short>(rItem.GetProp()) * 10 : rItem.GetProp() );
743  }
744  else
745  {
746  pSizeBox->SetRelative(false);
747  pSizeBox->set_value( CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
748  }
749  }
750  else if ( eState >= SfxItemState::DEFAULT )
751  {
752  MapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
753  const SvxFontHeightItem& rItem = static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich ));
754  pSizeBox->set_value( CalcToPoint( rItem.GetHeight(), eUnit, 10 ) );
755  }
756  else
757  {
758  pSizeBox->set_active_or_entry_text(OUString());
759  if ( eState <= SfxItemState::DISABLED )
760  {
761  pSizeBox->set_sensitive(false);
762  pSizeLabel->set_sensitive(false);
763  }
764  }
765 
766  switch ( eLangGrp )
767  {
768  case Western : nWhich = GetWhich( SID_ATTR_CHAR_LANGUAGE ); break;
769  case Asian : nWhich = GetWhich( SID_ATTR_CHAR_CJK_LANGUAGE ); break;
770  case Ctl : nWhich = GetWhich( SID_ATTR_CHAR_CTL_LANGUAGE ); break;
771  }
772  pLangBox->set_active(-1);
773  eState = rSet.GetItemState( nWhich );
774 
775  switch ( eState )
776  {
777  case SfxItemState::UNKNOWN:
778  pLangFT->hide();
779  pLangBox->hide();
780  break;
781 
782  case SfxItemState::DISABLED:
783  pLangFT->set_sensitive(false);
784  pLangBox->set_sensitive(false);
785  break;
786 
787  case SfxItemState::DEFAULT:
788  case SfxItemState::SET:
789  {
790  const SvxLanguageItem& rItem = static_cast<const SvxLanguageItem&>(rSet.Get( nWhich ));
791  LanguageType eLangType = rItem.GetValue();
792  DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
793  if (eLangType != LANGUAGE_DONTKNOW)
794  pLangBox->set_active_id(eLangType);
795  break;
796  }
797  case SfxItemState::DONTCARE:
798  break;
799  }
800 
801  OUString sMapText(pFontList->GetFontMapText(
802  pFontList->Get(pNameBox->get_active_text(), pStyleBox->get_active_text())));
803 
804  switch (eLangGrp)
805  {
806  case Western:
807  m_xWestFontTypeFT->set_label(sMapText);
808  break;
809  case Asian:
810  m_xEastFontTypeFT->set_label(sMapText);
811  break;
812  case Ctl:
813  m_xCTLFontTypeFT->set_label(sMapText);
814  break;
815  }
816 
817  EnableFeatureButton(*pNameBox);
818 
819  // save these settings
820  pNameBox->save_value();
821  pStyleBox->save_value();
822  pSizeBox->save_value();
823  pLangBox->save_active_id();
824 }
825 
827 {
828  bool bModified = false;
829 
830  weld::ComboBox* pNameBox = nullptr;
831  FontStyleBox* pStyleBox = nullptr;
832  FontSizeBox* pSizeBox = nullptr;
833  SvxLanguageBox* pLangBox = nullptr;
834  sal_uInt16 nWhich = 0;
835  sal_uInt16 nSlot = 0;
836 
837  switch ( eLangGrp )
838  {
839  case Western :
840  pNameBox = m_xWestFontNameLB.get();
841  pStyleBox = m_xWestFontStyleLB.get();
842  pSizeBox = m_xWestFontSizeLB.get();
843  pLangBox = m_xWestFontLanguageLB.get();
844  nSlot = SID_ATTR_CHAR_FONT;
845  break;
846 
847  case Asian :
848  pNameBox = m_xEastFontNameLB.get();
849  pStyleBox = m_xEastFontStyleLB.get();
850  pSizeBox = m_xEastFontSizeLB.get();
851  pLangBox = m_xEastFontLanguageLB.get();
852  nSlot = SID_ATTR_CHAR_CJK_FONT;
853  break;
854 
855  case Ctl :
856  pNameBox = m_xCTLFontNameLB.get();
857  pStyleBox = m_xCTLFontStyleLB.get();
858  pSizeBox = m_xCTLFontSizeLB.get();
859  pLangBox = m_xCTLFontLanguageLB.get();
860  nSlot = SID_ATTR_CHAR_CTL_FONT;
861  break;
862  }
863 
864  nWhich = GetWhich( nSlot );
865  const SfxPoolItem* pItem = nullptr;
866  const SfxItemSet& rOldSet = GetItemSet();
867  const SfxPoolItem* pOld = nullptr;
868 
869  const SfxItemSet* pExampleSet = GetDialogExampleSet();
870 
871  bool bChanged = true;
872  const OUString& rFontName = pNameBox->get_active_text();
873  const FontList* pFontList = GetFontList();
874  OUString aStyleBoxText = pStyleBox->get_active_text();
875  int nEntryPos = pStyleBox->find_text(aStyleBoxText);
876  if (nEntryPos >= m_pImpl->m_nExtraEntryPos)
877  aStyleBoxText.clear();
878  FontMetric aInfo( pFontList->Get( rFontName, aStyleBoxText ) );
879  SvxFontItem aFontItem( aInfo.GetFamilyType(), aInfo.GetFamilyName(), aInfo.GetStyleName(),
880  aInfo.GetPitch(), aInfo.GetCharSet(), nWhich );
881  pOld = GetOldItem( rSet, nSlot );
882 
883  if ( pOld )
884  {
885  const SvxFontItem& rItem = *static_cast<const SvxFontItem*>(pOld);
886 
887  if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() )
888  bChanged = false;
889  }
890 
891  if ( !bChanged )
892  bChanged = pNameBox->get_saved_value().isEmpty();
893 
894  if ( !bChanged && pExampleSet &&
895  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
896  static_cast<const SvxFontItem*>(pItem)->GetFamilyName() != aFontItem.GetFamilyName() )
897  bChanged = true;
898 
899  if ( bChanged && !rFontName.isEmpty() )
900  {
901  rSet.Put( aFontItem );
902  bModified = true;
903  }
904  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
905  rSet.ClearItem( nWhich );
906 
907 
908  bChanged = true;
909  switch ( eLangGrp )
910  {
911  case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break;
912  case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break;
913  case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break;
914  }
915  nWhich = GetWhich( nSlot );
916  FontWeight eWeight = aInfo.GetWeight();
917  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
918  eWeight = WEIGHT_NORMAL;
919  SvxWeightItem aWeightItem( eWeight, nWhich );
920  pOld = GetOldItem( rSet, nSlot );
921 
922  if ( pOld )
923  {
924  const SvxWeightItem& rItem = *static_cast<const SvxWeightItem*>(pOld);
925 
926  if ( rItem.GetValue() == aWeightItem.GetValue() )
927  bChanged = false;
928  }
929 
930  if ( !bChanged )
931  {
932  bChanged = pStyleBox->get_saved_value().isEmpty();
933 
934  if ( m_pImpl->m_bInSearchMode && bChanged &&
935  aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE )
936  bChanged = false;
937  }
938 
939  if ( !bChanged && pExampleSet &&
940  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
941  static_cast<const SvxWeightItem*>(pItem)->GetValue() != aWeightItem.GetValue() )
942  bChanged = true;
943 
944  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
945  bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos );
946 
947  OUString aText( pStyleBox->get_active_text() ); // Tristate, then text empty
948 
949  if ( bChanged && !aText.isEmpty() )
950  {
951  rSet.Put( aWeightItem );
952  bModified = true;
953  }
954  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
955  rSet.InvalidateItem(nWhich);
956 
957  bChanged = true;
958  switch ( eLangGrp )
959  {
960  case Western : nSlot = SID_ATTR_CHAR_POSTURE; break;
961  case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break;
962  case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break;
963  }
964  nWhich = GetWhich( nSlot );
965  FontItalic eItalic = aInfo.GetItalic();
966  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
967  eItalic = ITALIC_NONE;
968  SvxPostureItem aPostureItem( eItalic, nWhich );
969  pOld = GetOldItem( rSet, nSlot );
970 
971  if ( pOld )
972  {
973  const SvxPostureItem& rItem = *static_cast<const SvxPostureItem*>(pOld);
974 
975  if ( rItem.GetValue() == aPostureItem.GetValue() )
976  bChanged = false;
977  }
978 
979  if ( !bChanged )
980  {
981  bChanged = pStyleBox->get_saved_value().isEmpty();
982 
983  if ( m_pImpl->m_bInSearchMode && bChanged &&
984  aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL )
985  bChanged = false;
986  }
987 
988  if ( !bChanged && pExampleSet &&
989  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
990  static_cast<const SvxPostureItem*>(pItem)->GetValue() != aPostureItem.GetValue() )
991  bChanged = true;
992 
993  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
994  bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) );
995 
996  if ( bChanged && !aText.isEmpty() )
997  {
998  rSet.Put( aPostureItem );
999  bModified = true;
1000  }
1001  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1002  rSet.InvalidateItem(nWhich);
1003 
1004  // FontSize
1005  tools::Long nSize = pSizeBox->get_value();
1006 
1007  if ( pSizeBox->get_active_text().isEmpty() ) // GetValue() returns the min-value
1008  nSize = 0;
1009  tools::Long nSavedSize = pSizeBox->get_saved_value();
1010  const bool bRel = pSizeBox->IsRelative();
1011 
1012  switch ( eLangGrp )
1013  {
1014  case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break;
1015  case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break;
1016  case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break;
1017  }
1018  nWhich = GetWhich( nSlot );
1019  const SvxFontHeightItem* pOldHeight = static_cast<const SvxFontHeightItem*>(GetOldItem( rSet, nSlot ));
1020  bChanged = ( nSize != nSavedSize );
1021 
1022  if ( !bChanged && pExampleSet &&
1023  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET )
1024  {
1025  float fSize = static_cast<float>(nSize) / 10;
1026  tools::Long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) );
1027  if ( static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() != static_cast<sal_uInt32>(nVal) )
1028  bChanged = true;
1029  }
1030 
1031  if ( bChanged || !pOldHeight ||
1032  bRel != ( MapUnit::MapRelative != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) )
1033  {
1034  MapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1035  if ( pSizeBox->IsRelative() )
1036  {
1037  DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
1038  const SvxFontHeightItem& rOldItem =
1039  static_cast<const SvxFontHeightItem&>(GetItemSet().GetParent()->Get( nWhich ));
1040 
1041  SvxFontHeightItem aHeight( 240, 100, nWhich );
1042  if ( pSizeBox->IsPtRelative() )
1043  aHeight.SetHeight( rOldItem.GetHeight(), static_cast<sal_uInt16>( nSize / 10 ), MapUnit::MapPoint, eUnit );
1044  else
1045  aHeight.SetHeight( rOldItem.GetHeight(), static_cast<sal_uInt16>(nSize) );
1046  rSet.Put( aHeight );
1047  }
1048  else
1049  {
1050  float fSize = static_cast<float>(nSize) / 10;
1051  rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) );
1052  }
1053  bModified = true;
1054  }
1055  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1056  rSet.InvalidateItem(nWhich);
1057 
1058  bChanged = true;
1059  switch ( eLangGrp )
1060  {
1061  case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break;
1062  case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break;
1063  case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break;
1064  }
1065  nWhich = GetWhich( nSlot );
1066  pOld = GetOldItem( rSet, nSlot );
1067 
1068  // For language list boxes acting as ComboBox, check for, add and select an
1069  // edited entry.
1070  if (pLangBox == m_xWestFontLanguageLB.get())
1071  {
1072  switch (pLangBox->GetEditedAndValid())
1073  {
1075  ; // nothing to do
1076  break;
1078  {
1079  const int nPos = pLangBox->SaveEditedAsEntry();
1080  if (nPos != -1)
1081  pLangBox->set_active(nPos);
1082  }
1083  break;
1085  pLangBox->set_active_id(pLangBox->get_saved_active_id());
1086  break;
1087  }
1088  }
1089 
1090  int nLangPos = pLangBox->get_active();
1091  LanguageType eLangType = pLangBox->get_active_id();
1092 
1093  if (pOld)
1094  {
1095  const SvxLanguageItem& rItem = *static_cast<const SvxLanguageItem*>(pOld);
1096  if (nLangPos == -1 || eLangType == rItem.GetValue())
1097  bChanged = false;
1098  }
1099 
1100  if (!bChanged)
1101  bChanged = pLangBox->get_active_id_changed_from_saved();
1102 
1103  if (bChanged && nLangPos != -1)
1104  {
1105  rSet.Put(SvxLanguageItem(eLangType, nWhich));
1106  bModified = true;
1107  }
1108  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1109  rSet.InvalidateItem(nWhich);
1110 
1111  return bModified;
1112 }
1113 
1114 IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl, Timer *, void)
1115 {
1116  UpdatePreview_Impl();
1117 }
1118 
1119 IMPL_LINK(SvxCharNamePage, FontModifyComboBoxHdl_Impl, weld::ComboBox&, rBox, void)
1120 {
1121  FontModifyHdl_Impl(rBox);
1122 }
1123 
1124 IMPL_LINK(SvxCharNamePage, FontFeatureButtonClicked, weld::Button&, rButton, void)
1125 {
1126  OUString sFontName;
1127  weld::ComboBox* pNameBox = nullptr;
1128 
1129  if (&rButton == m_xWestFontFeaturesButton.get())
1130  {
1131  pNameBox = m_xWestFontNameLB.get();
1132  sFontName = GetPreviewFont().GetFamilyName();
1133  }
1134  else if (&rButton == m_xEastFontFeaturesButton.get())
1135  {
1136  pNameBox = m_xEastFontNameLB.get();
1137  sFontName = GetPreviewCJKFont().GetFamilyName();
1138  }
1139  else if (&rButton == m_xCTLFontFeaturesButton.get())
1140  {
1141  pNameBox = m_xCTLFontNameLB.get();
1142  sFontName = GetPreviewCTLFont().GetFamilyName();
1143  }
1144 
1145  if (!sFontName.isEmpty() && pNameBox)
1146  {
1147  cui::FontFeaturesDialog aDialog(GetFrameWeld(), sFontName);
1148  if (aDialog.run() == RET_OK)
1149  {
1150  pNameBox->set_entry_text(aDialog.getResultFontName());
1151  UpdatePreview_Impl();
1152  }
1153  }
1154 }
1155 
1157 {
1158  m_pImpl->m_aUpdateIdle.Start();
1159 
1160  if (m_xWestFontNameLB.get() == &rNameBox || m_xEastFontNameLB.get() == &rNameBox || m_xCTLFontNameLB.get() == &rNameBox)
1161  {
1162  FillStyleBox_Impl(rNameBox);
1163  FillSizeBox_Impl(rNameBox);
1164  EnableFeatureButton(rNameBox);
1165  }
1166 }
1167 
1169 {
1171 
1172  UpdatePreview_Impl(); // instead of asynchronous calling in ctor
1173 }
1174 
1176 {
1177  if ( _pSet )
1178  FillItemSet( _pSet );
1179  return DeactivateRC::LeavePage;
1180 }
1181 
1182 std::unique_ptr<SfxTabPage> SvxCharNamePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1183 {
1184  return std::make_unique<SvxCharNamePage>(pPage, pController, *rSet );
1185 }
1186 
1188 {
1189  Reset_Impl( *rSet, Western );
1190  Reset_Impl( *rSet, Asian );
1191  Reset_Impl( *rSet, Ctl );
1192 
1193  SetPrevFontWidthScale( *rSet );
1195 }
1196 
1198 {
1199  m_xWestFontNameLB->save_value();
1200  m_xWestFontStyleLB->save_value();
1201  m_xWestFontSizeLB->save_value();
1202  m_xWestFontLanguageLB->save_active_id();
1203  m_xEastFontNameLB->save_value();
1204  m_xEastFontStyleLB->save_value();
1205  m_xEastFontSizeLB->save_value();
1206  m_xEastFontLanguageLB->save_active_id();
1207  m_xCTLFontNameLB->save_value();
1208  m_xCTLFontStyleLB->save_value();
1209  m_xCTLFontSizeLB->save_value();
1210  m_xCTLFontLanguageLB->save_active_id();
1211 }
1212 
1214 {
1215  bool bModified = FillItemSet_Impl( *rSet, Western );
1216  bModified |= FillItemSet_Impl( *rSet, Asian );
1217  bModified |= FillItemSet_Impl( *rSet, Ctl );
1218  return bModified;
1219 }
1220 
1222 {
1223  m_pImpl->m_pFontList = rItem.GetFontList()->Clone();
1224 }
1225 
1226 namespace
1227 {
1228  void enableRelativeMode( SvxCharNamePage const * _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich )
1229  {
1230  _pFontSizeLB->EnableRelativeMode( 5, 995 ); // min 5%, max 995%, step 5
1231 
1232  const SvxFontHeightItem& rHeightItem =
1233  static_cast<const SvxFontHeightItem&>(_pPage->GetItemSet().GetParent()->Get( _nHeightWhich ));
1234  MapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich );
1235  short nCurHeight =
1236  static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 );
1237 
1238  // based on the current height:
1239  // - negative until minimum of 2 pt
1240  // - positive until maximum of 999 pt
1241  _pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight) );
1242  }
1243 }
1244 
1246 {
1247  DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" );
1248  enableRelativeMode(this,m_xWestFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
1249  enableRelativeMode(this,m_xEastFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
1250  enableRelativeMode(this,m_xCTLFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
1251 }
1252 
1254 {
1255  m_pImpl->m_bInSearchMode = true;
1256 }
1257 
1258 void SvxCharNamePage::DisableControls( sal_uInt16 nDisable )
1259 {
1260  if ( DISABLE_HIDE_LANGUAGE & nDisable )
1261  {
1268  }
1269 }
1270 
1272 {
1273  const SvxFontListItem* pFontListItem = aSet.GetItem<SvxFontListItem>(SID_ATTR_CHAR_FONTLIST, false);
1274  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
1275  const SfxUInt16Item* pDisableItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
1276  if (pFontListItem)
1277  SetFontList(*pFontListItem);
1278 
1279  if (pFlagItem)
1280  {
1281  sal_uInt32 nFlags=pFlagItem->GetValue();
1282  if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
1284  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
1285  // the writer uses SID_ATTR_BRUSH as font background
1287  }
1288  if (pDisableItem)
1289  DisableControls(pDisableItem->GetValue());
1290 }
1291 // class SvxCharEffectsPage ----------------------------------------------
1292 
1294  : SvxCharBasePage(pPage, pController, "cui/ui/effectspage.ui", "EffectsPage", rInSet)
1295  , m_bOrigFontColor(false)
1296  , m_bNewFontColor(false)
1297  , m_bEnableNoneFontColor(false)
1298  , m_xFontColorFT(m_xBuilder->weld_label("fontcolorft"))
1299  , m_xFontColorLB(new ColorListBox(m_xBuilder->weld_menu_button("fontcolorlb"),
1300  [this]{ return GetDialogController()->getDialog(); }))
1301  , m_xFontTransparencyFT(m_xBuilder->weld_label("fonttransparencyft"))
1302  , m_xFontTransparencyMtr(
1303  m_xBuilder->weld_metric_spin_button("fonttransparencymtr", FieldUnit::PERCENT))
1304  , m_xEffectsFT(m_xBuilder->weld_label("effectsft"))
1305  , m_xEffectsLB(m_xBuilder->weld_combo_box("effectslb"))
1306  , m_xReliefFT(m_xBuilder->weld_label("reliefft"))
1307  , m_xReliefLB(m_xBuilder->weld_combo_box("relieflb"))
1308  , m_xOutlineBtn(m_xBuilder->weld_check_button("outlinecb"))
1309  , m_xShadowBtn(m_xBuilder->weld_check_button("shadowcb"))
1310  , m_xHiddenBtn(m_xBuilder->weld_check_button("hiddencb"))
1311  , m_xOverlineLB(m_xBuilder->weld_combo_box("overlinelb"))
1312  , m_xOverlineColorFT(m_xBuilder->weld_label("overlinecolorft"))
1313  , m_xOverlineColorLB(new ColorListBox(m_xBuilder->weld_menu_button("overlinecolorlb"),
1314  [this]{ return GetDialogController()->getDialog(); }))
1315  , m_xStrikeoutLB(m_xBuilder->weld_combo_box("strikeoutlb"))
1316  , m_xUnderlineLB(m_xBuilder->weld_combo_box("underlinelb"))
1317  , m_xUnderlineColorFT(m_xBuilder->weld_label("underlinecolorft"))
1318  , m_xUnderlineColorLB(new ColorListBox(m_xBuilder->weld_menu_button("underlinecolorlb"),
1319  [this]{ return GetDialogController()->getDialog(); }))
1320  , m_xIndividualWordsBtn(m_xBuilder->weld_check_button("individualwordscb"))
1321  , m_xEmphasisFT(m_xBuilder->weld_label("emphasisft"))
1322  , m_xEmphasisLB(m_xBuilder->weld_combo_box("emphasislb"))
1323  , m_xPositionFT(m_xBuilder->weld_label("positionft"))
1324  , m_xPositionLB(m_xBuilder->weld_combo_box("positionlb"))
1325  , m_xA11yWarningFT(m_xBuilder->weld_label("a11ywarning"))
1326 {
1327  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
1328 #ifdef IOS
1329  m_xPreviewWin->hide();
1330 #endif
1331  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1332  m_xOverlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1333  m_xUnderlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1334  Initialize();
1335 }
1336 
1338 {
1339  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR, true);
1340  m_bEnableNoneFontColor = true;
1341 }
1342 
1344 {
1345  m_xUnderlineColorLB.reset();
1346  m_xOverlineColorLB.reset();
1347  m_xFontTransparencyMtr.reset();
1348  m_xFontColorLB.reset();
1349 }
1350 
1352 {
1353  // to handle the changes of the other pages
1355 
1356  // HTML-Mode
1357  const SfxUInt16Item* pHtmlModeItem = GetItemSet().GetItemIfSet( SID_HTML_MODE, false );
1358  if ( !pHtmlModeItem)
1359  {
1361  if (pShell)
1362  pHtmlModeItem = pShell->GetItem( SID_HTML_MODE );
1363  }
1364  if (pHtmlModeItem)
1365  {
1366  m_nHtmlMode = pHtmlModeItem->GetValue();
1367  if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
1368  {
1370  }
1371  }
1372 
1373  m_xFontColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1374  m_xFontTransparencyMtr->connect_value_changed(
1375  LINK(this, SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl));
1376 
1377  // handler
1378  Link<weld::ComboBox&,void> aLink = LINK( this, SvxCharEffectsPage, SelectListBoxHdl_Impl );
1379  m_xUnderlineLB->connect_changed( aLink );
1380  m_xUnderlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1381  m_xOverlineLB->connect_changed( aLink );
1382  m_xOverlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1383  m_xStrikeoutLB->connect_changed( aLink );
1384  m_xEmphasisLB->connect_changed( aLink );
1385  m_xPositionLB->connect_changed( aLink );
1386  m_xEffectsLB->connect_changed( aLink );
1387  m_xReliefLB->connect_changed( aLink );
1388 
1389  m_xUnderlineLB->set_active( 0 );
1390  m_xOverlineLB->set_active( 0 );
1391  m_xStrikeoutLB->set_active( 0 );
1392  m_xEmphasisLB->set_active( 0 );
1393  m_xPositionLB->set_active( 0 );
1394  SelectHdl_Impl(nullptr);
1396 
1397  m_xEffectsLB->set_active( 0 );
1398 
1399  m_xHiddenBtn->connect_toggled(LINK(this, SvxCharEffectsPage, HiddenBtnClickHdl));
1400  m_xIndividualWordsBtn->connect_toggled(LINK(this, SvxCharEffectsPage, CbClickHdl_Impl));
1401  m_xOutlineBtn->connect_toggled(LINK(this, SvxCharEffectsPage, OutlineBtnClickHdl));
1402  m_xShadowBtn->connect_toggled(LINK(this, SvxCharEffectsPage, ShadowBtnClickHdl));
1403 
1405  {
1406  m_xEmphasisFT->hide();
1407  m_xEmphasisLB->hide();
1408  m_xPositionFT->hide();
1409  m_xPositionLB->hide();
1410  }
1411 
1412  m_xA11yWarningFT->set_visible(officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get());
1413 }
1414 
1416 {
1417  SvxFont& rFont = GetPreviewFont();
1418  SvxFont& rCJKFont = GetPreviewCJKFont();
1419  SvxFont& rCTLFont = GetPreviewCTLFont();
1420 
1421  const Color& rSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1422  rFont.SetColor(rSelectedColor);
1423  rCJKFont.SetColor(rSelectedColor);
1424  rCTLFont.SetColor(rSelectedColor);
1425  m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO
1426 
1427  FontLineStyle eUnderline = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
1428  FontLineStyle eOverline = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
1429  FontStrikeout eStrikeout = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
1430  rFont.SetUnderline( eUnderline );
1431  rCJKFont.SetUnderline( eUnderline );
1432  rCTLFont.SetUnderline( eUnderline );
1433  m_aPreviewWin.SetTextLineColor( m_xUnderlineColorLB->GetSelectEntryColor() );
1434  rFont.SetOverline( eOverline );
1435  rCJKFont.SetOverline( eOverline );
1436  rCTLFont.SetOverline( eOverline );
1437  m_aPreviewWin.SetOverlineColor( m_xOverlineColorLB->GetSelectEntryColor() );
1438  rFont.SetStrikeout( eStrikeout );
1439  rCJKFont.SetStrikeout( eStrikeout );
1440  rCTLFont.SetStrikeout( eStrikeout );
1441 
1442  auto nEmphasis = m_xEmphasisLB->get_active();
1443  if (nEmphasis != -1)
1444  {
1445  bool bUnder = (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32());
1446  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nEmphasis);
1447  eMark |= bUnder ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
1448  rFont.SetEmphasisMark( eMark );
1449  rCJKFont.SetEmphasisMark( eMark );
1450  rCTLFont.SetEmphasisMark( eMark );
1451  }
1452 
1453  auto nRelief = m_xReliefLB->get_active();
1454  if (nRelief != -1)
1455  {
1456  rFont.SetRelief( static_cast<FontRelief>(nRelief) );
1457  rCJKFont.SetRelief( static_cast<FontRelief>(nRelief) );
1458  rCTLFont.SetRelief( static_cast<FontRelief>(nRelief) );
1459  }
1460 
1461  rFont.SetOutline( StateToAttr( m_xOutlineBtn->get_state() ) );
1462  rCJKFont.SetOutline( rFont.IsOutline() );
1463  rCTLFont.SetOutline( rFont.IsOutline() );
1464 
1465  rFont.SetShadow( StateToAttr( m_xShadowBtn->get_state() ) );
1466  rCJKFont.SetShadow( rFont.IsShadow() );
1467  rCTLFont.SetShadow( rFont.IsShadow() );
1468 
1469  auto nCapsPos = m_xEffectsLB->get_active();
1470  if (nCapsPos != -1)
1471  {
1472  SvxCaseMap eCaps = static_cast<SvxCaseMap>(nCapsPos);
1473  rFont.SetCaseMap( eCaps );
1474  rCJKFont.SetCaseMap( eCaps );
1475  // #i78474# small caps do not exist in CTL fonts
1476  rCTLFont.SetCaseMap( eCaps == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaps );
1477  }
1478 
1479  bool bWordLine = StateToAttr( m_xIndividualWordsBtn->get_state() );
1480  rFont.SetWordLineMode( bWordLine );
1481  rCJKFont.SetWordLineMode( bWordLine );
1482  rCTLFont.SetWordLineMode( bWordLine );
1483 
1484  m_aPreviewWin.Invalidate();
1485 }
1486 
1488 {
1489  if ( SvxCaseMap::End > eCaseMap )
1490  m_xEffectsLB->set_active(
1491  sal::static_int_cast< sal_Int32 >( eCaseMap ) );
1492  else
1493  {
1494  // not mapped
1495  m_xEffectsLB->set_active(-1);
1496  }
1497 
1499 }
1500 
1502 {
1503  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1504  SfxItemState eState = rSet.GetItemState( nWhich );
1505 
1506  m_bOrigFontColor = false;
1507  switch ( eState )
1508  {
1509  case SfxItemState::UNKNOWN:
1510  m_xFontColorFT->hide();
1511  m_xFontColorLB->hide();
1512  break;
1513 
1514  case SfxItemState::DISABLED:
1515  m_xFontColorFT->set_sensitive(false);
1516  m_xFontColorLB->set_sensitive(false);
1517  break;
1518 
1519  case SfxItemState::DONTCARE:
1520  //Related: tdf#106080 if there is no font color, then allow "none"
1521  //as a color so the listbox can display that state.
1523  m_xFontColorLB->SetNoSelection();
1524  break;
1525 
1526  case SfxItemState::DEFAULT:
1527  case SfxItemState::SET:
1528  {
1529  SvxFont& rFont = GetPreviewFont();
1530  SvxFont& rCJKFont = GetPreviewCJKFont();
1531  SvxFont& rCTLFont = GetPreviewCTLFont();
1532 
1533  const SvxColorItem& rItem = static_cast<const SvxColorItem&>(rSet.Get( nWhich ));
1534  Color aColor = rItem.GetValue();
1535  rFont.SetColor(aColor);
1536  rCJKFont.SetColor(aColor);
1537  rCTLFont.SetColor(aColor);
1538  m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO
1539 
1540  m_aPreviewWin.Invalidate();
1541 
1542  Color aRGBColor = aColor;
1543  if (aRGBColor.IsTransparent() && aColor != COL_AUTO)
1544  {
1545  aRGBColor.SetAlpha(255);
1546  }
1547  m_xFontColorLB->SelectEntry(aRGBColor);
1548 
1549  if (m_xFontTransparencyMtr->get_visible() && aColor != COL_AUTO)
1550  {
1551  double fTransparency = (255 - aColor.GetAlpha()) * 100.0 / 255;
1552  m_xFontTransparencyMtr->set_value(basegfx::fround(fTransparency),
1553  FieldUnit::PERCENT);
1554  }
1555 
1556  m_aOrigFontColor = aColor;
1557  m_bOrigFontColor = true;
1558  break;
1559  }
1560  }
1561  m_bNewFontColor = false;
1562 }
1563 
1565 {
1566  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1567  const SfxItemSet& rOldSet = GetItemSet();
1568 
1569  svx::NamedThemedColor aSelectedColor;
1570  bool bChanged = m_bNewFontColor;
1571 
1572  if (bChanged)
1573  {
1574  aSelectedColor = m_xFontColorLB->GetSelectedEntryThemedColor();
1575 
1576  if (m_xFontTransparencyMtr->get_value_changed_from_saved())
1577  {
1578  double fTransparency
1579  = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100;
1580  aSelectedColor.m_aColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
1581  }
1582 
1583  if (m_bOrigFontColor)
1584  bChanged = aSelectedColor.m_aColor != m_aOrigFontColor;
1585  if (m_bEnableNoneFontColor && bChanged && aSelectedColor.m_aColor == COL_NONE_COLOR)
1586  bChanged = false;
1587  }
1588 
1589  if (bChanged)
1590  {
1591  SvxColorItem aItem( aSelectedColor.m_aColor, nWhich );
1592 
1593  if (aSelectedColor.m_nThemeIndex != -1)
1594  {
1595  // The color was picked from the theme palette, remember its index.
1596  aItem.GetThemeColor().SetThemeIndex(aSelectedColor.m_nThemeIndex);
1597  aItem.GetThemeColor().SetLumMod(aSelectedColor.m_nLumMod);
1598  aItem.GetThemeColor().SetLumOff(aSelectedColor.m_nLumOff);
1599  }
1600 
1601  rSet.Put(aItem);
1602  }
1603  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1604  rSet.InvalidateItem(nWhich);
1605 
1606  return bChanged;
1607 }
1608 
1609 IMPL_LINK( SvxCharEffectsPage, SelectListBoxHdl_Impl, weld::ComboBox&, rBox, void )
1610 {
1611  SelectHdl_Impl(&rBox);
1612 }
1613 
1615 {
1616  if (m_xEmphasisLB.get() == pBox)
1617  {
1618  auto nEPos = m_xEmphasisLB->get_active();
1619  bool bEnable = nEPos > 0;
1620  m_xPositionFT->set_sensitive( bEnable );
1621  m_xPositionLB->set_sensitive( bEnable );
1622  }
1623  else if (m_xReliefLB.get() == pBox)
1624  {
1625  bool bEnable = ( pBox->get_active() == 0 );
1626  m_xOutlineBtn->set_sensitive( bEnable );
1627  m_xShadowBtn->set_sensitive( bEnable );
1628  }
1629  else if (m_xPositionLB.get() != pBox)
1630  {
1631  auto nUPos = m_xUnderlineLB->get_active();
1632  bool bUEnable = nUPos > 0;
1633  m_xUnderlineColorFT->set_sensitive(bUEnable);
1634  m_xUnderlineColorLB->set_sensitive(bUEnable);
1635 
1636  auto nOPos = m_xOverlineLB->get_active();
1637  bool bOEnable = nOPos > 0;
1638  m_xOverlineColorFT->set_sensitive(bOEnable);
1639  m_xOverlineColorLB->set_sensitive(bOEnable);
1640 
1641  auto nSPos = m_xStrikeoutLB->get_active();
1642  m_xIndividualWordsBtn->set_sensitive( bUEnable || bOEnable || nSPos > 0);
1643  }
1645 }
1646 
1647 IMPL_LINK(SvxCharEffectsPage, CbClickHdl_Impl, weld::Toggleable&, rToggle, void)
1648 {
1649  m_aIndividualWordsState.ButtonToggled(rToggle);
1650  UpdatePreview_Impl();
1651  UpdatePreview_Impl();
1652 }
1653 
1654 IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox&, rBox, void)
1655 {
1656  if (m_xFontColorLB.get() == &rBox)
1657  m_bNewFontColor = true;
1658  UpdatePreview_Impl();
1659 }
1660 
1661 IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void)
1662 {
1663  m_bNewFontColor = true;
1664 }
1665 
1667 {
1668  if ( _pSet )
1669  FillItemSet( _pSet );
1670  return DeactivateRC::LeavePage;
1671 }
1672 
1673 std::unique_ptr<SfxTabPage> SvxCharEffectsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
1674 {
1675  return std::make_unique<SvxCharEffectsPage>( pPage, pController, *rSet );
1676 }
1677 
1679 {
1680  SvxFont& rFont = GetPreviewFont();
1681  SvxFont& rCJKFont = GetPreviewCJKFont();
1682  SvxFont& rCTLFont = GetPreviewCTLFont();
1683 
1684  bool bEnable = false;
1685 
1686  // Underline
1687  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
1688  rFont.SetUnderline( LINESTYLE_NONE );
1689  rCJKFont.SetUnderline( LINESTYLE_NONE );
1690  rCTLFont.SetUnderline( LINESTYLE_NONE );
1691 
1692  m_xUnderlineLB->set_active( 0 );
1693  SfxItemState eState = rSet->GetItemState( nWhich );
1694 
1695  if ( eState >= SfxItemState::DONTCARE )
1696  {
1697  if ( eState == SfxItemState::DONTCARE )
1698  m_xUnderlineLB->set_active(-1);
1699  else
1700  {
1701  const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>(rSet->Get( nWhich ));
1702  FontLineStyle eUnderline = rItem.GetValue();
1703  rFont.SetUnderline( eUnderline );
1704  rCJKFont.SetUnderline( eUnderline );
1705  rCTLFont.SetUnderline( eUnderline );
1706 
1707  if ( eUnderline != LINESTYLE_NONE )
1708  {
1709  auto nPos = m_xUnderlineLB->find_id(OUString::number(eUnderline));
1710  if (nPos != -1)
1711  {
1712  m_xUnderlineLB->set_active(nPos);
1713  bEnable = true;
1714  }
1715  Color aColor = rItem.GetColor();
1716  m_xUnderlineColorLB->SelectEntry(aColor);
1717  }
1718  else
1719  {
1720  m_xUnderlineColorLB->SelectEntry(COL_AUTO);
1721  m_xUnderlineColorLB->set_sensitive(false);
1722  }
1723  }
1724  }
1725 
1726  // Overline
1727  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
1728  rFont.SetOverline( LINESTYLE_NONE );
1729  rCJKFont.SetOverline( LINESTYLE_NONE );
1730  rCTLFont.SetOverline( LINESTYLE_NONE );
1731 
1732  m_xOverlineLB->set_active( 0 );
1733  eState = rSet->GetItemState( nWhich );
1734 
1735  if ( eState >= SfxItemState::DONTCARE )
1736  {
1737  if ( eState == SfxItemState::DONTCARE )
1738  m_xOverlineLB->set_active(-1);
1739  else
1740  {
1741  const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>(rSet->Get( nWhich ));
1742  FontLineStyle eOverline = rItem.GetValue();
1743  rFont.SetOverline( eOverline );
1744  rCJKFont.SetOverline( eOverline );
1745  rCTLFont.SetOverline( eOverline );
1746 
1747  if ( eOverline != LINESTYLE_NONE )
1748  {
1749  auto nPos = m_xOverlineLB->find_id(OUString::number(eOverline));
1750  if (nPos != -1)
1751  {
1752  m_xOverlineLB->set_active(nPos);
1753  bEnable = true;
1754  }
1755  Color aColor = rItem.GetColor();
1756  m_xOverlineColorLB->SelectEntry(aColor);
1757  }
1758  else
1759  {
1760  m_xOverlineColorLB->SelectEntry(COL_AUTO);
1761  m_xOverlineColorLB->set_sensitive(false);
1762  }
1763  }
1764  }
1765 
1766  // Strikeout
1767  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
1768  rFont.SetStrikeout( STRIKEOUT_NONE );
1769  rCJKFont.SetStrikeout( STRIKEOUT_NONE );
1770  rCTLFont.SetStrikeout( STRIKEOUT_NONE );
1771 
1772  m_xStrikeoutLB->set_active( 0 );
1773  eState = rSet->GetItemState( nWhich );
1774 
1775  if ( eState >= SfxItemState::DONTCARE )
1776  {
1777  if ( eState == SfxItemState::DONTCARE )
1778  m_xStrikeoutLB->set_active(-1);
1779  else
1780  {
1781  const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>(rSet->Get( nWhich ));
1782  FontStrikeout eStrikeout = rItem.GetValue();
1783  rFont.SetStrikeout( eStrikeout );
1784  rCJKFont.SetStrikeout( eStrikeout );
1785  rCTLFont.SetStrikeout( eStrikeout );
1786 
1787  if ( eStrikeout != STRIKEOUT_NONE )
1788  {
1789  auto nPos = m_xStrikeoutLB->find_id(OUString::number(eStrikeout));
1790  if (nPos != -1)
1791  {
1792  m_xStrikeoutLB->set_active(nPos);
1793  bEnable = true;
1794  }
1795  }
1796  }
1797  }
1798 
1799  // WordLineMode
1800  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
1801  eState = rSet->GetItemState( nWhich );
1802 
1803  switch ( eState )
1804  {
1805  case SfxItemState::UNKNOWN:
1807  m_xIndividualWordsBtn->hide();
1808  break;
1809 
1810  case SfxItemState::DISABLED:
1812  m_xIndividualWordsBtn->set_sensitive(false);
1813  break;
1814 
1815  case SfxItemState::DONTCARE:
1817  m_xIndividualWordsBtn->set_state( TRISTATE_INDET );
1818  break;
1819 
1820  case SfxItemState::DEFAULT:
1821  case SfxItemState::SET:
1822  {
1823  const SvxWordLineModeItem& rItem = static_cast<const SvxWordLineModeItem&>(rSet->Get( nWhich ));
1824  rFont.SetWordLineMode( rItem.GetValue() );
1825  rCJKFont.SetWordLineMode( rItem.GetValue() );
1826  rCTLFont.SetWordLineMode( rItem.GetValue() );
1827 
1829  m_xIndividualWordsBtn->set_active(rItem.GetValue());
1830  m_xIndividualWordsBtn->set_sensitive(bEnable);
1831  break;
1832  }
1833  }
1834 
1835  // Emphasis
1836  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
1837  eState = rSet->GetItemState( nWhich );
1838 
1839  if ( eState >= SfxItemState::DEFAULT )
1840  {
1841  const SvxEmphasisMarkItem& rItem = static_cast<const SvxEmphasisMarkItem&>(rSet->Get( nWhich ));
1842  FontEmphasisMark eMark = rItem.GetEmphasisMark();
1843  rFont.SetEmphasisMark( eMark );
1844  rCJKFont.SetEmphasisMark( eMark );
1845  rCTLFont.SetEmphasisMark( eMark );
1846 
1847  m_xEmphasisLB->set_active( static_cast<sal_Int32>(FontEmphasisMark( eMark & FontEmphasisMark::Style )) );
1848  eMark &= ~FontEmphasisMark::Style;
1849  int nEntryData = ( eMark == FontEmphasisMark::PosAbove )
1851  : ( eMark == FontEmphasisMark::PosBelow ) ? CHRDLG_POSITION_UNDER : 0;
1852 
1853  auto nPos = m_xPositionLB->find_id(OUString::number(nEntryData));
1854  if (nPos != -1)
1855  m_xPositionLB->set_active(nPos);
1856  }
1857  else if ( eState == SfxItemState::DONTCARE )
1858  m_xEmphasisLB->set_active(-1);
1859  else if ( eState == SfxItemState::UNKNOWN )
1860  {
1861  m_xEmphasisFT->hide();
1862  m_xEmphasisLB->hide();
1863  }
1864  else // SfxItemState::DISABLED
1865  {
1866  m_xEmphasisFT->set_sensitive(false);
1867  m_xEmphasisLB->set_sensitive(false);
1868  }
1869 
1870  // the select handler for the underline/overline/strikeout list boxes
1872 
1873  // the select handler for the emphasis listbox
1875 
1876  // Effects
1877  SvxCaseMap eCaseMap = SvxCaseMap::End;
1878  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
1879  eState = rSet->GetItemState( nWhich );
1880  switch ( eState )
1881  {
1882  case SfxItemState::UNKNOWN:
1883  m_xEffectsFT->hide();
1884  m_xEffectsLB->hide();
1885  break;
1886 
1887  case SfxItemState::DISABLED:
1888  m_xEffectsFT->set_sensitive(false);
1889  m_xEffectsLB->set_sensitive(false);
1890  break;
1891 
1892  case SfxItemState::DONTCARE:
1893  m_xEffectsLB->set_active(-1);
1894  break;
1895 
1896  case SfxItemState::DEFAULT:
1897  case SfxItemState::SET:
1898  {
1899  const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>(rSet->Get( nWhich ));
1900  eCaseMap = rItem.GetValue();
1901  break;
1902  }
1903  }
1904  SetCaseMap_Impl( eCaseMap );
1905 
1906  //Relief
1907  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
1908  eState = rSet->GetItemState( nWhich );
1909  switch ( eState )
1910  {
1911  case SfxItemState::UNKNOWN:
1912  m_xReliefFT->hide();
1913  m_xReliefLB->hide();
1914  break;
1915 
1916  case SfxItemState::DISABLED:
1917  m_xReliefFT->set_sensitive(false);
1918  m_xReliefLB->set_sensitive(false);
1919  break;
1920 
1921  case SfxItemState::DONTCARE:
1922  m_xReliefLB->set_active(-1);
1923  break;
1924 
1925  case SfxItemState::DEFAULT:
1926  case SfxItemState::SET:
1927  {
1928  const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>(rSet->Get( nWhich ));
1929  m_xReliefLB->set_active(static_cast<sal_Int32>(rItem.GetValue()));
1930  SelectHdl_Impl(m_xReliefLB.get());
1931  break;
1932  }
1933  }
1934 
1935  // Outline
1936  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
1937  eState = rSet->GetItemState( nWhich );
1938  switch ( eState )
1939  {
1940  case SfxItemState::UNKNOWN:
1942  m_xOutlineBtn->hide();
1943  break;
1944 
1945  case SfxItemState::DISABLED:
1947  m_xOutlineBtn->set_sensitive(false);
1948  break;
1949 
1950  case SfxItemState::DONTCARE:
1952  m_xOutlineBtn->set_state(TRISTATE_INDET);
1953  break;
1954 
1955  case SfxItemState::DEFAULT:
1956  case SfxItemState::SET:
1957  {
1958  const SvxContourItem& rItem = static_cast<const SvxContourItem&>(rSet->Get( nWhich ));
1960  m_xOutlineBtn->set_state(static_cast<TriState>(rItem.GetValue()));
1961  break;
1962  }
1963  }
1964 
1965  // Shadow
1966  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
1967  eState = rSet->GetItemState( nWhich );
1968 
1969  switch ( eState )
1970  {
1971  case SfxItemState::UNKNOWN:
1973  m_xShadowBtn->hide();
1974  break;
1975 
1976  case SfxItemState::DISABLED:
1978  m_xShadowBtn->set_sensitive(false);
1979  break;
1980 
1981  case SfxItemState::DONTCARE:
1983  m_xShadowBtn->set_state( TRISTATE_INDET );
1984  break;
1985 
1986  case SfxItemState::DEFAULT:
1987  case SfxItemState::SET:
1988  {
1989  const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>(rSet->Get( nWhich ));
1991  m_xShadowBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
1992  break;
1993  }
1994  }
1995 
1996  // Hidden
1997  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
1998  eState = rSet->GetItemState( nWhich );
1999 
2000  switch ( eState )
2001  {
2002  case SfxItemState::UNKNOWN:
2004  m_xHiddenBtn->hide();
2005  break;
2006 
2007  case SfxItemState::DISABLED:
2009  m_xHiddenBtn->set_sensitive(false);
2010  break;
2011 
2012  case SfxItemState::DONTCARE:
2014  m_xHiddenBtn->set_state(TRISTATE_INDET);
2015  break;
2016 
2017  case SfxItemState::DEFAULT:
2018  case SfxItemState::SET:
2019  {
2020  const SvxCharHiddenItem& rItem = static_cast<const SvxCharHiddenItem&>(rSet->Get( nWhich ));
2022  m_xHiddenBtn->set_state(static_cast<TriState>(rItem.GetValue()));
2023  break;
2024  }
2025  }
2026 
2027  SetPrevFontWidthScale( *rSet );
2028  ResetColor_Impl( *rSet );
2029 
2030  // preview update
2031  m_aPreviewWin.Invalidate();
2032 
2033  // save this settings
2034  ChangesApplied();
2035 }
2036 
2037 IMPL_LINK(SvxCharEffectsPage, HiddenBtnClickHdl, weld::Toggleable&, rToggle, void)
2038 {
2039  m_aHiddenState.ButtonToggled(rToggle);
2040 }
2041 
2042 IMPL_LINK(SvxCharEffectsPage, OutlineBtnClickHdl, weld::Toggleable&, rToggle, void)
2043 {
2044  m_aOutlineState.ButtonToggled(rToggle);
2045  UpdatePreview_Impl();
2046 }
2047 
2048 IMPL_LINK(SvxCharEffectsPage, ShadowBtnClickHdl, weld::Toggleable&, rToggle, void)
2049 {
2050  m_aShadowState.ButtonToggled(rToggle);
2051  UpdatePreview_Impl();
2052 }
2053 
2055 {
2056  m_xUnderlineLB->save_value();
2057  m_xOverlineLB->save_value();
2058  m_xStrikeoutLB->save_value();
2059  m_xIndividualWordsBtn->save_state();
2060  m_xEmphasisLB->save_value();
2061  m_xPositionLB->save_value();
2062  m_xEffectsLB->save_value();
2063  m_xReliefLB->save_value();
2064  m_xOutlineBtn->save_state();
2065  m_xShadowBtn->save_state();
2066  m_xHiddenBtn->save_state();
2067  m_xFontTransparencyMtr->save_value();
2068 }
2069 
2071 {
2072  const SfxPoolItem* pOld = nullptr;
2073  const SfxItemSet& rOldSet = GetItemSet();
2074  bool bModified = false;
2075  bool bChanged = true;
2076 
2077  // Underline
2078  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2079  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_UNDERLINE );
2080  auto nPos = m_xUnderlineLB->get_active();
2081  FontLineStyle eUnder = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
2082 
2083  if ( pOld )
2084  {
2089  bool bAllowChg = nPos != -1 &&
2090  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2091 
2092  const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld);
2093  if ( rItem.GetValue() == eUnder &&
2094  ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) &&
2095  ! bAllowChg )
2096  bChanged = false;
2097  }
2098 
2099  if ( bChanged )
2100  {
2101  SvxUnderlineItem aNewItem( eUnder, nWhich );
2102  aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() );
2103  rSet->Put( aNewItem );
2104  bModified = true;
2105  }
2106  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2107  rSet->InvalidateItem(nWhich);
2108 
2109  bChanged = true;
2110 
2111  // Overline
2112  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2113  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_OVERLINE );
2114  nPos = m_xOverlineLB->get_active();
2115  FontLineStyle eOver = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
2116 
2117  if ( pOld )
2118  {
2123  bool bAllowChg = nPos != -1 &&
2124  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2125 
2126  const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld);
2127  if ( rItem.GetValue() == eOver &&
2128  ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) &&
2129  ! bAllowChg )
2130  bChanged = false;
2131  }
2132 
2133  if ( bChanged )
2134  {
2135  SvxOverlineItem aNewItem( eOver, nWhich );
2136  aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() );
2137  rSet->Put( aNewItem );
2138  bModified = true;
2139  }
2140  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2141  rSet->InvalidateItem(nWhich);
2142 
2143  bChanged = true;
2144 
2145  // Strikeout
2146  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2147  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_STRIKEOUT );
2148  nPos = m_xStrikeoutLB->get_active();
2149  FontStrikeout eStrike = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
2150 
2151  if ( pOld )
2152  {
2157  bool bAllowChg = nPos != -1 &&
2158  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2159 
2160  const SvxCrossedOutItem& rItem = *static_cast<const SvxCrossedOutItem*>(pOld);
2161  if ( !m_xStrikeoutLB->get_sensitive()
2162  || (rItem.GetValue() == eStrike && !bAllowChg) )
2163  bChanged = false;
2164  }
2165 
2166  if ( bChanged )
2167  {
2168  rSet->Put( SvxCrossedOutItem( eStrike, nWhich ) );
2169  bModified = true;
2170  }
2171  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2172  rSet->InvalidateItem(nWhich);
2173 
2174  bChanged = true;
2175 
2176  // Individual words
2177  const SfxItemSet* pExampleSet = GetDialogExampleSet();
2178  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2179  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_WORDLINEMODE );
2180  TriState eState = m_xIndividualWordsBtn->get_state();
2181  const SfxPoolItem* pItem;
2182 
2183  if ( pOld )
2184  {
2185  const SvxWordLineModeItem& rItem = *static_cast<const SvxWordLineModeItem*>(pOld);
2186  if ( rItem.GetValue() == StateToAttr( eState ) && m_xIndividualWordsBtn->get_saved_state() == eState )
2187  bChanged = false;
2188  }
2189 
2190  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2191  !StateToAttr( eState ) && static_cast<const SvxWordLineModeItem*>(pItem)->GetValue() )
2192  bChanged = true;
2193 
2194  if ( bChanged && eState != TRISTATE_INDET )
2195  {
2196  rSet->Put( SvxWordLineModeItem( StateToAttr( eState ), nWhich ) );
2197  bModified = true;
2198  }
2199  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2200  rSet->InvalidateItem(nWhich);
2201 
2202  bChanged = true;
2203 
2204  // Emphasis
2205  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2206  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_EMPHASISMARK );
2207  int nMarkPos = m_xEmphasisLB->get_active();
2208  OUString sMarkPos = m_xEmphasisLB->get_active_text();
2209  OUString sPosPos = m_xPositionLB->get_active_text();
2210  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nMarkPos);
2211  if (m_xPositionLB->get_sensitive())
2212  {
2213  eMark |= (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32())
2214  ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
2215  }
2216 
2217  if ( pOld )
2218  {
2219  if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE )
2220  {
2221  const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld);
2222  if ( rItem.GetEmphasisMark() == eMark )
2223  bChanged = false;
2224  }
2225  }
2226 
2227  if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
2228  m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos)
2229  {
2230  bChanged = false;
2231  }
2232 
2233  if (bChanged)
2234  {
2235  rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2236  bModified = true;
2237  }
2238  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2239  rSet->InvalidateItem(nWhich);
2240 
2241  bChanged = true;
2242 
2243  // Effects
2244  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2245  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CASEMAP );
2246  SvxCaseMap eCaseMap = SvxCaseMap::NotMapped;
2247  bool bChecked = false;
2248  auto nCapsPos = m_xEffectsLB->get_active();
2249  if (nCapsPos != -1)
2250  {
2251  eCaseMap = static_cast<SvxCaseMap>(nCapsPos);
2252  bChecked = true;
2253  }
2254 
2255  if ( pOld )
2256  {
2261  bool bAllowChg = nPos != -1 &&
2262  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2263 
2264  const SvxCaseMapItem& rItem = *static_cast<const SvxCaseMapItem*>(pOld);
2265  if ( rItem.GetValue() == eCaseMap && !bAllowChg )
2266  bChanged = false;
2267  }
2268 
2269  if ( bChanged && bChecked )
2270  {
2271  rSet->Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2272  bModified = true;
2273  }
2274  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2275  rSet->InvalidateItem(nWhich);
2276 
2277  bChanged = true;
2278 
2279  //Relief
2280  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2281  if (m_xReliefLB->get_value_changed_from_saved())
2282  {
2283  m_xReliefLB->save_value();
2284  SvxCharReliefItem aRelief(static_cast<FontRelief>(m_xReliefLB->get_active()), nWhich);
2285  rSet->Put(aRelief);
2286  }
2287 
2288  // Outline
2289  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2290  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CONTOUR );
2291  eState = m_xOutlineBtn->get_state();
2292 
2293  if ( pOld )
2294  {
2295  const SvxContourItem& rItem = *static_cast<const SvxContourItem*>(pOld);
2296  if ( rItem.GetValue() == StateToAttr( eState ) && m_xOutlineBtn->get_saved_state() == eState )
2297  bChanged = false;
2298  }
2299 
2300  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2301  !StateToAttr( eState ) && static_cast<const SvxContourItem*>(pItem)->GetValue() )
2302  bChanged = true;
2303 
2304  if ( bChanged && eState != TRISTATE_INDET )
2305  {
2306  rSet->Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2307  bModified = true;
2308  }
2309  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2310  rSet->InvalidateItem(nWhich);
2311 
2312  bChanged = true;
2313 
2314  // Shadow
2315  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2316  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_SHADOWED );
2317  eState = m_xShadowBtn->get_state();
2318 
2319  if ( pOld )
2320  {
2321  const SvxShadowedItem& rItem = *static_cast<const SvxShadowedItem*>(pOld);
2322  if ( rItem.GetValue() == StateToAttr( eState ) && m_xShadowBtn->get_saved_state() == eState )
2323  bChanged = false;
2324  }
2325 
2326  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2327  !StateToAttr( eState ) && static_cast<const SvxShadowedItem*>(pItem)->GetValue() )
2328  bChanged = true;
2329 
2330  if ( bChanged && eState != TRISTATE_INDET )
2331  {
2332  rSet->Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2333  bModified = true;
2334  }
2335  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2336  rSet->InvalidateItem(nWhich);
2337 
2338  bChanged = true;
2339 
2340  // Hidden
2341  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2342  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_HIDDEN );
2343  eState = m_xHiddenBtn->get_state();
2344  bChanged = true;
2345 
2346  if ( pOld )
2347  {
2348  const SvxCharHiddenItem& rItem = *static_cast<const SvxCharHiddenItem*>(pOld);
2349  if ( rItem.GetValue() == StateToAttr( eState ) && m_xHiddenBtn->get_saved_state() == eState )
2350  bChanged = false;
2351  }
2352 
2353  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2354  !StateToAttr( eState ) && static_cast<const SvxCharHiddenItem*>(pItem)->GetValue() )
2355  bChanged = true;
2356 
2357  if ( bChanged && eState != TRISTATE_INDET )
2358  {
2359  rSet->Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2360  bModified = true;
2361  }
2362  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2363  rSet->InvalidateItem(nWhich);
2364 
2365  bModified |= FillItemSetColor_Impl( *rSet );
2366 
2367  return bModified;
2368 }
2369 
2370 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2371 {
2372  if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2373  {
2374  m_xEffectsFT->set_sensitive(false);
2375  m_xEffectsLB->set_sensitive(false);
2376  }
2377 }
2378 
2380 {
2381  const SfxUInt16Item* pDisableCtlItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
2382  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
2383  if (pDisableCtlItem)
2384  DisableControls(pDisableCtlItem->GetValue());
2385 
2386  if (!pFlagItem)
2387  return;
2388 
2389  sal_uInt32 nFlags=pFlagItem->GetValue();
2390  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2391  // the writer uses SID_ATTR_BRUSH as font background
2393  if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY)
2394  {
2395  // Only show these in case client code explicitly wants this.
2396  m_xFontTransparencyFT->hide();
2397  m_xFontTransparencyMtr->hide();
2398  }
2399 }
2400 
2401 // class SvxCharPositionPage ---------------------------------------------
2402 
2404  : SvxCharBasePage(pPage, pController, "cui/ui/positionpage.ui", "PositionPage", rInSet)
2405  , m_nSuperEsc(short(DFLT_ESC_SUPER))
2406  , m_nSubEsc(short(DFLT_ESC_SUB))
2407  , m_nScaleWidthItemSetVal(100)
2408  , m_nScaleWidthInitialVal(100)
2409  , m_nSuperProp(sal_uInt8(DFLT_ESC_PROP))
2410  , m_nSubProp(sal_uInt8(DFLT_ESC_PROP))
2411  , m_xHighPosBtn(m_xBuilder->weld_radio_button("superscript"))
2412  , m_xNormalPosBtn(m_xBuilder->weld_radio_button("normal"))
2413  , m_xLowPosBtn(m_xBuilder->weld_radio_button("subscript"))
2414  , m_xHighLowFT(m_xBuilder->weld_label("raiselower"))
2415  , m_xHighLowMF(m_xBuilder->weld_metric_spin_button("raiselowersb", FieldUnit::PERCENT))
2416  , m_xHighLowRB(m_xBuilder->weld_check_button("automatic"))
2417  , m_xFontSizeFT(m_xBuilder->weld_label("relativefontsize"))
2418  , m_xFontSizeMF(m_xBuilder->weld_metric_spin_button("fontsizesb", FieldUnit::PERCENT))
2419  , m_xRotationContainer(m_xBuilder->weld_widget("rotationcontainer"))
2420  , m_xScalingFT(m_xBuilder->weld_label("scale"))
2421  , m_xScalingAndRotationFT(m_xBuilder->weld_label("rotateandscale"))
2422  , m_x0degRB(m_xBuilder->weld_radio_button("0deg"))
2423  , m_x90degRB(m_xBuilder->weld_radio_button("90deg"))
2424  , m_x270degRB(m_xBuilder->weld_radio_button("270deg"))
2425  , m_xFitToLineCB(m_xBuilder->weld_check_button("fittoline"))
2426  , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT))
2427  , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT))
2428  , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning"))
2429 {
2430  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
2431 #ifdef IOS
2432  m_xPreviewWin->hide();
2433 #endif
2434  Initialize();
2435 }
2436 
2438 {
2439 }
2440 
2441 
2443 {
2444  // to handle the changes of the other pages
2446 
2447  GetPreviewFont().SetFontSize( Size( 0, 240 ) );
2448  GetPreviewCJKFont().SetFontSize( Size( 0, 240 ) );
2449  GetPreviewCTLFont().SetFontSize( Size( 0, 240 ) );
2450 
2451  m_xNormalPosBtn->set_active(true);
2452  PositionHdl_Impl(*m_xNormalPosBtn);
2453 
2454  Link<weld::Toggleable&,void> aLink2 = LINK(this, SvxCharPositionPage, PositionHdl_Impl);
2455  m_xHighPosBtn->connect_toggled(aLink2);
2456  m_xNormalPosBtn->connect_toggled(aLink2);
2457  m_xLowPosBtn->connect_toggled(aLink2);
2458 
2459  aLink2 = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
2460  m_x0degRB->connect_toggled(aLink2);
2461  m_x90degRB->connect_toggled(aLink2);
2462  m_x270degRB->connect_toggled(aLink2);
2463 
2464  Link<weld::MetricSpinButton&,void> aLink3 = LINK(this, SvxCharPositionPage, ValueChangedHdl_Impl);
2465  m_xHighLowMF->connect_value_changed(aLink3);
2466  m_xFontSizeMF->connect_value_changed(aLink3);
2467 
2468  m_xHighLowRB->connect_toggled(LINK(this, SvxCharPositionPage, AutoPositionHdl_Impl));
2469  m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl));
2470  m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl));
2471  m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl));
2472 }
2473 
2475 {
2476  SetPrevFontEscapement( nProp, nEscProp, nEsc );
2477 }
2478 
2479 
2481 {
2482  SvxEscapementItem aEscItm( nEsc, SID_ATTR_CHAR_ESCAPEMENT );
2483 
2484  if ( SvxEscapement::Superscript == nEsc )
2485  {
2486  aEscItm.GetEsc() = m_nSuperEsc;
2487  aEscItm.GetProportionalHeight() = m_nSuperProp;
2488  }
2489  else if ( SvxEscapement::Subscript == nEsc )
2490  {
2491  aEscItm.GetEsc() = m_nSubEsc;
2492  aEscItm.GetProportionalHeight() = m_nSubProp;
2493  }
2494 
2495  short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
2496 
2497  m_xHighLowMF->set_value(aEscItm.GetEsc() * nFac, FieldUnit::PERCENT);
2498  m_xFontSizeMF->set_value(aEscItm.GetProportionalHeight(), FieldUnit::PERCENT);
2499 
2500  if ( SvxEscapement::Off == nEsc )
2501  {
2502  m_xHighLowFT->set_sensitive(false);
2503  m_xHighLowMF->set_sensitive(false);
2504  m_xFontSizeFT->set_sensitive(false);
2505  m_xFontSizeMF->set_sensitive(false);
2506  m_xHighLowRB->set_sensitive(false);
2507  }
2508  else
2509  {
2510  m_xFontSizeFT->set_sensitive(true);
2511  m_xFontSizeMF->set_sensitive(true);
2512  m_xHighLowRB->set_sensitive(true);
2513 
2514  if (!m_xHighLowRB->get_active())
2515  {
2516  m_xHighLowFT->set_sensitive(true);
2517  m_xHighLowMF->set_sensitive(true);
2518  }
2519  else
2520  AutoPositionHdl_Impl(*m_xHighLowRB);
2521  }
2522 
2523  UpdatePreview_Impl( 100, aEscItm.GetProportionalHeight(), aEscItm.GetEsc() );
2524 }
2525 
2526 
2528 {
2529  SvxEscapement nEsc = SvxEscapement::Off; // also when pBtn == NULL
2530 
2531  if (m_xHighPosBtn->get_active())
2532  nEsc = SvxEscapement::Superscript;
2533  else if (m_xLowPosBtn->get_active())
2534  nEsc = SvxEscapement::Subscript;
2535 
2536  SetEscapement_Impl( nEsc );
2537 }
2538 
2540 {
2541  bool bEnable = false;
2542  if (m_x90degRB->get_active() || m_x270degRB->get_active())
2543  bEnable = true;
2544  else
2545  OSL_ENSURE(m_x0degRB->get_active(), "unexpected button");
2546  m_xFitToLineCB->set_sensitive(bEnable);
2547 }
2548 
2550 {
2551  sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2552  short nEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2553  nEsc *= m_xLowPosBtn->get_active() ? -1 : 1;
2554  UpdatePreview_Impl( 100, nEscProp, nEsc );
2555 }
2556 
2557 IMPL_LINK(SvxCharPositionPage, AutoPositionHdl_Impl, weld::Toggleable&, rBox, void)
2558 {
2559  if (rBox.get_active())
2560  {
2561  m_xHighLowFT->set_sensitive(false);
2562  m_xHighLowMF->set_sensitive(false);
2563  }
2564  else
2565  PositionHdl_Impl(m_xHighPosBtn->get_active() ? *m_xHighPosBtn
2566  : m_xLowPosBtn->get_active() ? *m_xLowPosBtn
2567  : *m_xNormalPosBtn);
2568 }
2569 
2571 {
2572  sal_uInt16 nVal = m_nScaleWidthInitialVal;
2573  if (m_xFitToLineCB->get_active())
2574  nVal = m_nScaleWidthItemSetVal;
2575  m_xScaleWidthMF->set_value(nVal, FieldUnit::PERCENT);
2576  m_aPreviewWin.SetFontWidthScale( nVal );
2577 }
2578 
2580 {
2581  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2583 
2584  tools::Long nKern = static_cast<short>(m_xKerningMF->denormalize(nVal));
2585 
2586  SvxFont& rFont = GetPreviewFont();
2587  SvxFont& rCJKFont = GetPreviewCJKFont();
2588  SvxFont& rCTLFont = GetPreviewCTLFont();
2589 
2590  rFont.SetFixKerning( static_cast<short>(nKern) );
2591  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2592  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2593  m_aPreviewWin.Invalidate();
2594 }
2595 
2596 IMPL_LINK(SvxCharPositionPage, ValueChangedHdl_Impl, weld::MetricSpinButton&, rField, void)
2597 {
2598  bool bHigh = m_xHighPosBtn->get_active();
2599  bool bLow = m_xLowPosBtn->get_active();
2600  DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
2601 
2602  if (m_xHighLowMF.get() == &rField)
2603  {
2604  if ( bLow )
2605  m_nSubEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT)) * -1;
2606  else
2607  m_nSuperEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2608  }
2609  else if (m_xFontSizeMF.get() == &rField)
2610  {
2611  if ( bLow )
2612  m_nSubProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2613  else
2614  m_nSuperProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2615  }
2616 
2617  FontModifyHdl_Impl();
2618 }
2619 
2621 {
2622  m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)));
2623 }
2624 
2626 {
2627  if ( _pSet )
2628  FillItemSet( _pSet );
2629  return DeactivateRC::LeavePage;
2630 }
2631 
2632 std::unique_ptr<SfxTabPage> SvxCharPositionPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2633 {
2634  return std::make_unique<SvxCharPositionPage>(pPage, pController, *rSet);
2635 }
2636 
2638 {
2639  OUString sUser = GetUserData();
2640 
2641  if ( !sUser.isEmpty() )
2642  {
2643  sal_Int32 nIdx {0};
2644  m_nSuperEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx )));
2645  m_nSubEsc = static_cast<short>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx )));
2646  m_nSuperProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx )));
2647  m_nSubProp = static_cast<sal_uInt8>(o3tl::toInt32(o3tl::getToken(sUser, 0, ';', nIdx )));
2648 
2649  m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT);
2650 
2651  //fdo#75307 validate all the entries and discard all of them if any are
2652  //out of range
2653  bool bValid = true;
2654  if (m_nSuperEsc < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSuperEsc > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2655  bValid = false;
2656  if (m_nSubEsc*-1 < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSubEsc*-1 > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2657  bValid = false;
2658  if (m_nSuperProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSuperProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2659  bValid = false;
2660  if (m_nSubProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSubProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2661  bValid = false;
2662 
2663  if (!bValid)
2664  {
2669  }
2670  }
2671 
2672  short nEsc = 0;
2673  sal_uInt8 nEscProp = 100;
2674 
2675  m_xHighLowFT->set_sensitive(false);
2676  m_xHighLowMF->set_sensitive(false);
2677  m_xFontSizeFT->set_sensitive(false);
2678  m_xFontSizeMF->set_sensitive(false);
2679 
2680  SvxFont& rFont = GetPreviewFont();
2681  SvxFont& rCJKFont = GetPreviewCJKFont();
2682  SvxFont& rCTLFont = GetPreviewCTLFont();
2683  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2684 
2685  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2686  {
2687  const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>(rSet->Get( nWhich ));
2688  nEsc = rItem.GetEsc();
2689  nEscProp = rItem.GetProportionalHeight();
2690 
2691  if ( nEsc != 0 )
2692  {
2693  m_xHighLowFT->set_sensitive(true);
2694  m_xHighLowMF->set_sensitive(true);
2695  m_xFontSizeFT->set_sensitive(true);
2696  m_xFontSizeMF->set_sensitive(true);
2697 
2698  short nFac;
2699  bool bAutomatic(false);
2700 
2701  if ( nEsc > 0 )
2702  {
2703  nFac = 1;
2704  m_xHighPosBtn->set_active(true);
2705  if ( nEsc == DFLT_ESC_AUTO_SUPER )
2706  {
2707  nEsc = .8 * (100 - nEscProp); //approximation of actual percentage used
2708  bAutomatic = true;
2709  }
2710  }
2711  else
2712  {
2713  nFac = -1;
2714  m_xLowPosBtn->set_active(true);
2715  if ( nEsc == DFLT_ESC_AUTO_SUB )
2716  {
2717  nEsc = .2 * -(100 - nEscProp); //approximation of actual percentage used
2718  bAutomatic = true;
2719  }
2720  }
2721  if (!m_xHighLowRB->get_sensitive())
2722  {
2723  m_xHighLowRB->set_sensitive(true);
2724  }
2725  m_xHighLowRB->set_active(bAutomatic);
2726 
2727  if (m_xHighLowRB->get_active())
2728  {
2729  m_xHighLowFT->set_sensitive(false);
2730  m_xHighLowMF->set_sensitive(false);
2731  }
2732  m_xHighLowMF->set_value(m_xHighLowMF->normalize(nFac * nEsc), FieldUnit::PERCENT);
2733  }
2734  else
2735  {
2736  m_xNormalPosBtn->set_active(true);
2737  m_xHighLowRB->set_active(true);
2738  PositionHdl_Impl(*m_xNormalPosBtn);
2739  }
2740  //the height has to be set after the handler is called to keep the value also if the escapement is zero
2741  m_xFontSizeMF->set_value(m_xFontSizeMF->normalize(nEscProp), FieldUnit::PERCENT);
2742  }
2743  else
2744  {
2745  m_xHighPosBtn->set_active(false);
2746  m_xNormalPosBtn->set_active(false);
2747  m_xLowPosBtn->set_active(false);
2748  }
2749 
2750  // set BspFont
2751  SetPrevFontEscapement( 100, nEscProp, nEsc );
2752 
2753  // Kerning
2754  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2755 
2756  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2757  {
2758  const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>(rSet->Get( nWhich ));
2759  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2760  tools::Long nBig = static_cast<tools::Long>(m_xKerningMF->normalize( static_cast<tools::Long>(rItem.GetValue()) ));
2761  tools::Long nKerning = OutputDevice::LogicToLogic(nBig, eUnit, MapUnit::MapPoint);
2762 
2763  // set Kerning at the Font, convert into Twips before
2764  tools::Long nKern = OutputDevice::LogicToLogic(rItem.GetValue(), eUnit, MapUnit::MapTwip);
2765  rFont.SetFixKerning( static_cast<short>(nKern) );
2766  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2767  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2768 
2769  //the attribute value must be displayed also if it's above the maximum allowed value
2770  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_max(FieldUnit::POINT));
2771  if(nVal < nKerning)
2772  m_xKerningMF->set_max(nKerning, FieldUnit::POINT);
2773  m_xKerningMF->set_value(nKerning, FieldUnit::POINT);
2774  }
2775  else
2776  m_xKerningMF->set_text(OUString());
2777 
2778  // Pair kerning
2779  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2780 
2781  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2782  {
2783  const SvxAutoKernItem& rItem = static_cast<const SvxAutoKernItem&>(rSet->Get( nWhich ));
2784  m_xPairKerningBtn->set_active(rItem.GetValue());
2785  }
2786  else
2787  m_xPairKerningBtn->set_active(false);
2788 
2789  // Scale Width
2790  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2791  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2792  {
2793  const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet->Get( nWhich ) );
2794  m_nScaleWidthInitialVal = rItem.GetValue();
2795  m_xScaleWidthMF->set_value(m_nScaleWidthInitialVal, FieldUnit::PERCENT);
2796  }
2797  else
2798  m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT);
2799 
2800  if ( rSet->GetItemState( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) >= SfxItemState::DEFAULT )
2801  m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE )).GetValue();
2802 
2803  // Rotation
2804  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2805  SfxItemState eState = rSet->GetItemState( nWhich );
2806  if( SfxItemState::UNKNOWN == eState )
2807  {
2808  m_xRotationContainer->hide();
2809  m_xScalingAndRotationFT->hide();
2810  m_xScalingFT->show();
2811  }
2812  else
2813  {
2814  m_xRotationContainer->show();
2815  m_xScalingAndRotationFT->show();
2816  m_xScalingFT->hide();
2817 
2818  if( eState >= SfxItemState::DEFAULT )
2819  {
2820  const SvxCharRotateItem& rItem =
2821  static_cast<const SvxCharRotateItem&>( rSet->Get( nWhich ));
2822  if (rItem.IsBottomToTop())
2823  m_x90degRB->set_active(true);
2824  else if (rItem.IsTopToBottom())
2825  m_x270degRB->set_active(true);
2826  else
2827  {
2828  DBG_ASSERT( 0_deg10 == rItem.GetValue(), "incorrect value" );
2829  m_x0degRB->set_active(true);
2830  }
2831  m_xFitToLineCB->set_active(rItem.IsFitToLine());
2832  }
2833  else
2834  {
2835  if( eState == SfxItemState::DONTCARE )
2836  {
2837  m_x0degRB->set_active(false);
2838  m_x90degRB->set_active(false);
2839  m_x270degRB->set_active(false);
2840  }
2841  else
2842  m_x0degRB->set_active(true);
2843 
2844  m_xFitToLineCB->set_active(false);
2845  }
2846  m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active());
2847 
2848  // is this value set?
2849  if( SfxItemState::UNKNOWN == rSet->GetItemState(
2850  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ))
2851  m_xFitToLineCB->hide();
2852  }
2853  ChangesApplied();
2854 }
2855 
2857 {
2858  m_xHighPosBtn->save_state();
2859  m_xNormalPosBtn->save_state();
2860  m_xLowPosBtn->save_state();
2861  m_xHighLowRB->save_state();
2862  m_x0degRB->save_state();
2863  m_x90degRB->save_state();
2864  m_x270degRB->save_state();
2865  m_xFitToLineCB->save_state();
2866  m_xScaleWidthMF->save_value();
2867  m_xKerningMF->save_value();
2868  m_xPairKerningBtn->save_state();
2869 }
2870 
2872 {
2873  // Position (high, normal or low)
2874  const SfxItemSet& rOldSet = GetItemSet();
2875  bool bModified = false, bChanged = true;
2876  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2877  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_ESCAPEMENT );
2878  const bool bHigh = m_xHighPosBtn->get_active();
2879  short nEsc;
2880  sal_uInt8 nEscProp;
2881 
2882  if (bHigh || m_xLowPosBtn->get_active())
2883  {
2884  if (m_xHighLowRB->get_active())
2885  nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
2886  else
2887  {
2888  nEsc = static_cast<short>(m_xHighLowMF->denormalize(m_xHighLowMF->get_value(FieldUnit::PERCENT)));
2889  nEsc *= (bHigh ? 1 : -1);
2890  }
2891  nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->denormalize(m_xFontSizeMF->get_value(FieldUnit::PERCENT)));
2892  }
2893  else
2894  {
2895  nEsc = 0;
2896  nEscProp = 100;
2897  }
2898 
2899  if ( pOld )
2900  {
2901  const SvxEscapementItem& rItem = *static_cast<const SvxEscapementItem*>(pOld);
2902  if (rItem.GetEsc() == nEsc && rItem.GetProportionalHeight() == nEscProp)
2903  bChanged = false;
2904  }
2905 
2906  if ( !bChanged && !m_xHighPosBtn->get_saved_state() &&
2907  !m_xNormalPosBtn->get_saved_state() && !m_xLowPosBtn->get_saved_state() )
2908  bChanged = true;
2909 
2910  if ( bChanged &&
2911  ( m_xHighPosBtn->get_active() || m_xNormalPosBtn->get_active() || m_xLowPosBtn->get_active() ) )
2912  {
2913  rSet->Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
2914  bModified = true;
2915  }
2916  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2917  rSet->InvalidateItem(nWhich);
2918 
2919  bChanged = true;
2920 
2921  // Kerning
2922  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2923  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_KERNING );
2924  short nKerning = 0;
2925  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2926 
2927  tools::Long nTmp = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2928  tools::Long nVal = OutputDevice::LogicToLogic(nTmp, MapUnit::MapPoint, eUnit);
2929  nKerning = static_cast<short>(m_xKerningMF->denormalize( nVal ));
2930 
2931  SfxItemState eOldKernState = rOldSet.GetItemState( nWhich, false );
2932  if ( pOld )
2933  {
2934  const SvxKerningItem& rItem = *static_cast<const SvxKerningItem*>(pOld);
2935  if ( (eOldKernState >= SfxItemState::DEFAULT || m_xKerningMF->get_text().isEmpty()) && rItem.GetValue() == nKerning )
2936  bChanged = false;
2937  }
2938 
2939  if ( bChanged )
2940  {
2941  rSet->Put( SvxKerningItem( nKerning, nWhich ) );
2942  bModified = true;
2943  }
2944  else if ( SfxItemState::DEFAULT == eOldKernState )
2945  rSet->InvalidateItem(nWhich);
2946 
2947  // Pair-Kerning
2948  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2949 
2950  if (m_xPairKerningBtn->get_state_changed_from_saved())
2951  {
2952  rSet->Put( SvxAutoKernItem( m_xPairKerningBtn->get_active(), nWhich ) );
2953  bModified = true;
2954  }
2955  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2956  rSet->InvalidateItem(nWhich);
2957 
2958  // Scale Width
2959  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2960  if (m_xScaleWidthMF->get_value_changed_from_saved())
2961  {
2962  rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich));
2963  bModified = true;
2964  }
2965  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2966  rSet->InvalidateItem(nWhich);
2967 
2968  // Rotation
2969  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2970  if ( m_x0degRB->get_state_changed_from_saved() ||
2971  m_x90degRB->get_state_changed_from_saved() ||
2972  m_x270degRB->get_state_changed_from_saved() ||
2973  m_xFitToLineCB->get_state_changed_from_saved() )
2974  {
2975  SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), nWhich );
2976  if (m_x90degRB->get_active())
2977  aItem.SetBottomToTop();
2978  else if (m_x270degRB->get_active())
2979  aItem.SetTopToBottom();
2980  rSet->Put( aItem );
2981  bModified = true;
2982  }
2983  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2984  rSet->InvalidateItem(nWhich);
2985 
2986  return bModified;
2987 }
2988 
2989 
2991 {
2992  static const OUStringLiteral cTok( u";" );
2993 
2994  OUString sUser = OUString::number( m_nSuperEsc ) + cTok +
2995  OUString::number( m_nSubEsc ) + cTok +
2996  OUString::number( m_nSuperProp ) + cTok +
2997  OUString::number( m_nSubProp );
2998  SetUserData( sUser );
2999 }
3000 
3001 
3003 {
3004  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3005  if (pFlagItem)
3006  {
3007  sal_uInt32 nFlags=pFlagItem->GetValue();
3008  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3009  // the writer uses SID_ATTR_BRUSH as font background
3011  }
3012 }
3013 // class SvxCharTwoLinesPage ------------------------------------------------
3014 
3016  : SvxCharBasePage(pPage, pController, "cui/ui/twolinespage.ui", "TwoLinesPage", rInSet)
3017  , m_nStartBracketPosition( 0 )
3018  , m_nEndBracketPosition( 0 )
3019  , m_xTwoLinesBtn(m_xBuilder->weld_check_button("twolines"))
3020  , m_xEnclosingFrame(m_xBuilder->weld_widget("enclosing"))
3021  , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket"))
3022  , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket"))
3023 {
3024  for (size_t i = 0; i < std::size(TWOLINE_OPEN); ++i)
3025  m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first));
3026  for (size_t i = 0; i < std::size(TWOLINE_CLOSE); ++i)
3027  m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first));
3028 
3029  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
3030 #ifdef IOS
3031  m_xPreviewWin->hide();
3032 #endif
3033  Initialize();
3034 }
3035 
3037 {
3038 }
3039 
3041 {
3042  m_xTwoLinesBtn->set_active(false);
3043  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3044 
3045  m_xTwoLinesBtn->connect_toggled(LINK(this, SvxCharTwoLinesPage, TwoLinesHdl_Impl));
3046 
3047  Link<weld::TreeView&,void> aLink = LINK(this, SvxCharTwoLinesPage, CharacterMapHdl_Impl);
3048  m_xStartBracketLB->connect_changed(aLink);
3049  m_xEndBracketLB->connect_changed(aLink);
3050 
3051  SvxFont& rFont = GetPreviewFont();
3052  SvxFont& rCJKFont = GetPreviewCJKFont();
3053  SvxFont& rCTLFont = GetPreviewCTLFont();
3054  rFont.SetFontSize( Size( 0, 220 ) );
3055  rCJKFont.SetFontSize( Size( 0, 220 ) );
3056  rCTLFont.SetFontSize( Size( 0, 220 ) );
3057 }
3058 
3060 {
3061  bool bStart = pBox == m_xStartBracketLB.get();
3062  SvxCharacterMap aDlg(GetFrameWeld(), nullptr, nullptr);
3063  aDlg.DisableFontSelection();
3064 
3065  if (aDlg.run() == RET_OK)
3066  {
3067  sal_Unicode cChar = static_cast<sal_Unicode>(aDlg.GetChar());
3068  SetBracket( cChar, bStart );
3069  }
3070  else
3071  {
3073  }
3074 }
3075 
3076 
3077 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart )
3078 {
3079  int nEntryPos = 0;
3080  weld::TreeView* pBox = bStart ? m_xStartBracketLB.get() : m_xEndBracketLB.get();
3081  if (cBracket == 0)
3082  pBox->select(0);
3083  else
3084  {
3085  bool bFound = false;
3086  for (int i = 1; i < pBox->n_children(); ++i)
3087  {
3088  if (pBox->get_id(i).toInt32() != CHRDLG_ENCLOSE_SPECIAL_CHAR)
3089  {
3090  const sal_Unicode cChar = pBox->get_text(i)[0];
3091  if (cChar == cBracket)
3092  {
3093  pBox->select(i);
3094  nEntryPos = i;
3095  bFound = true;
3096  break;
3097  }
3098  }
3099  }
3100 
3101  if (!bFound)
3102  {
3103  pBox->append_text(OUString(cBracket));
3104  nEntryPos = pBox->n_children() - 1;
3105  pBox->select(nEntryPos);
3106  }
3107  }
3108  if (bStart)
3109  m_nStartBracketPosition = nEntryPos;
3110  else
3111  m_nEndBracketPosition = nEntryPos;
3112 }
3113 
3115 {
3116  bool bChecked = m_xTwoLinesBtn->get_active();
3117  m_xEnclosingFrame->set_sensitive(bChecked);
3118  UpdatePreview_Impl();
3119 }
3120 
3121 IMPL_LINK(SvxCharTwoLinesPage, CharacterMapHdl_Impl, weld::TreeView&, rBox, void)
3122 {
3123  int nPos = rBox.get_selected_index();
3124  if (rBox.get_id(nPos).toInt32() == CHRDLG_ENCLOSE_SPECIAL_CHAR)
3125  SelectCharacter( &rBox );
3126  else
3127  {
3128  bool bStart = &rBox == m_xStartBracketLB.get();
3129  if (bStart)
3130  m_nStartBracketPosition = nPos;
3131  else
3132  m_nEndBracketPosition = nPos;
3133  }
3134  UpdatePreview_Impl();
3135 }
3136 
3138 {
3140 }
3141 
3143 {
3144  if ( _pSet )
3145  FillItemSet( _pSet );
3146  return DeactivateRC::LeavePage;
3147 }
3148 
3149 std::unique_ptr<SfxTabPage> SvxCharTwoLinesPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
3150 {
3151  return std::make_unique<SvxCharTwoLinesPage>(pPage, pController, *rSet);
3152 }
3153 
3155 {
3156  m_xTwoLinesBtn->set_active(false);
3157  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3158  SfxItemState eState = rSet->GetItemState( nWhich );
3159 
3160  if ( eState >= SfxItemState::DONTCARE )
3161  {
3162  const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich ));
3163  m_xTwoLinesBtn->set_active(rItem.GetValue());
3164 
3165  if ( rItem.GetValue() )
3166  {
3167  SetBracket( rItem.GetStartBracket(), true );
3168  SetBracket( rItem.GetEndBracket(), false );
3169  }
3170  }
3171  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3172 
3173  SetPrevFontWidthScale( *rSet );
3174 }
3175 
3177 {
3178  const SfxItemSet& rOldSet = GetItemSet();
3179  bool bModified = false, bChanged = true;
3180  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3181  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_TWO_LINES );
3182  bool bOn = m_xTwoLinesBtn->get_active();
3183  sal_Unicode cStart = ( bOn && m_xStartBracketLB->get_selected_index() > 0 )
3184  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3185  sal_Unicode cEnd = ( bOn && m_xEndBracketLB->get_selected_index() > 0 )
3186  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3187 
3188  if ( pOld )
3189  {
3190  const SvxTwoLinesItem& rItem = *static_cast<const SvxTwoLinesItem*>(pOld);
3191  if ( rItem.GetValue() == bOn &&
3192  ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3193  bChanged = false;
3194  }
3195 
3196  if ( bChanged )
3197  {
3198  rSet->Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3199  bModified = true;
3200  }
3201  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3202  rSet->InvalidateItem(nWhich);
3203 
3204  return bModified;
3205 }
3206 
3208 {
3209  sal_Unicode cStart = m_xStartBracketLB->get_selected_index() > 0
3210  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3211  sal_Unicode cEnd = m_xEndBracketLB->get_selected_index() > 0
3212  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3213  m_aPreviewWin.SetBrackets(cStart, cEnd);
3214  m_aPreviewWin.SetTwoLines(m_xTwoLinesBtn->get_active());
3215  m_aPreviewWin.Invalidate();
3216 }
3217 
3219 {
3220  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3221  if (pFlagItem)
3222  {
3223  sal_uInt32 nFlags=pFlagItem->GetValue();
3224  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3225  // the writer uses SID_ATTR_BRUSH as font background
3227  }
3228 }
3229 
3230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFamily(FontFamily)
sal_uInt16 m_nScaleWidthInitialVal
Definition: chardlg.hxx:246
bool IsAvailable(std::u16string_view rName) const
virtual ~SvxCharEffectsPage() override
Definition: chardlg.cxx:1343
std::unique_ptr< weld::CheckButton > m_xFitToLineCB
Definition: chardlg.hxx:267
std::unique_ptr< weld::Label > m_xWestFontLanguageFT
Definition: chardlg.hxx:75
std::unique_ptr< FontSizeBox > m_xEastFontSizeLB
Definition: chardlg.hxx:86
std::unique_ptr< FontStyleBox > m_xCTLFontStyleLB
Definition: chardlg.hxx:95
bool IsRelativeMode() const
void SetPropr(const sal_uInt8 nNewPropr)
std::unique_ptr< weld::RadioButton > m_xHighPosBtn
Definition: chardlg.hxx:251
std::unique_ptr< SvxCharNamePage_Impl > m_pImpl
Definition: chardlg.hxx:66
FieldUnit
void SetBracket(sal_Unicode cBracket, bool bStart)
Definition: chardlg.cxx:3077
std::unique_ptr< weld::RadioButton > m_xNormalPosBtn
Definition: chardlg.hxx:252
SvxFont & GetCTLFont()
sal_Int32 nIndex
std::unique_ptr< weld::ComboBox > m_xStrikeoutLB
Definition: chardlg.hxx:191
OUString m_aNoStyleText
Definition: chardlg.cxx:174
void SetFontSize(const Size &)
sal_uInt8 GetAlpha() const
void SetAlpha(sal_uInt8 nAlpha)
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
OUString const & get_saved_value() const
const OUString & GetFamilyName() const
std::unique_ptr< weld::CheckButton > m_xHiddenBtn
Definition: chardlg.hxx:187
IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl, Timer *, void)
Definition: chardlg.cxx:1114
void SetUserData(const OUString &rString)
void FillSizeBox_Impl(const weld::Widget &rBox)
Definition: chardlg.cxx:551
int get_value() const
void setWidth(tools::Long nWidth)
bool GetValue() const
static constexpr auto Items
bool IsCJKFontEnabled()
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:1175
std::unique_ptr< weld::Button > m_xWestFontFeaturesButton
Definition: chardlg.hxx:77
virtual void FillUserData() override
Definition: chardlg.cxx:2990
std::unique_ptr< weld::ComboBox > m_xWestFontNameLB
Definition: chardlg.hxx:70
sal_Unicode GetStartBracket() const
const OUString & GetStyleName() const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:1666
std::unique_ptr< weld::MetricSpinButton > m_xFontSizeMF
Definition: chardlg.hxx:258
SvxCaseMap
Idle m_aUpdateIdle cui SvxCharNamePage_Impl m_aUpdateIdle
Definition: chardlg.cxx:173
bool IsTransparent() const
virtual short run() override
OUString const & getResultFontName() const
LanguageType get_active_id() const
bool FillItemSetColor_Impl(SfxItemSet &rSet)
Definition: chardlg.cxx:1564
virtual void hide()=0
void SetColor(const Color &rCol)
SvxCharPositionPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:2403
void set_active_text(const OUString &rText)
const FontList * GetFontList() const
Definition: chardlg.cxx:343
#define DISABLE_HIDE_LANGUAGE
bool IsRelative() const
long Long
bool get_value_changed_from_saved() const
std::unique_ptr< weld::Label > m_xWestFontStyleFT
Definition: chardlg.hxx:71
sal_uInt8 & GetProportionalHeight()
void EnableFeatureButton(const weld::Widget &rNameBox)
Definition: chardlg.cxx:475
SvxFont & GetPreviewFont()
Definition: chardlg.cxx:120
FontEmphasisMark
std::unique_ptr< weld::Widget > m_xRotationContainer
Definition: chardlg.hxx:260
constexpr::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
SvxFontPrevWindow m_aPreviewWin
Definition: chardlg.hxx:37
SvxFont & GetCJKFont()
std::unique_ptr< weld::Label > m_xEmphasisFT
Definition: chardlg.hxx:196
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
void set_value(int nValue)
constexpr OUStringLiteral PERCENT(u"Percent")
Language for asian text.
Definition: chardlg.hxx:121
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:3154
std::unique_ptr< weld::Label > m_xFontColorFT
Definition: chardlg.hxx:177
std::unique_ptr< weld::ComboBox > m_xEffectsLB
Definition: chardlg.hxx:182
std::unique_ptr< weld::Label > m_xCTLFontStyleFT
Definition: chardlg.hxx:94
std::unique_ptr< weld::Label > m_xEastFontNameFT
Definition: chardlg.hxx:81
sal_uInt16 m_nHtmlMode
Definition: chardlg.hxx:170
#define max(a, b)
void SetPtRelative(bool bPtRel)
sal_uInt16 GetValue() const
virtual int find_text(const OUString &rStr) const =0
void SetHeight(sal_uInt32 nNewHeight, const sal_uInt16 nNewProp=100, MapUnit eUnit=MapUnit::MapRelative)
virtual void ChangesApplied() override
Definition: chardlg.cxx:1197
void InvalidateItem(sal_uInt16 nWhich)
tools::Long ItemToControl(tools::Long nIn, MapUnit eItem, FieldUnit eCtrl)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::unique_ptr< weld::Label > m_xWestFontNameFT
Definition: chardlg.hxx:69
void save_value()
std::unique_ptr< weld::Label > m_xWestFontSizeFT
Definition: chardlg.hxx:73
Language for western text.
Definition: chardlg.hxx:117
bool IsBottomToTop() const
std::unique_ptr< weld::ComboBox > m_xReliefLB
Definition: chardlg.hxx:184
EditedAndValid GetEditedAndValid() const
void SetCharSet(rtl_TextEncoding)
static SfxObjectShell * Current()
#define DFLT_ESC_AUTO_SUB
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:1187
bool IsCTLFontEnabled() const
void Fill(const FontList *pList)
virtual int get_active() const =0
void Initialize()
Definition: chardlg.cxx:315
void set_sensitive(bool bSensitive)
void SetThemeIndex(sal_Int16 nIndex)
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: chardlg.cxx:145
FontPitch GetPitch() const
TRISTATE_TRUE
#define DISABLE_CASEMAP
void SetCaseMap_Impl(SvxCaseMap eCaseMap)
Definition: chardlg.cxx:1487
OUString get_active_text() const
virtual void ChangesApplied() override
Definition: chardlg.cxx:2856
bool m_bPreviewBackgroundToCharacter
Definition: chardlg.hxx:40
weld::TriStateEnabled m_aShadowState
Definition: chardlg.hxx:173
std::unique_ptr< weld::CheckButton > m_xShadowBtn
Definition: chardlg.hxx:186
std::unique_ptr< weld::Label > m_xCTLFontTypeFT
Definition: chardlg.hxx:101
void FontModifyHdl_Impl(const weld::Widget &)
Definition: chardlg.cxx:1156
FontFamily GetFamily() const
FontFamily GetFamilyType()
void FillStyleBox_Impl(const weld::Widget &rBox)
Definition: chardlg.cxx:505
std::unique_ptr< FontStyleBox > m_xEastFontStyleLB
Definition: chardlg.hxx:84
void SelectHdl_Impl(const weld::ComboBox *)
Definition: chardlg.cxx:1614
static OutputDevice * GetDefaultDevice()
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
std::unique_ptr< weld::CheckButton > m_xIndividualWordsBtn
Definition: chardlg.hxx:195
SvxFont & GetPreviewCTLFont()
Definition: chardlg.cxx:130
#define CHRDLG_POSITION_UNDER
Definition: chardlg.h:24
sal_uInt16 sal_Unicode
FontItalic GetItalic()
virtual ~SvxCharPositionPage() override
Definition: chardlg.cxx:2437
const Color & GetColor() const
std::unique_ptr< weld::CheckButton > m_xOutlineBtn
Definition: chardlg.hxx:185
Degree10 GetValue() const
std::unique_ptr< weld::Label > m_xOverlineColorFT
Definition: chardlg.hxx:189
sal_Unicode GetEndBracket() const
void append_text(const OUString &rStr)
std::unique_ptr< weld::RadioButton > m_x0degRB
Definition: chardlg.hxx:264
LINESTYLE_NONE
std::unique_ptr< SvxLanguageBox > m_xEastFontLanguageLB
Definition: chardlg.hxx:88
void SetTextLineColor(const Color &rColor)
ScopedVclPtrInstance< VirtualDevice > m_xVDev
Definition: chardlg.hxx:104
rtl_TextEncoding GetCharSet() const
std::unique_ptr< SvxLanguageBox > m_xWestFontLanguageLB
Definition: chardlg.hxx:76
void SetExchangeSupport()
void SetFixKerning(const short nNewKern)
std::unique_ptr< weld::ComboBox > m_xPositionLB
Definition: chardlg.hxx:199
std::unique_ptr< weld::Label > m_xWestFontTypeFT
Definition: chardlg.hxx:78
virtual int n_children() const =0
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:3218
const OUString & GetBoldStr() const
virtual ~SvxCharNamePage() override
Definition: chardlg.cxx:300
Color m_aOrigFontColor
Definition: chardlg.hxx:169
#define SVX_PREVIEW_CHARACTER
FontMetric Get(const OUString &rName, const OUString &rStyleName) const
const OUString & GetUserData() const
virtual OUString get_id(int pos) const =0
void SetRelative(bool bRelative)
#define DFLT_ESC_AUTO_SUPER
FontEmphasisMark GetEmphasisMark() const
IMPL_LINK(SvxCharNamePage, FontModifyComboBoxHdl_Impl, weld::ComboBox &, rBox, void)
Definition: chardlg.cxx:1119
std::unique_ptr< weld::CheckButton > m_xHighLowRB
Definition: chardlg.hxx:256
bool get_active_id_changed_from_saved() const
bool FillItemSet_Impl(SfxItemSet &rSet, LanguageGroup eLangGrp)
Definition: chardlg.cxx:826
std::unique_ptr< weld::Label > m_xEastFontLanguageFT
Definition: chardlg.hxx:87
std::vector< vcl::font::Feature > getFontFeatureList(OUString const &rFontName, VirtualDevice &rVDev)
void save_value()
void SetEscapement_Impl(SvxEscapement nEsc)
Definition: chardlg.cxx:2480
SvxFont & GetFont()
#define DFLT_ESC_PROP
sal_uInt8 m_nSuperProp
Definition: chardlg.hxx:248
void DisableControls(sal_uInt16 nDisable)
Definition: chardlg.cxx:1258
SvxThemeColor & GetThemeColor()
const OUString & GetStyleName(FontWeight eWeight, FontItalic eItalic) const
std::unique_ptr< weld::CustomWeld > m_xPreviewWin
Definition: chardlg.hxx:38
TRISTATE_INDET
B2IRange fround(const B2DRange &rRange)
virtual ~SvxCharBasePage() override
Definition: chardlg.cxx:141
sal_uInt16 GetProp() const
void FontModifyHdl_Impl()
Definition: chardlg.cxx:2549
std::unique_ptr< weld::CheckButton > m_xTwoLinesBtn
Definition: chardlg.hxx:313
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2070
void SetPitch(FontPitch ePitch)
SvxFont & GetPreviewCJKFont()
Definition: chardlg.cxx:125
const OUString & GetStyleName() const
LanguageType get_saved_active_id() const
const SfxItemSet & GetItemSet() const
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:1678
virtual tools::Long GetValue() const override
void save_active_id()
std::unique_ptr< weld::Label > m_xHighLowFT
Definition: chardlg.hxx:254
const FontMetric & GetFontName(size_t nFont) const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1182
std::unique_ptr< weld::Label > m_xUnderlineColorFT
Definition: chardlg.hxx:193
OUString CuiResId(TranslateId aKey)
Definition: cuiresmgr.cxx:23
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
weld::TriStateEnabled m_aIndividualWordsState
Definition: chardlg.hxx:175
std::unique_ptr< weld::Label > m_xCTLFontLanguageFT
Definition: chardlg.hxx:98
void set_active_text(const OUString &rStr)
static const WhichRangesContainer pPositionRanges
Definition: chardlg.hxx:239
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
int get_count() const
const SfxItemSet * GetParent() const
#define COL_NONE_COLOR
void SetFamilyName(const OUString &rFamilyName)
std::unique_ptr< weld::Label > m_xEastFontStyleFT
Definition: chardlg.hxx:83
FontPitch GetPitch()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
void EnableSearchMode()
Definition: chardlg.cxx:1253
int i
std::unique_ptr< weld::Label > m_xEffectsFT
Definition: chardlg.hxx:181
std::unique_ptr< FontStyleBox > m_xWestFontStyleLB
Definition: chardlg.hxx:72
#define LANGUAGE_SYSTEM
void set_sensitive(bool bSensitive)
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: chardlg.cxx:3137
virtual void insert_vector(const std::vector< weld::ComboBoxEntry > &rItems, bool bKeepExisting)=0
sal_uInt16 m_nEndBracketPosition
Definition: chardlg.hxx:311
HTMLMODE_ON
SvxCharTwoLinesPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:3015
void SetPrevFontEscapement(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc)
Definition: chardlg.cxx:160
static const WhichRangesContainer pEffectsRanges
Definition: chardlg.hxx:165
std::unique_ptr< weld::CheckButton > m_xPairKerningBtn
Definition: chardlg.hxx:272
WEIGHT_NORMAL
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:1213
std::unique_ptr< SvxLanguageBox > m_xCTLFontLanguageLB
Definition: chardlg.hxx:99
float u
sal_uInt16 m_nStartBracketPosition
Definition: chardlg.hxx:310
std::unique_ptr< weld::Label > m_xEastFontSizeFT
Definition: chardlg.hxx:85
std::unique_ptr< ColorListBox > m_xFontColorLB
Definition: chardlg.hxx:178
#define LANGUAGE_DONTKNOW
const Size & GetFontSize() const
bool IsAsianTypographyEnabled()
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:2379
tools::Long CalcToUnit(float nIn, MapUnit eUnit)
virtual OUString get_text(int row, int col=-1) const =0
void EnableNoneFontColor()
Definition: chardlg.cxx:1337
virtual void set_active(int pos)=0
SvxCharBasePage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID, const SfxItemSet &rAttrSet)
Definition: chardlg.cxx:135
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
ITALIC_NONE
std::unique_ptr< weld::Notebook > m_xWestern
Definition: chardlg.hxx:68
void set_active_id(const LanguageType eLangType)
std::unique_ptr< weld::ComboBox > m_xEastFontNameLB
Definition: chardlg.hxx:82
virtual void ActivatePage(const SfxItemSet &rSet) override
Definition: chardlg.cxx:1168
SfxItemPool * GetPool() const
const SfxItemSet * GetDialogExampleSet() const
std::unique_ptr< weld::ComboBox > m_xUnderlineLB
Definition: chardlg.hxx:192
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:2637
void SetTwoLines(bool bSet)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:3002
bool IsFitToLine() const
void set_active_or_entry_text(const OUString &rText)
void EnableRelativeMode()
Definition: chardlg.cxx:1245
virtual short run() override
Definition: cuicharmap.cxx:187
static const WhichRangesContainer pNameRanges
Definition: chardlg.hxx:64
int get_active() const
size_t GetFontNameCount() const
sal_uInt8 m_nSubProp
Definition: chardlg.hxx:249
std::unique_ptr< weld::RadioButton > m_x90degRB
Definition: chardlg.hxx:265
std::unique_ptr< weld::Label > m_xReliefFT
Definition: chardlg.hxx:183
void ResetColor_Impl(const SfxItemSet &rSet)
Definition: chardlg.cxx:1501
const OUString & GetFamilyName() const
bool m_bEnableNoneFontColor
Definition: chardlg.hxx:168
DeviceFormat
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetCaseMap(const SvxCaseMap eNew)
void set_active(int nPos)
virtual void select(int pos)=0
FontWeight
std::unique_ptr< weld::Label > m_xEastFontTypeFT
Definition: chardlg.hxx:90
weld::Window * GetFrameWeld() const
void SetStyleName(const OUString &rStyleName)
sal_Int32 SaveEditedAsEntry()
static bool StateToAttr(TriState aState)
Definition: chardlg.cxx:105
sal_uInt32 GetHeight() const
void SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
SfxItemState
void EnableRelativeMode(sal_uInt16 nMin, sal_uInt16 nMax, sal_uInt16 nStep=5)
std::unique_ptr< FontSizeBox > m_xWestFontSizeLB
Definition: chardlg.hxx:74
#define DFLT_ESC_SUB
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void ChangesApplied() override
Definition: chardlg.cxx:2054
std::unique_ptr< weld::RadioButton > m_x270degRB
Definition: chardlg.hxx:266
void set_sensitive(bool bSensitive)
FontWeight GetWeight()
void SetLumOff(sal_Int16 nLumOff)
void SetLumMod(sal_Int16 nLumMod)
unsigned char sal_uInt8
void UpdatePreview_Impl(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc)
Definition: chardlg.cxx:2474
std::unique_ptr< weld::TreeView > m_xEndBracketLB
Definition: chardlg.hxx:316
void SetPrevFontWidthScale(const SfxItemSet &rSet)
Definition: chardlg.cxx:150
static const WhichRangesContainer pTwoLinesRanges
Definition: chardlg.hxx:309
void UpdatePreview_Impl()
Definition: chardlg.cxx:444
tools::Long CalcToPoint(tools::Long nIn, MapUnit eUnit, sal_uInt16 nFactor)
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:3142
const OUString & GetItalicStr() const
std::unique_ptr< weld::MetricSpinButton > m_xHighLowMF
Definition: chardlg.hxx:255
RET_OK
virtual ~SvxCharTwoLinesPage() override
Definition: chardlg.cxx:3036
bool IsTopToBottom() const
#define DFLT_ESC_SUPER
int find_text(const OUString &rStr) const
void DisableControls(sal_uInt16 nDisable)
Definition: chardlg.cxx:2370
SfxOkDialogController * GetDialogController() const
std::unique_ptr< weld::Notebook > m_xCJK_CTL
Definition: chardlg.hxx:80
void DisableFontSelection()
Definition: cuicharmap.cxx:219
int get_saved_value() const
void UpdatePreview_Impl()
Definition: chardlg.cxx:3207
Language for ctl text.
Definition: chardlg.hxx:125
virtual OUString get_id(int pos) const =0
std::unique_ptr< weld::Label > m_xCTLFontNameFT
Definition: chardlg.hxx:92
std::unique_ptr< weld::MetricSpinButton > m_xKerningMF
Definition: chardlg.hxx:271
#define CHRDLG_POSITION_OVER
Definition: chardlg.h:23
weld::TriStateEnabled m_aOutlineState
Definition: chardlg.hxx:172
std::unique_ptr< weld::Label > m_xCTLFontSizeFT
Definition: chardlg.hxx:96
DeactivateRC
void setHeight(tools::Long nHeight)
void SelectCharacter(weld::TreeView *pBox)
Definition: chardlg.cxx:3059
void SetProprRel(const sal_uInt8 nNewPropr)
SvxEscapement
sal_uInt32 GetValue() const
void SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBackgroundToCharacter)
std::unique_ptr< weld::TreeView > m_xStartBracketLB
Definition: chardlg.hxx:315
void Reset_Impl(const SfxItemSet &rSet, LanguageGroup eLangGrp)
Definition: chardlg.cxx:596
void Fill(std::u16string_view rName, const FontList *pList)
sal_UCS4 GetChar() const
Definition: cuicharmap.cxx:214
MapUnit
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2871
#define SAL_WARN(area, stream)
void AutoCorrectFontColor()
std::unique_ptr< FontSizeBox > m_xCTLFontSizeLB
Definition: chardlg.hxx:97
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
Definition: cuicharmap.hxx:76
std::unique_ptr< weld::Button > m_xEastFontFeaturesButton
Definition: chardlg.hxx:89
std::unique_ptr< ColorListBox > m_xUnderlineColorLB
Definition: chardlg.hxx:194
void SetPriority(TaskPriority ePriority)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1673
void SetFontList(const SvxFontListItem &rItem)
Definition: chardlg.cxx:1221
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:2625
#define MAX_ESC_POS
std::unique_ptr< FontList > m_pFontList
Definition: chardlg.cxx:175
const FontList * GetFontList() const
STRIKEOUT_NONE
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
TriState
FontLineStyle
sal_uInt16 m_nScaleWidthItemSetVal
Definition: chardlg.hxx:245
constexpr OUStringLiteral first
OUString GetFontMapText(const FontMetric &rFontMetric) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
std::unique_ptr< weld::MetricSpinButton > m_xFontTransparencyMtr
Definition: chardlg.hxx:180
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:3176
#define SVX_ENABLE_CHAR_TRANSPARENCY
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:2632
bool IsPtRelative() const
std::unique_ptr< weld::Label > m_xScalingFT
Definition: chardlg.hxx:262
void SetEscapement(const short nNewEsc)
std::unique_ptr< weld::ComboBox > m_xOverlineLB
Definition: chardlg.hxx:188
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
std::unique_ptr< weld::Label > m_xScalingAndRotationFT
Definition: chardlg.hxx:263
OUString const & get_saved_value() const
std::unique_ptr< weld::MetricSpinButton > m_xScaleWidthMF
Definition: chardlg.hxx:269
std::unique_ptr< weld::Label > m_xFontSizeFT
Definition: chardlg.hxx:257
virtual void set_entry_text(const OUString &rStr)=0
std::unique_ptr< weld::RadioButton > m_xLowPosBtn
Definition: chardlg.hxx:253
#define SVX_RELATIVE_MODE
std::unique_ptr< ColorListBox > m_xOverlineColorLB
Definition: chardlg.hxx:190
FontStrikeout
OUString get_active_text() const
MapUnit GetPropUnit() const
std::unique_ptr< weld::Button > m_xCTLFontFeaturesButton
Definition: chardlg.hxx:100
std::unique_ptr< weld::ComboBox > m_xEmphasisLB
Definition: chardlg.hxx:197
SvxCharEffectsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:1293
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:1271
std::unique_ptr< FontList > Clone() const
void SetFontWidthScale(sal_uInt16 nScaleInPercent)
weld::TriStateEnabled m_aHiddenState
Definition: chardlg.hxx:174
std::unique_ptr< weld::Label > m_xA11yWarningFT
Definition: chardlg.hxx:200
rtl_TextEncoding GetCharSet() const
void EnablePtRelativeMode(short nMin, short nMax, short nStep=10)
const Color & GetValue() const
sal_uInt16 nPos
virtual void set_sensitive(bool sensitive)=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void append_text(const OUString &rStr)
FontItalic
virtual OUString get_active_text() const =0
std::unique_ptr< weld::Label > m_xFontTransparencyFT
Definition: chardlg.hxx:179
void UpdatePreview_Impl()
Definition: chardlg.cxx:1415
bool m_bDetectedRangeSegmentation false
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:3149
void SetOverlineColor(const Color &rColor)
std::unique_ptr< weld::Label > m_xPositionFT
Definition: chardlg.hxx:198
std::unique_ptr< weld::ComboBox > m_xCTLFontNameLB
Definition: chardlg.hxx:93
SvxCharNamePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:190