[Libreoffice-commits] .: 2 commits - sw/source

Lubos Lunak llunak at kemper.freedesktop.org
Fri Feb 11 08:28:37 PST 2011


 sw/source/filter/ww8/docxattributeoutput.cxx |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

New commits:
commit 978cb6303a5c5c808952ec8cab6dbef4b0bab16d
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Feb 11 17:21:02 2011 +0100

    save wp:anchor position using wp:posOffset (bnc#513579)
    
    wp:simplePos handling seems to be broken in msof.

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 73a476c..a35f2d5 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -95,6 +95,7 @@
 #include <svx/svdmodel.hxx>
 #include <svx/svdobj.hxx>
 
+#include <anchoredobject.hxx>
 #include <docufld.hxx>
 #include <flddropdown.hxx>
 #include <format.hxx>
@@ -1887,15 +1888,12 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
     if( isAnchor )
     {
         m_pSerializer->startElementNS( XML_wp, XML_anchor,
-                XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "1",
+                XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
                 XML_relativeHeight, "0", // TODO
                 XML_behindDoc, rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1",
                 XML_locked, "0", XML_layoutInCell, "1", XML_allowOverlap, "1", // TODO
                 FSEND );
-        Point pos = rGrfNode.GetFlyFmt()->FindLayoutRect().Pos() - rGrfNode.FindPageFrmRect( false, NULL, false ).Pos();
-        OString x( OString::valueOf( pos.X()));
-        OString y( OString::valueOf( pos.Y()));
-        m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, x.getStr(), XML_y, y.getStr(), FSEND );
+        m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND ); // required, unused
         const char* relativeFromH;
         const char* relativeFromV;
         switch( rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId())
@@ -1913,15 +1911,20 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
                 relativeFromV = "line";
                 break;
         };
+        Point pos( 0, 0 );
+        if( SwFlyFrmFmt* flyfmt = dynamic_cast<SwFlyFrmFmt*>(rGrfNode.GetFlyFmt())) // TODO is always true?
+            pos = flyfmt->GetAnchoredObj()->GetCurrRelPos();
+        OString x( OString::valueOf( TwipsToEMU( pos.X())));
+        OString y( OString::valueOf( TwipsToEMU( pos.Y())));
         m_pSerializer->startElementNS( XML_wp, XML_positionH, XML_relativeFrom, relativeFromH, FSEND );
-        m_pSerializer->startElementNS( XML_wp, XML_align, FSEND );
-        m_pSerializer->write( "left" ); // TODO
-        m_pSerializer->endElementNS( XML_wp, XML_align );
+        m_pSerializer->startElementNS( XML_wp, XML_posOffset, FSEND );
+        m_pSerializer->write( x );
+        m_pSerializer->endElementNS( XML_wp, XML_posOffset );
         m_pSerializer->endElementNS( XML_wp, XML_positionH );
         m_pSerializer->startElementNS( XML_wp, XML_positionV, XML_relativeFrom, relativeFromV, FSEND );
-        m_pSerializer->startElementNS( XML_wp, XML_align, FSEND );
-        m_pSerializer->write( "top" ); // TODO
-        m_pSerializer->endElementNS( XML_wp, XML_align );
+        m_pSerializer->startElementNS( XML_wp, XML_posOffset, FSEND );
+        m_pSerializer->write( y );
+        m_pSerializer->endElementNS( XML_wp, XML_posOffset );
         m_pSerializer->endElementNS( XML_wp, XML_positionV );
     }
     else
commit f75438a622dcd9a811616af6b56f27cf3f7f9a56
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Feb 10 18:06:06 2011 +0100

    save position properly for wp:anchor (bnc#513579)

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c9a4d3f..73a476c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1887,12 +1887,15 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
     if( isAnchor )
     {
         m_pSerializer->startElementNS( XML_wp, XML_anchor,
-                XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
+                XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "1",
                 XML_relativeHeight, "0", // TODO
                 XML_behindDoc, rGrfNode.GetFlyFmt()->GetOpaque().GetValue() ? "0" : "1",
                 XML_locked, "0", XML_layoutInCell, "1", XML_allowOverlap, "1", // TODO
                 FSEND );
-        m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND );
+        Point pos = rGrfNode.GetFlyFmt()->FindLayoutRect().Pos() - rGrfNode.FindPageFrmRect( false, NULL, false ).Pos();
+        OString x( OString::valueOf( pos.X()));
+        OString y( OString::valueOf( pos.Y()));
+        m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, x.getStr(), XML_y, y.getStr(), FSEND );
         const char* relativeFromH;
         const char* relativeFromV;
         switch( rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId())


More information about the Libreoffice-commits mailing list