Kaydet (Commit) 5ad4d151 authored tarafından Ivan Timofeev's avatar Ivan Timofeev

migrate to StringRangeEnumerator in pdfexport

üst f9f4c631
...@@ -168,8 +168,12 @@ PDFExport::~PDFExport() ...@@ -168,8 +168,12 @@ PDFExport::~PDFExport()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com::sun::star::view::XRenderable >& rRenderable, Any& rSelection, sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter,
MultiSelection aMultiSelection, Sequence< PropertyValue >& rRenderOptions, sal_Int32 nPageCount ) Reference< com::sun::star::view::XRenderable >& rRenderable,
const Any& rSelection,
const StringRangeEnumerator& rRangeEnum,
Sequence< PropertyValue >& rRenderOptions,
sal_Int32 nPageCount )
{ {
sal_Bool bRet = sal_False; sal_Bool bRet = sal_False;
try try
...@@ -192,11 +196,12 @@ sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com: ...@@ -192,11 +196,12 @@ sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com:
vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() ); vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() );
if ( nPageCount ) if ( nPageCount )
{ {
sal_Int32 nSel = aMultiSelection.FirstSelected();
sal_Int32 nCurrentPage(0); sal_Int32 nCurrentPage(0);
while ( nSel != sal_Int32(SFX_ENDOFSELECTION) ) StringRangeEnumerator::Iterator aIter = rRangeEnum.begin();
StringRangeEnumerator::Iterator aEnd = rRangeEnum.end();
while ( aIter != aEnd )
{ {
Sequence< PropertyValue > aRenderer( rRenderable->getRenderer( nSel - 1, rSelection, rRenderOptions ) ); Sequence< PropertyValue > aRenderer( rRenderable->getRenderer( *aIter, rSelection, rRenderOptions ) );
awt::Size aPageSize; awt::Size aPageSize;
for( sal_Int32 nProperty = 0, nPropertyCount = aRenderer.getLength(); nProperty < nPropertyCount; ++nProperty ) for( sal_Int32 nProperty = 0, nPropertyCount = aRenderer.getLength(); nProperty < nPropertyCount; ++nProperty )
...@@ -221,9 +226,9 @@ sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com: ...@@ -221,9 +226,9 @@ sal_Bool PDFExport::ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com:
// #i35176# // #i35176#
// IsLastPage property. // IsLastPage property.
const sal_Int32 nCurrentRenderer = nSel - 1; const sal_Int32 nCurrentRenderer = *aIter;
nSel = aMultiSelection.NextSelected(); ++aIter;
if ( pLastPage && sal_Int32(SFX_ENDOFSELECTION) == nSel ) if ( pLastPage && aIter == aEnd )
*pLastPage <<= sal_True; *pLastPage <<= sal_True;
rRenderable->render( nCurrentRenderer, rSelection, rRenderOptions ); rRenderable->render( nCurrentRenderer, rSelection, rRenderOptions );
...@@ -862,8 +867,6 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue ...@@ -862,8 +867,6 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
} }
const sal_Int32 nPageCount = xRenderable->getRendererCount( aSelection, aRenderOptions ); const sal_Int32 nPageCount = xRenderable->getRendererCount( aSelection, aRenderOptions );
const Range aRange( 1, nPageCount );
MultiSelection aMultiSelection;
if ( mbExportNotesPages && aCreator.EqualsAscii( "Impress" ) ) if ( mbExportNotesPages && aCreator.EqualsAscii( "Impress" ) )
{ {
...@@ -874,21 +877,20 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue ...@@ -874,21 +877,20 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
if( !aPageRange.getLength() ) if( !aPageRange.getLength() )
{ {
aMultiSelection.SetTotalRange( aRange ); aPageRange = OUStringBuffer()
aMultiSelection.Select( aRange ); .append( static_cast< sal_Int32 >( 1 ) )
} .append( static_cast< sal_Unicode >( '-' ) )
else .append( nPageCount ).makeStringAndClear();
{
aMultiSelection = MultiSelection( aPageRange );
aMultiSelection.SetTotalRange( aRange );
} }
StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 );
if ( mxStatusIndicator.is() ) if ( mxStatusIndicator.is() )
{ {
ByteString aResMgrName( "pdffilter" ); ByteString aResMgrName( "pdffilter" );
ResMgr* pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() ); ResMgr* pResMgr = ResMgr::CreateResMgr( aResMgrName.GetBuffer(), Application::GetSettings().GetUILocale() );
if ( pResMgr ) if ( pResMgr )
{ {
sal_Int32 nTotalPageCount = aMultiSelection.GetSelectCount(); sal_Int32 nTotalPageCount = aRangeEnum.size();
if ( bSecondPassForImpressNotes ) if ( bSecondPassForImpressNotes )
nTotalPageCount *= 2; nTotalPageCount *= 2;
mxStatusIndicator->start( String( ResId( PDF_PROGRESS_BAR, *pResMgr ) ), nTotalPageCount ); mxStatusIndicator->start( String( ResId( PDF_PROGRESS_BAR, *pResMgr ) ), nTotalPageCount );
...@@ -897,14 +899,14 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue ...@@ -897,14 +899,14 @@ sal_Bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue
} }
if( nPageCount > 0 ) if( nPageCount > 0 )
bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aMultiSelection, aRenderOptions, nPageCount ); bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount );
else else
bRet = sal_False; bRet = sal_False;
if ( bRet && bSecondPassForImpressNotes ) if ( bRet && bSecondPassForImpressNotes )
{ {
rExportNotesValue <<= sal_True; rExportNotesValue <<= sal_True;
bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aMultiSelection, aRenderOptions, nPageCount ); bRet = ExportSelection( *pPDFWriter, xRenderable, aSelection, aRangeEnum, aRenderOptions, nPageCount );
} }
if ( mxStatusIndicator.is() ) if ( mxStatusIndicator.is() )
mxStatusIndicator->end(); mxStatusIndicator->end();
......
...@@ -125,8 +125,12 @@ public: ...@@ -125,8 +125,12 @@ public:
const Reference< lang::XMultiServiceFactory >& xFact ); const Reference< lang::XMultiServiceFactory >& xFact );
~PDFExport(); ~PDFExport();
sal_Bool ExportSelection( vcl::PDFWriter& rPDFWriter, Reference< com::sun::star::view::XRenderable >& rRenderable, Any& rSelection, sal_Bool ExportSelection( vcl::PDFWriter& rPDFWriter,
MultiSelection aMultiSelection, Sequence< PropertyValue >& rRenderOptions, sal_Int32 nPageCount ); Reference< com::sun::star::view::XRenderable >& rRenderable,
const Any& rSelection,
const StringRangeEnumerator& rRangeEnum,
Sequence< PropertyValue >& rRenderOptions,
sal_Int32 nPageCount );
sal_Bool Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData ); sal_Bool Export( const OUString& rFile, const Sequence< PropertyValue >& rFilterData );
......
...@@ -51,7 +51,7 @@ namespace rtl ...@@ -51,7 +51,7 @@ namespace rtl
{ {
class OUString; class OUString;
} }
class MultiSelection; class StringRangeEnumerator;
class SwTxtNode; class SwTxtNode;
class SwNumRule; class SwNumRule;
class SwTable; class SwTable;
...@@ -215,7 +215,8 @@ class SwEnhancedPDFExportHelper ...@@ -215,7 +215,8 @@ class SwEnhancedPDFExportHelper
SwEditShell& mrSh; SwEditShell& mrSh;
OutputDevice& mrOut; OutputDevice& mrOut;
MultiSelection* pPageRange; StringRangeEnumerator* mpRangeEnum;
std::vector<bool> maIsPageEmpty;
bool mbSkipEmptyPages; bool mbSkipEmptyPages;
bool mbEditEngineOnly; bool mbEditEngineOnly;
...@@ -230,6 +231,7 @@ class SwEnhancedPDFExportHelper ...@@ -230,6 +231,7 @@ class SwEnhancedPDFExportHelper
void EnhancedPDFExport(); void EnhancedPDFExport();
sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const; sal_Int32 CalcOutputPageNum( const SwRect& rRect ) const;
void CalcOutputPageNums( const SwRect& rRect, std::vector<sal_Int32>& rPageNums ) const;
void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData, void MakeHeaderFooterLinks( vcl::PDFExtOutDevData& rPDFExtOutDevData,
const SwTxtNode& rTNd, const SwRect& rLinkRect, const SwTxtNode& rTNd, const SwRect& rLinkRect,
......
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