[Libreoffice-commits] core.git: vcl/inc vcl/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 21 18:09:05 UTC 2021
vcl/inc/textlineinfo.hxx | 10 +++++----
vcl/source/gdi/pdfwriter_impl.cxx | 15 ++++++-------
vcl/source/outdev/text.cxx | 42 ++++++++++++++++++--------------------
3 files changed, 33 insertions(+), 34 deletions(-)
New commits:
commit a7f05c009aad9fb8c8872312929c473b55cb1454
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jul 21 13:35:17 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jul 21 20:08:30 2021 +0200
flatten vector in ImplMultiTextLineInfo
Change-Id: I30f40c3906c38d29bab7aeef0a9562bd96934a72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119329
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/inc/textlineinfo.hxx b/vcl/inc/textlineinfo.hxx
index 6b0e72ad36aa..0dc199bff64e 100644
--- a/vcl/inc/textlineinfo.hxx
+++ b/vcl/inc/textlineinfo.hxx
@@ -51,18 +51,20 @@ public:
ImplMultiTextLineInfo();
~ImplMultiTextLineInfo();
- void AddLine( ImplTextLineInfo* pLine );
+ void AddLine( const ImplTextLineInfo& );
void Clear();
- ImplTextLineInfo* GetLine( sal_Int32 nLine ) const
- { return mvLines[nLine].get(); }
+ const ImplTextLineInfo& GetLine( sal_Int32 nLine ) const
+ { return mvLines[nLine]; }
+ ImplTextLineInfo& GetLine( sal_Int32 nLine )
+ { return mvLines[nLine]; }
sal_Int32 Count() const { return mvLines.size(); }
private:
ImplMultiTextLineInfo( const ImplMultiTextLineInfo& ) = delete;
ImplMultiTextLineInfo& operator=( const ImplMultiTextLineInfo& ) = delete;
- std::vector<std::unique_ptr<ImplTextLineInfo>> mvLines;
+ std::vector<ImplTextLineInfo> mvLines;
};
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 5ca3dfd4cf25..ab7926c50b4e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6553,7 +6553,6 @@ void PDFWriterImpl::drawText( const tools::Rectangle& rRect, const OUString& rOr
if ( nStyle & DrawTextFlags::MultiLine )
{
ImplMultiTextLineInfo aMultiLineInfo;
- ImplTextLineInfo* pLineInfo;
sal_Int32 i;
sal_Int32 nFormatLines;
@@ -6573,8 +6572,8 @@ void PDFWriterImpl::drawText( const tools::Rectangle& rRect, const OUString& rOr
// handle last line
nFormatLines = nLines-1;
- pLineInfo = aMultiLineInfo.GetLine( nFormatLines );
- aLastLine = convertLineEnd(aStr.copy(pLineInfo->GetIndex()), LINEEND_LF);
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( nFormatLines );
+ aLastLine = convertLineEnd(aStr.copy(rLineInfo.GetIndex()), LINEEND_LF);
// replace line feed by space
aLastLine = aLastLine.replace('\n', ' ');
aLastLine = GetEllipsisString( aLastLine, nWidth, nStyle );
@@ -6592,13 +6591,13 @@ void PDFWriterImpl::drawText( const tools::Rectangle& rRect, const OUString& rOr
// draw all lines excluding the last
for ( i = 0; i < nFormatLines; i++ )
{
- pLineInfo = aMultiLineInfo.GetLine( i );
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( i );
if ( nStyle & DrawTextFlags::Right )
- aPos.AdjustX(nWidth-pLineInfo->GetWidth() );
+ aPos.AdjustX(nWidth-rLineInfo.GetWidth() );
else if ( nStyle & DrawTextFlags::Center )
- aPos.AdjustX((nWidth-pLineInfo->GetWidth())/2 );
- sal_Int32 nIndex = pLineInfo->GetIndex();
- sal_Int32 nLineLen = pLineInfo->GetLen();
+ aPos.AdjustX((nWidth-rLineInfo.GetWidth())/2 );
+ sal_Int32 nIndex = rLineInfo.GetIndex();
+ sal_Int32 nLineLen = rLineInfo.GetLen();
drawText( aPos, aStr, nIndex, nLineLen );
// mnemonics should not appear in documents,
// if the need arises, put them in here
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 9de93b342c53..25234b9f0341 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -58,9 +58,9 @@ ImplMultiTextLineInfo::~ImplMultiTextLineInfo()
{
}
-void ImplMultiTextLineInfo::AddLine( ImplTextLineInfo* pLine )
+void ImplMultiTextLineInfo::AddLine( const ImplTextLineInfo& rLine )
{
- mvLines.push_back(std::unique_ptr<ImplTextLineInfo>(pLine));
+ mvLines.push_back(rLine);
}
void ImplMultiTextLineInfo::Clear()
@@ -631,7 +631,7 @@ tools::Long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
if ( nLineWidth > nMaxLineWidth )
nMaxLineWidth = nLineWidth;
- rLineInfo.AddLine( new ImplTextLineInfo( nLineWidth, nPos, nBreakPos-nPos ) );
+ rLineInfo.AddLine( ImplTextLineInfo( nLineWidth, nPos, nBreakPos-nPos ) );
if ( nBreakPos == nPos )
nBreakPos++;
@@ -649,8 +649,8 @@ tools::Long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo,
#ifdef DBG_UTIL
for ( sal_Int32 nL = 0; nL < rLineInfo.Count(); nL++ )
{
- ImplTextLineInfo* pLine = rLineInfo.GetLine( nL );
- OUString aLine = rStr.copy( pLine->GetIndex(), pLine->GetLen() );
+ ImplTextLineInfo& rLine = rLineInfo.GetLine( nL );
+ OUString aLine = rStr.copy( rLine.GetIndex(), rLine.GetLen() );
SAL_WARN_IF( aLine.indexOf( '\r' ) != -1, "vcl", "ImplGetTextLines - Found CR!" );
SAL_WARN_IF( aLine.indexOf( '\n' ) != -1, "vcl", "ImplGetTextLines - Found LF!" );
}
@@ -1528,7 +1528,6 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
{
ImplMultiTextLineInfo aMultiLineInfo;
- ImplTextLineInfo* pLineInfo;
sal_Int32 i;
sal_Int32 nFormatLines;
@@ -1547,8 +1546,8 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
// Create last line and shorten it
nFormatLines = nLines-1;
- pLineInfo = aMultiLineInfo.GetLine( nFormatLines );
- aLastLine = convertLineEnd(aStr.copy(pLineInfo->GetIndex()), LINEEND_LF);
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( nFormatLines );
+ aLastLine = convertLineEnd(aStr.copy(rLineInfo.GetIndex()), LINEEND_LF);
// Replace all LineFeeds with Spaces
OUStringBuffer aLastLineBuffer(aLastLine);
sal_Int32 nLastLineLen = aLastLineBuffer.getLength();
@@ -1595,13 +1594,13 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
// Output all lines except for the last one
for ( i = 0; i < nFormatLines; i++ )
{
- pLineInfo = aMultiLineInfo.GetLine( i );
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( i );
if ( nStyle & DrawTextFlags::Right )
- aPos.AdjustX(nWidth-pLineInfo->GetWidth() );
+ aPos.AdjustX(nWidth-rLineInfo.GetWidth() );
else if ( nStyle & DrawTextFlags::Center )
- aPos.AdjustX((nWidth-pLineInfo->GetWidth())/2 );
- sal_Int32 nIndex = pLineInfo->GetIndex();
- sal_Int32 nLineLen = pLineInfo->GetLen();
+ aPos.AdjustX((nWidth-rLineInfo.GetWidth())/2 );
+ sal_Int32 nIndex = rLineInfo.GetIndex();
+ sal_Int32 nLineLen = rLineInfo.GetLen();
_rLayout.DrawText( aPos, aStr, nIndex, nLineLen, pVector, pDisplayText );
if ( bDrawMnemonics )
{
@@ -1815,7 +1814,6 @@ tools::Rectangle OutputDevice::GetTextRect( const tools::Rectangle& rRect,
if ( nStyle & DrawTextFlags::MultiLine )
{
ImplMultiTextLineInfo aMultiLineInfo;
- ImplTextLineInfo* pLineInfo;
sal_Int32 nFormatLines;
sal_Int32 i;
@@ -1849,20 +1847,20 @@ tools::Rectangle OutputDevice::GetTextRect( const tools::Rectangle& rRect,
pInfo->mnMaxWidth = 0;
for ( i = 0; i < nLines; i++ )
{
- pLineInfo = aMultiLineInfo.GetLine( i );
- if ( bMaxWidth && (pLineInfo->GetWidth() > nMaxWidth) )
- nMaxWidth = pLineInfo->GetWidth();
- if ( pLineInfo->GetWidth() > pInfo->mnMaxWidth )
- pInfo->mnMaxWidth = pLineInfo->GetWidth();
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( i );
+ if ( bMaxWidth && (rLineInfo.GetWidth() > nMaxWidth) )
+ nMaxWidth = rLineInfo.GetWidth();
+ if ( rLineInfo.GetWidth() > pInfo->mnMaxWidth )
+ pInfo->mnMaxWidth = rLineInfo.GetWidth();
}
}
else if ( !nMaxWidth )
{
for ( i = 0; i < nLines; i++ )
{
- pLineInfo = aMultiLineInfo.GetLine( i );
- if ( pLineInfo->GetWidth() > nMaxWidth )
- nMaxWidth = pLineInfo->GetWidth();
+ ImplTextLineInfo& rLineInfo = aMultiLineInfo.GetLine( i );
+ if ( rLineInfo.GetWidth() > nMaxWidth )
+ nMaxWidth = rLineInfo.GetWidth();
}
}
}
More information about the Libreoffice-commits
mailing list