summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-01-24 18:08:41 +0000
committerEike Rathke <erack@redhat.com>2013-02-07 13:13:13 +0000
commit795796da79d5dd815fb2d31e8d4a244bf8d54328 (patch)
tree62b9fa63ece01a8255b61a039ce7c911bf328e31
parenta5acd33bc54cbc00f2194c923641fbd0ab45d801 (diff)
export/import anchoring for xls(x) drawing ( & ole ) objects fdo#58360
this patch rolls up the following commits I8f12ce4fedd3da76bab683ac85169186deeb89dc 55f0c9e03250cf7563b37de9953fe239dceb4ba3 1f41546e5786dbd0a248c67ba4f1cba409fe05a6 Change-Id: I8f12ce4fedd3da76bab683ac85169186deeb89dc Reviewed-on: https://gerrit.libreoffice.org/1877 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--filter/inc/filter/msfilter/msdffimp.hxx3
-rw-r--r--sc/source/filter/excel/xeescher.cxx8
-rw-r--r--sc/source/filter/excel/xiescher.cxx12
-rw-r--r--sc/source/filter/inc/drawingbase.hxx20
-rw-r--r--sc/source/filter/inc/xiescher.hxx2
-rw-r--r--sc/source/filter/oox/drawingbase.cxx13
-rw-r--r--sc/source/filter/oox/drawingfragment.cxx9
7 files changed, 50 insertions, 17 deletions
diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index b798be049f25..020655ee82e5 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -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 ){}
};
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 32afdaba7d32..4221d0c40e90 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -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 )
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 6e16f279b7fe..24a5cc6e265d 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -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 ) ) );
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/inc/xiescher.hxx b/sc/source/filter/inc/xiescher.hxx
index eb99781bf62c..07655516b419 100644
--- a/sc/source/filter/inc/xiescher.hxx
+++ b/sc/source/filter/inc/xiescher.hxx
@@ -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 );
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();