LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/slidesorter/controller - SlsDragAndDropContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 43 2.3 %
Date: 2012-12-27 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             : 
      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           0 :     ::std::vector<const SdPage*> aPages;
      49             : 
      50             :     // No Drag-and-Drop for master pages.
      51           0 :     if (rSlideSorter.GetModel().GetEditMode() != EM_PAGE)
      52           0 :         return;
      53             : 
      54             :     // For poperly handling transferables created by the navigator we
      55             :     // need additional information.  For this a user data object is
      56             :     // created that contains the necessary information.
      57           0 :     SdTransferable* pTransferable = SD_MOD()->pTransferDrag;
      58             :     SdPageObjsTLB::SdPageObjsTransferable* pTreeListBoxTransferable
      59           0 :         = dynamic_cast<SdPageObjsTLB::SdPageObjsTransferable*>(pTransferable);
      60           0 :     if (pTreeListBoxTransferable!=NULL && !TransferableData::GetFromTransferable(pTransferable))
      61             :     {
      62             :         pTransferable->AddUserData(
      63           0 :             rSlideSorter.GetController().GetClipboard().CreateTransferableUserData(pTransferable));
      64             :     }
      65             : 
      66           0 :     rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(pTransferable);
      67             : }
      68             : 
      69             : 
      70             : 
      71             : 
      72           0 : DragAndDropContext::~DragAndDropContext (void)
      73             : {
      74           0 :     SetTargetSlideSorter (NULL, Point(0,0), InsertionIndicatorHandler::UnknownMode, false);
      75           0 : }
      76             : 
      77             : 
      78             : 
      79             : 
      80           0 : void DragAndDropContext::Dispose (void)
      81             : {
      82           0 :     mnInsertionIndex = -1;
      83           0 : }
      84             : 
      85             : 
      86             : 
      87             : 
      88           0 : void DragAndDropContext::UpdatePosition (
      89             :     const Point& rMousePosition,
      90             :     const InsertionIndicatorHandler::Mode eMode,
      91             :     const bool bAllowAutoScroll)
      92             : {
      93           0 :     if (mpTargetSlideSorter == NULL)
      94             :         return;
      95             : 
      96           0 :     if (mpTargetSlideSorter->GetProperties()->IsUIReadOnly())
      97             :         return;
      98             : 
      99             :     // Convert window coordinates into model coordinates (we need the
     100             :     // window coordinates for auto-scrolling because that remains
     101             :     // constant while scrolling.)
     102           0 :     SharedSdWindow pWindow (mpTargetSlideSorter->GetContentWindow());
     103           0 :     const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
     104             :     ::boost::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler (
     105           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler());
     106             : 
     107             :     bool bDoAutoScroll = bAllowAutoScroll
     108           0 :             && mpTargetSlideSorter->GetController().GetScrollBarManager().AutoScroll(
     109             :                 rMousePosition,
     110             :                 ::boost::bind(
     111           0 :                     &DragAndDropContext::UpdatePosition, this, rMousePosition, eMode, false));
     112             : 
     113           0 :     if (!bDoAutoScroll)
     114             :     {
     115           0 :         pInsertionIndicatorHandler->UpdatePosition(aMouseModelPosition, eMode);
     116             : 
     117             :         // Remember the new insertion index.
     118           0 :         mnInsertionIndex = pInsertionIndicatorHandler->GetInsertionPageIndex();
     119           0 :         if (pInsertionIndicatorHandler->IsInsertionTrivial(mnInsertionIndex, eMode))
     120           0 :             mnInsertionIndex = -1;
     121           0 :     }
     122             : }
     123             : 
     124             : 
     125             : 
     126             : 
     127           0 : void DragAndDropContext::SetTargetSlideSorter (
     128             :     SlideSorter* pSlideSorter,
     129             :     const Point aMousePosition,
     130             :     const InsertionIndicatorHandler::Mode eMode,
     131             :     const bool bIsOverSourceView)
     132             : {
     133           0 :     if (mpTargetSlideSorter != NULL)
     134             :     {
     135           0 :         mpTargetSlideSorter->GetController().GetScrollBarManager().StopAutoScroll();
     136           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->End(
     137           0 :             Animator::AM_Animated);
     138             :     }
     139             : 
     140           0 :     mpTargetSlideSorter = pSlideSorter;
     141             : 
     142           0 :     if (mpTargetSlideSorter != NULL)
     143             :     {
     144           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->Start(
     145           0 :             bIsOverSourceView);
     146           0 :         mpTargetSlideSorter->GetController().GetInsertionIndicatorHandler()->UpdatePosition(
     147             :             aMousePosition,
     148           0 :             eMode);
     149             : 
     150             :     }
     151           0 : }
     152             : 
     153             : 
     154           9 : } } } // end of namespace ::sd::slidesorter::controller
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10