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