diff options
author | David Tardon <dtardon@redhat.com> | 2013-03-22 16:49:41 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2013-03-23 08:09:44 +0100 |
commit | 91864e19c84ae9834d6e97ee5ddc4db5bf957681 (patch) | |
tree | 4cb75ff52dd6d760d68315b03c2ea538f3949b84 /svx/source | |
parent | e3ad376f601d3abfc1b9e47dc0419d52785bd9b9 (diff) |
rhbz#876742 speed up table manipulation in Impress
It turns out this is not actually a performance problem but an oversight
in implementation (or a bug, if you want .-)
Every manipulation with a table (e.g., move, resize; actually even a
selection of the table) leads to creation of a full copy of the table
(SdrObject::getFullDragClone()). One of the actions the table copy impl.
does is to call sdr::CellProperties::SetStyleSheet() on every cell of
the new table. CellProperties is derived from
sdr::properties::TextProperties and CellProperties::SetStyleSheet() just
passes the call to TextProperties::SetStyleSheet(). This is where the
trouble begins :-)
The SDR representation of a table, SdrTableObj, is derived from
SdrTextObj. Because of that, SdrTextObj needs to be able to contain more
than one SdrText (because a table needs one for every cell). This is
handled correctly by TextProperties. But, because there is no SDR
representation of a single cell, CellProperties uses the SdrTableObj as
the SDR object it works on. Therefore TextProperties::SetStyleSheet()
processes all SdrText objects of the _whole table_, not just a single
cell. And this is repeated for every other cell...
Change-Id: Iab2e2d0e1e8038710645c0bd24666e6032b0a003
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/sdr/properties/textproperties.cxx | 38 | ||||
-rw-r--r-- | svx/source/table/cell.cxx | 52 |
2 files changed, 76 insertions, 14 deletions
diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index e4b7f5f56e6b..156268f95b9c 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -82,14 +82,15 @@ namespace sdr void TextProperties::ItemSetChanged(const SfxItemSet& rSet) { SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); - sal_Int32 nText = rObj.getTextCount(); + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); // #i101556# ItemSet has changed -> new version maVersion++; while( --nText >= 0 ) { - SdrText* pText = rObj.getText( nText ); + SdrText* pText = rTextProvider.getText( nText ); OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; @@ -170,10 +171,11 @@ namespace sdr { SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); - sal_Int32 nCount = rObj.getTextCount(); + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nCount = rTextProvider.getTextCount(); while( nCount-- ) { - SdrText* pText = rObj.getText( nCount ); + SdrText* pText = rTextProvider.getText( nCount ); OutlinerParaObject* pParaObj = pText->GetOutlinerParaObject(); if( pParaObj ) { @@ -223,6 +225,11 @@ namespace sdr } } + const svx::ITextProvider& TextProperties::getTextProvider() const + { + return static_cast<const SdrTextObj&>(GetSdrObject()); + } + void TextProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) { SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); @@ -237,11 +244,12 @@ namespace sdr { SdrOutliner& rOutliner = rObj.ImpGetDrawOutliner(); - sal_Int32 nText = rObj.getTextCount(); + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); while( --nText >= 0 ) { - SdrText* pText = rObj.getText( nText ); + SdrText* pText = rTextProvider.getText( nText ); OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; if( !pParaObj ) @@ -396,11 +404,12 @@ namespace sdr && !rObj.IsLinkedText()) { Outliner* pOutliner = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, rObj.GetModel()); - sal_Int32 nText = rObj.getTextCount(); + const svx::ITextProvider& rTextProvider(getTextProvider()); + sal_Int32 nText = rTextProvider.getTextCount(); while( --nText >= 0 ) { - SdrText* pText = rObj.getText( nText ); + SdrText* pText = rTextProvider.getText( nText ); OutlinerParaObject* pParaObj = pText ? pText->GetOutlinerParaObject() : 0; if( !pParaObj ) @@ -542,6 +551,7 @@ namespace sdr SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); if(rObj.HasText()) { + const svx::ITextProvider& rTextProvider(getTextProvider()); if(HAS_BASE(SfxStyleSheet, &rBC)) { SfxSimpleHint* pSimple = PTR_CAST(SfxSimpleHint, &rHint); @@ -551,10 +561,10 @@ namespace sdr { rObj.SetPortionInfoChecked(sal_False); - sal_Int32 nText = rObj.getTextCount(); + sal_Int32 nText = rTextProvider.getTextCount(); while( --nText > 0 ) { - OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); if( pParaObj ) pParaObj->ClearPortionInfo(); } @@ -574,10 +584,10 @@ namespace sdr if(SFX_HINT_DYING == nId) { rObj.SetPortionInfoChecked(sal_False); - sal_Int32 nText = rObj.getTextCount(); + sal_Int32 nText = rTextProvider.getTextCount(); while( --nText > 0 ) { - OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); if( pParaObj ) pParaObj->ClearPortionInfo(); } @@ -596,10 +606,10 @@ namespace sdr if(!aOldName.Equals(aNewName)) { - sal_Int32 nText = rObj.getTextCount(); + sal_Int32 nText = rTextProvider.getTextCount(); while( --nText > 0 ) { - OutlinerParaObject* pParaObj = rObj.getText(nText )->GetOutlinerParaObject(); + OutlinerParaObject* pParaObj = rTextProvider.getText( nText )->GetOutlinerParaObject(); if( pParaObj ) pParaObj->ChangeStyleSheetName(eFamily, aOldName, aNewName); } diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index e46b4865fb50..3a33a282b9ec 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -99,6 +99,46 @@ static const SvxItemPropertySet* ImplGetSvxCellPropertySet() return &aSvxCellPropertySet; } +namespace +{ + +class CellTextProvider : public svx::ITextProvider +{ +public: + explicit CellTextProvider(const sdr::table::CellRef xCell); + virtual ~CellTextProvider(); + +private: + virtual sal_Int32 getTextCount() const; + virtual SdrText* getText(sal_Int32 nIndex) const; + +private: + const sdr::table::CellRef m_xCell; +}; + +CellTextProvider::CellTextProvider(const sdr::table::CellRef xCell) + : m_xCell(xCell) +{ +} + +CellTextProvider::~CellTextProvider() +{ +} + +sal_Int32 CellTextProvider::getTextCount() const +{ + return 1; +} + +SdrText* CellTextProvider::getText(sal_Int32 nIndex) const +{ + (void) nIndex; + assert(nIndex == 0); + return m_xCell.get(); +} + +} + namespace sdr { namespace properties @@ -109,6 +149,8 @@ namespace sdr // create a new itemset SfxItemSet& CreateObjectSpecificItemSet(SfxItemPool& rPool); + const svx::ITextProvider& getTextProvider() const; + public: // basic constructor CellProperties(SdrObject& rObj, sdr::table::Cell* pCell ); @@ -131,6 +173,9 @@ namespace sdr void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr); sdr::table::CellRef mxCell; + + private: + const CellTextProvider maTextProvider; }; // create a new itemset @@ -153,15 +198,22 @@ namespace sdr 0, 0)); } + const svx::ITextProvider& CellProperties::getTextProvider() const + { + return maTextProvider; + } + CellProperties::CellProperties(SdrObject& rObj, sdr::table::Cell* pCell) : TextProperties(rObj) , mxCell(pCell) + , maTextProvider(mxCell) { } CellProperties::CellProperties(const CellProperties& rProps, SdrObject& rObj, sdr::table::Cell* pCell) : TextProperties(rProps, rObj) , mxCell( pCell ) + , maTextProvider(mxCell) { } |