1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "res_TextSeparator.hxx"
32 #include "ResourceIds.hrc"
33 #include "Strings.hrc"
37 #ifndef _SVT_CONTROLDIMS_HRC_
38 #include <svtools/controldims.hrc>
41 //.............................................................................
44 //.............................................................................
46 TextSeparatorResources::TextSeparatorResources( Window
* pWindow
)
47 : m_aFT_Separator( pWindow
, pWindow
->GetStyle() )
48 , m_aLB_Separator( pWindow
, SchResId( LB_TEXT_SEPARATOR
) )
52 m_aFT_Separator
.SetText( String( SchResId( STR_TEXT_SEPARATOR
)) );
53 m_aFT_Separator
.SetSizePixel( m_aFT_Separator
.CalcMinimumSize() );
55 m_aLB_Separator
.SetDropDownLineCount(m_aLB_Separator
.GetEntryCount());
56 m_aLB_Separator
.SetSizePixel( m_aLB_Separator
.CalcMinimumSize() );
58 m_aEntryMap
[ C2U( " " ) ] = 0;
59 m_aEntryMap
[ C2U( ", " ) ] = 1;
60 m_aEntryMap
[ C2U( "; " ) ] = 2;
61 m_aEntryMap
[ C2U( "\n" ) ] = 3;
63 TextSeparatorResources::~TextSeparatorResources()
66 void TextSeparatorResources::Show( bool bShow
)
68 m_aFT_Separator
.Show( bShow
);
69 m_aLB_Separator
.Show( bShow
);
71 void TextSeparatorResources::Enable( bool bEnable
)
73 m_aFT_Separator
.Enable( bEnable
);
74 m_aLB_Separator
.Enable( bEnable
);
76 void TextSeparatorResources::PositionBelowControl( const Window
& rWindow
)
78 Point
aPoint( rWindow
.GetPosPixel() );
79 Size
aSize( rWindow
.GetSizePixel() );
80 aPoint
.Y() += aSize
.Height();
81 Size
aBigDistanceSize( rWindow
.LogicToPixel( Size(0,RSC_SP_CTRL_Y
), MapMode(MAP_APPFONT
) ) );
82 aPoint
.Y() += aBigDistanceSize
.Height();
84 Size
aDistanceSize( rWindow
.LogicToPixel( Size(RSC_SP_CTRL_DESC_X
, (RSC_CD_DROPDOWN_HEIGHT
-RSC_CD_FIXEDTEXT_HEIGHT
)/2), MapMode(MAP_APPFONT
) ) );
85 aPoint
.Y() += aDistanceSize
.Height();
87 m_aFT_Separator
.SetPosPixel( aPoint
);
88 m_aLB_Separator
.SetPosPixel( Point( aPoint
.X()+m_aFT_Separator
.GetSizePixel().Width()+aDistanceSize
.Width(), aPoint
.Y()-aDistanceSize
.Height()-1) );
91 void TextSeparatorResources::AlignListBoxWidthAndXPos( long nWantedLeftBorder
/*use -1 to indicate that this can be automatic*/
92 , long nWantedRightBorder
/*use -1 to indicate that this can be automatic*/
93 , long nMinimumListBoxWidth
/*use -1 to indicate that this can be automatic*/ )
95 long nMinPossibleLeftBorder
= m_aFT_Separator
.GetPosPixel().X() + m_aFT_Separator
.GetSizePixel().Width() + 1 ;
96 if( nWantedLeftBorder
>= 0 && nWantedLeftBorder
>nMinPossibleLeftBorder
)
98 Point
aPos( m_aLB_Separator
.GetPosPixel() );
99 aPos
.X() = nWantedLeftBorder
;
100 m_aLB_Separator
.SetPosPixel( aPos
);
103 long nMinPossibleRightBorder
= m_aLB_Separator
.GetPosPixel().X() + m_aLB_Separator
.CalcMinimumSize().Width() - 1 ;
104 if( nWantedRightBorder
< m_aLB_Separator
.GetPosPixel().X() + nMinimumListBoxWidth
)
105 nWantedRightBorder
= m_aLB_Separator
.GetPosPixel().X() + nMinimumListBoxWidth
;
107 if( nWantedRightBorder
>= 0 && nWantedRightBorder
> nMinPossibleRightBorder
)
109 Size
aSize( m_aLB_Separator
.GetSizePixel() );
110 aSize
.Width() = nWantedRightBorder
-m_aLB_Separator
.GetPosPixel().X();
111 m_aLB_Separator
.SetSizePixel(aSize
);
115 Point
TextSeparatorResources::GetCurrentListBoxPosition() const
117 return m_aLB_Separator
.GetPosPixel();
120 Size
TextSeparatorResources::GetCurrentListBoxSize() const
122 return m_aLB_Separator
.GetSizePixel();
125 void TextSeparatorResources::SetValue( const rtl::OUString
& rSeparator
)
127 ::std::map
< ::rtl::OUString
, USHORT
>::iterator
aIter( m_aEntryMap
.find(rSeparator
) );
128 if( aIter
== m_aEntryMap
.end() )
129 m_aLB_Separator
.SelectEntryPos( m_nDefaultPos
);
131 m_aLB_Separator
.SelectEntryPos( aIter
->second
);
134 void TextSeparatorResources::SetDefault()
136 m_aLB_Separator
.SelectEntryPos( m_nDefaultPos
);
139 rtl::OUString
TextSeparatorResources::GetValue() const
141 USHORT nPos
= m_aLB_Separator
.GetSelectEntryPos();
142 ::std::map
< ::rtl::OUString
, USHORT
>::const_iterator
aIter( m_aEntryMap
.begin() );
143 while( aIter
!= m_aEntryMap
.end() )
145 if(aIter
->second
==nPos
)
152 //.............................................................................
154 //.............................................................................