34#include <com/sun/star/linguistic2/XHyphenator.hpp>
35#include <com/sun/star/linguistic2/XHyphenatedWord.hpp>
36#include <osl/diagnose.h>
47class 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();
74PaMIntoCursorShellRing::~PaMIntoCursorShellRing()
77 RemoveFromRing(m_rDelPam, m_pPrevDelPam);
78 RemoveFromRing(m_rCursor, m_pPrevCursor);
81void 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)
170 if( 1 == rText.getLength() )
186 assert(nSourceLength == 1);
215 bool bDoReplace =
true;
216 sal_Int32
const nLen = rText.getLength();
249 assert(
pos.second !=
pos.first->Len());
254 pos.first->GetText().getLength(),
pos.second + nSourceLength) );
264 pos.first->GetText().getLength(),
pos.second + nSourceLength) );
273 if( 1 == rText.getLength() )
298 sal_uInt16 nWhich = rPool.
GetWhich( nSlotId,
false );
339 OUString
const* pStr(
nullptr);
349 pTextNd; pTextNd =
m_oIndex->GetNode().GetTextNode())
353 if (pFrame && !pFrame->
GetText().isEmpty())
359 if (pFrame && !pFrame->
GetText().isEmpty() &&
381 OSL_ENSURE( pTextNd,
"where is the TextNode?" );
384 if( nEndPos == rSttPos )
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()->GetNode() == ranges.front()->GetMark()->GetNode());
435 *ranges.front(), pFnd->
GetLong(),
false);
436 for (
auto it = ranges.begin() + 1; it != ranges.end(); ++it)
461 OSL_ENSURE( !
m_oIndex,
"who has not deleted his Index?" );
469 SwPaM aCpyPam( aSttIdx );
494 pTextNd =
m_oIndex->GetNode().GetTextNode();
502 if( bRet && pPara && pTextNd )
518 OSL_ENSURE( pTextNd,
"where is the TextNode?" );
521 if( nEndPos == rSttPos )
533 const OUString sFrameText = pFrame->
GetText();
538 OUString sWord(sFrameText.copy(rSttPos, nEndPos - rSttPos));
540 uno::Reference< linguistic2::XHyphenator > xHyph;
542 OUStringBuffer sDisambiguatedWord;
544 const ::css::uno::Sequence< ::css::beans::PropertyValue >
aProperties;
545 css::uno::Reference< css::linguistic2::XHyphenatedWord > xHyphWord;
546 for (
int i = 0;
i+1 < sWord.getLength();
i++ )
548 xHyphWord = xHyph->hyphenate( sWord,
553 if (xHyphWord.is() && xHyphWord->getHyphenationPos()+1 ==
i && !xHyphWord->isAlternativeSpelling())
557 sDisambiguatedWord.append(sWord[
i]);
559 sDisambiguatedWord.append(sWord[sWord.getLength()-1]);
563 if (pFormatter && !sWord.isEmpty())
565 const Color* pColor =
nullptr;
571 bool bHasBracket = sWord.endsWith(
"]");
573 sDisambiguatedWord.append(
"]");
574 OUString
sPrefix(
"[NatNum12 " + sDisambiguatedWord +
"0");
578 sConverted = sConverted +
"]";
585 if (bRet && nEndPos <= sFrameText.getLength())
598 const OUString& rExceptWord,
604 nNode,
nPos, rExceptWord, cChar, eLang ));
635 if (ACFlags::CapitalStartWord &
m_nFlags)
637 else if (ACFlags::CapitalStartSentence &
m_nFlags)
663 n != pTextNd->
GetText().getLength() ))
677 if( nStart == pTextNd->
GetText().getLength() )
684 sal_Int32 nAttrStart;
686 for(
size_t n = 0;
n < nSize; ++
n )
690 if( nAttrStart > nStart )
693 const sal_Int32* pAttrEnd;
694 if(
nullptr != ( pAttrEnd = pHt->
End() ) &&
695 ( ( nAttrStart < nStart &&
697 : nStart <= *pAttrEnd )) ||
698 ( nStart == nAttrStart &&
699 ( nAttrStart == *pAttrEnd || !nStart ))) )
703 GetItemState( pHt->
Which(),
false, &pItem ) ||
@ CheckPosInFly
check if target position is in fly anchored at source range
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...
PropertiesInfo aProperties
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, SwCopyFlags flags) const =0
Copy a selected content range to a position.
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
virtual bool ReplaceRange(SwPaM &rPam, const OUString &rNewStr, const bool bRegExReplace)=0
Replace selected range in a TextNode with string.
virtual bool InsertString(const SwPaM &rRg, const OUString &, const SwInsertFlags nInsertMode=SwInsertFlags::EMPTYEXPAND)=0
Insert string into existing text node at position rRg.Point().
virtual bool HasRedline(const SwPaM &rPam, RedlineType nType, bool bStartOrEndInRange) const =0
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void SetWhich(sal_uInt16 nId)
SvxAutoCorrect * GetAutoCorrect()
static SvxAutoCorrCfg & Get()
bool AddWordStartException(const OUString &rNew, LanguageType eLang)
OUString GetAutoCorrFileName(const LanguageTag &rLanguageTag, bool bNewFile=false, bool bTstUserExist=false, bool bUnlocalized=false) const
bool AddCplSttException(const OUString &rNew, LanguageType eLang)
const SvxAutocorrWord * SearchWordsInList(std::u16string_view rTxt, sal_Int32 &rStt, sal_Int32 nEndPos, SvxAutoCorrDoc &rDoc, LanguageTag &rLang)
const OUString & GetShort() const
const OUString & GetLong() const
virtual LanguageType GetLanguage(sal_Int32 nPos) const override
virtual bool ReplaceRange(sal_Int32 nPos, sal_Int32 nLen, const OUString &rText) override
virtual bool Replace(sal_Int32 nPos, const OUString &rText) override
virtual bool TransliterateRTLWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, bool bApply=false) override
virtual void SaveCpltSttWord(ACFlags nFlag, sal_Int32 nPos, const OUString &rExceptWord, sal_Unicode cChar) override
void DeleteSel(SwPaM &rDelPam)
virtual bool SetINetAttr(sal_Int32 nStt, sal_Int32 nEnd, const OUString &rURL) override
virtual bool Delete(sal_Int32 nStt, sal_Int32 nEnd) override
virtual void SetAttr(sal_Int32 nStt, sal_Int32 nEnd, sal_uInt16 nSlotId, SfxPoolItem &) override
void DeleteSelImpl(SwPaM &rDelPam)
virtual bool ChgAutoCorrWord(sal_Int32 &rSttPos, sal_Int32 nEndPos, SvxAutoCorrect &rACorrect, OUString *pPara) override
virtual bool Insert(sal_Int32 nPos, const OUString &rText) override
virtual ~SwAutoCorrDoc() override
SwAutoCorrDoc(SwEditShell &rEditShell, SwPaM &rPam, sal_Unicode cIns=0)
virtual OUString const * GetPrevPara(bool bAtNormalPos) override
Return the text of a previous paragraph.
std::optional< SwNodeIndex > m_oIndex
bool m_bUndoIdInitialized
bool CheckDelChar(const SwPosition &rPos)
void CheckChar(const SwPosition &rPos, sal_Unicode cChar)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
virtual sal_Int32 Len() const
SwShellCursor * GetCursor_()
bool IsAutoFormatRedline() const
IDocumentContentOperations const & getIDocumentContentOperations() const
void SetAutoCorrExceptWord(std::unique_ptr< SwAutoCorrExceptWord > pNew)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
bool DontExpandFormat(const SwPosition &rPos, bool bFlag=true)
const SwAttrPool & GetAttrPool() const
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
void SetFormatItemByAutoFormat(const SwPaM &rPam, const SfxItemSet &)
void RestoreDontExpandItems(const SwPosition &rPos)
std::unique_ptr< SfxItemSet > m_pDontExpandItems
void SaveDontExpandItems(const SwPosition &rPos)
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
bool IsRightToLeft() const
SwRootFrame * getRootFrame()
Marks a node in the document model.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwTableNode * FindTableNode()
Search table node, in which it is.
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
SwContentNode * GoNext(SwNodeIndex *) const
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
SwNode & GetPointNode() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
SwContentNode * GetPointContentNode() const
const SwPosition * GetPoint() const
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding).
SwShellCursor * GetPrev()
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SfxPoolItem & GetAttr() const
const sal_Int32 * End() const
sal_Int32 GetStart() const
void SetDontExpand(bool bDontExpand)
bool BeginGetDoc(sal_uInt16)
sal_uInt16 GetIndex(const OUString &) const
Represents the visualization of a paragraph.
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
LanguageType GetLangOfChar(TextFrameIndex nIndex, sal_uInt16 nScript, bool bNoChar=false) const
std::pair< SwTextNode *, sal_Int32 > MapViewToModel(TextFrameIndex nIndex) const
map position in potentially merged text frame to SwPosition
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
SwTextNode const * GetTextNodeForParaProps() const
SwTextNode is a paragraph in the document model.
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.
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
int GetAttrOutlineLevel() const
Returns outline level of this text node.
SwpHints * GetpSwpHints()
const OUString & GetText() const
SwRootFrame * GetLayout() const
SwTextAttr * Get(size_t nPos) const
void merge(RingContainer< value_type > aDestRing)
Merges two ring containers.
ring_container GetRingContainer()
#define CH_TXTATR_BREAKWORD
WhichRangesContainer const aCharFormatSetRange(svl::Items< RES_CHRATR_BEGIN, RES_CHRATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1 >)
LanguageType GetAppLanguage()
#define LANGUAGE_USER_HUNGARIAN_ROVAS
double getLength(const B2DPolygon &rCandidate)
constexpr OUStringLiteral first
void GotoNextLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
void GotoPrevLayoutTextFrame(SwNodeIndex &rIndex, SwRootFrame const *const pLayout)
bool GetRanges(std::vector< std::shared_ptr< SwUnoCursor > > &rRanges, SwDoc &rDoc, SwPaM const &rDelPam)
void SetAllScriptItem(SfxItemSet &rSet, const SfxPoolItem &rItem)
Marks a position in the document model.
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.
SwNodeOffset GetNodeIndex() const
sal_Int32 GetContentIndex() const
uno::Reference< linguistic2::XHyphenator > GetHyphenator()