2000-09-18 11:07:07 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* $RCSfile: fucopy.cxx,v $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2006-07-25 05:32:32 -05:00
|
|
|
* $Revision: 1.10 $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2006-07-25 05:32:32 -05:00
|
|
|
* last change: $Author: rt $ $Date: 2006-07-25 11:32:32 $
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
2005-09-08 22:40:10 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 11:07:07 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#pragma hdrstop
|
|
|
|
|
2004-01-20 04:00:18 -06:00
|
|
|
#include "fucopy.hxx"
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
#ifndef _SFX_PROGRESS_HXX
|
|
|
|
#include <sfx2/progress.hxx>
|
|
|
|
#endif
|
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
|
|
|
|
#include "sdresid.hxx"
|
|
|
|
#include "sdattr.hxx"
|
|
|
|
#include "strings.hrc"
|
2004-01-20 04:00:18 -06:00
|
|
|
#ifndef SD_VIEW_SHELL_HXX
|
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#endif
|
|
|
|
#ifndef SD_VIEW_HXX
|
|
|
|
#include "View.hxx"
|
|
|
|
#endif
|
2004-05-10 09:46:31 -05:00
|
|
|
//CHINA001 #ifndef SD_COPY_DLG_HXX
|
|
|
|
//CHINA001 #include "copydlg.hxx"
|
|
|
|
//CHINA001 #endif
|
2000-09-18 11:07:07 -05:00
|
|
|
#include "drawdoc.hxx"
|
2004-01-20 04:00:18 -06:00
|
|
|
#include "DrawDocShell.hxx"
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
#ifndef _SV_WRKWIN_HXX
|
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVDOBJ_HXX //autogen
|
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SV_MSGBOX_HXX //autogen
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXAPP_HXX //autogen
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_XCOLORITEM_HXX //autogen
|
|
|
|
#include <svx/xcolit.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_XFLCLIT_HXX //autogen
|
|
|
|
#include <svx/xflclit.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _XDEF_HXX //autogen
|
|
|
|
#include <svx/xdef.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef SVX_XFILLIT0_HXX //autogen
|
|
|
|
#include <svx/xfillit0.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXREQUEST_HXX //autogen
|
|
|
|
#include <sfx2/request.hxx>
|
|
|
|
#endif
|
2004-05-10 09:46:31 -05:00
|
|
|
#include "sdabstdlg.hxx" //CHINA001
|
|
|
|
#include "copydlg.hrc" //CHINA001
|
2004-01-20 04:00:18 -06:00
|
|
|
namespace sd {
|
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
TYPEINIT1( FuCopy, FuPoor );
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
2004-01-20 04:00:18 -06:00
|
|
|
FuCopy::FuCopy (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
2000-09-18 11:07:07 -05:00
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2005-12-14 09:57:19 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuCopy::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuCopy( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuCopy::DoExecute( SfxRequest& rReq )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2004-07-12 09:01:25 -05:00
|
|
|
if( pView->AreObjectsMarked() )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
|
|
|
// Undo
|
2004-07-12 09:01:25 -05:00
|
|
|
String aString( pView->GetDescriptionOfMarkedObjects() );
|
2000-09-18 11:07:07 -05:00
|
|
|
aString.Append( sal_Unicode(' ') );
|
|
|
|
aString.Append( String( SdResId( STR_UNDO_COPYOBJECTS ) ) );
|
|
|
|
pView->BegUndo( aString );
|
|
|
|
|
|
|
|
const SfxItemSet* pArgs = rReq.GetArgs();
|
|
|
|
|
|
|
|
if( !pArgs )
|
|
|
|
{
|
2005-12-14 09:57:19 -06:00
|
|
|
SfxItemSet aSet( pViewShell->GetPool(),
|
2000-09-18 11:07:07 -05:00
|
|
|
ATTR_COPY_START, ATTR_COPY_END, 0 );
|
|
|
|
|
|
|
|
// Farb-Attribut angeben
|
|
|
|
SfxItemSet aAttr( pDoc->GetPool() );
|
|
|
|
pView->GetAttributes( aAttr );
|
|
|
|
const SfxPoolItem* pPoolItem = NULL;
|
|
|
|
|
|
|
|
if( SFX_ITEM_SET == aAttr.GetItemState( XATTR_FILLSTYLE, TRUE, &pPoolItem ) )
|
|
|
|
{
|
|
|
|
XFillStyle eStyle = ( ( const XFillStyleItem* ) pPoolItem )->GetValue();
|
|
|
|
|
|
|
|
if( eStyle == XFILL_SOLID &&
|
|
|
|
SFX_ITEM_SET == aAttr.GetItemState( XATTR_FILLCOLOR, TRUE, &pPoolItem ) )
|
|
|
|
{
|
|
|
|
const XFillColorItem* pItem = ( const XFillColorItem* ) pPoolItem;
|
|
|
|
XColorItem aXColorItem( ATTR_COPY_START_COLOR, pItem->GetName(),
|
2006-06-19 06:32:18 -05:00
|
|
|
pItem->GetColorValue() );
|
2000-09-18 11:07:07 -05:00
|
|
|
aSet.Put( aXColorItem );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-10 09:46:31 -05:00
|
|
|
//CHINA001 CopyDlg* pDlg = new CopyDlg( NULL, aSet, pDoc->GetColorTable(), pView );
|
|
|
|
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();//CHINA001
|
|
|
|
DBG_ASSERT(pFact, "SdAbstractDialogFactory fail!");//CHINA001
|
|
|
|
AbstractCopyDlg* pDlg = pFact->CreateCopyDlg(ResId( DLG_COPY ), NULL, aSet, pDoc->GetColorTable(), pView );
|
|
|
|
DBG_ASSERT(pDlg, "Dialogdiet fail!");//CHINA001
|
2003-03-27 03:58:12 -06:00
|
|
|
USHORT nResult = pDlg->Execute();
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
switch( nResult )
|
|
|
|
{
|
|
|
|
case RET_OK:
|
|
|
|
pDlg->GetAttr( aSet );
|
|
|
|
rReq.Done( aSet );
|
|
|
|
pArgs = rReq.GetArgs();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
delete pDlg;
|
|
|
|
pView->EndUndo();
|
|
|
|
}
|
|
|
|
return; // Abbruch
|
|
|
|
}
|
|
|
|
delete( pDlg );
|
|
|
|
}
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
Rectangle aRect;
|
|
|
|
INT32 lWidth, lHeight, lSizeX = 0L, lSizeY = 0L, lAngle = 0L;
|
|
|
|
UINT16 nNumber = 0;
|
|
|
|
Color aStartColor, aEndColor;
|
|
|
|
BOOL bColor = FALSE;
|
|
|
|
const SfxPoolItem* pPoolItem = NULL;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// Anzahl
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_NUMBER, TRUE, &pPoolItem ) )
|
|
|
|
nNumber = ( ( const SfxUInt16Item* ) pPoolItem )->GetValue();
|
|
|
|
|
|
|
|
// Verschiebung
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_MOVE_X, TRUE, &pPoolItem ) )
|
|
|
|
lSizeX = ( ( const SfxInt32Item* ) pPoolItem )->GetValue();
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_MOVE_Y, TRUE, &pPoolItem ) )
|
|
|
|
lSizeY = ( ( const SfxInt32Item* ) pPoolItem )->GetValue();
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_ANGLE, TRUE, &pPoolItem ) )
|
|
|
|
lAngle = ( ( const SfxInt32Item* )pPoolItem )->GetValue();
|
|
|
|
|
|
|
|
// Verrgroesserung / Verkleinerung
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_WIDTH, TRUE, &pPoolItem ) )
|
|
|
|
lWidth = ( ( const SfxInt32Item* ) pPoolItem )->GetValue();
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_HEIGHT, TRUE, &pPoolItem ) )
|
|
|
|
lHeight = ( ( const SfxInt32Item* ) pPoolItem )->GetValue();
|
|
|
|
|
|
|
|
// Startfarbe / Endfarbe
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_START_COLOR, TRUE, &pPoolItem ) )
|
|
|
|
{
|
2006-06-19 06:32:18 -05:00
|
|
|
aStartColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
|
2000-09-18 11:07:07 -05:00
|
|
|
bColor = TRUE;
|
|
|
|
}
|
|
|
|
if( SFX_ITEM_SET == pArgs->GetItemState( ATTR_COPY_END_COLOR, TRUE, &pPoolItem ) )
|
|
|
|
{
|
2006-06-19 06:32:18 -05:00
|
|
|
aEndColor = ( ( const XColorItem* ) pPoolItem )->GetColorValue();
|
2000-09-18 11:07:07 -05:00
|
|
|
if( aStartColor == aEndColor )
|
|
|
|
bColor = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bColor = FALSE;
|
|
|
|
|
|
|
|
// Handles wegnehmen
|
|
|
|
pView->HideMarkHdl( NULL );
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
SfxProgress* pProgress = NULL;
|
|
|
|
BOOL bWaiting = FALSE;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( nNumber > 1 )
|
|
|
|
{
|
|
|
|
String aStr( SdResId( STR_OBJECTS ) );
|
|
|
|
aStr.Append( sal_Unicode(' ') );
|
|
|
|
aStr.Append( String( SdResId( STR_UNDO_COPYOBJECTS ) ) );
|
|
|
|
|
|
|
|
pProgress = new SfxProgress( pDocSh, aStr, nNumber );
|
|
|
|
pDocSh->SetWaitCursor( TRUE );
|
|
|
|
bWaiting = TRUE;
|
|
|
|
}
|
|
|
|
|
2004-07-12 09:01:25 -05:00
|
|
|
const SdrMarkList aMarkList( pView->GetMarkedObjectList() );
|
2003-03-27 03:58:12 -06:00
|
|
|
const ULONG nMarkCount = aMarkList.GetMarkCount();
|
|
|
|
SdrPageView* pPageView = pView->GetPageViewPvNum( 0 );
|
|
|
|
SdrObject* pObj = NULL;
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
// Anzahl moeglicher Kopien berechnen
|
|
|
|
aRect = pView->GetAllMarkedRect();
|
2003-03-27 03:58:12 -06:00
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
if( lWidth < 0L )
|
|
|
|
{
|
|
|
|
long nTmp = ( aRect.Right() - aRect.Left() ) / -lWidth;
|
|
|
|
nNumber = (UINT16) Min( nTmp, (long)nNumber );
|
|
|
|
}
|
2003-03-27 03:58:12 -06:00
|
|
|
|
2000-09-18 11:07:07 -05:00
|
|
|
if( lHeight < 0L )
|
|
|
|
{
|
|
|
|
long nTmp = ( aRect.Bottom() - aRect.Top() ) / -lHeight;
|
|
|
|
nNumber = (UINT16) Min( nTmp, (long)nNumber );
|
|
|
|
}
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
for( USHORT i = 1; i <= nNumber; i++ )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2003-03-27 03:58:12 -06:00
|
|
|
if( pProgress )
|
2000-09-18 11:07:07 -05:00
|
|
|
pProgress->SetState( i );
|
|
|
|
|
|
|
|
aRect = pView->GetAllMarkedRect();
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
if( ( 1 == i ) && bColor )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2005-12-14 09:57:19 -06:00
|
|
|
SfxItemSet aNewSet( pViewShell->GetPool(), XATTR_FILLSTYLE, XATTR_FILLCOLOR, 0L );
|
2000-09-18 11:07:07 -05:00
|
|
|
aNewSet.Put( XFillStyleItem( XFILL_SOLID ) );
|
|
|
|
aNewSet.Put( XFillColorItem( String(), aStartColor ) );
|
|
|
|
pView->SetAttributes( aNewSet );
|
|
|
|
}
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
// make a copy of selected objects
|
2000-09-18 11:07:07 -05:00
|
|
|
pView->CopyMarked();
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
// get newly selected objects
|
2004-07-12 09:01:25 -05:00
|
|
|
SdrMarkList aCopyMarkList( pView->GetMarkedObjectList() );
|
2003-03-27 03:58:12 -06:00
|
|
|
ULONG j, nCopyMarkCount = aMarkList.GetMarkCount();
|
|
|
|
|
|
|
|
// set protection flags at marked copies to null
|
|
|
|
for( j = 0; j < nCopyMarkCount; j++ )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2006-07-25 05:32:32 -05:00
|
|
|
pObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj();
|
2003-03-27 03:58:12 -06:00
|
|
|
|
|
|
|
if( pObj )
|
2000-09-18 11:07:07 -05:00
|
|
|
{
|
2003-03-27 03:58:12 -06:00
|
|
|
pObj->SetMoveProtect( FALSE );
|
|
|
|
pObj->SetResizeProtect( FALSE );
|
2000-09-18 11:07:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-27 03:58:12 -06:00
|
|
|
Fraction aWidth( aRect.Right() - aRect.Left() + lWidth, aRect.Right() - aRect.Left() );
|
|
|
|
Fraction aHeight( aRect.Bottom() - aRect.Top() + lHeight, aRect.Bottom() - aRect.Top() );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( pView->IsResizeAllowed() )
|
|
|
|
pView->ResizeAllMarked( aRect.TopLeft(), aWidth, aHeight );
|
|
|
|
|
|
|
|
if( pView->IsRotateAllowed() )
|
2003-03-27 03:58:12 -06:00
|
|
|
pView->RotateAllMarked( aRect.Center(), lAngle * 100 );
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( pView->IsMoveAllowed() )
|
2003-03-27 03:58:12 -06:00
|
|
|
pView->MoveAllMarked( Size( lSizeX, lSizeY ) );
|
|
|
|
|
|
|
|
// set protection flags at marked copies to original values
|
|
|
|
if( nMarkCount == nCopyMarkCount )
|
|
|
|
{
|
|
|
|
for( j = 0; j < nMarkCount; j++ )
|
|
|
|
{
|
2006-07-25 05:32:32 -05:00
|
|
|
SdrObject* pSrcObj = aMarkList.GetMark( j )->GetMarkedSdrObj();
|
|
|
|
SdrObject* pDstObj = aCopyMarkList.GetMark( j )->GetMarkedSdrObj();
|
2003-03-27 03:58:12 -06:00
|
|
|
|
|
|
|
if( pSrcObj && pDstObj &&
|
|
|
|
( pSrcObj->GetObjInventor() == pDstObj->GetObjInventor() ) &&
|
|
|
|
( pSrcObj->GetObjIdentifier() == pDstObj->GetObjIdentifier() ) )
|
|
|
|
{
|
|
|
|
pDstObj->SetMoveProtect( pSrcObj->IsMoveProtect() );
|
|
|
|
pDstObj->SetResizeProtect( pSrcObj->IsResizeProtect() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 11:07:07 -05:00
|
|
|
|
|
|
|
if( bColor )
|
|
|
|
{
|
|
|
|
// Koennte man sicher noch optimieren, wuerde aber u.U.
|
|
|
|
// zu Rundungsfehlern fuehren
|
2001-03-08 04:12:28 -06:00
|
|
|
BYTE nRed = aStartColor.GetRed() + (BYTE) ( ( (long) aEndColor.GetRed() - (long) aStartColor.GetRed() ) * (long) i / (long) nNumber );
|
|
|
|
BYTE nGreen = aStartColor.GetGreen() + (BYTE) ( ( (long) aEndColor.GetGreen() - (long) aStartColor.GetGreen() ) * (long) i / (long) nNumber );
|
|
|
|
BYTE nBlue = aStartColor.GetBlue() + (BYTE) ( ( (long) aEndColor.GetBlue() - (long) aStartColor.GetBlue() ) * (long) i / (long) nNumber );
|
2000-09-18 11:07:07 -05:00
|
|
|
Color aNewColor( nRed, nGreen, nBlue );
|
2005-12-14 09:57:19 -06:00
|
|
|
SfxItemSet aNewSet( pViewShell->GetPool(), XATTR_FILLSTYLE, XATTR_FILLCOLOR, 0L );
|
2000-09-18 11:07:07 -05:00
|
|
|
aNewSet.Put( XFillStyleItem( XFILL_SOLID ) );
|
|
|
|
aNewSet.Put( XFillColorItem( String(), aNewColor ) );
|
|
|
|
pView->SetAttributes( aNewSet );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pProgress )
|
|
|
|
delete pProgress;
|
|
|
|
|
|
|
|
if ( bWaiting )
|
|
|
|
pDocSh->SetWaitCursor( FALSE );
|
|
|
|
|
|
|
|
// Handles zeigen
|
|
|
|
pView->AdjustMarkHdl( TRUE );
|
|
|
|
pView->ShowMarkHdl( NULL );
|
|
|
|
|
|
|
|
pView->EndUndo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 04:00:18 -06:00
|
|
|
} // end of namespace
|