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::DISABLED )
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  pLangFT->set_sensitive(false);
798  pLangBox->set_sensitive(false);
799  break;
800 
801  case SfxItemState::DEFAULT:
802  case SfxItemState::SET:
803  {
804  const SvxLanguageItem& rItem = static_cast<const SvxLanguageItem&>(rSet.Get( nWhich ));
805  LanguageType eLangType = rItem.GetValue();
806  DBG_ASSERT( eLangType != LANGUAGE_SYSTEM, "LANGUAGE_SYSTEM not allowed" );
807  if (eLangType != LANGUAGE_DONTKNOW)
808  pLangBox->set_active_id(eLangType);
809  break;
810  }
811  case SfxItemState::DONTCARE:
812  break;
813  }
814 
815  OUString sMapText(pFontList->GetFontMapText(
816  pFontList->Get(pNameBox->get_active_text(), pStyleBox->get_active_text())));
817 
818  switch (eLangGrp)
819  {
820  case Western:
821  m_xWestFontTypeFT->set_label(sMapText);
822  break;
823  case Asian:
824  m_xEastFontTypeFT->set_label(sMapText);
825  break;
826  case Ctl:
827  m_xCTLFontTypeFT->set_label(sMapText);
828  break;
829  }
830 
831  // save these settings
832  pNameBox->save_value();
833  pStyleBox->save_value();
834  pSizeBox->save_value();
835  pLangBox->save_active_id();
836 }
837 
839 {
840  bool bModified = false;
841 
842  weld::ComboBox* pNameBox = nullptr;
843  FontStyleBox* pStyleBox = nullptr;
844  FontSizeBox* pSizeBox = nullptr;
845  SvxLanguageBox* pLangBox = nullptr;
846  sal_uInt16 nWhich = 0;
847  sal_uInt16 nSlot = 0;
848 
849  switch ( eLangGrp )
850  {
851  case Western :
852  pNameBox = m_xWestFontNameLB.get();
853  pStyleBox = m_xWestFontStyleLB.get();
854  pSizeBox = m_xWestFontSizeLB.get();
855  pLangBox = m_xWestFontLanguageLB.get();
856  nSlot = SID_ATTR_CHAR_FONT;
857  break;
858 
859  case Asian :
860  pNameBox = m_xEastFontNameLB.get();
861  pStyleBox = m_xEastFontStyleLB.get();
862  pSizeBox = m_xEastFontSizeLB.get();
863  pLangBox = m_xEastFontLanguageLB.get();
864  nSlot = SID_ATTR_CHAR_CJK_FONT;
865  break;
866 
867  case Ctl :
868  pNameBox = m_xCTLFontNameLB.get();
869  pStyleBox = m_xCTLFontStyleLB.get();
870  pSizeBox = m_xCTLFontSizeLB.get();
871  pLangBox = m_xCTLFontLanguageLB.get();
872  nSlot = SID_ATTR_CHAR_CTL_FONT;
873  break;
874  }
875 
876  nWhich = GetWhich( nSlot );
877  const SfxPoolItem* pItem = nullptr;
878  const SfxItemSet& rOldSet = GetItemSet();
879  const SfxPoolItem* pOld = nullptr;
880 
881  const SfxItemSet* pExampleSet = GetDialogExampleSet();
882 
883  bool bChanged = true;
884  const OUString& rFontName = pNameBox->get_active_text();
885  const FontList* pFontList = GetFontList();
886  OUString aStyleBoxText = pStyleBox->get_active_text();
887  int nEntryPos = pStyleBox->find_text(aStyleBoxText);
888  if (nEntryPos >= m_pImpl->m_nExtraEntryPos)
889  aStyleBoxText.clear();
890  FontMetric aInfo( pFontList->Get( rFontName, aStyleBoxText ) );
891  SvxFontItem aFontItem( aInfo.GetFamilyType(), aInfo.GetFamilyName(), aInfo.GetStyleName(),
892  aInfo.GetPitch(), aInfo.GetCharSet(), nWhich );
893  pOld = GetOldItem( rSet, nSlot );
894 
895  if ( pOld )
896  {
897  const SvxFontItem& rItem = *static_cast<const SvxFontItem*>(pOld);
898 
899  if ( rItem.GetFamilyName() == aFontItem.GetFamilyName() )
900  bChanged = false;
901  }
902 
903  if ( !bChanged )
904  bChanged = pNameBox->get_saved_value().isEmpty();
905 
906  if ( !bChanged && pExampleSet &&
907  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
908  static_cast<const SvxFontItem*>(pItem)->GetFamilyName() != aFontItem.GetFamilyName() )
909  bChanged = true;
910 
911  if ( bChanged && !rFontName.isEmpty() )
912  {
913  rSet.Put( aFontItem );
914  bModified = true;
915  }
916  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
917  rSet.ClearItem( nWhich );
918 
919 
920  bChanged = true;
921  switch ( eLangGrp )
922  {
923  case Western : nSlot = SID_ATTR_CHAR_WEIGHT; break;
924  case Asian : nSlot = SID_ATTR_CHAR_CJK_WEIGHT; break;
925  case Ctl : nSlot = SID_ATTR_CHAR_CTL_WEIGHT; break;
926  }
927  nWhich = GetWhich( nSlot );
928  FontWeight eWeight = aInfo.GetWeight();
929  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
930  eWeight = WEIGHT_NORMAL;
931  SvxWeightItem aWeightItem( eWeight, nWhich );
932  pOld = GetOldItem( rSet, nSlot );
933 
934  if ( pOld )
935  {
936  const SvxWeightItem& rItem = *static_cast<const SvxWeightItem*>(pOld);
937 
938  if ( rItem.GetValue() == aWeightItem.GetValue() )
939  bChanged = false;
940  }
941 
942  if ( !bChanged )
943  {
944  bChanged = pStyleBox->get_saved_value().isEmpty();
945 
946  if ( m_pImpl->m_bInSearchMode && bChanged &&
947  aInfo.GetWeight() == WEIGHT_NORMAL && aInfo.GetItalic() != ITALIC_NONE )
948  bChanged = false;
949  }
950 
951  if ( !bChanged && pExampleSet &&
952  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
953  static_cast<const SvxWeightItem*>(pItem)->GetValue() != aWeightItem.GetValue() )
954  bChanged = true;
955 
956  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
957  bChanged = ( nEntryPos == m_pImpl->m_nExtraEntryPos );
958 
959  OUString aText( pStyleBox->get_active_text() ); // Tristate, then text empty
960 
961  if ( bChanged && !aText.isEmpty() )
962  {
963  rSet.Put( aWeightItem );
964  bModified = true;
965  }
966  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
967  rSet.InvalidateItem(nWhich);
968 
969  bChanged = true;
970  switch ( eLangGrp )
971  {
972  case Western : nSlot = SID_ATTR_CHAR_POSTURE; break;
973  case Asian : nSlot = SID_ATTR_CHAR_CJK_POSTURE; break;
974  case Ctl : nSlot = SID_ATTR_CHAR_CTL_POSTURE; break;
975  }
976  nWhich = GetWhich( nSlot );
977  FontItalic eItalic = aInfo.GetItalic();
978  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
979  eItalic = ITALIC_NONE;
980  SvxPostureItem aPostureItem( eItalic, nWhich );
981  pOld = GetOldItem( rSet, nSlot );
982 
983  if ( pOld )
984  {
985  const SvxPostureItem& rItem = *static_cast<const SvxPostureItem*>(pOld);
986 
987  if ( rItem.GetValue() == aPostureItem.GetValue() )
988  bChanged = false;
989  }
990 
991  if ( !bChanged )
992  {
993  bChanged = pStyleBox->get_saved_value().isEmpty();
994 
995  if ( m_pImpl->m_bInSearchMode && bChanged &&
996  aInfo.GetItalic() == ITALIC_NONE && aInfo.GetWeight() != WEIGHT_NORMAL )
997  bChanged = false;
998  }
999 
1000  if ( !bChanged && pExampleSet &&
1001  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
1002  static_cast<const SvxPostureItem*>(pItem)->GetValue() != aPostureItem.GetValue() )
1003  bChanged = true;
1004 
1005  if ( nEntryPos >= m_pImpl->m_nExtraEntryPos )
1006  bChanged = ( nEntryPos == ( m_pImpl->m_nExtraEntryPos + 1 ) );
1007 
1008  if ( bChanged && !aText.isEmpty() )
1009  {
1010  rSet.Put( aPostureItem );
1011  bModified = true;
1012  }
1013  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1014  rSet.InvalidateItem(nWhich);
1015 
1016  // FontSize
1017  tools::Long nSize = pSizeBox->get_value();
1018 
1019  if ( pSizeBox->get_active_text().isEmpty() ) // GetValue() returns the min-value
1020  nSize = 0;
1021  tools::Long nSavedSize = pSizeBox->get_saved_value();
1022  const bool bRel = pSizeBox->IsRelative();
1023 
1024  switch ( eLangGrp )
1025  {
1026  case Western : nSlot = SID_ATTR_CHAR_FONTHEIGHT; break;
1027  case Asian : nSlot = SID_ATTR_CHAR_CJK_FONTHEIGHT; break;
1028  case Ctl : nSlot = SID_ATTR_CHAR_CTL_FONTHEIGHT; break;
1029  }
1030  nWhich = GetWhich( nSlot );
1031  const SvxFontHeightItem* pOldHeight = static_cast<const SvxFontHeightItem*>(GetOldItem( rSet, nSlot ));
1032  bChanged = ( nSize != nSavedSize );
1033 
1034  if ( !bChanged && pExampleSet &&
1035  pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET )
1036  {
1037  float fSize = static_cast<float>(nSize) / 10;
1038  tools::Long nVal = CalcToUnit( fSize, rSet.GetPool()->GetMetric( nWhich ) );
1039  if ( static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() != static_cast<sal_uInt32>(nVal) )
1040  bChanged = true;
1041  }
1042 
1043  if ( bChanged || !pOldHeight ||
1044  bRel != ( MapUnit::MapRelative != pOldHeight->GetPropUnit() || 100 != pOldHeight->GetProp() ) )
1045  {
1046  MapUnit eUnit = rSet.GetPool()->GetMetric( nWhich );
1047  if ( pSizeBox->IsRelative() )
1048  {
1049  DBG_ASSERT( GetItemSet().GetParent(), "No parent set" );
1050  const SvxFontHeightItem& rOldItem =
1051  static_cast<const SvxFontHeightItem&>(GetItemSet().GetParent()->Get( nWhich ));
1052 
1053  SvxFontHeightItem aHeight( 240, 100, nWhich );
1054  if ( pSizeBox->IsPtRelative() )
1055  aHeight.SetHeight( rOldItem.GetHeight(), static_cast<sal_uInt16>( nSize / 10 ), MapUnit::MapPoint, eUnit );
1056  else
1057  aHeight.SetHeight( rOldItem.GetHeight(), static_cast<sal_uInt16>(nSize) );
1058  rSet.Put( aHeight );
1059  }
1060  else
1061  {
1062  float fSize = static_cast<float>(nSize) / 10;
1063  rSet.Put( SvxFontHeightItem( CalcToUnit( fSize, eUnit ), 100, nWhich ) );
1064  }
1065  bModified = true;
1066  }
1067  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1068  rSet.InvalidateItem(nWhich);
1069 
1070  bChanged = true;
1071  switch ( eLangGrp )
1072  {
1073  case Western : nSlot = SID_ATTR_CHAR_LANGUAGE; break;
1074  case Asian : nSlot = SID_ATTR_CHAR_CJK_LANGUAGE; break;
1075  case Ctl : nSlot = SID_ATTR_CHAR_CTL_LANGUAGE; break;
1076  }
1077  nWhich = GetWhich( nSlot );
1078  pOld = GetOldItem( rSet, nSlot );
1079 
1080  // For language list boxes acting as ComboBox, check for, add and select an
1081  // edited entry.
1082  if (pLangBox == m_xWestFontLanguageLB.get())
1083  {
1084  switch (pLangBox->GetEditedAndValid())
1085  {
1087  ; // nothing to do
1088  break;
1090  {
1091  const int nPos = pLangBox->SaveEditedAsEntry();
1092  if (nPos != -1)
1093  pLangBox->set_active(nPos);
1094  }
1095  break;
1097  pLangBox->set_active_id(pLangBox->get_saved_active_id());
1098  break;
1099  }
1100  }
1101 
1102  int nLangPos = pLangBox->get_active();
1103  LanguageType eLangType = pLangBox->get_active_id();
1104 
1105  if (pOld)
1106  {
1107  const SvxLanguageItem& rItem = *static_cast<const SvxLanguageItem*>(pOld);
1108  if (nLangPos == -1 || eLangType == rItem.GetValue())
1109  bChanged = false;
1110  }
1111 
1112  if (!bChanged)
1113  bChanged = pLangBox->get_active_id_changed_from_saved();
1114 
1115  if (bChanged && nLangPos != -1)
1116  {
1117  rSet.Put(SvxLanguageItem(eLangType, nWhich));
1118  bModified = true;
1119  }
1120  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1121  rSet.InvalidateItem(nWhich);
1122 
1123  return bModified;
1124 }
1125 
1126 IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl, Timer *, void)
1127 {
1128  UpdatePreview_Impl();
1129 }
1130 
1131 IMPL_LINK(SvxCharNamePage, FontModifyComboBoxHdl_Impl, weld::ComboBox&, rBox, void)
1132 {
1133  FontModifyHdl_Impl(rBox);
1134 }
1135 
1136 IMPL_LINK(SvxCharNamePage, FontFeatureButtonClicked, weld::Button&, rButton, void)
1137 {
1138  OUString sFontName;
1139  weld::ComboBox* pNameBox = nullptr;
1140 
1141  if (&rButton == m_xWestFontFeaturesButton.get())
1142  {
1143  pNameBox = m_xWestFontNameLB.get();
1144  sFontName = GetPreviewFont().GetFamilyName();
1145  }
1146  else if (&rButton == m_xEastFontFeaturesButton.get())
1147  {
1148  pNameBox = m_xEastFontNameLB.get();
1149  sFontName = GetPreviewCJKFont().GetFamilyName();
1150  }
1151  else if (&rButton == m_xCTLFontFeaturesButton.get())
1152  {
1153  pNameBox = m_xCTLFontNameLB.get();
1154  sFontName = GetPreviewCTLFont().GetFamilyName();
1155  }
1156 
1157  if (!sFontName.isEmpty() && pNameBox)
1158  {
1159  cui::FontFeaturesDialog aDialog(GetFrameWeld(), sFontName);
1160  if (aDialog.run() == RET_OK)
1161  {
1162  pNameBox->set_entry_text(aDialog.getResultFontName());
1163  UpdatePreview_Impl();
1164  }
1165  }
1166 }
1167 
1169 {
1170  m_pImpl->m_aUpdateIdle.Start();
1171 
1172  if (m_xWestFontNameLB.get() == &rNameBox || m_xEastFontNameLB.get() == &rNameBox || m_xCTLFontNameLB.get() == &rNameBox)
1173  {
1174  FillStyleBox_Impl(rNameBox);
1175  FillSizeBox_Impl(rNameBox);
1176  }
1177 }
1178 
1180 {
1182 
1183  UpdatePreview_Impl(); // instead of asynchronous calling in ctor
1184 }
1185 
1187 {
1188  if ( _pSet )
1189  FillItemSet( _pSet );
1190  return DeactivateRC::LeavePage;
1191 }
1192 
1193 std::unique_ptr<SfxTabPage> SvxCharNamePage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
1194 {
1195  return std::make_unique<SvxCharNamePage>(pPage, pController, *rSet );
1196 }
1197 
1199 {
1200  Reset_Impl( *rSet, Western );
1201  Reset_Impl( *rSet, Asian );
1202  Reset_Impl( *rSet, Ctl );
1203 
1204  SetPrevFontWidthScale( *rSet );
1206 }
1207 
1209 {
1210  m_xWestFontNameLB->save_value();
1211  m_xWestFontStyleLB->save_value();
1212  m_xWestFontSizeLB->save_value();
1213  m_xWestFontLanguageLB->save_active_id();
1214  m_xEastFontNameLB->save_value();
1215  m_xEastFontStyleLB->save_value();
1216  m_xEastFontSizeLB->save_value();
1217  m_xEastFontLanguageLB->save_active_id();
1218  m_xCTLFontNameLB->save_value();
1219  m_xCTLFontStyleLB->save_value();
1220  m_xCTLFontSizeLB->save_value();
1221  m_xCTLFontLanguageLB->save_active_id();
1222 }
1223 
1225 {
1226  bool bModified = FillItemSet_Impl( *rSet, Western );
1227  bModified |= FillItemSet_Impl( *rSet, Asian );
1228  bModified |= FillItemSet_Impl( *rSet, Ctl );
1229  return bModified;
1230 }
1231 
1233 {
1234  m_pImpl->m_pFontList = rItem.GetFontList()->Clone();
1235 }
1236 
1237 namespace
1238 {
1239  void enableRelativeMode( SvxCharNamePage const * _pPage, FontSizeBox* _pFontSizeLB, sal_uInt16 _nHeightWhich )
1240  {
1241  _pFontSizeLB->EnableRelativeMode( 5, 995 ); // min 5%, max 995%, step 5
1242 
1243  const SvxFontHeightItem& rHeightItem =
1244  static_cast<const SvxFontHeightItem&>(_pPage->GetItemSet().GetParent()->Get( _nHeightWhich ));
1245  MapUnit eUnit = _pPage->GetItemSet().GetPool()->GetMetric( _nHeightWhich );
1246  short nCurHeight =
1247  static_cast< short >( CalcToPoint( rHeightItem.GetHeight(), eUnit, 1 ) * 10 );
1248 
1249  // based on the current height:
1250  // - negative until minimum of 2 pt
1251  // - positive until maximum of 999 pt
1252  _pFontSizeLB->EnablePtRelativeMode( sal::static_int_cast< short >(-(nCurHeight - 20)), (9999 - nCurHeight) );
1253  }
1254 }
1255 
1257 {
1258  DBG_ASSERT( GetItemSet().GetParent(), "RelativeMode, but no ParentSet!" );
1259  enableRelativeMode(this,m_xWestFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_FONTHEIGHT ));
1260  enableRelativeMode(this,m_xEastFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT ));
1261  enableRelativeMode(this,m_xCTLFontSizeLB.get(),GetWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT ));
1262 }
1263 
1265 {
1266  m_pImpl->m_bInSearchMode = true;
1267 }
1268 
1269 void SvxCharNamePage::DisableControls( sal_uInt16 nDisable )
1270 {
1271  if ( DISABLE_HIDE_LANGUAGE & nDisable )
1272  {
1279  }
1280 }
1281 
1283 {
1284  const SvxFontListItem* pFontListItem = aSet.GetItem<SvxFontListItem>(SID_ATTR_CHAR_FONTLIST, false);
1285  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
1286  const SfxUInt16Item* pDisableItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
1287  if (pFontListItem)
1288  SetFontList(*pFontListItem);
1289 
1290  if (pFlagItem)
1291  {
1292  sal_uInt32 nFlags=pFlagItem->GetValue();
1293  if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
1295  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
1296  // the writer uses SID_ATTR_BRUSH as font background
1298  }
1299  if (pDisableItem)
1300  DisableControls(pDisableItem->GetValue());
1301 }
1302 // class SvxCharEffectsPage ----------------------------------------------
1303 
1305  : SvxCharBasePage(pPage, pController, "cui/ui/effectspage.ui", "EffectsPage", rInSet)
1306  , m_bOrigFontColor(false)
1307  , m_bNewFontColor(false)
1308  , m_bEnableNoneFontColor(false)
1309  , m_xFontColorFT(m_xBuilder->weld_label("fontcolorft"))
1310  , m_xFontColorLB(new ColorListBox(m_xBuilder->weld_menu_button("fontcolorlb"),
1311  [this]{ return GetDialogController()->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"),
1325  [this]{ return GetDialogController()->getDialog(); }))
1326  , m_xStrikeoutLB(m_xBuilder->weld_combo_box("strikeoutlb"))
1327  , m_xUnderlineLB(m_xBuilder->weld_combo_box("underlinelb"))
1328  , m_xUnderlineColorFT(m_xBuilder->weld_label("underlinecolorft"))
1329  , m_xUnderlineColorLB(new ColorListBox(m_xBuilder->weld_menu_button("underlinecolorlb"),
1330  [this]{ return GetDialogController()->getDialog(); }))
1331  , m_xIndividualWordsBtn(m_xBuilder->weld_check_button("individualwordscb"))
1332  , m_xEmphasisFT(m_xBuilder->weld_label("emphasisft"))
1333  , m_xEmphasisLB(m_xBuilder->weld_combo_box("emphasislb"))
1334  , m_xPositionFT(m_xBuilder->weld_label("positionft"))
1335  , m_xPositionLB(m_xBuilder->weld_combo_box("positionlb"))
1336  , m_xA11yWarningFT(m_xBuilder->weld_label("a11ywarning"))
1337 {
1338  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
1339 #ifdef IOS
1340  m_xPreviewWin->hide();
1341 #endif
1342  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1343  m_xOverlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1344  m_xUnderlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1345  Initialize();
1346 }
1347 
1349 {
1350  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR, true);
1351  m_bEnableNoneFontColor = true;
1352 }
1353 
1355 {
1356  m_xUnderlineColorLB.reset();
1357  m_xOverlineColorLB.reset();
1358  m_xFontTransparencyMtr.reset();
1359  m_xFontColorLB.reset();
1360 }
1361 
1363 {
1364  // to handle the changes of the other pages
1366 
1367  // HTML-Mode
1368  const SfxPoolItem* pItem;
1369  SfxObjectShell* pShell;
1370  if ( SfxItemState::SET == GetItemSet().GetItemState( SID_HTML_MODE, false, &pItem ) ||
1371  ( nullptr != ( pShell = SfxObjectShell::Current() ) &&
1372  nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1373  {
1374  m_nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1375  if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
1376  {
1378  }
1379  }
1380 
1381  m_xFontColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1382  m_xFontTransparencyMtr->connect_value_changed(
1383  LINK(this, SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl));
1384 
1385  // handler
1386  Link<weld::ComboBox&,void> aLink = LINK( this, SvxCharEffectsPage, SelectListBoxHdl_Impl );
1387  m_xUnderlineLB->connect_changed( aLink );
1388  m_xUnderlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1389  m_xOverlineLB->connect_changed( aLink );
1390  m_xOverlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1391  m_xStrikeoutLB->connect_changed( aLink );
1392  m_xEmphasisLB->connect_changed( aLink );
1393  m_xPositionLB->connect_changed( aLink );
1394  m_xEffectsLB->connect_changed( aLink );
1395  m_xReliefLB->connect_changed( aLink );
1396 
1397  m_xUnderlineLB->set_active( 0 );
1398  m_xOverlineLB->set_active( 0 );
1399  m_xStrikeoutLB->set_active( 0 );
1400  m_xEmphasisLB->set_active( 0 );
1401  m_xPositionLB->set_active( 0 );
1402  SelectHdl_Impl(nullptr);
1404 
1405  m_xEffectsLB->set_active( 0 );
1406 
1407  m_xHiddenBtn->connect_toggled(LINK(this, SvxCharEffectsPage, HiddenBtnClickHdl));
1408  m_xIndividualWordsBtn->connect_toggled(LINK(this, SvxCharEffectsPage, CbClickHdl_Impl));
1409  m_xOutlineBtn->connect_toggled(LINK(this, SvxCharEffectsPage, OutlineBtnClickHdl));
1410  m_xShadowBtn->connect_toggled(LINK(this, SvxCharEffectsPage, ShadowBtnClickHdl));
1411 
1412  if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
1413  {
1414  m_xEmphasisFT->hide();
1415  m_xEmphasisLB->hide();
1416  m_xPositionFT->hide();
1417  m_xPositionLB->hide();
1418  }
1419 
1420  m_xA11yWarningFT->set_visible(officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get());
1421 }
1422 
1424 {
1425  SvxFont& rFont = GetPreviewFont();
1426  SvxFont& rCJKFont = GetPreviewCJKFont();
1427  SvxFont& rCTLFont = GetPreviewCTLFont();
1428 
1429  const Color& rSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1430  rFont.SetColor(rSelectedColor);
1431  rCJKFont.SetColor(rSelectedColor);
1432  rCTLFont.SetColor(rSelectedColor);
1433  m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO
1434 
1435  FontLineStyle eUnderline = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
1436  FontLineStyle eOverline = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
1437  FontStrikeout eStrikeout = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
1438  rFont.SetUnderline( eUnderline );
1439  rCJKFont.SetUnderline( eUnderline );
1440  rCTLFont.SetUnderline( eUnderline );
1441  m_aPreviewWin.SetTextLineColor( m_xUnderlineColorLB->GetSelectEntryColor() );
1442  rFont.SetOverline( eOverline );
1443  rCJKFont.SetOverline( eOverline );
1444  rCTLFont.SetOverline( eOverline );
1445  m_aPreviewWin.SetOverlineColor( m_xOverlineColorLB->GetSelectEntryColor() );
1446  rFont.SetStrikeout( eStrikeout );
1447  rCJKFont.SetStrikeout( eStrikeout );
1448  rCTLFont.SetStrikeout( eStrikeout );
1449 
1450  auto nEmphasis = m_xEmphasisLB->get_active();
1451  if (nEmphasis != -1)
1452  {
1453  bool bUnder = (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32());
1454  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nEmphasis);
1455  eMark |= bUnder ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
1456  rFont.SetEmphasisMark( eMark );
1457  rCJKFont.SetEmphasisMark( eMark );
1458  rCTLFont.SetEmphasisMark( eMark );
1459  }
1460 
1461  auto nRelief = m_xReliefLB->get_active();
1462  if (nRelief != -1)
1463  {
1464  rFont.SetRelief( static_cast<FontRelief>(nRelief) );
1465  rCJKFont.SetRelief( static_cast<FontRelief>(nRelief) );
1466  rCTLFont.SetRelief( static_cast<FontRelief>(nRelief) );
1467  }
1468 
1469  rFont.SetOutline( StateToAttr( m_xOutlineBtn->get_state() ) );
1470  rCJKFont.SetOutline( rFont.IsOutline() );
1471  rCTLFont.SetOutline( rFont.IsOutline() );
1472 
1473  rFont.SetShadow( StateToAttr( m_xShadowBtn->get_state() ) );
1474  rCJKFont.SetShadow( rFont.IsShadow() );
1475  rCTLFont.SetShadow( rFont.IsShadow() );
1476 
1477  auto nCapsPos = m_xEffectsLB->get_active();
1478  if (nCapsPos != -1)
1479  {
1480  SvxCaseMap eCaps = static_cast<SvxCaseMap>(nCapsPos);
1481  rFont.SetCaseMap( eCaps );
1482  rCJKFont.SetCaseMap( eCaps );
1483  // #i78474# small caps do not exist in CTL fonts
1484  rCTLFont.SetCaseMap( eCaps == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaps );
1485  }
1486 
1487  bool bWordLine = StateToAttr( m_xIndividualWordsBtn->get_state() );
1488  rFont.SetWordLineMode( bWordLine );
1489  rCJKFont.SetWordLineMode( bWordLine );
1490  rCTLFont.SetWordLineMode( bWordLine );
1491 
1492  m_aPreviewWin.Invalidate();
1493 }
1494 
1496 {
1497  if ( SvxCaseMap::End > eCaseMap )
1498  m_xEffectsLB->set_active(
1499  sal::static_int_cast< sal_Int32 >( eCaseMap ) );
1500  else
1501  {
1502  // not mapped
1503  m_xEffectsLB->set_active(-1);
1504  }
1505 
1507 }
1508 
1510 {
1511  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1512  SfxItemState eState = rSet.GetItemState( nWhich );
1513 
1514  m_bOrigFontColor = false;
1515  switch ( eState )
1516  {
1517  case SfxItemState::UNKNOWN:
1518  m_xFontColorFT->hide();
1519  m_xFontColorLB->hide();
1520  break;
1521 
1522  case SfxItemState::DISABLED:
1523  m_xFontColorFT->set_sensitive(false);
1524  m_xFontColorLB->set_sensitive(false);
1525  break;
1526 
1527  case SfxItemState::DONTCARE:
1528  //Related: tdf#106080 if there is no font color, then allow "none"
1529  //as a color so the listbox can display that state.
1531  m_xFontColorLB->SetNoSelection();
1532  break;
1533 
1534  case SfxItemState::DEFAULT:
1535  case SfxItemState::SET:
1536  {
1537  SvxFont& rFont = GetPreviewFont();
1538  SvxFont& rCJKFont = GetPreviewCJKFont();
1539  SvxFont& rCTLFont = GetPreviewCTLFont();
1540 
1541  const SvxColorItem& rItem = static_cast<const SvxColorItem&>(rSet.Get( nWhich ));
1542  Color aColor = rItem.GetValue();
1543  rFont.SetColor(aColor);
1544  rCJKFont.SetColor(aColor);
1545  rCTLFont.SetColor(aColor);
1546  m_aPreviewWin.AutoCorrectFontColor(); // handle color COL_AUTO
1547 
1548  m_aPreviewWin.Invalidate();
1549 
1550  Color aRGBColor = aColor;
1551  if (aRGBColor.IsTransparent() && aColor != COL_AUTO)
1552  {
1553  aRGBColor.SetAlpha(255);
1554  }
1555  m_xFontColorLB->SelectEntry(aRGBColor);
1556 
1557  if (m_xFontTransparencyMtr->get_visible() && aColor != COL_AUTO)
1558  {
1559  double fTransparency = (255 - aColor.GetAlpha()) * 100.0 / 255;
1560  m_xFontTransparencyMtr->set_value(basegfx::fround(fTransparency),
1561  FieldUnit::PERCENT);
1562  }
1563 
1564  m_aOrigFontColor = aColor;
1565  m_bOrigFontColor = true;
1566  break;
1567  }
1568  }
1569  m_bNewFontColor = false;
1570 }
1571 
1573 {
1574  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1575  const SfxItemSet& rOldSet = GetItemSet();
1576 
1577  Color aSelectedColor;
1578  bool bChanged = m_bNewFontColor;
1579 
1580  if (bChanged)
1581  {
1582  aSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1583 
1584  if (m_xFontTransparencyMtr->get_value_changed_from_saved())
1585  {
1586  double fTransparency
1587  = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100;
1588  aSelectedColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
1589  }
1590 
1591  if (m_bOrigFontColor)
1592  bChanged = aSelectedColor != m_aOrigFontColor;
1593  if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR)
1594  bChanged = false;
1595  }
1596 
1597  if (bChanged)
1598  rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
1599  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1600  rSet.InvalidateItem(nWhich);
1601 
1602  return bChanged;
1603 }
1604 
1605 IMPL_LINK( SvxCharEffectsPage, SelectListBoxHdl_Impl, weld::ComboBox&, rBox, void )
1606 {
1607  SelectHdl_Impl(&rBox);
1608 }
1609 
1611 {
1612  if (m_xEmphasisLB.get() == pBox)
1613  {
1614  auto nEPos = m_xEmphasisLB->get_active();
1615  bool bEnable = nEPos > 0;
1616  m_xPositionFT->set_sensitive( bEnable );
1617  m_xPositionLB->set_sensitive( bEnable );
1618  }
1619  else if (m_xReliefLB.get() == pBox)
1620  {
1621  bool bEnable = ( pBox->get_active() == 0 );
1622  m_xOutlineBtn->set_sensitive( bEnable );
1623  m_xShadowBtn->set_sensitive( bEnable );
1624  }
1625  else if (m_xPositionLB.get() != pBox)
1626  {
1627  auto nUPos = m_xUnderlineLB->get_active();
1628  bool bUEnable = nUPos > 0;
1629  m_xUnderlineColorFT->set_sensitive(bUEnable);
1630  m_xUnderlineColorLB->set_sensitive(bUEnable);
1631 
1632  auto nOPos = m_xOverlineLB->get_active();
1633  bool bOEnable = nOPos > 0;
1634  m_xOverlineColorFT->set_sensitive(bOEnable);
1635  m_xOverlineColorLB->set_sensitive(bOEnable);
1636 
1637  auto nSPos = m_xStrikeoutLB->get_active();
1638  m_xIndividualWordsBtn->set_sensitive( bUEnable || bOEnable || nSPos > 0);
1639  }
1641 }
1642 
1643 IMPL_LINK(SvxCharEffectsPage, CbClickHdl_Impl, weld::Toggleable&, rToggle, void)
1644 {
1645  m_aIndividualWordsState.ButtonToggled(rToggle);
1646  UpdatePreview_Impl();
1647  UpdatePreview_Impl();
1648 }
1649 
1650 IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox&, rBox, void)
1651 {
1652  if (m_xFontColorLB.get() == &rBox)
1653  m_bNewFontColor = true;
1654  UpdatePreview_Impl();
1655 }
1656 
1657 IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void)
1658 {
1659  m_bNewFontColor = true;
1660 }
1661 
1663 {
1664  if ( _pSet )
1665  FillItemSet( _pSet );
1666  return DeactivateRC::LeavePage;
1667 }
1668 
1669 std::unique_ptr<SfxTabPage> SvxCharEffectsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
1670 {
1671  return std::make_unique<SvxCharEffectsPage>( pPage, pController, *rSet );
1672 }
1673 
1675 {
1676  SvxFont& rFont = GetPreviewFont();
1677  SvxFont& rCJKFont = GetPreviewCJKFont();
1678  SvxFont& rCTLFont = GetPreviewCTLFont();
1679 
1680  bool bEnable = false;
1681 
1682  // Underline
1683  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
1684  rFont.SetUnderline( LINESTYLE_NONE );
1685  rCJKFont.SetUnderline( LINESTYLE_NONE );
1686  rCTLFont.SetUnderline( LINESTYLE_NONE );
1687 
1688  m_xUnderlineLB->set_active( 0 );
1689  SfxItemState eState = rSet->GetItemState( nWhich );
1690 
1691  if ( eState >= SfxItemState::DONTCARE )
1692  {
1693  if ( eState == SfxItemState::DONTCARE )
1694  m_xUnderlineLB->set_active(-1);
1695  else
1696  {
1697  const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>(rSet->Get( nWhich ));
1698  FontLineStyle eUnderline = rItem.GetValue();
1699  rFont.SetUnderline( eUnderline );
1700  rCJKFont.SetUnderline( eUnderline );
1701  rCTLFont.SetUnderline( eUnderline );
1702 
1703  if ( eUnderline != LINESTYLE_NONE )
1704  {
1705  auto nPos = m_xUnderlineLB->find_id(OUString::number(eUnderline));
1706  if (nPos != -1)
1707  {
1708  m_xUnderlineLB->set_active(nPos);
1709  bEnable = true;
1710  }
1711  Color aColor = rItem.GetColor();
1712  m_xUnderlineColorLB->SelectEntry(aColor);
1713  }
1714  else
1715  {
1716  m_xUnderlineColorLB->SelectEntry(COL_AUTO);
1717  m_xUnderlineColorLB->set_sensitive(false);
1718  }
1719  }
1720  }
1721 
1722  // Overline
1723  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
1724  rFont.SetOverline( LINESTYLE_NONE );
1725  rCJKFont.SetOverline( LINESTYLE_NONE );
1726  rCTLFont.SetOverline( LINESTYLE_NONE );
1727 
1728  m_xOverlineLB->set_active( 0 );
1729  eState = rSet->GetItemState( nWhich );
1730 
1731  if ( eState >= SfxItemState::DONTCARE )
1732  {
1733  if ( eState == SfxItemState::DONTCARE )
1734  m_xOverlineLB->set_active(-1);
1735  else
1736  {
1737  const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>(rSet->Get( nWhich ));
1738  FontLineStyle eOverline = rItem.GetValue();
1739  rFont.SetOverline( eOverline );
1740  rCJKFont.SetOverline( eOverline );
1741  rCTLFont.SetOverline( eOverline );
1742 
1743  if ( eOverline != LINESTYLE_NONE )
1744  {
1745  auto nPos = m_xOverlineLB->find_id(OUString::number(eOverline));
1746  if (nPos != -1)
1747  {
1748  m_xOverlineLB->set_active(nPos);
1749  bEnable = true;
1750  }
1751  Color aColor = rItem.GetColor();
1752  m_xOverlineColorLB->SelectEntry(aColor);
1753  }
1754  else
1755  {
1756  m_xOverlineColorLB->SelectEntry(COL_AUTO);
1757  m_xOverlineColorLB->set_sensitive(false);
1758  }
1759  }
1760  }
1761 
1762  // Strikeout
1763  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
1764  rFont.SetStrikeout( STRIKEOUT_NONE );
1765  rCJKFont.SetStrikeout( STRIKEOUT_NONE );
1766  rCTLFont.SetStrikeout( STRIKEOUT_NONE );
1767 
1768  m_xStrikeoutLB->set_active( 0 );
1769  eState = rSet->GetItemState( nWhich );
1770 
1771  if ( eState >= SfxItemState::DONTCARE )
1772  {
1773  if ( eState == SfxItemState::DONTCARE )
1774  m_xStrikeoutLB->set_active(-1);
1775  else
1776  {
1777  const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>(rSet->Get( nWhich ));
1778  FontStrikeout eStrikeout = rItem.GetValue();
1779  rFont.SetStrikeout( eStrikeout );
1780  rCJKFont.SetStrikeout( eStrikeout );
1781  rCTLFont.SetStrikeout( eStrikeout );
1782 
1783  if ( eStrikeout != STRIKEOUT_NONE )
1784  {
1785  auto nPos = m_xStrikeoutLB->find_id(OUString::number(eStrikeout));
1786  if (nPos != -1)
1787  {
1788  m_xStrikeoutLB->set_active(nPos);
1789  bEnable = true;
1790  }
1791  }
1792  }
1793  }
1794 
1795  // WordLineMode
1796  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
1797  eState = rSet->GetItemState( nWhich );
1798 
1799  switch ( eState )
1800  {
1801  case SfxItemState::UNKNOWN:
1803  m_xIndividualWordsBtn->hide();
1804  break;
1805 
1806  case SfxItemState::DISABLED:
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
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  m_xEffectsFT->set_sensitive(false);
1885  m_xEffectsLB->set_sensitive(false);
1886  break;
1887 
1888  case SfxItemState::DONTCARE:
1889  m_xEffectsLB->set_active(-1);
1890  break;
1891 
1892  case SfxItemState::DEFAULT:
1893  case SfxItemState::SET:
1894  {
1895  const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>(rSet->Get( nWhich ));
1896  eCaseMap = rItem.GetValue();
1897  break;
1898  }
1899  }
1900  SetCaseMap_Impl( eCaseMap );
1901 
1902  //Relief
1903  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
1904  eState = rSet->GetItemState( nWhich );
1905  switch ( eState )
1906  {
1907  case SfxItemState::UNKNOWN:
1908  m_xReliefFT->hide();
1909  m_xReliefLB->hide();
1910  break;
1911 
1912  case SfxItemState::DISABLED:
1913  m_xReliefFT->set_sensitive(false);
1914  m_xReliefLB->set_sensitive(false);
1915  break;
1916 
1917  case SfxItemState::DONTCARE:
1918  m_xReliefLB->set_active(-1);
1919  break;
1920 
1921  case SfxItemState::DEFAULT:
1922  case SfxItemState::SET:
1923  {
1924  const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>(rSet->Get( nWhich ));
1925  m_xReliefLB->set_active(static_cast<sal_Int32>(rItem.GetValue()));
1926  SelectHdl_Impl(m_xReliefLB.get());
1927  break;
1928  }
1929  }
1930 
1931  // Outline
1932  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
1933  eState = rSet->GetItemState( nWhich );
1934  switch ( eState )
1935  {
1936  case SfxItemState::UNKNOWN:
1938  m_xOutlineBtn->hide();
1939  break;
1940 
1941  case SfxItemState::DISABLED:
1943  m_xOutlineBtn->set_sensitive(false);
1944  break;
1945 
1946  case SfxItemState::DONTCARE:
1948  m_xOutlineBtn->set_state(TRISTATE_INDET);
1949  break;
1950 
1951  case SfxItemState::DEFAULT:
1952  case SfxItemState::SET:
1953  {
1954  const SvxContourItem& rItem = static_cast<const SvxContourItem&>(rSet->Get( nWhich ));
1956  m_xOutlineBtn->set_state(static_cast<TriState>(rItem.GetValue()));
1957  break;
1958  }
1959  }
1960 
1961  // Shadow
1962  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
1963  eState = rSet->GetItemState( nWhich );
1964 
1965  switch ( eState )
1966  {
1967  case SfxItemState::UNKNOWN:
1969  m_xShadowBtn->hide();
1970  break;
1971 
1972  case SfxItemState::DISABLED:
1974  m_xShadowBtn->set_sensitive(false);
1975  break;
1976 
1977  case SfxItemState::DONTCARE:
1979  m_xShadowBtn->set_state( TRISTATE_INDET );
1980  break;
1981 
1982  case SfxItemState::DEFAULT:
1983  case SfxItemState::SET:
1984  {
1985  const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>(rSet->Get( nWhich ));
1987  m_xShadowBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
1988  break;
1989  }
1990  }
1991 
1992  // Hidden
1993  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
1994  eState = rSet->GetItemState( nWhich );
1995 
1996  switch ( eState )
1997  {
1998  case SfxItemState::UNKNOWN:
2000  m_xHiddenBtn->hide();
2001  break;
2002 
2003  case SfxItemState::DISABLED:
2005  m_xHiddenBtn->set_sensitive(false);
2006  break;
2007 
2008  case SfxItemState::DONTCARE:
2010  m_xHiddenBtn->set_state(TRISTATE_INDET);
2011  break;
2012 
2013  case SfxItemState::DEFAULT:
2014  case SfxItemState::SET:
2015  {
2016  const SvxCharHiddenItem& rItem = static_cast<const SvxCharHiddenItem&>(rSet->Get( nWhich ));
2018  m_xHiddenBtn->set_state(static_cast<TriState>(rItem.GetValue()));
2019  break;
2020  }
2021  }
2022 
2023  SetPrevFontWidthScale( *rSet );
2024  ResetColor_Impl( *rSet );
2025 
2026  // preview update
2027  m_aPreviewWin.Invalidate();
2028 
2029  // save this settings
2030  ChangesApplied();
2031 }
2032 
2033 IMPL_LINK(SvxCharEffectsPage, HiddenBtnClickHdl, weld::Toggleable&, rToggle, void)
2034 {
2035  m_aHiddenState.ButtonToggled(rToggle);
2036 }
2037 
2038 IMPL_LINK(SvxCharEffectsPage, OutlineBtnClickHdl, weld::Toggleable&, rToggle, void)
2039 {
2040  m_aOutlineState.ButtonToggled(rToggle);
2041  UpdatePreview_Impl();
2042 }
2043 
2044 IMPL_LINK(SvxCharEffectsPage, ShadowBtnClickHdl, weld::Toggleable&, rToggle, void)
2045 {
2046  m_aShadowState.ButtonToggled(rToggle);
2047  UpdatePreview_Impl();
2048 }
2049 
2051 {
2052  m_xUnderlineLB->save_value();
2053  m_xOverlineLB->save_value();
2054  m_xStrikeoutLB->save_value();
2055  m_xIndividualWordsBtn->save_state();
2056  m_xEmphasisLB->save_value();
2057  m_xPositionLB->save_value();
2058  m_xEffectsLB->save_value();
2059  m_xReliefLB->save_value();
2060  m_xOutlineBtn->save_state();
2061  m_xShadowBtn->save_state();
2062  m_xHiddenBtn->save_state();
2063  m_xFontTransparencyMtr->save_value();
2064 }
2065 
2067 {
2068  const SfxPoolItem* pOld = nullptr;
2069  const SfxItemSet& rOldSet = GetItemSet();
2070  bool bModified = false;
2071  bool bChanged = true;
2072 
2073  // Underline
2074  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2075  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_UNDERLINE );
2076  auto nPos = m_xUnderlineLB->get_active();
2077  FontLineStyle eUnder = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
2078 
2079  if ( pOld )
2080  {
2085  bool bAllowChg = nPos != -1 &&
2086  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2087 
2088  const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld);
2089  if ( rItem.GetValue() == eUnder &&
2090  ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) &&
2091  ! bAllowChg )
2092  bChanged = false;
2093  }
2094 
2095  if ( bChanged )
2096  {
2097  SvxUnderlineItem aNewItem( eUnder, nWhich );
2098  aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() );
2099  rSet->Put( aNewItem );
2100  bModified = true;
2101  }
2102  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2103  rSet->InvalidateItem(nWhich);
2104 
2105  bChanged = true;
2106 
2107  // Overline
2108  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2109  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_OVERLINE );
2110  nPos = m_xOverlineLB->get_active();
2111  FontLineStyle eOver = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
2112 
2113  if ( pOld )
2114  {
2119  bool bAllowChg = nPos != -1 &&
2120  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2121 
2122  const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld);
2123  if ( rItem.GetValue() == eOver &&
2124  ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) &&
2125  ! bAllowChg )
2126  bChanged = false;
2127  }
2128 
2129  if ( bChanged )
2130  {
2131  SvxOverlineItem aNewItem( eOver, nWhich );
2132  aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() );
2133  rSet->Put( aNewItem );
2134  bModified = true;
2135  }
2136  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2137  rSet->InvalidateItem(nWhich);
2138 
2139  bChanged = true;
2140 
2141  // Strikeout
2142  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2143  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_STRIKEOUT );
2144  nPos = m_xStrikeoutLB->get_active();
2145  FontStrikeout eStrike = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
2146 
2147  if ( pOld )
2148  {
2153  bool bAllowChg = nPos != -1 &&
2154  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2155 
2156  const SvxCrossedOutItem& rItem = *static_cast<const SvxCrossedOutItem*>(pOld);
2157  if ( !m_xStrikeoutLB->get_sensitive()
2158  || (rItem.GetValue() == eStrike && !bAllowChg) )
2159  bChanged = false;
2160  }
2161 
2162  if ( bChanged )
2163  {
2164  rSet->Put( SvxCrossedOutItem( eStrike, nWhich ) );
2165  bModified = true;
2166  }
2167  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2168  rSet->InvalidateItem(nWhich);
2169 
2170  bChanged = true;
2171 
2172  // Individual words
2173  const SfxItemSet* pExampleSet = GetDialogExampleSet();
2174  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2175  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_WORDLINEMODE );
2176  TriState eState = m_xIndividualWordsBtn->get_state();
2177  const SfxPoolItem* pItem;
2178 
2179  if ( pOld )
2180  {
2181  const SvxWordLineModeItem& rItem = *static_cast<const SvxWordLineModeItem*>(pOld);
2182  if ( rItem.GetValue() == StateToAttr( eState ) && m_xIndividualWordsBtn->get_saved_state() == eState )
2183  bChanged = false;
2184  }
2185 
2186  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2187  !StateToAttr( eState ) && static_cast<const SvxWordLineModeItem*>(pItem)->GetValue() )
2188  bChanged = true;
2189 
2190  if ( bChanged && eState != TRISTATE_INDET )
2191  {
2192  rSet->Put( SvxWordLineModeItem( StateToAttr( eState ), nWhich ) );
2193  bModified = true;
2194  }
2195  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2196  rSet->InvalidateItem(nWhich);
2197 
2198  bChanged = true;
2199 
2200  // Emphasis
2201  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2202  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_EMPHASISMARK );
2203  int nMarkPos = m_xEmphasisLB->get_active();
2204  OUString sMarkPos = m_xEmphasisLB->get_active_text();
2205  OUString sPosPos = m_xPositionLB->get_active_text();
2206  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nMarkPos);
2207  if (m_xPositionLB->get_sensitive())
2208  {
2209  eMark |= (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32())
2210  ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
2211  }
2212 
2213  if ( pOld )
2214  {
2215  if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE )
2216  {
2217  const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld);
2218  if ( rItem.GetEmphasisMark() == eMark )
2219  bChanged = false;
2220  }
2221  }
2222 
2223  if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
2224  m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos)
2225  {
2226  bChanged = false;
2227  }
2228 
2229  if (bChanged)
2230  {
2231  rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2232  bModified = true;
2233  }
2234  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2235  rSet->InvalidateItem(nWhich);
2236 
2237  bChanged = true;
2238 
2239  // Effects
2240  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2241  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CASEMAP );
2242  SvxCaseMap eCaseMap = SvxCaseMap::NotMapped;
2243  bool bChecked = false;
2244  auto nCapsPos = m_xEffectsLB->get_active();
2245  if (nCapsPos != -1)
2246  {
2247  eCaseMap = static_cast<SvxCaseMap>(nCapsPos);
2248  bChecked = true;
2249  }
2250 
2251  if ( pOld )
2252  {
2257  bool bAllowChg = nPos != -1 &&
2258  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2259 
2260  const SvxCaseMapItem& rItem = *static_cast<const SvxCaseMapItem*>(pOld);
2261  if ( rItem.GetValue() == eCaseMap && !bAllowChg )
2262  bChanged = false;
2263  }
2264 
2265  if ( bChanged && bChecked )
2266  {
2267  rSet->Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2268  bModified = true;
2269  }
2270  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2271  rSet->InvalidateItem(nWhich);
2272 
2273  bChanged = true;
2274 
2275  //Relief
2276  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2277  if (m_xReliefLB->get_value_changed_from_saved())
2278  {
2279  m_xReliefLB->save_value();
2280  SvxCharReliefItem aRelief(static_cast<FontRelief>(m_xReliefLB->get_active()), nWhich);
2281  rSet->Put(aRelief);
2282  }
2283 
2284  // Outline
2285  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2286  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CONTOUR );
2287  eState = m_xOutlineBtn->get_state();
2288 
2289  if ( pOld )
2290  {
2291  const SvxContourItem& rItem = *static_cast<const SvxContourItem*>(pOld);
2292  if ( rItem.GetValue() == StateToAttr( eState ) && m_xOutlineBtn->get_saved_state() == eState )
2293  bChanged = false;
2294  }
2295 
2296  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2297  !StateToAttr( eState ) && static_cast<const SvxContourItem*>(pItem)->GetValue() )
2298  bChanged = true;
2299 
2300  if ( bChanged && eState != TRISTATE_INDET )
2301  {
2302  rSet->Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2303  bModified = true;
2304  }
2305  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2306  rSet->InvalidateItem(nWhich);
2307 
2308  bChanged = true;
2309 
2310  // Shadow
2311  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2312  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_SHADOWED );
2313  eState = m_xShadowBtn->get_state();
2314 
2315  if ( pOld )
2316  {
2317  const SvxShadowedItem& rItem = *static_cast<const SvxShadowedItem*>(pOld);
2318  if ( rItem.GetValue() == StateToAttr( eState ) && m_xShadowBtn->get_saved_state() == eState )
2319  bChanged = false;
2320  }
2321 
2322  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2323  !StateToAttr( eState ) && static_cast<const SvxShadowedItem*>(pItem)->GetValue() )
2324  bChanged = true;
2325 
2326  if ( bChanged && eState != TRISTATE_INDET )
2327  {
2328  rSet->Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2329  bModified = true;
2330  }
2331  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2332  rSet->InvalidateItem(nWhich);
2333 
2334  bChanged = true;
2335 
2336  // Hidden
2337  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2338  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_HIDDEN );
2339  eState = m_xHiddenBtn->get_state();
2340  bChanged = true;
2341 
2342  if ( pOld )
2343  {
2344  const SvxCharHiddenItem& rItem = *static_cast<const SvxCharHiddenItem*>(pOld);
2345  if ( rItem.GetValue() == StateToAttr( eState ) && m_xHiddenBtn->get_saved_state() == eState )
2346  bChanged = false;
2347  }
2348 
2349  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2350  !StateToAttr( eState ) && static_cast<const SvxCharHiddenItem*>(pItem)->GetValue() )
2351  bChanged = true;
2352 
2353  if ( bChanged && eState != TRISTATE_INDET )
2354  {
2355  rSet->Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2356  bModified = true;
2357  }
2358  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2359  rSet->InvalidateItem(nWhich);
2360 
2361  bModified |= FillItemSetColor_Impl( *rSet );
2362 
2363  return bModified;
2364 }
2365 
2366 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2367 {
2368  if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2369  {
2370  m_xEffectsFT->set_sensitive(false);
2371  m_xEffectsLB->set_sensitive(false);
2372  }
2373 }
2374 
2376 {
2377  const SfxUInt16Item* pDisableCtlItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
2378  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
2379  if (pDisableCtlItem)
2380  DisableControls(pDisableCtlItem->GetValue());
2381 
2382  if (!pFlagItem)
2383  return;
2384 
2385  sal_uInt32 nFlags=pFlagItem->GetValue();
2386  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2387  // the writer uses SID_ATTR_BRUSH as font background
2389  if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY)
2390  {
2391  // Only show these in case client code explicitly wants this.
2392  m_xFontTransparencyFT->hide();
2393  m_xFontTransparencyMtr->hide();
2394  }
2395 }
2396 
2397 // class SvxCharPositionPage ---------------------------------------------
2398 
2400  : SvxCharBasePage(pPage, pController, "cui/ui/positionpage.ui", "PositionPage", rInSet)
2401  , m_nSuperEsc(short(DFLT_ESC_SUPER))
2402  , m_nSubEsc(short(DFLT_ESC_SUB))
2403  , m_nScaleWidthItemSetVal(100)
2404  , m_nScaleWidthInitialVal(100)
2405  , m_nSuperProp(sal_uInt8(DFLT_ESC_PROP))
2406  , m_nSubProp(sal_uInt8(DFLT_ESC_PROP))
2407  , m_xHighPosBtn(m_xBuilder->weld_radio_button("superscript"))
2408  , m_xNormalPosBtn(m_xBuilder->weld_radio_button("normal"))
2409  , m_xLowPosBtn(m_xBuilder->weld_radio_button("subscript"))
2410  , m_xHighLowFT(m_xBuilder->weld_label("raiselower"))
2411  , m_xHighLowMF(m_xBuilder->weld_metric_spin_button("raiselowersb", FieldUnit::PERCENT))
2412  , m_xHighLowRB(m_xBuilder->weld_check_button("automatic"))
2413  , m_xFontSizeFT(m_xBuilder->weld_label("relativefontsize"))
2414  , m_xFontSizeMF(m_xBuilder->weld_metric_spin_button("fontsizesb", FieldUnit::PERCENT))
2415  , m_xRotationContainer(m_xBuilder->weld_widget("rotationcontainer"))
2416  , m_xScalingFT(m_xBuilder->weld_label("scale"))
2417  , m_xScalingAndRotationFT(m_xBuilder->weld_label("rotateandscale"))
2418  , m_x0degRB(m_xBuilder->weld_radio_button("0deg"))
2419  , m_x90degRB(m_xBuilder->weld_radio_button("90deg"))
2420  , m_x270degRB(m_xBuilder->weld_radio_button("270deg"))
2421  , m_xFitToLineCB(m_xBuilder->weld_check_button("fittoline"))
2422  , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT))
2423  , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT))
2424  , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning"))
2425 {
2426  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
2427 #ifdef IOS
2428  m_xPreviewWin->hide();
2429 #endif
2430  Initialize();
2431 }
2432 
2434 {
2435 }
2436 
2437 
2439 {
2440  // to handle the changes of the other pages
2442 
2443  GetPreviewFont().SetFontSize( Size( 0, 240 ) );
2444  GetPreviewCJKFont().SetFontSize( Size( 0, 240 ) );
2445  GetPreviewCTLFont().SetFontSize( Size( 0, 240 ) );
2446 
2447  m_xNormalPosBtn->set_active(true);
2448  PositionHdl_Impl(*m_xNormalPosBtn);
2449 
2450  Link<weld::Toggleable&,void> aLink2 = LINK(this, SvxCharPositionPage, PositionHdl_Impl);
2451  m_xHighPosBtn->connect_toggled(aLink2);
2452  m_xNormalPosBtn->connect_toggled(aLink2);
2453  m_xLowPosBtn->connect_toggled(aLink2);
2454 
2455  aLink2 = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
2456  m_x0degRB->connect_toggled(aLink2);
2457  m_x90degRB->connect_toggled(aLink2);
2458  m_x270degRB->connect_toggled(aLink2);
2459 
2460  Link<weld::MetricSpinButton&,void> aLink3 = LINK(this, SvxCharPositionPage, ValueChangedHdl_Impl);
2461  m_xHighLowMF->connect_value_changed(aLink3);
2462  m_xFontSizeMF->connect_value_changed(aLink3);
2463 
2464  m_xHighLowRB->connect_toggled(LINK(this, SvxCharPositionPage, AutoPositionHdl_Impl));
2465  m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl));
2466  m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl));
2467  m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl));
2468 }
2469 
2471 {
2472  SetPrevFontEscapement( nProp, nEscProp, nEsc );
2473 }
2474 
2475 
2477 {
2478  SvxEscapementItem aEscItm( nEsc, SID_ATTR_CHAR_ESCAPEMENT );
2479 
2480  if ( SvxEscapement::Superscript == nEsc )
2481  {
2482  aEscItm.GetEsc() = m_nSuperEsc;
2483  aEscItm.GetProportionalHeight() = m_nSuperProp;
2484  }
2485  else if ( SvxEscapement::Subscript == nEsc )
2486  {
2487  aEscItm.GetEsc() = m_nSubEsc;
2488  aEscItm.GetProportionalHeight() = m_nSubProp;
2489  }
2490 
2491  short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
2492 
2493  m_xHighLowMF->set_value(aEscItm.GetEsc() * nFac, FieldUnit::PERCENT);
2494  m_xFontSizeMF->set_value(aEscItm.GetProportionalHeight(), FieldUnit::PERCENT);
2495 
2496  if ( SvxEscapement::Off == nEsc )
2497  {
2498  m_xHighLowFT->set_sensitive(false);
2499  m_xHighLowMF->set_sensitive(false);
2500  m_xFontSizeFT->set_sensitive(false);
2501  m_xFontSizeMF->set_sensitive(false);
2502  m_xHighLowRB->set_sensitive(false);
2503  }
2504  else
2505  {
2506  m_xFontSizeFT->set_sensitive(true);
2507  m_xFontSizeMF->set_sensitive(true);
2508  m_xHighLowRB->set_sensitive(true);
2509 
2510  if (!m_xHighLowRB->get_active())
2511  {
2512  m_xHighLowFT->set_sensitive(true);
2513  m_xHighLowMF->set_sensitive(true);
2514  }
2515  else
2516  AutoPositionHdl_Impl(*m_xHighLowRB);
2517  }
2518 
2519  UpdatePreview_Impl( 100, aEscItm.GetProportionalHeight(), aEscItm.GetEsc() );
2520 }
2521 
2522 
2524 {
2525  SvxEscapement nEsc = SvxEscapement::Off; // also when pBtn == NULL
2526 
2527  if (m_xHighPosBtn->get_active())
2528  nEsc = SvxEscapement::Superscript;
2529  else if (m_xLowPosBtn->get_active())
2530  nEsc = SvxEscapement::Subscript;
2531 
2532  SetEscapement_Impl( nEsc );
2533 }
2534 
2536 {
2537  bool bEnable = false;
2538  if (m_x90degRB->get_active() || m_x270degRB->get_active())
2539  bEnable = true;
2540  else
2541  OSL_ENSURE(m_x0degRB->get_active(), "unexpected button");
2542  m_xFitToLineCB->set_sensitive(bEnable);
2543 }
2544 
2546 {
2547  sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2548  short nEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2549  nEsc *= m_xLowPosBtn->get_active() ? -1 : 1;
2550  UpdatePreview_Impl( 100, nEscProp, nEsc );
2551 }
2552 
2553 IMPL_LINK(SvxCharPositionPage, AutoPositionHdl_Impl, weld::Toggleable&, rBox, void)
2554 {
2555  if (rBox.get_active())
2556  {
2557  m_xHighLowFT->set_sensitive(false);
2558  m_xHighLowMF->set_sensitive(false);
2559  }
2560  else
2561  PositionHdl_Impl(m_xHighPosBtn->get_active() ? *m_xHighPosBtn
2562  : m_xLowPosBtn->get_active() ? *m_xLowPosBtn
2563  : *m_xNormalPosBtn);
2564 }
2565 
2567 {
2568  sal_uInt16 nVal = m_nScaleWidthInitialVal;
2569  if (m_xFitToLineCB->get_active())
2570  nVal = m_nScaleWidthItemSetVal;
2571  m_xScaleWidthMF->set_value(nVal, FieldUnit::PERCENT);
2572  m_aPreviewWin.SetFontWidthScale( nVal );
2573 }
2574 
2576 {
2577  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2578  nVal = OutputDevice::LogicToLogic( nVal, MapUnit::MapPoint, MapUnit::MapTwip );
2579  tools::Long nKern = static_cast<short>(m_xKerningMF->denormalize(nVal));
2580 
2581  SvxFont& rFont = GetPreviewFont();
2582  SvxFont& rCJKFont = GetPreviewCJKFont();
2583  SvxFont& rCTLFont = GetPreviewCTLFont();
2584 
2585  rFont.SetFixKerning( static_cast<short>(nKern) );
2586  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2587  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2588  m_aPreviewWin.Invalidate();
2589 }
2590 
2591 IMPL_LINK(SvxCharPositionPage, ValueChangedHdl_Impl, weld::MetricSpinButton&, rField, void)
2592 {
2593  bool bHigh = m_xHighPosBtn->get_active();
2594  bool bLow = m_xLowPosBtn->get_active();
2595  DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
2596 
2597  if (m_xHighLowMF.get() == &rField)
2598  {
2599  if ( bLow )
2600  m_nSubEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT)) * -1;
2601  else
2602  m_nSuperEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2603  }
2604  else if (m_xFontSizeMF.get() == &rField)
2605  {
2606  if ( bLow )
2607  m_nSubProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2608  else
2609  m_nSuperProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2610  }
2611 
2612  FontModifyHdl_Impl();
2613 }
2614 
2616 {
2617  m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)));
2618 }
2619 
2621 {
2622  if ( _pSet )
2623  FillItemSet( _pSet );
2624  return DeactivateRC::LeavePage;
2625 }
2626 
2627 std::unique_ptr<SfxTabPage> SvxCharPositionPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2628 {
2629  return std::make_unique<SvxCharPositionPage>(pPage, pController, *rSet);
2630 }
2631 
2633 {
2634  OUString sUser = GetUserData();
2635 
2636  if ( !sUser.isEmpty() )
2637  {
2638  sal_Int32 nIdx {0};
2639  m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2640  m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2641  m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2642  m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2643 
2644  m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT);
2645 
2646  //fdo#75307 validate all the entries and discard all of them if any are
2647  //out of range
2648  bool bValid = true;
2649  if (m_nSuperEsc < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSuperEsc > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2650  bValid = false;
2651  if (m_nSubEsc*-1 < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSubEsc*-1 > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2652  bValid = false;
2653  if (m_nSuperProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSuperProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2654  bValid = false;
2655  if (m_nSubProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSubProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2656  bValid = false;
2657 
2658  if (!bValid)
2659  {
2664  }
2665  }
2666 
2667  short nEsc = 0;
2668  sal_uInt8 nEscProp = 100;
2669 
2670  m_xHighLowFT->set_sensitive(false);
2671  m_xHighLowMF->set_sensitive(false);
2672  m_xFontSizeFT->set_sensitive(false);
2673  m_xFontSizeMF->set_sensitive(false);
2674 
2675  SvxFont& rFont = GetPreviewFont();
2676  SvxFont& rCJKFont = GetPreviewCJKFont();
2677  SvxFont& rCTLFont = GetPreviewCTLFont();
2678  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2679 
2680  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2681  {
2682  const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>(rSet->Get( nWhich ));
2683  nEsc = rItem.GetEsc();
2684  nEscProp = rItem.GetProportionalHeight();
2685 
2686  if ( nEsc != 0 )
2687  {
2688  m_xHighLowFT->set_sensitive(true);
2689  m_xHighLowMF->set_sensitive(true);
2690  m_xFontSizeFT->set_sensitive(true);
2691  m_xFontSizeMF->set_sensitive(true);
2692 
2693  short nFac;
2694  bool bAutomatic(false);
2695 
2696  if ( nEsc > 0 )
2697  {
2698  nFac = 1;
2699  m_xHighPosBtn->set_active(true);
2700  if ( nEsc == DFLT_ESC_AUTO_SUPER )
2701  {
2702  nEsc = .8 * (100 - nEscProp); //approximation of actual percentage used
2703  bAutomatic = true;
2704  }
2705  }
2706  else
2707  {
2708  nFac = -1;
2709  m_xLowPosBtn->set_active(true);
2710  if ( nEsc == DFLT_ESC_AUTO_SUB )
2711  {
2712  nEsc = .2 * -(100 - nEscProp); //approximation of actual percentage used
2713  bAutomatic = true;
2714  }
2715  }
2716  if (!m_xHighLowRB->get_sensitive())
2717  {
2718  m_xHighLowRB->set_sensitive(true);
2719  }
2720  m_xHighLowRB->set_active(bAutomatic);
2721 
2722  if (m_xHighLowRB->get_active())
2723  {
2724  m_xHighLowFT->set_sensitive(false);
2725  m_xHighLowMF->set_sensitive(false);
2726  }
2727  m_xHighLowMF->set_value(m_xHighLowMF->normalize(nFac * nEsc), FieldUnit::PERCENT);
2728  }
2729  else
2730  {
2731  m_xNormalPosBtn->set_active(true);
2732  m_xHighLowRB->set_active(true);
2733  PositionHdl_Impl(*m_xNormalPosBtn);
2734  }
2735  //the height has to be set after the handler is called to keep the value also if the escapement is zero
2736  m_xFontSizeMF->set_value(m_xFontSizeMF->normalize(nEscProp), FieldUnit::PERCENT);
2737  }
2738  else
2739  {
2740  m_xHighPosBtn->set_active(false);
2741  m_xNormalPosBtn->set_active(false);
2742  m_xLowPosBtn->set_active(false);
2743  }
2744 
2745  // set BspFont
2746  SetPrevFontEscapement( 100, nEscProp, nEsc );
2747 
2748  // Kerning
2749  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2750 
2751  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2752  {
2753  const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>(rSet->Get( nWhich ));
2754  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2755  tools::Long nBig = static_cast<tools::Long>(m_xKerningMF->normalize( static_cast<tools::Long>(rItem.GetValue()) ));
2756  tools::Long nKerning = OutputDevice::LogicToLogic(nBig, eUnit, MapUnit::MapPoint);
2757 
2758  // set Kerning at the Font, convert into Twips before
2759  tools::Long nKern = OutputDevice::LogicToLogic(rItem.GetValue(), eUnit, MapUnit::MapTwip);
2760  rFont.SetFixKerning( static_cast<short>(nKern) );
2761  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2762  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2763 
2764  //the attribute value must be displayed also if it's above the maximum allowed value
2765  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_max(FieldUnit::POINT));
2766  if(nVal < nKerning)
2767  m_xKerningMF->set_max(nKerning, FieldUnit::POINT);
2768  m_xKerningMF->set_value(nKerning, FieldUnit::POINT);
2769  }
2770  else
2771  m_xKerningMF->set_text(OUString());
2772 
2773  // Pair kerning
2774  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2775 
2776  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2777  {
2778  const SvxAutoKernItem& rItem = static_cast<const SvxAutoKernItem&>(rSet->Get( nWhich ));
2779  m_xPairKerningBtn->set_active(rItem.GetValue());
2780  }
2781  else
2782  m_xPairKerningBtn->set_active(false);
2783 
2784  // Scale Width
2785  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2786  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2787  {
2788  const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet->Get( nWhich ) );
2789  m_nScaleWidthInitialVal = rItem.GetValue();
2790  m_xScaleWidthMF->set_value(m_nScaleWidthInitialVal, FieldUnit::PERCENT);
2791  }
2792  else
2793  m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT);
2794 
2795  nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
2796  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2797  m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( nWhich )).GetValue();
2798 
2799  // Rotation
2800  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2801  SfxItemState eState = rSet->GetItemState( nWhich );
2802  if( SfxItemState::UNKNOWN == eState )
2803  {
2804  m_xRotationContainer->hide();
2805  m_xScalingAndRotationFT->hide();
2806  m_xScalingFT->show();
2807  }
2808  else
2809  {
2810  m_xRotationContainer->show();
2811  m_xScalingAndRotationFT->show();
2812  m_xScalingFT->hide();
2813 
2814  if( eState >= SfxItemState::DEFAULT )
2815  {
2816  const SvxCharRotateItem& rItem =
2817  static_cast<const SvxCharRotateItem&>( rSet->Get( nWhich ));
2818  if (rItem.IsBottomToTop())
2819  m_x90degRB->set_active(true);
2820  else if (rItem.IsTopToBottom())
2821  m_x270degRB->set_active(true);
2822  else
2823  {
2824  DBG_ASSERT( 0_deg10 == rItem.GetValue(), "incorrect value" );
2825  m_x0degRB->set_active(true);
2826  }
2827  m_xFitToLineCB->set_active(rItem.IsFitToLine());
2828  }
2829  else
2830  {
2831  if( eState == SfxItemState::DONTCARE )
2832  {
2833  m_x0degRB->set_active(false);
2834  m_x90degRB->set_active(false);
2835  m_x270degRB->set_active(false);
2836  }
2837  else
2838  m_x0degRB->set_active(true);
2839 
2840  m_xFitToLineCB->set_active(false);
2841  }
2842  m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active());
2843 
2844  // is this value set?
2845  if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich(
2846  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
2847  m_xFitToLineCB->hide();
2848  }
2849  ChangesApplied();
2850 }
2851 
2853 {
2854  m_xHighPosBtn->save_state();
2855  m_xNormalPosBtn->save_state();
2856  m_xLowPosBtn->save_state();
2857  m_xHighLowRB->save_state();
2858  m_x0degRB->save_state();
2859  m_x90degRB->save_state();
2860  m_x270degRB->save_state();
2861  m_xFitToLineCB->save_state();
2862  m_xScaleWidthMF->save_value();
2863  m_xKerningMF->save_value();
2864  m_xPairKerningBtn->save_state();
2865 }
2866 
2868 {
2869  // Position (high, normal or low)
2870  const SfxItemSet& rOldSet = GetItemSet();
2871  bool bModified = false, bChanged = true;
2872  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2873  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_ESCAPEMENT );
2874  const bool bHigh = m_xHighPosBtn->get_active();
2875  short nEsc;
2876  sal_uInt8 nEscProp;
2877 
2878  if (bHigh || m_xLowPosBtn->get_active())
2879  {
2880  if (m_xHighLowRB->get_active())
2881  nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
2882  else
2883  {
2884  nEsc = static_cast<short>(m_xHighLowMF->denormalize(m_xHighLowMF->get_value(FieldUnit::PERCENT)));
2885  nEsc *= (bHigh ? 1 : -1);
2886  }
2887  nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->denormalize(m_xFontSizeMF->get_value(FieldUnit::PERCENT)));
2888  }
2889  else
2890  {
2891  nEsc = 0;
2892  nEscProp = 100;
2893  }
2894 
2895  if ( pOld )
2896  {
2897  const SvxEscapementItem& rItem = *static_cast<const SvxEscapementItem*>(pOld);
2898  if (rItem.GetEsc() == nEsc && rItem.GetProportionalHeight() == nEscProp)
2899  bChanged = false;
2900  }
2901 
2902  if ( !bChanged && !m_xHighPosBtn->get_saved_state() &&
2903  !m_xNormalPosBtn->get_saved_state() && !m_xLowPosBtn->get_saved_state() )
2904  bChanged = true;
2905 
2906  if ( bChanged &&
2907  ( m_xHighPosBtn->get_active() || m_xNormalPosBtn->get_active() || m_xLowPosBtn->get_active() ) )
2908  {
2909  rSet->Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
2910  bModified = true;
2911  }
2912  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2913  rSet->InvalidateItem(nWhich);
2914 
2915  bChanged = true;
2916 
2917  // Kerning
2918  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2919  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_KERNING );
2920  short nKerning = 0;
2921  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2922 
2923  tools::Long nTmp = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2924  tools::Long nVal = OutputDevice::LogicToLogic(nTmp, MapUnit::MapPoint, eUnit);
2925  nKerning = static_cast<short>(m_xKerningMF->denormalize( nVal ));
2926 
2927  SfxItemState eOldKernState = rOldSet.GetItemState( nWhich, false );
2928  if ( pOld )
2929  {
2930  const SvxKerningItem& rItem = *static_cast<const SvxKerningItem*>(pOld);
2931  if ( (eOldKernState >= SfxItemState::DEFAULT || m_xKerningMF->get_text().isEmpty()) && rItem.GetValue() == nKerning )
2932  bChanged = false;
2933  }
2934 
2935  if ( bChanged )
2936  {
2937  rSet->Put( SvxKerningItem( nKerning, nWhich ) );
2938  bModified = true;
2939  }
2940  else if ( SfxItemState::DEFAULT == eOldKernState )
2941  rSet->InvalidateItem(nWhich);
2942 
2943  // Pair-Kerning
2944  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2945 
2946  if (m_xPairKerningBtn->get_state_changed_from_saved())
2947  {
2948  rSet->Put( SvxAutoKernItem( m_xPairKerningBtn->get_active(), nWhich ) );
2949  bModified = true;
2950  }
2951  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2952  rSet->InvalidateItem(nWhich);
2953 
2954  // Scale Width
2955  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2956  if (m_xScaleWidthMF->get_value_changed_from_saved())
2957  {
2958  rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich));
2959  bModified = true;
2960  }
2961  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2962  rSet->InvalidateItem(nWhich);
2963 
2964  // Rotation
2965  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2966  if ( m_x0degRB->get_state_changed_from_saved() ||
2967  m_x90degRB->get_state_changed_from_saved() ||
2968  m_x270degRB->get_state_changed_from_saved() ||
2969  m_xFitToLineCB->get_state_changed_from_saved() )
2970  {
2971  SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), nWhich );
2972  if (m_x90degRB->get_active())
2973  aItem.SetBottomToTop();
2974  else if (m_x270degRB->get_active())
2975  aItem.SetTopToBottom();
2976  rSet->Put( aItem );
2977  bModified = true;
2978  }
2979  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2980  rSet->InvalidateItem(nWhich);
2981 
2982  return bModified;
2983 }
2984 
2985 
2987 {
2988  static const OUStringLiteral cTok( u";" );
2989 
2990  OUString sUser = OUString::number( m_nSuperEsc ) + cTok +
2991  OUString::number( m_nSubEsc ) + cTok +
2992  OUString::number( m_nSuperProp ) + cTok +
2993  OUString::number( m_nSubProp );
2994  SetUserData( sUser );
2995 }
2996 
2997 
2999 {
3000  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3001  if (pFlagItem)
3002  {
3003  sal_uInt32 nFlags=pFlagItem->GetValue();
3004  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3005  // the writer uses SID_ATTR_BRUSH as font background
3007  }
3008 }
3009 // class SvxCharTwoLinesPage ------------------------------------------------
3010 
3012  : SvxCharBasePage(pPage, pController, "cui/ui/twolinespage.ui", "TwoLinesPage", rInSet)
3013  , m_nStartBracketPosition( 0 )
3014  , m_nEndBracketPosition( 0 )
3015  , m_xTwoLinesBtn(m_xBuilder->weld_check_button("twolines"))
3016  , m_xEnclosingFrame(m_xBuilder->weld_widget("enclosing"))
3017  , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket"))
3018  , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket"))
3019 {
3020  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_OPEN); ++i)
3021  m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first));
3022  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_CLOSE); ++i)
3023  m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first));
3024 
3025  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
3026 #ifdef IOS
3027  m_xPreviewWin->hide();
3028 #endif
3029  Initialize();
3030 }
3031 
3033 {
3034 }
3035 
3037 {
3038  m_xTwoLinesBtn->set_active(false);
3039  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3040 
3041  m_xTwoLinesBtn->connect_toggled(LINK(this, SvxCharTwoLinesPage, TwoLinesHdl_Impl));
3042 
3043  Link<weld::TreeView&,void> aLink = LINK(this, SvxCharTwoLinesPage, CharacterMapHdl_Impl);
3044  m_xStartBracketLB->connect_changed(aLink);
3045  m_xEndBracketLB->connect_changed(aLink);
3046 
3047  SvxFont& rFont = GetPreviewFont();
3048  SvxFont& rCJKFont = GetPreviewCJKFont();
3049  SvxFont& rCTLFont = GetPreviewCTLFont();
3050  rFont.SetFontSize( Size( 0, 220 ) );
3051  rCJKFont.SetFontSize( Size( 0, 220 ) );
3052  rCTLFont.SetFontSize( Size( 0, 220 ) );
3053 }
3054 
3056 {
3057  bool bStart = pBox == m_xStartBracketLB.get();
3058  SvxCharacterMap aDlg(GetFrameWeld(), nullptr, nullptr);
3059  aDlg.DisableFontSelection();
3060 
3061  if (aDlg.run() == RET_OK)
3062  {
3063  sal_Unicode cChar = static_cast<sal_Unicode>(aDlg.GetChar());
3064  SetBracket( cChar, bStart );
3065  }
3066  else
3067  {
3069  }
3070 }
3071 
3072 
3073 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart )
3074 {
3075  int nEntryPos = 0;
3076  weld::TreeView* pBox = bStart ? m_xStartBracketLB.get() : m_xEndBracketLB.get();
3077  if (cBracket == 0)
3078  pBox->select(0);
3079  else
3080  {
3081  bool bFound = false;
3082  for (int i = 1; i < pBox->n_children(); ++i)
3083  {
3084  if (pBox->get_id(i).toInt32() != CHRDLG_ENCLOSE_SPECIAL_CHAR)
3085  {
3086  const sal_Unicode cChar = pBox->get_text(i)[0];
3087  if (cChar == cBracket)
3088  {
3089  pBox->select(i);
3090  nEntryPos = i;
3091  bFound = true;
3092  break;
3093  }
3094  }
3095  }
3096 
3097  if (!bFound)
3098  {
3099  pBox->append_text(OUString(cBracket));
3100  nEntryPos = pBox->n_children() - 1;
3101  pBox->select(nEntryPos);
3102  }
3103  }
3104  if (bStart)
3105  m_nStartBracketPosition = nEntryPos;
3106  else
3107  m_nEndBracketPosition = nEntryPos;
3108 }
3109 
3111 {
3112  bool bChecked = m_xTwoLinesBtn->get_active();
3113  m_xEnclosingFrame->set_sensitive(bChecked);
3114  UpdatePreview_Impl();
3115 }
3116 
3117 IMPL_LINK(SvxCharTwoLinesPage, CharacterMapHdl_Impl, weld::TreeView&, rBox, void)
3118 {
3119  int nPos = rBox.get_selected_index();
3120  if (rBox.get_id(nPos).toInt32() == CHRDLG_ENCLOSE_SPECIAL_CHAR)
3121  SelectCharacter( &rBox );
3122  else
3123  {
3124  bool bStart = &rBox == m_xStartBracketLB.get();
3125  if (bStart)
3126  m_nStartBracketPosition = nPos;
3127  else
3128  m_nEndBracketPosition = nPos;
3129  }
3130  UpdatePreview_Impl();
3131 }
3132 
3134 {
3136 }
3137 
3139 {
3140  if ( _pSet )
3141  FillItemSet( _pSet );
3142  return DeactivateRC::LeavePage;
3143 }
3144 
3145 std::unique_ptr<SfxTabPage> SvxCharTwoLinesPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
3146 {
3147  return std::make_unique<SvxCharTwoLinesPage>(pPage, pController, *rSet);
3148 }
3149 
3151 {
3152  m_xTwoLinesBtn->set_active(false);
3153  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3154  SfxItemState eState = rSet->GetItemState( nWhich );
3155 
3156  if ( eState >= SfxItemState::DONTCARE )
3157  {
3158  const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich ));
3159  m_xTwoLinesBtn->set_active(rItem.GetValue());
3160 
3161  if ( rItem.GetValue() )
3162  {
3163  SetBracket( rItem.GetStartBracket(), true );
3164  SetBracket( rItem.GetEndBracket(), false );
3165  }
3166  }
3167  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3168 
3169  SetPrevFontWidthScale( *rSet );
3170 }
3171 
3173 {
3174  const SfxItemSet& rOldSet = GetItemSet();
3175  bool bModified = false, bChanged = true;
3176  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3177  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_TWO_LINES );
3178  bool bOn = m_xTwoLinesBtn->get_active();
3179  sal_Unicode cStart = ( bOn && m_xStartBracketLB->get_selected_index() > 0 )
3180  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3181  sal_Unicode cEnd = ( bOn && m_xEndBracketLB->get_selected_index() > 0 )
3182  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3183 
3184  if ( pOld )
3185  {
3186  const SvxTwoLinesItem& rItem = *static_cast<const SvxTwoLinesItem*>(pOld);
3187  if ( rItem.GetValue() == bOn &&
3188  ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3189  bChanged = false;
3190  }
3191 
3192  if ( bChanged )
3193  {
3194  rSet->Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3195  bModified = true;
3196  }
3197  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3198  rSet->InvalidateItem(nWhich);
3199 
3200  return bModified;
3201 }
3202 
3204 {
3205  sal_Unicode cStart = m_xStartBracketLB->get_selected_index() > 0
3206  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3207  sal_Unicode cEnd = m_xEndBracketLB->get_selected_index() > 0
3208  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3209  m_aPreviewWin.SetBrackets(cStart, cEnd);
3210  m_aPreviewWin.SetTwoLines(m_xTwoLinesBtn->get_active());
3211  m_aPreviewWin.Invalidate();
3212 }
3213 
3215 {
3216  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3217  if (pFlagItem)
3218  {
3219  sal_uInt32 nFlags=pFlagItem->GetValue();
3220  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3221  // the writer uses SID_ATTR_BRUSH as font background
3223  }
3224 }
3225 
3226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFamily(FontFamily)
sal_uInt16 m_nScaleWidthInitialVal
Definition: chardlg.hxx:243
virtual ~SvxCharEffectsPage() override
Definition: chardlg.cxx:1354
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:3073
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:1126
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:1186
std::unique_ptr< weld::Button > m_xWestFontFeaturesButton
Definition: chardlg.hxx:78
virtual void FillUserData() override
Definition: chardlg.cxx:2986
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:1662
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:1572
virtual void hide()=0
void SetColor(const Color &rCol)
SvxCharPositionPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:2399
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
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
void set_value(int nValue)
constexpr OUStringLiteral PERCENT(u"Percent")
Language for asian text.
Definition: chardlg.hxx:118
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:3150
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:1208
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:1198
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:1495
OUString get_active_text() const
virtual void ChangesApplied() override
Definition: chardlg.cxx:2852
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:1168
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:1610
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:2433
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:3214
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:1131
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:838
std::unique_ptr< weld::Label > m_xEastFontLanguageFT
Definition: chardlg.hxx:87
void save_value()
void SetEscapement_Impl(SvxEscapement nEsc)
Definition: chardlg.cxx:2476
SvxFont & GetFont()
#define DFLT_ESC_PROP
sal_uInt8 m_nSuperProp
Definition: chardlg.hxx:245
void DisableControls(sal_uInt16 nDisable)
Definition: chardlg.cxx:1269
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:2545
std::unique_ptr< weld::CheckButton > m_xTwoLinesBtn
Definition: chardlg.hxx:310
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2066
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:1674
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:1193
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:1264
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:3133
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:3011
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:1224
std::unique_ptr< SvxLanguageBox > m_xCTLFontLanguageLB
Definition: chardlg.hxx:100
float u
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:2375
tools::Long CalcToUnit(float nIn, MapUnit eUnit)
virtual OUString get_text(int row, int col=-1) const =0
void EnableNoneFontColor()
Definition: chardlg.cxx:1348
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:1179
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:2632
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
void SetTwoLines(bool bSet)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:2998
bool IsFitToLine() const
void set_active_or_entry_text(const OUString &rText)
void EnableRelativeMode()
Definition: chardlg.cxx:1256
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:1509
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:2050
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:2470
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:3138
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:3032
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:2366
SfxOkDialogController * GetDialogController() const
void DisableFontSelection()
Definition: cuicharmap.cxx:216
int get_saved_value() const
void UpdatePreview_Impl()
Definition: chardlg.cxx:3203
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:3055
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:2867
#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:76
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:1669
void SetFontList(const SvxFontListItem &rItem)
Definition: chardlg.cxx:1232
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:2620
#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:3172
#define SVX_ENABLE_CHAR_TRANSPARENCY
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:2627
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:1304
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:1282
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:1423
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:3145
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