[Libreoffice-commits] core.git: include/oox oox/source sd/qa

PriyankaGaikwad priyanka.gaikwad at synerzip.com
Tue May 12 01:40:54 PDT 2015


 include/oox/export/drawingml.hxx                   |    1 
 oox/source/export/drawingml.cxx                    |   75 +++++++++++++++++++--
 sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx    |binary
 sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx |binary
 sd/qa/unit/export-tests.cxx                        |   68 +++++++++++++++++++
 5 files changed, 138 insertions(+), 6 deletions(-)

New commits:
commit a878ffae876610bf7522d79685b6e07191a88214
Author: PriyankaGaikwad <priyanka.gaikwad at synerzip.com>
Date:   Thu Mar 26 13:41:47 2015 +0530

    tdf#90246 PPTX paragraph and bullet leftMargin and Indentation is not exported
    
    Problem Description :
    XML Difference
    Original :
    <a:pPr marL="360000" indent="-456840">
    
    After RT :
    <a:pPr>
    
    Solution : added support for marL and indent for paragraph and bullet.
    
    Change-Id: I1132d7b90ac1d7fc924f9a048f189e07e255e33b
    Reviewed-on: https://gerrit.libreoffice.org/15016
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 24867c2..2707852 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -185,6 +185,7 @@ public:
     void WriteShape3DEffects( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
     void WriteArtisticEffect( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet );
     OString WriteWdpPicture( const OUString& rFileId, const ::com::sun::star::uno::Sequence< sal_Int8 >& rPictureData );
+    sal_Int32 getBulletMarginIndentation (::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,sal_Int16 nLevel, const OUString& propName);
 
     static void ResetCounters();
 
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 2287fdf..36c0a96 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1764,6 +1764,48 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
     }
 }
 
+sal_Int32 DrawingML::getBulletMarginIndentation (Reference< XPropertySet > rXPropSet,sal_Int16 nLevel, const OUString& propName)
+{
+    if( nLevel < 0 || !GETA( NumberingRules ) )
+        return 0;
+
+    Reference< XIndexAccess > rXIndexAccess;
+
+    if (!(mAny >>= rXIndexAccess) || nLevel >= rXIndexAccess->getCount())
+        return 0;
+
+    DBG(fprintf (stderr, "numbering rules\n"));
+
+    Sequence<PropertyValue> aPropertySequence;
+    rXIndexAccess->getByIndex(nLevel) >>= aPropertySequence;
+
+    if (!aPropertySequence.hasElements())
+        return 0;
+
+    sal_Int32 nPropertyCount = aPropertySequence.getLength();
+
+    const PropertyValue* pPropValue = aPropertySequence.getArray();
+
+    sal_Int16 nNumberingType = SVX_NUM_NUMBER_NONE;
+
+    for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
+    {
+        const void* pValue = pPropValue[ i ].Value.getValue();
+        if ( pValue )
+        {
+            OUString aPropName( pPropValue[ i ].Name );
+            DBG(fprintf (stderr, "pro name: %s\n", OUStringToOString( aPropName, RTL_TEXTENCODING_UTF8 ).getStr()));
+            if ( aPropName == propName )
+                return *( static_cast<sal_Int32 const *>(pValue) );
+        }
+    }
+
+    if (nNumberingType == SVX_NUM_NUMBER_NONE)
+        return 0;
+
+    return 0;
+}
+
 const char* DrawingML::GetAlignment( sal_Int32 nAlignment )
 {
     const char* sAlignment = NULL;
@@ -1832,16 +1874,37 @@ void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph )
         }
     }
 
+    sal_Int32 nParaLeftMargin = 0;
+    sal_Int32 nParaFirstLineIndent = 0;
+
+    GET( nParaLeftMargin, ParaLeftMargin );
+    GET( nParaFirstLineIndent,ParaFirstLineIndent);
+
+    sal_Int32 nLeftMargin =  getBulletMarginIndentation ( rXPropSet, nLevel,"LeftMargin");
+    sal_Int32 nLineIndentation = getBulletMarginIndentation ( rXPropSet, nLevel,"FirstLineOffset");
+
     if( nLevel != -1
         || nAlignment != style::ParagraphAdjust_LEFT
         || bHasLinespacing )
     {
-        mpFS->startElementNS( XML_a, XML_pPr,
-                              XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL,
-                              XML_marL, NULL,
-                              XML_algn, GetAlignment( nAlignment ),
-                              XML_rtl, bRtl ? BS(bRtl) : NULL,
-                              FSEND );
+        if (nParaLeftMargin) // For Paraghraph
+            mpFS->startElementNS( XML_a, XML_pPr,
+                               XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL,
+                               XML_marL, nParaLeftMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nParaLeftMargin ) ) : NULL,
+                               XML_indent, nParaFirstLineIndent ? I32S( oox::drawingml::convertHmmToEmu( nParaFirstLineIndent ) ) : NULL,
+                               XML_algn, GetAlignment( nAlignment ),
+                               XML_rtl, bRtl ? BS(bRtl) : NULL,
+                               FSEND );
+        else
+            mpFS->startElementNS( XML_a, XML_pPr,
+                               XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL,
+                               XML_marL, nLeftMargin > 0 ? I32S( oox::drawingml::convertHmmToEmu( nLeftMargin ) ) : NULL,
+                               XML_indent, nLineIndentation ? I32S( oox::drawingml::convertHmmToEmu( nLineIndentation ) ) : NULL,
+                               XML_algn, GetAlignment( nAlignment ),
+                               XML_rtl, bRtl ? BS(bRtl) : NULL,
+                               FSEND );
+
+
 
         if( bHasLinespacing )
         {
diff --git a/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx b/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx
new file mode 100644
index 0000000..3ecfb5a
Binary files /dev/null and b/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx differ
diff --git a/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx b/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx
new file mode 100644
index 0000000..a6164a2
Binary files /dev/null and b/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 70744f0..036e179 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -100,6 +100,8 @@ public:
     void testRightToLeftParaghraph();
     void testTableCellBorder();
     void testBulletColor();
+    void testBulletMarginAndIndentation();
+    void testParaMarginAndindentation();
 
 #if !defined WNT
     void testBnc822341();
@@ -130,6 +132,8 @@ public:
     CPPUNIT_TEST(testRightToLeftParaghraph);
     CPPUNIT_TEST(testTableCellBorder);
     CPPUNIT_TEST(testBulletColor);
+    CPPUNIT_TEST(testBulletMarginAndIndentation);
+    CPPUNIT_TEST(testParaMarginAndindentation);
 
 #if !defined WNT
     CPPUNIT_TEST(testBnc822341);
@@ -946,6 +950,70 @@ void SdExportTest::testBnc822341()
 
 #endif
 
+void SdExportTest::testBulletMarginAndIndentation()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX );
+
+    xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(
+    xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+    uno::Reference< drawing::XDrawPage > xPage(
+    xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+
+    const SdrPage *pPage = pDoc->GetPage(1);
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+    SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
+    CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+
+    const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
+    const SvxNumBulletItem *pNumFmt = dynamic_cast<const SvxNumBulletItem *>(aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET));
+    CPPUNIT_ASSERT(pNumFmt);
+
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_uInt32(1000),sal_uInt32(pNumFmt->GetNumRule()->GetLevel(0).GetAbsLSpace()) ); // left margin is 0.79 cm
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's indentation is wrong!", sal_Int32(-998),sal_Int32(pNumFmt->GetNumRule()->GetLevel(0). GetFirstLineOffset()));
+}
+
+void SdExportTest::testParaMarginAndindentation()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx"), PPTX);
+
+    xDocShRef = saveAndReload( xDocShRef, PPTX );
+
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(
+    xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+
+    uno::Reference< drawing::XDrawPage > xPage(
+    xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+
+    uno::Reference< beans::XPropertySet > xShape(
+    xPage->getByIndex(0), uno::UNO_QUERY );
+    CPPUNIT_ASSERT_MESSAGE( "no shape", xShape.is() );
+
+    // Get first paragraph
+    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
+    CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
+    uno::Reference<container::XEnumerationAccess> paraEnumAccess;
+    paraEnumAccess.set(xText, uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+    uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
+                uno::UNO_QUERY_THROW);
+    uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
+
+    sal_Int32 nParaLeftMargin = 0;
+    xPropSet->getPropertyValue( "ParaLeftMargin" ) >>= nParaLeftMargin;
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(1000), sal_uInt32(nParaLeftMargin));
+
+    sal_Int32 nParaFirstLineIndent = 0;
+    xPropSet->getPropertyValue( "ParaFirstLineIndent" ) >>= nParaFirstLineIndent;
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-1268), sal_Int32(nParaFirstLineIndent));
+
+    xDocShRef->DoClose();
+}
+
 void SdExportTest::testCellLeftAndRightMargin()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/pptx/n90223.pptx"), PPTX);


More information about the Libreoffice-commits mailing list