summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/source/filter/html/htmlgrin.cxx70
1 files changed, 42 insertions, 28 deletions
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index 9e95fa8678cf..8cc516f72c53 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -312,6 +312,7 @@ void SwHTMLParser::InsertImage()
OUString sGrfNm;
sal_Int16 eVertOri = text::VertOrientation::TOP;
sal_Int16 eHoriOri = text::HoriOrientation::NONE;
+ bool bWidthProvided=false, bHeightProvided=false;
long nWidth=0, nHeight=0;
long nVSpace=0, nHSpace=0;
@@ -361,6 +362,7 @@ void SwHTMLParser::InsertImage()
bPrcWidth = (rOption.GetString().indexOf('%') != -1);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
+ bWidthProvided = true;
break;
case HTML_O_HEIGHT:
// erstmal nur als Pixelwerte merken!
@@ -368,6 +370,7 @@ void SwHTMLParser::InsertImage()
bPrcHeight = (rOption.GetString().indexOf('%') != -1);
if( bPrcHeight && nHeight>100 )
nHeight = 100;
+ bHeightProvided = true;
break;
case HTML_O_VSPACE:
nVSpace = rOption.GetNumber();
@@ -461,6 +464,42 @@ IMAGE_SETEVENT:
}
}
+ Graphic aGraphic;
+ INetURLObject aGraphicURL( sGrfNm );
+ if( aGraphicURL.GetProtocol() == INET_PROT_DATA )
+ {
+ // use embedded base64 encoded data
+ ::com::sun::star::uno::Sequence< sal_Int8 > aPass;
+ OUString sBase64Data = sGrfNm.replaceAt(0,22,"");
+ ::sax::Converter::decodeBase64(aPass, sBase64Data);
+ if( aPass.hasElements() )
+ {
+ SvMemoryStream aStream(aPass.getArray(), aPass.getLength(), STREAM_READ);
+ if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, "", aStream))
+ sGrfNm = "";
+ }
+ }
+ // sBaseURL is empty if the source is clipboard
+ else if (sBaseURL.isEmpty())
+ {
+ if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aGraphicURL))
+ sGrfNm = "";
+ }
+
+ if (!sGrfNm.isEmpty())
+ {
+ aGraphic.SetDefaultType();
+ }
+
+ if (!bHeightProvided || !bWidthProvided)
+ {
+ Size aPixelSize = aGraphic.GetSizePixel(Application::GetDefaultDevice());
+ if (!bWidthProvided)
+ nWidth = aPixelSize.Width();
+ if (!bHeightProvided)
+ nHeight = aPixelSize.Height();
+ }
+
SfxItemSet aItemSet( pDoc->GetAttrPool(), pCSS1Parser->GetWhichMap() );
SvxCSS1PropertyInfo aPropInfo;
if( HasStyleOptions( aStyle, aId, aClass ) )
@@ -694,31 +733,6 @@ IMAGE_SETEVENT:
aFrmSize.SetHeightPercent( nPrcHeight );
aFrmSet.Put( aFrmSize );
- Graphic aGraphic;
- INetURLObject aGraphicURL( sGrfNm );
- if( aGraphicURL.GetProtocol() == INET_PROT_DATA )
- {
- // use embedded base64 encoded data
- ::com::sun::star::uno::Sequence< sal_Int8 > aPass;
- OUString sBase64Data = sGrfNm.replaceAt(0,22,"");
- ::sax::Converter::decodeBase64(aPass, sBase64Data);
- if( aPass.hasElements() )
- {
- SvMemoryStream aStream(aPass.getArray(), aPass.getLength(), STREAM_READ);
- if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, "", aStream))
- sGrfNm = "";
- }
- }
- // sBaseURL is empty if the source is clipboard
- else if (sBaseURL.isEmpty())
- {
- if (GRFILTER_OK == GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aGraphicURL))
- sGrfNm = "";
- }
- if (!sGrfNm.isEmpty())
- {
- aGraphic.SetDefaultType();
- }
// passing empty sGrfNm here, means we don't want the graphic to be linked
SwFrmFmt *pFlyFmt = pDoc->Insert( *pPam, sGrfNm, aEmptyOUStr, &aGraphic,
&aFrmSet, NULL, NULL );
@@ -742,10 +756,10 @@ IMAGE_SETEVENT:
if( !sAltNm.isEmpty() )
pGrfNd->SetTitle( sAltNm );
- if( bSetTwipSize )
- pGrfNd->SetTwipSize( aGrfSz );
+ if( bSetTwipSize )
+ pGrfNd->SetTwipSize( aGrfSz );
- pGrfNd->SetChgTwipSize( bChangeFrmSize, bChangeFrmSize );
+ pGrfNd->SetChgTwipSize( bChangeFrmSize, bChangeFrmSize );
if( bSetScaleImageMap )
pGrfNd->SetScaleImageMap( true );