editeng: change the ParaPortion parameter from pointer to ref.
In most cases we expect the ParaPortion pointer to be not-null, so it makes more sense to have the ParaPortion parameter as a ref. and not a raw pointer. Change-Id: I1659a1978e2615982e4ce6bdd99c9d9f3719e7bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162040 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
ee880f953e
commit
01092e6329
@@ -865,16 +865,14 @@ EditSelection EditEngine::SelectWord(
|
||||
return pImpEditEngine->SelectWord(rCurSelection, nWordType);
|
||||
}
|
||||
|
||||
tools::Long EditEngine::GetXPos(
|
||||
const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const
|
||||
tools::Long EditEngine::GetXPos(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const
|
||||
{
|
||||
return pImpEditEngine->GetXPos(pParaPortion, rLine, nIndex, bPreferPortionStart);
|
||||
return pImpEditEngine->GetXPos(rParaPortion, rLine, nIndex, bPreferPortionStart);
|
||||
}
|
||||
|
||||
Range EditEngine::GetLineXPosStartEnd(
|
||||
const ParaPortion* pParaPortion, EditLine const& rLine) const
|
||||
Range EditEngine::GetLineXPosStartEnd(ParaPortion const& rParaPortion, EditLine const& rLine) const
|
||||
{
|
||||
return pImpEditEngine->GetLineXPosStartEnd(pParaPortion, rLine);
|
||||
return pImpEditEngine->GetLineXPosStartEnd(rParaPortion, rLine);
|
||||
}
|
||||
|
||||
bool EditEngine::IsFormatted() const
|
||||
|
||||
@@ -576,7 +576,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
|
||||
nEndIndex = nStartIndex;
|
||||
|
||||
tools::Rectangle aTmpRect(pEditEngine->pImpEditEngine->GetEditCursor(
|
||||
&rInfo.rPortion, *rInfo.pLine, nStartIndex, GetCursorFlags::NONE));
|
||||
rInfo.rPortion, *rInfo.pLine, nStartIndex, GetCursorFlags::NONE));
|
||||
const Size aLineOffset = pEditEngine->pImpEditEngine->getTopLeftDocOffset(rInfo.aArea);
|
||||
aTmpRect.Move(0, aLineOffset.Height());
|
||||
|
||||
@@ -595,7 +595,7 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
|
||||
// Now that we have Bidi, the first/last index doesn't have to be the 'most outside' position
|
||||
if (!bPartOfLine)
|
||||
{
|
||||
Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(&rInfo.rPortion, *rInfo.pLine);
|
||||
Range aLineXPosStartEnd = pEditEngine->GetLineXPosStartEnd(rInfo.rPortion, *rInfo.pLine);
|
||||
aTmpRect.SetLeft(aLineXPosStartEnd.Min());
|
||||
aTmpRect.SetRight(aLineXPosStartEnd.Max());
|
||||
aTmpRect.Move(aLineOffset.Width(), 0);
|
||||
@@ -616,8 +616,8 @@ void ImpEditView::DrawSelectionXOR( EditSelection aTmpSel, vcl::Region* pRegion,
|
||||
|
||||
DBG_ASSERT(nTmpEndIndex > nTmpStartIndex, "DrawSelectionXOR, Start >= End?");
|
||||
|
||||
tools::Long nX1 = pEditEngine->GetXPos(&rInfo.rPortion, *rInfo.pLine, nTmpStartIndex, true);
|
||||
tools::Long nX2 = pEditEngine->GetXPos(&rInfo.rPortion, *rInfo.pLine, nTmpEndIndex);
|
||||
tools::Long nX1 = pEditEngine->GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpStartIndex, true);
|
||||
tools::Long nX2 = pEditEngine->GetXPos(rInfo.rPortion, *rInfo.pLine, nTmpEndIndex);
|
||||
|
||||
aTmpRect.SetLeft(std::min(nX1, nX2));
|
||||
aTmpRect.SetRight(std::max(nX1, nX2));
|
||||
@@ -1103,8 +1103,7 @@ boost::property_tree::ptree getHyperlinkPropTree(const OUString& sText, const OU
|
||||
|
||||
} // End of anon namespace
|
||||
|
||||
tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags, sal_Int32& nTextPortionStart,
|
||||
const ParaPortion* pParaPortion) const
|
||||
tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags, sal_Int32& nTextPortionStart, ParaPortion const& rParaPortion) const
|
||||
{
|
||||
tools::Rectangle aEditCursor = pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, nShowCursorFlags );
|
||||
if ( !IsInsertMode() && !aEditSelection.HasRange() )
|
||||
@@ -1115,8 +1114,8 @@ tools::Rectangle ImpEditView::ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nS
|
||||
aEditCursor.SetLeft( pEditEngine->pImpEditEngine->PaMtoEditCursor( aPaM, GetCursorFlags::TextOnly|GetCursorFlags::PreferPortionStart ).Left() );
|
||||
aEditCursor.SetRight( aEditCursor.Left() );
|
||||
|
||||
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
|
||||
const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[nTextPortion];
|
||||
sal_Int32 nTextPortion = rParaPortion.GetTextPortions().FindPortion( aPaM.GetIndex(), nTextPortionStart, true );
|
||||
const TextPortion& rTextPortion = rParaPortion.GetTextPortions()[nTextPortion];
|
||||
if ( rTextPortion.GetKind() == PortionKind::TAB )
|
||||
{
|
||||
aEditCursor.AdjustRight(rTextPortion.GetSize().Width() );
|
||||
@@ -1163,7 +1162,7 @@ tools::Rectangle ImpEditView::GetEditCursor() const
|
||||
nShowCursorFlags |= GetCursorFlags::PreferPortionStart;
|
||||
}
|
||||
|
||||
return ImplGetEditCursor(aPaM, nShowCursorFlags, nTextPortionStart, pParaPortion);
|
||||
return ImplGetEditCursor(aPaM, nShowCursorFlags, nTextPortionStart, *pParaPortion);
|
||||
}
|
||||
|
||||
void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
|
||||
@@ -1210,7 +1209,7 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
|
||||
nShowCursorFlags |= GetCursorFlags::PreferPortionStart;
|
||||
}
|
||||
|
||||
tools::Rectangle aEditCursor = ImplGetEditCursor(aPaM, nShowCursorFlags, nTextPortionStart, pParaPortion);
|
||||
tools::Rectangle aEditCursor = ImplGetEditCursor(aPaM, nShowCursorFlags, nTextPortionStart, *pParaPortion);
|
||||
|
||||
if ( bGotoCursor ) // && (!pEditEngine->pImpEditEngine->GetStatus().AutoPageSize() ) )
|
||||
{
|
||||
|
||||
@@ -344,8 +344,7 @@ protected:
|
||||
void HideDDCursor();
|
||||
|
||||
void ImplDrawHighlightRect(OutputDevice& rTarget, const Point& rDocPosTopLeft, const Point& rDocPosBottomRight, tools::PolyPolygon* pPolyPoly, bool bLOKCalcRTL);
|
||||
tools::Rectangle ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags,
|
||||
sal_Int32& nTextPortionStart, const ParaPortion* pParaPortion) const;
|
||||
tools::Rectangle ImplGetEditCursor(EditPaM& aPaM, GetCursorFlags nShowCursorFlags, sal_Int32& nTextPortionStart, ParaPortion const& rParaPortion) const;
|
||||
|
||||
public:
|
||||
ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindow );
|
||||
@@ -643,7 +642,7 @@ private:
|
||||
|
||||
void ParaAttribsChanged( ContentNode const * pNode, bool bIgnoreUndoCheck = false );
|
||||
void TextModified();
|
||||
void CalcHeight( ParaPortion* pPortion );
|
||||
void CalcHeight(ParaPortion& rParaPortion);
|
||||
|
||||
void InsertUndo( std::unique_ptr<EditUndo> pUndo, bool bTryMerge = false );
|
||||
void ResetUndoManager();
|
||||
@@ -656,10 +655,10 @@ private:
|
||||
std::tuple<const ParaPortion*, const EditLine*, tools::Long> GetPortionAndLine(Point aDocPos);
|
||||
EditPaM GetPaM( Point aDocPos, bool bSmart = true );
|
||||
bool IsTextPos(const Point& rDocPos, sal_uInt16 nBorder);
|
||||
tools::Long GetXPos(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
|
||||
tools::Long GetPortionXOffset(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const;
|
||||
sal_Int32 GetChar(const ParaPortion* pParaPortion, EditLine const& rLine, tools::Long nX, bool bSmart = true);
|
||||
Range GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLine const& rLine) const;
|
||||
tools::Long GetXPos(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
|
||||
tools::Long GetPortionXOffset(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const;
|
||||
sal_Int32 GetChar(ParaPortion const& rParaPortion, EditLine const& rLine, tools::Long nX, bool bSmart = true);
|
||||
Range GetLineXPosStartEnd(ParaPortion const& rParaPortion, EditLine const& rLine) const;
|
||||
|
||||
void ParaAttribsToCharAttribs( ContentNode* pNode );
|
||||
void GetCharAttribs( sal_Int32 nPara, std::vector<EECharAttrib>& rLst ) const;
|
||||
@@ -678,17 +677,17 @@ private:
|
||||
tools::Long calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem);
|
||||
bool CreateLines(sal_Int32 nPara, sal_uInt32 nStartPosY);
|
||||
|
||||
void CreateAndInsertEmptyLine( ParaPortion* pParaPortion );
|
||||
bool FinishCreateLines( ParaPortion* pParaPortion );
|
||||
void CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rStartPos /*, sal_Bool bCreateBlockPortions */ );
|
||||
void RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars );
|
||||
sal_Int32 SplitTextPortion( ParaPortion* pParaPortion, sal_Int32 nPos, EditLine* pCurLine = nullptr );
|
||||
void CreateAndInsertEmptyLine(ParaPortion& rParaPortion);
|
||||
bool FinishCreateLines(ParaPortion& rParaPortion);
|
||||
void CreateTextPortions(ParaPortion& rParaPortion, sal_Int32& rStartPos);
|
||||
void RecalcTextPortion(ParaPortion& rParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars);
|
||||
sal_Int32 SplitTextPortion(ParaPortion& rParaPortion, sal_Int32 nPos, EditLine* pCurLine = nullptr);
|
||||
void SeekCursor( ContentNode* pNode, sal_Int32 nPos, SvxFont& rFont, OutputDevice* pOut = nullptr );
|
||||
void RecalcFormatterFontMetrics( FormatterFontMetric& rCurMetrics, SvxFont& rFont );
|
||||
void CheckAutoPageSize();
|
||||
|
||||
void ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate );
|
||||
void ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine, tools::Long nRemainingSpace );
|
||||
void ImpBreakLine(ParaPortion& rParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate);
|
||||
void ImpAdjustBlocks(ParaPortion& rParaPortion, EditLine& rLine, tools::Long nRemainingSpace );
|
||||
EditPaM ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pRight, bool bBackward = false );
|
||||
EditPaM ImpDeleteSelection(const EditSelection& rCurSel);
|
||||
EditPaM ImpInsertParaBreak( EditPaM& rPaM, bool bKeepEndingAttribs = true );
|
||||
@@ -744,7 +743,7 @@ private:
|
||||
|
||||
bool ImplCalcAsianCompression( ContentNode* pNode, TextPortion* pTextPortion, sal_Int32 nStartPos,
|
||||
sal_Int32* pDXArray, sal_uInt16 n100thPercentFromMax, bool bManipulateDXArray );
|
||||
void ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth);
|
||||
void ImplExpandCompressedPortions(EditLine& rLine, ParaPortion& rParaPortion, tools::Long nRemainingWidth);
|
||||
|
||||
void ImplInitLayoutMode(OutputDevice& rOutDev, sal_Int32 nPara, sal_Int32 nIndex);
|
||||
static LanguageType ImplCalcDigitLang(LanguageType eCurLang);
|
||||
@@ -1025,7 +1024,7 @@ public:
|
||||
sal_uInt32 GetTextHeightNTP() const;
|
||||
sal_uInt32 CalcTextWidth( bool bIgnoreExtraSpace);
|
||||
sal_uInt32 CalcParaWidth( sal_Int32 nParagraph, bool bIgnoreExtraSpace );
|
||||
sal_uInt32 CalcLineWidth( ParaPortion* pPortion, EditLine const& rLine, bool bIgnoreExtraSpace);
|
||||
sal_uInt32 CalcLineWidth(ParaPortion const& rPortion, EditLine const& rLine, bool bIgnoreExtraSpace);
|
||||
sal_Int32 GetLineCount( sal_Int32 nParagraph ) const;
|
||||
sal_Int32 GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
|
||||
void GetLineBoundaries( /*out*/sal_Int32& rStart, /*out*/sal_Int32& rEnd, sal_Int32 nParagraph, sal_Int32 nLine ) const;
|
||||
@@ -1052,7 +1051,7 @@ public:
|
||||
}
|
||||
|
||||
tools::Rectangle PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nFlags = GetCursorFlags::NONE );
|
||||
tools::Rectangle GetEditCursor(const ParaPortion* pPortion, EditLine const& rLine, sal_Int32 nIndex, GetCursorFlags nFlags);
|
||||
tools::Rectangle GetEditCursor(ParaPortion const& rPortion, EditLine const& rLine, sal_Int32 nIndex, GetCursorFlags nFlags);
|
||||
|
||||
bool IsModified() const { return maEditDoc.IsModified(); }
|
||||
void SetModifyFlag(bool b) { maEditDoc.SetModified( b ); }
|
||||
|
||||
@@ -578,7 +578,7 @@ bool ImpEditEngine::Command( const CommandEvent& rCEvt, EditView* pView )
|
||||
{
|
||||
if (rInfo.pLine->IsIn(n))
|
||||
{
|
||||
tools::Rectangle aR = GetEditCursor(pParaPortion, *rInfo.pLine, n, GetCursorFlags::NONE);
|
||||
tools::Rectangle aR = GetEditCursor(*pParaPortion, *rInfo.pLine, n, GetCursorFlags::NONE);
|
||||
aR.Move(getTopLeftDocOffset(rInfo.aArea));
|
||||
aRects[n - nMinPos] = pView->GetImpEditView()->GetWindowPos(aR);
|
||||
}
|
||||
@@ -790,7 +790,7 @@ void ImpEditEngine::ParaAttribsChanged( ContentNode const * pNode, bool bIgnoreU
|
||||
ParaPortion* pNextPortion = GetParaPortions().SafeGetObject( nPara+1 );
|
||||
// => is formatted again anyway, if Invalid.
|
||||
if ( pNextPortion && !pNextPortion->IsInvalid() )
|
||||
CalcHeight( pNextPortion );
|
||||
CalcHeight(*pNextPortion);
|
||||
}
|
||||
|
||||
|
||||
@@ -1274,7 +1274,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView )
|
||||
tools::Long nX;
|
||||
if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
|
||||
{
|
||||
nX = GetXPos(pPPortion, rLine, rPaM.GetIndex());
|
||||
nX = GetXPos(*pPPortion, rLine, rPaM.GetIndex());
|
||||
pView->pImpEditView->nTravelXPos = nX + mnOnePixelInRef;
|
||||
}
|
||||
else
|
||||
@@ -1284,7 +1284,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView )
|
||||
if ( nLine ) // same paragraph
|
||||
{
|
||||
const EditLine& rPrevLine = pPPortion->GetLines()[nLine-1];
|
||||
aNewPaM.SetIndex(GetChar(pPPortion, rPrevLine, nX));
|
||||
aNewPaM.SetIndex(GetChar(*pPPortion, rPrevLine, nX));
|
||||
// If a previous automatically wrapped line, and one has to be exactly
|
||||
// at the end of this line, the cursor lands on the current line at the
|
||||
// beginning. See Problem: Last character of an automatically wrapped
|
||||
@@ -1299,7 +1299,7 @@ EditPaM ImpEditEngine::CursorUp( const EditPaM& rPaM, EditView const * pView )
|
||||
{
|
||||
const EditLine& rLine2 = pPrevPortion->GetLines()[pPrevPortion->GetLines().Count()-1];
|
||||
aNewPaM.SetNode( pPrevPortion->GetNode() );
|
||||
aNewPaM.SetIndex(GetChar(pPrevPortion, rLine2, nX + mnOnePixelInRef));
|
||||
aNewPaM.SetIndex(GetChar(*pPrevPortion, rLine2, nX + mnOnePixelInRef));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1318,7 +1318,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView )
|
||||
if ( pView->pImpEditView->nTravelXPos == TRAVEL_X_DONTKNOW )
|
||||
{
|
||||
const EditLine& rLine = pPPortion->GetLines()[nLine];
|
||||
nX = GetXPos(pPPortion, rLine, rPaM.GetIndex());
|
||||
nX = GetXPos(*pPPortion, rLine, rPaM.GetIndex());
|
||||
pView->pImpEditView->nTravelXPos = nX + mnOnePixelInRef;
|
||||
}
|
||||
else
|
||||
@@ -1328,7 +1328,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView )
|
||||
if ( nLine < pPPortion->GetLines().Count()-1 )
|
||||
{
|
||||
const EditLine& rNextLine = pPPortion->GetLines()[nLine+1];
|
||||
aNewPaM.SetIndex(GetChar(pPPortion, rNextLine, nX));
|
||||
aNewPaM.SetIndex(GetChar(*pPPortion, rNextLine, nX));
|
||||
// Special treatment, see CursorUp ...
|
||||
if ( ( aNewPaM.GetIndex() == rNextLine.GetEnd() ) && ( aNewPaM.GetIndex() > rNextLine.GetStart() ) && ( aNewPaM.GetIndex() < pPPortion->GetNode()->Len() ) )
|
||||
aNewPaM = CursorLeft( aNewPaM );
|
||||
@@ -1342,7 +1342,7 @@ EditPaM ImpEditEngine::CursorDown( const EditPaM& rPaM, EditView const * pView )
|
||||
aNewPaM.SetNode( pNextPortion->GetNode() );
|
||||
// Never at the very end when several lines, because then a line
|
||||
// below the cursor appears.
|
||||
aNewPaM.SetIndex(GetChar(pNextPortion, rLine, nX + mnOnePixelInRef));
|
||||
aNewPaM.SetIndex(GetChar(*pNextPortion, rLine, nX + mnOnePixelInRef));
|
||||
if ( ( aNewPaM.GetIndex() == rLine.GetEnd() ) && ( aNewPaM.GetIndex() > rLine.GetStart() ) && ( pNextPortion->GetLines().Count() > 1 ) )
|
||||
aNewPaM = CursorLeft( aNewPaM );
|
||||
}
|
||||
@@ -2247,14 +2247,14 @@ EditSelection ImpEditEngine::ImpMoveParagraphs( Range aOldPositions, sal_Int32 n
|
||||
|
||||
maEditDoc.SetModified( true );
|
||||
|
||||
if ( pRecalc1 )
|
||||
CalcHeight( pRecalc1 );
|
||||
if ( pRecalc2 )
|
||||
CalcHeight( pRecalc2 );
|
||||
if ( pRecalc3 )
|
||||
CalcHeight( pRecalc3 );
|
||||
if ( pRecalc4 )
|
||||
CalcHeight( pRecalc4 );
|
||||
if (pRecalc1)
|
||||
CalcHeight(*pRecalc1);
|
||||
if (pRecalc2)
|
||||
CalcHeight(*pRecalc2);
|
||||
if (pRecalc3)
|
||||
CalcHeight(*pRecalc3);
|
||||
if (pRecalc4)
|
||||
CalcHeight(*pRecalc4);
|
||||
|
||||
#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
|
||||
ParaPortionList::DbgCheck(GetParaPortions(), maEditDoc);
|
||||
@@ -3120,29 +3120,28 @@ EditPaM ImpEditEngine::InsertLineBreak(const EditSelection& aCurSel)
|
||||
|
||||
// Helper functions
|
||||
|
||||
tools::Rectangle ImpEditEngine::GetEditCursor(const ParaPortion* pPortion, EditLine const& rLine,
|
||||
tools::Rectangle ImpEditEngine::GetEditCursor(ParaPortion const& rPortion, EditLine const& rLine,
|
||||
sal_Int32 nIndex, GetCursorFlags nFlags)
|
||||
{
|
||||
assert(pPortion);
|
||||
// nIndex might be not in the line
|
||||
// Search within the line...
|
||||
tools::Long nX;
|
||||
|
||||
if ((nIndex == rLine.GetStart()) && (nFlags & GetCursorFlags::StartOfLine))
|
||||
{
|
||||
Range aXRange = GetLineXPosStartEnd(pPortion, rLine);
|
||||
nX = !IsRightToLeft(GetEditDoc().GetPos(pPortion->GetNode())) ? aXRange.Min()
|
||||
Range aXRange = GetLineXPosStartEnd(rPortion, rLine);
|
||||
nX = !IsRightToLeft(GetEditDoc().GetPos(rPortion.GetNode())) ? aXRange.Min()
|
||||
: aXRange.Max();
|
||||
}
|
||||
else if ((nIndex == rLine.GetEnd()) && (nFlags & GetCursorFlags::EndOfLine))
|
||||
{
|
||||
Range aXRange = GetLineXPosStartEnd(pPortion, rLine);
|
||||
nX = !IsRightToLeft(GetEditDoc().GetPos(pPortion->GetNode())) ? aXRange.Max()
|
||||
Range aXRange = GetLineXPosStartEnd(rPortion, rLine);
|
||||
nX = !IsRightToLeft(GetEditDoc().GetPos(rPortion.GetNode())) ? aXRange.Max()
|
||||
: aXRange.Min();
|
||||
}
|
||||
else
|
||||
{
|
||||
nX = GetXPos(pPortion, rLine, nIndex, bool(nFlags & GetCursorFlags::PreferPortionStart));
|
||||
nX = GetXPos(rPortion, rLine, nIndex, bool(nFlags & GetCursorFlags::PreferPortionStart));
|
||||
}
|
||||
|
||||
tools::Rectangle aEditCursor;
|
||||
@@ -3189,9 +3188,9 @@ tools::Rectangle ImpEditEngine::PaMtoEditCursor( EditPaM aPaM, GetCursorFlags nF
|
||||
};
|
||||
IterateLineAreas(FindPortionLineAndArea, IterFlag::none);
|
||||
|
||||
if (pLastLine)
|
||||
if (pLastLine && pPortion)
|
||||
{
|
||||
aEditCursor = GetEditCursor(pPortion, *pLastLine, nIndex, nFlags);
|
||||
aEditCursor = GetEditCursor(*pPortion, *pLastLine, nIndex, nFlags);
|
||||
aEditCursor.Move(getTopLeftDocOffset(aLineArea));
|
||||
}
|
||||
else
|
||||
@@ -3334,7 +3333,8 @@ EditPaM ImpEditEngine::GetPaM( Point aDocPos, bool bSmart )
|
||||
if (const auto& [pPortion, pLine, nLineStartX] = GetPortionAndLine(aDocPos); pPortion)
|
||||
{
|
||||
assert(pLine);
|
||||
sal_Int32 nCurIndex = GetChar(pPortion, *pLine, aDocPos.X() - nLineStartX, bSmart);
|
||||
assert(pPortion);
|
||||
sal_Int32 nCurIndex = GetChar(*pPortion, *pLine, aDocPos.X() - nLineStartX, bSmart);
|
||||
EditPaM aPaM(pPortion->GetNode(), nCurIndex);
|
||||
|
||||
if (nCurIndex && (nCurIndex == pLine->GetEnd())
|
||||
@@ -3353,7 +3353,8 @@ bool ImpEditEngine::IsTextPos(const Point& rDocPos, sal_uInt16 nBorder)
|
||||
if (const auto& [pPortion, pLine, nLineStartX] = GetPortionAndLine(rDocPos); pPortion)
|
||||
{
|
||||
assert(pLine);
|
||||
Range aLineXPosStartEnd = GetLineXPosStartEnd(pPortion, *pLine);
|
||||
assert(pPortion);
|
||||
Range aLineXPosStartEnd = GetLineXPosStartEnd(*pPortion, *pLine);
|
||||
if ((rDocPos.X() >= nLineStartX + aLineXPosStartEnd.Min() - nBorder)
|
||||
&& (rDocPos.X() <= nLineStartX + aLineXPosStartEnd.Max() + nBorder))
|
||||
return true;
|
||||
@@ -3431,7 +3432,7 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace
|
||||
}
|
||||
}
|
||||
nCurWidth += scaleXSpacingValue(rLRItem.GetRight());
|
||||
nCurWidth += CalcLineWidth(pPortion, rLine, bIgnoreExtraSpace);
|
||||
nCurWidth += CalcLineWidth(*pPortion, rLine, bIgnoreExtraSpace);
|
||||
if ( nCurWidth > nMaxWidth )
|
||||
{
|
||||
nMaxWidth = nCurWidth;
|
||||
@@ -3443,9 +3444,9 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool bIgnoreExtraSpace
|
||||
return static_cast<sal_uInt32>(nMaxWidth);
|
||||
}
|
||||
|
||||
sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion* pPortion, EditLine const& rLine, bool bIgnoreExtraSpace)
|
||||
sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion const& rPortion, EditLine const& rLine, bool bIgnoreExtraSpace)
|
||||
{
|
||||
sal_Int32 nPara = GetEditDoc().GetPos( pPortion->GetNode() );
|
||||
sal_Int32 nPara = GetEditDoc().GetPos(rPortion.GetNode());
|
||||
|
||||
// #114278# Saving both layout mode and language (since I'm
|
||||
// potentially changing both)
|
||||
@@ -3460,7 +3461,7 @@ sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion* pPortion, EditLine const& r
|
||||
sal_Int32 nPos = rLine.GetStart();
|
||||
for ( sal_Int32 nTP = rLine.GetStartPortion(); nTP <= rLine.GetEndPortion(); nTP++ )
|
||||
{
|
||||
const TextPortion& rTextPortion = pPortion->GetTextPortions()[nTP];
|
||||
const TextPortion& rTextPortion = rPortion.GetTextPortions()[nTP];
|
||||
switch ( rTextPortion.GetKind() )
|
||||
{
|
||||
case PortionKind::FIELD:
|
||||
@@ -3478,12 +3479,12 @@ sal_uInt32 ImpEditEngine::CalcLineWidth(ParaPortion* pPortion, EditLine const& r
|
||||
}
|
||||
else
|
||||
{
|
||||
SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() );
|
||||
SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
|
||||
SvxFont aTmpFont(rPortion.GetNode()->GetCharAttribs().GetDefFont());
|
||||
SeekCursor(rPortion.GetNode(), nPos + 1, aTmpFont);
|
||||
aTmpFont.SetPhysFont(*GetRefDevice());
|
||||
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
|
||||
nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(),
|
||||
pPortion->GetNode()->GetString(), nPos, rTextPortion.GetLen(), nullptr ).Width();
|
||||
rPortion.GetNode()->GetString(), nPos, rTextPortion.GetLen(), nullptr ).Width();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3997,7 +3998,7 @@ EditSelection ImpEditEngine::PasteText( uno::Reference< datatransfer::XTransfera
|
||||
return aNewSelection;
|
||||
}
|
||||
|
||||
sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const& rLine, tools::Long nXPos, bool bSmart)
|
||||
sal_Int32 ImpEditEngine::GetChar(ParaPortion const& rParaPortion, EditLine const& rLine, tools::Long nXPos, bool bSmart)
|
||||
{
|
||||
sal_Int32 nChar = -1;
|
||||
sal_Int32 nCurIndex = rLine.GetStart();
|
||||
@@ -4006,8 +4007,8 @@ sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const
|
||||
// Search best matching portion with GetPortionXOffset()
|
||||
for ( sal_Int32 i = rLine.GetStartPortion(); i <= rLine.GetEndPortion(); i++ )
|
||||
{
|
||||
const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
|
||||
tools::Long nXLeft = GetPortionXOffset( pParaPortion, rLine, i );
|
||||
const TextPortion& rPortion = rParaPortion.GetTextPortions()[i];
|
||||
tools::Long nXLeft = GetPortionXOffset(rParaPortion, rLine, i);
|
||||
tools::Long nXRight = nXLeft + rPortion.GetSize().Width();
|
||||
if ( ( nXLeft <= nXPos ) && ( nXRight >= nXPos ) )
|
||||
{
|
||||
@@ -4075,9 +4076,9 @@ sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const
|
||||
nChar = nChar + nOffset;
|
||||
|
||||
// Check if index is within a cell:
|
||||
if ( nChar && ( nChar < pParaPortion->GetNode()->Len() ) )
|
||||
if ( nChar && ( nChar < rParaPortion.GetNode()->Len() ) )
|
||||
{
|
||||
EditPaM aPaM( pParaPortion->GetNode(), nChar+1 );
|
||||
EditPaM aPaM( rParaPortion.GetNode(), nChar+1 );
|
||||
sal_uInt16 nScriptType = GetI18NScriptType( aPaM );
|
||||
if ( nScriptType == i18n::ScriptType::COMPLEX )
|
||||
{
|
||||
@@ -4085,9 +4086,9 @@ sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const
|
||||
sal_Int32 nCount = 1;
|
||||
lang::Locale aLocale = GetLocale( aPaM );
|
||||
sal_Int32 nRight = _xBI->nextCharacters(
|
||||
pParaPortion->GetNode()->GetString(), nChar, aLocale, css::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
|
||||
rParaPortion.GetNode()->GetString(), nChar, aLocale, css::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
|
||||
sal_Int32 nLeft = _xBI->previousCharacters(
|
||||
pParaPortion->GetNode()->GetString(), nRight, aLocale, css::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
|
||||
rParaPortion.GetNode()->GetString(), nRight, aLocale, css::i18n::CharacterIteratorMode::SKIPCELL, nCount, nCount );
|
||||
if ( ( nLeft != nChar ) && ( nRight != nChar ) )
|
||||
{
|
||||
nChar = ( std::abs( nRight - nChar ) < std::abs( nLeft - nChar ) ) ? nRight : nLeft;
|
||||
@@ -4095,7 +4096,7 @@ sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const
|
||||
}
|
||||
else
|
||||
{
|
||||
OUString aStr(pParaPortion->GetNode()->GetString());
|
||||
OUString aStr(rParaPortion.GetNode()->GetString());
|
||||
// tdf#102625: don't select middle of a pair of surrogates with mouse cursor
|
||||
if (rtl::isSurrogate(aStr[nChar]))
|
||||
--nChar;
|
||||
@@ -4115,11 +4116,11 @@ sal_Int32 ImpEditEngine::GetChar(const ParaPortion* pParaPortion, EditLine const
|
||||
return nChar;
|
||||
}
|
||||
|
||||
Range ImpEditEngine::GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLine const& rLine) const
|
||||
Range ImpEditEngine::GetLineXPosStartEnd(ParaPortion const& rParaPortion, EditLine const& rLine) const
|
||||
{
|
||||
Range aLineXPosStartEnd;
|
||||
|
||||
sal_Int32 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() );
|
||||
sal_Int32 nPara = GetEditDoc().GetPos(rParaPortion.GetNode());
|
||||
if ( !IsRightToLeft( nPara ) )
|
||||
{
|
||||
aLineXPosStartEnd.Min() = rLine.GetStartPosX();
|
||||
@@ -4134,13 +4135,13 @@ Range ImpEditEngine::GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLi
|
||||
return aLineXPosStartEnd;
|
||||
}
|
||||
|
||||
tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const
|
||||
tools::Long ImpEditEngine::GetPortionXOffset(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nTextPortion) const
|
||||
{
|
||||
tools::Long nX = rLine.GetStartPosX();
|
||||
|
||||
for ( sal_Int32 i = rLine.GetStartPortion(); i < nTextPortion; i++ )
|
||||
{
|
||||
const TextPortion& rPortion = pParaPortion->GetTextPortions()[i];
|
||||
const TextPortion& rPortion = rParaPortion.GetTextPortions()[i];
|
||||
switch ( rPortion.GetKind() )
|
||||
{
|
||||
case PortionKind::FIELD:
|
||||
@@ -4155,10 +4156,10 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
}
|
||||
}
|
||||
|
||||
sal_Int32 nPara = GetEditDoc().GetPos( pParaPortion->GetNode() );
|
||||
sal_Int32 nPara = GetEditDoc().GetPos(rParaPortion.GetNode());
|
||||
bool bR2LPara = IsRightToLeft( nPara );
|
||||
|
||||
const TextPortion& rDestPortion = pParaPortion->GetTextPortions()[nTextPortion];
|
||||
const TextPortion& rDestPortion = rParaPortion.GetTextPortions()[nTextPortion];
|
||||
if ( rDestPortion.GetKind() != PortionKind::TAB )
|
||||
{
|
||||
if ( !bR2LPara && rDestPortion.GetRightToLeftLevel() )
|
||||
@@ -4167,7 +4168,7 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
sal_Int32 nTmpPortion = nTextPortion+1;
|
||||
while ( nTmpPortion <= rLine.GetEndPortion() )
|
||||
{
|
||||
const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
|
||||
const TextPortion& rNextTextPortion = rParaPortion.GetTextPortions()[nTmpPortion];
|
||||
if ( rNextTextPortion.GetRightToLeftLevel() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
|
||||
nX += rNextTextPortion.GetSize().Width();
|
||||
else
|
||||
@@ -4179,7 +4180,7 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
while ( nTmpPortion > rLine.GetStartPortion() )
|
||||
{
|
||||
--nTmpPortion;
|
||||
const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
|
||||
const TextPortion& rPrevTextPortion = rParaPortion.GetTextPortions()[nTmpPortion];
|
||||
if ( rPrevTextPortion.GetRightToLeftLevel() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
|
||||
nX -= rPrevTextPortion.GetSize().Width();
|
||||
else
|
||||
@@ -4192,7 +4193,7 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
sal_Int32 nTmpPortion = nTextPortion+1;
|
||||
while ( nTmpPortion <= rLine.GetEndPortion() )
|
||||
{
|
||||
const TextPortion& rNextTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
|
||||
const TextPortion& rNextTextPortion = rParaPortion.GetTextPortions()[nTmpPortion];
|
||||
if ( !rNextTextPortion.IsRightToLeft() && ( rNextTextPortion.GetKind() != PortionKind::TAB ) )
|
||||
nX += rNextTextPortion.GetSize().Width();
|
||||
else
|
||||
@@ -4204,7 +4205,7 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
while ( nTmpPortion > rLine.GetStartPortion() )
|
||||
{
|
||||
--nTmpPortion;
|
||||
const TextPortion& rPrevTextPortion = pParaPortion->GetTextPortions()[nTmpPortion];
|
||||
const TextPortion& rPrevTextPortion = rParaPortion.GetTextPortions()[nTmpPortion];
|
||||
if ( !rPrevTextPortion.IsRightToLeft() && ( rPrevTextPortion.GetKind() != PortionKind::TAB ) )
|
||||
nX -= rPrevTextPortion.GetSize().Width();
|
||||
else
|
||||
@@ -4224,8 +4225,7 @@ tools::Long ImpEditEngine::GetPortionXOffset(const ParaPortion* pParaPortion, Ed
|
||||
return nX;
|
||||
}
|
||||
|
||||
tools::Long ImpEditEngine::GetXPos(
|
||||
const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const
|
||||
tools::Long ImpEditEngine::GetXPos(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart) const
|
||||
{
|
||||
OSL_ENSURE( ( nIndex >= rLine.GetStart() ) && ( nIndex <= rLine.GetEnd() ) , "GetXPos has to be called properly!" );
|
||||
|
||||
@@ -4237,13 +4237,13 @@ tools::Long ImpEditEngine::GetXPos(
|
||||
bDoPreferPortionStart = false;
|
||||
|
||||
sal_Int32 nTextPortionStart = 0;
|
||||
sal_Int32 nTextPortion = pParaPortion->GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
|
||||
sal_Int32 nTextPortion = rParaPortion.GetTextPortions().FindPortion( nIndex, nTextPortionStart, bDoPreferPortionStart );
|
||||
|
||||
OSL_ENSURE( ( nTextPortion >= rLine.GetStartPortion() ) && ( nTextPortion <= rLine.GetEndPortion() ), "GetXPos: Portion not in current line! " );
|
||||
|
||||
const TextPortion& rPortion = pParaPortion->GetTextPortions()[nTextPortion];
|
||||
const TextPortion& rPortion = rParaPortion.GetTextPortions()[nTextPortion];
|
||||
|
||||
tools::Long nX = GetPortionXOffset( pParaPortion, rLine, nTextPortion );
|
||||
tools::Long nX = GetPortionXOffset(rParaPortion, rLine, nTextPortion);
|
||||
|
||||
// calc text width, portion size may include CJK/CTL spacing...
|
||||
// But the array might not be init yet, if using text ranger this method is called within CreateLines()...
|
||||
@@ -4259,18 +4259,18 @@ tools::Long ImpEditEngine::GetXPos(
|
||||
// End of Portion
|
||||
if ( rPortion.GetKind() == PortionKind::TAB )
|
||||
{
|
||||
if ( nTextPortion+1 < pParaPortion->GetTextPortions().Count() )
|
||||
if ( nTextPortion+1 < rParaPortion.GetTextPortions().Count() )
|
||||
{
|
||||
const TextPortion& rNextPortion = pParaPortion->GetTextPortions()[nTextPortion+1];
|
||||
const TextPortion& rNextPortion = rParaPortion.GetTextPortions()[nTextPortion+1];
|
||||
if ( rNextPortion.GetKind() != PortionKind::TAB )
|
||||
{
|
||||
if ( !bPreferPortionStart )
|
||||
nX = GetXPos( pParaPortion, rLine, nIndex, true );
|
||||
else if ( !IsRightToLeft( GetEditDoc().GetPos( pParaPortion->GetNode() ) ) )
|
||||
nX = GetXPos(rParaPortion, rLine, nIndex, true );
|
||||
else if ( !IsRightToLeft( GetEditDoc().GetPos(rParaPortion.GetNode()) ) )
|
||||
nX += nPortionTextWidth;
|
||||
}
|
||||
}
|
||||
else if ( !IsRightToLeft( GetEditDoc().GetPos( pParaPortion->GetNode() ) ) )
|
||||
else if ( !IsRightToLeft( GetEditDoc().GetPos(rParaPortion.GetNode()) ) )
|
||||
{
|
||||
nX += nPortionTextWidth;
|
||||
}
|
||||
@@ -4311,7 +4311,7 @@ tools::Long ImpEditEngine::GetXPos(
|
||||
nX += rPortion.GetExtraInfos()->nPortionOffsetX;
|
||||
if ( rPortion.GetExtraInfos()->nAsianCompressionTypes & AsianCompressionFlags::PunctuationRight )
|
||||
{
|
||||
AsianCompressionFlags nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex ) );
|
||||
AsianCompressionFlags nType = GetCharTypeForCompression(rParaPortion.GetNode()->GetChar(nIndex));
|
||||
if ( nType == AsianCompressionFlags::PunctuationRight && !rLine.GetCharPosArray().empty() )
|
||||
{
|
||||
sal_Int32 n = nIndex - nTextPortionStart;
|
||||
@@ -4321,7 +4321,7 @@ tools::Long ImpEditEngine::GetXPos(
|
||||
if ( (n+1) < rPortion.GetLen() )
|
||||
{
|
||||
// smaller, when char behind is AsianCompressionFlags::PunctuationRight also
|
||||
nType = GetCharTypeForCompression( pParaPortion->GetNode()->GetChar( nIndex+1 ) );
|
||||
nType = GetCharTypeForCompression(rParaPortion.GetNode()->GetChar(nIndex + 1));
|
||||
if ( nType == AsianCompressionFlags::PunctuationRight )
|
||||
{
|
||||
sal_Int32 nNextCharWidth = ( ( (n+2) < rPortion.GetLen() ) ? pDXArray[n+1] : rPortion.GetSize().Width() )
|
||||
@@ -4354,44 +4354,44 @@ tools::Long ImpEditEngine::GetXPos(
|
||||
return nX;
|
||||
}
|
||||
|
||||
void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
|
||||
void ImpEditEngine::CalcHeight(ParaPortion& rPortion)
|
||||
{
|
||||
pPortion->nHeight = 0;
|
||||
pPortion->nFirstLineOffset = 0;
|
||||
rPortion.nHeight = 0;
|
||||
rPortion.nFirstLineOffset = 0;
|
||||
|
||||
if ( !pPortion->IsVisible() )
|
||||
if (!rPortion.IsVisible())
|
||||
return;
|
||||
|
||||
OSL_ENSURE( pPortion->GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight" );
|
||||
for (sal_Int32 nLine = 0; nLine < pPortion->GetLines().Count(); ++nLine)
|
||||
pPortion->nHeight += pPortion->GetLines()[nLine].GetHeight();
|
||||
OSL_ENSURE(rPortion.GetLines().Count(), "Paragraph with no lines in ParaPortion::CalcHeight");
|
||||
for (sal_Int32 nLine = 0; nLine < rPortion.GetLines().Count(); ++nLine)
|
||||
rPortion.nHeight += rPortion.GetLines()[nLine].GetHeight();
|
||||
|
||||
if (maStatus.IsOutliner())
|
||||
return;
|
||||
|
||||
const SvxULSpaceItem& rULItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
|
||||
const SvxLineSpacingItem& rLSItem = pPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
|
||||
const SvxULSpaceItem& rULItem = rPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_ULSPACE );
|
||||
const SvxLineSpacingItem& rLSItem = rPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
|
||||
sal_Int32 nSBL = ( rLSItem.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Fix ) ? scaleYSpacingValue(rLSItem.GetInterLineSpace()) : 0;
|
||||
|
||||
if ( nSBL )
|
||||
{
|
||||
if ( pPortion->GetLines().Count() > 1 )
|
||||
pPortion->nHeight += ( pPortion->GetLines().Count() - 1 ) * nSBL;
|
||||
if (rPortion.GetLines().Count() > 1)
|
||||
rPortion.nHeight += (rPortion.GetLines().Count() - 1) * nSBL;
|
||||
if (maStatus.ULSpaceSummation())
|
||||
pPortion->nHeight += nSBL;
|
||||
rPortion.nHeight += nSBL;
|
||||
}
|
||||
|
||||
sal_Int32 nPortion = GetParaPortions().GetPos( pPortion );
|
||||
sal_Int32 nPortion = GetParaPortions().GetPos(&rPortion);
|
||||
if ( nPortion )
|
||||
{
|
||||
sal_uInt16 nUpper = scaleYSpacingValue(rULItem.GetUpper());
|
||||
pPortion->nHeight += nUpper;
|
||||
pPortion->nFirstLineOffset = nUpper;
|
||||
rPortion.nHeight += nUpper;
|
||||
rPortion.nFirstLineOffset = nUpper;
|
||||
}
|
||||
|
||||
if ( nPortion != (GetParaPortions().Count()-1) )
|
||||
{
|
||||
pPortion->nHeight += scaleYSpacingValue(rULItem.GetLower()); // not in the last
|
||||
rPortion.nHeight += scaleYSpacingValue(rULItem.GetLower()); // not in the last
|
||||
}
|
||||
|
||||
|
||||
@@ -4412,29 +4412,28 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
|
||||
|
||||
// check if distance by LineSpacing > Upper:
|
||||
sal_uInt16 nExtraSpace = scaleYSpacingValue(lcl_CalcExtraSpace(rLSItem));
|
||||
if ( nExtraSpace > pPortion->nFirstLineOffset )
|
||||
if (nExtraSpace > rPortion.nFirstLineOffset)
|
||||
{
|
||||
// Paragraph becomes 'bigger':
|
||||
pPortion->nHeight += ( nExtraSpace - pPortion->nFirstLineOffset );
|
||||
pPortion->nFirstLineOffset = nExtraSpace;
|
||||
rPortion.nHeight += (nExtraSpace - rPortion.nFirstLineOffset);
|
||||
rPortion.nFirstLineOffset = nExtraSpace;
|
||||
}
|
||||
|
||||
// Determine nFirstLineOffset now f(pNode) => now f(pNode, pPrev):
|
||||
sal_uInt16 nPrevLower = scaleYSpacingValue(rPrevULItem.GetLower());
|
||||
|
||||
// This PrevLower is still in the height of PrevPortion ...
|
||||
if ( nPrevLower > pPortion->nFirstLineOffset )
|
||||
if (nPrevLower > rPortion.nFirstLineOffset)
|
||||
{
|
||||
// Paragraph is 'small':
|
||||
pPortion->nHeight -= pPortion->nFirstLineOffset;
|
||||
pPortion->nFirstLineOffset = 0;
|
||||
rPortion.nHeight -= rPortion.nFirstLineOffset;
|
||||
rPortion.nFirstLineOffset = 0;
|
||||
}
|
||||
else if ( nPrevLower )
|
||||
{
|
||||
// Paragraph becomes 'somewhat smaller':
|
||||
pPortion->nHeight -= nPrevLower;
|
||||
pPortion->nFirstLineOffset =
|
||||
pPortion->nFirstLineOffset - nPrevLower;
|
||||
rPortion.nHeight -= nPrevLower;
|
||||
rPortion.nFirstLineOffset = rPortion.nFirstLineOffset - nPrevLower;
|
||||
}
|
||||
// I find it not so good, but Writer3 feature:
|
||||
// Check if distance by LineSpacing > Lower: this value is not
|
||||
@@ -4447,10 +4446,10 @@ void ImpEditEngine::CalcHeight( ParaPortion* pPortion )
|
||||
{
|
||||
sal_uInt16 nMoreLower = nExtraSpace - nPrevLower;
|
||||
// Paragraph becomes 'bigger', 'grows' downwards:
|
||||
if ( nMoreLower > pPortion->nFirstLineOffset )
|
||||
if ( nMoreLower > rPortion.nFirstLineOffset )
|
||||
{
|
||||
pPortion->nHeight += ( nMoreLower - pPortion->nFirstLineOffset );
|
||||
pPortion->nFirstLineOffset = nMoreLower;
|
||||
rPortion.nHeight += (nMoreLower - rPortion.nFirstLineOffset);
|
||||
rPortion.nFirstLineOffset = nMoreLower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+102
-108
@@ -643,8 +643,8 @@ bool ImpEditEngine::createLinesForEmptyParagraph(ParaPortion& rParaPortion)
|
||||
if (rParaPortion.GetLines().Count())
|
||||
rParaPortion.GetLines().Reset();
|
||||
|
||||
CreateAndInsertEmptyLine(&rParaPortion);
|
||||
return FinishCreateLines(&rParaPortion);
|
||||
CreateAndInsertEmptyLine(rParaPortion);
|
||||
return FinishCreateLines(rParaPortion);
|
||||
}
|
||||
|
||||
tools::Long ImpEditEngine::calculateMaxLineWidth(tools::Long nStartX, SvxLRSpaceItem const& rLRItem)
|
||||
@@ -770,11 +770,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
else if ( bQuickFormat )
|
||||
{
|
||||
// faster Method:
|
||||
RecalcTextPortion( pParaPortion, nInvalidStart, nInvalidDiff );
|
||||
RecalcTextPortion(*pParaPortion, nInvalidStart, nInvalidDiff);
|
||||
}
|
||||
else // nRealInvalidStart can be before InvalidStart, since Portions were deleted...
|
||||
{
|
||||
CreateTextPortions( pParaPortion, nRealInvalidStart );
|
||||
CreateTextPortions(*pParaPortion, nRealInvalidStart);
|
||||
}
|
||||
|
||||
// Search for line with InvalidPos, start one line before
|
||||
@@ -877,7 +877,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
{
|
||||
GetTextRanger()->SetVertical( IsEffectivelyVertical() );
|
||||
|
||||
tools::Long nTextY = nStartPosY + GetEditCursor(pParaPortion, *pLine, pLine->GetStart(), GetCursorFlags::NONE).Top();
|
||||
tools::Long nTextY = nStartPosY + GetEditCursor(*pParaPortion, *pLine, pLine->GetStart(), GetCursorFlags::NONE).Top();
|
||||
if ( !bSameLineAgain )
|
||||
{
|
||||
SeekCursor( pNode, nTmpPos+1, aTmpFont );
|
||||
@@ -1344,7 +1344,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
{
|
||||
DBG_ASSERT( pPortion->GetKind() == PortionKind::TEXT, "Len>1, but no TextPortion?" );
|
||||
nTmpWidth -= pPortion->GetSize().Width();
|
||||
sal_Int32 nP = SplitTextPortion( pParaPortion, nTmpPos, pLine );
|
||||
sal_Int32 nP = SplitTextPortion(*pParaPortion, nTmpPos, pLine);
|
||||
nTmpWidth += pParaPortion->GetTextPortions()[nP].GetSize().Width();
|
||||
}
|
||||
}
|
||||
@@ -1419,8 +1419,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
pNode, pPortion, nPortionStart, pDXArray, 10000, true);
|
||||
}
|
||||
if( pPortion )
|
||||
ImpBreakLine( pParaPortion, *pLine, pPortion, nPortionStart,
|
||||
nRemainingWidth, bCanHyphenate && bHyphenatePara );
|
||||
ImpBreakLine(*pParaPortion, *pLine, pPortion, nPortionStart, nRemainingWidth, bCanHyphenate && bHyphenatePara);
|
||||
}
|
||||
|
||||
|
||||
@@ -1566,7 +1565,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
tools::Long nRemainingWidth = nMaxLineWidth - aTextSize.Width();
|
||||
if ( nRemainingWidth > 0 )
|
||||
{
|
||||
ImplExpandCompressedPortions(*pLine, pParaPortion, nRemainingWidth);
|
||||
ImplExpandCompressedPortions(*pLine, *pParaPortion, nRemainingWidth);
|
||||
aTextSize = pLine->CalcTextSize( *pParaPortion );
|
||||
}
|
||||
}
|
||||
@@ -1611,7 +1610,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
tools::Long nRemainingSpace = nMaxLineWidth - aTextSize.Width();
|
||||
pLine->SetStartPosX( nStartX );
|
||||
if ( nRemainingSpace > 0 && (!bEOC || bDistLastLine) )
|
||||
ImpAdjustBlocks(pParaPortion, *pLine, nRemainingSpace);
|
||||
ImpAdjustBlocks(*pParaPortion, *pLine, nRemainingSpace);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -1755,9 +1754,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
DBG_ASSERT( pParaPortion->GetLines().Count(), "No line after CreateLines!" );
|
||||
|
||||
if ( bLineBreak )
|
||||
CreateAndInsertEmptyLine( pParaPortion );
|
||||
CreateAndInsertEmptyLine(*pParaPortion);
|
||||
|
||||
bool bHeightChanged = FinishCreateLines( pParaPortion );
|
||||
bool bHeightChanged = FinishCreateLines(*pParaPortion);
|
||||
|
||||
if ( bMapChanged )
|
||||
GetRefDevice()->Pop();
|
||||
@@ -1767,20 +1766,20 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
|
||||
return bHeightChanged;
|
||||
}
|
||||
|
||||
void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion )
|
||||
void ImpEditEngine::CreateAndInsertEmptyLine(ParaPortion& rParaPortion)
|
||||
{
|
||||
DBG_ASSERT( !GetTextRanger(), "Don't use CreateAndInsertEmptyLine with a polygon!" );
|
||||
|
||||
EditLine* pTmpLine = new EditLine;
|
||||
pTmpLine->SetStart( pParaPortion->GetNode()->Len() );
|
||||
pTmpLine->SetEnd( pParaPortion->GetNode()->Len() );
|
||||
pParaPortion->GetLines().Append(std::unique_ptr<EditLine>(pTmpLine));
|
||||
pTmpLine->SetStart(rParaPortion.GetNode()->Len());
|
||||
pTmpLine->SetEnd(rParaPortion.GetNode()->Len());
|
||||
rParaPortion.GetLines().Append(std::unique_ptr<EditLine>(pTmpLine));
|
||||
|
||||
bool bLineBreak = pParaPortion->GetNode()->Len() > 0;
|
||||
bool bLineBreak = rParaPortion.GetNode()->Len() > 0;
|
||||
sal_Int32 nSpaceBefore = 0;
|
||||
sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth( pParaPortion->GetNode(), &nSpaceBefore );
|
||||
const SvxLRSpaceItem& rLRItem = GetLRSpaceItem( pParaPortion->GetNode() );
|
||||
const SvxLineSpacingItem& rLSItem = pParaPortion->GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
|
||||
sal_Int32 nSpaceBeforeAndMinLabelWidth = GetSpaceBeforeAndMinLabelWidth(rParaPortion.GetNode(), &nSpaceBefore);
|
||||
const SvxLRSpaceItem& rLRItem = GetLRSpaceItem(rParaPortion.GetNode());
|
||||
const SvxLineSpacingItem& rLSItem = rParaPortion.GetNode()->GetContentAttribs().GetItem( EE_PARA_SBL );
|
||||
tools::Long nStartX = scaleXSpacingValue(rLRItem.GetTextLeft() + rLRItem.GetTextFirstLineOffset() + nSpaceBefore);
|
||||
|
||||
tools::Rectangle aBulletArea { Point(), Point() };
|
||||
@@ -1790,28 +1789,28 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion )
|
||||
}
|
||||
else
|
||||
{
|
||||
aBulletArea = GetEditEnginePtr()->GetBulletArea( GetParaPortions().GetPos( pParaPortion ) );
|
||||
aBulletArea = GetEditEnginePtr()->GetBulletArea( GetParaPortions().GetPos(&rParaPortion));
|
||||
if ( !aBulletArea.IsEmpty() && aBulletArea.Right() > 0 )
|
||||
pParaPortion->SetBulletX(sal_Int32(scaleXSpacingValue(aBulletArea.Right())));
|
||||
rParaPortion.SetBulletX(sal_Int32(scaleXSpacingValue(aBulletArea.Right())));
|
||||
else
|
||||
pParaPortion->SetBulletX( 0 ); // If Bullet set incorrectly.
|
||||
if ( pParaPortion->GetBulletX() > nStartX )
|
||||
rParaPortion.SetBulletX( 0 ); // If Bullet set incorrectly.
|
||||
if (rParaPortion.GetBulletX() > nStartX)
|
||||
{
|
||||
nStartX = scaleXSpacingValue(rLRItem.GetTextLeft() + rLRItem.GetTextFirstLineOffset() + nSpaceBeforeAndMinLabelWidth);
|
||||
if ( pParaPortion->GetBulletX() > nStartX )
|
||||
nStartX = pParaPortion->GetBulletX();
|
||||
if (rParaPortion.GetBulletX() > nStartX)
|
||||
nStartX = rParaPortion.GetBulletX();
|
||||
}
|
||||
}
|
||||
|
||||
SvxFont aTmpFont;
|
||||
SeekCursor( pParaPortion->GetNode(), bLineBreak ? pParaPortion->GetNode()->Len() : 0, aTmpFont );
|
||||
SeekCursor(rParaPortion.GetNode(), bLineBreak ? rParaPortion.GetNode()->Len() : 0, aTmpFont );
|
||||
aTmpFont.SetPhysFont(*mpRefDev);
|
||||
|
||||
TextPortion* pDummyPortion = new TextPortion( 0 );
|
||||
pDummyPortion->SetSize(aTmpFont.GetPhysTxtSize(mpRefDev));
|
||||
if ( IsFixedCellHeight() )
|
||||
pDummyPortion->setHeight( ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
|
||||
pParaPortion->GetTextPortions().Append(pDummyPortion);
|
||||
rParaPortion.GetTextPortions().Append(pDummyPortion);
|
||||
FormatterFontMetric aFormatterMetrics;
|
||||
RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
|
||||
pTmpLine->SetMaxAscent( aFormatterMetrics.nMaxAscent );
|
||||
@@ -1822,7 +1821,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion )
|
||||
|
||||
if (!maStatus.IsOutliner())
|
||||
{
|
||||
sal_Int32 nPara = GetParaPortions().GetPos( pParaPortion );
|
||||
sal_Int32 nPara = GetParaPortions().GetPos(&rParaPortion);
|
||||
SvxAdjust eJustification = GetJustification( nPara );
|
||||
tools::Long nMaxLineWidth = GetColumnWidth(maPaperSize);
|
||||
nMaxLineWidth -= scaleXSpacingValue(rLRItem.GetRight());
|
||||
@@ -1860,7 +1859,7 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion )
|
||||
}
|
||||
else if ( rLSItem.GetInterLineSpaceRule() == SvxInterLineSpaceRule::Prop )
|
||||
{
|
||||
sal_Int32 nPara = GetParaPortions().GetPos( pParaPortion );
|
||||
sal_Int32 nPara = GetParaPortions().GetPos(&rParaPortion);
|
||||
if ( nPara || pTmpLine->GetStartPortion() ) // Not the very first line
|
||||
{
|
||||
// There are documents with PropLineSpace 0, why?
|
||||
@@ -1897,30 +1896,30 @@ void ImpEditEngine::CreateAndInsertEmptyLine( ParaPortion* pParaPortion )
|
||||
{
|
||||
// -2: The new one is already inserted.
|
||||
#ifdef DBG_UTIL
|
||||
EditLine& rLastLine = pParaPortion->GetLines()[pParaPortion->GetLines().Count()-2];
|
||||
DBG_ASSERT( rLastLine.GetEnd() == pParaPortion->GetNode()->Len(), "different anyway?" );
|
||||
EditLine& rLastLine = rParaPortion.GetLines()[rParaPortion.GetLines().Count()-2];
|
||||
DBG_ASSERT( rLastLine.GetEnd() == rParaPortion.GetNode()->Len(), "different anyway?" );
|
||||
#endif
|
||||
sal_Int32 nPos = pParaPortion->GetTextPortions().Count() - 1 ;
|
||||
sal_Int32 nPos = rParaPortion.GetTextPortions().Count() - 1 ;
|
||||
pTmpLine->SetStartPortion( nPos );
|
||||
pTmpLine->SetEndPortion( nPos );
|
||||
}
|
||||
}
|
||||
|
||||
bool ImpEditEngine::FinishCreateLines( ParaPortion* pParaPortion )
|
||||
bool ImpEditEngine::FinishCreateLines(ParaPortion& rParaPortion)
|
||||
{
|
||||
// CalcCharPositions( pParaPortion );
|
||||
pParaPortion->SetValid();
|
||||
tools::Long nOldHeight = pParaPortion->GetHeight();
|
||||
CalcHeight( pParaPortion );
|
||||
rParaPortion.SetValid();
|
||||
tools::Long nOldHeight = rParaPortion.GetHeight();
|
||||
CalcHeight(rParaPortion);
|
||||
|
||||
DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "FinishCreateLines: No Text-Portion?" );
|
||||
bool bRet = ( pParaPortion->GetHeight() != nOldHeight );
|
||||
DBG_ASSERT(rParaPortion.GetTextPortions().Count(), "FinishCreateLines: No Text-Portion?");
|
||||
bool bRet = rParaPortion.GetHeight() != nOldHeight;
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate )
|
||||
void ImpEditEngine::ImpBreakLine(ParaPortion& rParaPortion, EditLine& rLine, TextPortion const * pPortion, sal_Int32 nPortionStart, tools::Long nRemainingWidth, bool bCanHyphenate)
|
||||
{
|
||||
ContentNode* const pNode = pParaPortion->GetNode();
|
||||
ContentNode* const pNode = rParaPortion.GetNode();
|
||||
|
||||
sal_Int32 nBreakInLine = nPortionStart - rLine.GetStart();
|
||||
sal_Int32 nMax = nBreakInLine + pPortion->GetLen();
|
||||
@@ -2138,7 +2137,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, Te
|
||||
// the dickey portion is the end portion
|
||||
rLine.SetEnd( nBreakPos );
|
||||
|
||||
sal_Int32 nEndPortion = SplitTextPortion( pParaPortion, nBreakPos, &rLine);
|
||||
sal_Int32 nEndPortion = SplitTextPortion(rParaPortion, nBreakPos, &rLine);
|
||||
|
||||
if ( !bCompressBlank && !bHangingPunctuation )
|
||||
{
|
||||
@@ -2152,7 +2151,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, Te
|
||||
|
||||
if ( bCompressBlank || bHangingPunctuation )
|
||||
{
|
||||
TextPortion& rTP = pParaPortion->GetTextPortions()[nEndPortion];
|
||||
TextPortion& rTP = rParaPortion.GetTextPortions()[nEndPortion];
|
||||
DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "BlankRubber: No TextPortion!" );
|
||||
DBG_ASSERT( nBreakPos > rLine.GetStart(), "SplitTextPortion at the beginning of the line?" );
|
||||
sal_Int32 nPosInArray = nBreakPos - 1 - rLine.GetStart();
|
||||
@@ -2169,7 +2168,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, Te
|
||||
pHyphPortion->SetKind( PortionKind::HYPHENATOR );
|
||||
if ( (cAlternateReplChar || cAlternateExtraChar) && bAltFullRight ) // alternation after the break doesn't supported
|
||||
{
|
||||
TextPortion& rPrev = pParaPortion->GetTextPortions()[nEndPortion];
|
||||
TextPortion& rPrev = rParaPortion.GetTextPortions()[nEndPortion];
|
||||
DBG_ASSERT( rPrev.GetLen(), "Hyphenate: Prev portion?!" );
|
||||
rPrev.SetLen( rPrev.GetLen() - nAltDelChar );
|
||||
pHyphPortion->SetLen( nAltDelChar );
|
||||
@@ -2181,27 +2180,25 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine& rLine, Te
|
||||
|
||||
// Determine the width of the Hyph-Portion:
|
||||
SvxFont aFont;
|
||||
SeekCursor( pParaPortion->GetNode(), nBreakPos, aFont );
|
||||
SeekCursor(rParaPortion.GetNode(), nBreakPos, aFont);
|
||||
aFont.SetPhysFont(*GetRefDevice());
|
||||
pHyphPortion->SetSize(Size(GetRefDevice()->GetTextWidth(CH_HYPH), GetRefDevice()->GetTextHeight()));
|
||||
|
||||
pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion);
|
||||
rParaPortion.GetTextPortions().Insert(++nEndPortion, pHyphPortion);
|
||||
}
|
||||
rLine.SetEndPortion( nEndPortion );
|
||||
}
|
||||
|
||||
void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine, tools::Long nRemainingSpace )
|
||||
void ImpEditEngine::ImpAdjustBlocks(ParaPortion& rParaPortion, EditLine& rLine, tools::Long nRemainingSpace )
|
||||
{
|
||||
DBG_ASSERT( nRemainingSpace > 0, "AdjustBlocks: Somewhat too little..." );
|
||||
|
||||
if ( ( nRemainingSpace < 0 ) || rLine.IsEmpty() )
|
||||
return ;
|
||||
|
||||
assert(pParaPortion);
|
||||
|
||||
const sal_Int32 nFirstChar = rLine.GetStart();
|
||||
const sal_Int32 nLastChar = rLine.GetEnd() -1; // Last points behind
|
||||
ContentNode* pNode = pParaPortion->GetNode();
|
||||
ContentNode* pNode = rParaPortion.GetNode();
|
||||
|
||||
DBG_ASSERT( nLastChar < pNode->Len(), "AdjustBlocks: Out of range!" );
|
||||
|
||||
@@ -2256,8 +2253,8 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine,
|
||||
{
|
||||
aPositions.pop_back();
|
||||
sal_Int32 nPortionStart, nPortion;
|
||||
nPortion = pParaPortion->GetTextPortions().FindPortion( nLastChar+1, nPortionStart );
|
||||
TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
|
||||
nPortion = rParaPortion.GetTextPortions().FindPortion( nLastChar+1, nPortionStart );
|
||||
TextPortion& rLastPortion = rParaPortion.GetTextPortions()[ nPortion ];
|
||||
tools::Long nRealWidth = rLine.GetCharPosArray()[nLastChar-nFirstChar];
|
||||
tools::Long nBlankWidth = nRealWidth;
|
||||
if ( nLastChar > nPortionStart )
|
||||
@@ -2301,8 +2298,8 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion* pParaPortion, EditLine& rLine,
|
||||
if ( nChar < nLastChar )
|
||||
{
|
||||
sal_Int32 nPortionStart, nPortion;
|
||||
nPortion = pParaPortion->GetTextPortions().FindPortion( nChar, nPortionStart, true );
|
||||
TextPortion& rLastPortion = pParaPortion->GetTextPortions()[ nPortion ];
|
||||
nPortion = rParaPortion.GetTextPortions().FindPortion( nChar, nPortionStart, true );
|
||||
TextPortion& rLastPortion = rParaPortion.GetTextPortions()[ nPortion ];
|
||||
|
||||
// The width of the portion:
|
||||
rLastPortion.adjustSize(nMore4Everyone, 0);
|
||||
@@ -2522,21 +2519,19 @@ void ImpEditEngine::ImpFindKashidas( ContentNode* pNode, sal_Int32 nStart, sal_I
|
||||
rArray.push_back(pos);
|
||||
}
|
||||
|
||||
sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos, EditLine* pCurLine )
|
||||
sal_Int32 ImpEditEngine::SplitTextPortion(ParaPortion& rParaPortion, sal_Int32 nPos, EditLine* pCurLine)
|
||||
{
|
||||
// The portion at nPos is split, if there is not a transition at nPos anyway
|
||||
if ( nPos == 0 )
|
||||
return 0;
|
||||
|
||||
assert( pPortion && "SplitTextPortion: Which ?" );
|
||||
|
||||
sal_Int32 nSplitPortion;
|
||||
sal_Int32 nTmpPos = 0;
|
||||
TextPortion* pTextPortion = nullptr;
|
||||
sal_Int32 nPortions = pPortion->GetTextPortions().Count();
|
||||
sal_Int32 nPortions = rParaPortion.GetTextPortions().Count();
|
||||
for ( nSplitPortion = 0; nSplitPortion < nPortions; nSplitPortion++ )
|
||||
{
|
||||
TextPortion& rTP = pPortion->GetTextPortions()[nSplitPortion];
|
||||
TextPortion& rTP = rParaPortion.GetTextPortions()[nSplitPortion];
|
||||
nTmpPos = nTmpPos + rTP.GetLen();
|
||||
if ( nTmpPos >= nPos )
|
||||
{
|
||||
@@ -2559,7 +2554,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
|
||||
sal_Int32 nOverlapp = nTmpPos - nPos;
|
||||
pTextPortion->SetLen( pTextPortion->GetLen() - nOverlapp );
|
||||
TextPortion* pNewPortion = new TextPortion( nOverlapp );
|
||||
pPortion->GetTextPortions().Insert(nSplitPortion+1, pNewPortion);
|
||||
rParaPortion.GetTextPortions().Insert(nSplitPortion+1, pNewPortion);
|
||||
// Set sizes
|
||||
if ( pCurLine )
|
||||
{
|
||||
@@ -2570,13 +2565,13 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
|
||||
if ( pTextPortion->GetExtraInfos() && pTextPortion->GetExtraInfos()->bCompressed )
|
||||
{
|
||||
// We need the original size from the portion
|
||||
sal_Int32 nTxtPortionStart = pPortion->GetTextPortions().GetStartPos( nSplitPortion );
|
||||
SvxFont aTmpFont( pPortion->GetNode()->GetCharAttribs().GetDefFont() );
|
||||
SeekCursor( pPortion->GetNode(), nTxtPortionStart+1, aTmpFont );
|
||||
sal_Int32 nTxtPortionStart = rParaPortion.GetTextPortions().GetStartPos( nSplitPortion );
|
||||
SvxFont aTmpFont = rParaPortion.GetNode()->GetCharAttribs().GetDefFont();
|
||||
SeekCursor(rParaPortion.GetNode(), nTxtPortionStart + 1, aTmpFont);
|
||||
aTmpFont.SetPhysFont(*GetRefDevice());
|
||||
GetRefDevice()->Push( vcl::PushFlags::TEXTLANGUAGE );
|
||||
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
|
||||
Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), pPortion->GetNode()->GetString(),
|
||||
Size aSz = aTmpFont.QuickGetTextSize( GetRefDevice(), rParaPortion.GetNode()->GetString(),
|
||||
nTxtPortionStart, pTextPortion->GetLen(), nullptr );
|
||||
GetRefDevice()->Pop();
|
||||
pTextPortion->GetExtraInfos()->nOrgWidth = aSz.Width();
|
||||
@@ -2588,10 +2583,10 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion* pPortion, sal_Int32 nPos
|
||||
return nSplitPortion;
|
||||
}
|
||||
|
||||
void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rStart )
|
||||
void ImpEditEngine::CreateTextPortions(ParaPortion& rParaPortion, sal_Int32& rStart)
|
||||
{
|
||||
sal_Int32 nStartPos = rStart;
|
||||
ContentNode* pNode = pParaPortion->GetNode();
|
||||
ContentNode* pNode = rParaPortion.GetNode();
|
||||
DBG_ASSERT( pNode->Len(), "CreateTextPortions should not be used for empty paragraphs!" );
|
||||
|
||||
o3tl::sorted_vector< sal_Int32 > aPositions;
|
||||
@@ -2609,14 +2604,14 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
|
||||
}
|
||||
aPositions.insert( pNode->Len() );
|
||||
|
||||
if ( pParaPortion->aScriptInfos.empty() )
|
||||
InitScriptTypes( GetParaPortions().GetPos( pParaPortion ) );
|
||||
if (rParaPortion.aScriptInfos.empty())
|
||||
InitScriptTypes(GetParaPortions().GetPos(&rParaPortion));
|
||||
|
||||
const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
|
||||
const ScriptTypePosInfos& rTypes = rParaPortion.aScriptInfos;
|
||||
for (const ScriptTypePosInfo& rType : rTypes)
|
||||
aPositions.insert( rType.nStartPos );
|
||||
|
||||
const WritingDirectionInfos& rWritingDirections = pParaPortion->aWritingDirectionInfos;
|
||||
const WritingDirectionInfos& rWritingDirections = rParaPortion.aWritingDirectionInfos;
|
||||
for (const WritingDirectionInfo & rWritingDirection : rWritingDirections)
|
||||
aPositions.insert( rWritingDirection.nStartPos );
|
||||
|
||||
@@ -2640,9 +2635,9 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
|
||||
sal_Int32 nPortionStart = 0;
|
||||
sal_Int32 nInvPortion = 0;
|
||||
sal_Int32 nP;
|
||||
for ( nP = 0; nP < pParaPortion->GetTextPortions().Count(); nP++ )
|
||||
for ( nP = 0; nP < rParaPortion.GetTextPortions().Count(); nP++ )
|
||||
{
|
||||
const TextPortion& rTmpPortion = pParaPortion->GetTextPortions()[nP];
|
||||
const TextPortion& rTmpPortion = rParaPortion.GetTextPortions()[nP];
|
||||
nPortionStart = nPortionStart + rTmpPortion.GetLen();
|
||||
if ( nPortionStart >= nStartPos )
|
||||
{
|
||||
@@ -2652,16 +2647,16 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
|
||||
break;
|
||||
}
|
||||
}
|
||||
DBG_ASSERT( nP < pParaPortion->GetTextPortions().Count() || !pParaPortion->GetTextPortions().Count(), "Nothing to delete: CreateTextPortions" );
|
||||
if ( nInvPortion && ( nPortionStart+pParaPortion->GetTextPortions()[nInvPortion].GetLen() > nStartPos ) )
|
||||
DBG_ASSERT( nP < rParaPortion.GetTextPortions().Count() || !rParaPortion.GetTextPortions().Count(), "Nothing to delete: CreateTextPortions" );
|
||||
if ( nInvPortion && ( nPortionStart + rParaPortion.GetTextPortions()[nInvPortion].GetLen() > nStartPos ) )
|
||||
{
|
||||
// prefer one in front...
|
||||
// But only if it was in the middle of the portion of, otherwise it
|
||||
// might be the only one in the row in front!
|
||||
nInvPortion--;
|
||||
nPortionStart = nPortionStart - pParaPortion->GetTextPortions()[nInvPortion].GetLen();
|
||||
nPortionStart = nPortionStart - rParaPortion.GetTextPortions()[nInvPortion].GetLen();
|
||||
}
|
||||
pParaPortion->GetTextPortions().DeleteFromPortion( nInvPortion );
|
||||
rParaPortion.GetTextPortions().DeleteFromPortion( nInvPortion );
|
||||
|
||||
// A portion may also have been formed by a line break:
|
||||
aPositions.insert( nPortionStart );
|
||||
@@ -2674,21 +2669,21 @@ void ImpEditEngine::CreateTextPortions( ParaPortion* pParaPortion, sal_Int32& rS
|
||||
while ( i != aPositions.end() )
|
||||
{
|
||||
TextPortion* pNew = new TextPortion( (*i++) - *nInvPos++ );
|
||||
pParaPortion->GetTextPortions().Append(pNew);
|
||||
rParaPortion.GetTextPortions().Append(pNew);
|
||||
}
|
||||
|
||||
DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No Portions?!" );
|
||||
DBG_ASSERT(rParaPortion.GetTextPortions().Count(), "No Portions?!");
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
OSL_ENSURE( ParaPortion::DbgCheckTextPortions(*pParaPortion), "Portion is broken?" );
|
||||
OSL_ENSURE( ParaPortion::DbgCheckTextPortions(rParaPortion), "Portion is broken?" );
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars )
|
||||
void ImpEditEngine::RecalcTextPortion(ParaPortion& rParaPortion, sal_Int32 nStartPos, sal_Int32 nNewChars)
|
||||
{
|
||||
DBG_ASSERT( pParaPortion->GetTextPortions().Count(), "No Portions!" );
|
||||
DBG_ASSERT(rParaPortion.GetTextPortions().Count(), "No Portions!");
|
||||
DBG_ASSERT( nNewChars, "RecalcTextPortion with Diff == 0" );
|
||||
|
||||
ContentNode* const pNode = pParaPortion->GetNode();
|
||||
ContentNode* const pNode = rParaPortion.GetNode();
|
||||
if ( nNewChars > 0 )
|
||||
{
|
||||
// If an Attribute begins/ends at nStartPos, then a new portion starts
|
||||
@@ -2697,29 +2692,28 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
|
||||
{
|
||||
sal_Int32 nNewPortionPos = 0;
|
||||
if ( nStartPos )
|
||||
nNewPortionPos = SplitTextPortion( pParaPortion, nStartPos ) + 1;
|
||||
nNewPortionPos = SplitTextPortion(rParaPortion, nStartPos) + 1;
|
||||
|
||||
// A blank portion may be here, if the paragraph was empty,
|
||||
// or if a line was created by a hard line break.
|
||||
if ( ( nNewPortionPos < pParaPortion->GetTextPortions().Count() ) &&
|
||||
!pParaPortion->GetTextPortions()[nNewPortionPos].GetLen() )
|
||||
if ( ( nNewPortionPos < rParaPortion.GetTextPortions().Count() ) &&
|
||||
!rParaPortion.GetTextPortions()[nNewPortionPos].GetLen() )
|
||||
{
|
||||
TextPortion& rTP = pParaPortion->GetTextPortions()[nNewPortionPos];
|
||||
TextPortion& rTP = rParaPortion.GetTextPortions()[nNewPortionPos];
|
||||
DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "the empty portion was no TextPortion!" );
|
||||
rTP.SetLen( rTP.GetLen() + nNewChars );
|
||||
}
|
||||
else
|
||||
{
|
||||
TextPortion* pNewPortion = new TextPortion( nNewChars );
|
||||
pParaPortion->GetTextPortions().Insert(nNewPortionPos, pNewPortion);
|
||||
rParaPortion.GetTextPortions().Insert(nNewPortionPos, pNewPortion);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int32 nPortionStart;
|
||||
const sal_Int32 nTP = pParaPortion->GetTextPortions().
|
||||
FindPortion( nStartPos, nPortionStart );
|
||||
TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
|
||||
const sal_Int32 nTP = rParaPortion.GetTextPortions().FindPortion( nStartPos, nPortionStart );
|
||||
TextPortion& rTP = rParaPortion.GetTextPortions()[ nTP ];
|
||||
rTP.SetLen( rTP.GetLen() + nNewChars );
|
||||
rTP.setWidth(-1);
|
||||
}
|
||||
@@ -2736,11 +2730,11 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
|
||||
sal_Int32 nPortion = 0;
|
||||
sal_Int32 nPos = 0;
|
||||
sal_Int32 nEnd = nStartPos-nNewChars;
|
||||
sal_Int32 nPortions = pParaPortion->GetTextPortions().Count();
|
||||
sal_Int32 nPortions = rParaPortion.GetTextPortions().Count();
|
||||
TextPortion* pTP = nullptr;
|
||||
for ( nPortion = 0; nPortion < nPortions; nPortion++ )
|
||||
{
|
||||
pTP = &pParaPortion->GetTextPortions()[ nPortion ];
|
||||
pTP = &rParaPortion.GetTextPortions()[ nPortion ];
|
||||
if ( ( nPos+pTP->GetLen() ) > nStartPos )
|
||||
{
|
||||
DBG_ASSERT( nPos <= nStartPos, "Wrong Start!" );
|
||||
@@ -2754,14 +2748,14 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
|
||||
{
|
||||
// Remove portion;
|
||||
PortionKind nType = pTP->GetKind();
|
||||
pParaPortion->GetTextPortions().Remove( nPortion );
|
||||
rParaPortion.GetTextPortions().Remove( nPortion );
|
||||
if ( nType == PortionKind::LINEBREAK )
|
||||
{
|
||||
TextPortion& rNext = pParaPortion->GetTextPortions()[ nPortion ];
|
||||
TextPortion& rNext = rParaPortion.GetTextPortions()[ nPortion ];
|
||||
if ( !rNext.GetLen() )
|
||||
{
|
||||
// Remove dummy portion
|
||||
pParaPortion->GetTextPortions().Remove( nPortion );
|
||||
rParaPortion.GetTextPortions().Remove( nPortion );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2771,30 +2765,30 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* pParaPortion, sal_Int32 nSta
|
||||
pTP->SetLen( pTP->GetLen() + nNewChars );
|
||||
}
|
||||
|
||||
sal_Int32 nPortionCount = pParaPortion->GetTextPortions().Count();
|
||||
sal_Int32 nPortionCount = rParaPortion.GetTextPortions().Count();
|
||||
assert( nPortionCount );
|
||||
if (nPortionCount)
|
||||
{
|
||||
// No HYPHENATOR portion is allowed to get stuck right at the end...
|
||||
sal_Int32 nLastPortion = nPortionCount - 1;
|
||||
pTP = &pParaPortion->GetTextPortions()[nLastPortion];
|
||||
pTP = &rParaPortion.GetTextPortions()[nLastPortion];
|
||||
if ( pTP->GetKind() == PortionKind::HYPHENATOR )
|
||||
{
|
||||
// Discard portion; if possible, correct the ones before,
|
||||
// if the Hyphenator portion has swallowed one character...
|
||||
if ( nLastPortion && pTP->GetLen() )
|
||||
{
|
||||
TextPortion& rPrev = pParaPortion->GetTextPortions()[nLastPortion - 1];
|
||||
TextPortion& rPrev = rParaPortion.GetTextPortions()[nLastPortion - 1];
|
||||
DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT, "Portion?!" );
|
||||
rPrev.SetLen( rPrev.GetLen() + pTP->GetLen() );
|
||||
rPrev.setWidth(-1);
|
||||
}
|
||||
pParaPortion->GetTextPortions().Remove( nLastPortion );
|
||||
rParaPortion.GetTextPortions().Remove( nLastPortion );
|
||||
}
|
||||
}
|
||||
}
|
||||
#if OSL_DEBUG_LEVEL > 0
|
||||
OSL_ENSURE( ParaPortion::DbgCheckTextPortions(*pParaPortion), "Portions are broken?" );
|
||||
OSL_ENSURE( ParaPortion::DbgCheckTextPortions(rParaPortion), "Portions are broken?" );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3423,7 +3417,7 @@ void ImpEditEngine::Paint( OutputDevice& rOutDev, tools::Rectangle aClipRect, Po
|
||||
DBG_ASSERT( pPortion->GetTextPortions().Count(), "Line without Textportion in Paint!" );
|
||||
const TextPortion& rTextPortion = pPortion->GetTextPortions()[nPortion];
|
||||
|
||||
const tools::Long nPortionXOffset = GetPortionXOffset( pPortion, rLine, nPortion );
|
||||
const tools::Long nPortionXOffset = GetPortionXOffset(*pPortion, rLine, nPortion);
|
||||
setXDirectionAwareFrom(aTmpPos, aStartPos);
|
||||
adjustXDirectionAware(aTmpPos, nPortionXOffset);
|
||||
if (isXOverflowDirectionAware(aTmpPos, aClipRect))
|
||||
@@ -4227,7 +4221,7 @@ void ImpEditEngine::ShowParagraph( sal_Int32 nParagraph, bool bShow )
|
||||
}
|
||||
else
|
||||
{
|
||||
CalcHeight( pPPortion );
|
||||
CalcHeight(*pPPortion);
|
||||
}
|
||||
mnCurTextHeight += pPPortion->GetHeight();
|
||||
}
|
||||
@@ -4840,14 +4834,14 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode* pNode,
|
||||
}
|
||||
|
||||
|
||||
void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* pParaPortion, tools::Long nRemainingWidth)
|
||||
void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion& rParaPortion, tools::Long nRemainingWidth)
|
||||
{
|
||||
bool bFoundCompressedPortion = false;
|
||||
tools::Long nCompressed = 0;
|
||||
std::vector<TextPortion*> aCompressedPortions;
|
||||
|
||||
sal_Int32 nPortion = rLine.GetEndPortion();
|
||||
TextPortion* pTP = &pParaPortion->GetTextPortions()[ nPortion ];
|
||||
TextPortion* pTP = &rParaPortion.GetTextPortions()[ nPortion ];
|
||||
while ( pTP && ( pTP->GetKind() == PortionKind::TEXT ) )
|
||||
{
|
||||
if ( pTP->GetExtraInfos() && pTP->GetExtraInfos()->bCompressed )
|
||||
@@ -4856,7 +4850,7 @@ void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* p
|
||||
nCompressed += pTP->GetExtraInfos()->nOrgWidth - pTP->GetSize().Width();
|
||||
aCompressedPortions.push_back(pTP);
|
||||
}
|
||||
pTP = ( nPortion > rLine.GetStartPortion() ) ? &pParaPortion->GetTextPortions()[ --nPortion ] : nullptr;
|
||||
pTP = ( nPortion > rLine.GetStartPortion() ) ? &rParaPortion.GetTextPortions()[ --nPortion ] : nullptr;
|
||||
}
|
||||
|
||||
if ( !bFoundCompressedPortion )
|
||||
@@ -4878,13 +4872,13 @@ void ImpEditEngine::ImplExpandCompressedPortions(EditLine& rLine, ParaPortion* p
|
||||
pTP->setWidth(pTP->GetExtraInfos()->nOrgWidth);
|
||||
if ( nCompressPercent )
|
||||
{
|
||||
sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos( pTP );
|
||||
sal_Int32 nTxtPortionStart = pParaPortion->GetTextPortions().GetStartPos( nTxtPortion );
|
||||
sal_Int32 nTxtPortion = rParaPortion.GetTextPortions().GetPos( pTP );
|
||||
sal_Int32 nTxtPortionStart = rParaPortion.GetTextPortions().GetStartPos( nTxtPortion );
|
||||
DBG_ASSERT( nTxtPortionStart >= rLine.GetStart(), "Portion doesn't belong to the line!!!" );
|
||||
sal_Int32* pDXArray = rLine.GetCharPosArray().data() + (nTxtPortionStart - rLine.GetStart());
|
||||
if ( pTP->GetExtraInfos()->pOrgDXArray )
|
||||
memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) );
|
||||
ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true );
|
||||
ImplCalcAsianCompression( rParaPortion.GetNode(), pTP, nTxtPortionStart, pDXArray, static_cast<sal_uInt16>(nCompressPercent), true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,10 +184,9 @@ private:
|
||||
const EditSelection& rCurSelection,
|
||||
sal_Int16 nWordType = css::i18n::WordType::ANYWORD_IGNOREWHITESPACES);
|
||||
|
||||
EDITENG_DLLPRIVATE tools::Long GetXPos(
|
||||
const ParaPortion* pParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
|
||||
EDITENG_DLLPRIVATE tools::Long GetXPos(ParaPortion const& rParaPortion, EditLine const& rLine, sal_Int32 nIndex, bool bPreferPortionStart = false) const;
|
||||
|
||||
EDITENG_DLLPRIVATE Range GetLineXPosStartEnd(const ParaPortion* pParaPortion, EditLine const& rLine) const;
|
||||
EDITENG_DLLPRIVATE Range GetLineXPosStartEnd(ParaPortion const& rParaPortion, EditLine const& rLine) const;
|
||||
|
||||
EDITENG_DLLPRIVATE InternalEditStatus& GetInternalEditStatus();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user