[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

2023-11-17 Thread Balazs Varga (via logerrit)
 include/unotools/compatibility.hxx   |   55 
 sw/source/ui/config/optcomp.cxx  |   18 -
 unotools/source/config/compatibility.cxx |   60 +++
 3 files changed, 132 insertions(+), 1 deletion(-)

New commits:
commit 35f59457ff434b7b97cad6ce1dbef6ff07f7bc96
Author: Balazs Varga 
AuthorDate: Thu Nov 16 17:03:39 2023 +0100
Commit: Balazs Varga 
CommitDate: Fri Nov 17 18:55:22 2023 +0100

tdf#158135 - UI: Part 30 - Unify lockdown behavior of Options dialog

for Writer - Compatibility Page.

Change-Id: Id9ad445b451b332314f72f54e183730097584a74
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159513
Tested-by: Jenkins
Reviewed-by: Balazs Varga 

diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index 620d3c1c3fa4..9c2acefcf1d7 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -131,8 +132,50 @@ class SvtCompatibilityEntry
 setValue(rIdx, css::uno::Any(rValue));
 }
 
+bool getPropertyReadOnly(const Index rIdx) const
+{
+if (static_cast(rIdx) < getElementCount())
+{
+return m_aPropertyReadOnly.at(static_cast(rIdx));
+}
+else
+{
+/* Wrong index. */
+assert(false);
+return false;
+}
+}
+
+void setPropertyReadOnly(const Index rIdx, const bool bReadOnly)
+{
+if (static_cast(rIdx) < getElementCount())
+{
+m_aPropertyReadOnly.insert({ static_cast(rIdx), bReadOnly 
});
+}
+else
+{
+/* Wrong index. */
+assert(false);
+}
+}
+
+bool haveReadOnlyProperty() const
+{
+bool bRet = false;
+for (const auto& pair : m_aPropertyReadOnly)
+{
+if (pair.second == true)
+{
+bRet = true;
+break;
+}
+}
+return bRet;
+}
+
 private:
 std::vector m_aPropertyValue;
+std::map m_aPropertyReadOnly;
 };
 
 
/*-
@@ -183,6 +226,18 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final : 
public utl::detail::Opt
 
*//*-*/
 std::vector< SvtCompatibilityEntry > GetList() const;
 
+
/*-
+@short  return property/option is readonly or not
+@descr  Call it to get the readonly status of default entry of
+compatibility options.
+@return Return true if the compatibility option is true, 
otherwise false.
+
+@onerrorWe return false.
+
*//*-*/
+bool GetPropertyReadOnly( SvtCompatibilityEntry::Index rIdx ) const;
+bool GetDefaultPropertyReadOnly( SvtCompatibilityEntry::Index rIdx ) 
const;
+bool HaveDefaultReadOnlyProperty() const;
+
 private:
 std::shared_ptr m_pImpl;
 
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index a1ea231d305c..1393b2864d95 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -216,7 +216,7 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 rEntry.getValue( SvtCompatibilityEntry::Index::NoExtLeading 
),
 rEntry.getValue( 
SvtCompatibilityEntry::Index::UseLineSpacing ),
 rEntry.getValue( 
SvtCompatibilityEntry::Index::AddTableSpacing ),
-
rEntry.getValue(SvtCompatibilityEntry::Index::AddTableLineSpacing),
+rEntry.getValue( 
SvtCompatibilityEntry::Index::AddTableLineSpacing),
 rEntry.getValue( 
SvtCompatibilityEntry::Index::UseObjectPositioning ),
 rEntry.getValue( 
SvtCompatibilityEntry::Index::UseOurTextWrapping ),
 rEntry.getValue( 
SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
@@ -277,9 +277,11 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, 
weld::Button&, void)
 void SwCompatibilityOptPage::SetCurrentOptions( sal_uInt32 nOptions )
 {
 const int nCount = m_xOptionsLB->n_children();
+const OUString aOptionsName = m_xFormattingLB->get_active_text();
 OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry 
overflow" );
 for (int i = 0; i < nCount; ++i)
 {
+bool 

[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

2023-06-23 Thread Baole Fang (via logerrit)
 include/unotools/charclass.hxx |4 
 sw/source/core/edit/autofmt.cxx|2 +-
 unotools/source/i18n/charclass.cxx |   17 +
 3 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit caab94a3e0387bde05538cff91ff13446f330785
Author: Baole Fang 
AuthorDate: Fri Jun 23 11:47:54 2023 -0400
Commit: خالد حسني 
CommitDate: Fri Jun 23 22:20:58 2023 +0200

tdf#142437: Fix word boundary detection in autocorrect

Marks (combining and spacing) were incorrectly considered word separators,
because isLetterNumeric() matches only for letters and numbers.

The new isBase() matches any character with BASE_FORM character class, 
which covers letters, numbers, and marks.

Change-Id: I27ec2f7fb8d360791a280d10aba9b6d16e7cfb71
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153509
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/include/unotools/charclass.hxx b/include/unotools/charclass.hxx
index 7cb35ba2a594..bc91aca63631 100644
--- a/include/unotools/charclass.hxx
+++ b/include/unotools/charclass.hxx
@@ -58,6 +58,9 @@ inline constexpr sal_Int32 nCharClassNumericTypeMask =
 css::i18n::KCharacterType::PRINTABLE |
 css::i18n::KCharacterType::BASE_FORM;
 
+inline constexpr sal_Int32 nCharClassBaseType =
+css::i18n::KCharacterType::BASE_FORM;
+
 class UNOTOOLS_DLLPUBLIC CharClass
 {
 LanguageTag maLanguageTag;
@@ -167,6 +170,7 @@ public:
 bool isDigit( const OUString& rStr, sal_Int32 nPos ) const;
 bool isAlphaNumeric( const OUString& rStr, sal_Int32 nPos ) const;
 bool isLetterNumeric( const OUString& rStr, sal_Int32 nPos ) const;
+bool isBase( const OUString& rStr, sal_Int32 nPos ) const;
 bool isUpper( const OUString& rStr, sal_Int32 nPos ) const;
 bool isLetter( const OUString& rStr ) const;
 bool isNumeric( const OUString& rStr ) const;
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 2c9eb69ac16a..010e0b20b80e 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -2110,7 +2110,7 @@ void SwAutoFormat::AutoCorrect(TextFrameIndex nPos)
 bFirstSent = true;
 [[fallthrough]];
 default:
-if (!(rAppCC.isLetterNumeric(*pText, sal_Int32(nPos))
+if (!(rAppCC.isBase(*pText, sal_Int32(nPos))
 || '/' == cChar )) //  '/' should not be a word 
separator (e.g. '1/2' needs to be handled as one word for replacement)
 {
 --nPos; // revert ++nPos which was decremented in for 
loop
diff --git a/unotools/source/i18n/charclass.cxx 
b/unotools/source/i18n/charclass.cxx
index be3a9f4f0ee0..423f9530f2cb 100644
--- a/unotools/source/i18n/charclass.cxx
+++ b/unotools/source/i18n/charclass.cxx
@@ -253,6 +253,23 @@ bool CharClass::isLetterNumeric( const OUString& rStr ) 
const
 return false;
 }
 
+bool CharClass::isBase( const OUString& rStr, sal_Int32 nPos ) const
+{
+sal_Unicode c = rStr[nPos];
+if ( c < 128 )
+return rtl::isAsciiAlphanumeric( c );
+
+try
+{
+return  (xCC->getCharacterType( rStr, nPos, getMyLocale() ) & 
nCharClassBaseType ) != 0;
+}
+catch ( const Exception& )
+{
+TOOLS_WARN_EXCEPTION("unotools.i18n", "" );
+}
+return false;
+}
+
 bool CharClass::isUpper( const OUString& rStr, sal_Int32 nPos ) const
 {
 sal_Unicode c = rStr[nPos];


[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

2022-12-30 Thread Noel Grandin (via logerrit)
 include/unotools/compatibility.hxx   |   11 ---
 sw/source/ui/config/optcomp.cxx  |   10 --
 unotools/source/config/compatibility.cxx |2 --
 3 files changed, 8 insertions(+), 15 deletions(-)

New commits:
commit c6f756e968bbb72522bd01dea283288a61a286a7
Author: Noel Grandin 
AuthorDate: Sat Dec 31 08:52:53 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Dec 31 07:49:03 2022 +

tdf#152676 Writer: Compatibility options no longer saved as default

regression from
commit 78adf246d5e99d0f5d91d2e03c1379b154289d8d
Date:   Mon Jul 26 10:54:36 2021 +0200
return SvtCompatibilityEntry from SvtCompatibilityOptions::GetList

where I mistakenly assumed that the bIsDefault flag in
SvtCompatibilityEntry was being set by the SvtCompatibilityOptions
code. Rather remove this field if it is not going to be maintained
properly.

Change-Id: I23963ae885563d5abc8a99cfd144d7fe00c6f192
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144882
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index 73e77a598ec9..72017812ab8b 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -129,19 +129,8 @@ class SvtCompatibilityEntry
 setValue(rIdx, css::uno::Any(rValue));
 }
 
-bool isDefaultEntry() const
-{
-return m_bDefaultEntry;
-}
-
-void setDefaultEntry( bool rValue )
-{
-m_bDefaultEntry = rValue;
-}
-
 private:
 std::vector m_aPropertyValue;
-bool   m_bDefaultEntry;
 };
 
 
/*-
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 0ba1b147614c..d760e885a66e 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -205,10 +205,11 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 {
 const OUString sEntryName = rEntry.getValue( 
SvtCompatibilityEntry::Index::Name );
 const bool bIsUserEntry= ( sEntryName == 
SvtCompatibilityEntry::USER_ENTRY_NAME );
+const bool bIsDefaultEntry = ( sEntryName == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME );
 
 m_pImpl->m_aList.push_back( rEntry );
 
-if ( rEntry.isDefaultEntry() )
+if ( bIsDefaultEntry )
 continue;
 
 OUString sNewEntry;
@@ -260,7 +261,12 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, 
weld::Button&, void)
 return;
 
 auto pItem = std::find_if(m_pImpl->m_aList.begin(), m_pImpl->m_aList.end(),
-[](const SvtCompatibilityEntry& rItem) { return 
rItem.isDefaultEntry(); });
+[](const SvtCompatibilityEntry& rItem)
+{
+const OUString sEntryName = rItem.getValue( 
SvtCompatibilityEntry::Index::Name );
+const bool bIsDefaultEntry = ( sEntryName == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME );
+return bIsDefaultEntry;
+});
 if (pItem != m_pImpl->m_aList.end())
 {
 const sal_Int32 nCount = m_xOptionsLB->n_children();
diff --git a/unotools/source/config/compatibility.cxx 
b/unotools/source/config/compatibility.cxx
index 4f0e1d2ac20c..eed01cce1c8b 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -65,8 +65,6 @@ SvtCompatibilityEntry::SvtCompatibilityEntry()
 setValue( Index::SubtractFlysAnchoredAtFlys, false );
 setValue( Index::EmptyDbFieldHidesPara, true );
 setValue( Index::AddTableLineSpacing, false );
-
-setDefaultEntry( false );
 }
 
 OUString SvtCompatibilityEntry::getName( const Index rIdx )


[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

2021-07-26 Thread Noel Grandin (via logerrit)
 include/unotools/compatibility.hxx   |3 +
 sw/source/ui/config/optcomp.cxx  |   53 ---
 unotools/source/config/compatibility.cxx |   26 ++-
 3 files changed, 27 insertions(+), 55 deletions(-)

New commits:
commit 78adf246d5e99d0f5d91d2e03c1379b154289d8d
Author: Noel Grandin 
AuthorDate: Mon Jul 26 10:54:36 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 26 20:50:16 2021 +0200

return SvtCompatibilityEntry from SvtCompatibilityOptions::GetList

instead of converting back and forth

Change-Id: Iec913494ccad65ebff76bf7b6cf5b2440fbade42
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119514
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index ba8de4e784b5..85c6c2484a31 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace com::sun::star::beans { struct PropertyValue; }
 namespace osl { class Mutex; }
@@ -211,7 +212,7 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions final : 
public utl::detail::Opt
 
 @onerrorWe return an empty list.
 
*//*-*/
-css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > 
GetList() const;
+std::vector< SvtCompatibilityEntry > GetList() const;
 
 private:
 std::shared_ptr m_pImpl;
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index bea377047ae9..071b2fa1c76c 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -206,27 +206,16 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 m_xMain->set_label(rText.replaceAll("%DOCNAME", sDocTitle));
 
 // loading file formats
-const Sequence< Sequence< PropertyValue > > aList = 
m_aConfigItem.GetList();
+const std::vector< SvtCompatibilityEntry > aList = m_aConfigItem.GetList();
 
-SvtCompatibilityEntry aEntry;
-
-for ( const Sequence< PropertyValue >& rEntry : aList )
+for ( const SvtCompatibilityEntry& rEntry : aList )
 {
-for ( const PropertyValue& aValue : rEntry )
-{
-aEntry.setValue( SvtCompatibilityEntry::getIndex(aValue.Name), 
aValue.Value );
-}
-
-const OUString sEntryName = aEntry.getValue( 
SvtCompatibilityEntry::Index::Name );
-
+const OUString sEntryName = rEntry.getValue( 
SvtCompatibilityEntry::Index::Name );
 const bool bIsUserEntry= ( sEntryName == 
SvtCompatibilityEntry::USER_ENTRY_NAME );
-const bool bIsDefaultEntry = ( sEntryName == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME );
-
-aEntry.setDefaultEntry( bIsDefaultEntry );
 
-m_pImpl->m_aList.push_back( aEntry );
+m_pImpl->m_aList.push_back( rEntry );
 
-if ( aEntry.isDefaultEntry() )
+if ( rEntry.isDefaultEntry() )
 continue;
 
 OUString sNewEntry;
@@ -245,22 +234,22 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 sNewEntry = sEntryName;
 
 sal_uInt32 nOptions = convertBools2Ulong_Impl(
-aEntry.getValue( SvtCompatibilityEntry::Index::UsePrtMetrics 
),
-aEntry.getValue( SvtCompatibilityEntry::Index::AddSpacing ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::AddSpacingAtPages ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::UseOurTabStops ),
-aEntry.getValue( SvtCompatibilityEntry::Index::NoExtLeading 
),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::UseLineSpacing ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::AddTableSpacing ),
-
aEntry.getValue(SvtCompatibilityEntry::Index::AddTableLineSpacing),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::UseObjectPositioning ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::UseOurTextWrapping ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::ExpandWordSpace ),
-aEntry.getValue( SvtCompatibilityEntry::Index::ProtectForm ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::MsWordTrailingBlanks ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::SubtractFlysAnchoredAtFlys ),
-aEntry.getValue( 
SvtCompatibilityEntry::Index::EmptyDbFieldHidesPara ) );
+rEntry.getValue( SvtCompatibilityEntry::Index::UsePrtMetrics 
),
+rEntry.getValue( SvtCompatibilityEntry::Index::AddSpacing ),
+rEntry.getValue( 
SvtCompatibilityEntry::Index::AddSpacingAtPages ),
+rEntry.getValue( 
SvtCompatibilityEntry::Index::UseOurTabStops ),
+rEntry.getValue( SvtCompatibili

[Libreoffice-commits] core.git: include/unotools sw/source unotools/source

2021-07-26 Thread Noel Grandin (via logerrit)
 include/unotools/compatibility.hxx   |   11 ++-
 sw/source/ui/config/optcomp.cxx  |4 ++--
 unotools/source/config/compatibility.cxx |4 ++--
 3 files changed, 6 insertions(+), 13 deletions(-)

New commits:
commit d14ab85a4446279e24aa6b6d5e8bfedb48ccdfe1
Author: Noel Grandin 
AuthorDate: Mon Jul 26 10:44:16 2021 +0200
Commit: Noel Grandin 
CommitDate: Mon Jul 26 20:49:25 2021 +0200

convert these into constants

Change-Id: Ie3e3b497cfeb8c9e9456fb86a04f409658116e1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119513
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index 3c025224ea1b..ba8de4e784b5 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -75,15 +75,8 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
 
 static OUString getName( const Index rIdx );
 
-static OUString getUserEntryName()
-{
-return "_user";
-}
-
-static OUString getDefaultEntryName()
-{
-return "_default";
-}
+static constexpr OUStringLiteral USER_ENTRY_NAME = u"_user";
+static constexpr OUStringLiteral DEFAULT_ENTRY_NAME = u"_default";
 
 static Index getIndex( std::u16string_view rName )
 {
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 8a57f054abca..bea377047ae9 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -219,8 +219,8 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
 
 const OUString sEntryName = aEntry.getValue( 
SvtCompatibilityEntry::Index::Name );
 
-const bool bIsUserEntry= ( sEntryName == 
SvtCompatibilityEntry::getUserEntryName() );
-const bool bIsDefaultEntry = ( sEntryName == 
SvtCompatibilityEntry::getDefaultEntryName() );
+const bool bIsUserEntry= ( sEntryName == 
SvtCompatibilityEntry::USER_ENTRY_NAME );
+const bool bIsDefaultEntry = ( sEntryName == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME );
 
 aEntry.setDefaultEntry( bIsDefaultEntry );
 
diff --git a/unotools/source/config/compatibility.cxx 
b/unotools/source/config/compatibility.cxx
index 5556a0a231d4..c3ac4b6c532a 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -186,7 +186,7 @@ 
SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() : ConfigItem( ROOTN
 
 m_aOptions.push_back( aItem );
 
-if ( !bDefaultFound && aItem.getValue( 
SvtCompatibilityEntry::Index::Name ) == 
SvtCompatibilityEntry::getDefaultEntryName() )
+if ( !bDefaultFound && aItem.getValue( 
SvtCompatibilityEntry::Index::Name ) == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME )
 {
 SvtSysLocale aSysLocale;
 css::lang::Locale aLocale = 
aSysLocale.GetLanguageTag().getLocale();
@@ -209,7 +209,7 @@ void SvtCompatibilityOptions_Impl::AppendItem( const 
SvtCompatibilityEntry& aIte
 m_aOptions.push_back( aItem );
 
 // default item reset?
-if ( aItem.getValue( SvtCompatibilityEntry::Index::Name ) == 
SvtCompatibilityEntry::getDefaultEntryName() )
+if ( aItem.getValue( SvtCompatibilityEntry::Index::Name ) == 
SvtCompatibilityEntry::DEFAULT_ENTRY_NAME )
 m_aDefOptions = aItem;
 
 SetModified();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits