[Libreoffice-commits] core.git: Branch 'libreoffice-7-5-3' - cui/source cui/uiconfig

2023-04-25 Thread Caolán McNamara (via logerrit)
 cui/source/dialogs/FontFeaturesDialog.cxx |   30 --
 cui/source/inc/FontFeaturesDialog.hxx |8 +++-
 cui/uiconfig/ui/fontfragment.ui   |1 +
 3 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 04ae8bda4a219d1b6b3628813d76b5d8c984ced9
Author: Caolán McNamara 
AuthorDate: Mon Apr 24 12:52:22 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue Apr 25 10:28:31 2023 +0200

Resolves: tdf#153441 use a TriStateEnabled helper

Change-Id: I976e4271a072bfb53c676091509e1d4ef7dbcccb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150916
Reviewed-by: خالد حسني 
Reviewed-by: Xisco Fauli 
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/cui/source/dialogs/FontFeaturesDialog.cxx 
b/cui/source/dialogs/FontFeaturesDialog.cxx
index ab6063c9b6c3..b394495b3ae3 100644
--- a/cui/source/dialogs/FontFeaturesDialog.cxx
+++ b/cui/source/dialogs/FontFeaturesDialog.cxx
@@ -109,19 +109,21 @@ int 
FontFeaturesDialog::fillGrid(std::vector const& rFontFea
 {
 nIdx = nStylisticSets++;
 m_xStylisticSetsBox->set_visible(true);
-m_aFeatureItems.emplace_back(m_xStylisticSetsGrid.get());
+m_aFeatureItems.emplace_back(
+std::make_unique(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(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(m_xContentGrid.get()));
 }
 
 int32_t nValue = 0;
@@ -130,7 +132,7 @@ int 
FontFeaturesDialog::fillGrid(std::vector 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 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 m_aToggleHdl;
 std::unique_ptr m_xBuilder;
 std::unique_ptr m_xContainer;
 std::unique_p

[Libreoffice-commits] core.git: Branch 'libreoffice-7-5-3' - cui/source

2023-04-17 Thread Caolán McNamara (via logerrit)
 cui/source/dialogs/hyphen.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8e379477def5085743d2b024bb99eba0ebc8
Author: Caolán McNamara 
AuthorDate: Sat Apr 15 20:25:36 2023 +0100
Commit: Michael Stahl 
CommitDate: Mon Apr 17 14:19:51 2023 +0200

Resolves: tdf#153958 Hyphenation crashes with -Alte...

nPos2 is 0 due to the -, so aLeft is empty, nPos is set to 0
then incremented to 1, aLeft.replaceFirst is run after its end pos
so crashes/asserts. Presumably we can do nothing meaningful here
so skip if nPos2 is 0

Change-Id: I09754c4b2567fe5c1b4c36de0b36ee99f575244d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150327
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos 
(cherry picked from commit 7584e403d57097ed4cc2d827d68895ec35cf805f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150502
Reviewed-by: Xisco Fauli 
Reviewed-by: Caolán McNamara 
Tested-by: Michael Stahl 
Reviewed-by: Michael Stahl 

diff --git a/cui/source/dialogs/hyphen.cxx b/cui/source/dialogs/hyphen.cxx
index ccd7de8c..259ec5d03395 100644
--- a/cui/source/dialogs/hyphen.cxx
+++ b/cui/source/dialogs/hyphen.cxx
@@ -161,7 +161,7 @@ OUString SvxHyphenWordDialog::EraseUnusableHyphens_Impl()
 // 2) remove all hyphenation positions from the start that are not 
considered by the core
 const std::u16string_view aSearchRange( aTxt.subView( 0, nPos1 ) );
 size_t nPos2 = aSearchRange.rfind( '-' );  // the '-' position the 
core will use by default
-if (nPos2 != std::u16string_view::npos )
+if (nPos2 != std::u16string_view::npos && nPos2 != 0)
 {
 OUString aLeft( aSearchRange.substr( 0, nPos2 ) );
 nPos = 0;