LibreOffice Module chart2 (master) 1
tp_Wizard_TitlesAndObjects.cxx
Go to the documentation of this file.
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
21#include <res_Titles.hxx>
23#include <ChartModelHelper.hxx>
24#include <ChartModel.hxx>
25#include <Diagram.hxx>
26#include <AxisHelper.hxx>
28#include <utility>
29
30namespace chart
31{
32using namespace ::com::sun::star;
33using namespace ::com::sun::star::chart2;
34
38 : OWizardPage(pPage, pController, "modules/schart/ui/wizelementspage.ui", "WizElementsPage")
39 , m_xTitleResources(new TitleResources(*m_xBuilder, false))
40 , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xContext))
41 , m_xChartModel(std::move(xChartModel))
42 , m_xCC(xContext)
43 , m_bCommitToModel(true)
44 , m_aTimerTriggeredControllerLock( m_xChartModel )
45 , m_xCB_Grid_X(m_xBuilder->weld_check_button("x"))
46 , m_xCB_Grid_Y(m_xBuilder->weld_check_button("y"))
47 , m_xCB_Grid_Z(m_xBuilder->weld_check_button("z"))
48{
49 m_xTitleResources->connect_changed( LINK( this, TitlesAndObjectsTabPage, ChangeEditHdl ));
50 m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl ));
51
52 m_xCB_Grid_X->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
53 m_xCB_Grid_Y->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
54 m_xCB_Grid_Z->connect_toggled( LINK( this, TitlesAndObjectsTabPage, ChangeCheckBoxHdl ));
55}
56
58{
59}
60
62{
63 m_bCommitToModel = false;
64
65 //init titles
66 {
67 TitleDialogData aTitleInput;
68 aTitleInput.readFromModel( m_xChartModel );
69 m_xTitleResources->writeToResources( aTitleInput );
70 }
71
72 //init legend
73 {
74 m_xLegendPositionResources->writeToResources( m_xChartModel );
75 }
76
77 //init grid checkboxes
78 {
79 rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram();
80 uno::Sequence< sal_Bool > aPossibilityList;
81 uno::Sequence< sal_Bool > aExistenceList;
82 AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false );
83 AxisHelper::getAxisOrGridExistence( aExistenceList, xDiagram, false );
84 m_xCB_Grid_X->set_sensitive( aPossibilityList[0] );
85 m_xCB_Grid_Y->set_sensitive( aPossibilityList[1] );
86 m_xCB_Grid_Z->set_sensitive( aPossibilityList[2] );
87 m_xCB_Grid_X->set_active( aExistenceList[0] );
88 m_xCB_Grid_Y->set_active( aExistenceList[1] );
89 m_xCB_Grid_Z->set_active( aExistenceList[2] );
90 }
91
92 m_bCommitToModel = true;
93}
94
96{
97 if( m_xTitleResources->get_value_changed_from_saved() ) //titles may have changed in the meanwhile
99 return true;//return false if this page should not be left
100}
101
103{
106
107 ControllerLockGuardUNO aLockedControllers( xModel );
108
109 //commit title changes to model
110 {
111 TitleDialogData aTitleOutput;
112 m_xTitleResources->readFromResources( aTitleOutput );
113 aTitleOutput.writeDifferenceToModel( xModel, m_xCC );
114 m_xTitleResources->save_value();
115 }
116
117 //commit legend changes to model
118 {
119 m_xLegendPositionResources->writeToModel( xModel );
120 }
121
122 //commit grid changes to model
123 {
124 rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram();
125 uno::Sequence< sal_Bool > aOldExistenceList;
126 AxisHelper::getAxisOrGridExistence( aOldExistenceList, xDiagram, false );
127 uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList);
128 sal_Bool* pNewExistenceList = aNewExistenceList.getArray();
129 pNewExistenceList[0] = m_xCB_Grid_X->get_active();
130 pNewExistenceList[1] = m_xCB_Grid_Y->get_active();
131 pNewExistenceList[2] = m_xCB_Grid_Z->get_active();
133 , aOldExistenceList, aNewExistenceList );
134 }
135}
136
138{
139 ChangeHdl(nullptr);
140}
141
143{
144 ChangeHdl(nullptr);
145}
146
148{
149 if( m_bCommitToModel )
150 commitToModel();
151}
152
154{
155 return false;
156}
157
158} //namespace chart
159
160/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void getAxisOrGridExistence(css::uno::Sequence< sal_Bool > &rExistenceList, const rtl::Reference< ::chart::Diagram > &xDiagram, bool bAxis=true)
Definition: AxisHelper.cxx:915
static void getAxisOrGridPossibilities(css::uno::Sequence< sal_Bool > &rPossibilityList, const rtl::Reference< ::chart::Diagram > &xDiagram, bool bAxis=true)
Definition: AxisHelper.cxx:846
static bool changeVisibilityOfGrids(const rtl::Reference< ::chart::Diagram > &xDiagram, const css::uno::Sequence< sal_Bool > &rOldExistenceList, const css::uno::Sequence< sal_Bool > &rNewExistenceList)
Definition: AxisHelper.cxx:963
This guard calls lockControllers at the given Model in the CTOR and unlockControllers in the DTOR.
TimerTriggeredControllerLock m_aTimerTriggeredControllerLock
css::uno::Reference< css::uno::XComponentContext > m_xCC
std::unique_ptr< LegendPositionResources > m_xLegendPositionResources
TitlesAndObjectsTabPage(weld::Container *pPage, weld::DialogController *pController, rtl::Reference<::chart::ChartModel > xChartModel, const css::uno::Reference< css::uno::XComponentContext > &xContext)
virtual bool canAdvance() const override
std::unique_ptr< weld::CheckButton > m_xCB_Grid_Y
virtual bool commitPage(::vcl::WizardTypes::CommitPageReason eReason) override
std::unique_ptr< weld::CheckButton > m_xCB_Grid_Z
rtl::Reference<::chart::ChartModel > m_xChartModel
std::unique_ptr< TitleResources > m_xTitleResources
std::unique_ptr< weld::CheckButton > m_xCB_Grid_X
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
bool writeDifferenceToModel(const rtl::Reference<::chart::ChartModel > &xChartModel, const css::uno::Reference< css::uno::XComponentContext > &xContext, const TitleDialogData *pOldState=nullptr)
void readFromModel(const rtl::Reference<::chart::ChartModel > &xChartModel)
Reference< XModel > xModel
unsigned char sal_Bool