diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-27 11:12:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-27 13:06:59 +0200 |
commit | e5ece062058f7772f8414d47d07bb8af6e8e5c2a (patch) | |
tree | 97ab9340c5e29f5445279a9585b4abe42396b14d /sw/qa | |
parent | 2d5090419e0113f5b411ee84bfc55926a19da411 (diff) |
loplugin:oncevar in sw
Change-Id: Ia96172489eec09607113d388a5b683bb6e0d2dec
Reviewed-on: https://gerrit.libreoffice.org/39290
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/core/macros-test.cxx | 3 | ||||
-rw-r--r-- | sw/qa/core/test_ToxTextGenerator.cxx | 10 | ||||
-rw-r--r-- | sw/qa/core/test_ToxWhitespaceStripper.cxx | 38 | ||||
-rw-r--r-- | sw/qa/core/uwriter.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 6 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport8.cxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/rtfimport/rtfimport.cxx | 4 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 3 |
10 files changed, 35 insertions, 41 deletions
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index b356a5f237fc..cc75587a04dd 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -159,11 +159,10 @@ void SwMacrosTest::testVba() OUString("vnd.sun.Star.script:Project.NewMacros.Macro1?language=Basic&location=document") } }; - OUString aFileExtension( "doc" ); for ( sal_uInt32 i=0; i<SAL_N_ELEMENTS( testInfo ); ++i ) { OUString aFileName; - createFileURL(testInfo[i].sFileBaseName, aFileExtension, aFileName); + createFileURL(testInfo[i].sFileBaseName, "doc", aFileName); uno::Reference< css::lang::XComponent > xComponent = loadFromDesktop(aFileName, "com.sun.star.text.TextDocument"); OUStringBuffer sMsg( "Failed to load " ); sMsg.append ( aFileName ); diff --git a/sw/qa/core/test_ToxTextGenerator.cxx b/sw/qa/core/test_ToxTextGenerator.cxx index 2a41c9844201..a9b280f59994 100644 --- a/sw/qa/core/test_ToxTextGenerator.cxx +++ b/sw/qa/core/test_ToxTextGenerator.cxx @@ -61,7 +61,7 @@ struct MockedSortTab : public SwTOXSortTabBase { void ToxTextGeneratorTest::EmptyStringIsReturnedForPageNumberPlaceholderOfZeroItems() { - OUString expected(""); + OUString const expected(""); OUString actual = ToxTextGenerator::ConstructPageNumberPlaceholder(0); CPPUNIT_ASSERT_EQUAL(expected, actual); } @@ -69,7 +69,7 @@ ToxTextGeneratorTest::EmptyStringIsReturnedForPageNumberPlaceholderOfZeroItems() void ToxTextGeneratorTest::OneAtSignIsReturnedForPageNumberPlaceholderOfOneItem() { - OUString expected("@~"); + OUString const expected("@~"); OUString actual = ToxTextGenerator::ConstructPageNumberPlaceholder(1); CPPUNIT_ASSERT_EQUAL(expected, actual); } @@ -77,7 +77,7 @@ ToxTextGeneratorTest::OneAtSignIsReturnedForPageNumberPlaceholderOfOneItem() void ToxTextGeneratorTest::TwoAtSignsAreReturnedForPageNumberPlaceholderOfOneItem() { - OUString expected("@, @~"); + OUString const expected("@, @~"); OUString actual = ToxTextGenerator::ConstructPageNumberPlaceholder(2); CPPUNIT_ASSERT_EQUAL(expected, actual); } @@ -88,7 +88,7 @@ ToxTextGeneratorTest::EmptyStringIsReturnedAsNumStringIfNoTextMarkIsSet() MockedSortTab sortTab; sortTab.pTextMark = nullptr; - OUString expected(""); + OUString const expected(""); OUString actual = ToxTextGenerator::GetNumStringOfFirstNode(sortTab, false, 0); CPPUNIT_ASSERT_EQUAL(expected, actual); } @@ -99,7 +99,7 @@ ToxTextGeneratorTest::EmptyStringIsReturnedAsNumStringIfToxSourcesIsEmpty() MockedSortTab sortTab; sortTab.pTextMark = reinterpret_cast<SwTextTOXMark*>(1); - OUString expected(""); + OUString const expected(""); OUString actual = ToxTextGenerator::GetNumStringOfFirstNode(sortTab, false, 0); CPPUNIT_ASSERT_EQUAL(expected, actual); } diff --git a/sw/qa/core/test_ToxWhitespaceStripper.cxx b/sw/qa/core/test_ToxWhitespaceStripper.cxx index 53819333579e..dc3b23b828aa 100644 --- a/sw/qa/core/test_ToxWhitespaceStripper.cxx +++ b/sw/qa/core/test_ToxWhitespaceStripper.cxx @@ -49,7 +49,7 @@ void ToxWhitespaceStripperTest::MappingCharactersToVariousStrippedStringsWorks() { { - OUString test("abc\n"); + OUString const test("abc\n"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), sut.GetPositionInStrippedString(0)); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), sut.GetPositionInStrippedString(1)); @@ -57,7 +57,7 @@ ToxWhitespaceStripperTest::MappingCharactersToVariousStrippedStringsWorks() CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), sut.GetPositionInStrippedString(3)); } { - OUString test("abc\n\n"); + OUString const test("abc\n\n"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), sut.GetPositionInStrippedString(0)); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), sut.GetPositionInStrippedString(1)); @@ -66,7 +66,7 @@ ToxWhitespaceStripperTest::MappingCharactersToVariousStrippedStringsWorks() CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), sut.GetPositionInStrippedString(4)); } { - OUString test("abc\ndef"); + OUString const test("abc\ndef"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), sut.GetPositionInStrippedString(0)); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), sut.GetPositionInStrippedString(1)); @@ -78,7 +78,7 @@ ToxWhitespaceStripperTest::MappingCharactersToVariousStrippedStringsWorks() } { // 012345 6789 - OUString test(" abc \ndef"); + OUString const test(" abc \ndef"); // 01234567 // " abc def" ToxWhitespaceStripper sut(test); @@ -99,38 +99,38 @@ void ToxWhitespaceStripperTest::StrippingWhitespacesFromVariousStringsWorks() { { - OUString test("abc\n"); - OUString expected("abc"); + OUString const test("abc\n"); + OUString const expected("abc"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } { - OUString test("abc\n\n"); - OUString expected("abc"); + OUString const test("abc\n\n"); + OUString const expected("abc"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } { - OUString test("abc\ndef"); - OUString expected("abc def"); + OUString const test("abc\ndef"); + OUString const expected("abc def"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } { - OUString test(" abc \ndef"); - OUString expected(" abc def"); + OUString const test(" abc \ndef"); + OUString const expected(" abc def"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } { - OUString test(" "); - OUString expected(""); + OUString const test(" "); + OUString const expected(""); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } { - OUString test("d "); - OUString expected("d"); + OUString const test("d "); + OUString const expected("d"); ToxWhitespaceStripper sut(test); CPPUNIT_ASSERT_EQUAL(expected, sut.GetStrippedString()); } @@ -139,7 +139,7 @@ ToxWhitespaceStripperTest::StrippingWhitespacesFromVariousStringsWorks() void ToxWhitespaceStripperTest::PositionAfterStringCanBeRequested() { - OUString test("abc"); + OUString const test("abc"); ToxWhitespaceStripper sut(test); sal_Int32 expected = test.getLength(); CPPUNIT_ASSERT_EQUAL(expected, sut.GetPositionInStrippedString(test.getLength())); @@ -148,9 +148,9 @@ ToxWhitespaceStripperTest::PositionAfterStringCanBeRequested() void ToxWhitespaceStripperTest::InvalidPositionIsMappedToLastEntry() { - OUString test("ab c"); + OUString const test("ab c"); ToxWhitespaceStripper sut(test); - sal_Int32 expected = 4; // the length of the string after merging the two whitespaces + sal_Int32 const expected = 4; // the length of the string after merging the two whitespaces sal_Int32 result = sut.GetPositionInStrippedString(40); // a value past the original string length CPPUNIT_ASSERT_EQUAL(expected, result); } diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 4148d93c40f2..b6bb8526b6b0 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -1559,13 +1559,11 @@ void SwDocTest::testClientModify() CPPUNIT_ASSERT_EQUAL(aClient1.GetRegisteredIn(), static_cast<SwModify*>(nullptr)); CPPUNIT_ASSERT_EQUAL(aClient2.GetRegisteredIn(), static_cast<SwModify*>(nullptr)); { - int nCount = 0; SwIterator<TestClient,SwModify> aIter(aMod); for(TestClient* pClient = aIter.First(); pClient ; pClient = aIter.Next()) { CPPUNIT_ASSERT(false); } - CPPUNIT_ASSERT_EQUAL(nCount,0); } aMod.ModifyBroadcast(nullptr, nullptr); CPPUNIT_ASSERT_EQUAL(aClient1.m_nModifyCount,2); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 9a43087df0c8..3a84b313b15c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -593,7 +593,7 @@ DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); //check that images are also saved - OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name + OUString const sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY); CPPUNIT_ASSERT( xInputStream.is() ); } @@ -620,12 +620,12 @@ DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx") comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); //check that images are also saved - OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name + OUString const sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name uno::Reference<io::XInputStream> xInputStream1(xNameAccess->getByName( sImageFile1 ), uno::UNO_QUERY); CPPUNIT_ASSERT( xInputStream1.is() ); //check that images are saved for other smart-arts as well. - OUString sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name + OUString const sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name uno::Reference<io::XInputStream> xInputStream2(xNameAccess->getByName( sImageFile2 ), uno::UNO_QUERY); CPPUNIT_ASSERT( xInputStream2.is() ); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 67179b5c14a0..c4c4f035a784 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -691,8 +691,6 @@ DECLARE_OOXMLEXPORT_TEST(testAbsolutePositionOffsetValue,"fdo78432.docx") if (!pXmlDoc) return; - sal_Int32 IntMax = SAL_MAX_INT32; - xmlXPathObjectPtr pXmlObjs[6]; pXmlObjs[0] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionH[1]/wp:posOffset[1]"); pXmlObjs[1] = getXPathNode(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/wp:positionV[1]/wp:posOffset[1]"); @@ -708,7 +706,7 @@ DECLARE_OOXMLEXPORT_TEST(testAbsolutePositionOffsetValue,"fdo78432.docx") CPPUNIT_ASSERT(pXmlObjs[index]->nodesetval != nullptr); xmlNodePtr pXmlNode = pXmlObjs[index]->nodesetval->nodeTab[0]; OUString contents = OUString::createFromAscii(reinterpret_cast<const char*>((pXmlNode->children[0]).content)); - CPPUNIT_ASSERT( contents.toInt64() <= IntMax ); + CPPUNIT_ASSERT( contents.toInt64() <= SAL_MAX_INT32 ); xmlXPathFreeObject(pXmlObjs[index]); } } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx index ac7ba7838132..808ac9679b14 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx @@ -745,7 +745,7 @@ DECLARE_OOXMLEXPORT_TEST(testN793998, "n793998.docx") sal_Int32 nTextPortion = parseDump("/root/page/body/txt/Text[1]", "nWidth").toInt32(); // Width of the first (text) portion sal_Int32 nTabPortion = parseDump("/root/page/body/txt/Text[2]", "nWidth").toInt32(); // Width of the second (tab) portion sal_Int32 nParagraph = parseDump("/root/page/body/txt/infos/bounds", "width").toInt32(); // Width of the paragraph - sal_Int32 nRightMargin = 3000; + sal_Int32 const nRightMargin = 3000; // The problem was that the tab portion didn't ignore the right margin, so text + tab width wasn't larger than body (paragraph - right margin) width. CPPUNIT_ASSERT(nTextPortion + nTabPortion > nParagraph - nRightMargin); } diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 0ab46d27f0ee..abba8f9bfe39 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -244,14 +244,14 @@ DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf") DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf") { OUString aActual = getFormula(getRun(getParagraph(1), 1)); - OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]"); + OUString const aExpected("left [matrix {1 # 2 ## 3 # 4} right ]"); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf") { OUString aActual = getFormula(getRun(getParagraph(1), 1)); - OUString aExpected("a"); + OUString const aExpected("a"); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index fe52bed1cf87..05df875832d5 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -1643,7 +1643,7 @@ DECLARE_RTFIMPORT_TEST(testCp1000018, "cp1000018.rtf") uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY); uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY); - OUString aExpected("Footnote first line.\n"); + OUString const aExpected("Footnote first line.\n"); CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); } @@ -2055,7 +2055,7 @@ DECLARE_RTFIMPORT_TEST(testFdo82114, "fdo82114.rtf") { uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName("Converted1"), "HeaderText"); OUString aActual = xHeaderText->getString(); - OUString aExpected("First page header, section 2"); + OUString const aExpected("First page header, section 2"); // This was 'Right page header, section 1'. CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d574ad0efaf6..f743fd5a80b9 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -3764,9 +3764,8 @@ void SwUiWriterTest::testTdf87922() // Get access to the single paragraph in the document. SwNodeIndex aNodeIndex(pDoc->GetNodes().GetEndOfContent(), -1); const OUString& rText = aNodeIndex.GetNode().GetTextNode()->GetText(); - sal_Int32 nIndex = 0; sal_Int32 nLength = rText.getLength(); - SwDrawTextInfo aDrawTextInfo(pWrtShell, *pWrtShell->GetOut(), pScriptInfo, rText, nIndex, nLength); + SwDrawTextInfo aDrawTextInfo(pWrtShell, *pWrtShell->GetOut(), pScriptInfo, rText, 0, nLength); // Root -> page -> body -> text. SwTextFrame* pTextFrame = static_cast<SwTextFrame*>(pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()); aDrawTextInfo.SetFrame(pTextFrame); |