LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/controller - SlsDragAndDropContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 44 2.3 %
Date: 2014-11-03 Functions: 2 7 28.6 %
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 "SlsDragAndDropContext.hxx"
      21             : 
      22             : #include "SlideSorter.hxx"
      23             : #include "model/SlideSorterModel.hxx"
      24             : #include "model/SlsPageEnumerationProvider.hxx"
      25             : #include "view/SlideSorterView.hxx"
      26             : #include "controller/SlideSorterController.hxx"
      27             : #include "controller/SlsInsertionIndicatorHandler.hxx"
      28             : #include "controller/SlsScrollBarManager.hxx"
      29             : #include "controller/SlsProperties.hxx"
      30             : #include "controller/SlsSelectionFunction.hxx"
      31             : #include "controller/SlsSelectionManager.hxx"
      32             : #include "controller/SlsClipboard.hxx"
      33             : #include "controller/SlsTransferableData.hxx"
      34             : #include "DrawDocShell.hxx"
      35             : #include "drawdoc.hxx"
      36             : #include "app.hrc"
      37             : #include "sdtreelb.hxx"
      38             : #include <sfx2/bindings.hxx>
      39             : #include <boost/bind.hpp>
      40             : 
      41             : namespace sd { namespace slidesorter { namespace controller {
      42             : 
      43           0 : DragAndDropContext::DragAndDropContext (SlideSorter& rSlideSorter)
      44             :     : mpTargetSlideSorter(&rSlideSorter),
      45           0 :       mnInsertionIndex(-1)
      46             : {
      47             :     // No Drag-and-Drop for master pages.
      48           0 :     if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE)
      49           0 :         return;
      50             : 
      51             :     // For poperly handling transferables created by the navigator we
      52             :     // need additional information.  For this a user data object is
      53             :     // created that contains the necessary information.
      54           0 :     SdTransferable* pTransferable = SD_MOD()->pTransferDrag;
      55             :     SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable
      56           0 :         = dynamic_cast<SdPageObjsTLB::SdPageObjsTransferable*>(pTransferable);
      57           0 :     if (pTreeListBoxTransferable!=NULL && !TransferableData::GetFromTransferable(pTransferable))
      58             :     {
      59             :         pTransferable->AddUserData(
      60           0 :             rSlideSorter.GetController().GetClipboard().CreateTransferableUserData(pTransferable));
      61             :     }
      62             : 
      63           0 :     rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(pTransferable);
      64             : }
      65             : 
      66           0 : DragAndDropContext::~DragAndDropContext (void)
      67             : {
      68           0 :     SetTargetSlideSorter (NULL, Point(0,0), InsertionIndicatorHandler::UnknownMode, false);
      69           0 : }
      70             : 
      71           0 : void DragAndDropContext::Dispose (void)
      72             : {
      73           0 :     mnInsertionIndex = -1;
      74           0 : }
      75             : 
      76           0 : void DragAndDropContext::UpdatePosition (
      77             :     const Point& rMousePosition,
      78             :     const InsertionIndicatorHandler::Mode eMode,
      79             :     const bool bAllowAutoScroll)
      80             : {
      81           0 :     if (mpTargetSlideSorter == NULL)
      82           0 :         return;
      83             : 
      84           0 :     if (mpTargetSlideSorter->GetProperties()->IsUIReadOnly())
      85           0 :         return;
      86             : 
      87             :     // Convert window coordinates into model coordinates (we need the
      88             :     // window coordinates for auto-scrolling because that remains
      89             :     // constant while scrolling.)
      90           0 :     SharedSdWindow pWindow (mpTargetSlideSorter->GetContentWindow());
      91           0 :     const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
      92             :     ::boost::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler (
      93           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler());
      94             : 
      95             :     bool bDoAutoScroll = bAllowAutoScroll
      96           0 :             && mpTargetSlideSorter->GetController().GetScrollBarManager().AutoScroll(
      97             :                 rMousePosition,
      98             :                 ::boost::bind(
      99           0 :                     &DragAndDropContext::UpdatePosition, this, rMousePosition, eMode, false));
     100             : 
     101           0 :     if (!bDoAutoScroll)
     102             :     {
     103           0 :         pInsertionIndicatorHandler->UpdatePosition(aMouseModelPosition, eMode);
     104             : 
     105             :         // Remember the new insertion index.
     106           0 :         mnInsertionIndex = pInsertionIndicatorHandler->GetInsertionPageIndex();
     107           0 :         if (pInsertionIndicatorHandler->IsInsertionTrivial(mnInsertionIndex, eMode))
     108           0 :             mnInsertionIndex = -1;
     109           0 :     }
     110             : }
     111             : 
     112           0 : void DragAndDropContext::SetTargetSlideSorter (
     113             :     SlideSorter* pSlideSorter,
     114             :     const Point aMousePosition,
     115             :     const InsertionIndicatorHandler::Mode eMode,
     116             :     const bool bIsOverSourceView)
     117             : {
     118           0 :     if (mpTargetSlideSorter != NULL)
     119             :     {
     120           0 :         mpTargetSlideSorter->GetController().GetScrollBarManager().StopAutoScroll();
     121           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->End(
     122           0 :             Animator::AM_Animated);
     123             :     }
     124             : 
     125           0 :     mpTargetSlideSorter = pSlideSorter;
     126             : 
     127           0 :     if (mpTargetSlideSorter != NULL)
     128             :     {
     129           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->Start(
     130           0 :             bIsOverSourceView);
     131           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->UpdatePosition(
     132             :             aMousePosition,
     133           0 :             eMode);
     134             : 
     135             :     }
     136           0 : }
     137             : 
     138         114 : } } } // end of namespace ::sd::slidesorter::controller
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10