[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/inc sw/source

Michael Stahl mstahl at redhat.com
Tue May 31 14:48:30 UTC 2016


 sw/inc/doc.hxx                   |    2 +-
 sw/inc/fesh.hxx                  |    3 ++-
 sw/source/core/docnode/ndtbl.cxx |    7 ++++++-
 sw/source/core/frmedt/fetab.cxx  |   14 +++++++++-----
 sw/source/core/inc/UndoTable.hxx |    1 +
 sw/source/core/undo/untbl.cxx    |   13 ++++++++++---
 6 files changed, 29 insertions(+), 11 deletions(-)

New commits:
commit d12a9cb847029d89edf0829a27de58375f9f2741
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon May 30 23:01:04 2016 +0200

    tdf#98226: fix undo of table AutoFormat
    
    The new call to SwTable::SetTableStyleName() was not recorded in
    SwUndoTableAutoFormat and hence persisted even after Undo.
    
    (regression from 73f4a06c0bce51c7c8b9ae9adfdc7ffac27d06b4)
    
    (cherry picked from commit 7b042d2865c5bb2c2dde1dd47de124bc0df61ae8)
    
    Change-Id: Ia7f769dafa62f02ff8e4b0596b48266190c7a69b
    Reviewed-on: https://gerrit.libreoffice.org/25713
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index c752fa3..44d8f1e 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1247,7 +1247,7 @@ public:
 
     /// AutoFormat for table/table selection.
     /// @param bResetDirect Reset direct formatting that might be applied to the cells.
-    bool SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect = false);
+    bool SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect = false, bool isSetStyleName = false);
 
     // Query attributes.
     bool GetTableAutoFormat( const SwSelBoxes& rBoxes, SwTableAutoFormat& rGet );
diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx
index 5821cb1..19d2f7c 100644
--- a/sw/inc/fesh.hxx
+++ b/sw/inc/fesh.hxx
@@ -727,7 +727,8 @@ public:
     /// Update the direct formatting according to the current table style.
     /// @param pTableNode Table node to update.  When nullptr, current cursor position is used.
     /// @param bResetDirect Reset direct formatting that might be applied to the cells.
-    bool UpdateTableStyleFormatting(SwTableNode *pTableNode = nullptr, bool bResetDirect = false);
+    /// @param pStyleName new style to apply
+    bool UpdateTableStyleFormatting(SwTableNode *pTableNode = nullptr, bool bResetDirect = false, OUString const* pStyleName = nullptr);
 
     bool GetTableAutoFormat( SwTableAutoFormat& rGet );
 
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index e5d68c8..6367691 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3742,7 +3742,7 @@ static bool lcl_SetAFormatBox(_FndBox & rBox, _SetAFormatTabPara *pSetPara, bool
     return true;
 }
 
-bool SwDoc::SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect)
+bool SwDoc::SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat& rNew, bool bResetDirect, bool const isSetStyleName)
 {
     OSL_ENSURE( !rBoxes.empty(), "No valid Box list" );
     SwTableNode* pTableNd = const_cast<SwTableNode*>(rBoxes[0]->GetSttNd()->FindTableNode());
@@ -3781,6 +3781,11 @@ bool SwDoc::SetTableAutoFormat(const SwSelBoxes& rBoxes, const SwTableAutoFormat
         GetIDocumentUndoRedo().DoUndo(false);
     }
 
+    if (isSetStyleName)
+    {   // tdf#98226 do this here where undo can record it
+        pTableNd->GetTable().SetTableStyleName(rNew.GetName());
+    }
+
     rNew.RestoreTableProperties(table);
 
     _SetAFormatTabPara aPara( rNew );
diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx
index a03f227..8e9178e 100644
--- a/sw/source/core/frmedt/fetab.cxx
+++ b/sw/source/core/frmedt/fetab.cxx
@@ -1185,11 +1185,12 @@ bool SwFEShell::SetTableStyle(const SwTableAutoFormat& rStyle)
         return false;
 
     // set the name & update
-    pTableNode->GetTable().SetTableStyleName(rStyle.GetName());
-    return UpdateTableStyleFormatting(pTableNode);
+    OUString const name(rStyle.GetName());
+    return UpdateTableStyleFormatting(pTableNode, false, &name);
 }
 
-bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode, bool bResetDirect)
+bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode,
+        bool bResetDirect, OUString const*const pStyleName)
 {
     if (!pTableNode)
     {
@@ -1198,7 +1199,9 @@ bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode, bool bResetD
             return false;
     }
 
-    OUString aTableStyleName(pTableNode->GetTable().GetTableStyleName());
+    OUString const aTableStyleName((pStyleName)
+            ? *pStyleName
+            : pTableNode->GetTable().GetTableStyleName());
     SwTableAutoFormat* pTableStyle = GetDoc()->GetTableStyles().FindAutoFormat(aTableStyleName);
     if (!pTableStyle)
         return false;
@@ -1226,7 +1229,8 @@ bool SwFEShell::UpdateTableStyleFormatting(SwTableNode *pTableNode, bool bResetD
     {
         SET_CURR_SHELL( this );
         StartAllAction();
-        bRet = GetDoc()->SetTableAutoFormat(aBoxes, *pTableStyle, bResetDirect);
+        bRet = GetDoc()->SetTableAutoFormat(
+                aBoxes, *pTableStyle, bResetDirect, pStyleName != nullptr);
         DELETEZ( pLastCols );
         DELETEZ( pLastRows );
         EndAllActionAndCall();
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 2e18078..6a70873 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -143,6 +143,7 @@ class SwUndoTableNumFormat;
 
 class SwUndoTableAutoFormat : public SwUndo
 {
+    OUString m_TableStyleName;
     sal_uLong nSttNode;
     _SaveTable* pSaveTable;
     std::vector< std::shared_ptr<SwUndoTableNumFormat> > m_Undos;
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 2072eda..9fc23f2 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1402,9 +1402,10 @@ void SwUndoAttrTable::RedoImpl(::sw::UndoRedoContext & rContext)
 // UndoObject for AutoFormat on Table
 SwUndoTableAutoFormat::SwUndoTableAutoFormat( const SwTableNode& rTableNd,
                                     const SwTableAutoFormat& rAFormat )
-    : SwUndo( UNDO_TABLE_AUTOFMT ),
-    nSttNode( rTableNd.GetIndex() ),
-    bSaveContentAttr( false )
+    : SwUndo( UNDO_TABLE_AUTOFMT )
+    , m_TableStyleName(rTableNd.GetTable().GetTableStyleName())
+    , nSttNode( rTableNd.GetIndex() )
+    , bSaveContentAttr( false )
     , m_nRepeatHeading(rTableNd.GetTable().GetRowsToRepeat())
 {
     pSaveTable = new _SaveTable( rTableNd.GetTable() );
@@ -1437,6 +1438,12 @@ SwUndoTableAutoFormat::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rConte
     OSL_ENSURE( pTableNd, "no TableNode" );
 
     SwTable& table = pTableNd->GetTable();
+    if (table.GetTableStyleName() != m_TableStyleName)
+    {
+        OUString const temp(table.GetTableStyleName());
+        table.SetTableStyleName(m_TableStyleName);
+        m_TableStyleName = temp;
+    }
     _SaveTable* pOrig = new _SaveTable( table );
     // than go also over the ContentNodes of the EndBoxes and collect
     // all paragraph attributes


More information about the Libreoffice-commits mailing list