Kaydet (Commit) 795796da authored tarafından Noel Power's avatar Noel Power Kaydeden (comit) Eike Rathke

export/import anchoring for xls(x) drawing ( & ole ) objects fdo#58360

this patch rolls up the following commits

I8f12ce4fedd3da76bab683ac85169186deeb89dc
55f0c9e0
1f41546e

Change-Id: I8f12ce4fedd3da76bab683ac85169186deeb89dc
Reviewed-on: https://gerrit.libreoffice.org/1877Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
Tested-by: 's avatarEike Rathke <erack@redhat.com>
üst a5acd33b
......@@ -312,7 +312,7 @@ struct DffObjData
sal_Bool bOpt2 : 1;
sal_Bool bIsAutoText : 1;
sal_Bool bRotateTextWithShape : 1;
bool bPageAnchor;
int nCalledByGroup;
DffObjData( const DffRecordHeader& rObjHd,
......@@ -331,6 +331,7 @@ struct DffObjData
bOpt2( sal_False ),
bIsAutoText( sal_False ),
bRotateTextWithShape( sal_True ),
bPageAnchor( true ),
nCalledByGroup( nClByGroup ){}
};
......
......@@ -257,9 +257,11 @@ XclExpDffSheetAnchor::XclExpDffSheetAnchor( const XclExpRoot& rRoot ) :
void XclExpDffSheetAnchor::ImplSetFlags( const SdrObject& rSdrObj )
{
// Special case "page anchor" (X==0,Y==1) -> lock pos and size.
const Point& rPos = rSdrObj.GetAnchorPos();
mnFlags = ((rPos.X() == 0) && (rPos.Y() == 1)) ? EXC_ESC_ANCHOR_LOCKED : 0;
// set flags for cell/page anchoring
if ( ScDrawLayer::GetAnchorType( rSdrObj ) == SCA_CELL )
mnFlags = 0;
else
mnFlags = EXC_ESC_ANCHOR_LOCKED;
}
void XclExpDffSheetAnchor::ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit )
......
......@@ -3407,11 +3407,17 @@ void XclImpDffConverter::ProcessClientAnchor2( SvStream& rDffStrm,
OSL_ENSURE( rHeader.nRecType == DFF_msofbtClientAnchor, "XclImpDffConverter::ProcessClientAnchor2 - no client anchor record" );
XclObjAnchor aAnchor;
rHeader.SeekToContent( rDffStrm );
rDffStrm.SeekRel( 2 ); // flags
sal_uInt8 nFlags(0);
rDffStrm >> nFlags;
rDffStrm.SeekRel( 1 ); // flags
rDffStrm >> aAnchor; // anchor format equal to BIFF5 OBJ records
pDrawObj->SetAnchor( aAnchor );
rObjData.aChildAnchor = rConvData.mrDrawing.CalcAnchorRect( aAnchor, true );
rObjData.bChildAnchor = sal_True;
// page anchoring is the best approximation we have if mbMove
// is set
rObjData.bPageAnchor = ( nFlags & 0x1 );
}
}
......@@ -3479,6 +3485,10 @@ SdrObject* XclImpDffConverter::ProcessObj( SvStream& rDffStrm, DffObjData& rDffO
// process the SdrObject
if( xSdrObj.is() )
{
// 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_STRING, GetPalette().GetColor( EXC_COLOR_WINDOWBACK ) ) );
......
......@@ -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.
};
// ============================================================================
......
......@@ -125,6 +125,7 @@ public:
/** Additional processing for the passed SdrObject after insertion into the
drawing page (calls virtual DoPostProcessSdrObj() function). */
void PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
SCTAB GetTab() const { return mnTab; }
protected:
/** Reads the object name in a BIFF5 OBJ record. */
......@@ -167,7 +168,6 @@ protected:
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes may perform additional processing for the passed SdrObject after insertion. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
SCTAB GetTab() const { return mnTab; }
private:
/** Reads the contents of a BIFF3 OBJ record. */
void ImplReadObj3( XclImpStream& rStrm );
......
......@@ -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" );
......
......@@ -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();
......
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