diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2010-10-14 14:49:30 +0200 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2010-10-14 14:49:30 +0200 |
commit | 7e56aed62ec2230680d6f4a69ae3462974daa458 (patch) | |
tree | fec79e4a19093e105f4a3119efebc55ee95cc2e2 | |
parent | 01e86a21f5970475f94626c7bc4805cb4b3687f6 (diff) | |
parent | 9fcf7378bb3417a764db72f43057a40044023fb3 (diff) |
CWS-TOOLING: integrate CWS impress201
Notes
split repo tag: filters_ooo/DEV300_m90
-rw-r--r-- | oox/inc/oox/drawingml/fillproperties.hxx | 2 | ||||
-rw-r--r-- | oox/inc/oox/helper/graphichelper.hxx | 4 | ||||
-rw-r--r-- | oox/inc/oox/ppt/slidepersist.hxx | 2 | ||||
-rw-r--r-- | oox/source/drawingml/fillproperties.cxx | 21 | ||||
-rw-r--r-- | oox/source/drawingml/fillpropertiesgroupcontext.cxx | 10 | ||||
-rw-r--r-- | oox/source/helper/graphichelper.cxx | 25 | ||||
-rw-r--r-- | oox/source/ppt/slidefragmenthandler.cxx | 7 | ||||
-rw-r--r-- | oox/source/ppt/slidepersist.cxx | 7 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 |
9 files changed, 77 insertions, 2 deletions
diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index 42457e6f4dde..d62651ebdc20 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -117,6 +117,8 @@ struct BlipFillProperties OptValue< sal_Int32 > moBitmapMode; /// Bitmap tile or stretch. OptValue< ::com::sun::star::geometry::IntegerRectangle2D > moFillRect; /// Stretch fill offsets. + OptValue< ::com::sun::star::geometry::IntegerRectangle2D > + moClipRect; OptValue< sal_Int32 > moTileOffsetX; /// Width of bitmap tiles (EMUs). OptValue< sal_Int32 > moTileOffsetY; /// Height of bitmap tiles (EMUs). OptValue< sal_Int32 > moTileScaleX; /// Horizontal scaling of bitmap tiles (1/1000 percent). diff --git a/oox/inc/oox/helper/graphichelper.hxx b/oox/inc/oox/helper/graphichelper.hxx index 37002940cb17..1c112efcf923 100644 --- a/oox/inc/oox/helper/graphichelper.hxx +++ b/oox/inc/oox/helper/graphichelper.hxx @@ -148,6 +148,10 @@ public: @return The URL of the created and internally cached graphic object. */ ::rtl::OUString importEmbeddedGraphicObject( const ::rtl::OUString& rStreamName ) const; + /** calculates the orignal size of a graphic which is necessary to be able to calculate cropping values + @return The original Graphic size in 100thmm */ + ::com::sun::star::awt::Size getOriginalSize( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic ) const; + // ------------------------------------------------------------------------ private: typedef ::std::map< sal_Int32, sal_Int32 > SystemPalette; diff --git a/oox/inc/oox/ppt/slidepersist.hxx b/oox/inc/oox/ppt/slidepersist.hxx index 31156a56ee84..bcb0c5803d61 100644 --- a/oox/inc/oox/ppt/slidepersist.hxx +++ b/oox/inc/oox/ppt/slidepersist.hxx @@ -91,6 +91,7 @@ public: void setBackgroundProperties( const oox::drawingml::FillPropertiesPtr pFillPropertiesPtr ){ mpBackgroundPropertiesPtr = pFillPropertiesPtr; } oox::drawingml::FillPropertiesPtr getBackgroundProperties() const { return mpBackgroundPropertiesPtr; } + oox::drawingml::Color& getBackgroundColorRef() { return maBackgroundColorRef; } sal_Bool isMasterPage() const { return mbMaster; } sal_Bool isNotesPage() const { return mbNotes; } @@ -130,6 +131,7 @@ private: SlidePersistPtr mpMasterPagePtr; oox::drawingml::ShapePtr maShapesPtr; + oox::drawingml::Color maBackgroundColorRef; oox::drawingml::FillPropertiesPtr mpBackgroundPropertiesPtr; ::std::list< boost::shared_ptr< TimeNode > > maTimeNodeList; diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 168055935104..08d001f09a62 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -29,6 +29,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/drawing/ColorMode.hpp> @@ -435,6 +436,26 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic ); if( aGraphicUrl.getLength() > 0 ) rPropMap[ PROP_GraphicURL ] <<= aGraphicUrl; + + // cropping + if ( maBlipProps.moClipRect.has() ) + { + geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() ); + awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) ); + if ( aOriginalSize.Width && aOriginalSize.Height ) + { + text::GraphicCrop aGraphCrop( 0, 0, 0, 0 ); + if ( oClipRect.X1 ) + aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 ); + if ( oClipRect.Y1 ) + aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 ); + if ( oClipRect.X2 ) + aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 ); + if ( oClipRect.Y2 ) + aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 ); + rPropMap[ PROP_GraphicCrop ] <<= aGraphCrop; + } + } } // color effect diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index b9d7fa7e1142..cb2037294786 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -225,7 +225,15 @@ Reference< XFastContextHandler > BlipFillContext::createFastChildContext( return new BlipContext( *this, rxAttribs, mrBlipProps ); case A_TOKEN( srcRect ): - // TODO + { + rtl::OUString aDefault( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "0" ) ) ); + ::com::sun::star::geometry::IntegerRectangle2D aClipRect; + aClipRect.X1 = GetPercent( aAttribs.getString( XML_l, aDefault ) ); + aClipRect.Y1 = GetPercent( aAttribs.getString( XML_t, aDefault ) ); + aClipRect.X2 = GetPercent( aAttribs.getString( XML_r, aDefault ) ); + aClipRect.Y2 = GetPercent( aAttribs.getString( XML_b, aDefault ) ); + mrBlipProps.moClipRect = aClipRect; + } break; case A_TOKEN( tile ): diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index 455778f939f7..ae664cf86668 100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -38,6 +38,7 @@ #include <comphelper/seqstream.hxx> #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> using ::rtl::OUString; using ::com::sun::star::awt::DeviceInfo; @@ -52,6 +53,7 @@ using ::com::sun::star::graphic::GraphicObject; using ::com::sun::star::graphic::XGraphic; using ::com::sun::star::graphic::XGraphicObject; using ::com::sun::star::graphic::XGraphicProvider; +using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::io::XInputStream; using ::com::sun::star::lang::XMultiServiceFactory; using ::com::sun::star::uno::Exception; @@ -352,6 +354,29 @@ OUString GraphicHelper::importEmbeddedGraphicObject( const OUString& rStreamName return xGraphic.is() ? createGraphicObject( xGraphic ) : OUString(); } +Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) const +{ + Size aSize100thMM( 0, 0 ); + Reference< XPropertySet > xGraphicPropertySet( xGraphic, UNO_QUERY_THROW ); + if ( xGraphicPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Size100thMM" ) ) ) >>= aSize100thMM ) + { + if ( !aSize100thMM.Width && !aSize100thMM.Height ) + { // MAPMODE_PIXEL USED :-( + Size aSourceSizePixel( 0, 0 ); + if ( xGraphicPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SizePixel" ) ) ) >>= aSourceSizePixel ) + { + const DeviceInfo& rDeviceInfo = getDeviceInfo(); + if ( rDeviceInfo.PixelPerMeterX && rDeviceInfo.PixelPerMeterY ) + { + aSize100thMM.Width = static_cast< sal_Int32 >( ( aSourceSizePixel.Width * 100000.0 ) / rDeviceInfo.PixelPerMeterX ); + aSize100thMM.Height = static_cast< sal_Int32 >( ( aSourceSizePixel.Height * 100000.0 ) / rDeviceInfo.PixelPerMeterY ); + } + } + } + } + return aSize100thMM; +} + // ============================================================================ } // namespace oox diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 69f32e01e7eb..7e77f5a54938 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -145,7 +145,14 @@ Reference< XFastContextHandler > SlideFragmentHandler::createFastChildContext( s mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); } break; + case NMSP_PPT|XML_bgRef: // a:CT_StyleMatrixReference + { + FillPropertiesPtr pFillPropertiesPtr( new FillProperties( + *mpSlidePersistPtr->getTheme()->getFillStyle( xAttribs->getOptionalValue( XML_idx ).toInt32() ) ) ); + xRet.set( new ColorContext( *this, mpSlidePersistPtr->getBackgroundColorRef() ) ); + mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); + } break; case NMSP_PPT|XML_clrMap: // CT_ColorMapping diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index ce99ffc49f19..8555ba371b77 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -173,12 +173,17 @@ void SlidePersist::createBackground( const XmlFilterBase& rFilterBase ) { try { + sal_Int32 nPhClr = API_RGB_TRANSPARENT; + if ( maBackgroundColorRef.isUsed() ) + nPhClr = maBackgroundColorRef.getColor( rFilterBase.getGraphicHelper() ); + PropertyMap aPropMap; static const rtl::OUString sBackground( RTL_CONSTASCII_USTRINGPARAM( "Background" ) ); uno::Reference< beans::XPropertySet > xPagePropSet( mxPage, uno::UNO_QUERY_THROW ); uno::Reference< beans::XPropertySet > xPropertySet( aPropMap.makePropertySet() ); PropertySet aPropSet( xPropertySet ); - mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), rFilterBase.getGraphicHelper() ); + mpBackgroundPropertiesPtr->pushToPropSet( aPropSet, rFilterBase.getModelObjectHelper(), + rFilterBase.getGraphicHelper(), oox::drawingml::FillProperties::DEFAULT_IDS, 0, nPhClr ); xPagePropSet->setPropertyValue( sBackground, Any( xPropertySet ) ); } catch( Exception ) diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index da1aeb2ed265..ba51c3577a8e 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -166,6 +166,7 @@ Geometry3D GradientName Graphic GraphicColorMode +GraphicCrop GraphicSize GraphicURL GridColor |