LibreOffice Module sc (master)  1
namedlg.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_NAMEDLG_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_NAMEDLG_HXX
22 
23 #include "anyrefdg.hxx"
24 #include "namemgrtable.hxx"
25 
26 #include <memory>
27 #include <map>
28 
29 class ScViewData;
30 class ScDocument;
31 
32 //logic behind the manage names dialog
34 {
35 private:
36  const OUString maGlobalNameStr;
37  const OUString maErrInvalidNameStr;
38  const OUString maErrNameInUse;
39  const OUString maStrMultiSelect;
40  OUString maStrInfoDefault;
41 
45 
47  //ugly hack to call DefineNames from ManageNames
49 
50  typedef std::map<OUString, std::unique_ptr<ScRangeName>> RangeNameContainer;
51 
52  RangeNameContainer m_RangeMap;
53 
54  std::unique_ptr<weld::Entry> m_xEdName;
55  std::unique_ptr<weld::Label> m_xFtAssign;
56  std::unique_ptr<formula::RefEdit> m_xEdAssign;
57  std::unique_ptr<formula::RefButton> m_xRbAssign;
58  std::unique_ptr<weld::ComboBox> m_xLbScope;
59 
60  std::unique_ptr<weld::CheckButton> m_xBtnPrintArea;
61  std::unique_ptr<weld::CheckButton> m_xBtnColHeader;
62  std::unique_ptr<weld::CheckButton> m_xBtnCriteria;
63  std::unique_ptr<weld::CheckButton> m_xBtnRowHeader;
64 
65  std::unique_ptr<weld::Button> m_xBtnAdd;
66  std::unique_ptr<weld::Button> m_xBtnDelete;
67  std::unique_ptr<weld::Button> m_xBtnOk;
68  std::unique_ptr<weld::Button> m_xBtnCancel;
69 
70  std::unique_ptr<weld::Label> m_xFtInfo;
71 
72  std::unique_ptr<weld::Expander> m_xExpander;
73 
74  std::unique_ptr<ScRangeManagerTable> m_xRangeManagerTable;
75 
76 private:
77  void Init();
78  void UpdateChecks(const ScRangeData* pData);
79  void ShowOptions(const ScRangeNameLine& rLine);
80 
81  bool IsNameValid();
82  bool IsFormulaValid();
83  void CheckForEmptyTable();
84 
85  ScRangeName* GetRangeName(const OUString& rScope);
86 
87  void AddPushed();
88  void RemovePushed();
89  void ScopeChanged();
90  void NameModified();
91 
92  void SelectionChanged();
93 
94  // Handler:
95  DECL_LINK( OkBtnHdl, weld::Button&, void );
96  DECL_LINK( CancelBtnHdl, weld::Button&, void );
97  DECL_LINK( AddBtnHdl, weld::Button&, void );
98  DECL_LINK( RemoveBtnHdl, weld::Button&, void );
99  DECL_LINK( EdModifyHdl, weld::Entry&, void );
100  DECL_LINK( RefEdModifyHdl, formula::RefEdit&, void );
101  DECL_LINK( EdModifyCheckBoxHdl, weld::ToggleButton&, void );
102  DECL_LINK( AssignGetFocusHdl, formula::RefEdit&, void );
103  DECL_LINK( SelectionChangedHdl_Impl, weld::TreeView&, void );
104  DECL_LINK( ScopeChangedHdl, weld::ComboBox&, void );
105 
106 protected:
107  virtual void RefInputDone( bool bForced = false ) override;
108 
109 public:
110  ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, weld::Window* pParent,
111  ScViewData& rViewData,
112  const ScAddress& aCursorPos,
113  std::map<OUString, std::unique_ptr<ScRangeName>>* pRangeMap = nullptr);
114  virtual ~ScNameDlg() override;
115 
116  virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override;
117  virtual bool IsRefInputMode() const override;
118 
119  virtual void SetActive() override;
120  virtual void Close() override;
121 
122  void GetRangeNames(std::map<OUString, std::unique_ptr<ScRangeName>>& rRangeMap);
123  void SetEntry(const OUString& rName, const OUString& rScope);
124 };
125 
126 #endif // INCLUDED_SC_SOURCE_UI_INC_NAMEDLG_HXX
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScDocument & mrDoc
Definition: namedlg.hxx:43
std::unique_ptr< weld::Label > m_xFtAssign
Definition: namedlg.hxx:55
const OUString maErrNameInUse
Definition: namedlg.hxx:38
virtual void SetActive() override
Definition: namedlg.cxx:208
const OUString maStrMultiSelect
Definition: namedlg.hxx:39
ScViewData & mrViewData
Definition: namedlg.hxx:42
const OUString maErrInvalidNameStr
Definition: namedlg.hxx:37
void SetEntry(const OUString &rName, const OUString &rScope)
Definition: namedlg.cxx:307
std::unique_ptr< weld::Button > m_xBtnCancel
Definition: namedlg.hxx:68
virtual ~ScNameDlg() override
Definition: namedlg.cxx:99
virtual void Close() override
Definition: namedlg.cxx:171
virtual void SetReference(const ScRange &rRef, ScDocument &rDoc) override
Definition: namedlg.cxx:159
void RemovePushed()
Definition: namedlg.cxx:319
void ScopeChanged()
Definition: namedlg.cxx:445
std::unique_ptr< formula::RefButton > m_xRbAssign
Definition: namedlg.hxx:57
std::unique_ptr< weld::Button > m_xBtnAdd
Definition: namedlg.hxx:65
DECL_LINK(OkBtnHdl, weld::Button &, void)
bool IsNameValid()
Definition: namedlg.cxx:240
std::unique_ptr< weld::Entry > m_xEdName
Definition: namedlg.hxx:54
std::unique_ptr< weld::ComboBox > m_xLbScope
Definition: namedlg.hxx:58
void GetRangeNames(std::map< OUString, std::unique_ptr< ScRangeName >> &rRangeMap)
Definition: namedlg.cxx:450
void NameModified()
Definition: namedlg.cxx:337
void CheckForEmptyTable()
Definition: namedlg.cxx:178
RangeNameContainer m_RangeMap
Definition: namedlg.hxx:52
ScRangeName * GetRangeName(const OUString &rScope)
Definition: namedlg.cxx:282
OUString maStrInfoDefault
Definition: namedlg.hxx:40
std::unique_ptr< weld::Label > m_xFtInfo
Definition: namedlg.hxx:70
std::unique_ptr< weld::CheckButton > m_xBtnPrintArea
Definition: namedlg.hxx:60
void SelectionChanged()
Definition: namedlg.cxx:403
std::unique_ptr< formula::RefEdit > m_xEdAssign
Definition: namedlg.hxx:56
virtual bool IsRefInputMode() const override
Definition: namedlg.cxx:148
const OUString maGlobalNameStr
Definition: namedlg.hxx:36
std::unique_ptr< weld::Expander > m_xExpander
Definition: namedlg.hxx:72
bool IsFormulaValid()
Definition: namedlg.cxx:267
std::unique_ptr< weld::CheckButton > m_xBtnCriteria
Definition: namedlg.hxx:62
virtual void RefInputDone(bool bForced=false) override
Definition: namedlg.cxx:153
void Init()
Definition: namedlg.cxx:103
std::unique_ptr< ScRangeManagerTable > m_xRangeManagerTable
Definition: namedlg.hxx:74
const ScAddress maCursorPos
Definition: namedlg.hxx:44
std::unique_ptr< weld::CheckButton > m_xBtnRowHeader
Definition: namedlg.hxx:63
ScNameDlg(SfxBindings *pB, SfxChildWindow *pCW, weld::Window *pParent, ScViewData &rViewData, const ScAddress &aCursorPos, std::map< OUString, std::unique_ptr< ScRangeName >> *pRangeMap=nullptr)
Definition: namedlg.cxx:44
std::unique_ptr< weld::Button > m_xBtnOk
Definition: namedlg.hxx:67
void AddPushed()
Definition: namedlg.cxx:300
bool mbCloseWithoutUndo
Definition: namedlg.hxx:48
void ShowOptions(const ScRangeNameLine &rLine)
Definition: namedlg.cxx:290
std::unique_ptr< weld::CheckButton > m_xBtnColHeader
Definition: namedlg.hxx:61
std::map< OUString, std::unique_ptr< ScRangeName > > RangeNameContainer
Definition: namedlg.hxx:50
bool mbDataChanged
Definition: namedlg.hxx:46
std::unique_ptr< weld::Button > m_xBtnDelete
Definition: namedlg.hxx:66
void UpdateChecks(const ScRangeData *pData)
Definition: namedlg.cxx:214