Kaydet (Commit) 8dca2d5a authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:oncevar in starmath..svl

Change-Id: I20e3796407c7e429a88d2811673929ac1141a41c
Reviewed-on: https://gerrit.libreoffice.org/39280Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 513ac8eb
......@@ -67,7 +67,7 @@ void Test::tearDown()
void Test::testCopyPaste()
{
OUString sInput("a * b + c");
OUString const sInput("a * b + c");
std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput));
xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);
......@@ -90,7 +90,7 @@ void Test::testCopyPaste()
void Test::testCopySelectPaste()
{
OUString sInput("a * b + c");
OUString const sInput("a * b + c");
std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput));
xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);
......@@ -117,7 +117,7 @@ void Test::testCopySelectPaste()
void Test::testCutPaste()
{
OUString sInput("a * b + c");
OUString const sInput("a * b + c");
std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput));
xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);
......@@ -140,7 +140,7 @@ void Test::testCutPaste()
void Test::testCutSelectPaste()
{
OUString sInput("a * b + c");
OUString const sInput("a * b + c");
std::unique_ptr<SmNode> xTree(SmParser().Parse(sInput));
xTree->Prepare(xDocShRef->GetFormat(), *xDocShRef);
......
......@@ -144,7 +144,7 @@ void Test::editMarker()
}
{
OUString sTargetText("a under b under c");
OUString const sTargetText("a under b under c");
ESelection aSelection;
m_pEditWindow->SelNextMark();
......
......@@ -116,21 +116,21 @@ void Test::testColor()
void Test::testSimple()
{
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/simple.mml"));
OUString sExpected("left ( {a + b} right )^2");
OUString const sExpected("left ( {a + b} right )^2");
CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, mxDocShell->GetText());
}
void Test::testNsPrefixMath()
{
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/ns-prefix-math.mml"));
OUString sExpected("left ( {a + b} right )^2");
OUString const sExpected("left ( {a + b} right )^2");
CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, mxDocShell->GetText());
}
void Test::testMaction()
{
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/maction.mml"));
OUString sExpected("matrix {1 ## 2 ## 3}");
OUString const sExpected("matrix {1 ## 2 ## 3}");
CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, mxDocShell->GetText());
}
......@@ -143,7 +143,7 @@ void Test::testMspace()
void Test::testtdf99556()
{
loadURL(m_directories.getURLFromSrc("starmath/qa/extras/data/tdf99556-1.mml"));
OUString sExpected("sqrt { {} }");
OUString const sExpected("sqrt { {} }");
CPPUNIT_ASSERT_EQUAL_MESSAGE("loaded text", sExpected, mxDocShell->GetText());
}
......
......@@ -316,11 +316,10 @@ const OUString SmFontFormatList::GetNewFontFormatId() const
{
// returns first unused FormatId
OUString aPrefix("Id");
sal_Int32 nCnt = GetCount();
for (sal_Int32 i = 1; i <= nCnt + 1; ++i)
{
OUString aTmpId = aPrefix + OUString::number(i);
OUString aTmpId = "Id" + OUString::number(i);
if (!GetFontFormat(aTmpId))
return aTmpId;
}
......
......@@ -445,8 +445,7 @@ SmNodeList::iterator SmCursor::TakeSelectedNodesFromList(SmNodeList *pLineList,
sal_uInt16 eFontDesc = pText->GetFontDesc();
//If we need make segment 1
if(len1 > 0) {
int start1 = 0;
OUString str = aText.copy(start1, len1);
OUString str = aText.copy(0, len1);
pText->ChangeText(str);
++it;
} else {//Remove it if not needed
......
......@@ -165,9 +165,8 @@ bool SmXMLExportWrapper::Export(SfxMedium &rMedium)
new comphelper::PropertySetInfo( aInfoMap ) ) );
SvtSaveOptions aSaveOpt;
OUString sUsePrettyPrinting("UsePrettyPrinting");
bool bUsePrettyPrinting( bFlat || aSaveOpt.IsPrettyPrinting() );
xInfoSet->setPropertyValue( sUsePrettyPrinting, Any(bUsePrettyPrinting) );
xInfoSet->setPropertyValue( "UsePrettyPrinting", Any(bUsePrettyPrinting) );
// Set base URI
OUString sPropName( "BaseURI" );
......@@ -330,21 +329,16 @@ bool SmXMLExportWrapper::WriteThroughComponent(
return false;
}
OUString aPropName( "MediaType" );
OUString aMime( "text/xml" );
uno::Reference < beans::XPropertySet > xSet( xStream, uno::UNO_QUERY );
xSet->setPropertyValue( aPropName, Any(aMime) );
xSet->setPropertyValue( "MediaType", Any(OUString( "text/xml" )) );
// all streams must be encrypted in encrypted document
OUString aTmpPropName( "UseCommonStoragePasswordEncryption" );
xSet->setPropertyValue( aTmpPropName, Any(true) );
xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", Any(true) );
// set Base URL
if ( rPropSet.is() )
{
OUString sPropName( "StreamName" );
rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
rPropSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
}
// write the stuff
......
......@@ -384,8 +384,7 @@ ErrCode SmXMLImportWrapper::ReadThroughComponent(
// set Base URL
if ( rPropSet.is() )
{
OUString sPropName( "StreamName");
rPropSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
rPropSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
}
......
......@@ -1015,8 +1015,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_DIRECT)
{
// Truncate direct data pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::directCount;
for (i = n; i > nRemain; i--)
for (sal_uInt16 i = OStoreDirectoryDataBlock::directCount; i > nRemain; i--)
{
// Obtain data page location.
sal_uInt32 nAddr = directLink (i - 1);
......@@ -1038,8 +1037,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_SINGLE)
{
// Truncate single indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::singleCount;
for (i = n; i > nRemain; i--)
for (sal_uInt16 i = OStoreDirectoryDataBlock::singleCount; i > nRemain; i--)
{
// Truncate single indirect page to zero data pages.
eErrCode = store_truncate_Impl (singleLink (i - 1), 0, rBIOS);
......@@ -1057,8 +1055,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_DOUBLE)
{
// Truncate double indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::doubleCount;
for (i = n; i > nRemain; i--)
for (sal_uInt16 i = OStoreDirectoryDataBlock::doubleCount; i > nRemain; i--)
{
// Truncate double indirect page to zero single indirect pages.
eErrCode = store_truncate_Impl (doubleLink (i - 1), 0, 0, rBIOS);
......@@ -1076,8 +1073,7 @@ storeError OStoreDirectoryPageObject::truncate (
if (eScope == page::SCOPE_TRIPLE)
{
// Truncate triple indirect pages.
sal_uInt16 i, n = OStoreDirectoryDataBlock::tripleCount;
for (i = n; i > nRemain; i--)
for (sal_uInt16 i = OStoreDirectoryDataBlock::tripleCount; i > nRemain; i--)
{
// Truncate to zero double indirect pages.
eErrCode = store_truncate_Impl (tripleLink (i - 1), 0, 0, 0, rBIOS);
......
......@@ -251,25 +251,19 @@ namespace svgio
}
const ::FontWeight nFontWeight(getVclFontWeight(rSvgStyleAttributes.getFontWeight()));
bool bSymbol(false);
bool bVertical(false);
bool bItalic(FontStyle_italic == rSvgStyleAttributes.getFontStyle() || FontStyle_oblique == rSvgStyleAttributes.getFontStyle());
bool bMonospaced(false);
bool bOutline(false);
bool bRTL(false);
bool bBiDiStrong(false);
const drawinglayer::attribute::FontAttribute aFontAttribute(
aFontFamily,
OUString(),
nFontWeight,
bSymbol,
bVertical,
false/*bSymbol*/,
false/*bVertical*/,
bItalic,
bMonospaced,
bOutline,
bRTL,
bBiDiStrong);
false/*bMonospaced*/,
false/*bOutline*/,
false/*bRTL*/,
false/*bBiDiStrong*/);
// prepare FontSizeNumber
double fFontWidth(rSvgStyleAttributes.getFontSizeNumber().solve(*this));
......
......@@ -64,11 +64,8 @@ namespace svgio
const SvgStyleAttributes* SvgGradientNode::getSvgStyleAttributes() const
{
OUString aClassStrA("linearGradient");
OUString aClassStrB("radialGradient");
return checkForCssStyle(
SVGTokenLinearGradient == getType() ? aClassStrA : aClassStrB,
SVGTokenLinearGradient == getType() ? OUString("linearGradient") : OUString("radialGradient"),
maSvgStyleAttributes);
}
......
......@@ -38,9 +38,7 @@ namespace svgio
const SvgStyleAttributes* SvgGradientStopNode::getSvgStyleAttributes() const
{
OUString aClassStr("stop");
return checkForCssStyle(aClassStr, maSvgStyleAttributes);
return checkForCssStyle("stop", maSvgStyleAttributes);
}
void SvgGradientStopNode::parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent)
......
......@@ -606,55 +606,51 @@ namespace svgio
// initially despite I found various examples of Svg files out there
// which have no correct values for this clipping. It's correct
// due to the Svg spec.
bool bDoCorrectCanvasClipping(true);
if(bDoCorrectCanvasClipping)
{
// different from Svg we have the possibility with primitives to get
// a correct bounding box for the geometry. Get it for evtl. taking action
const basegfx::B2DRange aContentRange(
aSequence.getB2DRange(
drawinglayer::geometry::ViewInformation2D()));
// different from Svg we have the possibility with primitives to get
// a correct bounding box for the geometry. Get it for evtl. taking action
const basegfx::B2DRange aContentRange(
aSequence.getB2DRange(
drawinglayer::geometry::ViewInformation2D()));
if(aSvgCanvasRange.isInside(aContentRange))
{
// no clip needed, but an invisible HiddenGeometryPrimitive2D
// to allow getting the full Svg range using the primitive mechanisms.
// This is needed since e.g. an SdrObject using this as graphic will
// create a mapping transformation to exactly map the content to its
// real life size
const drawinglayer::primitive2d::Primitive2DReference xLine(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
if(aSvgCanvasRange.isInside(aContentRange))
{
// no clip needed, but an invisible HiddenGeometryPrimitive2D
// to allow getting the full Svg range using the primitive mechanisms.
// This is needed since e.g. an SdrObject using this as graphic will
// create a mapping transformation to exactly map the content to its
// real life size
const drawinglayer::primitive2d::Primitive2DReference xLine(
new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
basegfx::tools::createPolygonFromRect(
aSvgCanvasRange),
basegfx::BColor(0.0, 0.0, 0.0)));
const drawinglayer::primitive2d::Primitive2DReference xHidden(
new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(
drawinglayer::primitive2d::Primitive2DContainer { xLine }));
aSequence.push_back(xHidden);
}
else if(aSvgCanvasRange.overlaps(aContentRange))
{
// Clip is necessary. This will make Svg images evtl. smaller
// than wanted from Svg (the free space which may be around it is
// conform to the Svg spec), but avoids an expensive and unnecessary
// clip. Keep the full Svg range here to get the correct mappings
// to objects using this. Optimizations can be done in the processors
const drawinglayer::primitive2d::Primitive2DReference xMask(
new drawinglayer::primitive2d::MaskPrimitive2D(
basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(
aSvgCanvasRange),
basegfx::BColor(0.0, 0.0, 0.0)));
const drawinglayer::primitive2d::Primitive2DReference xHidden(
new drawinglayer::primitive2d::HiddenGeometryPrimitive2D(
drawinglayer::primitive2d::Primitive2DContainer { xLine }));
aSequence.push_back(xHidden);
}
else if(aSvgCanvasRange.overlaps(aContentRange))
{
// Clip is necessary. This will make Svg images evtl. smaller
// than wanted from Svg (the free space which may be around it is
// conform to the Svg spec), but avoids an expensive and unnecessary
// clip. Keep the full Svg range here to get the correct mappings
// to objects using this. Optimizations can be done in the processors
const drawinglayer::primitive2d::Primitive2DReference xMask(
new drawinglayer::primitive2d::MaskPrimitive2D(
basegfx::B2DPolyPolygon(
basegfx::tools::createPolygonFromRect(
aSvgCanvasRange)),
aSequence));
aSvgCanvasRange)),
aSequence));
aSequence = drawinglayer::primitive2d::Primitive2DContainer { xMask };
}
else
{
// not inside, no overlap. Empty Svg
aSequence.clear();
}
aSequence = drawinglayer::primitive2d::Primitive2DContainer { xMask };
}
else
{
// not inside, no overlap. Empty Svg
aSequence.clear();
}
if(!aSequence.empty())
......
......@@ -73,10 +73,8 @@ void IndexedStyleSheetsTest::InstantiationWorks()
void IndexedStyleSheetsTest::AddedStylesheetsCanBeFoundAndRetrievedByPosition()
{
rtl::OUString name1("name1");
rtl::OUString name2("name2");
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet(name1));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet(name2));
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet("name1"));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet("name2"));
IndexedStyleSheets iss;
iss.AddStyleSheet(sheet1);
iss.AddStyleSheet(sheet2);
......@@ -97,10 +95,8 @@ void IndexedStyleSheetsTest::AddingSameStylesheetTwiceHasNoEffect()
void IndexedStyleSheetsTest::RemovedStyleSheetIsNotFound()
{
rtl::OUString name1("name1");
rtl::OUString name2("name2");
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet(name1));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet(name2));
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet("name1"));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet("name2"));
IndexedStyleSheets iss;
iss.AddStyleSheet(sheet1);
iss.AddStyleSheet(sheet2);
......@@ -147,8 +143,8 @@ void IndexedStyleSheetsTest::StyleSheetsCanBeRetrievedByTheirName()
void IndexedStyleSheetsTest::KnowsThatItStoresAStyleSheet()
{
rtl::OUString name1("name1");
rtl::OUString name2("name2");
rtl::OUString const name1("name1");
rtl::OUString const name2("name2");
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet(name1));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet(name1));
rtl::Reference<SfxStyleSheetBase> sheet3(new MockedStyleSheet(name2));
......@@ -169,12 +165,9 @@ void IndexedStyleSheetsTest::KnowsThatItStoresAStyleSheet()
void IndexedStyleSheetsTest::PositionCanBeQueriedByFamily()
{
rtl::OUString name1("name1");
rtl::OUString name2("name2");
rtl::OUString name3("name3");
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet(name1, SfxStyleFamily::Char));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet(name2, SfxStyleFamily::Para));
rtl::Reference<SfxStyleSheetBase> sheet3(new MockedStyleSheet(name3, SfxStyleFamily::Char));
rtl::Reference<SfxStyleSheetBase> sheet1(new MockedStyleSheet("name1", SfxStyleFamily::Char));
rtl::Reference<SfxStyleSheetBase> sheet2(new MockedStyleSheet("name2", SfxStyleFamily::Para));
rtl::Reference<SfxStyleSheetBase> sheet3(new MockedStyleSheet("name3", SfxStyleFamily::Char));
IndexedStyleSheets iss;
iss.AddStyleSheet(sheet1);
......
......@@ -317,7 +317,7 @@ void Test::testSharedStringPool()
CPPUNIT_ASSERT_EQUAL(p1.getData(), p2.getData());
// Test case insensitive string ID's.
OUString aAndyLower("andy"), aAndyUpper("ANDY");
OUString const aAndyLower("andy"), aAndyUpper("ANDY");
p1 = aPool.intern(aAndy);
p2 = aPool.intern(aAndyLower);
CPPUNIT_ASSERT_MESSAGE("Failed to intern strings.", p1.getData() && p2.getData());
......
......@@ -189,11 +189,10 @@ void FSStorage::CopyContentToStorage_Impl( ::ucbhelper::Content* pContent, const
OUString* pProps = aProps.getArray();
pProps[0] = "TargetURL";
pProps[1] = "IsFolder";
::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
try
{
uno::Reference< sdbc::XResultSet > xResultSet = pContent->createCursor( aProps, eInclude );
uno::Reference< sdbc::XResultSet > xResultSet = pContent->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
if ( xResultSet.is() )
{
......@@ -918,10 +917,9 @@ uno::Sequence< OUString > SAL_CALL FSStorage::getElementNames()
throw io::IOException(); // TODO: error handling
uno::Sequence<OUString> aProps { "Title" };
::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
sal_Int32 nSize = 0;
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude );
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
if ( xResultSet.is() )
{
......@@ -1019,9 +1017,8 @@ sal_Bool SAL_CALL FSStorage::hasElements()
throw io::IOException(); // TODO: error handling
uno::Sequence<OUString> aProps { "TargetURL" };
::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS;
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, eInclude );
uno::Reference< sdbc::XResultSet > xResultSet = GetContent()->createCursor( aProps, ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS );
return ( xResultSet.is() && xResultSet->next() );
}
catch (const uno::RuntimeException&)
......
......@@ -1104,8 +1104,7 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference<
if ( bCanChangePassword )
{
// ask for the new password, but do not set it
PasswordRequestMode aRMode = PasswordRequestMode_PASSWORD_CREATE;
OUString aPass = RequestPasswordFromUser( aRMode, xTmpHandler );
OUString aPass = RequestPasswordFromUser( PasswordRequestMode_PASSWORD_CREATE, xTmpHandler );
if ( !aPass.isEmpty() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment