summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@novell.com>2010-09-17 10:11:31 +0200
committerJan Holesovsky <kendy@suse.cz>2010-09-17 10:14:53 +0200
commite479f47f7d48dbd0d701bf347b6a2d5121ba3d34 (patch)
tree75bb4c012292178482dfab7dd052d9864121e230 /editeng
parent1ea6792208820a5d1920b59ee895336beb994085 (diff)
fit-list-to-size.diff: Shrink font automatically when text overflows.
i#94086 Scale-font-down if typing text in Impress and the text box becomes too small.
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editobj2.hxx10
-rw-r--r--editeng/source/editeng/impedit3.cxx67
-rwxr-xr-xediteng/source/editeng/impedit4.cxx6
-rw-r--r--editeng/source/outliner/outliner.cxx11
4 files changed, 62 insertions, 32 deletions
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 6ef3ce359d49..6b777081f371 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -112,12 +112,16 @@ class XParaPortionList : public XBaseParaPortionList
ULONG nRefDevPtr;
OutDevType eRefDevType;
MapMode aRefMapMode;
+ sal_uInt16 nStretchX;
+ sal_uInt16 nStretchY;
ULONG nPaperWidth;
public:
- XParaPortionList( OutputDevice* pRefDev, ULONG nPW ) :
- aRefMapMode( pRefDev->GetMapMode() )
+ XParaPortionList( OutputDevice* pRefDev, ULONG nPW, sal_uInt16 _nStretchX, sal_uInt16 _nStretchY ) :
+ aRefMapMode( pRefDev->GetMapMode() ),
+ nStretchX(_nStretchX),
+ nStretchY(_nStretchY)
{
nRefDevPtr = (ULONG)pRefDev; nPaperWidth = nPW;
eRefDevType = pRefDev->GetOutDevType();
@@ -127,6 +131,8 @@ public:
ULONG GetPaperWidth() const { return nPaperWidth; }
OutDevType GetRefDevType() const { return eRefDevType; }
const MapMode& GetRefMapMode() const { return aRefMapMode; }
+ sal_uInt16 GetStretchX() const { return nStretchX; }
+ sal_uInt16 GetStretchY() const { return nStretchY; }
};
/* cl removed because not needed anymore since binfilter
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 524d69592298..c74b0250917f 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2657,36 +2657,44 @@ void ImpEditEngine::SeekCursor( ContentNode* pNode, sal_uInt16 nPos, SvxFont& rF
}
if ( nStretchX != 100 )
{
- aRealSz.Width() *= nStretchX;
- aRealSz.Width() /= 100;
-
- // Auch das Kerning: (long wegen Zwischenergebnis)
- long nKerning = rFont.GetFixKerning();
-/*
- Die Ueberlegung war: Wenn neg. Kerning, aber StretchX = 200
- => Nicht das Kerning verdoppelt, also die Buchstaben weiter
- zusammenziehen
- ---------------------------
- Kern StretchX =>Kern
- ---------------------------
- >0 <100 < (Proportional)
- <0 <100 < (Proportional)
- >0 >100 > (Proportional)
- <0 >100 < (Der Betrag, also Antiprop)
-*/
- if ( ( nKerning < 0 ) && ( nStretchX > 100 ) )
+ if ( nStretchX == nStretchY &&
+ nRelWidth == 100 )
{
- // Antiproportional
- nKerning *= 100;
- nKerning /= nStretchX;
+ aRealSz.Width() = 0;
}
- else if ( nKerning )
+ else
{
- // Proportional
- nKerning *= nStretchX;
- nKerning /= 100;
+ aRealSz.Width() *= nStretchX;
+ aRealSz.Width() /= 100;
+
+ // Auch das Kerning: (long wegen Zwischenergebnis)
+ long nKerning = rFont.GetFixKerning();
+/*
+ Die Ueberlegung war: Wenn neg. Kerning, aber StretchX = 200
+ => Nicht das Kerning verdoppelt, also die Buchstaben weiter
+ zusammenziehen
+ ---------------------------
+ Kern StretchX =>Kern
+ ---------------------------
+ >0 <100 < (Proportional)
+ <0 <100 < (Proportional)
+ >0 >100 > (Proportional)
+ <0 >100 < (Der Betrag, also Antiprop)
+*/
+ if ( ( nKerning < 0 ) && ( nStretchX > 100 ) )
+ {
+ // Antiproportional
+ nKerning *= 100;
+ nKerning /= nStretchX;
+ }
+ else if ( nKerning )
+ {
+ // Proportional
+ nKerning *= nStretchX;
+ nKerning /= 100;
+ }
+ rFont.SetFixKerning( (short)nKerning );
}
- rFont.SetFixKerning( (short)nKerning );
}
}
if ( nRelWidth != 100 )
@@ -4095,20 +4103,25 @@ void ImpEditEngine::SetFlatMode( sal_Bool bFlat )
void ImpEditEngine::SetCharStretching( sal_uInt16 nX, sal_uInt16 nY )
{
+ bool bChanged(false);
if ( !IsVertical() )
{
+ bChanged = nStretchX!=nX || nStretchY!=nY;
nStretchX = nX;
nStretchY = nY;
}
else
{
+ bChanged = nStretchX!=nY || nStretchY!=nX;
nStretchX = nY;
nStretchY = nX;
}
- if ( aStatus.DoStretch() )
+ if (bChanged && aStatus.DoStretch())
{
FormatFullDoc();
+ // (potentially) need everything redrawn
+ aInvalidRec=Rectangle(0,0,1000000,1000000);
UpdateViews( GetActiveView() );
}
}
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 46a0668394f2..f3f54c78def1 100755
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1159,7 +1159,7 @@ EditTextObject* ImpEditEngine::CreateBinTextObject( EditSelection aSel, SfxItemP
// Schwelle rauf setzen, wenn Olli die Absaetze nicht mehr zerhackt!
if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) )
{
- XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), aPaperSize.Width() );
+ XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), aPaperSize.Width(), nStretchX, nStretchY );
pTxtObj->SetPortionInfo( pXList );
for ( nNode = nStartNode; nNode <= nEndNode; nNode++ )
{
@@ -1250,7 +1250,9 @@ EditSelection ImpEditEngine::InsertBinTextObject( BinTextObject& rTextObject, Ed
XParaPortionList* pPortionInfo = rTextObject.GetPortionInfo();
if ( pPortionInfo && ( (long)pPortionInfo->GetPaperWidth() == aPaperSize.Width() )
- && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() ) )
+ && ( pPortionInfo->GetRefMapMode() == GetRefDevice()->GetMapMode() )
+ && ( pPortionInfo->GetStretchX() == nStretchX )
+ && ( pPortionInfo->GetStretchY() == nStretchY ) )
{
if ( ( pPortionInfo->GetRefDevPtr() == (sal_uIntPtr)GetRefDevice() ) ||
( ( pPortionInfo->GetRefDevType() == OUTDEV_VIRDEV ) &&
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 9e9b5dcc0e70..a1d1f5935196 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -925,7 +925,10 @@ Font Outliner::ImpCalcBulletFont( USHORT nPara ) const
}
// #107508# Use original scale...
- USHORT nScale = /* pEditEngine->IsFlatMode() ? DEFAULT_SCALE : */ pFmt->GetBulletRelSize();
+ USHORT nStretchX, nStretchY;
+ const_cast<Outliner*>(this)->GetGlobalCharStretching(nStretchX, nStretchY);
+
+ USHORT nScale = pFmt->GetBulletRelSize() * nStretchY / 100;
ULONG nScaledLineHeight = aStdFont.GetSize().Height();
nScaledLineHeight *= nScale*10;
nScaledLineHeight /= 1000;
@@ -968,6 +971,12 @@ void Outliner::PaintBullet( USHORT nPara, const Point& rStartPos,
BOOL bRightToLeftPara = pEditEngine->IsRightToLeft( nPara );
Rectangle aBulletArea( ImpCalcBulletArea( nPara, TRUE, FALSE ) );
+ USHORT nStretchX, nStretchY;
+ GetGlobalCharStretching(nStretchX, nStretchY);
+ aBulletArea = Rectangle( Point(aBulletArea.Left()*nStretchX/100,
+ aBulletArea.Top()),
+ Size(aBulletArea.GetWidth()*nStretchX/100,
+ aBulletArea.GetHeight()) );
Paragraph* pPara = pParaList->GetParagraph( nPara );
const SvxNumberFormat* pFmt = GetNumberFormat( nPara );