sw/inc/EnhancedPDFExportHelper.hxx | 2 sw/source/core/text/EnhancedPDFExportHelper.cxx | 92 +++++------------------- 2 files changed, 21 insertions(+), 73 deletions(-)
New commits: commit 4cffdb68196d6c23e5134a57018648af5d1f4111 Author: Ivan Timofeev <timofeev....@gmail.com> Date: Fri Jun 22 16:41:31 2012 +0400 reuse existing code Change-Id: I10f3d9958679b485cf75d514a38093cbe51d540e diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index b04a1bd..c04b03d 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2149,58 +2149,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() */ sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( const SwRect& rRect ) const { - // Document page number. - sal_Int32 nPageNumOfRect = mrSh.GetPageNumAndSetOffsetForPDF( mrOut, rRect ); - if ( nPageNumOfRect < 0 ) - return -1; - - // What will be the page number of page nPageNumOfRect in the output pdf? - sal_Int32 nRet = -1; - if ( mpRangeEnum ) - { - if ( mbSkipEmptyPages ) - // Map the page number to the range without empty pages. - nPageNumOfRect = maPageNumberMap[ nPageNumOfRect ]; - - if ( mpRangeEnum->hasValue( nPageNumOfRect ) ) - { - sal_Int32 nOutputPageNum = 0; - StringRangeEnumerator::Iterator aIter = mpRangeEnum->begin(); - StringRangeEnumerator::Iterator aEnd = mpRangeEnum->end(); - for ( ; aIter != aEnd; ++aIter ) - { - if ( *aIter == nPageNumOfRect ) - { - nRet = nOutputPageNum; - break; - } - ++nOutputPageNum; - } - } - } - else - { - if ( mbSkipEmptyPages ) - { - sal_Int32 nOutputPageNum = 0; - for ( size_t i = 0; i < maPageNumberMap.size(); ++i ) - { - if ( maPageNumberMap[i] >= 0 ) // is not empty? - { - if ( i == static_cast<size_t>( nPageNumOfRect ) ) - { - nRet = nOutputPageNum; - break; - } - ++nOutputPageNum; - } - } - } - else - nRet = nPageNumOfRect; - } - - return nRet; + std::vector< sal_Int32 > aPageNums = CalcOutputPageNums( rRect ); + if ( !aPageNums.empty() ) + return aPageNums[0]; + return -1; } /* commit 99a05de8245c7365fbb19a7e1ea595ccd3d1224a Author: Ivan Timofeev <timofeev....@gmail.com> Date: Thu Jun 21 14:41:16 2012 +0400 rely on the return value optimization Change-Id: Ide566aa8bbf6f4128bed598c76269b16acf99a7b diff --git a/sw/inc/EnhancedPDFExportHelper.hxx b/sw/inc/EnhancedPDFExportHelper.hxx index a5a5210..4ea69cd 100644 --- a/sw/inc/EnhancedPDFExportHelper.hxx +++ b/sw/inc/EnhancedPDFExportHelper.hxx @@ -238,7 +238,7 @@ class SwEnhancedPDFExportHelper void EnhancedPDFExport(); sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const; - void CalcOutputPageNums( const SwRect& rRect, std::vector<sal_Int32>& rPageNums ) const; + std::vector< sal_Int32 > CalcOutputPageNums( const SwRect& rRect ) const; void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData, const SwTxtNode& rTNd, const SwRect& rLinkRect, diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index cfa3120..b04a1bd 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -1627,8 +1627,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwRect& rNoteRect = mrSh.GetCharRect(); // Link PageNums - std::vector<sal_Int32> aNotePageNums; - CalcOutputPageNums( rNoteRect, aNotePageNums ); + std::vector<sal_Int32> aNotePageNums = CalcOutputPageNums( rNoteRect ); for ( size_t nNumIdx = 0; nNumIdx < aNotePageNums.size(); ++nNumIdx ) { // Link Note @@ -1740,8 +1739,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwRect& rLinkRect( aTmp[ i ] ); // Link PageNums - std::vector<sal_Int32> aLinkPageNums; - CalcOutputPageNums( rLinkRect, aLinkPageNums ); + std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( rLinkRect ); for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx ) { @@ -1810,8 +1808,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwRect aLinkRect = pFrmFmt->FindLayoutRect( sal_False, &aNullPt ); // Link PageNums - std::vector<sal_Int32> aLinkPageNums; - CalcOutputPageNums( aLinkRect, aLinkPageNums ); + std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( aLinkRect ); // Link Export for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx ) @@ -1900,8 +1897,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() const SwRect& rLinkRect( aTmp[ i ] ); // Link PageNums - std::vector<sal_Int32> aLinkPageNums; - CalcOutputPageNums( rLinkRect, aLinkPageNums ); + std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( rLinkRect ); for ( size_t nNumIdx = 0; nNumIdx < aLinkPageNums.size(); ++nNumIdx ) { @@ -1969,8 +1965,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() if ( mrSh.GotoFtnTxt() ) { // Link PageNums - std::vector<sal_Int32> aLinkPageNums; - CalcOutputPageNums( aLinkRect, aLinkPageNums ); + std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( aLinkRect ); // Destination Rectangle const SwRect& rDestRect = mrSh.GetCharRect(); @@ -2211,19 +2206,19 @@ sal_Int32 SwEnhancedPDFExportHelper::CalcOutputPageNum( const SwRect& rRect ) co /* * SwEnhancedPDFExportHelper::CalcOutputPageNums() * - * Fills rPageNums with the page numbers in the output pdf on which the given + * Returns a vector of the page numbers in the output pdf on which the given * rect is located. There can be many such pages since StringRangeEnumerator * allows duplication of its entries. */ -void SwEnhancedPDFExportHelper::CalcOutputPageNums( const SwRect& rRect, - std::vector<sal_Int32>& rPageNums ) const +std::vector< sal_Int32 > SwEnhancedPDFExportHelper::CalcOutputPageNums( + const SwRect& rRect ) const { - rPageNums.clear(); + std::vector< sal_Int32 > aPageNums; // Document page number. sal_Int32 nPageNumOfRect = mrSh.GetPageNumAndSetOffsetForPDF( mrOut, rRect ); if ( nPageNumOfRect < 0 ) - return; + return aPageNums; // What will be the page numbers of page nPageNumOfRect in the output pdf? if ( mpRangeEnum ) @@ -2240,7 +2235,7 @@ void SwEnhancedPDFExportHelper::CalcOutputPageNums( const SwRect& rRect, for ( ; aIter != aEnd; ++aIter ) { if ( *aIter == nPageNumOfRect ) - rPageNums.push_back( nOutputPageNum ); + aPageNums.push_back( nOutputPageNum ); ++nOutputPageNum; } } @@ -2256,7 +2251,7 @@ void SwEnhancedPDFExportHelper::CalcOutputPageNums( const SwRect& rRect, { if ( i == static_cast<size_t>( nPageNumOfRect ) ) { - rPageNums.push_back( nOutputPageNum ); + aPageNums.push_back( nOutputPageNum ); break; } ++nOutputPageNum; @@ -2264,8 +2259,10 @@ void SwEnhancedPDFExportHelper::CalcOutputPageNums( const SwRect& rRect, } } else - rPageNums.push_back( nPageNumOfRect ); + aPageNums.push_back( nPageNumOfRect ); } + + return aPageNums; } void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData, @@ -2293,8 +2290,7 @@ void SwEnhancedPDFExportHelper::MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rP if ( aHFLinkRect.Pos() != rLinkRect.Pos() ) { // Link PageNums - std::vector<sal_Int32> aHFLinkPageNums; - CalcOutputPageNums( aHFLinkRect, aHFLinkPageNums ); + std::vector<sal_Int32> aHFLinkPageNums = CalcOutputPageNums( aHFLinkRect ); for ( size_t nNumIdx = 0; nNumIdx < aHFLinkPageNums.size(); ++nNumIdx ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits