// It must be able to communicate to a SwViewShell. This is going to be removed later. const SwRootFrame *DocumentLayoutManager::GetCurrentLayout() const
{ if(GetCurrentViewShell()) return GetCurrentViewShell()->GetLayout(); return nullptr;
}
/** Create a new format whose settings fit to the Request by default.
Theformatisputintotherespectiveformatarray.
If there already is a fitting format, it is returned instead. */
SwFrameFormat *DocumentLayoutManager::MakeLayoutFormat( RndStdIds eRequest, const SfxItemSet* pSet )
{
SwFrameFormat *pFormat = nullptr; constbool bMod = m_rDoc.getIDocumentState().IsModified(); bool bHeader = false;
switch ( eRequest )
{ case RndStdIds::HEADER: case RndStdIds::HEADERL: case RndStdIds::HEADERR:
{
bHeader = true;
[[fallthrough]];
} case RndStdIds::FOOTER:
{
pFormat = new SwFrameFormat( m_rDoc.GetAttrPool(),
UIName(bHeader ? u"Right header"_ustr : u"Right footer"_ustr),
m_rDoc.GetDfltFrameFormat() );
if( pSet ) // Set a few more attributes
pFormat->SetFormatAttr( *pSet );
// Why set it back? Doc has changed, or not? // In any case, wrong for the FlyFrames! if ( !bMod )
m_rDoc.getIDocumentState().ResetModified();
} break;
case RndStdIds::DRAW_OBJECT:
{
pFormat = m_rDoc.MakeDrawFrameFormat( UIName(), m_rDoc.GetDfltFrameFormat() ); if( pSet ) // Set a few more attributes
pFormat->SetFormatAttr( *pSet );
if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{
m_rDoc.GetIDocumentUndoRedo().AppendUndo(
std::make_unique<SwUndoInsLayFormat>(pFormat, SwNodeOffset(0), 0));
}
} break;
#if OSL_DEBUG_LEVEL > 0 case RndStdIds::FLY_AT_PAGE: case RndStdIds::FLY_AT_CHAR: case RndStdIds::FLY_AT_FLY: case RndStdIds::FLY_AT_PARA: case RndStdIds::FLY_AS_CHAR:
OSL_FAIL( "use new interface instead: SwDoc::MakeFlySection!" ); break; #endif
default:
OSL_ENSURE( false, "LayoutFormat was requested with an invalid Request." );
} return pFormat;
}
/// Deletes the denoted format and its content. void DocumentLayoutManager::DelLayoutFormat( SwFrameFormat *pFormat )
{ // Do not paint, until the destruction is complete. Paint may access the layout and nodes // while it's in inconsistent state, and crash.
Scheduler::IdlesLockGuard g; // A chain of frames needs to be merged, if necessary, // so that the Frame's contents are adjusted accordingly before we destroy the Frames. const SwFormatChain &rChain = pFormat->GetChain(); if ( rChain.GetPrev() )
{
SwFormatChain aChain( rChain.GetPrev()->GetChain() );
aChain.SetNext( rChain.GetNext() );
m_rDoc.SetAttr( aChain, *rChain.GetPrev() );
} if ( rChain.GetNext() )
{
SwFormatChain aChain( rChain.GetNext()->GetChain() );
aChain.SetPrev( rChain.GetPrev() );
m_rDoc.SetAttr( aChain, *rChain.GetNext() );
}
const SwNodeIndex* pCntIdx = nullptr; // The draw format doesn't own its content, it just has a pointer to it. if (pFormat->Which() != RES_DRAWFRMFMT)
pCntIdx = pFormat->GetContent().GetContentIdx(); if (pCntIdx && !m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{ // Disconnect if it's an OLE object
SwOLENode* pOLENd = m_rDoc.GetNodes()[ pCntIdx->GetIndex()+1 ]->GetOLENode(); if( pOLENd && pOLENd->GetOLEObj().IsOleRef() )
{ try
{
pOLENd->GetOLEObj().GetOleRef()->changeState( embed::EmbedStates::LOADED );
} catch ( uno::Exception& )
{
}
}
}
// Destroy Frames
pFormat->DelFrames();
// Only FlyFrames are undoable at first const sal_uInt16 nWh = pFormat->Which(); if (m_rDoc.GetIDocumentUndoRedo().DoesUndo() &&
(RES_FLYFRMFMT == nWh || RES_DRAWFRMFMT == nWh))
{
m_rDoc.GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoDelLayFormat>( pFormat ));
} else
{ // #i32089# - delete at-frame anchored objects if ( nWh == RES_FLYFRMFMT )
{ // determine frame formats of at-frame anchored objects const SwNodeIndex* pContentIdx = nullptr; if (pFormat->Which() != RES_DRAWFRMFMT)
pContentIdx = pFormat->GetContent().GetContentIdx(); if (pContentIdx)
{
sw::SpzFrameFormats* pSpzs = pFormat->GetDoc().GetSpzFrameFormats(); if ( pSpzs )
{
std::vector<SwFrameFormat*> aToDeleteFrameFormats; const SwNodeOffset nNodeIdxOfFlyFormat( pContentIdx->GetIndex() );
// May we copy this object? // We may, unless it's 1) it's a control (and therefore a draw) // 2) anchored in a header/footer // 3) anchored (to paragraph?) bool bMayNotCopy = false; const SwNode* pCAnchor = rNewAnchor.GetAnchorNode(); bool bInHeaderFooter = pCAnchor && m_rDoc.IsInHeaderFooter(*pCAnchor); if(bDraw)
{ bool bCheckControlLayer = false;
rSource.CallSwClientNotify(sw::CheckDrawFrameFormatLayerHint(&bCheckControlLayer));
bMayNotCopy =
bCheckControlLayer &&
((RndStdIds::FLY_AT_PARA == rNewAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_FLY == rNewAnchor.GetAnchorId()) || (RndStdIds::FLY_AT_CHAR == rNewAnchor.GetAnchorId())) &&
bInHeaderFooter;
}
// just return if we can't copy this if( bMayNotCopy ) return nullptr;
SwFrameFormat* pDest = m_rDoc.GetDfltFrameFormat(); if( rSource.GetRegisteredIn() != rSrcDoc.GetDfltFrameFormat() )
pDest = m_rDoc.CopyFrameFormat( *static_cast<const SwFrameFormat*>(rSource.GetRegisteredIn()) ); if( bFly )
{ // #i11176# // To do a correct cloning concerning the ZOrder for all objects // it is necessary to actually create a draw object for fly frames, too. // These are then added to the DrawingLayer (which needs to exist). // Together with correct sorting of all drawinglayer based objects // before cloning ZOrder transfer works correctly then.
SwFlyFrameFormat *pFormat = m_rDoc.MakeFlyFrameFormat( rSource.GetName(), pDest );
pDest = pFormat;
// Set the Anchor/ContentIndex first. // Within the copying part, we can access the values (DrawFormat in Headers and Footers)
SwNodeIndex aIdx( *pSttNd );
SwFormatContent aAttr( rSource.GetContent() );
aAttr.SetNewContentIdx( &aIdx );
pDest->SetFormatAttr( aAttr );
pDest->SetFormatAttr( rNewAnchor );
if( !m_rDoc.IsCopyIsMove() || &m_rDoc != &rSrcDoc )
{ if( (m_rDoc.IsInReading() && !bInHeaderFooter) || m_rDoc.IsInMailMerge() )
pDest->SetFormatName( UIName() ); else
{ // Test first if the name is already taken, if so generate a new one.
SwNodeType nNdTyp = aRg.aStart.GetNode().GetNodeType();
UIName sOld( pDest->GetName() );
pDest->SetFormatName( UIName() ); if( m_rDoc.FindFlyByName( sOld, nNdTyp ) ) // found one switch( nNdTyp )
{ case SwNodeType::Grf: sOld = m_rDoc.GetUniqueGrfName(sOld); break; case SwNodeType::Ole: sOld = m_rDoc.GetUniqueOLEName(); break; default: sOld = m_rDoc.GetUniqueFrameName(); break;
}
pDest->SetFormatName( sOld );
}
}
if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{
m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoInsLayFormat>(pDest,SwNodeOffset(0),0));
}
// Make sure that FlyFrames in FlyFrames are copied
aIdx = *pSttNd->EndOfSectionNode();
//fdo#36631 disable (scoped) any undo operations associated with the //contact object itself. They should be managed by SwUndoInsLayFormat. const ::sw::DrawUndoGuard drawUndoGuard(m_rDoc.GetIDocumentUndoRedo());
if(pDest->GetAnchor() == rNewAnchor)
{ // Do *not* connect to layout, if a <MakeFrames> will not be called. if(bMakeFrames)
pDest->CallSwClientNotify(sw::DrawFrameFormatHint(sw::DrawFrameFormatHintId::MAKE_FRAMES));
} else
pDest->SetFormatAttr( rNewAnchor );
if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
{
m_rDoc.GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoInsLayFormat>(pDest,SwNodeOffset(0),0));
}
}
if (pDest->GetName().isEmpty())
{ // Format name should have unique name. Let's use object name as a fallback
SdrObject *pObj = pDest->FindSdrObject(); if (pObj)
pDest->SetFormatName(UIName(pObj->GetName()));
}
// If the draw format has a TextBox, then copy its fly format as well. if (constauto& pTextBoxes = rSource.GetOtherTextBoxFormats())
pTextBoxes->Clone(&m_rDoc, rNewAnchor, pDest, bSetTextFlyAtt, bMakeFrames);
return pDest;
}
//Load document from fdo#42534 under valgrind, drag the scrollbar down so full //document layout is triggered. Close document before layout has completed, and //SwAnchoredObject objects deleted by the deletion of layout remain referenced //by the SwLayouter void DocumentLayoutManager::ClearSwLayouterEntries()
{
SwLayouter::ClearMovedFwdFrames( m_rDoc );
SwLayouter::ClearObjsTmpConsiderWrapInfluence( m_rDoc ); // #i65250#
SwLayouter::ClearMoveBwdLayoutInfo( m_rDoc );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.