26#include <osl/diagnose.h>
51 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextModified, aNotify->
nParagraph ) );
54 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextParaInserted, aNotify->
nParagraph ) );
57 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextParaRemoved, aNotify->
nParagraph ) );
63 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextHeightChanged, aNotify->
nParagraph ) );
66 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextViewScrolled ) );
69 return std::unique_ptr<SfxHint>(
new SvxEditSourceHint( SfxHintId::EditSourceSelectionChanged ) );
72 return std::unique_ptr<SfxHint>(
new TextHint( SfxHintId::TextProcessNotifications ));
77 OSL_FAIL(
"SvxEditSourceHelper::EENotification2Hint unknown notification" );
82 return std::make_unique<SfxHint>( );
92 std::vector<EECharAttrib> aCharAttribs, aTempCharAttribs;
95 if (!aTempCharAttribs.empty())
97 sal_Int32 nIndex2 = 0;
99 for (
size_t nAttr = 0; nAttr < aTempCharAttribs.size(); ++nAttr)
101 if (nIndex2 < aTempCharAttribs[nAttr].nStart)
103 EECharAttrib aEEAttr(nIndex2, aTempCharAttribs[nAttr].nStart);
104 aCharAttribs.insert(aCharAttribs.begin() + nAttr, aEEAttr);
106 nIndex2 = aTempCharAttribs[nAttr].nEnd;
107 aCharAttribs.push_back(aTempCharAttribs[nAttr]);
109 if ( nIndex2 != nParaLen )
112 aCharAttribs.push_back(aEEAttr);
116 sal_Int32 nCurrIndex;
117 sal_Int32 nClosestStartIndex_s = 0, nClosestStartIndex_e = 0;
118 for (
auto const& charAttrib : aCharAttribs)
120 nCurrIndex = charAttrib.nStart;
122 if( nCurrIndex > nClosestStartIndex_s &&
125 nClosestStartIndex_s = nCurrIndex;
127 nCurrIndex = charAttrib.nEnd;
128 if ( nCurrIndex > nClosestStartIndex_e &&
131 nClosestStartIndex_e = nCurrIndex;
134 sal_Int32 nClosestStartIndex = std::max(nClosestStartIndex_s, nClosestStartIndex_e);
137 sal_Int32 nClosestEndIndex_s, nClosestEndIndex_e;
138 nClosestEndIndex_s = nClosestEndIndex_e = rEE.
GetTextLen(nPara);
139 for (
auto const& charAttrib : aCharAttribs)
141 nCurrIndex = charAttrib.nEnd;
143 if( nCurrIndex >
nIndex &&
144 nCurrIndex < nClosestEndIndex_e )
146 nClosestEndIndex_e = nCurrIndex;
148 nCurrIndex = charAttrib.nStart;
149 if ( nCurrIndex >
nIndex &&
150 nCurrIndex < nClosestEndIndex_s)
152 nClosestEndIndex_s = nCurrIndex;
155 sal_Int32 nClosestEndIndex = std::min(nClosestEndIndex_s, nClosestEndIndex_e);
157 nStartIndex = nClosestStartIndex;
158 nEndIndex = nClosestEndIndex;
163 EPosition aStartPos( nPara, nStartIndex ), aEndPos( nPara, nEndIndex );
165 sal_Int32 nCrrntParaLen = rEE.
GetTextLen(nPara);
167 if ( aStartPos.nIndex == 0 )
170 for ( sal_Int32 nParaIdx = nPara-1; nParaIdx >= 0; nParaIdx-- )
175 sal_Int32 nStartIdx, nEndIdx;
178 if ( aSet == aCrrntSet )
180 aStartPos.nPara = nParaIdx;
181 aStartPos.nIndex = nStartIdx;
182 if ( aStartPos.nIndex != 0 )
191 if ( aEndPos.
nIndex == nCrrntParaLen )
194 for ( sal_Int32 nParaIdx = nPara+1; nParaIdx < nParaCount; nParaIdx++ )
199 sal_Int32 nStartIdx, nEndIdx;
202 if ( aSet == aCrrntSet )
204 aEndPos.
nPara = nParaIdx;
206 if ( aEndPos.
nIndex != nLen )
215 if ( aStartPos.nPara > 0 )
217 for ( sal_Int32
i = 0;
i < aStartPos.nPara;
i++ )
222 nStartIndex += aStartPos.nIndex;
224 if ( aEndPos.
nPara > 0 )
226 for ( sal_Int32
i = 0;
i < aEndPos.
nPara;
i++ )
231 nEndIndex += aEndPos.
nIndex;
236 return bIsVertical ?
Point( -rPoint.
Y() + rEESize.
Height(), rPoint.
X() ) : rPoint;
241 return bIsVertical ?
Point( rPoint.
Y(), -rPoint.
X() + rEESize.
Height() ) : rPoint;
sal_Int32 GetParagraphCount() const
SfxItemSet GetAttribs(sal_Int32 nPara, sal_Int32 nStart, sal_Int32 nEnd, GetAttribsFlags nFlags=GetAttribsFlags::ALL) const
sal_Int32 GetTextLen() const
void GetCharAttribs(sal_Int32 nPara, std::vector< EECharAttrib > &rLst) const
constexpr tools::Long Y() const
constexpr tools::Long X() const
constexpr tools::Long Height() const
static void GetAttributeRun(sal_Int32 &nStartIndex, sal_Int32 &nEndIndex, const EditEngine &rEE, sal_Int32 nPara, sal_Int32 nIndex, bool bInCell=false)
Calculate attribute run for EditEngines.
static Point EEToUserSpace(const Point &rPoint, const Size &rEESize, bool bIsVertical)
Convert point from edit engine to user coordinate space.
static Point UserSpaceToEE(const Point &rPoint, const Size &rEESize, bool bIsVertical)
Convert point from user to edit engine coordinate space.
static ::std::unique_ptr< SfxHint > EENotification2Hint(EENotify const *aNotify)
Translates EditEngine notifications into broadcastable hints.
Extends TextHint by two additional parameters which are necessary for the SfxHintId::EditSourceParasM...
SvxEditSourceHint(SfxHintId nId)
@ EE_NOTIFY_PARAGRAPHSMOVED
Multiple paragraphs have been removed from the EditEngine.
@ EE_NOTIFY_TEXTVIEWSCROLLED
The view area of the EditEngine scrolled.
@ EE_NOTIFY_PARAGRAPHREMOVED
A paragraph was removed from the EditEngine.
@ EE_NOTIFY_TEXTVIEWSELECTIONCHANGED
The selection and/or the cursor position has changed.
@ EE_NOTIFY_PARAGRAPHINSERTED
A paragraph was inserted into the EditEngine.
@ EE_NOTIFY_PROCESSNOTIFICATIONS
The EditEngine is in a valid state again. Process pending notifications.
@ EE_NOTIFY_TEXTVIEWSELECTIONCHANGED_ENDD_PARA
@ EE_NOTIFY_TextHeightChanged
The height of at least one paragraph has changed.
@ EE_NOTIFY_TEXTMODIFIED
EditEngine text was modified.
EENotifyType eNotificationType