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