improve xlsx shape/chart import, anchor to cell where needed fdo#45266
This commit is contained in:
parent
3364fcc5a5
commit
c07e9299bb
4 changed files with 42 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -9,6 +9,7 @@ AdjustLuminance
|
|||
AdjustmentValues
|
||||
Address
|
||||
Align
|
||||
Anchor
|
||||
AnchorPosition
|
||||
ApplyFormDesignMode
|
||||
AreaLinks
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue