diff options
author | Noel Power <noel.power@novell.com> | 2012-01-26 11:00:15 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2012-02-03 12:43:42 +0000 |
commit | c07e9299bb2c8d5477669568b12708bd2ff12684 (patch) | |
tree | ad4de6430ced620df45523fdea71e1c818192e80 /oox | |
parent | enable Kerberos by default on DragonFly, too (diff) | |
download | core-c07e9299bb2c8d5477669568b12708bd2ff12684.tar.gz core-c07e9299bb2c8d5477669568b12708bd2ff12684.zip |
improve xlsx shape/chart import, anchor to cell where needed fdo#45266
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/xls/drawingbase.hxx | 10 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rw-r--r-- | oox/source/xls/drawingbase.cxx | 30 | ||||
-rw-r--r-- | oox/source/xls/drawingfragment.cxx | 3 |
4 files changed, 42 insertions, 2 deletions
diff --git a/oox/inc/oox/xls/drawingbase.hxx b/oox/inc/oox/xls/drawingbase.hxx index c79eb7a863c0..95fae469b8ab 100644 --- a/oox/inc/oox/xls/drawingbase.hxx +++ b/oox/inc/oox/xls/drawingbase.hxx @@ -32,6 +32,9 @@ #include "oox/drawingml/drawingmltypes.hxx" #include "oox/xls/worksheethelper.hxx" +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/table/XCell.hpp> + namespace oox { namespace xls { @@ -108,7 +111,12 @@ public: /** Calculates the resulting shape anchor in 1/100 mm. */ ::com::sun::star::awt::Rectangle calcAnchorRectHmm( const ::com::sun::star::awt::Size& rPageSizeHmm ) const; - + /** Returns the 'to' cell if it exists */ + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > getToCell() const; + /** Returns the 'from' cell if it exists */ + ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > getFromCell() const; + /** Applies Cell Anchor to an XShape if needed*/ + void applyToXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape ); private: /** Converts the passed anchor to an absolute position in EMUs. */ ::oox::drawingml::EmuPoint calcCellAnchorEmu( const CellAnchorModel& rModel ) const; diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 9127c389f5f2..94a1947842e8 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -9,6 +9,7 @@ AdjustLuminance AdjustmentValues Address Align +Anchor AnchorPosition ApplyFormDesignMode AreaLinks diff --git a/oox/source/xls/drawingbase.cxx b/oox/source/xls/drawingbase.cxx index 3369ba9f7e65..91ed337334b8 100644 --- a/oox/source/xls/drawingbase.cxx +++ b/oox/source/xls/drawingbase.cxx @@ -32,6 +32,7 @@ #include "oox/helper/attributelist.hxx" #include "oox/helper/binaryinputstream.hxx" #include "oox/xls/unitconverter.hxx" +#include "oox/helper/propertyset.hxx" namespace oox { namespace xls { @@ -281,6 +282,35 @@ Rectangle ShapeAnchor::calcAnchorRectHmm( const Size& rPageSizeHmm ) const return Rectangle( lclEmuToHmm( aAnchorRect.X ), lclEmuToHmm( aAnchorRect.Y ), lclEmuToHmm( aAnchorRect.Width ), lclEmuToHmm( aAnchorRect.Height ) ); } +::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > +ShapeAnchor::getToCell() const +{ + CellAddress aAddress; + aAddress.Sheet = getSheetIndex(); + aAddress.Row = maTo.mnRow; + aAddress.Column = maTo.mnCol; + return getCell( aAddress ); +} +::com::sun::star::uno::Reference< ::com::sun::star::table::XCell > +ShapeAnchor::getFromCell() const +{ + CellAddress aAddress; + aAddress.Sheet = getSheetIndex(); + aAddress.Row = maFrom.mnRow; + aAddress.Column = maFrom.mnCol; + return getCell( aAddress ); +} + +void +ShapeAnchor::applyToXShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape ) +{ + if ( ( meAnchorType == ANCHOR_TWOCELL || meAnchorType == ANCHOR_ONECELL ) && getFromCell().is() ) + { + PropertySet aShapeProp( rxShape ); + aShapeProp.setProperty( PROP_Anchor, getFromCell() ); + } +} + // private -------------------------------------------------------------------- EmuPoint ShapeAnchor::calcCellAnchorEmu( const CellAnchorModel& rModel ) const diff --git a/oox/source/xls/drawingfragment.cxx b/oox/source/xls/drawingfragment.cxx index 75cf0c8d562e..1fa504c9c5f0 100644 --- a/oox/source/xls/drawingfragment.cxx +++ b/oox/source/xls/drawingfragment.cxx @@ -273,7 +273,8 @@ void DrawingFragment::onEndElement() basegfx::B2DHomMatrix aTransformation; mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, aTransformation, &aShapeRectEmu32 ); - + // apply Cell anchoring if necessary + mxAnchor->applyToXShape( mxShape->getXShape() ); /* Collect all shape positions in the WorksheetHelper base class. But first, scale EMUs to 1/100 mm. */ Rectangle aShapeRectHmm( |