Rebased ref, commits from common ancestor:
commit 286ecbe1bc79134e1e33a8782df89d8c1dd323aa
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Tue Sep 27 22:21:37 2022 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Mon Oct 17 21:46:55 2022 +0200
Check Textbox Fit To Frame
Change-Id: I4a02658d06b84cd1222713f12adf14a8194b5b93
diff --git a/editeng/inc/editdoc.hxx b/editeng/inc/editdoc.hxx
index 25a3dca4b1fc..4aa6ff167b45 100644
--- a/editeng/inc/editdoc.hxx
+++ b/editeng/inc/editdoc.hxx
@@ -409,7 +409,29 @@ public:
sal_Int32 GetLen() const { return nLen; }
void SetLen( sal_Int32 nL ) { nLen = nL; }
- Size& GetSize() { return aOutSz; }
+ void setWidth(tools::Long nWidth)
+ {
+ aOutSz.setWidth(nWidth);
+ }
+
+ void setHeight(tools::Long nHeight)
+ {
+ aOutSz.setHeight(nHeight);
+ }
+
+ void adjustSize(tools::Long nDeltaX, tools::Long nDeltaY)
+ {
+ if (nDeltaX != 0)
+ aOutSz.AdjustWidth(nDeltaX);
+ if (nDeltaY != 0)
+ aOutSz.AdjustHeight(nDeltaY);
+ }
+
+ void SetSize(const Size& rSize)
+ {
+ aOutSz = rSize;
+ }
+
const Size& GetSize() const { return aOutSz; }
void SetKind(PortionKind n) { nKind = n; }
@@ -728,7 +750,7 @@ private:
rtl::Reference<SfxItemPool> pItemPool;
Link<LinkParamNone*,void> aModifyHdl;
- SvxFont aDefFont; //faster than ever from the pool!!
+ SvxFont maDefFont; //faster than ever from the pool!!
sal_uInt16 nDefTab;
bool bIsVertical:1;
TextRotation mnRotation;
@@ -755,7 +777,7 @@ public:
void SetModifyHdl( const Link<LinkParamNone*,void>& rLink ) {
aModifyHdl = rLink; }
void CreateDefFont( bool bUseStyles );
- const SvxFont& GetDefFont() const { return aDefFont; }
+ const SvxFont& GetDefFont() const { return maDefFont; }
void SetDefTab( sal_uInt16 nTab ) { nDefTab = nTab ? nTab :
DEFTAB; }
sal_uInt16 GetDefTab() const { return nDefTab; }
diff --git a/editeng/source/editeng/editdoc.cxx
b/editeng/source/editeng/editdoc.cxx
index c3777f111783..c8113a601cf7 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -1988,7 +1988,11 @@ void CreateFont( SvxFont& rFont, const SfxItemSet& rSet,
bool bSearchInParent, S
if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_BKGCOLOR ) ==
SfxItemState::SET ) )
rFont.SetFillColor( rSet.Get( EE_CHAR_BKGCOLOR ).GetValue() );
if ( bSearchInParent || ( rSet.GetItemState( nWhich_FontHeight ) ==
SfxItemState::SET ) )
- rFont.SetFontSize( Size( rFont.GetFontSize().Width(),
static_cast<const SvxFontHeightItem&>(rSet.Get( nWhich_FontHeight )
).GetHeight() ) );
+ {
+ auto nHeight = static_cast<const SvxFontHeightItem&>(rSet.Get(
nWhich_FontHeight ) ).GetHeight();
+ printf ("FONTHEIGHT %ld\n", nHeight);
+ rFont.SetFontSize(Size(rFont.GetFontSize().Width(), nHeight));
+ }
if ( bSearchInParent || ( rSet.GetItemState( nWhich_Weight ) ==
SfxItemState::SET ) )
rFont.SetWeight( static_cast<const SvxWeightItem&>(rSet.Get(
nWhich_Weight )).GetWeight() );
if ( bSearchInParent || ( rSet.GetItemState( EE_CHAR_UNDERLINE ) ==
SfxItemState::SET ) )
@@ -2039,14 +2043,14 @@ void CreateFont( SvxFont& rFont, const SfxItemSet&
rSet, bool bSearchInParent, S
void EditDoc::CreateDefFont( bool bUseStyles )
{
SfxItemSetFixed<EE_PARA_START, EE_CHAR_END> aTmpSet( GetItemPool() );
- CreateFont( aDefFont, aTmpSet );
- aDefFont.SetVertical( IsEffectivelyVertical() );
- aDefFont.SetOrientation( Degree10(IsEffectivelyVertical() ?
(IsTopToBottom() ? 2700 : 900) : 0) );
+ CreateFont(maDefFont, aTmpSet);
+ maDefFont.SetVertical( IsEffectivelyVertical() );
+ maDefFont.SetOrientation( Degree10(IsEffectivelyVertical() ?
(IsTopToBottom() ? 2700 : 900) : 0) );
for ( sal_Int32 nNode = 0; nNode < Count(); nNode++ )
{
ContentNode* pNode = GetObject( nNode );
- pNode->GetCharAttribs().GetDefFont() = aDefFont;
+ pNode->GetCharAttribs().GetDefFont() = maDefFont;
if ( bUseStyles )
pNode->CreateDefFont();
}
diff --git a/editeng/source/editeng/impedit2.cxx
b/editeng/source/editeng/impedit2.cxx
index ffa8913b0c75..ddde6b26f9c7 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -3347,6 +3347,7 @@ sal_uInt32 ImpEditEngine::GetTextHeight() const
sal_uInt32 ImpEditEngine::CalcTextWidth( bool bIgnoreExtraSpace )
{
+ printf("ImpEditEngine::CalcTextWidth\n");
// If still not formatted and not in the process.
// Will be brought in the formatting for AutoPageSize.
if ( !IsFormatted() && !IsFormatting() )
@@ -3361,12 +3362,13 @@ sal_uInt32 ImpEditEngine::CalcTextWidth( bool
bIgnoreExtraSpace )
{
nMaxWidth = std::max(nMaxWidth, CalcParaWidth(nPara,
bIgnoreExtraSpace));
}
-
+ printf("end ImpEditEngine::CalcTextWidth %d\n", nMaxWidth);
return nMaxWidth;
}
sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara, bool
bIgnoreExtraSpace )
{
+ printf("ImpEditEngine::CalcParaWidth\n");
// If still not formatted and not in the process.
// Will be brought in the formatting for AutoPageSize.
if ( !IsFormatted() && !IsFormatting() )
@@ -3386,8 +3388,8 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara,
bool bIgnoreExtraSpace
// On the lines of the paragraph ...
- sal_Int32 nLines = pPortion->GetLines().Count();
- for ( sal_Int32 nLine = 0; nLine < nLines; nLine++ )
+ sal_Int32 nNumberOfLines = pPortion->GetLines().Count();
+ for (sal_Int32 nLine = 0; nLine < nNumberOfLines; nLine++)
{
EditLine& rLine = pPortion->GetLines()[nLine];
// nCurWidth = pLine->GetStartPosX();
@@ -3396,7 +3398,8 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32 nPara,
bool bIgnoreExtraSpace
// to StartPosX, also the right indents have to be taken into
// account!
tools::Long nCurWidth = GetXValue( rLRItem.GetTextLeft() +
nSpaceBeforeAndMinLabelWidth );
- if ( nLine == 0 )
+ printf ("nCurWidth 1 - %ld\n", nCurWidth);
+ if (nLine == 0)
{
tools::Long nFI = GetXValue( rLRItem.GetTextFirstLineOffset()
);
nCurWidth -= nFI;
@@ -3407,17 +3410,19 @@ sal_uInt32 ImpEditEngine::CalcParaWidth( sal_Int32
nPara, bool bIgnoreExtraSpace
nCurWidth = pPortion->GetBulletX();
}
}
- nCurWidth += GetXValue( rLRItem.GetRight() );
- nCurWidth += CalcLineWidth( pPortion, &rLine, bIgnoreExtraSpace );
- if ( nCurWidth > nMaxWidth )
- {
- nMaxWidth = nCurWidth;
- }
+
+ nCurWidth += GetXValue(rLRItem.GetRight());
+ printf ("nCurWidth 2 - %ld\n", nCurWidth);
+ nCurWidth += CalcLineWidth(pPortion, &rLine, bIgnoreExtraSpace);
+ printf ("nCurWidth 3 - %ld\n", nCurWidth);
+
+ nMaxWidth = std::max(nCurWidth, nMaxWidth);
}
}
nMaxWidth++; // widen it, because in CreateLines for >= is wrapped.
- return static_cast<sal_uInt32>(nMaxWidth);
+ printf ("max width: %ld\n", nMaxWidth);
+ return sal_uInt32(nMaxWidth);
}
sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion* pPortion, EditLine*
pLine, bool bIgnoreExtraSpace )
@@ -3451,7 +3456,9 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion*
pPortion, EditLine* pLine,
{
if ( ( eJustification != SvxAdjust::Block ) || (
!bIgnoreExtraSpace ) )
{
- nWidth += rTextPortion.GetSize().Width();
+ auto width = rTextPortion.GetSize().Width();
+ printf ("WIDTH: %ld\n", width);
+ nWidth += width;
}
else
{
@@ -3459,8 +3466,11 @@ sal_uInt32 ImpEditEngine::CalcLineWidth( ParaPortion*
pPortion, EditLine* pLine,
SeekCursor( pPortion->GetNode(), nPos+1, aTmpFont );
aTmpFont.SetPhysFont(*GetRefDevice());
ImplInitDigitMode(*GetRefDevice(), aTmpFont.GetLanguage());
- nWidth += aTmpFont.QuickGetTextSize( GetRefDevice(),
+ auto width = aTmpFont.QuickGetTextSize( GetRefDevice(),
pPortion->GetNode()->GetString(), nPos,
rTextPortion.GetLen(), nullptr ).Width();
+
+ printf ("WIDTH: %ld\n", width);
+ nWidth += width;
}
}
break;
diff --git a/editeng/source/editeng/impedit3.cxx
b/editeng/source/editeng/impedit3.cxx
index b33b8c5f1554..5ba70bb9c875 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -676,6 +676,7 @@ tools::Long ImpEditEngine::GetColumnWidth(const Size&
rPaperSize) const
bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY )
{
+ printf ("ImpEditEngine::CreateLines\n");
ParaPortion* pParaPortion = GetParaPortions()[nPara];
// sal_Bool: Changes in the height of paragraph Yes / No -
sal_True/sal_False
@@ -838,7 +839,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
EditLine aSaveLine( *pLine );
SvxFont aTmpFont( pNode->GetCharAttribs().GetDefFont() );
- std::vector<sal_Int32> aBuf( pNode->Len() );
+ std::vector<sal_Int32> aCharPositionArray(pNode->Len());
bool bSameLineAgain = false; // For TextRanger, if the height changes.
TabInfo aCurrentTab;
@@ -973,6 +974,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
}
// search for Portion that no longer fits in line...
+
TextPortion* pPortion = nullptr;
sal_Int32 nPortionLen = 0;
bool bContinueLastPortion = false;
@@ -1014,7 +1016,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
nTmpWidth -= rPrev.GetSize().Width();
nTmpPos = nTmpPos - rPrev.GetLen();
rPrev.SetLen(rPrev.GetLen() + nTmpLen);
- rPrev.GetSize().setWidth( -1 );
+ rPrev.setWidth(-1);
}
assert( nTmpPortion < pParaPortion->GetTextPortions().Count()
&& "No more Portions left!" );
@@ -1043,6 +1045,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
{
case EE_FEATURE_TAB:
{
+ printf ("EE_FEATURE_TAB\n");
tools::Long nOldTmpWidth = nTmpWidth;
// Search for Tab-Pos...
@@ -1077,11 +1080,11 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
pPortion->SetKind(PortionKind::TAB);
pPortion->SetExtraValue(
aCurrentTab.aTabStop.GetFill() );
- pPortion->GetSize().setWidth( aCurrentTab.nTabPos -
(nTmpWidth+nStartX) );
+ pPortion->setWidth( aCurrentTab.nTabPos -
(nTmpWidth+nStartX) );
// Height needed...
SeekCursor( pNode, nTmpPos+1, aTmpFont );
- pPortion->GetSize().setHeight(
GetRefDevice()->GetTextHeight() );
+ pPortion->setHeight( GetRefDevice()->GetTextHeight() );
DBG_ASSERT( pPortion->GetSize().Width() >= 0, "Tab
incorrectly calculated!" );
@@ -1093,7 +1096,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
{
// What now?
// make the tab fitting
- pPortion->GetSize().setWidth( nXWidth-nOldTmpWidth
);
+ pPortion->setWidth( nXWidth-nOldTmpWidth );
nTmpWidth = nXWidth-1;
bEOL = true;
bBrokenLine = true;
@@ -1106,8 +1109,9 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
break;
case EE_FEATURE_LINEBR:
{
+ printf ("EE_FEATURE_LINEBR\n");
assert( pPortion );
- pPortion->GetSize().setWidth( 0 );
+ pPortion->setWidth(0);
bEOL = true;
bLineBreak = true;
pPortion->SetKind( PortionKind::LINEBREAK );
@@ -1119,6 +1123,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
break;
case EE_FEATURE_FIELD:
{
+ printf ("EE_FEATURE_FIELD\n");
SeekCursor( pNode, nTmpPos+1, aTmpFont );
aTmpFont.SetPhysFont(*GetRefDevice());
ImplInitDigitMode(*GetRefDevice(),
aTmpFont.GetLanguage());
@@ -1126,8 +1131,8 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
OUString aFieldValue = static_cast<const
EditCharAttribField*>(pNextFeature)->GetFieldValue();
// get size, but also DXArray to allow length
information in line breaking below
std::vector<sal_Int32> aTmpDXArray;
- pPortion->GetSize() =
aTmpFont.QuickGetTextSize(GetRefDevice(),
- aFieldValue, 0, aFieldValue.getLength(),
&aTmpDXArray);
+
pPortion->SetSize(aTmpFont.QuickGetTextSize(GetRefDevice(),
+ aFieldValue, 0, aFieldValue.getLength(),
&aTmpDXArray));
// So no scrolling for oversized fields
if ( pPortion->GetSize().Width() > nXWidth )
@@ -1232,27 +1237,35 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
if (bContinueLastPortion)
{
Size aSize( aTmpFont.QuickGetTextSize( GetRefDevice(),
- pParaPortion->GetNode()->GetString(), nTmpPos,
nPortionLen, &aBuf ));
- pPortion->GetSize().AdjustWidth(aSize.Width() );
+ pParaPortion->GetNode()->GetString(), nTmpPos,
nPortionLen, &aCharPositionArray ));
+ pPortion->adjustSize(aSize.Width(), 0);
if (pPortion->GetSize().Height() < aSize.Height())
- pPortion->GetSize().setHeight( aSize.Height() );
+ pPortion->setHeight(aSize.Height());
}
else
{
- pPortion->GetSize() = aTmpFont.QuickGetTextSize(
GetRefDevice(),
- pParaPortion->GetNode()->GetString(), nTmpPos,
nPortionLen, &aBuf );
+ for (auto n : aCharPositionArray)
+ printf ("%d ", n);
+ printf ("\n");
+ GetRefDevice()->SetText
+ auto aSize = aTmpFont.QuickGetTextSize(GetRefDevice(),
pParaPortion->GetNode()->GetString(), nTmpPos, nPortionLen,
&aCharPositionArray);
+ pPortion->SetSize(aSize);
+ printf ("SDDDDD %ld %ld - %ld %ld\n", aSize.Width(),
aSize.Height(), aTmpFont.GetFontSize().Width(),
aTmpFont.GetFontSize().Height());
}
// #i9050# Do Kerning also behind portions...
if ( ( aTmpFont.GetFixKerning() > 0 ) && ( ( nTmpPos +
nPortionLen ) < pNode->Len() ) )
- pPortion->GetSize().AdjustWidth(aTmpFont.GetFixKerning() );
+ pPortion->adjustSize(aTmpFont.GetFixKerning(), 0);
if ( IsFixedCellHeight() )
- pPortion->GetSize().setHeight(
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+ {
+ printf ("IsFixedCellHeight - true\n");
+ pPortion->setHeight(
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+ }
// The array is generally flattened at the beginning
// => Always simply quick inserts.
size_t nPos = nTmpPos - pLine->GetStart();
EditLine::CharPosArrayType& rArray = pLine->GetCharPosArray();
- rArray.insert( rArray.begin() + nPos, aBuf.data(), aBuf.data()
+ nPortionLen);
+ rArray.insert( rArray.begin() + nPos,
aCharPositionArray.data(), aCharPositionArray.data() + nPortionLen);
// And now check for Compression:
if ( !bContinueLastPortion && nPortionLen &&
GetAsianCompressionMode() != CharCompressType::NONE )
@@ -1278,7 +1291,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
{
tools::Long nExtraSpace =
pPortion->GetSize().Height()/5;
nExtraSpace = GetXValue( nExtraSpace );
- pPortion->GetSize().AdjustWidth(nExtraSpace );
+ pPortion->adjustSize(nExtraSpace, 0);
nTmpWidth += nExtraSpace;
}
}
@@ -1324,7 +1337,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
aCurrentTab.bValid = false;
}
TextPortion& rTabPortion =
pParaPortion->GetTextPortions()[aCurrentTab.nTabPortion];
- rTabPortion.GetSize().setWidth( aCurrentTab.nTabPos -
aCurrentTab.nStartPosX - nW - nStartX );
+ rTabPortion.setWidth( aCurrentTab.nTabPos -
aCurrentTab.nStartPosX - nW - nStartX );
nTmpWidth = aCurrentTab.nStartPosX +
rTabPortion.GetSize().Width() + nWidthAfterTab;
}
@@ -1576,7 +1589,7 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara,
sal_uInt32 nStartPosY )
{
pLine->GetCharPosArray()[ nPosInArray ] = nNewValue;
}
- rTP.GetSize().AdjustWidth(n );
+ rTP.adjustSize(n, 0);
}
pLine->SetTextWidth( aTextSize.Width() );
@@ -1801,9 +1814,9 @@ void ImpEditEngine::CreateAndInsertEmptyLine(
ParaPortion* pParaPortion )
aTmpFont.SetPhysFont(*pRefDev);
TextPortion* pDummyPortion = new TextPortion( 0 );
- pDummyPortion->GetSize() = aTmpFont.GetPhysTxtSize( pRefDev );
+ pDummyPortion->SetSize(aTmpFont.GetPhysTxtSize(pRefDev));
if ( IsFixedCellHeight() )
- pDummyPortion->GetSize().setHeight(
ImplCalculateFontIndependentLineSpacing( aTmpFont.GetFontHeight() ) );
+ pDummyPortion->setHeight( ImplCalculateFontIndependentLineSpacing(
aTmpFont.GetFontHeight() ) );
pParaPortion->GetTextPortions().Append(pDummyPortion);
FormatterFontMetric aFormatterMetrics;
RecalcFormatterFontMetrics( aFormatterMetrics, aTmpFont );
@@ -2138,7 +2151,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion*
pParaPortion, EditLine* pLine, Te
DBG_ASSERT( rTP.GetKind() == PortionKind::TEXT, "BlankRubber: No
TextPortion!" );
DBG_ASSERT( nBreakPos > pLine->GetStart(), "SplitTextPortion at the
beginning of the line?" );
sal_Int32 nPosInArray = nBreakPos - 1 - pLine->GetStart();
- rTP.GetSize().setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ?
pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 );
+ rTP.setWidth( ( nPosInArray && ( rTP.GetLen() > 1 ) ) ?
pLine->GetCharPosArray()[ nPosInArray-1 ] : 0 );
if (o3tl::make_unsigned(nPosInArray) < pLine->GetCharPosArray().size())
{
pLine->GetCharPosArray()[ nPosInArray ] = rTP.GetSize().Width();
@@ -2157,7 +2170,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion*
pParaPortion, EditLine* pLine, Te
pHyphPortion->SetLen( nAltDelChar );
if (cAlternateReplChar && !bAltFullLeft)
pHyphPortion->SetExtraValue( cAlternateReplChar );
// Correct width of the portion above:
- rPrev.GetSize().setWidth(
+ rPrev.setWidth(
pLine->GetCharPosArray()[ nBreakPos-1 - pLine->GetStart() -
nAltDelChar ] );
}
@@ -2165,8 +2178,7 @@ void ImpEditEngine::ImpBreakLine( ParaPortion*
pParaPortion, EditLine* pLine, Te
SvxFont aFont;
SeekCursor( pParaPortion->GetNode(), nBreakPos, aFont );
aFont.SetPhysFont(*GetRefDevice());
- pHyphPortion->GetSize().setHeight( GetRefDevice()->GetTextHeight() );
- pHyphPortion->GetSize().setWidth( GetRefDevice()->GetTextWidth(
CH_HYPH ) );
+ pHyphPortion->SetSize(Size(GetRefDevice()->GetTextHeight(),
GetRefDevice()->GetTextWidth(CH_HYPH)));
pParaPortion->GetTextPortions().Insert(++nEndPortion, pHyphPortion);
}
@@ -2251,7 +2263,7 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion*
pParaPortion, EditLine* pLine,
// For the last character the portion must stop behind the blank
// => Simplify correction:
DBG_ASSERT( ( nPortionStart + rLastPortion.GetLen() ) == (
nLastChar+1 ), "Blank actually not at the end of the portion!?");
- rLastPortion.GetSize().AdjustWidth( -nBlankWidth );
+ rLastPortion.adjustSize(-nBlankWidth, 0);
nRemainingSpace += nBlankWidth;
}
pLine->GetCharPosArray()[nLastChar-nFirstChar] -= nBlankWidth;
@@ -2288,9 +2300,11 @@ void ImpEditEngine::ImpAdjustBlocks( ParaPortion*
pParaPortion, EditLine* pLine,
TextPortion& rLastPortion = pParaPortion->GetTextPortions()[
nPortion ];
// The width of the portion:
- rLastPortion.GetSize().AdjustWidth(nMore4Everyone );
- if ( nSomeExtraSpace )
- rLastPortion.GetSize().AdjustWidth( 1 );
+ rLastPortion.adjustSize(nMore4Everyone, 0);
+ if (nSomeExtraSpace)
+ {
+ rLastPortion.adjustSize(1, 0);
+ }
// Correct positions in array
sal_Int32 nPortionEnd = nPortionStart + rLastPortion.GetLen();
@@ -2546,7 +2560,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion*
pPortion, sal_Int32 nPos
{
// No new GetTextSize, instead use values from the Array:
assert( nPos > pCurLine->GetStart() && "SplitTextPortion at the
beginning of the line?" );
- pTextPortion->GetSize().setWidth( pCurLine->GetCharPosArray()[
nPos-pCurLine->GetStart()-1 ] );
+ pTextPortion->setWidth(pCurLine->GetCharPosArray()[nPos -
pCurLine->GetStart() - 1]);
if ( pTextPortion->GetExtraInfos() &&
pTextPortion->GetExtraInfos()->bCompressed )
{
@@ -2564,7 +2578,7 @@ sal_Int32 ImpEditEngine::SplitTextPortion( ParaPortion*
pPortion, sal_Int32 nPos
}
}
else
- pTextPortion->GetSize().setWidth( -1 );
+ pTextPortion->setWidth(-1);
return nSplitPortion;
}
@@ -2702,7 +2716,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion*
pParaPortion, sal_Int32 nSta
FindPortion( nStartPos, nPortionStart );
TextPortion& rTP = pParaPortion->GetTextPortions()[ nTP ];
rTP.SetLen( rTP.GetLen() + nNewChars );
- rTP.GetSize().setWidth( -1 );
+ rTP.setWidth(-1);
}
}
else
@@ -2768,7 +2782,7 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion*
pParaPortion, sal_Int32 nSta
TextPortion& rPrev =
pParaPortion->GetTextPortions()[nLastPortion - 1];
DBG_ASSERT( rPrev.GetKind() == PortionKind::TEXT,
"Portion?!" );
rPrev.SetLen( rPrev.GetLen() + pTP->GetLen() );
- rPrev.GetSize().setWidth( -1 );
+ rPrev.setWidth(-1);
}
pParaPortion->GetTextPortions().Remove( nLastPortion );
}
@@ -4743,7 +4757,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode*
pNode,
if ( bCompressed && ( n100thPercentFromMax == 10000 ) )
pTextPortion->GetExtraInfos()->nWidthFullCompression =
nNewPortionWidth;
- pTextPortion->GetSize().setWidth( nNewPortionWidth );
+ pTextPortion->setWidth(nNewPortionWidth);
if ( pTextPortion->GetExtraInfos() && ( n100thPercentFromMax != 10000
) )
{
@@ -4753,7 +4767,7 @@ bool ImpEditEngine::ImplCalcAsianCompression(ContentNode*
pNode,
nShrink /= 10000;
tools::Long nNewWidth = pTextPortion->GetExtraInfos()->nOrgWidth -
nShrink;
if ( nNewWidth < pTextPortion->GetSize().Width() )
- pTextPortion->GetSize().setWidth( nNewWidth );
+ pTextPortion->setWidth(nNewWidth);
}
}
return bCompressed;
@@ -4795,7 +4809,7 @@ void ImpEditEngine::ImplExpandCompressedPortions(
EditLine* pLine, ParaPortion*
{
pTP = pTP2;
pTP->GetExtraInfos()->bCompressed = false;
- pTP->GetSize().setWidth( pTP->GetExtraInfos()->nOrgWidth );
+ pTP->setWidth(pTP->GetExtraInfos()->nOrgWidth);
if ( nCompressPercent )
{
sal_Int32 nTxtPortion = pParaPortion->GetTextPortions().GetPos(
pTP );
diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx
index 65191cab8ed7..f9623936ca54 100644
--- a/editeng/source/items/svxfont.cxx
+++ b/editeng/source/items/svxfont.cxx
@@ -477,9 +477,13 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut )
Size SvxFont::QuickGetTextSize( const OutputDevice *pOut, const OUString &rTxt,
const sal_Int32 nIdx, const sal_Int32 nLen,
std::vector<sal_Int32>* pDXArray ) const
{
- if ( !IsCaseMap() && !IsFixKerning() )
- return Size( GetTextArray( pOut, rTxt, pDXArray, nIdx, nLen ),
- pOut->GetTextHeight() );
+ if (!IsCaseMap() && !IsFixKerning())
+ {
+ printf ("SvxFont TextHeight %ld\n", pOut->GetTextHeight());
+ auto nWidth = GetTextArray(pOut, rTxt, pDXArray, nIdx, nLen);
+ auto nHeight = pOut->GetTextHeight();
+ return Size(nWidth, nHeight);
+ }
std::vector<sal_Int32> aDXArray;
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index 24223aaee738..c4779866b391 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -199,6 +199,7 @@ SdrTextObj::~SdrTextObj()
void SdrTextObj::FitFrameToTextSize()
{
+ printf ("FitFrameToTextSize\n");
ImpJustifyRect(maRect);
SdrText* pText = getActiveText();
@@ -866,6 +867,8 @@ std::optional<OutlinerParaObject>
SdrTextObj::CreateEditOutlinerParaObject() con
void SdrTextObj::ImpSetCharStretching(SdrOutliner& rOutliner, const Size&
rTextSize, const Size& rShapeSize, Fraction& rFitXCorrection)
{
+ printf ("SdrTextObj::ImpSetCharStretching\n");
+
OutputDevice* pOut = rOutliner.GetRefDevice();
bool bNoStretching(false);
commit 1ea1cfa748f34e95f0f0b58c8012d9223ce4407d
Author: Tomaž Vajngerl <[email protected]>
AuthorDate: Thu Oct 13 10:12:27 2022 +0200
Commit: Tomaž Vajngerl <[email protected]>
CommitDate: Mon Oct 17 21:46:55 2022 +0200
add division of length units to LengthUnitBase
Reult of division of 2 length units is a ratio (double).
Change-Id: I3d0e605492ca0af93580de138b5bc0c3e7877fa5
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
index 8861a2ade316..11095f3222b5 100644
--- a/basegfx/test/LengthUnitTest.cxx
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -32,11 +32,6 @@ public:
CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
- gfx::Length cm4(1_cm);
- cm4 /= 2;
- CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
-
// (635 * 20) + 3 * (635 * 15) = 41275EMU
gfx::Length pt = 1_pt + 3_px;
CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4);
@@ -92,6 +87,23 @@ public:
CPPUNIT_ASSERT_EQUAL(sal_Int64(3636), bb.raw());
}
+ void testDivision()
+ {
+ gfx::Length cm(1_cm);
+ cm /= 2;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm.raw());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm.as_cm(), 1e-4);
+
+ gfx::Length cm4(1_cm);
+ cm4 /= 2.0;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
+
+ // with division of 2 length units you get a ratio
+ double aRatio = gfx::Length::hmm(10) / gfx::Length::hmm(20);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, aRatio, 1e-9);
+ }
+
void testInRange()
{
gfx::Range2DL aRange(1_cm, 2_cm, 2_cm, 30_mm);
@@ -159,6 +171,7 @@ public:
CPPUNIT_TEST_SUITE(LengthTest);
CPPUNIT_TEST(testBasic);
+ CPPUNIT_TEST(testDivision);
CPPUNIT_TEST(testInRange);
CPPUNIT_TEST(testInTuple);
CPPUNIT_TEST(testConversionToRectanle);
diff --git a/include/basegfx/units/LengthUnitBase.hxx
b/include/basegfx/units/LengthUnitBase.hxx
index c1d8a8e8e431..30daccef8015 100644
--- a/include/basegfx/units/LengthUnitBase.hxx
+++ b/include/basegfx/units/LengthUnitBase.hxx
@@ -173,14 +173,25 @@ inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs,
const LengthUnitBase<T
return lhs -= rhs;
}
+/// Multiplication of a length unit with a scalar value.
+/// example 1cm * 2 = 2cm
template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T>
lhs, const long rhs)
{
return lhs *= rhs;
}
+/// Division of a length unit with a scalar value.
+/// example 1cm / 2 = 0.5cm
template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T>
lhs, const long rhs)
{
return lhs /= rhs;
}
+/// Division of 2 length units, which results in a ratio.
+/// example 1cm / 2cm = 0.5
+template <typename T> inline double operator/(LengthUnitBase<T> lhs, const
LengthUnitBase<T> rhs)
+{
+ return lhs.raw() / double(rhs.raw());
+}
+
} // end namespace gfx