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  {
540  // additional entries for the search:
541  // "not bold" and "not italic"
542  OUString aEntry = m_pImpl->m_aNoStyleText;
543  const char sS[] = "%1";
544  aEntry = aEntry.replaceFirst( sS, pFontList->GetBoldStr() );
545  m_pImpl->m_nExtraEntryPos = pStyleBox->get_count();
546  pStyleBox->append_text( aEntry );
547  aEntry = m_pImpl->m_aNoStyleText;
548  aEntry = aEntry.replaceFirst( sS, pFontList->GetItalicStr() );
549  pStyleBox->append_text(aEntry);
550  }
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_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_LANGUAGE & nDisable )
1270  {
1271  if ( m_xWestFontLanguageFT ) m_xWestFontLanguageFT->set_sensitive(false);
1272  if ( m_xWestFontLanguageLB ) m_xWestFontLanguageLB->set_sensitive(false);
1273  if ( m_xEastFontLanguageFT ) m_xEastFontLanguageFT->set_sensitive(false);
1274  if ( m_xEastFontLanguageLB ) m_xEastFontLanguageLB->set_sensitive(false);
1275  if ( m_xCTLFontLanguageFT ) m_xCTLFontLanguageFT->set_sensitive(false);
1276  if ( m_xCTLFontLanguageLB ) m_xCTLFontLanguageLB->set_sensitive(false);
1277  }
1278 
1279  if ( DISABLE_HIDE_LANGUAGE & nDisable )
1280  {
1287  }
1288 }
1289 
1291 {
1292  const SvxFontListItem* pFontListItem = aSet.GetItem<SvxFontListItem>(SID_ATTR_CHAR_FONTLIST, false);
1293  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
1294  const SfxUInt16Item* pDisalbeItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
1295  if (pFontListItem)
1296  SetFontList(*pFontListItem);
1297 
1298  if (pFlagItem)
1299  {
1300  sal_uInt32 nFlags=pFlagItem->GetValue();
1301  if ( ( nFlags & SVX_RELATIVE_MODE ) == SVX_RELATIVE_MODE )
1303  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
1304  // the writer uses SID_ATTR_BRUSH as font background
1306  }
1307  if (pDisalbeItem)
1308  DisableControls(pDisalbeItem->GetValue());
1309 }
1310 // class SvxCharEffectsPage ----------------------------------------------
1311 
1313  : SvxCharBasePage(pPage, pController, "cui/ui/effectspage.ui", "EffectsPage", rInSet)
1314  , m_bOrigFontColor(false)
1315  , m_bNewFontColor(false)
1316  , m_bEnableNoneFontColor(false)
1317  , m_bUnderlineColorDisabled(false)
1318  , m_xFontColorFT(m_xBuilder->weld_label("fontcolorft"))
1319  , m_xFontColorLB(new ColorListBox(m_xBuilder->weld_menu_button("fontcolorlb"), pController->getDialog()))
1320  , m_xFontTransparencyFT(m_xBuilder->weld_label("fonttransparencyft"))
1321  , m_xFontTransparencyMtr(
1322  m_xBuilder->weld_metric_spin_button("fonttransparencymtr", FieldUnit::PERCENT))
1323  , m_xEffectsFT(m_xBuilder->weld_label("effectsft"))
1324  , m_xEffectsLB(m_xBuilder->weld_combo_box("effectslb"))
1325  , m_xReliefFT(m_xBuilder->weld_label("reliefft"))
1326  , m_xReliefLB(m_xBuilder->weld_combo_box("relieflb"))
1327  , m_xOutlineBtn(m_xBuilder->weld_check_button("outlinecb"))
1328  , m_xShadowBtn(m_xBuilder->weld_check_button("shadowcb"))
1329  , m_xBlinkingBtn(m_xBuilder->weld_check_button("blinkingcb"))
1330  , m_xHiddenBtn(m_xBuilder->weld_check_button("hiddencb"))
1331  , m_xOverlineLB(m_xBuilder->weld_combo_box("overlinelb"))
1332  , m_xOverlineColorFT(m_xBuilder->weld_label("overlinecolorft"))
1333  , m_xOverlineColorLB(new ColorListBox(m_xBuilder->weld_menu_button("overlinecolorlb"), pController->getDialog()))
1334  , m_xStrikeoutLB(m_xBuilder->weld_combo_box("strikeoutlb"))
1335  , m_xUnderlineLB(m_xBuilder->weld_combo_box("underlinelb"))
1336  , m_xUnderlineColorFT(m_xBuilder->weld_label("underlinecolorft"))
1337  , m_xUnderlineColorLB(new ColorListBox(m_xBuilder->weld_menu_button("underlinecolorlb"), pController->getDialog()))
1338  , m_xIndividualWordsBtn(m_xBuilder->weld_check_button("individualwordscb"))
1339  , m_xEmphasisFT(m_xBuilder->weld_label("emphasisft"))
1340  , m_xEmphasisLB(m_xBuilder->weld_combo_box("emphasislb"))
1341  , m_xPositionFT(m_xBuilder->weld_label("positionft"))
1342  , m_xPositionLB(m_xBuilder->weld_combo_box("positionlb"))
1343  , m_xA11yWarningFT(m_xBuilder->weld_label("a11ywarning"))
1344 {
1345  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
1346 #ifdef IOS
1347  m_xPreviewWin->hide();
1348 #endif
1349  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1350  m_xOverlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1351  m_xUnderlineColorLB->SetSlotId(SID_ATTR_CHAR_COLOR);
1352  Initialize();
1353 }
1354 
1356 {
1357  m_xFontColorLB->SetSlotId(SID_ATTR_CHAR_COLOR, true);
1358  m_bEnableNoneFontColor = true;
1359 }
1360 
1362 {
1363  if (rColor == COL_AUTO)
1364  return COL_BLACK;
1365  if (m_bEnableNoneFontColor && rColor == COL_NONE_COLOR)
1366  return COL_BLACK;
1367  return rColor;
1368 }
1369 
1371 {
1372  m_xUnderlineColorLB.reset();
1373  m_xOverlineColorLB.reset();
1374  m_xFontTransparencyMtr.reset();
1375  m_xFontColorLB.reset();
1376 }
1377 
1379 {
1380  // to handle the changes of the other pages
1382 
1383  // HTML-Mode
1384  const SfxPoolItem* pItem;
1385  SfxObjectShell* pShell;
1386  if ( SfxItemState::SET == GetItemSet().GetItemState( SID_HTML_MODE, false, &pItem ) ||
1387  ( nullptr != ( pShell = SfxObjectShell::Current() ) &&
1388  nullptr != ( pItem = pShell->GetItem( SID_HTML_MODE ) ) ) )
1389  {
1390  m_nHtmlMode = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1391  if ( ( m_nHtmlMode & HTMLMODE_ON ) == HTMLMODE_ON )
1392  {
1394  }
1395  }
1396 
1397  m_xFontColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1398  m_xFontTransparencyMtr->connect_value_changed(
1399  LINK(this, SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl));
1400 
1401  // handler
1402  Link<weld::ComboBox&,void> aLink = LINK( this, SvxCharEffectsPage, SelectListBoxHdl_Impl );
1403  m_xUnderlineLB->connect_changed( aLink );
1404  m_xUnderlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1405  m_xOverlineLB->connect_changed( aLink );
1406  m_xOverlineColorLB->SetSelectHdl(LINK(this, SvxCharEffectsPage, ColorBoxSelectHdl_Impl));
1407  m_xStrikeoutLB->connect_changed( aLink );
1408  m_xEmphasisLB->connect_changed( aLink );
1409  m_xPositionLB->connect_changed( aLink );
1410  m_xEffectsLB->connect_changed( aLink );
1411  m_xReliefLB->connect_changed( aLink );
1412 
1413  m_xUnderlineLB->set_active( 0 );
1414  m_xOverlineLB->set_active( 0 );
1415  m_xStrikeoutLB->set_active( 0 );
1416  m_xEmphasisLB->set_active( 0 );
1417  m_xPositionLB->set_active( 0 );
1418  SelectHdl_Impl(nullptr);
1420 
1421  m_xEffectsLB->set_active( 0 );
1422 
1423  m_xIndividualWordsBtn->connect_toggled(LINK(this, SvxCharEffectsPage, CbClickHdl_Impl));
1424  Link<weld::ToggleButton&,void> aLink2 = LINK(this, SvxCharEffectsPage, TristClickHdl_Impl);
1425  m_xOutlineBtn->connect_toggled(aLink2);
1426  m_xShadowBtn->connect_toggled(aLink2);
1427 
1428  if ( !SvtLanguageOptions().IsAsianTypographyEnabled() )
1429  {
1430  m_xEmphasisFT->hide();
1431  m_xEmphasisLB->hide();
1432  m_xPositionFT->hide();
1433  m_xPositionLB->hide();
1434  }
1435 
1436  m_xA11yWarningFT->set_visible(officecfg::Office::Common::Accessibility::IsAutomaticFontColor::get());
1437 }
1438 
1440 {
1441  SvxFont& rFont = GetPreviewFont();
1442  SvxFont& rCJKFont = GetPreviewCJKFont();
1443  SvxFont& rCTLFont = GetPreviewCTLFont();
1444 
1445  const Color& rSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1446  rFont.SetColor(GetPreviewFontColor(rSelectedColor));
1447  rCJKFont.SetColor(GetPreviewFontColor(rSelectedColor));
1448  rCTLFont.SetColor(GetPreviewFontColor(rSelectedColor));
1449 
1450  FontLineStyle eUnderline = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
1451  FontLineStyle eOverline = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
1452  FontStrikeout eStrikeout = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
1453  rFont.SetUnderline( eUnderline );
1454  rCJKFont.SetUnderline( eUnderline );
1455  rCTLFont.SetUnderline( eUnderline );
1456  m_aPreviewWin.SetTextLineColor( m_xUnderlineColorLB->GetSelectEntryColor() );
1457  rFont.SetOverline( eOverline );
1458  rCJKFont.SetOverline( eOverline );
1459  rCTLFont.SetOverline( eOverline );
1460  m_aPreviewWin.SetOverlineColor( m_xOverlineColorLB->GetSelectEntryColor() );
1461  rFont.SetStrikeout( eStrikeout );
1462  rCJKFont.SetStrikeout( eStrikeout );
1463  rCTLFont.SetStrikeout( eStrikeout );
1464 
1465  auto nEmphasis = m_xEmphasisLB->get_active();
1466  if (nEmphasis != -1)
1467  {
1468  bool bUnder = (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32());
1469  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nEmphasis);
1470  eMark |= bUnder ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
1471  rFont.SetEmphasisMark( eMark );
1472  rCJKFont.SetEmphasisMark( eMark );
1473  rCTLFont.SetEmphasisMark( eMark );
1474  }
1475 
1476  auto nRelief = m_xReliefLB->get_active();
1477  if (nRelief != -1)
1478  {
1479  rFont.SetRelief( static_cast<FontRelief>(nRelief) );
1480  rCJKFont.SetRelief( static_cast<FontRelief>(nRelief) );
1481  rCTLFont.SetRelief( static_cast<FontRelief>(nRelief) );
1482  }
1483 
1484  rFont.SetOutline( StateToAttr( m_xOutlineBtn->get_state() ) );
1485  rCJKFont.SetOutline( rFont.IsOutline() );
1486  rCTLFont.SetOutline( rFont.IsOutline() );
1487 
1488  rFont.SetShadow( StateToAttr( m_xShadowBtn->get_state() ) );
1489  rCJKFont.SetShadow( rFont.IsShadow() );
1490  rCTLFont.SetShadow( rFont.IsShadow() );
1491 
1492  auto nCapsPos = m_xEffectsLB->get_active();
1493  if (nCapsPos != -1)
1494  {
1495  SvxCaseMap eCaps = static_cast<SvxCaseMap>(nCapsPos);
1496  rFont.SetCaseMap( eCaps );
1497  rCJKFont.SetCaseMap( eCaps );
1498  // #i78474# small caps do not exist in CTL fonts
1499  rCTLFont.SetCaseMap( eCaps == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaps );
1500  }
1501 
1502  bool bWordLine = m_xIndividualWordsBtn->get_active();
1503  rFont.SetWordLineMode( bWordLine );
1504  rCJKFont.SetWordLineMode( bWordLine );
1505  rCTLFont.SetWordLineMode( bWordLine );
1506 
1507  m_aPreviewWin.Invalidate();
1508 }
1509 
1511 {
1512  if ( SvxCaseMap::End > eCaseMap )
1513  m_xEffectsLB->set_active(
1514  sal::static_int_cast< sal_Int32 >( eCaseMap ) );
1515  else
1516  {
1517  // not mapped
1518  m_xEffectsLB->set_active(-1);
1519  }
1520 
1522 }
1523 
1525 {
1526  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1527  SfxItemState eState = rSet.GetItemState( nWhich );
1528 
1529  m_bOrigFontColor = false;
1530  switch ( eState )
1531  {
1532  case SfxItemState::UNKNOWN:
1533  m_xFontColorFT->hide();
1534  m_xFontColorLB->hide();
1535  break;
1536 
1537  case SfxItemState::DISABLED:
1538  case SfxItemState::READONLY:
1539  m_xFontColorFT->set_sensitive(false);
1540  m_xFontColorLB->set_sensitive(false);
1541  break;
1542 
1543  case SfxItemState::DONTCARE:
1544  //Related: tdf#106080 if there is no font color, then allow "none"
1545  //as a color so the listbox can display that state.
1547  m_xFontColorLB->SetNoSelection();
1548  break;
1549 
1550  case SfxItemState::DEFAULT:
1551  case SfxItemState::SET:
1552  {
1553  SvxFont& rFont = GetPreviewFont();
1554  SvxFont& rCJKFont = GetPreviewCJKFont();
1555  SvxFont& rCTLFont = GetPreviewCTLFont();
1556 
1557  const SvxColorItem& rItem = static_cast<const SvxColorItem&>(rSet.Get( nWhich ));
1558  Color aColor = rItem.GetValue();
1559  rFont.SetColor(GetPreviewFontColor(aColor));
1560  rCJKFont.SetColor(GetPreviewFontColor(aColor));
1561  rCTLFont.SetColor(GetPreviewFontColor(aColor));
1562 
1563  m_aPreviewWin.Invalidate();
1564 
1565  Color aRGBColor = aColor;
1566  if (aRGBColor.GetTransparency() && aColor != COL_AUTO)
1567  {
1568  aRGBColor.SetTransparency(0);
1569  }
1570  m_xFontColorLB->SelectEntry(aRGBColor);
1571 
1572  if (m_xFontTransparencyMtr->get_visible() && aColor != COL_AUTO)
1573  {
1574  double fTransparency = aColor.GetTransparency() * 100.0 / 255;
1575  m_xFontTransparencyMtr->set_value(basegfx::fround(fTransparency),
1576  FieldUnit::PERCENT);
1577  }
1578 
1579  m_aOrigFontColor = aColor;
1580  m_bOrigFontColor = true;
1581  break;
1582  }
1583  }
1584  m_bNewFontColor = false;
1585 }
1586 
1588 {
1589  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_COLOR );
1590  const SfxItemSet& rOldSet = GetItemSet();
1591 
1592  Color aSelectedColor;
1593  bool bChanged = m_bNewFontColor;
1594 
1595  if (bChanged)
1596  {
1597  aSelectedColor = m_xFontColorLB->GetSelectEntryColor();
1598 
1599  if (m_xFontTransparencyMtr->get_value_changed_from_saved())
1600  {
1601  double fTransparency
1602  = m_xFontTransparencyMtr->get_value(FieldUnit::PERCENT) * 255.0 / 100;
1603  aSelectedColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
1604  }
1605 
1606  if (m_bOrigFontColor)
1607  bChanged = aSelectedColor != m_aOrigFontColor;
1608  if (m_bEnableNoneFontColor && bChanged && aSelectedColor == COL_NONE_COLOR)
1609  bChanged = false;
1610  }
1611 
1612  if (bChanged)
1613  rSet.Put( SvxColorItem( aSelectedColor, nWhich ) );
1614  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
1615  rSet.InvalidateItem(nWhich);
1616 
1617  return bChanged;
1618 }
1619 
1620 IMPL_LINK( SvxCharEffectsPage, SelectListBoxHdl_Impl, weld::ComboBox&, rBox, void )
1621 {
1622  SelectHdl_Impl(&rBox);
1623 }
1624 
1626 {
1627  if (m_xEmphasisLB.get() == pBox)
1628  {
1629  auto nEPos = m_xEmphasisLB->get_active();
1630  bool bEnable = nEPos > 0;
1631  m_xPositionFT->set_sensitive( bEnable );
1632  m_xPositionLB->set_sensitive( bEnable );
1633  }
1634  else if (m_xReliefLB.get() == pBox)
1635  {
1636  bool bEnable = ( pBox->get_active() == 0 );
1637  m_xOutlineBtn->set_sensitive( bEnable );
1638  m_xShadowBtn->set_sensitive( bEnable );
1639  }
1640  else if (m_xPositionLB.get() != pBox)
1641  {
1642  bool bUEnable = false;
1644  {
1645  auto nUPos = m_xUnderlineLB->get_active();
1646  bUEnable = nUPos > 0;
1647  m_xUnderlineColorFT->set_sensitive(bUEnable);
1648  m_xUnderlineColorLB->set_sensitive(bUEnable);
1649  }
1650 
1651  auto nOPos = m_xOverlineLB->get_active();
1652  bool bOEnable = nOPos > 0;
1653  m_xOverlineColorFT->set_sensitive(bOEnable);
1654  m_xOverlineColorLB->set_sensitive(bOEnable);
1655 
1656  auto nSPos = m_xStrikeoutLB->get_active();
1657  m_xIndividualWordsBtn->set_sensitive( bUEnable || bOEnable || nSPos > 0);
1658  }
1660 }
1661 
1663 {
1664  UpdatePreview_Impl();
1665 }
1666 
1668 {
1669  UpdatePreview_Impl();
1670 }
1671 
1672 IMPL_LINK(SvxCharEffectsPage, ColorBoxSelectHdl_Impl, ColorListBox&, rBox, void)
1673 {
1674  if (m_xFontColorLB.get() == &rBox)
1675  m_bNewFontColor = true;
1676  UpdatePreview_Impl();
1677 }
1678 
1679 IMPL_LINK_NOARG(SvxCharEffectsPage, ModifyFontTransparencyHdl_Impl, weld::MetricSpinButton&, void)
1680 {
1681  m_bNewFontColor = true;
1682 }
1683 
1685 {
1686  if ( _pSet )
1687  FillItemSet( _pSet );
1688  return DeactivateRC::LeavePage;
1689 }
1690 
1691 std::unique_ptr<SfxTabPage> SvxCharEffectsPage::Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet )
1692 {
1693  return std::make_unique<SvxCharEffectsPage>( pPage, pController, *rSet );
1694 }
1695 
1697 {
1698  SvxFont& rFont = GetPreviewFont();
1699  SvxFont& rCJKFont = GetPreviewCJKFont();
1700  SvxFont& rCTLFont = GetPreviewCTLFont();
1701 
1702  bool bEnable = false;
1703 
1704  // Underline
1705  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
1706  rFont.SetUnderline( LINESTYLE_NONE );
1707  rCJKFont.SetUnderline( LINESTYLE_NONE );
1708  rCTLFont.SetUnderline( LINESTYLE_NONE );
1709 
1710  m_xUnderlineLB->set_active( 0 );
1711  SfxItemState eState = rSet->GetItemState( nWhich );
1712 
1713  if ( eState >= SfxItemState::DONTCARE )
1714  {
1715  if ( eState == SfxItemState::DONTCARE )
1716  m_xUnderlineLB->set_active(-1);
1717  else
1718  {
1719  const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>(rSet->Get( nWhich ));
1720  FontLineStyle eUnderline = rItem.GetValue();
1721  rFont.SetUnderline( eUnderline );
1722  rCJKFont.SetUnderline( eUnderline );
1723  rCTLFont.SetUnderline( eUnderline );
1724 
1725  if ( eUnderline != LINESTYLE_NONE )
1726  {
1727  auto nPos = m_xUnderlineLB->find_id(OUString::number(eUnderline));
1728  if (nPos != -1)
1729  {
1730  m_xUnderlineLB->set_active(nPos);
1731  bEnable = true;
1732  }
1733  Color aColor = rItem.GetColor();
1734  m_xUnderlineColorLB->SelectEntry(aColor);
1735  }
1736  else
1737  {
1738  m_xUnderlineColorLB->SelectEntry(COL_AUTO);
1739  m_xUnderlineColorLB->set_sensitive(false);
1740  }
1741  }
1742  }
1743 
1744  // Overline
1745  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
1746  rFont.SetOverline( LINESTYLE_NONE );
1747  rCJKFont.SetOverline( LINESTYLE_NONE );
1748  rCTLFont.SetOverline( LINESTYLE_NONE );
1749 
1750  m_xOverlineLB->set_active( 0 );
1751  eState = rSet->GetItemState( nWhich );
1752 
1753  if ( eState >= SfxItemState::DONTCARE )
1754  {
1755  if ( eState == SfxItemState::DONTCARE )
1756  m_xOverlineLB->set_active(-1);
1757  else
1758  {
1759  const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>(rSet->Get( nWhich ));
1760  FontLineStyle eOverline = rItem.GetValue();
1761  rFont.SetOverline( eOverline );
1762  rCJKFont.SetOverline( eOverline );
1763  rCTLFont.SetOverline( eOverline );
1764 
1765  if ( eOverline != LINESTYLE_NONE )
1766  {
1767  auto nPos = m_xOverlineLB->find_id(OUString::number(eOverline));
1768  if (nPos != -1)
1769  {
1770  m_xOverlineLB->set_active(nPos);
1771  bEnable = true;
1772  }
1773  Color aColor = rItem.GetColor();
1774  m_xOverlineColorLB->SelectEntry(aColor);
1775  }
1776  else
1777  {
1778  m_xOverlineColorLB->SelectEntry(COL_AUTO);
1779  m_xOverlineColorLB->set_sensitive(false);
1780  }
1781  }
1782  }
1783 
1784  // Strikeout
1785  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
1786  rFont.SetStrikeout( STRIKEOUT_NONE );
1787  rCJKFont.SetStrikeout( STRIKEOUT_NONE );
1788  rCTLFont.SetStrikeout( STRIKEOUT_NONE );
1789 
1790  m_xStrikeoutLB->set_active( 0 );
1791  eState = rSet->GetItemState( nWhich );
1792 
1793  if ( eState >= SfxItemState::DONTCARE )
1794  {
1795  if ( eState == SfxItemState::DONTCARE )
1796  m_xStrikeoutLB->set_active(-1);
1797  else
1798  {
1799  const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>(rSet->Get( nWhich ));
1800  FontStrikeout eStrikeout = rItem.GetValue();
1801  rFont.SetStrikeout( eStrikeout );
1802  rCJKFont.SetStrikeout( eStrikeout );
1803  rCTLFont.SetStrikeout( eStrikeout );
1804 
1805  if ( eStrikeout != STRIKEOUT_NONE )
1806  {
1807  auto nPos = m_xStrikeoutLB->find_id(OUString::number(eStrikeout));
1808  if (nPos != -1)
1809  {
1810  m_xStrikeoutLB->set_active(nPos);
1811  bEnable = true;
1812  }
1813  }
1814  }
1815  }
1816 
1817  // WordLineMode
1818  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
1819  eState = rSet->GetItemState( nWhich );
1820 
1821  switch ( eState )
1822  {
1823  case SfxItemState::UNKNOWN:
1824  m_xIndividualWordsBtn->hide();
1825  break;
1826 
1827  case SfxItemState::DISABLED:
1828  case SfxItemState::READONLY:
1829  m_xIndividualWordsBtn->set_sensitive(false);
1830  break;
1831 
1832  case SfxItemState::DONTCARE:
1833  m_xIndividualWordsBtn->set_state( TRISTATE_INDET );
1834  break;
1835 
1836  case SfxItemState::DEFAULT:
1837  case SfxItemState::SET:
1838  {
1839  const SvxWordLineModeItem& rItem = static_cast<const SvxWordLineModeItem&>(rSet->Get( nWhich ));
1840  rFont.SetWordLineMode( rItem.GetValue() );
1841  rCJKFont.SetWordLineMode( rItem.GetValue() );
1842  rCTLFont.SetWordLineMode( rItem.GetValue() );
1843 
1844  m_xIndividualWordsBtn->set_active(rItem.GetValue());
1845  m_xIndividualWordsBtn->set_sensitive(bEnable);
1846  break;
1847  }
1848  }
1849 
1850  // Emphasis
1851  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
1852  eState = rSet->GetItemState( nWhich );
1853 
1854  if ( eState >= SfxItemState::DEFAULT )
1855  {
1856  const SvxEmphasisMarkItem& rItem = static_cast<const SvxEmphasisMarkItem&>(rSet->Get( nWhich ));
1857  FontEmphasisMark eMark = rItem.GetEmphasisMark();
1858  rFont.SetEmphasisMark( eMark );
1859  rCJKFont.SetEmphasisMark( eMark );
1860  rCTLFont.SetEmphasisMark( eMark );
1861 
1862  m_xEmphasisLB->set_active( static_cast<sal_Int32>(FontEmphasisMark( eMark & FontEmphasisMark::Style )) );
1863  eMark &= ~FontEmphasisMark::Style;
1864  int nEntryData = ( eMark == FontEmphasisMark::PosAbove )
1866  : ( eMark == FontEmphasisMark::PosBelow ) ? CHRDLG_POSITION_UNDER : 0;
1867 
1868  auto nPos = m_xPositionLB->find_id(OUString::number(nEntryData));
1869  if (nPos != -1)
1870  m_xPositionLB->set_active(nPos);
1871  }
1872  else if ( eState == SfxItemState::DONTCARE )
1873  m_xEmphasisLB->set_active(-1);
1874  else if ( eState == SfxItemState::UNKNOWN )
1875  {
1876  m_xEmphasisFT->hide();
1877  m_xEmphasisLB->hide();
1878  }
1879  else // SfxItemState::DISABLED or SfxItemState::READONLY
1880  {
1881  m_xEmphasisFT->set_sensitive(false);
1882  m_xEmphasisLB->set_sensitive(false);
1883  }
1884 
1885  // the select handler for the underline/overline/strikeout list boxes
1887 
1888  // the select handler for the emphasis listbox
1890 
1891  // Effects
1892  SvxCaseMap eCaseMap = SvxCaseMap::End;
1893  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
1894  eState = rSet->GetItemState( nWhich );
1895  switch ( eState )
1896  {
1897  case SfxItemState::UNKNOWN:
1898  m_xEffectsFT->hide();
1899  m_xEffectsLB->hide();
1900  break;
1901 
1902  case SfxItemState::DISABLED:
1903  case SfxItemState::READONLY:
1904  m_xEffectsFT->set_sensitive(false);
1905  m_xEffectsLB->set_sensitive(false);
1906  break;
1907 
1908  case SfxItemState::DONTCARE:
1909  m_xEffectsLB->set_active(-1);
1910  break;
1911 
1912  case SfxItemState::DEFAULT:
1913  case SfxItemState::SET:
1914  {
1915  const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>(rSet->Get( nWhich ));
1916  eCaseMap = rItem.GetValue();
1917  break;
1918  }
1919  }
1920  SetCaseMap_Impl( eCaseMap );
1921 
1922  //Relief
1923  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
1924  eState = rSet->GetItemState( nWhich );
1925  switch ( eState )
1926  {
1927  case SfxItemState::UNKNOWN:
1928  m_xReliefFT->hide();
1929  m_xReliefLB->hide();
1930  break;
1931 
1932  case SfxItemState::DISABLED:
1933  case SfxItemState::READONLY:
1934  m_xReliefFT->set_sensitive(false);
1935  m_xReliefLB->set_sensitive(false);
1936  break;
1937 
1938  case SfxItemState::DONTCARE:
1939  m_xReliefLB->set_active(-1);
1940  break;
1941 
1942  case SfxItemState::DEFAULT:
1943  case SfxItemState::SET:
1944  {
1945  const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>(rSet->Get( nWhich ));
1946  m_xReliefLB->set_active(static_cast<sal_Int32>(rItem.GetValue()));
1947  SelectHdl_Impl(m_xReliefLB.get());
1948  break;
1949  }
1950  }
1951 
1952  // Outline
1953  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
1954  eState = rSet->GetItemState( nWhich );
1955  switch ( eState )
1956  {
1957  case SfxItemState::UNKNOWN:
1958  m_xOutlineBtn->hide();
1959  break;
1960 
1961  case SfxItemState::DISABLED:
1962  case SfxItemState::READONLY:
1963  m_xOutlineBtn->set_sensitive(false);
1964  break;
1965 
1966  case SfxItemState::DONTCARE:
1967  m_xOutlineBtn->set_state(TRISTATE_INDET);
1968  break;
1969 
1970  case SfxItemState::DEFAULT:
1971  case SfxItemState::SET:
1972  {
1973  const SvxContourItem& rItem = static_cast<const SvxContourItem&>(rSet->Get( nWhich ));
1974  m_xOutlineBtn->set_state(static_cast<TriState>(rItem.GetValue()));
1975  break;
1976  }
1977  }
1978 
1979  // Shadow
1980  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
1981  eState = rSet->GetItemState( nWhich );
1982 
1983  switch ( eState )
1984  {
1985  case SfxItemState::UNKNOWN:
1986  m_xShadowBtn->hide();
1987  break;
1988 
1989  case SfxItemState::DISABLED:
1990  case SfxItemState::READONLY:
1991  m_xShadowBtn->set_sensitive(false);
1992  break;
1993 
1994  case SfxItemState::DONTCARE:
1995  m_xShadowBtn->set_state( TRISTATE_INDET );
1996  break;
1997 
1998  case SfxItemState::DEFAULT:
1999  case SfxItemState::SET:
2000  {
2001  const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>(rSet->Get( nWhich ));
2002  m_xShadowBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
2003  break;
2004  }
2005  }
2006 
2007  // Blinking
2008  nWhich = GetWhich( SID_ATTR_FLASH );
2009  eState = rSet->GetItemState( nWhich );
2010 
2011  switch ( eState )
2012  {
2013  case SfxItemState::UNKNOWN:
2014  m_xBlinkingBtn->hide();
2015  break;
2016 
2017  case SfxItemState::DISABLED:
2018  case SfxItemState::READONLY:
2019  m_xBlinkingBtn->set_sensitive(false);
2020  break;
2021 
2022  case SfxItemState::DONTCARE:
2023  m_xBlinkingBtn->set_state( TRISTATE_INDET );
2024  break;
2025 
2026  case SfxItemState::DEFAULT:
2027  case SfxItemState::SET:
2028  {
2029  const SvxBlinkItem& rItem = static_cast<const SvxBlinkItem&>(rSet->Get( nWhich ));
2030  m_xBlinkingBtn->set_state( static_cast<TriState>(rItem.GetValue()) );
2031  break;
2032  }
2033  }
2034  // Hidden
2035  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2036  eState = rSet->GetItemState( nWhich );
2037 
2038  switch ( eState )
2039  {
2040  case SfxItemState::UNKNOWN:
2041  m_xHiddenBtn->hide();
2042  break;
2043 
2044  case SfxItemState::DISABLED:
2045  case SfxItemState::READONLY:
2046  m_xHiddenBtn->set_sensitive(false);
2047  break;
2048 
2049  case SfxItemState::DONTCARE:
2050  m_xHiddenBtn->set_state(TRISTATE_INDET);
2051  break;
2052 
2053  case SfxItemState::DEFAULT:
2054  case SfxItemState::SET:
2055  {
2056  const SvxCharHiddenItem& rItem = static_cast<const SvxCharHiddenItem&>(rSet->Get( nWhich ));
2057  m_xHiddenBtn->set_state(static_cast<TriState>(rItem.GetValue()));
2058  break;
2059  }
2060  }
2061 
2062  SetPrevFontWidthScale( *rSet );
2063  ResetColor_Impl( *rSet );
2064 
2065  // preview update
2066  m_aPreviewWin.Invalidate();
2067 
2068  // save this settings
2069  ChangesApplied();
2070 }
2071 
2073 {
2074  m_xUnderlineLB->save_value();
2075  m_xOverlineLB->save_value();
2076  m_xStrikeoutLB->save_value();
2077  m_xIndividualWordsBtn->save_state();
2078  m_xEmphasisLB->save_value();
2079  m_xPositionLB->save_value();
2080  m_xEffectsLB->save_value();
2081  m_xReliefLB->save_value();
2082  m_xOutlineBtn->save_state();
2083  m_xShadowBtn->save_state();
2084  m_xBlinkingBtn->save_state();
2085  m_xHiddenBtn->save_state();
2086  m_xFontTransparencyMtr->save_value();
2087 }
2088 
2090 {
2091  const SfxPoolItem* pOld = nullptr;
2092  const SfxItemSet& rOldSet = GetItemSet();
2093  bool bModified = false;
2094  bool bChanged = true;
2095 
2096  // Underline
2097  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_UNDERLINE );
2098  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_UNDERLINE );
2099  auto nPos = m_xUnderlineLB->get_active();
2100  FontLineStyle eUnder = static_cast<FontLineStyle>(m_xUnderlineLB->get_active_id().toInt32());
2101 
2102  if ( pOld )
2103  {
2108  bool bAllowChg = nPos != -1 &&
2109  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2110 
2111  const SvxUnderlineItem& rItem = *static_cast<const SvxUnderlineItem*>(pOld);
2112  if ( rItem.GetValue() == eUnder &&
2113  ( LINESTYLE_NONE == eUnder || rItem.GetColor() == m_xUnderlineColorLB->GetSelectEntryColor() ) &&
2114  ! bAllowChg )
2115  bChanged = false;
2116  }
2117 
2118  if ( bChanged )
2119  {
2120  SvxUnderlineItem aNewItem( eUnder, nWhich );
2121  aNewItem.SetColor( m_xUnderlineColorLB->GetSelectEntryColor() );
2122  rSet->Put( aNewItem );
2123  bModified = true;
2124  }
2125  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2126  rSet->InvalidateItem(nWhich);
2127 
2128  bChanged = true;
2129 
2130  // Overline
2131  nWhich = GetWhich( SID_ATTR_CHAR_OVERLINE );
2132  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_OVERLINE );
2133  nPos = m_xOverlineLB->get_active();
2134  FontLineStyle eOver = static_cast<FontLineStyle>(m_xOverlineLB->get_active_id().toInt32());
2135 
2136  if ( pOld )
2137  {
2142  bool bAllowChg = nPos != -1 &&
2143  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2144 
2145  const SvxOverlineItem& rItem = *static_cast<const SvxOverlineItem*>(pOld);
2146  if ( rItem.GetValue() == eOver &&
2147  ( LINESTYLE_NONE == eOver || rItem.GetColor() == m_xOverlineColorLB->GetSelectEntryColor() ) &&
2148  ! bAllowChg )
2149  bChanged = false;
2150  }
2151 
2152  if ( bChanged )
2153  {
2154  SvxOverlineItem aNewItem( eOver, nWhich );
2155  aNewItem.SetColor( m_xOverlineColorLB->GetSelectEntryColor() );
2156  rSet->Put( aNewItem );
2157  bModified = true;
2158  }
2159  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2160  rSet->InvalidateItem(nWhich);
2161 
2162  bChanged = true;
2163 
2164  // Strikeout
2165  nWhich = GetWhich( SID_ATTR_CHAR_STRIKEOUT );
2166  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_STRIKEOUT );
2167  nPos = m_xStrikeoutLB->get_active();
2168  FontStrikeout eStrike = static_cast<FontStrikeout>(m_xStrikeoutLB->get_active_id().toInt32());
2169 
2170  if ( pOld )
2171  {
2176  bool bAllowChg = nPos != -1 &&
2177  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2178 
2179  const SvxCrossedOutItem& rItem = *static_cast<const SvxCrossedOutItem*>(pOld);
2180  if ( !m_xStrikeoutLB->get_sensitive()
2181  || (rItem.GetValue() == eStrike && !bAllowChg) )
2182  bChanged = false;
2183  }
2184 
2185  if ( bChanged )
2186  {
2187  rSet->Put( SvxCrossedOutItem( eStrike, nWhich ) );
2188  bModified = true;
2189  }
2190  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2191  rSet->InvalidateItem(nWhich);
2192 
2193  bChanged = true;
2194 
2195  // Individual words
2196  nWhich = GetWhich( SID_ATTR_CHAR_WORDLINEMODE );
2197  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_WORDLINEMODE );
2198 
2199  if ( pOld )
2200  {
2201  const SvxWordLineModeItem& rItem = *static_cast<const SvxWordLineModeItem*>(pOld);
2202  if ( rItem.GetValue() == m_xIndividualWordsBtn->get_active() )
2203  bChanged = false;
2204  }
2205 
2206  if ( rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
2207  ! m_xIndividualWordsBtn->get_state_changed_from_saved() )
2208  bChanged = false;
2209 
2210  if ( bChanged )
2211  {
2212  rSet->Put( SvxWordLineModeItem( m_xIndividualWordsBtn->get_active(), nWhich ) );
2213  bModified = true;
2214  }
2215  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2216  rSet->InvalidateItem(nWhich);
2217 
2218  bChanged = true;
2219 
2220  // Emphasis
2221  nWhich = GetWhich( SID_ATTR_CHAR_EMPHASISMARK );
2222  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_EMPHASISMARK );
2223  int nMarkPos = m_xEmphasisLB->get_active();
2224  OUString sMarkPos = m_xEmphasisLB->get_active_text();
2225  OUString sPosPos = m_xPositionLB->get_active_text();
2226  FontEmphasisMark eMark = static_cast<FontEmphasisMark>(nMarkPos);
2227  if (m_xPositionLB->get_sensitive())
2228  {
2229  eMark |= (CHRDLG_POSITION_UNDER == m_xPositionLB->get_active_id().toInt32())
2230  ? FontEmphasisMark::PosBelow : FontEmphasisMark::PosAbove;
2231  }
2232 
2233  if ( pOld )
2234  {
2235  if( rOldSet.GetItemState( nWhich ) != SfxItemState::DONTCARE )
2236  {
2237  const SvxEmphasisMarkItem& rItem = *static_cast<const SvxEmphasisMarkItem*>(pOld);
2238  if ( rItem.GetEmphasisMark() == eMark )
2239  bChanged = false;
2240  }
2241  }
2242 
2243  if (rOldSet.GetItemState( nWhich ) == SfxItemState::DONTCARE &&
2244  m_xEmphasisLB->get_saved_value() == sMarkPos && m_xPositionLB->get_saved_value() == sPosPos)
2245  {
2246  bChanged = false;
2247  }
2248 
2249  if (bChanged)
2250  {
2251  rSet->Put( SvxEmphasisMarkItem( eMark, nWhich ) );
2252  bModified = true;
2253  }
2254  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2255  rSet->InvalidateItem(nWhich);
2256 
2257  bChanged = true;
2258 
2259  // Effects
2260  nWhich = GetWhich( SID_ATTR_CHAR_CASEMAP );
2261  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CASEMAP );
2262  SvxCaseMap eCaseMap = SvxCaseMap::NotMapped;
2263  bool bChecked = false;
2264  auto nCapsPos = m_xEffectsLB->get_active();
2265  if (nCapsPos != -1)
2266  {
2267  eCaseMap = static_cast<SvxCaseMap>(nCapsPos);
2268  bChecked = true;
2269  }
2270 
2271  if ( pOld )
2272  {
2277  bool bAllowChg = nPos != -1 &&
2278  SfxItemState::DEFAULT > rOldSet.GetItemState( nWhich );
2279 
2280  const SvxCaseMapItem& rItem = *static_cast<const SvxCaseMapItem*>(pOld);
2281  if ( rItem.GetValue() == eCaseMap && !bAllowChg )
2282  bChanged = false;
2283  }
2284 
2285  if ( bChanged && bChecked )
2286  {
2287  rSet->Put( SvxCaseMapItem( eCaseMap, nWhich ) );
2288  bModified = true;
2289  }
2290  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2291  rSet->InvalidateItem(nWhich);
2292 
2293  bChanged = true;
2294 
2295  //Relief
2296  nWhich = GetWhich(SID_ATTR_CHAR_RELIEF);
2297  if (m_xReliefLB->get_value_changed_from_saved())
2298  {
2299  m_xReliefLB->save_value();
2300  SvxCharReliefItem aRelief(static_cast<FontRelief>(m_xReliefLB->get_active()), nWhich);
2301  rSet->Put(aRelief);
2302  }
2303 
2304  // Outline
2305  const SfxItemSet* pExampleSet = GetDialogExampleSet();
2306  nWhich = GetWhich( SID_ATTR_CHAR_CONTOUR );
2307  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_CONTOUR );
2308  TriState eState = m_xOutlineBtn->get_state();
2309  const SfxPoolItem* pItem;
2310 
2311  if ( pOld )
2312  {
2313  const SvxContourItem& rItem = *static_cast<const SvxContourItem*>(pOld);
2314  if ( rItem.GetValue() == StateToAttr( eState ) && m_xOutlineBtn->get_saved_state() == eState )
2315  bChanged = false;
2316  }
2317 
2318  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2319  !StateToAttr( eState ) && static_cast<const SvxContourItem*>(pItem)->GetValue() )
2320  bChanged = true;
2321 
2322  if ( bChanged && eState != TRISTATE_INDET )
2323  {
2324  rSet->Put( SvxContourItem( StateToAttr( eState ), nWhich ) );
2325  bModified = true;
2326  }
2327  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2328  rSet->InvalidateItem(nWhich);
2329 
2330  bChanged = true;
2331 
2332  // Shadow
2333  nWhich = GetWhich( SID_ATTR_CHAR_SHADOWED );
2334  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_SHADOWED );
2335  eState = m_xShadowBtn->get_state();
2336 
2337  if ( pOld )
2338  {
2339  const SvxShadowedItem& rItem = *static_cast<const SvxShadowedItem*>(pOld);
2340  if ( rItem.GetValue() == StateToAttr( eState ) && m_xShadowBtn->get_saved_state() == eState )
2341  bChanged = false;
2342  }
2343 
2344  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2345  !StateToAttr( eState ) && static_cast<const SvxShadowedItem*>(pItem)->GetValue() )
2346  bChanged = true;
2347 
2348  if ( bChanged && eState != TRISTATE_INDET )
2349  {
2350  rSet->Put( SvxShadowedItem( StateToAttr( eState ), nWhich ) );
2351  bModified = true;
2352  }
2353  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2354  rSet->InvalidateItem(nWhich);
2355 
2356  bChanged = true;
2357 
2358  // Blinking
2359  nWhich = GetWhich( SID_ATTR_FLASH );
2360  pOld = GetOldItem( *rSet, SID_ATTR_FLASH );
2361  eState = m_xBlinkingBtn->get_state();
2362 
2363  if ( pOld )
2364  {
2365  const SvxBlinkItem& rItem = *static_cast<const SvxBlinkItem*>(pOld);
2366  if ( rItem.GetValue() == StateToAttr( eState ) && m_xBlinkingBtn->get_saved_state() == eState )
2367  bChanged = false;
2368  }
2369 
2370  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2371  !StateToAttr( eState ) && static_cast<const SvxBlinkItem*>(pItem)->GetValue() )
2372  bChanged = true;
2373 
2374  if ( bChanged && eState != TRISTATE_INDET )
2375  {
2376  rSet->Put( SvxBlinkItem( StateToAttr( eState ), nWhich ) );
2377  bModified = true;
2378  }
2379  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2380  rSet->InvalidateItem(nWhich);
2381 
2382  // Hidden
2383  nWhich = GetWhich( SID_ATTR_CHAR_HIDDEN );
2384  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_HIDDEN );
2385  eState = m_xHiddenBtn->get_state();
2386  bChanged = true;
2387 
2388  if ( pOld )
2389  {
2390  const SvxCharHiddenItem& rItem = *static_cast<const SvxCharHiddenItem*>(pOld);
2391  if ( rItem.GetValue() == StateToAttr( eState ) && m_xHiddenBtn->get_saved_state() == eState )
2392  bChanged = false;
2393  }
2394 
2395  if ( !bChanged && pExampleSet && pExampleSet->GetItemState( nWhich, false, &pItem ) == SfxItemState::SET &&
2396  !StateToAttr( eState ) && static_cast<const SvxCharHiddenItem*>(pItem)->GetValue() )
2397  bChanged = true;
2398 
2399  if ( bChanged && eState != TRISTATE_INDET )
2400  {
2401  rSet->Put( SvxCharHiddenItem( StateToAttr( eState ), nWhich ) );
2402  bModified = true;
2403  }
2404  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2405  rSet->InvalidateItem(nWhich);
2406 
2407  bModified |= FillItemSetColor_Impl( *rSet );
2408 
2409  return bModified;
2410 }
2411 
2412 void SvxCharEffectsPage::DisableControls( sal_uInt16 nDisable )
2413 {
2414  if ( ( DISABLE_CASEMAP & nDisable ) == DISABLE_CASEMAP )
2415  {
2416  m_xEffectsFT->set_sensitive(false);
2417  m_xEffectsLB->set_sensitive(false);
2418  }
2419 
2420  if ( ( DISABLE_WORDLINE & nDisable ) == DISABLE_WORDLINE )
2421  m_xIndividualWordsBtn->set_sensitive(false);
2422 
2423  if ( ( DISABLE_BLINK & nDisable ) == DISABLE_BLINK )
2424  m_xBlinkingBtn->set_sensitive(false);
2425 
2426  if ( ( DISABLE_UNDERLINE_COLOR & nDisable ) == DISABLE_UNDERLINE_COLOR )
2427  {
2428  // disable the controls
2429  m_xUnderlineColorFT->set_sensitive(false);
2430  m_xUnderlineColorLB->set_sensitive(false);
2432  }
2433 }
2434 
2436 {
2437  const SfxUInt16Item* pDisableCtlItem = aSet.GetItem<SfxUInt16Item>(SID_DISABLE_CTL, false);
2438  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
2439  if (pDisableCtlItem)
2440  DisableControls(pDisableCtlItem->GetValue());
2441 
2442  if (pFlagItem)
2443  {
2444  sal_uInt32 nFlags=pFlagItem->GetValue();
2445  if ( ( nFlags & SVX_ENABLE_FLASH ) == SVX_ENABLE_FLASH )
2446  m_xBlinkingBtn->show();
2447  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
2448  // the writer uses SID_ATTR_BRUSH as font background
2450  if ((nFlags & SVX_ENABLE_CHAR_TRANSPARENCY) != SVX_ENABLE_CHAR_TRANSPARENCY)
2451  {
2452  // Only show these in case client code explicitly wants this.
2453  m_xFontTransparencyFT->hide();
2454  m_xFontTransparencyMtr->hide();
2455  }
2456  }
2457 }
2458 
2459 // class SvxCharPositionPage ---------------------------------------------
2460 
2462  : SvxCharBasePage(pPage, pController, "cui/ui/positionpage.ui", "PositionPage", rInSet)
2463  , m_nSuperEsc(short(DFLT_ESC_SUPER))
2464  , m_nSubEsc(short(DFLT_ESC_SUB))
2465  , m_nScaleWidthItemSetVal(100)
2466  , m_nScaleWidthInitialVal(100)
2467  , m_nSuperProp(sal_uInt8(DFLT_ESC_PROP))
2468  , m_nSubProp(sal_uInt8(DFLT_ESC_PROP))
2469  , m_xHighPosBtn(m_xBuilder->weld_radio_button("superscript"))
2470  , m_xNormalPosBtn(m_xBuilder->weld_radio_button("normal"))
2471  , m_xLowPosBtn(m_xBuilder->weld_radio_button("subscript"))
2472  , m_xHighLowFT(m_xBuilder->weld_label("raiselower"))
2473  , m_xHighLowMF(m_xBuilder->weld_metric_spin_button("raiselowersb", FieldUnit::PERCENT))
2474  , m_xHighLowRB(m_xBuilder->weld_check_button("automatic"))
2475  , m_xFontSizeFT(m_xBuilder->weld_label("relativefontsize"))
2476  , m_xFontSizeMF(m_xBuilder->weld_metric_spin_button("fontsizesb", FieldUnit::PERCENT))
2477  , m_xRotationContainer(m_xBuilder->weld_widget("rotationcontainer"))
2478  , m_xScalingFT(m_xBuilder->weld_label("scale"))
2479  , m_xScalingAndRotationFT(m_xBuilder->weld_label("rotateandscale"))
2480  , m_x0degRB(m_xBuilder->weld_radio_button("0deg"))
2481  , m_x90degRB(m_xBuilder->weld_radio_button("90deg"))
2482  , m_x270degRB(m_xBuilder->weld_radio_button("270deg"))
2483  , m_xFitToLineCB(m_xBuilder->weld_check_button("fittoline"))
2484  , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FieldUnit::PERCENT))
2485  , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FieldUnit::POINT))
2486  , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning"))
2487 {
2488  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
2489 #ifdef IOS
2490  m_xPreviewWin->hide();
2491 #endif
2492  Initialize();
2493 }
2494 
2496 {
2497 }
2498 
2499 
2501 {
2502  // to handle the changes of the other pages
2504 
2505  GetPreviewFont().SetFontSize( Size( 0, 240 ) );
2506  GetPreviewCJKFont().SetFontSize( Size( 0, 240 ) );
2507  GetPreviewCTLFont().SetFontSize( Size( 0, 240 ) );
2508 
2509  m_xNormalPosBtn->set_active(true);
2510  PositionHdl_Impl(*m_xNormalPosBtn);
2511 
2512  Link<weld::ToggleButton&,void> aLink2 = LINK(this, SvxCharPositionPage, PositionHdl_Impl);
2513  m_xHighPosBtn->connect_toggled(aLink2);
2514  m_xNormalPosBtn->connect_toggled(aLink2);
2515  m_xLowPosBtn->connect_toggled(aLink2);
2516 
2517  aLink2 = LINK( this, SvxCharPositionPage, RotationHdl_Impl );
2518  m_x0degRB->connect_toggled(aLink2);
2519  m_x90degRB->connect_toggled(aLink2);
2520  m_x270degRB->connect_toggled(aLink2);
2521 
2522  Link<weld::MetricSpinButton&,void> aLink3 = LINK(this, SvxCharPositionPage, ValueChangedHdl_Impl);
2523  m_xHighLowMF->connect_value_changed(aLink3);
2524  m_xFontSizeMF->connect_value_changed(aLink3);
2525 
2526  m_xHighLowRB->connect_toggled(LINK(this, SvxCharPositionPage, AutoPositionHdl_Impl));
2527  m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl));
2528  m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl));
2529  m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl));
2530 }
2531 
2533 {
2534  SetPrevFontEscapement( nProp, nEscProp, nEsc );
2535 }
2536 
2537 
2539 {
2540  SvxEscapementItem aEscItm( nEsc, SID_ATTR_CHAR_ESCAPEMENT );
2541 
2542  if ( SvxEscapement::Superscript == nEsc )
2543  {
2544  aEscItm.GetEsc() = m_nSuperEsc;
2545  aEscItm.GetProportionalHeight() = m_nSuperProp;
2546  }
2547  else if ( SvxEscapement::Subscript == nEsc )
2548  {
2549  aEscItm.GetEsc() = m_nSubEsc;
2550  aEscItm.GetProportionalHeight() = m_nSubProp;
2551  }
2552 
2553  short nFac = aEscItm.GetEsc() < 0 ? -1 : 1;
2554 
2555  m_xHighLowMF->set_value(aEscItm.GetEsc() * nFac, FieldUnit::PERCENT);
2556  m_xFontSizeMF->set_value(aEscItm.GetProportionalHeight(), FieldUnit::PERCENT);
2557 
2558  if ( SvxEscapement::Off == nEsc )
2559  {
2560  m_xHighLowFT->set_sensitive(false);
2561  m_xHighLowMF->set_sensitive(false);
2562  m_xFontSizeFT->set_sensitive(false);
2563  m_xFontSizeMF->set_sensitive(false);
2564  m_xHighLowRB->set_sensitive(false);
2565  }
2566  else
2567  {
2568  m_xFontSizeFT->set_sensitive(true);
2569  m_xFontSizeMF->set_sensitive(true);
2570  m_xHighLowRB->set_sensitive(true);
2571 
2572  if (!m_xHighLowRB->get_active())
2573  {
2574  m_xHighLowFT->set_sensitive(true);
2575  m_xHighLowMF->set_sensitive(true);
2576  }
2577  else
2578  AutoPositionHdl_Impl(*m_xHighLowRB);
2579  }
2580 
2581  UpdatePreview_Impl( 100, aEscItm.GetProportionalHeight(), aEscItm.GetEsc() );
2582 }
2583 
2584 
2586 {
2587  SvxEscapement nEsc = SvxEscapement::Off; // also when pBtn == NULL
2588 
2589  if (m_xHighPosBtn->get_active())
2590  nEsc = SvxEscapement::Superscript;
2591  else if (m_xLowPosBtn->get_active())
2592  nEsc = SvxEscapement::Subscript;
2593 
2594  SetEscapement_Impl( nEsc );
2595 }
2596 
2598 {
2599  bool bEnable = false;
2600  if (m_x90degRB->get_active() || m_x270degRB->get_active())
2601  bEnable = true;
2602  else
2603  OSL_ENSURE(m_x0degRB->get_active(), "unexpected button");
2604  m_xFitToLineCB->set_sensitive(bEnable);
2605 }
2606 
2608 {
2609  sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2610  short nEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2611  nEsc *= m_xLowPosBtn->get_active() ? -1 : 1;
2612  UpdatePreview_Impl( 100, nEscProp, nEsc );
2613 }
2614 
2615 IMPL_LINK(SvxCharPositionPage, AutoPositionHdl_Impl, weld::ToggleButton&, rBox, void)
2616 {
2617  if (rBox.get_active())
2618  {
2619  m_xHighLowFT->set_sensitive(false);
2620  m_xHighLowMF->set_sensitive(false);
2621  }
2622  else
2623  PositionHdl_Impl(m_xHighPosBtn->get_active() ? *m_xHighPosBtn
2624  : m_xLowPosBtn->get_active() ? *m_xLowPosBtn
2625  : *m_xNormalPosBtn);
2626 }
2627 
2629 {
2630  sal_uInt16 nVal = m_nScaleWidthInitialVal;
2631  if (m_xFitToLineCB->get_active())
2632  nVal = m_nScaleWidthItemSetVal;
2633  m_xScaleWidthMF->set_value(nVal, FieldUnit::PERCENT);
2634  m_aPreviewWin.SetFontWidthScale( nVal );
2635 }
2636 
2638 {
2639  long nVal = static_cast<long>(m_xKerningMF->get_value(FieldUnit::POINT));
2640  nVal = OutputDevice::LogicToLogic( nVal, MapUnit::MapPoint, MapUnit::MapTwip );
2641  long nKern = static_cast<short>(m_xKerningMF->denormalize(nVal));
2642 
2643  SvxFont& rFont = GetPreviewFont();
2644  SvxFont& rCJKFont = GetPreviewCJKFont();
2645  SvxFont& rCTLFont = GetPreviewCTLFont();
2646 
2647  rFont.SetFixKerning( static_cast<short>(nKern) );
2648  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2649  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2650  m_aPreviewWin.Invalidate();
2651 }
2652 
2653 IMPL_LINK(SvxCharPositionPage, ValueChangedHdl_Impl, weld::MetricSpinButton&, rField, void)
2654 {
2655  bool bHigh = m_xHighPosBtn->get_active();
2656  bool bLow = m_xLowPosBtn->get_active();
2657  DBG_ASSERT( bHigh || bLow, "normal position is not valid" );
2658 
2659  if (m_xHighLowMF.get() == &rField)
2660  {
2661  if ( bLow )
2662  m_nSubEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT)) * -1;
2663  else
2664  m_nSuperEsc = static_cast<short>(m_xHighLowMF->get_value(FieldUnit::PERCENT));
2665  }
2666  else if (m_xFontSizeMF.get() == &rField)
2667  {
2668  if ( bLow )
2669  m_nSubProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2670  else
2671  m_nSuperProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FieldUnit::PERCENT));
2672  }
2673 
2674  FontModifyHdl_Impl();
2675 }
2676 
2678 {
2679  m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)));
2680 }
2681 
2683 {
2684  if ( _pSet )
2685  FillItemSet( _pSet );
2686  return DeactivateRC::LeavePage;
2687 }
2688 
2689 std::unique_ptr<SfxTabPage> SvxCharPositionPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
2690 {
2691  return std::make_unique<SvxCharPositionPage>(pPage, pController, *rSet);
2692 }
2693 
2695 {
2696  OUString sUser = GetUserData();
2697 
2698  if ( !sUser.isEmpty() )
2699  {
2700  sal_Int32 nIdx {0};
2701  m_nSuperEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2702  m_nSubEsc = static_cast<short>(sUser.getToken( 0, ';', nIdx ).toInt32());
2703  m_nSuperProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2704  m_nSubProp = static_cast<sal_uInt8>(sUser.getToken( 0, ';', nIdx ).toInt32());
2705 
2706  m_xHighLowMF->set_max(MAX_ESC_POS, FieldUnit::PERCENT);
2707 
2708  //fdo#75307 validate all the entries and discard all of them if any are
2709  //out of range
2710  bool bValid = true;
2711  if (m_nSuperEsc < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSuperEsc > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2712  bValid = false;
2713  if (m_nSubEsc*-1 < m_xHighLowMF->get_min(FieldUnit::PERCENT) || m_nSubEsc*-1 > m_xHighLowMF->get_max(FieldUnit::PERCENT))
2714  bValid = false;
2715  if (m_nSuperProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSuperProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2716  bValid = false;
2717  if (m_nSubProp < m_xFontSizeMF->get_min(FieldUnit::PERCENT) || m_nSubProp > m_xFontSizeMF->get_max(FieldUnit::PERCENT))
2718  bValid = false;
2719 
2720  if (!bValid)
2721  {
2726  }
2727  }
2728 
2729  short nEsc = 0;
2730  sal_uInt8 nEscProp = 100;
2731 
2732  m_xHighLowFT->set_sensitive(false);
2733  m_xHighLowMF->set_sensitive(false);
2734  m_xFontSizeFT->set_sensitive(false);
2735  m_xFontSizeMF->set_sensitive(false);
2736 
2737  SvxFont& rFont = GetPreviewFont();
2738  SvxFont& rCJKFont = GetPreviewCJKFont();
2739  SvxFont& rCTLFont = GetPreviewCTLFont();
2740  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2741 
2742  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2743  {
2744  const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>(rSet->Get( nWhich ));
2745  nEsc = rItem.GetEsc();
2746  nEscProp = rItem.GetProportionalHeight();
2747 
2748  if ( nEsc != 0 )
2749  {
2750  m_xHighLowFT->set_sensitive(true);
2751  m_xHighLowMF->set_sensitive(true);
2752  m_xFontSizeFT->set_sensitive(true);
2753  m_xFontSizeMF->set_sensitive(true);
2754 
2755  short nFac;
2756  bool bAutomatic(false);
2757 
2758  if ( nEsc > 0 )
2759  {
2760  nFac = 1;
2761  m_xHighPosBtn->set_active(true);
2762  if ( nEsc == DFLT_ESC_AUTO_SUPER )
2763  {
2764  nEsc = DFLT_ESC_SUPER;
2765  bAutomatic = true;
2766  }
2767  }
2768  else
2769  {
2770  nFac = -1;
2771  m_xLowPosBtn->set_active(true);
2772  if ( nEsc == DFLT_ESC_AUTO_SUB )
2773  {
2774  nEsc = DFLT_ESC_SUB;
2775  bAutomatic = true;
2776  }
2777  }
2778  if (!m_xHighLowRB->get_sensitive())
2779  {
2780  m_xHighLowRB->set_sensitive(true);
2781  }
2782  m_xHighLowRB->set_active(bAutomatic);
2783 
2784  if (m_xHighLowRB->get_active())
2785  {
2786  m_xHighLowFT->set_sensitive(false);
2787  m_xHighLowMF->set_sensitive(false);
2788  }
2789  m_xHighLowMF->set_value(m_xHighLowMF->normalize(nFac * nEsc), FieldUnit::PERCENT);
2790  }
2791  else
2792  {
2793  m_xNormalPosBtn->set_active(true);
2794  m_xHighLowRB->set_active(true);
2795  PositionHdl_Impl(*m_xNormalPosBtn);
2796  }
2797  //the height has to be set after the handler is called to keep the value also if the escapement is zero
2798  m_xFontSizeMF->set_value(m_xFontSizeMF->normalize(nEscProp), FieldUnit::PERCENT);
2799  }
2800  else
2801  {
2802  m_xHighPosBtn->set_active(false);
2803  m_xNormalPosBtn->set_active(false);
2804  m_xLowPosBtn->set_active(false);
2805  }
2806 
2807  // set BspFont
2808  SetPrevFontEscapement( 100, nEscProp, nEsc );
2809 
2810  // Kerning
2811  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2812 
2813  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2814  {
2815  const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>(rSet->Get( nWhich ));
2816  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2817  long nBig = static_cast<long>(m_xKerningMF->normalize( static_cast<long>(rItem.GetValue()) ));
2818  long nKerning = OutputDevice::LogicToLogic(nBig, eUnit, MapUnit::MapPoint);
2819 
2820  // set Kerning at the Font, convert into Twips before
2821  long nKern = OutputDevice::LogicToLogic(rItem.GetValue(), eUnit, MapUnit::MapTwip);
2822  rFont.SetFixKerning( static_cast<short>(nKern) );
2823  rCJKFont.SetFixKerning( static_cast<short>(nKern) );
2824  rCTLFont.SetFixKerning( static_cast<short>(nKern) );
2825 
2826  //the attribute value must be displayed also if it's above the maximum allowed value
2827  long nVal = static_cast<long>(m_xKerningMF->get_max(FieldUnit::POINT));
2828  if(nVal < nKerning)
2829  m_xKerningMF->set_max(nKerning, FieldUnit::POINT);
2830  m_xKerningMF->set_value(nKerning, FieldUnit::POINT);
2831  }
2832  else
2833  m_xKerningMF->set_text(OUString());
2834 
2835  // Pair kerning
2836  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
2837 
2838  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2839  {
2840  const SvxAutoKernItem& rItem = static_cast<const SvxAutoKernItem&>(rSet->Get( nWhich ));
2841  m_xPairKerningBtn->set_active(rItem.GetValue());
2842  }
2843  else
2844  m_xPairKerningBtn->set_active(false);
2845 
2846  // Scale Width
2847  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
2848  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2849  {
2850  const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet->Get( nWhich ) );
2851  m_nScaleWidthInitialVal = rItem.GetValue();
2852  m_xScaleWidthMF->set_value(m_nScaleWidthInitialVal, FieldUnit::PERCENT);
2853  }
2854  else
2855  m_xScaleWidthMF->set_value(100, FieldUnit::PERCENT);
2856 
2857  nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE );
2858  if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT )
2859  m_nScaleWidthItemSetVal = static_cast<const SfxUInt16Item&>( rSet->Get( nWhich )).GetValue();
2860 
2861  // Rotation
2862  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
2863  SfxItemState eState = rSet->GetItemState( nWhich );
2864  if( SfxItemState::UNKNOWN == eState )
2865  {
2866  m_xRotationContainer->hide();
2867  m_xScalingAndRotationFT->hide();
2868  m_xScalingFT->show();
2869  }
2870  else
2871  {
2872  m_xRotationContainer->show();
2873  m_xScalingAndRotationFT->show();
2874  m_xScalingFT->hide();
2875 
2876  if( eState >= SfxItemState::DEFAULT )
2877  {
2878  const SvxCharRotateItem& rItem =
2879  static_cast<const SvxCharRotateItem&>( rSet->Get( nWhich ));
2880  if (rItem.IsBottomToTop())
2881  m_x90degRB->set_active(true);
2882  else if (rItem.IsTopToBottom())
2883  m_x270degRB->set_active(true);
2884  else
2885  {
2886  DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" );
2887  m_x0degRB->set_active(true);
2888  }
2889  m_xFitToLineCB->set_active(rItem.IsFitToLine());
2890  }
2891  else
2892  {
2893  if( eState == SfxItemState::DONTCARE )
2894  {
2895  m_x0degRB->set_active(false);
2896  m_x90degRB->set_active(false);
2897  m_x270degRB->set_active(false);
2898  }
2899  else
2900  m_x0degRB->set_active(true);
2901 
2902  m_xFitToLineCB->set_active(false);
2903  }
2904  m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active());
2905 
2906  // is this value set?
2907  if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich(
2908  SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) ))
2909  m_xFitToLineCB->hide();
2910  }
2911  ChangesApplied();
2912 }
2913 
2915 {
2916  m_xHighPosBtn->save_state();
2917  m_xNormalPosBtn->save_state();
2918  m_xLowPosBtn->save_state();
2919  m_xHighLowRB->save_state();
2920  m_x0degRB->save_state();
2921  m_x90degRB->save_state();
2922  m_x270degRB->save_state();
2923  m_xFitToLineCB->save_state();
2924  m_xScaleWidthMF->save_value();
2925  m_xKerningMF->save_value();
2926  m_xPairKerningBtn->save_state();
2927 }
2928 
2930 {
2931  // Position (high, normal or low)
2932  const SfxItemSet& rOldSet = GetItemSet();
2933  bool bModified = false, bChanged = true;
2934  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT );
2935  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_ESCAPEMENT );
2936  const bool bHigh = m_xHighPosBtn->get_active();
2937  short nEsc;
2938  sal_uInt8 nEscProp;
2939 
2940  if (bHigh || m_xLowPosBtn->get_active())
2941  {
2942  if (m_xHighLowRB->get_active())
2943  nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB;
2944  else
2945  {
2946  nEsc = static_cast<short>(m_xHighLowMF->denormalize(m_xHighLowMF->get_value(FieldUnit::PERCENT)));
2947  nEsc *= (bHigh ? 1 : -1);
2948  }
2949  nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->denormalize(m_xFontSizeMF->get_value(FieldUnit::PERCENT)));
2950  }
2951  else
2952  {
2953  nEsc = 0;
2954  nEscProp = 100;
2955  }
2956 
2957  if ( pOld )
2958  {
2959  const SvxEscapementItem& rItem = *static_cast<const SvxEscapementItem*>(pOld);
2960  if (rItem.GetEsc() == nEsc && rItem.GetProportionalHeight() == nEscProp)
2961  bChanged = false;
2962  }
2963 
2964  if ( !bChanged && !m_xHighPosBtn->get_saved_state() &&
2965  !m_xNormalPosBtn->get_saved_state() && !m_xLowPosBtn->get_saved_state() )
2966  bChanged = true;
2967 
2968  if ( bChanged &&
2969  ( m_xHighPosBtn->get_active() || m_xNormalPosBtn->get_active() || m_xLowPosBtn->get_active() ) )
2970  {
2971  rSet->Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) );
2972  bModified = true;
2973  }
2974  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
2975  rSet->InvalidateItem(nWhich);
2976 
2977  bChanged = true;
2978 
2979  // Kerning
2980  nWhich = GetWhich( SID_ATTR_CHAR_KERNING );
2981  pOld = GetOldItem( *rSet, SID_ATTR_CHAR_KERNING );
2982  short nKerning = 0;
2983  MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich );
2984 
2985  long nTmp = static_cast<long>(m_xKerningMF->get_value(FieldUnit::POINT));
2986  long nVal = OutputDevice::LogicToLogic(nTmp, MapUnit::MapPoint, eUnit);
2987  nKerning = static_cast<short>(m_xKerningMF->denormalize( nVal ));
2988 
2989  SfxItemState eOldKernState = rOldSet.GetItemState( nWhich, false );
2990  if ( pOld )
2991  {
2992  const SvxKerningItem& rItem = *static_cast<const SvxKerningItem*>(pOld);
2993  if ( (eOldKernState >= SfxItemState::DEFAULT || m_xKerningMF->get_text().isEmpty()) && rItem.GetValue() == nKerning )
2994  bChanged = false;
2995  }
2996 
2997  if ( bChanged )
2998  {
2999  rSet->Put( SvxKerningItem( nKerning, nWhich ) );
3000  bModified = true;
3001  }
3002  else if ( SfxItemState::DEFAULT == eOldKernState )
3003  rSet->InvalidateItem(nWhich);
3004 
3005  // Pair-Kerning
3006  nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN );
3007 
3008  if (m_xPairKerningBtn->get_state_changed_from_saved())
3009  {
3010  rSet->Put( SvxAutoKernItem( m_xPairKerningBtn->get_active(), nWhich ) );
3011  bModified = true;
3012  }
3013  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3014  rSet->InvalidateItem(nWhich);
3015 
3016  // Scale Width
3017  nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH );
3018  if (m_xScaleWidthMF->get_value_changed_from_saved())
3019  {
3020  rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FieldUnit::PERCENT)), nWhich));
3021  bModified = true;
3022  }
3023  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3024  rSet->InvalidateItem(nWhich);
3025 
3026  // Rotation
3027  nWhich = GetWhich( SID_ATTR_CHAR_ROTATED );
3028  if ( m_x0degRB->get_state_changed_from_saved() ||
3029  m_x90degRB->get_state_changed_from_saved() ||
3030  m_x270degRB->get_state_changed_from_saved() ||
3031  m_xFitToLineCB->get_state_changed_from_saved() )
3032  {
3033  SvxCharRotateItem aItem( 0, m_xFitToLineCB->get_active(), nWhich );
3034  if (m_x90degRB->get_active())
3035  aItem.SetBottomToTop();
3036  else if (m_x270degRB->get_active())
3037  aItem.SetTopToBottom();
3038  rSet->Put( aItem );
3039  bModified = true;
3040  }
3041  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3042  rSet->InvalidateItem(nWhich);
3043 
3044  return bModified;
3045 }
3046 
3047 
3049 {
3050  const OUString cTok( ";" );
3051 
3052  OUString sUser = OUString::number( m_nSuperEsc ) + cTok +
3053  OUString::number( m_nSubEsc ) + cTok +
3054  OUString::number( m_nSuperProp ) + cTok +
3055  OUString::number( m_nSubProp );
3056  SetUserData( sUser );
3057 }
3058 
3059 
3061 {
3062  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3063  if (pFlagItem)
3064  {
3065  sal_uInt32 nFlags=pFlagItem->GetValue();
3066  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3067  // the writer uses SID_ATTR_BRUSH as font background
3069  }
3070 }
3071 // class SvxCharTwoLinesPage ------------------------------------------------
3072 
3074  : SvxCharBasePage(pPage, pController, "cui/ui/twolinespage.ui", "TwoLinesPage", rInSet)
3075  , m_nStartBracketPosition( 0 )
3076  , m_nEndBracketPosition( 0 )
3077  , m_xTwoLinesBtn(m_xBuilder->weld_check_button("twolines"))
3078  , m_xEnclosingFrame(m_xBuilder->weld_widget("enclosing"))
3079  , m_xStartBracketLB(m_xBuilder->weld_tree_view("startbracket"))
3080  , m_xEndBracketLB(m_xBuilder->weld_tree_view("endbracket"))
3081 {
3082  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_OPEN); ++i)
3083  m_xStartBracketLB->append(OUString::number(TWOLINE_OPEN[i].second), CuiResId(TWOLINE_OPEN[i].first));
3084  for (size_t i = 0; i < SAL_N_ELEMENTS(TWOLINE_CLOSE); ++i)
3085  m_xEndBracketLB->append(OUString::number(TWOLINE_CLOSE[i].second), CuiResId(TWOLINE_CLOSE[i].first));
3086 
3087  m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin));
3088 #ifdef IOS
3089  m_xPreviewWin->hide();
3090 #endif
3091  Initialize();
3092 }
3093 
3095 {
3096 }
3097 
3099 {
3100  m_xTwoLinesBtn->set_active(false);
3101  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3102 
3103  m_xTwoLinesBtn->connect_toggled(LINK(this, SvxCharTwoLinesPage, TwoLinesHdl_Impl));
3104 
3105  Link<weld::TreeView&,void> aLink = LINK(this, SvxCharTwoLinesPage, CharacterMapHdl_Impl);
3106  m_xStartBracketLB->connect_changed(aLink);
3107  m_xEndBracketLB->connect_changed(aLink);
3108 
3109  SvxFont& rFont = GetPreviewFont();
3110  SvxFont& rCJKFont = GetPreviewCJKFont();
3111  SvxFont& rCTLFont = GetPreviewCTLFont();
3112  rFont.SetFontSize( Size( 0, 220 ) );
3113  rCJKFont.SetFontSize( Size( 0, 220 ) );
3114  rCTLFont.SetFontSize( Size( 0, 220 ) );
3115 }
3116 
3118 {
3119  bool bStart = pBox == m_xStartBracketLB.get();
3120  SvxCharacterMap aDlg(GetFrameWeld(), nullptr, nullptr);
3121  aDlg.DisableFontSelection();
3122 
3123  if (aDlg.run() == RET_OK)
3124  {
3125  sal_Unicode cChar = static_cast<sal_Unicode>(aDlg.GetChar());
3126  SetBracket( cChar, bStart );
3127  }
3128  else
3129  {
3131  }
3132 }
3133 
3134 
3135 void SvxCharTwoLinesPage::SetBracket( sal_Unicode cBracket, bool bStart )
3136 {
3137  int nEntryPos = 0;
3138  weld::TreeView* pBox = bStart ? m_xStartBracketLB.get() : m_xEndBracketLB.get();
3139  if (cBracket == 0)
3140  pBox->select(0);
3141  else
3142  {
3143  bool bFound = false;
3144  for (int i = 1; i < pBox->n_children(); ++i)
3145  {
3146  if (pBox->get_id(i).toInt32() != CHRDLG_ENCLOSE_SPECIAL_CHAR)
3147  {
3148  const sal_Unicode cChar = pBox->get_text(i)[0];
3149  if (cChar == cBracket)
3150  {
3151  pBox->select(i);
3152  nEntryPos = i;
3153  bFound = true;
3154  break;
3155  }
3156  }
3157  }
3158 
3159  if (!bFound)
3160  {
3161  pBox->append_text(OUString(cBracket));
3162  nEntryPos = pBox->n_children() - 1;
3163  pBox->select(nEntryPos);
3164  }
3165  }
3166  if (bStart)
3167  m_nStartBracketPosition = nEntryPos;
3168  else
3169  m_nEndBracketPosition = nEntryPos;
3170 }
3171 
3173 {
3174  bool bChecked = m_xTwoLinesBtn->get_active();
3175  m_xEnclosingFrame->set_sensitive(bChecked);
3176  UpdatePreview_Impl();
3177 }
3178 
3179 IMPL_LINK(SvxCharTwoLinesPage, CharacterMapHdl_Impl, weld::TreeView&, rBox, void)
3180 {
3181  int nPos = rBox.get_selected_index();
3182  if (rBox.get_id(nPos).toInt32() == CHRDLG_ENCLOSE_SPECIAL_CHAR)
3183  SelectCharacter( &rBox );
3184  else
3185  {
3186  bool bStart = &rBox == m_xStartBracketLB.get();
3187  if (bStart)
3188  m_nStartBracketPosition = nPos;
3189  else
3190  m_nEndBracketPosition = nPos;
3191  }
3192  UpdatePreview_Impl();
3193 }
3194 
3196 {
3198 }
3199 
3201 {
3202  if ( _pSet )
3203  FillItemSet( _pSet );
3204  return DeactivateRC::LeavePage;
3205 }
3206 
3207 std::unique_ptr<SfxTabPage> SvxCharTwoLinesPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rSet)
3208 {
3209  return std::make_unique<SvxCharTwoLinesPage>(pPage, pController, *rSet);
3210 }
3211 
3213 {
3214  m_xTwoLinesBtn->set_active(false);
3215  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3216  SfxItemState eState = rSet->GetItemState( nWhich );
3217 
3218  if ( eState >= SfxItemState::DONTCARE )
3219  {
3220  const SvxTwoLinesItem& rItem = static_cast<const SvxTwoLinesItem&>(rSet->Get( nWhich ));
3221  m_xTwoLinesBtn->set_active(rItem.GetValue());
3222 
3223  if ( rItem.GetValue() )
3224  {
3225  SetBracket( rItem.GetStartBracket(), true );
3226  SetBracket( rItem.GetEndBracket(), false );
3227  }
3228  }
3229  TwoLinesHdl_Impl(*m_xTwoLinesBtn);
3230 
3231  SetPrevFontWidthScale( *rSet );
3232 }
3233 
3235 {
3236  const SfxItemSet& rOldSet = GetItemSet();
3237  bool bModified = false, bChanged = true;
3238  sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_TWO_LINES );
3239  const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_TWO_LINES );
3240  bool bOn = m_xTwoLinesBtn->get_active();
3241  sal_Unicode cStart = ( bOn && m_xStartBracketLB->get_selected_index() > 0 )
3242  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3243  sal_Unicode cEnd = ( bOn && m_xEndBracketLB->get_selected_index() > 0 )
3244  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3245 
3246  if ( pOld )
3247  {
3248  const SvxTwoLinesItem& rItem = *static_cast<const SvxTwoLinesItem*>(pOld);
3249  if ( rItem.GetValue() == bOn &&
3250  ( !bOn || ( rItem.GetStartBracket() == cStart && rItem.GetEndBracket() == cEnd ) ) )
3251  bChanged = false;
3252  }
3253 
3254  if ( bChanged )
3255  {
3256  rSet->Put( SvxTwoLinesItem( bOn, cStart, cEnd, nWhich ) );
3257  bModified = true;
3258  }
3259  else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
3260  rSet->InvalidateItem(nWhich);
3261 
3262  return bModified;
3263 }
3264 
3266 {
3267  sal_Unicode cStart = m_xStartBracketLB->get_selected_index() > 0
3268  ? m_xStartBracketLB->get_selected_text()[0] : 0;
3269  sal_Unicode cEnd = m_xEndBracketLB->get_selected_index() > 0
3270  ? m_xEndBracketLB->get_selected_text()[0] : 0;
3271  m_aPreviewWin.SetBrackets(cStart, cEnd);
3272  m_aPreviewWin.SetTwoLines(m_xTwoLinesBtn->get_active());
3273  m_aPreviewWin.Invalidate();
3274 }
3275 
3277 {
3278  const SfxUInt32Item* pFlagItem = aSet.GetItem<SfxUInt32Item>(SID_FLAG_TYPE, false);
3279  if (pFlagItem)
3280  {
3281  sal_uInt32 nFlags=pFlagItem->GetValue();
3282  if ( ( nFlags & SVX_PREVIEW_CHARACTER ) == SVX_PREVIEW_CHARACTER )
3283  // the writer uses SID_ATTR_BRUSH as font background
3285  }
3286 }
3287 
3288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetFamily(FontFamily)
sal_uInt16 m_nScaleWidthInitialVal
Definition: chardlg.hxx:240
virtual ~SvxCharEffectsPage() override
Definition: chardlg.cxx:1370
std::unique_ptr< weld::CheckButton > m_xFitToLineCB
Definition: chardlg.hxx:261
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:245
std::unique_ptr< SvxCharNamePage_Impl > m_pImpl
Definition: chardlg.hxx:67
FieldUnit
void SetBracket(sal_Unicode cBracket, bool bStart)
Definition: chardlg.cxx:3135
std::unique_ptr< weld::RadioButton > m_xNormalPosBtn
Definition: chardlg.hxx:246
SvxFont & GetCTLFont()
sal_Int32 nIndex
std::unique_ptr< weld::ComboBox > m_xStrikeoutLB
Definition: chardlg.hxx:186
OUString m_aNoStyleText
Definition: chardlg.cxx:199
void SetFontSize(const Size &)
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
OUString const & get_saved_value() const
const OUString & GetFamilyName() const
std::unique_ptr< weld::CheckButton > m_xHiddenBtn
Definition: chardlg.hxx:182
IMPL_LINK_NOARG(SvxCharNamePage, UpdateHdl_Impl, Timer *, void)
Definition: chardlg.cxx:1124
#define SVX_ENABLE_FLASH
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
#define DISABLE_WORDLINE
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:3048
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:1684
std::unique_ptr< weld::MetricSpinButton > m_xFontSizeMF
Definition: chardlg.hxx:252
SvxCaseMap
virtual short run() override
OUString const & getResultFontName() const
LanguageType get_active_id() const
bool FillItemSetColor_Impl(SfxItemSet &rSet)
Definition: chardlg.cxx:1587
virtual void hide()=0
void SetColor(const Color &rCol)
SvxCharPositionPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:2461
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:254
SvxFontPrevWindow m_aPreviewWin
Definition: chardlg.hxx:38
SvxFont & GetCJKFont()
std::unique_ptr< weld::Label > m_xEmphasisFT
Definition: chardlg.hxx:191
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
void set_value(int nValue)
Language for asian text.
Definition: chardlg.hxx:119
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:3212
std::unique_ptr< weld::Label > m_xFontColorFT
Definition: chardlg.hxx:171
std::unique_ptr< weld::ComboBox > m_xEffectsLB
Definition: chardlg.hxx:176
std::unique_ptr< weld::Label > m_xCTLFontStyleFT
Definition: chardlg.hxx:96
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
std::unique_ptr< weld::ComboBox > m_xReliefLB
Definition: chardlg.hxx:178
EditedAndValid GetEditedAndValid() const
void SetCharSet(rtl_TextEncoding)
static SfxObjectShell * Current()
#define DFLT_ESC_AUTO_SUB
void set_entry_text(const OUString &rText)
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:1510
OUString get_active_text() const
virtual void ChangesApplied() override
Definition: chardlg.cxx:2914
bool m_bPreviewBackgroundToCharacter
Definition: chardlg.hxx:41
bool IsAvailable(const OUString &rName) const
std::unique_ptr< weld::CheckButton > m_xShadowBtn
Definition: chardlg.hxx:180
std::unique_ptr< weld::Label > m_xCTLFontTypeFT
Definition: chardlg.hxx:102
void FontModifyHdl_Impl(const weld::Widget &)
Definition: chardlg.cxx: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:1625
static OutputDevice * GetDefaultDevice()
virtual MapUnit GetMetric(sal_uInt16 nWhich) const
std::unique_ptr< weld::CheckButton > m_xIndividualWordsBtn
Definition: chardlg.hxx:190
SvxFont & GetPreviewCTLFont()
Definition: chardlg.cxx:155
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
#define CHRDLG_POSITION_UNDER
Definition: chardlg.h:25
sal_uInt16 sal_Unicode
FontItalic GetItalic()
virtual ~SvxCharPositionPage() override
Definition: chardlg.cxx:2495
const Color & GetColor() const
std::unique_ptr< weld::CheckButton > m_xOutlineBtn
Definition: chardlg.hxx:179
std::unique_ptr< weld::Label > m_xOverlineColorFT
Definition: chardlg.hxx:184
sal_Unicode GetEndBracket() const
void append_text(const OUString &rStr)
std::unique_ptr< weld::RadioButton > m_x0degRB
Definition: chardlg.hxx:258
LINESTYLE_NONE
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:194
std::unique_ptr< weld::Label > m_xWestFontTypeFT
Definition: chardlg.hxx:78
virtual int n_children() const =0
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:3276
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:250
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:2538
SvxFont & GetFont()
#define DFLT_ESC_PROP
sal_uInt8 m_nSuperProp
Definition: chardlg.hxx:242
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:2607
std::unique_ptr< weld::CheckButton > m_xTwoLinesBtn
Definition: chardlg.hxx:307
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:2089
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:1696
void save_active_id()
std::unique_ptr< weld::Label > m_xHighLowFT
Definition: chardlg.hxx:248
const FontMetric & GetFontName(size_t nFont) const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1191
std::unique_ptr< weld::Label > m_xUnderlineColorFT
Definition: chardlg.hxx:188
std::unique_ptr< weld::CheckButton > m_xBlinkingBtn
Definition: chardlg.hxx:181
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
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)
#define DISABLE_BLINK
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:1361
void EnableSearchMode()
Definition: chardlg.cxx:1262
int i
std::unique_ptr< weld::Label > m_xEffectsFT
Definition: chardlg.hxx:175
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:3195
virtual void insert_vector(const std::vector< weld::ComboBoxEntry > &rItems, bool bKeepExisting)=0
sal_uInt16 m_nEndBracketPosition
Definition: chardlg.hxx:305
HTMLMODE_ON
SvxCharTwoLinesPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:3073
void SetPrevFontEscapement(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc)
Definition: chardlg.cxx:185
std::unique_ptr< weld::CheckButton > m_xPairKerningBtn
Definition: chardlg.hxx:266
WEIGHT_NORMAL
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:1222
std::unique_ptr< SvxLanguageBox > m_xCTLFontLanguageLB
Definition: chardlg.hxx:101
sal_uInt16 m_nStartBracketPosition
Definition: chardlg.hxx:304
std::unique_ptr< weld::Label > m_xEastFontSizeFT
Definition: chardlg.hxx:86
std::unique_ptr< ColorListBox > m_xFontColorLB
Definition: chardlg.hxx:172
static const sal_uInt16 pNameRanges[]
Definition: chardlg.hxx:65
#define LANGUAGE_DONTKNOW
const Size & GetFontSize() const
std::unique_ptr< weld::Widget > m_xEastFrame
Definition: chardlg.hxx:81
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:2435
long PointToTwips(long nIn)
virtual OUString get_text(int row, int col=-1) const =0
void EnableNoneFontColor()
Definition: chardlg.cxx:1355
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:187
virtual void Reset(const SfxItemSet *rSet) override
Definition: chardlg.cxx:2694
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
void SetTwoLines(bool bSet)
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:3060
bool IsFitToLine() const
void EnableRelativeMode()
Definition: chardlg.cxx:1254
virtual short run() override
Definition: cuicharmap.cxx:183
static const sal_uInt16 pPositionRanges[]
Definition: chardlg.hxx:233
int get_active() const
size_t GetFontNameCount() const
std::unique_ptr< weld::Widget > m_xWestFrame
Definition: chardlg.hxx:69
sal_uInt8 m_nSubProp
Definition: chardlg.hxx:243
std::unique_ptr< weld::RadioButton > m_x90degRB
Definition: chardlg.hxx:259
std::unique_ptr< weld::Label > m_xReliefFT
Definition: chardlg.hxx:177
void ResetColor_Impl(const SfxItemSet &rSet)
Definition: chardlg.cxx:1524
#define DISABLE_UNDERLINE_COLOR
const OUString & GetFamilyName() const
bool m_bEnableNoneFontColor
Definition: chardlg.hxx:166
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetCaseMap(const SvxCaseMap eNew)
void set_active(int nPos)
virtual void select(int pos)=0
bool m_bUnderlineColorDisabled
Definition: chardlg.hxx:169
FontWeight
std::unique_ptr< weld::Label > m_xEastFontTypeFT
Definition: chardlg.hxx:90
weld::Window * GetFrameWeld() const
void SetStyleName(const OUString &rStyleName)
sal_Int32 SaveEditedAsEntry()
static bool StateToAttr(TriState aState)
Definition: chardlg.cxx:130
sal_uInt32 GetHeight() const
void SetBrackets(sal_Unicode cStart, sal_Unicode cEnd)
SfxItemState
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:2072
std::unique_ptr< weld::RadioButton > m_x270degRB
Definition: chardlg.hxx:260
void set_sensitive(bool bSensitive)
FontWeight GetWeight()
unsigned char sal_uInt8
void UpdatePreview_Impl(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc)
Definition: chardlg.cxx:2532
std::unique_ptr< weld::TreeView > m_xEndBracketLB
Definition: chardlg.hxx:310
void SetPrevFontWidthScale(const SfxItemSet &rSet)
Definition: chardlg.cxx:175
void UpdatePreview_Impl()
Definition: chardlg.cxx:475
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:3200
const OUString & GetItalicStr() const
std::unique_ptr< weld::MetricSpinButton > m_xHighLowMF
Definition: chardlg.hxx:249
RET_OK
bool IsCTLFontEnabled() const
virtual ~SvxCharTwoLinesPage() override
Definition: chardlg.cxx:3094
#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:2412
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:3265
Language for ctl text.
Definition: chardlg.hxx:123
virtual OUString get_id(int pos) const =0
std::unique_ptr< weld::Label > m_xCTLFontNameFT
Definition: chardlg.hxx:94
#define DISABLE_LANGUAGE
std::unique_ptr< weld::MetricSpinButton > m_xKerningMF
Definition: chardlg.hxx:265
#define CHRDLG_POSITION_OVER
Definition: chardlg.h:24
std::unique_ptr< weld::Label > m_xCTLFontSizeFT
Definition: chardlg.hxx:98
DeactivateRC
void SelectCharacter(weld::TreeView *pBox)
Definition: chardlg.cxx:3117
void SetProprRel(const sal_uInt8 nNewPropr)
SvxEscapement
sal_uInt32 GetValue() const
void SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBackgroundToCharacter)
void SAL_CALL first(const css::awt::SpinEvent &rEvent) override
std::unique_ptr< weld::TreeView > m_xStartBracketLB
Definition: chardlg.hxx:309
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:2929
#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:71
std::unique_ptr< weld::Button > m_xEastFontFeaturesButton
Definition: chardlg.hxx:91
std::unique_ptr< ColorListBox > m_xUnderlineColorLB
Definition: chardlg.hxx:189
void SetPriority(TaskPriority ePriority)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1691
void SetFontList(const SvxFontListItem &rItem)
Definition: chardlg.cxx:1230
virtual DeactivateRC DeactivatePage(SfxItemSet *pSet) override
Definition: chardlg.cxx:2682
#define MAX_ESC_POS
std::unique_ptr< FontList > m_pFontList
Definition: chardlg.cxx:200
const FontList * GetFontList() const
STRIKEOUT_NONE
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
TriState
FontLineStyle
sal_uInt16 m_nScaleWidthItemSetVal
Definition: chardlg.hxx:239
OUString GetFontMapText(const FontMetric &rFontMetric) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
static const sal_uInt16 pTwoLinesRanges[]
Definition: chardlg.hxx:303
std::unique_ptr< weld::MetricSpinButton > m_xFontTransparencyMtr
Definition: chardlg.hxx:174
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: chardlg.cxx:3234
#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:2689
bool IsPtRelative() const
void Fill(const FontMetric *pFontMetric, const FontList *pList)
std::unique_ptr< weld::Label > m_xScalingFT
Definition: chardlg.hxx:256
void SetEscapement(const short nNewEsc)
std::unique_ptr< weld::ComboBox > m_xOverlineLB
Definition: chardlg.hxx:183
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
std::unique_ptr< weld::Label > m_xScalingAndRotationFT
Definition: chardlg.hxx:257
OUString const & get_saved_value() const
std::unique_ptr< weld::MetricSpinButton > m_xScaleWidthMF
Definition: chardlg.hxx:263
std::unique_ptr< weld::Label > m_xFontSizeFT
Definition: chardlg.hxx:251
virtual void set_entry_text(const OUString &rStr)=0
std::unique_ptr< weld::RadioButton > m_xLowPosBtn
Definition: chardlg.hxx:247
#define SVX_RELATIVE_MODE
std::unique_ptr< ColorListBox > m_xOverlineColorLB
Definition: chardlg.hxx:185
FontStrikeout
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:192
SvxCharEffectsPage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:1312
virtual void PageCreated(const SfxAllItemSet &aSet) override
Definition: chardlg.cxx:1290
std::unique_ptr< FontList > Clone() const
long ItemToControl(long nIn, MapUnit eItem, FieldUnit eCtrl)
void SetFontWidthScale(sal_uInt16 nScaleInPercent)
std::unique_ptr< weld::Label > m_xA11yWarningFT
Definition: chardlg.hxx:195
rtl_TextEncoding GetCharSet() const
void EnablePtRelativeMode(short nMin, short nMax, short nStep=10)
const Color & GetValue() const
sal_uInt16 nPos
virtual void set_sensitive(bool sensitive)=0
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
void append_text(const OUString &rStr)
FontItalic
virtual OUString get_active_text() const =0
std::unique_ptr< weld::Label > m_xFontTransparencyFT
Definition: chardlg.hxx:173
void UpdatePreview_Impl()
Definition: chardlg.cxx:1439
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:3207
void SetOverlineColor(const Color &rColor)
std::unique_ptr< weld::Label > m_xPositionFT
Definition: chardlg.hxx:193
std::unique_ptr< weld::ComboBox > m_xCTLFontNameLB
Definition: chardlg.hxx:95
SvxCharNamePage(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: chardlg.cxx:215
void setHeight(long nHeight)