Kaydet (Commit) a2741b57 authored tarafından Christian Lippka's avatar Christian Lippka

impress201: merge

...@@ -70,7 +70,7 @@ const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentCo ...@@ -70,7 +70,7 @@ const DeviceInfo& GraphicCollector::GetDeviceInfo( const Reference< XComponentCo
return aDeviceInfo; return aDeviceInfo;
} }
void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, Reference< XGraphic >& rxGraphic, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser ) void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntities, const GraphicSettings& rGraphicSettings, const GraphicCollector::GraphicUser& rUser )
{ {
const rtl::OUString aGraphicURL( rUser.maGraphicURL ); const rtl::OUString aGraphicURL( rUser.maGraphicURL );
const rtl::OUString sPackageURL( OUString::createFromAscii( "vnd.sun.star.GraphicObject:" ) ); const rtl::OUString sPackageURL( OUString::createFromAscii( "vnd.sun.star.GraphicObject:" ) );
...@@ -93,7 +93,7 @@ void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntit ...@@ -93,7 +93,7 @@ void ImpAddEntity( std::vector< GraphicCollector::GraphicEntity >& rGraphicEntit
} }
if ( aIter == rGraphicEntities.end() ) if ( aIter == rGraphicEntities.end() )
{ {
GraphicCollector::GraphicEntity aEntity( rxGraphic, rUser ); GraphicCollector::GraphicEntity aEntity( rUser );
rGraphicEntities.push_back( aEntity ); rGraphicEntities.push_back( aEntity );
} }
} }
...@@ -133,7 +133,7 @@ void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference ...@@ -133,7 +133,7 @@ void ImpAddGraphicEntity( const Reference< XComponentContext >& rxMSF, Reference
} }
aUser.maGraphicCropLogic = aGraphicCropLogic; aUser.maGraphicCropLogic = aGraphicCropLogic;
aUser.maLogicalSize = aLogicalSize; aUser.maLogicalSize = aLogicalSize;
ImpAddEntity( rGraphicEntities, xGraphic, rGraphicSettings, aUser ); ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
} }
} }
...@@ -198,7 +198,7 @@ void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const ...@@ -198,7 +198,7 @@ void ImpAddFillBitmapEntity( const Reference< XComponentContext >& rxMSF, const
aUser.mbFillBitmap = sal_True; aUser.mbFillBitmap = sal_True;
aUser.maLogicalSize = aLogicalSize; aUser.maLogicalSize = aLogicalSize;
aUser.mxPagePropertySet = rxPagePropertySet; aUser.mxPagePropertySet = rxPagePropertySet;
ImpAddEntity( rGraphicEntities, xGraphic, rGraphicSettings, aUser ); ImpAddEntity( rGraphicEntities, rGraphicSettings, aUser );
} }
} }
} }
......
...@@ -76,14 +76,13 @@ class GraphicCollector ...@@ -76,14 +76,13 @@ class GraphicCollector
struct GraphicEntity struct GraphicEntity
{ {
com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > mxGraphic; // the corresponding XGraphic of the Shape
com::sun::star::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed com::sun::star::awt::Size maLogicalSize; // the biggest logical size the graphic will be displayed
sal_Bool mbRemoveCropArea; // sal_Bool mbRemoveCropArea; //
com::sun::star::text::GraphicCrop maGraphicCropLogic; com::sun::star::text::GraphicCrop maGraphicCropLogic;
std::vector< GraphicUser > maUser; std::vector< GraphicUser > maUser;
GraphicEntity( const com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic >& xGraphic, const GraphicUser& rUser ) GraphicEntity( const GraphicUser& rUser )
: mxGraphic( xGraphic ), maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); }; : maLogicalSize( rUser.maLogicalSize ), mbRemoveCropArea( sal_False ), maGraphicCropLogic( 0, 0, 0, 0 ) { maUser.push_back( rUser ); };
}; };
static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact ); static const com::sun::star::awt::DeviceInfo& GetDeviceInfo( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxFact );
......
...@@ -409,66 +409,84 @@ void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XComponentCont ...@@ -409,66 +409,84 @@ void CompressGraphics( ImpOptimizer& rOptimizer, const Reference< XComponentCont
rOptimizer.SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( nProgress ) ) ); rOptimizer.SetStatusValue( TK_Progress, Any( static_cast< sal_Int32 >( nProgress ) ) );
rOptimizer.DispatchStatus(); rOptimizer.DispatchStatus();
GraphicSettings aGraphicSettings( rGraphicSettings ); if ( aGraphicIter->maUser.size() )
aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea;
Reference< XPropertySet > xNewGraphicPropertySet( aGraphicIter->mxGraphic, UNO_QUERY_THROW );
awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, aGraphicIter->mxGraphic ) );
Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxMSF, aGraphicIter->mxGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) );
if ( xNewGraphic.is() )
{ {
// applying graphic to each user GraphicSettings aGraphicSettings( rGraphicSettings );
std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() ); aGraphicSettings.mbRemoveCropArea = aGraphicIter->mbRemoveCropArea;
while( aGraphicUserIter != aGraphicIter->maUser.end() )
Reference< XGraphic > xGraphic;
if ( aGraphicIter->maUser[ 0 ].mbFillBitmap && aGraphicIter->maUser[ 0 ].mxPropertySet.is() )
{
Reference< XBitmap > xFillBitmap;
if ( aGraphicIter->maUser[ 0 ].mxPropertySet->getPropertyValue( TKGet( TK_FillBitmap ) ) >>= xFillBitmap )
xGraphic = Reference< XGraphic >( xFillBitmap, UNO_QUERY_THROW );
}
else if ( aGraphicIter->maUser[ 0 ].mxShape.is() )
{
Reference< XPropertySet > xShapePropertySet( aGraphicIter->maUser[ 0 ].mxShape, UNO_QUERY_THROW );
xShapePropertySet->getPropertyValue( TKGet( TK_Graphic ) ) >>= xGraphic;
}
if ( xGraphic.is() )
{ {
if ( aGraphicUserIter->mxShape.is() ) Reference< XPropertySet > xNewGraphicPropertySet( xGraphic, UNO_QUERY_THROW );
awt::Size aSize100thMM( GraphicCollector::GetOriginalSize( rxMSF, xGraphic ) );
Reference< XGraphic > xNewGraphic( ImpCompressGraphic( rxMSF, xGraphic, aGraphicIter->maLogicalSize, aGraphicIter->maGraphicCropLogic, aGraphicSettings ) );
if ( xNewGraphic.is() )
{ {
rtl::OUString sEmptyGraphicURL; // applying graphic to each user
Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW ); std::vector< GraphicCollector::GraphicUser >::iterator aGraphicUserIter( aGraphicIter->maUser.begin() );
xShapePropertySet->setPropertyValue( TKGet( TK_GraphicURL ), Any( sEmptyGraphicURL ) ); while( aGraphicUserIter != aGraphicIter->maUser.end() )
xShapePropertySet->setPropertyValue( TKGet( TK_Graphic ), Any( xNewGraphic ) ); {
if ( aGraphicUserIter->mxShape.is() )
if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top
|| aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom )
{ // removing crop area was not possible or should't been applied
text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
if ( !aGraphicSettings.mbRemoveCropArea )
{ {
awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxMSF, xNewGraphic ) ); rtl::OUString sEmptyGraphicURL;
aGraphicCropLogic.Left = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Left * ((double)aNewSize.Width / (double)aSize100thMM.Width)); Reference< XPropertySet > xShapePropertySet( aGraphicUserIter->mxShape, UNO_QUERY_THROW );
aGraphicCropLogic.Top = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Top * ((double)aNewSize.Height / (double)aSize100thMM.Height)); xShapePropertySet->setPropertyValue( TKGet( TK_GraphicURL ), Any( sEmptyGraphicURL ) );
aGraphicCropLogic.Right = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Right * ((double)aNewSize.Width / (double)aSize100thMM.Width)); xShapePropertySet->setPropertyValue( TKGet( TK_Graphic ), Any( xNewGraphic ) );
aGraphicCropLogic.Bottom = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Bottom * ((double)aNewSize.Height / (double)aSize100thMM.Height));
if ( aGraphicUserIter->maGraphicCropLogic.Left || aGraphicUserIter->maGraphicCropLogic.Top
|| aGraphicUserIter->maGraphicCropLogic.Right || aGraphicUserIter->maGraphicCropLogic.Bottom )
{ // removing crop area was not possible or should't been applied
text::GraphicCrop aGraphicCropLogic( 0, 0, 0, 0 );
if ( !aGraphicSettings.mbRemoveCropArea )
{
awt::Size aNewSize( GraphicCollector::GetOriginalSize( rxMSF, xNewGraphic ) );
aGraphicCropLogic.Left = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Left * ((double)aNewSize.Width / (double)aSize100thMM.Width));
aGraphicCropLogic.Top = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Top * ((double)aNewSize.Height / (double)aSize100thMM.Height));
aGraphicCropLogic.Right = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Right * ((double)aNewSize.Width / (double)aSize100thMM.Width));
aGraphicCropLogic.Bottom = (sal_Int32)((double)aGraphicUserIter->maGraphicCropLogic.Bottom * ((double)aNewSize.Height / (double)aSize100thMM.Height));
}
xShapePropertySet->setPropertyValue( TKGet( TK_GraphicCrop ), Any( aGraphicCropLogic ) );
}
} }
xShapePropertySet->setPropertyValue( TKGet( TK_GraphicCrop ), Any( aGraphicCropLogic ) ); else if ( aGraphicUserIter->mxPropertySet.is() )
}
}
else if ( aGraphicUserIter->mxPropertySet.is() )
{
Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY );
if ( xFillBitmap.is() )
{
awt::Size aSize;
sal_Bool bLogicalSize;
Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet );
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmap ), Any( xFillBitmap ) );
if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize )
&& ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width )
&& ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) )
{ {
if ( !aSize.Width || !aSize.Height ) Reference< XBitmap > xFillBitmap( xNewGraphic, UNO_QUERY );
if ( xFillBitmap.is() )
{ {
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapLogicalSize ), Any( sal_True ) ); awt::Size aSize;
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeX ), Any( aGraphicUserIter->maLogicalSize.Width ) ); sal_Bool bLogicalSize;
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeY ), Any( aGraphicUserIter->maLogicalSize.Height ) );
Reference< XPropertySet >& rxPropertySet( aGraphicUserIter->mxPropertySet );
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmap ), Any( xFillBitmap ) );
if ( ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapLogicalSize ) ) >>= bLogicalSize )
&& ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeX ) ) >>= aSize.Width )
&& ( rxPropertySet->getPropertyValue( TKGet( TK_FillBitmapSizeY ) ) >>= aSize.Height ) )
{
if ( !aSize.Width || !aSize.Height )
{
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapLogicalSize ), Any( sal_True ) );
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeX ), Any( aGraphicUserIter->maLogicalSize.Width ) );
rxPropertySet->setPropertyValue( TKGet( TK_FillBitmapSizeY ), Any( aGraphicUserIter->maLogicalSize.Height ) );
}
}
if ( aGraphicUserIter->mxPagePropertySet.is() )
aGraphicUserIter->mxPagePropertySet->setPropertyValue( TKGet( TK_Background ), Any( rxPropertySet ) );
} }
} }
if ( aGraphicUserIter->mxPagePropertySet.is() ) aGraphicUserIter++;
aGraphicUserIter->mxPagePropertySet->setPropertyValue( TKGet( TK_Background ), Any( rxPropertySet ) );
} }
} }
aGraphicUserIter++;
} }
} }
aGraphicIter++; aGraphicIter++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment