sc/qa/unit/data/xlsx/tdf97598_scenarios.xlsx |binary sc/qa/unit/subsequent_filters-test.cxx | 15 +++++++++++++++ sc/source/filter/inc/scenariobuffer.hxx | 3 ++- sc/source/filter/oox/scenariobuffer.cxx | 23 +++++++---------------- 4 files changed, 24 insertions(+), 17 deletions(-)
New commits: commit 9fdb840b23889e2554740abcb99c71b566dbafc6 Author: Justin Luth <justin_l...@sil.org> Date: Mon Dec 26 14:59:21 2016 +0300 tdf#97598 xlsx import: do not apply any scenarios Excel does not automatically apply scenarios, so neither should LO. Scenarios appear to first be supported in 2009 and this section that applies the "mnShown" scenario comes from > commit 0851da4d8a0a557f1e9a31af652a530c615c2989 > CWS-TOOLING: integrate CWS dr68 mnShown should only mean the last scenario that was shown, so mark it as active, but don't apply it. In Excel, mnCurrent tracks and auto-selects a scenario in the dialog box, so that is irrelevant to us. Change-Id: I6b4a9b14733d6ab6dc2283a569f0e2484f81c24f Reviewed-on: https://gerrit.libreoffice.org/32432 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Eike Rathke <er...@redhat.com> (cherry picked from commit dfc6f4c1be58b088dd099f6f8bb6103bf962e144) Reviewed-on: https://gerrit.libreoffice.org/32941 Reviewed-by: Justin Luth <justin_l...@sil.org> diff --git a/sc/qa/unit/data/xlsx/tdf97598_scenarios.xlsx b/sc/qa/unit/data/xlsx/tdf97598_scenarios.xlsx new file mode 100755 index 0000000..ba3f43f Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf97598_scenarios.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 3b5efca..8873513 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -239,6 +239,7 @@ public: void testTdf100458(); void testTdf100709XLSX(); + void testTdf97598XLSX(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testBooleanFormatXLSX); @@ -355,6 +356,7 @@ public: CPPUNIT_TEST(testTdf100458); CPPUNIT_TEST(testTdf100709XLSX); + CPPUNIT_TEST(testTdf97598XLSX); CPPUNIT_TEST_SUITE_END(); @@ -3849,6 +3851,19 @@ void ScFiltersTest::testTdf100709XLSX() xDocSh->DoClose(); } +void ScFiltersTest::testTdf97598XLSX() +{ + ScDocShellRef xDocSh = loadDoc("tdf97598_scenarios.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load tdf97598_secenarios.xlsx", xDocSh.Is()); + + ScDocument& rDoc = xDocSh->GetDocument(); + OUString aStr = rDoc.GetString(0, 0, 0); // A1 + CPPUNIT_ASSERT_EQUAL(OUString("Cell A1"), aStr); + + xDocSh->DoClose(); +} + + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { diff --git a/sc/source/filter/inc/scenariobuffer.hxx b/sc/source/filter/inc/scenariobuffer.hxx index cfe18f7..ddfbee5 100644 --- a/sc/source/filter/inc/scenariobuffer.hxx +++ b/sc/source/filter/inc/scenariobuffer.hxx @@ -44,6 +44,7 @@ struct ScenarioModel OUString maUser; /// Name of user created the scenario. bool mbLocked; /// True = input cell values locked. bool mbHidden; /// True = scenario is hidden. + bool mbActive; explicit ScenarioModel(); }; @@ -51,7 +52,7 @@ struct ScenarioModel class Scenario : public WorkbookHelper { public: - explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet ); + explicit Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet, bool bIsActive ); /** Imports a scenario definition from a scenario element. */ void importScenario( const AttributeList& rAttribs ); diff --git a/sc/source/filter/oox/scenariobuffer.cxx b/sc/source/filter/oox/scenariobuffer.cxx index 0060adf..1ae9bec 100644 --- a/sc/source/filter/oox/scenariobuffer.cxx +++ b/sc/source/filter/oox/scenariobuffer.cxx @@ -50,14 +50,16 @@ ScenarioCellModel::ScenarioCellModel() : ScenarioModel::ScenarioModel() : mbLocked( false ), - mbHidden( false ) + mbHidden( false ), + mbActive( false ) { } -Scenario::Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet ) : +Scenario::Scenario( const WorkbookHelper& rHelper, sal_Int16 nSheet, bool bIsActive ) : WorkbookHelper( rHelper ), mnSheet( nSheet ) { + maModel.mbActive = bIsActive; } void Scenario::importScenario( const AttributeList& rAttribs ) @@ -138,7 +140,7 @@ void Scenario::finalizeImport() // scenario properties PropertySet aPropSet( xScenarios->getByName( aScenName ) ); - aPropSet.setProperty( PROP_IsActive, false ); + aPropSet.setProperty( PROP_IsActive, maModel.mbActive ); aPropSet.setProperty( PROP_CopyBack, false ); aPropSet.setProperty( PROP_CopyStyles, false ); aPropSet.setProperty( PROP_CopyFormulas, false ); @@ -178,7 +180,8 @@ void SheetScenarios::importScenarios( SequenceInputStream& rStrm ) Scenario& SheetScenarios::createScenario() { - ScenarioVector::value_type xScenario( new Scenario( *this, mnSheet ) ); + bool bIsActive = maScenarios.size() == (sal_uInt32) maModel.mnShown; + ScenarioVector::value_type xScenario( new Scenario( *this, mnSheet, bIsActive ) ); maScenarios.push_back( xScenario ); return *xScenario; } @@ -186,18 +189,6 @@ Scenario& SheetScenarios::createScenario() void SheetScenarios::finalizeImport() { maScenarios.forEachMem( &Scenario::finalizeImport ); - - // activate a scenario - try - { - Reference< XScenariosSupplier > xScenariosSupp( getSheetFromDoc( mnSheet ), UNO_QUERY_THROW ); - Reference< XIndexAccess > xScenariosIA( xScenariosSupp->getScenarios(), UNO_QUERY_THROW ); - Reference< XScenario > xScenario( xScenariosIA->getByIndex( maModel.mnShown ), UNO_QUERY_THROW ); - xScenario->apply(); - } - catch( Exception& ) - { - } } ScenarioBuffer::ScenarioBuffer( const WorkbookHelper& rHelper ) : _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits