[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at suse.cz
Fri Mar 29 07:38:43 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo48557.odt   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx     |   14 ++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |   15 ++++++++++++++-
 sw/source/filter/ww8/docxattributeoutput.hxx |    2 ++
 4 files changed, 30 insertions(+), 1 deletion(-)

New commits:
commit 18f299a47fecda6570ff898d6da4207b1ddd9a45
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Mar 29 14:53:09 2013 +0100

    fdo#48557 implement DOCX export of inner margin values for textbox text
    
    Change-Id: I524e3bcd21731ad203a420f60dd328c6551f0eb7

diff --git a/sw/qa/extras/ooxmlexport/data/fdo48557.odt b/sw/qa/extras/ooxmlexport/data/fdo48557.odt
new file mode 100644
index 0000000..35353ba
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo48557.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 808bf63..05908c4 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 be4f9ed..0ffc3a1 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 8689d53..2591f0b 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;


More information about the Libreoffice-commits mailing list