From 067a53bbcd209d7458b04142f989e1ff7ec1f785 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Fri, 27 Nov 2009 13:45:30 +0000 Subject: #i101821# find correct frame and SwPageFrame to print (or PDF export) selections --- sw/source/core/view/vprint.cxx | 59 ++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 13 deletions(-) (limited to 'sw') diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index cf72af66d0a8..c9f5e012c74a 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -776,16 +776,32 @@ SwDoc * ViewShell::CreatePrtDoc( SfxPrinter* pPrt, SfxObjectShellRef &rDocShellR pActCrsr = dynamic_cast(pActCrsr->GetPrev()); } - // Die Y-Position der ersten Selektion - const Point aSelPoint = pFESh->IsTableMode() ? - pFESh->GetTableCrsr()->GetSttPos() : - pFirstCrsr->GetSttPos(); + Point aSelPoint; + if( pFESh->IsTableMode() ) + { + SwShellTableCrsr* pShellTblCrsr = pFESh->GetTableCrsr(); + + const SwCntntNode* pCntntNode = pShellTblCrsr->GetNode()->GetCntntNode(); + const SwCntntFrm *pCntntFrm = pCntntNode ? pCntntNode->GetFrm( 0, pShellTblCrsr->Start() ) : 0; + if( pCntntFrm ) + { + SwRect aCharRect; + SwCrsrMoveState aTmpState( MV_NONE ); + pCntntFrm->GetCharRect( aCharRect, *pShellTblCrsr->Start(), &aTmpState ); + aSelPoint = Point( aCharRect.Left(), aCharRect.Top() ); + } + } + else + { + aSelPoint = pFirstCrsr->GetSttPos(); + } const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aSelPoint ); + ASSERT( pPage, "no page found!" ); - // und ihren Seitendescribtor - const SwPageDesc* pPageDesc = pPrtDoc->FindPageDescByName( - pPage->GetPageDesc()->GetName() ); + // get page descriptor - fall back to the first one if pPage could not be found + const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDescByName( + pPage->GetPageDesc()->GetName() ) : &pPrtDoc->_GetPageDesc( (sal_uInt16)0 ); if( !pFESh->IsTableMode() && pActCrsr->HasMark() ) { // Am letzten Absatz die Absatzattribute richten: @@ -868,15 +884,32 @@ SwDoc * ViewShell::FillPrtDoc( SwDoc *pPrtDoc, const SfxPrinter* pPrt) // Die Y-Position der ersten Selektion // Die Y-Position der ersten Selektion - const Point aSelPoint = pFESh->IsTableMode() ? - pFESh->GetTableCrsr()->GetSttPos() : - pFirstCrsr->GetSttPos(); + Point aSelPoint; + if( pFESh->IsTableMode() ) + { + SwShellTableCrsr* pShellTblCrsr = pFESh->GetTableCrsr(); + + const SwCntntNode* pCntntNode = pShellTblCrsr->GetNode()->GetCntntNode(); + const SwCntntFrm *pCntntFrm = pCntntNode ? pCntntNode->GetFrm( 0, pShellTblCrsr->Start() ) : 0; + if( pCntntFrm ) + { + SwRect aCharRect; + SwCrsrMoveState aTmpState( MV_NONE ); + pCntntFrm->GetCharRect( aCharRect, *pShellTblCrsr->Start(), &aTmpState ); + aSelPoint = Point( aCharRect.Left(), aCharRect.Top() ); + } + } + else + { + aSelPoint = pFirstCrsr->GetSttPos(); + } const SwPageFrm* pPage = GetLayout()->GetPageAtPos( aSelPoint ); + ASSERT( pPage, "no page found!" ); - // und ihren Seitendescribtor - const SwPageDesc* pPageDesc = pPrtDoc->FindPageDescByName( - pPage->GetPageDesc()->GetName() ); + // get page descriptor - fall back to the first one if pPage could not be found + const SwPageDesc* pPageDesc = pPage ? pPrtDoc->FindPageDescByName( + pPage->GetPageDesc()->GetName() ) : &pPrtDoc->_GetPageDesc( (sal_uInt16)0 ); if( !pFESh->IsTableMode() && pActCrsr->HasMark() ) { // Am letzten Absatz die Absatzattribute richten: -- cgit v1.2.3