[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 2 commits - sc/source sw/source
Ursache Vladimir
ursache at collabora.co.uk
Fri Feb 13 16:51:32 PST 2015
sc/source/core/data/document10.cxx | 58 ++++++++++---------------------------
sw/source/core/doc/docfmt.cxx | 57 ++++++++++--------------------------
2 files changed, 32 insertions(+), 83 deletions(-)
New commits:
commit 5fb88fddb856f53e0b187a3cf2ca98c9b83e874c
Author: Ursache Vladimir <ursache at collabora.co.uk>
Date: Fri Feb 13 21:56:43 2015 +0200
related tdf#89004 improve performance of document data collection
Change-Id: Ieca50aa0920753cd952123e27d5355d32e82c918
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 5a82a57..8ff95c6 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1922,53 +1922,28 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const OUString & sNewName,
BroadcastStyleOperation(sNewName, eFamily, SFX_STYLESHEET_MODIFIED);
}
-
std::vector<Color> SwDoc::GetDocColors()
{
- std::vector<Color> docColors;
-
- for(unsigned int i = 0; i < m_pNodes->Count(); ++i)
+ std::vector<Color> aDocColors;
+ SwAttrPool& rPool = GetAttrPool();
+ const sal_uInt16 pAttribs[] = {RES_CHRATR_COLOR, RES_CHRATR_HIGHLIGHT, RES_BACKGROUND};
+ for (size_t i=0; i<SAL_N_ELEMENTS(pAttribs); i++)
{
- const SwNode* pNode = (*m_pNodes)[i];
- if( ! pNode->IsTxtNode() )
- continue;
-
- const SfxItemSet* pItemSet = pNode->GetTxtNode()->GetpSwAttrSet();
- if( pItemSet == 0 )
- continue;
-
- SfxWhichIter aIter( *pItemSet );
- sal_uInt16 nWhich = aIter.FirstWhich();
- while( nWhich )
+ const sal_uInt16 nAttrib = pAttribs[i];
+ const sal_uInt32 nCount = rPool.GetItemCount2(nAttrib);
+ for (sal_uInt32 j=0; j<nCount; j++)
{
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == pItemSet->GetItemState( nWhich, false, &pItem ) )
- {
- sal_uInt16 aWhich = pItem->Which();
- switch (aWhich)
- {
- // list of color attributes to collect
- case RES_CHRATR_COLOR:
- case RES_CHRATR_HIGHLIGHT:
- case RES_BACKGROUND:
- {
- Color aColor( static_cast<const SvxColorItem*>(pItem)->GetValue() );
- if( COL_AUTO != aColor.GetColor() &&
- std::find(docColors.begin(), docColors.end(), aColor) == docColors.end() )
- {
- docColors.push_back( aColor );
- }
- }
- break;
- default:
- break;
- }
- }
-
- nWhich = aIter.NextWhich();
+ const SvxColorItem *pItem = static_cast<const SvxColorItem*>(rPool.GetItem2(nAttrib, j));
+ if (pItem == 0)
+ continue;
+ Color aColor( pItem->GetValue() );
+ if (COL_AUTO == aColor.GetColor())
+ continue;
+ if (std::find(aDocColors.begin(), aDocColors.end(), aColor) == aDocColors.end())
+ aDocColors.push_back(aColor);
}
}
- return docColors;
+ return aDocColors;
}
// #i69627#
commit e7672e9633d0fe23917a2a348e77808a40ae0942
Author: Ursache Vladimir <ursache at collabora.co.uk>
Date: Fri Feb 13 06:23:53 2015 +0200
tdf#89004 improve performance of document data collection
Change-Id: Ie74495745b48d721c7dda0b447fc59066c869874
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 0a2e3cb..362acbf 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -19,6 +19,7 @@
#include <poolhelp.hxx>
#include <bcaslot.hxx>
#include <cellvalues.hxx>
+#include <docpool.hxx>
#include "dociter.hxx"
#include "patattr.hxx"
@@ -157,53 +158,26 @@ void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellVal
std::vector<Color> ScDocument::GetDocColors()
{
- std::vector<Color> docColors;
-
- for( unsigned int nTabIx = 0; nTabIx < maTabs.size(); ++nTabIx )
+ std::vector<Color> aDocColors;
+ ScDocumentPool *pPool = GetPool();
+ const sal_uInt16 pAttribs[] = {ATTR_BACKGROUND, ATTR_FONT_COLOR};
+ for (size_t i=0; i<SAL_N_ELEMENTS( pAttribs ); i++)
{
- ScUsedAreaIterator aIt(this, nTabIx, 0, 0, MAXCOLCOUNT-1, MAXROWCOUNT-1);
-
- for( bool bIt = aIt.GetNext(); bIt; bIt = aIt.GetNext() )
+ const sal_uInt16 nAttrib = pAttribs[i];
+ const sal_uInt32 nCount = pPool->GetItemCount2(nAttrib);
+ for (sal_uInt32 j=0; j<nCount; j++)
{
- const ScPatternAttr* pPattern = aIt.GetPattern();
-
- if( pPattern == 0 )
+ const SvxColorItem *pItem = static_cast<const SvxColorItem*>(pPool->GetItem2(nAttrib, j));
+ if (pItem == 0)
continue;
-
- const SfxItemSet& rItemSet = pPattern->GetItemSet();
-
- SfxWhichIter aIter( rItemSet );
- sal_uInt16 nWhich = aIter.FirstWhich();
- while( nWhich )
- {
- const SfxPoolItem *pItem;
- if( SfxItemState::SET == rItemSet.GetItemState( nWhich, false, &pItem ) )
- {
- sal_uInt16 aWhich = pItem->Which();
- switch (aWhich)
- {
- // attributes we want to collect
- case ATTR_FONT_COLOR:
- case ATTR_BACKGROUND:
- {
- Color aColor( static_cast<const SvxColorItem*>(pItem)->GetValue() );
- if( COL_AUTO != aColor.GetColor() &&
- std::find(docColors.begin(), docColors.end(), aColor) == docColors.end() )
- {
- docColors.push_back( aColor );
- }
- }
- break;
- default:
- break;
- }
- }
-
- nWhich = aIter.NextWhich();
- }
+ Color aColor( pItem->GetValue() );
+ if (COL_AUTO == aColor.GetColor())
+ continue;
+ if (std::find(aDocColors.begin(), aDocColors.end(), aColor) == aDocColors.end())
+ aDocColors.push_back(aColor);
}
}
- return docColors;
+ return aDocColors;
}
void ScDocument::SetCalcConfig( const ScCalcConfig& rConfig )
More information about the Libreoffice-commits
mailing list