1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sd.hxx" 30 31 #include "controller/SlsTransferableData.hxx" 32 33 #include "SlideSorterViewShell.hxx" 34 #include "View.hxx" 35 36 namespace sd { namespace slidesorter { namespace controller { 37 38 SdTransferable* TransferableData::CreateTransferable ( 39 SdDrawDocument* pSrcDoc, 40 ::sd::View* pWorkView, 41 sal_Bool bInitOnGetData, 42 SlideSorterViewShell* pViewShell, 43 const ::std::vector<Representative>& rRepresentatives) 44 { 45 SdTransferable* pTransferable = new SdTransferable (pSrcDoc, pWorkView, bInitOnGetData); 46 ::boost::shared_ptr<TransferableData> pData (new TransferableData(pViewShell, rRepresentatives)); 47 pTransferable->AddUserData(pData); 48 return pTransferable; 49 } 50 51 52 53 54 ::boost::shared_ptr<TransferableData> TransferableData::GetFromTransferable (const SdTransferable* pTransferable) 55 { 56 ::boost::shared_ptr<TransferableData> pData; 57 for (sal_Int32 nIndex=0,nCount=pTransferable->GetUserDataCount(); nIndex<nCount; ++nIndex) 58 { 59 pData = ::boost::dynamic_pointer_cast<TransferableData>(pTransferable->GetUserData(nIndex)); 60 if (pData) 61 return pData; 62 } 63 return ::boost::shared_ptr<TransferableData>(); 64 } 65 66 67 68 69 TransferableData::TransferableData ( 70 SlideSorterViewShell* pViewShell, 71 const ::std::vector<Representative>& rRepresentatives) 72 : mpViewShell(pViewShell), 73 maRepresentatives(rRepresentatives) 74 { 75 if (mpViewShell != NULL) 76 StartListening(*mpViewShell); 77 } 78 79 80 81 82 TransferableData::~TransferableData (void) 83 { 84 if (mpViewShell != NULL) 85 EndListening(*mpViewShell); 86 } 87 88 89 90 91 void TransferableData::DragFinished (sal_Int8 nDropAction) 92 { 93 if (mpViewShell != NULL) 94 mpViewShell->DragFinished(nDropAction); 95 /* 96 for (CallbackContainer::const_iterator 97 iCallback(maDragFinishCallbacks.begin()), 98 iEnd(maDragFinishCallbacks.end()); 99 iCallback!=iEnd; 100 ++iCallback) 101 { 102 if (*iCallback) 103 (*iCallback)(nDropAction); 104 } 105 maDragFinishCallbacks.clear(); 106 */ 107 } 108 109 110 111 112 void TransferableData::Notify (SfxBroadcaster&, const SfxHint& rHint) 113 { 114 if (rHint.ISA(SfxSimpleHint) && mpViewShell!=NULL) 115 { 116 SfxSimpleHint& rSimpleHint (*PTR_CAST(SfxSimpleHint, &rHint)); 117 if (rSimpleHint.GetId() == SFX_HINT_DYING) 118 { 119 // This hint may come either from the ViewShell or from the 120 // document (registered by SdTransferable). We do not know 121 // which but both are sufficient to disconnect from the 122 // ViewShell. 123 EndListening(*mpViewShell); 124 mpViewShell = NULL; 125 } 126 } 127 } 128 129 130 131 132 const ::std::vector<TransferableData::Representative>& TransferableData::GetRepresentatives (void) const 133 { 134 return maRepresentatives; 135 } 136 137 138 139 140 SlideSorterViewShell* TransferableData::GetSourceViewShell (void) const 141 { 142 return mpViewShell; 143 } 144 145 } } } // end of namespace ::sd::slidesorter::controller 146