include/unotools/compatibility.hxx                                |    4 
 officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs |    8 +
 sw/source/core/doc/DocumentSettingManager.cxx                     |    2 
 sw/source/core/view/viewsh.cxx                                    |    5 -
 sw/source/ui/config/optcomp.cxx                                   |   48 
++++++++--
 sw/uiconfig/swriter/ui/optcompatpage.ui                           |    1 
 unotools/source/config/compatibility.cxx                          |    2 
 7 files changed, 62 insertions(+), 8 deletions(-)

New commits:
commit d263af834a7d6b506ac72d009f7a96cebe9e4140
Author:     Michael Stahl <michael.st...@cib.de>
AuthorDate: Wed Sep 23 18:51:54 2020 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Mon Sep 28 02:20:22 2020 +0200

    tdf#134782 sw,unotools,officecfg: adapt configuration and UI
    
    Store AddParaLineSpacingToTableCells in configuration as
    "AddTableLineSpacing", consistently inconsistent like AddTableSpacing
    (the <desc> elements are not subject to translation).
    
    Adapt SwCompatibilityOptPage with some ugly hacks to allow 3 different
    states (TriState) for the corresponding checkbox that map to false/false,
    true/false and true/true.
    
    The checkbox widget doesn't allow to change *to* indeterminate but at
    least the status of the document can be displayed this way,
    with a non-obvious tweak to optcompatpage.ui to reference "checktri1"
    column.
    
    Change-Id: I5f32e05c93b5e16e782cba5d1d055809d9e5e251
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103318
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>
    (cherry picked from commit 68aec8fd57eda8c05926b7f361dc102772f2c501)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103360
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    (cherry picked from commit 70b2ee8ce4aa081a608bbde4f3125300675934c5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103336
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>
    Tested-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/include/unotools/compatibility.hxx 
b/include/unotools/compatibility.hxx
index 24f2da53e590..812b8cc480bd 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -62,6 +62,10 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
             MsWordTrailingBlanks,
             SubtractFlysAnchoredAtFlys,
             EmptyDbFieldHidesPara,
+            /// special entry: optcomp.cxx converts the other values to
+            /// integers but not this one because it doesn't have its own
+            /// checkbox, so keep it at the end!
+            AddTableLineSpacing,
 
             /* Should be at the end. Do not remove it. */
             INVALID
diff --git a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
index 71007f80c22e..77d33d1fbc0c 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Compatibility.xcs
@@ -76,7 +76,13 @@
       </prop>
       <prop oor:name="AddTableSpacing" oor:type="xs:boolean" 
oor:nillable="false">
         <info>
-          <desc>???</desc>
+          <desc>Add paragraph and table spacing at bottom of table cells</desc>
+        </info>
+        <value>true</value>
+      </prop>
+      <prop oor:name="AddTableLineSpacing" oor:type="xs:boolean" 
oor:nillable="false">
+        <info>
+          <desc>Add paragraph line spacing at bottom of table cells</desc>
         </info>
         <value>true</value>
       </prop>
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx 
b/sw/source/core/doc/DocumentSettingManager.cxx
index a29c5bc6275f..726db3242647 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -112,7 +112,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc 
&rDoc)
         mbAddExternalLeading                = !aOptions.GetDefault( 
SvtCompatibilityEntry::Index::NoExtLeading );
         mbOldLineSpacing                    = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::UseLineSpacing );
         mbAddParaSpacingToTableCells        = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::AddTableSpacing );
-        mbAddParaLineSpacingToTableCells    = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::AddTableSpacing ); // FIXME? separate UI?
+        mbAddParaLineSpacingToTableCells    = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::AddTableLineSpacing );
         mbUseFormerObjectPos                = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::UseObjectPositioning );
         mbUseFormerTextWrapping             = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::UseOurTextWrapping );
         mbConsiderWrapOnObjPos              = aOptions.GetDefault( 
SvtCompatibilityEntry::Index::ConsiderWrappingStyle );
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 6ce52e5e041c..bf160861ee3c 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -833,10 +833,13 @@ void SwViewShell::SetUseVirDev( bool bNewVirtual )
 void SwViewShell::SetAddParaSpacingToTableCells( bool 
_bAddParaSpacingToTableCells )
 {
     IDocumentSettingAccess& rIDSA = getIDocumentSettingAccess();
-    if ( rIDSA.get(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS) != 
_bAddParaSpacingToTableCells )
+    if (rIDSA.get(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS) != 
_bAddParaSpacingToTableCells
+        || rIDSA.get(DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS) 
!= _bAddParaSpacingToTableCells)
     {
         SwWait aWait( *GetDoc()->GetDocShell(), true );
         rIDSA.set(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS, 
_bAddParaSpacingToTableCells );
+        // note: the dialog can't change the value to indeterminate, so only 
false/false and true/true
+        rIDSA.set(DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS, 
_bAddParaSpacingToTableCells );
         const SwInvalidateFlags nInv = SwInvalidateFlags::PrtArea;
         lcl_InvalidateAllContent( *this, nInv );
     }
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 9ae91126e608..8c2c821570ad 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -72,7 +72,9 @@ 
SwCompatibilityOptPage::SwCompatibilityOptPage(weld::Container* pPage, weld::Dia
     m_xGlobalOptionsCLB->set_column_fixed_widths(aWidths);
 
     int nPos = 0;
-    for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module) + 1; 
i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+    for (int i = static_cast<int>(SvtCompatibilityEntry::Index::Module) + 1;
+         i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID) - 1; // 
omit AddTableLineSpacing
+         ++i)
     {
         int nCoptIdx = i - 2; /* Do not consider "Name" & "Module" indexes */
 
@@ -122,6 +124,7 @@ static sal_uLong convertBools2Ulong_Impl
     bool _bNoExtLeading,
     bool _bUseLineSpacing,
     bool _bAddTableSpacing,
+    bool _bAddTableLineSpacing,
     bool _bUseObjPos,
     bool _bUseOurTextWrapping,
     bool _bConsiderWrappingStyle,
@@ -156,6 +159,9 @@ static sal_uLong convertBools2Ulong_Impl
     if ( _bAddTableSpacing )
         nRet |= nSetBit;
     nSetBit = nSetBit << 1;
+    if (_bAddTableLineSpacing)
+        nRet |= nSetBit;
+    nSetBit = nSetBit << 1;
     if ( _bUseObjPos )
         nRet |= nSetBit;
     nSetBit = nSetBit << 1;
@@ -253,6 +259,7 @@ void SwCompatibilityOptPage::InitControls( const 
SfxItemSet& rSet )
             aEntry.getValue<bool>( SvtCompatibilityEntry::Index::NoExtLeading 
),
             aEntry.getValue<bool>( 
SvtCompatibilityEntry::Index::UseLineSpacing ),
             aEntry.getValue<bool>( 
SvtCompatibilityEntry::Index::AddTableSpacing ),
+            
aEntry.getValue<bool>(SvtCompatibilityEntry::Index::AddTableLineSpacing),
             aEntry.getValue<bool>( 
SvtCompatibilityEntry::Index::UseObjectPositioning ),
             aEntry.getValue<bool>( 
SvtCompatibilityEntry::Index::UseOurTextWrapping ),
             aEntry.getValue<bool>( 
SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
@@ -288,6 +295,15 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, 
weld::Button&, void)
 
                 int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
                 pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), 
bChecked );
+                if (nCoptIdx == 
int(SvtCompatibilityEntry::Index::AddTableSpacing))
+                {
+                    bool const isLineSpacing = m_xOptionsLB->get_toggle(i, 0) 
== TRISTATE_TRUE;
+                    
pItem->setValue<bool>(SvtCompatibilityEntry::Index::AddTableLineSpacing, 
isLineSpacing);
+                }
+                else
+                {
+                    assert(m_xOptionsLB->get_toggle(i, 0) != TRISTATE_INDET);
+                }
             }
         }
 
@@ -302,7 +318,17 @@ void SwCompatibilityOptPage::SetCurrentOptions( sal_uLong 
nOptions )
     for (int i = 0; i < nCount; ++i)
     {
         bool bChecked = ( ( nOptions & 0x00000001 ) == 0x00000001 );
-        m_xOptionsLB->set_toggle(i, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE, 
0);
+        TriState value = bChecked ? TRISTATE_TRUE : TRISTATE_FALSE;
+        if (i == int(SvtCompatibilityEntry::Index::AddTableSpacing) - 2)
+        {   // hack: map 2 bools to 1 tristate
+            nOptions = nOptions >> 1;
+            if (value == TRISTATE_TRUE
+                && (nOptions & 0x00000001) != 0x00000001) // 
ADD_PARA_LINE_SPACING_TO_TABLE_CELLS
+            {
+                value = TRISTATE_INDET; // 3 values possible here
+            }
+        }
+        m_xOptionsLB->set_toggle(i, value, 0);
         nOptions = nOptions >> 1;
     }
 }
@@ -321,6 +347,7 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
             !rIDocumentSettingAccess.get( DocumentSettingId::ADD_EXT_LEADING ),
             rIDocumentSettingAccess.get( DocumentSettingId::OLD_LINE_SPACING ),
             rIDocumentSettingAccess.get( 
DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS ),
+            rIDocumentSettingAccess.get( 
DocumentSettingId::ADD_PARA_LINE_SPACING_TO_TABLE_CELLS ),
             rIDocumentSettingAccess.get( 
DocumentSettingId::USE_FORMER_OBJECT_POS ),
             rIDocumentSettingAccess.get( 
DocumentSettingId::USE_FORMER_TEXT_WRAPPING ),
             rIDocumentSettingAccess.get( 
DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION ),
@@ -356,10 +383,21 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet*  )
 
         for (int i = 0; i < nCount; ++i)
         {
-            bool bChecked = m_xOptionsLB->get_toggle(i, 0) == TRISTATE_TRUE;
-            bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 
0x00000001 );
-            if ( bChecked != bSavedChecked )
+            TriState const current = m_xOptionsLB->get_toggle(i, 0);
+            TriState saved = ((nSavedOptions & 0x00000001) == 0x00000001) ? 
TRISTATE_TRUE : TRISTATE_FALSE;
+            if (i == int(SvtCompatibilityEntry::Index::AddTableSpacing) - 2)
+            {   // hack: map 2 bools to 1 tristate
+                nSavedOptions = nSavedOptions >> 1;
+                if (saved == TRISTATE_TRUE
+                    && ((nSavedOptions & 0x00000001) != 0x00000001))
+                {
+                    saved = TRISTATE_INDET;
+                }
+            }
+            if (current != saved)
             {
+                bool const bChecked(current != TRISTATE_FALSE);
+                assert(current != TRISTATE_INDET); // can't *change* it to that
                 int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
                 switch ( SvtCompatibilityEntry::Index(nCoptIdx) )
                 {
diff --git a/sw/uiconfig/swriter/ui/optcompatpage.ui 
b/sw/uiconfig/swriter/ui/optcompatpage.ui
index 29a5c6eaee75..1018dcc5e979 100644
--- a/sw/uiconfig/swriter/ui/optcompatpage.ui
+++ b/sw/uiconfig/swriter/ui/optcompatpage.ui
@@ -229,6 +229,7 @@
                               <attributes>
                                 <attribute name="visible">3</attribute>
                                 <attribute name="active">0</attribute>
+                                <attribute name="inconsistent">4</attribute>
                               </attributes>
                             </child>
                           </object>
diff --git a/unotools/source/config/compatibility.cxx 
b/unotools/source/config/compatibility.cxx
index a71c8ac39c8d..5556a0a231d4 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -66,6 +66,7 @@ SvtCompatibilityEntry::SvtCompatibilityEntry()
     setValue<bool>( Index::MsWordTrailingBlanks, false );
     setValue<bool>( Index::SubtractFlysAnchoredAtFlys, false );
     setValue<bool>( Index::EmptyDbFieldHidesPara, true );
+    setValue<bool>( Index::AddTableLineSpacing, false );
 
     setDefaultEntry( false );
 }
@@ -94,6 +95,7 @@ OUString SvtCompatibilityEntry::getName( const Index rIdx )
         "MsWordCompTrailingBlanks",
         "SubtractFlysAnchoredAtFlys",
         "EmptyDbFieldHidesPara",
+        "AddTableLineSpacing",
     };
 
     /* Size of sPropertyName array not equal size of the 
SvtCompatibilityEntry::Index enum class */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to