LCOV - code coverage report
Current view: top level - sc/source/ui/optdlg - calcoptionsdlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 324 0.0 %
Date: 2014-11-03 Functions: 0 34 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 :     vcl::Font aOldFont = pView->GetFont();
      56           0 :     vcl::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 :     vcl::Font aOldFont = rDev.GetFont();
      76           0 :     vcl::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(vcl::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<vcl::Window>("ref_syntax_caption")->GetText();
     154           0 :     maDescStringRefSyntax = get<vcl::Window>("ref_syntax_desc")->GetText();
     155           0 :     maUseFormulaSyntax = get<vcl::Window>("use_formula_syntax")->GetText();
     156             : 
     157           0 :     maCaptionStringConversion = get<vcl::Window>("string_conversion_caption")->GetText();
     158           0 :     maDescStringConversion = get<vcl::Window>("string_conversion_desc")->GetText();
     159           0 :     maStringConversionAsError = get<vcl::Window>("string_conversion_as_error")->GetText();
     160           0 :     maStringConversionAsZero = get<vcl::Window>("string_conversion_as_zero")->GetText();
     161           0 :     maStringConversionUnambiguous = get<vcl::Window>("string_conversion_unambiguous")->GetText();
     162           0 :     maStringConversionLocaleDependent = get<vcl::Window>("string_conversion_locale_dependent")->GetText();
     163             : 
     164           0 :     maCaptionEmptyStringAsZero = get<vcl::Window>("empty_str_as_zero_caption")->GetText();
     165           0 :     maDescEmptyStringAsZero = get<vcl::Window>("empty_str_as_zero_desc")->GetText();
     166             : 
     167           0 :     maCaptionOpenCLEnabled = get<vcl::Window>("opencl_enabled")->GetText();
     168           0 :     maDescOpenCLEnabled = get<vcl::Window>("opencl_enabled_desc")->GetText();
     169           0 :     maSoftware = get<vcl::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 : SvTreeListEntry *ScCalcOptionsDialog::createBoolItem(const OUString &rCaption, bool bValue) const
     192             : {
     193           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     194           0 :     pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
     195           0 :     pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
     196           0 :     OptionString* pItem = new OptionString(rCaption, toString(bValue));
     197           0 :     pEntry->AddItem(pItem);
     198           0 :     return pEntry;
     199             : }
     200             : 
     201           0 : void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue)
     202             : {
     203           0 :     SvTreeList *pModel = mpLbSettings->GetModel();
     204           0 :     SvTreeListEntry* pEntry = pModel->GetEntry(NULL, nPos);
     205           0 :     if (!pEntry)
     206             :     {
     207             :         SAL_WARN("sc", "missing entry at " << nPos << " in value view");
     208           0 :         return;
     209             :     }
     210           0 :     OptionString* pOpt = dynamic_cast<OptionString *>(pEntry->GetItem(2));
     211           0 :     if (!pOpt)
     212             :     {
     213             :         SAL_WARN("sc", "missing option string item so can't set " << rValue);
     214           0 :         return;
     215             :     }
     216             : 
     217           0 :     pOpt->SetValue(rValue);
     218           0 :     pModel->InvalidateEntry(pEntry);
     219             : }
     220             : 
     221             : #if HAVE_FEATURE_OPENCL
     222             : 
     223           0 : void ScCalcOptionsDialog::fillOpenCLList()
     224             : {
     225           0 :     mpOpenclInfoList->SetUpdateMode(false);
     226           0 :     mpOpenclInfoList->Clear();
     227           0 :     SvTreeListEntry* pSoftwareEntry = mpOpenclInfoList->InsertEntry(maSoftware);
     228             : 
     229           0 :     OUString aStoredDevice = maConfig.maOpenCLDevice;
     230             : 
     231           0 :     SvTreeListEntry* pSelectedEntry = NULL;
     232             : 
     233           0 :     sc::FormulaGroupInterpreter::fillOpenCLInfo(maPlatformInfo);
     234           0 :     for(std::vector<sc::OpenCLPlatformInfo>::iterator it = maPlatformInfo.begin(),
     235           0 :             itEnd = maPlatformInfo.end(); it != itEnd; ++it)
     236             :     {
     237           0 :         for(std::vector<sc::OpenCLDeviceInfo>::iterator
     238           0 :                 itr = it->maDevices.begin(), itrEnd = it->maDevices.end(); itr != itrEnd; ++itr)
     239             :         {
     240           0 :             OUString aDeviceId = it->maVendor + " " + itr->maName;
     241           0 :             SvTreeListEntry* pEntry = mpOpenclInfoList->InsertEntry(aDeviceId);
     242           0 :             if(aDeviceId == aStoredDevice)
     243             :             {
     244           0 :                 pSelectedEntry = pEntry;
     245             :             }
     246           0 :             pEntry->SetUserData(&(*itr));
     247           0 :         }
     248             :     }
     249             : 
     250           0 :     mpOpenclInfoList->SetUpdateMode(true);
     251           0 :     mpOpenclInfoList->GetModel()->GetView(0)->SelectAll(false, false);
     252             : 
     253           0 :     if (pSelectedEntry)
     254           0 :         mpOpenclInfoList->Select(pSelectedEntry);
     255           0 :     else if (aStoredDevice == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME)
     256           0 :         mpOpenclInfoList->Select(pSoftwareEntry);
     257             : 
     258           0 :     SelectedDeviceChanged();
     259           0 : }
     260             : 
     261             : #endif
     262             : 
     263             : namespace {
     264           0 : void addOption( SvTreeList* pModel, OptionString* pItem )
     265             : {
     266           0 :     SvTreeListEntry* pEntry = new SvTreeListEntry;
     267           0 :     pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
     268           0 :     pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
     269           0 :     pEntry->AddItem(pItem);
     270           0 :     pModel->Insert(pEntry);
     271           0 : }
     272             : }
     273             : 
     274           0 : void ScCalcOptionsDialog::FillOptionsList()
     275             : {
     276           0 :     mpLbSettings->SetUpdateMode(false);
     277           0 :     mpLbSettings->Clear();
     278             : 
     279           0 :     SvTreeList* pModel = mpLbSettings->GetModel();
     280             : 
     281             :     {
     282             :         // String conversion for arithmetic operations.
     283             :         OptionString* pItem = new OptionString(
     284           0 :             maCaptionStringConversion, toString(maConfig.meStringConversion));
     285           0 :         addOption( pModel, pItem);
     286             :     }
     287             : 
     288           0 :     pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero));
     289             : 
     290             :     {
     291             :         // Syntax for INDIRECT function.
     292             :         OptionString* pItem = new OptionString(
     293           0 :             maCaptionStringRefSyntax, toString(maConfig.meStringRefAddressSyntax));
     294           0 :         addOption( pModel, pItem);
     295             :     }
     296             : 
     297             : #if HAVE_FEATURE_OPENCL
     298           0 :     pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled));
     299           0 :     fillOpenCLList();
     300             : 
     301           0 :     mpBtnAutomaticSelectionFalse->Check(!maConfig.mbOpenCLAutoSelect);
     302           0 :     mpBtnAutomaticSelectionTrue->Check(maConfig.mbOpenCLAutoSelect);
     303             : #endif
     304             : 
     305           0 :     mpLbSettings->SetUpdateMode(true);
     306           0 : }
     307             : 
     308           0 : void ScCalcOptionsDialog::SelectionChanged()
     309             : {
     310           0 :     sal_uLong nSelectedPos = mpLbSettings->GetSelectEntryPos();
     311           0 :     switch ((CalcOptionOrder)nSelectedPos)
     312             :     {
     313             :         case CALC_OPTION_REF_SYNTAX:
     314             :         {
     315             :             // Formula syntax for INDIRECT function.
     316           0 :             mpBtnTrue->Hide();
     317           0 :             mpBtnFalse->Hide();
     318           0 :             mpLbOptionEdit->Show();
     319           0 :             mpOpenclInfoList->GetParent()->Hide();
     320             : 
     321           0 :             mpLbOptionEdit->Clear();
     322           0 :             mpLbOptionEdit->InsertEntry(maUseFormulaSyntax);
     323           0 :             mpLbOptionEdit->InsertEntry(maCalcA1);
     324           0 :             mpLbOptionEdit->InsertEntry(maExcelA1);
     325           0 :             mpLbOptionEdit->InsertEntry(maExcelR1C1);
     326           0 :             switch (maConfig.meStringRefAddressSyntax)
     327             :             {
     328             :                 case formula::FormulaGrammar::CONV_OOO:
     329           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     330           0 :                 break;
     331             :                 case formula::FormulaGrammar::CONV_XL_A1:
     332           0 :                     mpLbOptionEdit->SelectEntryPos(2);
     333           0 :                 break;
     334             :                 case formula::FormulaGrammar::CONV_XL_R1C1:
     335           0 :                     mpLbOptionEdit->SelectEntryPos(3);
     336           0 :                 break;
     337             :                 case formula::FormulaGrammar::CONV_UNSPECIFIED:
     338             :                 default:
     339           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     340             :             }
     341           0 :             mpFtAnnotation->SetText(maDescStringRefSyntax);
     342             :         }
     343           0 :         break;
     344             : 
     345             :         case CALC_OPTION_STRING_CONVERSION:
     346             :         {
     347             :             // String conversion for arithmetic operations.
     348           0 :             mpBtnTrue->Hide();
     349           0 :             mpBtnFalse->Hide();
     350           0 :             mpLbOptionEdit->Show();
     351           0 :             mpOpenclInfoList->GetParent()->Hide();
     352             : 
     353           0 :             mpLbOptionEdit->Clear();
     354           0 :             mpLbOptionEdit->InsertEntry(maStringConversionAsError);
     355           0 :             mpLbOptionEdit->InsertEntry(maStringConversionAsZero);
     356           0 :             mpLbOptionEdit->InsertEntry(maStringConversionUnambiguous);
     357           0 :             mpLbOptionEdit->InsertEntry(maStringConversionLocaleDependent);
     358           0 :             switch (maConfig.meStringConversion)
     359             :             {
     360             :                 case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     361           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     362           0 :                 break;
     363             :                 case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     364           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     365           0 :                 break;
     366             :                 case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     367           0 :                     mpLbOptionEdit->SelectEntryPos(2);
     368           0 :                 break;
     369             :                 case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     370           0 :                     mpLbOptionEdit->SelectEntryPos(3);
     371           0 :                 break;
     372             :             }
     373           0 :             mpFtAnnotation->SetText(maDescStringConversion);
     374             :         }
     375           0 :         break;
     376             : 
     377             :         // booleans
     378             :         case CALC_OPTION_EMPTY_AS_ZERO:
     379             :         case CALC_OPTION_ENABLE_OPENCL:
     380             :         {
     381             :             // Treat empty string as zero.
     382           0 :             mpLbOptionEdit->Hide();
     383           0 :             mpBtnTrue->Show();
     384           0 :             mpBtnFalse->Show();
     385             : 
     386           0 :             bool bValue = false;
     387           0 :             bool bEnable = true;
     388           0 :             if ( nSelectedPos == CALC_OPTION_EMPTY_AS_ZERO )
     389             :             {
     390           0 :                 bValue = maConfig.mbEmptyStringAsZero;
     391           0 :                 mpFtAnnotation->SetText(maDescEmptyStringAsZero);
     392           0 :                 mpOpenclInfoList->GetParent()->Hide();
     393           0 :                 switch (maConfig.meStringConversion)
     394             :                 {
     395             :                     case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     396             :                     case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     397           0 :                         bEnable = false;
     398           0 :                         break;
     399             :                     case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     400             :                     case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     401           0 :                         break;  // nothing
     402             :                 }
     403             :             }
     404             :             else
     405             :             {
     406           0 :                 bValue = maConfig.mbOpenCLEnabled;
     407           0 :                 mpFtAnnotation->SetText(maDescOpenCLEnabled);
     408           0 :                 mpOpenclInfoList->GetParent()->Show();
     409           0 :                 setOptimalLayoutSize();
     410           0 :                 if(bValue)
     411           0 :                     mpOpenclInfoList->GetParent()->Enable();
     412             :                 else
     413           0 :                     mpOpenclInfoList->GetParent()->Disable();
     414             : 
     415           0 :                 OpenCLAutomaticSelectionChanged();
     416             :             }
     417             : 
     418           0 :             if ( bValue )
     419             :             {
     420           0 :                 mpBtnTrue->Check(true);
     421           0 :                 mpBtnFalse->Check(false);
     422             :             }
     423             :             else
     424             :             {
     425           0 :                 mpBtnTrue->Check(false);
     426           0 :                 mpBtnFalse->Check(true);
     427             :             }
     428           0 :             if (bEnable)
     429             :             {
     430           0 :                 mpBtnTrue->Enable();
     431           0 :                 mpBtnFalse->Enable();
     432             :             }
     433             :             else
     434             :             {
     435           0 :                 mpBtnTrue->Disable();
     436           0 :                 mpBtnFalse->Disable();
     437             :             }
     438             :         }
     439           0 :         break;
     440             :         default:
     441             :             ;
     442             :     }
     443           0 : }
     444             : 
     445           0 : void ScCalcOptionsDialog::ListOptionValueChanged()
     446             : {
     447           0 :     sal_uLong nSelected = mpLbSettings->GetSelectEntryPos();
     448           0 :     switch ((CalcOptionOrder) nSelected)
     449             :     {
     450             :         case CALC_OPTION_REF_SYNTAX:
     451             :         {
     452             :             // Formula syntax for INDIRECT function.
     453           0 :             sal_Int32 nPos = mpLbOptionEdit->GetSelectEntryPos();
     454           0 :             maConfig.meStringRefAddressSyntax = toAddressConvention(nPos);
     455             : 
     456           0 :             setValueAt(nSelected, toString(maConfig.meStringRefAddressSyntax));
     457             :         }
     458           0 :         break;
     459             : 
     460             :         case CALC_OPTION_STRING_CONVERSION:
     461             :         {
     462             :             // String conversion for arithmetic operations.
     463           0 :             sal_Int32 nPos = mpLbOptionEdit->GetSelectEntryPos();
     464           0 :             maConfig.meStringConversion = toStringConversion(nPos);
     465             : 
     466           0 :             setValueAt(nSelected, toString(maConfig.meStringConversion));
     467             : 
     468           0 :             switch (maConfig.meStringConversion)
     469             :             {
     470             :                 case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     471           0 :                     maConfig.mbEmptyStringAsZero = false;
     472           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     473           0 :                     mpLbOptionEdit->SelectEntryPos(0);
     474           0 :                 break;
     475             :                 case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     476           0 :                     maConfig.mbEmptyStringAsZero = true;
     477           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     478           0 :                     mpLbOptionEdit->SelectEntryPos(1);
     479           0 :                 break;
     480             :                 case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     481             :                 case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     482             :                     // Reset to the value the user selected before.
     483           0 :                     maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero;
     484           0 :                     setValueAt(CALC_OPTION_EMPTY_AS_ZERO, toString(maConfig.mbEmptyStringAsZero));
     485           0 :                 break;
     486             :             }
     487             :         }
     488           0 :         break;
     489             : 
     490             :         case CALC_OPTION_EMPTY_AS_ZERO:
     491             :         case CALC_OPTION_ENABLE_OPENCL:
     492           0 :             break;
     493             :     }
     494           0 : }
     495             : 
     496           0 : void ScCalcOptionsDialog::OpenCLAutomaticSelectionChanged()
     497             : {
     498           0 :     bool bValue = mpBtnAutomaticSelectionTrue->IsChecked();
     499           0 :     if(bValue)
     500           0 :         mpOpenclInfoList->Disable();
     501             :     else
     502           0 :         mpOpenclInfoList->Enable();
     503             : 
     504           0 :     maConfig.mbOpenCLAutoSelect = bValue;
     505           0 : }
     506             : 
     507           0 : void ScCalcOptionsDialog::SelectedDeviceChanged()
     508             : {
     509             : #if HAVE_FEATURE_OPENCL
     510           0 :     SvTreeListEntry* pEntry = mpOpenclInfoList->GetModel()->GetView(0)->FirstSelected();
     511           0 :     if(!pEntry)
     512           0 :         return;
     513             : 
     514           0 :     sc::OpenCLDeviceInfo* pInfo = reinterpret_cast<sc::OpenCLDeviceInfo*>(pEntry->GetUserData());
     515           0 :     if(pInfo)
     516             :     {
     517           0 :         mpFtFrequency->SetText(OUString::number(pInfo->mnFrequency));
     518           0 :         mpFtComputeUnits->SetText(OUString::number(pInfo->mnComputeUnits));
     519           0 :         mpFtMemory->SetText(OUString::number(pInfo->mnMemory/1024/1024));
     520             :     }
     521             :     else
     522             :     {
     523           0 :         mpFtFrequency->SetText(OUString());
     524           0 :         mpFtComputeUnits->SetText(OUString());
     525           0 :         mpFtMemory->SetText(OUString());
     526             :     }
     527             : 
     528           0 :     SvLBoxString* pBoxEntry = dynamic_cast<SvLBoxString*>(pEntry->GetItem(1));
     529           0 :     if (!pBoxEntry)
     530           0 :         return;
     531             : 
     532           0 :     OUString aDevice = pBoxEntry->GetText();
     533             :     // use english string for configuration
     534           0 :     if(aDevice == maSoftware)
     535           0 :         aDevice = OPENCL_SOFTWARE_DEVICE_CONFIG_NAME;
     536             : 
     537           0 :     maConfig.maOpenCLDevice = aDevice;
     538             : #endif
     539             : }
     540             : 
     541           0 : void ScCalcOptionsDialog::RadioValueChanged()
     542             : {
     543           0 :     sal_uLong nSelected = mpLbSettings->GetSelectEntryPos();
     544           0 :     bool bValue = mpBtnTrue->IsChecked();
     545           0 :     switch (nSelected)
     546             :     {
     547             :         case CALC_OPTION_REF_SYNTAX:
     548             :         case CALC_OPTION_STRING_CONVERSION:
     549           0 :             return;
     550             :         case CALC_OPTION_EMPTY_AS_ZERO:
     551           0 :             maConfig.mbEmptyStringAsZero = mbSelectedEmptyStringAsZero = bValue;
     552           0 :             break;
     553             :         case CALC_OPTION_ENABLE_OPENCL:
     554           0 :             maConfig.mbOpenCLEnabled = bValue;
     555           0 :             if(bValue)
     556           0 :                 mpOpenclInfoList->GetParent()->Enable();
     557             :             else
     558           0 :                 mpOpenclInfoList->GetParent()->Disable();
     559           0 :             OpenCLAutomaticSelectionChanged();
     560           0 :             break;
     561             :     }
     562             : 
     563           0 :     setValueAt(nSelected, toString(bValue));
     564             : }
     565             : 
     566           0 : OUString ScCalcOptionsDialog::toString(formula::FormulaGrammar::AddressConvention eConv) const
     567             : {
     568           0 :     switch (eConv)
     569             :     {
     570             :         case formula::FormulaGrammar::CONV_OOO:
     571           0 :             return maCalcA1;
     572             :         case formula::FormulaGrammar::CONV_XL_A1:
     573           0 :             return maExcelA1;
     574             :         case formula::FormulaGrammar::CONV_XL_R1C1:
     575           0 :             return maExcelR1C1;
     576             :         case formula::FormulaGrammar::CONV_UNSPECIFIED:
     577             :         default:
     578             :             ;
     579             :     }
     580           0 :     return maUseFormulaSyntax;
     581             : }
     582             : 
     583           0 : OUString ScCalcOptionsDialog::toString(ScCalcConfig::StringConversion eConv) const
     584             : {
     585           0 :     switch (eConv)
     586             :     {
     587             :         case ScCalcConfig::STRING_CONVERSION_AS_ERROR:
     588           0 :             return maStringConversionAsError;
     589             :         case ScCalcConfig::STRING_CONVERSION_AS_ZERO:
     590           0 :             return maStringConversionAsZero;
     591             :         case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS:
     592           0 :             return maStringConversionUnambiguous;
     593             :         case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT:
     594           0 :             return maStringConversionLocaleDependent;
     595             :     }
     596           0 :     return maStringConversionAsError;
     597             : }
     598             : 
     599           0 : OUString ScCalcOptionsDialog::toString(bool bVal) const
     600             : {
     601           0 :     return bVal ? maTrue : maFalse;
     602             : }
     603             : 
     604           0 : IMPL_LINK(ScCalcOptionsDialog, SettingsSelHdl, Control*, pCtrl)
     605             : {
     606           0 :     if (pCtrl == mpLbSettings)
     607           0 :         SelectionChanged();
     608           0 :     else if (pCtrl == mpLbOptionEdit)
     609           0 :         ListOptionValueChanged();
     610             : 
     611           0 :     return 0;
     612             : }
     613             : 
     614           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnToggleHdl)
     615             : {
     616           0 :     RadioValueChanged();
     617           0 :     return 0;
     618             : }
     619             : 
     620           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, BtnAutomaticSelectHdl)
     621             : {
     622           0 :     OpenCLAutomaticSelectionChanged();
     623           0 :     return 0;
     624             : }
     625             : 
     626           0 : IMPL_LINK_NOARG(ScCalcOptionsDialog, DeviceSelHdl)
     627             : {
     628           0 :     SelectedDeviceChanged();
     629           0 :     return 0;
     630           0 : }
     631             : 
     632             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10