Kaydet (Commit) 55f0c9e0 authored tarafından Noel Power's avatar Noel Power

import page/cell anchoring for xlsx drawing objects fdo#58360

Change-Id: I5f6cf9c5f28e8176c1057d50e39c67202bf1f143
üst 1f41546e
...@@ -79,6 +79,14 @@ struct AnchorClientDataModel ...@@ -79,6 +79,14 @@ struct AnchorClientDataModel
class ShapeAnchor : public WorksheetHelper class ShapeAnchor : public WorksheetHelper
{ {
public: 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 ); explicit ShapeAnchor( const WorksheetHelper& rHelper );
/** Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor, xdr:twoCellAnchor). */ /** Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor, xdr:twoCellAnchor). */
...@@ -100,19 +108,13 @@ public: ...@@ -100,19 +108,13 @@ public:
/** Calculates the resulting shape anchor in 1/100 mm. */ /** Calculates the resulting shape anchor in 1/100 mm. */
::com::sun::star::awt::Rectangle calcAnchorRectHmm( ::com::sun::star::awt::Rectangle calcAnchorRectHmm(
const ::com::sun::star::awt::Size& rPageSizeHmm ) const; const ::com::sun::star::awt::Size& rPageSizeHmm ) const;
AnchorType getEditAs() const { return meEditAs; }
private: private:
/** Converts the passed anchor to an absolute position in EMUs. */ /** Converts the passed anchor to an absolute position in EMUs. */
::oox::drawingml::EmuPoint calcCellAnchorEmu( const CellAnchorModel& rModel ) const; ::oox::drawingml::EmuPoint calcCellAnchorEmu( const CellAnchorModel& rModel ) const;
private: 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. */ /** Specifies how cell positions from CellAnchorModel have to be processed. */
enum CellAnchorType enum CellAnchorType
...@@ -129,7 +131,7 @@ private: ...@@ -129,7 +131,7 @@ private:
CellAnchorModel maFrom; /// Top-left position, if anchor is not of type absolute. CellAnchorModel maFrom; /// Top-left position, if anchor is not of type absolute.
CellAnchorModel maTo; /// Bottom-right position, if anchor is of type two-cell. CellAnchorModel maTo; /// Bottom-right position, if anchor is of type two-cell.
AnchorClientDataModel maClientData; /// Shape client data. AnchorClientDataModel maClientData; /// Shape client data.
sal_Int32 mnEditAs; /// Anchor mode as shown in the UI. AnchorType meEditAs; /// Anchor mode as shown in the UI.
}; };
// ============================================================================ // ============================================================================
......
...@@ -79,7 +79,7 @@ ShapeAnchor::ShapeAnchor( const WorksheetHelper& rHelper ) : ...@@ -79,7 +79,7 @@ ShapeAnchor::ShapeAnchor( const WorksheetHelper& rHelper ) :
WorksheetHelper( rHelper ), WorksheetHelper( rHelper ),
meAnchorType( ANCHOR_INVALID ), meAnchorType( ANCHOR_INVALID ),
meCellAnchorType( CELLANCHOR_EMU ), meCellAnchorType( CELLANCHOR_EMU ),
mnEditAs( XML_twoCell ) meEditAs( ANCHOR_TWOCELL )
{ {
} }
...@@ -94,8 +94,17 @@ void ShapeAnchor::importAnchor( sal_Int32 nElement, const AttributeList& rAttrib ...@@ -94,8 +94,17 @@ void ShapeAnchor::importAnchor( sal_Int32 nElement, const AttributeList& rAttrib
meAnchorType = ANCHOR_ONECELL; meAnchorType = ANCHOR_ONECELL;
break; break;
case XDR_TOKEN( twoCellAnchor ): case XDR_TOKEN( twoCellAnchor ):
{
meAnchorType = ANCHOR_TWOCELL; 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; break;
default: default:
OSL_ENSURE( false, "ShapeAnchor::importAnchor - unexpected element" ); OSL_ENSURE( false, "ShapeAnchor::importAnchor - unexpected element" );
......
...@@ -289,6 +289,15 @@ void DrawingFragment::onEndElement() ...@@ -289,6 +289,15 @@ void DrawingFragment::onEndElement()
convertEmuToHmm( aShapeRectEmu.X ), convertEmuToHmm( aShapeRectEmu.Y ), convertEmuToHmm( aShapeRectEmu.X ), convertEmuToHmm( aShapeRectEmu.Y ),
convertEmuToHmm( aShapeRectEmu.Width ), convertEmuToHmm( aShapeRectEmu.Height ) ); convertEmuToHmm( aShapeRectEmu.Width ), convertEmuToHmm( aShapeRectEmu.Height ) );
extendShapeBoundingBox( aShapeRectHmm ); 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(); mxShape.reset();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment