summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/export/drawingml.hxx1
-rw-r--r--oox/source/export/drawingml.cxx75
-rw-r--r--sd/qa/unit/data/pptx/bulletMarginAndIndent.pptxbin0 -> 32905 bytes
-rw-r--r--sd/qa/unit/data/pptx/paraMarginAndIndentation.pptxbin0 -> 32854 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx68
5 files changed, 138 insertions, 6 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 24867c2eb39d..2707852def5f 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 2287fdff8dda..36c0a9615b1e 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 000000000000..3ecfb5a74061
--- /dev/null
+++ b/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx
Binary files differ
diff --git a/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx b/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx
new file mode 100644
index 000000000000..a6164a227ddd
--- /dev/null
+++ b/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 70744f0a54d8..036e179fc857 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);