diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2009-06-15 08:47:44 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2009-06-15 08:47:44 +0000 |
commit | 0ca8e0ea2db280fc7ce464611079b513a020199f (patch) | |
tree | 6542e82f1a655bf2419a256138dacbb7ecef3d83 /sdext/source/pdfimport/tree | |
parent | 19ed9c3a16889a49f6d6b222de40f7b377ff3e83 (diff) |
CWS-TOOLING: integrate CWS pdfextfix02_DEV300
2009-05-10 11:23:59 +0200 pl r271736 : #i94755# adjust extension version, add extension icon
2009-05-08 17:06:50 +0200 pl r271726 : #i92909# handle some cases of mirroring
2009-05-08 14:51:37 +0200 pl r271720 : #i95270# cope with some rotated images
2009-05-08 11:37:46 +0200 pl r271709 : #i101327# recognize non breaking space also (thanks ayaniger)
2009-05-07 13:39:06 +0200 pl r271658 : #i92598# still more masked bitmap support
2009-05-07 10:44:41 +0200 pl r271638 : remove some compiler warnings
2009-05-07 09:59:56 +0200 pl r271633 : make test compile again
2009-05-06 21:12:55 +0200 pl r271612 : #i92903# handle two color images
2009-05-06 19:48:19 +0200 pl r271610 : soft masked images
2009-05-06 16:30:36 +0200 pl r271600 : #i92598# use masked PNG images for drawMask
2009-05-05 18:40:06 +0200 pl r271550 : #i90617# #i92598# some workarounds for mask bitmaps
2009-05-04 18:53:09 +0200 pl r271479 : #i94755# add supported for encrypted PDF files
Diffstat (limited to 'sdext/source/pdfimport/tree')
-rw-r--r-- | sdext/source/pdfimport/tree/drawtreevisiting.cxx | 12 | ||||
-rw-r--r-- | sdext/source/pdfimport/tree/genericelements.hxx | 3 | ||||
-rw-r--r-- | sdext/source/pdfimport/tree/pdfiprocessor.cxx | 106 |
3 files changed, 105 insertions, 16 deletions
diff --git a/sdext/source/pdfimport/tree/drawtreevisiting.cxx b/sdext/source/pdfimport/tree/drawtreevisiting.cxx index 151cff129c91..71928fd98fcf 100644 --- a/sdext/source/pdfimport/tree/drawtreevisiting.cxx +++ b/sdext/source/pdfimport/tree/drawtreevisiting.cxx @@ -175,6 +175,11 @@ void DrawXmlEmitter::fillFrameProps( DrawElement& rElem, // TODO(F2): general transformation case missing; if implemented, note // that ODF rotation is oriented the other way + // vertical mirroring is done by horizontally mirroring and rotaing 180 degree + // quaint ! + if( rElem.MirrorVertical ) + fRotate += M_PI; + // build transformation string if( fShearX != 0.0 ) { @@ -854,6 +859,13 @@ void DrawXmlFinalizer::visit( FrameElement& elem, const std::list< Element* >::c aGCProps[ USTR("fo:padding-right") ] = USTR("0cm"); aGCProps[ USTR("fo:padding-bottom") ] = USTR("0cm"); + // remark: vertical mirroring is done in current OOO by + // mirroring horzontally and rotating 180 degrees + // this is quaint, but unfortunately it seems + // mirror=vertical is defined but not implemented in current code + if( elem.MirrorVertical ) + aGCProps[ USTR("style:mirror") ] = USTR("horizontal"); + StyleContainer::Style aStyle( "style:style", aProps ); StyleContainer::Style aSubStyle( "style:graphic-properties", aGCProps ); aStyle.SubStyles.push_back( &aSubStyle ); diff --git a/sdext/source/pdfimport/tree/genericelements.hxx b/sdext/source/pdfimport/tree/genericelements.hxx index 34fbdf6391de..029032579d57 100644 --- a/sdext/source/pdfimport/tree/genericelements.hxx +++ b/sdext/source/pdfimport/tree/genericelements.hxx @@ -133,10 +133,11 @@ namespace pdfi { protected: GraphicalElement( Element* pParent, sal_Int32 nGCId ) - : Element( pParent ), GCId(nGCId ) {} + : Element( pParent ), GCId( nGCId ), MirrorVertical( false ) {} public: sal_Int32 GCId; + bool MirrorVertical; }; struct DrawElement : public GraphicalElement diff --git a/sdext/source/pdfimport/tree/pdfiprocessor.cxx b/sdext/source/pdfimport/tree/pdfiprocessor.cxx index a478bef72d2d..ccfc273124e1 100644 --- a/sdext/source/pdfimport/tree/pdfiprocessor.cxx +++ b/sdext/source/pdfimport/tree/pdfiprocessor.cxx @@ -369,9 +369,10 @@ void PDFIProcessor::processGlyphLine() else { if ( - ( m_GlyphsList[i].getPrevGlyphsSpace()<= fPreAvarageSpaceValue )&& - ( fPrevDiffCharSpace<=fAvarageDiffCharSpaceValue )&& - ( fPostDiffCharSpace<=fAvarageDiffCharSpaceValue ) || + ( ( m_GlyphsList[i].getPrevGlyphsSpace()<= fPreAvarageSpaceValue )&& + ( fPrevDiffCharSpace<=fAvarageDiffCharSpaceValue )&& + ( fPostDiffCharSpace<=fAvarageDiffCharSpaceValue ) + ) || ( m_GlyphsList[i].getPrevGlyphsSpace() == 0.0 ) ) { @@ -446,7 +447,6 @@ void PDFIProcessor::drawGlyphLine( const rtl::OUString& rGlyphs, const geometry::Matrix2D& rFontMatrix ) { double isFirstLine= fYPrevTextPosition+ fXPrevTextPosition+ fPrevTextHeight+ fPrevTextWidth ; - if( ( ( ( fYPrevTextPosition!= rRect.Y1 ) ) || ( ( fXPrevTextPosition > rRect.X2 ) ) || @@ -456,8 +456,6 @@ void PDFIProcessor::drawGlyphLine( const rtl::OUString& rGlyphs, { processGlyphLine(); - } - CharGlyph aGlyph; aGlyph.setGlyph ( rGlyphs ); @@ -485,6 +483,36 @@ void PDFIProcessor::drawGlyphLine( const rtl::OUString& rGlyphs, m_bIsWhiteSpaceInLine=rGlyphs.equals( tempWhiteSpaceStr ); } +======= + + CharGlyph aGlyph; + + aGlyph.setGlyph ( rGlyphs ); + aGlyph.setRect ( rRect ); + aGlyph.setFontMatrix ( rFontMatrix ); + aGlyph.setGraphicsContext ( getCurrentContext() ); + getGCId(getCurrentContext()); + aGlyph.setCurElement( m_pCurElement ); + + aGlyph.setYPrevGlyphPosition( fYPrevTextPosition ); + aGlyph.setXPrevGlyphPosition( fXPrevTextPosition ); + aGlyph.setPrevGlyphHeight ( fPrevTextHeight ); + aGlyph.setPrevGlyphWidth ( fPrevTextWidth ); + + m_GlyphsList.push_back( aGlyph ); + + fYPrevTextPosition = rRect.Y1; + fXPrevTextPosition = rRect.X2; + fPrevTextHeight = rRect.Y2-rRect.Y1; + fPrevTextWidth = rRect.X2-rRect.X1; + + if( !m_bIsWhiteSpaceInLine ) + { + static rtl::OUString tempWhiteSpaceStr( 0x20 ); + static rtl::OUString tempWhiteSpaceNonBreakingStr( 0xa0 ); + m_bIsWhiteSpaceInLine=(rGlyphs.equals( tempWhiteSpaceStr ) || rGlyphs.equals( tempWhiteSpaceNonBreakingStr )); + } +>>>>>>> .merge-right.r272944 } GraphicsContext& PDFIProcessor::getTransformGlyphContext( CharGlyph& rGlyph ) @@ -571,22 +599,70 @@ void PDFIProcessor::setupImage(ImageId nImage) { const GraphicsContext& rGC( getCurrentContext() ); - // transform unit rect, to determine view box - basegfx::B2DPoint aOrigin(0,0); - aOrigin *= rGC.Transformation; + basegfx::B2DHomMatrix aTrans( rGC.Transformation ); - basegfx::B2DVector aSize(1,1); - aSize *= rGC.Transformation; + // check for rotation, which is the other way around in ODF + basegfx::B2DTuple aScale, aTranslation; + double fRotate, fShearX; + rGC.Transformation.decompose( aScale, aTranslation, fRotate, fShearX ); + // TODDO(F4): correcting rotation when fShearX != 0 ? + if( fRotate != 0.0 ) + { + + // try to create a Transformation that corrects for the wrong rotation + aTrans.identity(); + aTrans.scale( aScale.getX(), aScale.getY() ); + aTrans.rotate( -fRotate ); + + basegfx::B2DRange aRect( 0, 0, 1, 1 ); + aRect.transform( aTrans ); + + // TODO(F3) treat translation correctly + // the corrections below work for multiples of 90 degree + // which is a common case (landscape/portrait/seascape) + // we need a general solution here; however this needs to + // work in sync with DrawXmlEmitter::fillFrameProps and WriterXmlEmitter::fillFrameProps + // admittedly this is a lame workaround and fails for arbitrary rotation + double fQuadrant = fmod( fRotate, 2.0*M_PI ) / M_PI_2; + int nQuadrant = (int)fQuadrant; + if( nQuadrant < 0 ) + nQuadrant += 4; + if( nQuadrant == 1 ) + { + aTranslation.setX( aTranslation.getX() + aRect.getHeight() + aRect.getWidth()); + aTranslation.setY( aTranslation.getY() + aRect.getHeight() ); + } + if( nQuadrant == 3 ) + aTranslation.setX( aTranslation.getX() - aRect.getHeight() ); + + aTrans.translate( aTranslation.getX(), + aTranslation.getY() ); + } + + bool bMirrorVertical = aScale.getY() > 0; + + // transform unit rect to determine view box + basegfx::B2DRange aRect( 0, 0, 1, 1 ); + aRect.transform( aTrans ); // TODO(F3): Handle clip const sal_Int32 nGCId = getGCId(rGC); FrameElement* pFrame = m_pElFactory->createFrameElement( m_pCurElement, nGCId ); ImageElement* pImageElement = m_pElFactory->createImageElement( pFrame, nGCId, nImage ); - pFrame->x = pImageElement->x = aOrigin.getX(); - pFrame->y = pImageElement->y = aOrigin.getY(); - pFrame->w = pImageElement->w = aSize.getX(); - pFrame->h = pImageElement->h = aSize.getY(); + pFrame->x = pImageElement->x = aRect.getMinX(); + pFrame->y = pImageElement->y = aRect.getMinY(); + pFrame->w = pImageElement->w = aRect.getWidth(); + pFrame->h = pImageElement->h = aRect.getHeight(); pFrame->ZOrder = m_nNextZOrder++; + + if( bMirrorVertical ) + { + pFrame->MirrorVertical = pImageElement->MirrorVertical = true; + pFrame->x += aRect.getWidth(); + pImageElement->x += aRect.getWidth(); + pFrame->y += aRect.getHeight(); + pImageElement->y += aRect.getHeight(); + } } void PDFIProcessor::drawMask(const uno::Sequence<beans::PropertyValue>& xBitmap, |