1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <controller/SlsTransferableData.hxx>
22 #include <SlideSorterViewShell.hxx>
25 namespace sd
{ namespace slidesorter
{ namespace controller
{
27 SdTransferable
* TransferableData::CreateTransferable (
28 SdDrawDocument
* pSrcDoc
,
29 SlideSorterViewShell
* pViewShell
,
30 const ::std::vector
<Representative
>& rRepresentatives
)
32 SdTransferable
* pTransferable
= new SdTransferable (pSrcDoc
, nullptr, false/*bInitOnGetData*/);
33 std::shared_ptr
<TransferableData
> pData (new TransferableData(pViewShell
, rRepresentatives
));
34 pTransferable
->AddUserData(pData
);
38 std::shared_ptr
<TransferableData
> TransferableData::GetFromTransferable (const SdTransferable
* pTransferable
)
42 for (sal_Int32 nIndex
=0,nCount
=pTransferable
->GetUserDataCount(); nIndex
<nCount
; ++nIndex
)
44 std::shared_ptr
<TransferableData
> xData
=
45 std::dynamic_pointer_cast
<TransferableData
>(pTransferable
->GetUserData(nIndex
));
50 return std::shared_ptr
<TransferableData
>();
53 TransferableData::TransferableData (
54 SlideSorterViewShell
* pViewShell
,
55 const ::std::vector
<Representative
>& rRepresentatives
)
56 : mpViewShell(pViewShell
),
57 maRepresentatives(rRepresentatives
)
59 if (mpViewShell
!= nullptr)
60 StartListening(*mpViewShell
);
63 TransferableData::~TransferableData()
65 if (mpViewShell
!= nullptr)
66 EndListening(*mpViewShell
);
69 void TransferableData::Notify (SfxBroadcaster
&, const SfxHint
& rHint
)
73 if (rHint
.GetId() == SfxHintId::Dying
)
75 // This hint may come either from the ViewShell or from the
76 // document (registered by SdTransferable). We do not know
77 // which but both are sufficient to disconnect from the
79 EndListening(*mpViewShell
);
80 mpViewShell
= nullptr;
85 } } } // end of namespace ::sd::slidesorter::controller
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */