/* -*- 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 .
*/
/* TextRanger::SetVertical(..) If there's is a change in the writing direction, the cache has to be cleared.
*/ void TextRanger::SetVertical( bool bNew )
{ if( IsVertical() != bNew )
{
bVertical = bNew;
mRangeCache.clear();
}
}
// Here the line is held inside a large rectangle for "simple" // contour wrap. Currently (April 1999) the EditEngine evaluates // only the first rectangle. If it one day is able to output a line // in several parts, it may be advisable to delete the following lines. if( pTextRanger->IsSimple() && pLongArr->size() > 2 )
pLongArr->erase( pLongArr->begin() + 1, pLongArr->end() - 1 );
}
void SvxBoundArgs::Concat( const tools::PolyPolygon* pPoly )
{
SetConcat( true );
DBG_ASSERT( pPoly, "Nothing to do?" );
std::deque<tools::Long>* pOld = pLongArr;
pLongArr = new std::deque<tools::Long>;
aBoolArr.clear();
bInner = false;
Calc( *pPoly ); // Note that this updates pLongArr, which is why we swapped it out earlier.
std::deque<tools::Long>::size_type nCount = pLongArr->size();
std::deque<tools::Long>::size_type nIdx = 0;
std::deque<tools::Long>::size_type i = 0; bool bSubtract = pTextRanger->IsInner(); while( i < nCount )
{
std::deque<tools::Long>::size_type nOldCount = pOld->size(); if( nIdx == nOldCount )
{ // Reached the end of the old Array... if( !bSubtract )
pOld->insert( pOld->begin() + nIdx, pLongArr->begin() + i, pLongArr->end() ); break;
}
tools::Long nLeft = (*pLongArr)[ i++ ];
tools::Long nRight = (*pLongArr)[ i++ ];
std::deque<tools::Long>::size_type nLeftPos = nIdx + 1; while( nLeftPos < nOldCount && nLeft > (*pOld)[ nLeftPos ] )
nLeftPos += 2; if( nLeftPos >= nOldCount )
{ // The current interval belongs to the end of the old array ... if( !bSubtract )
pOld->insert( pOld->begin() + nOldCount, pLongArr->begin() + i - 2, pLongArr->end() ); break;
}
std::deque<tools::Long>::size_type nRightPos = nLeftPos - 1; while( nRightPos < nOldCount && nRight >= (*pOld)[ nRightPos ] )
nRightPos += 2; if( nRightPos < nLeftPos )
{ // The current interval belongs between two old intervals if( !bSubtract )
pOld->insert( pOld->begin() + nRightPos, pLongArr->begin() + i - 2, pLongArr->begin() + i );
} elseif( bSubtract ) // Subtract, if necessary separate
{ const tools::Long nOld = (*pOld)[nLeftPos - 1]; if (nLeft > nOld)
{ // Now we split the left part... if( nLeft - 1 > nOld )
{
pOld->insert( pOld->begin() + nLeftPos - 1, nOld );
pOld->insert( pOld->begin() + nLeftPos, nLeft - 1 );
nLeftPos += 2;
nRightPos += 2;
}
} if( nRightPos - nLeftPos > 1 )
pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 ); if (++nRight >= (*pOld)[nLeftPos])
pOld->erase( pOld->begin() + nLeftPos - 1, pOld->begin() + nLeftPos + 1 ); else
(*pOld)[ nLeftPos - 1 ] = nRight;
} else// Merge
{ if( nLeft < (*pOld)[ nLeftPos - 1 ] )
(*pOld)[ nLeftPos - 1 ] = nLeft; if( nRight > (*pOld)[ nRightPos - 1 ] )
(*pOld)[ nRightPos - 1 ] = nRight; if( nRightPos - nLeftPos > 1 )
pOld->erase( pOld->begin() + nLeftPos, pOld->begin() + nRightPos - 1 );
}
nIdx = nLeftPos - 1;
} delete pLongArr;
}
/************************************************************************* * SvxBoundArgs::Area returns the area in which the point is located. * 0 = within the line * 1 = below, but within the upper edge * 2 = above, but within the lower edge * 5 = below the upper edge *10 = above the lower edge
*************************************************************************/
sal_uInt16 SvxBoundArgs::Area( const Point& rPt )
{
tools::Long nB = B( rPt ); if( nB >= nBottom )
{ if( nB >= nLower ) return 5; return 1;
} if( nB <= nTop )
{ if( nB <= nUpper ) return 10; return 2;
} return 0;
}
/************************************************************************* * lcl_Cut calculates the X-Coordinate of the distance (Pt1-Pt2) at the * Y-Coordinate nY. * It is assumed that the one of the points are located above and the other * one below the Y-Coordinate.
*************************************************************************/
std::deque<tools::Long>* TextRanger::GetTextRanges( const Range& rRange )
{
DBG_ASSERT( rRange.Min() || rRange.Max(), "Zero-Range not allowed, Bye Bye" ); //Can we find the result we need in the cache? for (auto & elem : mRangeCache)
{ if (elem.range == rRange) return &(elem.results);
} //Calculate a new result
RangeCacheItem rngCache(rRange);
SvxBoundArgs aArg( this, &(rngCache.results), rRange );
aArg.Calc( maPolyPolygon ); if( mpLinePolyPolygon )
aArg.Concat( &*mpLinePolyPolygon ); //Add new result to the cache
mRangeCache.push_back(std::move(rngCache)); if (mRangeCache.size() > nCacheSize)
mRangeCache.pop_front(); return &(mRangeCache.back().results);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.