tdf#131638: Fix text cell incorrect formula
Change-Id: I086f077540f52c6ed5fb4df9f0ea64aa95aea152 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152348 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
committed by
Mike Kaganski
parent
b111418f61
commit
730e6fa063
@@ -0,0 +1,26 @@
|
||||
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
|
||||
#
|
||||
# This file is part of the LibreOffice project.
|
||||
#
|
||||
# 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_url_for_data_file
|
||||
from libreoffice.calc.document import get_cell_by_position
|
||||
from libreoffice.uno.propertyvalue import mkPropertyValues
|
||||
|
||||
class tdf137726(UITestCase):
|
||||
|
||||
def test_tdf137726(self):
|
||||
with self.ui_test.load_file(get_url_for_data_file("tdf131638.ods")) as calc_doc:
|
||||
MainWindow = self.xUITest.getTopFocusWindow()
|
||||
grid_window = MainWindow.getChild("grid_window")
|
||||
grid_window.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
|
||||
grid_window.executeAction("TYPE", mkPropertyValues({"TEXT": "-/2"}))
|
||||
grid_window.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
|
||||
self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "-/2")
|
||||
|
||||
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|
||||
Binary file not shown.
@@ -408,8 +408,11 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
|
||||
bool bFormula = false;
|
||||
|
||||
// do not check formula if it is a text cell
|
||||
sal_uInt32 format = rDoc.GetNumberFormat( nCol, nRow, nTab );
|
||||
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
|
||||
// a single '=' character is handled as string (needed for special filters)
|
||||
if ( rString.getLength() > 1 )
|
||||
if ( pFormatter->GetType(format) != SvNumFormatType::TEXT && rString.getLength() > 1 )
|
||||
{
|
||||
if ( rString[0] == '=' )
|
||||
{
|
||||
@@ -431,10 +434,8 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
// is non-empty and not a number, handle as formula
|
||||
if ( aString.getLength() > 1 )
|
||||
{
|
||||
sal_uInt32 nFormat = rDoc.GetNumberFormat( nCol, nRow, nTab );
|
||||
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
|
||||
double fNumber = 0;
|
||||
if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
|
||||
if ( !pFormatter->IsNumberFormat( aString, format, fNumber ) )
|
||||
{
|
||||
bFormula = true;
|
||||
}
|
||||
@@ -568,7 +569,6 @@ void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab,
|
||||
|
||||
ScFormulaCell aCell(rDoc, aPos, std::move( pArr ), formula::FormulaGrammar::GRAM_DEFAULT, ScMatrixMode::NONE);
|
||||
|
||||
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
|
||||
for (const auto& rTab : rMark)
|
||||
{
|
||||
i = rTab;
|
||||
|
||||
Reference in New Issue
Block a user