From 1ca277fad69d8a53788a5d457a2dd99bd50b6910 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Apr 2016 10:09:40 +0200 Subject: tdf#84394: xls load: delay cell-anchoring of object groups When cell-anchored object groups are loaded, their anchoring must be delayed until all nested objects have been loaded, lest the invalid rectangle dimensions lead to incorrect positioning of the object. To achieve this, we keep track of the DffObjectData of the pending group, and move the anchoring to a FinalizeObj() method. Since DffObjectData has a const reference to a DffRecordHeader (which we need when setting the object anchoring) whose scope has closed by the time we call FinalizeObj() on the parent object, the stack of pending DffObjectData has references to clones of the original DffRecordHeader held in shared pointers. (This is to minimize the invasiveness of this patch wrt the Import* API.) Change-Id: Id23f5549dbc82306271cc02afc750f37eeea3ca2 Signed-off-by: Giuseppe Bilotta Reviewed-on: https://gerrit.libreoffice.org/24292 Tested-by: Jenkins Reviewed-by: Markus Mohrhard --- sc/source/filter/excel/xiescher.cxx | 26 ++++++++++++++++++++++---- sc/source/filter/inc/xiescher.hxx | 5 +++++ 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index d895e757872b..b76bd75f990e 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -3551,10 +3551,6 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO // process the SdrObject if( xSdrObj ) { - // cell anchoring - if ( !rDffObjData.bPageAnchor ) - ScDrawLayer::SetCellAnchoredFromPosition( *xSdrObj, GetDoc(), xDrawObj->GetTab() ); - // filled without color -> set system window color if( GetPropertyBool( DFF_Prop_fFilled ) && !IsProperty( DFF_Prop_fillColor ) ) xSdrObj->SetMergedItem( XFillColorItem( EMPTY_OUSTRING, GetPalette().GetColor( EXC_COLOR_WINDOWBACK ) ) ); @@ -3591,6 +3587,28 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO return xSdrObj.release(); } +SdrObject* XclImpDffConverter::FinalizeObj(DffObjData& rDffObjData, SdrObject* pOldSdrObj ) +{ + XclImpDffConvData& rConvData = GetConvData(); + + /* pOldSdrObj passes a generated SdrObject. This function owns this object + and can modify it. The function has either to return it back to caller + or to delete it by itself. */ + SdrObjectPtr xSdrObj( pOldSdrObj ); + + // find the OBJ record data related to the processed shape + XclImpDrawObjRef xDrawObj = rConvData.mrDrawing.FindDrawObj( rDffObjData.rSpHd ); + + if( xSdrObj && xDrawObj ) + { + // cell anchoring + if ( !rDffObjData.bPageAnchor ) + ScDrawLayer::SetCellAnchoredFromPosition( *xSdrObj, GetDoc(), xDrawObj->GetTab() ); + } + + return xSdrObj.release(); +} + bool XclImpDffConverter::InsertControl( const Reference< XFormComponent >& rxFormComp, const css::awt::Size& /*rSize*/, Reference< XShape >* pxShape, bool /*bFloatingCtrl*/ ) diff --git a/sc/source/filter/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx index 7041bbbe4706..35c3a5c8931b 100644 --- a/sc/source/filter/inc/xiescher.hxx +++ b/sc/source/filter/inc/xiescher.hxx @@ -980,6 +980,11 @@ private: Rectangle& rTextRect, SdrObject* pOldSdrObj = nullptr ) override; + /** Finalize a DFF object, sets anchor after nested objs have been loaded. */ + virtual SdrObject* FinalizeObj( + DffObjData& rDffObjData, + SdrObject* pOldSdrObj = nullptr ) override; + // virtual functions of SvxMSConvertOCXControls /** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */ -- cgit