1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 
31 #include "dlg_InsertTrendline.hxx"
32 #include "dlg_InsertTrendline.hrc"
33 #include "res_Trendline.hxx"
34 #include "ResourceIds.hrc"
35 #include "ResId.hxx"
36 #include "Strings.hrc"
37 #include "chartview/ExplicitValueProvider.hxx"
38 #include "ChartModelHelper.hxx"
39 #include "ObjectIdentifier.hxx"
40 #include "DiagramHelper.hxx"
41 #include "AxisHelper.hxx"
42 #include "ObjectNameProvider.hxx"
43 #include <com/sun/star/chart2/XAxis.hpp>
44 #include <com/sun/star/chart2/XDiagram.hpp>
45 
46 #include <svtools/controldims.hrc>
47 
48 using namespace ::com::sun::star;
49 using namespace ::com::sun::star::chart2;
50 
51 namespace
52 {
53 void lcl_SetControlXPos( Control & rControl, long nPosPixel )
54 {
55     Point aPos( rControl.GetPosPixel());
56     aPos.setX( nPosPixel );
57     rControl.SetPosPixel( aPos );
58 }
59 } // anonymous namespace
60 
61 //.............................................................................
62 namespace chart
63 {
64 //.............................................................................
65 
66 InsertTrendlineDialog::InsertTrendlineDialog( Window* pParent, const SfxItemSet& rMyAttrs ) :
67         ModalDialog( pParent, SchResId( DLG_DATA_TRENDLINE )),
68         rInAttrs( rMyAttrs ),
69         aBtnOK( this, SchResId( BTN_OK )),
70         aBtnCancel( this, SchResId( BTN_CANCEL )),
71         aBtnHelp( this, SchResId( BTN_HELP )),
72         m_apTrendlineResources( new TrendlineResources( this, rInAttrs, true ))
73 {
74     FreeResource();
75     this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) );
76 }
77 
78 InsertTrendlineDialog::~InsertTrendlineDialog()
79 {
80 }
81 
82 void InsertTrendlineDialog::adjustSize()
83 {
84     long nControlsRightEdge = m_apTrendlineResources->adjustControlSizes();
85     long nButtonXPos = nControlsRightEdge +
86         LogicToPixel( Size( RSC_SP_CTRL_X, 10 ), MapMode( MAP_APPFONT )).getWidth();
87     lcl_SetControlXPos( aBtnOK, nButtonXPos );
88     lcl_SetControlXPos( aBtnCancel, nButtonXPos );
89     lcl_SetControlXPos( aBtnHelp, nButtonXPos );
90 
91     Size aDialogSize( GetSizePixel());
92     aDialogSize.setWidth(
93         nControlsRightEdge +
94         LogicToPixel( Size( RSC_SP_CTRL_X + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_DLG_INNERBORDER_RIGHT, 0 ),
95                       MapMode( MAP_APPFONT )).getWidth());
96     SetSizePixel( aDialogSize );
97 }
98 
99 void InsertTrendlineDialog::FillItemSet(SfxItemSet& rOutAttrs)
100 {
101     m_apTrendlineResources->FillItemSet(rOutAttrs);
102 }
103 
104 void InsertTrendlineDialog::DataChanged( const DataChangedEvent& rDCEvt )
105 {
106     ModalDialog::DataChanged( rDCEvt );
107 
108     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
109         m_apTrendlineResources->FillValueSets();
110 }
111 
112 //.............................................................................
113 } //namespace chart
114 //.............................................................................
115