summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2002-09-17 12:17:03 +0000
committerPhilipp Lohmann <pl@openoffice.org>2002-09-17 12:17:03 +0000
commit68ce5d35834826453e89609cc07c91f453223b2a (patch)
tree657957cb42b042a13bc749f1716d2ac42ae87615
parent5ec3887adbd6ba0f1a2a43b80eac66554165c580 (diff)
#103088# use correct offsets for translating mapmodes
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx34
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx10
2 files changed, 24 insertions, 20 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 5831e41ef087..15fcc34138a7 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pdfwriter_impl.cxx,v $
*
- * $Revision: 1.25 $
+ * $Revision: 1.26 $
*
- * last change: $Author: sj $ $Date: 2002-09-17 12:11:00 $
+ * last change: $Author: pl $ $Date: 2002-09-17 13:16:28 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -2254,7 +2254,7 @@ void PDFWriterImpl::drawLayout( const SalLayout& rLayout, const String& rText )
int nMinCharPos = 0, nMaxCharPos = rText.Len()-1;
double fXScale = 1.0;
sal_Int32 nFontHeight = m_pReferenceDevice->mpFontEntry->maFontSelData.mnHeight;
- TextAlign eAlign = m_pReferenceDevice->GetTextAlign();
+ TextAlign eAlign = m_aCurrentPDFState.m_aFont.GetAlign();
// transform font height back to current units
nFontHeight = m_pReferenceDevice->ImplDevicePixelToLogicWidth( nFontHeight );
if( m_aCurrentPDFState.m_aFont.GetWidth() )
@@ -2276,10 +2276,22 @@ void PDFWriterImpl::drawLayout( const SalLayout& rLayout, const String& rText )
// back transformation to current coordinate system
aPos = m_pReferenceDevice->PixelToLogic( aPos );
+ double fAngle = (double)m_aCurrentPDFState.m_aFont.GetOrientation() * M_PI / 1800.0;
+ double fSin = sin( fAngle );
+ double fCos = cos( fAngle );
+
+ Point aDiff;
if ( eAlign == ALIGN_BOTTOM )
- aPos.Y() -= m_pReferenceDevice->GetFontMetric().GetDescent();
+ aDiff.Y() -= m_pReferenceDevice->GetFontMetric().GetDescent();
else if ( eAlign == ALIGN_TOP )
- aPos.Y() += m_pReferenceDevice->GetFontMetric().GetAscent();
+ aDiff.Y() += m_pReferenceDevice->GetFontMetric().GetAscent();
+
+ if( aDiff.X() || aDiff.Y() )
+ {
+ aDiff = Point( (int)(fXScale * fCos * (double)aDiff.X() + fSin * (double)aDiff.Y()),
+ -(int)(fXScale * fSin * (double)aDiff.X() - fCos * (double)aDiff.Y()) );
+ aPos += aDiff;
+ }
for( int i = 0; i < nGlyphs; i++ )
{
@@ -2296,10 +2308,6 @@ void PDFWriterImpl::drawLayout( const SalLayout& rLayout, const String& rText )
}
registerGlyphs( nGlyphs, pGlyphs, pUnicodes, pMappedGlyphs, pMappedFontObjects );
- double fAngle = (double)m_aCurrentPDFState.m_aFont.GetOrientation() * M_PI / 1800.0;
- double fSin = sin( fAngle );
- double fCos = cos( fAngle );
-
if( pAdvanceWidths )
{
// have to emit each glyph on its own
@@ -2314,7 +2322,7 @@ void PDFWriterImpl::drawLayout( const SalLayout& rLayout, const String& rText )
if( nGlyphFlags[n] & GF_ROTL )
{
fDeltaAngle = M_PI/2.0;
- aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetAscent() + m_pReferenceDevice->GetFontMetric().GetDescent();
+ aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetAscent();
aDeltaPos.Y() = m_pReferenceDevice->GetFontMetric().GetDescent();
fYScale = fXScale;
fTempXScale = 1.0;
@@ -2323,11 +2331,11 @@ void PDFWriterImpl::drawLayout( const SalLayout& rLayout, const String& rText )
{
fDeltaAngle = -M_PI/2.0;
aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetDescent();
- aDeltaPos.Y() = -(m_pReferenceDevice->GetFontMetric().GetAscent() + m_pReferenceDevice->GetFontMetric().GetDescent());
+ aDeltaPos.Y() = -m_pReferenceDevice->GetFontMetric().GetAscent();
fYScale = fXScale;
fTempXScale = 1.0;
}
- aDeltaPos += m_pReferenceDevice->PixelToLogic( Point( (int)((double)nXOffset/fXScale)/rLayout.GetUnitsPerPixel(), 0 ) );
+ aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( (int)((double)nXOffset/fXScale)/rLayout.GetUnitsPerPixel(), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) );
nXOffset += pAdvanceWidths[n];
@@ -2481,7 +2489,7 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const String& rOrigStr, US
Point aPos = rRect.TopLeft();
long nTextHeight = m_pReferenceDevice->GetTextHeight();
- TextAlign eAlign = m_pReferenceDevice->GetTextAlign();
+ TextAlign eAlign = m_aCurrentPDFState.m_aFont.GetAlign();
xub_StrLen nMnemonicPos = STRING_NOTFOUND;
String aStr = rOrigStr;
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 0592ae35fcd6..6eecb4a89bbb 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: pdfwriter_impl.hxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: pl $ $Date: 2002-09-17 11:15:44 $
+ * last change: $Author: pl $ $Date: 2002-09-17 13:17:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -312,7 +312,6 @@ private:
Region m_aClipRegion;
sal_Int32 m_nAntiAlias;
sal_Int32 m_nLayoutMode;
- TextAlign m_eTextAlign;
sal_Int32 m_nTransparentPercent;
GraphicsState() :
@@ -321,7 +320,6 @@ private:
m_aTextLineColor( COL_BLACK ),
m_nAntiAlias( 1 ),
m_nLayoutMode( 0 ),
- m_eTextAlign( ALIGN_BASELINE ),
m_nTransparentPercent( 0 ) {}
GraphicsState( const GraphicsState& rState ) :
m_aFont( rState.m_aFont ),
@@ -332,7 +330,6 @@ private:
m_aClipRegion( rState.m_aClipRegion ),
m_nAntiAlias( rState.m_nAntiAlias ),
m_nLayoutMode( rState.m_nLayoutMode ),
- m_eTextAlign( rState.m_eTextAlign ),
m_nTransparentPercent( rState.m_nTransparentPercent )
{
}
@@ -347,7 +344,6 @@ private:
m_aClipRegion = rState.m_aClipRegion;
m_nAntiAlias = rState.m_nAntiAlias;
m_nLayoutMode = rState.m_nLayoutMode;
- m_eTextAlign = rState.m_eTextAlign;
m_nTransparentPercent = rState.m_nTransparentPercent;
return *this;
}
@@ -514,7 +510,7 @@ public:
{ m_aGraphicsStack.front().m_nLayoutMode = nLayoutMode; }
void setTextAlign( TextAlign eAlign )
- { m_aGraphicsStack.front().m_eTextAlign = eAlign; }
+ { m_aGraphicsStack.front().m_aFont.SetAlign( eAlign ); }
void setAntiAlias( sal_Int32 nAntiAlias )
{ m_aGraphicsStack.front().m_nAntiAlias = nAntiAlias; }