/* -*- 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 .
*/
// And now the own bottom edge with the succeeding top edge if( !pGCPara->IsLastLine() )
{
SwCollectTableLineBoxes aBottom( false );
SwCollectTableLineBoxes aTop( true );
staticbool lcl_MergeGCBox(SwTableBox* pTableBox, GCLinePara* pPara)
{ if( !pTableBox->GetTabLines().empty() )
{ // ATTENTION: The Line count can change!
GCLinePara aPara( pTableBox->GetTabLines(), pPara ); for( SwTableLines::size_type n = 0;
n < pTableBox->GetTabLines().size() && lcl_MergeGCLine( pTableBox->GetTabLines()[n], &aPara );
++n )
;
if( 1 == pTableBox->GetTabLines().size() )
{ // we have a box with a single line, so we just replace it by the line's boxes
SwTableLine* pInsLine = pTableBox->GetUpper();
SwTableLine* pCpyLine = pTableBox->GetTabLines()[0];
SwTableBoxes::iterator it = std::find( pInsLine->GetTabBoxes().begin(), pInsLine->GetTabBoxes().end(), pTableBox ); for( auto pTabBox : pCpyLine->GetTabBoxes() )
pTabBox->SetUpper( pInsLine );
SfxPoolItem const* pRowBrush(nullptr);
pCpyLine->GetFrameFormat()->GetItemState(RES_BACKGROUND, true, &pRowBrush); if (pRowBrush)
{ for (auto pBox : pCpyLine->GetTabBoxes())
{ if (pBox->GetFrameFormat()->GetItemState(RES_BACKGROUND) != SfxItemState::SET)
{ // set inner row background on inner cell
pBox->ClaimFrameFormat();
pBox->GetFrameFormat()->SetFormatAttr(*pRowBrush);
}
}
}
// remove the old box from its parent line
it = pInsLine->GetTabBoxes().erase( it ); // insert the nested line's boxes in its place
pInsLine->GetTabBoxes().insert( it, pCpyLine->GetTabBoxes().begin(), pCpyLine->GetTabBoxes().end());
pCpyLine->GetTabBoxes().clear(); // destroy the removed box delete pTableBox;
returnfalse; // set up anew
}
} returntrue;
}
staticbool lcl_MergeGCLine(SwTableLine* pLn, GCLinePara* pGCPara)
{
SwTableBoxes::size_type nBoxes = pLn->GetTabBoxes().size(); if( nBoxes )
{ while( 1 == nBoxes )
{ // We have a Box with Lines
SwTableBox* pBox = pLn->GetTabBoxes().front(); if( pBox->GetTabLines().empty() ) break;
SwTableLine* pLine = pBox->GetTabLines()[0];
// pLine turns into the current Line (that is rpLine), the rest is moved // into the LinesArray past the current one. // The LinesArray is in pPara!
SwTableLines::size_type nLines = pBox->GetTabLines().size();
rLns.erase( rLns.begin() + nInsPos ); // remove the Line from the array
rLns.insert( rLns.begin() + nInsPos, pBox->GetTabLines().begin(), pBox->GetTabLines().end() );
// JP 31.03.99: Bug 60000 // Pass the attributes of the to-be-deleted Lines to the "inserted" one const SfxPoolItem* pItem; if( SfxItemState::SET == pLn->GetFrameFormat()->GetItemState(
RES_BACKGROUND, true, &pItem ))
{
SwTableLines& rBoxLns = pBox->GetTabLines(); for( auto pBoxLine : rBoxLns ) if( SfxItemState::SET != pBoxLine->GetFrameFormat()->
GetItemState( RES_BACKGROUND ))
pGCPara->pShareFormats->SetAttr( *pBoxLine, *pItem );
}
pBox->GetTabLines().erase( pBox->GetTabLines().begin(), pBox->GetTabLines().begin() + nLines ); // Remove Lines from the array
delete pLn;
// Set the dependency anew while( nLines-- )
rLns[ nInsPos++ ]->SetUpper( pUpper );
pLn = pLine; // and set up anew
nBoxes = pLn->GetTabBoxes().size();
}
// ATTENTION: The number of boxes can change!
SwTableBoxes::size_type nLen = 0; while (nLen < pLn->GetTabBoxes().size())
{ if( !lcl_MergeGCBox( pLn->GetTabBoxes()[nLen], pGCPara ))
{ if (nLen == 0) break;
--nLen; continue;
}
++nLen;
}
} returntrue;
}
// Clean structure a bit void SwTable::GCLines()
{ // ATTENTION: The Line count can change!
GCLinePara aPara( GetTabLines() );
SwShareBoxFormats aShareFormats;
aPara.pShareFormats = &aShareFormats; for( SwTableLines::size_type n = 0; n < GetTabLines().size() &&
lcl_MergeGCLine( GetTabLines()[n], &aPara ); ++n )
;
}
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.