[Libreoffice-commits] .: 3 commits - sw/source
Lubos Lunak
llunak at kemper.freedesktop.org
Mon Nov 29 08:12:48 PST 2010
sw/source/filter/ww8/docxattributeoutput.cxx | 74 ++++++++++++++++++++++++---
1 file changed, 68 insertions(+), 6 deletions(-)
New commits:
commit e037303192565e808fd202b1e8e1c35ebfba3856
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Mon Nov 29 17:05:50 2010 +0100
implement wp:anchor properly
added missing attributes and children elements, although some are
still not fully functional (positioning mostly) , bnc#513579
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 955d83a..e8e3c8f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -91,6 +91,7 @@
#include <editeng/frmdiritem.hxx>
#include <editeng/blnkitem.hxx>
#include <editeng/charhiddenitem.hxx>
+#include <editeng/opaqitem.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdobj.hxx>
@@ -1742,16 +1743,49 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
FSEND );
bool isAnchor = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() != FLY_AS_CHAR;
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_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 );
+ const char* relativeFromH;
+ const char* relativeFromV;
+ switch( rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId())
+ {
+ case FLY_AT_PAGE:
+ relativeFromV = relativeFromH = "page";
+ break;
+ case FLY_AT_PARA:
+ relativeFromH = "column";
+ relativeFromV = "paragraph";
+ break;
+ case FLY_AT_CHAR:
+ default:
+ relativeFromH = "character";
+ relativeFromV = "line";
+ break;
+ };
+ 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->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->endElementNS( XML_wp, XML_positionV );
+ }
else
+ {
m_pSerializer->startElementNS( XML_wp, XML_inline,
XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
FSEND );
-
- if( isAnchor )
- m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND );
+ }
+ // now the common parts
// extent of the image
OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) );
OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) );
@@ -1764,6 +1798,27 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0",
FSEND );
+ if( isAnchor )
+ {
+ switch( rGrfNode.GetFlyFmt()->GetSurround().GetValue())
+ {
+ case SURROUND_NONE:
+ m_pSerializer->singleElementNS( XML_wp, XML_wrapTopAndBottom, FSEND );
+ break;
+ case SURROUND_THROUGHT:
+ m_pSerializer->singleElementNS( XML_wp, XML_wrapNone, FSEND );
+ break;
+ case SURROUND_PARALLEL:
+ m_pSerializer->singleElementNS( XML_wp, XML_wrapSquare,
+ XML_wrapText, "bothSides", FSEND );
+ break;
+ case SURROUND_IDEAL:
+ default:
+ m_pSerializer->singleElementNS( XML_wp, XML_wrapSquare,
+ XML_wrapText, "largest", FSEND );
+ break;
+ }
+ }
// picture description
// TODO the right image description
m_pSerializer->startElementNS( XML_wp, XML_docPr,
commit d8e23a9d16ea89940a49fc055c98388f2ebcec49
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu Nov 25 19:10:39 2010 +0100
wp:simplePos actually applies only to wp:anchor, not to wp:inline
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 9765c90..955d83a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1740,12 +1740,18 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
m_pSerializer->startElementNS( XML_w, XML_drawing,
FSEND );
- sal_Int32 anchorOrInline = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR ? XML_inline : XML_anchor;
- m_pSerializer->startElementNS( XML_wp, anchorOrInline,
- XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
- FSEND );
+ bool isAnchor = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() != FLY_AS_CHAR;
+ if( isAnchor )
+ m_pSerializer->startElementNS( XML_wp, XML_anchor,
+ XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
+ FSEND );
+ else
+ m_pSerializer->startElementNS( XML_wp, XML_inline,
+ XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
+ FSEND );
- m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND );
+ if( isAnchor )
+ m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND );
// extent of the image
OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) );
OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) );
@@ -1871,7 +1877,7 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
m_pSerializer->endElementNS( XML_a, XML_graphicData );
m_pSerializer->endElementNS( XML_a, XML_graphic );
- m_pSerializer->endElementNS( XML_wp, anchorOrInline );
+ m_pSerializer->endElementNS( XML_wp, isAnchor ? XML_anchor : XML_inline );
m_pSerializer->endElementNS( XML_w, XML_drawing );
}
commit 652fafdceaa3332700a21ba79e44316df5a46321
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu Nov 25 19:06:24 2010 +0100
implement wp:simplePos for wp:anchor (empty, but it's required)
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 2c1dade..9765c90 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1742,9 +1742,10 @@ void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size
FSEND );
sal_Int32 anchorOrInline = rGrfNode.GetFlyFmt()->GetAnchor().GetAnchorId() == FLY_AS_CHAR ? XML_inline : XML_anchor;
m_pSerializer->startElementNS( XML_wp, anchorOrInline,
- XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0",
+ XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", XML_simplePos, "0",
FSEND );
+ m_pSerializer->singleElementNS( XML_wp, XML_simplePos, XML_x, "0", XML_y, "0", FSEND );
// extent of the image
OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) );
OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) );
More information about the Libreoffice-commits
mailing list