[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - oox/source sd/qa
LuboÅ¡ LuÅák
l.lunak at collabora.com
Thu Mar 27 15:04:37 PDT 2014
oox/source/export/drawingml.cxx | 4 +++-
sd/qa/unit/data/fdo71961.odp |binary
sd/qa/unit/import-tests.cxx | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
New commits:
commit dac36077c3823a9f4ac738e35a9421c4c403328a
Author: LuboÅ¡ LuÅák <l.lunak at collabora.com>
Date: Thu Mar 27 18:46:16 2014 +0100
write (no)wrap of text only for custom shapes to .pptx (fdo#71961)
Apparently checking the TextWordWrap property in DrawingML::WriteText()
gives false by default for objects that do not have it set, which happens
to be everything except for custom shapes, which seem to be the only ones
to actually obey it. So all normal text would be exported as nowrap to .pptx
and read back as custom shape that has non-wrapping text.
I tried to make the property return true (which is what it should be in practice),
but that appears to be an exercise in futility, or I'm not mad enough to follow
the complicated property sets and whatnot. So just write it out only for custom
shapes. UNO purists, if any, are welcome to change the dynamic_cast to something
UNO-better if they manage without an ambiguous base class error.
Conflicts:
sd/qa/unit/import-tests.cxx
Change-Id: I3ed906285fde88d902ac9c801986a82a7515638b
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index b3bfd7f..d4a3edc 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -70,6 +70,7 @@
#include <editeng/svxenum.hxx>
#include <svx/unoapi.hxx>
#include <svx/svdoashp.hxx>
+#include <svx/unoshape.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
@@ -1327,7 +1328,8 @@ void DrawingML::WriteText( Reference< XInterface > rXIface )
sal_Bool bHasWrap = sal_False;
sal_Bool bWrap = sal_False;
- if( GETA( TextWordWrap ) ) {
+ // Only custom shapes obey the TextWordWrap option, normal text always wraps.
+ if( dynamic_cast<SvxCustomShape*>(rXIface.get()) && GETA( TextWordWrap ) ) {
mAny >>= bWrap;
bHasWrap = sal_True;
}
diff --git a/sd/qa/unit/data/fdo71961.odp b/sd/qa/unit/data/fdo71961.odp
new file mode 100644
index 0000000..323fbe8
Binary files /dev/null and b/sd/qa/unit/data/fdo71961.odp differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index ba67b22..518b022 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -36,6 +36,7 @@ public:
void testN759180();
void testN778859();
void testFdo64512();
+ void testFdo71961();
CPPUNIT_TEST_SUITE(SdFiltersTest);
CPPUNIT_TEST(testDocumentLayout);
@@ -43,6 +44,8 @@ public:
CPPUNIT_TEST(testN759180);
CPPUNIT_TEST(testN778859);
CPPUNIT_TEST(testFdo64512);
+ CPPUNIT_TEST(testFdo71961);
+
CPPUNIT_TEST_SUITE_END();
};
@@ -208,6 +211,39 @@ void SdFiltersTest::testFdo64512()
xTargetShape != xSvgShape );
}
+void SdFiltersTest::testFdo71961()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"));
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+ CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+ xDocShRef = saveAndReload( xDocShRef, PPTX );
+ CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+ CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+ SdDrawDocument *pDoc = xDocShRef->GetDoc();
+ CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+ const SdrPage *pPage = pDoc->GetPage (1);
+ CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+ // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
+ // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
+ SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 1 ));
+ CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+ CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
+ CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
+
+ pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 2 ));
+ CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+ CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
+ CPPUNIT_ASSERT_EQUAL( false, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
+
+ pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 3 ));
+ CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
+ CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
+ CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list