LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - solveroptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 233 0.0 %
Date: 2012-08-25 Functions: 0 42 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 518 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "solveroptions.hxx"
      30                 :            : #include "solveroptions.hrc"
      31                 :            : #include "scresid.hxx"
      32                 :            : #include "global.hxx"
      33                 :            : #include "miscuno.hxx"
      34                 :            : #include "solverutil.hxx"
      35                 :            : 
      36                 :            : #include <rtl/math.hxx>
      37                 :            : #include <vcl/msgbox.hxx>
      38                 :            : #include <unotools/collatorwrapper.hxx>
      39                 :            : #include <unotools/localedatawrapper.hxx>
      40                 :            : 
      41                 :            : #include <algorithm>
      42                 :            : 
      43                 :            : #include <com/sun/star/sheet/Solver.hpp>
      44                 :            : #include <com/sun/star/sheet/XSolverDescription.hpp>
      45                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      46                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      47                 :            : 
      48                 :            : using namespace com::sun::star;
      49                 :            : 
      50                 :            : //==================================================================
      51                 :            : 
      52                 :            : /// Helper for sorting properties
      53                 :          0 : struct ScSolverOptionsEntry
      54                 :            : {
      55                 :            :     sal_Int32       nPosition;
      56                 :            :     rtl::OUString   aDescription;
      57                 :            : 
      58                 :          0 :     ScSolverOptionsEntry() : nPosition(0) {}
      59                 :            : 
      60                 :          0 :     bool operator< (const ScSolverOptionsEntry& rOther) const
      61                 :            :     {
      62                 :          0 :         return ( ScGlobal::GetCollator()->compareString( aDescription, rOther.aDescription ) == COMPARE_LESS );
      63                 :            :     }
      64                 :            : };
      65                 :            : 
      66                 :            : //------------------------------------------------------------------
      67                 :            : 
      68         [ #  # ]:          0 : class ScSolverOptionsString : public SvLBoxString
      69                 :            : {
      70                 :            :     bool        mbIsDouble;
      71                 :            :     double      mfDoubleValue;
      72                 :            :     sal_Int32   mnIntValue;
      73                 :            : 
      74                 :            : public:
      75                 :          0 :     ScSolverOptionsString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, const String& rStr ) :
      76                 :            :         SvLBoxString( pEntry, nFlags, rStr ),
      77                 :            :         mbIsDouble( false ),
      78                 :            :         mfDoubleValue( 0.0 ),
      79         [ #  # ]:          0 :         mnIntValue( 0 ) {}
      80                 :            : 
      81                 :          0 :     bool      IsDouble() const        { return mbIsDouble; }
      82                 :          0 :     double    GetDoubleValue() const  { return mfDoubleValue; }
      83                 :          0 :     sal_Int32 GetIntValue() const     { return mnIntValue; }
      84                 :            : 
      85                 :          0 :     void      SetDoubleValue( double fNew ) { mbIsDouble = true; mfDoubleValue = fNew; }
      86                 :          0 :     void      SetIntValue( sal_Int32 nNew ) { mbIsDouble = false; mnIntValue = nNew; }
      87                 :            : 
      88                 :            :     virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, SvLBoxEntry* pEntry );
      89                 :            : };
      90                 :            : 
      91                 :          0 : void ScSolverOptionsString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16, SvLBoxEntry* /* pEntry */ )
      92                 :            : {
      93                 :            :     //! move position? (SvxLinguTabPage: aPos.X() += 20)
      94         [ #  # ]:          0 :     String aNormalStr( GetText() );
      95         [ #  # ]:          0 :     aNormalStr.Append( (sal_Unicode) ':' );
      96         [ #  # ]:          0 :     rDev.DrawText( rPos, aNormalStr );
      97                 :            : 
      98                 :          0 :     Point aNewPos( rPos );
      99         [ #  # ]:          0 :     aNewPos.X() += rDev.GetTextWidth( aNormalStr );
     100         [ #  # ]:          0 :     Font aOldFont( rDev.GetFont() );
     101         [ #  # ]:          0 :     Font aFont( aOldFont );
     102         [ #  # ]:          0 :     aFont.SetWeight( WEIGHT_BOLD );
     103                 :            : 
     104                 :          0 :     rtl::OUString sTxt( ' ' );
     105         [ #  # ]:          0 :     if ( mbIsDouble )
     106                 :            :         sTxt += rtl::math::doubleToUString( mfDoubleValue,
     107                 :            :             rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
     108 [ #  # ][ #  # ]:          0 :             ScGlobal::GetpLocaleData()->getNumDecimalSep()[0], true );
     109                 :            :     else
     110                 :          0 :         sTxt += rtl::OUString::valueOf(mnIntValue);
     111         [ #  # ]:          0 :     rDev.SetFont( aFont );
     112 [ #  # ][ #  # ]:          0 :     rDev.DrawText( aNewPos, sTxt );
                 [ #  # ]
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :     rDev.SetFont( aOldFont );
         [ #  # ][ #  # ]
     115                 :          0 : }
     116                 :            : 
     117                 :            : //------------------------------------------------------------------
     118                 :            : 
     119                 :          0 : ScSolverOptionsDialog::ScSolverOptionsDialog( Window* pParent,
     120                 :            :                         const uno::Sequence<rtl::OUString>& rImplNames,
     121                 :            :                         const uno::Sequence<rtl::OUString>& rDescriptions,
     122                 :            :                         const String& rEngine,
     123                 :            :                         const uno::Sequence<beans::PropertyValue>& rProperties )
     124                 :            :     : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVEROPTIONS ) ),
     125                 :            :     maFtEngine      ( this, ScResId( FT_ENGINE ) ),
     126                 :            :     maLbEngine      ( this, ScResId( LB_ENGINE ) ),
     127                 :            :     maFtSettings    ( this, ScResId( FT_SETTINGS ) ),
     128                 :            :     maLbSettings    ( this, ScResId( LB_SETTINGS ) ),
     129                 :            :     maBtnEdit       ( this, ScResId( BTN_EDIT ) ),
     130                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
     131                 :            :     maBtnHelp       ( this, ScResId( BTN_HELP ) ),
     132                 :            :     maBtnOk         ( this, ScResId( BTN_OK ) ),
     133                 :            :     maBtnCancel     ( this, ScResId( BTN_CANCEL ) ),
     134                 :            :     mpCheckButtonData( NULL ),
     135                 :            :     maImplNames( rImplNames ),
     136                 :            :     maDescriptions( rDescriptions ),
     137                 :            :     maEngine( rEngine ),
     138 [ #  # ][ #  # ]:          0 :     maProperties( rProperties )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     139                 :            : {
     140         [ #  # ]:          0 :     maLbEngine.SetSelectHdl( LINK( this, ScSolverOptionsDialog, EngineSelectHdl ) );
     141                 :            : 
     142         [ #  # ]:          0 :     maBtnEdit.SetClickHdl( LINK( this, ScSolverOptionsDialog, ButtonHdl ) );
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     maLbSettings.SetStyle( maLbSettings.GetStyle()|WB_CLIPCHILDREN|WB_FORCE_MAKEVISIBLE );
     145         [ #  # ]:          0 :     maLbSettings.SetHelpId( HID_SC_SOLVEROPTIONS_LB );
     146         [ #  # ]:          0 :     maLbSettings.SetHighlightRange();
     147                 :            : 
     148         [ #  # ]:          0 :     maLbSettings.SetSelectHdl( LINK( this, ScSolverOptionsDialog, SettingsSelHdl ) );
     149         [ #  # ]:          0 :     maLbSettings.SetDoubleClickHdl( LINK( this, ScSolverOptionsDialog, SettingsDoubleClickHdl ) );
     150                 :            : 
     151                 :          0 :     sal_Int32 nSelect = -1;
     152                 :          0 :     sal_Int32 nImplCount = maImplNames.getLength();
     153         [ #  # ]:          0 :     for (sal_Int32 nImpl=0; nImpl<nImplCount; ++nImpl)
     154                 :            :     {
     155 [ #  # ][ #  # ]:          0 :         String aImplName( maImplNames[nImpl] );
     156 [ #  # ][ #  # ]:          0 :         String aDescription( maDescriptions[nImpl] );   // user-visible descriptions in list box
     157         [ #  # ]:          0 :         maLbEngine.InsertEntry( aDescription );
     158 [ #  # ][ #  # ]:          0 :         if ( aImplName == maEngine )
     159                 :          0 :             nSelect = nImpl;
     160 [ #  # ][ #  # ]:          0 :     }
     161         [ #  # ]:          0 :     if ( nSelect < 0 )                  // no (valid) engine given
     162                 :            :     {
     163         [ #  # ]:          0 :         if ( nImplCount > 0 )
     164                 :            :         {
     165 [ #  # ][ #  # ]:          0 :             maEngine = maImplNames[0];  // use first implementation
     166                 :          0 :             nSelect = 0;
     167                 :            :         }
     168                 :            :         else
     169         [ #  # ]:          0 :             maEngine.Erase();
     170         [ #  # ]:          0 :         maProperties.realloc(0);        // don't use options from different engine
     171                 :            :     }
     172         [ #  # ]:          0 :     if ( nSelect >= 0 )                 // select in list box
     173         [ #  # ]:          0 :         maLbEngine.SelectEntryPos( static_cast<sal_uInt16>(nSelect) );
     174                 :            : 
     175         [ #  # ]:          0 :     if ( !maProperties.getLength() )
     176         [ #  # ]:          0 :         ReadFromComponent();            // fill maProperties from component (using maEngine)
     177         [ #  # ]:          0 :     FillListBox();                      // using maProperties
     178                 :            : 
     179         [ #  # ]:          0 :     FreeResource();
     180                 :          0 : }
     181                 :            : 
     182 [ #  # ][ #  # ]:          0 : ScSolverOptionsDialog::~ScSolverOptionsDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     183                 :            : {
     184 [ #  # ][ #  # ]:          0 :     delete mpCheckButtonData;
     185         [ #  # ]:          0 : }
     186                 :            : 
     187                 :          0 : const String& ScSolverOptionsDialog::GetEngine() const
     188                 :            : {
     189                 :          0 :     return maEngine;    // already updated in selection handler
     190                 :            : }
     191                 :            : 
     192                 :          0 : const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties()
     193                 :            : {
     194                 :            :     // update maProperties from list box content
     195                 :            :     // order of entries in list box and maProperties is the same
     196                 :          0 :     sal_Int32 nEntryCount = maProperties.getLength();
     197                 :          0 :     SvLBoxTreeList* pModel = maLbSettings.GetModel();
     198         [ #  # ]:          0 :     if ( nEntryCount == (sal_Int32)pModel->GetEntryCount() )
     199                 :            :     {
     200         [ #  # ]:          0 :         for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos)
     201                 :            :         {
     202                 :          0 :             uno::Any& rValue = maProperties[nEntryPos].Value;
     203                 :          0 :             SvLBoxEntry* pEntry = pModel->GetEntry(nEntryPos);
     204                 :            : 
     205                 :          0 :             bool bHasData = false;
     206                 :          0 :             sal_uInt16 nItemCount = pEntry->ItemCount();
     207 [ #  # ][ #  # ]:          0 :             for (sal_uInt16 nItemPos=0; nItemPos<nItemCount && !bHasData; ++nItemPos)
                 [ #  # ]
     208                 :            :             {
     209                 :          0 :                 SvLBoxItem* pItem = pEntry->GetItem( nItemPos );
     210         [ #  # ]:          0 :                 ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
     211         [ #  # ]:          0 :                 if ( pStringItem )
     212                 :            :                 {
     213         [ #  # ]:          0 :                     if ( pStringItem->IsDouble() )
     214         [ #  # ]:          0 :                         rValue <<= pStringItem->GetDoubleValue();
     215                 :            :                     else
     216         [ #  # ]:          0 :                         rValue <<= pStringItem->GetIntValue();
     217                 :          0 :                     bHasData = true;
     218                 :            :                 }
     219                 :            :             }
     220         [ #  # ]:          0 :             if ( !bHasData )
     221                 :            :                 ScUnoHelpFunctions::SetBoolInAny( rValue,
     222                 :          0 :                                     maLbSettings.GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED );
     223                 :            :         }
     224                 :            :     }
     225                 :            :     else
     226                 :            :     {
     227                 :            :         OSL_FAIL( "wrong count" );
     228                 :            :     }
     229                 :            : 
     230                 :          0 :     return maProperties;
     231                 :            : }
     232                 :            : 
     233                 :          0 : void ScSolverOptionsDialog::FillListBox()
     234                 :            : {
     235                 :            :     // get property descriptions, sort by them
     236                 :            : 
     237 [ #  # ][ #  # ]:          0 :     uno::Reference<sheet::XSolverDescription> xDesc( ScSolverUtil::GetSolver( maEngine ), uno::UNO_QUERY );
                 [ #  # ]
     238                 :          0 :     sal_Int32 nCount = maProperties.getLength();
     239         [ #  # ]:          0 :     std::vector<ScSolverOptionsEntry> aDescriptions( nCount );
     240         [ #  # ]:          0 :     for (sal_Int32 nPos=0; nPos<nCount; nPos++)
     241                 :            :     {
     242         [ #  # ]:          0 :         rtl::OUString aPropName( maProperties[nPos].Name );
     243                 :          0 :         rtl::OUString aVisName;
     244         [ #  # ]:          0 :         if ( xDesc.is() )
     245 [ #  # ][ #  # ]:          0 :             aVisName = xDesc->getPropertyDescription( aPropName );
     246         [ #  # ]:          0 :         if ( aVisName.isEmpty() )
     247                 :          0 :             aVisName = aPropName;
     248                 :          0 :         aDescriptions[nPos].nPosition = nPos;
     249                 :          0 :         aDescriptions[nPos].aDescription = aVisName;
     250                 :          0 :     }
     251         [ #  # ]:          0 :     std::sort( aDescriptions.begin(), aDescriptions.end() );
     252                 :            : 
     253                 :            :     // also update maProperties to the order of descriptions
     254                 :            : 
     255         [ #  # ]:          0 :     uno::Sequence<beans::PropertyValue> aNewSeq;
     256         [ #  # ]:          0 :     aNewSeq.realloc( nCount );
     257         [ #  # ]:          0 :     for (sal_Int32 nPos=0; nPos<nCount; nPos++)
     258 [ #  # ][ #  # ]:          0 :         aNewSeq[nPos] = maProperties[ aDescriptions[nPos].nPosition ];
     259         [ #  # ]:          0 :     maProperties = aNewSeq;
     260                 :            : 
     261                 :            :     // fill the list box
     262                 :            : 
     263         [ #  # ]:          0 :     maLbSettings.SetUpdateMode(false);
     264         [ #  # ]:          0 :     maLbSettings.Clear();
     265                 :            : 
     266         [ #  # ]:          0 :     String sEmpty;
     267         [ #  # ]:          0 :     if (!mpCheckButtonData)
     268 [ #  # ][ #  # ]:          0 :         mpCheckButtonData = new SvLBoxButtonData( &maLbSettings );
     269                 :            : 
     270                 :          0 :     SvLBoxTreeList* pModel = maLbSettings.GetModel();
     271                 :          0 :     SvLBoxEntry* pEntry = NULL;
     272                 :            : 
     273         [ #  # ]:          0 :     for (sal_Int32 nPos=0; nPos<nCount; nPos++)
     274                 :            :     {
     275                 :          0 :         rtl::OUString aVisName = aDescriptions[nPos].aDescription;
     276                 :            : 
     277         [ #  # ]:          0 :         uno::Any aValue = maProperties[nPos].Value;
     278                 :          0 :         uno::TypeClass eClass = aValue.getValueTypeClass();
     279         [ #  # ]:          0 :         if ( eClass == uno::TypeClass_BOOLEAN )
     280                 :            :         {
     281                 :            :             // check box entry
     282 [ #  # ][ #  # ]:          0 :             pEntry = new SvLBoxEntry;
     283 [ #  # ][ #  # ]:          0 :             SvLBoxButton* pButton = new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, mpCheckButtonData );
     284 [ #  # ][ #  # ]:          0 :             if ( ScUnoHelpFunctions::GetBoolFromAny( aValue ) )
     285         [ #  # ]:          0 :                 pButton->SetStateChecked();
     286                 :            :             else
     287         [ #  # ]:          0 :                 pButton->SetStateUnchecked();
     288         [ #  # ]:          0 :             pEntry->AddItem( pButton );
     289 [ #  # ][ #  # ]:          0 :             pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     290 [ #  # ][ #  # ]:          0 :             pEntry->AddItem( new SvLBoxString( pEntry, 0, aVisName ) );
                 [ #  # ]
     291                 :            :         }
     292                 :            :         else
     293                 :            :         {
     294                 :            :             // value entry
     295 [ #  # ][ #  # ]:          0 :             pEntry = new SvLBoxEntry;
     296 [ #  # ][ #  # ]:          0 :             pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty ) );                   // empty column
         [ #  # ][ #  # ]
     297 [ #  # ][ #  # ]:          0 :             pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     298 [ #  # ][ #  # ]:          0 :             ScSolverOptionsString* pItem = new ScSolverOptionsString( pEntry, 0, aVisName );
         [ #  # ][ #  # ]
     299         [ #  # ]:          0 :             if ( eClass == uno::TypeClass_DOUBLE )
     300                 :            :             {
     301                 :          0 :                 double fDoubleValue = 0.0;
     302         [ #  # ]:          0 :                 if ( aValue >>= fDoubleValue )
     303                 :          0 :                     pItem->SetDoubleValue( fDoubleValue );
     304                 :            :             }
     305                 :            :             else
     306                 :            :             {
     307                 :          0 :                 sal_Int32 nIntValue = 0;
     308         [ #  # ]:          0 :                 if ( aValue >>= nIntValue )
     309                 :          0 :                     pItem->SetIntValue( nIntValue );
     310                 :            :             }
     311         [ #  # ]:          0 :             pEntry->AddItem( pItem );
     312                 :            :         }
     313         [ #  # ]:          0 :         pModel->Insert( pEntry );
     314                 :          0 :     }
     315                 :            : 
     316 [ #  # ][ #  # ]:          0 :     maLbSettings.SetUpdateMode(sal_True);
                 [ #  # ]
     317                 :          0 : }
     318                 :            : 
     319                 :          0 : void ScSolverOptionsDialog::ReadFromComponent()
     320                 :            : {
     321 [ #  # ][ #  # ]:          0 :     maProperties = ScSolverUtil::GetDefaults( maEngine );
                 [ #  # ]
     322                 :          0 : }
     323                 :            : 
     324                 :          0 : void ScSolverOptionsDialog::EditOption()
     325                 :            : {
     326                 :          0 :     SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
     327         [ #  # ]:          0 :     if (pEntry)
     328                 :            :     {
     329                 :          0 :         sal_uInt16 nItemCount = pEntry->ItemCount();
     330         [ #  # ]:          0 :         for (sal_uInt16 nPos=0; nPos<nItemCount; ++nPos)
     331                 :            :         {
     332                 :          0 :             SvLBoxItem* pItem = pEntry->GetItem( nPos );
     333         [ #  # ]:          0 :             ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
     334         [ #  # ]:          0 :             if ( pStringItem )
     335                 :            :             {
     336         [ #  # ]:          0 :                 if ( pStringItem->IsDouble() )
     337                 :            :                 {
     338         [ #  # ]:          0 :                     ScSolverValueDialog aValDialog( this );
     339 [ #  # ][ #  # ]:          0 :                     aValDialog.SetOptionName( pStringItem->GetText() );
                 [ #  # ]
     340         [ #  # ]:          0 :                     aValDialog.SetValue( pStringItem->GetDoubleValue() );
     341 [ #  # ][ #  # ]:          0 :                     if ( aValDialog.Execute() == RET_OK )
     342                 :            :                     {
     343         [ #  # ]:          0 :                         pStringItem->SetDoubleValue( aValDialog.GetValue() );
     344         [ #  # ]:          0 :                         maLbSettings.InvalidateEntry( pEntry );
     345         [ #  # ]:          0 :                     }
     346                 :            :                 }
     347                 :            :                 else
     348                 :            :                 {
     349         [ #  # ]:          0 :                     ScSolverIntegerDialog aIntDialog( this );
     350 [ #  # ][ #  # ]:          0 :                     aIntDialog.SetOptionName( pStringItem->GetText() );
                 [ #  # ]
     351         [ #  # ]:          0 :                     aIntDialog.SetValue( pStringItem->GetIntValue() );
     352 [ #  # ][ #  # ]:          0 :                     if ( aIntDialog.Execute() == RET_OK )
     353                 :            :                     {
     354         [ #  # ]:          0 :                         pStringItem->SetIntValue( aIntDialog.GetValue() );
     355         [ #  # ]:          0 :                         maLbSettings.InvalidateEntry( pEntry );
     356         [ #  # ]:          0 :                     }
     357                 :            :                 }
     358                 :            :             }
     359                 :            :         }
     360                 :            :     }
     361                 :          0 : }
     362                 :            : 
     363                 :          0 : IMPL_LINK( ScSolverOptionsDialog, ButtonHdl, PushButton*, pBtn )
     364                 :            : {
     365         [ #  # ]:          0 :     if ( pBtn == &maBtnEdit )
     366                 :          0 :         EditOption();
     367                 :            : 
     368                 :          0 :     return 0;
     369                 :            : }
     370                 :            : 
     371                 :          0 : IMPL_LINK_NOARG(ScSolverOptionsDialog, SettingsDoubleClickHdl)
     372                 :            : {
     373                 :          0 :     EditOption();
     374                 :          0 :     return 0;
     375                 :            : }
     376                 :            : 
     377                 :          0 : IMPL_LINK_NOARG(ScSolverOptionsDialog, EngineSelectHdl)
     378                 :            : {
     379                 :          0 :     sal_uInt16 nSelectPos = maLbEngine.GetSelectEntryPos();
     380         [ #  # ]:          0 :     if ( nSelectPos < maImplNames.getLength() )
     381                 :            :     {
     382 [ #  # ][ #  # ]:          0 :         String aNewEngine( maImplNames[nSelectPos] );
     383 [ #  # ][ #  # ]:          0 :         if ( aNewEngine != maEngine )
     384                 :            :         {
     385         [ #  # ]:          0 :             maEngine = aNewEngine;
     386         [ #  # ]:          0 :             ReadFromComponent();            // fill maProperties from component (using maEngine)
     387         [ #  # ]:          0 :             FillListBox();                  // using maProperties
     388         [ #  # ]:          0 :         }
     389                 :            :     }
     390                 :          0 :     return 0;
     391                 :            : }
     392                 :            : 
     393                 :          0 : IMPL_LINK_NOARG(ScSolverOptionsDialog, SettingsSelHdl)
     394                 :            : {
     395                 :          0 :     sal_Bool bCheckbox = false;
     396                 :            : 
     397                 :          0 :     SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
     398         [ #  # ]:          0 :     if (pEntry)
     399                 :            :     {
     400                 :          0 :         SvLBoxItem* pItem = pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON);
     401 [ #  # ][ #  # ]:          0 :         if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
                 [ #  # ]
     402                 :          0 :             bCheckbox = sal_True;
     403                 :            :     }
     404                 :            : 
     405                 :          0 :     maBtnEdit.Enable( !bCheckbox );
     406                 :            : 
     407                 :          0 :     return 0;
     408                 :            : }
     409                 :            : 
     410                 :            : //------------------------------------------------------------------
     411                 :            : 
     412                 :          0 : ScSolverIntegerDialog::ScSolverIntegerDialog( Window * pParent )
     413                 :            :     : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_INTEGER ) ),
     414                 :            :     maFtName        ( this, ScResId( FT_OPTIONNAME ) ),
     415                 :            :     maNfValue       ( this, ScResId( NF_VALUE ) ),
     416                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
     417                 :            :     maBtnOk         ( this, ScResId( BTN_OK ) ),
     418 [ #  # ][ #  # ]:          0 :     maBtnCancel     ( this, ScResId( BTN_CANCEL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     419                 :            : {
     420         [ #  # ]:          0 :     FreeResource();
     421                 :          0 : }
     422                 :            : 
     423 [ #  # ][ #  # ]:          0 : ScSolverIntegerDialog::~ScSolverIntegerDialog()
         [ #  # ][ #  # ]
                 [ #  # ]
     424                 :            : {
     425         [ #  # ]:          0 : }
     426                 :            : 
     427                 :          0 : void ScSolverIntegerDialog::SetOptionName( const String& rName )
     428                 :            : {
     429                 :          0 :     maFtName.SetText( rName );
     430                 :          0 : }
     431                 :            : 
     432                 :          0 : void ScSolverIntegerDialog::SetValue( sal_Int32 nValue )
     433                 :            : {
     434                 :          0 :     maNfValue.SetValue( nValue );
     435                 :          0 : }
     436                 :            : 
     437                 :          0 : sal_Int32 ScSolverIntegerDialog::GetValue() const
     438                 :            : {
     439                 :          0 :     sal_Int64 nValue = maNfValue.GetValue();
     440         [ #  # ]:          0 :     if ( nValue < SAL_MIN_INT32 )
     441                 :          0 :         return SAL_MIN_INT32;
     442         [ #  # ]:          0 :     if ( nValue > SAL_MAX_INT32 )
     443                 :          0 :         return SAL_MAX_INT32;
     444                 :          0 :     return (sal_Int32) nValue;
     445                 :            : }
     446                 :            : 
     447                 :            : //------------------------------------------------------------------
     448                 :            : 
     449                 :          0 : ScSolverValueDialog::ScSolverValueDialog( Window * pParent )
     450                 :            :     : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_DOUBLE ) ),
     451                 :            :     maFtName        ( this, ScResId( FT_OPTIONNAME ) ),
     452                 :            :     maEdValue       ( this, ScResId( ED_VALUE ) ),
     453                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
     454                 :            :     maBtnOk         ( this, ScResId( BTN_OK ) ),
     455 [ #  # ][ #  # ]:          0 :     maBtnCancel     ( this, ScResId( BTN_CANCEL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     456                 :            : {
     457         [ #  # ]:          0 :     FreeResource();
     458                 :          0 : }
     459                 :            : 
     460 [ #  # ][ #  # ]:          0 : ScSolverValueDialog::~ScSolverValueDialog()
         [ #  # ][ #  # ]
                 [ #  # ]
     461                 :            : {
     462         [ #  # ]:          0 : }
     463                 :            : 
     464                 :          0 : void ScSolverValueDialog::SetOptionName( const String& rName )
     465                 :            : {
     466                 :          0 :     maFtName.SetText( rName );
     467                 :          0 : }
     468                 :            : 
     469                 :          0 : void ScSolverValueDialog::SetValue( double fValue )
     470                 :            : {
     471                 :            :     maEdValue.SetText( rtl::math::doubleToUString( fValue,
     472                 :            :             rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
     473 [ #  # ][ #  # ]:          0 :             ScGlobal::GetpLocaleData()->getNumDecimalSep()[0], true ) );
                 [ #  # ]
     474                 :          0 : }
     475                 :            : 
     476                 :          0 : double ScSolverValueDialog::GetValue() const
     477                 :            : {
     478         [ #  # ]:          0 :     String aInput = maEdValue.GetText();
     479                 :            : 
     480         [ #  # ]:          0 :     const LocaleDataWrapper* pLocaleData = ScGlobal::GetpLocaleData();
     481                 :          0 :     rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
     482                 :            :     double fValue = rtl::math::stringToDouble( aInput,
     483         [ #  # ]:          0 :                             pLocaleData->getNumDecimalSep()[0],
     484         [ #  # ]:          0 :                             pLocaleData->getNumThousandSep()[0],
     485         [ #  # ]:          0 :                             &eStatus, NULL );
     486         [ #  # ]:          0 :     return fValue;
     487                 :            : }
     488                 :            : 
     489                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10