cid#1608071 Out-of-bounds access
[LibreOffice.git] / chart2 / source / controller / dialogs / dlg_View3D.cxx
blob1e5232dfc38768b96bb15c1a8302faa1a8633fd3
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 #include <dlg_View3D.hxx>
21 #include <strings.hrc>
22 #include <ResId.hxx>
23 #include "tp_3D_SceneGeometry.hxx"
24 #include "tp_3D_SceneAppearance.hxx"
25 #include "tp_3D_SceneIllumination.hxx"
26 #include <ChartModelHelper.hxx>
27 #include <ChartModel.hxx>
28 #include <Diagram.hxx>
30 namespace chart
33 using namespace ::com::sun::star;
35 sal_uInt16 View3DDialog::m_nLastPageId = 0;
37 View3DDialog::View3DDialog(weld::Window* pParent, const rtl::Reference<::chart::ChartModel> & xChartModel)
38 : GenericDialogController(pParent, u"modules/schart/ui/3dviewdialog.ui"_ustr, u"3DViewDialog"_ustr)
39 , m_aControllerLocker(xChartModel)
40 , m_xTabControl(m_xBuilder->weld_notebook(u"tabcontrol"_ustr))
42 rtl::Reference< Diagram > xSceneProperties = xChartModel->getFirstChartDiagram();
44 m_xTabControl->append_page(u"geometry"_ustr, SchResId(STR_PAGE_PERSPECTIVE));
45 m_xGeometry.reset(new ThreeD_SceneGeometry_TabPage(m_xTabControl->get_page(u"geometry"_ustr), xSceneProperties, m_aControllerLocker));
47 m_xTabControl->append_page(u"appearance"_ustr, SchResId(STR_PAGE_APPEARANCE));
48 m_xAppearance.reset(new ThreeD_SceneAppearance_TabPage(m_xTabControl->get_page(u"appearance"_ustr), xChartModel, m_aControllerLocker));
50 m_xTabControl->append_page(u"illumination"_ustr, SchResId(STR_PAGE_ILLUMINATION));
51 m_xIllumination.reset(new ThreeD_SceneIllumination_TabPage(m_xTabControl->get_page(u"illumination"_ustr), m_xDialog.get(),
52 xSceneProperties, xChartModel));
54 m_xTabControl->connect_enter_page(LINK(this, View3DDialog, ActivatePageHdl));
56 m_xTabControl->set_current_page(m_nLastPageId);
59 IMPL_LINK(View3DDialog, ActivatePageHdl, const OUString&, rPage, void)
61 if (rPage == "appearance")
62 m_xAppearance->ActivatePage();
65 View3DDialog::~View3DDialog()
67 m_nLastPageId = m_xTabControl->get_current_page();
70 short View3DDialog::run()
72 short nResult = GenericDialogController::run();
73 if (nResult == RET_OK && m_xGeometry)
74 m_xGeometry->commitPendingChanges();
75 return nResult;
78 } //namespace chart
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */