LibreOffice Module sd (master) 1
SlsTransferableData.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
23
25
27 SdDrawDocument* pSrcDoc,
28 SlideSorterViewShell* pViewShell,
29 ::std::vector<Representative>&& rRepresentatives)
30{
31 rtl::Reference<SdTransferable> pTransferable = new SdTransferable (pSrcDoc, nullptr, false/*bInitOnGetData*/);
32 auto pData = std::make_shared<TransferableData>(pViewShell, std::move(rRepresentatives));
33 pTransferable->AddUserData(pData);
34 return pTransferable;
35}
36
37std::shared_ptr<TransferableData> TransferableData::GetFromTransferable (const SdTransferable* pTransferable)
38{
39 if (pTransferable)
40 {
41 for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex<nCount; ++nIndex)
42 {
43 std::shared_ptr<TransferableData> xData =
44 std::dynamic_pointer_cast<TransferableData>(pTransferable->GetUserData(nIndex));
45 if (xData)
46 return xData;
47 }
48 }
49 return std::shared_ptr<TransferableData>();
50}
51
53 SlideSorterViewShell* pViewShell,
54 ::std::vector<Representative>&& rRepresentatives)
55 : mpViewShell(pViewShell),
56 maRepresentatives(std::move(rRepresentatives))
57{
58 if (mpViewShell != nullptr)
60}
61
63{
64 if (mpViewShell != nullptr)
66}
67
69{
70 if (mpViewShell)
71 {
72 if (rHint.GetId() == SfxHintId::Dying)
73 {
74 // This hint may come either from the ViewShell or from the
75 // document (registered by SdTransferable). We do not know
76 // which but both are sufficient to disconnect from the
77 // ViewShell.
79 mpViewShell = nullptr;
80 }
81 }
82}
83
84} // end of namespace ::sd::slidesorter::controller
85
86/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 GetUserDataCount() const
Return the number of user data objects.
Definition: sdxfer.cxx:711
std::shared_ptr< UserData > GetUserData(const sal_Int32 nIndex) const
Return the specified user data object.
Definition: sdxfer.cxx:716
SfxHintId GetId() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
static rtl::Reference< SdTransferable > CreateTransferable(SdDrawDocument *pSrcDoc, SlideSorterViewShell *pViewShell, ::std::vector< TransferableData::Representative > &&rRepresentatives)
TransferableData(SlideSorterViewShell *pViewShell, ::std::vector< TransferableData::Representative > &&rRepresentatives)
virtual void Notify(SfxBroadcaster &rBroadcaster, const SfxHint &rHint) override
static std::shared_ptr< TransferableData > GetFromTransferable(const SdTransferable *pTransferable)
int nCount
sal_Int32 nIndex
std::unique_ptr< sal_Int32[]> pData