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_TextSeparator.hxx"
28cdf0e10cSrcweir #include "ResourceIds.hrc"
29cdf0e10cSrcweir #include "Strings.hrc"
30cdf0e10cSrcweir #include "ResId.hxx"
31cdf0e10cSrcweir #include "macros.hxx"
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #ifndef _SVT_CONTROLDIMS_HRC_
34cdf0e10cSrcweir #include <svtools/controldims.hrc>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //.............................................................................
38cdf0e10cSrcweir namespace chart
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //.............................................................................
41cdf0e10cSrcweir 
TextSeparatorResources(Window * pWindow)42cdf0e10cSrcweir TextSeparatorResources::TextSeparatorResources( Window* pWindow )
43cdf0e10cSrcweir     : m_aFT_Separator( pWindow, pWindow->GetStyle() )
44cdf0e10cSrcweir 	, m_aLB_Separator( pWindow , SchResId( LB_TEXT_SEPARATOR ) )
45cdf0e10cSrcweir     , m_aEntryMap()
46cdf0e10cSrcweir     , m_nDefaultPos(0)
47cdf0e10cSrcweir {
48cdf0e10cSrcweir     m_aFT_Separator.SetText( String( SchResId( STR_TEXT_SEPARATOR )) );
49cdf0e10cSrcweir     m_aFT_Separator.SetSizePixel( m_aFT_Separator.CalcMinimumSize() );
50cdf0e10cSrcweir 
51cdf0e10cSrcweir     m_aLB_Separator.SetDropDownLineCount(m_aLB_Separator.GetEntryCount());
52cdf0e10cSrcweir     m_aLB_Separator.SetSizePixel( m_aLB_Separator.CalcMinimumSize() );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir     m_aEntryMap[ C2U( " " ) ] = 0;
55cdf0e10cSrcweir     m_aEntryMap[ C2U( ", " ) ] = 1;
56cdf0e10cSrcweir     m_aEntryMap[ C2U( "; " ) ] = 2;
57cdf0e10cSrcweir     m_aEntryMap[ C2U( "\n" ) ] = 3;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     m_aLB_Separator.SetAccessibleName(m_aFT_Separator.GetText());
60cdf0e10cSrcweir 	m_aLB_Separator.SetAccessibleRelationLabeledBy(&m_aFT_Separator);
61cdf0e10cSrcweir }
~TextSeparatorResources()62cdf0e10cSrcweir TextSeparatorResources::~TextSeparatorResources()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir }
Show(bool bShow)65cdf0e10cSrcweir void TextSeparatorResources::Show( bool bShow )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir     m_aFT_Separator.Show( bShow );
68cdf0e10cSrcweir     m_aLB_Separator.Show( bShow );
69cdf0e10cSrcweir }
Enable(bool bEnable)70cdf0e10cSrcweir void TextSeparatorResources::Enable( bool bEnable )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir     m_aFT_Separator.Enable( bEnable );
73cdf0e10cSrcweir     m_aLB_Separator.Enable( bEnable );
74cdf0e10cSrcweir }
PositionBelowControl(const Window & rWindow)75cdf0e10cSrcweir void TextSeparatorResources::PositionBelowControl( const Window& rWindow )
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     Point aPoint( rWindow.GetPosPixel() );
78cdf0e10cSrcweir     Size aSize( rWindow.GetSizePixel() );
79cdf0e10cSrcweir     aPoint.Y() += aSize.Height();
80cdf0e10cSrcweir     Size aBigDistanceSize( rWindow.LogicToPixel( Size(0,RSC_SP_CTRL_Y), MapMode(MAP_APPFONT) ) );
81cdf0e10cSrcweir     aPoint.Y() += aBigDistanceSize.Height();
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     Size aDistanceSize( rWindow.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, (RSC_CD_DROPDOWN_HEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2), MapMode(MAP_APPFONT) ) );
84cdf0e10cSrcweir     aPoint.Y() += aDistanceSize.Height();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     m_aFT_Separator.SetPosPixel( aPoint );
87cdf0e10cSrcweir     m_aLB_Separator.SetPosPixel( Point( aPoint.X()+m_aFT_Separator.GetSizePixel().Width()+aDistanceSize.Width(), aPoint.Y()-aDistanceSize.Height()-1) );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
AlignListBoxWidthAndXPos(long nWantedLeftBorder,long nWantedRightBorder,long nMinimumListBoxWidth)90cdf0e10cSrcweir void TextSeparatorResources::AlignListBoxWidthAndXPos( long nWantedLeftBorder /*use -1 to indicate that this can be automatic*/
91cdf0e10cSrcweir                                                      , long nWantedRightBorder /*use -1 to indicate that this can be automatic*/
92cdf0e10cSrcweir                                                      , long nMinimumListBoxWidth /*use -1 to indicate that this can be automatic*/ )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     long nMinPossibleLeftBorder = m_aFT_Separator.GetPosPixel().X() + m_aFT_Separator.GetSizePixel().Width() + 1 ;
95cdf0e10cSrcweir     if( nWantedLeftBorder >= 0 && nWantedLeftBorder>nMinPossibleLeftBorder )
96cdf0e10cSrcweir     {
97cdf0e10cSrcweir         Point aPos( m_aLB_Separator.GetPosPixel() );
98cdf0e10cSrcweir         aPos.X() = nWantedLeftBorder;
99cdf0e10cSrcweir         m_aLB_Separator.SetPosPixel( aPos );
100cdf0e10cSrcweir     }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     long nMinPossibleRightBorder = m_aLB_Separator.GetPosPixel().X() + m_aLB_Separator.CalcMinimumSize().Width() - 1 ;
103cdf0e10cSrcweir     if( nWantedRightBorder < m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth )
104cdf0e10cSrcweir         nWantedRightBorder = m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     if( nWantedRightBorder >= 0 && nWantedRightBorder > nMinPossibleRightBorder )
107cdf0e10cSrcweir     {
108cdf0e10cSrcweir         Size aSize( m_aLB_Separator.GetSizePixel() );
109cdf0e10cSrcweir         aSize.Width() = nWantedRightBorder-m_aLB_Separator.GetPosPixel().X();
110cdf0e10cSrcweir         m_aLB_Separator.SetSizePixel(aSize);
111cdf0e10cSrcweir     }
112cdf0e10cSrcweir }
113cdf0e10cSrcweir 
GetCurrentListBoxPosition() const114cdf0e10cSrcweir Point TextSeparatorResources::GetCurrentListBoxPosition() const
115cdf0e10cSrcweir {
116cdf0e10cSrcweir     return m_aLB_Separator.GetPosPixel();
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
GetCurrentListBoxSize() const119cdf0e10cSrcweir Size TextSeparatorResources::GetCurrentListBoxSize() const
120cdf0e10cSrcweir {
121cdf0e10cSrcweir     return m_aLB_Separator.GetSizePixel();
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
SetValue(const rtl::OUString & rSeparator)124cdf0e10cSrcweir void TextSeparatorResources::SetValue( const rtl::OUString& rSeparator )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     ::std::map< ::rtl::OUString, sal_uInt16 >::iterator aIter( m_aEntryMap.find(rSeparator) );
127cdf0e10cSrcweir     if( aIter == m_aEntryMap.end() )
128cdf0e10cSrcweir         m_aLB_Separator.SelectEntryPos( m_nDefaultPos );
129cdf0e10cSrcweir     else
130cdf0e10cSrcweir         m_aLB_Separator.SelectEntryPos( aIter->second );
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
SetDefault()133cdf0e10cSrcweir void TextSeparatorResources::SetDefault()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir     m_aLB_Separator.SelectEntryPos( m_nDefaultPos );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
GetValue() const138cdf0e10cSrcweir rtl::OUString TextSeparatorResources::GetValue() const
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     sal_uInt16 nPos = m_aLB_Separator.GetSelectEntryPos();
141cdf0e10cSrcweir     ::std::map< ::rtl::OUString, sal_uInt16 >::const_iterator aIter( m_aEntryMap.begin() );
142cdf0e10cSrcweir     while( aIter != m_aEntryMap.end() )
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir         if(aIter->second==nPos )
145cdf0e10cSrcweir             return aIter->first;
146cdf0e10cSrcweir         ++aIter;
147cdf0e10cSrcweir     }
148cdf0e10cSrcweir     return C2U( " " );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir //.............................................................................
152cdf0e10cSrcweir } //namespace chart
153cdf0e10cSrcweir //.............................................................................
154cdf0e10cSrcweir 
155