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
This commit is contained in:
parent
737a584d9a
commit
4908c16a73
3 changed files with 68 additions and 0 deletions
|
@ -218,6 +218,7 @@ HelpText
|
|||
HideInactiveSelection
|
||||
HoriJustify
|
||||
HoriJustifyMethod
|
||||
HoriOrientPosition
|
||||
HorizontalSplitMode
|
||||
HorizontalSplitPositionTwips
|
||||
IgnoreBlankCells
|
||||
|
@ -496,6 +497,7 @@ VertJustifyMethod
|
|||
VerticalAlign
|
||||
VerticalSplitMode
|
||||
VerticalSplitPositionTwips
|
||||
VertOrientPosition
|
||||
ViewBox
|
||||
Visible
|
||||
VisibleFlag
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) )
|
||||
|
|
Loading…
Reference in a new issue