Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/inc/TableDesignPane.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 <svtools/valueset.hxx>
23
#include <sfx2/sidebar/ILayoutableWindow.hxx>
24
#include <sfx2/sidebar/PanelLayout.hxx>
25
#include <vcl/weld/Builder.hxx>
26
#include <vcl/weld/weld.hxx>
27
28
namespace com::sun::star::beans { class XPropertySet; }
29
namespace com::sun::star::container { class XIndexAccess; class XNameContainer; }
30
31
namespace sdtools {
32
class EventMultiplexerEvent;
33
}
34
35
namespace sd
36
{
37
38
class ViewShellBase;
39
class DrawController;
40
41
enum TableCheckBox : sal_uInt16
42
{
43
    CB_HEADER_ROW       = 0,
44
    CB_TOTAL_ROW        = 1,
45
    CB_BANDED_ROWS      = 2,
46
    CB_FIRST_COLUMN     = 3,
47
    CB_LAST_COLUMN      = 4,
48
    CB_BANDED_COLUMNS   = 5,
49
    CB_COUNT            = CB_BANDED_COLUMNS + 1
50
};
51
52
class TableValueSet final : public ValueSet
53
{
54
private:
55
    bool m_bModal;
56
    Link<const Point*, void> maContextMenuHandler;
57
public:
58
    TableValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow);
59
    virtual bool Command(const CommandEvent& rEvent) override;
60
    virtual void Resize() override;
61
    virtual void StyleUpdated() override;
62
    void updateSettings();
63
0
    void setModal(bool bModal) { m_bModal = bModal; }
64
0
    void SetContextMenuHandler(const Link<const Point*, void>& rLink) { maContextMenuHandler = rLink; }
65
0
    static constexpr int getMaxRowCount() { return 3; }
66
};
67
68
class TableDesignWidget final
69
{
70
public:
71
    TableDesignWidget(weld::Builder& rBuilder, ViewShellBase& rBase);
72
    ~TableDesignWidget();
73
74
    // callbacks
75
    void onSelectionChanged();
76
77
    void ApplyOptions();
78
    void ApplyStyle();
79
    void InsertStyle();
80
    void CloneStyle();
81
    void ResetStyle();
82
    void DeleteStyle();
83
    void EditStyle(const OUString& rCommand);
84
85
private:
86
    void addListener();
87
    void removeListener();
88
    void updateControls();
89
    void selectStyle(std::u16string_view rStyle);
90
    void endTextEditForStyle(const css::uno::Reference<css::uno::XInterface>& rStyle);
91
    void setDocumentModified();
92
93
    void FillDesignPreviewControl();
94
95
    DECL_LINK(EventMultiplexerListener, sdtools::EventMultiplexerEvent&, void);
96
    DECL_LINK(implContextMenuHandler, const Point*, void);
97
    DECL_LINK(implValueSetHdl, ValueSet*, void);
98
    DECL_LINK(implCheckBoxHdl, weld::Toggleable&, void);
99
100
    ViewShellBase& mrBase;
101
102
    std::unique_ptr<weld::Menu> m_xMenu;
103
    std::unique_ptr<TableValueSet> m_xValueSet;
104
    std::unique_ptr<weld::CustomWeld> m_xValueSetWin;
105
    std::unique_ptr<weld::CheckButton> m_aCheckBoxes[CB_COUNT];
106
107
    css::uno::Reference< css::beans::XPropertySet > mxSelectedTable;
108
    rtl::Reference< DrawController > mxView;
109
    css::uno::Reference< css::container::XIndexAccess > mxTableFamily;
110
    css::uno::Reference< css::container::XNameContainer > mxCellFamily;
111
};
112
113
class TableDesignPane final : public PanelLayout
114
                      , public sfx2::sidebar::ILayoutableWindow
115
{
116
private:
117
    std::unique_ptr<TableDesignWidget> m_xImpl;
118
public:
119
    TableDesignPane( weld::Widget* pParent, ViewShellBase& rBase )
120
0
        : PanelLayout(pParent, u"TableDesignPanel"_ustr,
121
0
            u"modules/simpress/ui/tabledesignpanel.ui"_ustr)
122
0
        , m_xImpl(new TableDesignWidget(*m_xBuilder, rBase))
123
0
    {
124
0
    }
125
    virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 /*nWidth*/) override
126
0
    {
127
0
        sal_Int32 nMinimumHeight = get_preferred_size().Height();
128
0
        return css::ui::LayoutSize(nMinimumHeight, -1, nMinimumHeight);
129
0
    }
130
};
131
132
}
133
134
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */