LibreOffice Module cui (master)  1
chardlg.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <vcl/svapp.hxx>
21 #include <vcl/idle.hxx>
22 #include <svtools/ctrltool.hxx>
23 #include <sfx2/objsh.hxx>
24 #include <svx/svxids.hrc>
25 #include <svtools/unitconv.hxx>
26 #include <svl/languageoptions.hxx>
27 #include <svl/cjkoptions.hxx>
28 #include <svl/ctloptions.hxx>
29 #include <chardlg.hxx>
30 #include <editeng/fontitem.hxx>
31 #include <editeng/postitem.hxx>
32 #include <editeng/udlnitem.hxx>
34 #include <editeng/contouritem.hxx>
35 #include <editeng/langitem.hxx>
36 #include <editeng/wghtitem.hxx>
37 #include <editeng/fhgtitem.hxx>
38 #include <editeng/shdditem.hxx>
40 #include <editeng/wrlmitem.hxx>
41 #include <editeng/cmapitem.hxx>
42 #include <editeng/kernitem.hxx>
43 #include <editeng/flstitem.hxx>
44 #include <editeng/autokernitem.hxx>
45 #include <editeng/colritem.hxx>
46 #include <dialmgr.hxx>
47 #include <sfx2/htmlmode.hxx>
48 #include <cui/cuicharmap.hxx>
49 #include "chardlg.h"
52 #include <editeng/twolinesitem.hxx>
56 #include <officecfg/Office/Common.hxx>
57 #include <strings.hrc>
58 #include <twolines.hrc>
59 #include <svl/intitem.hxx>
60 #include <svx/flagsdef.hxx>
61 #include <FontFeatures.hxx>
62 #include <FontFeaturesDialog.hxx>
63 #include <sal/log.hxx>
64 #include <osl/diagnose.h>
65 #include <o3tl/unit_conversion.hxx>
66 
67 using namespace ::com::sun::star;
68 
69 // static ----------------------------------------------------------------
70 
72  SID_ATTR_CHAR_FONT, SID_ATTR_CHAR_WEIGHT,
73  SID_ATTR_CHAR_FONTHEIGHT, SID_ATTR_CHAR_FONTHEIGHT,
74  SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
75  SID_ATTR_CHAR_LANGUAGE, SID_ATTR_CHAR_LANGUAGE,
76  SID_ATTR_CHAR_CJK_FONT, SID_ATTR_CHAR_CJK_WEIGHT,
77  SID_ATTR_CHAR_CTL_FONT, SID_ATTR_CHAR_CTL_WEIGHT
78 >);
79 
81  SID_ATTR_CHAR_SHADOWED, SID_ATTR_CHAR_UNDERLINE,
82  SID_ATTR_CHAR_COLOR, SID_ATTR_CHAR_COLOR,
83  SID_ATTR_CHAR_CASEMAP, SID_ATTR_CHAR_CASEMAP,
84  SID_ATTR_FLASH, SID_ATTR_FLASH,
85  SID_ATTR_CHAR_EMPHASISMARK, SID_ATTR_CHAR_EMPHASISMARK,
86  SID_ATTR_CHAR_RELIEF, SID_ATTR_CHAR_RELIEF,
87  SID_ATTR_CHAR_HIDDEN, SID_ATTR_CHAR_HIDDEN,
88  SID_ATTR_CHAR_OVERLINE, SID_ATTR_CHAR_OVERLINE
89 >);
90 
92  SID_ATTR_CHAR_KERNING, SID_ATTR_CHAR_KERNING,
93  SID_ATTR_CHAR_ESCAPEMENT, SID_ATTR_CHAR_ESCAPEMENT,
94  SID_ATTR_CHAR_AUTOKERN, SID_ATTR_CHAR_AUTOKERN,
95  SID_ATTR_CHAR_ROTATED, SID_ATTR_CHAR_SCALEWIDTH,
96  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE, SID_ATTR_CHAR_WIDTH_FIT_TO_LINE
97 >);
98 
100  SID_ATTR_CHAR_TWO_LINES, SID_ATTR_CHAR_TWO_LINES
101 >);
102 
103 // C-Function ------------------------------------------------------------
104 
105 static bool StateToAttr( TriState aState )
106 {
107  return ( TRISTATE_TRUE == aState );
108 }
109 
110 namespace
111 {
112  void setPrevFontEscapement(SvxFont& _rFont,sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
113  {
114  _rFont.SetPropr( nProp );
115  _rFont.SetProprRel( nEscProp );
116  _rFont.SetEscapement( nEsc );
117  }
118 }
119 
121 {
122  return m_aPreviewWin.GetFont();
123 }
124 
126 {
127  return m_aPreviewWin.GetCJKFont();
128 }
129 
131 {
132  return m_aPreviewWin.GetCTLFont();
133 }
134 
135 SvxCharBasePage::SvxCharBasePage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemset)
136  : SfxTabPage(pPage, pController, rUIXMLDescription, rID, &rItemset)
137  , m_bPreviewBackgroundToCharacter( false )
138 {
139 }
140 
142 {
143 }
144 
146 {
148 }
149 
151 {
152  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
153  if (rSet.GetItemState(nWhich)>=SfxItemState::DEFAULT)
154  {
155  const SvxCharScaleWidthItem &rItem = static_cast<const SvxCharScaleWidthItem&>( rSet.Get( nWhich ) );
156  m_aPreviewWin.SetFontWidthScale(rItem.GetValue());
157  }
158 }
159 
160 void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc )
161 {
162  setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc);
163  setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc);
164  setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc);
165  m_aPreviewWin.Invalidate();
166 }
167 
168 
169 // SvxCharNamePage_Impl --------------------------------------------------
170 
172 {
173  Idle m_aUpdateIdle { "cui SvxCharNamePage_Impl m_aUpdateIdle" };
174  OUString m_aNoStyleText;
175  std::unique_ptr<FontList> m_pFontList;
178 
180  : m_nExtraEntryPos(std::numeric_limits<int>::max())
181  , m_bInSearchMode(false)
182 
183  {
184  m_aUpdateIdle.SetPriority( TaskPriority::LOWEST );
185  }
186 };
187 
188 // class SvxCharNamePage -------------------------------------------------
189 
191  : SvxCharBasePage(pPage, pController, "cui/ui/charnamepage.ui", "CharNamePage", rInSet)
193  , m_xEastFrame(m_xBuilder->weld_widget("asian"))
194  , m_xEastFontNameFT(m_xBuilder->weld_label("eastfontnameft"))
195  , m_xEastFontNameLB(m_xBuilder->weld_combo_box("eastfontnamelb"))
196  , m_xEastFontStyleFT(m_xBuilder->weld_label("eaststyleft"))
197  , m_xEastFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("eaststylelb")))
198  , m_xEastFontSizeFT(m_xBuilder->weld_label("eastsizeft"))
199  , m_xEastFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("eastsizelb")))
200  , m_xEastFontLanguageFT(m_xBuilder->weld_label("eastlangft"))
201  , m_xEastFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("eastlanglb")))
202  , m_xEastFontTypeFT(m_xBuilder->weld_label("eastfontinfo"))
203  , m_xEastFontFeaturesButton(m_xBuilder->weld_button("east_features_button"))
204  , m_xCTLFrame(m_xBuilder->weld_widget("ctl"))
205  , m_xCTLFontNameFT(m_xBuilder->weld_label("ctlfontnameft"))
206  , m_xCTLFontNameLB(m_xBuilder->weld_combo_box("ctlfontnamelb"))
207  , m_xCTLFontStyleFT(m_xBuilder->weld_label("ctlstyleft"))
208  , m_xCTLFontStyleLB(new FontStyleBox(m_xBuilder->weld_combo_box("ctlstylelb")))
209  , m_xCTLFontSizeFT(m_xBuilder->weld_label("ctlsizeft"))
210  , m_xCTLFontSizeLB(new FontSizeBox(m_xBuilder->weld_combo_box("ctlsizelb")))
211  , m_xCTLFontLanguageFT(m_xBuilder->weld_label("ctllangft"))
212  , m_xCTLFontLanguageLB(new SvxLanguageBox(m_xBuilder->weld_combo_box("ctllanglb")))
213  , m_xCTLFontTypeFT(m_xBuilder->weld_label("ctlfontinfo"))
214  , m_xCTLFontFeaturesButton(m_xBuilder->weld_button("ctl_features_button"))
215  , m_xVDev(*Application::GetDefaultDevice(), DeviceFormat::DEFAULT, DeviceFormat::DEFAULT)
216 {
217  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
218 #ifdef IOS
219  m_xPreviewWin->hide();
220 #endif
221  m_pImpl->m_aNoStyleText = CuiResId( RID_SVXSTR_CHARNAME_NOSTYLE );
222 
223  SvtCTLOptions aCTLLanguageOptions;
224  bool bShowCJK = SvtCJKOptions::IsCJKFontEnabled();
225  bool bShowCTL = aCTLLanguageOptions.IsCTLFontEnabled();
226  bool bShowNonWestern = bShowCJK || bShowCTL;
227 
228  if (bShowNonWestern)
229  {
230  m_xWestFrame = m_xBuilder->weld_widget("western");
231  m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-cjk");
232  m_xWestFontNameLB = m_xBuilder->weld_combo_box("westfontnamelb-cjk");
233  m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-cjk");
234  m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-cjk");
235 
236  m_xWestFontStyleLB.reset(new FontStyleBox(m_xBuilder->weld_combo_box("weststylelb-cjk")));
237  m_xWestFontSizeLB.reset(new FontSizeBox(m_xBuilder->weld_combo_box("westsizelb-cjk")));
238 
239  m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-cjk");
240  m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-cjk")));
241  m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-cjk");
242 
243  m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-cjk");
244  }
245  else
246  {
247  m_xWestFrame = m_xBuilder->weld_widget("simple");
248  m_xWestFontNameFT = m_xBuilder->weld_label("westfontnameft-nocjk");
249  m_xWestFontStyleFT = m_xBuilder->weld_label("weststyleft-nocjk");
250  m_xWestFontSizeFT = m_xBuilder->weld_label("westsizeft-nocjk");
251 
252  m_xWestFontLanguageFT = m_xBuilder->weld_label("westlangft-nocjk");
253  m_xWestFontLanguageLB.reset(new SvxLanguageBox(m_xBuilder->weld_combo_box("westlanglb-nocjk")));
254  m_xWestFontTypeFT = m_xBuilder->weld_label("westfontinfo-nocjk");
255 
256  m_xWestFontFeaturesButton = m_xBuilder->weld_button("west_features_button-nocjk");
257 
258  std::unique_ptr<weld::EntryTreeView> xWestFontNameLB = m_xBuilder->weld_entry_tree_view("namegrid", "westfontname-nocjk", "westfontnamelb-nocjk");
259  std::unique_ptr<weld::EntryTreeView> xWestFontStyleLB = m_xBuilder->weld_entry_tree_view("stylegrid", "weststyle-nocjk", "weststylelb-nocjk");
260  std::unique_ptr<weld::EntryTreeView> xWestFontSizeLB = m_xBuilder->weld_entry_tree_view("sizegrid", "westsize-nocjk", "westsizelb-nocjk");
261 
262  // 7 lines in the treeview
263  xWestFontNameLB->set_height_request_by_rows(7);
264  xWestFontStyleLB->set_height_request_by_rows(7);
265  xWestFontSizeLB->set_height_request_by_rows(7);
266 
267  m_xWestFontNameLB = std::move(xWestFontNameLB);
268  m_xWestFontStyleLB.reset(new FontStyleBox(std::move(xWestFontStyleLB)));
269  m_xWestFontSizeLB.reset(new FontSizeBox(std::move(xWestFontSizeLB)));
270  }
271 
272  //In MacOSX the standard dialogs name font-name, font-style as
273  //Family, Typeface
274  //In GNOME the standard dialogs name font-name, font-style as
275  //Family, Style
276  //In Windows the standard dialogs name font-name, font-style as
277  //Font, Style
278 #ifdef _WIN32
279  OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FONT));
280 #else
281  OUString sFontFamilyString(CuiResId(RID_SVXSTR_CHARNAME_FAMILY));
282 #endif
283  m_xWestFontNameFT->set_label(sFontFamilyString);
284  m_xEastFontNameFT->set_label(sFontFamilyString);
285  m_xCTLFontNameFT->set_label(sFontFamilyString);
286 
287 #ifdef MACOSX
288  OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_TYPEFACE));
289 #else
290  OUString sFontStyleString(CuiResId(RID_SVXSTR_CHARNAME_STYLE));
291 #endif
292  m_xWestFontStyleFT->set_label(sFontStyleString);
293  m_xEastFontStyleFT->set_label(sFontStyleString);
294  m_xCTLFontStyleFT->set_label(sFontStyleString);
295 
296  m_xWestFrame->show();
297  m_xEastFrame->set_visible(bShowCJK);
298  m_xCTLFrame->set_visible(bShowCTL);
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  Color aSelectedColor;
1577  bool bChanged = m_bNewFontColor;
1578 
1579  if (bChanged)
1580  {
1581  aSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1582 
1583  if (m_xFontTransparencyMtr->get_value_changed_from_saved())
1584  {
1585  double fTransparency
1586  = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100;
1587  aSelectedColor.SetAlpha(255 - static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
1588  }
1589 
1590  if (m_bOrigFontColor)
1591  bChanged = aSelectedColor != m_aOrigFontColor;
1592  if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR)
1593  bChanged = false;
1594  }
1595 
1596  if (bChanged)
1597  rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
1598  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1599  rSet.InvalidateItem(nWhich);
1600 
1601  return bChanged;
1602 }
1603 
1604 IMPL_LINK( SvxCharEffectsPage, SelectListBoxHdl_Impl, weld::ComboBox&, rBox, void )
1605 {
1606  SelectHdl_Impl(&rBox);
1607 }
1608 
1610 {
1611  if (m_xEmphasisLB.get() == pBox)
1612  {
1613  auto nEPos = m_xEmphasisLB->get_active();
1614  bool bEnable = nEPos > 0;
1615  m_xPositionFT->set_sensitive( bEnable );
1616  m_xPositionLB->set_sensitive( bEnable );
1617  }
1618  else if (m_xReliefLB.get() == pBox)
1619  {
1620  bool bEnable = ( pBox->get_active() == 0 );
1621  m_xOutlineBtn->set_sensitive( bEnable );
1622  m_xShadowBtn->set_sensitive( bEnable );
1623  }
1624  else if (m_xPositionLB.get() != pBox)
1625  {
1626  auto nUPos = m_xUnderlineLB->get_active();
1627  bool bUEnable = nUPos > 0;
1628  m_xUnderlineColorFT->set_sensitive(bUEnable);
1629  m_xUnderlineColorLB->set_sensitive(bUEnable);
1630 
1631  auto nOPos = m_xOverlineLB->get_active();
1632  bool bOEnable = nOPos > 0;
1633  m_xOverlineColorFT->set_sensitive(bOEnable);
1634  m_xOverlineColorLB->set_sensitive(bOEnable);
1635 
1636  auto nSPos = m_xStrikeoutLB->get_active();
1637  m_xIndividualWordsBtn->set_sensitive( bUEnable || bOEnable || nSPos > 0);
1638  }
1640 }
1641 
1642 IMPL_LINK(SvxCharEffectsPage, CbClickHdl_Impl, weld::Toggleable&, rToggle, void)
1643 {
1644  m_aIndividualWordsState.ButtonToggled(rToggle);
1645  UpdatePreview_Impl();
1646  UpdatePreview_Impl();
1647 }
1648 
1649 IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox&, rBox, void)
1650 {
1651  if (m_xFontColorLB.get() == &rBox)
1652  m_bNewFontColor = true;
1653  UpdatePreview_Impl();
1654 }
1655 
1656 IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void)
1657 {
1658  m_bNewFontColor = true;
1659 }
1660 
1662 {
1663  if ( _pSet )
1664  FillItemSet( _pSet );
1665  return DeactivateRC::LeavePage;
1666 }
1667 
1668 std::unique_ptr<SfxTabPage> SvxCharEffectsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
1669 {
1670  return std::make_unique<SvxCharEffectsPage>( pPage, pController, *rSet );
1671 }
1672 
1674 {
1675  SvxFont& rFont = GetPreviewFont();
1676  SvxFont& rCJKFont = GetPreviewCJKFont();
1677  SvxFont& rCTLFont = GetPreviewCTLFont();
1678 
1679  bool bEnable = false;
1680 
1681  // Underline
1682  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
1683  rFont.SetUnderline( LINESTYLE_NONE );
1684  rCJKFont.SetUnderline( LINESTYLE_NONE );
1685  rCTLFont.SetUnderline( LINESTYLE_NONE );
1686 
1687  m_xUnderlineLB->set_active( 0 );
1688  SfxItemState eState = rSet->GetItemState( nWhich );
1689 
1690  if ( eState >= SfxItemState::DONTCARE )
1691  {
1692  if ( eState == SfxItemState::DONTCARE )
1693  m_xUnderlineLB->set_active(-1);
1694  else
1695  {
1696  const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>(rSet->Get( nWhich ));
1697  FontLineStyle eUnderline = rItem.GetValue();
1698  rFont.SetUnderline( eUnderline );
1699  rCJKFont.SetUnderline( eUnderline );
1700  rCTLFont.SetUnderline( eUnderline );
1701 
1702  if ( eUnderline != LINESTYLE_NONE )
1703  {
1704  auto nPos = m_xUnderlineLB->find_id(OUString::number(eUnderline));
1705  if (nPos != -1)
1706  {
1707  m_xUnderlineLB->set_active(nPos);
1708  bEnable = true;
1709  }
1710  Color aColor = rItem.GetColor();
1711  m_xUnderlineColorLB->SelectEntry(aColor);
1712  }
1713  else
1714  {
1715  m_xUnderlineColorLB->SelectEntry(COL_AUTO);
1716  m_xUnderlineColorLB->set_sensitive(false);
1717  }
1718  }
1719  }
1720 
1721  // Overline
1722  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
1723  rFont.SetOverline( LINESTYLE_NONE );
1724  rCJKFont.SetOverline( LINESTYLE_NONE );
1725  rCTLFont.SetOverline( LINESTYLE_NONE );
1726 
1727  m_xOverlineLB->set_active( 0 );
1728  eState = rSet->GetItemState( nWhich );
1729 
1730  if ( eState >= SfxItemState::DONTCARE )
1731  {
1732  if ( eState == SfxItemState::DONTCARE )
1733  m_xOverlineLB->set_active(-1);
1734  else
1735  {
1736  const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>(rSet->Get( nWhich ));
1737  FontLineStyle eOverline = rItem.GetValue();
1738  rFont.SetOverline( eOverline );
1739  rCJKFont.SetOverline( eOverline );
1740  rCTLFont.SetOverline( eOverline );
1741 
1742  if ( eOverline != LINESTYLE_NONE )
1743  {
1744  auto nPos = m_xOverlineLB->find_id(OUString::number(eOverline));
1745  if (nPos != -1)
1746  {
1747  m_xOverlineLB->set_active(nPos);
1748  bEnable = true;
1749  }
1750  Color aColor = rItem.GetColor();
1751  m_xOverlineColorLB->SelectEntry(aColor);
1752  }
1753  else
1754  {
1755  m_xOverlineColorLB->SelectEntry(COL_AUTO);
1756  m_xOverlineColorLB->set_sensitive(false);
1757  }
1758  }
1759  }
1760 
1761  // Strikeout
1762  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
1763  rFont.SetStrikeout( STRIKEOUT_NONE );
1764  rCJKFont.SetStrikeout( STRIKEOUT_NONE );
1765  rCTLFont.SetStrikeout( STRIKEOUT_NONE );
1766 
1767  m_xStrikeoutLB->set_active( 0 );
1768  eState = rSet->GetItemState( nWhich );
1769 
1770  if ( eState >= SfxItemState::DONTCARE )
1771  {
1772  if ( eState == SfxItemState::DONTCARE )
1773  m_xStrikeoutLB->set_active(-1);
1774  else
1775  {
1776  const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>(rSet->Get( nWhich ));
1777  FontStrikeout eStrikeout = rItem.GetValue();
1778  rFont.SetStrikeout( eStrikeout );
1779  rCJKFont.SetStrikeout( eStrikeout );
1780  rCTLFont.SetStrikeout( eStrikeout );
1781 
1782  if ( eStrikeout != STRIKEOUT_NONE )
1783  {
1784  auto nPos = m_xStrikeoutLB->find_id(OUString::number(eStrikeout));
1785  if (nPos != -1)
1786  {
1787  m_xStrikeoutLB->set_active(nPos);
1788  bEnable = true;
1789  }
1790  }
1791  }
1792  }
1793 
1794  // WordLineMode
1795  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
1796  eState = rSet->GetItemState( nWhich );
1797 
1798  switch ( eState )
1799  {
1800  case SfxItemState::UNKNOWN:
1802  m_xIndividualWordsBtn->hide();
1803  break;
1804 
1805  case SfxItemState::DISABLED:
1807  m_xIndividualWordsBtn->set_sensitive(false);
1808  break;
1809 
1810  case SfxItemState::DONTCARE:
1812  m_xIndividualWordsBtn->set_state( TRISTATE_INDET );
1813  break;
1814 
1815  case SfxItemState::DEFAULT:
1816  case SfxItemState::SET:
1817  {
1818  const SvxWordLineModeItem& rItem = static_cast<const SvxWordLineModeItem&>(rSet->Get( nWhich ));
1819  rFont.SetWordLineMode( rItem.GetValue() );
1820  rCJKFont.SetWordLineMode( rItem.GetValue() );
1821  rCTLFont.SetWordLineMode( rItem.GetValue() );
1822 
1824  m_xIndividualWordsBtn->set_active(rItem.GetValue());
1825  m_xIndividualWordsBtn->set_sensitive(bEnable);
1826  break;
1827  }
1828  }
1829 
1830  // Emphasis
1831  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
1832  eState = rSet->GetItemState( nWhich );
1833 
1834  if ( eState >= SfxItemState::DEFAULT )
1835  {
1836  const SvxEmphasisMarkItem& rItem = static_cast<const SvxEmphasisMarkItem&>(rSet->Get( nWhich ));
1837  FontEmphasisMark eMark = rItem.GetEmphasisMark();
1838  rFont.SetEmphasisMark( eMark );
1839  rCJKFont.SetEmphasisMark( eMark );
1840  rCTLFont.SetEmphasisMark( eMark );
1841 
1842  m_xEmphasisLB->set_active( static_cast<sal_Int32>(FontEmphasisMark( eMark & FontEmphasisMark::Style )) );
1843  eMark &= ~FontEmphasisMark::Style;
1844  int nEntryData = ( eMark == FontEmphasisMark::PosAbove )
1846  : ( eMark == FontEmphasisMark::PosBelow ) ? CHRDLG_POSITION_UNDER : 0;
1847 
1848  auto nPos = m_xPositionLB->find_id(OUString::number(nEntryData));
1849  if (nPos != -1)
1850  m_xPositionLB->set_active(nPos);
1851  }
1852  else if ( eState == SfxItemState::DONTCARE )
1853  m_xEmphasisLB->set_active(-1);
1854  else if ( eState == SfxItemState::UNKNOWN )
1855  {
1856  m_xEmphasisFT->hide();
1857  m_xEmphasisLB->hide();
1858  }
1859  else // SfxItemState::DISABLED
1860  {
1861  m_xEmphasisFT->set_sensitive(false);
1862  m_xEmphasisLB->set_sensitive(false);
1863  }
1864 
1865  // the select handler for the underline/overline/strikeout list boxes
1867 
1868  // the select handler for the emphasis listbox
1870 
1871  // Effects
1872  SvxCaseMap eCaseMap = SvxCaseMap::End;
1873  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
1874  eState = rSet->GetItemState( nWhich );
1875  switch ( eState )
1876  {
1877  case SfxItemState::UNKNOWN:
1878  m_xEffectsFT->hide();
1879  m_xEffectsLB->hide();
1880  break;
1881 
1882  case SfxItemState::DISABLED:
1883  m_xEffectsFT->set_sensitive(false);
1884  m_xEffectsLB->set_sensitive(false);
1885  break;
1886 
1887  case SfxItemState::DONTCARE:
1888  m_xEffectsLB->set_active(-1);
1889  break;
1890 
1891  case SfxItemState::DEFAULT:
1892  case SfxItemState::SET:
1893  {
1894  const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>(rSet->Get( nWhich ));
1895  eCaseMap = rItem.GetValue();
1896  break;
1897  }
1898  }
1899  SetCaseMap_Impl( eCaseMap );
1900 
1901  //Relief
1902  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
1903  eState = rSet->GetItemState( nWhich );
1904  switch ( eState )
1905  {
1906  case SfxItemState::UNKNOWN:
1907  m_xReliefFT->hide();
1908  m_xReliefLB->hide();
1909  break;
1910 
1911  case SfxItemState::DISABLED:
1912  m_xReliefFT->set_sensitive(false);
1913  m_xReliefLB->set_sensitive(false);
1914  break;
1915 
1916  case SfxItemState::DONTCARE:
1917  m_xReliefLB->set_active(-1);
1918  break;
1919 
1920  case SfxItemState::DEFAULT:
1921  case SfxItemState::SET:
1922  {
1923  const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>(rSet->Get( nWhich ));
1924  m_xReliefLB->set_active(static_cast<sal_Int32>(rItem.GetValue()));
1925  SelectHdl_Impl(m_xReliefLB.get());
1926  break;
1927  }
1928  }
1929 
1930  // Outline
1931  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
1932  eState = rSet->GetItemState( nWhich );
1933  switch ( eState )
1934  {
1935  case SfxItemState::UNKNOWN:
1937  m_xOutlineBtn->hide();
1938  break;
1939 
1940  case SfxItemState::DISABLED:
1942  m_xOutlineBtn->set_sensitive(false);
1943  break;
1944 
1945  case SfxItemState::DONTCARE:
1947  m_xOutlineBtn->set_state(TRISTATE_INDET);
1948  break;
1949 
1950  case SfxItemState::DEFAULT:
1951  case SfxItemState::SET:
1952  {
1953  const SvxContourItem& rItem = static_cast<const SvxContourItem&>(rSet->Get( nWhich ));
1955  m_xOutlineBtn->set_state(static_cast<TriState>(rItem.GetValue()));
1956  break;
1957  }
1958  }
1959 
1960  // Shadow
1961  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
1962  eState = rSet->GetItemState( nWhich );
1963 
1964  switch ( eState )
1965  {
1966  case SfxItemState::UNKNOWN:
1968  m_xShadowBtn->hide();
1969  break;
1970 
1971  case SfxItemState::DISABLED:
1973  m_xShadowBtn->set_sensitive(false);
1974  break;
1975 
1976  case SfxItemState::DONTCARE:
1978  m_xShadowBtn->set_state( TRISTATE_INDET );
1979  break;
1980 
1981  case SfxItemState::DEFAULT:
1982  case SfxItemState::SET:
1983  {
1984  const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>(rSet->Get( nWhich ));
1986  m_xShadowBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
1987  break;
1988  }
1989  }
1990 
1991  // Hidden
1992  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
1993  eState = rSet->GetItemState( nWhich );
1994 
1995  switch ( eState )
1996  {
1997  case SfxItemState::UNKNOWN:
1999  m_xHiddenBtn->hide();
2000  break;
2001 
2002  case SfxItemState::DISABLED:
2004  m_xHiddenBtn->set_sensitive(false);
2005  break;
2006 
2007  case SfxItemState::DONTCARE:
2009  m_xHiddenBtn->set_state(TRISTATE_INDET);
2010  break;
2011 
2012  case SfxItemState::DEFAULT:
2013  case SfxItemState::SET:
2014  {
2015  const SvxCharHiddenItem& rItem = static_cast<const SvxCharHiddenItem&>(rSet->Get( nWhich ));
2017  m_xHiddenBtn->set_state(static_cast<TriState>(rItem.GetValue()));
2018  break;
2019  }
2020  }
2021 
2022  SetPrevFontWidthScale( *rSet );
2023  ResetColor_Impl( *rSet );
2024 
2025  // preview update
2026  m_aPreviewWin.Invalidate();
2027 
2028  // save this settings
2029  ChangesApplied();
2030 }
2031 
2032 IMPL_LINK(SvxCharEffectsPage, HiddenBtnClickHdl, weld::Toggleable&, rToggle, void)
2033 {
2034  m_aHiddenState.ButtonToggled(rToggle);
2035 }
2036 
2037 IMPL_LINK(SvxCharEffectsPage, OutlineBtnClickHdl, weld::Toggleable&, rToggle, void)
2038 {
2039  m_aOutlineState.ButtonToggled(rToggle);
2040  UpdatePreview_Impl();
2041 }
2042 
2043 IMPL_LINK(SvxCharEffectsPage, ShadowBtnClickHdl, weld::Toggleable&, rToggle, void)
2044 {
2045  m_aShadowState.ButtonToggled(rToggle);
2046  UpdatePreview_Impl();
2047 }
2048 
2050 {
2051  m_xUnderlineLB->save_value();
2052  m_xOverlineLB->save_value();
2053  m_xStrikeoutLB->save_value();
2054  m_xIndividualWordsBtn->save_state();
2055  m_xEmphasisLB->save_value();
2056  m_xPositionLB->save_value();
2057  m_xEffectsLB->save_value();
2058  m_xReliefLB->save_value();
2059  m_xOutlineBtn->save_state();
2060  m_xShadowBtn->save_state();
2061  m_xHiddenBtn->save_state();
2062  m_xFontTransparencyMtr->save_value();
2063 }
2064 
2066 {
2067  const SfxPoolItem* pOld = nullptr;
2068  const SfxItemSet& rOldSet = GetItemSet();
2069  bool bModified = false;
2070  bool bChanged = true;
2071 
2072  // Underline
2073  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2074  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_UNDERLINE );
2075  auto nPos = m_xUnderlineLB->get_active();
2076  FontLineStyle eUnder = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
2077 
2078  if ( pOld )
2079  {
2084  bool bAllowChg = nPos != -1 &&
2085  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2086 
2087  const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld);
2088  if ( rItem.GetValue() == eUnder &&
2089  ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) &&
2090  ! bAllowChg )
2091  bChanged = false;
2092  }
2093 
2094  if ( bChanged )
2095  {
2096  SvxUnderlineItem aNewItem( eUnder, nWhich );
2097  aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() );
2098  rSet->Put( aNewItem );
2099  bModified = true;
2100  }
2101  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2102  rSet->InvalidateItem(nWhich);
2103 
2104  bChanged = true;
2105 
2106  // Overline
2107  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2108  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_OVERLINE );
2109  nPos = m_xOverlineLB->get_active();
2110  FontLineStyle eOver = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
2111 
2112  if ( pOld )
2113  {
2118  bool bAllowChg = nPos != -1 &&
2119  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2120 
2121  const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld);
2122  if ( rItem.GetValue() == eOver &&
2123  ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) &&
2124  ! bAllowChg )
2125  bChanged = false;
2126  }
2127 
2128  if ( bChanged )
2129  {
2130  SvxOverlineItem aNewItem( eOver, nWhich );
2131  aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() );
2132  rSet->Put( aNewItem );
2133  bModified = true;
2134  }
2135  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2136  rSet->InvalidateItem(nWhich);
2137 
2138  bChanged = true;
2139 
2140  // Strikeout
2141  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2142  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_STRIKEOUT );
2143  nPos = m_xStrikeoutLB->get_active();
2144  FontStrikeout eStrike = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
2145 
2146  if ( pOld )
2147  {
2152  bool bAllowChg = nPos != -1 &&
2153  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2154 
2155  const SvxCrossedOutItem& rItem = *static_cast<const SvxCrossedOutItem*>(pOld);
2156  if ( !m_xStrikeoutLB->get_sensitive()
2157  || (rItem.GetValue() == eStrike && !bAllowChg) )
2158  bChanged = false;
2159  }
2160 
2161  if ( bChanged )
2162  {
2163  rSet->Put( SvxCrossedOutItem( eStrike, nWhich ) );
2164  bModified = true;
2165  }
2166  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2167  rSet->InvalidateItem(nWhich);
2168 
2169  bChanged = true;
2170 
2171  // Individual words
2172  const SfxItemSet* pExampleSet = GetDialogExampleSet();
2173  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2174  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_WORDLINEMODE );
2175  TriState eState = m_xIndividualWordsBtn->get_state();
2176  const SfxPoolItem* pItem;
2177 
2178  if ( pOld )
2179  {
2180  const SvxWordLineModeItem& rItem = *static_cast<const SvxWordLineModeItem*>(pOld);
2181  if ( rItem.GetValue() == StateToAttr( eState ) && m_xIndividualWordsBtn->get_saved_state() == eState )
2182  bChanged = false;
2183  }
2184 
2185  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2186  !StateToAttr( eState ) && static_cast<const SvxWordLineModeItem*>(pItem)->GetValue() )
2187  bChanged = true;
2188 
2189  if ( bChanged && eState != TRISTATE_INDET )
2190  {
2191  rSet->Put( SvxWordLineModeItem( StateToAttr( eState ), nWhich ) );
2192  bModified = true;
2193  }
2194  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2195  rSet->InvalidateItem(nWhich);
2196 
2197  bChanged = true;
2198 
2199  // Emphasis
2200  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2201  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_EMPHASISMARK );
2202  int nMarkPos = m_xEmphasisLB->get_active();
2203  OUString sMarkPos = m_xEmphasisLB->get_active_text();
2204  OUString sPosPos = m_xPositionLB->get_active_text();
2205  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nMarkPos);
2206  if (m_xPositionLB->get_sensitive())
2207  {
2208  eMark |= (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32())
2209  ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
2210  }
2211 
2212  if ( pOld )
2213  {
2214  if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE )
2215  {
2216  const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld);
2217  if ( rItem.GetEmphasisMark() == eMark )
2218  bChanged = false;
2219  }
2220  }
2221 
2222  if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
2223  m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos)
2224  {
2225  bChanged = false;
2226  }
2227 
2228  if (bChanged)
2229  {
2230  rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2231  bModified = true;
2232  }
2233  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2234  rSet->InvalidateItem(nWhich);
2235 
2236  bChanged = true;
2237 
2238  // Effects
2239  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2240  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CASEMAP );
2241  SvxCaseMap eCaseMap = SvxCaseMap::NotMapped;
2242  bool bChecked = false;
2243  auto nCapsPos = m_xEffectsLB->get_active();
2244  if (nCapsPos != -1)
2245  {
2246  eCaseMap = static_cast<SvxCaseMap>(nCapsPos);
2247  bChecked = true;
2248  }
2249 
2250  if ( pOld )
2251  {
2256  bool bAllowChg = nPos != -1 &&
2257  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2258 
2259  const SvxCaseMapItem& rItem = *static_cast<const SvxCaseMapItem*>(pOld);
2260  if ( rItem.GetValue() == eCaseMap && !bAllowChg )
2261  bChanged = false;
2262  }
2263 
2264  if ( bChanged && bChecked )
2265  {
2266  rSet->Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2267  bModified = true;
2268  }
2269  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2270  rSet->InvalidateItem(nWhich);
2271 
2272  bChanged = true;
2273 
2274  //Relief
2275  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2276  if (m_xReliefLB->get_value_changed_from_saved())
2277  {
2278  m_xReliefLB->save_value();
2279  SvxCharReliefItem aRelief(static_cast<FontRelief>(m_xReliefLB->get_active()), nWhich);
2280  rSet->Put(aRelief);
2281  }
2282 
2283  // Outline
2284  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2285  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CONTOUR );
2286  eState = m_xOutlineBtn->get_state();
2287 
2288  if ( pOld )
2289  {
2290  const SvxContourItem& rItem = *static_cast<const SvxContourItem*>(pOld);
2291  if ( rItem.GetValue() == StateToAttr( eState ) && m_xOutlineBtn->get_saved_state() == eState )
2292  bChanged = false;
2293  }
2294 
2295  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2296  !StateToAttr( eState ) && static_cast<const SvxContourItem*>(pItem)->GetValue() )
2297  bChanged = true;
2298 
2299  if ( bChanged && eState != TRISTATE_INDET )
2300  {
2301  rSet->Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2302  bModified = true;
2303  }
2304  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2305  rSet->InvalidateItem(nWhich);
2306 
2307  bChanged = true;
2308 
2309  // Shadow
2310  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2311  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_SHADOWED );
2312  eState = m_xShadowBtn->get_state();
2313 
2314  if ( pOld )
2315  {
2316  const SvxShadowedItem& rItem = *static_cast<const SvxShadowedItem*>(pOld);
2317  if ( rItem.GetValue() == StateToAttr( eState ) && m_xShadowBtn->get_saved_state() == eState )
2318  bChanged = false;
2319  }
2320 
2321  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2322  !StateToAttr( eState ) && static_cast<const SvxShadowedItem*>(pItem)->GetValue() )
2323  bChanged = true;
2324 
2325  if ( bChanged && eState != TRISTATE_INDET )
2326  {
2327  rSet->Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2328  bModified = true;
2329  }
2330  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2331  rSet->InvalidateItem(nWhich);
2332 
2333  bChanged = true;
2334 
2335  // Hidden
2336  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2337  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_HIDDEN );
2338  eState = m_xHiddenBtn->get_state();
2339  bChanged = true;
2340 
2341  if ( pOld )
2342  {
2343  const SvxCharHiddenItem& rItem = *static_cast<const SvxCharHiddenItem*>(pOld);
2344  if ( rItem.GetValue() == StateToAttr( eState ) && m_xHiddenBtn->get_saved_state() == eState )
2345  bChanged = false;
2346  }
2347 
2348  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2349  !StateToAttr( eState ) && static_cast<const SvxCharHiddenItem*>(pItem)->GetValue() )
2350  bChanged = true;
2351 
2352  if ( bChanged && eState != TRISTATE_INDET )
2353  {
2354  rSet->Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2355  bModified = true;
2356  }
2357  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2358  rSet->InvalidateItem(nWhich);
2359 
2360  bModified |= FillItemSetColor_Impl( *rSet );
2361 
2362  return bModified;
2363 }
2364 
2365 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2366 {
2367  if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2368  {
2369  m_xEffectsFT->set_sensitive(false);
2370  m_xEffectsLB->set_sensitive(false);
2371  }
2372 }
2373 
2375 {
2376  const SfxUInt16Item* pDisableCtlItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
2377  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
2378  if (pDisableCtlItem)
2379  DisableControls(pDisableCtlItem->GetValue());
2380 
2381  if (!pFlagItem)
2382  return;
2383 
2384  sal_uInt32 nFlags=pFlagItem->GetValue();
2385  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2386  // the writer uses SID_ATTR_BRUSH as font background
2388  if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY)
2389  {
2390  // Only show these in case client code explicitly wants this.
2391  m_xFontTransparencyFT->hide();
2392  m_xFontTransparencyMtr->hide();
2393  }
2394 }
2395 
2396 // class SvxCharPositionPage ---------------------------------------------
2397 
2399  : SvxCharBasePage(pPage, pController, "cui/ui/positionpage.ui", "PositionPage", rInSet)
2400  , m_nSuperEsc(short(DFLT_ESC_SUPER))
2401  , m_nSubEsc(short(DFLT_ESC_SUB))
2402  , m_nScaleWidthItemSetVal(100)
2403  , m_nScaleWidthInitialVal(100)
2404  , m_nSuperProp(sal_uInt8(DFLT_ESC_PROP))
2405  , m_nSubProp(sal_uInt8(DFLT_ESC_PROP))
2406  , m_xHighPosBtn(m_xBuilder->weld_radio_button("superscript"))
2407  , m_xNormalPosBtn(m_xBuilder->weld_radio_button("normal"))
2408  , m_xLowPosBtn(m_xBuilder->weld_radio_button("subscript"))
2409  , m_xHighLowFT(m_xBuilder->weld_label("raiselower"))
2410  , m_xHighLowMF(m_xBuilder->weld_metric_spin_button("raiselowersb", FieldUnit::PERCENT))
2411  , m_xHighLowRB(m_xBuilder->weld_check_button("automatic"))
2412  , m_xFontSizeFT(m_xBuilder->weld_label("relativefontsize"))
2413  , m_xFontSizeMF(m_xBuilder->weld_metric_spin_button("fontsizesb", FieldUnit::PERCENT))
2414  , m_xRotationContainer(m_xBuilder->weld_widget("rotationcontainer"))
2415  , m_xScalingFT(m_xBuilder->weld_label("scale"))
2416  , m_xScalingAndRotationFT(m_xBuilder->weld_label("rotateandscale"))
2417  , m_x0degRB(m_xBuilder->weld_radio_button("0deg"))
2418  , m_x90degRB(m_xBuilder->weld_radio_button("90deg"))
2419  , m_x270degRB(m_xBuilder->weld_radio_button("270deg"))
2420  , m_xFitToLineCB(m_xBuilder->weld_check_button("fittoline"))
2421  , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT))
2422  , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT))
2423  , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning"))
2424 {
2425  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
2426 #ifdef IOS
2427  m_xPreviewWin->hide();
2428 #endif
2429  Initialize();
2430 }
2431 
2433 {
2434 }
2435 
2436 
2438 {
2439  // to handle the changes of the other pages
2441 
2442  GetPreviewFont().SetFontSize( Size( 0, 240 ) );
2443  GetPreviewCJKFont().SetFontSize( Size( 0, 240 ) );
2444  GetPreviewCTLFont().SetFontSize( Size( 0, 240 ) );
2445 
2446  m_xNormalPosBtn->set_active(true);
2447  PositionHdl_Impl(*m_xNormalPosBtn);
2448 
2449  Link<weld::Toggleable&,void> aLink2 = LINK(this, SvxCharPositionPage, PositionHdl_Impl);
2450  m_xHighPosBtn->connect_toggled(aLink2);
2451  m_xNormalPosBtn->connect_toggled(aLink2);
2452  m_xLowPosBtn->connect_toggled(aLink2);
2453 
2454  aLink2 = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
2455  m_x0degRB->connect_toggled(aLink2);
2456  m_x90degRB->connect_toggled(aLink2);
2457  m_x270degRB->connect_toggled(aLink2);
2458 
2459  Link<weld::MetricSpinButton&,void> aLink3 = LINK(this, SvxCharPositionPage, ValueChangedHdl_Impl);
2460  m_xHighLowMF->connect_value_changed(aLink3);
2461  m_xFontSizeMF->connect_value_changed(aLink3);
2462 
2463  m_xHighLowRB->connect_toggled(LINK(this, SvxCharPositionPage, AutoPositionHdl_Impl));
2464  m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl));
2465  m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl));
2466  m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl));
2467 }
2468 
2470 {
2471  SetPrevFontEscapement( nProp, nEscProp, nEsc );
2472 }
2473 
2474 
2476 {
2477  SvxEscapementItem aEscItm( nEsc, SID_ATTR_CHAR_ESCAPEMENT );
2478 
2479  if ( SvxEscapement::Superscript == nEsc )
2480  {
2481  aEscItm.GetEsc() = m_nSuperEsc;
2482  aEscItm.GetProportionalHeight() = m_nSuperProp;
2483  }
2484  else if ( SvxEscapement::Subscript == nEsc )
2485  {
2486  aEscItm.GetEsc() = m_nSubEsc;
2487  aEscItm.GetProportionalHeight() = m_nSubProp;
2488  }
2489 
2490  short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
2491 
2492  m_xHighLowMF->set_value(aEscItm.GetEsc() * nFac, FieldUnit::PERCENT);
2493  m_xFontSizeMF->set_value(aEscItm.GetProportionalHeight(), FieldUnit::PERCENT);
2494 
2495  if ( SvxEscapement::Off == nEsc )
2496  {
2497  m_xHighLowFT->set_sensitive(false);
2498  m_xHighLowMF->set_sensitive(false);
2499  m_xFontSizeFT->set_sensitive(false);
2500  m_xFontSizeMF->set_sensitive(false);
2501  m_xHighLowRB->set_sensitive(false);
2502  }
2503  else
2504  {
2505  m_xFontSizeFT->set_sensitive(true);
2506  m_xFontSizeMF->set_sensitive(true);
2507  m_xHighLowRB->set_sensitive(true);
2508 
2509  if (!m_xHighLowRB->get_active())
2510  {
2511  m_xHighLowFT->set_sensitive(true);
2512  m_xHighLowMF->set_sensitive(true);
2513  }
2514  else
2515  AutoPositionHdl_Impl(*m_xHighLowRB);
2516  }
2517 
2518  UpdatePreview_Impl( 100, aEscItm.GetProportionalHeight(), aEscItm.GetEsc() );
2519 }
2520 
2521 
2523 {
2524  SvxEscapement nEsc = SvxEscapement::Off; // also when pBtn == NULL
2525 
2526  if (m_xHighPosBtn->get_active())
2527  nEsc = SvxEscapement::Superscript;
2528  else if (m_xLowPosBtn->get_active())
2529  nEsc = SvxEscapement::Subscript;
2530 
2531  SetEscapement_Impl( nEsc );
2532 }
2533 
2535 {
2536  bool bEnable = false;
2537  if (m_x90degRB->get_active() || m_x270degRB->get_active())
2538  bEnable = true;
2539  else
2540  OSL_ENSURE(m_x0degRB->get_active(), "unexpected button");
2541  m_xFitToLineCB->set_sensitive(bEnable);
2542 }
2543 
2545 {
2546  sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2547  short nEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2548  nEsc *= m_xLowPosBtn->get_active() ? -1 : 1;
2549  UpdatePreview_Impl( 100, nEscProp, nEsc );
2550 }
2551 
2552 IMPL_LINK(SvxCharPositionPage, AutoPositionHdl_Impl, weld::Toggleable&, rBox, void)
2553 {
2554  if (rBox.get_active())
2555  {
2556  m_xHighLowFT->set_sensitive(false);
2557  m_xHighLowMF->set_sensitive(false);
2558  }
2559  else
2560  PositionHdl_Impl(m_xHighPosBtn->get_active() ? *m_xHighPosBtn
2561  : m_xLowPosBtn->get_active() ? *m_xLowPosBtn
2562  : *m_xNormalPosBtn);
2563 }
2564 
2566 {
2567  sal_uInt16 nVal = m_nScaleWidthInitialVal;
2568  if (m_xFitToLineCB->get_active())
2569  nVal = m_nScaleWidthItemSetVal;
2570  m_xScaleWidthMF->set_value(nVal, FieldUnit::PERCENT);
2571  m_aPreviewWin.SetFontWidthScale( nVal );
2572 }
2573 
2575 {
2576  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2578 
2579  tools::Long nKern = static_cast<short>(m_xKerningMF->denormalize(nVal));
2580 
2581  SvxFont& rFont = GetPreviewFont();
2582  SvxFont& rCJKFont = GetPreviewCJKFont();
2583  SvxFont& rCTLFont = GetPreviewCTLFont();
2584 
2585  rFont.SetFixKerning( static_cast<short>(nKern) );
2586  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2587  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2588  m_aPreviewWin.Invalidate();
2589 }
2590 
2591 IMPL_LINK(SvxCharPositionPage, ValueChangedHdl_Impl, weld::MetricSpinButton&, rField, void)
2592 {
2593  bool bHigh = m_xHighPosBtn->get_active();
2594  bool bLow = m_xLowPosBtn->get_active();
2595  DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
2596 
2597  if (m_xHighLowMF.get() == &rField)
2598  {
2599  if ( bLow )
2600  m_nSubEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT)) * -1;
2601  else
2602  m_nSuperEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2603  }
2604  else if (m_xFontSizeMF.get() == &rField)
2605  {
2606  if ( bLow )
2607  m_nSubProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2608  else
2609  m_nSuperProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2610  }
2611 
2612  FontModifyHdl_Impl();
2613 }
2614 
2616 {
2617  m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)));
2618 }
2619 
2621 {
2622  if ( _pSet )
2623  FillItemSet( _pSet );
2624  return DeactivateRC::LeavePage;
2625 }
2626 
2627 std::unique_ptr<SfxTabPage> SvxCharPositionPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2628 {
2629  return std::make_unique<SvxCharPositionPage>(pPage, pController, *rSet);
2630 }
2631 
2633 {
2634  OUString sUser = GetUserData();
2635 
2636  if ( !sUser.isEmpty() )
2637  {
2638  sal_Int32 nIdx {0};
2639  m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2640  m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2641  m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2642  m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2643 
2644  m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT);
2645 
2646  //fdo#75307 validate all the entries and discard all of them if any are
2647  //out of range
2648  bool bValid = true;
2649  if (m_nSuperEsc < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSuperEsc > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2650  bValid = false;
2651  if (m_nSubEsc*-1 < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSubEsc*-1 > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2652  bValid = false;
2653  if (m_nSuperProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSuperProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2654  bValid = false;
2655  if (m_nSubProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSubProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2656  bValid = false;
2657 
2658  if (!bValid)
2659  {
2664  }
2665  }
2666 
2667  short nEsc = 0;
2668  sal_uInt8 nEscProp = 100;
2669 
2670  m_xHighLowFT->set_sensitive(false);
2671  m_xHighLowMF->set_sensitive(false);
2672  m_xFontSizeFT->set_sensitive(false);
2673  m_xFontSizeMF->set_sensitive(false);
2674 
2675  SvxFont& rFont = GetPreviewFont();
2676  SvxFont& rCJKFont = GetPreviewCJKFont();
2677  SvxFont& rCTLFont = GetPreviewCTLFont();
2678  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2679 
2680  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2681  {
2682  const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>(rSet->Get( nWhich ));
2683  nEsc = rItem.GetEsc();
2684  nEscProp = rItem.GetProportionalHeight();
2685 
2686  if ( nEsc != 0 )
2687  {
2688  m_xHighLowFT->set_sensitive(true);
2689  m_xHighLowMF->set_sensitive(true);
2690  m_xFontSizeFT->set_sensitive(true);
2691  m_xFontSizeMF->set_sensitive(true);
2692 
2693  short nFac;
2694  bool bAutomatic(false);
2695 
2696  if ( nEsc > 0 )
2697  {
2698  nFac = 1;
2699  m_xHighPosBtn->set_active(true);
2700  if ( nEsc == DFLT_ESC_AUTO_SUPER )
2701  {
2702  nEsc = .8 * (100 - nEscProp); //approximation of actual percentage used
2703  bAutomatic = true;
2704  }
2705  }
2706  else
2707  {
2708  nFac = -1;
2709  m_xLowPosBtn->set_active(true);
2710  if ( nEsc == DFLT_ESC_AUTO_SUB )
2711  {
2712  nEsc = .2 * -(100 - nEscProp); //approximation of actual percentage used
2713  bAutomatic = true;
2714  }
2715  }
2716  if (!m_xHighLowRB->get_sensitive())
2717  {
2718  m_xHighLowRB->set_sensitive(true);
2719  }
2720  m_xHighLowRB->set_active(bAutomatic);
2721 
2722  if (m_xHighLowRB->get_active())
2723  {
2724  m_xHighLowFT->set_sensitive(false);
2725  m_xHighLowMF->set_sensitive(false);
2726  }
2727  m_xHighLowMF->set_value(m_xHighLowMF->normalize(nFac * nEsc), FieldUnit::PERCENT);
2728  }
2729  else
2730  {
2731  m_xNormalPosBtn->set_active(true);
2732  m_xHighLowRB->set_active(true);
2733  PositionHdl_Impl(*m_xNormalPosBtn);
2734  }
2735  //the height has to be set after the handler is called to keep the value also if the escapement is zero
2736  m_xFontSizeMF->set_value(m_xFontSizeMF->normalize(nEscProp), FieldUnit::PERCENT);
2737  }
2738  else
2739  {
2740  m_xHighPosBtn->set_active(false);
2741  m_xNormalPosBtn->set_active(false);
2742  m_xLowPosBtn->set_active(false);
2743  }
2744 
2745  // set BspFont
2746  SetPrevFontEscapement( 100, nEscProp, nEsc );
2747 
2748  // Kerning
2749  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2750 
2751  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2752  {
2753  const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>(rSet->Get( nWhich ));
2754  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2755  tools::Long nBig = static_cast<tools::Long>(m_xKerningMF->normalize( static_cast<tools::Long>(rItem.GetValue()) ));
2756  tools::Long nKerning = OutputDevice::LogicToLogic(nBig, eUnit, MapUnit::MapPoint);
2757 
2758  // set Kerning at the Font, convert into Twips before
2759  tools::Long nKern = OutputDevice::LogicToLogic(rItem.GetValue(), eUnit, MapUnit::MapTwip);
2760  rFont.SetFixKerning( static_cast<short>(nKern) );
2761  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2762  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2763 
2764  //the attribute value must be displayed also if it's above the maximum allowed value
2765  tools::Long nVal = static_cast<tools::Long>(m_xKerningMF->get_max(FieldUnit::POINT));
2766  if(nVal < nKerning)
2767  m_xKerningMF->set_max(nKerning, FieldUnit::POINT);
2768  m_xKerningMF->set_value(nKerning, FieldUnit::POINT);
2769  }
2770  else
2771  m_xKerningMF->set_text(OUString());
2772 
2773  // Pair kerning
2774  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2775 
2776  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2777  {
2778  const SvxAutoKernItem& rItem = static_cast<const SvxAutoKernItem&>(rSet->Get( nWhich ));
2779  m_xPairKerningBtn->set_active(rItem.GetValue());
2780  }
2781  else
2782  m_xPairKerningBtn->set_active(false);
2783 
2784  // Scale Width
2785  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2786  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2787  {
2788  const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet->Get( nWhich ) );
2789  m_nScaleWidthInitialVal = rItem.GetValue();
2790  m_xScaleWidthMF->set_value(m_nScaleWidthInitialVal, FieldUnit::PERCENT);
2791  }
2792  else
2793  m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT);
2794 
2795  nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
2796  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2797  m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( nWhich )).GetValue();
2798 
2799  // Rotation
2800  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2801  SfxItemState eState = rSet->GetItemState( nWhich );
2802  if( SfxItemState::UNKNOWN == eState )
2803  {
2804  m_xRotationContainer->hide();
2805  m_xScalingAndRotationFT->hide();
2806  m_xScalingFT->show();
2807  }
2808  else
2809  {
2810  m_xRotationContainer->show();
2811  m_xScalingAndRotationFT->show();
2812  m_xScalingFT->hide();
2813 
2814  if( eState >= SfxItemState::DEFAULT )
2815  {
2816  const SvxCharRotateItem& rItem =
2817  static_cast<const SvxCharRotateItem&>( rSet->Get( nWhich ));
2818  if (rItem.IsBottomToTop())
2819  m_x90degRB->set_active(true);
2820  else if (rItem.IsTopToBottom())
2821  m_x270degRB->set_active(true);
2822  else
2823  {
2824  DBG_ASSERT( 0_deg10 == rItem.GetValue(), "incorrect value" );
2825  m_x0degRB->set_active(true);
2826  }
2827  m_xFitToLineCB->set_active(rItem.IsFitToLine());
2828  }
2829  else
2830  {
2831  if( eState == SfxItemState::DONTCARE )
2832  {
2833  m_x0degRB->set_active(false);
2834  m_x90degRB->set_active(false);
2835  m_x270degRB->set_active(false);
2836  }
2837  else
2838  m_x0degRB->set_active(true);
2839 
2840  m_xFitToLineCB->set_active(false);
2841  }
2842  m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active());
2843 
2844  // is this value set?
2845  if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich(
2846  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
2847  m_xFitToLineCB->hide();
2848  }
2849  ChangesApplied();
2850 }
2851 
2853 {
2854  m_xHighPosBtn->save_state();
2855  m_xNormalPosBtn->save_state();
2856  m_xLowPosBtn->save_state();
2857  m_xHighLowRB->save_state();
2858  m_x0degRB->save_state();
2859  m_x90degRB->save_state();
2860  m_x270degRB->save_state();
2861  m_xFitToLineCB->save_state();
2862  m_xScaleWidthMF->save_value();
2863  m_xKerningMF->save_value();
2864  m_xPairKerningBtn->save_state();
2865 }
2866 
2868 {
2869  // Position (high, normal or low)
2870  const SfxItemSet& rOldSet = GetItemSet();
2871  bool bModified = false, bChanged = true;
2872  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2873  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_ESCAPEMENT );
2874  const bool bHigh = m_xHighPosBtn->get_active();
2875  short nEsc;
2876  sal_uInt8 nEscProp;
2877 
2878  if (bHigh || m_xLowPosBtn->get_active())
2879  {
2880  if (m_xHighLowRB->get_active())
2881  nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
2882  else
2883  {
2884  nEsc = static_cast<short>(m_xHighLowMF->denormalize(m_xHighLowMF->get_value(FieldUnit::PERCENT)));
2885  nEsc *= (bHigh ? 1 : -1);
2886  }
2887  nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->denormalize(m_xFontSizeMF->get_value(FieldUnit::PERCENT)));
2888  }
2889  else
2890  {
2891  nEsc = 0;
2892  nEscProp = 100;
2893  }
2894 
2895  if ( pOld )
2896  {
2897  const SvxEscapementItem& rItem = *static_cast<const SvxEscapementItem*>(pOld);
2898  if (rItem.GetEsc() == nEsc && rItem.GetProportionalHeight() == nEscProp)
2899  bChanged = false;
2900  }
2901 
2902  if ( !bChanged && !m_xHighPosBtn->get_saved_state() &&
2903  !m_xNormalPosBtn->get_saved_state() && !m_xLowPosBtn->get_saved_state() )
2904  bChanged = true;
2905 
2906  if ( bChanged &&
2907  ( m_xHighPosBtn->get_active() || m_xNormalPosBtn->get_active() || m_xLowPosBtn->get_active() ) )
2908  {
2909  rSet->Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
2910  bModified = true;
2911  }
2912  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2913  rSet->InvalidateItem(nWhich);
2914 
2915  bChanged = true;
2916 
2917  // Kerning
2918  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2919  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_KERNING );
2920  short nKerning = 0;
2921  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2922 
2923  tools::Long nTmp = static_cast<tools::Long>(m_xKerningMF->get_value(FieldUnit::POINT));
2924  tools::Long nVal = OutputDevice::LogicToLogic(nTmp, MapUnit::MapPoint, eUnit);
2925  nKerning = static_cast<short>(m_xKerningMF->denormalize( nVal ));
2926 
2927  SfxItemState eOldKernState = rOldSet.GetItemState( nWhich, false );
2928  if ( pOld )
2929  {
2930  const SvxKerningItem& rItem = *static_cast<const SvxKerningItem*>(pOld);
2931  if ( (eOldKernState >= SfxItemState::DEFAULT || m_xKerningMF->get_text().isEmpty()) && rItem.GetValue() == nKerning )
2932  bChanged = false;
2933  }
2934 
2935  if ( bChanged )
2936  {
2937  rSet->Put( SvxKerningItem( nKerning, nWhich ) );
2938  bModified = true;
2939  }
2940  else if ( SfxItemState::DEFAULT == eOldKernState )
2941  rSet->InvalidateItem(nWhich);
2942 
2943  // Pair-Kerning
2944  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2945 
2946  if (m_xPairKerningBtn->get_state_changed_from_saved())
2947  {
2948  rSet->Put( SvxAutoKernItem( m_xPairKerningBtn->get_active(), nWhich ) );
2949  bModified = true;
2950  }
2951  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2952  rSet->InvalidateItem(nWhich);
2953 
2954  // Scale Width
2955  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2956  if (m_xScaleWidthMF->get_value_changed_from_saved())
2957  {
2958  rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich));
2959  bModified = true;
2960  }
2961  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2962  rSet->InvalidateItem(nWhich);
2963 
2964  // Rotation
2965  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2966  if ( m_x0degRB->get_state_changed_from_saved() ||
2967  m_x90degRB->get_state_changed_from_saved() ||
2968  m_x270degRB->get_state_changed_from_saved() ||
2969  m_xFitToLineCB->get_state_changed_from_saved() )
2970  {
2971  SvxCharRotateItem aItem( 0_deg10, m_xFitToLineCB->get_active(), nWhich );
2972  if (m_x90degRB->get_active())
2973  aItem.SetBottomToTop();
2974  else if (m_x270degRB->get_active())
2975  aItem.SetTopToBottom();
2976  rSet->Put( aItem );
2977  bModified = true;
2978  }
2979  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2980  rSet->InvalidateItem(nWhich);
2981 
2982  return bModified;
2983 }
2984 
2985 
2987 {
2988  static const OUStringLiteral cTok( u";" );
2989 
2990  OUString sUser = OUString::number( m_nSuperEsc ) + cTok +
2991  OUString::number( m_nSubEsc ) + cTok +
2992  OUString::number( m_nSuperProp ) + cTok +
2993  OUString::number( m_nSubProp );
2994  SetUserData( sUser );
2995 }
2996 
2997 
2999 {
3000  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3001  if (pFlagItem)
3002  {
3003  sal_uInt32 nFlags=pFlagItem->GetValue();
3004  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3005  // the writer uses SID_ATTR_BRUSH as font background
3007  }
3008 }
3009 // class SvxCharTwoLinesPage ------------------------------------------------
3010 
3012  : SvxCharBasePage(pPage, pController, "cui/ui/twolinespage.ui", "TwoLinesPage", rInSet)
3013  , m_nStartBracketPosition( 0 )
3014  , m_nEndBracketPosition( 0 )
3015  , m_xTwoLinesBtn(m_xBuilder->weld_check_button("twolines"))
3016  , m_xEnclosingFrame(m_xBuilder->weld_widget("enclosing"))
3017  , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket"))
3018  , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket"))
3019 {
3020  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_OPEN); ++i)
3021  m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first));
3022  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_CLOSE); ++i)
3023  m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first));
3024 
3025  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
3026 #ifdef IOS
3027  m_xPreviewWin->hide();
3028 #endif
3029  Initialize();
3030 }
3031 
3033 {
3034 }
3035 
3037 {
3038  m_xTwoLinesBtn->set_active(false);
3039  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3040 
3041  m_xTwoLinesBtn->connect_toggled(LINK(this, SvxCharTwoLinesPage, TwoLinesHdl_Impl));
3042 
3043  Link<weld::TreeView&,void> aLink = LINK(this, SvxCharTwoLinesPage, CharacterMapHdl_Impl);
3044  m_xStartBracketLB->connect_changed(aLink);
3045  m_xEndBracketLB->connect_changed(aLink);
3046 
3047  SvxFont& rFont = GetPreviewFont();
3048  SvxFont& rCJKFont = GetPreviewCJKFont();
3049  SvxFont& rCTLFont = GetPreviewCTLFont();
3050  rFont.SetFontSize( Size( 0, 220 ) );
3051  rCJKFont.SetFontSize( Size( 0, 220 ) );
3052  rCTLFont.SetFontSize( Size( 0, 220 ) );
3053 }
3054 
3056 {
3057  bool bStart = pBox == m_xStartBracketLB.get();
3058  SvxCharacterMap aDlg(GetFrameWeld(), nullptr, nullptr);
3059  aDlg.DisableFontSelection();
3060 
3061  if (aDlg.run() == RET_OK)
3062  {
3063  sal_Unicode cChar = static_cast<sal_Unicode>(aDlg.GetChar());
3064  SetBracket( cChar, bStart );
3065  }
3066  else
3067  {
3069  }
3070 }
3071 
3072 
3073 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart )
3074 {
3075  int nEntryPos = 0;
3076  weld::TreeView* pBox = bStart ? m_xStartBracketLB.get() : m_xEndBracketLB.get();
3077  if (cBracket == 0)
3078  pBox->select(0);
3079  else
3080  {
3081  bool bFound = false;
3082  for (int i = 1; i < pBox->n_children(); ++i)
3083  {
3084  if (pBox->get_id(i).toInt32() != CHRDLG_ENCLOSE_SPECIAL_CHAR)
3085  {
3086  const sal_Unicode cChar = pBox->get_text(i)[0];
3087  if (cChar == cBracket)
3088  {
3089  pBox->select(i);
3090  nEntryPos = i;
3091  bFound = true;
3092  break;
3093  }
3094  }
3095  }
3096 
3097  if (!bFound)
3098  {
3099  pBox->append_text(OUString(cBracket));
3100  nEntryPos = pBox->n_children() - 1;
3101  pBox->select(nEntryPos);
3102  }
3103  }
3104  if (bStart)
3105  m_nStartBracketPosition = nEntryPos;
3106  else
3107  m_nEndBracketPosition = nEntryPos;
3108 }
3109 
3111 {
3112  bool bChecked = m_xTwoLinesBtn->get_active();
3113  m_xEnclosingFrame->set_sensitive(bChecked);
3114  UpdatePreview_Impl();
3115 }
3116 
3117 IMPL_LINK(SvxCharTwoLinesPage, CharacterMapHdl_Impl, weld::TreeView&, rBox, void)
3118 {
3119  int nPos = rBox.get_selected_index();
3120  if (rBox.get_id(nPos).toInt32() == CHRDLG_ENCLOSE_SPECIAL_CHAR)
3121  SelectCharacter( &rBox );
3122  else
3123  {
3124  bool bStart = &rBox == m_xStartBracketLB.get();
3125  if (bStart)
3126  m_nStartBracketPosition = nPos;
3127  else
3128  m_nEndBracketPosition = nPos;
3129  }
3130  UpdatePreview_Impl();
3131 }
3132 
3134 {
3136 }
3137 
3139 {
3140  if ( _pSet )
3141  FillItemSet( _pSet );
3142  return DeactivateRC::LeavePage;
3143 }
3144 
3145 std::unique_ptr<SfxTabPage> SvxCharTwoLinesPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
3146 {
3147  return std::make_unique<SvxCharTwoLinesPage>(pPage, pController, *rSet);
3148 }
3149 
3151 {
3152  m_xTwoLinesBtn->set_active(false);
3153  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3154  SfxItemState eState = rSet->GetItemState( nWhich );
3155 
3156  if ( eState >= SfxItemState::DONTCARE )
3157  {
3158  const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich ));
3159  m_xTwoLinesBtn->set_active(rItem.GetValue());
3160 
3161  if ( rItem.GetValue() )
3162  {
3163  SetBracket( rItem.GetStartBracket(), true );
3164  SetBracket( rItem.GetEndBracket(), false );
3165  }
3166  }
3167  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3168 
3169  SetPrevFontWidthScale( *rSet );
3170 }
3171 
3173 {
3174  const SfxItemSet& rOldSet = GetItemSet();
3175  bool bModified = false, bChanged = true;
3176  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3177  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_TWO_LINES );
3178  bool bOn = m_xTwoLinesBtn->get_active();
3179  sal_Unicode cStart = ( bOn && m_xStartBracketLB->get_selected_index() > 0 )
3180  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3181  sal_Unicode cEnd = ( bOn && m_xEndBracketLB->get_selected_index() > 0 )
3182  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3183 
3184  if ( pOld )
3185  {
3186  const SvxTwoLinesItem& rItem = *static_cast<const SvxTwoLinesItem*>(pOld);
3187  if ( rItem.GetValue() == bOn &&
3188  ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3189  bChanged = false;
3190  }
3191 
3192  if ( bChanged )
3193  {
3194  rSet->Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3195  bModified = true;
3196  }
3197  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3198  rSet->InvalidateItem(nWhich);
3199 
3200  return bModified;
3201 }
3202 
3204 {
3205  sal_Unicode cStart = m_xStartBracketLB->get_selected_index() > 0
3206  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3207  sal_Unicode cEnd = m_xEndBracketLB->get_selected_index() > 0
3208  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3209  m_aPreviewWin.SetBrackets(cStart, cEnd);
3210  m_aPreviewWin.SetTwoLines(m_xTwoLinesBtn->get_active());
3211  m_aPreviewWin.Invalidate();
3212 }
3213 
3215 {
3216  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3217  if (pFlagItem)
3218  {
3219  sal_uInt32 nFlags=pFlagItem->GetValue();
3220  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3221  // the writer uses SID_ATTR_BRUSH as font background
3223  }
3224 }
3225 
3226 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFamily(FontFamily)
sal_uInt16 m_nScaleWidthInitialVal
Definition: chardlg.hxx:247
virtual ~SvxCharEffectsPage() override
Definition: chardlg.cxx:1353
std::unique_ptr< weld::CheckButton > m_xFitToLineCB
Definition: chardlg.hxx:268
std::unique_ptr< weld::Label > m_xWestFontLanguageFT
Definition: chardlg.hxx:75
std::unique_ptr< FontSizeBox > m_xEastFontSizeLB
Definition: chardlg.hxx:86
std::unique_ptr< FontStyleBox > m_xCTLFontStyleLB
Definition: chardlg.hxx:96
bool IsRelativeMode() const
void SetPropr(const sal_uInt8 nNewPropr)
std::unique_ptr< weld::RadioButton > m_xHighPosBtn
Definition: chardlg.hxx:252
std::unique_ptr< SvxCharNamePage_Impl > m_pImpl
Definition: chardlg.hxx:66
FieldUnit
void SetBracket(sal_Unicode cBracket, bool bStart)
Definition: chardlg.cxx:3073
std::unique_ptr< weld::RadioButton > m_xNormalPosBtn
Definition: chardlg.hxx:253
SvxFont & GetCTLFont()
sal_Int32 nIndex
std::unique_ptr< weld::ComboBox > m_xStrikeoutLB
Definition: chardlg.hxx:192
OUString m_aNoStyleText
Definition: chardlg.cxx:174
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:188
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:2986
std::unique_ptr< weld::ComboBox > m_xWestFontNameLB
Definition: chardlg.hxx:70
sal_Unicode GetStartBracket() const
std::string GetValue
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:1661
std::unique_ptr< weld::MetricSpinButton > m_xFontSizeMF
Definition: chardlg.hxx:259
SvxCaseMap
Idle m_aUpdateIdle cui SvxCharNamePage_Impl m_aUpdateIdle
Definition: chardlg.cxx:173
bool IsTransparent() const
virtual short run() override
OUString const & getResultFontName() const
LanguageType get_active_id() const
bool FillItemSetColor_Impl(SfxItemSet &rSet)
Definition: chardlg.cxx:1571
virtual void hide()=0
void SetColor(const Color &rCol)
SvxCharPositionPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:2398
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:120
FontEmphasisMark
std::unique_ptr< weld::Widget > m_xRotationContainer
Definition: chardlg.hxx:261
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:197
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:122
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:3150
std::unique_ptr< weld::Label > m_xFontColorFT
Definition: chardlg.hxx:178
std::unique_ptr< weld::ComboBox > m_xEffectsLB
Definition: chardlg.hxx:183
std::unique_ptr< weld::Label > m_xCTLFontStyleFT
Definition: chardlg.hxx:95
std::unique_ptr< weld::Label > m_xEastFontNameFT
Definition: chardlg.hxx:81
sal_uInt16 m_nHtmlMode
Definition: chardlg.hxx:171
#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:118
bool IsBottomToTop() const
std::unique_ptr< weld::ComboBox > m_xReliefLB
Definition: chardlg.hxx:185
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:145
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:2852
bool m_bPreviewBackgroundToCharacter
Definition: chardlg.hxx:40
weld::TriStateEnabled m_aShadowState
Definition: chardlg.hxx:174
bool IsAvailable(const OUString &rName) const
std::unique_ptr< weld::CheckButton > m_xShadowBtn
Definition: chardlg.hxx:187
std::unique_ptr< weld::Label > m_xCTLFontTypeFT
Definition: chardlg.hxx:101
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:1609
static OutputDevice * GetDefaultDevice()
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
std::unique_ptr< weld::CheckButton > m_xIndividualWordsBtn
Definition: chardlg.hxx:196
SvxFont & GetPreviewCTLFont()
Definition: chardlg.cxx:130
#define CHRDLG_POSITION_UNDER
Definition: chardlg.h:24
sal_uInt16 sal_Unicode
FontItalic GetItalic()
virtual ~SvxCharPositionPage() override
Definition: chardlg.cxx:2432
const Color & GetColor() const
std::unique_ptr< weld::CheckButton > m_xOutlineBtn
Definition: chardlg.hxx:186
Degree10 GetValue() const
std::unique_ptr< weld::Label > m_xOverlineColorFT
Definition: chardlg.hxx:190
sal_Unicode GetEndBracket() const
void append_text(const OUString &rStr)
std::unique_ptr< weld::RadioButton > m_x0degRB
Definition: chardlg.hxx:265
LINESTYLE_NONE
std::unique_ptr< SvxLanguageBox > m_xEastFontLanguageLB
Definition: chardlg.hxx:88
void SetTextLineColor(const Color &rColor)
ScopedVclPtrInstance< VirtualDevice > m_xVDev
Definition: chardlg.hxx:105
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:200
std::unique_ptr< weld::Label > m_xWestFontTypeFT
Definition: chardlg.hxx:77
virtual int n_children() const =0
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:3214
const OUString & GetBoldStr() const
virtual ~SvxCharNamePage() override
Definition: chardlg.cxx:310
Color m_aOrigFontColor
Definition: chardlg.hxx:170
#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:257
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:2475
SvxFont & GetFont()
#define DFLT_ESC_PROP
sal_uInt8 m_nSuperProp
Definition: chardlg.hxx:249
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:141
sal_uInt16 GetProp() const
void FontModifyHdl_Impl()
Definition: chardlg.cxx:2544
std::unique_ptr< weld::CheckButton > m_xTwoLinesBtn
Definition: chardlg.hxx:314
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2065
void SetPitch(FontPitch ePitch)
SvxFont & GetPreviewCJKFont()
Definition: chardlg.cxx:125
const OUString & GetStyleName() const
LanguageType get_saved_active_id() const
const SfxItemSet & GetItemSet() const
#define SAL_N_ELEMENTS(arr)
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:1673
void save_active_id()
std::unique_ptr< weld::Label > m_xHighLowFT
Definition: chardlg.hxx:255
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:194
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:176
std::unique_ptr< weld::Label > m_xCTLFontLanguageFT
Definition: chardlg.hxx:99
void set_active_text(const OUString &rStr)
static const WhichRangesContainer pPositionRanges
Definition: chardlg.hxx:240
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:182
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:3133
virtual void insert_vector(const std::vector< weld::ComboBoxEntry > &rItems, bool bKeepExisting)=0
sal_uInt16 m_nEndBracketPosition
Definition: chardlg.hxx:312
HTMLMODE_ON
SvxCharTwoLinesPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:3011
void SetPrevFontEscapement(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc)
Definition: chardlg.cxx:160
static const WhichRangesContainer pEffectsRanges
Definition: chardlg.hxx:166
std::unique_ptr< weld::CheckButton > m_xPairKerningBtn
Definition: chardlg.hxx:273
WEIGHT_NORMAL
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:1223
std::unique_ptr< SvxLanguageBox > m_xCTLFontLanguageLB
Definition: chardlg.hxx:100
float u
sal_uInt16 m_nStartBracketPosition
Definition: chardlg.hxx:311
std::unique_ptr< weld::Label > m_xEastFontSizeFT
Definition: chardlg.hxx:85
std::unique_ptr< ColorListBox > m_xFontColorLB
Definition: chardlg.hxx:179
#define LANGUAGE_DONTKNOW
const Size & GetFontSize() const
bool IsAsianTypographyEnabled()
std::unique_ptr< weld::Widget > m_xEastFrame
Definition: chardlg.hxx:80
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:2374
tools::Long CalcToUnit(float nIn, MapUnit eUnit)
virtual OUString get_text(int row, int col=-1) const =0
void EnableNoneFontColor()
Definition: chardlg.cxx:1347
virtual void set_active(int pos)=0
SvxCharBasePage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID, const SfxItemSet &rAttrSet)
Definition: chardlg.cxx:135
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:193
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:2632
void SetTwoLines(bool bSet)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:2998
bool IsFitToLine() const
void set_active_or_entry_text(const OUString &rText)
void EnableRelativeMode()
Definition: chardlg.cxx:1255
virtual short run() override
Definition: cuicharmap.cxx:186
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:250
std::unique_ptr< weld::RadioButton > m_x90degRB
Definition: chardlg.hxx:266
std::unique_ptr< weld::Label > m_xReliefFT
Definition: chardlg.hxx:184
void ResetColor_Impl(const SfxItemSet &rSet)
Definition: chardlg.cxx:1508
const OUString & GetFamilyName() const
bool m_bEnableNoneFontColor
Definition: chardlg.hxx:169
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:105
sal_uInt32 GetHeight() const
void SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
SfxItemState
void EnableRelativeMode(sal_uInt16 nMin, sal_uInt16 nMax, sal_uInt16 nStep=5)
std::unique_ptr< FontSizeBox > m_xWestFontSizeLB
Definition: chardlg.hxx:74
#define DFLT_ESC_SUB
std::unique_ptr< weld::Widget > m_xCTLFrame
Definition: chardlg.hxx:92
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual void ChangesApplied() override
Definition: chardlg.cxx:2049
std::unique_ptr< weld::RadioButton > m_x270degRB
Definition: chardlg.hxx:267
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:2469
std::unique_ptr< weld::TreeView > m_xEndBracketLB
Definition: chardlg.hxx:317
void SetPrevFontWidthScale(const SfxItemSet &rSet)
Definition: chardlg.cxx:150
static const WhichRangesContainer pTwoLinesRanges
Definition: chardlg.hxx:310
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:3138
const OUString & GetItalicStr() const
std::unique_ptr< weld::MetricSpinButton > m_xHighLowMF
Definition: chardlg.hxx:256
RET_OK
virtual ~SvxCharTwoLinesPage() override
Definition: chardlg.cxx:3032
bool IsTopToBottom() const
#define DFLT_ESC_SUPER
int find_text(const OUString &rStr) const
void Fill(const OUString &rName, const FontList *pList)
void DisableControls(sal_uInt16 nDisable)
Definition: chardlg.cxx:2365
SfxOkDialogController * GetDialogController() const
void DisableFontSelection()
Definition: cuicharmap.cxx:218
int get_saved_value() const
void UpdatePreview_Impl()
Definition: chardlg.cxx:3203
Language for ctl text.
Definition: chardlg.hxx:126
virtual OUString get_id(int pos) const =0
std::unique_ptr< weld::Label > m_xCTLFontNameFT
Definition: chardlg.hxx:93
std::unique_ptr< weld::MetricSpinButton > m_xKerningMF
Definition: chardlg.hxx:272
#define CHRDLG_POSITION_OVER
Definition: chardlg.h:23
weld::TriStateEnabled m_aOutlineState
Definition: chardlg.hxx:173
std::unique_ptr< weld::Label > m_xCTLFontSizeFT
Definition: chardlg.hxx:97
DeactivateRC
void setHeight(tools::Long nHeight)
void SelectCharacter(weld::TreeView *pBox)
Definition: chardlg.cxx:3055
void SetProprRel(const sal_uInt8 nNewPropr)
SvxEscapement
sal_uInt32 GetValue() const
void SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBackgroundToCharacter)
std::unique_ptr< weld::TreeView > m_xStartBracketLB
Definition: chardlg.hxx:316
void Reset_Impl(const SfxItemSet &rSet, LanguageGroup eLangGrp)
Definition: chardlg.cxx:606
sal_UCS4 GetChar() const
Definition: cuicharmap.cxx:213
MapUnit
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2867
#define SAL_WARN(area, stream)
void AutoCorrectFontColor()
std::unique_ptr< FontSizeBox > m_xCTLFontSizeLB
Definition: chardlg.hxx:98
The main purpose of this dialog is to enable the use of characters that are not easily accessible fro...
Definition: cuicharmap.hxx:76
std::unique_ptr< weld::Button > m_xEastFontFeaturesButton
Definition: chardlg.hxx:90
std::unique_ptr< ColorListBox > m_xUnderlineColorLB
Definition: chardlg.hxx:195
void SetPriority(TaskPriority ePriority)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1668
void SetFontList(const SvxFontListItem &rItem)
Definition: chardlg.cxx:1231
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:2620
#define MAX_ESC_POS
std::unique_ptr< FontList > m_pFontList
Definition: chardlg.cxx:175
const FontList * GetFontList() const
STRIKEOUT_NONE
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
TriState
FontLineStyle
sal_uInt16 m_nScaleWidthItemSetVal
Definition: chardlg.hxx:246
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:181
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:3172
#define SVX_ENABLE_CHAR_TRANSPARENCY
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:2627
bool IsPtRelative() const
std::unique_ptr< weld::Label > m_xScalingFT
Definition: chardlg.hxx:263
void SetEscapement(const short nNewEsc)
std::unique_ptr< weld::ComboBox > m_xOverlineLB
Definition: chardlg.hxx:189
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
std::unique_ptr< weld::Label > m_xScalingAndRotationFT
Definition: chardlg.hxx:264
OUString const & get_saved_value() const
std::unique_ptr< weld::MetricSpinButton > m_xScaleWidthMF
Definition: chardlg.hxx:270
std::unique_ptr< weld::Label > m_xFontSizeFT
Definition: chardlg.hxx:258
virtual void set_entry_text(const OUString &rStr)=0
std::unique_ptr< weld::RadioButton > m_xLowPosBtn
Definition: chardlg.hxx:254
#define SVX_RELATIVE_MODE
std::unique_ptr< ColorListBox > m_xOverlineColorLB
Definition: chardlg.hxx:191
FontStrikeout
OUString get_active_text() const
MapUnit GetPropUnit() const
std::unique_ptr< weld::Button > m_xCTLFontFeaturesButton
Definition: chardlg.hxx:102
std::unique_ptr< weld::ComboBox > m_xEmphasisLB
Definition: chardlg.hxx:198
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:175
std::unique_ptr< weld::Label > m_xA11yWarningFT
Definition: chardlg.hxx:201
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:180
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:3145
void SetOverlineColor(const Color &rColor)
std::unique_ptr< weld::Label > m_xPositionFT
Definition: chardlg.hxx:199
std::unique_ptr< weld::ComboBox > m_xCTLFontNameLB
Definition: chardlg.hxx:94
SvxCharNamePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:190