summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-06-08 15:36:24 +0200
committerCaolán McNamara <caolanm@redhat.com>2016-06-09 11:10:35 +0000
commit0525de4392491aa267c719dda09e3a068cdb413d (patch)
treed5020b022307ab0cfb969d0ef3af957c669ca363 /svx
parent50e8780b1471c551ad58d7babeb99028868a0c4d (diff)
tdf#100269 svx: fix undo of table column resize
SdrTableObjImpl::LayoutTable() assumed no re-layout is needed in case the total width of the table and the number of columns is the same, but undo of resize is a situation where we also need to check the individual widths of the columns, otherwise layout won't be up to date. (cherry picked from commits a106165e7fd39215c4717e1486aef05f6af9180f and 9cea9137b2534da4056f72d3c8a07f85a02f85be) Conflicts: sd/qa/unit/tiledrendering/tiledrendering.cxx Change-Id: Ia5ebb05af79dda1c0d8c5bb10e7f37f81ee1d035 Reviewed-on: https://gerrit.libreoffice.org/26072 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/svdotable.cxx40
-rw-r--r--svx/source/table/tablecolumn.cxx9
-rw-r--r--svx/source/table/tablecolumn.hxx5
-rw-r--r--svx/source/table/tablelayouter.cxx29
-rw-r--r--svx/source/table/tablelayouter.hxx2
-rw-r--r--svx/source/table/tablemodel.cxx7
-rw-r--r--svx/source/table/tablemodel.hxx2
-rw-r--r--svx/source/table/tableundo.cxx3
8 files changed, 96 insertions, 1 deletions
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 4fbcb1f4963c..1bf48c1b8372 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -57,6 +57,7 @@
#include "svx/xflftrit.hxx"
#include "svx/xfltrit.hxx"
#include <cppuhelper/implbase.hxx>
+#include <libxml/xmlwriter.h>
using ::com::sun::star::uno::Any;
@@ -223,6 +224,8 @@ public:
void dispose();
sal_Int32 getColumnCount() const;
+ /// Get widths of the columns in the table.
+ std::vector<sal_Int32> getColumnWidths() const;
sal_Int32 getRowCount() const;
void DragEdge( bool mbHorizontal, int nEdge, sal_Int32 nOffset );
@@ -240,6 +243,7 @@ public:
void connectTableStyle();
void disconnectTableStyle();
virtual bool isInUse() override;
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
static SdrTableObjImpl* lastLayoutTable;
static Rectangle lastLayoutInputRectangle;
@@ -249,6 +253,7 @@ private:
static WritingMode lastLayoutMode;
static sal_Int32 lastRowCount;
static sal_Int32 lastColCount;
+ static std::vector<sal_Int32> lastColWidths;
};
SdrTableObjImpl* SdrTableObjImpl::lastLayoutTable = nullptr;
@@ -259,6 +264,7 @@ bool SdrTableObjImpl::lastLayoutFitHeight;
WritingMode SdrTableObjImpl::lastLayoutMode;
sal_Int32 SdrTableObjImpl::lastRowCount;
sal_Int32 SdrTableObjImpl::lastColCount;
+std::vector<sal_Int32> SdrTableObjImpl::lastColWidths;
SdrTableObjImpl::SdrTableObjImpl()
: mpTableObj( nullptr )
@@ -641,6 +647,14 @@ bool SdrTableObjImpl::isInUse()
return mpTableObj && mpTableObj->IsInserted();
}
+void SdrTableObjImpl::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("sdrTableObjImpl"));
+ if (mpLayouter)
+ mpLayouter->dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+}
+
// XEventListener
@@ -680,6 +694,15 @@ sal_Int32 SdrTableObjImpl::getColumnCount() const
return mxTable.is() ? mxTable->getColumnCount() : 0;
}
+std::vector<sal_Int32> SdrTableObjImpl::getColumnWidths() const
+{
+ std::vector<sal_Int32> aRet;
+
+ if (mxTable.is())
+ aRet = mxTable->getColumnWidths();
+
+ return aRet;
+}
sal_Int32 SdrTableObjImpl::getRowCount() const
@@ -701,7 +724,8 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe
|| lastLayoutFitWidth != bFitWidth || lastLayoutFitHeight != bFitHeight
|| lastLayoutMode != writingMode
|| lastRowCount != getRowCount()
- || lastColCount != getColumnCount() )
+ || lastColCount != getColumnCount()
+ || lastColWidths != getColumnWidths() )
{
lastLayoutTable = this;
lastLayoutInputRectangle = rArea;
@@ -710,6 +734,9 @@ void SdrTableObjImpl::LayoutTable( Rectangle& rArea, bool bFitWidth, bool bFitHe
lastLayoutMode = writingMode;
lastRowCount = getRowCount();
lastColCount = getColumnCount();
+ // Column resize, when the total width and column count of the
+ // table is unchanged, but re-layout is still needed.
+ lastColWidths = getColumnWidths();
TableModelNotifyGuard aGuard( mxTable.get() );
mpLayouter->LayoutTable( rArea, bFitWidth, bFitHeight );
lastLayoutResultRectangle = rArea;
@@ -2609,6 +2636,17 @@ void SdrTableObj::uno_unlock()
mpImpl->mxTable->unlockBroadcasts();
}
+void SdrTableObj::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("sdrTableObj"));
+ xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+
+ SdrObject::dumpAsXml(pWriter);
+
+ mpImpl->dumpAsXml(pWriter);
+
+ xmlTextWriterEndElement(pWriter);
+}
diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx
index 8f48aad20184..96951694b8af 100644
--- a/svx/source/table/tablecolumn.cxx
+++ b/svx/source/table/tablecolumn.cxx
@@ -294,6 +294,15 @@ rtl::Reference< FastPropertySetInfo > TableColumn::getStaticPropertySetInfo()
return xInfo;
}
+TableModelRef TableColumn::getModel() const
+{
+ return mxTableModel;
+}
+
+sal_Int32 TableColumn::getWidth() const
+{
+ return mnWidth;
+}
} }
diff --git a/svx/source/table/tablecolumn.hxx b/svx/source/table/tablecolumn.hxx
index 2f9b3cc7cd5c..cc768458692b 100644
--- a/svx/source/table/tablecolumn.hxx
+++ b/svx/source/table/tablecolumn.hxx
@@ -59,6 +59,11 @@ public:
virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::beans::PropertyVetoException, css::lang::IllegalArgumentException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
virtual css::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) throw (css::beans::UnknownPropertyException, css::lang::WrappedTargetException, css::uno::RuntimeException, std::exception) override;
+ /// Get the table that owns this column.
+ TableModelRef getModel() const;
+ /// Get the width of this column.
+ sal_Int32 getWidth() const;
+
private:
static rtl::Reference< FastPropertySetInfo > getStaticPropertySetInfo();
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 1df137851e40..62d179f7b718 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/awt/XLayoutConstrains.hpp>
#include <tools/gen.hxx>
+#include <libxml/xmlwriter.h>
#include "cell.hxx"
#include "cellrange.hxx"
@@ -1151,6 +1152,34 @@ void TableLayouter::DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal
}
}
+void TableLayouter::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("tableLayouter"));
+
+ xmlTextWriterStartElement(pWriter, BAD_CAST("columns"));
+ for (const auto& rColumn : maColumns)
+ rColumn.dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+
+ xmlTextWriterStartElement(pWriter, BAD_CAST("rows"));
+ for (const auto& rRow : maRows)
+ rRow.dumpAsXml(pWriter);
+ xmlTextWriterEndElement(pWriter);
+
+ xmlTextWriterEndElement(pWriter);
+}
+
+void TableLayouter::Layout::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+ xmlTextWriterStartElement(pWriter, BAD_CAST("layout"));
+
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("pos"), BAD_CAST(OString::number(mnPos).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::number(mnSize).getStr()));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("minSize"), BAD_CAST(OString::number(mnMinSize).getStr()));
+
+ xmlTextWriterEndElement(pWriter);
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/table/tablelayouter.hxx b/svx/source/table/tablelayouter.hxx
index 82b84685eb1d..9cd73599cb6d 100644
--- a/svx/source/table/tablelayouter.hxx
+++ b/svx/source/table/tablelayouter.hxx
@@ -97,6 +97,7 @@ public:
void DistributeColumns( ::Rectangle& rArea, sal_Int32 nFirstCol, sal_Int32 nLastCol );
void DistributeRows( ::Rectangle& rArea, sal_Int32 nFirstRow, sal_Int32 nLastRow );
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
CellRef getCell( const CellPos& rPos ) const;
@@ -126,6 +127,7 @@ private:
Layout() : mnPos( 0 ), mnSize( 0 ), mnMinSize( 0 ) {}
void clear() { mnPos = 0; mnSize = 0; mnMinSize = 0; }
+ void dumpAsXml(struct _xmlTextWriter* pWriter) const;
};
typedef std::vector< Layout > LayoutVector;
diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx
index c81572018a34..0bef744e5285 100644
--- a/svx/source/table/tablemodel.cxx
+++ b/svx/source/table/tablemodel.cxx
@@ -338,6 +338,13 @@ sal_Int32 SAL_CALL TableModel::getColumnCount() throw (RuntimeException, std::ex
return getColumnCountImpl();
}
+std::vector<sal_Int32> TableModel::getColumnWidths()
+{
+ std::vector<sal_Int32> aRet;
+ for (const TableColumnRef& xColumn : maColumns)
+ aRet.push_back(xColumn->getWidth());
+ return aRet;
+}
// XComponent
diff --git a/svx/source/table/tablemodel.hxx b/svx/source/table/tablemodel.hxx
index 32d59735e805..cf9d2535ad49 100644
--- a/svx/source/table/tablemodel.hxx
+++ b/svx/source/table/tablemodel.hxx
@@ -82,6 +82,8 @@ public:
/// merges the cell at the given position with the given span
void merge( sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan );
+ /// Get the width of all columns in this table.
+ std::vector<sal_Int32> getColumnWidths();
// ICellRange
virtual sal_Int32 getLeft() override;
diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx
index 59d08a2edbf2..eb0184780615 100644
--- a/svx/source/table/tableundo.cxx
+++ b/svx/source/table/tableundo.cxx
@@ -423,6 +423,9 @@ void TableColumnUndo::setData( const Data& rData )
mxCol->mbIsVisible = rData.mbIsVisible;
mxCol->mbIsStartOfNewPage = rData.mbIsStartOfNewPage;
mxCol->maName = rData.maName;
+
+ // Trigger re-layout of the table.
+ mxCol->getModel()->setModified(true);
}