/* -*- 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 .
*/
void SwEditShell::ReinstatePaM(const SwRangeRedline& rRedline, SwPaM& rPaM)
{ if (rRedline.GetType() == RedlineType::Insert)
{ // Disable compressing redlines, that would merge a self-insert and a self-delete, which is // not wanted for reinstate.
IDocumentRedlineAccess& rIDRA = GetDoc()->getIDocumentRedlineAccess();
RedlineFlags eOld = rIDRA.GetRedlineFlags();
rIDRA.SetRedlineFlags(eOld | RedlineFlags::DontCombineRedlines);
DeleteSel(rPaM, /*isArtificialSelection=*/true);
rIDRA.SetRedlineFlags(eOld);
} elseif (rRedline.GetType() == RedlineType::Delete)
{ // Re-insert after the deletion.
SwDocShell* pDocShell = GetDoc()->GetDocShell(); if (!pDocShell)
{ return;
}
SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); if (!pWrtShell)
{ return;
}
// Get rid of table selection or multi-selection if there is one.
KillPams();
assert(!GetTableCursor() && "coverity#1645529");
SwShellCursor* pCursor = getShellCursor(/*bBlock=*/true);
*pCursor->GetPoint() = *rPaM.End();
SetMark();
*pCursor->GetMark() = *rPaM.Start();
rtl::Reference<SwTransferable> pTransfer(new SwTransferable(*pWrtShell)); // Copy rich text, but don't strip out text inside delete redlines.
pTransfer->Copy(/*bIsCut=*/false, /*bDeleteRedlines=*/false);
ClearMark();
*pCursor->GetPoint() = *rPaM.End();
TransferableDataHelper aHelper(pTransfer);
SwTransferable::Paste(*pWrtShell, aHelper);
}
}
// Work on a copy, since reinstate will modify the table, and reinstate of just inserted // redlines is not wanted.
std::vector<SwRangeRedline*> aRedlines(rTable.begin(), rTable.end());
IDocumentUndoRedo& rIDUR = GetDoc()->GetIDocumentUndoRedo(); if (rIDUR.DoesUndo())
{
rIDUR.StartUndo(SwUndoId::REINSTATE_REDLINE, nullptr);
} int nRedlines = 0; for (size_t nIndex = 0; nIndex < aRedlines.size(); ++nIndex)
{ const SwRangeRedline& rRedline = *aRedlines[nIndex]; if (!rRedline.HasMark() || !rRedline.IsVisible())
{ continue;
}
if (*rRedline.End() < aCursorStart)
{ // Ends before the selection, skip to the next redline. continue;
}
if (*rRedline.Start() > aCursorEnd)
{ // Starts after the selection, can stop. break;
}
// Check if the redline is only partially selected. const SwPosition* pStart = rRedline.Start(); if (*pStart < aCursorStart)
{
pStart = &aCursorStart;
} const SwPosition* pEnd = rRedline.End(); if (*pEnd > aCursorEnd)
{
pEnd = &aCursorEnd;
}
// Set the comment at the Redline bool SwEditShell::SetRedlineComment( const OUString& rS )
{ bool bRet = false; for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
{
bRet = bRet || GetDoc()->getIDocumentRedlineAccess().SetRedlineComment( rPaM, rS );
}
return bRet;
}
const SwRangeRedline* SwEditShell::GetCurrRedline() const
{ if (const SwRangeRedline* pRed = GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetPoint(), nullptr )) return pRed; // check the other side of the selection to handle completely selected changes, where the Point is at the end return GetDoc()->getIDocumentRedlineAccess().GetRedline( *GetCursor()->GetMark(), nullptr );
}
/** Search the Redline of the data given * * @return Returns the Pos of the Array, or SwRedlineTable::npos if not present
*/
SwRedlineTable::size_type SwEditShell::FindRedlineOfData( const SwRedlineData& rData ) const
{ const SwRedlineTable& rTable = GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
for( SwRedlineTable::size_type i = 0, nCnt = rTable.size(); i < nCnt; ++i ) if( &rTable[ i ]->GetRedlineData() == &rData ) return i; return SwRedlineTable::npos;
}
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.