LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - PivotLayoutTreeList.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 60 1.7 %
Date: 2015-06-13 12:38:46 Functions: 2 12 16.7 %
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 <vcl/builderfactory.hxx>
      16             : #include <svtools/treelistentry.hxx>
      17             : #include "pivot.hxx"
      18             : #include "scabstdlg.hxx"
      19             : 
      20             : using namespace std;
      21             : 
      22           0 : VCL_BUILDER_FACTORY_ARGS(ScPivotLayoutTreeList,
      23             :                          WB_BORDER | WB_TABSTOP | WB_CLIPCHILDREN |
      24             :                          WB_FORCE_MAKEVISIBLE)
      25             : 
      26           0 : ScPivotLayoutTreeList::ScPivotLayoutTreeList(vcl::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 : bool ScPivotLayoutTreeList::DoubleClickHdl()
      40             : {
      41           0 :     SvTreeListEntry* pEntry = GetCurEntry();
      42           0 :     if (!pEntry)
      43           0 :         return false;
      44             : 
      45           0 :     ScItemValue* pCurrentItemValue = static_cast<ScItemValue*>(pEntry->GetUserData());
      46           0 :     ScPivotFuncData& rCurrentFunctionData = pCurrentItemValue->maFunctionData;
      47             : 
      48           0 :     if (mpParent->IsDataElement(rCurrentFunctionData.mnCol))
      49           0 :         return false;
      50             : 
      51           0 :     SCCOL nCurrentColumn = rCurrentFunctionData.mnCol;
      52           0 :     ScDPLabelData* pCurrentLabelData = mpParent->GetLabelData(nCurrentColumn);
      53           0 :     if (!pCurrentLabelData)
      54           0 :         return false;
      55             : 
      56           0 :     ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
      57             : 
      58           0 :     vector<ScDPName> aDataFieldNames;
      59           0 :     mpParent->PushDataFieldNames(aDataFieldNames);
      60             : 
      61             :     boost::scoped_ptr<AbstractScDPSubtotalDlg> pDialog(
      62           0 :         pFactory->CreateScDPSubtotalDlg(this, mpParent->maPivotTableObject, *pCurrentLabelData, rCurrentFunctionData, aDataFieldNames, true));
      63             : 
      64           0 :     if (pDialog->Execute() == RET_OK)
      65             :     {
      66           0 :         pDialog->FillLabelData(*pCurrentLabelData);
      67           0 :         rCurrentFunctionData.mnFuncMask = pDialog->GetFuncMask();
      68             :     }
      69             : 
      70           0 :     return true;
      71             : }
      72             : 
      73           0 : void ScPivotLayoutTreeList::FillFields(ScPivotFieldVector& rFieldVector)
      74             : {
      75           0 :     Clear();
      76             : 
      77           0 :     ScPivotFieldVector::iterator it;
      78           0 :     for (it = rFieldVector.begin(); it != rFieldVector.end(); ++it)
      79             :     {
      80           0 :         ScPivotField& rField = *it;
      81           0 :         ScItemValue* pItemValue = mpParent->GetItem(rField.nCol);
      82           0 :         InsertEntry(pItemValue->maName, NULL, false, TREELIST_APPEND, pItemValue);
      83             :     }
      84           0 : }
      85             : 
      86           0 : void ScPivotLayoutTreeList::InsertEntryForSourceTarget(SvTreeListEntry* pSource, SvTreeListEntry* pTarget)
      87             : {
      88           0 :     ScItemValue* pItemValue = static_cast<ScItemValue*>(pSource->GetUserData());
      89           0 :     ScItemValue* pOriginalItemValue = pItemValue->mpOriginalItemValue;
      90             : 
      91             :     // Don't allow to add "Data" element to page fields
      92           0 :     if(meType == PAGE_LIST && mpParent->IsDataElement(pItemValue->maFunctionData.mnCol))
      93           0 :         return;
      94             : 
      95           0 :     mpParent->ItemInserted(pOriginalItemValue, meType);
      96             : 
      97           0 :     sal_uLong nPosition = (pTarget == NULL) ? TREELIST_APPEND : GetModel()->GetAbsPos(pTarget) + 1;
      98           0 :     InsertEntryForItem(pOriginalItemValue, nPosition);
      99             : }
     100             : 
     101           0 : void ScPivotLayoutTreeList::InsertEntryForItem(ScItemValue* pItemValue, sal_uLong nPosition)
     102             : {
     103           0 :     OUString rName = pItemValue->maName;
     104           0 :     InsertEntry(rName, NULL, false, nPosition, pItemValue);
     105           0 : }
     106             : 
     107           0 : void ScPivotLayoutTreeList::KeyInput(const KeyEvent& rKeyEvent)
     108             : {
     109           0 :     vcl::KeyCode aCode = rKeyEvent.GetKeyCode();
     110           0 :     sal_uInt16 nCode = aCode.GetCode();
     111             : 
     112           0 :     if (nCode == KEY_DELETE)
     113             :     {
     114           0 :         const SvTreeListEntry* pEntry = GetCurEntry();
     115           0 :         if (pEntry)
     116           0 :             GetModel()->Remove(pEntry);
     117           0 :         return;
     118             :     }
     119           0 :     SvTreeListBox::KeyInput(rKeyEvent);
     120         156 : }
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11