/* -*- 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 .
*/
/// Delete and move all Flys at the paragraph, that are within the selection. /// If there is a Fly at the SPoint, it is moved onto the Mark. void DelFlyInRange( SwNode& rMkNd,
SwNode& rPtNd,
std::optional<sal_Int32> oMkContentIdx, std::optional<sal_Int32> oPtContentIdx)
{
assert(oMkContentIdx.has_value() == oPtContentIdx.has_value());
SwPosition const point(oPtContentIdx
? SwPosition(rPtNd, rPtNd.GetContentNode(), *oPtContentIdx)
: SwPosition(rPtNd));
SwPosition const mark(oPtContentIdx
? SwPosition(rMkNd, rMkNd.GetContentNode(), *oMkContentIdx)
: SwPosition(rMkNd));
SwPosition const& rStart = mark <= point ? mark : point;
SwPosition const& rEnd = mark <= point ? point : mark;
SwDoc& rDoc = rMkNd.GetDoc();
sw::SpzFrameFormats& rTable = *rDoc.GetSpzFrameFormats(); for ( auto i = rTable.size(); i; )
{
sw::SpzFrameFormat* pFormat = rTable[--i]; const SwFormatAnchor &rAnch = pFormat->GetAnchor();
SwPosition const*const pAPos = rAnch.GetContentAnchor(); if (pAPos &&
(((rAnch.GetAnchorId() == RndStdIds::FLY_AT_PARA)
&& IsSelectFrameAnchoredAtPara(*pAPos, rStart, rEnd, oPtContentIdx
? DelContentType::AllMask|DelContentType::WriterfilterHack
: DelContentType::AllMask|DelContentType::WriterfilterHack|DelContentType::CheckNoCntnt))
|| ((rAnch.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
&& IsDestroyFrameAnchoredAtChar(*pAPos, rStart, rEnd, oPtContentIdx
? DelContentType::AllMask|DelContentType::WriterfilterHack
: DelContentType::AllMask|DelContentType::WriterfilterHack|DelContentType::CheckNoCntnt))))
{ // If the Fly is deleted, all Flys in its content have to be deleted too. const SwFormatContent &rContent = pFormat->GetContent(); // But only fly formats own their content, not draw formats. if (rContent.GetContentIdx() && pFormat->Which() == RES_FLYFRMFMT)
{
DelFlyInRange( rContent.GetContentIdx()->GetNode(),
*rContent.GetContentIdx()->
GetNode().EndOfSectionNode() ); // Position could have been moved! if (i > rTable.size())
i = rTable.size(); elseif (i == rTable.size() || pFormat != rTable[i])
i = std::distance(rTable.begin(), rTable.find(pFormat));
}
// DelLayoutFormat can also trigger the deletion of objects. if (i > rTable.size())
i = rTable.size();
}
}
}
// #i59534: Redo of insertion of multiple text nodes runs into trouble // because of unnecessary expanded redlines // From now on this class saves the redline positions of all redlines which ends exact at the // insert position (node _and_ content index)
SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const SwNode& rInsIdx, sal_Int32 nCnt )
: mnSaveContent( nCnt )
{ const SwDoc& rDest = rInsIdx.GetDoc(); if( rDest.getIDocumentRedlineAccess().GetRedlineTable().empty() ) return;
void SaveRedlEndPosForRestore::Restore()
{ if (mvSavArr.empty()) return;
++(*moSaveIndex);
SwContentNode* pNode = moSaveIndex->GetNode().GetContentNode(); // If there's no content node at the remembered position, we will not restore the old position // This may happen if a table (or section?) will be inserted. if( pNode )
{
SwPosition aPos( *moSaveIndex, pNode, mnSaveContent ); for( auto n = mvSavArr.size(); n; )
*mvSavArr[ --n ] = aPos;
}
}
/// Convert list of ranges of whichIds to a corresponding list of whichIds static std::vector<sal_uInt16> lcl_RangesToVector(const WhichRangesContainer& pRanges)
{
std::vector<sal_uInt16> aResult;
if( pTextNd && pTextNd->CanJoinNext( &aIdx ) )
{
SwDoc& rDoc = rPam.GetDoc(); if( bJoinPrev )
{ // We do not need to handle xmlids in this case, because // it is only invoked if one paragraph is/becomes completely empty // (see sw_GetJoinFlags)
{ // If PageBreaks are deleted/set, it must not be added to the Undo history! // Also, deleting the Node is not added to the Undo history!
::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
/* PageBreaks, PageDesc, ColumnBreaks */ // If we need to change something about the logic to copy the PageBreaks, // PageDesc, etc. we also have to change SwUndoDelete. // There, we copy the AUTO PageBreak from the GetMarkNode!
<something> and <other> are paragraph attributes. The attribute <something> stayed if not overwritten by an attribute in "ccc". Fixed by first resetting all character attributes in first paragraph (pTextNd).
*/
std::vector<sal_uInt16> aShorts =
lcl_RangesToVector(aCharFormatSetRange);
pTextNd->ResetAttr(aShorts);
if( pDelNd->HasSwAttrSet() )
{ // only copy the character attributes
SfxItemSet aTmpSet( rDoc.GetAttrPool(), aCharFormatSetRange );
aTmpSet.Put( *pDelNd->GetpSwAttrSet() );
pTextNd->SetAttr( aTmpSet );
}
}
rDoc.CorrRel( aIdx.GetNode(), *rPam.GetPoint(), 0, true ); // #i100466# adjust given <rPam>, if it does not belong to the cursors if ( pDelNd == rPam.GetBound().GetContentNode() )
{
rPam.GetBound().Assign( *pTextNd );
} if( pDelNd == rPam.GetBound( false ).GetContentNode() )
{
rPam.GetBound( false ).Assign( *pTextNd );
}
pTextNd->JoinNext();
} returntrue;
} elsereturnfalse;
}
// get suggestions to use for the specific error position
bGrammarErrors = aResult.aErrors.hasElements(); // if grammar checking doesn't have any progress then quit if( aResult.nStartOfNextSentencePosition <= nBeginGrammarCheck ) break; // prepare next iteration
nBeginGrammarCheck = aResult.nStartOfNextSentencePosition;
} while( nSpellErrorPosition > aResult.nBehindEndOfSentencePosition && !bGrammarErrors && aResult.nBehindEndOfSentencePosition < nEndGrammarCheck );
SwHyphArgs::SwHyphArgs( const SwPaM *pPam, const Point &rCursorPos,
sal_uInt16* pPageCount, sal_uInt16* pPageStart )
: SwInterHyphInfo( rCursorPos ), m_aNodeIdx(pPam->GetPoint()->GetNode()),
m_pPageCnt( pPageCount ), m_pPageSt( pPageStart )
{ // The following constraints have to be met: // 1) there is at least one Selection // 2) SPoint() == Start()
OSL_ENSURE( pPam->HasMark(), "SwDoc::Hyphenate: blowing in the wind");
OSL_ENSURE( *pPam->GetPoint() <= *pPam->GetMark(), "SwDoc::Hyphenate: New York, New York");
const SwPosition *pPoint = pPam->GetPoint();
// Set start
m_pStart = pPoint->GetNode().GetTextNode();
m_nPamStart = pPoint->GetContentIndex();
// Set End and Length const SwPosition *pMark = pPam->GetMark();
m_pEnd = pMark->GetNode().GetTextNode();
m_nPamLen = pMark->GetContentIndex(); if( pPoint->GetNode() == pMark->GetNode() )
m_nPamLen = m_nPamLen - pPoint->GetContentIndex();
}
SwHyphArgs aHyphArg( pPam, rCursorPos, pPageCnt, pPageSt );
SwNodeIndex aTmpIdx( pPam->GetMark()->GetNode(), 1 );
GetNodes().ForEach( pPam->GetPoint()->GetNode(), aTmpIdx.GetNode(),
lcl_HyphenateNode, &aHyphArg );
aHyphArg.SetPam( pPam ); return aHyphArg.GetHyphWord(); // will be set by lcl_HyphenateNode
}
// Save the current values to add them as automatic entries to AutoCorrect. void SwDoc::SetAutoCorrExceptWord( std::unique_ptr<SwAutoCorrExceptWord> pNew )
{
mpACEWord = std::move(pNew);
}
void SwDoc::CountWords( const SwPaM& rPaM, SwDocStat& rStat )
{ // This is a modified version of SwDoc::TransliterateText auto [pStart, pEnd] = rPaM.StartEnd(); // SwPosition*
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.