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

Generated by: LCOV version 1.10