diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2021-12-16 15:10:33 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2022-01-03 14:40:09 +0100 |
commit | 678790f292b63c9def1f0427df20028a1f734c15 (patch) | |
tree | b9d25d13c2ff874fc6a8fd52413160b9532aa8d0 /sd | |
parent | f6fefed87a3ffac4a8d236e6a96a6405bfbb31f0 (diff) |
tdf#127696 PPTX export: fix lost outline character formatting
Now outline font property export is supported partially in PPTX
export and in text shape export in other OOXML formats.
Note: OOXML/MSO has customizable Text Fill and Text Outline in
Format Text Effects, while LO has only simple and buggy outline
character formatting property, showing only white or completely
transparent outline fill color. Transparency issues and the buggy
outline font handling of LO (e.g. 1% font color (line) transparency
results 100% fill transparency of the outline text) haven't been
handled yet.
Change-Id: Ic34bce4efd4a544d799b1d89af1107c4918061d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126996
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 2ea61ea63e94..5a773aa8ced6 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -7,8 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include <test/bootstrapfixture.hxx> -#include <unotest/macros_test.hxx> +#include "sdmodeltestbase.hxx" #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <com/sun/star/beans/XPropertySet.hpp> @@ -45,10 +44,8 @@ #include <vcl/scheduler.hxx> #include <comphelper/propertyvalue.hxx> -#include <DrawDocShell.hxx> #include <ViewShell.hxx> #include <app.hrc> -#include <drawdoc.hxx> #include <sdpage.hxx> #include <unomodel.hxx> #include <osl/thread.hxx> @@ -69,6 +66,8 @@ public: void checkCurrentPageNumber(sal_uInt16 nNum); void insertStringToObject(sal_uInt16 nObj, const std::string& rStr, bool bUseEscape); sd::slidesorter::SlideSorterViewShell* getSlideSorterViewShell(); + FileFormat* getFormat(sal_Int32 nExportType); + void save(sd::DrawDocShell* pShell, FileFormat const* pFormat, utl::TempFile const& rTempFile); }; void SdUiImpressTest::setUp() @@ -150,6 +149,46 @@ sd::slidesorter::SlideSorterViewShell* SdUiImpressTest::getSlideSorterViewShell( return pSSVS; } +FileFormat* SdUiImpressTest::getFormat(sal_Int32 nExportType) +{ + FileFormat* pFormat = &aFileFormats[0]; + if (o3tl::make_unsigned(nExportType) < SAL_N_ELEMENTS(aFileFormats)) + pFormat = &aFileFormats[nExportType]; + return pFormat; +} + +void SdUiImpressTest::save(sd::DrawDocShell* pShell, FileFormat const* pFormat, + utl::TempFile const& rTempFile) +{ + SfxMedium aStoreMedium(rTempFile.GetURL(), StreamMode::STD_WRITE); + if (std::strcmp(pFormat->pName, "odg") == 0) + { // Draw + SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE; + if (pFormat->nFormatType == ODG_FORMAT_TYPE) + nExportFormat = SotClipboardFormatId::STARDRAW_8; + auto pExportFilter = std::make_shared<SfxFilter>( + OUString::createFromAscii(pFormat->pFilterName), OUString(), pFormat->nFormatType, + nExportFormat, OUString::createFromAscii(pFormat->pTypeName), OUString(), + OUString::createFromAscii(pFormat->pUserData), "private:factory/sdraw*"); + pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); + aStoreMedium.SetFilter(pExportFilter); + } + else // Impress + { + SotClipboardFormatId nExportFormat = SotClipboardFormatId::NONE; + if (pFormat->nFormatType == ODP_FORMAT_TYPE) + nExportFormat = SotClipboardFormatId::STARCHART_8; + auto pExportFilter = std::make_shared<SfxFilter>( + OUString::createFromAscii(pFormat->pFilterName), OUString(), pFormat->nFormatType, + nExportFormat, OUString::createFromAscii(pFormat->pTypeName), OUString(), + OUString::createFromAscii(pFormat->pUserData), "private:factory/simpress*"); + pExportFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT); + aStoreMedium.SetFilter(pExportFilter); + } + pShell->DoSaveAs(aStoreMedium); + pShell->DoClose(); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522) { // Load the document and create two new windows. @@ -880,6 +919,50 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testCharColorTheme) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(8000), nCharColorLumOff); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf127696) +{ + mxComponent = loadFromDesktop("private:factory/simpress", + "com.sun.star.presentation.PresentationDocument"); + + dispatchCommand(mxComponent, ".uno:InsertPage", {}); + Scheduler::ProcessEventsToIdle(); + + insertStringToObject(0, "Test", /*bUseEscape*/ false); + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:OutlineFont", {}); + + // Save it as PPTX and load it again. + utl::TempFile aTempFile; + save(dynamic_cast<SdXImpressDocument*>(mxComponent.get())->GetDocShell(), getFormat(PPTX), + aTempFile); + mxComponent = loadFromDesktop(aTempFile.GetURL()); + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(1), + uno::UNO_QUERY); + + uno::Reference<beans::XPropertySet> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); + + uno::Reference<text::XText> xText + = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText(); + CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is()); + + uno::Reference<container::XEnumerationAccess> paraEnumAccess(xText, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> paraEnum(paraEnumAccess->createEnumeration()); + + uno::Reference<text::XTextRange> xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW); + + uno::Reference<container::XEnumerationAccess> runEnumAccess(xParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> runEnum = runEnumAccess->createEnumeration(); + + uno::Reference<text::XTextRange> xRun(runEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW); + + bool bContoured = false; + xPropSet->getPropertyValue("CharContoured") >>= bContoured; + CPPUNIT_ASSERT(bContoured); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |