diff options
author | Noel Power <noel.power@novell.com> | 2012-05-24 16:49:55 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-05-25 11:34:05 +0100 |
commit | 3ed479a1d83916cb5dc3be0eee0aa6fbe65a844a (patch) | |
tree | 6c71f2ed6746fc6820baf87c9f7d68d92798ccd1 /sc/source/ui/unoobj | |
parent | 0a8de8d937ea1e9cb26ea7c89951f559961b49de (diff) |
Revert "fix bad import positions of shapes & controls fdo#49430"
This reverts commit 9dc4fa1b22a533ba0a6ce0353112c55eef8a14ef.
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index ec1ec10e1366..a1e7a1e2fe97 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; @@ -1690,19 +1739,13 @@ void SAL_CALL ScModelObj::setPropertyValue( // 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. Here we save Hori/Vert - // values before calling UpdateAllRowHeights. Also due to - // differences between the drawing layer and gridwindow - // position calculations we actually can't reliably use cell - // anchoring so we need to remove the cell anchoring, custom - // calculate where the view would position the shape and - // then position the shape absolutely at the newly - // calculated postion. + // UpdateAllRowHeights is called. Save Hori/Vert values + // before calling UpdateAllRowHeights and re-apply them + // after std::vector< OrientationInfo > savedOrientations; - uno::Reference< frame::XModel > xModel( this ); - ScGlobal::CaptureShapeOrientationInfo( savedOrientations, xModel ); + lcl_captureShapeOrientationInfo( savedOrientations, *this ); pDocShell->UpdateAllRowHeights(); - ScGlobal::ApplyShapeOrientationInfo( savedOrientations, xModel, *pDoc ); + lcl_applyShapeOrientationInfo( savedOrientations ); } } } |