LibreOffice Module sd (master) 1
SlsDragAndDropContext.cxx
Go to the documentation of this file.
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
21
22#include <SlideSorter.hxx>
30#include <Window.hxx>
31#include <sdtreelb.hxx>
32#include <sdmod.hxx>
33
35
37 : mpTargetSlideSorter(&rSlideSorter),
38 mnInsertionIndex(-1)
39{
40 // No Drag-and-Drop for master pages.
41 if (rSlideSorter.GetModel().GetEditMode() != EditMode::Page)
42 return;
43
44 // For properly handling transferables created by the navigator we
45 // need additional information. For this a user data object is
46 // created that contains the necessary information.
47 SdTransferable* pTransferable = SD_MOD()->pTransferDrag;
48 SdPageObjsTLV::SdPageObjsTransferable* pTreeListBoxTransferable
49 = dynamic_cast<SdPageObjsTLV::SdPageObjsTransferable*>(pTransferable);
50 if (pTreeListBoxTransferable!=nullptr && !TransferableData::GetFromTransferable(pTransferable))
51 {
52 pTransferable->AddUserData(
54 }
55
56 rSlideSorter.GetController().GetInsertionIndicatorHandler()->UpdateIndicatorIcon(pTransferable);
57}
58
60{
62}
63
65{
67}
68
70 const Point& rMousePosition,
72 const bool bAllowAutoScroll)
73{
74 if (mpTargetSlideSorter == nullptr)
75 return;
76
77 // Convert window coordinates into model coordinates (we need the
78 // window coordinates for auto-scrolling because that remains
79 // constant while scrolling.)
81 const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
82 std::shared_ptr<InsertionIndicatorHandler> pInsertionIndicatorHandler (
84
85 bool bDoAutoScroll = bAllowAutoScroll
87 rMousePosition,
88 [this, eMode, rMousePosition] () {
89 return this->UpdatePosition(rMousePosition, eMode, false);
90 });
91
92 if (!bDoAutoScroll)
93 {
94 pInsertionIndicatorHandler->UpdatePosition(aMouseModelPosition, eMode);
95
96 // Remember the new insertion index.
97 mnInsertionIndex = pInsertionIndicatorHandler->GetInsertionPageIndex();
98 if (pInsertionIndicatorHandler->IsInsertionTrivial(mnInsertionIndex, eMode))
100 }
101}
102
104{
105 if (mpTargetSlideSorter != nullptr)
106 {
110 }
111
112 mpTargetSlideSorter = nullptr;
113}
114
115} // end of namespace ::sd::slidesorter::controller
116
117/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddUserData(const std::shared_ptr< UserData > &rpData)
Add a user data object.
Definition: sdxfer.cxx:706
reference_type * get() const
An SdWindow contains the actual working area of ViewShell.
Definition: Window.hxx:45
Show previews for all the slides in a document and allow the user to insert or delete slides and modi...
Definition: SlideSorter.hxx:62
SD_DLLPUBLIC controller::SlideSorterController & GetController() const
const VclPtr< sd::Window > & GetContentWindow() const
Return the content window.
Definition: SlideSorter.hxx:99
model::SlideSorterModel & GetModel() const
static std::shared_ptr< SdTransferable::UserData > CreateTransferableUserData(SdTransferable *pTransferable)
Create a slide sorter transferable from the given sd transferable.
void UpdatePosition(const Point &rMousePosition, const InsertionIndicatorHandler::Mode eMode, const bool bAllowAutoScroll)
Move the substitution display by the distance the mouse has travelled since the last call to this met...
DragAndDropContext(SlideSorter &rSlideSorter)
Create a substitution display of the currently selected pages or, when provided, the pages in the tra...
void Dispose()
Call this method (for example as reaction to ESC key press) to avoid processing (ie moving or inserti...
bool AutoScroll(const Point &rMouseWindowPosition, const ::std::function< void()> &rAutoScrollFunctor)
Call this method to scroll a window while the mouse is in dragging a selection.
ScrollBarManager & GetScrollBarManager()
Return the object that manages the scroll bars.
std::shared_ptr< InsertionIndicatorHandler > const & GetInsertionIndicatorHandler() const
static std::shared_ptr< TransferableData > GetFromTransferable(const SdTransferable *pTransferable)
Point PixelToLogic(const Point &rDevicePt) const
Mode eMode
#define SD_MOD()
Definition: sdmod.hxx:184