45#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
46#include <osl/diagnose.h>
54 const SwNode* pInsertPos,
bool const isForceToStartPos)
57 for(
const SaveFly & rSave : rArr)
63 if (rSave.isAtInsertNode || isForceToStartPos)
65 if( pInsertPos !=
nullptr )
67 if (aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_PARA)
75 assert(aAnchor.
GetAnchorId() == RndStdIds::FLY_AT_CHAR);
92 : rSave.nContentIndex);
111 auto pSpz = rSpzs[
n];
115 ((RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()) ||
116 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId())) &&
124 rArr.push_back( aSave );
129 pSpz->SetFormatAttr(aAnchor);
156 pFormat = rFormats[
n];
161 ((RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()) ||
162 (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId())) &&
165 (*pContentIdx >= rInsPos.
GetNode() ||
168 bool bInsPos =
false;
170 if ( (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId()
172 || (RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()
177 || (RndStdIds::FLY_AT_PARA == pAnchor->
GetAnchorId()
179 || (RndStdIds::FLY_AT_CHAR == pAnchor->
GetAnchorId()
180 && (bInsPos = (rInsPos == *pAPos))))
193 rArr.push_back( aSave );
210 std::optional<sal_Int32> oMkContentIdx, std::optional<sal_Int32> oPtContentIdx)
212 assert(oMkContentIdx.has_value() == oPtContentIdx.has_value());
224 for (
auto i = rTable.
size();
i; )
234 || ((rAnch.
GetAnchorId() == RndStdIds::FLY_AT_CHAR)
246 GetNode().EndOfSectionNode() );
248 if (
i > rTable.
size())
250 else if (
i == rTable.
size() || pFormat != rTable[
i])
251 i = std::distance(rTable.
begin(), rTable.
find(pFormat));
257 if (
i > rTable.
size())
268 : mnSaveContent( nCnt )
281 && *pRedl->
Start() < aSrcPos )
315 std::vector<sal_uInt16> aResult;
319 for (sal_uInt16 j = rPair.first; j <= rPair.second; j++)
320 aResult.push_back(j);
333 auto [pStt, pEnd] = rPam.
StartEnd();
339 rJoinText =
nullptr != pEndNd;
343 bool bExchange = pStt == rPam.
GetPoint();
344 if( !pStt->GetContentIndex() &&
345 pEndNd->
GetText().getLength() != pEnd->GetContentIndex())
346 bExchange = !bExchange;
349 rJoinPrev = rPam.
GetPoint() == pStt;
350 OSL_ENSURE( !pStt->GetContentIndex() &&
351 pEndNd->
GetText().getLength() != pEnd->GetContentIndex()
420 if( !pContentStore->Empty() )
421 pContentStore->Restore( rDoc, aIdx.
GetIndex() );
461 std::vector<sal_uInt16> aShorts =
497 linguistic2::SingleProofreadingError* pArray = rResult.aErrors.getArray();
501 for( sal_Int32
i = 0;
i < rResult.aErrors.getLength(); ++
i )
503 const linguistic2::SingleProofreadingError &rError = rResult.aErrors[
i];
507 pArray[j] = pArray[
i];
512 if( rResult.aErrors.getLength() > j )
513 rResult.aErrors.realloc( j );
517 uno::Reference< XSpellChecker1 >
const &xSpeller,
518 sal_uInt16* pPageCnt, sal_uInt16* pPageSt,
526 std::unique_ptr<SwSpellArgs> pSpellArgs;
530 pConvArgs->
SetEnd(*pEndPos);
533 pSpellArgs.reset(
new SwSpellArgs( xSpeller, *pSttPos, *pEndPos, bGrammarCheck ));
539 if( nCurrNd <= nEndNd )
556 else if( !
static_cast<SwTextFrame*
>(pContentFrame)->IsHiddenNow() )
558 if( pPageCnt && *pPageCnt && pPageSt )
564 if( *pPageCnt < *pPageSt )
565 *pPageCnt = *pPageSt;
568 if( nPageNr >= *pPageSt )
569 nStat = nPageNr - *pPageSt + 1;
571 nStat = nPageNr + *pPageCnt - *pPageSt + 1;
575 sal_Int32 nBeginGrammarCheck = 0;
576 sal_Int32 nEndGrammarCheck = 0;
577 if( pSpellArgs && pSpellArgs->bIsGrammarCheck)
579 nBeginGrammarCheck = &pSpellArgs->pStartPos->GetNode() == pNd ? pSpellArgs->pStartPos->GetContentIndex() : 0;
581 if( nBeginGrammarCheck )
588 if( aOrigPos != *aCursor.
GetPoint() )
593 nEndGrammarCheck = (&pSpellArgs->pEndPos->GetNode() == pNd)
594 ? pSpellArgs->pEndPos->GetContentIndex()
605 nSpellErrorPosition = pSpellArgs->pStartPos->GetContentIndex() > pSpellArgs->pEndPos->GetContentIndex() ?
606 pSpellArgs->pEndPos->GetContentIndex() :
607 pSpellArgs->pStartPos->GetContentIndex();
608 if( nCurrNd != nEndNd )
616 if( pSpellArgs && pSpellArgs->bIsGrammarCheck )
618 uno::Reference< linguistic2::XProofreadingIterator > xGCIterator(
GetGCIterator() );
619 if (xGCIterator.is())
624 const OUString& aExpandText = aConversionMap.
getViewText();
630 linguistic2::ProofreadingResult aResult;
635 aResult = xGCIterator->checkSentenceAtPosition(
636 xDoc, xFlatPara, aExpandText, lang::Locale(), nBeginGrammarCheck, -1, -1 );
641 bGrammarErrors = aResult.aErrors.hasElements();
643 if( aResult.nStartOfNextSentencePosition <= nBeginGrammarCheck )
646 nBeginGrammarCheck = aResult.nStartOfNextSentencePosition;
648 while( nSpellErrorPosition > aResult.nBehindEndOfSentencePosition && !bGrammarErrors && aResult.nBehindEndOfSentencePosition < nEndGrammarCheck );
650 if( bGrammarErrors && nSpellErrorPosition >= aResult.nBehindEndOfSentencePosition )
654 const linguistic2::SingleProofreadingError &rError = aResult.aErrors[0];
667 if(
static_cast<SwSectionNode*
>(pNd)->GetSection().IsProtect() ||
678 bGoOn = nCurrNd < nEndNd;
688 aRet <<= pSpellArgs->xSpellAlt;
701 sal_uInt16 *m_pPageCnt;
702 sal_uInt16 *m_pPageSt;
704 sal_Int32 m_nPamStart;
708 SwHyphArgs(
const SwPaM *pPam,
const Point &rPoint,
709 sal_uInt16* pPageCount, sal_uInt16* pPageStart );
710 void SetPam(
SwPaM *pPam )
const;
711 void SetNode(
SwNode& rNew ) { m_aNodeIdx.
Assign(rNew); }
712 inline void SetRange(
const SwNode *pNew );
713 void NextNode() { ++m_aNodeIdx; }
714 sal_uInt16 *GetPageCnt() {
return m_pPageCnt; }
715 sal_uInt16 *GetPageSt() {
return m_pPageSt; }
720SwHyphArgs::SwHyphArgs(
const SwPaM *pPam,
const Point &rCursorPos,
721 sal_uInt16* pPageCount, sal_uInt16* pPageStart )
723 m_pPageCnt( pPageCount ), m_pPageSt( pPageStart )
728 OSL_ENSURE( pPam->
HasMark(),
"SwDoc::Hyphenate: blowing in the wind");
730 "SwDoc::Hyphenate: New York, New York");
746inline void SwHyphArgs::SetRange(
const SwNode *pNew )
748 m_nStart = m_pStart == pNew ? m_nPamStart : 0;
749 m_nEnd = m_pEnd == pNew ? m_nPamStart + m_nPamLen :
SAL_MAX_INT32;
752void SwHyphArgs::SetPam(
SwPaM *pPam )
const
755 pPam->
GetMark()->
Assign( m_aNodeIdx, m_nWordStart + m_nWordLen );
763 SwHyphArgs *pHyphArgs =
static_cast<SwHyphArgs*
>(pArgs);
771 sal_uInt16 *pPageSt = pHyphArgs->GetPageSt();
772 sal_uInt16 *pPageCnt = pHyphArgs->GetPageCnt();
773 if( pPageCnt && *pPageCnt && pPageSt )
779 if( *pPageCnt < *pPageSt )
780 *pPageCnt = *pPageSt;
782 tools::Long nStat = nPageNr >= *pPageSt ? nPageNr - *pPageSt + 1
783 : nPageNr + *pPageCnt - *pPageSt + 1;
786 pHyphArgs->SetRange( pNd );
789 pHyphArgs->SetNode( *pNd );
794 pHyphArgs->NextNode();
800 sal_uInt16* pPageCnt, sal_uInt16* pPageSt )
802 OSL_ENSURE(
this == &pPam->
GetDoc(),
"SwDoc::Hyphenate: strangers in the night");
807 SwHyphArgs aHyphArg( pPam, rCursorPos, pPageCnt, pPageSt );
811 aHyphArg.SetPam( pPam );
812 return aHyphArg.GetHyphWord();
829 auto [pStt, pEnd] = rPaM.
StartEnd();
834 const sal_Int32 nSttCnt = pStt->GetContentIndex();
835 const sal_Int32 nEndCnt = pEnd->GetContentIndex();
838 if( pStt == pEnd && pTNd )
844 if( nSttNd != nEndNd )
854 for( ; aIdx.
GetIndex() < nEndNd; ++aIdx )
858 if( nEndCnt &&
nullptr != ( pTNd = pEnd->GetNode().
GetTextNode() ))
861 else if( pTNd && nSttCnt < nEndCnt )
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
ModelPosition ConvertToModelPosition(sal_Int32 nViewPos) const
Converts a view position into a model position.
const OUString & getViewText() const
sal_Int32 ConvertToViewPosition(sal_Int32 nModelPos) const
Converts a model position into a view position.
std::optional< SwNodeIndex > moSaveIndex
~SaveRedlEndPosForRestore()
SaveRedlEndPosForRestore(const SwNode &rInsIdx, sal_Int32 nContent)
std::vector< SwPosition * > mvSavArr
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Marks a character position inside a document model content node (SwContentNode)
bool HasSwAttrSet() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
bool CanJoinNext(SwNodeIndex *pIdx=nullptr) const
Is it possible to join two nodes? In pIdx the second position can be returned.
const SwAttrSet * GetpSwAttrSet() const
bool GoSentence(SentenceMoveType eMoveType, SwRootFrame const *pLayout=nullptr)
void CorrRel(const SwNode &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
static void CountWords(const SwPaM &rPaM, SwDocStat &rStat)
std::unique_ptr< SwAutoCorrExceptWord > mpACEWord
For the automated takeover of auto-corrected words that are "re-corrected".
IDocumentUndoRedo & GetIDocumentUndoRedo()
void SetAutoCorrExceptWord(std::unique_ptr< SwAutoCorrExceptWord > pNew)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
css::uno::Reference< css::linguistic2::XHyphenatedWord > Hyphenate(SwPaM *pPam, const Point &rCursorPos, sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt)
void DeleteAutoCorrExceptWord()
css::uno::Reference< css::linguistic2::XProofreadingIterator > const & GetGCIterator() const
const SwAttrPool & GetAttrPool() const
const sw::FrameFormats< sw::SpzFrameFormat * > * GetSpzFrameFormats() const
SwDocShell * GetDocShell()
css::uno::Any Spell(SwPaM &, css::uno::Reference< css::linguistic2::XSpellChecker1 > const &, sal_uInt16 *pPageCnt, sal_uInt16 *pPageSt, bool bGrammarCheck, SwRootFrame const *pLayout, SwConversionArgs *pConvArgs=nullptr) const
Operations on the content of the document e.g.
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
sal_uInt16 GetPhyPageNum() const
void AddChangeFlyAnchor(sw::SpzFrameFormat &rFormat)
Marks a node in the document model.
SwNodeOffset GetIndex() const
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset nIdx)
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
Merge
sw_redlinehide: redline node merge state
Merge GetRedlineMergeFlag() const
SwNodeOffset EndOfSectionIndex() const
bool IsCreateFrameWhenHidingRedlines() const
SwContentNode * GetContentNode()
SwNodeType GetNodeType() const
const SwEndNode * EndOfSectionNode() const
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes=SwNodeOffset(1))
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
std::pair< const SwPosition *, const SwPosition * > StartEnd() const
Because sometimes the cost of the operator<= can add up.
const SwPosition * End() const
SwPosition & GetBound(bool bOne=true)
const SwPosition * GetPoint() const
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
vector_type::size_type size_type
The root element of a Writer document layout.
A section node represents the start of a section on the UI, i.e.
Represents the visualization of a paragraph.
bool IsHiddenNow() const
Hidden.
SwTextNode is a paragraph in the document model.
virtual sal_Int32 Len() const override
virtual SwContentNode * JoinNext() override
bool IsGrammarCheckDirty() const
void CutText(SwTextNode *const pDest, const SwContentIndex &rStart, const sal_Int32 nLen)
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
bool CountWords(SwDocStat &rStat, sal_Int32 nStart, sal_Int32 nEnd) const
count words in given range - returns true if we refreshed out count
bool Convert(SwConversionArgs &)
SwGrammarMarkUp * GetGrammarCheck()
bool Spell(SwSpellArgs *)
const OUString & GetText() const
bool Hyphenate(SwInterHyphInfo &rHyphInf)
Interactive hyphenation: we find TextFrame and call its CalcHyph.
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0) override
bool LookForEntry(sal_Int32 nBegin, sal_Int32 nEnd)
static std::shared_ptr< ContentIdxStore > Create()
bool sw_JoinText(SwPaM &rPam, bool bJoinPrev)
void sw_GetJoinFlags(SwPaM &rPam, bool &rJoinText, bool &rJoinPrev)
static bool lcl_HyphenateNode(SwNode *pNd, void *pArgs)
void SaveFlyInRange(const SwNodeRange &rRg, SaveFlyArr &rArr)
void DelFlyInRange(SwNode &rMkNd, SwNode &rPtNd, std::optional< sal_Int32 > oMkContentIdx, std::optional< sal_Int32 > oPtContentIdx)
Delete and move all Flys at the paragraph, that are within the selection.
static std::vector< sal_uInt16 > lcl_RangesToVector(const WhichRangesContainer &pRanges)
Convert list of ranges of whichIds to a corresponding list of whichIds.
void RestFlyInRange(SaveFlyArr &rArr, const SwPosition &rStartPos, const SwNode *pInsertPos, bool const isForceToStartPos)
static void lcl_syncGrammarError(SwTextNode &rTextNode, linguistic2::ProofreadingResult &rResult, const ModelToViewHelper &rConversionMap)
constexpr OUStringLiteral IsHidden(u"IsHidden")
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
WhichRangesContainer const aCharFormatSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1 >)
WhichRangesContainer const aBreakSetRange(svl::Items< RES_PAGEDESC, RES_BREAK >)
void SetProgressState(tools::Long nPosition, SwDocShell const *pDocShell)
std::deque< SaveFly > SaveFlyArr
void CheckResetRedlineMergeFlag(SwTextNode &rNode, Recreate eRecreateMerged)
if first node is First, its frames may need to be moved, never deleted.
void CheckAnchoredFlyConsistency(SwDoc const &rDoc)
void MoveDeletedPrevFrames(const SwTextNode &rDeletedPrev, SwTextNode &rNode)
if first node is deleted & second survives, then the first node's frame will be deleted too; prevent ...
@ Section
SwSectionNode is derived from SwStartNode.
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
data structure to temporarily hold fly anchor positions relative to some location.
void SetEnd(SwPosition &rEnd)
void SetStart(SwPosition &rStart)
Marks a position in the document model.
void Adjust(SwNodeOffset nDelta)
Adjust node position, and resets content position to zero.
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
void SetContent(sal_Int32 nContentIndex)
Set content index, only valid to call this if the position points to a SwContentNode subclass.
const SwContentNode * GetContentNode() const
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
bool IsSelectFrameAnchoredAtPara(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
is a fly anchored at paragraph at rAnchorPos selected?
bool IsDestroyFrameAnchoredAtChar(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
will DelContentIndex destroy a frame anchored at character at rAnchorPos?
std::pair< sal_uInt16, sal_uInt16 > WhichPair