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 "res_Titles.hxx"
28 #include "res_Titles.hrc"
29 #include "ResId.hxx"
30 #include "TitleDialogData.hxx"
31
32 #ifndef _SVT_CONTROLDIMS_HRC_
33 #include <svtools/controldims.hrc>
34 #endif
35
36 //.............................................................................
37 namespace chart
38 {
39 //.............................................................................
40
TitleResources(Window * pWindow,bool bShowSecondaryAxesTitle)41 TitleResources::TitleResources( Window* pWindow, bool bShowSecondaryAxesTitle )
42 : m_aFT_Main(pWindow, SchResId(FT_MAINTITLE))
43 , m_aEd_Main(pWindow, SchResId(ED_MAINTITLE))
44 , m_aFT_Sub(pWindow, SchResId(FT_SUBTITLE))
45 , m_aEd_Sub(pWindow, SchResId(ED_SUBTITLE))
46 , m_aFL_Axes(pWindow, SchResId(FL_AXES))
47 , m_aFT_XAxis(pWindow, SchResId(FT_TITLE_X_AXIS))
48 , m_aEd_XAxis(pWindow, SchResId(ED_X_AXIS))
49 , m_aFT_YAxis(pWindow, SchResId(FT_TITLE_Y_AXIS))
50 , m_aEd_YAxis(pWindow, SchResId(ED_Y_AXIS))
51 , m_aFT_ZAxis(pWindow, SchResId(FT_TITLE_Z_AXIS))
52 , m_aEd_ZAxis(pWindow, SchResId(ED_Z_AXIS))
53 , m_aFL_SecondaryAxes(pWindow, SchResId(FL_SECONDARY_AXES))
54 , m_aFT_SecondaryXAxis(pWindow, SchResId(FT_TITLE_SECONDARY_X_AXIS))
55 , m_aEd_SecondaryXAxis(pWindow, SchResId(ED_SECONDARY_X_AXIS))
56 , m_aFT_SecondaryYAxis(pWindow, SchResId(FT_TITLE_SECONDARY_Y_AXIS))
57 , m_aEd_SecondaryYAxis(pWindow, SchResId(ED_SECONDARY_Y_AXIS))
58 {
59 long nMaxTextWidth = ::std::max( m_aFT_Main.CalcMinimumSize().Width(),m_aFT_Sub.CalcMinimumSize().Width() ) ;
60 nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_XAxis.CalcMinimumSize().Width() ) ;
61 nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_YAxis.CalcMinimumSize().Width() ) ;
62 nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_ZAxis.CalcMinimumSize().Width() ) ;
63 if( bShowSecondaryAxesTitle )
64 {
65 nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryXAxis.CalcMinimumSize().Width() ) ;
66 nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryYAxis.CalcMinimumSize().Width() ) ;
67 }
68
69 Size aControlDistance( m_aFT_Main.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) );
70 long nEditFieldXPos = m_aFT_Main.GetPosPixel().X() + nMaxTextWidth + aControlDistance.Width();
71 long nEditFieldWidth = m_aEd_Main.GetPosPixel().X() + m_aEd_Main.GetSizePixel().Width() - nEditFieldXPos;
72
73 if( nEditFieldWidth > 10 )
74 {
75 Size aFTSize( m_aFT_Main.GetSizePixel() );
76 aFTSize.Width() = nMaxTextWidth;
77 m_aFT_Main.SetSizePixel(aFTSize);
78 m_aFT_Sub.SetSizePixel(aFTSize);
79 m_aFT_XAxis.SetSizePixel(aFTSize);
80 m_aFT_YAxis.SetSizePixel(aFTSize);
81 m_aFT_ZAxis.SetSizePixel(aFTSize);
82 if( bShowSecondaryAxesTitle )
83 {
84 m_aFT_SecondaryXAxis.SetSizePixel(aFTSize);
85 m_aFT_SecondaryYAxis.SetSizePixel(aFTSize);
86 }
87
88 m_aEd_Main.SetPosPixel( Point( nEditFieldXPos, m_aEd_Main.GetPosPixel().Y() ) );
89 m_aEd_Sub.SetPosPixel( Point( nEditFieldXPos, m_aEd_Sub.GetPosPixel().Y() ) );
90 m_aEd_XAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_XAxis.GetPosPixel().Y() ) );
91 m_aEd_YAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_YAxis.GetPosPixel().Y() ) );
92 m_aEd_ZAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_ZAxis.GetPosPixel().Y() ) );
93 if(bShowSecondaryAxesTitle)
94 {
95 m_aEd_SecondaryXAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryXAxis.GetPosPixel().Y() ) );
96 m_aEd_SecondaryYAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryYAxis.GetPosPixel().Y() ) );
97 }
98
99 Size aEditSize( m_aEd_Main.GetSizePixel() );
100 aEditSize.Width() = nEditFieldWidth;
101 m_aEd_Main.SetSizePixel( aEditSize );
102 m_aEd_Sub.SetSizePixel( aEditSize );
103 m_aEd_XAxis.SetSizePixel( aEditSize );
104 m_aEd_YAxis.SetSizePixel( aEditSize );
105 m_aEd_ZAxis.SetSizePixel( aEditSize );
106 if(bShowSecondaryAxesTitle)
107 {
108 m_aEd_SecondaryXAxis.SetSizePixel( aEditSize );
109 m_aEd_SecondaryYAxis.SetSizePixel( aEditSize );
110 }
111 }
112
113 m_aFT_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
114 m_aEd_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
115 m_aFT_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
116 m_aEd_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
117 }
118
~TitleResources()119 TitleResources::~TitleResources()
120 {
121 }
122
SetUpdateDataHdl(const Link & rLink)123 void TitleResources::SetUpdateDataHdl( const Link& rLink )
124 {
125 sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT;
126
127 m_aEd_Main.EnableUpdateData( nTimeout );
128 m_aEd_Main.SetUpdateDataHdl( rLink );
129
130 m_aEd_Sub.EnableUpdateData( nTimeout );
131 m_aEd_Sub.SetUpdateDataHdl( rLink );
132
133 m_aEd_XAxis.EnableUpdateData( nTimeout );
134 m_aEd_XAxis.SetUpdateDataHdl( rLink );
135
136 m_aEd_YAxis.EnableUpdateData( nTimeout );
137 m_aEd_YAxis.SetUpdateDataHdl( rLink );
138
139 m_aEd_ZAxis.EnableUpdateData( nTimeout );
140 m_aEd_ZAxis.SetUpdateDataHdl( rLink );
141
142 m_aEd_SecondaryXAxis.EnableUpdateData( nTimeout );
143 m_aEd_SecondaryXAxis.SetUpdateDataHdl( rLink );
144
145 m_aEd_SecondaryYAxis.EnableUpdateData( nTimeout );
146 m_aEd_SecondaryYAxis.SetUpdateDataHdl( rLink );
147 }
148
IsModified()149 bool TitleResources::IsModified()
150 {
151 return m_aEd_Main.IsModified()
152 || m_aEd_Sub.IsModified()
153 || m_aEd_XAxis.IsModified()
154 || m_aEd_YAxis.IsModified()
155 || m_aEd_ZAxis.IsModified()
156 || m_aEd_SecondaryXAxis.IsModified()
157 || m_aEd_SecondaryYAxis.IsModified();
158 }
159
ClearModifyFlag()160 void TitleResources::ClearModifyFlag()
161 {
162 m_aEd_Main.ClearModifyFlag();
163 m_aEd_Sub.ClearModifyFlag();
164 m_aEd_XAxis.ClearModifyFlag();
165 m_aEd_YAxis.ClearModifyFlag();
166 m_aEd_ZAxis.ClearModifyFlag();
167 m_aEd_SecondaryXAxis.ClearModifyFlag();
168 m_aEd_SecondaryYAxis.ClearModifyFlag();
169 }
170
writeToResources(const TitleDialogData & rInput)171 void TitleResources::writeToResources( const TitleDialogData& rInput )
172 {
173 m_aFT_Main.Enable( rInput.aPossibilityList[0] );
174 m_aFT_Sub.Enable( rInput.aPossibilityList[1] );
175 m_aFT_XAxis.Enable( rInput.aPossibilityList[2] );
176 m_aFT_YAxis.Enable( rInput.aPossibilityList[3] );
177 m_aFT_ZAxis.Enable( rInput.aPossibilityList[4] );
178 m_aFT_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
179 m_aFT_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
180
181 m_aEd_Main.Enable( rInput.aPossibilityList[0] );
182 m_aEd_Sub.Enable( rInput.aPossibilityList[1] );
183 m_aEd_XAxis.Enable( rInput.aPossibilityList[2] );
184 m_aEd_YAxis.Enable( rInput.aPossibilityList[3] );
185 m_aEd_ZAxis.Enable( rInput.aPossibilityList[4] );
186 m_aEd_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
187 m_aEd_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
188
189 m_aEd_Main.SetText(rInput.aTextList[0]);
190 m_aEd_Sub.SetText(rInput.aTextList[1]);
191 m_aEd_XAxis.SetText(rInput.aTextList[2]);
192 m_aEd_YAxis.SetText(rInput.aTextList[3]);
193 m_aEd_ZAxis.SetText(rInput.aTextList[4]);
194 m_aEd_SecondaryXAxis.SetText(rInput.aTextList[5]);
195 m_aEd_SecondaryYAxis.SetText(rInput.aTextList[6]);
196 }
197
readFromResources(TitleDialogData & rOutput)198 void TitleResources::readFromResources( TitleDialogData& rOutput )
199 {
200 rOutput.aExistenceList[0] = static_cast<sal_Bool>(m_aEd_Main.GetText().Len()!=0);
201 rOutput.aExistenceList[1] = static_cast<sal_Bool>(m_aEd_Sub.GetText().Len()!=0);
202 rOutput.aExistenceList[2] = static_cast<sal_Bool>(m_aEd_XAxis.GetText().Len()!=0);
203 rOutput.aExistenceList[3] = static_cast<sal_Bool>(m_aEd_YAxis.GetText().Len()!=0);
204 rOutput.aExistenceList[4] = static_cast<sal_Bool>(m_aEd_ZAxis.GetText().Len()!=0);
205 rOutput.aExistenceList[5] = static_cast<sal_Bool>(m_aEd_SecondaryXAxis.GetText().Len()!=0);
206 rOutput.aExistenceList[6] = static_cast<sal_Bool>(m_aEd_SecondaryYAxis.GetText().Len()!=0);
207
208 rOutput.aTextList[0] = m_aEd_Main.GetText();
209 rOutput.aTextList[1] = m_aEd_Sub.GetText();
210 rOutput.aTextList[2] = m_aEd_XAxis.GetText();
211 rOutput.aTextList[3] = m_aEd_YAxis.GetText();
212 rOutput.aTextList[4] = m_aEd_ZAxis.GetText();
213 rOutput.aTextList[5] = m_aEd_SecondaryXAxis.GetText();
214 rOutput.aTextList[6] = m_aEd_SecondaryYAxis.GetText();
215 }
216
217 //.............................................................................
218 } //namespace chart
219 //.............................................................................
220
221