1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_chart2.hxx"
26 
27 #include "dlg_InsertTrendline.hxx"
28 #include "dlg_InsertTrendline.hrc"
29 #include "res_Trendline.hxx"
30 #include "ResourceIds.hrc"
31 #include "ResId.hxx"
32 #include "Strings.hrc"
33 #include "chartview/ExplicitValueProvider.hxx"
34 #include "ChartModelHelper.hxx"
35 #include "ObjectIdentifier.hxx"
36 #include "DiagramHelper.hxx"
37 #include "AxisHelper.hxx"
38 #include "ObjectNameProvider.hxx"
39 #include <com/sun/star/chart2/XAxis.hpp>
40 #include <com/sun/star/chart2/XDiagram.hpp>
41 
42 #include <svtools/controldims.hrc>
43 
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::chart2;
46 
47 namespace
48 {
lcl_SetControlXPos(Control & rControl,long nPosPixel)49 void lcl_SetControlXPos( Control & rControl, long nPosPixel )
50 {
51     Point aPos( rControl.GetPosPixel());
52     aPos.setX( nPosPixel );
53     rControl.SetPosPixel( aPos );
54 }
55 } // anonymous namespace
56 
57 //.............................................................................
58 namespace chart
59 {
60 //.............................................................................
61 
InsertTrendlineDialog(Window * pParent,const SfxItemSet & rMyAttrs)62 InsertTrendlineDialog::InsertTrendlineDialog( Window* pParent, const SfxItemSet& rMyAttrs ) :
63         ModalDialog( pParent, SchResId( DLG_DATA_TRENDLINE )),
64         rInAttrs( rMyAttrs ),
65         aBtnOK( this, SchResId( BTN_OK )),
66         aBtnCancel( this, SchResId( BTN_CANCEL )),
67         aBtnHelp( this, SchResId( BTN_HELP )),
68         m_apTrendlineResources( new TrendlineResources( this, rInAttrs, true ))
69 {
70     FreeResource();
71     this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) );
72 }
73 
~InsertTrendlineDialog()74 InsertTrendlineDialog::~InsertTrendlineDialog()
75 {
76 }
77 
adjustSize()78 void InsertTrendlineDialog::adjustSize()
79 {
80     long nControlsRightEdge = m_apTrendlineResources->adjustControlSizes();
81     long nButtonXPos = nControlsRightEdge +
82         LogicToPixel( Size( RSC_SP_CTRL_X, 10 ), MapMode( MAP_APPFONT )).getWidth();
83     lcl_SetControlXPos( aBtnOK, nButtonXPos );
84     lcl_SetControlXPos( aBtnCancel, nButtonXPos );
85     lcl_SetControlXPos( aBtnHelp, nButtonXPos );
86 
87     Size aDialogSize( GetSizePixel());
88     aDialogSize.setWidth(
89         nControlsRightEdge +
90         LogicToPixel( Size( RSC_SP_CTRL_X + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_DLG_INNERBORDER_RIGHT, 0 ),
91                       MapMode( MAP_APPFONT )).getWidth());
92     SetSizePixel( aDialogSize );
93 }
94 
FillItemSet(SfxItemSet & rOutAttrs)95 void InsertTrendlineDialog::FillItemSet(SfxItemSet& rOutAttrs)
96 {
97     m_apTrendlineResources->FillItemSet(rOutAttrs);
98 }
99 
DataChanged(const DataChangedEvent & rDCEvt)100 void InsertTrendlineDialog::DataChanged( const DataChangedEvent& rDCEvt )
101 {
102     ModalDialog::DataChanged( rDCEvt );
103 
104     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
105         m_apTrendlineResources->FillValueSets();
106 }
107 
108 //.............................................................................
109 } //namespace chart
110 //.............................................................................
111