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