summaryrefslogtreecommitdiff
path: root/oox/source
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source')
-rw-r--r--oox/source/drawingml/fillproperties.cxx21
-rw-r--r--oox/source/drawingml/fillpropertiesgroupcontext.cxx10
-rw-r--r--oox/source/helper/graphichelper.cxx25
-rw-r--r--oox/source/ppt/slidefragmenthandler.cxx7
-rw-r--r--oox/source/ppt/slidepersist.cxx7
-rw-r--r--oox/source/token/properties.txt1
6 files changed, 69 insertions, 2 deletions
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