summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-03-29 14:53:09 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-03-29 15:38:21 +0100
commit18f299a47fecda6570ff898d6da4207b1ddd9a45 (patch)
treea5f776fd9814310b57402bf41829cdff8c3e8289
parentf7f9b74163acd6811ccfaabb2a1d762225258e15 (diff)
fdo#48557 implement DOCX export of inner margin values for textbox text
Change-Id: I524e3bcd21731ad203a420f60dd328c6551f0eb7
-rw-r--r--sw/qa/extras/ooxmlexport/data/fdo48557.odtbin0 -> 16782 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx14
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx15
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx2
4 files changed, 30 insertions, 1 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo48557.odt b/sw/qa/extras/ooxmlexport/data/fdo48557.odt
new file mode 100644
index 000000000000..35353baace27
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/fdo48557.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 808bf6319af7..05908c414f90 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -85,6 +85,7 @@ public:
void testCellBtlr();
void testTableStylerPrSz();
void testMathLiteral();
+ void testFdo48557();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -130,6 +131,7 @@ void Test::run()
{"cell-btlr.docx", &Test::testCellBtlr},
{"table-style-rPr-sz.docx", &Test::testTableStylerPrSz},
{"math-literal.docx", &Test::testMathLiteral},
+ {"fdo48557.odt", &Test::testFdo48557},
};
// Don't test the first import of these, for some reason those tests fail
const char* aBlacklist[] = {
@@ -658,6 +660,18 @@ void Test::testMathLiteral()
getFormula( getRun( getParagraph( 1 ), 1 )));
}
+void Test::testFdo48557()
+{
+ // Inner margins of the textframe wasn't exported.
+ 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);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "LeftBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "RightBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TopBorderDistance"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "BottomBorderDistance"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index be4f9ed8c8f6..0ffc3a12267b 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -307,11 +307,14 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_bTextFrameSyntax = true;
m_pFlyAttrList = m_pSerializer->createAttrList( );
+ m_pTextboxAttrList = m_pSerializer->createAttrList();
m_aTextFrameStyle = "position:absolute";
m_rExport.OutputFormat( pParentFrame->GetFrmFmt(), false, false, true );
m_pFlyAttrList->add(XML_style, m_aTextFrameStyle.makeStringAndClear());
XFastAttributeListRef xFlyAttrList( m_pFlyAttrList );
m_pFlyAttrList = NULL;
+ XFastAttributeListRef xTextboxAttrList(m_pTextboxAttrList);
+ m_pTextboxAttrList = NULL;
m_bTextFrameSyntax = false;
m_pSerializer->startElementNS( XML_w, XML_r, FSEND );
@@ -324,7 +327,7 @@ void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pT
m_pFlyFillAttrList = NULL;
m_pSerializer->singleElementNS(XML_v, XML_fill, xFlyFillAttrList);
}
- m_pSerializer->startElementNS( XML_v, XML_textbox, FSEND );
+ m_pSerializer->startElementNS( XML_v, XML_textbox, xTextboxAttrList );
m_pSerializer->startElementNS( XML_w, XML_txbxContent, FSEND );
m_rExport.WriteText( );
m_pSerializer->endElementNS( XML_w, XML_txbxContent );
@@ -4671,6 +4674,14 @@ void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox )
sal_Int32 nWidth = sal_Int32(fConverted / 20);
m_pFlyAttrList->add(XML_strokeweight, OString::valueOf(nWidth) + "pt");
}
+
+ // v:textbox's inset attribute: inner margin values for textbox text
+ OStringBuffer aInset;
+ aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_LEFT))/20) + "pt,");
+ aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_TOP))/20) + "pt,");
+ aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_RIGHT))/20) + "pt,");
+ aInset.append(OString::number(double(rBox.GetDistance(BOX_LINE_BOTTOM))/20) + "pt");
+ m_pTextboxAttrList->add(XML_inset, aInset.makeStringAndClear());
return;
}
@@ -4842,6 +4853,7 @@ DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSeri
m_pHyperlinkAttrList( NULL ),
m_pFlyAttrList( NULL ),
m_pFlyFillAttrList( NULL ),
+ m_pTextboxAttrList( NULL ),
m_pFootnotesList( new ::docx::FootnotesList() ),
m_pEndnotesList( new ::docx::FootnotesList() ),
m_footnoteEndnoteRefTag( 0 ),
@@ -4882,6 +4894,7 @@ DocxAttributeOutput::~DocxAttributeOutput()
delete m_pParagraphSpacingAttrList, m_pParagraphSpacingAttrList = NULL;
delete m_pHyperlinkAttrList, m_pHyperlinkAttrList = NULL;
delete m_pFlyAttrList, m_pFlyAttrList = NULL;
+ delete m_pTextboxAttrList, m_pTextboxAttrList = NULL;
delete m_pFootnotesList, m_pFootnotesList = NULL;
delete m_pEndnotesList, m_pEndnotesList = NULL;
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 8689d53bd407..2591f0b13f6d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -565,6 +565,8 @@ private:
::sax_fastparser::FastAttributeList *m_pHyperlinkAttrList;
::sax_fastparser::FastAttributeList *m_pFlyAttrList;
::sax_fastparser::FastAttributeList *m_pFlyFillAttrList;
+ /// Attributes of the next v:textbox element.
+ ::sax_fastparser::FastAttributeList *m_pTextboxAttrList;
::docx::FootnotesList *m_pFootnotesList;
::docx::FootnotesList *m_pEndnotesList;