[Libreoffice-commits] .: oox/source sc/source
Noel Power
noelp at kemper.freedesktop.org
Wed Feb 8 09:50:49 PST 2012
oox/source/token/properties.txt | 2 +
oox/source/xls/drawingbase.cxx | 6 ++++
sc/source/ui/unoobj/docuno.cxx | 60 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
New commits:
commit 4908c16a73b397f83c327789f113658c1ea4d904
Author: Noel Power <noel.power at novell.com>
Date: Wed Feb 8 17:45:34 2012 +0000
handle row and column offsets for imported shape with cell anchor fdo#45266
This is an update to the previous commit ( for the same bug ) d3a26738b426846ee1a787e7c97280fc43002961
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 94a1947..176ae08 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 91ed337..cfc9f32 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 ba7157e..0b3b231 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 ) )
More information about the Libreoffice-commits
mailing list