[Libreoffice-commits] core.git: 3 commits - include/oox oox/source sw/qa sw/source
Miklos Vajna
vmiklos at suse.cz
Fri Aug 16 10:54:24 PDT 2013
include/oox/vml/vmlshape.hxx | 4 +
oox/source/vml/vmlshape.cxx | 19 ++++++++
oox/source/vml/vmlshapecontext.cxx | 4 +
sw/qa/extras/ooxmlexport/data/table-floating-margins.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 30 ++++++++++++++
sw/source/filter/ww8/docxattributeoutput.cxx | 6 ++
6 files changed, 62 insertions(+), 1 deletion(-)
New commits:
commit e41ce95ca86d37af35e7725edc2f63bd6634051e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Aug 16 17:50:11 2013 +0200
DOCX export: fix bottom paragraph margin inside text frame
Having non-null mpParentFrame during the export of text (not during the
export of the frame properties) resulted in getting the frame margins as
an SvxULSpaceItem, not the real paragraph margins.
Change-Id: Icab8906ef7935a86098d7340f5469e732393663c
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index c5b1419..2db8917 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -46,6 +46,7 @@
class Test : public SwModelTestBase
{
public:
+ Test();
void testZoom();
void defaultTabStopNotInStyles();
void testFdo38244();
@@ -125,8 +126,15 @@ private:
*/
xmlDocPtr parseExport();
void assertXPath(xmlDocPtr pXmlDoc, OString aXPath, OString aAttribute = OString(), OUString aExpectedValue = OUString());
+ /// If the XPath test for now runs only after one export iteration, check for this variable.
+ bool m_bImport;
};
+Test::Test()
+ : m_bImport(false)
+{
+}
+
void Test::run()
{
MethodEntry<Test> aMethods[] = {
@@ -204,9 +212,11 @@ void Test::run()
{
MethodEntry<Test>& rEntry = aMethods[i];
load("/sw/qa/extras/ooxmlexport/data/", rEntry.pName);
+ m_bImport = true;
// If the testcase is stored in some other format, it's pointless to test.
if (OString(rEntry.pName).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), rEntry.pName) == vBlacklist.end())
(this->*rEntry.pMethod)();
+ m_bImport = false;
reload("Office Open XML Text");
(this->*rEntry.pMethod)();
finish();
@@ -242,6 +252,7 @@ void Test::assertXPath(xmlDocPtr pXmlDoc, OString aXPath, OString aAttribute, OU
{
xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main"));
+ xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml"));
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
@@ -1156,6 +1167,13 @@ void Test::testTableFloatingMargins()
// These were 0, due to lack of import/export.
CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty<sal_Int32>(xFrame, "TopMargin"));
CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), getProperty<sal_Int32>(xFrame, "BottomMargin"));
+
+ if (m_bImport)
+ {
+ // Paragraph bottom margin wasn't 0 in the A1 cell of the floating table.
+ xmlDocPtr pXmlDoc = parseExport();
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:pict/v:rect/v:textbox/w:txbxContent/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "after", "0");
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index dd88b38..869db45 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -330,6 +330,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_pTextboxAttrList = NULL;
m_bTextFrameSyntax = false;
m_pFlyFrameSize = 0;
+ m_rExport.mpParentFrame = NULL;
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
m_pSerializer->startElementNS( XML_w, XML_pict, FSEND );
@@ -360,7 +361,6 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_rExport.RestoreData();
- m_rExport.mpParentFrame = NULL;
}
m_pSerializer->endElementNS( XML_w, XML_p );
commit cea495b0dbb6dcace3a3b46f88f7084d127c0482
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Aug 16 16:23:13 2013 +0200
DOCX export: implement wrap distance of Writer textframes
Change-Id: Ia4a36f18495de9f8a2fb0d2b6691231c7bcbcce4
diff --git a/sw/qa/extras/ooxmlexport/data/table-floating-margins.docx b/sw/qa/extras/ooxmlexport/data/table-floating-margins.docx
new file mode 100755
index 0000000..81f6f6c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/table-floating-margins.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index fc55bb9..c5b1419 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -107,6 +107,7 @@ public:
void testFdo64350();
void testFdo67013();
void testParaShadow();
+ void testTableFloatingMargins();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -190,6 +191,7 @@ void Test::run()
{"fdo64350.docx", &Test::testFdo64350},
{"fdo67013.docx", &Test::testFdo67013},
{"para-shadow.docx", &Test::testParaShadow},
+ {"table-floating-margins.docx", &Test::testTableFloatingMargins},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -1146,6 +1148,16 @@ void Test::testParaShadow()
CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(24/8*20)), aShadow.ShadowWidth);
}
+void Test::testTableFloatingMargins()
+{
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ // These were 0, due to lack of import/export.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), getProperty<sal_Int32>(xFrame, "TopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), getProperty<sal_Int32>(xFrame, "BottomMargin"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index a6904ce..dd88b38 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4681,6 +4681,8 @@ void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
if (m_bTextFrameSyntax)
{
+ m_aTextFrameStyle.append(";mso-wrap-distance-left:").append(double(rLRSpace.GetLeft()) / 20).append("pt");
+ m_aTextFrameStyle.append(";mso-wrap-distance-right:").append(double(rLRSpace.GetRight()) / 20).append("pt");
}
else if ( m_rExport.bOutFlyFrmAttrs )
{
@@ -4735,6 +4737,8 @@ void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
if (m_bTextFrameSyntax)
{
+ m_aTextFrameStyle.append(";mso-wrap-distance-top:").append(double(rULSpace.GetUpper()) / 20).append("pt");
+ m_aTextFrameStyle.append(";mso-wrap-distance-bottom:").append(double(rULSpace.GetLower()) / 20).append("pt");
}
else if ( m_rExport.bOutFlyFrmAttrs )
{
commit eeae7bf241ce34ac5b946a6b55a53c3f3a1c3d12
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Aug 16 18:28:26 2013 +0200
VML import of mso-wrap-distance-{left,right,top,bottom}
Change-Id: Ib16be0bf83120ed7aeb01f29634d51421fc351c8
diff --git a/include/oox/vml/vmlshape.hxx b/include/oox/vml/vmlshape.hxx
index 0312ec1..6ef4805 100644
--- a/include/oox/vml/vmlshape.hxx
+++ b/include/oox/vml/vmlshape.hxx
@@ -97,6 +97,10 @@ struct OOX_DLLPUBLIC ShapeTypeModel
OptValue< ::rtl::OUString > moWrapType; ///< How to wrap the text around the object
OptValue< ::rtl::OUString > moWrapSide; ///< On which side to wrap the text around the object
OUString maVTextAnchor; ///< How the text inside the shape is anchored vertically.
+ OUString maWrapDistanceLeft; ///< Distance from the left side of the shape to the text that wraps around it.
+ OUString maWrapDistanceRight; ///< Distance from the right side of the shape to the text that wraps around it.
+ OUString maWrapDistanceTop; ///< Distance from the top of the shape to the text that wraps around it.
+ OUString maWrapDistanceBottom; ///< Distance from the bottom of the shape to the text that wraps around it.
explicit ShapeTypeModel();
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 0c88d3f..47d8ceb 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -522,6 +522,25 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
Reference< XShape > xShape = mrDrawing.createAndInsertXShape( maService, rxShapes, aShapeRect );
convertShapeProperties( xShape );
+ // Handle left/right/top/bottom wrap distance.
+ const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper();
+ sal_Int32 nWrapDistanceLeft = 0;
+ if (!maTypeModel.maWrapDistanceLeft.isEmpty())
+ nWrapDistanceLeft = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceLeft, 0, true, true);
+ PropertySet(xShape).setAnyProperty(PROP_LeftMargin, uno::makeAny(nWrapDistanceLeft));
+ sal_Int32 nWrapDistanceRight = 0;
+ if (!maTypeModel.maWrapDistanceRight.isEmpty())
+ nWrapDistanceRight = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceRight, 0, true, true);
+ PropertySet(xShape).setAnyProperty(PROP_RightMargin, uno::makeAny(nWrapDistanceRight));
+ sal_Int32 nWrapDistanceTop = 0;
+ if (!maTypeModel.maWrapDistanceTop.isEmpty())
+ nWrapDistanceTop = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceTop, 0, false, true);
+ PropertySet(xShape).setAnyProperty(PROP_TopMargin, uno::makeAny(nWrapDistanceTop));
+ sal_Int32 nWrapDistanceBottom = 0;
+ if (!maTypeModel.maWrapDistanceBottom.isEmpty())
+ nWrapDistanceBottom = ConversionHelper::decodeMeasureToHmm(rGraphicHelper, maTypeModel.maWrapDistanceBottom, 0, false, true);
+ PropertySet(xShape).setAnyProperty(PROP_BottomMargin, uno::makeAny(nWrapDistanceBottom));
+
if ( maService.equalsAscii( "com.sun.star.text.TextFrame" ) )
{
PropertySet( xShape ).setAnyProperty( PROP_FrameIsAutomaticHeight, makeAny( maTypeModel.mbAutoHeight ) );
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 3c47c66..48340d5 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -418,6 +418,10 @@ void ShapeTypeContext::setStyle( const OUString& rStyle )
mrTypeModel.mbVisible = !aValue.equalsAscii( "hidden" );
else if( aName == "mso-wrap-style" ) mrTypeModel.maWrapStyle = aValue;
else if ( aName == "v-text-anchor" ) mrTypeModel.maVTextAnchor = aValue;
+ else if ( aName == "mso-wrap-distance-left" ) mrTypeModel.maWrapDistanceLeft = aValue;
+ else if ( aName == "mso-wrap-distance-right" ) mrTypeModel.maWrapDistanceRight = aValue;
+ else if ( aName == "mso-wrap-distance-top" ) mrTypeModel.maWrapDistanceTop = aValue;
+ else if ( aName == "mso-wrap-distance-bottom" ) mrTypeModel.maWrapDistanceBottom = aValue;
}
}
}
More information about the Libreoffice-commits
mailing list