LCOV - code coverage report
Current view: top level - libreoffice/chart2/source/controller/dialogs - res_TextSeparator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-12-27 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "res_TextSeparator.hxx"
      22             : #include "ResourceIds.hrc"
      23             : #include "Strings.hrc"
      24             : #include "ResId.hxx"
      25             : #include "macros.hxx"
      26             : 
      27             : #include <svtools/controldims.hrc>
      28             : 
      29             : //.............................................................................
      30             : namespace chart
      31             : {
      32             : //.............................................................................
      33             : 
      34           0 : TextSeparatorResources::TextSeparatorResources( Window* pWindow )
      35             :     : m_aFT_Separator( pWindow, pWindow->GetStyle() )
      36             :     , m_aLB_Separator( pWindow , SchResId( LB_TEXT_SEPARATOR ) )
      37             :     , m_aEntryMap()
      38           0 :     , m_nDefaultPos(0)
      39             : {
      40           0 :     m_aFT_Separator.SetText( String( SchResId( STR_TEXT_SEPARATOR )) );
      41           0 :     m_aFT_Separator.SetSizePixel( m_aFT_Separator.CalcMinimumSize() );
      42             : 
      43           0 :     m_aLB_Separator.SetDropDownLineCount(m_aLB_Separator.GetEntryCount());
      44           0 :     m_aLB_Separator.SetSizePixel( m_aLB_Separator.CalcMinimumSize() );
      45             : 
      46           0 :     m_aEntryMap[ " " ] = 0;
      47           0 :     m_aEntryMap[ ", " ] = 1;
      48           0 :     m_aEntryMap[ "; " ] = 2;
      49           0 :     m_aEntryMap[ "\n" ] = 3;
      50             : 
      51           0 :     m_aLB_Separator.SetAccessibleName(m_aFT_Separator.GetText());
      52           0 :     m_aLB_Separator.SetAccessibleRelationLabeledBy(&m_aFT_Separator);
      53           0 : }
      54           0 : TextSeparatorResources::~TextSeparatorResources()
      55             : {
      56           0 : }
      57           0 : void TextSeparatorResources::Show( bool bShow )
      58             : {
      59           0 :     m_aFT_Separator.Show( bShow );
      60           0 :     m_aLB_Separator.Show( bShow );
      61           0 : }
      62           0 : void TextSeparatorResources::Enable( bool bEnable )
      63             : {
      64           0 :     m_aFT_Separator.Enable( bEnable );
      65           0 :     m_aLB_Separator.Enable( bEnable );
      66           0 : }
      67           0 : void TextSeparatorResources::PositionBelowControl( const Window& rWindow )
      68             : {
      69           0 :     Point aPoint( rWindow.GetPosPixel() );
      70           0 :     Size aSize( rWindow.GetSizePixel() );
      71           0 :     aPoint.Y() += aSize.Height();
      72           0 :     Size aBigDistanceSize( rWindow.LogicToPixel( Size(0,RSC_SP_CTRL_Y), MapMode(MAP_APPFONT) ) );
      73           0 :     aPoint.Y() += aBigDistanceSize.Height();
      74             : 
      75           0 :     Size aDistanceSize( rWindow.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, (RSC_CD_DROPDOWN_HEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2), MapMode(MAP_APPFONT) ) );
      76           0 :     aPoint.Y() += aDistanceSize.Height();
      77             : 
      78           0 :     m_aFT_Separator.SetPosPixel( aPoint );
      79           0 :     m_aLB_Separator.SetPosPixel( Point( aPoint.X()+m_aFT_Separator.GetSizePixel().Width()+aDistanceSize.Width(), aPoint.Y()-aDistanceSize.Height()-1) );
      80           0 : }
      81             : 
      82           0 : void TextSeparatorResources::AlignListBoxWidthAndXPos( long nWantedLeftBorder /*use -1 to indicate that this can be automatic*/
      83             :                                                      , long nWantedRightBorder /*use -1 to indicate that this can be automatic*/
      84             :                                                      , long nMinimumListBoxWidth /*use -1 to indicate that this can be automatic*/ )
      85             : {
      86           0 :     long nMinPossibleLeftBorder = m_aFT_Separator.GetPosPixel().X() + m_aFT_Separator.GetSizePixel().Width() + 1 ;
      87           0 :     if( nWantedLeftBorder >= 0 && nWantedLeftBorder>nMinPossibleLeftBorder )
      88             :     {
      89           0 :         Point aPos( m_aLB_Separator.GetPosPixel() );
      90           0 :         aPos.X() = nWantedLeftBorder;
      91           0 :         m_aLB_Separator.SetPosPixel( aPos );
      92             :     }
      93             : 
      94           0 :     long nMinPossibleRightBorder = m_aLB_Separator.GetPosPixel().X() + m_aLB_Separator.CalcMinimumSize().Width() - 1 ;
      95           0 :     if( nWantedRightBorder < m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth )
      96           0 :         nWantedRightBorder = m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth;
      97             : 
      98           0 :     if( nWantedRightBorder >= 0 && nWantedRightBorder > nMinPossibleRightBorder )
      99             :     {
     100           0 :         Size aSize( m_aLB_Separator.GetSizePixel() );
     101           0 :         aSize.Width() = nWantedRightBorder-m_aLB_Separator.GetPosPixel().X();
     102           0 :         m_aLB_Separator.SetSizePixel(aSize);
     103             :     }
     104           0 : }
     105             : 
     106           0 : Point TextSeparatorResources::GetCurrentListBoxPosition() const
     107             : {
     108           0 :     return m_aLB_Separator.GetPosPixel();
     109             : }
     110             : 
     111           0 : Size TextSeparatorResources::GetCurrentListBoxSize() const
     112             : {
     113           0 :     return m_aLB_Separator.GetSizePixel();
     114             : }
     115             : 
     116           0 : void TextSeparatorResources::SetValue( const OUString& rSeparator )
     117             : {
     118           0 :     ::std::map< OUString , sal_uInt16 >::iterator aIter( m_aEntryMap.find(rSeparator) );
     119           0 :     if( aIter == m_aEntryMap.end() )
     120           0 :         m_aLB_Separator.SelectEntryPos( m_nDefaultPos );
     121             :     else
     122           0 :         m_aLB_Separator.SelectEntryPos( aIter->second );
     123           0 : }
     124             : 
     125           0 : void TextSeparatorResources::SetDefault()
     126             : {
     127           0 :     m_aLB_Separator.SelectEntryPos( m_nDefaultPos );
     128           0 : }
     129             : 
     130           0 :  OUString TextSeparatorResources::GetValue() const
     131             : {
     132           0 :     sal_uInt16 nPos = m_aLB_Separator.GetSelectEntryPos();
     133           0 :     ::std::map< OUString , sal_uInt16 >::const_iterator aIter( m_aEntryMap.begin() );
     134           0 :     while( aIter != m_aEntryMap.end() )
     135             :     {
     136           0 :         if(aIter->second==nPos )
     137           0 :             return aIter->first;
     138           0 :         ++aIter;
     139             :     }
     140           0 :     return OUString( " " );
     141             : }
     142             : 
     143             : //.............................................................................
     144             : } //namespace chart
     145             : //.............................................................................
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10