LCOV - code coverage report
Current view: top level - sc/source/ui/optdlg - calcoptionsdlg.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 325 0.0 %
Date: 2014-04-11 Functions: 0 33 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             : 
      10             : #include "calcoptionsdlg.hxx"
      11             : #include "sc.hrc"
      12             : #include "scresid.hxx"
      13             : 
      14             : #include "svtools/svlbitm.hxx"
      15             : #include "svtools/treelistentry.hxx"
      16             : 
      17             : #if HAVE_FEATURE_OPENCL
      18             : #include "formulagroup.hxx"
      19             : #include "globalnames.hxx"
      20             : #endif
      21             : 
      22             : namespace {
      23             : 
      24             : typedef enum {
      25             :     CALC_OPTION_STRING_CONVERSION = 0,
      26             :     CALC_OPTION_EMPTY_AS_ZERO     = 1,
      27             :     CALC_OPTION_REF_SYNTAX        = 2,
      28             :     CALC_OPTION_ENABLE_OPENCL     = 3
      29             : } CalcOptionOrder;
      30             : 
      31           0 : class OptionString : public SvLBoxString
      32             : {
      33             :     OUString maDesc;
      34             :     OUString maValue;
      35             : public:
      36           0 :     OptionString(const OUString& rDesc, const OUString& rValue) :
      37           0 :         maDesc(rDesc), maValue(rValue) {}
      38             : 
      39           0 :     void SetValue(const OUString &rValue) { maValue = rValue; }
      40             : 
      41             :     virtual void Paint(const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry) SAL_OVERRIDE;
      42             : 
      43             :     virtual void InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData) SAL_OVERRIDE;
      44             : };
      45             : 
      46           0 : void OptionString::InitViewData(
      47             :     SvTreeListBox* pView, SvTreeListEntry* pEntry, SvViewDataItem* pViewData)
      48             : {
      49           0 :     if( !pViewData )
      50           0 :         pViewData = pView->GetViewDataItem( pEntry, this );
      51             : 
      52           0 :     OUString aDesc = maDesc + ": ";
      53           0 :     Size aDescSize(pView->GetTextWidth(aDesc), pView->GetTextHeight());
      54             : 
      55           0 :     Font aOldFont = pView->GetFont();
      56           0 :     Font aFont = aOldFont;
      57           0 :     aFont.SetWeight(WEIGHT_BOLD);
      58             :     //To not make the SvTreeListBox try and recalculate all rows, call the
      59             :     //underlying SetFont, we just want to know what size this text will be
      60             :     //and are going to reset the font to the original again afterwards
      61           0 :     pView->Control::SetFont(aFont);
      62           0 :     Size aValueSize(pView->GetTextWidth(maValue), pView->GetTextHeight());
      63           0 :     pView->Control::SetFont(aOldFont);
      64             : 
      65           0 :     pViewData->maSize = Size(aDescSize.Width() + aValueSize.Width(), std::max(aDescSize.Height(), aValueSize.Height()));
      66           0 : }
      67             : 
      68           0 : void OptionString::Paint(const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* /*pView*/, const SvTreeListEntry* /*pEntry*/)
      69             : {
      70           0 :     Point aPos = rPos;
      71           0 :     OUString aDesc = maDesc + ": ";
      72           0 :     rDev.DrawText(aPos, aDesc);
      73             : 
      74           0 :     aPos.X() += rDev.GetTextWidth(aDesc);
      75           0 :     Font aOldFont = rDev.GetFont();
      76           0 :     Font aFont = aOldFont;
      77           0 :     aFont.SetWeight(WEIGHT_BOLD);
      78             : 
      79             :     //To not make the SvTreeListBox try and recalculate all rows, call the
      80             :     //underlying SetFont, we are going to draw this string and then going to
      81             :     //reset the font to the original again afterwards
      82           0 :     rDev.Control::SetFont(aFont);
      83           0 :     rDev.DrawText(aPos, maValue);
      84           0 :     rDev.Control::SetFont(aOldFont);
      85           0 : }
      86             : 
      87           0 : formula::FormulaGrammar::AddressConvention toAddressConvention(sal_Int32 nPos)
      88             : {
      89           0 :     switch (nPos)
      90             :     {
      91             :         case 1:
      92           0 :             return formula::FormulaGrammar::CONV_OOO;
      93             :         case 2:
      94           0 :             return formula::FormulaGrammar::CONV_XL_A1;
      95             :         case 3:
      96           0 :             return formula::FormulaGrammar::CONV_XL_R1C1;
      97             :         case 0:
      98             :         default:
      99             :             ;
     100             :     }
     101             : 
     102           0 :     return formula::FormulaGrammar::CONV_UNSPECIFIED;
     103             : }
     104             : 
     105           0 : ScCalcConfig::StringConversion toStringConversion(sal_Int32 nPos)
     106             : {
     107           0 :     switch (nPos)
     108             :     {
     109             :         case 0:
     110           0 :             return ScCalcConfig::STRING_CONVERSION_AS_ERROR;
     111             :         case 1:
     112           0 :             return ScCalcConfig::STRING_CONVERSION_AS_ZERO;
     113             :         case 2:
     114           0 :             return ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS;
     115             :         case 3:
     116           0 :             return ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT;
     117             :     }
     118             : 
     119           0 :     return ScCalcConfig::STRING_CONVERSION_AS_ERROR;
     120             : }
     121             : 
     122             : }
     123             : 
     124           0 : ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rConfig)
     125             :     : ModalDialog(pParent, "FormulaCalculationOptions",
     126             :         "modules/scalc/ui/formulacalculationoptions.ui")
     127             :     , maCalcA1(ScResId(SCSTR_FORMULA_SYNTAX_CALC_A1).toString())
     128             :     , maExcelA1(ScResId(SCSTR_FORMULA_SYNTAX_XL_A1).toString())
     129             :     , maExcelR1C1(ScResId(SCSTR_FORMULA_SYNTAX_XL_R1C1).toString())
     130             :     , maConfig(rConfig)
     131           0 :     , mbSelectedEmptyStringAsZero(rConfig.mbEmptyStringAsZero)
     132             : {
     133           0 :     get(mpLbSettings, "settings");
     134           0 :     get(mpLbOptionEdit, "edit");
     135           0 :     get(mpFtAnnotation, "annotation");
     136           0 :     get(mpBtnTrue, "true");
     137           0 :     get(mpBtnFalse, "false");
     138           0 :     get(mpOpenclInfoList, "opencl_list");
     139           0 :     get(mpBtnAutomaticSelectionTrue, "automatic_select_true");
     140           0 :     get(mpBtnAutomaticSelectionFalse, "automatic_select_false");
     141           0 :     get(mpFtFrequency, "frequency");
     142           0 :     get(mpFtComputeUnits, "compute_units");
     143           0 :     get(mpFtMemory, "memory");
     144             : 
     145           0 :     mpOpenclInfoList->set_height_request(4* mpOpenclInfoList->GetTextHeight());
     146           0 :     mpOpenclInfoList->SetStyle(mpOpenclInfoList->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
     147           0 :     mpOpenclInfoList->SetHighlightRange();
     148           0 :     mpOpenclInfoList->GetParent()->Hide();
     149           0 :     mpOpenclInfoList->SetSelectHdl(LINK(this, ScCalcOptionsDialog, DeviceSelHdl));
     150             : 
     151           0 :     mpBtnAutomaticSelectionTrue->SetToggleHdl(LINK(this, ScCalcOptionsDialog, BtnAutomaticSelectHdl));
     152             : 
     153           0 :     maCaptionStringRefSyntax = get<Window>("ref_syntax_caption")->GetText();
     154           0 :     maDescStringRefSyntax = get<Window>("ref_syntax_desc")->GetText();
     155           0 :     maUseFormulaSyntax = get<Window>("use_formula_syntax")->GetText();
     156             : 
     157           0 :     maCaptionStringConversion = get<Window>("string_conversion_caption")->GetText();
     158           0 :     maDescStringConversion = get<Window>("string_conversion_desc")->GetText();
     159           0 :     maStringConversionAsError = get<Window>("string_conversion_as_error")->GetText();
     160           0 :     maStringConversionAsZero = get<Window>("string_conversion_as_zero")->GetText();
     161           0 :     maStringConversionUnambiguous = get<Window>("string_conversion_unambiguous")->GetText();
     162           0 :     maStringConversionLocaleDependent = get<Window>("string_conversion_locale_dependent")->GetText();
     163             : 
     164           0 :     maCaptionEmptyStringAsZero = get<Window>("empty_str_as_zero_caption")->GetText();
     165           0 :     maDescEmptyStringAsZero = get<Window>("empty_str_as_zero_desc")->GetText();
     166             : 
     167           0 :     maCaptionOpenCLEnabled = get<Window>("opencl_enabled")->GetText();
     168           0 :     maDescOpenCLEnabled = get<Window>("opencl_enabled_desc")->GetText();
     169           0 :     maSoftware = get<Window>("software")->GetText();
     170             : 
     171           0 :     mpLbSettings->set_height_request(8 * mpLbSettings->GetTextHeight());
     172           0 :     mpLbSettings->SetStyle(mpLbSettings->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
     173           0 :     mpLbSettings->SetHighlightRange();
     174             : 
     175           0 :     Link aLink = LINK(this, ScCalcOptionsDialog, SettingsSelHdl);
     176           0 :     mpLbSettings->SetSelectHdl(aLink);
     177           0 :     mpLbOptionEdit->SetSelectHdl(aLink);
     178             : 
     179           0 :     aLink = LINK(this, ScCalcOptionsDialog, BtnToggleHdl);
     180           0 :     mpBtnTrue->SetToggleHdl(aLink); // Set handler only to the 'True' button.
     181             : 
     182           0 :     maTrue = mpBtnTrue->GetText();
     183           0 :     maFalse = mpBtnFalse->GetText();
     184             : 
     185           0 :     FillOptionsList();
     186           0 :     SelectionChanged();
     187           0 : }
     188             : 
     189           0 : ScCalcOptionsDialog::~ScCalcOptionsDialog() {}
     190             : 
     191           0 : const ScCalcConfig& ScCalcOptionsDialog::GetConfig() const
     192             : {
     193           0 :     return maConfig;
     194             : }
     195             : 
     196           0 : SvTreeListEntry *ScCalcOptionsDialog::createBoolItem(const OUString &rCaption, bool bValue) const
     197             : {
     198           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     199           0 :     pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
     200           0 :     pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
     201           0 :     OptionString* pItem = new OptionString(rCaption, toString(bValue));
     202           0 :     pEntry->AddItem(pItem);
     203           0 :     return pEntry;
     204             : }
     205             : 
     206           0 : void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue)
     207             : {
     208           0 :     SvTreeList *pModel = mpLbSettings->GetModel();
     209           0 :     SvTreeListEntry* pEntry = pModel->GetEntry(NULL, nPos);
     210           0 :     if (!pEntry)
     211             :     {
     212             :         SAL_WARN("sc", "missing entry at " << nPos << " in value view");
     213           0 :         return;
     214             :     }
     215           0 :     OptionString* pOpt = dynamic_cast<OptionString *>(pEntry->GetItem(2));
     216           0 :     if (!pOpt)
     217             :     {
     218             :         SAL_WARN("sc", "missing option string item so can't set " << rValue);
     219           0 :         return;
     220             :     }
     221             : 
     222           0 :     pOpt->SetValue(rValue);
     223           0 :     pModel->InvalidateEntry(pEntry);
     224             : }
     225             : 
     226             : #if HAVE_FEATURE_OPENCL
     227             : 
     228           0 : void ScCalcOptionsDialog::fillOpenclList()
     229             : {
     230           0 :     mpOpenclInfoList->SetUpdateMode(false);
     231           0 :     mpOpenclInfoList->Clear();
     232           0 :     SvTreeListEntry* pSoftwareEntry = mpOpenclInfoList->InsertEntry(maSoftware);
     233             : 
     234           0 :     OUString aStoredDevice = maConfig.maOpenCLDevice;
     235             : 
     236           0 :     SvTreeListEntry* pSelectedEntry = NULL;
     237             : 
     238           0 :     sc::FormulaGroupInterpreter::fillOpenCLInfo(maPlatformInfo);
     239           0 :     for(std::vector<sc::OpenclPlatformInfo>::iterator it = maPlatformInfo.begin(),
     240           0 :             itEnd = maPlatformInfo.end(); it != itEnd; ++it)
     241             :     {
     242           0 :         for(std::vector<sc::OpenclDeviceInfo>::iterator
     243           0 :                 itr = it->maDevices.begin(), itrEnd = it->maDevices.end(); itr != itrEnd; ++itr)
     244             :         {
     245           0 :             OUString aDeviceId = it->maVendor + " " + itr->maName;
     246           0 :             SvTreeListEntry* pEntry = mpOpenclInfoList->InsertEntry(aDeviceId);
     247           0 :             if(aDeviceId == aStoredDevice)
     248             :             {
     249           0 :                 pSelectedEntry = pEntry;
     250             :             }
     251           0 :             pEntry->SetUserData(&(*itr));
     252           0 :         }
     253             :     }
     254             : 
     255           0 :     mpOpenclInfoList->SetUpdateMode(true);
     256           0 :     mpOpenclInfoList->GetModel()->GetView(0)->SelectAll(false, false);
     257             : 
     258           0 :     if (pSelectedEntry)
     259           0 :         mpOpenclInfoList->Select(pSelectedEntry);
     260           0 :     else if (aStoredDevice == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME)
     261           0 :         mpOpenclInfoList->Select(pSoftwareEntry);
     262             : 
     263           0 :     SelectedDeviceChanged();
     264           0 : }
     265             : 
     266             : #endif
     267             : 
     268             : 
     269             : namespace {
     270           0 : void addOption( SvTreeList* pModel, OptionString* pItem )
     271             : {
     272           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     273           0 :     pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
     274           0 :     pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
     275           0 :     pEntry->AddItem(pItem);
     276           0 :     pModel->Insert(pEntry);
     277           0 : }
     278             : }
     279             : 
     280           0 : void ScCalcOptionsDialog::FillOptionsList()
     281             : {
     282           0 :     mpLbSettings->SetUpdateMode(false);
     283           0 :     mpLbSettings->Clear();
     284             : 
     285           0 :     SvTreeList* pModel = mpLbSettings->GetModel();
     286             : 
     287             :     {
     288             :         // String conversion for arithmetic operations.
     289             :         OptionString* pItem = new OptionString(
     290           0 :             maCaptionStringConversion, toString(maConfig.meStringConversion));
     291           0 :         addOption( pModel, pItem);
     292             :     }
     293             : 
     294           0 :     pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero));
     295             : 
     296             :     {
     297             :         // Syntax for INDIRECT function.
     298             :         OptionString* pItem = new OptionString(
     299           0 :             maCaptionStringRefSyntax, toString(maConfig.meStringRefAddressSyntax));
     300           0 :         addOption( pModel, pItem);
     301             :     }
     302             : 
     303             : #if HAVE_FEATURE_OPENCL
     304           0 :     pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled));
     305           0 :     fillOpenclList();
     306             : 
     307           0 :     mpBtnAutomaticSelectionFalse->Check(!maConfig.mbOpenCLAutoSelect);
     308           0 :     mpBtnAutomaticSelectionTrue->Check(maConfig.mbOpenCLAutoSelect);
     309             : #endif
     310             : 
     311           0 :     mpLbSettings->SetUpdateMode(true);
     312           0 : }
     313             : 
     314           0 : void ScCalcOptionsDialog::SelectionChanged()
     315             : {
     316           0 :     sal_uLong nSelectedPos = mpLbSettings->GetSelectEntryPos();
     317           0 :     switch ((CalcOptionOrder)nSelectedPos)
     318             :     {
     319             :         case CALC_OPTION_REF_SYNTAX:
     320             :         {
     321             :             // Formula syntax for INDIRECT function.
     322           0 :             mpBtnTrue->Hide();
     323           0 :             mpBtnFalse->Hide();
     324           0 :             mpLbOptionEdit->Show();
     325           0 :             mpOpenclInfoList->GetParent()->Hide();
     326             : 
     327           0 :             mpLbOptionEdit->Clear();
     328           0 :             mpLbOptionEdit->InsertEntry(maUseFormulaSyntax);
     329           0 :             mpLbOptionEdit->InsertEntry(maCalcA1);
     330           0 :             mpLbOptionEdit->InsertEntry(maExcelA1);
     331           0 :             mpLbOptionEdit->InsertEntry(maExcelR1C1);
     332           0 :             switch (maConfig.meStringRefAddressSyntax)
     333             :             {
     334             :                 case formula::FormulaGrammar::CONV_OOO:
     335           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     336           0 :                 break;
     337             :                 case formula::FormulaGrammar::CONV_XL_A1:
     338           0 :                     mpLbOptionEdit->SelectEntryPos(2);
     339           0 :                 break;
     340             :                 case formula::FormulaGrammar::CONV_XL_R1C1:
     341           0 :                     mpLbOptionEdit->SelectEntryPos(3);
     342           0 :                 break;
     343             :                 case formula::FormulaGrammar::CONV_UNSPECIFIED:
     344             :                 default:
     345           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     346             :             }
     347           0 :             mpFtAnnotation->SetText(maDescStringRefSyntax);
     348             :         }
     349           0 :         break;
     350             : 
     351             :         case CALC_OPTION_STRING_CONVERSION:
     352             :         {
     353             :             // String conversion for arithmetic operations.
     354           0 :             mpBtnTrue->Hide();
     355           0 :             mpBtnFalse->Hide();
     356           0 :             mpLbOptionEdit->Show();
     357           0 :             mpOpenclInfoList->GetParent()->Hide();
     358             : 
     359           0 :             mpLbOptionEdit->Clear();
     360           0 :             mpLbOptionEdit->InsertEntry(maStringConversionAsError);
     361           0 :             mpLbOptionEdit->InsertEntry(maStringConversionAsZero);
     362           0 :             mpLbOptionEdit->InsertEntry(maStringConversionUnambiguous);
     363           0 :             mpLbOptionEdit->InsertEntry(maStringConversionLocaleDependent);
     364           0 :             switch (maConfig.meStringConversion)
     365             :             {
     366             :                 case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     367           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     368           0 :                 break;
     369             :                 case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     370           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     371           0 :                 break;
     372             :                 case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     373           0 :                     mpLbOptionEdit->SelectEntryPos(2);
     374           0 :                 break;
     375             :                 case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     376           0 :                     mpLbOptionEdit->SelectEntryPos(3);
     377           0 :                 break;
     378             :             }
     379           0 :             mpFtAnnotation->SetText(maDescStringConversion);
     380             :         }
     381           0 :         break;
     382             : 
     383             :         // booleans
     384             :         case CALC_OPTION_EMPTY_AS_ZERO:
     385             :         case CALC_OPTION_ENABLE_OPENCL:
     386             :         {
     387             :             // Treat empty string as zero.
     388           0 :             mpLbOptionEdit->Hide();
     389           0 :             mpBtnTrue->Show();
     390           0 :             mpBtnFalse->Show();
     391             : 
     392           0 :             bool bValue = false;
     393           0 :             bool bEnable = true;
     394           0 :             if ( nSelectedPos == CALC_OPTION_EMPTY_AS_ZERO )
     395             :             {
     396           0 :                 bValue = maConfig.mbEmptyStringAsZero;
     397           0 :                 mpFtAnnotation->SetText(maDescEmptyStringAsZero);
     398           0 :                 mpOpenclInfoList->GetParent()->Hide();
     399           0 :                 switch (maConfig.meStringConversion)
     400             :                 {
     401             :                     case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     402             :                     case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     403           0 :                         bEnable = false;
     404           0 :                         break;
     405             :                     case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     406             :                     case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     407           0 :                         break;  // nothing
     408             :                 }
     409             :             }
     410             :             else
     411             :             {
     412           0 :                 bValue = maConfig.mbOpenCLEnabled;
     413           0 :                 mpFtAnnotation->SetText(maDescOpenCLEnabled);
     414           0 :                 mpOpenclInfoList->GetParent()->Show();
     415           0 :                 setOptimalLayoutSize();
     416           0 :                 if(bValue)
     417           0 :                     mpOpenclInfoList->GetParent()->Enable();
     418             :                 else
     419           0 :                     mpOpenclInfoList->GetParent()->Disable();
     420             : 
     421           0 :                 OpenclAutomaticSelectionChanged();
     422             :             }
     423             : 
     424           0 :             if ( bValue )
     425             :             {
     426           0 :                 mpBtnTrue->Check(true);
     427           0 :                 mpBtnFalse->Check(false);
     428             :             }
     429             :             else
     430             :             {
     431           0 :                 mpBtnTrue->Check(false);
     432           0 :                 mpBtnFalse->Check(true);
     433             :             }
     434           0 :             if (bEnable)
     435             :             {
     436           0 :                 mpBtnTrue->Enable();
     437           0 :                 mpBtnFalse->Enable();
     438             :             }
     439             :             else
     440             :             {
     441           0 :                 mpBtnTrue->Disable();
     442           0 :                 mpBtnFalse->Disable();
     443             :             }
     444             :         }
     445           0 :         break;
     446             :         default:
     447             :             ;
     448             :     }
     449           0 : }
     450             : 
     451           0 : void ScCalcOptionsDialog::ListOptionValueChanged()
     452             : {
     453           0 :     sal_uLong nSelected = mpLbSettings->GetSelectEntryPos();
     454           0 :     switch ((CalcOptionOrder) nSelected)
     455             :     {
     456             :         case CALC_OPTION_REF_SYNTAX:
     457             :         {
     458             :             // Formula syntax for INDIRECT function.
     459           0 :             sal_Int32 nPos = mpLbOptionEdit->GetSelectEntryPos();
     460           0 :             maConfig.meStringRefAddressSyntax = toAddressConvention(nPos);
     461             : 
     462           0 :             setValueAt(nSelected, toString(maConfig.meStringRefAddressSyntax));
     463             :         }
     464           0 :         break;
     465             : 
     466             :         case CALC_OPTION_STRING_CONVERSION:
     467             :         {
     468             :             // String conversion for arithmetic operations.
     469           0 :             sal_Int32 nPos = mpLbOptionEdit->GetSelectEntryPos();
     470           0 :             maConfig.meStringConversion = toStringConversion(nPos);
     471             : 
     472           0 :             setValueAt(nSelected, toString(maConfig.meStringConversion));
     473             : 
     474           0 :             switch (maConfig.meStringConversion)
     475             :             {
     476             :                 case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     477           0 :                     maConfig.mbEmptyStringAsZero = false;
     478           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     479           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     480           0 :                 break;
     481             :                 case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     482           0 :                     maConfig.mbEmptyStringAsZero = true;
     483           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     484           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     485           0 :                 break;
     486             :                 case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     487             :                 case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     488             :                     // Reset to the value the user selected before.
     489           0 :                     maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero;
     490           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     491           0 :                 break;
     492             :             }
     493             :         }
     494           0 :         break;
     495             : 
     496             :         case CALC_OPTION_EMPTY_AS_ZERO:
     497             :         case CALC_OPTION_ENABLE_OPENCL:
     498           0 :             break;
     499             :     }
     500           0 : }
     501             : 
     502           0 : void ScCalcOptionsDialog::OpenclAutomaticSelectionChanged()
     503             : {
     504           0 :     bool bValue = mpBtnAutomaticSelectionTrue->IsChecked();
     505           0 :     if(bValue)
     506           0 :         mpOpenclInfoList->Disable();
     507             :     else
     508           0 :         mpOpenclInfoList->Enable();
     509             : 
     510           0 :     maConfig.mbOpenCLAutoSelect = bValue;
     511           0 : }
     512             : 
     513           0 : void ScCalcOptionsDialog::SelectedDeviceChanged()
     514             : {
     515             : #if HAVE_FEATURE_OPENCL
     516           0 :     SvTreeListEntry* pEntry = mpOpenclInfoList->GetModel()->GetView(0)->FirstSelected();
     517           0 :     if(!pEntry)
     518           0 :         return;
     519             : 
     520           0 :     sc::OpenclDeviceInfo* pInfo = reinterpret_cast<sc::OpenclDeviceInfo*>(pEntry->GetUserData());
     521           0 :     if(pInfo)
     522             :     {
     523           0 :         mpFtFrequency->SetText(OUString::number(pInfo->mnFrequency));
     524           0 :         mpFtComputeUnits->SetText(OUString::number(pInfo->mnComputeUnits));
     525           0 :         mpFtMemory->SetText(OUString::number(pInfo->mnMemory/1024/1024));
     526             :     }
     527             :     else
     528             :     {
     529           0 :         mpFtFrequency->SetText(OUString());
     530           0 :         mpFtComputeUnits->SetText(OUString());
     531           0 :         mpFtMemory->SetText(OUString());
     532             :     }
     533             : 
     534           0 :     SvLBoxString* pBoxEntry = dynamic_cast<SvLBoxString*>(pEntry->GetItem(1));
     535           0 :     if (!pBoxEntry)
     536           0 :         return;
     537             : 
     538           0 :     OUString aDevice = pBoxEntry->GetText();
     539             :     // use english string for configuration
     540           0 :     if(aDevice == maSoftware)
     541           0 :         aDevice = OPENCL_SOFTWARE_DEVICE_CONFIG_NAME;
     542             : 
     543           0 :     maConfig.maOpenCLDevice = aDevice;
     544             : #endif
     545             : }
     546             : 
     547           0 : void ScCalcOptionsDialog::RadioValueChanged()
     548             : {
     549           0 :     sal_uLong nSelected = mpLbSettings->GetSelectEntryPos();
     550           0 :     bool bValue = mpBtnTrue->IsChecked();
     551           0 :     switch (nSelected)
     552             :     {
     553             :         case CALC_OPTION_REF_SYNTAX:
     554             :         case CALC_OPTION_STRING_CONVERSION:
     555           0 :             return;
     556             :         case CALC_OPTION_EMPTY_AS_ZERO:
     557           0 :             maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero = bValue;
     558           0 :             break;
     559             :         case CALC_OPTION_ENABLE_OPENCL:
     560           0 :             maConfig.mbOpenCLEnabled = bValue;
     561           0 :             if(bValue)
     562           0 :                 mpOpenclInfoList->GetParent()->Enable();
     563             :             else
     564           0 :                 mpOpenclInfoList->GetParent()->Disable();
     565           0 :             OpenclAutomaticSelectionChanged();
     566           0 :             break;
     567             :     }
     568             : 
     569           0 :     setValueAt(nSelected, toString(bValue));
     570             : }
     571             : 
     572           0 : OUString ScCalcOptionsDialog::toString(formula::FormulaGrammar::AddressConvention eConv) const
     573             : {
     574           0 :     switch (eConv)
     575             :     {
     576             :         case formula::FormulaGrammar::CONV_OOO:
     577           0 :             return maCalcA1;
     578             :         case formula::FormulaGrammar::CONV_XL_A1:
     579           0 :             return maExcelA1;
     580             :         case formula::FormulaGrammar::CONV_XL_R1C1:
     581           0 :             return maExcelR1C1;
     582             :         case formula::FormulaGrammar::CONV_UNSPECIFIED:
     583             :         default:
     584             :             ;
     585             :     }
     586           0 :     return maUseFormulaSyntax;
     587             : }
     588             : 
     589           0 : OUString ScCalcOptionsDialog::toString(ScCalcConfig::StringConversion eConv) const
     590             : {
     591           0 :     switch (eConv)
     592             :     {
     593             :         case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     594           0 :             return maStringConversionAsError;
     595             :         case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     596           0 :             return maStringConversionAsZero;
     597             :         case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     598           0 :             return maStringConversionUnambiguous;
     599             :         case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     600           0 :             return maStringConversionLocaleDependent;
     601             :     }
     602           0 :     return maStringConversionAsError;
     603             : }
     604             : 
     605           0 : OUString ScCalcOptionsDialog::toString(bool bVal) const
     606             : {
     607           0 :     return bVal ? maTrue : maFalse;
     608             : }
     609             : 
     610           0 : IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
     611             : {
     612           0 :     if (pCtrl == mpLbSettings)
     613           0 :         SelectionChanged();
     614           0 :     else if (pCtrl == mpLbOptionEdit)
     615           0 :         ListOptionValueChanged();
     616             : 
     617           0 :     return 0;
     618             : }
     619             : 
     620           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnToggleHdl)
     621             : {
     622           0 :     RadioValueChanged();
     623           0 :     return 0;
     624             : }
     625             : 
     626           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnAutomaticSelectHdl)
     627             : {
     628           0 :     OpenclAutomaticSelectionChanged();
     629           0 :     return 0;
     630             : }
     631             : 
     632           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, DeviceSelHdl)
     633             : {
     634           0 :     SelectedDeviceChanged();
     635           0 :     return 0;
     636             : }
     637             : 
     638             : 
     639             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10