summaryrefslogtreecommitdiff
path: root/sd/source/filter/grf/sdgrffilter.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/filter/grf/sdgrffilter.cxx')
-rw-r--r--sd/source/filter/grf/sdgrffilter.cxx84
1 files changed, 44 insertions, 40 deletions
diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx
index 522f2bab8fc4..985d625b04d2 100644
--- a/sd/source/filter/grf/sdgrffilter.cxx
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -163,62 +163,66 @@ bool SdGRFFilter::Import()
const sal_uInt16 nFilter = rGraphicFilter.GetImportFormatNumberForTypeName( mrMedium.GetFilter()->GetTypeName() );
bool bRet = false;
- SvStream* pIStm = mrMedium.GetInStream();
- ErrCode nReturn = pIStm ? rGraphicFilter.ImportGraphic( aGraphic, aFileName, *pIStm, nFilter ) : ErrCode(1);
+ SvStream* pIStm = mrMedium.GetInStream();
+ ErrCode nReturn = pIStm ? rGraphicFilter.ImportGraphic( aGraphic, aFileName, *pIStm, nFilter ) : ErrCode(1);
- if( nReturn )
- HandleGraphicFilterError( nReturn, rGraphicFilter.GetLastError().nStreamError );
- else
- {
- if( mrDocument.GetPageCount() == 0 )
- mrDocument.CreateFirstPages();
+ if( nReturn )
+ HandleGraphicFilterError( nReturn, rGraphicFilter.GetLastError().nStreamError );
+ else
+ {
+ if( mrDocument.GetPageCount() == 0 )
+ mrDocument.CreateFirstPages();
- SdPage* pPage = mrDocument.GetSdPage( 0, PageKind::Standard );
- Point aPos;
- Size aPagSize( pPage->GetSize() );
- Size aGrfSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(),
- aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)));
+ SdPage* pPage = mrDocument.GetSdPage( 0, PageKind::Standard );
+ Point aPos;
+ Size aPagSize( pPage->GetSize() );
+ Size aGrfSize( OutputDevice::LogicToLogic( aGraphic.GetPrefSize(),
+ aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)));
- aPagSize.AdjustWidth( -(pPage->GetLeftBorder() + pPage->GetRightBorder()) );
- aPagSize.AdjustHeight( -(pPage->GetUpperBorder() + pPage->GetLowerBorder()) );
+ aPagSize.AdjustWidth( -(pPage->GetLeftBorder() + pPage->GetRightBorder()) );
+ aPagSize.AdjustHeight( -(pPage->GetUpperBorder() + pPage->GetLowerBorder()) );
- // scale to fit page
- if ( ( ( aGrfSize.Height() > aPagSize.Height() ) || ( aGrfSize.Width() > aPagSize.Width() ) ) &&
- aGrfSize.Height() && aPagSize.Height() )
- {
- double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
- double fWinWH = static_cast<double>(aPagSize.Width()) / aPagSize.Height();
+ // scale to fit page
+ if ( ( ( aGrfSize.Height() > aPagSize.Height() ) || ( aGrfSize.Width() > aPagSize.Width() ) ) &&
+ aGrfSize.Height() && aPagSize.Height() )
+ {
+ double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
+ double fWinWH = static_cast<double>(aPagSize.Width()) / aPagSize.Height();
- // adjust graphic to page size (scales)
- if( fGrfWH < fWinWH )
- {
- aGrfSize.setWidth( static_cast<long>( aPagSize.Height() * fGrfWH ) );
- aGrfSize.setHeight( aPagSize.Height() );
- }
- else if( fGrfWH > 0.F )
- {
- aGrfSize.setWidth( aPagSize.Width() );
- aGrfSize.setHeight( static_cast<long>( aPagSize.Width() / fGrfWH ) );
- }
+ // adjust graphic to page size (scales)
+ if( fGrfWH < fWinWH )
+ {
+ aGrfSize.setWidth( static_cast<long>( aPagSize.Height() * fGrfWH ) );
+ aGrfSize.setHeight( aPagSize.Height() );
}
+ else if( fGrfWH > 0.F )
+ {
+ aGrfSize.setWidth( aPagSize.Width() );
+ aGrfSize.setHeight( static_cast<long>( aPagSize.Width() / fGrfWH ) );
+ }
+ }
- // set output rectangle for graphic
- aPos.setX( ( ( aPagSize.Width() - aGrfSize.Width() ) >> 1 ) + pPage->GetLeftBorder() );
- aPos.setY( ( ( aPagSize.Height() - aGrfSize.Height() ) >> 1 ) + pPage->GetUpperBorder() );
+ // set output rectangle for graphic
+ aPos.setX( ( ( aPagSize.Width() - aGrfSize.Width() ) >> 1 ) + pPage->GetLeftBorder() );
+ aPos.setY( ( ( aPagSize.Height() - aGrfSize.Height() ) >> 1 ) + pPage->GetUpperBorder() );
+
+ pPage->InsertObject(
+ new SdrGrafObj(
+ pPage->getSdrModelFromSdrPage(),
+ aGraphic,
+ ::tools::Rectangle(aPos, aGrfSize)));
+ bRet = true;
+ }
- pPage->InsertObject( new SdrGrafObj( aGraphic, ::tools::Rectangle( aPos, aGrfSize ) ) );
- bRet = true;
- }
return bRet;
}
bool SdGRFFilter::Export()
{
// SJ: todo: error handling, the GraphicExportFilter does not support proper errorhandling
-
bool bRet = false;
- uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
uno::Reference< drawing::XGraphicExportFilter > xExporter = drawing::GraphicExportFilter::create( xContext );
SdPage* pPage = nullptr;