diff options
author | Noel Power <noel.power@suse.com> | 2013-01-25 11:29:45 +0000 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-01-25 15:23:14 +0000 |
commit | 55f0c9e03250cf7563b37de9953fe239dceb4ba3 (patch) | |
tree | 8646b2f84e0cefb1019da82aeb64a530e85f260e /sc | |
parent | import page/cell anchoring for xls drawing ( & ole ) objects fdo#58360 (diff) | |
download | core-55f0c9e03250cf7563b37de9953fe239dceb4ba3.tar.gz core-55f0c9e03250cf7563b37de9953fe239dceb4ba3.zip |
import page/cell anchoring for xlsx drawing objects fdo#58360
Change-Id: I5f6cf9c5f28e8176c1057d50e39c67202bf1f143
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/inc/drawingbase.hxx | 20 | ||||
-rw-r--r-- | sc/source/filter/oox/drawingbase.cxx | 13 | ||||
-rw-r--r-- | sc/source/filter/oox/drawingfragment.cxx | 9 |
3 files changed, 31 insertions, 11 deletions
diff --git a/sc/source/filter/inc/drawingbase.hxx b/sc/source/filter/inc/drawingbase.hxx index 9f392a67f971..de19882ecfe5 100644 --- a/sc/source/filter/inc/drawingbase.hxx +++ b/sc/source/filter/inc/drawingbase.hxx @@ -79,6 +79,14 @@ struct AnchorClientDataModel class ShapeAnchor : public WorksheetHelper { public: + enum AnchorType + { + ANCHOR_INVALID, /// Anchor type is unknown. + ANCHOR_ABSOLUTE, /// Absolute anchor (top-left corner and size in absolute units). + ANCHOR_ONECELL, /// One-cell anchor (top-left corner at cell, size in absolute units). + ANCHOR_TWOCELL, /// Two-cell anchor (top-left and bottom-right corner at cell). + ANCHOR_VML + }; explicit ShapeAnchor( const WorksheetHelper& rHelper ); /** Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor, xdr:twoCellAnchor). */ @@ -100,19 +108,13 @@ public: /** Calculates the resulting shape anchor in 1/100 mm. */ ::com::sun::star::awt::Rectangle calcAnchorRectHmm( const ::com::sun::star::awt::Size& rPageSizeHmm ) const; + AnchorType getEditAs() const { return meEditAs; } private: /** Converts the passed anchor to an absolute position in EMUs. */ ::oox::drawingml::EmuPoint calcCellAnchorEmu( const CellAnchorModel& rModel ) const; private: - enum AnchorType - { - ANCHOR_INVALID, /// Anchor type is unknown. - ANCHOR_ABSOLUTE, /// Absolute anchor (top-left corner and size in absolute units). - ANCHOR_ONECELL, /// One-cell anchor (top-left corner at cell, size in absolute units). - ANCHOR_TWOCELL, /// Two-cell anchor (top-left and bottom-right corner at cell). - ANCHOR_VML - }; + /** Specifies how cell positions from CellAnchorModel have to be processed. */ enum CellAnchorType @@ -129,7 +131,7 @@ private: CellAnchorModel maFrom; /// Top-left position, if anchor is not of type absolute. CellAnchorModel maTo; /// Bottom-right position, if anchor is of type two-cell. AnchorClientDataModel maClientData; /// Shape client data. - sal_Int32 mnEditAs; /// Anchor mode as shown in the UI. + AnchorType meEditAs; /// Anchor mode as shown in the UI. }; // ============================================================================ diff --git a/sc/source/filter/oox/drawingbase.cxx b/sc/source/filter/oox/drawingbase.cxx index b035ec8b9bc8..f0a5f7d1e0c0 100644 --- a/sc/source/filter/oox/drawingbase.cxx +++ b/sc/source/filter/oox/drawingbase.cxx @@ -79,7 +79,7 @@ ShapeAnchor::ShapeAnchor( const WorksheetHelper& rHelper ) : WorksheetHelper( rHelper ), meAnchorType( ANCHOR_INVALID ), meCellAnchorType( CELLANCHOR_EMU ), - mnEditAs( XML_twoCell ) + meEditAs( ANCHOR_TWOCELL ) { } @@ -94,8 +94,17 @@ void ShapeAnchor::importAnchor( sal_Int32 nElement, const AttributeList& rAttrib meAnchorType = ANCHOR_ONECELL; break; case XDR_TOKEN( twoCellAnchor ): + { meAnchorType = ANCHOR_TWOCELL; - mnEditAs = rAttribs.getToken( XML_editAs, XML_twoCell ); + OUString sEditAs = rAttribs.getXString( XML_editAs, OUString() ); + if ( !sEditAs.isEmpty() ) + { + if ( sEditAs.equalsIgnoreAsciiCaseAscii("absolute" ) ) + meEditAs = ANCHOR_ABSOLUTE; + else if ( sEditAs.equalsIgnoreAsciiCaseAscii("oneCell") ) + meEditAs = ANCHOR_ONECELL; + } + } break; default: OSL_ENSURE( false, "ShapeAnchor::importAnchor - unexpected element" ); diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx index a301326ab906..d187a4f72db2 100644 --- a/sc/source/filter/oox/drawingfragment.cxx +++ b/sc/source/filter/oox/drawingfragment.cxx @@ -289,6 +289,15 @@ void DrawingFragment::onEndElement() convertEmuToHmm( aShapeRectEmu.X ), convertEmuToHmm( aShapeRectEmu.Y ), convertEmuToHmm( aShapeRectEmu.Width ), convertEmuToHmm( aShapeRectEmu.Height ) ); extendShapeBoundingBox( aShapeRectHmm ); + // set cell Anchoring + if ( mxAnchor->getEditAs() != ShapeAnchor::ANCHOR_ABSOLUTE ) + { + SdrObject* pObj = SdrObject::getSdrObjectFromXShape( mxShape->getXShape() ); + if ( pObj ) + { + ScDrawLayer::SetCellAnchoredFromPosition( *pObj, getScDocument(), static_cast<SCTAB>( getSheetIndex() ) ); + } + } } } mxShape.reset(); |