Kaydet (Commit) 51cfbf0c authored tarafından Miklos Vajna's avatar Miklos Vajna

n#751054 fix VML import of absolutely positioned pictures

There were multiple issues here:

- convertEmuToHmm() not handling negative values
- position:absolute style property being ignored
- mso-position-vertical-relative is not converted to
  text::RelOrientation
- SwAnchoredDrawObject::_SetPositioningAttr() re-positioning already
  positioned objects
- DomainMapper_Impl::PushShapeContext() inserting positioned objects as
  character
üst a75fd2d5
...@@ -156,7 +156,7 @@ inline sal_Int64 convertHmmToEmu( sal_Int32 nValue ) ...@@ -156,7 +156,7 @@ inline sal_Int64 convertHmmToEmu( sal_Int32 nValue )
/** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */ /** Converts the passed 64-bit integer value from EMUs to 1/100 mm. */
inline sal_Int32 convertEmuToHmm( sal_Int64 nValue ) inline sal_Int32 convertEmuToHmm( sal_Int64 nValue )
{ {
return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + EMU_PER_HMM / 2) / EMU_PER_HMM, 0, SAL_MAX_INT32 ); return getLimitedValue< sal_Int32, sal_Int64 >( (nValue + EMU_PER_HMM / 2) / EMU_PER_HMM, SAL_MIN_INT32, SAL_MAX_INT32 );
} }
// ============================================================================ // ============================================================================
......
...@@ -79,6 +79,7 @@ struct ShapeTypeModel ...@@ -79,6 +79,7 @@ struct ShapeTypeModel
::rtl::OUString maHeight; /// Height of the shape bounding box (number with unit). ::rtl::OUString maHeight; /// Height of the shape bounding box (number with unit).
::rtl::OUString maMarginLeft; /// X position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maMarginLeft; /// X position of the shape bounding box to shape anchor (number with unit).
::rtl::OUString maMarginTop; /// Y position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maMarginTop; /// Y position of the shape bounding box to shape anchor (number with unit).
::rtl::OUString maPositionVerticalRelative; /// The Y position is relative to this.
StrokeModel maStrokeModel; /// Border line formatting. StrokeModel maStrokeModel; /// Border line formatting.
FillModel maFillModel; /// Shape fill formatting. FillModel maFillModel; /// Shape fill formatting.
......
...@@ -498,6 +498,7 @@ VerticalAlign ...@@ -498,6 +498,7 @@ VerticalAlign
VerticalSplitMode VerticalSplitMode
VerticalSplitPositionTwips VerticalSplitPositionTwips
VertOrientPosition VertOrientPosition
VertOrientRelation
ViewBox ViewBox
Visible Visible
VisibleFlag VisibleFlag
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextContent.hpp>
#include <com/sun/star/text/XTextDocument.hpp> #include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextFrame.hpp> #include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/TextContentAnchorType.hpp>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include "oox/drawingml/shapepropertymap.hxx" #include "oox/drawingml/shapepropertymap.hxx"
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Any;
using namespace ::com::sun::star;
using namespace ::com::sun::star::text; using namespace ::com::sun::star::text;
namespace oox { namespace oox {
...@@ -524,11 +526,21 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes ...@@ -524,11 +526,21 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
if( xShape.is() ) if( xShape.is() )
{ {
OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( aGraphicPath ); OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( aGraphicPath );
PropertySet aPropSet( xShape );
if( !aGraphicUrl.isEmpty() ) if( !aGraphicUrl.isEmpty() )
{ {
PropertySet aPropSet( xShape );
aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl ); aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl );
} }
// If the shape has an absolute position, set the properties accordingly.
if (maTypeModel.maPosition.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("absolute")))
{
aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X);
aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
}
if (maTypeModel.maPositionVerticalRelative.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("page")))
{
aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
}
} }
return xShape; return xShape;
} }
......
...@@ -346,6 +346,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) ...@@ -346,6 +346,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle )
else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "height" ) ) ) mrTypeModel.maHeight = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "height" ) ) ) mrTypeModel.maHeight = aValue;
else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-left" ) ) ) mrTypeModel.maMarginLeft = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-left" ) ) ) mrTypeModel.maMarginLeft = aValue;
else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-top" ) ) ) mrTypeModel.maMarginTop = aValue; else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-top" ) ) ) mrTypeModel.maMarginTop = aValue;
else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "mso-position-vertical-relative" ) ) ) mrTypeModel.maPositionVerticalRelative = aValue;
} }
} }
} }
......
...@@ -798,12 +798,15 @@ void SwAnchoredDrawObject::_SetPositioningAttr() ...@@ -798,12 +798,15 @@ void SwAnchoredDrawObject::_SetPositioningAttr()
// --> #i71182# // --> #i71182#
// only change position - do not lose other attributes // only change position - do not lose other attributes
SwFmtHoriOrient aHori( GetFrmFmt().GetHoriOrient() ); SwFmtHoriOrient aHori( GetFrmFmt().GetHoriOrient() );
aHori.SetPos( nHoriPos ); // If the object is already positioned, leave it alone.
if (!aHori.GetPos())
aHori.SetPos( nHoriPos );
GetFrmFmt().SetFmtAttr( aHori ); GetFrmFmt().SetFmtAttr( aHori );
SwFmtVertOrient aVert( GetFrmFmt().GetVertOrient() ); SwFmtVertOrient aVert( GetFrmFmt().GetVertOrient() );
aVert.SetPos( nVertPos ); if (!aVert.GetPos())
aVert.SetPos( nVertPos );
GetFrmFmt().SetFmtAttr( aVert ); GetFrmFmt().SetFmtAttr( aVert );
// --> #i36010# - set layout direction of the position // --> #i36010# - set layout direction of the position
......
...@@ -1513,6 +1513,13 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape ...@@ -1513,6 +1513,13 @@ void DomainMapper_Impl::PushShapeContext( const uno::Reference< drawing::XShape
uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW ); uno::Reference< lang::XServiceInfo > xSInfo( xShape, uno::UNO_QUERY_THROW );
bool bIsGraphic = xSInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ) ); bool bIsGraphic = xSInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.GraphicObjectShape" ) ) );
// If there are position properties, the shape should not be inserted "as character".
sal_Int32 nHoriPosition = 0, nVertPosition = 0;
xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_HORI_ORIENT_POSITION)) >>= nHoriPosition;
xProps->getPropertyValue(rPropNameSupplier.GetName(PROP_VERT_ORIENT_POSITION)) >>= nVertPosition;
if (nHoriPosition != 0 || nVertPosition != 0)
bIsGraphic = false;
xProps->setPropertyValue( xProps->setPropertyValue(
rPropNameSupplier.GetName( PROP_OPAQUE ), rPropNameSupplier.GetName( PROP_OPAQUE ),
uno::makeAny( true ) ); uno::makeAny( true ) );
......
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