sc/inc/colorscale.hxx | 2 sc/inc/sc.hrc | 7 - sc/source/core/data/colorscale.cxx | 129 ++++++++++++++++++ sc/source/filter/inc/orcusinterface.hxx | 23 +++ sc/source/filter/orcus/interface.cxx | 101 +++++++++++++- sc/source/ui/condformat/condformatdlg.cxx | 9 + sc/source/ui/condformat/condformatdlgentry.cxx | 172 +++++++++++++++++++++++++ sc/source/ui/inc/condformatdlg.hrc | 7 + sc/source/ui/inc/condformatdlgentry.hxx | 40 +++++ sc/source/ui/src/condformatdlg.src | 71 ++++++++++ sc/source/ui/view/output.cxx | 121 ----------------- 11 files changed, 547 insertions(+), 135 deletions(-)
New commits: commit 704fdf2b23d0e0480f29e0e56f631c2835eed02b Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Dec 2 05:57:33 2012 +0100 create icon sets in UI Change-Id: I6c55cc1d1a1dbd4839b823df08f8c42a7b880132 diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 3d41971..86dec0d 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -1259,6 +1259,40 @@ ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pPar FreeResource(); } +ScColorScaleEntry* ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const +{ + sal_Int32 nPos = maLbEntryType.GetSelectEntryPos(); + rtl::OUString aText = maEdEntry.GetText(); + ScColorScaleEntry* pEntry = new ScColorScaleEntry(); + + sal_uInt32 nIndex = 0; + double nVal = 0; + SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable(); + pNumberFormatter->IsNumberFormat(aText, nIndex, nVal); + pEntry->SetValue(nVal); + + switch(nPos) + { + case 0: + pEntry->SetType(COLORSCALE_VALUE); + break; + case 1: + pEntry->SetType(COLORSCALE_PERCENT); + break; + case 2: + pEntry->SetType(COLORSCALE_PERCENTILE); + break; + case 3: + pEntry->SetType(COLORSCALE_FORMULA); + pEntry->SetFormula(aText, pDoc, rPos, pDoc->GetGrammar()); + break; + default: + assert(false); + } + + return pEntry; +} + ScIconSetFrmtEntry::ScIconSetFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat ): ScCondFrmtEntry( pParent, pDoc, rPos ), maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ), @@ -1317,7 +1351,7 @@ IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl ) OUString ScIconSetFrmtEntry::GetExpressionString() { - return OUString(""); + return ScCondFormatHelper::GetExpression(ICONSET, 0); } void ScIconSetFrmtEntry::SetActive() @@ -1348,7 +1382,18 @@ void ScIconSetFrmtEntry::SetInactive() ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const { - return NULL; + ScIconSetFormat* pFormat = new ScIconSetFormat(mpDoc); + + ScIconSetFormatData* pData = new ScIconSetFormatData; + pData->eIconSetType = static_cast<ScIconSetType>(maLbIconSetType.GetSelectEntryPos()); + for(ScIconSetFrmtDateEntriesType::const_iterator itr = maEntries.begin(), + itrEnd = maEntries.end(); itr != itrEnd; ++itr) + { + pData->maEntries.push_back(itr->CreateEntry(mpDoc, maPos)); + } + pFormat->SetIconSetData(pData); + + return pFormat; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx index 7017cd9..99d602c 100644 --- a/sc/source/ui/inc/condformatdlgentry.hxx +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -258,6 +258,8 @@ class ScIconSetFrmtEntry : public ScCondFrmtEntry public: ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i, const ScColorScaleEntry* pEntry = NULL ); + + ScColorScaleEntry* CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const; }; typedef boost::ptr_vector<ScIconSetFrmtDataEntry> ScIconSetFrmtDateEntriesType; ScIconSetFrmtDateEntriesType maEntries; commit f7cd8c619ef3db4b3a41b25eb9c4e5e798f2c155 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Dec 2 04:25:27 2012 +0100 correctly show existing icon sets in the UI Change-Id: I8970d3b0cc3263f46cfda45ae3b919a441bc0228 diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index b039493..3d41971 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -1224,7 +1224,7 @@ IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl ) return 0; } -ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i ): +ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i, const ScColorScaleEntry* pEntry ): Control( pParent, ScResId( RID_ICON_SET_ENTRY ) ), maImgIcon( this, ScResId( IMG_ICON ) ), maFtEntry( this, ScResId( FT_ICON_SET_ENTRY_TEXT ) ), @@ -1232,6 +1232,30 @@ ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pPar maLbEntryType( this, ScResId( LB_ICON_SET_ENTRY_TYPE ) ) { maImgIcon.SetImage(ScIconSetFormat::getBitmap( eType, i )); + if(pEntry) + { + switch(pEntry->GetType()) + { + case COLORSCALE_VALUE: + maLbEntryType.SelectEntryPos(0); + maEdEntry.SetText(OUString::valueOf(pEntry->GetValue())); + break; + case COLORSCALE_PERCENTILE: + maLbEntryType.SelectEntryPos(2); + maEdEntry.SetText(OUString::valueOf(pEntry->GetValue())); + break; + case COLORSCALE_PERCENT: + maLbEntryType.SelectEntryPos(1); + maEdEntry.SetText(OUString::valueOf(pEntry->GetValue())); + break; + case COLORSCALE_FORMULA: + maLbEntryType.SelectEntryPos(3); + maEdEntry.SetText(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT)); + break; + default: + assert(false); + } + } FreeResource(); } @@ -1245,10 +1269,22 @@ ScIconSetFrmtEntry::ScIconSetFrmtEntry( Window* pParent, ScDocument* pDoc, const if(pFormat) { + const ScIconSetFormatData* pIconSetFormatData = pFormat->GetIconSetData(); + ScIconSetType eType = pIconSetFormatData->eIconSetType; + sal_Int32 nType = static_cast<sal_Int32>(eType); + maLbIconSetType.SelectEntryPos(nType); + for(size_t i = 0, n = pIconSetFormatData->maEntries.size(); + i < n; ++i) + { + maEntries.push_back( new ScIconSetFrmtDataEntry( this, eType, i, &pIconSetFormatData->maEntries[i] ) ); + Point aPos = maEntries[0].GetPosPixel(); + aPos.Y() += maEntries[0].GetSizePixel().Height() * i * 1.2; + maEntries[i].SetPosPixel( aPos ); + } } - - IconSetTypeHdl(NULL); + else + IconSetTypeHdl(NULL); } void ScIconSetFrmtEntry::Init() @@ -1291,7 +1327,7 @@ void ScIconSetFrmtEntry::SetActive() for(ScIconSetFrmtDateEntriesType::iterator itr = maEntries.begin(), itrEnd = maEntries.end(); itr != itrEnd; ++itr) { - maEntries[0].Show(); + itr->Show(); } Select(); @@ -1304,7 +1340,7 @@ void ScIconSetFrmtEntry::SetInactive() for(ScIconSetFrmtDateEntriesType::iterator itr = maEntries.begin(), itrEnd = maEntries.end(); itr != itrEnd; ++itr) { - maEntries[0].Hide(); + itr->Hide(); } Deselect(); diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx index 9ef6184..7017cd9 100644 --- a/sc/source/ui/inc/condformatdlgentry.hxx +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -257,7 +257,7 @@ class ScIconSetFrmtEntry : public ScCondFrmtEntry ListBox maLbEntryType; public: - ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i ); + ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i, const ScColorScaleEntry* pEntry = NULL ); }; typedef boost::ptr_vector<ScIconSetFrmtDataEntry> ScIconSetFrmtDateEntriesType; ScIconSetFrmtDateEntriesType maEntries; commit 6efd796a303d631b263ad2177438248251c6d98e Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Sun Dec 2 03:49:28 2012 +0100 initial support for icon sets in the dialog Change-Id: I5da2500b96ba3b03bf822cf428c001204010989e diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 5907c6e..e7b611b 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -44,6 +44,7 @@ class ScDocument; class ScFormulaCell; class ScTokenArray; struct ScDataBarInfo; +class BitmapEx; // don't change the order // they are also used in the dialog to determine the position @@ -335,6 +336,7 @@ public: virtual condformat::ScFormatEntryType GetType() const; static ScIconSetMap* getIconSetMap(); + static BitmapEx& getBitmap( ScIconSetType eType, sal_Int32 nIndex ); typedef boost::ptr_vector<ScColorScaleEntry>::iterator iterator; typedef boost::ptr_vector<ScColorScaleEntry>::const_iterator const_iterator; diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 1bb2b8c..2a1113b 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1094,11 +1094,12 @@ #define RID_SCDLG_DATABAR (SC_DIALOGS_START + 155) #define RID_COND_ENTRY (SC_DIALOGS_START + 156) #define RID_SCDLG_FORMULA_CALCOPTIONS (SC_DIALOGS_START + 157) +#define RID_ICON_SET_ENTRY (SC_DIALOGS_START + 158) -#define RID_SCDLG_COND_FORMAT_MANAGER (SC_DIALOGS_START + 158) -#define RID_SCDLG_XML_SOURCE (SC_DIALOGS_START + 159) +#define RID_SCDLG_COND_FORMAT_MANAGER (SC_DIALOGS_START + 159) +#define RID_SCDLG_XML_SOURCE (SC_DIALOGS_START + 160) -#define SC_DIALOGS_END (SC_DIALOGS_START + 160) +#define SC_DIALOGS_END (SC_DIALOGS_START + 161) #ifndef STD_MASKCOLOR #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 897f1b8..2adf507 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -30,6 +30,8 @@ #include "document.hxx" #include "cell.hxx" #include "fillinfo.hxx" +#include "iconsets.hrc" +#include "scresid.hxx" #if DUMP_FORMAT_INFO #include <iostream> #endif @@ -1047,4 +1049,131 @@ ScIconSetMap* ScIconSetFormat::getIconSetMap() return aIconSetMap; } +namespace { + +sal_Int32 a3TrafficLights1[] = { + BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN +}; + +sal_Int32 a3TrafficLights2[] = { + BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN +}; + +sal_Int32 a3Arrows[] = { + BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP +}; + +sal_Int32 a3ArrowsGray[] = { + BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP +}; + +sal_Int32 a3Flags[] = { + BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN +}; + +sal_Int32 a4Arrows[] = { + BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP +}; + +sal_Int32 a4ArrowsGray[] = { + BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP +}; + +sal_Int32 a5Arrows[] = { + BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, + BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP +}; + +sal_Int32 a5ArrowsGray[] = { + BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, + BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP +}; + +sal_Int32 a4TrafficLights[] = { + BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED, + BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN +}; + +sal_Int32 a5Quarters[] = { + BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF, + BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL, +}; + +sal_Int32 a3Symbols1[] = { + BMP_ICON_SET_SYMBOLS1_CHECK, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CROSS +}; + +sal_Int32 a3Signs[] = { + BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE +}; + +sal_Int32 a4RedToBlack[] = { + BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY, + BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED +}; + +sal_Int32 a4Ratings[] = { + BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF, + BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL +}; + +sal_Int32 a5Ratings[] = { + BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF, + BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL +}; + +struct ScIconSetBitmapMap { + ScIconSetType eType; + sal_Int32* nBitmaps; +}; + +static ScIconSetBitmapMap aBitmapMap[] = { + { IconSet_3Arrows, a3Arrows }, + { IconSet_3ArrowsGray, a3ArrowsGray }, + { IconSet_3Flags, a3Flags }, + { IconSet_3Signs, a3Signs }, + { IconSet_3Symbols, a3Symbols1 }, + { IconSet_3Symbols2, a3Symbols1 }, + { IconSet_3TrafficLights1, a3TrafficLights1 }, + { IconSet_3TrafficLights2, a3TrafficLights2 }, + { IconSet_4Arrows, a4Arrows }, + { IconSet_4ArrowsGray, a4ArrowsGray }, + { IconSet_4Rating, a4Ratings }, + { IconSet_4RedToBlack, a4RedToBlack }, + { IconSet_4TrafficLights, a4TrafficLights }, + { IconSet_5Arrows, a5Arrows }, + { IconSet_5ArrowsGray, a5ArrowsGray }, + { IconSet_5Quarters, a5Quarters }, + { IconSet_5Ratings, a5Ratings } +}; + +} + +BitmapEx& ScIconSetFormat::getBitmap( ScIconSetType eType, sal_Int32 nIndex ) +{ + static std::map< sal_Int32, BitmapEx > aIconSetBitmaps; + + sal_Int32 nBitmap = -1; + + for(size_t i = 0; i < SAL_N_ELEMENTS(aBitmapMap); ++i) + { + if(aBitmapMap[i].eType == eType) + { + nBitmap = *(aBitmapMap[i].nBitmaps + nIndex); + } + } + assert( nBitmap != -1 ); + + std::map<sal_Int32, BitmapEx>::iterator itr = aIconSetBitmaps.find( nBitmap ); + if(itr != aIconSetBitmaps.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); + assert(itrNew.second); + + return itrNew.first->second; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 5212f62..8780647 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -90,6 +90,7 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum maEntries.push_back(new ScDataBarFrmtEntry( this, mpDoc, maPos, static_cast<const ScDataBarFormat*>( pEntry ) ) ); break; case condformat::ICONSET: + maEntries.push_back(new ScIconSetFrmtEntry( this, mpDoc, maPos, static_cast<const ScIconSetFormat*>( pEntry ) ) ); break; case condformat::DATE: maEntries.push_back(new ScDateFrmtEntry( this, mpDoc, static_cast<const ScCondDateFormatEntry*>( pEntry ) ) ); @@ -224,6 +225,12 @@ IMPL_LINK(ScCondFormatList, ColFormatTypeHdl, ListBox*, pBox) maEntries.replace( itr, new ScDataBarFrmtEntry( this, mpDoc, maPos ) ); break; + case 3: + if(itr->GetType() == condformat::entry::ICONSET) + return 0; + + maEntries.replace( itr, new ScIconSetFrmtEntry( this, mpDoc, maPos ) ); + break; default: break; } @@ -257,6 +264,7 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) case condformat::entry::COLORSCALE2: case condformat::entry::COLORSCALE3: case condformat::entry::DATABAR: + case condformat::entry::ICONSET: return 0; } maEntries.replace( itr, new ScColorScale3FrmtEntry(this, mpDoc, maPos)); @@ -287,6 +295,7 @@ IMPL_LINK(ScCondFormatList, TypeListHdl, ListBox*, pBox) static_cast<ScCondFormatDlg*>(GetParent())->InvalidateRefData(); itr->SetActive(); break; + } RecalcAll(); return 0; diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 59cfb92..b039493 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -1224,4 +1224,95 @@ IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl ) return 0; } +ScIconSetFrmtEntry::ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i ): + Control( pParent, ScResId( RID_ICON_SET_ENTRY ) ), + maImgIcon( this, ScResId( IMG_ICON ) ), + maFtEntry( this, ScResId( FT_ICON_SET_ENTRY_TEXT ) ), + maEdEntry( this, ScResId( ED_ICON_SET_ENTRY_VALUE ) ), + maLbEntryType( this, ScResId( LB_ICON_SET_ENTRY_TYPE ) ) +{ + maImgIcon.SetImage(ScIconSetFormat::getBitmap( eType, i )); + FreeResource(); +} + +ScIconSetFrmtEntry::ScIconSetFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat ): + ScCondFrmtEntry( pParent, pDoc, rPos ), + maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ), + maLbIconSetType( this, ScResId( LB_ICONSET_TYPE ) ) +{ + Init(); + FreeResource(); + + if(pFormat) + { + + } + + IconSetTypeHdl(NULL); +} + +void ScIconSetFrmtEntry::Init() +{ + maLbColorFormat.SelectEntryPos(3); + maLbType.SelectEntryPos(0); + maLbIconSetType.SelectEntryPos(0); + + maLbIconSetType.SetSelectHdl( LINK( this, ScIconSetFrmtEntry, IconSetTypeHdl ) ); +} + +IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl ) +{ + ScIconSetMap* pMap = ScIconSetFormat::getIconSetMap(); + + sal_Int32 nPos = maLbIconSetType.GetSelectEntryPos(); + sal_uInt32 nElements = pMap[nPos].nElements; + maEntries.clear(); + + for(size_t i = 0; i < nElements; ++i) + { + maEntries.push_back( new ScIconSetFrmtDataEntry( this, static_cast<ScIconSetType>(nPos), i ) ); + Point aPos = maEntries[0].GetPosPixel(); + aPos.Y() += maEntries[0].GetSizePixel().Height() * i * 1.2; + maEntries[i].SetPosPixel( aPos ); + } + + return 0; +} + +OUString ScIconSetFrmtEntry::GetExpressionString() +{ + return OUString(""); +} + +void ScIconSetFrmtEntry::SetActive() +{ + maLbColorFormat.Show(); + maLbIconSetType.Show(); + for(ScIconSetFrmtDateEntriesType::iterator itr = maEntries.begin(), + itrEnd = maEntries.end(); itr != itrEnd; ++itr) + { + maEntries[0].Show(); + } + + Select(); +} + +void ScIconSetFrmtEntry::SetInactive() +{ + maLbColorFormat.Hide(); + maLbIconSetType.Hide(); + for(ScIconSetFrmtDateEntriesType::iterator itr = maEntries.begin(), + itrEnd = maEntries.end(); itr != itrEnd; ++itr) + { + maEntries[0].Hide(); + } + + Deselect(); +} + +ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const +{ + return NULL; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc index b1ede3c..607404e 100644 --- a/sc/source/ui/inc/condformatdlg.hrc +++ b/sc/source/ui/inc/condformatdlg.hrc @@ -69,4 +69,11 @@ #define LB_TYPE_COL_SCALE_MAX 44 #define LB_DATE_TYPE 45 + +#define IMG_ICON 46 +#define LB_ICONSET_TYPE 47 +#define LB_ICON_SET_ENTRY_TYPE 48 +#define FT_ICON_SET_ENTRY_TEXT 49 +#define ED_ICON_SET_ENTRY_VALUE 50 + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx index b842ed2..9ef6184 100644 --- a/sc/source/ui/inc/condformatdlgentry.hxx +++ b/sc/source/ui/inc/condformatdlgentry.hxx @@ -22,6 +22,7 @@ enum ScCondFrmtEntryType COLORSCALE2, COLORSCALE3, DATABAR, + ICONSET, DATE }; @@ -239,4 +240,41 @@ private: SvxFontPrevWindow maWdPreview; }; +class ScIconSetFrmtEntry : public ScCondFrmtEntry +{ + //color format ui elements + ListBox maLbColorFormat; + + // icon set ui elements + ListBox maLbIconSetType; + + class ScIconSetFrmtDataEntry : public Control + { + private: + FixedImage maImgIcon; + FixedText maFtEntry; + Edit maEdEntry; + ListBox maLbEntryType; + + public: + ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, sal_Int32 i ); + }; + typedef boost::ptr_vector<ScIconSetFrmtDataEntry> ScIconSetFrmtDateEntriesType; + ScIconSetFrmtDateEntriesType maEntries; + + ScFormatEntry* createIconSetEntry(); + virtual rtl::OUString GetExpressionString(); + + void Init(); + + DECL_LINK( IconSetTypeHdl, void* ); + +public: + ScIconSetFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = NULL ); + virtual ScFormatEntry* GetEntry() const; + virtual void SetActive(); + virtual void SetInactive(); + virtual condformat::entry::ScCondFrmtEntryType GetType() { return condformat::entry::ICONSET; } +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src index ab98866..e0a5f25 100644 --- a/sc/source/ui/src/condformatdlg.src +++ b/sc/source/ui/src/condformatdlg.src @@ -177,14 +177,16 @@ Control RID_COND_ENTRY ListBox LB_COLOR_FORMAT { Pos = MAP_APPFONT( 100, 15 ); - Size = MAP_APPFONT( 100, 60); + Size = MAP_APPFONT( 80, 60); Border = TRUE; DropDown = TRUE; + DDExtraWidth = TRUE; StringList [ en-US ] = { "Color Scale (2 Entries)"; "Color Scale (3 Entries)"; "Data Bar"; + "Icon Set"; }; }; FixedText FT_STYLE @@ -334,6 +336,73 @@ Control RID_COND_ENTRY "Next year"; }; }; + ListBox LB_ICONSET_TYPE + { + Pos = MAP_APPFONT( 200, 15 ); + Size = MAP_APPFONT( 80, 50 ); + Border = TRUE; + DropDown = TRUE; + DDExtraWidth = TRUE; + StringList [ en-US ] = + { + "3 Arrows"; + "3 Gray Arrows"; + "3 Flags"; + "3 Traffic Lights 1"; + "3 Traffic Lights 2"; + "3 Signs"; + "3 Symbols 1"; + "3 Symbols 2"; + "4 Arrows"; + "4 Gray Arrows"; + "4 Circles Red to Black"; + "4 Ratings"; + "4 Traffic Lights"; + "5 Arrows"; + "5 Gray Arrows"; + "5 Ratings"; + "5 Quarters"; + }; + }; +}; + +Control RID_ICON_SET_ENTRY +{ + Pos = MAP_APPFONT( 0, 35 ); + Size = MAP_APPFONT(300, 16); + // Picture of the Icon + FixedImage IMG_ICON + { + Pos = MAP_APPFONT( 5, 0 ); + Size = MAP_APPFONT( 16, 16 ); + }; + FixedText FT_ICON_SET_ENTRY_TEXT + { + Pos = MAP_APPFONT( 40, 0 ); + Size = MAP_APPFONT(40, 14); + Text [en-US] = " <= "; + }; + Edit ED_ICON_SET_ENTRY_VALUE + { + Pos = MAP_APPFONT( 90, 0 ); + Size = MAP_APPFONT( 40, 14 ); + Border = TRUE; + }; + ListBox LB_ICON_SET_ENTRY_TYPE + { + Pos = MAP_APPFONT( 140, 0 ); + Size = MAP_APPFONT( 60, 40 ); + Border = TRUE; + DropDown = TRUE; + DDExtraWidth = TRUE; + StringList [ en-US ] = + { + "Value"; + "Percent"; + "Percentile"; + "Formula"; + }; + }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 16e253f..fd897f1 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -72,7 +72,6 @@ #include "postit.hxx" #include "scresid.hxx" -#include "iconsets.hrc" #include "colorscale.hxx" #include <math.h> @@ -93,103 +92,6 @@ static ColorData nAuthorColor[ SC_AUTHORCOLORCOUNT ] = { COL_GREEN, COL_RED, COL_BLUE, COL_BROWN, COL_MAGENTA, COL_CYAN }; -sal_Int32 a3TrafficLights1[] = { - BMP_ICON_SET_CIRCLES1_RED, BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN -}; - -sal_Int32 a3TrafficLights2[] = { - BMP_ICON_SET_TRAFFICLIGHTS_RED, BMP_ICON_SET_TRAFFICLIGHTS_YELLOW, BMP_ICON_SET_TRAFFICLIGHTS_GREEN -}; - -sal_Int32 a3Arrows[] = { - BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_UP -}; - -sal_Int32 a3ArrowsGray[] = { - BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_UP -}; - -sal_Int32 a3Flags[] = { - BMP_ICON_SET_FLAGS_RED, BMP_ICON_SET_FLAGS_YELLOW, BMP_ICON_SET_FLAGS_GREEN -}; - -sal_Int32 a4Arrows[] = { - BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP -}; - -sal_Int32 a4ArrowsGray[] = { - BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP -}; - -sal_Int32 a5Arrows[] = { - BMP_ICON_SET_COLORARROWS_DOWN, BMP_ICON_SET_COLORARROWS_SLIGHTLY_DOWN, - BMP_ICON_SET_COLORARROWS_SAME, BMP_ICON_SET_COLORARROWS_SLIGHTLY_UP, BMP_ICON_SET_COLORARROWS_UP -}; - -sal_Int32 a5ArrowsGray[] = { - BMP_ICON_SET_GRAYARROWS_DOWN, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_DOWN, - BMP_ICON_SET_GRAYARROWS_SAME, BMP_ICON_SET_GRAYARROWS_SLIGHTLY_UP, BMP_ICON_SET_GRAYARROWS_UP -}; - -sal_Int32 a4TrafficLights[] = { - BMP_ICON_SET_CIRCLES1_GRAY, BMP_ICON_SET_CIRCLES1_RED, - BMP_ICON_SET_CIRCLES1_YELLOW, BMP_ICON_SET_CIRCLES1_GREEN -}; - -sal_Int32 a5Quarters[] = { - BMP_ICON_SET_PIES_EMPTY, BMP_ICON_SET_PIES_ONE_QUARTER, BMP_ICON_SET_PIES_HALF, - BMP_ICON_SET_PIES_THREE_QUARTER, BMP_ICON_SET_PIES_FULL, -}; - -sal_Int32 a3Symbols1[] = { - BMP_ICON_SET_SYMBOLS1_CHECK, BMP_ICON_SET_SYMBOLS1_EXCLAMATION_MARK, BMP_ICON_SET_SYMBOLS1_CROSS -}; - -sal_Int32 a3Signs[] = { - BMP_ICON_SET_SHAPES_DIAMOND, BMP_ICON_SET_SHAPES_TRIANGLE, BMP_ICON_SET_SHAPES_CIRCLE -}; - -sal_Int32 a4RedToBlack[] = { - BMP_ICON_SET_CIRCLES2_DARK_GRAY, BMP_ICON_SET_CIRCLES2_LIGHT_GRAY, - BMP_ICON_SET_CIRCLES2_LIGHT_RED, BMP_ICON_SET_CIRCLES2_DARK_RED -}; - -sal_Int32 a4Ratings[] = { - BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF, - BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL -}; - -sal_Int32 a5Ratings[] = { - BMP_ICON_SET_BARS_EMPTY, BMP_ICON_SET_BARS_ONE_QUARTER, BMP_ICON_SET_BARS_HALF, - BMP_ICON_SET_BARS_THREE_QUARTER, BMP_ICON_SET_BARS_FULL -}; - -struct ScIconSetBitmapMap { - ScIconSetType eType; - sal_Int32* nBitmaps; -}; - -static ScIconSetBitmapMap aBitmapMap[] = { - { IconSet_3Arrows, a3Arrows }, - { IconSet_3ArrowsGray, a3ArrowsGray }, - { IconSet_3Flags, a3Flags }, - { IconSet_3Signs, a3Signs }, - { IconSet_3Symbols, a3Symbols1 }, - { IconSet_3Symbols2, a3Symbols1 }, - { IconSet_3TrafficLights1, a3TrafficLights1 }, - { IconSet_3TrafficLights2, a3TrafficLights2 }, - { IconSet_4Arrows, a4Arrows }, - { IconSet_4ArrowsGray, a4ArrowsGray }, - { IconSet_4Rating, a4Ratings }, - { IconSet_4RedToBlack, a4RedToBlack }, - { IconSet_4TrafficLights, a4TrafficLights }, - { IconSet_5Arrows, a5Arrows }, - { IconSet_5ArrowsGray, a5ArrowsGray }, - { IconSet_5Quarters, a5Quarters }, - { IconSet_5Ratings, a5Ratings } -}; - -static std::map< sal_Int32, BitmapEx > aIconSetBitmaps; // Hilfsklasse, fuer die Farbzuordnung, // um nicht mehrfach hintereinander denselben User aus der Liste zu suchen @@ -984,28 +886,7 @@ void drawDataBars( const ScDataBarInfo* pOldDataBarInfo, OutputDevice* pDev, con BitmapEx& getIcon( ScIconSetType eType, sal_Int32 nIndex ) { - sal_Int32 nBitmap = -1; - - for(size_t i = 0; i < SAL_N_ELEMENTS(aBitmapMap); ++i) - { - if(aBitmapMap[i].eType == eType) - { - nBitmap = *(aBitmapMap[i].nBitmaps + nIndex); - } - } - - assert( nBitmap != -1 ); - - std::map<sal_Int32, BitmapEx>::iterator itr = aIconSetBitmaps.find( nBitmap ); - if(itr != aIconSetBitmaps.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); - assert(itrNew.second); - - return itrNew.first->second; + return ScIconSetFormat::getBitmap( eType, nIndex ); } void drawIconSets( const ScIconSetInfo* pOldIconSetInfo, OutputDevice* pDev, const Rectangle& rRect ) commit 8c4719fd489ab70d5ae77e5f257254ef653a1f25 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Thu Nov 29 13:59:43 2012 +0100 support shared strings enough for gnumeric import Change-Id: I1cedf79d0465e8b8e4b8e85bea65bd35174e51a2 diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx index e2c9c08..6bf3311 100644 --- a/sc/source/filter/inc/orcusinterface.hxx +++ b/sc/source/filter/inc/orcusinterface.hxx @@ -20,10 +20,30 @@ class ScDocument; class ScOrcusSheet; +class ScOrcusSharedStrings : public orcus::spreadsheet::iface::import_shared_strings +{ + std::vector<OUString> maSharedStrings; + +public: + virtual size_t append(const char* s, size_t n); + virtual size_t add(const char* s, size_t n); + + virtual void set_segment_bold(bool b); + virtual void set_segment_italic(bool b); + virtual void set_segment_font_name(const char* s, size_t n); + virtual void set_segment_font_size(double point); + virtual void append_segment(const char* s, size_t n); + + virtual size_t commit_segments(); + + const OUString& getByIndex(size_t index) const; +}; + class ScOrcusFactory : public orcus::spreadsheet::iface::import_factory { ScDocument& mrDoc; boost::ptr_vector<ScOrcusSheet> maSheets; + ScOrcusSharedStrings maSharedStrings; public: ScOrcusFactory(ScDocument& rDoc); @@ -38,8 +58,9 @@ class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet { ScDocument& mrDoc; SCTAB mnTab; + ScOrcusSharedStrings& mrSharedStrings; public: - ScOrcusSheet(ScDocument& rDoc, SCTAB nTab); + ScOrcusSheet(ScDocument& rDoc, SCTAB nTab, ScOrcusSharedStrings& rSharedStrings); // Orcus import interface virtual void set_auto(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n); diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx index d22c208..52072ad 100644 --- a/sc/source/filter/orcus/interface.cxx +++ b/sc/source/filter/orcus/interface.cxx @@ -10,6 +10,7 @@ #include "orcusinterface.hxx" #include "document.hxx" +#include "cell.hxx" using orcus::spreadsheet::row_t; using orcus::spreadsheet::col_t; @@ -24,7 +25,7 @@ orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::append_sheet(const char return NULL; SCTAB nTab = mrDoc.GetTableCount() - 1; - maSheets.push_back(new ScOrcusSheet(mrDoc, nTab)); + maSheets.push_back(new ScOrcusSheet(mrDoc, nTab, maSharedStrings)); return &maSheets.back(); } @@ -56,14 +57,13 @@ orcus::spreadsheet::iface::import_sheet* ScOrcusFactory::get_sheet(const char* s return &(*it); // Create a new orcus sheet instance for this. - maSheets.push_back(new ScOrcusSheet(mrDoc, nTab)); + maSheets.push_back(new ScOrcusSheet(mrDoc, nTab, maSharedStrings)); return &maSheets.back(); } orcus::spreadsheet::iface::import_shared_strings* ScOrcusFactory::get_shared_strings() { - // We don't support it yet. - return NULL; + return &maSharedStrings; } orcus::spreadsheet::iface::import_styles* ScOrcusFactory::get_styles() @@ -72,8 +72,8 @@ orcus::spreadsheet::iface::import_styles* ScOrcusFactory::get_styles() return NULL; } -ScOrcusSheet::ScOrcusSheet(ScDocument& rDoc, SCTAB nTab) : - mrDoc(rDoc), mnTab(nTab) {} +ScOrcusSheet::ScOrcusSheet(ScDocument& rDoc, SCTAB nTab, ScOrcusSharedStrings& rSharedStrings) : + mrDoc(rDoc), mnTab(nTab), mrSharedStrings(rSharedStrings) {} void ScOrcusSheet::set_auto(row_t row, col_t col, const char* p, size_t n) { @@ -86,12 +86,40 @@ void ScOrcusSheet::set_format(row_t /*row*/, col_t /*col*/, size_t /*xf_index*/) } void ScOrcusSheet::set_formula( - row_t /*row*/, col_t /*col*/, formula_grammar_t /*grammar*/, const char* /*p*/, size_t /*n*/) + row_t row, col_t col, formula_grammar_t grammar, const char* p, size_t n) { + OUString aFormula(p, n, RTL_TEXTENCODING_UTF8); + formula::FormulaGrammar::Grammar eGrammar; + switch(grammar) + { + case orcus::spreadsheet::ods: + eGrammar = formula::FormulaGrammar::GRAM_ODFF; + break; + case orcus::spreadsheet::xlsx_2007: + case orcus::spreadsheet::xlsx_2010: + eGrammar = formula::FormulaGrammar::GRAM_ENGLISH_XL_A1; + break; + case orcus::spreadsheet::gnumeric: + eGrammar = formula::FormulaGrammar::GRAM_ENGLISH_XL_A1; + break; + } + + ScFormulaCell* pCell = new ScFormulaCell(&mrDoc, ScAddress(col, row, mnTab), aFormula, eGrammar); + mrDoc.PutCell(col, row, mnTab, pCell); } -void ScOrcusSheet::set_formula_result(row_t /*row*/, col_t /*col*/, const char* /*p*/, size_t /*n*/) +void ScOrcusSheet::set_formula_result(row_t row, col_t col, const char* p, size_t n) { + ScBaseCell* pCell; + mrDoc.GetCell( col, row, mnTab, pCell ); + if(!pCell || pCell->GetCellType() != CELLTYPE_FORMULA) + { + SAL_WARN("sc", "trying to set formula result for non formula \ + cell! Col: " << col << ";Row: " << row << ";Tab: " << mnTab); + return; + } + OUString aResult( p, n, RTL_TEXTENCODING_UTF8); + static_cast<ScFormulaCell*>(pCell)->SetHybridString(aResult); } void ScOrcusSheet::set_shared_formula( @@ -110,12 +138,65 @@ void ScOrcusSheet::set_shared_formula(row_t /*row*/, col_t /*col*/, size_t /*sin { } -void ScOrcusSheet::set_string(row_t /*row*/, col_t /*col*/, size_t /*sindex*/) +void ScOrcusSheet::set_string(row_t row, col_t col, size_t sindex) +{ + // Calc does not yet support shared strings so we have to + // workaround by importing shared strings into a temporary + // shared string container and writing into calc model as + // normal string + + const OUString& rSharedString = mrSharedStrings.getByIndex(sindex); + ScBaseCell* pCell = ScBaseCell::CreateTextCell( rSharedString, &mrDoc ); + mrDoc.PutCell(col, row, mnTab, pCell); +} + +void ScOrcusSheet::set_value(row_t row, col_t col, double value) +{ + mrDoc.SetValue( col, row, mnTab, value ); +} + +size_t ScOrcusSharedStrings::append(const char* s, size_t n) +{ + OUString aNewString(s, n, RTL_TEXTENCODING_UTF8); + maSharedStrings.push_back(aNewString); + + return maSharedStrings.size() - 1; +} + +size_t ScOrcusSharedStrings::add(const char* s, size_t n) +{ + OUString aNewString(s, n, RTL_TEXTENCODING_UTF8); + maSharedStrings.push_back(aNewString); + + return maSharedStrings.size() - 1; +} + +const OUString& ScOrcusSharedStrings::getByIndex(size_t nIndex) const { + if(nIndex < maSharedStrings.size()) + return maSharedStrings[nIndex]; + + throw std::exception(); } -void ScOrcusSheet::set_value(row_t /*row*/, col_t /*col*/, double /*value*/) +void ScOrcusSharedStrings::set_segment_bold(bool /*b*/) +{ +} +void ScOrcusSharedStrings::set_segment_italic(bool /*b*/) +{ +} +void ScOrcusSharedStrings::set_segment_font_name(const char* /*s*/, size_t /*n*/) +{ +} +void ScOrcusSharedStrings::set_segment_font_size(double /*point*/) +{ +} +void ScOrcusSharedStrings::append_segment(const char* /*s*/, size_t /*n*/) { } +size_t ScOrcusSharedStrings::commit_segments() +{ + return 0; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits