diff options
author | Philipp Hofer <philipp.hofer@protonmail.com> | 2020-11-12 13:12:24 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2020-11-19 01:36:55 +0100 |
commit | 6ceb1d0f2e23749fe03fab08ec338ba4d7782173 (patch) | |
tree | 44e69c2fdf12594169ca3a052224368faa967185 /sc/qa | |
parent | 695280feb90729fde1a7ecf1c409ae16f8281a46 (diff) |
tdf#123936 Formatting files in module sc with clang-format
Change-Id: I66cafda863e3e1e4559a57289c09925d68b0719c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105701
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Jenkins
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/extras/check_data_pilot_field.cxx | 61 | ||||
-rw-r--r-- | sc/qa/extras/recordchanges-test.cxx | 27 | ||||
-rw-r--r-- | sc/qa/extras/sccellrangesobj.cxx | 39 | ||||
-rw-r--r-- | sc/qa/extras/scmodelobj.cxx | 25 | ||||
-rw-r--r-- | sc/qa/extras/scoutlineobj.cxx | 17 | ||||
-rw-r--r-- | sc/qa/extras/scsubtotalfieldobj.cxx | 29 | ||||
-rw-r--r-- | sc/qa/unit/dataproviders_test.cxx | 45 | ||||
-rw-r--r-- | sc/qa/unit/test_ScChartListenerCollection.cxx | 38 |
8 files changed, 135 insertions, 146 deletions
diff --git a/sc/qa/extras/check_data_pilot_field.cxx b/sc/qa/extras/check_data_pilot_field.cxx index 3445245ade2b..bde647232839 100644 --- a/sc/qa/extras/check_data_pilot_field.cxx +++ b/sc/qa/extras/check_data_pilot_field.cxx @@ -27,17 +27,19 @@ using namespace css; using namespace css::lang; -namespace sc_apitest { - -class CheckDataPilotField : public CalcUnoApiTest, public apitest::XNamed, public apitest::XPropertySet +namespace sc_apitest +{ +class CheckDataPilotField : public CalcUnoApiTest, + public apitest::XNamed, + public apitest::XPropertySet { - public: +public: CheckDataPilotField(); virtual void setUp() override; virtual void tearDown() override; - uno::Reference< uno::XInterface > init() override; + uno::Reference<uno::XInterface> init() override; CPPUNIT_TEST_SUITE(CheckDataPilotField); @@ -53,7 +55,6 @@ class CheckDataPilotField : public CalcUnoApiTest, public apitest::XNamed, publi CPPUNIT_TEST_SUITE_END(); protected: - virtual bool isPropertyIgnored(const OUString& rName) override; private: @@ -64,19 +65,17 @@ private: bool CheckDataPilotField::isPropertyIgnored(const OUString& rName) { - return rName == "Function" - || rName == "Subtotals" - || rName == "Function2" - || rName == "Subtotals2"; + return rName == "Function" || rName == "Subtotals" || rName == "Function2" + || rName == "Subtotals2"; } CheckDataPilotField::CheckDataPilotField() - : CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XNamed("Col1") + : CalcUnoApiTest("/sc/qa/extras/testdocuments") + , apitest::XNamed("Col1") { } -uno::Reference< uno::XInterface > CheckDataPilotField::init() +uno::Reference<uno::XInterface> CheckDataPilotField::init() { // create a calc document if (!mxComponent.is()) @@ -85,14 +84,14 @@ uno::Reference< uno::XInterface > CheckDataPilotField::init() else return mxObject; - uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); // the cell range table::CellRangeAddress sCellRangeAdress; sCellRangeAdress.Sheet = 0; sCellRangeAdress.StartColumn = 1; sCellRangeAdress.StartRow = 0; - sCellRangeAdress.EndColumn = mMaxFieldIndex-1; + sCellRangeAdress.EndColumn = mMaxFieldIndex - 1; sCellRangeAdress.EndRow = mMaxFieldIndex - 1; // position of the data pilot table @@ -101,17 +100,17 @@ uno::Reference< uno::XInterface > CheckDataPilotField::init() sCellAdress.Column = 7; sCellAdress.Row = 8; // Getting spreadsheet - uno::Reference< sheet::XSpreadsheets > xSpreadsheets = xSheetDoc->getSheets(); - uno::Reference< container::XIndexAccess > oIndexAccess(xSpreadsheets, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheets> xSpreadsheets = xSheetDoc->getSheets(); + uno::Reference<container::XIndexAccess> oIndexAccess(xSpreadsheets, uno::UNO_QUERY_THROW); // Per default there's now just one sheet, make sure we have at least two, then xSpreadsheets->insertNewByName("Some Sheet", 0); uno::Any aAny = oIndexAccess->getByIndex(0); - uno::Reference< sheet::XSpreadsheet > oSheet; + uno::Reference<sheet::XSpreadsheet> oSheet; CPPUNIT_ASSERT(aAny >>= oSheet); uno::Any aAny2 = oIndexAccess->getByIndex(1); - uno::Reference< sheet::XSpreadsheet > oSheet2; + uno::Reference<sheet::XSpreadsheet> oSheet2; CPPUNIT_ASSERT(aAny2 >>= oSheet2); //Filling a table @@ -129,33 +128,33 @@ uno::Reference< uno::XInterface > CheckDataPilotField::init() { oSheet->getCellByPosition(i, j)->setValue(i * (j + 1)); oSheet2->getCellByPosition(i, j)->setValue(i * (j + 2)); - } + } } // change a value of a cell and check the change in the data pilot // cell of data uno::Any oChangeCell; - oChangeCell<<= oSheet->getCellByPosition(1, 5); + oChangeCell <<= oSheet->getCellByPosition(1, 5); int x = sCellAdress.Column; int y = sCellAdress.Row + 3; // cell of the data pilot output uno::Any oCheckCell; - oCheckCell<<= oSheet->getCellByPosition(x, y); + oCheckCell <<= oSheet->getCellByPosition(x, y); // create the test objects - uno::Reference< sheet::XDataPilotTablesSupplier> DPTS(oSheet, uno::UNO_QUERY_THROW); - uno::Reference< sheet::XDataPilotTables> DPT = DPTS->getDataPilotTables(); - uno::Reference< sheet::XDataPilotDescriptor> DPDsc = DPT->createDataPilotDescriptor(); + uno::Reference<sheet::XDataPilotTablesSupplier> DPTS(oSheet, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XDataPilotTables> DPT = DPTS->getDataPilotTables(); + uno::Reference<sheet::XDataPilotDescriptor> DPDsc = DPT->createDataPilotDescriptor(); DPDsc->setSourceRange(sCellRangeAdress); uno::Any oDataPilotField = DPDsc->getDataPilotFields()->getByIndex(0); - uno::Reference<beans::XPropertySet> fieldPropSet(oDataPilotField, uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> fieldPropSet(oDataPilotField, uno::UNO_QUERY_THROW); uno::Any sum; - sum<<= sheet::GeneralFunction_SUM; - fieldPropSet->setPropertyValue("Function", sum ); + sum <<= sheet::GeneralFunction_SUM; + fieldPropSet->setPropertyValue("Function", sum); uno::Any data; - data<<= sheet::DataPilotFieldOrientation_DATA; + data <<= sheet::DataPilotFieldOrientation_DATA; fieldPropSet->setPropertyValue("Orientation", data); //Insert the DataPilotTable @@ -163,7 +162,7 @@ uno::Reference< uno::XInterface > CheckDataPilotField::init() DPT->removeByName("DataPilotField"); DPT->insertNewByName("DataPilotTField", sCellAdress, DPDsc); - uno::Reference< container::XIndexAccess > IA = DPDsc->getDataPilotFields(); + uno::Reference<container::XIndexAccess> IA = DPDsc->getDataPilotFields(); uno::Reference<uno::XInterface> xDataPilotFieldObject; data = IA->getByIndex(0); CPPUNIT_ASSERT(data >>= xDataPilotFieldObject); @@ -172,7 +171,6 @@ uno::Reference< uno::XInterface > CheckDataPilotField::init() return xDataPilotFieldObject; } - void CheckDataPilotField::setUp() { CalcUnoApiTest::setUp(); @@ -187,7 +185,6 @@ void CheckDataPilotField::tearDown() } CPPUNIT_TEST_SUITE_REGISTRATION(CheckDataPilotField); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/extras/recordchanges-test.cxx b/sc/qa/extras/recordchanges-test.cxx index 357023e0d361..709a80238af6 100644 --- a/sc/qa/extras/recordchanges-test.cxx +++ b/sc/qa/extras/recordchanges-test.cxx @@ -31,22 +31,21 @@ public: CPPUNIT_TEST(testSetRecordChanges); CPPUNIT_TEST(testCheckRecordChangesProtection); CPPUNIT_TEST_SUITE_END(); - }; void ScRecordChangesTest::testSetRecordChanges() { + uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop("private:factory/scalc"); - uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop("private:factory/scalc"); - - uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xDocSettingsPropSet (xDoc, UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xDocSettingsPropSet(xDoc, UNO_QUERY_THROW); bool recordChangesValue = true; bool protectionValue = true; CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue); - CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue); + CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") + >>= protectionValue); CPPUNIT_ASSERT_MESSAGE("a new document does not record changes", !recordChangesValue); CPPUNIT_ASSERT_MESSAGE("a new document does not protect record changes", !protectionValue); @@ -66,17 +65,18 @@ void ScRecordChangesTest::testCheckRecordChangesProtection() { // test with protected changes OUString aFileName; - createFileURL( "RecordChangesProtected.ods", aFileName); - uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName); + createFileURL("RecordChangesProtected.ods", aFileName); + uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileName); - uno::Reference< sheet::XSpreadsheetDocument > xDoc(xComponent, UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xDocSettingsPropSet (xDoc, UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xDocSettingsPropSet(xDoc, UNO_QUERY_THROW); bool recordChangesValue = false; bool protectionValue = false; CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue); - CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue); + CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") + >>= protectionValue); CPPUNIT_ASSERT_MESSAGE("the document should be recording changes", recordChangesValue); CPPUNIT_ASSERT_MESSAGE("the protection should be active", protectionValue); @@ -87,7 +87,8 @@ void ScRecordChangesTest::testCheckRecordChangesProtection() xDocSettingsPropSet->setPropertyValue("RecordChanges", aValue); CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("RecordChanges") >>= recordChangesValue); - CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") >>= protectionValue); + CPPUNIT_ASSERT(xDocSettingsPropSet->getPropertyValue("IsRecordChangesProtected") + >>= protectionValue); // this document should still record changes as protection is set CPPUNIT_ASSERT_MESSAGE("the document should still be recording changes", recordChangesValue); @@ -97,7 +98,7 @@ void ScRecordChangesTest::testCheckRecordChangesProtection() } ScRecordChangesTest::ScRecordChangesTest() - : UnoApiTest("/sc/qa/extras/testdocuments") + : UnoApiTest("/sc/qa/extras/testdocuments") { } diff --git a/sc/qa/extras/sccellrangesobj.cxx b/sc/qa/extras/sccellrangesobj.cxx index 174552d9c598..e87f6792e9e9 100644 --- a/sc/qa/extras/sccellrangesobj.cxx +++ b/sc/qa/extras/sccellrangesobj.cxx @@ -28,8 +28,8 @@ using namespace css; using namespace css::uno; -namespace sc_apitest { - +namespace sc_apitest +{ class ScCellRangesObj : public CalcUnoApiTest, public apitest::SheetCellRanges, public apitest::XEnumerationAccess, @@ -45,8 +45,8 @@ public: virtual void setUp() override; virtual void tearDown() override; - virtual uno::Reference< uno::XInterface > getXSpreadsheet() override; - virtual uno::Reference< uno::XInterface > init() override; + virtual uno::Reference<uno::XInterface> getXSpreadsheet() override; + virtual uno::Reference<uno::XInterface> init() override; CPPUNIT_TEST_SUITE(ScCellRangesObj); @@ -80,23 +80,25 @@ public: CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< lang::XComponent > mxComponent; + uno::Reference<lang::XComponent> mxComponent; }; -ScCellRangesObj::ScCellRangesObj(): - CalcUnoApiTest("/sc/qa/extras/testdocuments"), - apitest::XFormulaQuery(table::CellRangeAddress(0, 4, 1, 5, 4), table::CellRangeAddress(0, 4, 1, 5, 4)) +ScCellRangesObj::ScCellRangesObj() + : CalcUnoApiTest("/sc/qa/extras/testdocuments") + , apitest::XFormulaQuery(table::CellRangeAddress(0, 4, 1, 5, 4), + table::CellRangeAddress(0, 4, 1, 5, 4)) { } -uno::Reference< uno::XInterface > ScCellRangesObj::init() +uno::Reference<uno::XInterface> ScCellRangesObj::init() { - uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndexAccess(xDoc->getSheets(), uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference< lang::XMultiServiceFactory > xMSF(xDoc, uno::UNO_QUERY_THROW); - uno::Reference< container::XNameContainer > xRanges(xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<lang::XMultiServiceFactory> xMSF(xDoc, uno::UNO_QUERY_THROW); + uno::Reference<container::XNameContainer> xRanges( + xMSF->createInstance("com.sun.star.sheet.SheetCellRanges"), uno::UNO_QUERY_THROW); uno::Any xCellRange; xCellRange <<= xSheet->getCellRangeByName("C1:D4"); @@ -108,9 +110,9 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init() xCellRange <<= xSheet->getCellRangeByName("I7:J8"); xRanges->insertByName("Range4", xCellRange); - for ( int i = 0; i < 10; i++ ) + for (int i = 0; i < 10; i++) { - for ( int j = 5; j < 10; j++ ) + for (int j = 5; j < 10; j++) { xSheet->getCellByPosition(i, j)->setValue(i + j); } @@ -121,9 +123,9 @@ uno::Reference< uno::XInterface > ScCellRangesObj::init() uno::Reference<uno::XInterface> ScCellRangesObj::getXSpreadsheet() { - uno::Reference< sheet::XSpreadsheetDocument > xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xSheetDoc(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference<sheet::XSpreadsheets> xSheets (xSheetDoc->getSheets(), UNO_SET_THROW); + uno::Reference<sheet::XSpreadsheets> xSheets(xSheetDoc->getSheets(), UNO_SET_THROW); uno::Reference<container::XIndexAccess> xIndex(xSheets, UNO_QUERY_THROW); uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); @@ -146,7 +148,6 @@ void ScCellRangesObj::tearDown() } CPPUNIT_TEST_SUITE_REGISTRATION(ScCellRangesObj); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/extras/scmodelobj.cxx b/sc/qa/extras/scmodelobj.cxx index 48b050b1134b..8c4a67f963ab 100644 --- a/sc/qa/extras/scmodelobj.cxx +++ b/sc/qa/extras/scmodelobj.cxx @@ -28,8 +28,8 @@ using namespace css; using namespace css::uno; -namespace sc_apitest { - +namespace sc_apitest +{ class ScModelObj : public UnoApiTest, public apitest::SpreadsheetDocumentSettings, public apitest::XCalculatable, @@ -42,8 +42,8 @@ public: virtual void setUp() override; virtual void tearDown() override; - virtual uno::Reference< uno::XInterface > init() override; - virtual uno::Reference< uno::XInterface > getXMSF() override; + virtual uno::Reference<uno::XInterface> init() override; + virtual uno::Reference<uno::XInterface> getXMSF() override; virtual uno::Sequence<uno::Reference<table::XCell>> getXCells() override; ScModelObj(); @@ -74,16 +74,16 @@ public: CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< lang::XComponent > mxComponent; + uno::Reference<lang::XComponent> mxComponent; uno::Sequence<uno::Reference<table::XCell>> m_xCells; }; ScModelObj::ScModelObj() - : UnoApiTest("/sc/qa/extras/testdocuments") + : UnoApiTest("/sc/qa/extras/testdocuments") { } -uno::Reference< uno::XInterface > ScModelObj::init() +uno::Reference<uno::XInterface> ScModelObj::init() { uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW); @@ -104,15 +104,9 @@ uno::Reference< uno::XInterface > ScModelObj::init() return xModel; } -uno::Reference<uno::XInterface> ScModelObj::getXMSF() -{ - return getMultiServiceFactory(); -} +uno::Reference<uno::XInterface> ScModelObj::getXMSF() { return getMultiServiceFactory(); } -uno::Sequence<uno::Reference<table::XCell>> ScModelObj::getXCells() -{ - return m_xCells; -} +uno::Sequence<uno::Reference<table::XCell>> ScModelObj::getXCells() { return m_xCells; } void ScModelObj::setUp() { @@ -130,7 +124,6 @@ void ScModelObj::tearDown() } CPPUNIT_TEST_SUITE_REGISTRATION(ScModelObj); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/extras/scoutlineobj.cxx b/sc/qa/extras/scoutlineobj.cxx index fba63ff98a65..8133cdb25614 100644 --- a/sc/qa/extras/scoutlineobj.cxx +++ b/sc/qa/extras/scoutlineobj.cxx @@ -17,8 +17,8 @@ using namespace css; using namespace css::uno; -namespace sc_apitest { - +namespace sc_apitest +{ class ScOutlineObj : public CalcUnoApiTest, public apitest::XSheetOutline { public: @@ -27,7 +27,7 @@ public: virtual void setUp() override; virtual void tearDown() override; - virtual uno::Reference< uno::XInterface > init() override; + virtual uno::Reference<uno::XInterface> init() override; CPPUNIT_TEST_SUITE(ScOutlineObj); @@ -43,7 +43,7 @@ public: CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< lang::XComponent > mxComponent; + uno::Reference<lang::XComponent> mxComponent; }; ScOutlineObj::ScOutlineObj() @@ -51,13 +51,13 @@ ScOutlineObj::ScOutlineObj() { } -uno::Reference< uno::XInterface > ScOutlineObj::init() +uno::Reference<uno::XInterface> ScOutlineObj::init() { // get the first sheet - uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex (xDoc->getSheets(), UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex(0), UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), UNO_QUERY_THROW); return xSheet; } @@ -78,7 +78,6 @@ void ScOutlineObj::tearDown() } CPPUNIT_TEST_SUITE_REGISTRATION(ScOutlineObj); - } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/qa/extras/scsubtotalfieldobj.cxx b/sc/qa/extras/scsubtotalfieldobj.cxx index 2667f28a4098..991ee7bed436 100644 --- a/sc/qa/extras/scsubtotalfieldobj.cxx +++ b/sc/qa/extras/scsubtotalfieldobj.cxx @@ -28,14 +28,14 @@ using namespace css; using namespace css::uno; using namespace com::sun::star; -namespace sc_apitest { - +namespace sc_apitest +{ class ScSubTotalFieldObj : public CalcUnoApiTest, public apitest::XSubTotalField { public: ScSubTotalFieldObj(); - virtual uno::Reference< uno::XInterface > init() override; + virtual uno::Reference<uno::XInterface> init() override; virtual void setUp() override; virtual void tearDown() override; @@ -48,8 +48,7 @@ public: CPPUNIT_TEST_SUITE_END(); private: - uno::Reference< lang::XComponent > mxComponent; - + uno::Reference<lang::XComponent> mxComponent; }; ScSubTotalFieldObj::ScSubTotalFieldObj() @@ -57,24 +56,25 @@ ScSubTotalFieldObj::ScSubTotalFieldObj() { } -uno::Reference< uno::XInterface > ScSubTotalFieldObj::init() +uno::Reference<uno::XInterface> ScSubTotalFieldObj::init() { - uno::Reference< sheet::XSpreadsheetDocument > xDoc(mxComponent, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, uno::UNO_QUERY_THROW); - uno::Reference< container::XIndexAccess > xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndex(xDoc->getSheets(), uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSpreadsheet> xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSubTotalCalculatable > xSubTotalCalc(xSheet, uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSubTotalDescriptor > xSubTotalDesc = xSubTotalCalc->createSubTotalDescriptor(true); + uno::Reference<sheet::XSubTotalCalculatable> xSubTotalCalc(xSheet, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSubTotalDescriptor> xSubTotalDesc + = xSubTotalCalc->createSubTotalDescriptor(true); - uno::Sequence< sheet::SubTotalColumn > xCols; + uno::Sequence<sheet::SubTotalColumn> xCols; xCols.realloc(1); xCols[0].Column = 5; xCols[0].Function = sheet::GeneralFunction_SUM; xSubTotalDesc->addNew(xCols, 1); - uno::Reference< container::XIndexAccess > xDescIndex(xSubTotalDesc, uno::UNO_QUERY_THROW); - uno::Reference< sheet::XSubTotalField > xSTF(xDescIndex->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xDescIndex(xSubTotalDesc, uno::UNO_QUERY_THROW); + uno::Reference<sheet::XSubTotalField> xSTF(xDescIndex->getByIndex(0), uno::UNO_QUERY_THROW); return xSTF; } @@ -84,7 +84,6 @@ void ScSubTotalFieldObj::setUp() CalcUnoApiTest::setUp(); // create a calc document mxComponent = loadFromDesktop("private:factory/scalc"); - } void ScSubTotalFieldObj::tearDown() diff --git a/sc/qa/unit/dataproviders_test.cxx b/sc/qa/unit/dataproviders_test.cxx index a9b6b1142c7f..1f83c620c58d 100644 --- a/sc/qa/unit/dataproviders_test.cxx +++ b/sc/qa/unit/dataproviders_test.cxx @@ -22,7 +22,6 @@ class ScDataProvidersTest : public ScBootstrapFixture { public: - ScDataProvidersTest(); virtual void setUp() override; @@ -44,13 +43,14 @@ public: private: ScDocShellRef m_xDocShell; - ScDocument *m_pDoc; + ScDocument* m_pDoc; }; void ScDataProvidersTest::testCSVImport() { ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10); - bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); + bool bInserted + = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); CPPUNIT_ASSERT(bInserted); OUString aFileURL; @@ -58,7 +58,6 @@ void ScDataProvidersTest::testCSVImport() sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.csv", m_pDoc); aDataSource.setDBData(pDBData->GetName()); - m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource); auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources(); CPPUNIT_ASSERT(!rDataSources.empty()); @@ -78,7 +77,8 @@ void ScDataProvidersTest::testCSVImport() void ScDataProvidersTest::testDataLargerThanDB() { ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 1, 1); - bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); + bool bInserted + = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); CPPUNIT_ASSERT(bInserted); OUString aFileURL; @@ -86,7 +86,6 @@ void ScDataProvidersTest::testDataLargerThanDB() sc::ExternalDataSource aDataSource(aFileURL, "org.libreoffice.calc.csv", m_pDoc); aDataSource.setDBData(pDBData->GetName()); - m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource); auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources(); CPPUNIT_ASSERT(!rDataSources.empty()); @@ -106,7 +105,8 @@ void ScDataProvidersTest::testDataLargerThanDB() void ScDataProvidersTest::testHTMLImport() { ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10); - bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); + bool bInserted + = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); CPPUNIT_ASSERT(bInserted); OUString aFileURL; @@ -115,7 +115,6 @@ void ScDataProvidersTest::testHTMLImport() aDataSource.setID("//table"); aDataSource.setDBData(pDBData->GetName()); - m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource); auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources(); CPPUNIT_ASSERT(!rDataSources.empty()); @@ -123,11 +122,12 @@ void ScDataProvidersTest::testHTMLImport() rDataSources[0].refresh(m_pDoc, true); Scheduler::ProcessEventsToIdle(); - - std::vector<OUString> aCarManufacturers = {"Audi", "GM", "Nissan", "Ferrari", "Peugeot"}; - std::vector<OUString> aCities = {"Berlin", "San Francisco", "Tokyo", "Rome", "Paris"}; - std::vector<double> aFirstCol = {1, 10, -100, -0.11111, 1}; - std::vector<double> aSecondCol = {2, 2.1, 40179, 2, 2,}; // 40179 is equal to 2010-1-1 + std::vector<OUString> aCarManufacturers = { "Audi", "GM", "Nissan", "Ferrari", "Peugeot" }; + std::vector<OUString> aCities = { "Berlin", "San Francisco", "Tokyo", "Rome", "Paris" }; + std::vector<double> aFirstCol = { 1, 10, -100, -0.11111, 1 }; + std::vector<double> aSecondCol = { + 2, 2.1, 40179, 2, 2, + }; // 40179 is equal to 2010-1-1 CPPUNIT_ASSERT_EQUAL(OUString("Col1"), m_pDoc->GetString(0, 0, 0)); CPPUNIT_ASSERT_EQUAL(OUString("Col2"), m_pDoc->GetString(1, 0, 0)); @@ -146,14 +146,15 @@ void ScDataProvidersTest::testHTMLImport() void ScDataProvidersTest::testXMLImport() { ScDBData* pDBData = new ScDBData("testDB", 0, 0, 0, 10, 10); - bool bInserted = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); + bool bInserted + = m_pDoc->GetDBCollection()->getNamedDBs().insert(std::unique_ptr<ScDBData>(pDBData)); CPPUNIT_ASSERT(bInserted); OUString aFileURL; ScOrcusImportXMLParam aParam; ScOrcusImportXMLParam::RangeLink aRangeLink; - aRangeLink.maPos = ScAddress(0,0,0); + aRangeLink.maPos = ScAddress(0, 0, 0); aRangeLink.maFieldPaths.push_back("/bookstore/book/title"); aRangeLink.maFieldPaths.push_back("/bookstore/book/author"); aRangeLink.maRowGroups.push_back("/bookstore/book"); @@ -164,7 +165,6 @@ void ScDataProvidersTest::testXMLImport() aDataSource.setDBData("testDB"); aDataSource.setXMLImportParam(aParam); - m_pDoc->GetExternalDataMapper().insertDataSource(aDataSource); auto& rDataSources = m_pDoc->GetExternalDataMapper().getDataSources(); CPPUNIT_ASSERT(!rDataSources.empty()); @@ -208,9 +208,9 @@ void ScDataProvidersTest::testBaseImport() } */ -ScDataProvidersTest::ScDataProvidersTest() : - ScBootstrapFixture( "sc/qa/unit/data/dataprovider" ), - m_pDoc(nullptr) +ScDataProvidersTest::ScDataProvidersTest() + : ScBootstrapFixture("sc/qa/unit/data/dataprovider") + , m_pDoc(nullptr) { } @@ -219,10 +219,9 @@ void ScDataProvidersTest::setUp() ScBootstrapFixture::setUp(); ScDLL::Init(); - m_xDocShell = new ScDocShell( - SfxModelFlags::EMBEDDED_OBJECT | - SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS | - SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); + m_xDocShell + = new ScDocShell(SfxModelFlags::EMBEDDED_OBJECT | SfxModelFlags::DISABLE_EMBEDDED_SCRIPTS + | SfxModelFlags::DISABLE_DOCUMENT_RECOVERY); m_xDocShell->SetIsInUcalc(); m_xDocShell->DoInitUnitTest(); diff --git a/sc/qa/unit/test_ScChartListenerCollection.cxx b/sc/qa/unit/test_ScChartListenerCollection.cxx index ba2e93c7223c..67f2f045c7bf 100644 --- a/sc/qa/unit/test_ScChartListenerCollection.cxx +++ b/sc/qa/unit/test_ScChartListenerCollection.cxx @@ -13,16 +13,15 @@ #include <chartlis.hxx> #include <scdll.hxx> -namespace { - +namespace +{ const ScRange RANGE_1(10, 10, 0, 19, 10, 0); const ScRange RANGE_2(20, 10, 0, 29, 10, 0); const ScRange RANGE_INTERSECTING_1_AND_2(10, 10, 0, 29, 10, 0); - -class ChartListenerCollectionTest : public test::BootstrapFixture { - +class ChartListenerCollectionTest : public test::BootstrapFixture +{ public: virtual void setUp() override { @@ -47,21 +46,21 @@ private: CPPUNIT_TEST(ListenersStopListeningIndependently); CPPUNIT_TEST_SUITE_END(); - }; -struct MockedHiddenRangeListener : public ScChartHiddenRangeListener { +struct MockedHiddenRangeListener : public ScChartHiddenRangeListener +{ unsigned mNotifyCount; MockedHiddenRangeListener() - : mNotifyCount(0) { + : mNotifyCount(0) + { } - void notify() override { - mNotifyCount++; - } + void notify() override { mNotifyCount++; } }; -void ChartListenerCollectionTest::ListenerGetsNotifiedWhenItsRangeIsSetDirty() { +void ChartListenerCollectionTest::ListenerGetsNotifiedWhenItsRangeIsSetDirty() +{ MockedHiddenRangeListener listener; ScDocument aDoc; ScChartListenerCollection sut(aDoc); @@ -72,7 +71,8 @@ void ChartListenerCollectionTest::ListenerGetsNotifiedWhenItsRangeIsSetDirty() { CPPUNIT_ASSERT_EQUAL(1u, listener.mNotifyCount); } -void ChartListenerCollectionTest::ListenerGetsNotifiedTwiceWhenRegisteredTwoTimes() { +void ChartListenerCollectionTest::ListenerGetsNotifiedTwiceWhenRegisteredTwoTimes() +{ MockedHiddenRangeListener listener; ScDocument aDoc; ScChartListenerCollection sut(aDoc); @@ -84,7 +84,8 @@ void ChartListenerCollectionTest::ListenerGetsNotifiedTwiceWhenRegisteredTwoTime CPPUNIT_ASSERT_EQUAL(2u, listener.mNotifyCount); } -void ChartListenerCollectionTest::ListenerDoesNotGetNotifiedWhenListeningStops() { +void ChartListenerCollectionTest::ListenerDoesNotGetNotifiedWhenListeningStops() +{ MockedHiddenRangeListener listener; ScDocument aDoc; ScChartListenerCollection sut(aDoc); @@ -94,10 +95,10 @@ void ChartListenerCollectionTest::ListenerDoesNotGetNotifiedWhenListeningStops() sut.SetRangeDirty(RANGE_INTERSECTING_1_AND_2); CPPUNIT_ASSERT_EQUAL(0u, listener.mNotifyCount); - } -void ChartListenerCollectionTest::ListenerStopsListeningForAllRanges() { +void ChartListenerCollectionTest::ListenerStopsListeningForAllRanges() +{ MockedHiddenRangeListener listener; ScDocument aDoc; ScChartListenerCollection sut(aDoc); @@ -110,7 +111,8 @@ void ChartListenerCollectionTest::ListenerStopsListeningForAllRanges() { CPPUNIT_ASSERT_EQUAL(0u, listener.mNotifyCount); } -void ChartListenerCollectionTest::ListenersStopListeningIndependently() { +void ChartListenerCollectionTest::ListenersStopListeningIndependently() +{ MockedHiddenRangeListener listener1; MockedHiddenRangeListener listener2; ScDocument aDoc; @@ -125,12 +127,10 @@ void ChartListenerCollectionTest::ListenersStopListeningIndependently() { CPPUNIT_ASSERT_EQUAL(0u, listener1.mNotifyCount); CPPUNIT_ASSERT_EQUAL(1u, listener2.mNotifyCount); } - } CPPUNIT_TEST_SUITE_REGISTRATION(ChartListenerCollectionTest); - CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |