[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Tobias Lippert
drtl at fastmail.fm
Wed Nov 4 06:30:32 PST 2015
sw/qa/python/check_table.py | 70 +++++++++++++++++++++++++++++++++++++++
sw/source/core/docnode/ndtbl.cxx | 2 -
sw/source/core/text/widorp.hxx | 9 ++++-
3 files changed, 79 insertions(+), 2 deletions(-)
New commits:
commit 20538f233fe120b33a23d594458d4639b0c9670e
Author: Tobias Lippert <drtl at fastmail.fm>
Date: Sun Sep 27 21:30:20 2015 +0200
tdf#83910 Formatting of lines which consist of a single dummy line only
The document which is attached to the ticket runs into an infinite
loop because GetLineNr() does not increase since
only dummy lines are added during formatting.
Change-Id: I92689c776fe69bb6f62af26b577989db7f34de43
Reviewed-on: https://gerrit.libreoffice.org/18896
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Oliver Specht <oliver.specht at cib.de>
diff --git a/sw/source/core/text/widorp.hxx b/sw/source/core/text/widorp.hxx
index 18e80f1..8541848 100644
--- a/sw/source/core/text/widorp.hxx
+++ b/sw/source/core/text/widorp.hxx
@@ -71,7 +71,14 @@ public:
// method <SwTextFrmBreak::IsBreakNow>, which isn't virtual.
bool IsBreakNowWidAndOrp( SwTextMargin &rLine )
{
- return ( rLine.GetLineNr() > nOrphLines ) && IsBreakNow( rLine );
+ bool isOnFirstLine = (rLine.GetLineNr() == 1 && !rLine.GetPrev());
+ if ( isOnFirstLine && rLine.GetCurr()->IsDummy()) {
+ return IsBreakNow( rLine );
+ }
+ if ( rLine.GetLineNr() > nOrphLines ) {
+ return IsBreakNow( rLine );
+ }
+ return false;
}
};
commit aa334d55ee34c125f6f4fdfaadbc1ed8fa33f5bc
Author: Niklas Johansson <sleeping.pillow at gmail.com>
Date: Fri Oct 23 19:52:17 2015 +0200
Make number recognition work in writer tables again
It seems that number recognition in tables are not working properly
enter 10-10-10 and it should be converted to a date but it is not.
I tracked it down to the fix of bug fdo#32082. It looks like bSetNumFmt
was changed to false by mistake. Since then it has changed name to
bSetNumFormat. From what I can tell fdo#32082 still works after this
patch, but I might have missed some nuance of that bug report.
Added two tests, one for the bug mentioned above and one to check
that number recognition is working. At least with a simple date.
Change-Id: Id58849a223eb602054c66c7379cd56a68a93dea2
Reviewed-on: https://gerrit.libreoffice.org/19563
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/sw/qa/python/check_table.py b/sw/qa/python/check_table.py
index a5a8308..1e361cf 100644
--- a/sw/qa/python/check_table.py
+++ b/sw/qa/python/check_table.py
@@ -7,6 +7,8 @@ from com.sun.star.table import BorderLine
from com.sun.star.table import BorderLine2
from com.sun.star.table.BorderLineStyle import (DOUBLE, SOLID, EMBOSSED,\
THICKTHIN_LARGEGAP, DASHED, DOTTED)
+from com.sun.star.util import XNumberFormats
+from com.sun.star.lang import Locale
class CheckTable(unittest.TestCase):
_uno = None
@@ -450,6 +452,74 @@ class CheckTable(unittest.TestCase):
self.assertEqual(
[int(txtval) for txtval in xSeq.TextualData],
[val for val in expectedValues[col]])
+ xDoc.dispose()
+
+ def test_tdf32082(self):
+ xDoc = CheckTable._uno.openEmptyWriterDoc()
+ xDocFrame = xDoc.CurrentController.Frame
+ xContext = CheckTable._uno.getContext()
+ xServiceManager = xContext.ServiceManager
+ xDispatcher = xServiceManager.createInstanceWithContext(
+ 'com.sun.star.frame.DispatchHelper', xContext)
+ xTable = xDoc.createInstance("com.sun.star.text.TextTable")
+ xTable.initialize(1,1)
+ xCursor = xDoc.Text.createTextCursor()
+ xDoc.Text.insertTextContent(xCursor, xTable, False)
+ # Setup numberformat for the cell
+ xNumberFormats = xDoc.NumberFormats
+ xLocale = Locale('en', 'US', '')
+ formatString = '#,##0.00 [$€-407];[RED]-#,##0.00 [$€-407]'
+ key = xNumberFormats.queryKey(formatString, xLocale, True)
+ if key == -1:
+ key = xNumberFormats.addNew(formatString, xLocale)
+ # Apply the format on the first cell
+ xTable.getCellByPosition(0,0).NumberFormat = key
+ xDispatcher.executeDispatch(xDocFrame, '.uno:GoToStartOfDoc', '', 0, ())
+ xDispatcher.executeDispatch(xDocFrame, '.uno:InsertText', '', 0,
+ (PropertyValue('Text', 0, '3', 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:JumpToNextCell', '', 0, ())
+ # Check that the formatting we set up is not destroyed
+ self.assertEquals(xTable.getCellByPosition(0,0).getString(), '3.00 €')
+ self.assertEquals(xTable.getCellByPosition(0,0).getValue(), 3)
+ # Verify that it works with number recognition turned on as well
+ xDispatcher.executeDispatch(xDocFrame, '.uno:TableNumberRecognition', '', 0,
+ (PropertyValue('TableNumberRecognition', 0, True, 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:InsertText', '', 0,
+ (PropertyValue('Text', 0, '4', 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:JumpToNextCell', '', 0, ())
+ self.assertEquals(xTable.getCellByPosition(0,1).getString(), '4.00 €')
+ self.assertEquals(xTable.getCellByPosition(0,1).getValue(), 4)
+ xDoc.dispose()
+
+ def test_numberRecognition(self):
+ xDoc = CheckTable._uno.openEmptyWriterDoc()
+ xDocFrame = xDoc.CurrentController.Frame
+ xContext = CheckTable._uno.getContext()
+ xServiceManager = xContext.ServiceManager
+ xDispatcher = xServiceManager.createInstanceWithContext(
+ 'com.sun.star.frame.DispatchHelper', xContext)
+ xTable = xDoc.createInstance('com.sun.star.text.TextTable')
+ xTable.initialize(2,1)
+ xCursor = xDoc.Text.createTextCursor()
+ xDoc.Text.insertTextContent(xCursor, xTable, False)
+ xDispatcher.executeDispatch(xDocFrame, '.uno:GoToStartOfDoc', '', 0, ())
+ xDispatcher.executeDispatch(xDocFrame, '.uno:InsertText', '', 0,
+ (PropertyValue('Text', 0, '15-10-30', 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:JumpToNextCell', '', 0, ())
+ # Without number recognition 15-10-30 should not be interperated as a date
+ self.assertEquals(xTable.getCellByPosition(0,0).getString(), '15-10-30')
+ self.assertEquals(xTable.getCellByPosition(0,0).getValue(), 0)
+ # Activate number recognition
+ xDispatcher.executeDispatch(xDocFrame, '.uno:TableNumberRecognition', '', 0,
+ (PropertyValue('TableNumberRecognition', 0, True, 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:InsertText', '', 0,
+ (PropertyValue('Text', 0, '15-10-30', 0),))
+ xDispatcher.executeDispatch(xDocFrame, '.uno:JumpToNextCell', '', 0, ())
+ # With number recognition it should now be a date, confirm by checking
+ # the string and value of the cell.
+ self.assertEquals(xTable.getCellByPosition(0,1).getString(), '2015-10-30')
+ self.assertEquals(xTable.getCellByPosition(0,1).getValue(), 42307.0)
+ xDoc.dispose()
if __name__ == '__main__':
unittest.main()
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 1faddb2..cef4277 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4060,7 +4060,7 @@ void SwDoc::ChkBoxNumFormat( SwTableBox& rBox, bool bCallUpdate )
SfxItemSet aBoxSet( GetAttrPool(), RES_BOXATR_FORMAT, RES_BOXATR_VALUE );
bool bLockModify = true;
- bool bSetNumberFormat = false;
+ bool bSetNumberFormat = IsInsTableFormatNum();
const bool bForceNumberFormat = IsInsTableFormatNum() && IsInsTableChangeNumFormat();
// if the user forced a number format in this cell previously,
More information about the Libreoffice-commits
mailing list