Kaydet (Commit) 7d481f7a authored tarafından Michael Stahl's avatar Michael Stahl

sw_redlinehide_4b: visibility checks for EnhancedPDFExport links

SwEnhancedPDFExportHelper should not create links to things that are
hidden by the layout:

* SwCursorShell::GotoFormatField() skips deleted fields
  (this triggers an assert in GetCharRect() with ooo69593-1.odt)

* SwEditShell::GetINetAttrs() skips deleted INet attributes
  (which, as an additional bonus, hides then in the Navigator too)

* SwDoc::GotoOutline() skips outline nodes where we know they have
  been deleted (as seen in ooo66088-9.odt)

* SwFlyFrameFormats are skipped by EnhancedPDFExportHelper itself

* footnotes dito

Change-Id: Ife77dc7724688631d20cbaf8531b3c826a8ece94
üst 59bdf21f
...@@ -854,7 +854,11 @@ bool SwCursorShell::MoveFieldType( ...@@ -854,7 +854,11 @@ bool SwCursorShell::MoveFieldType(
bool SwCursorShell::GotoFormatField( const SwFormatField& rField ) bool SwCursorShell::GotoFormatField( const SwFormatField& rField )
{ {
bool bRet = false; bool bRet = false;
if( rField.GetTextField() ) SwTextField const*const pTextField(rField.GetTextField());
if (pTextField
&& (!GetLayout()->IsHideRedlines()
|| !sw::IsFieldDeletedInModel(
GetDoc()->getIDocumentRedlineAccess(), *pTextField)))
{ {
SET_CURR_SHELL( this ); SET_CURR_SHELL( this );
SwCallLink aLk( *this ); // watch Cursor-Moves SwCallLink aLk( *this ); // watch Cursor-Moves
...@@ -862,9 +866,9 @@ bool SwCursorShell::GotoFormatField( const SwFormatField& rField ) ...@@ -862,9 +866,9 @@ bool SwCursorShell::GotoFormatField( const SwFormatField& rField )
SwCursor* pCursor = getShellCursor( true ); SwCursor* pCursor = getShellCursor( true );
SwCursorSaveState aSaveState( *pCursor ); SwCursorSaveState aSaveState( *pCursor );
SwTextNode* pTNd = rField.GetTextField()->GetpTextNode(); SwTextNode* pTNd = pTextField->GetpTextNode();
pCursor->GetPoint()->nNode = *pTNd; pCursor->GetPoint()->nNode = *pTNd;
pCursor->GetPoint()->nContent.Assign( pTNd, rField.GetTextField()->GetStart() ); pCursor->GetPoint()->nContent.Assign( pTNd, pTextField->GetStart() );
bRet = !pCursor->IsSelOvr(); bRet = !pCursor->IsSelOvr();
if( bRet ) if( bRet )
......
...@@ -594,6 +594,7 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type ...@@ -594,6 +594,7 @@ bool SwDoc::MoveOutlinePara( const SwPaM& rPam, SwOutlineNodes::difference_type
static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds, static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds,
SwRootFrame const*const pLayout, const OUString& rName, bool const bExact) SwRootFrame const*const pLayout, const OUString& rName, bool const bExact)
{ {
SwTextNode * pExactButDeleted(nullptr);
SwTextNode* pSavedNode = nullptr; SwTextNode* pSavedNode = nullptr;
for( auto pOutlNd : rOutlNds ) for( auto pOutlNd : rOutlNds )
{ {
...@@ -603,10 +604,18 @@ static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds, ...@@ -603,10 +604,18 @@ static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds,
{ {
if (sText.getLength() == rName.getLength()) if (sText.getLength() == rName.getLength())
{ {
// Found "exact", set Pos to the Node if (pLayout && !sw::IsParaPropsNode(*pLayout, *pTextNd))
return pTextNd; {
pExactButDeleted = pTextNd;
}
else
{
// Found "exact", set Pos to the Node
return pTextNd;
}
} }
if( !bExact && !pSavedNode ) if (!bExact && !pSavedNode
&& (!pLayout || sw::IsParaPropsNode(*pLayout, *pTextNd)))
{ {
// maybe we just found the text's first part // maybe we just found the text's first part
pSavedNode = pTextNd; pSavedNode = pTextNd;
...@@ -614,7 +623,7 @@ static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds, ...@@ -614,7 +623,7 @@ static SwTextNode* lcl_FindOutlineName(const SwOutlineNodes& rOutlNds,
} }
} }
return pSavedNode; return bExact ? pExactButDeleted : pSavedNode;
} }
static SwTextNode* lcl_FindOutlineNum(const SwOutlineNodes& rOutlNds, static SwTextNode* lcl_FindOutlineNum(const SwOutlineNodes& rOutlNds,
...@@ -749,6 +758,10 @@ bool SwDoc::GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame con ...@@ -749,6 +758,10 @@ bool SwDoc::GotoOutline(SwPosition& rPos, const OUString& rName, SwRootFrame con
SwTextNode *pTmpNd = ::lcl_FindOutlineName(rOutlNds, pLayout, sName, true); SwTextNode *pTmpNd = ::lcl_FindOutlineName(rOutlNds, pLayout, sName, true);
if ( pTmpNd ) // found via the Name if ( pTmpNd ) // found via the Name
{ {
if (pLayout && !sw::IsParaPropsNode(*pLayout, *pTmpNd))
{ // found the correct node but it's deleted!
return false; // avoid fallback to inexact search
}
pNd = pTmpNd; pNd = pTmpNd;
} }
} }
......
...@@ -694,15 +694,21 @@ void SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr ) ...@@ -694,15 +694,21 @@ void SwEditShell::GetINetAttrs( SwGetINetAttrs& rArr )
{ {
rArr.clear(); rArr.clear();
const SwTextNode* pTextNd;
const SwCharFormats* pFormats = GetDoc()->GetCharFormats(); const SwCharFormats* pFormats = GetDoc()->GetCharFormats();
for( auto n = pFormats->size(); 1 < n; ) for( auto n = pFormats->size(); 1 < n; )
{ {
SwIterator<SwTextINetFormat,SwCharFormat> aIter(*(*pFormats)[--n]); SwIterator<SwTextINetFormat,SwCharFormat> aIter(*(*pFormats)[--n]);
for( SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() ) for( SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() )
{ {
if( nullptr != ( pTextNd = pFnd->GetpTextNode()) && SwTextNode const*const pTextNd(pFnd->GetpTextNode());
pTextNd->GetNodes().IsDocNodes() ) SwTextFrame const*const pFrame(pTextNd
? static_cast<SwTextFrame const*>(pTextNd->getLayoutFrame(GetLayout()))
: nullptr);
if (nullptr != pTextNd && nullptr != pFrame
&& pTextNd->GetNodes().IsDocNodes()
// check it's not fully deleted
&& pFrame->MapModelToView(pTextNd, pFnd->GetStart())
!= pFrame->MapModelToView(pTextNd, *pFnd->GetEnd()))
{ {
SwTextINetFormat& rAttr = *pFnd; SwTextINetFormat& rAttr = *pFnd;
OUString sText( pTextNd->GetExpandText(GetLayout(), OUString sText( pTextNd->GetExpandText(GetLayout(),
......
...@@ -1662,7 +1662,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() ...@@ -1662,7 +1662,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
{ {
aURL = aURL.copy( 1 ); aURL = aURL.copy( 1 );
mrSh.SwCursorShell::ClearMark(); mrSh.SwCursorShell::ClearMark();
JumpToSwMark( &mrSh, aURL ); if (! JumpToSwMark( &mrSh, aURL ))
{
continue; // target deleted
}
// Destination Rectangle // Destination Rectangle
const SwRect& rDestRect = mrSh.GetCharRect(); const SwRect& rDestRect = mrSh.GetCharRect();
...@@ -1734,6 +1737,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() ...@@ -1734,6 +1737,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
SwFrameFormat* pFrameFormat = (*pTable)[n]; SwFrameFormat* pFrameFormat = (*pTable)[n];
const SfxPoolItem* pItem; const SfxPoolItem* pItem;
if ( RES_DRAWFRMFMT != pFrameFormat->Which() && if ( RES_DRAWFRMFMT != pFrameFormat->Which() &&
GetFrameOfModify(mrSh.GetLayout(), *pFrameFormat, SwFrameType::Fly) &&
SfxItemState::SET == pFrameFormat->GetAttrSet().GetItemState( RES_URL, true, &pItem ) ) SfxItemState::SET == pFrameFormat->GetAttrSet().GetItemState( RES_URL, true, &pItem ) )
{ {
const SwPageFrame* pCurrPage = const SwPageFrame* pCurrPage =
...@@ -1748,7 +1752,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() ...@@ -1748,7 +1752,10 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
{ {
aURL = aURL.copy( 1 ); aURL = aURL.copy( 1 );
mrSh.SwCursorShell::ClearMark(); mrSh.SwCursorShell::ClearMark();
JumpToSwMark( &mrSh, aURL ); if (! JumpToSwMark( &mrSh, aURL ))
{
continue; // target deleted
}
// Destination Rectangle // Destination Rectangle
const SwRect& rDestRect = mrSh.GetCharRect(); const SwRect& rDestRect = mrSh.GetCharRect();
...@@ -1947,8 +1954,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport() ...@@ -1947,8 +1954,12 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport()
// 1. Check if the whole paragraph is hidden // 1. Check if the whole paragraph is hidden
// 2. Check for hidden text attribute // 2. Check for hidden text attribute
if ( rTNd.GetTextNode()->IsHidden() || mrSh.SelectHiddenRange() ) if (rTNd.GetTextNode()->IsHidden() || mrSh.SelectHiddenRange()
|| (mrSh.GetLayout()->IsHideRedlines()
&& sw::IsFootnoteDeleted(pDoc->getIDocumentRedlineAccess(), *pTextFootnote)))
{
continue; continue;
}
SwCursorSaveState aSaveState( *mrSh.GetCursor_() ); SwCursorSaveState aSaveState( *mrSh.GetCursor_() );
......
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