diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-11-17 22:33:28 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-11-17 23:49:04 +0100 |
commit | 05896a16412dd48d19ffd2e360ae7da5e41c2725 (patch) | |
tree | eb9ff3428b6175c0c9f5cacfeb762fdcd00b87d9 /sc | |
parent | 510f463099272cec7f2193f3ffa1dbbd20d9f718 (diff) |
sc: loplugin:badstatics
Not sure if there would be a performance penalty to re-loading these
icons every time, so move the static map from
ScIconSetFormat::getBitmap() to a member of ScDocument.
Change-Id: If560d70cea27e25396dd821d9e77a785e3b79820
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/colorscale.hxx | 6 | ||||
-rw-r--r-- | sc/inc/document.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 10 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 20 |
6 files changed, 37 insertions, 17 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index a593e4ddaf78..427bf53413b0 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -30,6 +30,10 @@ struct ScDataBarInfo; class BitmapEx; class ScFormulaListener; +namespace sc { + class IconSetBitmapMap : public std::map<sal_Int32, BitmapEx> {}; +} + // don't change the order // they are also used in the dialog to determine the position // in the list box @@ -375,7 +379,7 @@ public: virtual condformat::ScFormatEntryType GetType() const override; static ScIconSetMap* getIconSetMap(); - static BitmapEx& getBitmap( ScIconSetType eType, sal_Int32 nIndex ); + static BitmapEx& getBitmap(sc::IconSetBitmapMap &, ScIconSetType eType, sal_Int32 nIndex); typedef ScIconSetFormatData::Entries_t::iterator iterator; typedef ScIconSetFormatData::Entries_t::const_iterator const_iterator; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 1fc5d2df62bc..72a2d2dcf0cd 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -79,6 +79,7 @@ class RefMovedHint; struct SortUndoParam; struct ReorderParam; class FormulaGroupAreaListener; +class IconSetBitmapMap; } @@ -467,6 +468,8 @@ private: bool mbUseEmbedFonts; + std::unique_ptr<sc::IconSetBitmapMap> m_pIconSetBitmapMap; + public: bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder); void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, bool &pbLeftEdge); @@ -1872,6 +1875,8 @@ public: std::set<Color> GetDocColors(); + sc::IconSetBitmapMap& GetIconSetBitmapMap(); + private: ScDocument(const ScDocument& r) = delete; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 2fc9a6443069..42904e108004 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -1333,10 +1333,9 @@ static const ScIconSetBitmapMap aBitmapMap[] = { } -BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType eType, sal_Int32 nIndex ) +BitmapEx& ScIconSetFormat::getBitmap(sc::IconSetBitmapMap & rIconSetBitmapMap, + ScIconSetType const eType, sal_Int32 const nIndex) { - static std::map< sal_Int32, BitmapEx > aIconSetBitmaps; - sal_Int32 nBitmap = -1; for(size_t i = 0; i < SAL_N_ELEMENTS(aBitmapMap); ++i) @@ -1349,13 +1348,13 @@ BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType eType, sal_Int32 nIndex ) } assert( nBitmap != -1 ); - std::map<sal_Int32, BitmapEx>::iterator itr = aIconSetBitmaps.find( nBitmap ); - if(itr != aIconSetBitmaps.end()) + std::map<sal_Int32, BitmapEx>::iterator itr = rIconSetBitmapMap.find(nBitmap); + if (itr != rIconSetBitmapMap.end()) return itr->second; BitmapEx aBitmap = BitmapEx(ScResId(nBitmap)); std::pair<sal_Int32, BitmapEx> aPair( nBitmap, aBitmap ); - std::pair<std::map<sal_Int32, BitmapEx>::iterator, bool> itrNew = aIconSetBitmaps.insert(aPair); + std::pair<std::map<sal_Int32, BitmapEx>::iterator, bool> itrNew = rIconSetBitmapMap.insert(aPair); assert(itrNew.second); return itrNew.first->second; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index d0a960e4b445..dd554ec7e462 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1406,4 +1406,14 @@ ScStyleSheet* ScDocument::GetPreviewCellStyle( SCCOL nCol, SCROW nRow, SCTAB nTa pRet = pPreviewCellStyle; return pRet; } + +sc::IconSetBitmapMap& ScDocument::GetIconSetBitmapMap() +{ + if (!m_pIconSetBitmapMap) + { + m_pIconSetBitmapMap.reset(new sc::IconSetBitmapMap); + } + return *m_pIconSetBitmapMap; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 059fbb5eb76d..51c0a6b47ed7 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -1418,7 +1418,7 @@ ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( vcl::Window* pParent, ScIconSetT maEdEntry( VclPtr<Edit>::Create( this, ScResId( ED_ICON_SET_ENTRY_VALUE ) ) ), maLbEntryType( VclPtr<ListBox>::Create( this, ScResId( LB_ICON_SET_ENTRY_TYPE ) ) ) { - maImgIcon->SetImage(Image(ScIconSetFormat::getBitmap(eType, i))); + maImgIcon->SetImage(Image(ScIconSetFormat::getBitmap(pDoc->GetIconSetBitmapMap(), eType, i))); if(pEntry) { switch(pEntry->GetType()) diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 12970ceb0dee..16e24992f9fd 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -873,24 +873,26 @@ void drawDataBars(vcl::RenderContext& rRenderContext, const ScDataBarInfo* pOldD } } -BitmapEx& getIcon( ScIconSetType eType, sal_Int32 nIndex ) +BitmapEx& getIcon(sc::IconSetBitmapMap & rIconSetBitmapMap, ScIconSetType eType, sal_Int32 nIndex) { - return ScIconSetFormat::getBitmap( eType, nIndex ); + return ScIconSetFormat::getBitmap(rIconSetBitmapMap, eType, nIndex); } -void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* pOldIconSetInfo, const Rectangle& rRect, long nOneX, long nOneY) +void drawIconSets(vcl::RenderContext& rRenderContext, const ScIconSetInfo* pOldIconSetInfo, const Rectangle& rRect, long nOneX, long nOneY, + sc::IconSetBitmapMap & rIconSetBitmapMap) { //long nSize = 16; ScIconSetType eType = pOldIconSetInfo->eIconSetType; sal_Int32 nIndex = pOldIconSetInfo->nIconIndex; - BitmapEx& rIcon = getIcon( eType, nIndex ); + BitmapEx& rIcon = getIcon(rIconSetBitmapMap, eType, nIndex); long aOrigSize = std::max<long>(0,std::min(rRect.GetSize().getWidth() - 4 * nOneX, rRect.GetSize().getHeight() -4 * nOneY)); rRenderContext.DrawBitmapEx( Point( rRect.Left() + 2 * nOneX, rRect.Top() + 2 * nOneY), Size(aOrigSize, aOrigSize), rIcon ); } void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const SvxBrushItem* pBackground, const Color*& pOldColor, const SvxBrushItem*& pOldBackground, Rectangle& rRect, long nPosX, long nLayoutSign, long nOneX, long nOneY, const ScDataBarInfo* pDataBarInfo, const ScDataBarInfo*& pOldDataBarInfo, - const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& pOldIconSetInfo) + const ScIconSetInfo* pIconSetInfo, const ScIconSetInfo*& pOldIconSetInfo, + sc::IconSetBitmapMap & rIconSetBitmapMap) { long nSignedOneX = nOneX * nLayoutSign; // need to paint if old color scale has been used and now @@ -907,7 +909,7 @@ void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const Sv if( pOldDataBarInfo ) drawDataBars(rRenderContext, pOldDataBarInfo, rRect, nOneX, nOneY); if( pOldIconSetInfo ) - drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY); + drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY, rIconSetBitmapMap); rRect.Left() = nPosX - nSignedOneX; } @@ -927,7 +929,7 @@ void drawCells(vcl::RenderContext& rRenderContext, const Color* pColor, const Sv if( pOldDataBarInfo ) drawDataBars(rRenderContext, pOldDataBarInfo, rRect, nOneX, nOneY); if( pOldIconSetInfo ) - drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY); + drawIconSets(rRenderContext, pOldIconSetInfo, rRect, nOneX, nOneY, rIconSetBitmapMap); rRect.Left() = nPosX - nSignedOneX; } @@ -1087,7 +1089,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext) if (bWorksInPixels) nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 0)).X(); - drawCells(rRenderContext, pColor, pBackground, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, pDataBarInfo, pOldDataBarInfo, pIconSetInfo, pOldIconSetInfo); + drawCells(rRenderContext, pColor, pBackground, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, pDataBarInfo, pOldDataBarInfo, pIconSetInfo, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap()); // extend for all merged cells nMergedCells = 1; @@ -1111,7 +1113,7 @@ void ScOutputData::DrawBackground(vcl::RenderContext& rRenderContext) if (bWorksInPixels) nPosXLogic = rRenderContext.PixelToLogic(Point(nPosX, 0)).X(); - drawCells(rRenderContext, nullptr, nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo); + drawCells(rRenderContext, nullptr, nullptr, pOldColor, pOldBackground, aRect, nPosXLogic, nLayoutSign, nOneXLogic, nOneYLogic, nullptr, pOldDataBarInfo, nullptr, pOldIconSetInfo, mpDoc->GetIconSetBitmapMap()); nArrY += nSkip; } |