1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "tp_Wizard_TitlesAndObjects.hxx"
21 #include <res_Titles.hxx>
22 #include <res_LegendPosition.hxx>
23 #include <ChartModelHelper.hxx>
24 #include <AxisHelper.hxx>
25 #include <ControllerLockGuard.hxx>
26 #include <com/sun/star/frame/XModel.hpp>
30 using namespace ::com::sun::star
;
31 using namespace ::com::sun::star::chart2
;
33 TitlesAndObjectsTabPage::TitlesAndObjectsTabPage(weld::Container
* pPage
, weld::DialogController
* pController
,
34 const uno::Reference
< XChartDocument
>& xChartModel
,
35 const uno::Reference
< uno::XComponentContext
>& xContext
)
36 : OWizardPage(pPage
, pController
, "modules/schart/ui/wizelementspage.ui", "WizElementsPage")
37 , m_xTitleResources(new TitleResources(*m_xBuilder
, false))
38 , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder
, xContext
))
39 , m_xChartModel(xChartModel
)
41 , m_bCommitToModel(true)
42 , m_aTimerTriggeredControllerLock( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) )
43 , m_xCB_Grid_X(m_xBuilder
->weld_check_button("x"))
44 , m_xCB_Grid_Y(m_xBuilder
->weld_check_button("y"))
45 , m_xCB_Grid_Z(m_xBuilder
->weld_check_button("z"))
47 m_xTitleResources
->connect_changed( LINK( this, TitlesAndObjectsTabPage
, ChangeEditHdl
));
48 m_xLegendPositionResources
->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage
, ChangeHdl
));
50 m_xCB_Grid_X
->connect_toggled( LINK( this, TitlesAndObjectsTabPage
, ChangeCheckBoxHdl
));
51 m_xCB_Grid_Y
->connect_toggled( LINK( this, TitlesAndObjectsTabPage
, ChangeCheckBoxHdl
));
52 m_xCB_Grid_Z
->connect_toggled( LINK( this, TitlesAndObjectsTabPage
, ChangeCheckBoxHdl
));
55 TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage()
59 void TitlesAndObjectsTabPage::initializePage()
61 m_bCommitToModel
= false;
65 TitleDialogData aTitleInput
;
66 aTitleInput
.readFromModel( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
67 m_xTitleResources
->writeToResources( aTitleInput
);
72 m_xLegendPositionResources
->writeToResources( uno::Reference
< frame::XModel
>( m_xChartModel
, uno::UNO_QUERY
) );
75 //init grid checkboxes
77 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram( m_xChartModel
);
78 uno::Sequence
< sal_Bool
> aPossibilityList
;
79 uno::Sequence
< sal_Bool
> aExistenceList
;
80 AxisHelper::getAxisOrGridPossibilities( aPossibilityList
, xDiagram
, false );
81 AxisHelper::getAxisOrGridExcistence( aExistenceList
, xDiagram
, false );
82 m_xCB_Grid_X
->set_sensitive( aPossibilityList
[0] );
83 m_xCB_Grid_Y
->set_sensitive( aPossibilityList
[1] );
84 m_xCB_Grid_Z
->set_sensitive( aPossibilityList
[2] );
85 m_xCB_Grid_X
->set_active( aExistenceList
[0] );
86 m_xCB_Grid_Y
->set_active( aExistenceList
[1] );
87 m_xCB_Grid_Z
->set_active( aExistenceList
[2] );
90 m_bCommitToModel
= true;
93 bool TitlesAndObjectsTabPage::commitPage( ::vcl::WizardTypes::CommitPageReason
/*eReason*/ )
95 if( m_xTitleResources
->get_value_changed_from_saved() ) //titles may have changed in the meanwhile
97 return true;//return false if this page should not be left
100 void TitlesAndObjectsTabPage::commitToModel()
102 m_aTimerTriggeredControllerLock
.startTimer();
103 uno::Reference
< frame::XModel
> xModel( m_xChartModel
, uno::UNO_QUERY
);
105 ControllerLockGuardUNO
aLockedControllers( xModel
);
107 //commit title changes to model
109 TitleDialogData aTitleOutput
;
110 m_xTitleResources
->readFromResources( aTitleOutput
);
111 aTitleOutput
.writeDifferenceToModel( xModel
, m_xCC
);
112 m_xTitleResources
->save_value();
115 //commit legend changes to model
117 m_xLegendPositionResources
->writeToModel( xModel
);
120 //commit grid changes to model
122 uno::Reference
< XDiagram
> xDiagram
= ChartModelHelper::findDiagram( xModel
);
123 uno::Sequence
< sal_Bool
> aOldExistenceList
;
124 AxisHelper::getAxisOrGridExcistence( aOldExistenceList
, xDiagram
, false );
125 uno::Sequence
< sal_Bool
> aNewExistenceList(aOldExistenceList
);
126 aNewExistenceList
[0] = m_xCB_Grid_X
->get_active();
127 aNewExistenceList
[1] = m_xCB_Grid_Y
->get_active();
128 aNewExistenceList
[2] = m_xCB_Grid_Z
->get_active();
129 AxisHelper::changeVisibilityOfGrids( xDiagram
130 , aOldExistenceList
, aNewExistenceList
);
134 IMPL_LINK_NOARG(TitlesAndObjectsTabPage
, ChangeCheckBoxHdl
, weld::ToggleButton
&, void)
139 IMPL_LINK_NOARG(TitlesAndObjectsTabPage
, ChangeEditHdl
, weld::Entry
&, void)
144 IMPL_LINK_NOARG(TitlesAndObjectsTabPage
, ChangeHdl
, LinkParamNone
*, void)
146 if( m_bCommitToModel
)
150 bool TitlesAndObjectsTabPage::canAdvance() const
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */