fdo#48557 implement DOCX export of inner margin values for textbox text

Change-Id: I524e3bcd21731ad203a420f60dd328c6551f0eb7
This commit is contained in:
Miklos Vajna
2013-03-29 14:53:09 +01:00
parent f7f9b74163
commit 18f299a47f
4 changed files with 30 additions and 1 deletions

Binary file not shown.

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;