cui/source/inc/chardlg.hxx | 97 ++- cui/source/tabpages/chardlg.cxx | 459 +++++++++--------- cui/uiconfig/ui/positionpage.ui | 71 ++ include/sfx2/dialoghelper.hxx | 2 include/svx/fntctrl.hxx | 58 ++ include/vcl/weld.hxx | 14 sfx2/source/dialog/dialoghelper.cxx | 4 solenv/sanitizers/ui/cui.suppr | 1 svtools/source/control/valueset.cxx | 2 svx/source/dialog/dlgctrl.cxx | 3 svx/source/dialog/fntctrl.cxx | 909 +++++++++++++++++++++++++++++++++++- svx/source/dialog/measctrl.cxx | 2 12 files changed, 1332 insertions(+), 290 deletions(-)
New commits: commit e10cd7f66af779347f428425f89fdd225ba5cc2e Author: Caolán McNamara <caol...@redhat.com> Date: Wed Jun 13 14:40:15 2018 +0100 weld SvxCharPositionPage Change-Id: I2084702798e5b01eae5905dc54ad8413e6d5fae6 Reviewed-on: https://gerrit.libreoffice.org/55765 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/inc/chardlg.hxx b/cui/source/inc/chardlg.hxx index 144b13e94513..fd46e3c3c334 100644 --- a/cui/source/inc/chardlg.hxx +++ b/cui/source/inc/chardlg.hxx @@ -26,6 +26,7 @@ #include <svx/colorbox.hxx> #include <svx/langbox.hxx> #include <vcl/layout.hxx> +#include <vcl/weld.hxx> #include <memory> // forward --------------------------------------------------------------- @@ -62,6 +63,33 @@ public: }; +class CharBasePage : public SfxTabPage +{ +protected: + FontPrevWindow m_aPreviewWin; + std::unique_ptr<weld::CustomWeld> m_xPreviewWin; + + bool m_bPreviewBackgroundToCharacter; + + CharBasePage(TabPageParent pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rAttrSet); + + void SetPrevFontWidthScale( const SfxItemSet& rSet ); + void SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); + + inline SvxFont& GetPreviewFont(); + inline SvxFont& GetPreviewCJKFont(); + inline SvxFont& GetPreviewCTLFont(); + +public: + virtual ~CharBasePage() override; + + using SfxTabPage::ActivatePage; + using SfxTabPage::DeactivatePage; + + virtual void ActivatePage( const SfxItemSet& rSet ) override; + +}; + // class SvxCharNamePage ------------------------------------------------- struct SvxCharNamePage_Impl; @@ -252,35 +280,12 @@ public: // class SvxCharPositionPage --------------------------------------------- -class SvxCharPositionPage : public SvxCharBasePage +class SvxCharPositionPage : public CharBasePage { friend class VclPtr<SvxCharPositionPage>; static const sal_uInt16 pPositionRanges[]; private: - VclPtr<RadioButton> m_pHighPosBtn; - VclPtr<RadioButton> m_pNormalPosBtn; - VclPtr<RadioButton> m_pLowPosBtn; - VclPtr<FixedText> m_pHighLowFT; - VclPtr<MetricField> m_pHighLowMF; - VclPtr<CheckBox> m_pHighLowRB; - VclPtr<FixedText> m_pFontSizeFT; - VclPtr<MetricField> m_pFontSizeMF; - - VclPtr<VclContainer> m_pRotationContainer; - - VclPtr<FixedText> m_pScalingFT; - VclPtr<FixedText> m_pScalingAndRotationFT; - VclPtr<RadioButton> m_p0degRB; - VclPtr<RadioButton> m_p90degRB; - VclPtr<RadioButton> m_p270degRB; - VclPtr<CheckBox> m_pFitToLineCB; - - VclPtr<MetricField> m_pScaleWidthMF; - - VclPtr<MetricField> m_pKerningMF; - VclPtr<CheckBox> m_pPairKerningBtn; - short m_nSuperEsc; short m_nSubEsc; @@ -290,25 +295,47 @@ private: sal_uInt8 m_nSuperProp; sal_uInt8 m_nSubProp; - SvxCharPositionPage( vcl::Window* pParent, const SfxItemSet& rSet ); + std::unique_ptr<weld::RadioButton> m_xHighPosBtn; + std::unique_ptr<weld::RadioButton> m_xNormalPosBtn; + std::unique_ptr<weld::RadioButton> m_xLowPosBtn; + std::unique_ptr<weld::Label> m_xHighLowFT; + std::unique_ptr<weld::MetricSpinButton> m_xHighLowMF; + std::unique_ptr<weld::CheckButton> m_xHighLowRB; + std::unique_ptr<weld::Label> m_xFontSizeFT; + std::unique_ptr<weld::MetricSpinButton> m_xFontSizeMF; + + std::unique_ptr<weld::Widget> m_xRotationContainer; + + std::unique_ptr<weld::Label> m_xScalingFT; + std::unique_ptr<weld::Label> m_xScalingAndRotationFT; + std::unique_ptr<weld::RadioButton> m_x0degRB; + std::unique_ptr<weld::RadioButton> m_x90degRB; + std::unique_ptr<weld::RadioButton> m_x270degRB; + std::unique_ptr<weld::CheckButton> m_xFitToLineCB; + + std::unique_ptr<weld::MetricSpinButton> m_xScaleWidthMF; + + std::unique_ptr<weld::MetricSpinButton> m_xKerningMF; + std::unique_ptr<weld::CheckButton> m_xPairKerningBtn; + + SvxCharPositionPage(TabPageParent pParent, const SfxItemSet& rSet); void Initialize(); void UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); void SetEscapement_Impl( SvxEscapement nEsc ); - DECL_LINK( PositionHdl_Impl, Button*, void ); - DECL_LINK( RotationHdl_Impl, Button*, void ); - DECL_LINK( FontModifyHdl_Impl, Edit&, void ); - DECL_LINK( AutoPositionHdl_Impl, Button*, void ); - DECL_LINK( FitToLineHdl_Impl, Button*, void ); - DECL_LINK( KerningSelectHdl_Impl, ListBox&, void ); - DECL_LINK( KerningModifyHdl_Impl, Edit&, void ); - DECL_LINK( LoseFocusHdl_Impl, Control&, void ); - DECL_LINK( ScaleWidthModifyHdl_Impl, Edit&, void ); + DECL_LINK(PositionHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(RotationHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(AutoPositionHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(FitToLineHdl_Impl, weld::ToggleButton&, void); + DECL_LINK(KerningSelectHdl_Impl, weld::ComboBoxText&, void); + DECL_LINK(KerningModifyHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(ValueChangedHdl_Impl, weld::MetricSpinButton&, void); + DECL_LINK(ScaleWidthModifyHdl_Impl, weld::MetricSpinButton&, void); + void FontModifyHdl_Impl(); public: virtual ~SvxCharPositionPage() override; - virtual void dispose() override; using SfxTabPage::DeactivatePage; diff --git a/cui/source/tabpages/chardlg.cxx b/cui/source/tabpages/chardlg.cxx index 0ee3241ed7dc..22422651f504 100644 --- a/cui/source/tabpages/chardlg.cxx +++ b/cui/source/tabpages/chardlg.cxx @@ -216,6 +216,55 @@ void SvxCharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp m_pPreviewWin->Invalidate(); } +inline SvxFont& CharBasePage::GetPreviewFont() +{ + return m_aPreviewWin.GetFont(); +} + +inline SvxFont& CharBasePage::GetPreviewCJKFont() +{ + return m_aPreviewWin.GetCJKFont(); +} + +inline SvxFont& CharBasePage::GetPreviewCTLFont() +{ + return m_aPreviewWin.GetCTLFont(); +} + +CharBasePage::CharBasePage(TabPageParent pParent, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet& rItemset) + : SfxTabPage(pParent, rUIXMLDescription, rID, &rItemset) + , m_bPreviewBackgroundToCharacter( false ) +{ +} + +CharBasePage::~CharBasePage() +{ +} + +void CharBasePage::ActivatePage(const SfxItemSet& rSet) +{ + m_aPreviewWin.SetFromItemSet(rSet, m_bPreviewBackgroundToCharacter); +} + +void CharBasePage::SetPrevFontWidthScale( const SfxItemSet& rSet ) +{ + sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); + if (rSet.GetItemState(nWhich)>=SfxItemState::DEFAULT) + { + const SvxCharScaleWidthItem &rItem = static_cast<const SvxCharScaleWidthItem&>( rSet.Get( nWhich ) ); + m_aPreviewWin.SetFontWidthScale(rItem.GetValue()); + } +} + +void CharBasePage::SetPrevFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) +{ + setPrevFontEscapement(GetPreviewFont(),nProp,nEscProp,nEsc); + setPrevFontEscapement(GetPreviewCJKFont(),nProp,nEscProp,nEsc); + setPrevFontEscapement(GetPreviewCTLFont(),nProp,nEscProp,nEsc); + m_aPreviewWin.Invalidate(); +} + + // SvxCharNamePage_Impl -------------------------------------------------- struct SvxCharNamePage_Impl @@ -2475,65 +2524,39 @@ void SvxCharEffectsPage::PageCreated(const SfxAllItemSet& aSet) // class SvxCharPositionPage --------------------------------------------- -SvxCharPositionPage::SvxCharPositionPage( vcl::Window* pParent, const SfxItemSet& rInSet ) - : SvxCharBasePage(pParent, "PositionPage", "cui/ui/positionpage.ui", rInSet) +SvxCharPositionPage::SvxCharPositionPage(TabPageParent pParent, const SfxItemSet& rInSet) + : CharBasePage(pParent, "cui/ui/positionpage.ui", "PositionPage", rInSet) , m_nSuperEsc(short(DFLT_ESC_SUPER)) , m_nSubEsc(short(DFLT_ESC_SUB)) , m_nScaleWidthItemSetVal(100) , m_nScaleWidthInitialVal(100) , m_nSuperProp(sal_uInt8(DFLT_ESC_PROP)) , m_nSubProp(sal_uInt8(DFLT_ESC_PROP)) -{ - get(m_pHighPosBtn, "superscript"); - get(m_pNormalPosBtn, "normal"); - get(m_pLowPosBtn, "subscript"); - get(m_pHighLowFT, "raiselower"); - get(m_pHighLowMF, "raiselowersb"); - get(m_pHighLowRB, "automatic"); - get(m_pFontSizeFT, "relativefontsize"); - get(m_pFontSizeMF, "fontsizesb"); - get(m_pRotationContainer, "rotationcontainer"); - get(m_pScalingFT, "scale"); - get(m_pScalingAndRotationFT, "rotateandscale"); - get(m_p0degRB, "0deg"); - get(m_p90degRB, "90deg"); - get(m_p270degRB, "270deg"); - get(m_pFitToLineCB, "fittoline"); - get(m_pScaleWidthMF, "scalewidthsb"); - get(m_pKerningMF, "kerningsb"); - get(m_pPairKerningBtn, "pairkerning"); - - get(m_pPreviewWin, "preview"); - + , m_xHighPosBtn(m_xBuilder->weld_radio_button("superscript")) + , m_xNormalPosBtn(m_xBuilder->weld_radio_button("normal")) + , m_xLowPosBtn(m_xBuilder->weld_radio_button("subscript")) + , m_xHighLowFT(m_xBuilder->weld_label("raiselower")) + , m_xHighLowMF(m_xBuilder->weld_metric_spin_button("raiselowersb", FUNIT_PERCENT)) + , m_xHighLowRB(m_xBuilder->weld_check_button("automatic")) + , m_xFontSizeFT(m_xBuilder->weld_label("relativefontsize")) + , m_xFontSizeMF(m_xBuilder->weld_metric_spin_button("fontsizesb", FUNIT_PERCENT)) + , m_xRotationContainer(m_xBuilder->weld_widget("rotationcontainer")) + , m_xScalingFT(m_xBuilder->weld_label("scale")) + , m_xScalingAndRotationFT(m_xBuilder->weld_label("rotateandscale")) + , m_x0degRB(m_xBuilder->weld_radio_button("0deg")) + , m_x90degRB(m_xBuilder->weld_radio_button("90deg")) + , m_x270degRB(m_xBuilder->weld_radio_button("270deg")) + , m_xFitToLineCB(m_xBuilder->weld_check_button("fittoline")) + , m_xScaleWidthMF(m_xBuilder->weld_metric_spin_button("scalewidthsb", FUNIT_PERCENT)) + , m_xKerningMF(m_xBuilder->weld_metric_spin_button("kerningsb", FUNIT_POINT)) + , m_xPairKerningBtn(m_xBuilder->weld_check_button("pairkerning")) +{ + m_xPreviewWin.reset(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWin)); Initialize(); } SvxCharPositionPage::~SvxCharPositionPage() { - disposeOnce(); -} - -void SvxCharPositionPage::dispose() -{ - m_pHighPosBtn.clear(); - m_pNormalPosBtn.clear(); - m_pLowPosBtn.clear(); - m_pHighLowFT.clear(); - m_pHighLowMF.clear(); - m_pHighLowRB.clear(); - m_pFontSizeFT.clear(); - m_pFontSizeMF.clear(); - m_pRotationContainer.clear(); - m_pScalingFT.clear(); - m_pScalingAndRotationFT.clear(); - m_p0degRB.clear(); - m_p90degRB.clear(); - m_p270degRB.clear(); - m_pFitToLineCB.clear(); - m_pScaleWidthMF.clear(); - m_pKerningMF.clear(); - m_pPairKerningBtn.clear(); - SvxCharBasePage::dispose(); } @@ -2546,31 +2569,27 @@ void SvxCharPositionPage::Initialize() GetPreviewCJKFont().SetFontSize( Size( 0, 240 ) ); GetPreviewCTLFont().SetFontSize( Size( 0, 240 ) ); - m_pNormalPosBtn->Check(); - PositionHdl_Impl( m_pNormalPosBtn ); + m_xNormalPosBtn->set_active(true); + PositionHdl_Impl(*m_xNormalPosBtn); - Link<Button*,void> aLink2 = LINK( this, SvxCharPositionPage, PositionHdl_Impl ); - m_pHighPosBtn->SetClickHdl( aLink2 ); - m_pNormalPosBtn->SetClickHdl( aLink2 ); - m_pLowPosBtn->SetClickHdl( aLink2 ); + Link<weld::ToggleButton&,void> aLink2 = LINK(this, SvxCharPositionPage, PositionHdl_Impl); + m_xHighPosBtn->connect_toggled(aLink2); + m_xNormalPosBtn->connect_toggled(aLink2); + m_xLowPosBtn->connect_toggled(aLink2); aLink2 = LINK( this, SvxCharPositionPage, RotationHdl_Impl ); - m_p0degRB->SetClickHdl( aLink2 ); - m_p90degRB->SetClickHdl( aLink2 ); - m_p270degRB->SetClickHdl( aLink2 ); - - Link<Edit&,void> aLink = LINK( this, SvxCharPositionPage, FontModifyHdl_Impl ); - m_pHighLowMF->SetModifyHdl( aLink ); - m_pFontSizeMF->SetModifyHdl( aLink ); + m_x0degRB->connect_toggled(aLink2); + m_x90degRB->connect_toggled(aLink2); + m_x270degRB->connect_toggled(aLink2); - Link<Control&,void> aLink3 = LINK( this, SvxCharPositionPage, LoseFocusHdl_Impl ); - m_pHighLowMF->SetLoseFocusHdl( aLink3 ); - m_pFontSizeMF->SetLoseFocusHdl( aLink3 ); + Link<weld::MetricSpinButton&,void> aLink3 = LINK(this, SvxCharPositionPage, ValueChangedHdl_Impl); + m_xHighLowMF->connect_value_changed(aLink3); + m_xFontSizeMF->connect_value_changed(aLink3); - m_pHighLowRB->SetClickHdl( LINK( this, SvxCharPositionPage, AutoPositionHdl_Impl ) ); - m_pFitToLineCB->SetClickHdl( LINK( this, SvxCharPositionPage, FitToLineHdl_Impl ) ); - m_pKerningMF->SetModifyHdl( LINK( this, SvxCharPositionPage, KerningModifyHdl_Impl ) ); - m_pScaleWidthMF->SetModifyHdl( LINK( this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl ) ); + m_xHighLowRB->connect_toggled(LINK(this, SvxCharPositionPage, AutoPositionHdl_Impl)); + m_xFitToLineCB->connect_toggled(LINK(this, SvxCharPositionPage, FitToLineHdl_Impl)); + m_xKerningMF->connect_value_changed(LINK(this, SvxCharPositionPage, KerningModifyHdl_Impl)); + m_xScaleWidthMF->connect_value_changed(LINK(this, SvxCharPositionPage, ScaleWidthModifyHdl_Impl)); } void SvxCharPositionPage::UpdatePreview_Impl( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ) @@ -2596,102 +2615,93 @@ void SvxCharPositionPage::SetEscapement_Impl( SvxEscapement nEsc ) short nFac = aEscItm.GetEsc() < 0 ? -1 : 1; - m_pHighLowMF->SetValue( aEscItm.GetEsc() * nFac ); - m_pFontSizeMF->SetValue( aEscItm.GetProportionalHeight() ); + m_xHighLowMF->set_value(aEscItm.GetEsc() * nFac, FUNIT_PERCENT); + m_xFontSizeMF->set_value(aEscItm.GetProportionalHeight(), FUNIT_PERCENT); if ( SvxEscapement::Off == nEsc ) { - m_pHighLowFT->Disable(); - m_pHighLowMF->Disable(); - m_pFontSizeFT->Disable(); - m_pFontSizeMF->Disable(); - m_pHighLowRB->Disable(); + m_xHighLowFT->set_sensitive(false); + m_xHighLowMF->set_sensitive(false); + m_xFontSizeFT->set_sensitive(false); + m_xFontSizeMF->set_sensitive(false); + m_xHighLowRB->set_sensitive(false); } else { - m_pFontSizeFT->Enable(); - m_pFontSizeMF->Enable(); - m_pHighLowRB->Enable(); + m_xFontSizeFT->set_sensitive(true); + m_xFontSizeMF->set_sensitive(true); + m_xHighLowRB->set_sensitive(true); - if ( !m_pHighLowRB->IsChecked() ) + if (!m_xHighLowRB->get_active()) { - m_pHighLowFT->Enable(); - m_pHighLowMF->Enable(); + m_xHighLowFT->set_sensitive(true); + m_xHighLowMF->set_sensitive(true); } else - AutoPositionHdl_Impl( m_pHighLowRB ); + AutoPositionHdl_Impl(*m_xHighLowRB); } UpdatePreview_Impl( 100, aEscItm.GetProportionalHeight(), aEscItm.GetEsc() ); } -IMPL_LINK( SvxCharPositionPage, PositionHdl_Impl, Button*, pBtn, void ) +IMPL_LINK_NOARG(SvxCharPositionPage, PositionHdl_Impl, weld::ToggleButton&, void) { SvxEscapement nEsc = SvxEscapement::Off; // also when pBtn == NULL - if ( m_pHighPosBtn == pBtn ) + if (m_xHighPosBtn->get_active()) nEsc = SvxEscapement::Superscript; - else if ( m_pLowPosBtn == pBtn ) + else if (m_xLowPosBtn->get_active()) nEsc = SvxEscapement::Subscript; SetEscapement_Impl( nEsc ); } - -IMPL_LINK( SvxCharPositionPage, RotationHdl_Impl, Button*, pBtn, void ) +IMPL_LINK_NOARG(SvxCharPositionPage, RotationHdl_Impl, weld::ToggleButton&, void) { bool bEnable = false; - if (m_p90degRB == pBtn || m_p270degRB == pBtn) + if (m_x90degRB->get_active() || m_x270degRB->get_active()) bEnable = true; else - OSL_ENSURE( m_p0degRB == pBtn, "unexpected button" ); - m_pFitToLineCB->Enable( bEnable ); + OSL_ENSURE(m_x0degRB->get_active(), "unexpected button"); + m_xFitToLineCB->set_sensitive(bEnable); } - -IMPL_LINK_NOARG(SvxCharPositionPage, FontModifyHdl_Impl, Edit&, void) +void SvxCharPositionPage::FontModifyHdl_Impl() { - sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_pFontSizeMF->GetValue()); - short nEsc = static_cast<short>(m_pHighLowMF->GetValue()); - nEsc *= m_pLowPosBtn->IsChecked() ? -1 : 1; + sal_uInt8 nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FUNIT_PERCENT)); + short nEsc = static_cast<short>(m_xHighLowMF->get_value(FUNIT_PERCENT)); + nEsc *= m_xLowPosBtn->get_active() ? -1 : 1; UpdatePreview_Impl( 100, nEscProp, nEsc ); } - -IMPL_LINK( SvxCharPositionPage, AutoPositionHdl_Impl, Button*, pBox, void ) +IMPL_LINK(SvxCharPositionPage, AutoPositionHdl_Impl, weld::ToggleButton&, rBox, void) { - if ( static_cast<CheckBox*>(pBox)->IsChecked() ) + if (rBox.get_active()) { - m_pHighLowFT->Disable(); - m_pHighLowMF->Disable(); + m_xHighLowFT->set_sensitive(false); + m_xHighLowMF->set_sensitive(false); } else - PositionHdl_Impl( m_pHighPosBtn->IsChecked() ? m_pHighPosBtn - : m_pLowPosBtn->IsChecked() ? m_pLowPosBtn - : m_pNormalPosBtn ); + PositionHdl_Impl(m_xHighPosBtn->get_active() ? *m_xHighPosBtn + : m_xLowPosBtn->get_active() ? *m_xLowPosBtn + : *m_xNormalPosBtn); } - -IMPL_LINK( SvxCharPositionPage, FitToLineHdl_Impl, Button*, pBox, void ) +IMPL_LINK_NOARG(SvxCharPositionPage, FitToLineHdl_Impl, weld::ToggleButton&, void) { - if (m_pFitToLineCB == pBox) - { - sal_uInt16 nVal = m_nScaleWidthInitialVal; - if (m_pFitToLineCB->IsChecked()) - nVal = m_nScaleWidthItemSetVal; - m_pScaleWidthMF->SetValue( nVal ); - - m_pPreviewWin->SetFontWidthScale( nVal ); - } + sal_uInt16 nVal = m_nScaleWidthInitialVal; + if (m_xFitToLineCB->get_active()) + nVal = m_nScaleWidthItemSetVal; + m_xScaleWidthMF->set_value(nVal, FUNIT_PERCENT); + m_aPreviewWin.SetFontWidthScale( nVal ); } - -IMPL_LINK_NOARG(SvxCharPositionPage, KerningModifyHdl_Impl, Edit&, void) +IMPL_LINK_NOARG(SvxCharPositionPage, KerningModifyHdl_Impl, weld::MetricSpinButton&, void) { - long nVal = static_cast<long>(m_pKerningMF->GetValue()); + long nVal = static_cast<long>(m_xKerningMF->get_value(FUNIT_POINT)); nVal = LogicToLogic( nVal, MapUnit::MapPoint, MapUnit::MapTwip ); - long nKern = static_cast<short>(m_pKerningMF->Denormalize( nVal )); + long nKern = static_cast<short>(m_xKerningMF->denormalize(nVal)); SvxFont& rFont = GetPreviewFont(); SvxFont& rCJKFont = GetPreviewCJKFont(); @@ -2700,37 +2710,36 @@ IMPL_LINK_NOARG(SvxCharPositionPage, KerningModifyHdl_Impl, Edit&, void) rFont.SetFixKerning( static_cast<short>(nKern) ); rCJKFont.SetFixKerning( static_cast<short>(nKern) ); rCTLFont.SetFixKerning( static_cast<short>(nKern) ); - m_pPreviewWin->Invalidate(); + m_aPreviewWin.Invalidate(); } - -IMPL_LINK( SvxCharPositionPage, LoseFocusHdl_Impl, Control&, rControl, void ) +IMPL_LINK(SvxCharPositionPage, ValueChangedHdl_Impl, weld::MetricSpinButton&, rField, void) { - MetricField* pField = static_cast<MetricField*>(&rControl); - bool bHigh = m_pHighPosBtn->IsChecked(); - bool bLow = m_pLowPosBtn->IsChecked(); + bool bHigh = m_xHighPosBtn->get_active(); + bool bLow = m_xLowPosBtn->get_active(); DBG_ASSERT( bHigh || bLow, "normal position is not valid" ); - if ( m_pHighLowMF == pField ) + if (m_xHighLowMF.get() == &rField) { if ( bLow ) - m_nSubEsc = static_cast<short>(m_pHighLowMF->GetValue()) * -1; + m_nSubEsc = static_cast<short>(m_xHighLowMF->get_value(FUNIT_PERCENT)) * -1; else - m_nSuperEsc = static_cast<short>(m_pHighLowMF->GetValue()); + m_nSuperEsc = static_cast<short>(m_xHighLowMF->get_value(FUNIT_PERCENT)); } - else if ( m_pFontSizeMF == pField ) + else if (m_xFontSizeMF.get() == &rField) { if ( bLow ) - m_nSubProp = static_cast<sal_uInt8>(m_pFontSizeMF->GetValue()); + m_nSubProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FUNIT_PERCENT)); else - m_nSuperProp = static_cast<sal_uInt8>(m_pFontSizeMF->GetValue()); + m_nSuperProp = static_cast<sal_uInt8>(m_xFontSizeMF->get_value(FUNIT_PERCENT)); } -} + FontModifyHdl_Impl(); +} -IMPL_LINK_NOARG(SvxCharPositionPage, ScaleWidthModifyHdl_Impl, Edit&, void) +IMPL_LINK_NOARG(SvxCharPositionPage, ScaleWidthModifyHdl_Impl, weld::MetricSpinButton&, void) { - m_pPreviewWin->SetFontWidthScale( sal_uInt16( m_pScaleWidthMF->GetValue() ) ); + m_aPreviewWin.SetFontWidthScale(sal_uInt16(m_xScaleWidthMF->get_value(FUNIT_PERCENT))); } DeactivateRC SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet ) @@ -2740,13 +2749,11 @@ DeactivateRC SvxCharPositionPage::DeactivatePage( SfxItemSet* _pSet ) return DeactivateRC::LeavePage; } - -VclPtr<SfxTabPage> SvxCharPositionPage::Create( TabPageParent pParent, const SfxItemSet* rSet ) +VclPtr<SfxTabPage> SvxCharPositionPage::Create(TabPageParent pParent, const SfxItemSet* rSet) { - return VclPtr<SvxCharPositionPage>::Create( pParent.pParent, *rSet ); + return VclPtr<SvxCharPositionPage>::Create(pParent, *rSet); } - void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) { OUString sUser = GetUserData(); @@ -2761,13 +2768,13 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) //fdo#75307 validate all the entries and discard all of them if any are //out of range bool bValid = true; - if (m_nSuperEsc < m_pHighLowMF->GetMin() || m_nSuperEsc > m_pHighLowMF->GetMax()) + if (m_nSuperEsc < m_xHighLowMF->get_min(FUNIT_PERCENT) || m_nSuperEsc > m_xHighLowMF->get_max(FUNIT_PERCENT)) bValid = false; - if (m_nSubEsc*-1 < m_pHighLowMF->GetMin() || m_nSubEsc*-1 > m_pHighLowMF->GetMax()) + if (m_nSubEsc*-1 < m_xHighLowMF->get_min(FUNIT_PERCENT) || m_nSubEsc*-1 > m_xHighLowMF->get_max(FUNIT_PERCENT)) bValid = false; - if (m_nSuperProp < m_pFontSizeMF->GetMin() || m_nSuperProp > m_pFontSizeMF->GetMax()) + if (m_nSuperProp < m_xFontSizeMF->get_min(FUNIT_PERCENT) || m_nSuperProp > m_xFontSizeMF->get_max(FUNIT_PERCENT)) bValid = false; - if (m_nSubProp < m_pFontSizeMF->GetMin() || m_nSubProp > m_pFontSizeMF->GetMax()) + if (m_nSubProp < m_xFontSizeMF->get_min(FUNIT_PERCENT) || m_nSubProp > m_xFontSizeMF->get_max(FUNIT_PERCENT)) bValid = false; if (!bValid) @@ -2782,10 +2789,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) short nEsc = 0; sal_uInt8 nEscProp = 100; - m_pHighLowFT->Disable(); - m_pHighLowMF->Disable(); - m_pFontSizeFT->Disable(); - m_pFontSizeMF->Disable(); + m_xHighLowFT->set_sensitive(false); + m_xHighLowMF->set_sensitive(false); + m_xFontSizeFT->set_sensitive(false); + m_xFontSizeMF->set_sensitive(false); SvxFont& rFont = GetPreviewFont(); SvxFont& rCJKFont = GetPreviewCJKFont(); @@ -2800,10 +2807,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( nEsc != 0 ) { - m_pHighLowFT->Enable(); - m_pHighLowMF->Enable(); - m_pFontSizeFT->Enable(); - m_pFontSizeMF->Enable(); + m_xHighLowFT->set_sensitive(true); + m_xHighLowMF->set_sensitive(true); + m_xFontSizeFT->set_sensitive(true); + m_xFontSizeMF->set_sensitive(true); short nFac; bool bAutomatic(false); @@ -2811,7 +2818,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( nEsc > 0 ) { nFac = 1; - m_pHighPosBtn->Check(); + m_xHighPosBtn->set_active(true); if ( nEsc == DFLT_ESC_AUTO_SUPER ) { nEsc = DFLT_ESC_SUPER; @@ -2821,40 +2828,40 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) else { nFac = -1; - m_pLowPosBtn->Check(); + m_xLowPosBtn->set_active(true); if ( nEsc == DFLT_ESC_AUTO_SUB ) { nEsc = DFLT_ESC_SUB; bAutomatic = true; } } - if (!m_pHighLowRB->IsEnabled()) + if (!m_xHighLowRB->get_sensitive()) { - m_pHighLowRB->Enable(); + m_xHighLowRB->set_sensitive(true); } - m_pHighLowRB->Check(bAutomatic); + m_xHighLowRB->set_active(bAutomatic); - if ( m_pHighLowRB->IsChecked() ) + if (m_xHighLowRB->get_active()) { - m_pHighLowFT->Disable(); - m_pHighLowMF->Disable(); + m_xHighLowFT->set_sensitive(false); + m_xHighLowMF->set_sensitive(false); } - m_pHighLowMF->SetValue( m_pHighLowMF->Normalize( nFac * nEsc ) ); + m_xHighLowMF->set_value(m_xHighLowMF->normalize(nFac * nEsc), FUNIT_PERCENT); } else { - m_pNormalPosBtn->Check(); - m_pHighLowRB->Check(); - PositionHdl_Impl( nullptr ); + m_xNormalPosBtn->set_active(true); + m_xHighLowRB->set_active(true); + PositionHdl_Impl(*m_xNormalPosBtn); } //the height has to be set after the handler is called to keep the value also if the escapement is zero - m_pFontSizeMF->SetValue( m_pFontSizeMF->Normalize( nEscProp ) ); + m_xFontSizeMF->set_value(m_xFontSizeMF->normalize(nEscProp), FUNIT_PERCENT); } else { - m_pHighPosBtn->Check( false ); - m_pNormalPosBtn->Check( false ); - m_pLowPosBtn->Check( false ); + m_xHighPosBtn->set_active(false); + m_xNormalPosBtn->set_active(false); + m_xLowPosBtn->set_active(false); } // set BspFont @@ -2867,7 +2874,7 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) { const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>(rSet->Get( nWhich )); MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich ); - long nBig = static_cast<long>(m_pKerningMF->Normalize( static_cast<long>(rItem.GetValue()) )); + long nBig = static_cast<long>(m_xKerningMF->normalize( static_cast<long>(rItem.GetValue()) )); long nKerning = LogicToLogic( nBig, eUnit, MapUnit::MapPoint ); // set Kerning at the Font, convert into Twips before @@ -2877,13 +2884,13 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) rCTLFont.SetFixKerning( static_cast<short>(nKern) ); //the attribute value must be displayed also if it's above the maximum allowed value - long nVal = static_cast<long>(m_pKerningMF->GetMax()); + long nVal = static_cast<long>(m_xKerningMF->get_max(FUNIT_POINT)); if(nVal < nKerning) - m_pKerningMF->SetMax( nKerning ); - m_pKerningMF->SetValue( nKerning ); + m_xKerningMF->set_max(nKerning, FUNIT_POINT); + m_xKerningMF->set_value(nKerning, FUNIT_POINT); } else - m_pKerningMF->SetText( OUString() ); + m_xKerningMF->set_text(OUString()); // Pair kerning nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN ); @@ -2891,10 +2898,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) { const SvxAutoKernItem& rItem = static_cast<const SvxAutoKernItem&>(rSet->Get( nWhich )); - m_pPairKerningBtn->Check( rItem.GetValue() ); + m_xPairKerningBtn->set_active(rItem.GetValue()); } else - m_pPairKerningBtn->Check( false ); + m_xPairKerningBtn->set_active(false); // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); @@ -2902,10 +2909,10 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) { const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet->Get( nWhich ) ); m_nScaleWidthInitialVal = rItem.GetValue(); - m_pScaleWidthMF->SetValue( m_nScaleWidthInitialVal ); + m_xScaleWidthMF->set_value(m_nScaleWidthInitialVal, FUNIT_PERCENT); } else - m_pScaleWidthMF->SetValue( 100 ); + m_xScaleWidthMF->set_value(100, FUNIT_PERCENT); nWhich = GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ); if ( rSet->GetItemState( nWhich ) >= SfxItemState::DEFAULT ) @@ -2916,73 +2923,69 @@ void SvxCharPositionPage::Reset( const SfxItemSet* rSet ) SfxItemState eState = rSet->GetItemState( nWhich ); if( SfxItemState::UNKNOWN == eState ) { - m_pRotationContainer->Hide(); - m_pScalingAndRotationFT->Hide(); - m_pScalingFT->Show(); + m_xRotationContainer->hide(); + m_xScalingAndRotationFT->hide(); + m_xScalingFT->show(); } else { - m_pRotationContainer->Show(); - m_pScalingAndRotationFT->Show(); - m_pScalingFT->Hide(); + m_xRotationContainer->show(); + m_xScalingAndRotationFT->show(); + m_xScalingFT->hide(); - Link<Button*,void> aOldLink( m_pFitToLineCB->GetClickHdl() ); - m_pFitToLineCB->SetClickHdl( Link<Button*,void>() ); if( eState >= SfxItemState::DEFAULT ) { const SvxCharRotateItem& rItem = static_cast<const SvxCharRotateItem&>( rSet->Get( nWhich )); if (rItem.IsBottomToTop()) - m_p90degRB->Check(); + m_x90degRB->set_active(true); else if (rItem.IsTopToBottom()) - m_p270degRB->Check(); + m_x270degRB->set_active(true); else { DBG_ASSERT( 0 == rItem.GetValue(), "incorrect value" ); - m_p0degRB->Check(); + m_x0degRB->set_active(true); } - m_pFitToLineCB->Check( rItem.IsFitToLine() ); + m_xFitToLineCB->set_active(rItem.IsFitToLine()); } else { if( eState == SfxItemState::DONTCARE ) { - m_p0degRB->Check( false ); - m_p90degRB->Check( false ); - m_p270degRB->Check( false ); + m_x0degRB->set_active(false); + m_x90degRB->set_active(false); + m_x270degRB->set_active(false); } else - m_p0degRB->Check(); + m_x0degRB->set_active(true); - m_pFitToLineCB->Check( false ); + m_xFitToLineCB->set_active(false); } - m_pFitToLineCB->SetClickHdl( aOldLink ); - m_pFitToLineCB->Enable( !m_p0degRB->IsChecked() ); + m_xFitToLineCB->set_sensitive(!m_x0degRB->get_active()); // is this value set? if( SfxItemState::UNKNOWN == rSet->GetItemState( GetWhich( SID_ATTR_CHAR_WIDTH_FIT_TO_LINE ) )) - m_pFitToLineCB->Hide(); + m_xFitToLineCB->hide(); } ChangesApplied(); } void SvxCharPositionPage::ChangesApplied() { - m_pHighPosBtn->SaveValue(); - m_pNormalPosBtn->SaveValue(); - m_pLowPosBtn->SaveValue(); - m_pHighLowRB->SaveValue(); - m_p0degRB->SaveValue(); - m_p90degRB->SaveValue(); - m_p270degRB->SaveValue(); - m_pFitToLineCB->SaveValue(); - m_pScaleWidthMF->SaveValue(); - m_pKerningMF->SaveValue(); - m_pPairKerningBtn->SaveValue(); + m_xHighPosBtn->save_state(); + m_xNormalPosBtn->save_state(); + m_xLowPosBtn->save_state(); + m_xHighLowRB->save_state(); + m_x0degRB->save_state(); + m_x90degRB->save_state(); + m_x270degRB->save_state(); + m_xFitToLineCB->save_state(); + m_xScaleWidthMF->save_value(); + m_xKerningMF->save_value(); + m_xPairKerningBtn->save_state(); } - bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) { // Position (high, normal or low) @@ -2990,20 +2993,20 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) bool bModified = false, bChanged = true; sal_uInt16 nWhich = GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); const SfxPoolItem* pOld = GetOldItem( *rSet, SID_ATTR_CHAR_ESCAPEMENT ); - const bool bHigh = m_pHighPosBtn->IsChecked(); + const bool bHigh = m_xHighPosBtn->get_active(); short nEsc; sal_uInt8 nEscProp; - if ( bHigh || m_pLowPosBtn->IsChecked() ) + if (bHigh || m_xLowPosBtn->get_active()) { - if ( m_pHighLowRB->IsChecked() ) + if (m_xHighLowRB->get_active()) nEsc = bHigh ? DFLT_ESC_AUTO_SUPER : DFLT_ESC_AUTO_SUB; else { - nEsc = static_cast<short>(m_pHighLowMF->Denormalize( m_pHighLowMF->GetValue() )); + nEsc = static_cast<short>(m_xHighLowMF->denormalize(m_xHighLowMF->get_value(FUNIT_PERCENT))); nEsc *= (bHigh ? 1 : -1); } - nEscProp = static_cast<sal_uInt8>(m_pFontSizeMF->Denormalize( m_pFontSizeMF->GetValue() )); + nEscProp = static_cast<sal_uInt8>(m_xFontSizeMF->denormalize(m_xFontSizeMF->get_value(FUNIT_PERCENT))); } else { @@ -3018,12 +3021,12 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) bChanged = false; } - if ( !bChanged && !m_pHighPosBtn->GetSavedValue() && - !m_pNormalPosBtn->GetSavedValue() && !m_pLowPosBtn->GetSavedValue() ) + if ( !bChanged && !m_xHighPosBtn->get_saved_state() && + !m_xNormalPosBtn->get_saved_state() && !m_xLowPosBtn->get_saved_state() ) bChanged = true; if ( bChanged && - ( m_pHighPosBtn->IsChecked() || m_pNormalPosBtn->IsChecked() || m_pLowPosBtn->IsChecked() ) ) + ( m_xHighPosBtn->get_active() || m_xNormalPosBtn->get_active() || m_xLowPosBtn->get_active() ) ) { rSet->Put( SvxEscapementItem( nEsc, nEscProp, nWhich ) ); bModified = true; @@ -3039,15 +3042,15 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) short nKerning = 0; MapUnit eUnit = rSet->GetPool()->GetMetric( nWhich ); - long nTmp = static_cast<long>(m_pKerningMF->GetValue()); + long nTmp = static_cast<long>(m_xKerningMF->get_value(FUNIT_POINT)); long nVal = LogicToLogic( nTmp, MapUnit::MapPoint, eUnit ); - nKerning = static_cast<short>(m_pKerningMF->Denormalize( nVal )); + nKerning = static_cast<short>(m_xKerningMF->denormalize( nVal )); SfxItemState eOldKernState = rOldSet.GetItemState( nWhich, false ); if ( pOld ) { const SvxKerningItem& rItem = *static_cast<const SvxKerningItem*>(pOld); - if ( (eOldKernState >= SfxItemState::DEFAULT || m_pKerningMF->GetText().isEmpty()) && rItem.GetValue() == nKerning ) + if ( (eOldKernState >= SfxItemState::DEFAULT || m_xKerningMF->get_text().isEmpty()) && rItem.GetValue() == nKerning ) bChanged = false; } @@ -3062,9 +3065,9 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) // Pair-Kerning nWhich = GetWhich( SID_ATTR_CHAR_AUTOKERN ); - if ( m_pPairKerningBtn->IsValueChangedFromSaved() ) + if (m_xPairKerningBtn->get_state_changed_from_saved()) { - rSet->Put( SvxAutoKernItem( m_pPairKerningBtn->IsChecked(), nWhich ) ); + rSet->Put( SvxAutoKernItem( m_xPairKerningBtn->get_active(), nWhich ) ); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -3072,9 +3075,9 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) // Scale Width nWhich = GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); - if ( m_pScaleWidthMF->IsValueChangedFromSaved() ) + if (m_xScaleWidthMF->get_value_changed_from_saved()) { - rSet->Put( SvxCharScaleWidthItem( static_cast<sal_uInt16>(m_pScaleWidthMF->GetValue()), nWhich ) ); + rSet->Put(SvxCharScaleWidthItem(static_cast<sal_uInt16>(m_xScaleWidthMF->get_value(FUNIT_PERCENT)), nWhich)); bModified = true; } else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) ) @@ -3082,15 +3085,15 @@ bool SvxCharPositionPage::FillItemSet( SfxItemSet* rSet ) // Rotation nWhich = GetWhich( SID_ATTR_CHAR_ROTATED ); - if ( m_p0degRB->IsValueChangedFromSaved() || - m_p90degRB->IsValueChangedFromSaved() || - m_p270degRB->IsValueChangedFromSaved() || - m_pFitToLineCB->IsValueChangedFromSaved() ) + if ( m_x0degRB->get_state_changed_from_saved() || + m_x90degRB->get_state_changed_from_saved() || + m_x270degRB->get_state_changed_from_saved() || + m_xFitToLineCB->get_state_changed_from_saved() ) { - SvxCharRotateItem aItem( 0, m_pFitToLineCB->IsChecked(), nWhich ); - if (m_p90degRB->IsChecked()) + SvxCharRotateItem aItem( 0, m_xFitToLineCB->get_active(), nWhich ); + if (m_x90degRB->get_active()) aItem.SetBottomToTop(); - else if (m_p270degRB->IsChecked()) + else if (m_x270degRB->get_active()) aItem.SetTopToBottom(); rSet->Put( aItem ); bModified = true; diff --git a/cui/uiconfig/ui/positionpage.ui b/cui/uiconfig/ui/positionpage.ui index d347bba3fe70..0e0c731d7b67 100644 --- a/cui/uiconfig/ui/positionpage.ui +++ b/cui/uiconfig/ui/positionpage.ui @@ -1,8 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> <object class="GtkAdjustment" id="adjustment1"> <property name="lower">1</property> <property name="upper">100</property> @@ -23,6 +22,12 @@ <property name="step_increment">0.10000000000000001</property> <property name="page_increment">1</property> </object> + <object class="GtkAdjustment" id="adjustment4"> + <property name="lower">1</property> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> <object class="GtkBox" id="PositionPage"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -123,7 +128,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="positionpage|raiselower">Raise/lower by</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">raiselowersb:0%</property> + <property name="mnemonic_widget">raiselowersb</property> <property name="xalign">0</property> </object> <packing> @@ -132,7 +137,7 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="raiselowersb:0%"> + <object class="GtkSpinButton" id="raiselowersb"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="adjustment">adjustment1</property> @@ -143,10 +148,10 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="fontsizesb:0%"> + <object class="GtkSpinButton" id="fontsizesb"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustment4</property> </object> <packing> <property name="left_attach">1</property> @@ -174,7 +179,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="positionpage|relativefontsize">Relative font size</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">fontsizesb:0%</property> + <property name="mnemonic_widget">fontsizesb</property> <property name="xalign">0</property> </object> <packing> @@ -245,7 +250,6 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">90deg</property> </object> <packing> <property name="expand">False</property> @@ -262,7 +266,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">270deg</property> + <property name="group">0deg</property> </object> <packing> <property name="expand">False</property> @@ -321,7 +325,7 @@ <property name="can_focus">False</property> <property name="label" translatable="yes" context="positionpage|label24">Scale width</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">scalewidthsb:0%</property> + <property name="mnemonic_widget">scalewidthsb</property> </object> <packing> <property name="expand">False</property> @@ -330,7 +334,7 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="scalewidthsb:0%"> + <object class="GtkSpinButton" id="scalewidthsb"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="adjustment">adjustment2</property> @@ -415,7 +419,21 @@ <property name="can_focus">False</property> <property name="spacing">12</property> <child> - <object class="GtkSpinButton" id="kerningsb:0pt"> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes" context="positionpage|label7">Character spacing</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">kerningsb</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="kerningsb"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="adjustment">adjustment3</property> @@ -424,7 +442,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> @@ -440,7 +458,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> </object> @@ -473,14 +491,29 @@ <property name="left_padding">12</property> <property name="right_padding">12</property> <child> - <object class="svxlo-SvxFontPrevWindow" id="preview:border"> + <object class="GtkScrolledWindow"> <property name="visible">True</property> - <property name="can_focus">False</property> + <property name="can_focus">True</property> <property name="hexpand">True</property> <property name="vexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="preview:border-atkobject"> - <property name="AtkObject::accessible-name" translatable="yes" context="positionpage|preview-atkobject">Preview</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkViewport"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkDrawingArea" id="preview"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="preview-atkobject"> + <property name="AtkObject::accessible-name" translatable="yes" context="positionpage|preview-atkobject">Preview</property> + </object> + </child> + </object> + </child> </object> </child> </object> diff --git a/include/sfx2/dialoghelper.hxx b/include/sfx2/dialoghelper.hxx index f83c438f76b4..ed06d76b733d 100644 --- a/include/sfx2/dialoghelper.hxx +++ b/include/sfx2/dialoghelper.hxx @@ -33,7 +33,7 @@ Size SFX2_DLLPUBLIC getParagraphPreviewOptimalSize(const OutputDevice& rReferenc Size SFX2_DLLPUBLIC getDrawPreviewOptimalSize(const vcl::Window *pReference); -Size SFX2_DLLPUBLIC getPreviewStripSize(const vcl::Window *pReference); +Size SFX2_DLLPUBLIC getPreviewStripSize(const OutputDevice& rReference); Size SFX2_DLLPUBLIC getPreviewOptionsSize(const vcl::Window *pReference); diff --git a/include/svx/fntctrl.hxx b/include/svx/fntctrl.hxx index ed0828e8cc3b..c65b7e3d92e6 100644 --- a/include/svx/fntctrl.hxx +++ b/include/svx/fntctrl.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SVX_FNTCTRL_HXX #include <memory> +#include <vcl/customweld.hxx> #include <vcl/window.hxx> #include <editeng/svxfont.hxx> #include <svx/svxdllapi.h> @@ -88,6 +89,63 @@ public: virtual Size GetOptimalSize() const override; }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC FontPrevWindow : public weld::CustomWidgetController +{ +private: + std::unique_ptr<FontPrevWin_Impl> pImpl; + OUString maText; + bool mbResetForeground : 1; + bool mbResetBackground : 1; + + SVX_DLLPRIVATE void ResetSettings(bool bForeground, bool bBackground); + SVX_DLLPRIVATE void ApplySettings(vcl::RenderContext& rRenderContext); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + SVX_DLLPRIVATE static void SetFontSize(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont); + SVX_DLLPRIVATE static void SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont); + +public: + FontPrevWindow(); + virtual ~FontPrevWindow() override; + + virtual void StyleUpdated() override; + + void Init( const SfxItemSet& rSet ); + + // for reasons of efficiency not const + SvxFont& GetFont(); + const SvxFont& GetFont() const; + void SetFont( const SvxFont& rNormalFont, const SvxFont& rCJKFont, const SvxFont& rCTLFont ); + SvxFont& GetCJKFont(); + SvxFont& GetCTLFont(); + void SetColor( const Color& rColor ); + void ResetColor(); + void SetBackColor( const Color& rColor ); + void UseResourceText(); + const OUString& GetText() const { return maText; } + void SetText(const OUString& rText) { maText = rText; } + void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override; + + bool IsTwoLines() const; + void SetTwoLines(bool bSet); + + void SetBrackets(sal_Unicode cStart, sal_Unicode cEnd); + + void SetFontWidthScale( sal_uInt16 nScaleInPercent ); + + void AutoCorrectFontColor(); + + void SetPreviewText( const OUString& rString ); + void SetFontNameAsPreviewText(); + + static void SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ); + static void SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nSlotPosture, sal_uInt16 nSlotWeight, SvxFont& rFont ); // posture/weight + void SetFontWidthScale( const SfxItemSet& rSet ); + void SetFontEscapement( sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc ); + + void SetFromItemSet( const SfxItemSet &rSet, + bool bPreviewBackgroundToCharacter ); +}; + #endif // INCLUDED_SVX_FNTCTRL_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 485470b25f02..86718d52a642 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -630,6 +630,20 @@ public: set_range(min, max, eValueUnit); } + int get_min(FieldUnit eValueUnit) + { + int min, dummy; + get_range(min, dummy, eValueUnit); + return min; + } + + int get_max(FieldUnit eValueUnit) + { + int dummy, max; + get_range(dummy, max, eValueUnit); + return max; + } + void set_increments(int step, int page, FieldUnit eValueUnit) { step = ConvertValue(step, eValueUnit, m_eSrcUnit); diff --git a/sfx2/source/dialog/dialoghelper.cxx b/sfx2/source/dialog/dialoghelper.cxx index 48a491d07c78..9e8bcd2f69b2 100644 --- a/sfx2/source/dialog/dialoghelper.cxx +++ b/sfx2/source/dialog/dialoghelper.cxx @@ -62,9 +62,9 @@ Size getDrawPreviewOptimalSize(const vcl::Window *pReference) return pReference->LogicToPixel(Size(88, 42), MapMode(MapUnit::MapAppFont)); } -Size getPreviewStripSize(const vcl::Window *pReference) +Size getPreviewStripSize(const OutputDevice& rReference) { - return pReference->LogicToPixel(Size(70 , 40), MapMode(MapUnit::MapAppFont)); + return rReference.LogicToPixel(Size(70 , 40), MapMode(MapUnit::MapAppFont)); } Size getPreviewOptionsSize(const vcl::Window *pReference) diff --git a/solenv/sanitizers/ui/cui.suppr b/solenv/sanitizers/ui/cui.suppr index a9dcaf2ae43f..9d872c73803f 100644 --- a/solenv/sanitizers/ui/cui.suppr +++ b/solenv/sanitizers/ui/cui.suppr @@ -111,7 +111,6 @@ cui/uiconfig/ui/personalization_tab.ui://GtkButton[@id='default3'] button-no-lab cui/uiconfig/ui/personalization_tab.ui://GtkLabel[@id='applied_theme'] orphan-label cui/uiconfig/ui/personalization_tab.ui://GtkLabel[@id='extensions_label'] orphan-label cui/uiconfig/ui/personalization_tab.ui://GtkButton[@id='persona_preview'] button-no-label -cui/uiconfig/ui/positionpage.ui://GtkSpinButton[@id='kerningsb:0pt'] no-labelled-by cui/uiconfig/ui/select_persona_dialog.ui://GtkEntry[@id='search_term'] no-labelled-by cui/uiconfig/ui/select_persona_dialog.ui://GtkButton[@id='suggestion1'] button-no-label cui/uiconfig/ui/select_persona_dialog.ui://GtkButton[@id='suggestion2'] button-no-label diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 292c89a097b2..7ecb3b4159fe 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -3504,7 +3504,7 @@ bool SvtValueSet::ImplScroll(const Point& rPos) void SvtValueSet::StyleUpdated() { mbFormat = true; - Invalidate(); + CustomWidgetController::StyleUpdated(); } void SvtValueSet::SetColCount( sal_uInt16 nNewCols ) diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index ef1461d640f1..48a24c0372f5 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -1950,7 +1950,7 @@ VCL_BUILDER_FACTORY(SvxXLinePreview) Size SvxXLinePreview::GetOptimalSize() const { - return getPreviewStripSize(this); + return getPreviewStripSize(*this); } SvxXLinePreview::~SvxXLinePreview() @@ -2264,6 +2264,7 @@ void PreviewBase::LocalPostPaint(vcl::RenderContext& rRenderContext) void PreviewBase::StyleUpdated() { InitSettings(); + CustomWidgetController::StyleUpdated(); } XRectPreview::XRectPreview() diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index 3e4b2b3f9f51..8b1d978bdfd1 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -142,6 +142,7 @@ bool CleanAndCheckEmpty(OUString& rText) class FontPrevWin_Impl { friend class SvxFontPrevWindow; + friend class FontPrevWindow; SvxFont maFont; VclPtr<Printer> mpPrinter; @@ -1448,7 +1449,913 @@ void SvxFontPrevWindow::SetFontEscapement(sal_uInt8 nProp, sal_uInt8 nEscProp, s Size SvxFontPrevWindow::GetOptimalSize() const { - return getPreviewStripSize(this); + return getPreviewStripSize(*this); +} + +void FontPrevWindow::ResetSettings(bool bForeground, bool bBackground) +{ + mbResetForeground = bForeground; + mbResetBackground = bBackground; + Invalidate(); +} + +void FontPrevWindow::ApplySettings(vcl::RenderContext& rRenderContext) +{ + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + + if (mbResetForeground) + { + svtools::ColorConfig aColorConfig; + Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor); + rRenderContext.SetTextColor(aTextColor); + mbResetForeground = false; + } + + if (mbResetBackground) + { + rRenderContext.SetBackground(rStyleSettings.GetWindowColor()); + mbResetBackground = false; + } +} + +void FontPrevWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + Size aPrefSize(getPreviewStripSize(pDrawingArea->get_ref_device())); + pDrawingArea->set_size_request(aPrefSize.Width(), aPrefSize.Height()); + + CustomWidgetController::SetDrawingArea(pDrawingArea); + + pImpl.reset(new FontPrevWin_Impl); + SfxViewShell* pSh = SfxViewShell::Current(); + + if (pSh) + pImpl->mpPrinter = pSh->GetPrinter(); + + if (!pImpl->mpPrinter) + { + pImpl->mpPrinter = VclPtr<Printer>::Create(); + pImpl->mbDelPrinter = true; + } + initFont(pImpl->maFont); + initFont(pImpl->maCJKFont); + initFont(pImpl->maCTLFont); + + ResetSettings(true, true); +} + +FontPrevWindow::FontPrevWindow() + : mbResetForeground(true) + , mbResetBackground(true) +{ +} + +FontPrevWindow::~FontPrevWindow() +{ +} + +SvxFont& FontPrevWindow::GetCTLFont() +{ + return pImpl->maCTLFont; +} + +SvxFont& FontPrevWindow::GetCJKFont() +{ + return pImpl->maCJKFont; +} + +void FontPrevWindow::StyleUpdated() +{ + ResetSettings(true, true); + CustomWidgetController::StyleUpdated(); +} + +SvxFont& FontPrevWindow::GetFont() +{ + pImpl->Invalidate100PercentFontWidth(); // because the user might change the size + return pImpl->maFont; +} + +const SvxFont& FontPrevWindow::GetFont() const +{ + return pImpl->maFont; +} + +void FontPrevWindow::SetPreviewText( const OUString& rString ) +{ + pImpl->maText = rString; + pImpl->mbTextInited = true; +} + +void FontPrevWindow::SetFontNameAsPreviewText() +{ + pImpl->mbUseFontNameAsText = true; +} + +void FontPrevWindow::SetFont( const SvxFont& rNormalOutFont, const SvxFont& rCJKOutFont, const SvxFont& rCTLFont ) +{ + setFont(rNormalOutFont, pImpl->maFont); + setFont(rCJKOutFont, pImpl->maCJKFont); + setFont(rCTLFont, pImpl->maCTLFont); + + pImpl->Invalidate100PercentFontWidth(); + Invalidate(); +} + +void FontPrevWindow::SetColor(const Color &rColor) +{ + pImpl->mpColor.reset(new Color(rColor)); + Invalidate(); +} + +void FontPrevWindow::ResetColor() +{ + pImpl->mpColor.reset(); + Invalidate(); +} + +void FontPrevWindow::SetBackColor(const Color &rColor) +{ + pImpl->mpBackColor.reset(new Color(rColor)); + Invalidate(); +} + +void FontPrevWindow::UseResourceText() +{ + pImpl->mbUseResText = true; +} + +void FontPrevWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) +{ + rRenderContext.Push(PushFlags::MAPMODE); + rRenderContext.SetMapMode(MapMode(MapUnit::MapTwip)); + + ApplySettings(rRenderContext); + + Printer* pPrinter = pImpl->mpPrinter; + const SvxFont& rFont = pImpl->maFont; + const SvxFont& rCJKFont = pImpl->maCJKFont; + const SvxFont& rCTLFont = pImpl->maCTLFont; + + if (!IsEnabled()) + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + const Size aLogSize(rRenderContext.GetOutputSize()); + + tools::Rectangle aRect(Point(0, 0), aLogSize); + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(rStyleSettings.GetWindowColor()); + rRenderContext.DrawRect(aRect); + } + else + { + if (pImpl->mbUseResText) + pImpl->maText = GetText(); + else if (!pImpl->mbSelection && !pImpl->mbTextInited) + { + using namespace css::i18n::ScriptType; + + SfxViewShell* pSh = SfxViewShell::Current(); + + if (pSh && !pImpl->mbGetSelection && !pImpl->mbUseFontNameAsText) + { + pImpl->maText = pSh->GetSelectionText(); + pImpl->mbGetSelection = true; + pImpl->mbSelection = !CleanAndCheckEmpty(pImpl->maText); + } + + if (!pImpl->mbSelection || pImpl->mbUseFontNameAsText) + { + //If we're showing multiple sample texts, then they're all + //sample texts. If only showing Latin, continue to use + //the fontname as the preview + if ((pImpl->m_bCJKEnabled) || (pImpl->m_bCTLEnabled)) + pImpl->maText = makeRepresentativeTextForFont(LATIN, rFont); + else + pImpl->maText = rFont.GetFamilyName(); + + if (pImpl->m_bCJKEnabled) + { + if (!pImpl->maText.isEmpty()) + pImpl->maText += " "; + pImpl->maText += makeRepresentativeTextForFont(ASIAN, rCJKFont); + + } + if (pImpl->m_bCTLEnabled) + { + if (!pImpl->maText.isEmpty()) + pImpl->maText += " "; + pImpl->maText += makeRepresentativeTextForFont(COMPLEX, rCTLFont); + } + } + + if (pImpl->maText.isEmpty()) + pImpl->maText = GetText(); + + if (pImpl->maText.isEmpty()) + { // fdo#58427: still no text? let's try that one... + pImpl->maText = makeRepresentativeTextForFont(LATIN, rFont); + } + + bool bEmpty = CleanAndCheckEmpty(pImpl->maText); + if (bEmpty) + pImpl->maText = GetText(); + + if (pImpl->maText.getLength() > (TEXT_WIDTH - 1)) + { + const sal_Int32 nSpaceIdx = pImpl->maText.indexOf(" ", TEXT_WIDTH); + if (nSpaceIdx != -1) + pImpl->maText = pImpl->maText.copy(0, nSpaceIdx); + else + pImpl->maText = pImpl->maText.copy(0, (TEXT_WIDTH - 1)); + } + } + + // calculate text width scaling + pImpl->ScaleFontWidth(rRenderContext); + + pImpl->CheckScript(); + Size aTxtSize = pImpl->CalcTextSize(rRenderContext, pPrinter, rFont); + + const Size aLogSize(rRenderContext.GetOutputSize()); + + long nX = aLogSize.Width() / 2 - aTxtSize.Width() / 2; + long nY = aLogSize.Height() / 2 - aTxtSize.Height() / 2; + + if (nY + pImpl->mnAscent > aLogSize.Height()) + nY = aLogSize.Height() - pImpl->mnAscent; + + if (pImpl->mpBackColor) + { + tools::Rectangle aRect(Point(0, 0), aLogSize); + Color aLineCol = rRenderContext.GetLineColor(); + Color aFillCol = rRenderContext.GetFillColor(); + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(*pImpl->mpBackColor); + rRenderContext.DrawRect(aRect); + rRenderContext.SetLineColor(aLineCol); + rRenderContext.SetFillColor(aFillCol); + } + if (pImpl->mpColor) + { + tools::Rectangle aRect(Point(nX, nY), aTxtSize); + Color aLineCol = rRenderContext.GetLineColor(); + Color aFillCol = rRenderContext.GetFillColor(); + rRenderContext.SetLineColor(); + rRenderContext.SetFillColor(*pImpl->mpColor); + rRenderContext.DrawRect(aRect); + rRenderContext.SetLineColor(aLineCol); + rRenderContext.SetFillColor(aFillCol); + } + + long nStdAscent = pImpl->mnAscent; + nY += nStdAscent; + + if (IsTwoLines()) + { + SvxFont aSmallFont(rFont); + Size aOldSize = pImpl->maCJKFont.GetFontSize(); + setFontSize(aSmallFont); + setFontSize(pImpl->maCJKFont); + + long nStartBracketWidth = 0; + long nEndBracketWidth = 0; + long nTextWidth = 0; + if (pImpl->mcStartBracket) + { + OUString sBracket(pImpl->mcStartBracket); + nStartBracketWidth = rFont.GetTextSize(pPrinter, sBracket).Width(); + } + if (pImpl->mcEndBracket) + { + OUString sBracket(pImpl->mcEndBracket); + nEndBracketWidth = rFont.GetTextSize(pPrinter, sBracket).Width(); + } + nTextWidth = pImpl->CalcTextSize(rRenderContext, pPrinter, aSmallFont).Width(); + long nResultWidth = nStartBracketWidth; + nResultWidth += nEndBracketWidth; + nResultWidth += nTextWidth; + + long _nX = (aLogSize.Width() - nResultWidth) / 2; + rRenderContext.DrawLine(Point(0, nY), Point(_nX, nY)); + rRenderContext.DrawLine(Point(_nX + nResultWidth, nY), Point(aLogSize.Width(), nY)); + + long nSmallAscent = pImpl->mnAscent; + long nOffset = (nStdAscent - nSmallAscent) / 2; + + if (pImpl->mcStartBracket) + { + OUString sBracket(pImpl->mcStartBracket); + rFont.DrawPrev(&rRenderContext, pPrinter, Point(_nX, nY - nOffset - 4), sBracket); + _nX += nStartBracketWidth; + } + + Point aTmpPoint1(_nX, nY - nSmallAscent - 2); + Point aTmpPoint2(_nX, nY); + pImpl->DrawPrev(rRenderContext, pPrinter, aTmpPoint1, aSmallFont); + pImpl->DrawPrev(rRenderContext, pPrinter, aTmpPoint2, aSmallFont); + + _nX += nTextWidth; + if (pImpl->mcEndBracket) + { + Point aTmpPoint( _nX + 1, nY - nOffset - 4); + OUString sBracket(pImpl->mcEndBracket); + rFont.DrawPrev(&rRenderContext, pPrinter, aTmpPoint, sBracket); + } + pImpl->maCJKFont.SetFontSize(aOldSize); + } + else + { + + Color aLineCol = rRenderContext.GetLineColor(); + + rRenderContext.SetLineColor(rFont.GetColor()); + rRenderContext.DrawLine(Point(0, nY), Point(nX, nY)); + rRenderContext.DrawLine(Point(nX + aTxtSize.Width(), nY), Point(aLogSize.Width(), nY)); + rRenderContext.SetLineColor(aLineCol); + + Point aTmpPoint(nX, nY); + pImpl->DrawPrev(rRenderContext, pPrinter, aTmpPoint, rFont); + } + } + rRenderContext.Pop(); +} + +bool FontPrevWindow::IsTwoLines() const +{ + return pImpl->mbTwoLines; +} + +void FontPrevWindow::SetTwoLines(bool bSet) +{ + pImpl->mbTwoLines = bSet; +} + +void FontPrevWindow::SetBrackets(sal_Unicode cStart, sal_Unicode cEnd) +{ + pImpl->mcStartBracket = cStart; + pImpl->mcEndBracket = cEnd; +} + +void FontPrevWindow::SetFontWidthScale( sal_uInt16 n ) +{ + if (pImpl->SetFontWidthScale(n)) + Invalidate(); +} + +void FontPrevWindow::AutoCorrectFontColor() +{ + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + Color aFontColor(rStyleSettings.GetWindowTextColor()); + + if (COL_AUTO == pImpl->maFont.GetColor()) + pImpl->maFont.SetColor(aFontColor); + + if (COL_AUTO == pImpl->maCJKFont.GetColor()) + pImpl->maCJKFont.SetColor(aFontColor); + + if (COL_AUTO == pImpl->maCTLFont.GetColor()) + pImpl->maCTLFont.SetColor(aFontColor); +} + +void FontPrevWindow::SetFontSize( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) +{ + sal_uInt16 nWhich; + long nH; + if (GetWhich(rSet, nSlot, nWhich)) + { + nH = OutputDevice::LogicToLogic(static_cast<const SvxFontHeightItem&>(rSet.Get(nWhich)).GetHeight(), + rSet.GetPool()->GetMetric(nWhich), + MapUnit::MapTwip); + } + else + nH = 240;// as default 12pt + + rFont.SetFontSize(Size(0, nH)); +} + +void FontPrevWindow::SetFontLang(const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont) +{ + sal_uInt16 nWhich; + LanguageType nLang; + if( GetWhich( rSet, nSlot, nWhich ) ) + nLang = static_cast<const SvxLanguageItem&>(rSet.Get(nWhich)).GetLanguage(); + else + nLang = LANGUAGE_NONE; + rFont.SetLanguage(nLang); +} + +void FontPrevWindow::SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBackgroundToCharacter) +{ + sal_uInt16 nWhich; + SvxFont& rFont = GetFont(); + SvxFont& rCJKFont = GetCJKFont(); + SvxFont& rCTLFont = GetCTLFont(); + + // Preview string + if( GetWhich( rSet, SID_CHAR_DLG_PREVIEW_STRING, nWhich ) ) + { + const SfxStringItem& rItem = static_cast<const SfxStringItem&>( rSet.Get( nWhich ) ); + const OUString& aString = rItem.GetValue(); + if( !aString.isEmpty() ) + SetPreviewText( aString ); + else + SetFontNameAsPreviewText(); + } + + // Underline + FontLineStyle eUnderline; + if( GetWhich( rSet, SID_ATTR_CHAR_UNDERLINE, nWhich ) ) + { + const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>( rSet.Get( nWhich ) ); + eUnderline = rItem.GetValue(); + } + else + eUnderline = LINESTYLE_NONE; + + rFont.SetUnderline( eUnderline ); + rCJKFont.SetUnderline( eUnderline ); + rCTLFont.SetUnderline( eUnderline ); + + // Overline + FontLineStyle eOverline; + if( GetWhich( rSet, SID_ATTR_CHAR_OVERLINE, nWhich ) ) + { + const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>( rSet.Get( nWhich ) ); + eOverline = rItem.GetValue(); + } + else + eOverline = LINESTYLE_NONE; + + rFont.SetOverline( eOverline ); + rCJKFont.SetOverline( eOverline ); + rCTLFont.SetOverline( eOverline ); + + // Strikeout + FontStrikeout eStrikeout; + if( GetWhich( rSet, SID_ATTR_CHAR_STRIKEOUT, nWhich ) ) + { + const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>( rSet.Get( nWhich ) ); + eStrikeout = rItem.GetValue(); + } + else + eStrikeout = STRIKEOUT_NONE; + + rFont.SetStrikeout( eStrikeout ); + rCJKFont.SetStrikeout( eStrikeout ); + rCTLFont.SetStrikeout( eStrikeout ); + + // WordLineMode + if( GetWhich( rSet, SID_ATTR_CHAR_WORDLINEMODE, nWhich ) ) + { + const SvxWordLineModeItem& rItem = static_cast<const SvxWordLineModeItem&>( rSet.Get( nWhich ) ); + rFont.SetWordLineMode( rItem.GetValue() ); + rCJKFont.SetWordLineMode( rItem.GetValue() ); + rCTLFont.SetWordLineMode( rItem.GetValue() ); + } + + // Emphasis + if( GetWhich( rSet, SID_ATTR_CHAR_EMPHASISMARK, nWhich ) ) + { + const SvxEmphasisMarkItem& rItem = static_cast<const SvxEmphasisMarkItem&>( rSet.Get( nWhich ) ); + FontEmphasisMark eMark = rItem.GetEmphasisMark(); + rFont.SetEmphasisMark( eMark ); + rCJKFont.SetEmphasisMark( eMark ); + rCTLFont.SetEmphasisMark( eMark ); + } + + // Relief + if( GetWhich( rSet, SID_ATTR_CHAR_RELIEF, nWhich ) ) + { + const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>( rSet.Get( nWhich ) ); + FontRelief eFontRelief = rItem.GetValue(); + rFont.SetRelief( eFontRelief ); + rCJKFont.SetRelief( eFontRelief ); + rCTLFont.SetRelief( eFontRelief ); + } + + // Effects + if( GetWhich( rSet, SID_ATTR_CHAR_CASEMAP, nWhich ) ) + { + const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>( rSet.Get( nWhich ) ); + SvxCaseMap eCaseMap = rItem.GetValue(); + rFont.SetCaseMap( eCaseMap ); + rCJKFont.SetCaseMap( eCaseMap ); + // #i78474# small caps do not exist in CTL fonts + rCTLFont.SetCaseMap( eCaseMap == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaseMap ); + } + + // Outline + if( GetWhich( rSet, SID_ATTR_CHAR_CONTOUR, nWhich ) ) + { + const SvxContourItem& rItem = static_cast<const SvxContourItem&>( rSet.Get( nWhich ) ); + bool bOutline = rItem.GetValue(); + rFont.SetOutline( bOutline ); + rCJKFont.SetOutline( bOutline ); + rCTLFont.SetOutline( bOutline ); + } + + // Shadow + if( GetWhich( rSet, SID_ATTR_CHAR_SHADOWED, nWhich ) ) + { + const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>( rSet.Get( nWhich ) ); + bool bShadow = rItem.GetValue(); + rFont.SetShadow( bShadow ); + rCJKFont.SetShadow( bShadow ); + rCTLFont.SetShadow( bShadow ); + } + + // Background + bool bTransparent; + if( GetWhich( rSet, bPreviewBackgroundToCharacter ? SID_ATTR_BRUSH : SID_ATTR_BRUSH_CHAR, nWhich ) ) + { + const SvxBrushItem& rBrush = static_cast<const SvxBrushItem&>( rSet.Get( nWhich ) ); + const Color& rColor = rBrush.GetColor(); + bTransparent = rColor.GetTransparency() > 0; + rFont.SetFillColor( rColor ); + rCJKFont.SetFillColor( rColor ); + rCTLFont.SetFillColor( rColor ); + } + else + bTransparent = TRUE; + + rFont.SetTransparent( bTransparent ); + rCJKFont.SetTransparent( bTransparent ); + rCTLFont.SetTransparent( bTransparent ); + + Color aBackCol( COL_TRANSPARENT ); + if( !bPreviewBackgroundToCharacter ) + { + if( GetWhich( rSet, SID_ATTR_BRUSH, nWhich ) ) + { + const SvxBrushItem& rBrush = static_cast<const SvxBrushItem&>( rSet.Get( nWhich ) ); + if( GPOS_NONE == rBrush.GetGraphicPos() ) + aBackCol = rBrush.GetColor(); + } + } + SetBackColor( aBackCol ); + + // Font + SetPrevFont( rSet, SID_ATTR_CHAR_FONT, rFont ); + SetPrevFont( rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont ); + SetPrevFont( rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont ); + + // Style + SetPrevFontStyle( rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont ); + SetPrevFontStyle( rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont ); + SetPrevFontStyle( rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont ); + + // Size + SetFontSize( rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont ); + SetFontSize( rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont ); + SetFontSize( rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont ); + + // Language + SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont ); + SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont ); + SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont ); + + // Color + if( GetWhich( rSet, SID_ATTR_CHAR_COLOR, nWhich ) ) + { + const SvxColorItem& rItem = static_cast<const SvxColorItem&>( rSet.Get( nWhich ) ); + Color aCol( rItem.GetValue() ); + rFont.SetColor( aCol ); + + rCJKFont.SetColor( aCol ); + rCTLFont.SetColor( aCol ); + + AutoCorrectFontColor(); // handle color COL_AUTO + } + + // Kerning + if( GetWhich( rSet, SID_ATTR_CHAR_KERNING, nWhich ) ) + { + const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>( rSet.Get( nWhich ) ); + short nKern = static_cast<short>(OutputDevice::LogicToLogic(rItem.GetValue(), rSet.GetPool()->GetMetric(nWhich), MapUnit::MapTwip)); + rFont.SetFixKerning( nKern ); + rCJKFont.SetFixKerning( nKern ); + rCTLFont.SetFixKerning( nKern ); + } + + // Escapement + const sal_uInt8 nProp = 100; + short nEsc; + sal_uInt8 nEscProp; + if( GetWhich( rSet, SID_ATTR_CHAR_ESCAPEMENT, nWhich ) ) + { + const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>( rSet.Get( nWhich ) ); + nEsc = rItem.GetEsc(); + nEscProp = rItem.GetProportionalHeight(); + + if( nEsc == DFLT_ESC_AUTO_SUPER ) + nEsc = DFLT_ESC_SUPER; + else if( nEsc == DFLT_ESC_AUTO_SUB ) + nEsc = DFLT_ESC_SUB; + } + else + { + nEsc = 0; + nEscProp = 100; + } + SetPrevFontEscapement( rFont, nProp, nEscProp, nEsc ); + SetPrevFontEscapement( rCJKFont, nProp, nEscProp, nEsc ); + SetPrevFontEscapement( rCTLFont, nProp, nEscProp, nEsc ); + + // Font width scale + if( GetWhich( rSet, SID_ATTR_CHAR_SCALEWIDTH, nWhich ) ) + { + const SvxCharScaleWidthItem&rItem = static_cast<const SvxCharScaleWidthItem&>( rSet.Get( nWhich ) ); + SetFontWidthScale( rItem.GetValue() ); + } + + Invalidate(); +} + +void FontPrevWindow::Init(const SfxItemSet& rSet) +{ + SvxFont& rFont = GetFont(); + SvxFont& rCJKFont = GetCJKFont(); + SvxFont& rCTLFont = GetCTLFont(); + + initFont(rFont); + initFont(rCJKFont); + initFont(rCTLFont); + ResetSettings(true, true); + + sal_uInt16 nWhich; + nWhich = rSet.GetPool()->GetWhich( SID_CHAR_DLG_PREVIEW_STRING ); + if (ISITEMSET) + { + const SfxStringItem& rItem = static_cast<const SfxStringItem&>( rSet.Get( nWhich ) ); + const OUString& aString = rItem.GetValue(); + if( !aString.isEmpty() ) + SetPreviewText( aString ); + else + SetFontNameAsPreviewText(); + } + + // Underline + FontLineStyle eUnderline; + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_UNDERLINE ); + if( ISITEMSET ) + { + const SvxUnderlineItem& rItem = static_cast<const SvxUnderlineItem&>( rSet.Get( nWhich ) ); + eUnderline = rItem.GetValue(); + } + else + eUnderline = LINESTYLE_NONE; + + rFont.SetUnderline( eUnderline ); + rCJKFont.SetUnderline( eUnderline ); + rCTLFont.SetUnderline( eUnderline ); + + // Overline + FontLineStyle eOverline; + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_OVERLINE ); + if( ISITEMSET ) + { + const SvxOverlineItem& rItem = static_cast<const SvxOverlineItem&>( rSet.Get( nWhich ) ); + eOverline = rItem.GetValue(); + } + else + eOverline = LINESTYLE_NONE; + + rFont.SetOverline( eOverline ); + rCJKFont.SetOverline( eOverline ); + rCTLFont.SetOverline( eOverline ); + + // Strikeout + FontStrikeout eStrikeout; + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_STRIKEOUT ); + if( ISITEMSET ) + { + const SvxCrossedOutItem& rItem = static_cast<const SvxCrossedOutItem&>( rSet.Get( nWhich ) ); + eStrikeout = rItem.GetValue(); + } + else + eStrikeout = STRIKEOUT_NONE; + + rFont.SetStrikeout( eStrikeout ); + rCJKFont.SetStrikeout( eStrikeout ); + rCTLFont.SetStrikeout( eStrikeout ); + + // WordLineMode + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_WORDLINEMODE ); + if( ISITEMSET ) + { + const SvxWordLineModeItem& rItem = static_cast<const SvxWordLineModeItem&>( rSet.Get( nWhich ) ); + rFont.SetWordLineMode( rItem.GetValue() ); + rCJKFont.SetWordLineMode( rItem.GetValue() ); + rCTLFont.SetWordLineMode( rItem.GetValue() ); + } + + // Emphasis + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_EMPHASISMARK ); + if( ISITEMSET ) + { + const SvxEmphasisMarkItem& rItem = static_cast<const SvxEmphasisMarkItem&>( rSet.Get( nWhich ) ); + FontEmphasisMark eMark = rItem.GetEmphasisMark(); + rFont.SetEmphasisMark( eMark ); + rCJKFont.SetEmphasisMark( eMark ); + rCTLFont.SetEmphasisMark( eMark ); + } + + // Relief + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_RELIEF ); + if( ISITEMSET ) + { + const SvxCharReliefItem& rItem = static_cast<const SvxCharReliefItem&>( rSet.Get( nWhich ) ); + FontRelief eFontRelief = rItem.GetValue(); + rFont.SetRelief( eFontRelief ); + rCJKFont.SetRelief( eFontRelief ); + rCTLFont.SetRelief( eFontRelief ); + } + + // Effects + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CASEMAP ); + if( ISITEMSET ) + { + const SvxCaseMapItem& rItem = static_cast<const SvxCaseMapItem&>( rSet.Get( nWhich ) ); + SvxCaseMap eCaseMap = rItem.GetValue(); + rFont.SetCaseMap( eCaseMap ); + rCJKFont.SetCaseMap( eCaseMap ); + // #i78474# small caps do not exist in CTL fonts + rCTLFont.SetCaseMap( eCaseMap == SvxCaseMap::SmallCaps ? SvxCaseMap::NotMapped : eCaseMap ); + } + + // Outline + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_CONTOUR ); + if( ISITEMSET ) + { + const SvxContourItem& rItem = static_cast<const SvxContourItem&>( rSet.Get( nWhich ) ); + bool bOutline = rItem.GetValue(); + rFont.SetOutline( bOutline ); + rCJKFont.SetOutline( bOutline ); + rCTLFont.SetOutline( bOutline ); + } + + // Shadow + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SHADOWED ); + if( ISITEMSET ) + { + const SvxShadowedItem& rItem = static_cast<const SvxShadowedItem&>( rSet.Get( nWhich ) ); + bool bShadow = rItem.GetValue(); + rFont.SetShadow( bShadow ); + rCJKFont.SetShadow( bShadow ); + rCTLFont.SetShadow( bShadow ); + } + + // Background + bool bTransparent; + nWhich = SID_ATTR_BRUSH_CHAR; + if (ISITEMSET) + { + const SvxBrushItem& rBrush = static_cast<const SvxBrushItem&>( rSet.Get( nWhich ) ); + const Color& rColor = rBrush.GetColor(); + bTransparent = rColor.GetTransparency() > 0; + rFont.SetFillColor(rColor); + rCJKFont.SetFillColor(rColor); + rCTLFont.SetFillColor(rColor); + } + else + bTransparent = true; + + rFont.SetTransparent( bTransparent ); + rCJKFont.SetTransparent( bTransparent ); + rCTLFont.SetTransparent( bTransparent ); + + Color aBackCol( COL_TRANSPARENT ); + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_BRUSH ); + if (ISITEMSET) + { + const SvxBrushItem& rBrush = static_cast<const SvxBrushItem&>(rSet.Get(nWhich)); + if (GPOS_NONE == rBrush.GetGraphicPos()) + aBackCol = rBrush.GetColor(); + } + SetBackColor(aBackCol); + + // Font + SetFont(rSet, SID_ATTR_CHAR_FONT, rFont); + SetFont(rSet, SID_ATTR_CHAR_CJK_FONT, rCJKFont); + SetFont(rSet, SID_ATTR_CHAR_CTL_FONT, rCTLFont); + + // Style + SetFontStyle(rSet, SID_ATTR_CHAR_POSTURE, SID_ATTR_CHAR_WEIGHT, rFont); + SetFontStyle(rSet, SID_ATTR_CHAR_CJK_POSTURE, SID_ATTR_CHAR_CJK_WEIGHT, rCJKFont); + SetFontStyle(rSet, SID_ATTR_CHAR_CTL_POSTURE, SID_ATTR_CHAR_CTL_WEIGHT, rCTLFont); + + // Size + SetFontSize(rSet, SID_ATTR_CHAR_FONTHEIGHT, rFont); + SetFontSize(rSet, SID_ATTR_CHAR_CJK_FONTHEIGHT, rCJKFont); + SetFontSize(rSet, SID_ATTR_CHAR_CTL_FONTHEIGHT, rCTLFont); + + // Language + SetFontLang( rSet, SID_ATTR_CHAR_LANGUAGE, rFont ); + SetFontLang( rSet, SID_ATTR_CHAR_CJK_LANGUAGE, rCJKFont ); + SetFontLang( rSet, SID_ATTR_CHAR_CTL_LANGUAGE, rCTLFont ); + + // Color + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_COLOR ); + if( ISITEMSET ) + { + const SvxColorItem& rItem = static_cast<const SvxColorItem&>( rSet.Get( nWhich ) ); + Color aCol( rItem.GetValue() ); + rFont.SetColor( aCol ); + rCJKFont.SetColor( aCol ); + rCTLFont.SetColor( aCol ); + + AutoCorrectFontColor(); // handle color COL_AUTO + } + + // Kerning + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_KERNING ); + if( ISITEMSET ) + { + const SvxKerningItem& rItem = static_cast<const SvxKerningItem&>( rSet.Get( nWhich ) ); + short nKern = static_cast<short>(OutputDevice::LogicToLogic(rItem.GetValue(), rSet.GetPool()->GetMetric(nWhich), MapUnit::MapTwip)); + rFont.SetFixKerning( nKern ); + rCJKFont.SetFixKerning( nKern ); + rCTLFont.SetFixKerning( nKern ); + } + + // Escapement + nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_ESCAPEMENT ); + const sal_uInt8 nProp = 100; + short nEsc; + sal_uInt8 nEscProp; + if( ISITEMSET ) + { + const SvxEscapementItem& rItem = static_cast<const SvxEscapementItem&>( rSet.Get( nWhich ) ); + nEsc = rItem.GetEsc(); + nEscProp = rItem.GetProportionalHeight(); + + if( nEsc == DFLT_ESC_AUTO_SUPER ) + nEsc = DFLT_ESC_SUPER; + else if( nEsc == DFLT_ESC_AUTO_SUB ) + nEsc = DFLT_ESC_SUB; + } + else + { + nEsc = 0; + nEscProp = 100; + } + + SetFontEscapement( nProp, nEscProp, nEsc ); + + // Font width scale + SetFontWidthScale( rSet ); + + Invalidate(); +} + +void FontPrevWindow::SetFont( const SfxItemSet& rSet, sal_uInt16 nSlot, SvxFont& rFont ) +{ + sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nSlot ); + if( ISITEMSET ) + { + const SvxFontItem& rFontItem = static_cast<const SvxFontItem&>( rSet.Get(nWhich) ); + rFont.SetFamily( rFontItem.GetFamily() ); + rFont.SetFamilyName( rFontItem.GetFamilyName() ); + rFont.SetPitch( rFontItem.GetPitch() ); + rFont.SetCharSet( rFontItem.GetCharSet() ); + rFont.SetStyleName( rFontItem.GetStyleName() ); + } +} + +void FontPrevWindow::SetFontStyle( const SfxItemSet& rSet, sal_uInt16 nPosture, sal_uInt16 nWeight, SvxFont& rFont ) +{ + sal_uInt16 nWhich = rSet.GetPool()->GetWhich( nPosture ); + if( ISITEMSET ) + { + const SvxPostureItem& rItem = static_cast<const SvxPostureItem&>( rSet.Get( nWhich ) ); + rFont.SetItalic( rItem.GetValue() != ITALIC_NONE ? ITALIC_NORMAL : ITALIC_NONE ); + } + + nWhich = rSet.GetPool()->GetWhich( nWeight ); + if( ISITEMSET ) + { + const SvxWeightItem& rItem = static_cast<const SvxWeightItem&>( rSet.Get( nWhich ) ); + rFont.SetWeight( rItem.GetValue() != WEIGHT_NORMAL ? WEIGHT_BOLD : WEIGHT_NORMAL ); + } +} + +void FontPrevWindow::SetFontWidthScale( const SfxItemSet& rSet ) +{ + sal_uInt16 nWhich = rSet.GetPool()->GetWhich( SID_ATTR_CHAR_SCALEWIDTH ); + if( ISITEMSET ) + { + const SvxCharScaleWidthItem& rItem = static_cast<const SvxCharScaleWidthItem&>( rSet.Get( nWhich ) ); + + SetFontWidthScale( rItem.GetValue() ); + } +} + +void FontPrevWindow::SetFontEscapement(sal_uInt8 nProp, sal_uInt8 nEscProp, short nEsc) +{ + setFontEscapement(GetFont(), nProp, nEscProp, nEsc); + setFontEscapement(GetCJKFont(), nProp, nEscProp, nEsc); + setFontEscapement(GetCTLFont(), nProp, nEscProp, nEsc); + Invalidate(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/measctrl.cxx b/svx/source/dialog/measctrl.cxx index b4fdf30ad4bb..6888c6cf0b6d 100644 --- a/svx/source/dialog/measctrl.cxx +++ b/svx/source/dialog/measctrl.cxx @@ -68,7 +68,7 @@ VCL_BUILDER_FACTORY_CONSTRUCTOR(SvxXMeasurePreview, 0) Size SvxXMeasurePreview::GetOptimalSize() const { - return getPreviewStripSize(this); + return getPreviewStripSize(*this); } SvxXMeasurePreview::~SvxXMeasurePreview() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits