cui/source/dialogs/FontFeaturesDialog.cxx | 30 ++++++++++++++++++++++++------ cui/source/inc/FontFeaturesDialog.hxx | 8 +++++++- cui/uiconfig/ui/fontfragment.ui | 1 + vcl/source/gdi/metaact.cxx | 2 ++ 4 files changed, 34 insertions(+), 7 deletions(-)
New commits: commit 4d6fcd7908f6db892e8d5fb3cabf7e0fe49328c4 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Apr 24 12:52:22 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Apr 24 20:47:55 2023 +0200 Resolves: tdf#153441 use a TriStateEnabled helper Change-Id: I976e4271a072bfb53c676091509e1d4ef7dbcccb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150934 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx b/cui/source/dialogs/FontFeaturesDialog.cxx index 1656f50bb5b1..e9aba0a6e409 100644 --- a/cui/source/dialogs/FontFeaturesDialog.cxx +++ b/cui/source/dialogs/FontFeaturesDialog.cxx @@ -109,19 +109,21 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea { nIdx = nStylisticSets++; m_xStylisticSetsBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xStylisticSetsGrid.get()); + m_aFeatureItems.emplace_back( + std::make_unique<FontFeatureItem>(m_xStylisticSetsGrid.get())); } else if (rFontFeature.isCharacterVariant()) { nIdx = nCharacterVariants++; m_xCharacterVariantsBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xCharacterVariantsGrid.get()); + m_aFeatureItems.emplace_back( + std::make_unique<FontFeatureItem>(m_xCharacterVariantsGrid.get())); } else { nIdx = nOtherFeatures++; m_xContentBox->set_visible(true); - m_aFeatureItems.emplace_back(m_xContentGrid.get()); + m_aFeatureItems.emplace_back(std::make_unique<FontFeatureItem>(m_xContentGrid.get())); } int32_t nValue = 0; @@ -130,7 +132,7 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea else nValue = aDefinition.getDefault(); - FontFeatureItem& aCurrentItem = m_aFeatureItems.back(); + FontFeatureItem& aCurrentItem = *m_aFeatureItems.back(); aCurrentItem.m_aFeatureCode = nFontFeatureCode; aCurrentItem.m_nDefault = aDefinition.getDefault(); @@ -158,11 +160,19 @@ int FontFeaturesDialog::fillGrid(std::vector<vcl::font::Feature> const& rFontFea else { if (nValue < 0) + { aCurrentItem.m_xCheck->set_state(TRISTATE_INDET); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = true; + aCurrentItem.m_aTriStateEnabled.eState = TRISTATE_INDET; + } else + { aCurrentItem.m_xCheck->set_state(nValue > 0 ? TRISTATE_TRUE : TRISTATE_FALSE); + aCurrentItem.m_aTriStateEnabled.bTriStateEnabled = false; + aCurrentItem.m_aTriStateEnabled.eState = aCurrentItem.m_xCheck->get_state(); + } aCurrentItem.m_xCheck->set_label(aDefinition.getDescription()); - aCurrentItem.m_xCheck->connect_toggled(aCheckBoxToggleHandler); + aCurrentItem.m_aToggleHdl = aCheckBoxToggleHandler; aCurrentItem.m_xCheck->show(); } @@ -188,6 +198,13 @@ void FontFeaturesDialog::updateFontPreview() m_aPreviewWindow.SetFont(rPreviewFont, rPreviewFontCJK, rPreviewFontCTL); } +IMPL_LINK(FontFeatureItem, CheckBoxToggledHdl, weld::Toggleable&, rToggle, void) +{ + m_aTriStateEnabled.ButtonToggled(rToggle); + m_aTriStateEnabled.bTriStateEnabled = false; + m_aToggleHdl.Call(rToggle); +} + IMPL_LINK_NOARG(FontFeaturesDialog, CheckBoxToggledHdl, weld::Toggleable&, void) { updateFontPreview(); @@ -204,8 +221,9 @@ OUString FontFeaturesDialog::createFontNameWithFeatures() OUStringBuffer sNameSuffix; bool bFirst = true; - for (const FontFeatureItem& rItem : m_aFeatureItems) + for (const auto& rEntry : m_aFeatureItems) { + const FontFeatureItem& rItem(*rEntry); if (rItem.m_xCheck->get_visible()) { if (rItem.m_xCheck->get_state() != TRISTATE_INDET) diff --git a/cui/source/inc/FontFeaturesDialog.hxx b/cui/source/inc/FontFeaturesDialog.hxx index c4eb43b79e98..93ba0cb9f80d 100644 --- a/cui/source/inc/FontFeaturesDialog.hxx +++ b/cui/source/inc/FontFeaturesDialog.hxx @@ -29,21 +29,27 @@ struct FontFeatureItem , m_xCombo(m_xBuilder->weld_combo_box("combo")) , m_xCheck(m_xBuilder->weld_check_button("check")) { + m_xCheck->connect_toggled(LINK(this, FontFeatureItem, CheckBoxToggledHdl)); } sal_uInt32 m_aFeatureCode; sal_Int32 m_nDefault; + weld::TriStateEnabled m_aTriStateEnabled; + Link<weld::Toggleable&, void> m_aToggleHdl; std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Widget> m_xContainer; std::unique_ptr<weld::Label> m_xText; std::unique_ptr<weld::ComboBox> m_xCombo; std::unique_ptr<weld::CheckButton> m_xCheck; + +private: + DECL_LINK(CheckBoxToggledHdl, weld::Toggleable&, void); }; class FontFeaturesDialog : public weld::GenericDialogController { private: - std::vector<FontFeatureItem> m_aFeatureItems; + std::vector<std::unique_ptr<FontFeatureItem>> m_aFeatureItems; OUString m_sFontName; OUString m_sResultFontName; diff --git a/cui/uiconfig/ui/fontfragment.ui b/cui/uiconfig/ui/fontfragment.ui index e66cd71b7ba6..dca735e5fe1e 100644 --- a/cui/uiconfig/ui/fontfragment.ui +++ b/cui/uiconfig/ui/fontfragment.ui @@ -30,6 +30,7 @@ <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="no_show_all">True</property> + <property name="inconsistent">True</property> <property name="draw_indicator">True</property> </object> <packing> commit 26b7d00c24c4d85d004e3840fb9053e4c88c1fee Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Mon Apr 24 16:27:52 2023 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Apr 24 20:47:43 2023 +0200 ofz#58241 Integer-overflow Change-Id: Ie5b82df4642c786e309022e3b5a436aef66d1137 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150945 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index d410dfe35181..6f4f75ccc4ba 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -1318,6 +1318,8 @@ void MetaHatchAction::Execute( OutputDevice* pOut ) { if (!AllowRect(pOut->LogicToPixel(maPolyPoly.GetBoundRect()))) return; + if (!AllowDim(pOut->LogicToPixel(Point(maHatch.GetDistance(), 0)).X())) + return; pOut->DrawHatch( maPolyPoly, maHatch ); }