summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin.luth@collabora.com>2018-05-23 08:36:54 +0300
committerEike Rathke <erack@redhat.com>2018-06-04 20:15:18 +0200
commit513204bcf7b9a43535ed585251e73a6d77805148 (patch)
tree141a0ff5d24353a97ca22c8887e4441a1c73674c
parent55eb65ba02dc8779fa489017745cdc952a07d10c (diff)
tdf#114487 sc htmlimp: rangeNames should be 3D
Without a visible sheet name, these absolute ranges become relative after a round-trip. Another way to handle this would be to ensure that ODS (and other text-based formats) export Absolute in a way that can be properly imported. But handling it on import is safer and ensures UI consistency. The InitRange default is for !IsFlag3D and !IsTabRel(). Since the range already imports as absolute, just add the appropriate 3D flags. Change-Id: Ia664e6f87e235096e1c2e5b702e18505e375e2ad Reviewed-on: https://gerrit.libreoffice.org/54725 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com> (cherry picked from commit c42b1cf2464924b125aeae15968fb79cf795bc81) Reviewed-on: https://gerrit.libreoffice.org/55273
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx16
-rw-r--r--sc/source/filter/html/htmlimp.cxx2
2 files changed, 18 insertions, 0 deletions
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 2a7a76e244a8..8762cbcc339a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -175,6 +175,7 @@ public:
#if !defined _WIN32
void testSupBookVirtualPathXLS();
#endif
+ void testAbsNamedRangeHTML();
void testSheetLocalRangeNameXLS();
void testSheetTextBoxHyperlinkXLSX();
void testFontSizeXLSX();
@@ -281,6 +282,7 @@ public:
CPPUNIT_TEST(testImageWithSpecialID);
CPPUNIT_TEST(testPreserveTextWhitespaceXLSX);
CPPUNIT_TEST(testPreserveTextWhitespace2XLSX);
+ CPPUNIT_TEST(testAbsNamedRangeHTML);
CPPUNIT_TEST(testSheetLocalRangeNameXLS);
CPPUNIT_TEST(testSheetTextBoxHyperlinkXLSX);
CPPUNIT_TEST(testFontSizeXLSX);
@@ -3325,6 +3327,20 @@ void ScExportTest::testImageWithSpecialID()
}
}
+void ScExportTest::testAbsNamedRangeHTML()
+{
+ ScDocShellRef xDocSh = loadDoc("numberformat.", FORMAT_HTML);
+ xDocSh->DoHardRecalc();
+ ScDocShellRef xDocSh2 = saveAndReload(xDocSh.get(), FORMAT_ODS);
+ xDocSh->DoClose();
+ xDocSh2->DoHardRecalc();
+
+ ScDocument& rDoc = xDocSh2->GetDocument();
+ ScRangeData* pRangeData = rDoc.GetRangeName()->findByUpperName(OUString("HTML_1"));
+ ScSingleRefData* pRef = pRangeData->GetCode()->FirstToken()->GetSingleRef();
+ CPPUNIT_ASSERT_MESSAGE("HTML_1 is an absolute reference",!pRef->IsTabRel());
+}
+
void ScExportTest::testSheetLocalRangeNameXLS()
{
ScDocShellRef xDocSh = loadDoc("named-ranges-local.", FORMAT_XLS);
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index a5f1f11abe4b..4957b2d381ad 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -102,6 +102,8 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const OUString& rName, con
{
ScComplexRefData aRefData;
aRefData.InitRange( rRange );
+ aRefData.Ref1.SetFlag3D( true );
+ aRefData.Ref2.SetFlag3D( aRefData.Ref2.Tab() != aRefData.Ref1.Tab() );
ScTokenArray aTokArray;
aTokArray.AddDoubleReference( aRefData );
ScRangeData* pRangeData = new ScRangeData( pDoc, rName, aTokArray );