[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source
sw/qa/uitest/data/tdf136715.odt |binary sw/qa/uitest/writer_tests7/tdf136715.py | 35 sw/source/core/undo/untbl.cxx |3 +- 3 files changed, 37 insertions(+), 1 deletion(-) New commits: commit aee6d4f8e028e0daee65611a0f94f1e4cc8325d1 Author: Balazs Santha AuthorDate: Thu Oct 14 15:53:06 2021 +0200 Commit: Xisco Fauli CommitDate: Wed Oct 27 12:56:35 2021 +0200 tdf#136715 sw: fix table Undo to update table style Applying table styles works by applying direct formatting on the table. Some of the built-in table styles, like "Box List Red" specifies boldness for the last row of the table. After selecting and deleting the last n rows of a table, which has a table style which specifies formatting for the last row, the new last row gets these formatting as expected. However before the fix, after undoing the deletion of the rows, this formatting were still applied on that row which previously became the last row. Change-Id: I3ad086dd9b5e4111b3f019ca3d23f1db8b348637 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123730 Tested-by: László Németh Reviewed-by: László Németh Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124256 Tested-by: Jenkins diff --git a/sw/qa/uitest/data/tdf136715.odt b/sw/qa/uitest/data/tdf136715.odt new file mode 100644 index ..ca5c89ce427c Binary files /dev/null and b/sw/qa/uitest/data/tdf136715.odt differ diff --git a/sw/qa/uitest/writer_tests7/tdf136715.py b/sw/qa/uitest/writer_tests7/tdf136715.py new file mode 100644 index ..df9f37ecc86c --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf136715.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 136715 - Undoing table rows caused inconsistent table look when using table styles + +class tdf136715(UITestCase): +def test_tdf136715(self): +self.ui_test.load_file(get_url_for_data_file("tdf136715.odt")) + +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:LineDownSel") +self.xUITest.executeCommand(".uno:DeleteRows") +self.xUITest.executeCommand(".uno:Undo") + +self.ui_test.execute_dialog_through_command(".uno:FontDialog") +xDialog = self.xUITest.getTopFocusWindow() +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "0") +xweststylebcjk = xDialog.getChild("weststylelb-cjk") +#without the fix in place, the row would have bold character formatting +self.assertEqual(get_state_as_dict(xweststylebcjk)["Text"], "Regular") +xOkBtn = xDialog.getChild("ok") +self.ui_test.close_dialog_through_button(xOkBtn) + +self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index ee509e6b602c..607b706f38d2 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -1762,7 +1763,7 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) // TL_CHART2: need to inform chart of probably changed cell names rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() ); - +rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); if( IsDelBox() ) m_nSttNode = pTableNd->GetIndex(); ClearFEShellTabCols(rDoc, nullptr);
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/uitest/data/tdf136715.odt |binary sw/qa/uitest/writer_tests7/tdf136715.py | 28 sw/source/core/undo/untbl.cxx |3 ++- 3 files changed, 30 insertions(+), 1 deletion(-) New commits: commit bc92028fdf7f52f555702386a6862631e08a3919 Author: Balazs Santha AuthorDate: Thu Oct 14 15:53:06 2021 +0200 Commit: László Németh CommitDate: Tue Oct 26 12:20:49 2021 +0200 tdf#136715 sw: fix table Undo to update table style Applying table styles works by applying direct formatting on the table. Some of the built-in table styles, like "Box List Red" specifies boldness for the last row of the table. After selecting and deleting the last n rows of a table, which has a table style which specifies formatting for the last row, the new last row gets these formatting as expected. However before the fix, after undoing the deletion of the rows, this formatting were still applied on that row which previously became the last row. Change-Id: I3ad086dd9b5e4111b3f019ca3d23f1db8b348637 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123730 Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/qa/uitest/data/tdf136715.odt b/sw/qa/uitest/data/tdf136715.odt new file mode 100644 index ..ca5c89ce427c Binary files /dev/null and b/sw/qa/uitest/data/tdf136715.odt differ diff --git a/sw/qa/uitest/writer_tests7/tdf136715.py b/sw/qa/uitest/writer_tests7/tdf136715.py new file mode 100644 index ..acd89808179d --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf136715.py @@ -0,0 +1,28 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 136715 - Undoing table rows caused inconsistent table look when using table styles + +class tdf136715(UITestCase): +def test_tdf136715(self): +with self.ui_test.load_file(get_url_for_data_file("tdf136715.odt")) as writer_doc: +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:LineDownSel") +self.xUITest.executeCommand(".uno:DeleteRows") +self.xUITest.executeCommand(".uno:Undo") +with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "0") +xweststylebcjk = xDialog.getChild("weststylelb-cjk") +#without the fix in place, the row would have bold character formatting +self.assertEqual(get_state_as_dict(xweststylebcjk)["Text"], "Regular") +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 5587dfeb9b1c..d3294b5446a3 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -1757,7 +1758,7 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) // TL_CHART2: need to inform chart of probably changed cell names rDoc.UpdateCharts( pTableNd->GetTable().GetFrameFormat()->GetName() ); - +rDoc.GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); if( IsDelBox() ) m_nSttNode = pTableNd->GetIndex(); ClearFEShellTabCols(rDoc, nullptr);
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf143904.odt |binary sw/qa/extras/uiwriter/uiwriter2.cxx | 23 +++ sw/source/core/table/swtable.cxx | 14 -- 3 files changed, 27 insertions(+), 10 deletions(-) New commits: commit 72590c55ad6c699b34dc404542abc3f60bc32a09 Author: Balazs Santha AuthorDate: Wed Aug 18 09:30:41 2021 +0200 Commit: Michael Stahl CommitDate: Fri Aug 27 11:27:44 2021 +0200 tdf#143904 fix direct character formatting copied into paragraph level Currently, Writer copied the direct character formattings, and applied them on paragraph level, when inserting a new row in a table. This bug is a regression from 498d2b82187ec3ff58f076e0d15741e64c0505ba . Explanation, why this regression happened: MSO Word uses a paragraph mark symbol (i.e the control character than can be configured to be shown), which is imported in Writer as a 0-length hint. To fasten up the import of DOCX tables, the core applies the formattings from this 0-length attribute on paragraph level, directly before inserting a new row. All in all, to solve this bug, we needed to make sure, that we only copy the formattings, if it is from a 0-length hint. Change-Id: Iba52e9318cc588feda559339e42897568d009806 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120624 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/uiwriter/data/tdf143904.odt b/sw/qa/extras/uiwriter/data/tdf143904.odt new file mode 100644 index ..5a1d28664c31 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf143904.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 70d63e36871a..2b263a7849dd 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -4440,6 +4440,29 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testOfz18563) TestImportDOCX(aFileStream); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf143904) +{ +SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf143904.odt"); + +SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); +CPPUNIT_ASSERT(pWrtShell); + +sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + +dispatchCommand(mxComponent, ".uno:InsertRowsAfter", {}); +pWrtShell->Down(false); +pWrtShell->Insert("foo"); + +SwTextNode* pTextNodeA1 = static_cast(pDoc->GetNodes()[nIndex]); +CPPUNIT_ASSERT(pTextNodeA1->GetText().startsWith("Insert")); +nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); +SwTextNode* pTextNodeA2 = static_cast(pDoc->GetNodes()[nIndex]); +CPPUNIT_ASSERT_EQUAL(OUString("foo"), pTextNodeA2->GetText()); +CPPUNIT_ASSERT_EQUAL(false, pTextNodeA2->GetSwAttrSet().HasItem(RES_CHRATR_FONT)); +OUString sFontName = pTextNodeA2->GetSwAttrSet().GetItem(RES_CHRATR_FONT)->GetFamilyName(); +CPPUNIT_ASSERT_EQUAL(OUString("Liberation Serif"), sFontName); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf90069) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf90069.docx"); diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index ad10eccc7d92..fb5839ea687b 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -145,17 +145,11 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, if( pCNd->GetpSwAttrSet() ) { SwAttrSet aAttrSet( *pCNd->GetpSwAttrSet() ); -SwTextNode* pTNd = static_cast(pCNd); -SwpHints * pSwpHints = pTNd->GetpSwpHints(); -if(pSwpHints && pSwpHints->Count()!=0) +if(pCNd->GetSwAttrSet().HasItem(RES_PARATR_LIST_AUTOFMT)) { -SwTextAttr* textAttr = pSwpHints->Get(pSwpHints->Count()-1); -if(textAttr->Which() == RES_TXTATR_AUTOFMT ) -{ -SwFormatAutoFormat& format = static_cast(textAttr->GetAttr()); -const std::shared_ptr& handle = format.GetStyleHandle(); -aAttrSet.Put(*handle); -} +SwFormatAutoFormat format = aAttrSet.Get(RES_PARATR_LIST_AUTOFMT); +const std::shared_ptr& handle = format.GetStyleHandle(); +aAttrSet.Put(*handle); } if( pBox->GetSaveNumFormatColor() ) {
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source
sw/qa/uitest/data/tdf143244.odt |binary sw/qa/uitest/writer_tests7/tdf143244.py | 50 sw/source/core/doc/tblrwcl.cxx |2 - 3 files changed, 51 insertions(+), 1 deletion(-) New commits: commit 53902e2ecf8ab1bb3f1cfa203de105d6d956e7ef Author: Balazs Santha AuthorDate: Tue Jul 20 15:54:01 2021 +0200 Commit: Xisco Fauli CommitDate: Thu Aug 12 17:54:09 2021 +0200 tdf#143244 sw: fix redo of adding table rows breaks table style This fixes a bug, which caused the break of table style when redo of inserting table rows, Normally, upon inserting a row, the formatting of the table is updated by the UpdateTableStyleFormatting() function. In certain situations (e.g in the description of the bug) this update wasn't successful. This was beacuse, the update function didn't know which tableNode needs to be updated. As the proper tableNode we need is already calculated in the SwTable::InsertRow function, we simply had to pass this argument too. Change-Id: I81ebd7bb37eebc9be8974f3f7a1adc5ad4ba1e7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119249 Tested-by: Jenkins Reviewed-by: Michael Stahl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119408 diff --git a/sw/qa/uitest/data/tdf143244.odt b/sw/qa/uitest/data/tdf143244.odt new file mode 100644 index ..0fd3ff915a8a Binary files /dev/null and b/sw/qa/uitest/data/tdf143244.odt differ diff --git a/sw/qa/uitest/writer_tests7/tdf143244.py b/sw/qa/uitest/writer_tests7/tdf143244.py new file mode 100644 index ..444b29bbf65d --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf143244.py @@ -0,0 +1,50 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 143244 - Redo of adding table rows breaks table style after cut/paste action + + +class tdf143244(UITestCase): +def test_tdf143244(self): +self.ui_test.load_file(get_url_for_data_file("tdf143244.odt")) +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:Cut") +self.xUITest.executeCommand(".uno:Paste") +self.xUITest.executeCommand(".uno:GoUp") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +for i in range(0,6): +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) +for i in range(0,4): +self.xUITest.executeCommand(".uno:Undo") +for i in range(0,4): +self.xUITest.executeCommand(".uno:Redo") +for i in range (0,3): +self.xUITest.executeCommand(".uno:GoUp") +self.ui_test.execute_dialog_through_command(".uno:TableDialog") +xDialog = self.xUITest.getTopFocusWindow() +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "4") #tab Background +btncolor = xDialog.getChild("btncolor") +btncolor.executeAction("CLICK", tuple()) +hex_custom = xDialog.getChild("hex_custom") +if i == 0: +self.assertEqual(get_state_as_dict(hex_custom)["Text"], "bee3d3") +if i == 1: +self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ff") +if i == 2: +self.assertEqual(get_state_as_dict(hex_custom)["Text"], "dd") + +xOKBtn = xDialog.getChild("ok") +self.ui_test.close_dialog_through_button(xOKBtn) + +self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 7b5367255fda..cb166d222cad 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -607,7 +607,7 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); pDoc->UpdateCharts( GetFrameFormat()->GetName() ); -pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); +pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); return true; }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa
sw/qa/uitest/writer_tests7/tdf131771.py | 46 1 file changed, 46 insertions(+) New commits: commit e688361af320a3edb4fb3665ee6c1af68ef8b1bd Author: Balazs Santha AuthorDate: Mon Jul 5 12:57:47 2021 +0200 Commit: Xisco Fauli CommitDate: Thu Aug 12 17:53:27 2021 +0200 sw: test fix of tdf#131771 Change-Id: I9879f13e842dd7288c996c1097130e7e7b28589c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118432 Tested-by: Jenkins Reviewed-by: Michael Stahl Reviewed-by: Xisco Fauli Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120375 diff --git a/sw/qa/uitest/writer_tests7/tdf131771.py b/sw/qa/uitest/writer_tests7/tdf131771.py new file mode 100644 index ..f6ed46eb1ad8 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf131771.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 131771 - Copying+Pasting a table: caused the loss of table style setting. + + +class tdf131771(UITestCase): +def test_tdf131771(self): +self.ui_test.create_doc_in_start_center("writer") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +# generate a 2x2 tables with the same autoformat table style (Default Table Style) +# Note that this style is different than applying nothing! +self.ui_test.execute_dialog_through_command(".uno:InsertTable") +xDialog = self.xUITest.getTopFocusWindow() +formatlbinstable = xDialog.getChild("formatlbinstable") +entry = formatlbinstable.getChild("1") +entry.executeAction("SELECT", tuple()) + +xOkBtn = xDialog.getChild("ok") +xOkBtn.executeAction("CLICK", tuple()) + +# select the table +self.xUITest.executeCommand(".uno:SelectAll") + +# copying and pasting the table below +self.xUITest.executeCommand(".uno:Copy") +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:Paste") + +document = self.ui_test.get_component() +tables = document.getTextTables() +self.assertEqual(tables[0].TableTemplateName, 'Default Style') +self.assertEqual(tables[1].TableTemplateName, 'Default Style') + +self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/source
sw/inc/doc.hxx|2 +- sw/inc/swtable.hxx|2 +- sw/source/core/doc/tblrwcl.cxx|3 ++- sw/source/core/docnode/ndcopy.cxx |1 + sw/source/core/docnode/ndtbl.cxx |4 ++-- sw/source/core/edit/edglss.cxx|2 +- 6 files changed, 8 insertions(+), 6 deletions(-) New commits: commit 15fbc6f2dbf114247a89cd3d4d3360c9c00a4390 Author: Balazs Santha AuthorDate: Fri Jul 2 19:21:47 2021 +0200 Commit: Michael Stahl CommitDate: Thu Aug 12 13:46:56 2021 +0200 tdf#131771 sw: fix missing table style after copying and pasting the table This fixes the loss of table style setting when copying and then pasting a table. Change-Id: Ie678a269b4cdcddfd73a5d6a27ef9fcb55dcaa46 Change-Id: I48208337ee14fde30417fa3999f56999cc5eda19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118336 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120373 Reviewed-by: Michael Stahl diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index c94e5f04c5f3..6ff73c35cb8c 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1269,7 +1269,7 @@ public: bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, const SwTable* pCpyTable, bool bCpyName = false, -bool bCorrPos = false ); +bool bCorrPos = false, const OUString& rStyleName = "" ); void UnProtectCells( std::u16string_view rTableName ); bool UnProtectCells( const SwSelBoxes& rBoxes ); diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index fd3cb0367a67..23930d19b7f3 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -278,7 +278,7 @@ public: const bool bPerformValidCheck = false ) const; // Copy selected boxes to another document. bool MakeCopy( SwDoc&, const SwPosition&, const SwSelBoxes&, -bool bCpyName = false ) const; +bool bCpyName = false, const OUString& rStyleName = "" ) const; // Copy table in this bool InsTable( const SwTable& rCpyTable, const SwNodeIndex&, SwUndoTableCpyTable* pUndo ); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 18eab679a289..7b5367255fda 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -2045,7 +2045,7 @@ void SwTable::CopyHeadlineIntoTable( SwTableNode& rTableNd ) bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, const SwSelBoxes& rSelBoxes, -bool bCpyName ) const +bool bCpyName, const OUString& rStyleName ) const { // Find all Boxes/Lines FndBox_ aFndBox( nullptr, nullptr ); @@ -2081,6 +2081,7 @@ bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName()); +pTableNd->GetTable().SetTableStyleName(rStyleName); if( auto pSwDDETable = dynamic_cast(this) ) { // A DDE-Table is being copied diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 5b3c9edbd9db..91bb99d696b6 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -271,6 +271,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx ) const SwNodeIndex aInsPos( *pEndNd ); SwTable& rTable = pTableNd->GetTable(); +rTable.SetTableStyleName(GetTable().GetTableStyleName()); rTable.RegisterToFormat( *pTableFormat ); rTable.SetRowsToRepeat( GetTable().GetRowsToRepeat() ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 3ddfd2019d17..d6005e273192 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4283,7 +4283,7 @@ void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode ) * This method is called by edglss.cxx/fecopy.cxx */ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, -const SwTable* pCpyTable, bool bCpyName, bool bCorrPos ) +const SwTable* pCpyTable, bool bCpyName, bool bCorrPos, const OUString& rStyleName ) { bool bRet; @@ -4306,7 +4306,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, { ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); bRet = pSrcTableNd->GetTable().MakeCopy( *this, rInsPos, rBoxes, -bCpyName ); +bCpyName, rStyleName ); } if( pUndo && bRet ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 536a0c1643ff..47791dc69a49 100644 --- a/sw/source/core/edit/edglss.cxx +++
[Libreoffice-commits] core.git: sw/source writerfilter/source
sw/source/core/table/swtable.cxx | 28 -- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 18 -- 2 files changed, 21 insertions(+), 25 deletions(-) New commits: commit 498d2b82187ec3ff58f076e0d15741e64c0505ba Author: Balazs Santha AuthorDate: Thu Jul 29 15:00:54 2021 +0200 Commit: László Németh CommitDate: Thu Aug 12 10:46:23 2021 +0200 tdf#131546 DOCX import: fix performance regression at tables Commit 2ab481b038b62b1ff576ac4d49d03c1798cd7f84 "tdf#90069 DOCX: fix character style of new table rows" caused ~20% slowing down in loading time of documents with huge tables, related to the extra processing of the redundant w:rPr of table paragraph runs. (In DOCX tables, MSO exports the run properties into the run and paragraph sections too, probably because of compatibility or usability reasons.) Theoretically in this case, the run properties which are under the run section win. On the other hand, because LO copies the props which are applied on paragraph level, and only them, when copying a row (e.g. upon inserting a new one), it was needed to apply the mentioned run props not only as direct character formatting, but as a direct paragraph formatting too. This way, the support of copying of rows are solved. Unfortunately, this "double" applying was done for every single paragraph, which quite slowed down the opening time. This patch gives a workaround, which completely removes this double applying functionality in the writerfilter by reverting commit 2ab481b038b62b1ff576ac4d49d03c1798cd7f84 (except its unit test), and copy the mentioned run properties into paragraph level, when its needed: upon inserting a new row before/after. This way we spare a lot of cycles, as most of the original applies had no real use whatsoever. Change-Id: Ic24d0d1830e9ec43323e5e213d6481ec28e9abe3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118985 Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index c17d6882b019..5f633ef65546 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -141,13 +141,28 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, if( pCNd->IsTextNode() ) { -if( pBox->GetSaveNumFormatColor() && pCNd->GetpSwAttrSet() ) +if( pCNd->GetpSwAttrSet() ) { SwAttrSet aAttrSet( *pCNd->GetpSwAttrSet() ); -if( pBox->GetSaveUserColor() ) -aAttrSet.Put( SvxColorItem( *pBox->GetSaveUserColor(), RES_CHRATR_COLOR )); -else -aAttrSet.ClearItem( RES_CHRATR_COLOR ); +SwTextNode* pTNd = static_cast(pCNd); +SwpHints * pSwpHints = pTNd->GetpSwpHints(); +if(pSwpHints && pSwpHints->Count()!=0) +{ +SwTextAttr* textAttr = pSwpHints->Get(pSwpHints->Count()-1); +if(textAttr->Which() == RES_TXTATR_AUTOFMT ) +{ +SwFormatAutoFormat& format = static_cast(textAttr->GetAttr()); +const std::shared_ptr& handle = format.GetStyleHandle(); +aAttrSet.Put(*handle); +} +} +if( pBox->GetSaveNumFormatColor() ) +{ +if( pBox->GetSaveUserColor() ) +aAttrSet.Put( SvxColorItem( *pBox->GetSaveUserColor(), RES_CHRATR_COLOR )); +else +aAttrSet.ClearItem( RES_CHRATR_COLOR ); +} rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat, static_cast(pCNd)->GetTextColl(), , nInsPos, nCnt ); @@ -155,8 +170,7 @@ void InsTableBox( SwDoc& rDoc, SwTableNode* pTableNd, else rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat, static_cast(pCNd)->GetTextColl(), -pCNd->GetpSwAttrSet(), -nInsPos, nCnt ); +pCNd->GetpSwAttrSet(), nInsPos, nCnt ); } else rDoc.GetNodes().InsBoxen( pTableNd, pLine, pBoxFrameFormat, diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 1249d45c82dd..fc1fbee7440f 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -2201,24 +2201,6 @@ void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap, con // fix table paragraph properties if ( xTextRange.is() && xParaProps && m_nTableDepth > 0 ) { -uno::Sequence< beans::PropertyValue > aParaProps =
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/uitest/data/tdf143244.odt |binary sw/qa/uitest/writer_tests7/tdf143244.py | 44 sw/source/core/doc/tblrwcl.cxx |2 - 3 files changed, 45 insertions(+), 1 deletion(-) New commits: commit 689b5a4862ead541e54e83cb14067cfaa691e2ab Author: Balazs Santha AuthorDate: Tue Jul 20 15:54:01 2021 +0200 Commit: Michael Stahl CommitDate: Thu Jul 22 16:34:47 2021 +0200 tdf#143244 sw: fix redo of adding table rows breaks table style This fixes a bug, which caused the break of table style when redo of inserting table rows, Normally, upon inserting a row, the formatting of the table is updated by the UpdateTableStyleFormatting() function. In certain situations (e.g in the description of the bug) this update wasn't successful. This was beacuse, the update function didn't know which tableNode needs to be updated. As the proper tableNode we need is already calculated in the SwTable::InsertRow function, we simply had to pass this argument too. Change-Id: I81ebd7bb37eebc9be8974f3f7a1adc5ad4ba1e7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119249 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sw/qa/uitest/data/tdf143244.odt b/sw/qa/uitest/data/tdf143244.odt new file mode 100644 index ..0fd3ff915a8a Binary files /dev/null and b/sw/qa/uitest/data/tdf143244.odt differ diff --git a/sw/qa/uitest/writer_tests7/tdf143244.py b/sw/qa/uitest/writer_tests7/tdf143244.py new file mode 100644 index ..a47074396334 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf143244.py @@ -0,0 +1,44 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 143244 - Redo of adding table rows breaks table style after cut/paste action + + +class tdf143244(UITestCase): +def test_tdf143244(self): +with self.ui_test.load_file(get_url_for_data_file("tdf143244.odt")) as writer_doc: +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:Cut") +self.xUITest.executeCommand(".uno:Paste") +self.xUITest.executeCommand(".uno:GoUp") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +for i in range(0,6): +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) +for i in range(0,4): +self.xUITest.executeCommand(".uno:Undo") +for i in range(0,4): +self.xUITest.executeCommand(".uno:Redo") +for i in range (0,3): +self.xUITest.executeCommand(".uno:GoUp") +with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "4") #tab Background +btncolor = xDialog.getChild("btncolor") +btncolor.executeAction("CLICK", tuple()) +hex_custom = xDialog.getChild("hex_custom") +if i == 0: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "bee3d3") +if i == 1: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ff") +if i == 2: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "dd") +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 6d8d86ce8f12..48ac3ea7fbc5 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -607,7 +607,7 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); pDoc->UpdateCharts( GetFrameFormat()->GetName() ); -pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); +pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/inc sw/qa sw/source
sw/inc/tblafmt.hxx |4 -- sw/qa/core/uwriter.cxx | 12 -- sw/qa/uitest/writer_tests7/tdf134452.py | 58 sw/source/core/doc/tblafmt.cxx | 22 +++- 4 files changed, 65 insertions(+), 31 deletions(-) New commits: commit 03bde450887c95f59f511d39cf2e10dcb26bbcf0 Author: Balazs Santha AuthorDate: Wed Jul 14 15:18:47 2021 +0200 Commit: Xisco Fauli CommitDate: Fri Jul 16 01:47:37 2021 +0200 tdf#134452 sw: fix page break disappears after applying table style After setting the break and pagedesc property of a table, applying a table style (autoformat) caused the loss of these settings. This was because, when applying a table style, the SwTableAutoFormat::RestoreTableProperties() overrid these settings with its own default settings. As the autoformats can never be modified, and they don't really use these two props, the easiest way to prevent any problem was to completely remove these properties and its uses. Unfortunately, m_aBreak couldn't be removed entirely, as the autoformats are stored in a binary file, and to be able to read and write these files the offset of the subsequent items must not be changed. Change-Id: Ieba439d3ba5da892b39f00f8b61c5c8467306635 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118662 Tested-by: Jenkins Reviewed-by: Michael Stahl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118991 diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 2873f51e9196..ff6abca8baa7 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -173,8 +173,6 @@ class SW_DLLPUBLIC SwTableAutoFormat SwBoxAutoFormat* m_aBoxAutoFormat[ 16 ] = {}; // Writer-specific options -std::shared_ptr m_aBreak; -SwFormatPageDesc m_aPageDesc; std::shared_ptr m_aKeepWithNextPara; sal_uInt16 m_aRepeatHeading; bool m_bLayoutSplit; @@ -191,11 +189,9 @@ public: SwTableAutoFormat& operator=( const SwTableAutoFormat& rNew ); -const SvxFormatBreakItem& GetBreak() const { return *m_aBreak; } const SvxFormatKeepItem& GetKeepWithNextPara() const { return *m_aKeepWithNextPara; } const SvxShadowItem& GetShadow() const { return *m_aShadow; } -void SetBreak(const SvxFormatBreakItem& rNew) { m_aBreak.reset(rNew.Clone()); } void SetKeepWithNextPara(const SvxFormatKeepItem& rNew) { m_aKeepWithNextPara.reset(rNew.Clone()); } void SetShadow(const SvxShadowItem& rNew) { m_aShadow.reset(rNew.Clone()); } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index ade0a9d8170b..4f9ffdb98c40 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1324,17 +1324,9 @@ void SwDocTest::testTableAutoFormats() //Set m_eNumFormatLanguage LanguageType aNFLang( LANGUAGE_GERMAN ); aBoxAF.SetNumFormatLanguage(aNFLang); -//Set m_aBreak -SvxFormatBreakItem aBreak( SvxBreak::PageBefore, 0 ); -aTableAF.SetBreak(aBreak); //Set m_aKeepWithNextPara SvxFormatKeepItem aKWNPara( true, 0 ); aTableAF.SetKeepWithNextPara(aKWNPara); -//Set m_aPageDesc -SwFormatPageDesc aPDesc; -uno::Any aPDAny( sal_uInt16(3) ); -aPDesc.PutValue( aPDAny, 0 ); -aTableAF.m_aPageDesc = aPDesc; //Set m_aRepeatHeading sal_uInt16 aRHeading = 3; aTableAF.m_aRepeatHeading = aRHeading; @@ -1466,12 +1458,8 @@ void SwDocTest::testTableAutoFormats() CPPUNIT_ASSERT( bool( pLoadAF->GetBoxFormat(0).GetSysLanguage() == aSLang ) ); //Get m_eNumFormatLanguage CPPUNIT_ASSERT( bool( pLoadAF->GetBoxFormat(0).GetNumFormatLanguage() == aNFLang ) ); -//Get m_aBreak -CPPUNIT_ASSERT( bool( pLoadAF->GetBreak() == aBreak ) ); //Get m_aKeepWithNextPara CPPUNIT_ASSERT( bool( pLoadAF->GetKeepWithNextPara() == aKWNPara ) ); -//Get m_aPageDesc -CPPUNIT_ASSERT( bool( pLoadAF->m_aPageDesc == aPDesc ) ); //Get m_aRepeatHeading CPPUNIT_ASSERT( bool( pLoadAF->m_aRepeatHeading == aRHeading ) ); //Get m_bLayoutSplit diff --git a/sw/qa/uitest/writer_tests7/tdf134452.py b/sw/qa/uitest/writer_tests7/tdf134452.py new file mode 100644 index ..09dc9c5f9c6a --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf134452.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 134452 - Applying a table style caused the loss of break/pagedesc props of the table + + +class tdf134452(UITestCase): +def test_tdf134452(self): +
[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
sw/inc/tblafmt.hxx |4 -- sw/qa/core/uwriter.cxx | 12 --- sw/qa/uitest/writer_tests7/tdf134452.py | 49 sw/source/core/doc/tblafmt.cxx | 22 -- 4 files changed, 56 insertions(+), 31 deletions(-) New commits: commit 554c3692b7e3b51ce6ce7772509ba7a2e8777d3a Author: Balazs Santha AuthorDate: Wed Jul 14 15:18:47 2021 +0200 Commit: Michael Stahl CommitDate: Thu Jul 15 16:04:56 2021 +0200 tdf#134452 sw: fix page break disappears after applying table style After setting the break and pagedesc property of a table, applying a table style (autoformat) caused the loss of these settings. This was because, when applying a table style, the SwTableAutoFormat::RestoreTableProperties() overrid these settings with its own default settings. As the autoformats can never be modified, and they don't really use these two props, the easiest way to prevent any problem was to completely remove these properties and its uses. Unfortunately, m_aBreak couldn't be removed entirely, as the autoformats are stored in a binary file, and to be able to read and write these files the offset of the subsequent items must not be changed. Change-Id: Ieba439d3ba5da892b39f00f8b61c5c8467306635 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118662 Tested-by: Jenkins Reviewed-by: Michael Stahl diff --git a/sw/inc/tblafmt.hxx b/sw/inc/tblafmt.hxx index 2873f51e9196..ff6abca8baa7 100644 --- a/sw/inc/tblafmt.hxx +++ b/sw/inc/tblafmt.hxx @@ -173,8 +173,6 @@ class SW_DLLPUBLIC SwTableAutoFormat SwBoxAutoFormat* m_aBoxAutoFormat[ 16 ] = {}; // Writer-specific options -std::shared_ptr m_aBreak; -SwFormatPageDesc m_aPageDesc; std::shared_ptr m_aKeepWithNextPara; sal_uInt16 m_aRepeatHeading; bool m_bLayoutSplit; @@ -191,11 +189,9 @@ public: SwTableAutoFormat& operator=( const SwTableAutoFormat& rNew ); -const SvxFormatBreakItem& GetBreak() const { return *m_aBreak; } const SvxFormatKeepItem& GetKeepWithNextPara() const { return *m_aKeepWithNextPara; } const SvxShadowItem& GetShadow() const { return *m_aShadow; } -void SetBreak(const SvxFormatBreakItem& rNew) { m_aBreak.reset(rNew.Clone()); } void SetKeepWithNextPara(const SvxFormatKeepItem& rNew) { m_aKeepWithNextPara.reset(rNew.Clone()); } void SetShadow(const SvxShadowItem& rNew) { m_aShadow.reset(rNew.Clone()); } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index ade0a9d8170b..4f9ffdb98c40 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1324,17 +1324,9 @@ void SwDocTest::testTableAutoFormats() //Set m_eNumFormatLanguage LanguageType aNFLang( LANGUAGE_GERMAN ); aBoxAF.SetNumFormatLanguage(aNFLang); -//Set m_aBreak -SvxFormatBreakItem aBreak( SvxBreak::PageBefore, 0 ); -aTableAF.SetBreak(aBreak); //Set m_aKeepWithNextPara SvxFormatKeepItem aKWNPara( true, 0 ); aTableAF.SetKeepWithNextPara(aKWNPara); -//Set m_aPageDesc -SwFormatPageDesc aPDesc; -uno::Any aPDAny( sal_uInt16(3) ); -aPDesc.PutValue( aPDAny, 0 ); -aTableAF.m_aPageDesc = aPDesc; //Set m_aRepeatHeading sal_uInt16 aRHeading = 3; aTableAF.m_aRepeatHeading = aRHeading; @@ -1466,12 +1458,8 @@ void SwDocTest::testTableAutoFormats() CPPUNIT_ASSERT( bool( pLoadAF->GetBoxFormat(0).GetSysLanguage() == aSLang ) ); //Get m_eNumFormatLanguage CPPUNIT_ASSERT( bool( pLoadAF->GetBoxFormat(0).GetNumFormatLanguage() == aNFLang ) ); -//Get m_aBreak -CPPUNIT_ASSERT( bool( pLoadAF->GetBreak() == aBreak ) ); //Get m_aKeepWithNextPara CPPUNIT_ASSERT( bool( pLoadAF->GetKeepWithNextPara() == aKWNPara ) ); -//Get m_aPageDesc -CPPUNIT_ASSERT( bool( pLoadAF->m_aPageDesc == aPDesc ) ); //Get m_aRepeatHeading CPPUNIT_ASSERT( bool( pLoadAF->m_aRepeatHeading == aRHeading ) ); //Get m_bLayoutSplit diff --git a/sw/qa/uitest/writer_tests7/tdf134452.py b/sw/qa/uitest/writer_tests7/tdf134452.py new file mode 100644 index ..ce13e8db2270 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf134452.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 134452 - Applying a table style caused the loss of break/pagedesc props of the table + + +class tdf134452(UITestCase): +def test_tdf134452(self): +with self.ui_test.create_doc_in_start_center("writer"): +xWriterDoc =
[Libreoffice-commits] core.git: sw/qa
sw/qa/uitest/writer_tests7/tdf131771.py | 40 1 file changed, 40 insertions(+) New commits: commit 913ea7e18af9e04c82c9b33ddd34b4b5a0917f29 Author: Balazs Santha AuthorDate: Mon Jul 5 12:57:47 2021 +0200 Commit: Xisco Fauli CommitDate: Tue Jul 6 11:15:32 2021 +0200 sw: test fix of tdf#131771 Change-Id: I9879f13e842dd7288c996c1097130e7e7b28589c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118432 Tested-by: Jenkins Reviewed-by: Michael Stahl Reviewed-by: Xisco Fauli diff --git a/sw/qa/uitest/writer_tests7/tdf131771.py b/sw/qa/uitest/writer_tests7/tdf131771.py new file mode 100644 index ..5cbadee63c0e --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf131771.py @@ -0,0 +1,40 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 131771 - Copying+Pasting a table: caused the loss of table style setting. + + +class tdf131771(UITestCase): +def test_tdf131771(self): +with self.ui_test.create_doc_in_start_center("writer"): +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +# generate a 2x2 tables with the same autoformat table style (Default Table Style) +# Note that this style is different than applying nothing! +with self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog: +formatlbinstable = xDialog.getChild("formatlbinstable") +entry = formatlbinstable.getChild("1") +entry.executeAction("SELECT", tuple()) + +# select the table +self.xUITest.executeCommand(".uno:SelectAll") + +# copying and pasting the table below +self.xUITest.executeCommand(".uno:Copy") +self.xUITest.executeCommand(".uno:GoDown") +self.xUITest.executeCommand(".uno:Paste") + +document = self.ui_test.get_component() +tables = document.getTextTables() +self.assertEqual(tables[0].TableTemplateName, 'Default Style') +self.assertEqual(tables[1].TableTemplateName, 'Default Style') + +# vim: set shiftwidth=4 softtabstop=4 expandtab: ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sw/inc sw/source
sw/inc/doc.hxx|2 +- sw/inc/swtable.hxx|2 +- sw/source/core/doc/tblrwcl.cxx|3 ++- sw/source/core/docnode/ndcopy.cxx |1 + sw/source/core/docnode/ndtbl.cxx |4 ++-- sw/source/core/edit/edglss.cxx|2 +- 6 files changed, 8 insertions(+), 6 deletions(-) New commits: commit ec277dfdda8acd08694b03a6b1fb88c5fede35d2 Author: Balazs Santha AuthorDate: Fri Jul 2 19:21:47 2021 +0200 Commit: Michael Stahl CommitDate: Mon Jul 5 11:56:33 2021 +0200 tdf#131771 sw: fix missing table style after copying and pasting the table This fixes the loss of table style setting when copying and then pasting a table. Change-Id: Ie678a269b4cdcddfd73a5d6a27ef9fcb55dcaa46 Change-Id: I48208337ee14fde30417fa3999f56999cc5eda19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118336 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d5c3a210af42..361bf3494c37 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -1268,7 +1268,7 @@ public: bool InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, const SwTable* pCpyTable, bool bCpyName = false, -bool bCorrPos = false ); +bool bCorrPos = false, const OUString& rStyleName = "" ); void UnProtectCells( const OUString& rTableName ); bool UnProtectCells( const SwSelBoxes& rBoxes ); diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx index 8838c54ec76e..6c98d5bed360 100644 --- a/sw/inc/swtable.hxx +++ b/sw/inc/swtable.hxx @@ -278,7 +278,7 @@ public: const bool bPerformValidCheck = false ) const; // Copy selected boxes to another document. bool MakeCopy( SwDoc&, const SwPosition&, const SwSelBoxes&, -bool bCpyName = false ) const; +bool bCpyName = false, const OUString& rStyleName = "" ) const; // Copy table in this bool InsTable( const SwTable& rCpyTable, const SwNodeIndex&, SwUndoTableCpyTable* pUndo ); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 18eab679a289..7b5367255fda 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -2045,7 +2045,7 @@ void SwTable::CopyHeadlineIntoTable( SwTableNode& rTableNd ) bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, const SwSelBoxes& rSelBoxes, -bool bCpyName ) const +bool bCpyName, const OUString& rStyleName ) const { // Find all Boxes/Lines FndBox_ aFndBox( nullptr, nullptr ); @@ -2081,6 +2081,7 @@ bool SwTable::MakeCopy( SwDoc& rInsDoc, const SwPosition& rPos, pNewTable->SetTableStyleName(pTableNd->GetTable().GetTableStyleName()); +pTableNd->GetTable().SetTableStyleName(rStyleName); if( auto pSwDDETable = dynamic_cast(this) ) { // A DDE-Table is being copied diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index 5b3c9edbd9db..91bb99d696b6 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -271,6 +271,7 @@ SwTableNode* SwTableNode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx ) const SwNodeIndex aInsPos( *pEndNd ); SwTable& rTable = pTableNd->GetTable(); +rTable.SetTableStyleName(GetTable().GetTableStyleName()); rTable.RegisterToFormat( *pTableFormat ); rTable.SetRowsToRepeat( GetTable().GetRowsToRepeat() ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 2fb74d2734d7..d6c37d252d36 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -4284,7 +4284,7 @@ void SwDoc::ClearBoxNumAttrs( const SwNodeIndex& rNode ) * This method is called by edglss.cxx/fecopy.cxx */ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, -const SwTable* pCpyTable, bool bCpyName, bool bCorrPos ) +const SwTable* pCpyTable, bool bCpyName, bool bCorrPos, const OUString& rStyleName ) { bool bRet; @@ -4307,7 +4307,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, { ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo()); bRet = pSrcTableNd->GetTable().MakeCopy( *this, rInsPos, rBoxes, -bCpyName ); +bCpyName, rStyleName ); } if( pUndo && bRet ) diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 536a0c1643ff..47791dc69a49 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -190,7 +190,7 @@ bool SwEditShell::CopySelToDoc( SwDoc& rInsDoc ) break;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa sw/source
sw/qa/uitest/writer_tests7/tdf109083.py | 67 sw/source/uibase/app/docst.cxx |5 +- 2 files changed, 71 insertions(+), 1 deletion(-) New commits: commit 67512141b2cce3d74985544ca58a1d8016676d75 Author: Balazs Santha AuthorDate: Fri Jun 18 14:14:04 2021 +0200 Commit: Xisco Fauli CommitDate: Mon Jun 21 13:12:37 2021 +0200 tdf#109083 sw table styles: fix missing format update of tables at table (cell) selection. Table styles (implemented as table templates yet) allows to format all tables (with the same table style) at once. Unfortunately, this worked only without table selection, putting the text cursor in a table cell. But if a table cell/row/column or the whole table was selected (e.g. after changing its format), Manage Styles(F11)->Table Styles-> Style actions menu (see top-right corner of the pane)-> Update Selected Style updated only the style, but it doesn't propagate the changes to the other tables with the same table style. This patch removes the selection to fix the problem in the same way, as the proposed workaround. Note: this fixes the usage of the user-defined table styles, too (created by Style actions->New Style from Selection). Change-Id: I58d01036d5a11e522407405e9ebc16c2c3c83e9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117079 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 840095f417af6619977f688f421e449273c26cae) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117552 Tested-by: Jenkins diff --git a/sw/qa/uitest/writer_tests7/tdf109083.py b/sw/qa/uitest/writer_tests7/tdf109083.py new file mode 100644 index ..bf61a0e4ee3f --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf109083.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +#Bug 109083 - Updating table style: changes didn't propagate to other tables when selection was over two columns at the moment of updating +class tdf109083(UITestCase): +def test_tdf109083(self): +self.ui_test.create_doc_in_start_center("writer") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +#generate two 2x2 tables with the same autoformat table style (Default Table Style) +#Note that this style is different than applying nothing! +for i in range(0, 2): +self.ui_test.execute_dialog_through_command(".uno:InsertTable") +xDialog = self.xUITest.getTopFocusWindow() +formatlbinstable = xDialog.getChild("formatlbinstable") +entry = formatlbinstable.getChild("1") +entry.executeAction("SELECT", tuple()) +xOkBtn = xDialog.getChild("ok") +self.ui_test.close_dialog_through_button(xOkBtn) +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + +#select the last row of the first table +for i in range (0,2): +self.xUITest.executeCommand(".uno:GoDown") +for i in range (0,2): +self.xUITest.executeCommand(".uno:CharRightSel") +#set a specific color on the selected cells (last row) + self.xUITest.executeCommandWithParameters(".uno:TableCellBackgroundColor", mkPropertyValues({"TableCellBackgroundColor" : 16776960 })) + +#Sidebar -> Table Styles -> Style Actions -> "Update Selected Style" (note: the row is still selected) +self.xUITest.executeCommand(".uno:Sidebar") +xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"})) +xLeft = xWriterEdit.getChild('left') +xLeft.executeAction("CLICK", mkPropertyValues({"POS": "5"})) +xRight = xWriterEdit.getChild('right') +xRight.executeAction("CLICK", mkPropertyValues({"POS": "3"})) +#select the second table +for i in range (0,2): +self.xUITest.executeCommand(".uno:GoDown") + +#first row's cells must be yellow, second/last row's cells must be updated to yellow by now +for i in range (0,4): +self.ui_test.execute_dialog_through_command(".uno:TableDialog") +xDialog = self.xUITest.getTopFocusWindow() +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "4") #tab Background +btncolor = xDialog.getChild("btncolor") +btncolor.executeAction("CLICK", tuple()) +hex_custom =
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/uitest/writer_tests7/tdf109083.py | 67 sw/source/uibase/app/docst.cxx |5 +- 2 files changed, 71 insertions(+), 1 deletion(-) New commits: commit 840095f417af6619977f688f421e449273c26cae Author: Balazs Santha AuthorDate: Fri Jun 18 14:14:04 2021 +0200 Commit: László Németh CommitDate: Fri Jun 18 19:23:45 2021 +0200 tdf#109083 sw table styles: fix missing format update of tables at table (cell) selection. Table styles (implemented as table templates yet) allows to format all tables (with the same table style) at once. Unfortunately, this worked only without table selection, putting the text cursor in a table cell. But if a table cell/row/column or the whole table was selected (e.g. after changing its format), Manage Styles(F11)->Table Styles-> Style actions menu (see top-right corner of the pane)-> Update Selected Style updated only the style, but it doesn't propagate the changes to the other tables with the same table style. This patch removes the selection to fix the problem in the same way, as the proposed workaround. Note: this fixes the usage of the user-defined table styles, too (created by Style actions->New Style from Selection). Change-Id: I58d01036d5a11e522407405e9ebc16c2c3c83e9b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117079 Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/qa/uitest/writer_tests7/tdf109083.py b/sw/qa/uitest/writer_tests7/tdf109083.py new file mode 100644 index ..bf61a0e4ee3f --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf109083.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +#Bug 109083 - Updating table style: changes didn't propagate to other tables when selection was over two columns at the moment of updating +class tdf109083(UITestCase): +def test_tdf109083(self): +self.ui_test.create_doc_in_start_center("writer") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +#generate two 2x2 tables with the same autoformat table style (Default Table Style) +#Note that this style is different than applying nothing! +for i in range(0, 2): +self.ui_test.execute_dialog_through_command(".uno:InsertTable") +xDialog = self.xUITest.getTopFocusWindow() +formatlbinstable = xDialog.getChild("formatlbinstable") +entry = formatlbinstable.getChild("1") +entry.executeAction("SELECT", tuple()) +xOkBtn = xDialog.getChild("ok") +self.ui_test.close_dialog_through_button(xOkBtn) +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + +#select the last row of the first table +for i in range (0,2): +self.xUITest.executeCommand(".uno:GoDown") +for i in range (0,2): +self.xUITest.executeCommand(".uno:CharRightSel") +#set a specific color on the selected cells (last row) + self.xUITest.executeCommandWithParameters(".uno:TableCellBackgroundColor", mkPropertyValues({"TableCellBackgroundColor" : 16776960 })) + +#Sidebar -> Table Styles -> Style Actions -> "Update Selected Style" (note: the row is still selected) +self.xUITest.executeCommand(".uno:Sidebar") +xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"})) +xLeft = xWriterEdit.getChild('left') +xLeft.executeAction("CLICK", mkPropertyValues({"POS": "5"})) +xRight = xWriterEdit.getChild('right') +xRight.executeAction("CLICK", mkPropertyValues({"POS": "3"})) +#select the second table +for i in range (0,2): +self.xUITest.executeCommand(".uno:GoDown") + +#first row's cells must be yellow, second/last row's cells must be updated to yellow by now +for i in range (0,4): +self.ui_test.execute_dialog_through_command(".uno:TableDialog") +xDialog = self.xUITest.getTopFocusWindow() +xTabs = xDialog.getChild("tabcontrol") +select_pos(xTabs, "4") #tab Background +btncolor = xDialog.getChild("btncolor") +btncolor.executeAction("CLICK", tuple()) +hex_custom = xDialog.getChild("hex_custom") +if i >= 2: +self.assertEqual(get_state_as_dict(hex_custom)["Text"], "00") +else: +
[Libreoffice-commits] core.git: sw/qa
sw/qa/uitest/writer_tests7/tdf140731.py | 57 1 file changed, 57 insertions(+) New commits: commit e9f9e2315ba5a4f10ac0d3a6a6a6cca711d49b6f Author: Balazs Santha AuthorDate: Sat Apr 24 17:21:36 2021 +0200 Commit: László Németh CommitDate: Mon May 10 10:55:26 2021 +0200 sw: test fix of tdf#140731 (freezing with track changes) Follow-up to commit e463d239555d3a4dc61797eeb8c638b6442112a3 "tdf#140731: sw transliteration: avoid too many redlines" Change-Id: I49d80d6fa5744797b7bb56d470ebc6f3b5f898d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113402 Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/qa/uitest/writer_tests7/tdf140731.py b/sw/qa/uitest/writer_tests7/tdf140731.py new file mode 100644 index ..79972c8ad7f8 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf140731.py @@ -0,0 +1,57 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import type_text + +class tdf140731(UITestCase): +def test_tdf140731(self): +self.ui_test.create_doc_in_start_center("writer") +xWriterDoc = self.xUITest.getTopFocusWindow() +xWriterEdit = xWriterDoc.getChild("writer_edit") +type_text(xWriterEdit, 'Lorem') +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F3"})) +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + +#generating a big text with ~60k words and several paragraphs +for i in range(0,8): +self.xUITest.executeCommand(".uno:SelectAll") +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+c"})) +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+v"})) +xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+v"})) +xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"})) + +#Format->Text operations on small selections (which would generate <~500 redlines), changetracking still working +self.xUITest.executeCommand(".uno:TrackChanges") +xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "1", "END_POS": "1000"})) +self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") +document = self.ui_test.get_component() + self.assertTrue(document.Redlines.createEnumeration().hasMoreElements()) + +#Removing all the redlines. + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges") +xTrackDlg = self.xUITest.getTopFocusWindow() +xAccBtn = xTrackDlg.getChild("rejectall") +xAccBtn.executeAction("CLICK", tuple()) +xCancBtn = xTrackDlg.getChild("close") +xCancBtn.executeAction("CLICK", tuple()) + +#Without the fix in place, on big selections writer would freeze. Now it ignores change tracking. +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") + self.assertFalse(document.Redlines.createEnumeration().hasMoreElements()) + +#The patch has no effects on the Format->Text operations +self.assertEqual(document.Text.String[0:26], "Lorem Ipsum Dolor Sit Amet") +self.xUITest.executeCommand(".uno:SelectAll") +self.xUITest.executeCommand(".uno:ChangeCaseToUpper") +self.assertEqual(document.Text.String[0:26], "LOREM IPSUM DOLOR SIT AMET") + +self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: + ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sw/inc sw/source
sw/inc/ndtxt.hxx|2 sw/source/core/doc/DocumentContentOperationsManager.cxx | 55 ++-- sw/source/core/txtnode/txtedt.cxx |6 - 3 files changed, 54 insertions(+), 9 deletions(-) New commits: commit e463d239555d3a4dc61797eeb8c638b6442112a3 Author: Balazs Santha AuthorDate: Fri Feb 26 08:06:03 2021 -0500 Commit: László Németh CommitDate: Wed Mar 24 15:08:18 2021 +0100 tdf#140731: sw transliteration: avoid too many redlines As a workaround for the performance regression from commit 2d3c77e9b10f20091ef338e262ba7756eb280ce9 (tdf#109266 sw change tracking: track transliteration), switch off redlining to avoid ~freezing, if a single transliteration could result too many (>~500) redlines. A single transliteration creates n redlines for n paragraphs of the selected text, except in the case of transliterating to title case, where it creates n redlines for n words. It's very easy to freeze Writer, because Writer's slowing down with n redlines is described by an O(n²) (quadratic) time complexity. Eg. in an experiment, title casing ~660 words was 6 sec, but ~3000 words was 85 sec, regarding to creating 660 vs 3000 redlines. Note: this is a partial revert of commit 2d3c77e9b10f20091ef338e262ba7756eb280ce9, if the selection contains more than 500 paragraphs (or in the case transliterating to title case, ~500 words). Change-Id: Iad98943cc9e1ed64aa9779e49ee3e941abad02ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111637 Tested-by: Jenkins Tested-by: László Németh Reviewed-by: László Németh diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 5dbbbc721f37..50986f3daca7 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -746,7 +746,7 @@ public: /// change text to Upper/Lower/Hiragana/Katakana/... void TransliterateText( utl::TransliterationWrapper& rTrans, sal_Int32 nStart, sal_Int32 nEnd, -SwUndoTransliterate* pUndo ); +SwUndoTransliterate* pUndo, bool bUseRedlining = false ); /// count words in given range - returns true if we refreshed out count bool CountWords( SwDocStat& rStat, sal_Int32 nStart, sal_Int32 nEnd ) const; diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index b9846d852a2a..e66ed8e4a673 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -74,6 +74,8 @@ #include #include #include +#include +#include #include #include #include @@ -2821,6 +2823,44 @@ void DocumentContentOperationsManager::TransliterateText( } } +bool bUseRedlining = m_rDoc.getIDocumentRedlineAccess().IsRedlineOn(); +// as a workaround for a known performance problem, switch off redlining +// to avoid freezing, if transliteration could result too many redlines +if ( bUseRedlining ) +{ +const sal_uLong nMaxRedlines = 500; +const bool bIsTitleCase = rTrans.getType() == TransliterationFlags::TITLE_CASE; +sal_uLong nAffectedNodes = 0; +sal_uLong nAffectedChars = nEndCnt; +SwNodeIndex aIdx( pStt->nNode ); +for( ; aIdx.GetIndex() <= nEndNd; ++aIdx ) +{ +SwTextNode* pAffectedNode = aIdx.GetNode().GetTextNode(); + +// don't count not text nodes or empty text nodes +if( !pAffectedNode || pAffectedNode->GetText().isEmpty() ) +continue; + +nAffectedNodes++; + +// count characters of the node (the last - maybe partially +// selected - node was counted at initialization of nAffectedChars) +if( aIdx.GetIndex() < nEndNd ) +nAffectedChars += pAffectedNode->GetText().getLength(); + +// transliteration creates n redlines for n nodes, except in the +// case of title case, where it creates n redlines for n words +if( nAffectedNodes > nMaxRedlines || +// estimate word count based on the character count, where +// 6 = average English word length is ~5 letters + space +( bIsTitleCase && (nAffectedChars - nSttCnt)/6 > nMaxRedlines ) ) +{ +bUseRedlining = false; +break; +} +} +} + if( nSttNd != nEndNd ) // is more than one text node involved? { // iterate over all effected text nodes, the first and the last one @@ -2831,8 +2871,10 @@ void DocumentContentOperationsManager::TransliterateText( { ++aIdx; if( pTNd ) +{ pTNd->TransliterateText( -rTrans, nSttCnt, pTNd->GetText().getLength(),