LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - PivotLayoutTreeList.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 13 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  */
      11             : 
      12             : #include "PivotLayoutTreeList.hxx"
      13             : #include "PivotLayoutDialog.hxx"
      14             : 
      15             : #include <svtools/treelistentry.hxx>
      16             : #include "pivot.hxx"
      17             : #include "scabstdlg.hxx"
      18             : 
      19             : using namespace std;
      20             : 
      21           0 : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeScPivotLayoutTreeList(Window *pParent, VclBuilder::stringmap& )
      22             : {
      23           0 :     return new ScPivotLayoutTreeList(pParent, WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
      24             : }
      25             : 
      26           0 : ScPivotLayoutTreeList::ScPivotLayoutTreeList(Window* pParent, WinBits nBits) :
      27           0 :     ScPivotLayoutTreeListBase(pParent, nBits)
      28           0 : {}
      29             : 
      30           0 : ScPivotLayoutTreeList::~ScPivotLayoutTreeList()
      31           0 : {}
      32             : 
      33           0 : void ScPivotLayoutTreeList::Setup(ScPivotLayoutDialog* pParent, SvPivotTreeListType eType)
      34             : {
      35           0 :     mpParent = pParent;
      36           0 :     meType = eType;
      37           0 : }
      38             : 
      39           0 : OUString lclFunctName(const sal_uInt16 nFunctionMask)
      40             : {
      41           0 :     switch (nFunctionMask)
      42             :     {
      43           0 :         case PIVOT_FUNC_SUM:       return OUString("Sum");
      44           0 :         case PIVOT_FUNC_COUNT:     return OUString("Count");
      45           0 :         case PIVOT_FUNC_AVERAGE:   return OUString("Mean");
      46           0 :         case PIVOT_FUNC_MAX:       return OUString("Max");
      47           0 :         case PIVOT_FUNC_MIN:       return OUString("Min");
      48           0 :         case PIVOT_FUNC_PRODUCT:   return OUString("Product");
      49           0 :         case PIVOT_FUNC_COUNT_NUM: return OUString("Count");
      50           0 :         case PIVOT_FUNC_STD_DEV:   return OUString("StDev");
      51           0 :         case PIVOT_FUNC_STD_DEVP:  return OUString("StDevP");
      52           0 :         case PIVOT_FUNC_STD_VAR:   return OUString("Var");
      53           0 :         case PIVOT_FUNC_STD_VARP:  return OUString("VarP");
      54             :         default:
      55           0 :             break;
      56             :     }
      57           0 :     return OUString();
      58             : }
      59             : 
      60           0 : bool ScPivotLayoutTreeList::DoubleClickHdl()
      61             : {
      62           0 :     ScItemValue* pCurrentItemValue = (ScItemValue*) GetCurEntry()->GetUserData();
      63           0 :     ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData;
      64             : 
      65           0 :     if (mpParent->IsDataElement(rCurrentFunctionData.mnCol))
      66           0 :         return false;
      67             : 
      68           0 :     SCCOL nCurrentColumn = rCurrentFunctionData.mnCol;
      69           0 :     ScDPLabelData* pCurrentLabelData = mpParent->GetLabelData(nCurrentColumn);
      70           0 :     if (!pCurrentLabelData)
      71           0 :         return false;
      72             : 
      73           0 :     ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
      74             : 
      75           0 :     vector<ScDPName> aDataFieldNames;
      76           0 :     mpParent->PushDataFieldNames(aDataFieldNames);
      77             : 
      78             :     boost::scoped_ptr<AbstractScDPSubtotalDlg> pDialog(
      79           0 :         pFactory->CreateScDPSubtotalDlg(this, mpParent->maPivotTableObject, *pCurrentLabelData, rCurrentFunctionData, aDataFieldNames, true));
      80             : 
      81           0 :     if (pDialog->Execute() == RET_OK)
      82             :     {
      83           0 :         pDialog->FillLabelData(*pCurrentLabelData);
      84           0 :         rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
      85             :     }
      86             : 
      87           0 :     return true;
      88             : }
      89             : 
      90           0 : void ScPivotLayoutTreeList::FillFields(ScPivotFieldVector& rFieldVector)
      91             : {
      92           0 :     Clear();
      93             : 
      94           0 :     ScPivotFieldVector::iterator it;
      95           0 :     for (it = rFieldVector.begin(); it != rFieldVector.end(); ++it)
      96             :     {
      97           0 :         ScPivotField& rField = *it;
      98           0 :         ScItemValue* pItemValue = mpParent->GetItem(rField.nCol);
      99           0 :         InsertEntry(pItemValue->maName, NULL, false, TREELIST_APPEND, pItemValue);
     100             :     }
     101           0 : }
     102             : 
     103           0 : void ScPivotLayoutTreeList::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget)
     104             : {
     105           0 :     ScItemValue* pItemValue = (ScItemValue*) pSource->GetUserData();
     106           0 :     ScItemValue* pOriginalItemValue = pItemValue->mpOriginalItemValue;
     107             : 
     108             :     // Don't allow to add "Data" element to page fields
     109           0 :     if(meType == PAGE_LIST && mpParent->IsDataElement(pItemValue->maFunctionData.mnCol))
     110           0 :         return;
     111             : 
     112           0 :     mpParent->ItemInserted(pOriginalItemValue, meType);
     113             : 
     114           0 :     sal_uLong nPosition = (pTarget == NULL) ? TREELIST_APPEND : GetModel()->GetAbsPos(pTarget) + 1;
     115           0 :     InsertEntryForItem(pOriginalItemValue, nPosition);
     116             : }
     117             : 
     118           0 : void ScPivotLayoutTreeList::InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition)
     119             : {
     120           0 :     OUString rName = pItemValue->maName;
     121           0 :     InsertEntry(rName, NULL, false, nPosition, pItemValue);
     122           0 : }
     123             : 
     124           0 : void ScPivotLayoutTreeList::KeyInput(const KeyEvent& rKeyEvent)
     125             : {
     126           0 :     KeyCode aCode = rKeyEvent.GetKeyCode();
     127           0 :     sal_uInt16 nCode = aCode.GetCode();
     128             : 
     129           0 :     switch (nCode)
     130             :     {
     131             :         case KEY_DELETE:
     132           0 :             GetModel()->Remove(GetCurEntry());
     133           0 :             return;
     134             :     }
     135           0 :     SvTreeListBox::KeyInput(rKeyEvent);
     136           0 : }
     137             : 
     138             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10