Kaydet (Commit) 82453a8c authored tarafından Kai Ahrens's avatar Kai Ahrens

#80266#: added D&D functionality for slide view

üst 3df221c8
......@@ -2,9 +2,9 @@
*
* $RCSfile: fudraw.cxx,v $
*
* $Revision: 1.5 $
* $Revision: 1.6 $
*
* last change: $Author: dl $ $Date: 2001-07-17 06:51:52 $
* last change: $Author: ka $ $Date: 2001-09-24 13:41:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -979,55 +979,6 @@ void FuDraw::DoubleClick(const MouseEvent& rMEvt)
pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
}
/*************************************************************************
|*
|* Command-event
|*
\************************************************************************/
BOOL FuDraw::Command(const CommandEvent& rCEvt)
{
BOOL bReturn = FALSE;
if ( rCEvt.GetCommand() == COMMAND_STARTDRAG )
{
USHORT nHitLog = USHORT ( pWindow->PixelToLogic(Size(HITPIX,0)).Width() );
// MouseButtonDown will not called
aMDPos = pWindow->PixelToLogic( rCEvt.GetMousePosPixel() );
if ( pView->IsMarkedHit(aMDPos, nHitLog) && !bIsInDragMode )
{
// hit handle or marked object
if ( !pView->IsAction() )
{
SdrHdl* pHdl = pView->HitHandle(aMDPos, *pWindow);
USHORT nDrgLog = USHORT ( pWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
if ( !pHdl && !pView->IsPresObjSelected(FALSE, TRUE) )
{
pWindow->ReleaseMouse();
bIsInDragMode = TRUE;
pView->BeginDrag(pWindow, aMDPos);
bIsInDragMode = FALSE;
}
}
bReturn = TRUE;
}
}
if (!bReturn)
{
bReturn = FuPoor::Command(rCEvt);
}
return bReturn;
}
/*************************************************************************
|*
|* Help-event
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: fupoor.cxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: ka $ $Date: 2001-01-11 16:19:17 $
* last change: $Author: ka $ $Date: 2001-09-24 13:41:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -585,8 +585,7 @@ IMPL_LINK( FuPoor, DragHdl, Timer *, pTimer )
{
pWindow->ReleaseMouse();
bIsInDragMode = TRUE;
pView->BeginDrag(pWindow, aMDPos);
pView->StartDrag( aMDPos, pWindow );
}
return 0;
}
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: bmcache.cxx,v $
*
* $Revision: 1.1.1.1 $
* $Revision: 1.2 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:48:43 $
* last change: $Author: ka $ $Date: 2001-09-24 13:38:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -61,24 +61,19 @@
#pragma hdrstop
#include <limits.h> // LONG_MAX
#ifndef _SOLAR_H
#include <limits.h> // LONG_MAX
#include <tools/solar.h>
#endif
#ifndef _SV_BITMAP_HXX
#include <vcl/bitmap.hxx>
#endif
#include <goodies/grfmgr.hxx>
#include "bmcache.hxx"
// eine Struktur fuer die Cache-Eintraege
typedef struct
struct BitmapCacheEntry
{
const SdPage* pPage;
Bitmap* pBitmap;
long nZoom;
} BitmapCacheEntry;
const SdPage* pPage;
GraphicObject* pGraphicObject;
sal_uInt32 nSizeBytes;
long nZoom;
};
/*************************************************************************
|*
......@@ -88,12 +83,10 @@ typedef struct
BitmapCache::~BitmapCache()
{
BitmapCacheEntry* pEntry = NULL;
while (aEntries.Count() > 0)
for( void* pEntry = aEntries.First(); pEntry; pEntry = aEntries.Next() )
{
pEntry = (BitmapCacheEntry*)aEntries.Remove((ULONG)0);
delete pEntry->pBitmap;
delete pEntry;
delete static_cast< BitmapCacheEntry* >( pEntry )->pGraphicObject;
delete static_cast< BitmapCacheEntry* >( pEntry );
}
}
......@@ -103,36 +96,38 @@ BitmapCache::~BitmapCache()
|*
\************************************************************************/
void BitmapCache::Add(const SdPage* pPage, Bitmap* pBitmap, long nZoom)
void BitmapCache::Add(const SdPage* pPage, const Bitmap& rBmp, long nZoom)
{
BitmapCacheEntry* pEntry = NULL;
ULONG nSizeOfBitmap = pBitmap->GetSizeBytes();
BitmapCacheEntry* pEntry = NULL;
ULONG nSizeOfBitmap = rBmp.GetSizeBytes();
if (nSizeOfBitmap < nMaxSize)
if( nSizeOfBitmap < nMaxSize )
{
while (nCurSize + nSizeOfBitmap > nMaxSize)
while (nCurSize + nSizeOfBitmap > nMaxSize)
{
if( aEntries.Count() )
{
if( aEntries.Count() )
pEntry = (BitmapCacheEntry*) aEntries.Remove(aEntries.Count() - 1);
if( pEntry && pEntry->pGraphicObject )
{
pEntry = (BitmapCacheEntry*)aEntries.Remove(aEntries.Count() - 1);
if ( pEntry && pEntry->pBitmap != NULL)
{
nCurSize -= pEntry->pBitmap->GetSizeBytes();
delete pEntry->pBitmap;
}
delete pEntry;
nCurSize -= pEntry->nSizeBytes;
delete pEntry->pGraphicObject;
}
else
break;
delete pEntry;
}
else
break;
}
pEntry = new BitmapCacheEntry;
pEntry->pPage = pPage;
pEntry->pBitmap = pBitmap;
pEntry->nZoom = nZoom;
pEntry = new BitmapCacheEntry;
pEntry->pPage = pPage;
pEntry->pGraphicObject = new GraphicObject( rBmp );
pEntry->nSizeBytes = nSizeOfBitmap;
pEntry->nZoom = nZoom;
aEntries.Insert(pEntry, (ULONG)0);
aEntries.Insert( pEntry, (ULONG) 0 );
nCurSize += nSizeOfBitmap;
}
}
......@@ -150,74 +145,70 @@ void BitmapCache::Add(const SdPage* pPage, Bitmap* pBitmap, long nZoom)
|*
\************************************************************************/
const Bitmap* BitmapCache::Get(const SdPage* pPage, long& rZoomPercent,
long nZoomTolerancePercent)
const GraphicObject* BitmapCache::Get( const SdPage* pPage, long& rZoomPercent, long nZoomTolerancePercent)
{
BitmapCacheEntry* pEntry = NULL;
Bitmap* pBitmap = NULL;
GraphicObject* pGraphicObject = NULL;
// "best fit"-Suche
if (nZoomTolerancePercent < 0)
if( nZoomTolerancePercent < 0 )
{
// "best fit"-Suche
long nTolerance = -nZoomTolerancePercent;
BitmapCacheEntry* pBest = NULL;
long nBest = LONG_MAX;
long nTest = 0L;
for (ULONG nPos = 0; nPos < aEntries.Count(); nPos++)
for( ULONG nPos = 0; nPos < aEntries.Count(); nPos++ )
{
pEntry = (BitmapCacheEntry*)aEntries.GetObject(nPos);
if (pEntry->pPage == pPage)
pEntry = (BitmapCacheEntry*) aEntries.GetObject( nPos );
if( pEntry->pPage == pPage )
{
nTest = rZoomPercent - pEntry->nZoom;
if (nTest >= 0 && nTest < nBest && nTest <= nTolerance)
{
if( nTest >= 0 && nTest < nBest && nTest <= nTolerance )
pBest = pEntry;
}
}
}
pEntry = pBest;
}
// "first fit"-suche
else
{
for (ULONG nPos = 0; nPos < aEntries.Count(); nPos++)
// "first fit"-suche
for( ULONG nPos = 0; nPos < aEntries.Count(); nPos++ )
{
pEntry = (BitmapCacheEntry*)aEntries.GetObject(nPos);
if (pEntry->pPage == pPage &&
Abs(pEntry->nZoom - rZoomPercent) <= nZoomTolerancePercent)
{
pEntry = (BitmapCacheEntry*)aEntries.GetObject( nPos );
if (pEntry->pPage == pPage && Abs( pEntry->nZoom - rZoomPercent ) <= nZoomTolerancePercent )
break;
}
else
{
pEntry = NULL;
}
}
}
// was passendes gefunden?
if (pEntry)
if( pEntry )
{
pBitmap = pEntry->pBitmap;
aEntries.Remove(pEntry);
aEntries.Insert(pEntry, (ULONG)0);
pGraphicObject = pEntry->pGraphicObject;
aEntries.Remove( pEntry );
aEntries.Insert( pEntry, (ULONG) 0 );
rZoomPercent = pEntry->nZoom;
}
return pBitmap;
return pGraphicObject;
}
void BitmapCache::Remove(const SdPage* pPage)
void BitmapCache::Remove( const SdPage* pPage )
{
for (ULONG nPos = 0; nPos < aEntries.Count(); )
for( ULONG nPos = 0; nPos < aEntries.Count(); )
{
BitmapCacheEntry* pCand = (BitmapCacheEntry*)aEntries.GetObject(nPos);
BitmapCacheEntry* pCand = (BitmapCacheEntry*) aEntries.GetObject( nPos );
if(pCand->pPage == pPage)
if( pCand->pPage == pPage )
{
pCand = (BitmapCacheEntry*)aEntries.Remove((ULONG)nPos);
delete pCand->pBitmap;
pCand = (BitmapCacheEntry*) aEntries.Remove((ULONG)nPos);
delete pCand->pGraphicObject;
delete pCand;
}
else
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: sdview2.cxx,v $
*
* $Revision: 1.21 $
* $Revision: 1.22 $
*
* last change: $Author: ka $ $Date: 2001-09-13 11:06:40 $
* last change: $Author: ka $ $Date: 2001-09-24 13:38:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -185,11 +185,14 @@ struct SdNavigatorDropEvent : public ExecuteDropEvent
String aDisplayName;
SdrOle2Obj* pSdrOleObj = NULL;
SdrPageView* pPgView = GetPageViewPvNum( 0 );
SdPage* pPage = (SdPage*) pPgView->GetPage();
SdPage* pNewPage = (SdPage*) pTransferable->GetWorkDocument()->GetPage(0);
SdPage* pOldPage = pPgView ? ( (SdPage*) pPgView->GetPage() ) : NULL;
SdPage* pNewPage = (SdPage*) pTransferable->GetWorkDocument()->GetPage( 0 );
pNewPage->SetSize( pPage->GetSize() );
pNewPage->SetLayoutName( pPage->GetLayoutName() );
if( pOldPage )
{
pNewPage->SetSize( pOldPage->GetSize() );
pNewPage->SetLayoutName( pOldPage->GetLayoutName() );
}
if( aMark.GetMarkCount() == 1 )
{
......@@ -383,85 +386,33 @@ void __EXPORT SdView::DoPaste( Window* pWindow )
}
else
{
Point aPos;
BOOL bPagesInserted = FALSE;
SdTransferable* pTransferClip = SD_MOD()->pTransferClip;
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewSh->GetActiveWindow() ) );
if( pWindow )
aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
if( pTransferClip && pTransferClip->GetDocShell() )
if( aDataHelper.GetTransferable().is() )
{
// Eigenes Format: Ganze Seiten einfuegen?
SvEmbeddedObject* pObj = pTransferClip->GetDocShell();
SdDrawDocShell* pDataDocSh = (SdDrawDocShell*) pObj;
SdDrawDocument* pDataDoc = pDataDocSh->GetDoc();
if( pDataDoc && pDataDoc->GetSdPageCount( PK_STANDARD ) > 1 )
{
// Dokument hat mehrere Seiten -> Seiten einfuegen
bPagesInserted = TRUE;
USHORT nInsertPgCnt = pDataDoc->GetSdPageCount(PK_STANDARD);
USHORT nInsertPos = pDoc->GetSdPageCount(PK_STANDARD) * 2 + 1;
USHORT nPgCnt = pDoc->GetSdPageCount(PK_STANDARD);
BOOL bMergeMasterPages = TRUE;
for( USHORT nPage = 0; nPage < nPgCnt; nPage++ )
{
SdPage* pPage = pDoc->GetSdPage( nPage, PK_STANDARD );
if( pPage->IsSelected() )
nInsertPos = nPage * 2 + 3;
}
if( pTransferClip->HasSourceDoc( pDoc ) )
bMergeMasterPages = FALSE;
pDoc->InsertBookmarkAsPage( NULL, NULL, FALSE, FALSE, nInsertPos,
FALSE, pDataDocSh, TRUE, bMergeMasterPages );
if( this->ISA( SdSlideView ) )
{
// Alle Seiten deselektieren
for( USHORT nPage = 0, nPgCnt = pDoc->GetSdPageCount( PK_STANDARD ); nPage < nPgCnt; nPage++ )
pDoc->GetSdPage( nPage, PK_STANDARD )->SetSelected( FALSE );
Point aPos;
sal_Int8 nDnDAction = DND_ACTION_COPY;
// Die letzte eingefuegte Seite selektieren
SdPage* pPage = pDoc->GetSdPage( nInsertPos / 2 + nInsertPgCnt - 1, PK_STANDARD );
if( pWindow )
aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
if( pPage )
pPage->SetSelected( TRUE );
}
}
}
if( !bPagesInserted && this->ISA( SdDrawView ) )
{
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewSh->GetActiveWindow() ) );
if( aDataHelper.GetTransferable().is() )
if( !InsertData( aDataHelper, aPos, nDnDAction, FALSE ) )
{
sal_Int8 nDnDAction = DND_ACTION_COPY;
SdDrawViewShell* pDrViewSh = (SdDrawViewShell*) pDocSh->GetViewShell();
if( !InsertData( aDataHelper, aPos, nDnDAction, FALSE ) )
if( pDrViewSh )
{
SdDrawViewShell* pDrViewSh = (SdDrawViewShell*) pDocSh->GetViewShell();
if( pDrViewSh )
String aEmptyStr;
INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
{
String aEmptyStr;
INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
{
pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
}
pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
}
}
}
......@@ -471,11 +422,9 @@ void __EXPORT SdView::DoPaste( Window* pWindow )
// -----------------------------------------------------------------------------
BOOL SdView::BeginDrag(Window* pWindow, Point aStartPos)
void SdView::StartDrag( const Point& rStartPos, Window* pWindow )
{
BOOL bRet = HasMarkedObj() && IsAction() && pViewSh && pWindow;
if( bRet )
if( HasMarkedObj() && IsAction() && pViewSh && pWindow )
{
BrkAction();
......@@ -499,10 +448,8 @@ BOOL SdView::BeginDrag(Window* pWindow, Point aStartPos)
aStr += sal_Unicode(' ');
aStr += pDragSrcMarkList->GetMarkDescription();
BegUndo(aStr);
CreateDragDataObject( this, *pWindow, aStartPos );
CreateDragDataObject( this, *pWindow, rStartPos );
}
return bRet;
}
// -----------------------------------------------------------------------------
......@@ -600,9 +547,15 @@ sal_Int8 SdView::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTar
if( pSourceView )
{
if( !( nDropAction & DND_ACTION_LINK ) || pSourceView->GetDocSh()->GetMedium()->GetName().Len() )
if( !( nDropAction & DND_ACTION_LINK ) ||
pSourceView->GetDocSh()->GetMedium()->GetName().Len() ||
pDragTransferable->IsPageTransferable() )
{
nRet = nDropAction;
}
}
else if( pDragTransferable->IsPageTransferable() )
nRet = nDropAction;
}
else
{
......
......@@ -2,9 +2,9 @@
*
* $RCSfile: sdview3.cxx,v $
*
* $Revision: 1.31 $
* $Revision: 1.32 $
*
* last change: $Author: ka $ $Date: 2001-09-05 08:54:48 $
* last change: $Author: ka $ $Date: 2001-09-24 13:38:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
......@@ -248,10 +248,43 @@ BOOL SdView::InsertData( const TransferableDataHelper& rDataHelper,
if( pOwnData && !nFormat )
{
// own data
const SdView* pSourceView = pOwnData->GetView();
if( pSourceView )
if( pOwnData->GetDocShell() && pOwnData->IsPageTransferable() && ISA( SdView ) )
{
USHORT nInsertPgCnt, nInsertPos = pDoc->GetSdPageCount( PK_STANDARD ) * 2 + 1;
USHORT nPgCnt = pDoc->GetSdPageCount( PK_STANDARD );
BOOL bMergeMasterPages = !pOwnData->HasSourceDoc( pDoc );
for( USHORT nPage = 0; nPage < nPgCnt; nPage++ )
{
SdPage* pPage = pDoc->GetSdPage( nPage, PK_STANDARD );
if( pPage->IsSelected() )
nInsertPos = nPage * 2 + 3;
}
if( pOwnData->HasPageBookmarks() )
{
const List& rBookmarkList = pOwnData->GetPageBookmarks();
nInsertPgCnt = (USHORT) rBookmarkList.Count();
pDoc->InsertBookmarkAsPage( const_cast< List* >( &rBookmarkList ), NULL, FALSE, FALSE, nInsertPos, TRUE, pOwnData->GetPageDocShell(), TRUE, bMergeMasterPages );
}
else
{
SvEmbeddedObject* pObj = pOwnData->GetDocShell();
SdDrawDocShell* pDataDocSh = (SdDrawDocShell*) pObj;
SdDrawDocument* pDataDoc = pDataDocSh->GetDoc();
if( pDataDoc && pDataDoc->GetSdPageCount( PK_STANDARD ) )
{
nInsertPgCnt = pDataDoc->GetSdPageCount( PK_STANDARD );
pDoc->InsertBookmarkAsPage( NULL, NULL, FALSE, FALSE, nInsertPos, TRUE, pDataDocSh, TRUE, bMergeMasterPages );
}
}
}
else if( pSourceView )
{
if( pSourceView == this )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment