summaryrefslogtreecommitdiff
path: root/sw/source/filter/html/htmlgrin.cxx
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2018-04-06 17:19:02 +0200
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-04-06 17:19:02 +0200
commitdfdc78dd2ca39bfa738ba9b4f9ee50682b1b379d (patch)
tree810469b35cc51ce27d7a41d6f310f42b59d01900 /sw/source/filter/html/htmlgrin.cxx
parent25c32884dfc537e328375aaad6261b72890ee778 (diff)
Html import: use loaded image width/height if width|height ="auto"
"auto" means viewing application decides what the size/dimension is going to be i.e. act as if no particular size was provided Change-Id: I4d9ef622d8252e049912850133295b3676a5f026
Diffstat (limited to 'sw/source/filter/html/htmlgrin.cxx')
-rw-r--r--sw/source/filter/html/htmlgrin.cxx28
1 files changed, 22 insertions, 6 deletions
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index ab51592c16d7..6ff807a9dc2f 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -320,6 +320,7 @@ void SwHTMLParser::InsertImage()
bool bIsMap = false;
bool bPrcWidth = false;
bool bPrcHeight = false;
+ OUString sWidthAsString, sHeightAsString;
SvxMacroItem aMacroItem(RES_FRMMACRO);
ScriptType eDfltScriptType;
@@ -359,18 +360,23 @@ void SwHTMLParser::InsertImage()
case HTML_O_WIDTH:
// erstmal nur als Pixelwerte merken!
nWidth = rOption.GetNumber();
- bPrcWidth = (rOption.GetString().indexOf('%') != -1);
+ sWidthAsString = rOption.GetString();
+ bPrcWidth = (sWidthAsString.indexOf('%') != -1);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
- bWidthProvided = true;
+ // width|height = "auto" means viewing app decides the size
+ // i.e. proceed as if no particular size was provided
+ bWidthProvided = (sWidthAsString != "auto");
break;
case HTML_O_HEIGHT:
// erstmal nur als Pixelwerte merken!
nHeight = rOption.GetNumber();
- bPrcHeight = (rOption.GetString().indexOf('%') != -1);
+ sHeightAsString = rOption.GetString();
+ bPrcHeight = (sHeightAsString.indexOf('%') != -1);
if( bPrcHeight && nHeight>100 )
nHeight = 100;
- bHeightProvided = true;
+ // the same as above w/ HtmlOptionId::WIDTH
+ bHeightProvided = (sHeightAsString != "auto");
break;
case HTML_O_VSPACE:
nVSpace = rOption.GetNumber();
@@ -558,8 +564,18 @@ IMAGE_SETEVENT:
Size aTwipSz( bPrcWidth ? 0 : nWidth, bPrcHeight ? 0 : nHeight );
if( (aTwipSz.Width() || aTwipSz.Height()) && Application::GetDefaultDevice() )
{
- aTwipSz = Application::GetDefaultDevice()
- ->PixelToLogic( aTwipSz, MapMode( MAP_TWIP ) );
+ if (bWidthProvided || bHeightProvided || // attributes imply pixel!
+ aGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL)
+ {
+ aTwipSz = Application::GetDefaultDevice()
+ ->PixelToLogic( aTwipSz, MapMode(MAP_TWIP) );
+ }
+ else
+ { // some bitmaps may have a size in metric units (e.g. PNG); use that
+ assert(aGraphic.GetPrefMapMode().GetMapUnit() < MAP_PIXEL);
+ aTwipSz = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
+ aGraphic.GetPrefMapMode(), MapMode(MAP_TWIP));
+ }
}
// CSS1-Groesse auf "normale" Groesse umrechnen