[Libreoffice-commits] core.git: Branch 'libreoffice-4-0' - filter/inc sc/source

Noel Power noel.power at suse.com
Thu Feb 7 05:13:33 PST 2013


 filter/inc/filter/msfilter/msdffimp.hxx  |    3 ++-
 sc/source/filter/excel/xeescher.cxx      |    8 +++++---
 sc/source/filter/excel/xiescher.cxx      |   12 +++++++++++-
 sc/source/filter/inc/drawingbase.hxx     |   20 +++++++++++---------
 sc/source/filter/inc/xiescher.hxx        |    2 +-
 sc/source/filter/oox/drawingbase.cxx     |   13 +++++++++++--
 sc/source/filter/oox/drawingfragment.cxx |    9 +++++++++
 7 files changed, 50 insertions(+), 17 deletions(-)

New commits:
commit 795796da79d5dd815fb2d31e8d4a244bf8d54328
Author: Noel Power <noel.power at suse.com>
Date:   Thu Jan 24 18:08:41 2013 +0000

    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 at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index b798be0..020655e 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 32afdab..4221d0c 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 6e16f27..24a5cc6 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 9f392a6..de19882 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 eb99781..0765551 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 b035ec8..f0a5f7d 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 a301326..d187a4f 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();


More information about the Libreoffice-commits mailing list