1*c82f2877SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*c82f2877SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*c82f2877SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*c82f2877SAndrew Rist * distributed with this work for additional information
6*c82f2877SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*c82f2877SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*c82f2877SAndrew Rist * "License"); you may not use this file except in compliance
9*c82f2877SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*c82f2877SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*c82f2877SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*c82f2877SAndrew Rist * software distributed under the License is distributed on an
15*c82f2877SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c82f2877SAndrew Rist * KIND, either express or implied. See the License for the
17*c82f2877SAndrew Rist * specific language governing permissions and limitations
18*c82f2877SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*c82f2877SAndrew Rist *************************************************************/
21*c82f2877SAndrew Rist
22*c82f2877SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "controller/SlsTransferableData.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include "SlideSorterViewShell.hxx"
30cdf0e10cSrcweir #include "View.hxx"
31cdf0e10cSrcweir
32cdf0e10cSrcweir namespace sd { namespace slidesorter { namespace controller {
33cdf0e10cSrcweir
CreateTransferable(SdDrawDocument * pSrcDoc,::sd::View * pWorkView,sal_Bool bInitOnGetData,SlideSorterViewShell * pViewShell,const::std::vector<Representative> & rRepresentatives)34cdf0e10cSrcweir SdTransferable* TransferableData::CreateTransferable (
35cdf0e10cSrcweir SdDrawDocument* pSrcDoc,
36cdf0e10cSrcweir ::sd::View* pWorkView,
37cdf0e10cSrcweir sal_Bool bInitOnGetData,
38cdf0e10cSrcweir SlideSorterViewShell* pViewShell,
39cdf0e10cSrcweir const ::std::vector<Representative>& rRepresentatives)
40cdf0e10cSrcweir {
41cdf0e10cSrcweir SdTransferable* pTransferable = new SdTransferable (pSrcDoc, pWorkView, bInitOnGetData);
42cdf0e10cSrcweir ::boost::shared_ptr<TransferableData> pData (new TransferableData(pViewShell, rRepresentatives));
43cdf0e10cSrcweir pTransferable->AddUserData(pData);
44cdf0e10cSrcweir return pTransferable;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
47cdf0e10cSrcweir
48cdf0e10cSrcweir
49cdf0e10cSrcweir
GetFromTransferable(const SdTransferable * pTransferable)50cdf0e10cSrcweir ::boost::shared_ptr<TransferableData> TransferableData::GetFromTransferable (const SdTransferable* pTransferable)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir ::boost::shared_ptr<TransferableData> pData;
53cdf0e10cSrcweir for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex<nCount; ++nIndex)
54cdf0e10cSrcweir {
55cdf0e10cSrcweir pData = ::boost::dynamic_pointer_cast<TransferableData>(pTransferable->GetUserData(nIndex));
56cdf0e10cSrcweir if (pData)
57cdf0e10cSrcweir return pData;
58cdf0e10cSrcweir }
59cdf0e10cSrcweir return ::boost::shared_ptr<TransferableData>();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir
63cdf0e10cSrcweir
64cdf0e10cSrcweir
TransferableData(SlideSorterViewShell * pViewShell,const::std::vector<Representative> & rRepresentatives)65cdf0e10cSrcweir TransferableData::TransferableData (
66cdf0e10cSrcweir SlideSorterViewShell* pViewShell,
67cdf0e10cSrcweir const ::std::vector<Representative>& rRepresentatives)
68cdf0e10cSrcweir : mpViewShell(pViewShell),
69cdf0e10cSrcweir maRepresentatives(rRepresentatives)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir if (mpViewShell != NULL)
72cdf0e10cSrcweir StartListening(*mpViewShell);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir
75cdf0e10cSrcweir
76cdf0e10cSrcweir
77cdf0e10cSrcweir
~TransferableData(void)78cdf0e10cSrcweir TransferableData::~TransferableData (void)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir if (mpViewShell != NULL)
81cdf0e10cSrcweir EndListening(*mpViewShell);
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir
85cdf0e10cSrcweir
86cdf0e10cSrcweir
DragFinished(sal_Int8 nDropAction)87cdf0e10cSrcweir void TransferableData::DragFinished (sal_Int8 nDropAction)
88cdf0e10cSrcweir {
89cdf0e10cSrcweir if (mpViewShell != NULL)
90cdf0e10cSrcweir mpViewShell->DragFinished(nDropAction);
91cdf0e10cSrcweir /*
92cdf0e10cSrcweir for (CallbackContainer::const_iterator
93cdf0e10cSrcweir iCallback(maDragFinishCallbacks.begin()),
94cdf0e10cSrcweir iEnd(maDragFinishCallbacks.end());
95cdf0e10cSrcweir iCallback!=iEnd;
96cdf0e10cSrcweir ++iCallback)
97cdf0e10cSrcweir {
98cdf0e10cSrcweir if (*iCallback)
99cdf0e10cSrcweir (*iCallback)(nDropAction);
100cdf0e10cSrcweir }
101cdf0e10cSrcweir maDragFinishCallbacks.clear();
102cdf0e10cSrcweir */
103cdf0e10cSrcweir }
104cdf0e10cSrcweir
105cdf0e10cSrcweir
106cdf0e10cSrcweir
107cdf0e10cSrcweir
Notify(SfxBroadcaster &,const SfxHint & rHint)108cdf0e10cSrcweir void TransferableData::Notify (SfxBroadcaster&, const SfxHint& rHint)
109cdf0e10cSrcweir {
110cdf0e10cSrcweir if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint));
113cdf0e10cSrcweir if (rSimpleHint.GetId() == SFX_HINT_DYING)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir // This hint may come either from the ViewShell or from the
116cdf0e10cSrcweir // document (registered by SdTransferable). We do not know
117cdf0e10cSrcweir // which but both are sufficient to disconnect from the
118cdf0e10cSrcweir // ViewShell.
119cdf0e10cSrcweir EndListening(*mpViewShell);
120cdf0e10cSrcweir mpViewShell = NULL;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir
126cdf0e10cSrcweir
127cdf0e10cSrcweir
GetRepresentatives(void) const128cdf0e10cSrcweir const ::std::vector<TransferableData::Representative>& TransferableData::GetRepresentatives (void) const
129cdf0e10cSrcweir {
130cdf0e10cSrcweir return maRepresentatives;
131cdf0e10cSrcweir }
132cdf0e10cSrcweir
133cdf0e10cSrcweir
134cdf0e10cSrcweir
135cdf0e10cSrcweir
GetSourceViewShell(void) const136cdf0e10cSrcweir SlideSorterViewShell* TransferableData::GetSourceViewShell (void) const
137cdf0e10cSrcweir {
138cdf0e10cSrcweir return mpViewShell;
139cdf0e10cSrcweir }
140cdf0e10cSrcweir
141cdf0e10cSrcweir } } } // end of namespace ::sd::slidesorter::controller
142