summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2020-07-23 13:45:51 +0300
committerGülşah Köse <gulsah.kose@collabora.com>2020-08-16 23:42:26 +0200
commitd8db387729092f5010d50ece4406a48517cd7917 (patch)
treee71cf8c3ad2a73e98e3e395ee5af3602bbbb82a0 /oox
parent0f3d1a154b18753a93a075b0be089c43bfcc9424 (diff)
tdf#133015 Fix duplicated row and column problem.
LibreOffice imports multicolumn texboxes as tables. When document has numCols=2 (or more) attribute at slidelayout and slide, the table rows and columns duplicates. maPPTShapes vector holds our PPTShape objects, hasSameSubTypeIndex function finds the status that I mention above. So that we can prevent that duplication. Change-Id: Iee03d130452a16e9b46d471a9b6ed5910e6351ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99279 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100826 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/inc/drawingml/table/tableproperties.hxx2
-rw-r--r--oox/source/drawingml/table/tableproperties.cxx21
-rw-r--r--oox/source/ppt/pptimport.cxx1
-rw-r--r--oox/source/ppt/pptshape.cxx5
-rw-r--r--oox/source/ppt/slidepersist.cxx34
5 files changed, 53 insertions, 10 deletions
diff --git a/oox/inc/drawingml/table/tableproperties.hxx b/oox/inc/drawingml/table/tableproperties.hxx
index 010fc67df416..40a0cc8efe0b 100644
--- a/oox/inc/drawingml/table/tableproperties.hxx
+++ b/oox/inc/drawingml/table/tableproperties.hxx
@@ -61,7 +61,7 @@ public:
const ::oox::drawingml::TextListStylePtr& pMasterTextListStyle );
/// Distributes text body with multiple columns in table cells.
- void pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth);
+ void pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth, bool bhasSameSubTypeIndex);
private:
diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx
index f867ee144003..3b1bbfb6514b 100644
--- a/oox/source/drawingml/table/tableproperties.cxx
+++ b/oox/source/drawingml/table/tableproperties.cxx
@@ -213,16 +213,25 @@ void TableProperties::pushToPropSet(const ::oox::core::XmlFilterBase& rFilterBas
xTableStyleToDelete.reset();
}
-void TableProperties::pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth)
+void TableProperties::pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sal_Int32 nShapeWidth, bool bhasSameSubTypeIndex)
{
// Create table grid and a single row.
sal_Int32 nNumCol = pTextBody->getTextProperties().mnNumCol;
std::vector<sal_Int32>& rTableGrid(getTableGrid());
- sal_Int32 nColWidth = nShapeWidth / nNumCol;
- for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol)
- rTableGrid.push_back(nColWidth);
std::vector<drawingml::table::TableRow>& rTableRows(getTableRows());
- rTableRows.emplace_back();
+ 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();
@@ -235,7 +244,7 @@ void TableProperties::pullFromTextBody(oox::drawingml::TextBodyPtr pTextBody, sa
for (sal_Int32 nCol = 0; nCol < nNumCol; ++nCol)
{
rTableCells.emplace_back();
- oox::drawingml::table::TableCell& rTableCell = rTableCells.back();
+ oox::drawingml::table::TableCell& rTableCell = rTableCells.at(nCol);
TextBodyPtr pCellTextBody(new TextBody);
rTableCell.setTextBody(pCellTextBody);
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 01f572a54dcf..99c528071226 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -70,6 +70,7 @@ PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxCont
PowerPointImport::~PowerPointImport()
{
+ maPPTShapes.clear();
}
/// Visits the relations from pRelations which are of type rType.
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index af7324485c65..e8182142c459 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -116,7 +116,8 @@ void PPTShape::addShape(
const oox::drawingml::Theme* pTheme,
const Reference< XShapes >& rxShapes,
basegfx::B2DHomMatrix& aTransformation,
- ::oox::drawingml::ShapeIdMap* pShapeMap )
+ ::oox::drawingml::ShapeIdMap* pShapeMap,
+ bool bhasSameSubTypeIndex )
{
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
@@ -237,7 +238,7 @@ void PPTShape::addShape(
// represent that as a table.
sServiceName = "com.sun.star.drawing.TableShape";
oox::drawingml::table::TablePropertiesPtr pTableProperties = getTableProperties();
- pTableProperties->pullFromTextBody(pTextBody, maSize.Width);
+ pTableProperties->pullFromTextBody(pTextBody, maSize.Width, bhasSameSubTypeIndex);
setTextBody(nullptr);
}
}
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index 247831677dfd..f46dd1b498d0 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/drawing/XShapes.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>
@@ -32,6 +33,7 @@
#include <oox/core/xmlfilterbase.hxx>
#include <drawingml/textliststyle.hxx>
#include <drawingml/textparagraphproperties.hxx>
+#include <drawingml/textbody.hxx>
#include <osl/diagnose.h>
@@ -50,6 +52,8 @@ using namespace ::com::sun::star::animations;
namespace oox { namespace 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 )
@@ -126,6 +130,21 @@ 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 );
@@ -133,6 +152,9 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
Reference< XShapes > xShapes( getPage(), UNO_QUERY );
std::vector< oox::drawingml::ShapePtr >& rShapes( maShapesPtr->getChildren() );
+ bool bhasSameSubTypeIndex = false;
+ sal_Int32 nNumCol = 1;
+
for (auto const& shape : rShapes)
{
std::vector< oox::drawingml::ShapePtr >& rChildren( shape->getChildren() );
@@ -141,7 +163,17 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
PPTShape* pPPTShape = dynamic_cast< PPTShape* >( child.get() );
basegfx::B2DHomMatrix aTransformation;
if ( pPPTShape )
- pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, &getShapeMap() );
+ {
+ 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 );
+ }
else
child->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, maShapesPtr->getFillProperties(), &getShapeMap() );
}