/* -*- 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 .
*/
// fix PaM for deletions shown in margin bool bIsDeletion = dynamic_cast<SwUndoRedlineDelete*>(this); const SwRedlineTable& rTable = rDoc.getIDocumentRedlineAccess().GetRedlineTable();
sal_uInt32 nMaxId = SAL_MAX_UINT32; if ( bIsDeletion && rTable.size() > 0 )
{ // Nodes of the deletion range are in the newest invisible redlines. // Set all redlines visible and recover the original deletion range. for (SwNodeOffset nNodes(0); nNodes < m_nEndNode - m_nSttNode + 1; ++nNodes)
{
SwRedlineTable::size_type nCurRedlinePos = 0;
SwRangeRedline * pRedline(rTable[nCurRedlinePos]);
// search last but nNodes redline by its nth biggest id for( SwRedlineTable::size_type n = 1; n < rTable.size(); ++n )
{
SwRangeRedline *pRed(rTable[n]); if ( !pRed->HasMark() && pRedline->GetId() < pRed->GetId() && pRed->GetId() < nMaxId )
{
nCurRedlinePos = n;
pRedline = pRed;
}
}
nMaxId = pRedline->GetId();
if ( !pRedline->IsVisible() && !pRedline->HasMark() )
{ // set it visible
pRedline->Show(0, rTable.GetPos(pRedline), /*bForced=*/true);
pRedline->Show(1, rTable.GetPos(pRedline), /*bForced=*/true);
// extend the range if ( nNodes == SwNodeOffset(0) )
rPam = *pRedline; else
{
rPam.SetMark();
*rPam.GetMark() = *pRedline->GetMark();
}
}
}
}
void SwUndoRedlineDelete::InitHistory(SwPaM const& rRedline)
{
m_pHistory.reset(new SwHistory); // try to rely on direction of rPam here so it works for // backspacing/deleting consecutive characters
SaveFlyArr flys;
SaveFlyInRange(rRedline, *rRedline.GetMark(), flys, false, m_pHistory.get());
RestFlyInRange(flys, *rRedline.GetPoint(), &rRedline.GetPoint()->GetNode(), true); if (m_pHistory->Count())
{
m_bCanGroup = false; // how to group history?
}
}
// bit of a hack, replace everything...
SwRewriter SwUndoRedlineDelete::GetRewriter() const
{
SwRewriter aResult;
OUString aStr = DenoteSpecialCharacters(m_sRedlineText);
aStr = ShortenString(aStr, nUndoStringLength, SwResId(STR_LDOTS));
SwRewriter aRewriter;
aRewriter.AddRule(UndoArg1, aStr);
OUString ret = aRewriter.Apply(SwResId(STR_UNDO_REDLINE_DELETE));
aResult.AddRule(UndoArg1, ret); return aResult;
}
void SwUndoRedlineDelete::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
{ if (rPam.GetPoint() != rPam.GetMark())
{ if (m_pHistory) // if it was created before, it must be recreated now
{
rPam.Normalize(m_bIsBackspace); // to check the correct edge
InitHistory(rPam);
}
rDoc.getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline(*mpRedlData, rPam), false );
}
sw::UpdateFramesForAddDeleteRedline(rDoc, rPam);
}
if( !( RedlineFlags::ShowDelete & rDoc.getIDocumentRedlineAccess().GetRedlineFlags()) )
{ // Search both Redline objects and make them visible to make the nodes // consistent again. The 'delete' one is hidden, thus search for the // 'insert' Redline object. The former is located directly after the latter.
SwRedlineTable::size_type nFnd = rDoc.getIDocumentRedlineAccess().GetRedlinePos(
*rDoc.GetNodes()[ m_nSttNode + 1 ],
RedlineType::Insert );
OSL_ENSURE( SwRedlineTable::npos != nFnd && nFnd+1 < rDoc.getIDocumentRedlineAccess().GetRedlineTable().size(), "could not find an Insert object" );
++nFnd;
rDoc.getIDocumentRedlineAccess().GetRedlineTable()[nFnd]->Show(1, nFnd);
}
// per definition Point is end (in SwUndRng!)
SwContentNode* pCSttNd = rPam.GetMarkContentNode();
SwContentNode* pCEndNd = rPam.GetPointContentNode();
// if start- and end-content is zero, then the doc-compare moves // complete nodes into the current doc. And then the selection // must be from end to start, so the delete join into the right // direction. if( !m_nSttContent && !m_nEndContent )
rPam.Exchange();
if( pCSttNd && !pCEndNd)
{ // #112139# Do not step behind the end of content.
SwNode & rTmp = rPam.GetPointNode();
SwNode * pEnd = rDoc.GetNodes().DocumentSectionEndNode(&rTmp);
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.