1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewfun3.cxx,v $
10 * $Revision: 1.41.126.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 //----------------------------------------------------------------------------
44 #define _BASE_DLGS_HXX
58 #define _NO_SVRTF_PARSER_HXX
61 #define _MOREBUTTON_HXX
71 //#define _STATUS_HXX ***
94 #define _SFX_DOCFILE_HXX
95 //#define _SFX_DOCFILT_HXX
96 #define _SFX_DOCINF_HXX
97 #define _SFX_DOCSH_HXX
98 //#define _SFXDOCFILT_HXX
99 //#define _SFXDOCINF_HXX
100 //#define _SFXDOCSH_HXX
101 #define _SFX_PRNMON_HXX
102 #define _SFX_RESMGR_HXX
103 #define _SFX_TEMPLDLG_HXX
104 //#define _SFXAPPWIN_HXX
105 #define _SFXBASIC_HXX
107 #define _SFXDLGCFG_HXX
108 //#define _SFXDISPATCH_HXX
109 #define _SFXFILEDLG_HXX
110 //#define _SFXIMGMGR_HXX
111 #define _SFXIPFRM_HXX
112 #define _SFX_MACRO_HXX
113 #define _SFXMNUITEM_HXX
114 #define _SFXMNUMGR_HXX
115 #define _SFXMULTISEL_HXX
116 //#define _SFXMSG_HXX
117 #define _SFXMSGDESCR_HXX
118 #define _SFXMSGPOOL_HXX
119 #define _SFX_MINFITEM_HXX
120 #define _SFXOBJFACE_HXX
121 #define _SFXOBJFAC_HXX
122 #define _SFX_SAVEOPT_HXX
123 #define _SFXSTBITEM_HXX
124 #define _SFXSTBMGR_HXX
125 #define _SFXTBXCTRL_HXX
126 #define _SFXTBXMGR_HXX
129 //#define _SI_DLL_HXX
131 //#define _SI_NOITEMS
132 //#define _SI_NOOTHERFORMS
133 //#define _SI_NOSBXCONTROLS
134 //#define _SINOSBXCONTROLS
136 //#define _SI_NOCONTROL
138 #define _SVBOXITM_HXX
139 #define _SVCONTNR_HXX //
141 #define _SDR_NOTRANSFORM
145 #define _SV_MULTISEL_HXX
148 #define _SVTREEBOX_HXX
149 #define _SVTREELIST_HXX
151 #define _SVX_DAILDLL_HXX
152 #define _SVX_HYPHEN_HXX
153 #define _SVX_IMPGRF_HXX
154 #define _SVX_LAYCTRL_HXX
155 #define _SVX_OPTITEMS_HXX
156 #define _SVX_OPTGERL_HXX
157 #define _SVX_OPTSAVE_HXX
158 #define _SVX_OPTSPELL_HXX
159 #define _SVX_OPTPATH_HXX
160 #define _SVX_OPTLINGU_HXX
161 #define _SVX_RULER_HXX
162 #define _SVX_RULRITEM_HXX
163 #define _SVX_SELCTRL_HXX
164 #define _SVX_SPLWRAP_HXX
165 #define _SVX_SPLDLG_HXX
166 #define _SVX_STDDLG_HXX
167 #define _SVX_THESDLG_HXX
169 // INCLUDE -------------------------------------------------------------------
171 #include "scitems.hxx"
172 #include <svx/dbexch.hrc>
173 #include <svx/svdetc.hxx>
174 #include <sfx2/dispatch.hxx>
175 #include <sfx2/docfile.hxx>
176 #include <svtools/stritem.hxx>
177 #include <svtools/ptitem.hxx>
178 #include <svtools/urlbmk.hxx>
179 #include <sot/clsids.hxx>
180 #include <sot/formats.hxx>
181 #include <vcl/graph.hxx>
182 #include <vcl/virdev.hxx>
183 #include <vcl/msgbox.hxx>
184 #include <tools/urlobj.hxx>
185 #include <sot/exchange.hxx>
188 #include "viewfunc.hxx"
189 #include "tabvwsh.hxx"
191 #include "docfunc.hxx"
192 #include "undoblk.hxx"
193 #include "refundo.hxx"
194 #include "globstr.hrc"
195 #include "global.hxx"
196 #include "transobj.hxx"
197 #include "drwtrans.hxx"
198 #include "rangenam.hxx"
199 #include "dbcolect.hxx"
200 #include "impex.hxx" // Sylk-ID fuer CB
201 #include "chgtrack.hxx"
202 #include "waitoff.hxx"
205 #include "inputopt.hxx"
206 #include "warnbox.hxx"
207 #include "drwlayer.hxx"
208 #include "editable.hxx"
209 #include "transobj.hxx"
210 #include "drwtrans.hxx"
211 #include "docuno.hxx"
212 #include "undodat.hxx" // Amelia Wang
213 #include "clipparam.hxx"
215 using namespace com::sun::star
;
217 // STATIC DATA ---------------------------------------------------------------
220 //============================================================================
222 // GlobalName der Writer-DocShell kommt jetzt aus comphelper/classids.hxx
224 //----------------------------------------------------------------------------
227 void ScViewFunc::CutToClip( ScDocument
* pClipDoc
, BOOL bIncludeObjects
)
231 ScEditableTester
aTester( this );
232 if (!aTester
.IsEditable()) // selection editable?
234 ErrorMessage( aTester
.GetMessageId() );
238 ScRange aRange
; // zu loeschender Bereich
239 if ( GetViewData()->GetSimpleArea( aRange
) == SC_MARK_SIMPLE
)
241 ScDocument
* pDoc
= GetViewData()->GetDocument();
242 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
243 ScMarkData
& rMark
= GetViewData()->GetMarkData();
244 const BOOL
bRecord(pDoc
->IsUndoEnabled()); // Undo/Redo
246 ScDocShellModificator
aModificator( *pDocSh
);
248 if ( !rMark
.IsMarked() && !rMark
.IsMultiMarked() ) // mark the range if not marked yet
252 rMark
.SetMarkArea( aRange
);
256 CopyToClip( pClipDoc
, TRUE
, FALSE
, bIncludeObjects
); // Ab ins Clipboard
258 ScAddress
aOldEnd( aRange
.aEnd
); // Zusammengefasste Zellen im Bereich?
259 pDoc
->ExtendMerge( aRange
, TRUE
);
261 ScDocument
* pUndoDoc
= NULL
;
264 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
265 pUndoDoc
->InitUndoSelected( pDoc
, rMark
);
266 // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
267 ScRange aCopyRange
= aRange
;
268 aCopyRange
.aStart
.SetTab(0);
269 aCopyRange
.aEnd
.SetTab(pDoc
->GetTableCount()-1);
270 pDoc
->CopyToDocument( aCopyRange
, (IDF_ALL
& ~IDF_OBJECTS
) | IDF_NOCAPTIONS
, FALSE
, pUndoDoc
);
271 pDoc
->BeginDrawUndo();
274 USHORT nExtFlags
= 0;
275 pDocSh
->UpdatePaintExt( nExtFlags
, aRange
);
277 HideCursor(); // Cursor aendert sich !
280 pDoc
->DeleteSelection( IDF_ALL
, rMark
);
281 if ( bIncludeObjects
)
282 pDoc
->DeleteObjectsInSelection( rMark
);
283 rMark
.MarkToSimple();
285 if ( !AdjustRowHeight( aRange
.aStart
.Row(), aRange
.aEnd
.Row() ) )
286 pDocSh
->PostPaint( aRange
, PAINT_GRID
, nExtFlags
);
288 if ( bRecord
) // erst jetzt ist Draw-Undo verfuegbar
289 pDocSh
->GetUndoManager()->AddUndoAction(
290 new ScUndoCut( pDocSh
, aRange
, aOldEnd
, rMark
, pUndoDoc
) );
292 aModificator
.SetDocumentModified();
293 ShowCursor(); // Cursor aendert sich !
294 pDocSh
->UpdateOle(GetViewData());
296 CellContentChanged();
299 ErrorMessage( STR_NOMULTISELECT
);
303 //----------------------------------------------------------------------------
306 BOOL
ScViewFunc::CopyToClip( ScDocument
* pClipDoc
, BOOL bCut
, BOOL bApi
, BOOL bIncludeObjects
, BOOL bStopEdit
)
313 ScMarkType eMarkType
= GetViewData()->GetSimpleArea( aRange
);
314 ScDocument
* pDoc
= GetViewData()->GetDocument();
315 ScMarkData
& rMark
= GetViewData()->GetMarkData();
316 if ( eMarkType
== SC_MARK_SIMPLE
|| eMarkType
== SC_MARK_SIMPLE_FILTERED
)
318 if ( !pDoc
->HasSelectedBlockMatrixFragment(
319 aRange
.aStart
.Col(), aRange
.aStart
.Row(),
320 aRange
.aEnd
.Col(), aRange
.aEnd
.Row(),
323 BOOL bSysClip
= FALSE
;
324 if ( !pClipDoc
) // no clip doc specified
326 pClipDoc
= new ScDocument( SCDOCMODE_CLIP
); // create one (deleted by ScTransferObj)
327 bSysClip
= TRUE
; // and copy into system
332 ScChangeTrack
* pChangeTrack
= pDoc
->GetChangeTrack();
334 pChangeTrack
->ResetLastCut(); // kein CutMode mehr
337 if ( bSysClip
&& bIncludeObjects
)
339 BOOL bAnyOle
= pDoc
->HasOLEObjectsInArea( aRange
, &rMark
);
340 // update ScGlobal::pDrawClipDocShellRef
341 ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle
) );
344 pDoc
->CopyToClip( aRange
.aStart
.Col(), aRange
.aStart
.Row(),
345 aRange
.aEnd
.Col(), aRange
.aEnd
.Row(),
346 bCut
, pClipDoc
, FALSE
, &rMark
, FALSE
, bIncludeObjects
);
349 ScDrawLayer::SetGlobalDrawPersist(NULL
);
351 ScGlobal::SetClipDocName( pDoc
->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME
) );
353 pClipDoc
->ExtendMerge( aRange
, TRUE
);
357 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
358 TransferableObjectDescriptor aObjDesc
;
359 pDocSh
->FillTransferableObjectDescriptor( aObjDesc
);
360 aObjDesc
.maDisplayName
= pDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
361 // maSize is set in ScTransferObj ctor
363 ScTransferObj
* pTransferObj
= new ScTransferObj( pClipDoc
, aObjDesc
);
364 uno::Reference
<datatransfer::XTransferable
> xTransferable( pTransferObj
);
366 if ( ScGlobal::pDrawClipDocShellRef
)
368 SfxObjectShellRef
aPersistRef( &(*ScGlobal::pDrawClipDocShellRef
) );
369 pTransferObj
->SetDrawPersist( aPersistRef
); // keep persist for ole objects alive
372 pTransferObj
->CopyToClipboard( GetActiveWin() ); // system clipboard
373 SC_MOD()->SetClipObject( pTransferObj
, NULL
); // internal clipboard
381 ErrorMessage(STR_MATRIXFRAGMENTERR
);
384 else if (eMarkType
== SC_MARK_MULTI
)
386 bool bSuccess
= false;
387 ScClipParam aClipParam
;
388 aClipParam
.mbCutMode
= false;
389 rMark
.FillRangeListWithMarks(&aClipParam
.maRanges
, false);
394 // We con't support cutting of multi-selections.
398 // TODO: What's this for?
401 ::std::auto_ptr
<ScDocument
> pDocClip(new ScDocument(SCDOCMODE_CLIP
));
403 // Check for geometrical feasibility of the ranges.
404 bool bValidRanges
= true;
405 ScRangePtr p
= aClipParam
.maRanges
.First();
406 SCCOL nPrevColDelta
= 0;
407 SCROW nPrevRowDelta
= 0;
408 SCCOL nPrevCol
= p
->aStart
.Col();
409 SCROW nPrevRow
= p
->aStart
.Row();
410 SCCOL nPrevColSize
= p
->aEnd
.Col() - p
->aStart
.Col() + 1;
411 SCROW nPrevRowSize
= p
->aEnd
.Row() - p
->aStart
.Row() + 1;
412 for (p
= aClipParam
.maRanges
.Next(); p
; p
= aClipParam
.maRanges
.Next())
414 if (pDoc
->HasSelectedBlockMatrixFragment(
415 p
->aStart
.Col(), p
->aStart
.Row(), p
->aEnd
.Col(), p
->aEnd
.Row(), rMark
))
417 bValidRanges
= false;
421 SCCOL nColDelta
= p
->aStart
.Col() - nPrevCol
;
422 SCROW nRowDelta
= p
->aStart
.Row() - nPrevRow
;
424 if ((nColDelta
&& nRowDelta
) || (nPrevColDelta
&& nRowDelta
) || (nPrevRowDelta
&& nColDelta
))
426 bValidRanges
= false;
430 if (aClipParam
.meDirection
== ScClipParam::Unspecified
)
433 aClipParam
.meDirection
= ScClipParam::Column
;
435 aClipParam
.meDirection
= ScClipParam::Row
;
438 SCCOL nColSize
= p
->aEnd
.Col() - p
->aStart
.Col() + 1;
439 SCROW nRowSize
= p
->aEnd
.Row() - p
->aStart
.Row() + 1;
441 if (aClipParam
.meDirection
== ScClipParam::Column
&& nRowSize
!= nPrevRowSize
)
443 // column-oriented ranges must have identical row size.
444 bValidRanges
= false;
447 if (aClipParam
.meDirection
== ScClipParam::Row
&& nColSize
!= nPrevColSize
)
449 // likewise, row-oriented ranges must have identical
451 bValidRanges
= false;
455 nPrevCol
= p
->aStart
.Col();
456 nPrevRow
= p
->aStart
.Row();
457 nPrevColDelta
= nColDelta
;
458 nPrevRowDelta
= nRowDelta
;
459 nPrevColSize
= nColSize
;
460 nPrevRowSize
= nRowSize
;
465 pDoc
->CopyToClip(aClipParam
, pDocClip
.get(), &rMark
, false, bIncludeObjects
);
467 ScChangeTrack
* pChangeTrack
= pDoc
->GetChangeTrack();
469 pChangeTrack
->ResetLastCut(); // kein CutMode mehr
472 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
473 TransferableObjectDescriptor aObjDesc
;
474 pDocSh
->FillTransferableObjectDescriptor( aObjDesc
);
475 aObjDesc
.maDisplayName
= pDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
476 // maSize is set in ScTransferObj ctor
478 ScTransferObj
* pTransferObj
= new ScTransferObj( pDocClip
.release(), aObjDesc
);
479 uno::Reference
<datatransfer::XTransferable
> xTransferable( pTransferObj
);
481 if ( ScGlobal::pDrawClipDocShellRef
)
483 SfxObjectShellRef
aPersistRef( &(*ScGlobal::pDrawClipDocShellRef
) );
484 pTransferObj
->SetDrawPersist( aPersistRef
); // keep persist for ole objects alive
487 pTransferObj
->CopyToClipboard( GetActiveWin() ); // system clipboard
488 SC_MOD()->SetClipObject( pTransferObj
, NULL
); // internal clipboard
495 if (!bSuccess
&& !bApi
)
496 ErrorMessage(STR_NOMULTISELECT
);
503 ErrorMessage(STR_NOMULTISELECT
);
509 ScTransferObj
* ScViewFunc::CopyToTransferable()
512 if ( GetViewData()->GetSimpleArea( aRange
) == SC_MARK_SIMPLE
)
514 ScDocument
* pDoc
= GetViewData()->GetDocument();
515 ScMarkData
& rMark
= GetViewData()->GetMarkData();
516 if ( !pDoc
->HasSelectedBlockMatrixFragment(
517 aRange
.aStart
.Col(), aRange
.aStart
.Row(),
518 aRange
.aEnd
.Col(), aRange
.aEnd
.Row(),
521 ScDocument
*pClipDoc
= new ScDocument( SCDOCMODE_CLIP
); // create one (deleted by ScTransferObj)
523 BOOL bAnyOle
= pDoc
->HasOLEObjectsInArea( aRange
, &rMark
);
524 ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle
) );
526 pDoc
->CopyToClip( aRange
.aStart
.Col(), aRange
.aStart
.Row(),
527 aRange
.aEnd
.Col(), aRange
.aEnd
.Row(),
528 FALSE
, pClipDoc
, FALSE
, &rMark
, FALSE
, TRUE
);
530 ScDrawLayer::SetGlobalDrawPersist(NULL
);
531 pClipDoc
->ExtendMerge( aRange
, TRUE
);
533 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
534 TransferableObjectDescriptor aObjDesc
;
535 pDocSh
->FillTransferableObjectDescriptor( aObjDesc
);
536 aObjDesc
.maDisplayName
= pDocSh
->GetMedium()->GetURLObject().GetURLNoPass();
537 ScTransferObj
* pTransferObj
= new ScTransferObj( pClipDoc
, aObjDesc
);
545 //----------------------------------------------------------------------------
548 void ScViewFunc::PasteDraw()
550 ScViewData
* pViewData
= GetViewData();
551 SCCOL nPosX
= pViewData
->GetCurX();
552 SCROW nPosY
= pViewData
->GetCurY();
553 Window
* pWin
= GetActiveWin();
554 Point aPos
= pWin
->PixelToLogic( pViewData
->GetScrPos( nPosX
, nPosY
,
555 pViewData
->GetActivePart() ) );
556 ScDrawTransferObj
* pDrawClip
= ScDrawTransferObj::GetOwnClipboard( pWin
);
558 PasteDraw( aPos
, pDrawClip
->GetModel(), FALSE
,
559 pDrawClip
->GetSourceDocID() == pViewData
->GetDocument()->GetDocumentID() );
562 void ScViewFunc::PasteFromSystem()
566 Window
* pWin
= GetActiveWin();
567 ScTransferObj
* pOwnClip
= ScTransferObj::GetOwnClipboard( pWin
);
568 ScDrawTransferObj
* pDrawClip
= ScDrawTransferObj::GetOwnClipboard( pWin
);
572 // #129384# keep a reference in case the clipboard is changed during PasteFromClip
573 uno::Reference
<datatransfer::XTransferable
> aOwnClipRef( pOwnClip
);
574 PasteFromClip( IDF_ALL
, pOwnClip
->GetDocument(),
575 PASTE_NOFUNC
, FALSE
, FALSE
, FALSE
, INS_NONE
, IDF_NONE
,
576 TRUE
); // allow warning dialog
582 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin
) );
584 // if (pClipObj.Is())
586 ULONG nBiff8
= SotExchange::RegisterFormatName(
587 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff8")));
588 ULONG nBiff5
= SotExchange::RegisterFormatName(
589 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5")));
591 // als erstes SvDraw-Model, dann Grafik
592 // (Grafik darf nur bei einzelner Grafik drinstehen)
594 if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_DRAWING
))
596 // special case for tables from drawing
597 if( aDataHelper
.HasFormat( SOT_FORMAT_RTF
) )
599 PasteFromSystem( FORMAT_RTF
);
603 PasteFromSystem( SOT_FORMATSTR_ID_DRAWING
);
606 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVXB
))
607 PasteFromSystem( SOT_FORMATSTR_ID_SVXB
);
608 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
))
610 // If it's a Writer object, insert RTF instead of OLE
613 SotStorageStreamRef xStm
;
614 TransferableObjectDescriptor aObjDesc
;
615 if( aDataHelper
.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aObjDesc
) &&
616 aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_EMBED_SOURCE
, xStm
) )
618 SotStorageRef
xStore( new SotStorage( *xStm
) );
619 bDoRtf
= ( ( aObjDesc
.maClassName
== SvGlobalName( SO3_SW_CLASSID
) ||
620 aObjDesc
.maClassName
== SvGlobalName( SO3_SWWEB_CLASSID
) )
621 && aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
624 PasteFromSystem( FORMAT_RTF
);
626 PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE
);
628 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE
))
629 PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE
);
630 // the following format can not affect scenario from #89579#
631 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
))
632 PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
);
633 // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
634 else if (aDataHelper
.HasFormat(nBiff8
)) // before xxx_OLE formats
635 PasteFromSystem(nBiff8
);
636 else if (aDataHelper
.HasFormat(nBiff5
))
637 PasteFromSystem(nBiff5
);
638 else if (aDataHelper
.HasFormat(FORMAT_RTF
))
639 PasteFromSystem(FORMAT_RTF
);
640 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_HTML
))
641 PasteFromSystem(SOT_FORMATSTR_ID_HTML
);
642 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE
))
643 PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE
);
644 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_SYLK
))
645 PasteFromSystem(SOT_FORMATSTR_ID_SYLK
);
646 else if (aDataHelper
.HasFormat(FORMAT_STRING
))
647 PasteFromSystem(FORMAT_STRING
);
648 else if (aDataHelper
.HasFormat(FORMAT_GDIMETAFILE
))
649 PasteFromSystem(FORMAT_GDIMETAFILE
);
650 else if (aDataHelper
.HasFormat(FORMAT_BITMAP
))
651 PasteFromSystem(FORMAT_BITMAP
);
652 // #89579# xxx_OLE formats come last, like in SotExchange tables
653 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
))
654 PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
);
655 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE
))
656 PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE
);
658 // ErrorMessage(STR_PASTE_ERROR);
661 // ErrorMessage(STR_PASTE_ERROR);
664 // keine Fehlermeldung, weil SID_PASTE in der idl das FastCall-Flag hat,
665 // also auch gerufen wird, wenn nichts im Clipboard steht (#42531#)
668 void ScViewFunc::PasteFromTransferable( const uno::Reference
<datatransfer::XTransferable
>& rxTransferable
)
670 ScTransferObj
*pOwnClip
=0;
671 ScDrawTransferObj
*pDrawClip
=0;
672 uno::Reference
<lang::XUnoTunnel
> xTunnel( rxTransferable
, uno::UNO_QUERY
);
675 sal_Int64 nHandle
= xTunnel
->getSomething( ScTransferObj::getUnoTunnelId() );
677 pOwnClip
= (ScTransferObj
*) (sal_IntPtr
) nHandle
;
680 nHandle
= xTunnel
->getSomething( ScDrawTransferObj::getUnoTunnelId() );
682 pDrawClip
= (ScDrawTransferObj
*) (sal_IntPtr
) nHandle
;
688 PasteFromClip( IDF_ALL
, pOwnClip
->GetDocument(),
689 PASTE_NOFUNC
, FALSE
, FALSE
, FALSE
, INS_NONE
, IDF_NONE
,
690 TRUE
); // allow warning dialog
694 ScViewData
* pViewData
= GetViewData();
695 SCCOL nPosX
= pViewData
->GetCurX();
696 SCROW nPosY
= pViewData
->GetCurY();
697 Window
* pWin
= GetActiveWin();
698 Point aPos
= pWin
->PixelToLogic( pViewData
->GetScrPos( nPosX
, nPosY
, pViewData
->GetActivePart() ) );
699 PasteDraw( aPos
, pDrawClip
->GetModel(), FALSE
, pDrawClip
->GetSourceDocID() == pViewData
->GetDocument()->GetDocumentID() );
703 TransferableDataHelper
aDataHelper( rxTransferable
);
705 ULONG nBiff8
= SotExchange::RegisterFormatName(
706 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff8")));
707 ULONG nBiff5
= SotExchange::RegisterFormatName(
708 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5")));
710 // als erstes SvDraw-Model, dann Grafik
711 // (Grafik darf nur bei einzelner Grafik drinstehen)
713 if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_DRAWING
))
714 nFormatId
= SOT_FORMATSTR_ID_DRAWING
;
715 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVXB
))
716 nFormatId
= SOT_FORMATSTR_ID_SVXB
;
717 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE
))
719 // If it's a Writer object, insert RTF instead of OLE
721 SotStorageStreamRef xStm
;
722 TransferableObjectDescriptor aObjDesc
;
723 if( aDataHelper
.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR
, aObjDesc
) &&
724 aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_EMBED_SOURCE
, xStm
) )
726 SotStorageRef
xStore( new SotStorage( *xStm
) );
727 bDoRtf
= ( ( aObjDesc
.maClassName
== SvGlobalName( SO3_SW_CLASSID
) ||
728 aObjDesc
.maClassName
== SvGlobalName( SO3_SWWEB_CLASSID
) )
729 && aDataHelper
.HasFormat( SOT_FORMAT_RTF
) );
732 nFormatId
= FORMAT_RTF
;
734 nFormatId
= SOT_FORMATSTR_ID_EMBED_SOURCE
;
736 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE
))
737 nFormatId
= SOT_FORMATSTR_ID_LINK_SOURCE
;
738 // the following format can not affect scenario from #89579#
739 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
))
740 nFormatId
= SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE
;
741 // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
742 else if (aDataHelper
.HasFormat(nBiff8
)) // before xxx_OLE formats
744 else if (aDataHelper
.HasFormat(nBiff5
))
746 else if (aDataHelper
.HasFormat(FORMAT_RTF
))
747 nFormatId
= FORMAT_RTF
;
748 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_HTML
))
749 nFormatId
= SOT_FORMATSTR_ID_HTML
;
750 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE
))
751 nFormatId
= SOT_FORMATSTR_ID_HTML_SIMPLE
;
752 else if (aDataHelper
.HasFormat(SOT_FORMATSTR_ID_SYLK
))
753 nFormatId
= SOT_FORMATSTR_ID_SYLK
;
754 else if (aDataHelper
.HasFormat(FORMAT_STRING
))
755 nFormatId
= FORMAT_STRING
;
756 else if (aDataHelper
.HasFormat(FORMAT_GDIMETAFILE
))
757 nFormatId
= FORMAT_GDIMETAFILE
;
758 else if (aDataHelper
.HasFormat(FORMAT_BITMAP
))
759 nFormatId
= FORMAT_BITMAP
;
760 // #89579# xxx_OLE formats come last, like in SotExchange tables
761 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
))
762 nFormatId
= SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
;
763 else if (aDataHelper
.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE
))
764 nFormatId
= SOT_FORMATSTR_ID_LINK_SOURCE_OLE
;
768 PasteDataFormat( nFormatId
, aDataHelper
.GetTransferable(),
769 GetViewData()->GetCurX(), GetViewData()->GetCurY(),
770 NULL
, FALSE
, FALSE
);
775 BOOL
ScViewFunc::PasteFromSystem( ULONG nFormatId
, BOOL bApi
)
780 Window
* pWin
= GetActiveWin();
781 ScTransferObj
* pOwnClip
= ScTransferObj::GetOwnClipboard( pWin
);
782 if ( nFormatId
== 0 && pOwnClip
)
784 // #129384# keep a reference in case the clipboard is changed during PasteFromClip
785 uno::Reference
<datatransfer::XTransferable
> aOwnClipRef( pOwnClip
);
786 PasteFromClip( IDF_ALL
, pOwnClip
->GetDocument(),
787 PASTE_NOFUNC
, FALSE
, FALSE
, FALSE
, INS_NONE
, IDF_NONE
,
788 !bApi
); // allow warning dialog
792 TransferableDataHelper
aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin
) );
793 if ( !aDataHelper
.GetTransferable().is() )
796 bRet
= PasteDataFormat( nFormatId
, aDataHelper
.GetTransferable(),
797 GetViewData()->GetCurX(), GetViewData()->GetCurY(),
798 NULL
, FALSE
, !bApi
); // allow warning dialog
800 if ( !bRet
&& !bApi
)
801 ErrorMessage(STR_PASTE_ERROR
);
807 //----------------------------------------------------------------------------
810 BOOL
ScViewFunc::PasteOnDrawObject( const uno::Reference
<datatransfer::XTransferable
>& rxTransferable
,
811 SdrObject
* pHitObj
, BOOL bLink
)
816 TransferableDataHelper
aDataHelper( rxTransferable
);
817 if ( aDataHelper
.HasFormat( SOT_FORMATSTR_ID_SVXB
) )
819 SotStorageStreamRef xStm
;
820 if( aDataHelper
.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB
, xStm
) )
824 bRet
= ApplyGraphicToObject( pHitObj
, aGraphic
);
827 else if ( aDataHelper
.HasFormat( SOT_FORMAT_GDIMETAFILE
) )
830 if( aDataHelper
.GetGDIMetaFile( FORMAT_GDIMETAFILE
, aMtf
) )
831 bRet
= ApplyGraphicToObject( pHitObj
, Graphic(aMtf
) );
833 else if ( aDataHelper
.HasFormat( SOT_FORMAT_BITMAP
) )
836 if( aDataHelper
.GetBitmap( FORMAT_BITMAP
, aBmp
) )
837 bRet
= ApplyGraphicToObject( pHitObj
, Graphic(aBmp
) );
847 BOOL
lcl_SelHasAttrib( ScDocument
* pDoc
, SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
,
848 const ScMarkData
& rTabSelection
, USHORT nMask
)
850 SCTAB nTabCount
= pDoc
->GetTableCount();
851 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
852 if ( rTabSelection
.GetTableSelect(nTab
) && pDoc
->HasAttrib( nCol1
, nRow1
, nTab
, nCol2
, nRow2
, nTab
, nMask
) )
858 // Einfuegen auf Tabelle:
868 CursorSwitcher(ScViewFunc
* pViewFunc
) :
869 mpViewFunc(pViewFunc
)
871 mpViewFunc
->HideCursor();
876 mpViewFunc
->ShowCursor();
879 ScViewFunc
* mpViewFunc
;
882 bool lcl_checkDestRangeForOverwrite(const ScRange
& rDestRange
, const ScDocument
* pDoc
, const ScMarkData
& rMark
, Window
* pParentWnd
)
884 bool bIsEmpty
= true;
885 SCTAB nTabCount
= pDoc
->GetTableCount();
886 for (SCTAB nTab
=0; nTab
< nTabCount
&& bIsEmpty
; ++nTab
)
888 if (!rMark
.GetTableSelect(nTab
))
891 bIsEmpty
= pDoc
->IsBlockEmpty(nTab
, rDestRange
.aStart
.Col(), rDestRange
.aStart
.Row(),
892 rDestRange
.aEnd
.Col(), rDestRange
.aEnd
.Row());
897 ScReplaceWarnBox
aBox(pParentWnd
);
898 if (aBox
.Execute() != RET_YES
)
900 // changing the configuration is within the ScReplaceWarnBox
909 BOOL
ScViewFunc::PasteFromClip( USHORT nFlags
, ScDocument
* pClipDoc
,
910 USHORT nFunction
, BOOL bSkipEmpty
,
911 BOOL bTranspose
, BOOL bAsLink
,
912 InsCellCmd eMoveMode
, USHORT nUndoExtraFlags
,
917 DBG_ERROR("PasteFromClip: pClipDoc=0 not allowed");
921 // fuer Undo etc. immer alle oder keine Inhalte sichern
922 USHORT nContFlags
= IDF_NONE
;
923 if (nFlags
& IDF_CONTENTS
)
924 nContFlags
|= IDF_CONTENTS
;
925 if (nFlags
& IDF_ATTRIB
)
926 nContFlags
|= IDF_ATTRIB
;
927 // evtl. Attribute ins Undo ohne sie vom Clip ins Doc zu kopieren
928 USHORT nUndoFlags
= nContFlags
;
929 if (nUndoExtraFlags
& IDF_ATTRIB
)
930 nUndoFlags
|= IDF_ATTRIB
;
931 // do not copy note captions into undo document
932 nUndoFlags
|= IDF_NOCAPTIONS
;
934 ScClipParam
& rClipParam
= pClipDoc
->GetClipParam();
935 if (rClipParam
.isMultiRange())
936 return PasteMultiRangesFromClip(
937 nFlags
, pClipDoc
, nFunction
, bSkipEmpty
, bTranspose
, bAsLink
, bAllowDialogs
,
938 eMoveMode
, nContFlags
, nUndoFlags
);
940 BOOL bCutMode
= pClipDoc
->IsCutMode(); // if transposing, take from original clipdoc
941 BOOL bIncludeFiltered
= bCutMode
;
943 // paste drawing: also if IDF_NOTE is set (to create drawing layer for note captions)
944 BOOL bPasteDraw
= ( pClipDoc
->GetDrawLayer() && ( nFlags
& (IDF_OBJECTS
|IDF_NOTE
) ) );
946 ScDocShellRef aTransShellRef
; // for objects in xTransClip - must remain valid as long as xTransClip
947 ScDocument
* pOrigClipDoc
= NULL
;
948 ::std::auto_ptr
< ScDocument
> xTransClip
;
953 // include filtered rows until TransposeClip can skip them
954 bIncludeFiltered
= TRUE
;
955 pClipDoc
->GetClipArea( nX
, nY
, TRUE
);
956 if ( nY
> static_cast<sal_Int32
>(MAXCOL
) ) // zuviele Zeilen zum Transponieren
958 ErrorMessage(STR_PASTE_FULL
);
961 pOrigClipDoc
= pClipDoc
; // fuer Referenzen
965 aTransShellRef
= new ScDocShell
; // DocShell needs a Ref immediately
966 aTransShellRef
->DoInitNew(NULL
);
968 ScDrawLayer::SetGlobalDrawPersist(aTransShellRef
);
970 xTransClip
.reset( new ScDocument( SCDOCMODE_CLIP
));
971 pClipDoc
->TransposeClip( xTransClip
.get(), nFlags
, bAsLink
);
972 pClipDoc
= xTransClip
.get();
974 ScDrawLayer::SetGlobalDrawPersist(NULL
);
985 pClipDoc
->GetClipArea( nClipSizeX
, nClipSizeY
, TRUE
); // size in clipboard doc
987 // size in target doc: include filtered rows only if CutMode is set
990 pClipDoc
->GetClipArea( nDestSizeX
, nDestSizeY
, bIncludeFiltered
);
992 ScDocument
* pDoc
= GetViewData()->GetDocument();
993 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
994 ScMarkData
& rMark
= GetViewData()->GetMarkData();
995 SfxUndoManager
* pUndoMgr
= pDocSh
->GetUndoManager();
996 const BOOL
bRecord(pDoc
->IsUndoEnabled());
998 ScDocShellModificator
aModificator( *pDocSh
);
1001 ScMarkData
aFilteredMark( rMark
); // local copy for all modifications
1002 ScMarkType eMarkType
= GetViewData()->GetSimpleArea( aMarkRange
, aFilteredMark
);
1003 bool bMarkIsFiltered
= (eMarkType
== SC_MARK_SIMPLE_FILTERED
);
1004 bool bNoPaste
= ((eMarkType
!= SC_MARK_SIMPLE
&& !bMarkIsFiltered
) ||
1005 (bMarkIsFiltered
&& (eMoveMode
!= INS_NONE
|| bAsLink
)));
1006 if (!bNoPaste
&& !rMark
.IsMarked())
1008 // Create a selection with clipboard row count and check that for
1010 nStartCol
= GetViewData()->GetCurX();
1011 nStartRow
= GetViewData()->GetCurY();
1012 nStartTab
= GetViewData()->GetTabNo();
1013 nEndCol
= nStartCol
+ nDestSizeX
;
1014 nEndRow
= nStartRow
+ nDestSizeY
;
1015 nEndTab
= nStartTab
;
1016 aMarkRange
= ScRange( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
);
1017 if (ScViewUtil::HasFiltered( aMarkRange
, pDoc
))
1019 bMarkIsFiltered
= true;
1020 // Fit to clipboard's row count unfiltered rows. If there is no
1021 // fit assume that pasting is not possible. Note that nDestSizeY is
1022 // size-1 (difference).
1023 if (!ScViewUtil::FitToUnfilteredRows( aMarkRange
, pDoc
, nDestSizeY
+1))
1026 aFilteredMark
.SetMarkArea( aMarkRange
);
1030 ErrorMessage(STR_MSSG_PASTEFROMCLIP_0
);
1034 SCROW nUnfilteredRows
= aMarkRange
.aEnd
.Row() - aMarkRange
.aStart
.Row() + 1;
1035 ScRangeList aRangeList
;
1036 if (bMarkIsFiltered
)
1038 ScViewUtil::UnmarkFiltered( aFilteredMark
, pDoc
);
1039 aFilteredMark
.FillRangeListWithMarks( &aRangeList
, FALSE
);
1040 nUnfilteredRows
= 0;
1041 for (ScRange
* p
= aRangeList
.First(); p
; p
= aRangeList
.Next())
1043 nUnfilteredRows
+= p
->aEnd
.Row() - p
->aStart
.Row() + 1;
1046 /* This isn't needed but could be a desired restriction. */
1047 // For filtered, destination rows have to be an exact multiple of
1048 // source rows. Note that nDestSizeY is size-1 (difference), so
1049 // nDestSizeY==0 fits always.
1050 if ((nUnfilteredRows
% (nDestSizeY
+1)) != 0)
1052 /* FIXME: this should be a more descriptive error message then. */
1053 ErrorMessage(STR_MSSG_PASTEFROMCLIP_0
);
1059 SCCOL nMarkAddX
= 0;
1060 SCROW nMarkAddY
= 0;
1062 // Also for a filtered selection the area is used, for undo et al.
1063 if ( aFilteredMark
.IsMarked() || bMarkIsFiltered
)
1065 aMarkRange
.GetVars( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
);
1066 SCCOL nBlockAddX
= nEndCol
-nStartCol
;
1067 SCROW nBlockAddY
= nEndRow
-nStartRow
;
1069 // #58422# Nachfrage, wenn die Selektion groesser als 1 Zeile/Spalte, aber kleiner
1070 // als das Clipboard ist (dann wird ueber die Selektion hinaus eingefuegt)
1072 // ClipSize is not size, but difference
1073 if ( ( nBlockAddX
!= 0 && nBlockAddX
< nDestSizeX
) ||
1074 ( nBlockAddY
!= 0 && nBlockAddY
< nDestSizeY
) ||
1075 ( bMarkIsFiltered
&& nUnfilteredRows
< nDestSizeY
+1 ) )
1077 ScWaitCursorOff
aWaitOff( GetFrameWin() );
1078 String aMessage
= ScGlobal::GetRscString( STR_PASTE_BIGGER
);
1079 QueryBox
aBox( GetViewData()->GetDialogParent(),
1080 WinBits(WB_YES_NO
| WB_DEF_NO
), aMessage
);
1081 if ( aBox
.Execute() != RET_YES
)
1087 if (nBlockAddX
> nDestSizeX
)
1088 nMarkAddX
= nBlockAddX
- nDestSizeX
; // fuer Merge-Test
1090 nEndCol
= nStartCol
+ nDestSizeX
;
1092 if (nBlockAddY
> nDestSizeY
)
1093 nMarkAddY
= nBlockAddY
- nDestSizeY
; // fuer Merge-Test
1096 nEndRow
= nStartRow
+ nDestSizeY
;
1097 if (bMarkIsFiltered
|| nEndRow
> aMarkRange
.aEnd
.Row())
1099 // Same as above if nothing was marked: re-fit selection to
1100 // unfiltered rows. Extending the selection actually may
1101 // introduce filtered rows where there weren't any before, so
1102 // we also need to test for that.
1103 aMarkRange
= ScRange( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
);
1104 if (bMarkIsFiltered
|| ScViewUtil::HasFiltered( aMarkRange
, pDoc
))
1106 bMarkIsFiltered
= true;
1107 // Worst case: all rows up to the end of the sheet are filtered.
1108 if (!ScViewUtil::FitToUnfilteredRows( aMarkRange
, pDoc
, nDestSizeY
+1))
1110 ErrorMessage(STR_PASTE_FULL
);
1114 aMarkRange
.GetVars( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
);
1115 aFilteredMark
.SetMarkArea( aMarkRange
);
1116 if (bMarkIsFiltered
)
1118 ScViewUtil::UnmarkFiltered( aFilteredMark
, pDoc
);
1119 aFilteredMark
.FillRangeListWithMarks( &aRangeList
, TRUE
);
1126 nStartCol
= GetViewData()->GetCurX();
1127 nStartRow
= GetViewData()->GetCurY();
1128 nStartTab
= GetViewData()->GetTabNo();
1129 nEndCol
= nStartCol
+ nDestSizeX
;
1130 nEndRow
= nStartRow
+ nDestSizeY
;
1131 nEndTab
= nStartTab
;
1134 bool bOffLimits
= !ValidCol(nEndCol
) || !ValidRow(nEndRow
);
1136 // Zielbereich, wie er angezeigt wird:
1137 ScRange
aUserRange( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
);
1139 // Sollen Zellen eingefuegt werden?
1140 // (zu grosse nEndCol/nEndRow werden weiter unten erkannt)
1141 BOOL bInsertCells
= ( eMoveMode
!= INS_NONE
&& !bOffLimits
);
1144 // #94115# Instead of EnterListAction, the paste undo action is merged into the
1145 // insert action, so Repeat can insert the right cells
1147 MarkRange( aUserRange
); // wird vor CopyFromClip sowieso gesetzt
1149 // #72930# CutMode is reset on insertion of cols/rows but needed again on cell move
1150 BOOL bCut
= pClipDoc
->IsCutMode();
1151 if (!InsertCells( eMoveMode
, bRecord
, TRUE
)) // is inserting possible?
1154 // #i21036# EnterListAction isn't used, and InsertCells doesn't insert
1155 // its undo action on failure, so no undo handling is needed here
1158 pClipDoc
->SetCutMode( bCut
);
1160 else if (!bOffLimits
)
1162 BOOL bAskIfNotEmpty
= bAllowDialogs
&&
1163 ( nFlags
& IDF_CONTENTS
) &&
1164 nFunction
== PASTE_NOFUNC
&&
1165 SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
1166 if ( bAskIfNotEmpty
)
1168 if (!lcl_checkDestRangeForOverwrite(aUserRange
, pDoc
, aFilteredMark
, GetViewData()->GetDialogParent()))
1173 SCCOL nClipStartX
; // Clipboard-Bereich erweitern
1175 pClipDoc
->GetClipStart( nClipStartX
, nClipStartY
);
1176 SCCOL nUndoEndCol
= nClipStartX
+ nClipSizeX
;
1177 SCROW nUndoEndRow
= nClipStartY
+ nClipSizeY
; // end of source area in clipboard document
1178 BOOL bClipOver
= FALSE
;
1179 // #i68690# ExtendMerge for the clip doc must be called with the clipboard's sheet numbers.
1180 // The same end column/row can be used for all calls because the clip doc doesn't contain
1181 // content outside the clip area.
1182 for (SCTAB nClipTab
=0; nClipTab
<=MAXTAB
; nClipTab
++)
1183 if ( pClipDoc
->HasTable(nClipTab
) )
1184 if ( pClipDoc
->ExtendMerge( nClipStartX
,nClipStartY
, nUndoEndCol
,nUndoEndRow
, nClipTab
, FALSE
) )
1186 nUndoEndCol
-= nClipStartX
+ nClipSizeX
;
1187 nUndoEndRow
-= nClipStartY
+ nClipSizeY
; // now contains only the difference added by ExtendMerge
1188 nUndoEndCol
= sal::static_int_cast
<SCCOL
>( nUndoEndCol
+ nEndCol
);
1189 nUndoEndRow
= sal::static_int_cast
<SCROW
>( nUndoEndRow
+ nEndRow
); // destination area, expanded for merged cells
1191 // if (nUndoEndCol < nEndCol) nUndoEndCol = nEndCol;
1192 // if (nUndoEndRow < nEndRow) nUndoEndRow = nEndRow;
1194 // nUndoEndCol += nMarkAddX;
1195 // nUndoEndRow += nMarkAddY;
1197 if (nUndoEndCol
>MAXCOL
|| nUndoEndRow
>MAXROW
)
1199 ErrorMessage(STR_PASTE_FULL
);
1203 pDoc
->ExtendMergeSel( nStartCol
,nStartRow
, nUndoEndCol
,nUndoEndRow
, aFilteredMark
, FALSE
);
1205 // Test auf Zellschutz
1207 ScEditableTester
aTester( pDoc
, nStartTab
, nStartCol
,nStartRow
, nUndoEndCol
,nUndoEndRow
);
1208 if (!aTester
.IsEditable())
1210 ErrorMessage(aTester
.GetMessageId());
1214 ScDocFunc
& rDocFunc
= pDocSh
->GetDocFunc();
1217 String aUndo
= ScGlobal::GetRscString( pClipDoc
->IsCutMode() ? STR_UNDO_MOVE
: STR_UNDO_COPY
);
1218 pUndoMgr
->EnterListAction( aUndo
, aUndo
);
1222 if (lcl_SelHasAttrib( pDoc
, nStartCol
,nStartRow
, nUndoEndCol
,nUndoEndRow
, aFilteredMark
, HASATTR_OVERLAPPED
))
1223 { // "Cell merge are possible if we unmerge cells before insertion"
1224 ScRange
destRange( nStartCol
, nStartRow
, nStartTab
, nUndoEndCol
, nUndoEndRow
, nEndTab
);
1225 rDocFunc
.UnmergeCells(destRange
, bRecord
, TRUE
);
1226 for (SCCOL i
= nStartCol
; i
<= nUndoEndCol
; i
++)
1227 for (SCROW j
= nStartRow
; j
<= nUndoEndRow
; j
++)
1229 ScRange
rrRange (i
, j
, nEndTab
);
1230 pDoc
->ExtendOverlapped(rrRange
);
1231 pDoc
->ExtendMerge(rrRange
);
1232 // we can have merged range in the selection,
1233 // so we take only those which are in the way
1234 if (rrRange
.aStart
.Col() < nStartCol
|| rrRange
.aEnd
.Col() > nEndCol
||
1235 rrRange
.aStart
.Row() < nStartRow
|| rrRange
.aEnd
.Row() > nEndRow
)
1237 rDocFunc
.UnmergeCells(rrRange
, bRecord
, TRUE
);
1244 ScChangeTrack
* pChangeTrack
= pDoc
->GetChangeTrack();
1246 pChangeTrack
->ResetLastCut(); // kein CutMode mehr
1249 BOOL bColInfo
= ( nStartRow
==0 && nEndRow
==MAXROW
);
1250 BOOL bRowInfo
= ( nStartCol
==0 && nEndCol
==MAXCOL
);
1252 ScDocument
* pUndoDoc
= NULL
;
1253 ScDocument
* pRefUndoDoc
= NULL
;
1254 ScDocument
* pRedoDoc
= NULL
;
1255 ScRefUndoData
* pUndoData
= NULL
;
1259 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
1260 pUndoDoc
->InitUndoSelected( pDoc
, aFilteredMark
, bColInfo
, bRowInfo
);
1262 // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
1263 SCTAB nTabCount
= pDoc
->GetTableCount();
1264 pDoc
->CopyToDocument( nStartCol
, nStartRow
, 0, nUndoEndCol
, nUndoEndRow
, nTabCount
-1,
1265 nUndoFlags
, FALSE
, pUndoDoc
);
1269 pRefUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
1270 pRefUndoDoc
->InitUndo( pDoc
, 0, nTabCount
-1, FALSE
, FALSE
);
1272 pUndoData
= new ScRefUndoData( pDoc
);
1276 USHORT nExtFlags
= 0;
1277 pDocSh
->UpdatePaintExt( nExtFlags
, nStartCol
, nStartRow
, nStartTab
,
1278 nEndCol
, nEndRow
, nEndTab
); // content before the change
1280 if (GetViewData()->IsActive())
1285 rMark
.SetMarkArea( aUserRange
);
1288 HideCursor(); // Cursor aendert sich !
1291 // Aus Clipboard kopieren,
1292 // wenn gerechnet werden soll, Originaldaten merken
1295 ScDocument
* pMixDoc
= NULL
;
1296 if ( bSkipEmpty
|| nFunction
)
1298 if ( nFlags
& IDF_CONTENTS
)
1300 pMixDoc
= new ScDocument( SCDOCMODE_UNDO
);
1301 pMixDoc
->InitUndo( pDoc
, nStartTab
, nEndTab
);
1302 pDoc
->CopyToDocument( nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
,
1303 IDF_CONTENTS
, FALSE
, pMixDoc
);
1307 /* Make draw layer and start drawing undo.
1308 - Needed before AdjustBlockHeight to track moved drawing objects.
1309 - Needed before pDoc->CopyFromClip to track inserted note caption objects.
1312 pDocSh
->MakeDrawLayer();
1314 pDoc
->BeginDrawUndo();
1316 USHORT nNoObjFlags
= nFlags
& ~IDF_OBJECTS
;
1319 // copy normally (original range)
1320 pDoc
->CopyFromClip( aUserRange
, aFilteredMark
, nNoObjFlags
,
1321 pRefUndoDoc
, pClipDoc
, TRUE
, FALSE
, bIncludeFiltered
,
1322 bSkipEmpty
, (bMarkIsFiltered
? &aRangeList
: NULL
) );
1324 // bei Transpose Referenzen per Hand anpassen
1325 if ( bTranspose
&& bCutMode
&& (nFlags
& IDF_CONTENTS
) )
1326 pDoc
->UpdateTranspose( aUserRange
.aStart
, pOrigClipDoc
, aFilteredMark
, pRefUndoDoc
);
1328 else if (!bTranspose
)
1330 // copy with bAsLink=TRUE
1331 pDoc
->CopyFromClip( aUserRange
, aFilteredMark
, nNoObjFlags
, pRefUndoDoc
, pClipDoc
,
1332 TRUE
, TRUE
, bIncludeFiltered
, bSkipEmpty
);
1336 // alle Inhalte kopieren (im TransClipDoc stehen nur Formeln)
1337 pDoc
->CopyFromClip( aUserRange
, aFilteredMark
, nContFlags
, pRefUndoDoc
, pClipDoc
);
1340 // skipped rows and merged cells don't mix
1341 if ( !bIncludeFiltered
&& pClipDoc
->HasClipFilteredRows() )
1342 rDocFunc
.UnmergeCells( aUserRange
, FALSE
, TRUE
);
1344 pDoc
->ExtendMergeSel( nStartCol
, nStartRow
, nEndCol
, nEndRow
, aFilteredMark
, TRUE
); // Refresh
1347 if ( pMixDoc
) // Rechenfunktionen mit Original-Daten auszufuehren ?
1349 pDoc
->MixDocument( aUserRange
, nFunction
, bSkipEmpty
, pMixDoc
);
1353 AdjustBlockHeight(); // update row heights before pasting objects
1355 if ( nFlags
& IDF_OBJECTS
)
1357 // Paste the drawing objects after the row heights have been updated.
1359 pDoc
->CopyFromClip( aUserRange
, aFilteredMark
, IDF_OBJECTS
, pRefUndoDoc
, pClipDoc
,
1360 TRUE
, FALSE
, bIncludeFiltered
);
1367 pDocSh
->UpdatePaintExt( nExtFlags
, nStartCol
, nStartRow
, nStartTab
,
1368 nEndCol
, nEndRow
, nEndTab
); // content after the change
1371 // ggf. Autofilter-Koepfe loeschen
1373 if (pDoc
->RefreshAutoFilter( nClipStartX
,nClipStartY
, nClipStartX
+nClipSizeX
,
1374 nClipStartY
+nClipSizeY
, nStartTab
))
1375 pDocSh
->PostPaint( nClipStartX
,nClipStartY
,nStartTab
,
1376 nClipStartX
+nClipSizeX
,nClipStartY
,nStartTab
,
1379 ShowCursor(); // Cursor aendert sich !
1381 //! Block-Bereich bei RefUndoDoc weglassen !!!
1385 // Redo-Daten werden erst beim ersten Undo kopiert
1386 // ohne RefUndoDoc muss das Redo-Doc noch nicht angelegt werden
1390 pRedoDoc
= new ScDocument( SCDOCMODE_UNDO
);
1391 pRedoDoc
->InitUndo( pDoc
, nStartTab
, nEndTab
, bColInfo
, bRowInfo
);
1393 // angepasste Referenzen ins Redo-Doc
1395 SCTAB nTabCount
= pDoc
->GetTableCount();
1396 pRedoDoc
->AddUndoTab( 0, nTabCount
-1 );
1397 pDoc
->CopyUpdated( pRefUndoDoc
, pRedoDoc
);
1399 // alte Referenzen ins Undo-Doc
1401 //! Tabellen selektieren ?
1402 pUndoDoc
->AddUndoTab( 0, nTabCount
-1 );
1403 pRefUndoDoc
->DeleteArea( nStartCol
, nStartRow
, nEndCol
, nEndRow
, aFilteredMark
, IDF_ALL
);
1404 pRefUndoDoc
->CopyToDocument( 0,0,0, MAXCOL
,MAXROW
,nTabCount
-1,
1405 IDF_FORMULA
, FALSE
, pUndoDoc
);
1409 // DeleteUnchanged for pUndoData is in ScUndoPaste ctor,
1410 // UndoData for redo is made during first undo
1412 ScUndoPasteOptions aOptions
; // store options for repeat
1413 aOptions
.nFunction
= nFunction
;
1414 aOptions
.bSkipEmpty
= bSkipEmpty
;
1415 aOptions
.bTranspose
= bTranspose
;
1416 aOptions
.bAsLink
= bAsLink
;
1417 aOptions
.eMoveMode
= eMoveMode
;
1419 SfxUndoAction
* pUndo
= new ScUndoPaste( pDocSh
,
1420 nStartCol
, nStartRow
, nStartTab
,
1421 nUndoEndCol
, nUndoEndRow
, nEndTab
, aFilteredMark
,
1422 pUndoDoc
, pRedoDoc
, nFlags
| nUndoFlags
,
1423 pUndoData
, NULL
, NULL
, NULL
,
1424 FALSE
, &aOptions
); // FALSE = Redo data not yet copied
1428 // Merge the paste undo action into the insert action.
1429 // Use ScUndoWrapper so the ScUndoPaste pointer can be stored in the insert action.
1431 pUndoMgr
->AddUndoAction( new ScUndoWrapper( pUndo
), TRUE
);
1434 pUndoMgr
->AddUndoAction( pUndo
);
1436 pUndoMgr
->LeaveListAction();
1439 USHORT nPaint
= PAINT_GRID
;
1442 nPaint
|= PAINT_TOP
;
1443 nUndoEndCol
= MAXCOL
; // nur zum Zeichnen !
1447 nPaint
|= PAINT_LEFT
;
1448 nUndoEndRow
= MAXROW
; // nur zum Zeichnen !
1450 pDocSh
->PostPaint( nStartCol
, nStartRow
, nStartTab
,
1451 nUndoEndCol
, nUndoEndRow
, nEndTab
, nPaint
, nExtFlags
);
1452 // AdjustBlockHeight has already been called above
1454 aModificator
.SetDocumentModified();
1455 PostPasteFromClip(aUserRange
, rMark
);
1459 bool ScViewFunc::PasteMultiRangesFromClip(
1460 sal_uInt16 nFlags
, ScDocument
* pClipDoc
, sal_uInt16 nFunction
,
1461 bool bSkipEmpty
, bool bTranspose
, bool bAsLink
, bool bAllowDialogs
,
1462 InsCellCmd eMoveMode
, sal_uInt16
/*nContFlags*/, sal_uInt16 nUndoFlags
)
1464 ScViewData
& rViewData
= *GetViewData();
1465 ScDocument
* pDoc
= rViewData
.GetDocument();
1466 ScDocShell
* pDocSh
= rViewData
.GetDocShell();
1467 ScMarkData
aMark(rViewData
.GetMarkData());
1468 const ScAddress
& rCurPos
= rViewData
.GetCurPos();
1469 ScClipParam
& rClipParam
= pClipDoc
->GetClipParam();
1470 SCCOL nColSize
= rClipParam
.getPasteColSize();
1471 SCROW nRowSize
= rClipParam
.getPasteRowSize();
1475 if (static_cast<SCROW
>(rCurPos
.Col()) + nRowSize
-1 > static_cast<SCROW
>(MAXCOL
))
1477 ErrorMessage(STR_PASTE_FULL
);
1481 ::std::auto_ptr
<ScDocument
> pTransClip(new ScDocument(SCDOCMODE_CLIP
));
1482 pClipDoc
->TransposeClip(pTransClip
.get(), nFlags
, bAsLink
);
1483 pClipDoc
= pTransClip
.release();
1484 SCCOL nTempColSize
= nColSize
;
1485 nColSize
= static_cast<SCCOL
>(nRowSize
);
1486 nRowSize
= static_cast<SCROW
>(nTempColSize
);
1489 if (!ValidCol(rCurPos
.Col()+nColSize
-1) || !ValidRow(rCurPos
.Row()+nRowSize
-1))
1491 ErrorMessage(STR_PASTE_FULL
);
1495 // Determine the first and last selected sheet numbers.
1496 SCTAB nTab1
= aMark
.GetFirstSelected();
1497 SCTAB nTab2
= nTab1
;
1498 for (SCTAB i
= nTab1
+1; i
<= MAXTAB
; ++i
)
1499 if (aMark
.GetTableSelect(i
))
1502 ScDocShellModificator
aModificator(*pDocSh
);
1504 // For multi-selection paste, we don't support cell duplication for larger
1505 // destination range. In case the destination is marked, we reset it to
1507 ScRange
aMarkedRange(rCurPos
.Col(), rCurPos
.Row(), nTab1
,
1508 rCurPos
.Col()+nColSize
-1, rCurPos
.Row()+nRowSize
-1, nTab2
);
1510 bool bAskIfNotEmpty
=
1511 bAllowDialogs
&& (nFlags
& IDF_CONTENTS
) &&
1512 nFunction
== PASTE_NOFUNC
&& SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
1516 if (!lcl_checkDestRangeForOverwrite(aMarkedRange
, pDoc
, aMark
, rViewData
.GetDialogParent()))
1520 aMark
.SetMarkArea(aMarkedRange
);
1521 MarkRange(aMarkedRange
);
1523 bool bInsertCells
= (eMoveMode
!= INS_NONE
);
1526 if (!InsertCells(eMoveMode
, pDoc
->IsUndoEnabled(), true))
1530 ::std::auto_ptr
<ScDocument
> pUndoDoc
;
1531 if (pDoc
->IsUndoEnabled())
1533 pUndoDoc
.reset(new ScDocument(SCDOCMODE_UNDO
));
1534 pUndoDoc
->InitUndoSelected(pDoc
, aMark
, false, false);
1535 pDoc
->CopyToDocument(aMarkedRange
, IDF_ALL
, false, pUndoDoc
.get(), &aMark
, true);
1538 ::std::auto_ptr
<ScDocument
> pMixDoc
;
1539 if ( bSkipEmpty
|| nFunction
)
1541 if ( nFlags
& IDF_CONTENTS
)
1543 pMixDoc
.reset(new ScDocument(SCDOCMODE_UNDO
));
1544 pMixDoc
->InitUndoSelected(pDoc
, aMark
, false, false);
1545 pDoc
->CopyToDocument(aMarkedRange
, IDF_CONTENTS
, false, pMixDoc
.get(), &aMark
, true);
1549 /* Make draw layer and start drawing undo.
1550 - Needed before AdjustBlockHeight to track moved drawing objects.
1551 - Needed before pDoc->CopyFromClip to track inserted note caption objects.
1553 if (nFlags
& IDF_OBJECTS
)
1554 pDocSh
->MakeDrawLayer();
1555 if (pDoc
->IsUndoEnabled())
1556 pDoc
->BeginDrawUndo();
1558 CursorSwitcher
aCursorSwitch(this);
1559 sal_uInt16 nNoObjFlags
= nFlags
& ~IDF_OBJECTS
;
1560 pDoc
->CopyMultiRangeFromClip(rCurPos
, aMark
, nNoObjFlags
, pClipDoc
,
1561 true, bAsLink
, false, bSkipEmpty
);
1564 pDoc
->MixDocument(aMarkedRange
, nFunction
, bSkipEmpty
, pMixDoc
.get());
1566 AdjustBlockHeight(); // update row heights before pasting objects
1568 if (nFlags
& IDF_OBJECTS
)
1570 // Paste the drawing objects after the row heights have been updated.
1571 pDoc
->CopyMultiRangeFromClip(rCurPos
, aMark
, IDF_OBJECTS
, pClipDoc
,
1572 true, false, false, true);
1575 pDocSh
->PostPaint(rCurPos
.Col(), rCurPos
.Row(), rCurPos
.Tab(),
1576 rCurPos
.Col()+nColSize
-1, rCurPos
.Row()+nRowSize
-1, rCurPos
.Tab(),
1579 if (pDoc
->IsUndoEnabled())
1581 SfxUndoManager
* pUndoMgr
= pDocSh
->GetUndoManager();
1582 String aUndo
= ScGlobal::GetRscString(
1583 pClipDoc
->IsCutMode() ? STR_UNDO_CUT
: STR_UNDO_COPY
);
1584 pUndoMgr
->EnterListAction(aUndo
, aUndo
);
1586 ScUndoPasteOptions aOptions
; // store options for repeat
1587 aOptions
.nFunction
= nFunction
;
1588 aOptions
.bSkipEmpty
= bSkipEmpty
;
1589 aOptions
.bTranspose
= bTranspose
;
1590 aOptions
.bAsLink
= bAsLink
;
1591 aOptions
.eMoveMode
= eMoveMode
;
1593 ScUndoPaste
* pUndo
= new ScUndoPaste(pDocSh
,
1594 aMarkedRange
.aStart
.Col(),
1595 aMarkedRange
.aStart
.Row(),
1596 aMarkedRange
.aStart
.Tab(),
1597 aMarkedRange
.aEnd
.Col(),
1598 aMarkedRange
.aEnd
.Row(),
1599 aMarkedRange
.aEnd
.Tab(),
1600 aMark
, pUndoDoc
.release(), NULL
, nFlags
|nUndoFlags
, NULL
, NULL
, NULL
, NULL
, false, &aOptions
);
1603 pUndoMgr
->AddUndoAction(new ScUndoWrapper(pUndo
), true);
1605 pUndoMgr
->AddUndoAction(pUndo
, false);
1607 pUndoMgr
->LeaveListAction();
1609 aModificator
.SetDocumentModified();
1610 PostPasteFromClip(aMarkedRange
, aMark
);
1614 void ScViewFunc::PostPasteFromClip(const ScRange
& rPasteRange
, const ScMarkData
& rMark
)
1616 ScViewData
* pViewData
= GetViewData();
1617 ScDocShell
* pDocSh
= pViewData
->GetDocShell();
1618 ScDocument
* pDoc
= pViewData
->GetDocument();
1619 pDocSh
->UpdateOle(pViewData
);
1623 // #i97876# Spreadsheet data changes are not notified
1624 ScModelObj
* pModelObj
= ScModelObj::getImplementation( pDocSh
->GetModel() );
1625 if ( pModelObj
&& pModelObj
->HasChangesListeners() )
1627 ScRangeList aChangeRanges
;
1628 SCTAB nTabCount
= pDoc
->GetTableCount();
1629 for ( SCTAB i
= 0; i
< nTabCount
; ++i
)
1631 if ( rMark
.GetTableSelect( i
) )
1633 ScRange
aChangeRange(rPasteRange
);
1634 aChangeRange
.aStart
.SetTab( i
);
1635 aChangeRange
.aEnd
.SetTab( i
);
1636 aChangeRanges
.Append( aChangeRange
);
1639 pModelObj
->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges
);
1644 //----------------------------------------------------------------------------
1645 // D R A G A N D D R O P
1647 // innerhalb des Dokuments
1649 BOOL
ScViewFunc::MoveBlockTo( const ScRange
& rSource
, const ScAddress
& rDestPos
,
1650 BOOL bCut
, BOOL bRecord
, BOOL bPaint
, BOOL bApi
)
1652 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
1653 HideAllCursors(); // wegen zusammengefassten
1655 BOOL bSuccess
= TRUE
;
1656 SCTAB nDestTab
= rDestPos
.Tab();
1657 const ScMarkData
& rMark
= GetViewData()->GetMarkData();
1658 if ( rSource
.aStart
.Tab() == nDestTab
&& rSource
.aEnd
.Tab() == nDestTab
&& rMark
.GetSelectCount() > 1 )
1660 // moving within one table and several tables selected -> apply to all selected tables
1664 String aUndo
= ScGlobal::GetRscString( bCut
? STR_UNDO_MOVE
: STR_UNDO_COPY
);
1665 pDocSh
->GetUndoManager()->EnterListAction( aUndo
, aUndo
);
1668 // collect ranges of consecutive selected tables
1670 ScRange aLocalSource
= rSource
;
1671 ScAddress aLocalDest
= rDestPos
;
1672 SCTAB nTabCount
= pDocSh
->GetDocument()->GetTableCount();
1673 SCTAB nStartTab
= 0;
1674 while ( nStartTab
< nTabCount
&& bSuccess
)
1676 while ( nStartTab
< nTabCount
&& !rMark
.GetTableSelect(nStartTab
) )
1678 if ( nStartTab
< nTabCount
)
1680 SCTAB nEndTab
= nStartTab
;
1681 while ( nEndTab
+1 < nTabCount
&& rMark
.GetTableSelect(nEndTab
+1) )
1684 aLocalSource
.aStart
.SetTab( nStartTab
);
1685 aLocalSource
.aEnd
.SetTab( nEndTab
);
1686 aLocalDest
.SetTab( nStartTab
);
1688 bSuccess
= pDocSh
->GetDocFunc().MoveBlock(
1689 aLocalSource
, aLocalDest
, bCut
, bRecord
, bPaint
, bApi
);
1691 nStartTab
= nEndTab
+ 1;
1696 pDocSh
->GetUndoManager()->LeaveListAction();
1700 // move the block as specified
1701 bSuccess
= pDocSh
->GetDocFunc().MoveBlock(
1702 rSource
, rDestPos
, bCut
, bRecord
, bPaint
, bApi
);
1708 // Zielbereich markieren
1710 rDestPos
.Col() + rSource
.aEnd
.Col() - rSource
.aStart
.Col(),
1711 rDestPos
.Row() + rSource
.aEnd
.Row() - rSource
.aStart
.Row(),
1714 BOOL bIncludeFiltered
= bCut
;
1715 if ( !bIncludeFiltered
)
1717 // find number of non-filtered rows
1718 SCROW nPastedCount
= pDocSh
->GetDocument()->CountNonFilteredRows(
1719 rSource
.aStart
.Row(), rSource
.aEnd
.Row(), rSource
.aStart
.Tab());
1721 if ( nPastedCount
== 0 )
1723 aDestEnd
.SetRow( rDestPos
.Row() + nPastedCount
- 1 );
1726 MarkRange( ScRange( rDestPos
, aDestEnd
), FALSE
); //! FALSE ???
1728 pDocSh
->UpdateOle(GetViewData());
1734 // Link innerhalb des Dokuments
1736 BOOL
ScViewFunc::LinkBlock( const ScRange
& rSource
, const ScAddress
& rDestPos
, BOOL bApi
)
1738 // Test auf Ueberlappung
1740 if ( rSource
.aStart
.Tab() == rDestPos
.Tab() )
1742 SCCOL nDestEndCol
= rDestPos
.Col() + ( rSource
.aEnd
.Col() - rSource
.aStart
.Col() );
1743 SCROW nDestEndRow
= rDestPos
.Row() + ( rSource
.aEnd
.Row() - rSource
.aStart
.Row() );
1745 if ( rSource
.aStart
.Col() <= nDestEndCol
&& rDestPos
.Col() <= rSource
.aEnd
.Col() &&
1746 rSource
.aStart
.Row() <= nDestEndRow
&& rDestPos
.Row() <= rSource
.aEnd
.Row() )
1749 ErrorMessage( STR_ERR_LINKOVERLAP
);
1754 // Ausfuehren per Paste
1756 ScDocument
* pDoc
= GetViewData()->GetDocument();
1757 ScDocument
* pClipDoc
= new ScDocument( SCDOCMODE_CLIP
);
1758 pDoc
->CopyTabToClip( rSource
.aStart
.Col(), rSource
.aStart
.Row(),
1759 rSource
.aEnd
.Col(), rSource
.aEnd
.Row(),
1760 rSource
.aStart
.Tab(), pClipDoc
);
1762 // Zielbereich markieren (Cursor setzen, keine Markierung)
1764 if ( GetViewData()->GetTabNo() != rDestPos
.Tab() )
1765 SetTabNo( rDestPos
.Tab() );
1767 MoveCursorAbs( rDestPos
.Col(), rDestPos
.Row(), SC_FOLLOW_NONE
, FALSE
, FALSE
);
1771 PasteFromClip( IDF_ALL
, pClipDoc
, PASTE_NOFUNC
, FALSE
, FALSE
, TRUE
); // als Link
1778 void ScViewFunc::DataFormPutData( SCROW nCurrentRow
,
1779 SCROW nStartRow
, SCCOL nStartCol
,
1780 SCROW nEndRow
, SCCOL nEndCol
,
1782 sal_uInt16 aColLength
)
1784 ScDocument
* pDoc
= GetViewData()->GetDocument();
1785 ScDocShell
* pDocSh
= GetViewData()->GetDocShell();
1786 ScMarkData
& rMark
= GetViewData()->GetMarkData();
1787 ScDocShellModificator
aModificator( *pDocSh
);
1788 SfxUndoManager
* pUndoMgr
= pDocSh
->GetUndoManager();
1791 const BOOL
bRecord( pDoc
->IsUndoEnabled());
1792 ScDocument
* pUndoDoc
= NULL
;
1793 ScDocument
* pRedoDoc
= NULL
;
1794 ScRefUndoData
* pUndoData
= NULL
;
1795 SCTAB nTab
= GetViewData()->GetTabNo();
1796 SCTAB nStartTab
= nTab
;
1797 SCTAB nEndTab
= nTab
;
1800 ScChangeTrack
* pChangeTrack
= pDoc
->GetChangeTrack();
1802 pChangeTrack
->ResetLastCut(); // kein CutMode mehr
1804 ScRange
aUserRange( nStartCol
, nCurrentRow
, nStartTab
, nEndCol
, nCurrentRow
, nEndTab
);
1805 BOOL bColInfo
= ( nStartRow
==0 && nEndRow
==MAXROW
);
1806 BOOL bRowInfo
= ( nStartCol
==0 && nEndCol
==MAXCOL
);
1807 SCCOL nUndoEndCol
= nStartCol
+aColLength
-1;
1808 SCROW nUndoEndRow
= nCurrentRow
;
1809 USHORT nUndoFlags
= IDF_NONE
;
1813 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
1814 pUndoDoc
->InitUndoSelected( pDoc
, rMark
, bColInfo
, bRowInfo
);
1815 pDoc
->CopyToDocument( aUserRange
, 1 , FALSE
, pUndoDoc
);
1817 USHORT nExtFlags
= 0;
1818 pDocSh
->UpdatePaintExt( nExtFlags
, nStartCol
, nStartRow
, nStartTab
, nEndCol
, nEndRow
, nEndTab
); // content before the change
1819 //rMark.SetMarkArea( aUserRange );
1820 pDoc
->BeginDrawUndo();
1822 for(sal_uInt16 i
= 0; i
< aColLength
; i
++)
1826 String aFieldName
=pEdits
[i
]->GetText();
1827 pDoc
->SetString( nStartCol
+ i
, nCurrentRow
, nTab
, aFieldName
);
1830 //pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, rMark, TRUE ); // Refresh
1831 pDocSh
->UpdatePaintExt( nExtFlags
, nStartCol
, nCurrentRow
, nStartTab
, nEndCol
, nCurrentRow
, nEndTab
); // content after the change
1832 SfxUndoAction
* pUndo
= new ScUndoDataForm( pDocSh
,
1833 nStartCol
, nCurrentRow
, nStartTab
,
1834 nUndoEndCol
, nUndoEndRow
, nEndTab
, rMark
,
1835 pUndoDoc
, pRedoDoc
, nUndoFlags
,
1836 pUndoData
, NULL
, NULL
, NULL
,
1837 FALSE
); // FALSE = Redo data not yet copied
1838 pUndoMgr
->AddUndoAction( new ScUndoWrapper( pUndo
), TRUE
);
1840 USHORT nPaint
= PAINT_GRID
;
1843 nPaint
|= PAINT_TOP
;
1844 nUndoEndCol
= MAXCOL
; // nur zum Zeichnen !
1848 nPaint
|= PAINT_LEFT
;
1849 nUndoEndRow
= MAXROW
; // nur zum Zeichnen !
1852 pDocSh
->PostPaint( nStartCol
, nCurrentRow
, nStartTab
,
1853 nUndoEndCol
, nUndoEndRow
, nEndTab
, nPaint
, nExtFlags
);
1854 pDocSh
->UpdateOle(GetViewData());