dev/null |binary helpcontent2 | 2 include/oox/ppt/pptimport.hxx | 2 include/oox/ppt/pptshape.hxx | 3 oox/inc/drawingml/table/tableproperties.hxx | 3 oox/inc/drawingml/textbodyproperties.hxx | 2 oox/source/drawingml/table/tableproperties.cxx | 61 ---------- oox/source/drawingml/textbodypropertiescontext.cxx | 16 ++ oox/source/export/drawingml.cxx | 19 +++ oox/source/ppt/pptimport.cxx | 1 oox/source/ppt/pptshape.cxx | 33 ----- oox/source/ppt/slidepersist.cxx | 33 ----- oox/source/token/properties.txt | 1 sd/qa/unit/data/pptx/3columns.pptx |binary sd/qa/unit/data/pptx/tdf140852.pptx |binary sd/qa/unit/export-tests-ooxml2.cxx | 120 +++++++++++++++++++++ sd/qa/unit/import-tests.cxx | 96 ++++------------ 17 files changed, 184 insertions(+), 208 deletions(-)
New commits: commit c4c8202359e574bce784f6b40ce95e49e983c7bb Author: Rafael Lima <rafael.palma.l...@gmail.com> AuthorDate: Tue Jun 8 14:52:10 2021 +0200 Commit: Gerrit Code Review <ger...@gerrit.libreoffice.org> CommitDate: Tue Jun 8 14:52:10 2021 +0200 Update git submodules * Update helpcontent2 from branch 'master' to 55408cd1b3e29b3706c2cb8b44dd55284f3c3fff - Update SF_Basic service help page Adds the following methods: - CDate - CDateFromUnoDateTime - CDateToUnoDateTime - GlobalScope.BasicLibraries - GlobalScope.DialogLibraries - ThisComponent - ThisDatabaseDocument Change-Id: I963ad0d850987b1047b28b34b9a1e264b2414eff Reviewed-on: https://gerrit.libreoffice.org/c/help/+/115965 Tested-by: Jenkins Reviewed-by: Alain Romedenne <alain.romede...@libreoffice.org> diff --git a/helpcontent2 b/helpcontent2 index cfd0aa4ba18b..55408cd1b3e2 160000 --- a/helpcontent2 +++ b/helpcontent2 @@ -1 +1 @@ -Subproject commit cfd0aa4ba18b58179724d50d7d1ac4f500ca1db4 +Subproject commit 55408cd1b3e29b3706c2cb8b44dd55284f3c3fff commit 486a11ad6fdae1714200229462b69f328be06b5a Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Jun 5 00:19:06 2021 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Jun 8 14:51:57 2021 +0200 editengine-columns: PPTX support (tdf#118458) The unit tests that used to check the workaround using tables to emulate columns (implemented in tdf#120028) are changed to test import of the columns. This reverts some commits related to the mentioned workaround, namely aef569ed83a3ccc02639e5b2a1c7cc131ba262fc, c50ae6a282ed83762bf634fed5c91033eb305c88, 7b64bd90637a6722438bf873b1ded74ab3424c46, 33696b2820ce3c8b21b753d2c2bf92345ecb9276, 99dff69b561a8fe2d9437e6aa67a9581a6666f41. Change-Id: I97693ad4a981780e822070938992f274920df5a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116738 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/include/oox/ppt/pptimport.hxx b/include/oox/ppt/pptimport.hxx index eafb114b47fd..29ef3c5732a6 100644 --- a/include/oox/ppt/pptimport.hxx +++ b/include/oox/ppt/pptimport.hxx @@ -77,8 +77,6 @@ public: ::Color getSchemeColor( sal_Int32 nToken ) const; - static std::vector< PPTShape* > maPPTShapes; - #if OSL_DEBUG_LEVEL > 0 static XmlFilterBase* mpDebugFilterBase; #endif diff --git a/include/oox/ppt/pptshape.hxx b/include/oox/ppt/pptshape.hxx index e67a77635111..f452e585abcf 100644 --- a/include/oox/ppt/pptshape.hxx +++ b/include/oox/ppt/pptshape.hxx @@ -66,8 +66,7 @@ public: const oox::drawingml::Theme* pTheme, const css::uno::Reference< css::drawing::XShapes >& rxShapes, basegfx::B2DHomMatrix& aTransformation, - ::oox::drawingml::ShapeIdMap* pShapeMap, - bool bhasSameSubTypeIndex = false ); + ::oox::drawingml::ShapeIdMap* pShapeMap ); ShapeLocation getShapeLocation() const { return meShapeLocation; }; void setReferenced( bool bReferenced ){ mbReferenced = bReferenced; }; diff --git a/oox/inc/drawingml/table/tableproperties.hxx b/oox/inc/drawingml/table/tableproperties.hxx index ec8b3c4c5b60..34e361b18add 100644 --- a/oox/inc/drawingml/table/tableproperties.hxx +++ b/oox/inc/drawingml/table/tableproperties.hxx @@ -58,9 +58,6 @@ public: const css::uno::Reference < css::beans::XPropertySet > & xPropSet, const ::oox::drawingml::TextListStylePtr& pMasterTextListStyle ); - /// Distributes text body with multiple columns in table cells. - void pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth, bool bhasSameSubTypeIndex, bool bMaster); - private: const TableStyle& getUsedTableStyle(const ::oox::core::XmlFilterBase& rFilterBase, std::unique_ptr<TableStyle>& rTableStyleToDelete); diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx index 8a51c2bb906e..41fbb832a5d8 100644 --- a/oox/inc/drawingml/textbodyproperties.hxx +++ b/oox/inc/drawingml/textbodyproperties.hxx @@ -42,8 +42,6 @@ struct TextBodyProperties std::optional< sal_Int32 > moTextOffRight; css::drawing::TextVerticalAdjust meVA; OUString msPrst; - /// Number of requested columns. - sal_Int32 mnNumCol = 1; /// Normal autofit: font scale (default: 100%). sal_Int32 mnFontScale = 100000; OUString msHorzOverflow; diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index 1c12c10eda47..69117123dca8 100644 --- a/oox/source/drawingml/table/tableproperties.cxx +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -145,7 +145,7 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas for (auto& tableRow : mvTableRows) { sal_Int32 nColumn = 0; - sal_Int32 nColumnSize = mvTableGrid.size(); + sal_Int32 nColumnSize = tableRow.getTableCells().size(); sal_Int32 nRemovedColumn = 0; // for (sal_Int32 nColIndex = 0; nColIndex < nColumnSize; nColIndex++) @@ -206,65 +206,6 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas xTableStyleToDelete.reset(); } - -void TableProperties::pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth, bool bhasSameSubTypeIndex, bool bMaster) -{ - // Create table grid and a single row. - sal_Int32 nNumCol = pTextBody->getTextProperties().mnNumCol; - std::vector<sal_Int32>& rTableGrid(getTableGrid()); - std::vector<drawingml::table::TableRow>& rTableRows(getTableRows()); - sal_Int32 nColWidth = nShapeWidth / nNumCol; - - if(!bhasSameSubTypeIndex) - { - for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol) - rTableGrid.push_back(nColWidth); - - rTableRows.emplace_back(); - } - - if(rTableRows.empty()) - rTableRows.emplace_back(); - - oox::drawingml::table::TableRow& rTableRow = rTableRows.back(); - std::vector<oox::drawingml::table::TableCell>& rTableCells = rTableRow.getTableCells(); - - // Create the cells and distribute the paragraphs from pTextBody. - sal_Int32 nNumPara = pTextBody->getParagraphs().size(); - sal_Int32 nParaPerCol = std::ceil(double(nNumPara) / nNumCol); - // Font scale of text body will be applied at a text run level. - sal_Int32 nFontScale = pTextBody->getTextProperties().mnFontScale; - size_t nPara = 0; - for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol) - { - rTableCells.emplace_back(); - oox::drawingml::table::TableCell& rTableCell = rTableCells.at(nCol); - TextBodyPtr pCellTextBody = std::make_shared<TextBody>(); - rTableCell.setTextBody(pCellTextBody); - - // Copy properties provided by <a:lstStyle>. - pCellTextBody->getTextListStyle() = pTextBody->getTextListStyle(); - - if (bMaster) - continue; - - for (sal_Int32 nParaInCol = 0; nParaInCol < nParaPerCol; ++nParaInCol) - { - if (nPara < pTextBody->getParagraphs().size()) - { - std::shared_ptr<oox::drawingml::TextParagraph> pParagraph - = pTextBody->getParagraphs()[nPara]; - if (nFontScale != 100000) - { - for (auto& pRun : pParagraph->getRuns()) - pRun->getTextCharacterProperties().moFontScale = nFontScale; - } - pCellTextBody->appendParagraph(pParagraph); - } - ++nPara; - } - } -} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index 4d94191dcfc7..f7d4abd4e685 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -22,16 +22,19 @@ #include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/drawing/TextFitToSizeType.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <drawingml/textbodyproperties.hxx> #include <drawingml/textbody.hxx> #include <drawingml/customshapegeometry.hxx> #include <drawingml/scene3dcontext.hxx> +#include <o3tl/unit_conversion.hxx> #include <oox/drawingml/drawingmltypes.hxx> #include <oox/helper/attributelist.hxx> #include <oox/helper/propertymap.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/properties.hxx> #include <oox/token/tokens.hxx> +#include <svx/SvxXTextColumns.hxx> using namespace ::oox::core; using namespace ::com::sun::star; @@ -85,7 +88,18 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons mrTextBodyProp.msVertOverflow = rAttribs.getString(XML_vertOverflow, ""); // ST_TextColumnCount - mrTextBodyProp.mnNumCol = rAttribs.getInteger( XML_numCol, 1 ); + if (const sal_Int32 nColumns = rAttribs.getInteger(XML_numCol, 0); nColumns > 0) + { + css::uno::Reference<css::text::XTextColumns> xCols(SvxXTextColumns_createInstance(), + css::uno::UNO_QUERY_THROW); + xCols->setColumnCount(nColumns); + css::uno::Reference<css::beans::XPropertySet> xProps(xCols, css::uno::UNO_QUERY_THROW); + // ST_PositiveCoordinate32 + const sal_Int32 nSpacing = o3tl::convert(rAttribs.getInteger(XML_spcCol, 0), + o3tl::Length::emu, o3tl::Length::mm100); + xProps->setPropertyValue("AutomaticDistance", css::uno::Any(nSpacing)); + mrTextBodyProp.maPropertyMap.setAnyProperty(PROP_TextColumns, css::uno::Any(xCols)); + } // ST_Angle mrTextBodyProp.moRotation = rAttribs.getInteger( XML_rot ); diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 684623a41813..4d2212b2d50f 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -85,6 +85,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/XTextRange.hpp> @@ -3133,6 +3134,22 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo sal_Int32 nShapeTextRotateAngle = 0; if (GetProperty(xTextSet, "RotateAngle")) nShapeTextRotateAngle = rXPropSet->getPropertyValue("RotateAngle").get<sal_Int32>() / 300; + sal_Int16 nCols = 0; + sal_Int32 nColSpacing = -1; + if (GetProperty(rXPropSet, "TextColumns")) + { + if (css::uno::Reference<css::text::XTextColumns> xCols{ mAny, css::uno::UNO_QUERY }) + { + nCols = xCols->getColumnCount(); + if (css::uno::Reference<css::beans::XPropertySet> xProps{ mAny, + css::uno::UNO_QUERY }) + { + if (GetProperty(xProps, "AutomaticDistance")) + mAny >>= nColSpacing; + } + } + } + std::optional<OString> isUpright; if (GetProperty(rXPropSet, "InteropGrabBag")) { @@ -3187,6 +3204,8 @@ void DrawingML::WriteText(const Reference<XInterface>& rXIface, bool bBodyPr, bo } mpFS->startElementNS( (nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr, + XML_numCol, sax_fastparser::UseIf(OString::number(nCols), nCols > 0), + XML_spcCol, sax_fastparser::UseIf(OString::number(oox::drawingml::convertHmmToEmu(nColSpacing)), nCols > 0 && nColSpacing >= 0), XML_wrap, pWrap, XML_horzOverflow, sHorzOverflow, XML_vertOverflow, sVertOverflow, diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 573dbd0c4234..1f569d099876 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -70,7 +70,6 @@ PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxCont PowerPointImport::~PowerPointImport() { - maPPTShapes.clear(); } bool PowerPointImport::importDocument() diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 2f346cca2192..1756ad9e32ab 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -116,8 +116,7 @@ void PPTShape::addShape( const oox::drawingml::Theme* pTheme, const Reference< XShapes >& rxShapes, basegfx::B2DHomMatrix& aTransformation, - ::oox::drawingml::ShapeIdMap* pShapeMap, - bool bhasSameSubTypeIndex ) + ::oox::drawingml::ShapeIdMap* pShapeMap ) { SAL_INFO("oox.ppt","add shape id: " << msId << " location: " << ((meShapeLocation == Master) ? "master" : ((meShapeLocation == Slide) ? "slide" : ((meShapeLocation == Layout) ? "layout" : "other"))) << " subtype: " << mnSubType << " service: " << msServiceName); // only placeholder from layout are being inserted @@ -227,36 +226,6 @@ void PPTShape::addShape( } } - if (sServiceName != "com.sun.star.drawing.TableShape") - { - if (TextBodyPtr pTextBody = getTextBody()) - { - // If slide shape has not numCol but placeholder has we should inherit from placeholder. - if (pTextBody->getTextProperties().mnNumCol == 1 && - mnSubType && - getSubTypeIndex().has() && - rSlidePersist.getMasterPersist()) - { - oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( - getSubTypeIndex().get(), - rSlidePersist.getMasterPersist()->getShapes()->getChildren()); - if (pPlaceholder && pPlaceholder->getTableProperties()) - pTextBody->getTextProperties().mnNumCol = pPlaceholder->getTableProperties()->getTableGrid().size(); - } - - sal_Int32 nNumCol = pTextBody->getTextProperties().mnNumCol; - if (nNumCol > 1) - { - // This shape is not a table, but has multiple columns, - // represent that as a table. - sServiceName = "com.sun.star.drawing.TableShape"; - oox::drawingml::table::TablePropertiesPtr pTableProperties = getTableProperties(); - pTableProperties->pullFromTextBody(pTextBody, maSize.Width, bhasSameSubTypeIndex, meShapeLocation == Layout); - setTextBody(nullptr); - } - } - } - SAL_INFO("oox.ppt","shape service: " << sServiceName); if (mnSubType && getSubTypeIndex().has() && meShapeLocation == Layout) diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index fae4e5541d96..ae9f0f567a7c 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -23,7 +23,6 @@ #include <com/sun/star/frame/XModel.hpp> #include <oox/ppt/timenode.hxx> #include <oox/ppt/pptshape.hxx> -#include <oox/ppt/pptimport.hxx> #include <oox/ppt/slidepersist.hxx> #include <drawingml/fillproperties.hxx> #include <oox/drawingml/shapepropertymap.hxx> @@ -35,7 +34,6 @@ #include <oox/core/xmlfilterbase.hxx> #include <drawingml/textliststyle.hxx> #include <drawingml/textparagraphproperties.hxx> -#include <drawingml/textbody.hxx> #include <osl/diagnose.h> @@ -54,8 +52,6 @@ using namespace ::com::sun::star::animations; namespace oox::ppt { -std::vector< PPTShape* > PowerPointImport::maPPTShapes; - SlidePersist::SlidePersist( XmlFilterBase& rFilter, bool bMaster, bool bNotes, const css::uno::Reference< css::drawing::XDrawPage >& rxPage, oox::drawingml::ShapePtr const & pShapesPtr, const drawingml::TextListStylePtr & pDefaultTextStyle ) @@ -132,29 +128,12 @@ sal_Int16 SlidePersist::getLayoutFromValueToken() const return nLayout; } -static bool hasSameSubTypeIndex(sal_Int32 checkSubTypeIndex) -{ - sal_Int32 nSubTypeIndex = -1; - for(PPTShape* pPPTShape : PowerPointImport::maPPTShapes) - { - if(!pPPTShape->getSubTypeIndex().has()) - continue; - - nSubTypeIndex = pPPTShape->getSubTypeIndex().get(); - - if( nSubTypeIndex == checkSubTypeIndex ) - return true; - } - return false; -} void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) { applyTextStyles( rFilterBase ); Reference< XShapes > xShapes( getPage() ); std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() ); - bool bhasSameSubTypeIndex = false; - sal_Int32 nNumCol = 1; for (auto const& shape : rShapes) { @@ -164,17 +143,7 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) PPTShape* pPPTShape = dynamic_cast< PPTShape* >( child.get() ); basegfx::B2DHomMatrix aTransformation; if ( pPPTShape ) - { - bhasSameSubTypeIndex = hasSameSubTypeIndex( pPPTShape->getSubTypeIndex().get()); - - if(pPPTShape->getTextBody()) - nNumCol = pPPTShape->getTextBody()->getTextProperties().mnNumCol; - - if(pPPTShape->getSubTypeIndex().has() && nNumCol > 1 ) - PowerPointImport::maPPTShapes.push_back(pPPTShape); - - pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap(), bhasSameSubTypeIndex ); - } + pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap() ); else child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() ); } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index d50cd4bb124d..980c1bb8c0f2 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -528,6 +528,7 @@ TextBox TextBreak TextCameraZRotateAngle TextColor +TextColumns TextFitToSize TextFrames TextHorizontalAdjust diff --git a/sd/qa/unit/data/pptx/3columns.pptx b/sd/qa/unit/data/pptx/3columns.pptx new file mode 100644 index 000000000000..596db14a0d21 Binary files /dev/null and b/sd/qa/unit/data/pptx/3columns.pptx differ diff --git a/sd/qa/unit/data/pptx/tdf120028b.pptx b/sd/qa/unit/data/pptx/tdf120028b.pptx deleted file mode 100644 index 7d50da36c120..000000000000 Binary files a/sd/qa/unit/data/pptx/tdf120028b.pptx and /dev/null differ diff --git a/sd/qa/unit/data/pptx/tdf140852.pptx b/sd/qa/unit/data/pptx/tdf140852.pptx new file mode 100644 index 000000000000..1332b5a68c8c Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf140852.pptx differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index e901b62c70a7..17664e632b35 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/frame/XLoadable.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> @@ -213,6 +214,8 @@ public: void testTdf125560_textDeflate(); void testTdf125560_textInflateTop(); void testTdf96061_textHighlight(); + void testTextColumns_tdf140852(); + void testTextColumns_3columns(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -340,6 +343,8 @@ public: CPPUNIT_TEST(testTdf125560_textDeflate); CPPUNIT_TEST(testTdf125560_textInflateTop); CPPUNIT_TEST(testTdf96061_textHighlight); + CPPUNIT_TEST(testTextColumns_tdf140852); + CPPUNIT_TEST(testTextColumns_3columns); CPPUNIT_TEST_SUITE_END(); @@ -3198,6 +3203,121 @@ void SdOOXMLExportTest2::testTdf96061_textHighlight() CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), aColor); } +void SdOOXMLExportTest2::testTextColumns_tdf140852() +{ + // The document defines two columns in slideLayout12.xml, but explicitly redefines + // in slide1.xml. Here we check that the redefinition in the slide takes precedence. + + auto xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140852.pptx"), PPTX); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when " + "it comes to serving ice cream"), + xParagraph->getString()); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)), + xColProps->getPropertyValue("AutomaticDistance")); + } + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps)); + CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when " + "it comes to serving ice cream"), + xParagraph->getString()); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)), + xColProps->getPropertyValue("AutomaticDistance")); + } + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "1"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "360000"); + + tempFile.EnableKillingFile(); +} + +void SdOOXMLExportTest2::testTextColumns_3columns() +{ + auto xDocShRef = loadURL( + m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/3columns.pptx"), PPTX); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)), + xColProps->getPropertyValue("AutomaticDistance")); + // Scale value may be unstable; just test that the text is actually scaled + sal_Int16 nScale; + CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale); + CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale); + CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale); + } + + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + + { + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef); + uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages(); + uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW); + uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW); + uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW); + uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)), + xColProps->getPropertyValue("AutomaticDistance")); + // Scale value may be unstable; just test that the text is actually scaled + sal_Int16 nScale; + CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale); + CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale); + CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale); + } + + xDocShRef->DoClose(); + + xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "3"); + assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "108000"); + + tempFile.EnableKillingFile(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 866542c717db..fec4db5b6586 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -84,6 +84,7 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/text/GraphicCrop.hpp> #include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp> @@ -225,7 +226,6 @@ public: void testPatternImport(); void testPptCrop(); void testTdf120028(); - void testTdf120028b(); void testDescriptionImport(); void testTdf83247(); void testTdf47365(); @@ -337,7 +337,6 @@ public: CPPUNIT_TEST(testTdf116266); CPPUNIT_TEST(testPptCrop); CPPUNIT_TEST(testTdf120028); - CPPUNIT_TEST(testTdf120028b); CPPUNIT_TEST(testDescriptionImport); CPPUNIT_TEST(testTdf83247); CPPUNIT_TEST(testTdf47365); @@ -1050,26 +1049,20 @@ void SdImportTest::testMultiColTexts() sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/multicol.pptx"), PPTX ); const SdrPage *pPage = GetPage( 1, xDocShRef ); - sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0)); - CPPUNIT_ASSERT( pTableObj ); + auto pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetObj(0)); + CPPUNIT_ASSERT(pTextObj); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pTableObj->getRowCount()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pTableObj->getColumnCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pTextObj->GetTextColumnsSpacing()); - sdr::table::SdrTableObj *pMasterTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->TRG_GetMasterPage().GetObj(0)); - CPPUNIT_ASSERT( pMasterTableObj ); + auto pMasterTextObj = dynamic_cast<SdrTextObj*>(pPage->TRG_GetMasterPage().GetObj(0)); + CPPUNIT_ASSERT(pMasterTextObj); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMasterTableObj->getRowCount()); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMasterTableObj->getColumnCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pMasterTextObj->GetTextColumnsNumber()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pMasterTextObj->GetTextColumnsSpacing()); - uno::Reference< table::XCellRange > xTable(pMasterTableObj->getTable(), uno::UNO_QUERY_THROW); - uno::Reference< beans::XPropertySet > xCell; - xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW); - uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); - uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) ); - OUString sText = xRun->getString(); - - CPPUNIT_ASSERT_EQUAL(OUString(""), sText); //We don't import master table text for multicolumn case. + uno::Reference<text::XTextRange> xText(pMasterTextObj->getUnoShape(), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(OUString("mastershape1\nmastershape2"), xText->getString()); } void SdImportTest::testPredefinedTableStyle() @@ -3089,7 +3082,7 @@ void SdImportTest::testTdf116266() void SdImportTest::testTdf120028() { - // Check that the table shape has 4 columns. + // Check that the text shape has 4 columns. ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf120028.pptx"), PPTX); uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), @@ -3099,63 +3092,22 @@ void SdImportTest::testTdf120028() uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY); CPPUNIT_ASSERT(xPage.is()); - // This failed, shape was not a table, all text was rendered in a single - // column. uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage)); - uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"), - uno::UNO_QUERY); - CPPUNIT_ASSERT(xModel.is()); - - uno::Reference<table::XTableColumns> xColumns = xModel->getColumns(); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount()); - - // Check font size in the A1 cell. - uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); + uno::Reference<text::XTextColumns> xCols(xShape->getPropertyValue("TextColumns"), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), xCols->getColumnCount()); + uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xColProps->getPropertyValue("AutomaticDistance")); + + // Check font size in the shape. + uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape)); uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); - uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW); double fCharHeight = 0; xPropSet->getPropertyValue("CharHeight") >>= fCharHeight; - // This failed, non-scaled height was 13.5. - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, fCharHeight, 1E-12); - - xDocShRef->DoClose(); -} - -void SdImportTest::testTdf120028b() -{ - // Check that the table shape has 4 columns. - ::sd::DrawDocShellRef xDocShRef - = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf120028b.pptx"), PPTX); - uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), - uno::UNO_QUERY); - CPPUNIT_ASSERT(xDoc.is()); - - uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT(xPage.is()); - - uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage)); - CPPUNIT_ASSERT(xShape.is()); - - uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"), - uno::UNO_QUERY); - CPPUNIT_ASSERT(xModel.is()); - - uno::Reference<table::XTableColumns> xColumns = xModel->getColumns(); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount()); - - // Check font color in the A1 cell. - uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell)); - uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph)); - uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY); - Color nCharColor; - xPropSet->getPropertyValue("CharColor") >>= nCharColor; - // This was 0x1f497d, not white: text list style from placeholder shape - // from slide layout was ignored. - CPPUNIT_ASSERT_EQUAL(COL_WHITE, nCharColor); + CPPUNIT_ASSERT_DOUBLES_EQUAL(13.5, fCharHeight, 1E-12); + // 13.5 * 86% is approx. 11.6 (the correct scaled font size) + CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(86)), xShape->getPropertyValue("TextFitToSizeScale")); xDocShRef->DoClose(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits