Line data Source code
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 :
10 : #include <svx/simptabl.hxx>
11 : #include <vcl/ctrl.hxx>
12 :
13 : #include "scresid.hxx"
14 : #include "address.hxx"
15 :
16 : #include <vector>
17 : #include <boost/ptr_container/ptr_map.hpp>
18 :
19 : class ScRangeName;
20 : class ScRangeData;
21 :
22 0 : struct ScRangeNameLine
23 : {
24 : OUString aName;
25 : OUString aExpression;
26 : OUString aScope;
27 : };
28 :
29 : //Implements the table for the manage names dialog
30 : //TODO: cache the lines for performance improvements
31 : //otherwise handling of a large set of range names might get extremely slow
32 : //Need some sort of a filter to handle several range names
33 : class SC_DLLPUBLIC ScRangeManagerTable : public SvxSimpleTable
34 : {
35 : private:
36 : OUString maGlobalString;
37 :
38 : // should be const because we should not modify it here
39 : const boost::ptr_map<OUString, ScRangeName>& mrRangeMap;
40 : // for performance, save which entries already have the formula entry
41 : // otherwise opening the dialog with a lot of range names is extremelly slow because
42 : // we would calculate all formula strings during opening
43 : std::map<SvTreeListEntry*, bool> maCalculatedFormulaEntries;
44 : const ScAddress maPos;
45 :
46 : void GetLine(ScRangeNameLine& aLine, SvTreeListEntry* pEntry);
47 : void Init();
48 : void CheckForFormulaString();
49 : const ScRangeData* findRangeData(const ScRangeNameLine& rLine);
50 :
51 : void setColWidths();
52 :
53 : public:
54 : ScRangeManagerTable( SvxSimpleTableContainer& rParent, boost::ptr_map<OUString, ScRangeName>& aTabRangeNames, const ScAddress& rPos );
55 : virtual ~ScRangeManagerTable();
56 :
57 : virtual void Resize();
58 :
59 : void addEntry( const ScRangeNameLine& rLine, bool bSetCurEntry = true );
60 : void DeleteSelectedEntries();
61 : void SetEntry( const ScRangeNameLine& rLine );
62 :
63 : void GetCurrentLine(ScRangeNameLine& rLine);
64 : bool IsMultiSelection();
65 : std::vector<ScRangeNameLine> GetSelectedEntries();
66 :
67 : DECL_LINK( ScrollHdl, void*);
68 : DECL_LINK( HeaderEndDragHdl, void*);
69 : };
70 :
71 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|