1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19*cde9e8dcSAndrew Rist  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "res_Titles.hxx"
28cdf0e10cSrcweir #include "res_Titles.hrc"
29cdf0e10cSrcweir #include "ResId.hxx"
30cdf0e10cSrcweir #include "TitleDialogData.hxx"
31cdf0e10cSrcweir 
32cdf0e10cSrcweir  #ifndef _SVT_CONTROLDIMS_HRC_
33cdf0e10cSrcweir  #include <svtools/controldims.hrc>
34cdf0e10cSrcweir  #endif
35cdf0e10cSrcweir 
36cdf0e10cSrcweir //.............................................................................
37cdf0e10cSrcweir namespace chart
38cdf0e10cSrcweir {
39cdf0e10cSrcweir //.............................................................................
40cdf0e10cSrcweir 
TitleResources(Window * pWindow,bool bShowSecondaryAxesTitle)41cdf0e10cSrcweir TitleResources::TitleResources( Window* pWindow, bool bShowSecondaryAxesTitle )
42cdf0e10cSrcweir     : m_aFT_Main(pWindow, SchResId(FT_MAINTITLE))
43cdf0e10cSrcweir 	, m_aEd_Main(pWindow, SchResId(ED_MAINTITLE))
44cdf0e10cSrcweir 	, m_aFT_Sub(pWindow, SchResId(FT_SUBTITLE))
45cdf0e10cSrcweir 	, m_aEd_Sub(pWindow, SchResId(ED_SUBTITLE))
46cdf0e10cSrcweir     , m_aFL_Axes(pWindow, SchResId(FL_AXES))
47cdf0e10cSrcweir 	, m_aFT_XAxis(pWindow, SchResId(FT_TITLE_X_AXIS))
48cdf0e10cSrcweir 	, m_aEd_XAxis(pWindow, SchResId(ED_X_AXIS))
49cdf0e10cSrcweir 	, m_aFT_YAxis(pWindow, SchResId(FT_TITLE_Y_AXIS))
50cdf0e10cSrcweir 	, m_aEd_YAxis(pWindow, SchResId(ED_Y_AXIS))
51cdf0e10cSrcweir 	, m_aFT_ZAxis(pWindow, SchResId(FT_TITLE_Z_AXIS))
52cdf0e10cSrcweir 	, m_aEd_ZAxis(pWindow, SchResId(ED_Z_AXIS))
53cdf0e10cSrcweir     , m_aFL_SecondaryAxes(pWindow, SchResId(FL_SECONDARY_AXES))
54cdf0e10cSrcweir     , m_aFT_SecondaryXAxis(pWindow, SchResId(FT_TITLE_SECONDARY_X_AXIS))
55cdf0e10cSrcweir     , m_aEd_SecondaryXAxis(pWindow, SchResId(ED_SECONDARY_X_AXIS))
56cdf0e10cSrcweir     , m_aFT_SecondaryYAxis(pWindow, SchResId(FT_TITLE_SECONDARY_Y_AXIS))
57cdf0e10cSrcweir     , m_aEd_SecondaryYAxis(pWindow, SchResId(ED_SECONDARY_Y_AXIS))
58cdf0e10cSrcweir {
59cdf0e10cSrcweir      long nMaxTextWidth = ::std::max( m_aFT_Main.CalcMinimumSize().Width(),m_aFT_Sub.CalcMinimumSize().Width() ) ;
60cdf0e10cSrcweir      nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_XAxis.CalcMinimumSize().Width() ) ;
61cdf0e10cSrcweir      nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_YAxis.CalcMinimumSize().Width() ) ;
62cdf0e10cSrcweir      nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_ZAxis.CalcMinimumSize().Width() ) ;
63cdf0e10cSrcweir      if( bShowSecondaryAxesTitle )
64cdf0e10cSrcweir      {
65cdf0e10cSrcweir          nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryXAxis.CalcMinimumSize().Width() ) ;
66cdf0e10cSrcweir          nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryYAxis.CalcMinimumSize().Width() ) ;
67cdf0e10cSrcweir      }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir      Size aControlDistance( m_aFT_Main.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) );
70cdf0e10cSrcweir      long nEditFieldXPos = m_aFT_Main.GetPosPixel().X() + nMaxTextWidth + aControlDistance.Width();
71cdf0e10cSrcweir      long nEditFieldWidth = m_aEd_Main.GetPosPixel().X() + m_aEd_Main.GetSizePixel().Width() - nEditFieldXPos;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir      if( nEditFieldWidth > 10 )
74cdf0e10cSrcweir      {
75cdf0e10cSrcweir          Size aFTSize( m_aFT_Main.GetSizePixel() );
76cdf0e10cSrcweir          aFTSize.Width() = nMaxTextWidth;
77cdf0e10cSrcweir          m_aFT_Main.SetSizePixel(aFTSize);
78cdf0e10cSrcweir  	     m_aFT_Sub.SetSizePixel(aFTSize);
79cdf0e10cSrcweir          m_aFT_XAxis.SetSizePixel(aFTSize);
80cdf0e10cSrcweir          m_aFT_YAxis.SetSizePixel(aFTSize);
81cdf0e10cSrcweir          m_aFT_ZAxis.SetSizePixel(aFTSize);
82cdf0e10cSrcweir          if( bShowSecondaryAxesTitle )
83cdf0e10cSrcweir          {
84cdf0e10cSrcweir              m_aFT_SecondaryXAxis.SetSizePixel(aFTSize);
85cdf0e10cSrcweir              m_aFT_SecondaryYAxis.SetSizePixel(aFTSize);
86cdf0e10cSrcweir          }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir          m_aEd_Main.SetPosPixel( Point( nEditFieldXPos, m_aEd_Main.GetPosPixel().Y() ) );
89cdf0e10cSrcweir          m_aEd_Sub.SetPosPixel( Point( nEditFieldXPos, m_aEd_Sub.GetPosPixel().Y() ) );
90cdf0e10cSrcweir          m_aEd_XAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_XAxis.GetPosPixel().Y() ) );
91cdf0e10cSrcweir          m_aEd_YAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_YAxis.GetPosPixel().Y() ) );
92cdf0e10cSrcweir          m_aEd_ZAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_ZAxis.GetPosPixel().Y() ) );
93cdf0e10cSrcweir          if(bShowSecondaryAxesTitle)
94cdf0e10cSrcweir          {
95cdf0e10cSrcweir              m_aEd_SecondaryXAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryXAxis.GetPosPixel().Y() ) );
96cdf0e10cSrcweir              m_aEd_SecondaryYAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryYAxis.GetPosPixel().Y() ) );
97cdf0e10cSrcweir          }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir          Size aEditSize( m_aEd_Main.GetSizePixel() );
100cdf0e10cSrcweir          aEditSize.Width() = nEditFieldWidth;
101cdf0e10cSrcweir          m_aEd_Main.SetSizePixel( aEditSize );
102cdf0e10cSrcweir          m_aEd_Sub.SetSizePixel( aEditSize );
103cdf0e10cSrcweir          m_aEd_XAxis.SetSizePixel( aEditSize );
104cdf0e10cSrcweir          m_aEd_YAxis.SetSizePixel( aEditSize );
105cdf0e10cSrcweir          m_aEd_ZAxis.SetSizePixel( aEditSize );
106cdf0e10cSrcweir          if(bShowSecondaryAxesTitle)
107cdf0e10cSrcweir          {
108cdf0e10cSrcweir              m_aEd_SecondaryXAxis.SetSizePixel( aEditSize );
109cdf0e10cSrcweir              m_aEd_SecondaryYAxis.SetSizePixel( aEditSize );
110cdf0e10cSrcweir          }
111cdf0e10cSrcweir      }
112cdf0e10cSrcweir 
113cdf0e10cSrcweir      m_aFT_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
114cdf0e10cSrcweir      m_aEd_SecondaryXAxis.Show( bShowSecondaryAxesTitle );
115cdf0e10cSrcweir      m_aFT_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
116cdf0e10cSrcweir      m_aEd_SecondaryYAxis.Show( bShowSecondaryAxesTitle );
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
~TitleResources()119cdf0e10cSrcweir TitleResources::~TitleResources()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
SetUpdateDataHdl(const Link & rLink)123cdf0e10cSrcweir void TitleResources::SetUpdateDataHdl( const Link& rLink )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     m_aEd_Main.EnableUpdateData( nTimeout );
128cdf0e10cSrcweir     m_aEd_Main.SetUpdateDataHdl( rLink );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     m_aEd_Sub.EnableUpdateData( nTimeout );
131cdf0e10cSrcweir     m_aEd_Sub.SetUpdateDataHdl( rLink );
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     m_aEd_XAxis.EnableUpdateData( nTimeout );
134cdf0e10cSrcweir     m_aEd_XAxis.SetUpdateDataHdl( rLink );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     m_aEd_YAxis.EnableUpdateData( nTimeout );
137cdf0e10cSrcweir     m_aEd_YAxis.SetUpdateDataHdl( rLink );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     m_aEd_ZAxis.EnableUpdateData( nTimeout );
140cdf0e10cSrcweir     m_aEd_ZAxis.SetUpdateDataHdl( rLink );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     m_aEd_SecondaryXAxis.EnableUpdateData( nTimeout );
143cdf0e10cSrcweir     m_aEd_SecondaryXAxis.SetUpdateDataHdl( rLink );
144cdf0e10cSrcweir 
145cdf0e10cSrcweir     m_aEd_SecondaryYAxis.EnableUpdateData( nTimeout );
146cdf0e10cSrcweir     m_aEd_SecondaryYAxis.SetUpdateDataHdl( rLink );
147cdf0e10cSrcweir }
148cdf0e10cSrcweir 
IsModified()149cdf0e10cSrcweir bool TitleResources::IsModified()
150cdf0e10cSrcweir {
151cdf0e10cSrcweir     return m_aEd_Main.IsModified()
152cdf0e10cSrcweir         || m_aEd_Sub.IsModified()
153cdf0e10cSrcweir         || m_aEd_XAxis.IsModified()
154cdf0e10cSrcweir         || m_aEd_YAxis.IsModified()
155cdf0e10cSrcweir         || m_aEd_ZAxis.IsModified()
156cdf0e10cSrcweir         || m_aEd_SecondaryXAxis.IsModified()
157cdf0e10cSrcweir         || m_aEd_SecondaryYAxis.IsModified();
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
ClearModifyFlag()160cdf0e10cSrcweir void TitleResources::ClearModifyFlag()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     m_aEd_Main.ClearModifyFlag();
163cdf0e10cSrcweir     m_aEd_Sub.ClearModifyFlag();
164cdf0e10cSrcweir     m_aEd_XAxis.ClearModifyFlag();
165cdf0e10cSrcweir     m_aEd_YAxis.ClearModifyFlag();
166cdf0e10cSrcweir     m_aEd_ZAxis.ClearModifyFlag();
167cdf0e10cSrcweir     m_aEd_SecondaryXAxis.ClearModifyFlag();
168cdf0e10cSrcweir     m_aEd_SecondaryYAxis.ClearModifyFlag();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
writeToResources(const TitleDialogData & rInput)171cdf0e10cSrcweir void TitleResources::writeToResources( const TitleDialogData& rInput )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     m_aFT_Main.Enable( rInput.aPossibilityList[0] );
174cdf0e10cSrcweir     m_aFT_Sub.Enable( rInput.aPossibilityList[1] );
175cdf0e10cSrcweir     m_aFT_XAxis.Enable( rInput.aPossibilityList[2] );
176cdf0e10cSrcweir     m_aFT_YAxis.Enable( rInput.aPossibilityList[3] );
177cdf0e10cSrcweir     m_aFT_ZAxis.Enable( rInput.aPossibilityList[4] );
178cdf0e10cSrcweir     m_aFT_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
179cdf0e10cSrcweir     m_aFT_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
180cdf0e10cSrcweir 
181cdf0e10cSrcweir     m_aEd_Main.Enable( rInput.aPossibilityList[0] );
182cdf0e10cSrcweir     m_aEd_Sub.Enable( rInput.aPossibilityList[1] );
183cdf0e10cSrcweir     m_aEd_XAxis.Enable( rInput.aPossibilityList[2] );
184cdf0e10cSrcweir     m_aEd_YAxis.Enable( rInput.aPossibilityList[3] );
185cdf0e10cSrcweir     m_aEd_ZAxis.Enable( rInput.aPossibilityList[4] );
186cdf0e10cSrcweir     m_aEd_SecondaryXAxis.Enable( rInput.aPossibilityList[5] );
187cdf0e10cSrcweir     m_aEd_SecondaryYAxis.Enable( rInput.aPossibilityList[6] );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     m_aEd_Main.SetText(rInput.aTextList[0]);
190cdf0e10cSrcweir     m_aEd_Sub.SetText(rInput.aTextList[1]);
191cdf0e10cSrcweir     m_aEd_XAxis.SetText(rInput.aTextList[2]);
192cdf0e10cSrcweir     m_aEd_YAxis.SetText(rInput.aTextList[3]);
193cdf0e10cSrcweir     m_aEd_ZAxis.SetText(rInput.aTextList[4]);
194cdf0e10cSrcweir     m_aEd_SecondaryXAxis.SetText(rInput.aTextList[5]);
195cdf0e10cSrcweir     m_aEd_SecondaryYAxis.SetText(rInput.aTextList[6]);
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
readFromResources(TitleDialogData & rOutput)198cdf0e10cSrcweir void TitleResources::readFromResources( TitleDialogData& rOutput )
199cdf0e10cSrcweir {
200cdf0e10cSrcweir     rOutput.aExistenceList[0] = static_cast<sal_Bool>(m_aEd_Main.GetText().Len()!=0);
201cdf0e10cSrcweir     rOutput.aExistenceList[1] = static_cast<sal_Bool>(m_aEd_Sub.GetText().Len()!=0);
202cdf0e10cSrcweir     rOutput.aExistenceList[2] = static_cast<sal_Bool>(m_aEd_XAxis.GetText().Len()!=0);
203cdf0e10cSrcweir     rOutput.aExistenceList[3] = static_cast<sal_Bool>(m_aEd_YAxis.GetText().Len()!=0);
204cdf0e10cSrcweir     rOutput.aExistenceList[4] = static_cast<sal_Bool>(m_aEd_ZAxis.GetText().Len()!=0);
205cdf0e10cSrcweir     rOutput.aExistenceList[5] = static_cast<sal_Bool>(m_aEd_SecondaryXAxis.GetText().Len()!=0);
206cdf0e10cSrcweir     rOutput.aExistenceList[6] = static_cast<sal_Bool>(m_aEd_SecondaryYAxis.GetText().Len()!=0);
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     rOutput.aTextList[0] = m_aEd_Main.GetText();
209cdf0e10cSrcweir     rOutput.aTextList[1] = m_aEd_Sub.GetText();
210cdf0e10cSrcweir     rOutput.aTextList[2] = m_aEd_XAxis.GetText();
211cdf0e10cSrcweir     rOutput.aTextList[3] = m_aEd_YAxis.GetText();
212cdf0e10cSrcweir     rOutput.aTextList[4] = m_aEd_ZAxis.GetText();
213cdf0e10cSrcweir     rOutput.aTextList[5] = m_aEd_SecondaryXAxis.GetText();
214cdf0e10cSrcweir     rOutput.aTextList[6] = m_aEd_SecondaryYAxis.GetText();
215cdf0e10cSrcweir }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir //.............................................................................
218cdf0e10cSrcweir } //namespace chart
219cdf0e10cSrcweir //.............................................................................
220cdf0e10cSrcweir 
221