/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX #define INCLUDED_SC_SOURCE_UI_INC_CONDFORMATDLGENTRY_HXX #include "colorscale.hxx" #include "conditio.hxx" #include #include class ScIconSetFrmtDataEntry; class ScCondFormatDlg; namespace condformat { namespace entry { enum ScCondFrmtEntryType { CONDITION, FORMULA, COLORSCALE2, COLORSCALE3, DATABAR, ICONSET, DATE }; } } class ScCondFrmtEntry : public Control { private: bool mbActive; Link maClickHdl; //general ui elements VclPtr maFtCondNr; VclPtr maFtCondition; sal_Int32 mnIndex; OUString maStrCondition; protected: VclPtr maLbType; ScDocument* mpDoc; ScAddress maPos; virtual void Select(); virtual void Deselect(); virtual OUString GetExpressionString() = 0; public: ScCondFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos ); virtual ~ScCondFrmtEntry(); virtual void dispose() override; virtual bool Notify( NotifyEvent& rNEvt ) override; bool IsSelected() const { return mbActive;} void SetIndex(sal_Int32 nIndex); void SetHeight(); virtual ScFormatEntry* GetEntry() const = 0; virtual void SetActive() = 0; virtual void SetInactive() = 0; virtual condformat::entry::ScCondFrmtEntryType GetType() = 0; }; class ScConditionFrmtEntry : public ScCondFrmtEntry, public SfxListener { //cond format ui elements VclPtr maLbCondType; VclPtr maEdVal1; VclPtr maEdVal2; VclPtr maFtVal; VclPtr maFtStyle; VclPtr maLbStyle; VclPtr maWdPreview; bool mbIsInStyleCreate; static const sal_Int32 NUM_COND_ENTRIES = 24; // Lookup table from positions in maLbCondType to the condition mode enum static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES]; ScFormatEntry* createConditionEntry() const; virtual OUString GetExpressionString() override; void Init(ScCondFormatDlg* pDialogParent); DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void ); DECL_LINK_TYPED( ConditionTypeSelectHdl, ListBox&, void ); DECL_LINK_TYPED( OnEdChanged, Edit&, void ); // Searches the lookup table for the entry position, given condition mode static sal_Int32 ConditionModeToEntryPos( ScConditionMode eMode ); // Accesses the lookup table for the condition mode, given entry position static ScConditionMode EntryPosToConditionMode( sal_Int32 aEntryPos ); // Returns the number of edit fields used for a given condition mode static sal_Int32 GetNumberEditFields( ScConditionMode eMode ); protected: virtual void Select() override; virtual void Deselect() override; public: ScConditionFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL ); virtual ~ScConditionFrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; using ScCondFrmtEntry::Notify; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::CONDITION; } }; class ScFormulaFrmtEntry : public ScCondFrmtEntry { VclPtr maFtStyle; VclPtr maLbStyle; VclPtr maWdPreview; VclPtr maEdFormula; ScFormatEntry* createFormulaEntry() const; virtual OUString GetExpressionString() override; void Init(ScCondFormatDlg* pDialogParent); DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void ); public: ScFormulaFrmtEntry( vcl::Window* pParent, ScDocument* PDoc, ScCondFormatDlg* pDialogParent, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry = NULL ); virtual ~ScFormulaFrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::FORMULA; } }; class ScColorScale2FrmtEntry : public ScCondFrmtEntry { //color format ui elements VclPtr maLbColorFormat; //color scale ui elements VclPtr maLbEntryTypeMin; VclPtr maLbEntryTypeMax; VclPtr maEdMin; VclPtr maEdMax; VclPtr maLbColMin; VclPtr maLbColMax; ScFormatEntry* createColorscaleEntry() const; virtual OUString GetExpressionString() override; void Init(); DECL_LINK_TYPED( EntryTypeHdl, ListBox&, void ); public: ScColorScale2FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL ); virtual ~ScColorScale2FrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE2; } }; class ScColorScale3FrmtEntry : public ScCondFrmtEntry { //color format ui elements VclPtr maLbColorFormat; //color scale ui elements VclPtr maLbEntryTypeMin; VclPtr maLbEntryTypeMiddle; VclPtr maLbEntryTypeMax; VclPtr maEdMin; VclPtr maEdMiddle; VclPtr maEdMax; VclPtr maLbColMin; VclPtr maLbColMiddle; VclPtr maLbColMax; ScFormatEntry* createColorscaleEntry() const; virtual OUString GetExpressionString() override; void Init(); DECL_LINK_TYPED( EntryTypeHdl, ListBox&, void ); public: ScColorScale3FrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat = NULL ); virtual ~ScColorScale3FrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::COLORSCALE3; } }; class ScDataBarFrmtEntry : public ScCondFrmtEntry { //color format ui elements VclPtr maLbColorFormat; //data bar ui elements VclPtr maLbDataBarMinType; VclPtr maLbDataBarMaxType; VclPtr maEdDataBarMin; VclPtr maEdDataBarMax; VclPtr maBtOptions; std::unique_ptr mpDataBarData; ScFormatEntry* createDatabarEntry() const; virtual OUString GetExpressionString() override; void Init(); DECL_LINK_TYPED( OptionBtnHdl, Button*, void ); DECL_LINK_TYPED( DataBarTypeSelectHdl, ListBox&, void ); public: ScDataBarFrmtEntry( vcl::Window* pParemt, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat = NULL ); virtual ~ScDataBarFrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATABAR; } }; class ScDateFrmtEntry : public ScCondFrmtEntry, public SfxListener { public: ScDateFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat = NULL ); virtual ~ScDateFrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::DATE; } virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; using ScCondFrmtEntry::Notify; protected: virtual OUString GetExpressionString() override; private: void Init(); DECL_LINK_TYPED( StyleSelectHdl, ListBox&, void ); VclPtr maLbDateEntry; VclPtr maFtStyle; VclPtr maLbStyle; VclPtr maWdPreview; bool mbIsInStyleCreate; }; class ScIconSetFrmtEntry : public ScCondFrmtEntry { //color format ui elements VclPtr maLbColorFormat; // icon set ui elements VclPtr maLbIconSetType; typedef std::vector> ScIconSetFrmtDataEntriesType; ScIconSetFrmtDataEntriesType maEntries; virtual OUString GetExpressionString() override; void Init(); DECL_LINK_TYPED( IconSetTypeHdl, ListBox&, void ); public: ScIconSetFrmtEntry( vcl::Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat = NULL ); virtual ~ScIconSetFrmtEntry(); virtual void dispose() override; virtual ScFormatEntry* GetEntry() const override; virtual void SetActive() override; virtual void SetInactive() override; virtual condformat::entry::ScCondFrmtEntryType GetType() override { return condformat::entry::ICONSET; } }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */