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