LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/controller - SlsTransferableData.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 30 3.3 %
Date: 2015-06-13 12:38:46 Functions: 2 8 25.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             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "controller/SlsTransferableData.hxx"
      21             : 
      22             : #include "SlideSorterViewShell.hxx"
      23             : #include "View.hxx"
      24             : 
      25             : namespace sd { namespace slidesorter { namespace controller {
      26             : 
      27           0 : SdTransferable* TransferableData::CreateTransferable (
      28             :     SdDrawDocument* pSrcDoc,
      29             :     ::sd::View* pWorkView,
      30             :     bool bInitOnGetData,
      31             :     SlideSorterViewShell* pViewShell,
      32             :     const ::std::vector<Representative>& rRepresentatives)
      33             : {
      34           0 :     SdTransferable* pTransferable = new SdTransferable (pSrcDoc, pWorkView, bInitOnGetData);
      35           0 :     ::boost::shared_ptr<TransferableData> pData (new TransferableData(pViewShell, rRepresentatives));
      36           0 :     pTransferable->AddUserData(pData);
      37           0 :     return pTransferable;
      38             : }
      39             : 
      40           0 : ::boost::shared_ptr<TransferableData> TransferableData::GetFromTransferable (const SdTransferable* pTransferable)
      41             : {
      42           0 :     if (pTransferable)
      43             :     {
      44           0 :         for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex<nCount; ++nIndex)
      45             :         {
      46             :             ::boost::shared_ptr<TransferableData> xData =
      47           0 :                 ::boost::dynamic_pointer_cast<TransferableData>(pTransferable->GetUserData(nIndex));
      48           0 :             if (xData)
      49           0 :                 return xData;
      50           0 :         }
      51             :     }
      52           0 :     return ::boost::shared_ptr<TransferableData>();
      53             : }
      54             : 
      55           0 : TransferableData::TransferableData (
      56             :     SlideSorterViewShell* pViewShell,
      57             :     const ::std::vector<Representative>& rRepresentatives)
      58             :     : mpViewShell(pViewShell),
      59           0 :       maRepresentatives(rRepresentatives)
      60             : {
      61           0 :     if (mpViewShell != NULL)
      62           0 :         StartListening(*mpViewShell);
      63           0 : }
      64             : 
      65           0 : TransferableData::~TransferableData()
      66             : {
      67           0 :     if (mpViewShell != NULL)
      68           0 :         EndListening(*mpViewShell);
      69           0 : }
      70             : 
      71           0 : void TransferableData::Notify (SfxBroadcaster&, const SfxHint& rHint)
      72             : {
      73           0 :     const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
      74           0 :     if (pSimpleHint && mpViewShell)
      75             :     {
      76           0 :         if (pSimpleHint->GetId() == SFX_HINT_DYING)
      77             :         {
      78             :             // This hint may come either from the ViewShell or from the
      79             :             // document (registered by SdTransferable).  We do not know
      80             :             // which but both are sufficient to disconnect from the
      81             :             // ViewShell.
      82           0 :             EndListening(*mpViewShell);
      83           0 :             mpViewShell = NULL;
      84             :         }
      85             :     }
      86           0 : }
      87             : 
      88          66 : } } } // end of namespace ::sd::slidesorter::controller
      89             : 
      90             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11