summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oox/source/token/properties.txt2
-rw-r--r--oox/source/xls/drawingbase.cxx6
-rw-r--r--sc/source/ui/unoobj/docuno.cxx60
3 files changed, 68 insertions, 0 deletions
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 94a1947842e8..176ae084813c 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -218,6 +218,7 @@ HelpText
HideInactiveSelection
HoriJustify
HoriJustifyMethod
+HoriOrientPosition
HorizontalSplitMode
HorizontalSplitPositionTwips
IgnoreBlankCells
@@ -496,6 +497,7 @@ VertJustifyMethod
VerticalAlign
VerticalSplitMode
VerticalSplitPositionTwips
+VertOrientPosition
ViewBox
Visible
VisibleFlag
diff --git a/oox/source/xls/drawingbase.cxx b/oox/source/xls/drawingbase.cxx
index 91ed337334b8..cfc9f32f861a 100644
--- a/oox/source/xls/drawingbase.cxx
+++ b/oox/source/xls/drawingbase.cxx
@@ -308,6 +308,12 @@ ShapeAnchor::applyToXShape( const ::com::sun::star::uno::Reference< ::com::sun::
{
PropertySet aShapeProp( rxShape );
aShapeProp.setProperty( PROP_Anchor, getFromCell() );
+ CellAnchorModel offSets;
+ offSets.mnColOffset = maFrom.mnColOffset;
+ offSets.mnRowOffset = maFrom.mnRowOffset;
+ EmuPoint aPos = calcCellAnchorEmu( offSets );
+ aShapeProp.setProperty( PROP_HoriOrientPosition, lclEmuToHmm( aPos.X ) );
+ aShapeProp.setProperty( PROP_VertOrientPosition, lclEmuToHmm( aPos.Y ) );
}
}
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index ba7157e08bc3..0b3b2311a736 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -194,6 +194,55 @@ const SfxItemPropertyMapEntry* lcl_GetRowsPropertyMap()
return aRowsPropertyMap_Impl;
}
+struct OrientationInfo
+{
+ OrientationInfo() : mnVert( 0 ), mnHori( 0 ) {}
+ uno::Reference< beans::XPropertySet > mxShape;
+ sal_Int32 mnVert;
+ sal_Int32 mnHori;
+};
+
+void lcl_captureShapeOrientationInfo( std::vector< OrientationInfo >& infos, ScModelObj& rModel )
+{
+ rtl::OUString sHori( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HORIPOS ) );
+ rtl::OUString sVert( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_VERTPOS ) );
+
+ uno::Reference<container::XIndexAccess> xPages( rModel.getDrawPages(), uno::UNO_QUERY );
+ if ( xPages.is() )
+ {
+ for ( sal_Int32 nIndex = 0, nPages = xPages->getCount(); nIndex < nPages; ++nIndex )
+ {
+ uno::Reference<container::XIndexAccess> xShapes( xPages->getByIndex( nIndex ), uno::UNO_QUERY );
+ for ( sal_Int32 nShapeIndex = 0, nShapes = xShapes->getCount(); nShapeIndex < nShapes; ++nShapeIndex )
+ {
+ uno::Reference< beans::XPropertySet > xShape( xShapes->getByIndex( nShapeIndex ), uno::UNO_QUERY );
+ uno::Reference< table::XCell > xCell( xShape->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ANCHOR ) ) ), uno::UNO_QUERY );
+ // only capture orientation if the shape is anchored to cell
+ if ( xShape.is() && xCell.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xPropInfo = xShape->getPropertySetInfo();
+ if ( xPropInfo.is() && xPropInfo->hasPropertyByName( sHori ) && xPropInfo->hasPropertyByName( sVert ) )
+ {
+ OrientationInfo aShape;
+ aShape.mxShape = xShape;
+ xShape->getPropertyValue( sHori ) >>= aShape.mnHori;
+ xShape->getPropertyValue( sVert ) >>= aShape.mnVert;
+ infos.push_back( aShape );
+ }
+ }
+ }
+ }
+ }
+}
+
+void lcl_applyShapeOrientationInfo( std::vector< OrientationInfo >& infos )
+{
+ for ( std::vector< OrientationInfo >::iterator it = infos.begin(), it_end = infos.end(); it != it_end; ++it )
+ {
+ it->mxShape->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_HORIPOS ) ), uno::makeAny( it->mnHori ) );
+ it->mxShape->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_VERTPOS ) ), uno::makeAny( it->mnVert ) );
+ }
+}
using sc::HMMToTwips;
using sc::TwipsToHMM;
@@ -1692,7 +1741,18 @@ void SAL_CALL ScModelObj::setPropertyValue(
{
pDoc->EnableAdjustHeight( bAdjustHeightEnabled );
if( bAdjustHeightEnabled )
+ {
+ // during import ( e.g. oox ) shapes anchored by cell lose
+ // any additional Hori/Vert orientation ( which offsets the
+ // shape position relative to the cell ) when
+ // UpdateAllRowHeights is called. Save Hori/Vert values
+ // before calling UpdateAllRowHeights and re-apply them
+ // after
+ std::vector< OrientationInfo > savedOrientations;
+ lcl_captureShapeOrientationInfo( savedOrientations, *this );
pDocShell->UpdateAllRowHeights();
+ lcl_applyShapeOrientationInfo( savedOrientations );
+ }
}
}
else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) )