cid#1640468 Dereference after null check
[LibreOffice.git] / sd / source / ui / inc / TableDesignPane.hxx
blobe3cbfdd084067f2caccc984dc25051af1b44dc07
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <svtools/valueset.hxx>
23 #include <sfx2/sidebar/ILayoutableWindow.hxx>
24 #include <sfx2/sidebar/PanelLayout.hxx>
25 #include <vcl/weld.hxx>
27 namespace com::sun::star::beans { class XPropertySet; }
28 namespace com::sun::star::container { class XIndexAccess; class XNameContainer; }
29 namespace com::sun::star::drawing { class XDrawView; }
31 namespace sd
34 namespace tools {
35 class EventMultiplexerEvent;
38 class ViewShellBase;
39 class DrawController;
41 enum TableCheckBox : sal_uInt16
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
52 class TableValueSet final : public ValueSet
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 void setModal(bool bModal) { m_bModal = bModal; }
64 void SetContextMenuHandler(const Link<const Point*, void>& rLink) { maContextMenuHandler = rLink; }
65 static constexpr int getMaxRowCount() { return 3; }
68 class TableDesignWidget final
70 public:
71 TableDesignWidget(weld::Builder& rBuilder, ViewShellBase& rBase);
72 ~TableDesignWidget();
74 // callbacks
75 void onSelectionChanged();
77 void ApplyOptions();
78 void ApplyStyle();
79 void InsertStyle();
80 void CloneStyle();
81 void ResetStyle();
82 void DeleteStyle();
83 void EditStyle(const OUString& rCommand);
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();
93 void FillDesignPreviewControl();
95 DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent&, void);
96 DECL_LINK(implContextMenuHandler, const Point*, void);
97 DECL_LINK(implValueSetHdl, ValueSet*, void);
98 DECL_LINK(implCheckBoxHdl, weld::Toggleable&, void);
100 ViewShellBase& mrBase;
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];
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;
113 class TableDesignPane final : public PanelLayout
114 , public sfx2::sidebar::ILayoutableWindow
116 private:
117 std::unique_ptr<TableDesignWidget> m_xImpl;
118 public:
119 TableDesignPane( weld::Widget* pParent, ViewShellBase& rBase )
120 : PanelLayout(pParent, u"TableDesignPanel"_ustr,
121 u"modules/simpress/ui/tabledesignpanel.ui"_ustr)
122 , m_xImpl(new TableDesignWidget(*m_xBuilder, rBase))
125 virtual css::ui::LayoutSize GetHeightForWidth(const sal_Int32 /*nWidth*/) override
127 sal_Int32 nMinimumHeight = get_preferred_size().Height();
128 return css::ui::LayoutSize(nMinimumHeight, -1, nMinimumHeight);
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */