/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ #include <doc.hxx> #include <IDocumentFieldsAccess.hxx> #include <IDocumentUndoRedo.hxx> #include <node.hxx> #include <frmfmt.hxx> #include <swtable.hxx> #include <ndtxt.hxx> #include <swtblfmt.hxx> #include <cellatr.hxx> #include <ddefld.hxx> #include <swddetbl.hxx> #include <ndindex.hxx> #include <frameformats.hxx> #include <vector> #include <osl/diagnose.h> #include <svl/numformat.hxx>
// Structure for the mapping from old and new frame formats to the // boxes and lines of a table struct MapTableFrameFormat
{ const SwFrameFormat *pOld;
SwFrameFormat *pNew;
MapTableFrameFormat( const SwFrameFormat *pOldFormat, SwFrameFormat*pNewFormat )
: pOld( pOldFormat ), pNew( pNewFormat )
{}
};
SwContentNode* SwTextNode::MakeCopy(SwDoc& rDoc, SwNode& rIdx, boolconst bNewFrames) const
{ // the Copy-Textnode is the Node with the Text, the Copy-Attrnode is the // node with the collection and hard attributes. Normally is the same // node, but if insert a glossary without formatting, then the Attrnode // is the prev node of the destination position in dest. document.
SwTextNode* pCpyTextNd = const_cast<SwTextNode*>(this);
SwTextNode* pCpyAttrNd = pCpyTextNd;
// Copy Attribute/Text if( !pCpyAttrNd->HasSwAttrSet() ) // An AttrSet was added for numbering, so delete it
pTextNd->ResetAllAttr();
// if Copy-Textnode unequal to Copy-Attrnode, then copy first // the attributes into the new Node. if( pCpyAttrNd != pCpyTextNd )
{
pCpyAttrNd->CopyAttr( pTextNd, 0, 0 ); if( pCpyAttrNd->HasSwAttrSet() )
{
SwAttrSet aSet( *pCpyAttrNd->GetpSwAttrSet() );
aSet.ClearItem( RES_PAGEDESC );
aSet.ClearItem( RES_BREAK );
aSet.CopyToModify( *pTextNd );
}
}
// Is that enough? What about PostIts/Fields/FieldTypes? // #i96213# - force copy of all attributes
pCpyTextNd->CopyText( pTextNd, SwContentIndex( pCpyTextNd ),
pCpyTextNd->GetText().getLength(), true );
if( pLineFormat == pLine->GetFrameFormat() ) // Create a new one?
{
pLineFormat = pCT->m_rDoc.MakeTableLineFormat();
pLineFormat->CopyAttrs( *pLine->GetFrameFormat() );
pCT->m_rMapArr.emplace_back(pLine->GetFrameFormat(), pLineFormat);
}
SwTableLine* pNewLine = new SwTableLine(pLineFormat, pLine->GetTabBoxes().size(), pCT->m_pInsBox); // Insert the new row into the table if (pCT->m_pInsBox)
{
pCT->m_pInsBox->GetTabLines().push_back(pNewLine);
} else
{
pCT->m_pTableNd->GetTable().GetTabLines().push_back(pNewLine);
}
SwDDEFieldType* pDDEType = nullptr; if( auto pSwDDETable = dynamic_cast<const SwDDETable*>( &GetTable() ) )
{ // We're copying a DDE table // Is the field type available in the new document?
pDDEType = const_cast<SwDDETable*>(pSwDDETable)->GetDDEFieldType(); if( pDDEType->IsDeleted() )
rDoc.getIDocumentFieldsAccess().InsDeletedFieldType( *pDDEType ); else
pDDEType = static_cast<SwDDEFieldType*>(rDoc.getIDocumentFieldsAccess().InsertFieldType( *pDDEType ));
OSL_ENSURE( pDDEType, "unknown FieldType" );
// Swap the table pointers in the node
std::unique_ptr<SwDDETable> pNewTable(new SwDDETable( pTableNd->GetTable(), pDDEType ));
pTableNd->SetNewTable( std::move(pNewTable), false );
} // First copy the content of the tables, we will later assign the // boxes/lines and create the frames
SwNodeRange aRg( *this, SwNodeOffset(+1), *EndOfSectionNode() );
// If there is a table in this table, the table format for the outer table // does not seem to be used, because the table does not have any contents yet // (see IsUsed). Therefore the inner table gets the same name as the outer table. // We have to make sure that the table node of the SwTable is accessible, even // without any content in m_TabSortContentBoxes. #i26629#
pTableNd->GetTable().SetTableNode( pTableNd );
rNds.Copy_( aRg, aInsPos.GetNode(), false );
pTableNd->GetTable().SetTableNode( nullptr );
// Special case for a single box if( 1 == GetTable().GetTabSortBoxes().size() )
{
aRg.aStart.Assign( *pTableNd, 1 );
aRg.aEnd.Assign( *pTableNd->EndOfSectionNode() );
rDoc.GetNodes().SectionDown( &aRg, SwTableBoxStartNode );
}
// Delete all frames from the copied area, they will be created // during the generation of the table frame
pTableNd->DelFrames();
void SwTextNode::CopyCollFormat(SwTextNode& rDestNd, boolconst bUndoForChgFormatColl)
{ // Copy the formats into the other document: // Special case for PageBreak/PageDesc/ColBrk
SwDoc& rDestDoc = rDestNd.GetDoc();
SwAttrSet aPgBrkSet( rDestDoc.GetAttrPool(), aBreakSetRange ); const SwAttrSet* pSet;
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.