/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include #include #include namespace basegfx { namespace trapezoidhelper { // helper class to hold a simple edge. This is only used for horizontal edges // currently, thus the YPositions will be equal. I did not create a special // class for this since holding the pointers is more effective and also can be // used as baseclass for the traversing edges class TrDeSimpleEdge { protected: // pointers to start and end point const B2DPoint* mpStart; const B2DPoint* mpEnd; public: // constructor TrDeSimpleEdge( const B2DPoint* pStart, const B2DPoint* pEnd) : mpStart(pStart), mpEnd(pEnd) { } // data read access const B2DPoint& getStart() const { return *mpStart; } const B2DPoint& getEnd() const { return *mpEnd; } }; // define vector of simple edges typedef std::vector< TrDeSimpleEdge > TrDeSimpleEdges; // helper class for holding a traversing edge. It will always have some // distance in YPos. The slope (in a numerically useful form, see comments) is // hold and used in SortValue to allow sorting traversing edges by Y, X and slope // (in that order) class TrDeEdgeEntry : public TrDeSimpleEdge { private: // the slope in a numerical useful form for sorting sal_uInt32 mnSortValue; public: // convenience data read access double getDeltaX() const { return mpEnd->getX() - mpStart->getX(); } double getDeltaY() const { return mpEnd->getY() - mpStart->getY(); } // convenience data read access. SortValue is created on demand since // it is not always used sal_uInt32 getSortValue() const { if(mnSortValue != 0) return mnSortValue; // get radiant; has to be in the range ]0.0 .. pi[, thus scale to full // sal_uInt32 range for maximum precision const double fRadiant(atan2(getDeltaY(), getDeltaX()) * (SAL_MAX_UINT32 / F_PI)); // convert to sal_uInt32 value const_cast< TrDeEdgeEntry* >(this)->mnSortValue = sal_uInt32(fRadiant); return mnSortValue; } // constructor. SortValue can be given when known, use zero otherwise TrDeEdgeEntry( const B2DPoint* pStart, const B2DPoint* pEnd, sal_uInt32 nSortValue) : TrDeSimpleEdge(pStart, pEnd), mnSortValue(nSortValue) { // force traversal of deltaY downward if(mpEnd->getY() < mpStart->getY()) { std::swap(mpStart, mpEnd); } // no horizontal edges allowed, all need to traverse vertically OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); } // data write access to StartPoint void setStart( const B2DPoint* pNewStart) { OSL_ENSURE(pNewStart != nullptr, "No null pointer allowed here (!)"); if(mpStart != pNewStart) { mpStart = pNewStart; // no horizontal edges allowed, all need to traverse vertically OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); } } // data write access to EndPoint void setEnd( const B2DPoint* pNewEnd) { OSL_ENSURE(pNewEnd != nullptr, "No null pointer allowed here (!)"); if(mpEnd != pNewEnd) { mpEnd = pNewEnd; // no horizontal edges allowed, all need to traverse vertically OSL_ENSURE(mpEnd->getY() > mpStart->getY(), "Illegal TrDeEdgeEntry constructed (!)"); } } // operator for sort support. Sort by Y, X and slope (in that order) bool operator<(const TrDeEdgeEntry& rComp) const { if(fTools::equal(getStart().getY(), rComp.getStart().getY())) { if(fTools::equal(getStart().getX(), rComp.getStart().getX())) { // when start points are equal, use the direction the edge is pointing // to. That value is created on demand and derived from atan2 in the // range ]0.0 .. pi[ (without extremas, we always have a deltaY in this // class) and scaled to sal_uInt32 range for best precision. 0 means no angle, // while SAL_MAX_UINT32 means pi. Thus, the higher the value, the more left // the edge traverses. return (getSortValue() > rComp.getSortValue()); } else { return fTools::less(getStart().getX(), rComp.getStart().getX()); } } else { return fTools::less(getStart().getY(), rComp.getStart().getY()); } } // method for cut support B2DPoint getCutPointForGivenY(double fGivenY) const { // Calculate cut point locally (do not use interpolate) since it is numerically // necessary to guarantee the new, equal Y-coordinate const double fFactor((fGivenY - getStart().getY()) / getDeltaY()); const double fDeltaXNew(fFactor * getDeltaX()); return B2DPoint(getStart().getX() + fDeltaXNew, fGivenY); } }; // define double linked list of edges (for fast random insert) typedef std::list< TrDeEdgeEntry > TrDeEdgeEntries; } // end of anonymous namespace } // end of namespace basegfx namespace basegfx { namespace trapezoidhelper { // FIXME: templatize this and use it for TrDeEdgeEntries too ... /// Class to allow efficient allocation and release of B2DPoints class PointBlockAllocator { static const size_t nBlockSize = 32; size_t nCurPoint; B2DPoint *mpPointBase; /// Special case the first allocation to avoid it. B2DPoint maFirstStackBlock[nBlockSize]; std::vector< B2DPoint * > maBlocks; public: PointBlockAllocator() : nCurPoint( nBlockSize ), mpPointBase( maFirstStackBlock ) { } ~PointBlockAllocator() { while(!maBlocks.empty()) { delete [] maBlocks.back(); maBlocks.pop_back(); } } B2DPoint *allocatePoint() { if(nCurPoint >= nBlockSize) { mpPointBase = new B2DPoint[nBlockSize]; maBlocks.push_back(mpPointBase); nCurPoint = 0; } return mpPointBase + nCurPoint++; } B2DPoint *allocatePoint(const B2DTuple &rPoint) { B2DPoint *pPoint = allocatePoint(); *pPoint = rPoint; return pPoint; } /// This is a very uncommon case but why not ... void freeIfLast(B2DPoint const *pPoint) { // just re-use the last point if we can. if ( nCurPoint > 0 && pPoint == mpPointBase + nCurPoint - 1 ) nCurPoint--; } }; // helper class to handle the complete trapezoid subdivision of a PolyPolygon class TrapezoidSubdivider { private: // local data sal_uInt32 mnInitialEdgeEntryCount; TrDeEdgeEntries maTrDeEdgeEntries; std::vector< B2DPoint > maPoints; /// new points allocated for cuts PointBlockAllocator maNewPoints; void addEdgeSorted( TrDeEdgeEntries::iterator aCurrent, const TrDeEdgeEntry& rNewEdge) { // Loop while new entry is bigger, use operator< while(aCurrent != maTrDeEdgeEntries.end() && (*aCurrent) < rNewEdge) { ++aCurrent; } // Insert before first which is smaller or equal or at end maTrDeEdgeEntries.insert(aCurrent, rNewEdge); } bool splitEdgeAtGivenPoint( TrDeEdgeEntries::reference aEdge, const B2DPoint& rCutPoint, const TrDeEdgeEntries::iterator& aCurrent) { // do not create edges without deltaY: do not split when start is identical if(aEdge.getStart().equal(rCutPoint)) { return false; } // do not create edges without deltaY: do not split when end is identical if(aEdge.getEnd().equal(rCutPoint)) { return false; } const double fOldDeltaYStart(rCutPoint.getY() - aEdge.getStart().getY()); if(fTools::lessOrEqual(fOldDeltaYStart, 0.0)) { // do not split: the resulting edge would be horizontal // correct it to new start point aEdge.setStart(&rCutPoint); return false; } const double fNewDeltaYStart(aEdge.getEnd().getY() - rCutPoint.getY()); if(fTools::lessOrEqual(fNewDeltaYStart, 0.0)) { // do not split: the resulting edge would be horizontal // correct it to new end point aEdge.setEnd(&rCutPoint); return false; } // Create new entry const TrDeEdgeEntry aNewEdge( &rCutPoint, &aEdge.getEnd(), aEdge.getSortValue()); // Correct old entry aEdge.setEnd(&rCutPoint); // Insert sorted (to avoid new sort) addEdgeSorted(aCurrent, aNewEdge); return true; } bool testAndCorrectEdgeIntersection( TrDeEdgeEntries::reference aEdgeA, TrDeEdgeEntries::reference aEdgeB, const TrDeEdgeEntries::iterator& aCurrent) { // Exclude simple cases: same start or end point if(aEdgeA.getStart().equal(aEdgeB.getStart())) { return false; } if(aEdgeA.getStart().equal(aEdgeB.getEnd())) { return false; } if(aEdgeA.getEnd().equal(aEdgeB.getStart())) { return false; } if(aEdgeA.getEnd().equal(aEdgeB.getEnd())) { return false; } // Exclude simple cases: one of the edges has no length anymore if(aEdgeA.getStart().equal(aEdgeA.getEnd())) { return false; } if(aEdgeB.getStart().equal(aEdgeB.getEnd())) { return false; } // check if one point is on the other edge (a touch, not a cut) const B2DVector aDeltaB(aEdgeB.getDeltaX(), aEdgeB.getDeltaY()); if(utils::isPointOnEdge(aEdgeA.getStart(), aEdgeB.getStart(), aDeltaB)) { return splitEdgeAtGivenPoint(aEdgeB, aEdgeA.getStart(), aCurrent); } if(utils::isPointOnEdge(aEdgeA.getEnd(), aEdgeB.getStart(), aDeltaB)) { return splitEdgeAtGivenPoint(aEdgeB, aEdgeA.getEnd(), aCurrent); } const B2DVector aDeltaA(aEdgeA.getDeltaX(), aEdgeA.getDeltaY()); if(utils::isPointOnEdge(aEdgeB.getStart(), aEdgeA.getStart(), aDeltaA)) { return splitEdgeAtGivenPoint(aEdgeA, aEdgeB.getStart(), aCurrent); } if(utils::isPointOnEdge(aEdgeB.getEnd(), aEdgeA.getStart(), aDeltaA)) { return splitEdgeAtGivenPoint(aEdgeA, aEdgeB.getEnd(), aCurrent); } // check for cut inside edges. Use both t-values to choose the more precise // one later double fCutA(0.0); double fCutB(0.0); if(utils::findCut( aEdgeA.getStart(), aDeltaA, aEdgeB.getStart(), aDeltaB, CutFlagValue::LINE, &fCutA, &fCutB) != CutFlagValue::NONE) { // use a simple metric (length criteria) for choosing the numerically // better cut const double fSimpleLengthA(aDeltaA.getX() + aDeltaA.getY()); const double fSimpleLengthB(aDeltaB.getX() + aDeltaB.getY()); const bool bAIsLonger(fSimpleLengthA > fSimpleLengthB); B2DPoint* pNewPoint = bAIsLonger ? maNewPoints.allocatePoint(aEdgeA.getStart() + (fCutA * aDeltaA)) : maNewPoints.allocatePoint(aEdgeB.getStart() + (fCutB * aDeltaB)); // try to split both edges bool bRetval = splitEdgeAtGivenPoint(aEdgeA, *pNewPoint, aCurrent); bRetval |= splitEdgeAtGivenPoint(aEdgeB, *pNewPoint, aCurrent); if(!bRetval) maNewPoints.freeIfLast(pNewPoint); return bRetval; } return false; } void solveHorizontalEdges(TrDeSimpleEdges& rTrDeSimpleEdges) { if(!rTrDeSimpleEdges.empty() && !maTrDeEdgeEntries.empty()) { // there were horizontal edges. These can be excluded, but // cuts with other edges need to be solved and added before // ignoring them for(TrDeSimpleEdge & rHorEdge : rTrDeSimpleEdges) { // get horizontal edge as candidate; prepare its range and fixed Y const B1DRange aRange(rHorEdge.getStart().getX(), rHorEdge.getEnd().getX()); const double fFixedY(rHorEdge.getStart().getY()); // loop over traversing edges TrDeEdgeEntries::iterator aCurrent(maTrDeEdgeEntries.begin()); do { // get compare edge TrDeEdgeEntries::reference aCompare(*aCurrent++); if(fTools::lessOrEqual(aCompare.getEnd().getY(), fFixedY)) { // edge ends above horizontal edge, continue continue; } if(fTools::moreOrEqual(aCompare.getStart().getY(), fFixedY)) { // edge starts below horizontal edge, continue continue; } // vertical overlap, get horizontal range const B1DRange aCompareRange(aCompare.getStart().getX(), aCompare.getEnd().getX()); if(aRange.overlaps(aCompareRange)) { // possible cut, get cut point const B2DPoint aSplit(aCompare.getCutPointForGivenY(fFixedY)); if(fTools::more(aSplit.getX(), aRange.getMinimum()) && fTools::less(aSplit.getX(), aRange.getMaximum())) { // cut is in XRange of horizontal edge, potentially needed cut B2DPoint* pNewPoint = maNewPoints.allocatePoint(aSplit); if(!splitEdgeAtGivenPoint(aCompare, *pNewPoint, aCurrent)) { maNewPoints.freeIfLast(pNewPoint); } } } } while(aCurrent != maTrDeEdgeEntries.end() && fTools::less(aCurrent->getStart().getY(), fFixedY)); } } } public: explicit TrapezoidSubdivider( const B2DPolyPolygon& rSourcePolyPolygon) : mnInitialEdgeEntryCount(0), maTrDeEdgeEntries(), maPoints(), maNewPoints() { B2DPolyPolygon aSource(rSourcePolyPolygon); TrDeSimpleEdges aTrDeSimpleEdges; sal_uInt32 nAllPointCount(0); // ensure there are no curves used if(aSource.areControlPointsUsed()) { aSource = aSource.getDefaultAdaptiveSubdivision(); } for(const auto& aPolygonCandidate : aSource) { // 1st run: count points const sal_uInt32 nCount(aPolygonCandidate.count()); if(nCount > 2) { nAllPointCount += nCount; } } if(nAllPointCount) { // reserve needed points. CAUTION: maPoints size is NOT to be changed anymore // after 2nd loop since pointers to it are used in the edges maPoints.reserve(nAllPointCount); for(const auto& aPolygonCandidate : aSource) { // 2nd run: add points const sal_uInt32 nCount(aPolygonCandidate.count()); if(nCount > 2) { for(sal_uInt32 b = 0; b < nCount; b++) { maPoints.push_back(aPolygonCandidate.getB2DPoint(b)); } } } // Moved the edge construction to a 3rd run: doing it in the 2nd run is // possible(and i used it), but requires a working vector::reserve() // implementation, else the vector will be reallocated and the pointers // in the edges may be wrong. Security first here. sal_uInt32 nStartIndex(0); for(const auto& aPolygonCandidate : aSource) { const sal_uInt32 nCount(aPolygonCandidate.count()); if(nCount > 2) { // get the last point of the current polygon B2DPoint* pPrev(&maPoints[nCount + nStartIndex - 1]); for(sal_uInt32 b = 0; b < nCount; b++) { // get next point B2DPoint* pCurr(&maPoints[nStartIndex++]); if(fTools::equal(pPrev->getY(), pCurr->getY())) { // horizontal edge, check for single point if(!fTools::equal(pPrev->getX(), pCurr->getX())) { // X-order not needed, just add aTrDeSimpleEdges.emplace_back(pPrev, pCurr); const double fMiddle((pPrev->getY() + pCurr->getY()) * 0.5); pPrev->setY(fMiddle); pCurr->setY(fMiddle); } } else { // vertical edge. Positive Y-direction is guaranteed by the // TrDeEdgeEntry constructor maTrDeEdgeEntries.emplace_back(pPrev, pCurr, 0); mnInitialEdgeEntryCount++; } // prepare next step pPrev = pCurr; } } } } if(!maTrDeEdgeEntries.empty()) { // single and initial sort of traversing edges maTrDeEdgeEntries.sort(); // solve horizontal edges if there are any detected solveHorizontalEdges(aTrDeSimpleEdges); } } void Subdivide(B2DTrapezoidVector& ro_Result) { // This is the central subdivider. The strategy is to use the first two entries // from the traversing edges as a potential trapezoid and do the needed corrections // and adaptations on the way. // There always must be two edges with the same YStart value: When adding the polygons // in the constructor, there is always a topmost point from which two edges start; when // the topmost is an edge, there is a start and end of this edge from which two edges // start. All cases have two edges with same StartY (QED). // Based on this these edges get corrected when: // - one is longer than the other // - they intersect // - they intersect with other edges // - another edge starts inside the thought trapezoid // All this cases again produce a valid state so that the first two edges have a common // Ystart again. Some cases lead to a restart of the process, some allow consuming the // edges and create the intended trapezoid. // Be careful when doing changes here: it is essential to keep all possible paths // in valid states and to be numerically correct. This is especially needed e.g. // by using fTools::equal(..) in the more robust small-value incarnation. B1DRange aLeftRange; B1DRange aRightRange; if(!maTrDeEdgeEntries.empty()) { // measuring shows that the relation between edges and created trapezoids is // mostly in the 1:1 range, thus reserve as much trapezoids as edges exist. Do // not use maTrDeEdgeEntries.size() since that may be a non-constant time // operation for Lists. Instead, use mnInitialEdgeEntryCount which will contain // the roughly counted adds to the List ro_Result.reserve(ro_Result.size() + mnInitialEdgeEntryCount); } while(!maTrDeEdgeEntries.empty()) { // Prepare current operator and get first edge TrDeEdgeEntries::iterator aCurrent(maTrDeEdgeEntries.begin()); TrDeEdgeEntries::reference aLeft(*aCurrent++); if(aCurrent == maTrDeEdgeEntries.end()) { // Should not happen: No 2nd edge; consume the single edge // to not have an endless loop and start next. During development // i constantly had breakpoints here, so i am sure enough to add an // assertion here OSL_FAIL("Trapezoid decomposer in illegal state (!)"); maTrDeEdgeEntries.pop_front(); continue; } // get second edge TrDeEdgeEntries::reference aRight(*aCurrent++); if(!fTools::equal(aLeft.getStart().getY(), aRight.getStart().getY())) { // Should not happen: We have a 2nd edge, but YStart is on another // line; consume the single edge to not have an endless loop and start // next. During development i constantly had breakpoints here, so i am // sure enough to add an assertion here OSL_FAIL("Trapezoid decomposer in illegal state (!)"); maTrDeEdgeEntries.pop_front(); continue; } // aLeft and aRight build a thought trapezoid now. They have a common // start line (same Y for start points). Potentially, one of the edges // is longer than the other. It is only needed to look at the shorter // length which build the potential trapezoid. To do so, get the end points // locally and adapt the evtl. longer one. Use only aLeftEnd and aRightEnd // from here on, not the aLeft.getEnd() or aRight.getEnd() accesses. B2DPoint aLeftEnd(aLeft.getEnd()); B2DPoint aRightEnd(aRight.getEnd()); // check if end points are on the same line. If yes, no adaptation // needs to be prepared. Also remember which one actually is longer. const bool bEndOnSameLine(fTools::equal(aLeftEnd.getY(), aRightEnd.getY())); bool bLeftIsLonger(false); if(!bEndOnSameLine) { // check which edge is longer and correct accordingly bLeftIsLonger = fTools::more(aLeftEnd.getY(), aRightEnd.getY()); if(bLeftIsLonger) { aLeftEnd = aLeft.getCutPointForGivenY(aRightEnd.getY()); } else { aRightEnd = aRight.getCutPointForGivenY(aLeftEnd.getY()); } } // check for same start and end points const bool bSameStartPoint(aLeft.getStart().equal(aRight.getStart())); const bool bSameEndPoint(aLeftEnd.equal(aRightEnd)); // check the simple case that the edges form a 'blind' edge (deadend) if(bSameStartPoint && bSameEndPoint) { // correct the longer edge if prepared if(!bEndOnSameLine) { if(bLeftIsLonger) { B2DPoint* pNewPoint = maNewPoints.allocatePoint(aLeftEnd); if(!splitEdgeAtGivenPoint(aLeft, *pNewPoint, aCurrent)) { maNewPoints.freeIfLast(pNewPoint); } } else { B2DPoint* pNewPoint = maNewPoints.allocatePoint(aRightEnd); if(!splitEdgeAtGivenPoint(aRight, *pNewPoint, aCurrent)) { maNewPoints.freeIfLast(pNewPoint); } } } // consume both edges and start next run maTrDeEdgeEntries.pop_front(); maTrDeEdgeEntries.pop_front(); continue; } // check if the edges self-intersect. This can only happen when // start and end point are different bool bRangesSet(false); if(!(bSameStartPoint || bSameEndPoint)) { // get XRanges of edges aLeftRange = B1DRange(aLeft.getStart().getX(), aLeftEnd.getX()); aRightRange = B1DRange(aRight.getStart().getX(), aRightEnd.getX()); bRangesSet = true; // use fast range test first if(aLeftRange.overlaps(aRightRange)) { // real cut test and correction. If correction was needed, // start new run if(testAndCorrectEdgeIntersection(aLeft, aRight, aCurrent)) { continue; } } } // now we need to check if there are intersections with other edges // or if other edges start inside the candidate trapezoid if(aCurrent != maTrDeEdgeEntries.end() && fTools::less(aCurrent->getStart().getY(), aLeftEnd.getY())) { // get XRanges of edges if(!bRangesSet) { aLeftRange = B1DRange(aLeft.getStart().getX(), aLeftEnd.getX()); aRightRange = B1DRange(aRight.getStart().getX(), aRightEnd.getX()); } // build full XRange for fast check B1DRange aAllRange(aLeftRange); aAllRange.expand(aRightRange); // prepare loop iterator; aCurrent needs to stay unchanged for // possibly sorted insertions of new EdgeNodes. Also prepare stop flag TrDeEdgeEntries::iterator aLoop(aCurrent); bool bDone(false); do { // get compare edge and its XRange TrDeEdgeEntries::reference aCompare(*aLoop++); // avoid edges using the same start point as one of // the edges. These can neither have their start point // in the thought trapezoid nor cut with one of the edges if(aCompare.getStart().equal(aRight.getStart())) { continue; } // get compare XRange const B1DRange aCompareRange(aCompare.getStart().getX(), aCompare.getEnd().getX()); // use fast range test first if(aAllRange.overlaps(aCompareRange)) { // check for start point inside thought trapezoid if(fTools::more(aCompare.getStart().getY(), aLeft.getStart().getY())) { // calculate the two possible split points at compare's Y const B2DPoint aSplitLeft(aLeft.getCutPointForGivenY(aCompare.getStart().getY())); const B2DPoint aSplitRight(aRight.getCutPointForGivenY(aCompare.getStart().getY())); // check for start point of aCompare being inside thought // trapezoid if(aCompare.getStart().getX() >= aSplitLeft.getX() && aCompare.getStart().getX() <= aSplitRight.getX()) { // is inside, correct and restart loop B2DPoint* pNewLeft = maNewPoints.allocatePoint(aSplitLeft); if(splitEdgeAtGivenPoint(aLeft, *pNewLeft, aCurrent)) { bDone = true; } else { maNewPoints.freeIfLast(pNewLeft); } B2DPoint* pNewRight = maNewPoints.allocatePoint(aSplitRight); if(splitEdgeAtGivenPoint(aRight, *pNewRight, aCurrent)) { bDone = true; } else { maNewPoints.freeIfLast(pNewRight); } } } if(!bDone && aLeftRange.overlaps(aCompareRange)) { // test for concrete cut of compare edge with left edge bDone = testAndCorrectEdgeIntersection(aLeft, aCompare, aCurrent); } if(!bDone && aRightRange.overlaps(aCompareRange)) { // test for concrete cut of compare edge with Right edge bDone = testAndCorrectEdgeIntersection(aRight, aCompare, aCurrent); } } } while(!bDone && aLoop != maTrDeEdgeEntries.end() && fTools::less(aLoop->getStart().getY(), aLeftEnd.getY())); if(bDone) { // something needed to be changed; start next loop continue; } } // when we get here, the intended trapezoid can be used. It needs to // be corrected possibly (if prepared); but this is no reason not to // use it in the same loop iteration if(!bEndOnSameLine) { if(bLeftIsLonger) { B2DPoint* pNewPoint = maNewPoints.allocatePoint(aLeftEnd); if(!splitEdgeAtGivenPoint(aLeft, *pNewPoint, aCurrent)) { maNewPoints.freeIfLast(pNewPoint); } } else { B2DPoint* pNewPoint = maNewPoints.allocatePoint(aRightEnd); if(!splitEdgeAtGivenPoint(aRight, *pNewPoint, aCurrent)) { maNewPoints.freeIfLast(pNewPoint); } } } // the two edges start at the same Y, they use the same DeltaY, they // do not cut themselves and not any other edge in range. Create a // B2DTrapezoid and consume both edges ro_Result.emplace_back( aLeft.getStart().getX(), aRight.getStart().getX(), aLeft.getStart().getY(), aLeftEnd.getX(), aRightEnd.getX(), aLeftEnd.getY()); maTrDeEdgeEntries.pop_front(); maTrDeEdgeEntries.pop_front(); } } }; } // end of anonymous namespace } // end of namespace basegfx namespace basegfx { B2DTrapezoid::B2DTrapezoid( const double& rfTopXLeft, const double& rfTopXRight, const double& rfTopY, const double& rfBottomXLeft, const double& rfBottomXRight, const double& rfBottomY) : mfTopXLeft(rfTopXLeft), mfTopXRight(rfTopXRight), mfTopY(rfTopY), mfBottomXLeft(rfBottomXLeft), mfBottomXRight(rfBottomXRight), mfBottomY(rfBottomY) { // guarantee mfTopXRight >= mfTopXLeft if(mfTopXLeft > mfTopXRight) { std::swap(mfTopXLeft, mfTopXRight); } // guarantee mfBottomXRight >= mfBottomXLeft if(mfBottomXLeft > mfBottomXRight) { std::swap(mfBottomXLeft, mfBottomXRight); } // guarantee mfBottomY >= mfTopY if(mfTopY > mfBottomY) { std::swap(mfTopY, mfBottomY); std::swap(mfTopXLeft, mfBottomXLeft); std::swap(mfTopXRight, mfBottomXRight); } } B2DPolygon B2DTrapezoid::getB2DPolygon() const { B2DPolygon aRetval; aRetval.append(B2DPoint(getTopXLeft(), getTopY())); aRetval.append(B2DPoint(getTopXRight(), getTopY())); aRetval.append(B2DPoint(getBottomXRight(), getBottomY())); aRetval.append(B2DPoint(getBottomXLeft(), getBottomY())); aRetval.setClosed(true); return aRetval; } } // end of namespace basegfx namespace basegfx { namespace utils { // convert Source utils::PolyPolygon to trapezoids void trapezoidSubdivide(B2DTrapezoidVector& ro_Result, const B2DPolyPolygon& rSourcePolyPolygon) { trapezoidhelper::TrapezoidSubdivider aTrapezoidSubdivider(rSourcePolyPolygon); aTrapezoidSubdivider.Subdivide(ro_Result); } void createLineTrapezoidFromEdge( B2DTrapezoidVector& ro_Result, const B2DPoint& rPointA, const B2DPoint& rPointB, double fLineWidth) { if(fTools::lessOrEqual(fLineWidth, 0.0)) { // no line width return; } if(rPointA.equal(rPointB)) { // points are equal, no edge return; } const double fHalfLineWidth(0.5 * fLineWidth); if(fTools::equal(rPointA.getX(), rPointB.getX())) { // vertical line const double fLeftX(rPointA.getX() - fHalfLineWidth); const double fRightX(rPointA.getX() + fHalfLineWidth); ro_Result.emplace_back( fLeftX, fRightX, std::min(rPointA.getY(), rPointB.getY()), fLeftX, fRightX, std::max(rPointA.getY(), rPointB.getY())); } else if(fTools::equal(rPointA.getY(), rPointB.getY())) { // horizontal line const double fLeftX(std::min(rPointA.getX(), rPointB.getX())); const double fRightX(std::max(rPointA.getX(), rPointB.getX())); ro_Result.emplace_back( fLeftX, fRightX, rPointA.getY() - fHalfLineWidth, fLeftX, fRightX, rPointA.getY() + fHalfLineWidth); } else { // diagonal line // create perpendicular vector const B2DVector aDelta(rPointB - rPointA); B2DVector aPerpendicular(-aDelta.getY(), aDelta.getX()); aPerpendicular.setLength(fHalfLineWidth); // create StartLow, StartHigh, EndLow and EndHigh const B2DPoint aStartLow(rPointA + aPerpendicular); const B2DPoint aStartHigh(rPointA - aPerpendicular); const B2DPoint aEndHigh(rPointB - aPerpendicular); const B2DPoint aEndLow(rPointB + aPerpendicular); // create EdgeEntries basegfx::trapezoidhelper::TrDeEdgeEntries aTrDeEdgeEntries; aTrDeEdgeEntries.emplace_back(&aStartLow, &aStartHigh, 0); aTrDeEdgeEntries.emplace_back(&aStartHigh, &aEndHigh, 0); aTrDeEdgeEntries.emplace_back(&aEndHigh, &aEndLow, 0); aTrDeEdgeEntries.emplace_back(&aEndLow, &aStartLow, 0); aTrDeEdgeEntries.sort(); // here we know we have exactly four edges, and they do not cut, touch or // intersect. This makes processing much easier. Get the first two as start // edges for the thought trapezoid basegfx::trapezoidhelper::TrDeEdgeEntries::iterator aCurrent(aTrDeEdgeEntries.begin()); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft(*aCurrent++); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight(*aCurrent++); const bool bEndOnSameLine(fTools::equal(aLeft.getEnd().getY(), aRight.getEnd().getY())); if(bEndOnSameLine) { // create two triangle trapezoids ro_Result.emplace_back( aLeft.getStart().getX(), aRight.getStart().getX(), aLeft.getStart().getY(), aLeft.getEnd().getX(), aRight.getEnd().getX(), aLeft.getEnd().getY()); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); ro_Result.emplace_back( aLeft2.getStart().getX(), aRight2.getStart().getX(), aLeft2.getStart().getY(), aLeft2.getEnd().getX(), aRight2.getEnd().getX(), aLeft2.getEnd().getY()); } else { // create three trapezoids. Check which edge is longer and // correct accordingly const bool bLeftIsLonger(fTools::more(aLeft.getEnd().getY(), aRight.getEnd().getY())); if(bLeftIsLonger) { basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); const B2DPoint aSplitLeft(aLeft.getCutPointForGivenY(aRight.getEnd().getY())); const B2DPoint aSplitRight(aRight2.getCutPointForGivenY(aLeft.getEnd().getY())); ro_Result.emplace_back( aLeft.getStart().getX(), aRight.getStart().getX(), aLeft.getStart().getY(), aSplitLeft.getX(), aRight.getEnd().getX(), aRight.getEnd().getY()); ro_Result.emplace_back( aSplitLeft.getX(), aRight.getEnd().getX(), aRight.getEnd().getY(), aLeft2.getStart().getX(), aSplitRight.getX(), aLeft2.getStart().getY()); ro_Result.emplace_back( aLeft2.getStart().getX(), aSplitRight.getX(), aLeft2.getStart().getY(), aLeft2.getEnd().getX(), aRight2.getEnd().getX(), aLeft2.getEnd().getY()); } else { basegfx::trapezoidhelper::TrDeEdgeEntries::reference aLeft2(*aCurrent++); basegfx::trapezoidhelper::TrDeEdgeEntries::reference aRight2(*aCurrent++); const B2DPoint aSplitRight(aRight.getCutPointForGivenY(aLeft.getEnd().getY())); const B2DPoint aSplitLeft(aLeft2.getCutPointForGivenY(aRight.getEnd().getY())); ro_Result.emplace_back( aLeft.getStart().getX(), aRight.getStart().getX(), aLeft.getStart().getY(), aLeft.getEnd().getX(), aSplitRight.getX(), aLeft.getEnd().getY()); ro_Result.emplace_back( aLeft.getEnd().getX(), aSplitRight.getX(), aLeft.getEnd().getY(), aSplitLeft.getX(), aRight.getEnd().getX(), aRight2.getStart().getY()); ro_Result.emplace_back( aSplitLeft.getX(), aRight.getEnd().getX(), aRight2.getStart().getY(), aLeft2.getEnd().getX(), aRight2.getEnd().getX(), aLeft2.getEnd().getY()); } } } } void createLineTrapezoidFromB2DPolygon( B2DTrapezoidVector& ro_Result, const B2DPolygon& rPolygon, double fLineWidth) { if(fTools::lessOrEqual(fLineWidth, 0.0)) { return; } // ensure there are no curves used B2DPolygon aSource(rPolygon); if(aSource.areControlPointsUsed()) { const double fPrecisionFactor = 0.25; aSource = adaptiveSubdivideByDistance( aSource, fLineWidth * fPrecisionFactor ); } const sal_uInt32 nPointCount(aSource.count()); if(!nPointCount) { return; } const sal_uInt32 nEdgeCount(aSource.isClosed() ? nPointCount : nPointCount - 1); B2DPoint aCurrent(aSource.getB2DPoint(0)); ro_Result.reserve(ro_Result.size() + (3 * nEdgeCount)); for(sal_uInt32 a(0); a < nEdgeCount; a++) { const sal_uInt32 nNextIndex((a + 1) % nPointCount); const B2DPoint aNext(aSource.getB2DPoint(nNextIndex)); createLineTrapezoidFromEdge(ro_Result, aCurrent, aNext, fLineWidth); aCurrent = aNext; } } } // end of namespace utils } // end of namespace basegfx /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ewer'>private/pranavk/modernize_gtktiledviewer LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-10-27 23:18:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-10-28 08:03:52 +0100
commit40fa3a61ac7dbe2ba73b5ee71bb85cc3bb4a27af (patch)
tree26f9d288b5434f5e23980053dab9d5a57749b60e
parentc4967928475f2be20ac2d79e3fa84ac435a7e560 (diff)
Extend loplugin:elidestringvar to OString
(In VisitVarDecl, filtering out AbstractConditionalOperator avoids an unhelpful > ~/lo/core/vcl/source/pdf/XmpMetadata.cxx:63:32: error: replace single use of literal 'rtl::OString' variable with a literal [loplugin:elidestringvar] > aXmlWriter.content(sPdfConformance); > ^~~~~~~~~~~~~~~ > ~/lo/core/vcl/source/pdf/XmpMetadata.cxx:52:21: note: literal 'rtl::OString' variable defined here [loplugin:elidestringvar] > OString sPdfConformance = (mnPDF_A == 1) ? "A" : "B"; > ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) Change-Id: I7d0410f04827d79b4b526752917c37d33cad2671 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104911 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--chart2/qa/extras/chart2geometry.cxx32
-rw-r--r--comphelper/qa/string/test_string.cxx12
-rw-r--r--compilerplugins/clang/elidestringvar.cxx47
-rw-r--r--compilerplugins/clang/test/elidestringvar.cxx12
-rw-r--r--cui/source/dialogs/AdditionsDialog.cxx4
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx25
-rw-r--r--sal/qa/OStringBuffer/rtl_OStringBuffer.cxx59
-rw-r--r--sal/qa/rtl/digest/rtl_digest.cxx18
-rw-r--r--sal/qa/rtl/oustring/rtl_OUString2.cxx78
-rw-r--r--sal/qa/rtl/uri/rtl_Uri.cxx3
-rw-r--r--sc/qa/unit/copy_paste_test.cxx3
-rw-r--r--sc/qa/unit/screenshots/screenshots.cxx3
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx8
-rw-r--r--sd/qa/unit/dialogs-test.cxx4
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx6
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx4
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx10
-rw-r--r--sd/source/ui/remotecontrol/Communicator.cxx5
-rw-r--r--sfx2/source/bastyp/frmhtmlw.cxx5
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx8
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx10
-rw-r--r--sw/source/filter/html/wrthtml.cxx4
23 files changed, 145 insertions, 218 deletions
diff --git a/chart2/qa/extras/chart2geometry.cxx b/chart2/qa/extras/chart2geometry.cxx
index be6d842d7780..08e909162766 100644
--- a/chart2/qa/extras/chart2geometry.cxx
+++ b/chart2/qa/extras/chart2geometry.cxx
@@ -296,9 +296,9 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
// Find transparency gradient name
xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sChartPath(
+ const OUString sOUChartStyleName = getXPathContent(
+ pXmlDoc,
"//office:document-content/office:body/office:chart/chart:chart/@chart:style-name");
- const OUString sOUChartStyleName = getXPathContent(pXmlDoc, sChartPath);
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -310,9 +310,8 @@ void Chart2GeometryTest::testTdf128345ChartArea_CG_TS_import()
// Verify the content of the opacity definition
xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc2);
- const OString sOpacityPath("//office:document-styles/office:styles/draw:opacity");
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
- const OString sStart(sOpacityPath + "[" + sAttribute);
+ const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
assertXPath(pXmlDoc2, sStart + "]", 1);
assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
assertXPath(pXmlDoc2, sStart + " and @draw:start='30%']");
@@ -348,9 +347,9 @@ void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
// Find transparency gradient name
xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sChartPath("//office:document-content/office:body/office:chart/chart:chart/"
- "chart:plot-area/chart:wall/@chart:style-name");
- const OUString sOUChartStyleName = getXPathContent(pXmlDoc, sChartPath);
+ const OUString sOUChartStyleName
+ = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
+ "chart:plot-area/chart:wall/@chart:style-name");
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -362,9 +361,8 @@ void Chart2GeometryTest::testTdf128345ChartWall_CS_TG_import()
// Verify content of the opacity definition
xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc2);
- const OString sOpacityPath("//office:document-styles/office:styles/draw:opacity");
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
- const OString sStart(sOpacityPath + "[" + sAttribute);
+ const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
assertXPath(pXmlDoc2, sStart + "]", 1);
assertXPath(pXmlDoc2, sStart + " and @draw:style='linear']");
assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
@@ -400,9 +398,9 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
// Find transparency gradient name
xmlDocUniquePtr pXmlDoc = parseExport("Object 1/content.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc);
- const OString sChartPath("//office:document-content/office:body/office:chart/chart:chart/"
- "chart:legend/@chart:style-name");
- const OUString sOUChartStyleName = getXPathContent(pXmlDoc, sChartPath);
+ const OUString sOUChartStyleName
+ = getXPathContent(pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/"
+ "chart:legend/@chart:style-name");
const OString sStylePath(
"//office:document-content/office:automatic-styles/style:style[@style:name='"
+ OU2O(sOUChartStyleName) + "']");
@@ -414,9 +412,8 @@ void Chart2GeometryTest::testTdf128345Legend_CS_TG_axial_import()
// Verify content of the opacity definition
xmlDocUniquePtr pXmlDoc2 = parseExport("Object 1/styles.xml", "impress8");
CPPUNIT_ASSERT(pXmlDoc2);
- const OString sOpacityPath("//office:document-styles/office:styles/draw:opacity");
const OString sAttribute("@draw:name='" + OU2O(sOUOpacityName) + "'");
- const OString sStart(sOpacityPath + "[" + sAttribute);
+ const OString sStart("//office:document-styles/office:styles/draw:opacity[" + sAttribute);
assertXPath(pXmlDoc2, sStart + "]", 1);
assertXPath(pXmlDoc2, sStart + " and @draw:style='axial']");
assertXPath(pXmlDoc2, sStart + " and @draw:start='0%']");
@@ -517,10 +514,9 @@ void Chart2GeometryTest::testTdf135366LabelExport()
CPPUNIT_ASSERT(pXmlDoc);
// Find label style
- const OString sLabelPath(
- "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
- "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
- const OUString sOULabelStyleName = getXPathContent(pXmlDoc, sLabelPath);
+ const OUString sOULabelStyleName = getXPathContent(
+ pXmlDoc, "//office:document-content/office:body/office:chart/chart:chart/chart:plot-area"
+ "/chart:series/chart:data-point[1]/chart:data-label/@chart:style-name");
// Verify content of graphic properties of label style
const OString sStylePath(
diff --git a/comphelper/qa/string/test_string.cxx b/comphelper/qa/string/test_string.cxx
index aa427bea8a65..faedac30260f 100644
--- a/comphelper/qa/string/test_string.cxx
+++ b/comphelper/qa/string/test_string.cxx
@@ -75,14 +75,11 @@ void TestString::testDecimalStringToNumber()
void TestString::testIsdigitAsciiString()
{
- OString s1("1234");
- CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(s1));
+ CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(OString("1234")));
- OString s2("1A34");
- CPPUNIT_ASSERT_EQUAL(false, comphelper::string::isdigitAsciiString(s2));
+ CPPUNIT_ASSERT_EQUAL(false, comphelper::string::isdigitAsciiString(OString("1A34")));
- OString s3;
- CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(s3));
+ CPPUNIT_ASSERT_EQUAL(true, comphelper::string::isdigitAsciiString(OString()));
}
using namespace ::com::sun::star;
@@ -369,8 +366,7 @@ void TestString::testTokenCount()
void TestString::testReverseString()
{
- OString aIn("ABC");
- OString aOut = ::comphelper::string::reverseString(aIn);
+ OString aOut = ::comphelper::string::reverseString(OString("ABC"));
CPPUNIT_ASSERT_EQUAL(OString("CBA"), aOut);
}
diff --git a/compilerplugins/clang/elidestringvar.cxx b/compilerplugins/clang/elidestringvar.cxx
index 27b0e5ab77bd..6fd57c44ff4f 100644
--- a/compilerplugins/clang/elidestringvar.cxx
+++ b/compilerplugins/clang/elidestringvar.cxx
@@ -17,7 +17,7 @@
#include "compat.hxx"
#include "plugin.hxx"
-// Find cases where a variable of a string type (at least for now, only OUString) is initialized
+// Find cases where a variable of a OString/OUString type is initialized
// with a literal value (incl. as an empty string) and used only once. Conservatively this only
// covers local non-static variables that are not defined outside of the loop (if any) in which they
// are used, as other cases may deliberately use the variable for performance (or even correctness,
@@ -37,6 +37,13 @@
namespace
{
+bool isStringType(QualType type)
+{
+ loplugin::TypeCheck const c(type);
+ return c.Class("OString").Namespace("rtl").GlobalNamespace()
+ || c.Class("OUString").Namespace("rtl").GlobalNamespace();
+}
+
class ElideStringVar : public loplugin::FilteringPlugin<ElideStringVar>
{
public:
@@ -67,12 +74,12 @@ public:
continue;
}
report(DiagnosticsEngine::Warning,
- "replace single use of literal OUString variable with a literal",
+ "replace single use of literal %0 variable with a literal",
(*var.second.singleUse)->getExprLoc())
- << (*var.second.singleUse)->getSourceRange();
- report(DiagnosticsEngine::Note, "literal OUString variable defined here",
+ << var.first->getType() << (*var.second.singleUse)->getSourceRange();
+ report(DiagnosticsEngine::Note, "literal %0 variable defined here",
var.first->getLocation())
- << var.first->getSourceRange();
+ << var.first->getType() << var.first->getSourceRange();
}
}
@@ -94,10 +101,7 @@ public:
{
return true;
}
- if (!loplugin::TypeCheck(decl->getType())
- .Class("OUString")
- .Namespace("rtl")
- .GlobalNamespace())
+ if (!isStringType(decl->getType()))
{
return true;
}
@@ -110,10 +114,7 @@ public:
{
return true;
}
- if (!loplugin::TypeCheck(e1->getType())
- .Class("OUString")
- .Namespace("rtl")
- .GlobalNamespace())
+ if (!isStringType(e1->getType()))
{
return true;
}
@@ -124,10 +125,9 @@ public:
case 1:
{
auto const e2 = e1->getArg(0);
- if (loplugin::TypeCheck(e2->getType())
- .Class("OUStringLiteral")
- .Namespace("rtl")
- .GlobalNamespace())
+ loplugin::TypeCheck const c(e2->getType());
+ if (c.Class("OStringLiteral").Namespace("rtl").GlobalNamespace()
+ || c.Class("OUStringLiteral").Namespace("rtl").GlobalNamespace())
{
break;
}
@@ -139,14 +139,19 @@ public:
}
case 2:
{
- auto const t = e1->getArg(0)->getType();
+ auto const e2 = e1->getArg(0);
+ auto const t = e2->getType();
if (!(t.isConstQualified() && t->isConstantArrayType()))
{
return true;
}
- auto const e2 = e1->getArg(1);
- if (!(isa<CXXDefaultArgExpr>(e2)
- && loplugin::TypeCheck(e2->getType())
+ if (isa<AbstractConditionalOperator>(e2->IgnoreParenImpCasts()))
+ {
+ return true;
+ }
+ auto const e3 = e1->getArg(1);
+ if (!(isa<CXXDefaultArgExpr>(e3)
+ && loplugin::TypeCheck(e3->getType())
.Struct("Dummy")
.Namespace("libreoffice_internal")
.Namespace("rtl")
diff --git a/compilerplugins/clang/test/elidestringvar.cxx b/compilerplugins/clang/test/elidestringvar.cxx
index 1835c183bb39..3e8e6592bbae 100644
--- a/compilerplugins/clang/test/elidestringvar.cxx
+++ b/compilerplugins/clang/test/elidestringvar.cxx
@@ -14,25 +14,25 @@
OUString f(sal_Unicode c, int n)
{
OUString s1(c);
- // expected-note@+1 {{literal OUString variable defined here [loplugin:elidestringvar]}}
+ // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
OUString s2('a');
- // expected-note@+1 {{literal OUString variable defined here [loplugin:elidestringvar]}}
+ // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
OUString s3(u'a');
static constexpr OUStringLiteral s4lit(u"a");
- // expected-note@+1 {{literal OUString variable defined here [loplugin:elidestringvar]}}
+ // expected-note@+1 {{literal 'rtl::OUString' variable defined here [loplugin:elidestringvar]}}
OUString s4 = s4lit;
switch (n)
{
case 1:
return s1;
case 2:
- // expected-error@+1 {{replace single use of literal OUString variable with a literal [loplugin:elidestringvar]}}
+ // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
return s2;
case 3:
- // expected-error@+1 {{replace single use of literal OUString variable with a literal [loplugin:elidestringvar]}}
+ // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
return s3;
default:
- // expected-error@+1 {{replace single use of literal OUString variable with a literal [loplugin:elidestringvar]}}
+ // expected-error@+1 {{replace single use of literal 'rtl::OUString' variable with a literal [loplugin:elidestringvar]}}
return s4;
}
}
diff --git a/cui/source/dialogs/AdditionsDialog.cxx b/cui/source/dialogs/AdditionsDialog.cxx
index cf9a605d5970..dd994839681a 100644
--- a/cui/source/dialogs/AdditionsDialog.cxx
+++ b/cui/source/dialogs/AdditionsDialog.cxx
@@ -511,9 +511,7 @@ AdditionsDialog::AdditionsDialog(weld::Window* pParent, const OUString& sAdditio
m_sTag = "allextensions"; // Means empty parameter
}
//FIXME: Temporary URL
- OString sPrefixURL = "https://yusufketen.com/api/";
- OString sSuffixURL = ".json";
- OString rURL = sPrefixURL + m_sTag + sSuffixURL;
+ OString rURL = "https://yusufketen.com/api/" + m_sTag + ".json";
m_sURL = rURL;
m_xExtensionManager
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 2d338d20014a..b2015dbafcf2 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -1783,8 +1783,7 @@ void DesktopLOKTest::testInput()
Scheduler::ProcessEventsToIdle();
char* pText = pDocument->pClass->getTextSelection(pDocument, "text/plain;charset=utf-8", nullptr);
CPPUNIT_ASSERT(pText != nullptr);
- OString aLovely("far beyond lovely ");
- CPPUNIT_ASSERT_EQUAL(aLovely, OString(pText));
+ CPPUNIT_ASSERT_EQUAL(OString("far beyond lovely "), OString(pText));
free(pText);
}
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 04603bc03f77..1a3e27ee3afd 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -1207,8 +1207,6 @@ void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D(
// support for FIELD_SEQ_BEGIN, FIELD_SEQ_END and URL. It wraps text primitives (but is not limited to)
// thus do the MetafileAction embedding stuff but just handle recursively.
const OString aCommentStringCommon("FIELD_SEQ_BEGIN");
- const OString aCommentStringPage("FIELD_SEQ_BEGIN;PageField");
- const OString aCommentStringEnd("FIELD_SEQ_END");
OUString aURL;
switch (rFieldPrimitive.getType())
@@ -1220,7 +1218,7 @@ void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D(
}
case drawinglayer::primitive2d::FIELD_TYPE_PAGE:
{
- mpMetaFile->AddAction(new MetaCommentAction(aCommentStringPage));
+ mpMetaFile->AddAction(new MetaCommentAction("FIELD_SEQ_BEGIN;PageField"));
break;
}
case drawinglayer::primitive2d::FIELD_TYPE_URL:
@@ -1244,7 +1242,7 @@ void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D(
process(rContent);
// for the end comment the type is not relevant yet, they are all the same. Just add.
- mpMetaFile->AddAction(new MetaCommentAction(aCommentStringEnd));
+ mpMetaFile->AddAction(new MetaCommentAction("FIELD_SEQ_END"));
if (!(mpPDFExtOutDevData
&& drawinglayer::primitive2d::FIELD_TYPE_URL == rFieldPrimitive.getType()))
@@ -1266,20 +1264,14 @@ void VclMetafileProcessor2D::processTextHierarchyFieldPrimitive2D(
void VclMetafileProcessor2D::processTextHierarchyLinePrimitive2D(
const primitive2d::TextHierarchyLinePrimitive2D& rLinePrimitive)
{
- const OString aCommentString("XTEXT_EOL");
-
// process recursively and add MetaFile comment
process(rLinePrimitive);
- mpMetaFile->AddAction(new MetaCommentAction(aCommentString));
+ mpMetaFile->AddAction(new MetaCommentAction("XTEXT_EOL"));
}
void VclMetafileProcessor2D::processTextHierarchyBulletPrimitive2D(
const primitive2d::TextHierarchyBulletPrimitive2D& rBulletPrimitive)
{
- // in Outliner::PaintBullet(), a MetafileComment for bullets is added, too. The
- // "XTEXT_EOC" is used, use here, too.
- const OString aCommentString("XTEXT_EOC");
-
// this is a part of list item, start LILabel ( = bullet)
if (mbInListItem)
{
@@ -1289,7 +1281,9 @@ void VclMetafileProcessor2D::processTextHierarchyBulletPrimitive2D(
// process recursively and add MetaFile comment
process(rBulletPrimitive);
- mpMetaFile->AddAction(new MetaCommentAction(aCommentString));
+ // in Outliner::PaintBullet(), a MetafileComment for bullets is added, too. The
+ // "XTEXT_EOC" is used, use here, too.
+ mpMetaFile->AddAction(new MetaCommentAction("XTEXT_EOC"));
if (mbInListItem)
{
@@ -1400,11 +1394,8 @@ void VclMetafileProcessor2D::processTextHierarchyParagraphPrimitive2D(
void VclMetafileProcessor2D::processTextHierarchyBlockPrimitive2D(
const primitive2d::TextHierarchyBlockPrimitive2D& rBlockPrimitive)
{
- const OString aCommentStringA("XTEXT_PAINTSHAPE_BEGIN");
- const OString aCommentStringB("XTEXT_PAINTSHAPE_END");
-
// add MetaFile comment, process recursively and add MetaFile comment
- mpMetaFile->AddAction(new MetaCommentAction(aCommentStringA));
+ mpMetaFile->AddAction(new MetaCommentAction("XTEXT_PAINTSHAPE_BEGIN"));
process(rBlockPrimitive);
if (mnCurrentOutlineLevel >= 0)
@@ -1416,7 +1407,7 @@ void VclMetafileProcessor2D::processTextHierarchyBlockPrimitive2D(
}
}
- mpMetaFile->AddAction(new MetaCommentAction(aCommentStringB));
+ mpMetaFile->AddAction(new MetaCommentAction("XTEXT_PAINTSHAPE_END"));
}
void VclMetafileProcessor2D::processTextSimplePortionPrimitive2D(
diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
index c8a7ccce2a89..cfc73ca42dfb 100644
--- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
+++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx
@@ -211,9 +211,8 @@ namespace rtl_OStringBuffer
void makeStringAndClear_001()
{
OStringBuffer aStrBuf1;
- OString aStr1;
- bool lastRes = (aStrBuf1.makeStringAndClear() == aStr1 );
+ bool lastRes = aStrBuf1.makeStringAndClear().isEmpty();
CPPUNIT_ASSERT_MESSAGE
(
@@ -236,9 +235,8 @@ namespace rtl_OStringBuffer
void makeStringAndClear_002()
{
OStringBuffer aStrBuf2(26);
- OString aStr2;
- bool lastRes = (aStrBuf2.makeStringAndClear() == aStr2 );
+ bool lastRes = aStrBuf2.makeStringAndClear().isEmpty();
CPPUNIT_ASSERT_MESSAGE
(
@@ -975,7 +973,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[0] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 32;
sal_Int32 input = 0;
@@ -984,7 +981,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength equal to 0",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1035,7 +1032,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[1] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 17;
sal_Int32 input = 0;
@@ -1044,7 +1040,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength less than the length of OUStringBuffer(1)",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1055,7 +1051,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[2] );
sal_Int32 expVal1 = 20;
- OString expVal2;
sal_Int32 expVal3 = 20;
sal_Int32 input = 20;
@@ -1064,7 +1059,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the capacity of OStringBuffer()",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1075,7 +1070,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[2] );
sal_Int32 expVal1 = 3;
- OString expVal2;
sal_Int32 expVal3 = 16;
sal_Int32 input = 3;
@@ -1084,7 +1078,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the length of OStringBuffer()",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1095,7 +1089,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[2] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 16;
sal_Int32 input = 0;
@@ -1104,7 +1097,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the length of OStringBuffer()",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1115,7 +1108,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[3] );
sal_Int32 expVal1 = 20;
- OString expVal2;
sal_Int32 expVal3 = 20;
sal_Int32 input = 20;
@@ -1124,7 +1116,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the capacity of OStringBuffer("")",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1135,7 +1127,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[3] );
sal_Int32 expVal1 = 5;
- OString expVal2;
sal_Int32 expVal3 = 16;
sal_Int32 input = 5;
@@ -1144,7 +1135,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the length of OStringBuffer("")",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1155,7 +1146,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[3] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 16;
sal_Int32 input = 0;
@@ -1164,7 +1154,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength less than the length of OStringBuffer("")",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1175,7 +1165,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[4] );
sal_Int32 expVal1 = 20;
- OString expVal2;
sal_Int32 expVal3 = 20;
sal_Int32 input = 20;
@@ -1184,7 +1173,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the length of OStringBuffer(\0)",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1195,7 +1184,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[4] );
sal_Int32 expVal1 = 5;
- OString expVal2;
sal_Int32 expVal3 = 17;
sal_Int32 input = 5;
@@ -1204,7 +1192,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength more than the length of OStringBuffer(\0)",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1215,7 +1203,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[4] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 17;
sal_Int32 input = 0;
@@ -1224,7 +1211,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength less than the length of OStringBuffer(\0)",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1315,7 +1302,6 @@ namespace rtl_OStringBuffer
{
OStringBuffer aStrBuf( arrOUS[5] );
sal_Int32 expVal1 = 0;
- OString expVal2;
sal_Int32 expVal3 = 48;
sal_Int32 input = 0;
@@ -1324,7 +1310,7 @@ namespace rtl_OStringBuffer
CPPUNIT_ASSERT_MESSAGE
(
"newLength equal to 0",
- aStrBuf.getStr() == expVal2 &&
+ aStrBuf.getStr()[0] == '\0' &&
aStrBuf.getLength() == expVal1 &&
aStrBuf.getCapacity() == expVal3
);
@@ -1443,6 +1429,8 @@ namespace rtl_OStringBuffer
{
OString arrOUS[5];
+ OString empty; // silence loplugin
+
public:
void setUp() override
{
@@ -1508,9 +1496,8 @@ namespace rtl_OStringBuffer
{
OString expVal( kTestStr7 );
OStringBuffer aStrBuf( arrOUS[0] );
- OString input2;
- aStrBuf.append( input2 );
+ aStrBuf.append( empty );
CPPUNIT_ASSERT_MESSAGE
(
@@ -1576,9 +1563,8 @@ namespace rtl_OStringBuffer
{
OString expVal;
OStringBuffer aStrBuf( arrOUS[1] );
- OString input2;
- aStrBuf.append( input2 );
+ aStrBuf.append( empty );
CPPUNIT_ASSERT_MESSAGE
(
@@ -1644,9 +1630,8 @@ namespace rtl_OStringBuffer
{
OString expVal;
OStringBuffer aStrBuf( arrOUS[2] );
- OString input2;
- aStrBuf.append( input2 );
+ aStrBuf.append( empty );
CPPUNIT_ASSERT_MESSAGE
(
@@ -1712,9 +1697,8 @@ namespace rtl_OStringBuffer
{
OString expVal;
OStringBuffer aStrBuf( arrOUS[3] );
- OString input2;
- aStrBuf.append( input2 );
+ aStrBuf.append( empty );
CPPUNIT_ASSERT_MESSAGE
(
@@ -1780,9 +1764,8 @@ namespace rtl_OStringBuffer
{
OString expVal( kTestStr28 );
OStringBuffer aStrBuf( arrOUS[4] );
- OString input2;
- aStrBuf.append( input2 );
+ aStrBuf.append( empty );
CPPUNIT_ASSERT_MESSAGE
(
diff --git a/sal/qa/rtl/digest/rtl_digest.cxx b/sal/qa/rtl/digest/rtl_digest.cxx
index d890f924ddb1..3d27ba52c9c7 100644
--- a/sal/qa/rtl/digest/rtl_digest.cxx
+++ b/sal/qa/rtl/digest/rtl_digest.cxx
@@ -194,22 +194,16 @@ public:
void testEqual()
{
{
- OString aMsg1 = sSampleString;
- OString aMsg2 = sSampleString;
-
- OString aSum1 = getDigest(aMsg1, rtl_Digest_AlgorithmMD5);
- OString aSum2 = getDigest(aMsg2, rtl_Digest_AlgorithmMD5);
+ OString aSum1 = getDigest(sSampleString, rtl_Digest_AlgorithmMD5);
+ OString aSum2 = getDigest(sSampleString, rtl_Digest_AlgorithmMD5);
CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aSum1.getLength() == 32 && aSum2.getLength() == 32 );
CPPUNIT_ASSERT_EQUAL_MESSAGE("source is the same, dest must be also the same", aSum1, aSum2);
}
{
- OString aMsg1 = sSampleString;
- OString aMsg2 = sSampleString_only_one_diff;
-
- OString aSum1 = getDigest(aMsg1, rtl_Digest_AlgorithmMD5);
- OString aSum2 = getDigest(aMsg2, rtl_Digest_AlgorithmMD5);
+ OString aSum1 = getDigest(sSampleString, rtl_Digest_AlgorithmMD5);
+ OString aSum2 = getDigest(sSampleString_only_one_diff, rtl_Digest_AlgorithmMD5);
CPPUNIT_ASSERT_MESSAGE("md5sum must have a length", aSum1.getLength() == 32 && aSum2.getLength() == 32 );
CPPUNIT_ASSERT_MESSAGE("differ only in one char", aSum1 != aSum2);
@@ -380,13 +374,11 @@ public:
std::unique_ptr<sal_uInt8[]> pResult(new sal_uInt8[RTL_DIGEST_LENGTH_SHA1]);
- OString sExpected = "06f460d693aecdd3b5cbe8365408eccfc570f32a";
-
rtl_digest_SHA1(aData, sizeof(aData), pResult.get(), RTL_DIGEST_LENGTH_SHA1);
OString sKey = createHex(pResult.get(), RTL_DIGEST_LENGTH_SHA1);
- CPPUNIT_ASSERT_EQUAL(sExpected, sKey);
+ CPPUNIT_ASSERT_EQUAL(OString("06f460d693aecdd3b5cbe8365408eccfc570f32a"), sKey);
}
// tdf#114939, verify that rtl_digest_SHA1 computes broken results for certain input (which
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index cbfdd800f1c3..516378dc14a7 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -296,65 +296,53 @@ public:
void toDouble_test_3()
{
- OString sValue("3");
- toDouble_test(sValue);
+ toDouble_test("3");
}
void toDouble_test_3_5()
{
- OString sValue("3.5");
- toDouble_test(sValue);
+ toDouble_test("3.5");
}
void toDouble_test_3_0625()
{
- OString sValue("3.0625");
- toDouble_test(sValue);
+ toDouble_test("3.0625");
}
void toDouble_test_pi()
{
// value from http://www.angio.net/pi/digits/50.txt
- OString sValue("3.141592653589793238462643383279502884197169399375");
- toDouble_test(sValue);
+ toDouble_test("3.141592653589793238462643383279502884197169399375");
}
void toDouble_test_1()
{
- OString sValue("1");
- toDouble_test(sValue);
+ toDouble_test("1");
}
void toDouble_test_10()
{
- OString sValue("10");
- toDouble_test(sValue);
+ toDouble_test("10");
}
void toDouble_test_100()
{
- OString sValue("100");
- toDouble_test(sValue);
+ toDouble_test("100");
}
void toDouble_test_1000()
{
- OString sValue("1000");
- toDouble_test(sValue);
+ toDouble_test("1000");
}
void toDouble_test_10000()
{
- OString sValue("10000");
- toDouble_test(sValue);
+ toDouble_test("10000");
}
void toDouble_test_1e99()
{
- OString sValue("1e99");
- toDouble_test(sValue);
+ toDouble_test("1e99");
}
void toDouble_test_1e_n99()
{
- OString sValue("1e-99");
- toDouble_test(sValue);
+ toDouble_test("1e-99");
}
void toDouble_test_1e308()
{
- OString sValue("1e308");
- toDouble_test(sValue);
+ toDouble_test("1e308");
}
// Change the following lines only, if you add, remove or rename
@@ -424,75 +412,61 @@ public:
void toFloat_test_3()
{
- OString sValue("3");
- toFloat_test(sValue);
+ toFloat_test("3");
}
void toFloat_test_3_5()
{
- OString sValue("3.5");
- toFloat_test(sValue);
+ toFloat_test("3.5");
}
void toFloat_test_3_0625()
{
- OString sValue("3.0625");
- toFloat_test(sValue);
+ toFloat_test("3.0625");
}
void toFloat_test_3_0625_e()
{
- OString sValue("3.0625e-4");
- toFloat_test(sValue);
+ toFloat_test("3.0625e-4");
}
void toFloat_test_pi()
{
// value from http://www.angio.net/pi/digits/50.txt
- OString sValue("3.141592653589793238462643383279502884197169399375");
- toFloat_test(sValue);
+ toFloat_test("3.141592653589793238462643383279502884197169399375");
}
void toFloat_test_1()
{
- OString sValue("1");
- toFloat_test(sValue);
+ toFloat_test("1");
}
void toFloat_test_10()
{
- OString sValue("10");
- toFloat_test(sValue);
+ toFloat_test("10");
}
void toFloat_test_100()
{
- OString sValue("100");
- toFloat_test(sValue);
+ toFloat_test("100");
}
void toFloat_test_1000()
{
- OString sValue("1000");
- toFloat_test(sValue);
+ toFloat_test("1000");
}
void toFloat_test_10000()
{
- OString sValue("10000");
- toFloat_test(sValue);
+ toFloat_test("10000");
}
void toFloat_test_mix()
{
- OString sValue("456789321455.123456789012");
- toFloat_test(sValue);
+ toFloat_test("456789321455.123456789012");
}
void toFloat_test_1e99()
{
- OString sValue("1e99");
- toFloat_test(sValue);
+ toFloat_test("1e99");
}
void toFloat_test_1e_n99()
{
- OString sValue("1e-9");
- toFloat_test(sValue);
+ toFloat_test("1e-9");
}
void toFloat_test_1e308()
{
- OString sValue("1e308");
- toFloat_test(sValue);
+ toFloat_test("1e308");
}
// Change the following lines only, if you add, remove or rename
diff --git a/sal/qa/rtl/uri/rtl_Uri.cxx b/sal/qa/rtl/uri/rtl_Uri.cxx
index 81ec983450f5..1084926c65bb 100644
--- a/sal/qa/rtl/uri/rtl_Uri.cxx
+++ b/sal/qa/rtl/uri/rtl_Uri.cxx
@@ -47,8 +47,7 @@ namespace Stringtest
void test_FromUTF8_001()
{
// string --> ustring
- OString sStrUTF8("h%C3%A4llo");
- OUString suStrUTF8 = OStringToOUString(sStrUTF8, RTL_TEXTENCODING_ASCII_US);
+ OUString suStrUTF8 = OStringToOUString("h%C3%A4llo", RTL_TEXTENCODING_ASCII_US);
// UTF8 --> real ustring
OUString suStr_UriDecodeToIuri = rtl::Uri::decode(suStrUTF8, rtl_UriDecodeToIuri, RTL_TEXTENCODING_UTF8);
diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx
index 54202137d0de..527afccaafe6 100644
--- a/sc/qa/unit/copy_paste_test.cxx
+++ b/sc/qa/unit/copy_paste_test.cxx
@@ -407,9 +407,8 @@ void ScCopyPasteTest::testTdf107394()
ScImportExport aObj(rDoc, ScAddress(0,0,0));
aObj.SetImportBroadcast(true);
- OString aHTML("<pre>First\nVery long sentence.</pre>");
SvMemoryStream aStream;
- aStream.WriteOString(aHTML);
+ aStream.WriteOString("<pre>First\nVery long sentence.</pre>");
aStream.Seek(0);
CPPUNIT_ASSERT(aObj.ImportStream(aStream, OUString(), SotClipboardFormatId::HTML));
diff --git a/sc/qa/unit/screenshots/screenshots.cxx b/sc/qa/unit/screenshots/screenshots.cxx