summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Jaap <patrick.jaap@tu-dresden.de>2018-01-15 16:43:07 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-01-23 23:28:04 +0100
commitada232a67fbb3acf60b104a4916719dbdb891819 (patch)
tree6506393d29be795a7bb5ba9bb3d97b87e63b3009
parent4e00b175e2c222bc320ec16caa90aa1bd2c1b7a7 (diff)
tdf#113946 add 'topMargin' to GraphicHelpers import
The case '...topMargin' was not caught for setting a relative vertical position in GraphicHelpers. The test file demands a '7' here, which stands for 'PAGE_FRAME'. The '7' was overwritten in GraphicImport in case 'LN_CT_Anchor_positionV' by a call of 'resolve'. For a better overview a switch is inserted here. Change-Id: Ie98209fe445ecbba15c3dafe5980ca52421126f8 Reviewed-on: https://gerrit.libreoffice.org/47908 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--sw/qa/extras/ooxmlimport/data/tdf113946.docxbin0 -> 15580 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx7
-rw-r--r--writerfilter/source/dmapper/GraphicHelpers.cxx86
3 files changed, 51 insertions, 42 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/tdf113946.docx b/sw/qa/extras/ooxmlimport/data/tdf113946.docx
new file mode 100644
index 000000000000..060df76ecc2a
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/tdf113946.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4d65beeb90c4..449dae04ac59 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1567,6 +1567,13 @@ DECLARE_OOXMLIMPORT_TEST(testTdf112443, "tdf112443.docx")
CPPUNIT_ASSERT_EQUAL( OUString("30624"), aTop );
}
+
+DECLARE_OOXMLIMPORT_TEST(testTdf113946, "tdf113946.docx")
+{
+ OUString aTop = parseDump("/root/page/body/txt/anchored/SwAnchoredDrawObject/bounds", "top");
+ CPPUNIT_ASSERT_EQUAL( OUString("1696"), aTop );
+}
+
// tests should only be added to ooxmlIMPORT *if* they fail round-tripping in ooxmlEXPORT
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicHelpers.cxx b/writerfilter/source/dmapper/GraphicHelpers.cxx
index 8108445d24fb..a7ce01868714 100644
--- a/writerfilter/source/dmapper/GraphicHelpers.cxx
+++ b/writerfilter/source/dmapper/GraphicHelpers.cxx
@@ -63,57 +63,59 @@ void PositionHandler::lcl_attribute( Id aName, Value& rVal )
{
case NS_ooxml::LN_CT_PosV_relativeFrom:
{
- // TODO There are some other unhandled values
- static const Id pVertRelValues[] =
+ switch ( nIntValue )
{
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line
- };
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_margin:
+ m_nRelation = text::RelOrientation::PAGE_PRINT_AREA;
+ break;
- static const sal_Int16 pVertRelations[] =
- {
- text::RelOrientation::PAGE_PRINT_AREA,
- text::RelOrientation::PAGE_FRAME,
- text::RelOrientation::FRAME,
- text::RelOrientation::TEXT_LINE
- };
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page:
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_topMargin: // fallthrough intended
+ m_nRelation = text::RelOrientation::PAGE_FRAME;
+ break;
- for ( int i = 0; i < 4; i++ )
- {
- if ( pVertRelValues[i] == sal_uInt32( nIntValue ) )
- m_nRelation = pVertRelations[i];
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_paragraph:
+ m_nRelation = text::RelOrientation::FRAME;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_line:
+ m_nRelation = text::RelOrientation::TEXT_LINE;
+ break;
+
+ // TODO There are some other unhandled values
}
}
break;
+
case NS_ooxml::LN_CT_PosH_relativeFrom:
{
- // TODO There are some other unhandled values
- static const Id pHoriRelValues[] =
+ switch ( nIntValue )
{
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_leftMargin,
- NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_rightMargin
- };
-
- static const sal_Int16 pHoriRelations[] =
- {
- text::RelOrientation::PAGE_PRINT_AREA,
- text::RelOrientation::PAGE_FRAME,
- text::RelOrientation::FRAME,
- text::RelOrientation::CHAR,
- text::RelOrientation::PAGE_LEFT,
- text::RelOrientation::PAGE_RIGHT,
- };
-
- for ( int i = 0; i < 6; i++ )
- {
- if ( pHoriRelValues[i] == sal_uInt32( nIntValue ) )
- m_nRelation = pHoriRelations[i];
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_margin:
+ m_nRelation = text::RelOrientation::PAGE_PRINT_AREA;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page:
+ m_nRelation = text::RelOrientation::PAGE_FRAME;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_column:
+ m_nRelation = text::RelOrientation::FRAME;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_character:
+ m_nRelation = text::RelOrientation::CHAR;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_leftMargin:
+ m_nRelation = text::RelOrientation::PAGE_LEFT;
+ break;
+
+ case NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_rightMargin:
+ m_nRelation = text::RelOrientation::PAGE_RIGHT;
+ break;
+
+ // TODO There are some other unhandled values
}
}
break;