34 #include <com/sun/star/linguistic2/XHyphenator.hpp>
35 #include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
36 #include <osl/diagnose.h>
47 class PaMIntoCursorShellRing
49 SwPaM &m_rDelPam, &m_rCursor;
53 static void RemoveFromRing(
SwPaM& rPam,
SwPaM const * pPrev );
56 ~PaMIntoCursorShellRing();
63 , m_rCursor(rShCursor)
67 m_pPrevDelPam = m_rDelPam.
GetPrev();
68 m_pPrevCursor = m_rCursor.
GetPrev();
74 PaMIntoCursorShellRing::~PaMIntoCursorShellRing()
77 RemoveFromRing(m_rDelPam, m_pPrevDelPam);
78 RemoveFromRing(m_rCursor, m_pPrevCursor);
81 void PaMIntoCursorShellRing::RemoveFromRing(
SwPaM& rPam,
SwPaM const * pPrev )
89 }
while( p != pPrev );
94 : m_rEditSh( rEditShell ), m_rCursor( rPam )
95 , m_nEndUndoCounter(0)
96 , m_bUndoIdInitialized( cIns == 0 )
112 std::vector<std::shared_ptr<SwUnoCursor>> ranges;
119 for (
auto const& pCursor : ranges)
147 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
162 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
170 if( 1 == rText.getLength() )
186 assert(nSourceLength == 1);
202 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
205 std::pair<SwTextNode *, sal_Int32>
const pos(pFrame->MapViewToModel(
TextFrameIndex(nPos)));
208 if (pPam->GetPoint()->nNode != *
pos.first
209 || pPam->GetPoint()->nContent !=
pos.second)
215 bool bDoReplace =
true;
216 sal_Int32
const nLen = rText.getLength();
217 for (sal_Int32
n = 0;
n < nLen &&
n + nPos < pFrame->GetText().getLength(); ++
n)
231 if ( bDoReplace && !pFrame->getRootFrame()->IsHideRedlines() &&
243 if (nPos == pFrame->GetText().getLength())
249 assert(
pos.second !=
pos.first->Len());
253 pPam->GetPoint()->nContent = std::min<sal_Int32>(
254 pos.first->GetText().getLength(),
pos.second + nSourceLength);
263 pPam->GetPoint()->nContent = std::min<sal_Int32>(
264 pos.first->GetText().getLength(),
pos.second + nSourceLength);
273 if( 1 == rText.getLength() )
291 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
298 sal_uInt16 nWhich = rPool.
GetWhich( nSlotId,
false );
316 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
339 OUString
const* pStr(
nullptr);
349 pTextNd; pTextNd =
m_pIndex->GetNode().GetTextNode())
353 if (pFrame && !pFrame->GetText().isEmpty())
359 if (pFrame && !pFrame->GetText().isEmpty() &&
360 0 == pFrame->GetTextNodeForParaProps()->GetAttrOutlineLevel())
362 pStr = & pFrame->GetText();
381 OSL_ENSURE( pTextNd,
"where is the TextNode?" );
384 if( nEndPos == rSttPos )
392 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
396 const OUString sFrameText = pFrame->GetText();
398 sFrameText, rSttPos, nEndPos, *
this, aLanguageTag);
403 const bool replaceLastChar = sFrameText.getLength() > nEndPos && pFnd->
GetShort()[0] ==
':'
408 SwPaM aPam(aStartPos, aEndPos);
419 const bool bLastCharIsPoint
420 = nEndPos < sFrameText.getLength() && (
'.' == sFrameText[nEndPos]);
421 if( !bLastCharIsPoint || pFnd->
GetLong().isEmpty() ||
425 std::vector<std::shared_ptr<SwUnoCursor>> ranges;
431 else if (!ranges.empty())
433 assert(ranges.front()->GetPoint()->nNode == ranges.front()->GetMark()->nNode);
435 *ranges.front(), pFnd->
GetLong(),
false);
436 for (
auto it = ranges.begin() + 1; it != ranges.end(); ++it)
454 if( USHRT_MAX != nPos && aTBlks.BeginGetDoc( nPos ) )
461 OSL_ENSURE( !
m_pIndex,
"who has not deleted his Index?" );
466 SwDoc* pAutoDoc = aTBlks.GetDoc();
469 SwPaM aCpyPam( aSttIdx );
483 pContentNd, pContentNd ? pContentNd->Len() : 0);
495 pTextNd =
m_pIndex->GetNode().GetTextNode();
503 if( bRet && pPara && pTextNd )
505 SwTextFrame const*
const pNewFrame(static_cast<SwTextFrame const*>(
519 OSL_ENSURE( pTextNd,
"where is the TextNode?" );
522 if( nEndPos == rSttPos )
530 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
534 const OUString sFrameText = pFrame->GetText();
536 if ( pFrame->IsRightToLeft() || bApply )
539 OUString sWord(sFrameText.copy(rSttPos, nEndPos - rSttPos));
541 uno::Reference< linguistic2::XHyphenator > xHyph;
543 OUStringBuffer sDisambiguatedWord;
545 const ::css::uno::Sequence< ::css::beans::PropertyValue >
aProperties;
546 css::uno::Reference< css::linguistic2::XHyphenatedWord > xHyphWord;
547 for (
int i = 0;
i+1 < sWord.getLength();
i++ )
549 xHyphWord = xHyph->hyphenate( sWord,
554 if (xHyphWord.is() && xHyphWord->getHyphenationPos()+1 ==
i && !xHyphWord->isAlternativeSpelling())
558 sDisambiguatedWord.append(sWord[
i]);
560 sDisambiguatedWord.append(sWord[sWord.getLength()-1]);
564 if (pFormatter && !sWord.isEmpty())
566 const Color* pColor =
nullptr;
568 OUString
sPrefix(
"[NatNum12 " + sDisambiguatedWord.makeStringAndClear() +
"]0");
575 if (bRet && nEndPos <= sFrameText.getLength())
588 const OUString& rExceptWord,
594 nNode, nPos, rExceptWord, cChar, eLang ));
605 SwTextFrame const*
const pFrame(static_cast<SwTextFrame const*>(
625 if (ACFlags::CapitalStartWord &
m_nFlags)
627 else if (ACFlags::CapitalStartSentence & m_nFlags)
653 n != pTextNd->
GetText().getLength() ))
667 if( nStart == pTextNd->
GetText().getLength() )
674 sal_Int32 nAttrStart;
676 for(
size_t n = 0;
n < nSize; ++
n )
680 if( nAttrStart > nStart )
683 const sal_Int32* pAttrEnd;
684 if(
nullptr != ( pAttrEnd = pHt->
End() ) &&
685 ( ( nAttrStart < nStart &&
687 : nStart <= *pAttrEnd )) ||
688 ( nStart == nAttrStart &&
689 ( nAttrStart == *pAttrEnd || !nStart ))) )
693 GetItemState( pHt->
Which(),
false, &pItem ) ||
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rText) override
void merge(RingContainer< value_type > aDestRing)
Merges two ring containers.
Represents the visualization of a paragraph.
SwNode & GetNode(bool bPoint=true) const
void SetDontExpand(bool bDontExpand)
static SvxAutoCorrCfg & Get()
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor >> &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
Marks a position in the document model.
virtual bool HasRedline(const SwPaM &rPam, RedlineType nType, bool bStartOrEndInRange) const =0
const OUString & GetText() const
SwpHints * GetpSwpHints()
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
const SwPosition * GetMark() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
const SvxAutocorrWord * SearchWordsInList(const OUString &rTxt, sal_Int32 &rStt, sal_Int32 nEndPos, SvxAutoCorrDoc &rDoc, LanguageTag &rLang)
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
bool m_bUndoIdInitialized
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
SwShellCursor * GetPrev()
bool AddCplSttException(const OUString &rNew, LanguageType eLang)
IDocumentContentOperations const & getIDocumentContentOperations() const
const OUString & GetShort() const
virtual ~SwAutoCorrDoc() override
void MoveTo(value_type *pDestRing)
Removes this item from its current ring container and adds it to another ring container.
virtual void SaveCpltSttWord(ACFlags nFlag, sal_Int32 nPos, const OUString &rExceptWord, sal_Unicode cChar) override
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
OUString GetAutoCorrFileName(const LanguageTag &rLanguageTag, bool bNewFile=false, bool bTstUserExist=false, bool bUnlocalized=false) const
SwContentNode * GetContentNode(bool bPoint=true) const
#define CH_TXTATR_BREAKWORD
void DeleteSel(SwPaM &rDelPam)
PropertiesInfo aProperties
void RestoreDontExpandItems(const SwPosition &rPos)
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
check if target position is in fly anchored at source range
void SetAllScriptItem(SfxItemSet &rSet, const SfxPoolItem &rItem)
sal_Int32 GetStart() const
void SetFormatItemByAutoFormat(const SwPaM &rPam, const SfxItemSet &)
void SaveDontExpandItems(const SwPosition &rPos)
SwNodeOffset GetIndex() const
void GotoNextLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
std::unique_ptr< SwNodeIndex > m_pIndex
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwShellCursor * GetCursor_()
virtual bool Insert(sal_Int32 nPos, const OUString &rText) override
PaM is Point and Mark: a selection of the document model.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
SwNodeIndex & Assign(SwNodes const &rNds, SwNodeOffset)
#define LANGUAGE_USER_HUNGARIAN_ROVAS
SwTextAttr * Get(size_t nPos) const
const SwPosition * GetPoint() const
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, SwCopyFlags flags) const =0
Copy a selected content range to a position.
SwIndex & Assign(SwIndexReg *, sal_Int32)
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
WhichRangesContainer const aCharFormatSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1 >)
SvxAutoCorrect * GetAutoCorrect()
void DeleteSelImpl(SwPaM &rDelPam)
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Marks a node in the document model.
virtual bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace)=0
Replace selected range in a TextNode with string.
ring_container GetRingContainer()
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
bool AddWordStartException(const OUString &rNew, LanguageType eLang)
void SetAutoCorrExceptWord(std::unique_ptr< SwAutoCorrExceptWord > pNew)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTextNode is a paragraph in the document model.
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Return the text of a previous paragraph.
virtual bool TransliterateRTLWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, bool bApply=false) override
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
bool CheckDelChar(const SwPosition &rPos)
bool DontExpandFormat(const SwPosition &rPos, bool bFlag=true)
void SetWhich(sal_uInt16 nId)
sal_Int32 GetIndex() const
LanguageType GetAppLanguage()
const sal_Int32 * End() const
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
bool IsAutoFormatRedline() const
SwTableNode * FindTableNode()
Search table node, in which it is.
void GotoPrevLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
const SfxPoolItem & GetAttr() const
uno::Reference< linguistic2::XHyphenator > GetHyphenator()
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const OUString & GetLong() const
std::unique_ptr< SfxItemSet > m_pDontExpandItems
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
SwRootFrame * GetLayout() const
virtual bool DeleteAndJoin(SwPaM &)=0
complete delete of a given PaM
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
SwAutoCorrDoc(SwEditShell &rEditShell, SwPaM &rPam, sal_Unicode cIns=0)
virtual bool Replace(sal_Int32 nPos, const OUString &rText) override
SwContentNode * GoNext(SwNodeIndex *) const
const SwAttrPool & GetAttrPool() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.