diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-11 11:06:57 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-03-25 07:19:13 +0100 |
commit | b1cfdb7bee4f7af97af54e6abbc5d04aed4ba082 (patch) | |
tree | 8211ea564e36152b9eeb7be7212342d9e82800c6 /sw/qa | |
parent | 26b81b23f0ad061b6d44fcea3e07ae4b18a63f94 (diff) |
new loplugin:unoquery
look for places we are doing code like:
Reference<XProperty>(model, css::uno::UNO_QUERY)->getAsProperty()
which might result in a SIGSEGV is the query fails
Change-Id: I5cbdbc9e64bd0bed588297c512bf60cbacb9442e
Reviewed-on: https://gerrit.libreoffice.org/69044
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/core/macros-test.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport.cxx | 8 | ||||
-rw-r--r-- | sw/qa/extras/odfimport/odfimport.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 12 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport6.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport2.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 12 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport2.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport5.cxx | 11 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 9 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 2 |
18 files changed, 48 insertions, 44 deletions
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 187a82e93f77..db544178b194 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -376,7 +376,7 @@ void SwMacrosTest::testFdo55289() uno::Reference<drawing::XShapes> const xShapes(xDPS->getDrawPage(), UNO_QUERY); uno::Reference<beans::XPropertySet> const xShape( - uno::Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY)-> + uno::Reference<lang::XMultiServiceFactory>(xModel, UNO_QUERY_THROW)-> createInstance("com.sun.star.drawing.GraphicObjectShape"), UNO_QUERY); xShape->setPropertyValue("AnchorType", @@ -391,7 +391,7 @@ void SwMacrosTest::testFdo55289() xShape->setPropertyValue("AnchorType", makeAny(text::TextContentAnchorType_AS_CHARACTER)); uno::Reference<text::XTextRange> const xEnd = - uno::Reference<text::XTextDocument>(xModel, UNO_QUERY)->getText()->getEnd(); + uno::Reference<text::XTextDocument>(xModel, UNO_QUERY_THROW)->getText()->getEnd(); uno::Reference<text::XTextContent> const xShapeContent(xShape, UNO_QUERY); xShapeContent->attach(xEnd); } diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index ea0eaac86c61..79a67296fe13 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -134,7 +134,7 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone const uno::Sequence<beans::PropertyValue>& rPropertyValues) { uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController(); + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); CPPUNIT_ASSERT(xController.is()); uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); CPPUNIT_ASSERT(xFrame.is()); diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 8ac8f1c81edd..5579c802833b 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -629,7 +629,7 @@ DECLARE_ODFEXPORT_TEST(testDuplicateCrossRefHeadingBookmark, "CrossRefHeadingBoo CPPUNIT_ASSERT_THROW(xBookmarks->getByName("__RefHeading__1673_25705824"), container::NoSuchElementException); uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh(); uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); @@ -1058,7 +1058,7 @@ DECLARE_ODFEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.odt") CPPUNIT_ASSERT_EQUAL(OUString("round-rectangle"), aCustomShapeGeometry["Type"].get<OUString>()); // The shape text should start with a table, with "a" in its A1 cell. - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY); uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString()); @@ -1975,7 +1975,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt") "Az (5)", "az 1", "A 2", "az 1" }; uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); // update "A (4)" to "Az (5)" - uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh(); uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); @@ -2045,7 +2045,7 @@ DECLARE_ODFEXPORT_TEST(testSpellOutNumberingTypes, "spellout-numberingtypes.odt" static const char* const aFieldTextFallbacks[] = { "Ordinal-number 1", "Ordinal 1", "1" }; uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); // update text field content - uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh(); uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index 0eaae316a22c..3065d64c4935 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -56,7 +56,7 @@ DECLARE_ODFIMPORT_TEST(testHideAllSections, "fdo53210.odt") uno::Reference<beans::XPropertySet> xMaster(xMasters->getByName("com.sun.star.text.fieldmaster.User._CS_Allgemein"), uno::UNO_QUERY); xMaster->setPropertyValue("Content", uno::makeAny(OUString("0"))); // This used to crash - uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh(); } DECLARE_ODFIMPORT_TEST(testOdtBorders, "borders_ooo33.odt") @@ -482,7 +482,7 @@ DECLARE_ODFIMPORT_TEST(testFdo55814, "fdo55814.odt") uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY); xField->setPropertyValue("Content", uno::makeAny(OUString("Yes"))); - uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh(); + uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY_THROW)->refresh(); uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); // This was "0". diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx index 991ab0616cec..768ab16c8a48 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx @@ -212,7 +212,7 @@ DECLARE_OOXMLEXPORT_TEST(textboxWpgOnly, "textbox-wpg-only.docx") // Character escapement was enabled by default, this was 58. uno::Reference<container::XIndexAccess> xGroup(xShape, uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText(); CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraphOfText(1, xText), 1), "CharEscapementHeight")); } @@ -220,7 +220,7 @@ DECLARE_OOXMLEXPORT_TEST(testMceWpg, "mce-wpg.docx") { // Make sure that we read the primary branch, if wpg is requested as a feature. uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText(); // This was VML1. getParagraphOfText(1, xText, "DML1"); } @@ -240,7 +240,7 @@ DECLARE_OOXMLEXPORT_TEST(testMceNested, "mce-nested.docx") // Now check the top right textbox. uno::Reference<container::XIndexAccess> xGroup(getShape(2), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "[Year]"); CPPUNIT_ASSERT_EQUAL(48.f, getProperty<float>(getRun(xParagraph, 1), "CharHeight")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor")); @@ -372,7 +372,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupshapeSdt, "dml-groupshape-sdt.docx") { uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY); // The text in the groupshape was missing due to the w:sdt and w:sdtContent wrapper around it. - CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("sdt and sdtContent inside groupshape"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW)->getString()); } DECLARE_OOXMLEXPORT_TEST(testDmlCharheightDefault, "dml-charheight-default.docx") @@ -387,7 +387,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capita { // Capitalization inside a group shape was not imported uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); // 2nd line is written with uppercase letters CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "CharCaseMap")); // 3rd line has no capitalization @@ -450,7 +450,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.doc { // Fonts defined by w:rFonts was not imported and so the font specified by a:fontRef was used. uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1); CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(xRun, "CharFontName")); CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex")); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx index 4d62de086506..a00179292cc5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -950,7 +950,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo60990, "fdo60990.odt") // The shape had no background, no paragraph adjust and no font color. uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty<sal_Int32>(xShape, "FillColor")); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText); CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor")); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx index 08d239ed3567..30c6b849ce6e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx @@ -378,7 +378,7 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing, "dml-groupshape-paraspaci { // Paragraph spacing (top/bottom margin and line spacing) inside a group shape was not imported uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); // 1st paragraph has 1.5x line spacing but it has no spacing before/after. uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 4dc0203fd7bc..82139b936f16 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -70,7 +70,7 @@ DECLARE_OOXMLEXPORT_TEST(testGroupshapeThemeFont, "groupshape-theme-font.docx") { // Font was specified using a theme reference, which wasn't handled. uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(0), uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1); // This was Calibri. CPPUNIT_ASSERT_EQUAL(OUString("Cambria"), getProperty<OUString>(xRun, "CharFontName")); @@ -874,7 +874,7 @@ DECLARE_OOXMLEXPORT_TEST(testTextboxRoundedCorners, "textbox-rounded-corners.doc CPPUNIT_ASSERT_EQUAL(OUString("ooxml-roundRect"), aCustomShapeGeometry["Type"].get<OUString>()); // The shape text should start with a table, with "a" in its A1 cell. - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1, xText), uno::UNO_QUERY); uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(OUString("a"), xCell->getString()); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index b0bd7bf349c5..9ab8a3f11731 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -1038,16 +1038,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo46361, "fdo46361.docx") uno::Reference<drawing::XShape> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); // This was CENTER. CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust_TOP, getProperty<drawing::TextVerticalAdjust>(xShape, "TextVerticalAdjust")); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText); // This was LEFT. CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); // This was black, not green. CPPUNIT_ASSERT_EQUAL(sal_Int32(0x008000), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor")); // \n char was missing due to unhandled w:br. - CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("text\ntext"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(1), uno::UNO_QUERY_THROW)->getString()); // \n chars were missing, due to unhandled multiple w:p tags. - CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("text\ntext\n"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(2), uno::UNO_QUERY_THROW)->getString()); } DECLARE_OOXMLEXPORT_TEST(testFdo65632, "fdo65632.docx") diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 095d938fc37f..eca2260e8f96 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -823,7 +823,7 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust { // Paragraph adjustment inside a group shape was not imported uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); // 2nd line is adjusted to the right CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "ParaAdjust")); // 3rd line has no adjustment diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx index 3ea6916e2839..213148db627e 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx @@ -90,7 +90,7 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, "groupshape-fontname.docx") // Font names inside a group shape were not imported uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); uno::Reference<text::XText> xText - = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY_THROW)->getText(); CPPUNIT_ASSERT_EQUAL( OUString("Calibri"), diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 6fa603c60b8c..359144d5169e 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -642,12 +642,12 @@ DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf") uno::Reference<text::XText> xText = xTextRange->getText(); CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString()); uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( - OUString("A"), - uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString()); - CPPUNIT_ASSERT_EQUAL( - OUString("B"), - uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>( + xTable->getCellByName("A1"), uno::UNO_QUERY_THROW) + ->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>( + xTable->getCellByName("B1"), uno::UNO_QUERY_THROW) + ->getString()); CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString()); } diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index a65ca6cc98aa..e363be008429 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -150,9 +150,11 @@ DECLARE_RTFEXPORT_TEST(testFdo45187, "fdo45187.rtf") uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xTextDocument->getText(), uno::UNO_QUERY); uno::Reference<text::XTextRange> xAnchor0 - = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY)->getAnchor(); + = uno::Reference<text::XTextContent>(xDraws->getByIndex(0), uno::UNO_QUERY_THROW) + ->getAnchor(); uno::Reference<text::XTextRange> xAnchor1 - = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY)->getAnchor(); + = uno::Reference<text::XTextContent>(xDraws->getByIndex(1), uno::UNO_QUERY_THROW) + ->getAnchor(); // Was 0 ("starts at the same position"), should be 1 ("starts before") CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xTextRangeCompare->compareRegionStarts(xAnchor0, xAnchor1)); } diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index d4e9a68b7f14..a60eb485ccdf 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -206,9 +206,9 @@ DECLARE_RTFEXPORT_TEST(testFdo66040, "fdo66040.rtf") uno::Reference<text::XTextRange> xTextRange(xDraws->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XText> xText = xTextRange->getText(); uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( - OUString("A"), - uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>( + xTable->getCellByName("A1"), uno::UNO_QUERY_THROW) + ->getString()); // Make sure the second shape has the correct position and size. uno::Reference<drawing::XShape> xShape(xDraws->getByIndex(1), uno::UNO_QUERY); @@ -401,8 +401,9 @@ DECLARE_RTFEXPORT_TEST(testFooterPara, "footer-para.rtf") uno::Reference<text::XText> xFooterText = getProperty<uno::Reference<text::XText>>( getStyles("PageStyles")->getByName("First Page"), "FooterText"); uno::Reference<text::XTextContent> xParagraph = getParagraphOrTable(1, xFooterText); - CPPUNIT_ASSERT_EQUAL(OUString("All Rights Reserved."), - uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL( + OUString("All Rights Reserved."), + uno::Reference<text::XTextRange>(xParagraph, uno::UNO_QUERY_THROW)->getString()); CPPUNIT_ASSERT_EQUAL( sal_Int16(style::ParagraphAdjust_CENTER), getProperty</*style::ParagraphAdjust*/ sal_Int16>(xParagraph, "ParaAdjust")); diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 17c59501c34b..1adfef5f48b4 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -767,7 +767,7 @@ DECLARE_RTFIMPORT_TEST(testFdo68291, "fdo68291.odt") // This was "Standard", causing an unwanted page break on next paste. CPPUNIT_ASSERT_EQUAL(uno::Any(), - uno::Reference<beans::XPropertySet>(getParagraph(1), uno::UNO_QUERY) + uno::Reference<beans::XPropertySet>(getParagraph(1), uno::UNO_QUERY_THROW) ->getPropertyValue("PageDescName")); } @@ -811,7 +811,7 @@ DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf") CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty<style::BreakType>(xParaSecond, "BreakType")); CPPUNIT_ASSERT_EQUAL(uno::Any(), - uno::Reference<beans::XPropertySet>(xParaSecond, uno::UNO_QUERY) + uno::Reference<beans::XPropertySet>(xParaSecond, uno::UNO_QUERY_THROW) ->getPropertyValue("PageDescName")); // actually not sure how many paragraph there should be between // SECOND and THIRD - important is that the page break is on there @@ -823,8 +823,9 @@ DECLARE_RTFIMPORT_TEST(testContSectionPageBreak, "cont-section-pagebreak.rtf") CPPUNIT_ASSERT_EQUAL(OUString("THIRD"), xParaThird->getString()); CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty<style::BreakType>(xParaThird, "BreakType")); - CPPUNIT_ASSERT_EQUAL(uno::Any(), uno::Reference<beans::XPropertySet>(xParaThird, uno::UNO_QUERY) - ->getPropertyValue("PageDescName")); + CPPUNIT_ASSERT_EQUAL(uno::Any(), + uno::Reference<beans::XPropertySet>(xParaThird, uno::UNO_QUERY_THROW) + ->getPropertyValue("PageDescName")); CPPUNIT_ASSERT_EQUAL(2, getPages()); } diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c6c3dc1123c8..ea1091a93907 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -3978,7 +3978,7 @@ void SwUiWriterTest::testShapeAnchorUndo() static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xComponent, const OUString& rCommand, const uno::Sequence<beans::PropertyValue>& rPropertyValues) { - uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController(); + uno::Reference<frame::XController> xController = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); CPPUNIT_ASSERT(xController.is()); uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); CPPUNIT_ASSERT(xFrame.is()); diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 28217c7a3281..ed5cdb8bb9e9 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -126,7 +126,7 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone const uno::Sequence<beans::PropertyValue>& rPropertyValues) { uno::Reference<frame::XController> xController - = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY)->getCurrentController(); + = uno::Reference<frame::XModel>(xComponent, uno::UNO_QUERY_THROW)->getCurrentController(); CPPUNIT_ASSERT(xController.is()); uno::Reference<frame::XDispatchProvider> xFrame(xController->getFrame(), uno::UNO_QUERY); CPPUNIT_ASSERT(xFrame.is()); diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 0a22a05fa3ea..fbc504cb5d97 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -516,7 +516,7 @@ DECLARE_WW8EXPORT_TEST(testTdf95321, "tdf95321.doc") uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); uno::Reference<text::XTextTable> xTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Second Column"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY_THROW)->getString()); } DECLARE_WW8EXPORT_TEST(testFdo77844, "fdo77844.doc") |