summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2016-12-26 14:59:21 +0300
committerEike Rathke <erack@redhat.com>2017-01-10 21:32:26 +0000
commitdfc6f4c1be58b088dd099f6f8bb6103bf962e144 (patch)
treeafdd7360fac4481f561b360da6ef79a6983a136a
parentcbebea151b9ba907e9ff69fd48996fee38c1f22d (diff)
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 <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
-rwxr-xr-xsc/qa/unit/data/xlsx/tdf97598_scenarios.xlsxbin0 -> 8400 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx15
-rw-r--r--sc/source/filter/inc/scenariobuffer.hxx3
-rw-r--r--sc/source/filter/oox/scenariobuffer.cxx23
4 files changed, 24 insertions, 17 deletions
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 000000000000..ba3f43f8e499
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf97598_scenarios.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 910334e1dd7f..7306a4a9354e 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -233,6 +233,7 @@ public:
void testTdf100458();
void testTdf100709XLSX();
+ void testTdf97598XLSX();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -347,6 +348,7 @@ public:
CPPUNIT_TEST(testTdf100458);
CPPUNIT_TEST(testTdf100709XLSX);
+ CPPUNIT_TEST(testTdf97598XLSX);
CPPUNIT_TEST_SUITE_END();
@@ -3814,6 +3816,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 cfe18f7eb94a..ddfbee5e86a8 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 0060adf80df7..1ae9becb6a21 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 ) :