[Libreoffice-commits] core.git: include/o3tl sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 27 05:40:22 UTC 2019
include/o3tl/sorted_vector.hxx | 10 +++++
sw/source/core/access/acctable.cxx | 74 +------------------------------------
2 files changed, 12 insertions(+), 72 deletions(-)
New commits:
commit 4edf078a77167d0fb5201f857146d95a901a809e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Nov 25 15:41:57 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Nov 27 06:39:02 2019 +0100
tdf#108642 simplify comparison data calculation
Complex table-based writer doc with sidebar slow to open.
We are only using the extent data in SwAccessibleTableData_Impl as a
comparison method to see if that table structure has changed.
So just compare the rows and columns arrays instead of calculating
extents.
The downside is that we might fire events a little more often.
This takes the opening time from 17s to 10s for me.
Change-Id: I936cbc01072345d6360c0ec162de20b3111a588e
Reviewed-on: https://gerrit.libreoffice.org/83682
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/o3tl/sorted_vector.hxx b/include/o3tl/sorted_vector.hxx
index 102287d52a21..088f5a2aa214 100644
--- a/include/o3tl/sorted_vector.hxx
+++ b/include/o3tl/sorted_vector.hxx
@@ -198,6 +198,16 @@ public:
return (ret.second) ? ret.first : m_vector.end();
}
+ bool operator==(const sorted_vector & other) const
+ {
+ return m_vector == other.m_vector;
+ }
+
+ bool operator!=(const sorted_vector & other) const
+ {
+ return m_vector != other.m_vector;
+ }
+
void insert(sorted_vector<Value,Compare,Find> const& rOther)
{
// optimization for the rather common case that we are overwriting this with the contents
diff --git a/sw/source/core/access/acctable.cxx b/sw/source/core/access/acctable.cxx
index 426d448327f3..3de840d534ff 100644
--- a/sw/source/core/access/acctable.cxx
+++ b/sw/source/core/access/acctable.cxx
@@ -77,14 +77,12 @@ class SwAccessibleTableData_Impl
SwAccessibleMap& mrAccMap;
Int32Set_Impl maRows;
Int32Set_Impl maColumns;
- std::vector < Int32Pair_Impl > maExtents; // cell extends for event processing only
Point maTabFramePos;
const SwTabFrame *mpTabFrame;
bool const mbIsInPagePreview;
bool const mbOnlyTableColumnHeader;
void CollectData( const SwFrame *pFrame );
- void CollectExtents( const SwFrame *pFrame );
bool FindCell( const Point& rPos, const SwFrame *pFrame ,
bool bExact, const SwFrame *& rFrame ) const;
@@ -130,11 +128,6 @@ public:
void CheckRowAndCol( sal_Int32 nRow, sal_Int32 nCol,
SwAccessibleTable *pThis ) const;
- void GetRowColumnAndExtent( const SwRect& rBox,
- sal_Int32& rRow, sal_Int32& rColumn,
- sal_Int32& rRowExtent,
- sal_Int32& rColumnExtent ) const;
-
const Point& GetTablePos() const { return maTabFramePos; }
void SetTablePos( const Point& rPos ) { maTabFramePos = rPos; }
};
@@ -173,42 +166,6 @@ void SwAccessibleTableData_Impl::CollectData( const SwFrame *pFrame )
}
}
-void SwAccessibleTableData_Impl::CollectExtents( const SwFrame *pFrame )
-{
- const SwAccessibleChildSList aList( *pFrame, mrAccMap );
- SwAccessibleChildSList::const_iterator aIter( aList.begin() );
- SwAccessibleChildSList::const_iterator aEndIter( aList.end() );
- while( aIter != aEndIter )
- {
- const SwAccessibleChild& rLower = *aIter;
- const SwFrame *pLower = rLower.GetSwFrame();
- if( pLower )
- {
- if( pLower->IsCellFrame() &&
- rLower.IsAccessible( mbIsInPagePreview ) )
- {
- sal_Int32 nRow, nCol;
- Int32Pair_Impl aCellExtents;
- GetRowColumnAndExtent( pLower->getFrameArea(), nRow, nCol,
- aCellExtents.first,
- aCellExtents.second );
-
- maExtents.push_back( aCellExtents );
- }
- else
- {
- // #i77106#
- if ( !pLower->IsRowFrame() ||
- IncludeRow( *pLower ) )
- {
- CollectExtents( pLower );
- }
- }
- }
- ++aIter;
- }
-}
-
bool SwAccessibleTableData_Impl::FindCell(
const Point& rPos, const SwFrame *pFrame, bool bExact,
const SwFrame *& rRet ) const
@@ -396,10 +353,8 @@ inline sal_Int32 SwAccessibleTableData_Impl::GetColumnCount() const
bool SwAccessibleTableData_Impl::CompareExtents(
const SwAccessibleTableData_Impl& rCmp ) const
{
- if( maExtents.size() != rCmp.maExtents.size() )
- return false;
-
- return std::equal(maExtents.begin(), maExtents.end(), rCmp.maExtents.begin());
+ return maRows == rCmp.maRows
+ && maColumns == rCmp.maColumns;
}
SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap,
@@ -413,7 +368,6 @@ SwAccessibleTableData_Impl::SwAccessibleTableData_Impl( SwAccessibleMap& rAccMap
, mbOnlyTableColumnHeader( bOnlyTableColumnHeader )
{
CollectData( mpTabFrame );
- CollectExtents( mpTabFrame );
}
inline Int32Set_Impl::const_iterator SwAccessibleTableData_Impl::GetRowIter(
@@ -454,30 +408,6 @@ void SwAccessibleTableData_Impl::CheckRowAndCol(
}
}
-void SwAccessibleTableData_Impl::GetRowColumnAndExtent(
- const SwRect& rBox,
- sal_Int32& rRow, sal_Int32& rColumn,
- sal_Int32& rRowExtent, sal_Int32& rColumnExtent ) const
-{
- Int32Set_Impl::const_iterator aStt(
- maRows.lower_bound( rBox.Top() - maTabFramePos.Y() ) );
- Int32Set_Impl::const_iterator aEnd(
- maRows.upper_bound( rBox.Bottom() - maTabFramePos.Y() ) );
- rRow =
- static_cast< sal_Int32 >( std::distance( maRows.begin(), aStt ) );
- sal_Int32 nRowEnd =
- static_cast< sal_Int32 >( std::distance( maRows.begin(), aEnd ) );
- rRowExtent = nRowEnd - rRow;
-
- aStt = maColumns.lower_bound( rBox.Left() - maTabFramePos.X() );
- aEnd = maColumns.upper_bound( rBox.Right() - maTabFramePos.X() );
- rColumn =
- static_cast< sal_Int32 >( std::distance( maColumns.begin(), aStt ) );
- sal_Int32 nColumnEnd =
- static_cast< sal_Int32 >( std::distance( maColumns.begin(), aEnd ) );
- rColumnExtent = nColumnEnd - rColumn;
-}
-
namespace {
class SwAccSingleTableSelHander_Impl : public SwAccTableSelHander_Impl
More information about the Libreoffice-commits
mailing list