Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sc/source/ui/inc/navipi.hxx
Line
Count
Source
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
#pragma once
21
22
#include <vector>
23
#include <vcl/idle.hxx>
24
#include <svl/lstner.hxx>
25
#include <sfx2/childwin.hxx>
26
#include <sfx2/navigat.hxx>
27
#include <sfx2/sidebar/PanelLayout.hxx>
28
#include <rangeutl.hxx>
29
#include "content.hxx"
30
31
class SfxPoolItem;
32
class ScTabViewShell;
33
class ScViewData;
34
class ScNavigatorControllerItem;
35
class ScNavigatorSettings;
36
37
0
#define SC_DROPMODE_URL         0
38
0
#define SC_DROPMODE_LINK        1
39
0
#define SC_DROPMODE_COPY        2
40
41
enum NavListMode { NAV_LMODE_NONE       = 0x4000,
42
                   NAV_LMODE_AREAS      = 0x2000,
43
                   NAV_LMODE_SCENARIOS  = 0x400 };
44
45
class ScScenarioWindow
46
{
47
public:
48
    ScScenarioWindow(weld::Builder& rBuilder, const OUString& rQH_List, const OUString& rQH_Comment);
49
    ~ScScenarioWindow();
50
    void NotifyState(const SfxPoolItem* pState);
51
    void SetComment(const OUString& rComment)
52
0
    {
53
0
        m_xEdComment->set_text(rComment);
54
0
    }
55
56
private:
57
    std::unique_ptr<weld::TreeView> m_xLbScenario;
58
    std::unique_ptr<weld::TextView> m_xEdComment;
59
60
    struct ScenarioEntry
61
    {
62
        OUString            maName;
63
        OUString            maComment;
64
        bool                mbProtected;
65
66
0
        explicit     ScenarioEntry() : mbProtected( false ) {}
67
    };
68
69
    std::vector< ScenarioEntry > m_aEntries;
70
71
    void UpdateEntries(const std::vector<OUString> &rNewEntryList);
72
    void SelectScenario();
73
    void ExecuteScenarioSlot(sal_uInt16 nSlotId);
74
    void EditScenario();
75
    void DeleteScenario();
76
    const ScenarioEntry* GetSelectedScenarioEntry() const;
77
78
    DECL_LINK(SelectHdl, weld::TreeView&, void);
79
    DECL_LINK(DoubleClickHdl, weld::TreeView&, bool);
80
    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
81
    DECL_LINK(ContextMenuHdl, const CommandEvent&, bool);
82
};
83
84
class ScNavigatorDlg : public PanelLayout, public SfxListener
85
{
86
friend class ScNavigatorWin;
87
friend class ScNavigatorControllerItem;
88
friend class ScContentTree;
89
friend class ScTabViewShell;
90
91
private:
92
    static constexpr int CTRL_ITEMS = 4;
93
94
    SfxBindings&        rBindings;      // must be first member
95
96
    std::unique_ptr<weld::SpinButton> m_xEdCol;
97
    std::unique_ptr<weld::SpinButton> m_xEdRow;
98
    std::unique_ptr<weld::Toolbar> m_xTbxCmd1;
99
    std::unique_ptr<weld::Toolbar> m_xTbxCmd2;
100
    std::unique_ptr<ScContentTree> m_xLbEntries;
101
    std::unique_ptr<weld::Widget> m_xScenarioBox;
102
    std::unique_ptr<ScScenarioWindow> m_xWndScenarios;
103
    std::unique_ptr<weld::ComboBox> m_xLbDocuments;
104
    std::unique_ptr<weld::Menu> m_xDragModeMenu;
105
106
    VclPtr<SfxNavigator> m_xNavigatorDlg;
107
108
    Size            aExpandedSize;
109
    Idle            aContentIdle;
110
111
    OUString        aStrActive;
112
    OUString        aStrNotActive;
113
    OUString        aStrActiveWin;
114
115
    std::optional<ScArea> moMarkArea;
116
117
    NavListMode     eListMode;
118
    sal_uInt16      nDropMode;
119
    SCCOL           nCurCol;
120
    SCROW           nCurRow;
121
    SCTAB           nCurTab;
122
123
    std::array<std::unique_ptr<ScNavigatorControllerItem>,CTRL_ITEMS> mvBoundItems;
124
125
    DECL_LINK(TimeHdl, Timer*, void);
126
    DECL_LINK(DocumentSelectHdl, weld::ComboBox&, void);
127
    DECL_LINK(ExecuteRowHdl, weld::Entry&, bool);
128
    DECL_LINK(ExecuteColHdl, weld::Entry&, bool);
129
    DECL_LINK(ToolBoxSelectHdl, const OUString&, void);
130
    DECL_LINK(ToolBoxDropdownClickHdl, const OUString&, void);
131
    DECL_LINK(MenuSelectHdl, const OUString&, void);
132
    DECL_STATIC_LINK(ScNavigatorDlg, FormatRowOutputHdl, sal_Int64, OUString);
133
    DECL_STATIC_LINK(ScNavigatorDlg, ParseRowInputHdl, const OUString&, std::optional<int>);
134
135
    void    UpdateButtons();
136
    void    SetCurrentCell( SCCOL nCol, SCROW Row );
137
    void    SetCurrentCellStr( const OUString& rName );
138
    void    SetCurrentTable( SCTAB nTab );
139
    void    SetCurrentTableStr( std::u16string_view rName );
140
    void    SetCurrentObject( const OUString& rName );
141
    void    SetCurrentDoc( const OUString& rDocName );
142
    void    UpdateSelection();
143
    void    ContentUpdated(); // stop aContentIdle because content is up to date
144
145
    SAL_RET_MAYBENULL static ScTabViewShell*  GetTabViewShell();
146
    static ScNavigatorSettings* GetNavigatorSettings();
147
    static ScViewData* GetViewData();
148
149
    void    UpdateSheetLimits();
150
151
    void    UpdateColumn    ( const SCCOL* pCol = nullptr );
152
    void    UpdateRow       ( const SCROW* pRow = nullptr );
153
    void    UpdateTable     ( const SCTAB* pTab );
154
    void    UpdateAll       ();
155
156
    void    GetDocNames(const OUString* pSelEntry);
157
158
    void    SetListMode(NavListMode eMode);
159
    void    ShowList(bool bShow);
160
    void    ShowScenarios();
161
162
    void    SetDropMode(sal_uInt16 nNew);
163
0
    sal_uInt16  GetDropMode() const         { return nDropMode; }
164
165
    void    MarkDataArea    ();
166
    void    UnmarkDataArea  ();
167
    void    StartOfDataArea ();
168
    void    EndOfDataArea   ();
169
170
    void    UpdateInitShow();
171
172
    static void ReleaseFocus();
173
174
public:
175
    ScNavigatorDlg(SfxBindings* pB, weld::Widget* pParent, SfxNavigator* pNavigatorDlg);
176
    virtual weld::Window* GetFrameWeld() const override;
177
    virtual ~ScNavigatorDlg() override;
178
179
    virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
180
181
};
182
183
class ScNavigatorWrapper final : public SfxNavigatorWrapper
184
{
185
public:
186
    ScNavigatorWrapper(vcl::Window *pParent, sal_uInt16 nId,
187
                       SfxBindings* pBindings, SfxChildWinInfo* pInfo);
188
    SFX_DECL_CHILDWINDOW(ScNavigatorWrapper);
189
};
190
191
class ScNavigatorWin : public SfxNavigator
192
{
193
    friend class ScTabViewShell;
194
private:
195
    std::unique_ptr<ScNavigatorDlg> m_xNavigator;
196
public:
197
    ScNavigatorWin(SfxBindings* _pBindings, SfxChildWindow* pMgr,
198
                   vcl::Window* pParent, SfxChildWinInfo* pInfo);
199
    virtual void StateChanged(StateChangedType nStateChange) override;
200
    virtual void dispose() override
201
0
    {
202
0
        m_xNavigator.reset();
203
0
        SfxNavigator::dispose();
204
0
    }
205
    virtual ~ScNavigatorWin() override
206
0
    {
207
0
        disposeOnce();
208
0
    }
209
};
210
211
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */