[ooo-build-commit] 2 commits - patches/dev300

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Jun 2 20:54:57 PDT 2009


 patches/dev300/apply                                |    1 
 patches/dev300/calc-multi-range-copy-paste.diff     |  987 ++++++++++----------
 patches/dev300/calc-selection-fixed-cursor-dnd.diff |   34 
 patches/dev300/calc-selection-fixed-cursor.diff     |  478 +++++----
 4 files changed, 783 insertions(+), 717 deletions(-)

New commits:
commit 57546deea1c6dfdb120659d899d3177625b98fdb
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 2 22:43:49 2009 -0400

    Combined the two patches, and removed unused variables.
    
    * patches/dev300/apply:
    * patches/dev300/calc-selection-fixed-cursor-dnd.diff: combined & removed.
    * patches/dev300/calc-selection-fixed-cursor.diff: combined with the
      first patch.

diff --git a/patches/dev300/apply b/patches/dev300/apply
index 160df62..bbb7fda 100644
--- a/patches/dev300/apply
+++ b/patches/dev300/apply
@@ -1992,7 +1992,6 @@ calc-dp-custom-names-ods-xmloff.diff, n#479062, i#22029, kohei
 
 # when making selection, don't move the cursor position.
 calc-selection-fixed-cursor.diff,     n#502717, kohei
-calc-selection-fixed-cursor-dnd.diff, n#508872, kohei
 
 [ OOXML ]
 oox-import-zoom-setting-with-tab-color.diff, n#494603, janneke
diff --git a/patches/dev300/calc-selection-fixed-cursor-dnd.diff b/patches/dev300/calc-selection-fixed-cursor-dnd.diff
deleted file mode 100644
index 53563f9..0000000
--- a/patches/dev300/calc-selection-fixed-cursor-dnd.diff
+++ /dev/null
@@ -1,34 +0,0 @@
-diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
-index 07aebda..491fdc9 100644
---- sc/source/ui/view/gridwin.cxx
-+++ sc/source/ui/view/gridwin.cxx
-@@ -3960,7 +3960,10 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
-                 if ( bDone )
-                 {
-                     pView->MarkRange( aDest, FALSE, FALSE );
--                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
-+
-+                    SCCOL nDCol = pViewData->GetCurX() - aSource.aStart.Col();
-+                    SCROW nDRow = pViewData->GetCurY() - aSource.aStart.Row();
-+                    pView->SetCursor( aDest.aStart.Col() + nDCol, aDest.aStart.Row() + nDRow );
-                 }
- 
-                 pDocSh->GetUndoManager()->LeaveListAction();
-@@ -4068,7 +4071,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
-                     pView->EnterMatrix( aFormula );
- 
-                     pView->MarkRange( aDest, FALSE, FALSE );
--                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
-+                    pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
-                 }
- 
-                 pDocSh->GetUndoManager()->LeaveListAction();
-@@ -4102,7 +4105,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
-                 if ( bDone )
-                 {
-                     pView->MarkRange( aDest, FALSE, FALSE );
--                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
-+                    pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
-                 }
-             }
- 
diff --git a/patches/dev300/calc-selection-fixed-cursor.diff b/patches/dev300/calc-selection-fixed-cursor.diff
index 417fa04..b8ffa05 100644
--- a/patches/dev300/calc-selection-fixed-cursor.diff
+++ b/patches/dev300/calc-selection-fixed-cursor.diff
@@ -1,21 +1,21 @@
 diff --git sc/inc/document.hxx sc/inc/document.hxx
-index b3d4642..b016e1e 100644
+index 004f7a2..e9cbe14 100644
 --- sc/inc/document.hxx
 +++ sc/inc/document.hxx
-@@ -830,6 +830,7 @@ public:
- 												ScRange* pLastRange = NULL,
- 												Rectangle* pLastMM = NULL ) const;
+@@ -825,6 +825,7 @@ public:
+                                                 ScRange* pLastRange = NULL,
+                                                 Rectangle* pLastMM = NULL ) const;
  
 +    void            SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const;
- 	BOOL			IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
- 	BOOL			IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
+     BOOL			IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
+     BOOL			IsVerOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
  
 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
-index af15cdb..98001ef 100644
+index 16e4dda..163feea 100644
 --- sc/source/core/data/document.cxx
 +++ sc/source/core/data/document.cxx
-@@ -4356,6 +4356,13 @@ BOOL ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
- 	return bChange;
+@@ -4273,6 +4273,13 @@ BOOL ScDocument::RefreshAutoFilter( SCCOL nStartCol, SCROW nStartRow,
+     return bChange;
  }
  
 +void ScDocument::SkipOverlapped( SCCOL& rCol, SCROW& rRow, SCTAB nTab ) const
@@ -29,7 +29,7 @@ index af15cdb..98001ef 100644
  BOOL ScDocument::IsHorOverlapped( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
  {
 diff --git sc/source/ui/inc/cellsh.hxx sc/source/ui/inc/cellsh.hxx
-index b859e36..39fe3e8 100644
+index 97f6d0d..a42a336 100644
 --- sc/source/ui/inc/cellsh.hxx
 +++ sc/source/ui/inc/cellsh.hxx
 @@ -37,6 +37,7 @@
@@ -41,59 +41,59 @@ index b859e36..39fe3e8 100644
  class SvxClipboardFmtItem;
  class TransferableDataHelper;
 diff --git sc/source/ui/inc/tabview.hxx sc/source/ui/inc/tabview.hxx
-index 4e5cb0b..882c88b 100644
+index 437b95b..804fbff 100644
 --- sc/source/ui/inc/tabview.hxx
 +++ sc/source/ui/inc/tabview.hxx
 @@ -179,7 +179,6 @@ private:
- 	BOOL				bInActivatePart;
- 	BOOL				bInZoomUpdate;
- 	BOOL				bMoveIsShift;
--	BOOL				bNewStartIfMarking;
+     BOOL				bInActivatePart;
+     BOOL				bInZoomUpdate;
+     BOOL				bMoveIsShift;
+-    BOOL				bNewStartIfMarking;
  
      BOOL                bOldSelection;          // old style (inverting) of selection
  
 @@ -203,6 +202,10 @@ private:
- 	static void		SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, BOOL bLayoutRTL );
- 	static long		GetScrollBarPos( ScrollBar& rScroll, BOOL bLayoutRTL );
+     static void		SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, BOOL bLayoutRTL );
+     static long		GetScrollBarPos( ScrollBar& rScroll, BOOL bLayoutRTL );
  
 +    void            GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY);
 +    void            GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, 
 +                                           SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
 +
  protected:
- 	void			UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
- 										const SCROW* pPosY = NULL );
+     void			UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
+                                         const SCROW* pPosY = NULL );
 @@ -391,8 +394,6 @@ public:
  
- 	void			FindNextUnprot( BOOL bShift, BOOL bInSelection = TRUE );
+     void			FindNextUnprot( BOOL bShift, BOOL bInSelection = TRUE );
  
--	void			SetNewStartIfMarking();
+-    void			SetNewStartIfMarking();
 -
      void            SetTabNo( SCTAB nTab, BOOL bNew = FALSE, BOOL bExtendSelection = FALSE );
      void            SelectNextTab( short nDir, BOOL bExtendSelection = FALSE );
  
 @@ -483,6 +484,10 @@ public:
  
- 	BOOL			IsBlockMode() const		{ return bIsBlockMode; }
+     BOOL			IsBlockMode() const		{ return bIsBlockMode; }
  
 +    void            ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode);
 +    void            ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY);
 +    void            ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY);
 +
- 	void			MarkColumns();
- 	void			MarkRows();
- 	void			MarkDataArea( BOOL bIncludeCursor = TRUE );
+     void			MarkColumns();
+     void			MarkRows();
+     void			MarkDataArea( BOOL bIncludeCursor = TRUE );
 diff --git sc/source/ui/view/cellsh4.cxx sc/source/ui/view/cellsh4.cxx
-index afb7c54..6c512e4 100644
+index 4cb00fb..3f80397 100644
 --- sc/source/ui/view/cellsh4.cxx
 +++ sc/source/ui/view/cellsh4.cxx
 @@ -88,10 +88,56 @@ void ScCellShell::ExecuteCursor( SfxRequest& rReq )
- 		{
- 			// ADD mode: keep the selection, start a new block when marking with shift again
- 			bKeep = TRUE;
--			pTabViewShell->SetNewStartIfMarking();
- 		}
- 	}
+         {
+             // ADD mode: keep the selection, start a new block when marking with shift again
+             bKeep = TRUE;
+-            pTabViewShell->SetNewStartIfMarking();
+         }
+     }
  
 +    if (bSel)
 +    {
@@ -142,56 +142,41 @@ index afb7c54..6c512e4 100644
 +        return;
 +    }
 +
- 	SCsCOLROW nRTLSign = 1;
- 	if ( pData->GetDocument()->IsLayoutRTL( pData->GetTabNo() ) )
- 	{
-@@ -172,38 +218,56 @@ void ScCellShell::GetStateCursor( SfxItemSet& /* rSet */ )
+     SCsCOLROW nRTLSign = 1;
+     if ( pData->GetDocument()->IsLayoutRTL( pData->GetTabNo() ) )
+     {
+@@ -172,38 +218,50 @@ void ScCellShell::GetStateCursor( SfxItemSet& /* rSet */ )
  
  void ScCellShell::ExecuteCursorSel( SfxRequest& rReq )
  {
--	const SfxItemSet*	pReqArgs = rReq.GetArgs();
--	USHORT				nSlotId  = rReq.GetSlot();
--	short				nRepeat = 1;
+-    const SfxItemSet*	pReqArgs = rReq.GetArgs();
+-    USHORT				nSlotId  = rReq.GetSlot();
+-    short				nRepeat = 1;
 -
--	if ( pReqArgs != NULL )
--	{
--		const	SfxPoolItem* pItem;
--		if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
--			nRepeat = ((const SfxInt16Item*)pItem)->GetValue();
--	}
--
--	switch ( nSlotId )
--	{
--		case SID_CURSORDOWN_SEL:		rReq.SetSlot( SID_CURSORDOWN );  break;
--		case SID_CURSORBLKDOWN_SEL:		rReq.SetSlot( SID_CURSORBLKDOWN );  break;
--		case SID_CURSORUP_SEL:			rReq.SetSlot( SID_CURSORUP );  break;
--		case SID_CURSORBLKUP_SEL:		rReq.SetSlot( SID_CURSORBLKUP );  break;
--		case SID_CURSORLEFT_SEL:		rReq.SetSlot( SID_CURSORLEFT );  break;
--		case SID_CURSORBLKLEFT_SEL:		rReq.SetSlot( SID_CURSORBLKLEFT );  break;
--		case SID_CURSORRIGHT_SEL:		rReq.SetSlot( SID_CURSORRIGHT );  break;
--		case SID_CURSORBLKRIGHT_SEL:	rReq.SetSlot( SID_CURSORBLKRIGHT );  break;
--		case SID_CURSORPAGEDOWN_SEL:	rReq.SetSlot( SID_CURSORPAGEDOWN );  break;
--		case SID_CURSORPAGEUP_SEL:		rReq.SetSlot( SID_CURSORPAGEUP );  break;
--		case SID_CURSORPAGERIGHT_SEL:	rReq.SetSlot( SID_CURSORPAGERIGHT_ );  break;
--		case SID_CURSORPAGELEFT_SEL:	rReq.SetSlot( SID_CURSORPAGELEFT_ );  break;
--		default:
--			DBG_ERROR("Unbekannte Message bei ViewShell (CursorSel)");
--			return;
--	}
--	rReq.AppendItem( SfxInt16Item(FN_PARAM_1, nRepeat ) );
--	rReq.AppendItem( SfxBoolItem(FN_PARAM_2, TRUE) );
--	ExecuteSlot( rReq, GetInterface() );
-+    const SfxItemSet*   pReqArgs = rReq.GetArgs();
-+    sal_uInt16          nSlotId  = rReq.GetSlot();
-+    short               nRepeat = 1;
-+    ScViewData* pData = GetViewData();
-+    ScTabViewShell* pViewShell = pData->GetViewShell();
-+
-+    sal_uInt16 nLocked = pViewShell->GetLockedModifiers();
-+    bool bAddSel = (nLocked & KEY_MOD1);
-+
+-    if ( pReqArgs != NULL )
+-    {
+-        const	SfxPoolItem* pItem;
+-        if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+-            nRepeat = ((const SfxInt16Item*)pItem)->GetValue();
+-    }
++    sal_uInt16 nSlotId  = rReq.GetSlot();
++    ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
+ 
+-    switch ( nSlotId )
 +    switch (nSlotId)
-+    {
+     {
+-        case SID_CURSORDOWN_SEL:		rReq.SetSlot( SID_CURSORDOWN );  break;
+-        case SID_CURSORBLKDOWN_SEL:		rReq.SetSlot( SID_CURSORBLKDOWN );  break;
+-        case SID_CURSORUP_SEL:			rReq.SetSlot( SID_CURSORUP );  break;
+-        case SID_CURSORBLKUP_SEL:		rReq.SetSlot( SID_CURSORBLKUP );  break;
+-        case SID_CURSORLEFT_SEL:		rReq.SetSlot( SID_CURSORLEFT );  break;
+-        case SID_CURSORBLKLEFT_SEL:		rReq.SetSlot( SID_CURSORBLKLEFT );  break;
+-        case SID_CURSORRIGHT_SEL:		rReq.SetSlot( SID_CURSORRIGHT );  break;
+-        case SID_CURSORBLKRIGHT_SEL:	rReq.SetSlot( SID_CURSORBLKRIGHT );  break;
+-        case SID_CURSORPAGEDOWN_SEL:	rReq.SetSlot( SID_CURSORPAGEDOWN );  break;
+-        case SID_CURSORPAGEUP_SEL:		rReq.SetSlot( SID_CURSORPAGEUP );  break;
+-        case SID_CURSORPAGERIGHT_SEL:	rReq.SetSlot( SID_CURSORPAGERIGHT_ );  break;
+-        case SID_CURSORPAGELEFT_SEL:	rReq.SetSlot( SID_CURSORPAGELEFT_ );  break;
 +        case SID_CURSORDOWN_SEL:
 +            pViewShell->ExpandBlock(0, 1, SC_FOLLOW_LINE);
 +        break;
@@ -228,60 +213,99 @@ index afb7c54..6c512e4 100644
 +        case SID_CURSORBLKLEFT_SEL:
 +            pViewShell->ExpandBlockArea(-1, 0);
 +        break;
-+        default:
+         default:
+-            DBG_ERROR("Unbekannte Message bei ViewShell (CursorSel)");
+-            return;
 +            ;
-+    }
+     }
+-    rReq.AppendItem( SfxInt16Item(FN_PARAM_1, nRepeat ) );
+-    rReq.AppendItem( SfxBoolItem(FN_PARAM_2, TRUE) );
+-    ExecuteSlot( rReq, GetInterface() );
  }
  
  void ScCellShell::ExecuteMove( SfxRequest& rReq )
-@@ -348,7 +412,6 @@ void ScCellShell::ExecutePage( SfxRequest& rReq )
- 		{
- 			// ADD mode: keep the selection, start a new block when marking with shift again
- 			bKeep = TRUE;
--			pTabViewShell->SetNewStartIfMarking();
- 		}
- 	}
+@@ -348,7 +406,6 @@ void ScCellShell::ExecutePage( SfxRequest& rReq )
+         {
+             // ADD mode: keep the selection, start a new block when marking with shift again
+             bKeep = TRUE;
+-            pTabViewShell->SetNewStartIfMarking();
+         }
+     }
+ 
+diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
+index 169dcc1..84e0bf9 100644
+--- sc/source/ui/view/gridwin.cxx
++++ sc/source/ui/view/gridwin.cxx
+@@ -3960,7 +3960,10 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
+                 if ( bDone )
+                 {
+                     pView->MarkRange( aDest, FALSE, FALSE );
+-                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
++
++                    SCCOL nDCol = pViewData->GetCurX() - aSource.aStart.Col();
++                    SCROW nDRow = pViewData->GetCurY() - aSource.aStart.Row();
++                    pView->SetCursor( aDest.aStart.Col() + nDCol, aDest.aStart.Row() + nDRow );
+                 }
+ 
+                 pDocSh->GetUndoManager()->LeaveListAction();
+@@ -4068,7 +4071,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
+                     pView->EnterMatrix( aFormula );
+ 
+                     pView->MarkRange( aDest, FALSE, FALSE );
+-                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
++                    pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
+                 }
+ 
+                 pDocSh->GetUndoManager()->LeaveListAction();
+@@ -4102,7 +4105,7 @@ sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPos
+                 if ( bDone )
+                 {
+                     pView->MarkRange( aDest, FALSE, FALSE );
+-                    pView->SetCursor( aDest.aEnd.Col(), aDest.aEnd.Row() );
++                    pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
+                 }
+             }
  
 diff --git sc/source/ui/view/select.cxx sc/source/ui/view/select.cxx
-index f7ae33d..e4bb262 100644
+index f5d28bb..c60d346 100644
 --- sc/source/ui/view/select.cxx
 +++ sc/source/ui/view/select.cxx
 @@ -668,7 +668,10 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
- 				}
- 			}
- 			if (bStarted)
+                 }
+             }
+             if (bStarted)
 +                // If the selection is already started, don't set the cursor.
- 				pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab, FALSE, FALSE, TRUE );
+                 pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab, FALSE, FALSE, TRUE );
 +            else
 +                pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
- 		}
- 		else
- 		{
+         }
+         else
+         {
 @@ -704,9 +707,9 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
- 				
- 				bStarted = TRUE;
- 			}
+                 
+                 bStarted = TRUE;
+             }
 +            pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
- 		}
+         }
  
--		pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
- 		pViewData->SetRefStart( nPosX, nPosY, nTab );
- 		if (bHideCur)
- 			pView->ShowAllCursors();
+-        pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
+         pViewData->SetRefStart( nPosX, nPosY, nTab );
+         if (bHideCur)
+             pView->ShowAllCursors();
 diff --git sc/source/ui/view/tabview.cxx sc/source/ui/view/tabview.cxx
-index 7d24844..83fa37b 100644
+index 75ad4ba..9b66eb6 100644
 --- sc/source/ui/view/tabview.cxx
 +++ sc/source/ui/view/tabview.cxx
 @@ -384,7 +384,6 @@ BOOL lcl_HasRowOutline( const ScViewData& rViewData )
- 			bInActivatePart( FALSE ),										\
- 			bInZoomUpdate( FALSE ),											\
- 			bMoveIsShift( FALSE ),											\
+             bInActivatePart( FALSE ),										\
+             bInZoomUpdate( FALSE ),											\
+             bMoveIsShift( FALSE ),											\
 -            bNewStartIfMarking( FALSE ),                                    \
              bOldSelection( FALSE )
  
  
 diff --git sc/source/ui/view/tabview2.cxx sc/source/ui/view/tabview2.cxx
-index 72bae06..7dec6f2 100644
+index c63ccc0..24aec8e 100644
 --- sc/source/ui/view/tabview2.cxx
 +++ sc/source/ui/view/tabview2.cxx
 @@ -62,6 +62,7 @@
@@ -293,24 +317,24 @@ index 72bae06..7dec6f2 100644
  #define SC_BLOCKMODE_NONE		0
  #define SC_BLOCKMODE_NORMAL		1
 @@ -178,16 +179,9 @@ void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
- 		InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY );
+         InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY );
  #endif
- 		UpdateSelectionOverlay();
+         UpdateSelectionOverlay();
 -
--		bNewStartIfMarking = FALSE;		// use only once
- 	}
+-        bNewStartIfMarking = FALSE;		// use only once
+     }
  }
  
 -void ScTabView::SetNewStartIfMarking()
 -{
--	bNewStartIfMarking = TRUE;
+-    bNewStartIfMarking = TRUE;
 -}
 -
  void ScTabView::DoneBlockMode( BOOL bContinue )            // Default FALSE
  {
- 	//	Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird,
+     //	Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird,
 @@ -414,6 +408,277 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
- 		aHdrFunc.SetAnchorFlag( FALSE );
+         aHdrFunc.SetAnchorFlag( FALSE );
  }
  
 +void ScTabView::GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY)
@@ -588,40 +612,40 @@ index 72bae06..7dec6f2 100644
  {
      for (USHORT i=0; i<4; i++)
 diff --git sc/source/ui/view/tabview3.cxx sc/source/ui/view/tabview3.cxx
-index 6f559a5..d8392e5 100644
+index 6e59c27..43e2903 100644
 --- sc/source/ui/view/tabview3.cxx
 +++ sc/source/ui/view/tabview3.cxx
 @@ -125,10 +125,7 @@ void ScTabView::ClickCursor( SCCOL nPosX, SCROW nPosY, BOOL bControl )
  {
- 	ScDocument* pDoc = aViewData.GetDocument();
- 	SCTAB nTab = aViewData.GetTabNo();
--	while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab ))		//! ViewData !!!
--		--nPosX;
--	while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab ))
--		--nPosY;
+     ScDocument* pDoc = aViewData.GetDocument();
+     SCTAB nTab = aViewData.GetTabNo();
+-    while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab ))		//! ViewData !!!
+-        --nPosX;
+-    while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab ))
+-        --nPosY;
 +	pDoc->SkipOverlapped(nPosX, nPosY, nTab);
  
- 	BOOL bRefMode = SC_MOD()->IsFormulaMode();
+     BOOL bRefMode = SC_MOD()->IsFormulaMode();
  
 @@ -921,22 +918,36 @@ void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
  
- 	HideAllCursors();
+     HideAllCursors();
  
--	if ( bShift && bNewStartIfMarking && IsBlockMode() )
--	{
--		//	used for ADD selection mode: start a new block from the cursor position
--		DoneBlockMode( TRUE );
--		InitBlockMode( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo(), TRUE );
--	}
+-    if ( bShift && bNewStartIfMarking && IsBlockMode() )
+-    {
+-        //	used for ADD selection mode: start a new block from the cursor position
+-        DoneBlockMode( TRUE );
+-        InitBlockMode( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo(), TRUE );
+-    }
 -
- 		//	aktiven Teil umschalten jetzt in AlignToCursor
+         //	aktiven Teil umschalten jetzt in AlignToCursor
  
- 	AlignToCursor( nCurX, nCurY, eMode );
- 	//!		auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
+     AlignToCursor( nCurX, nCurY, eMode );
+     //!		auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
  
- 	if (bKeepSel)
+     if (bKeepSel)
 +    {    
- 		SetCursor( nCurX, nCurY );		// Markierung stehenlassen
+         SetCursor( nCurX, nCurY );		// Markierung stehenlassen
 +
 +        // If the cursor is in existing selection, it's a cursor movement by 
 +        // ENTER or TAB.  If not, then it's a new selection during ADD
@@ -634,8 +658,8 @@ index 6f559a5..d8392e5 100644
 +            // Cursor not in existing selection.  Start a new selection.
 +            DoneBlockMode(true);
 +    }
- 	else
- 	{
+     else
+     {
 +        if (!bShift)
 +        {
 +            // Remove all marked data on cursor movement unless the Shift is locked.
@@ -644,78 +668,76 @@ index 6f559a5..d8392e5 100644
 +            SetMarkData(aData);
 +        }
 +
- 		BOOL bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
- 		bMoveIsShift = bShift;
- 		pSelEngine->CursorPosChanging( bShift, bControl );
+         BOOL bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
+         bMoveIsShift = bShift;
+         pSelEngine->CursorPosChanging( bShift, bControl );
 @@ -1080,68 +1091,18 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
  
  void ScTabView::MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
  {
--	SCCOL nCurX;
--	SCROW nCurY;
--	aViewData.GetMoveCursor( nCurX,nCurY );
+-    SCCOL nCurX;
+-    SCROW nCurY;
+-    aViewData.GetMoveCursor( nCurX,nCurY );
 -
--	ScSplitPos eWhich = aViewData.GetActivePart();
--	ScHSplitPos eWhichX = WhichH( eWhich );
--	ScVSplitPos eWhichY = WhichV( eWhich );
+-    ScSplitPos eWhich = aViewData.GetActivePart();
+-    ScHSplitPos eWhichX = WhichH( eWhich );
+-    ScVSplitPos eWhichY = WhichV( eWhich );
 -
--	SCsCOL nPageX;
--	SCsROW nPageY;
--	if (nMovX >= 0)
--		nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX;
--	else
--		nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX;
+     SCsCOL nPageX;
+     SCsROW nPageY;
+-    if (nMovX >= 0)
+-        nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX;
+-    else
+-        nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX;
 -
--	if (nMovY >= 0)
--		nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY;
--	else
--		nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY;
+-    if (nMovY >= 0)
+-        nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY;
+-    else
+-        nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY;
 -
--	if (nMovX != 0 && nPageX == 0) nPageX = (nMovX>0) ? 1 : -1;
--	if (nMovY != 0 && nPageY == 0) nPageY = (nMovY>0) ? 1 : -1;
+-    if (nMovX != 0 && nPageX == 0) nPageX = (nMovX>0) ? 1 : -1;
+-    if (nMovY != 0 && nPageY == 0) nPageY = (nMovY>0) ? 1 : -1;
 -
-+    SCsCOL nPageX;
-+    SCsROW nPageY;
 +    GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
- 	MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
+     MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
  }
  
  void ScTabView::MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
  {
--	SCCOL nCurX;
--	SCROW nCurY;
--	aViewData.GetMoveCursor( nCurX,nCurY );
--	SCCOL nNewX = nCurX;
--	SCROW nNewY = nCurY;
+-    SCCOL nCurX;
+-    SCROW nCurY;
+-    aViewData.GetMoveCursor( nCurX,nCurY );
+-    SCCOL nNewX = nCurX;
+-    SCROW nNewY = nCurY;
 -
--	ScDocument* pDoc = aViewData.GetDocument();
--	SCTAB nTab = aViewData.GetTabNo();
+-    ScDocument* pDoc = aViewData.GetDocument();
+-    SCTAB nTab = aViewData.GetTabNo();
 -
--	//	FindAreaPos kennt nur -1 oder 1 als Richtung
+-    //	FindAreaPos kennt nur -1 oder 1 als Richtung
 -
--	SCsCOLROW i;
--	if ( nMovX > 0 )
--		for ( i=0; i<nMovX; i++ )
--			pDoc->FindAreaPos( nNewX, nNewY, nTab,  1,  0 );
--	if ( nMovX < 0 )
--		for ( i=0; i<-nMovX; i++ )
--			pDoc->FindAreaPos( nNewX, nNewY, nTab, -1,  0 );
--	if ( nMovY > 0 )
--		for ( i=0; i<nMovY; i++ )
--			pDoc->FindAreaPos( nNewX, nNewY, nTab,  0,  1 );
--	if ( nMovY < 0 )
--		for ( i=0; i<-nMovY; i++ )
--			pDoc->FindAreaPos( nNewX, nNewY, nTab,  0, -1 );
+-    SCsCOLROW i;
+-    if ( nMovX > 0 )
+-        for ( i=0; i<nMovX; i++ )
+-            pDoc->FindAreaPos( nNewX, nNewY, nTab,  1,  0 );
+-    if ( nMovX < 0 )
+-        for ( i=0; i<-nMovX; i++ )
+-            pDoc->FindAreaPos( nNewX, nNewY, nTab, -1,  0 );
+-    if ( nMovY > 0 )
+-        for ( i=0; i<nMovY; i++ )
+-            pDoc->FindAreaPos( nNewX, nNewY, nTab,  0,  1 );
+-    if ( nMovY < 0 )
+-        for ( i=0; i<-nMovY; i++ )
+-            pDoc->FindAreaPos( nNewX, nNewY, nTab,  0, -1 );
 -
--	if (eMode==SC_FOLLOW_JUMP)					// unten/rechts nicht zuviel grau anzeigen
--	{
--		if (nMovX != 0 && nNewX == MAXCOL)
--			eMode = SC_FOLLOW_LINE;
--		if (nMovY != 0 && nNewY == MAXROW)
--			eMode = SC_FOLLOW_LINE;
--	}
+-    if (eMode==SC_FOLLOW_JUMP)					// unten/rechts nicht zuviel grau anzeigen
+-    {
+-        if (nMovX != 0 && nNewX == MAXCOL)
+-            eMode = SC_FOLLOW_LINE;
+-        if (nMovY != 0 && nNewY == MAXROW)
+-            eMode = SC_FOLLOW_LINE;
+-    }
 -
--	MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
+-    MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
 +    SCsCOL nNewX;
 +    SCsROW nNewY;
 +    GetAreaMoveEndPosition(nMovX, nMovY, eMode, nNewX, nNewY, eMode);
@@ -724,69 +746,69 @@ index 6f559a5..d8392e5 100644
  
  void ScTabView::MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
 @@ -1206,14 +1167,8 @@ void ScTabView::MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode
- 	else if (nMovY>0)
- 		nNewY=nPosY+nAddY;
+     else if (nMovY>0)
+         nNewY=nPosY+nAddY;
  
 -//	aViewData.ResetOldCursor();
- 	aViewData.SetOldCursor( nNewX,nNewY );
+     aViewData.SetOldCursor( nNewX,nNewY );
 -
--	while (pDoc->IsHorOverlapped( nNewX, nNewY, nTab ))
--		--nNewX;
--	while (pDoc->IsVerOverlapped( nNewX, nNewY, nTab ))
--		--nNewY;
+-    while (pDoc->IsHorOverlapped( nNewX, nNewY, nTab ))
+-        --nNewX;
+-    while (pDoc->IsVerOverlapped( nNewX, nNewY, nTab ))
+-        --nNewY;
 -
 +	pDoc->SkipOverlapped(nNewX, nNewY, nTab);
- 	MoveCursorAbs( nNewX, nNewY, eMode, bShift, FALSE, TRUE );
+     MoveCursorAbs( nNewX, nNewY, eMode, bShift, FALSE, TRUE );
  }
  
 @@ -1497,11 +1452,7 @@ void ScTabView::MarkRange( const ScRange& rRange, BOOL bSetCursor, BOOL bContinu
- 		SCCOL nPosX = rRange.aStart.Col();
- 		SCROW nPosY = rRange.aStart.Row();
- 		ScDocument* pDoc = aViewData.GetDocument();
+         SCCOL nPosX = rRange.aStart.Col();
+         SCROW nPosY = rRange.aStart.Row();
+         ScDocument* pDoc = aViewData.GetDocument();
 -
--		while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab ))		//! ViewData !!!
--			--nPosX;
--		while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab ))
--			--nPosY;
+-        while (pDoc->IsHorOverlapped( nPosX, nPosY, nTab ))		//! ViewData !!!
+-            --nPosX;
+-        while (pDoc->IsVerOverlapped( nPosX, nPosY, nTab ))
+-            --nPosY;
 +		pDoc->SkipOverlapped(nPosX, nPosY, nTab);
  
- 		aViewData.ResetOldCursor();
- 		SetCursor( nPosX, nPosY );
+         aViewData.ResetOldCursor();
+         SetCursor( nPosX, nPosY );
 diff --git sc/source/ui/view/tabvwsh3.cxx sc/source/ui/view/tabvwsh3.cxx
-index 81c2e1b..e44e2e0 100644
+index 5bca772..73d4c0d 100644
 --- sc/source/ui/view/tabvwsh3.cxx
 +++ sc/source/ui/view/tabvwsh3.cxx
-@@ -396,10 +396,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
- 					// und Cursor setzen
- 
- 					// zusammengefasste Zellen beruecksichtigen:
--					while ( pDoc->IsHorOverlapped( nCol, nRow, nTab ) )		//! ViewData !!!
--						--nCol;
--					while ( pDoc->IsVerOverlapped( nCol, nRow, nTab ) )
--						--nRow;
+@@ -389,10 +389,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
+                     // und Cursor setzen
+ 
+                     // zusammengefasste Zellen beruecksichtigen:
+-                    while ( pDoc->IsHorOverlapped( nCol, nRow, nTab ) )		//! ViewData !!!
+-                        --nCol;
+-                    while ( pDoc->IsVerOverlapped( nCol, nRow, nTab ) )
+-                        --nRow;
 +                    pDoc->SkipOverlapped(nCol, nRow, nTab);
  
- 					//	Navigator-Aufrufe sind nicht API!!!
+                     //	Navigator-Aufrufe sind nicht API!!!
  
 diff --git sc/source/ui/view/viewdata.cxx sc/source/ui/view/viewdata.cxx
-index 859daea..be4d659 100644
+index 3e2acbc..53117bd 100644
 --- sc/source/ui/view/viewdata.cxx
 +++ sc/source/ui/view/viewdata.cxx
 @@ -1883,12 +1883,11 @@ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
- 	{
- 		//!	public Methode um Position anzupassen
- 
--		BOOL bHOver = FALSE;
--		while (pDoc->IsHorOverlapped( rPosX, rPosY, nTabNo ))
--			{ --rPosX; bHOver=TRUE; }
--		BOOL bVOver = FALSE;
--		while (pDoc->IsVerOverlapped( rPosX, rPosY, nTabNo ))
--			{ --rPosY; bVOver=TRUE; }
+     {
+         //!	public Methode um Position anzupassen
+ 
+-        BOOL bHOver = FALSE;
+-        while (pDoc->IsHorOverlapped( rPosX, rPosY, nTabNo ))
+-            { --rPosX; bHOver=TRUE; }
+-        BOOL bVOver = FALSE;
+-        while (pDoc->IsVerOverlapped( rPosX, rPosY, nTabNo ))
+-            { --rPosY; bVOver=TRUE; }
 +        SCCOL nOrigX = rPosX;
 +        SCROW nOrigY = rPosY;
 +        pDoc->SkipOverlapped(rPosX, rPosY, nTabNo);
 +        bool bHOver = (nOrigX != rPosX);
 +        bool bVOver = (nOrigY != rPosY);
  
- 		if ( bRepair && ( bHOver || bVOver ) )
- 		{
+         if ( bRepair && ( bHOver || bVOver ) )
+         {
commit d4708dff2ab0e6858967626f5d085609c43ed625
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 2 22:13:53 2009 -0400

    Fixed a crasher during multi-range copy-n-paste.
    
    Updated the patch to fix one crasher bug during multi-range copy-n-paste,
    also refactored the code a bit to remove duplicated code blocks.
    (n#509209)
    
    * patches/dev300/calc-multi-range-copy-paste.diff:

diff --git a/patches/dev300/calc-multi-range-copy-paste.diff b/patches/dev300/calc-multi-range-copy-paste.diff
index 7db8a51..d7856d0 100644
--- a/patches/dev300/calc-multi-range-copy-paste.diff
+++ b/patches/dev300/calc-multi-range-copy-paste.diff
@@ -1,5 +1,5 @@
 diff --git sc/inc/cell.hxx sc/inc/cell.hxx
-index e9e2582..0bef331 100644
+index 5454907..b460a31 100644
 --- sc/inc/cell.hxx
 +++ sc/inc/cell.hxx
 @@ -40,6 +40,7 @@
@@ -10,14 +10,14 @@ index e9e2582..0bef331 100644
  #include "formula/grammar.hxx"
  #include "tokenarray.hxx"
  #include "formularesult.hxx"
-@@ -571,6 +572,7 @@ public:
- 	BOOL			IsRangeNameInUse(USHORT nIndex) const;
+@@ -462,6 +463,7 @@ public:
+     BOOL			IsRangeNameInUse(USHORT nIndex) const;
      void            FindRangeNamesInUse(std::set<USHORT>& rIndexes) const;
- 	void 			ReplaceRangeNamesInUse( const ScIndexMap& rMap );
+     void 			ReplaceRangeNamesInUse( const ScIndexMap& rMap );
 +	void 			ReplaceRangeNamesInUse( const ScRangeData::IndexMap& rMap );
- 	BOOL			IsSubTotal() const 						{ return bSubTotal; }
- 	BOOL			IsChanged() const  						{ return bChanged; }
- 	void			ResetChanged()							{ bChanged = FALSE; }
+     BOOL			IsSubTotal() const 						{ return bSubTotal; }
+     BOOL			IsChanged() const  						{ return bChanged; }
+     void			ResetChanged()							{ bChanged = FALSE; }
 diff --git sc/inc/clipparam.hxx sc/inc/clipparam.hxx
 new file mode 100644
 index 0000000..1a46f4c
@@ -115,7 +115,7 @@ index 0000000..1a46f4c
 +
 +#endif
 diff --git sc/inc/column.hxx sc/inc/column.hxx
-index f24c0c8..18cb668 100644
+index 64ac9a0..5b17512 100644
 --- sc/inc/column.hxx
 +++ sc/inc/column.hxx
 @@ -35,6 +35,7 @@
@@ -126,16 +126,16 @@ index f24c0c8..18cb668 100644
  #include <tools/solar.h>
  
  #include <set>
-@@ -300,6 +301,7 @@ public:
- 	BOOL		IsRangeNameInUse(SCROW nRow1, SCROW nRow2, USHORT nIndex) const;
+@@ -301,6 +302,7 @@ public:
+     BOOL		IsRangeNameInUse(SCROW nRow1, SCROW nRow2, USHORT nIndex) const;
      void        FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<USHORT>& rIndexes) const;
- 	void 		ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScIndexMap& rMap );
+     void 		ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScIndexMap& rMap );
 +	void 		ReplaceRangeNamesInUse( SCROW nRow1, SCROW nRow2, const ScRangeData::IndexMap& rMap );
  
- 	const SfxPoolItem*		GetAttr( SCROW nRow, USHORT nWhich ) const;
- 	const ScPatternAttr*	GetPattern( SCROW nRow ) const;
+     const SfxPoolItem*		GetAttr( SCROW nRow, USHORT nWhich ) const;
+     const ScPatternAttr*	GetPattern( SCROW nRow ) const;
 diff --git sc/inc/document.hxx sc/inc/document.hxx
-index d8ce3a5..fbcca0d 100644
+index f392382..87a9343 100644
 --- sc/inc/document.hxx
 +++ sc/inc/document.hxx
 @@ -138,6 +138,8 @@ class ScAutoNameCache;
@@ -147,42 +147,42 @@ index d8ce3a5..fbcca0d 100644
  
  namespace com { namespace sun { namespace star {
      namespace lang {
-@@ -289,6 +291,7 @@ private:
- 	ScFieldEditEngine*	pCacheFieldEditEngine;
+@@ -286,6 +288,7 @@ private:
+     ScFieldEditEngine*	pCacheFieldEditEngine;
  
      ::std::auto_ptr<ScDocProtection> pDocProtection;
 +    ::std::auto_ptr<ScClipParam>     mpClipParam;
  
      ::std::auto_ptr<ScExternalRefManager> pExternalRefMgr;
- 	String              aDocName;                       // opt: Dokumentname
-@@ -311,7 +314,6 @@ private:
+     String              aDocName;                       // opt: Dokumentname
+@@ -307,7 +310,6 @@ private:
  
      sal_uInt32          nRangeOverflowType;             // used in (xml) loading for overflow warnings
  
--	ScRange				aClipRange;
- 	ScRange				aEmbedRange;
- 	ScAddress			aCurTextWidthCalcPos;
- 	ScAddress			aOnlineSpellPos;				// within whole document
-@@ -363,7 +365,6 @@ private:
- 	BOOL				bForcedFormulaPending;
- 	BOOL				bCalculatingFormulaTree;
- 	BOOL				bIsClip;
--	BOOL				bCutMode;
- 	BOOL				bIsUndo;
- 	BOOL				bIsVisible;						// set from view ctor
- 
-@@ -971,6 +972,9 @@ public:
+-    ScRange				aClipRange;
+     ScRange				aEmbedRange;
+     ScAddress			aCurTextWidthCalcPos;
+     ScAddress			aOnlineSpellPos;				// within whole document
+@@ -357,7 +359,6 @@ private:
+     BOOL				bForcedFormulaPending;
+     BOOL				bCalculatingFormulaTree;
+     BOOL				bIsClip;
+-    BOOL				bCutMode;
+     BOOL				bIsUndo;
+     BOOL				bIsVisible;						// set from view ctor
+ 
+@@ -957,6 +958,9 @@ public:
                                  BOOL bKeepScenarioFlags = FALSE,
                                  BOOL bIncludeObjects = FALSE,
                                  BOOL bCloneNoteCaptions = TRUE);
 +    void            CopyToClip(const ScClipParam& rClipParam, ScDocument* pClipDoc, 
 +                               const ScMarkData* pMarks = NULL, bool bKeepScenarioFlags = false,
 +                               bool bIncludeObjects = false, bool bCloneNoteCaptions = true);
- 	void			CopyTabToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- 								SCTAB nTab, ScDocument* pClipDoc = NULL);
- 	void 			CopyBlockFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
-@@ -998,6 +1002,12 @@ public:
- 									BOOL bSkipAttrForEmpty = FALSE,
+     void			CopyTabToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+                                 SCTAB nTab, ScDocument* pClipDoc = NULL);
+     void 			CopyBlockFromClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+@@ -984,6 +988,12 @@ public:
+                                     BOOL bSkipAttrForEmpty = FALSE,
                                      const ScRangeList * pDestRanges = NULL );
  
 +    void            CopyMultiRangeFromClip(const ScAddress& rDestPos, const ScMarkData& rMark, 
@@ -191,35 +191,58 @@ index d8ce3a5..fbcca0d 100644
 +                                           bool bIncludeFiltered = true,
 +                                           bool bSkipAttrForEmpty = false);
 +
- 	void			GetClipArea(SCCOL& nClipX, SCROW& nClipY, BOOL bIncludeFiltered);
- 	void			GetClipStart(SCCOL& nClipX, SCROW& nClipY);
+     void			GetClipArea(SCCOL& nClipX, SCROW& nClipY, BOOL bIncludeFiltered);
+     void			GetClipStart(SCCOL& nClipX, SCROW& nClipY);
  
-@@ -1007,6 +1017,9 @@ public:
+@@ -993,6 +1003,9 @@ public:
  
- 	SC_DLLPUBLIC void			TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsLink );
+     SC_DLLPUBLIC void			TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsLink );
  
 +    ScClipParam&    GetClipParam();
 +    void            SetClipParam(const ScClipParam& rParam);
 +
- 	void			MixDocument( const ScRange& rRange, USHORT nFunction, BOOL bSkipEmpty,
- 									ScDocument* pSrcDoc );
+     void			MixDocument( const ScRange& rRange, USHORT nFunction, BOOL bSkipEmpty,
+                                     ScDocument* pSrcDoc );
  
-@@ -1732,6 +1745,13 @@ private: // CLOOK-Impl-Methoden
- 	void	UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
- 							 const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+@@ -1692,6 +1705,23 @@ public:
+ 
+ private: // CLOOK-Impl-Methoden
+ 
++    /** 
++     * Use this class as a locale variable to merge number formatter from 
++     * another document, and set NULL pointer to pFormatExchangeList when 
++     * done.
++     */
++    class NumFmtMergeHandler
++    {
++    public:
++        explicit NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc);
++        ~NumFmtMergeHandler();
++
++    private:
++        ScDocument* mpDoc;
++    };
++
++    void    MergeNumberFormatter(ScDocument* pSrcDoc);
++
+     void	ImplCreateOptions(); // bei Gelegenheit auf on-demand umstellen?
+     void	ImplDeleteOptions();
+ 
+@@ -1713,6 +1743,12 @@ private: // CLOOK-Impl-Methoden
+     void	UpdateRefAreaLinks( UpdateRefMode eUpdateRefMode,
+                              const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
  
 +    void    CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs);
-+    void    MergeNumberFormatterFromClip(ScDocument* pClipDoc);
 +    void    CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameData& rRangeNames);
 +    void    UpdateRangeNamesInFormulas(
 +        ScClipRangeNameData& rRangeNames, const ScRangeList& rDestRanges, const ScMarkData& rMark,
 +        SCCOL nXw, SCROW nYw);
 +
- 	BOOL	HasPartOfMerged( const ScRange& rRange );
+     BOOL	HasPartOfMerged( const ScRange& rRange );
  
- 	std::map< SCTAB, ScSortParam > mSheetSortParams;
+     std::map< SCTAB, ScSortParam > mSheetSortParams;
 diff --git sc/inc/rangenam.hxx sc/inc/rangenam.hxx
-index c168b00..89830bf 100644
+index 8231cbd..ece1609 100644
 --- sc/inc/rangenam.hxx
 +++ sc/inc/rangenam.hxx
 @@ -37,6 +37,8 @@
@@ -232,49 +255,49 @@ index c168b00..89830bf 100644
  
  class ScDocument;
 @@ -84,6 +86,8 @@ private:
- 	friend class ScRangeName;
- 	ScRangeData( USHORT nIndex );
+     friend class ScRangeName;
+     ScRangeData( USHORT nIndex );
  public:
 +    typedef ::std::map<sal_uInt16, sal_uInt16> IndexMap;
 +
- 	SC_DLLPUBLIC				ScRangeData( ScDocument* pDoc,
- 								 const String& rName,
- 								 const String& rSymbol,
+     SC_DLLPUBLIC				ScRangeData( ScDocument* pDoc,
+                                  const String& rName,
+                                  const String& rSymbol,
 @@ -150,6 +154,7 @@ public:
- 	void			ValidateTabRefs();
+     void			ValidateTabRefs();
  
- 	void			ReplaceRangeNamesInUse( const ScIndexMap& rMap );
+     void			ReplaceRangeNamesInUse( const ScIndexMap& rMap );
 +    void            ReplaceRangeNamesInUse( const IndexMap& rMap );
  
- 	static void		MakeValidName( String& rName );
- 	SC_DLLPUBLIC static BOOL		IsNameValid( const String& rName, ScDocument* pDoc );
+     static void		MakeValidName( String& rName );
+     SC_DLLPUBLIC static BOOL		IsNameValid( const String& rName, ScDocument* pDoc );
 diff --git sc/inc/table.hxx sc/inc/table.hxx
-index 74b743f..93ef44e 100644
+index 734ad3c..b32bb64 100644
 --- sc/inc/table.hxx
 +++ sc/inc/table.hxx
-@@ -297,6 +297,8 @@ public:
- 	void		DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nDelFlag);
- 	void		CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable,
+@@ -292,6 +292,8 @@ public:
+     void		DeleteArea(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, USHORT nDelFlag);
+     void		CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScTable* pTable,
                              BOOL bKeepScenarioFlags, BOOL bCloneNoteCaptions);
 +    void        CopyToClip(const ScRangeList& rRanges, ScTable* pTable, 
 +                           bool bKeepScenarioFlags, bool bCloneNoteCaptions);
- 	void		CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy,
- 								USHORT nInsFlag, BOOL bAsLink, BOOL bSkipAttrForEmpty, ScTable* pTable);
- 	void		StartListeningInArea( SCCOL nCol1, SCROW nRow1,
-@@ -410,6 +412,8 @@ public:
+     void		CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCsCOL nDx, SCsROW nDy,
+                                 USHORT nInsFlag, BOOL bAsLink, BOOL bSkipAttrForEmpty, ScTable* pTable);
+     void		StartListeningInArea( SCCOL nCol1, SCROW nRow1,
+@@ -406,6 +408,8 @@ public:
                                   std::set<USHORT>& rIndexes) const;
- 	void 		ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- 									  const ScIndexMap& rMap );
+     void 		ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+                                       const ScIndexMap& rMap );
 +	void 		ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
 +									  const ScRangeData::IndexMap& rMap );
- 	void		Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- 						ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
- 						double nStepValue, double nMaxValue);
+     void		Fill( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+                         ULONG nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
+                         double nStepValue, double nMaxValue);
 diff --git sc/source/core/data/cell2.cxx sc/source/core/data/cell2.cxx
-index ddd2bef..4c38b39 100644
+index 7e29ed7..c0c17ce 100644
 --- sc/source/core/data/cell2.cxx
 +++ sc/source/core/data/cell2.cxx
-@@ -1323,6 +1323,26 @@ void ScFormulaCell::ReplaceRangeNamesInUse( const ScIndexMap& rMap )
+@@ -1318,6 +1318,26 @@ void ScFormulaCell::ReplaceRangeNamesInUse( const ScIndexMap& rMap )
          CompileTokenArray();
  }
  
@@ -508,11 +531,11 @@ index 0000000..564b04d
 +        ScRangeData::IndexMap::value_type(nOldIndex, nNewIndex));
 +}
 diff --git sc/source/core/data/column.cxx sc/source/core/data/column.cxx
-index c396a27..9e03b31 100644
+index 721a66f..555c3e8 100644
 --- sc/source/core/data/column.cxx
 +++ sc/source/core/data/column.cxx
-@@ -1917,6 +1917,23 @@ void ScColumn::ReplaceRangeNamesInUse(SCROW nRow1, SCROW nRow2,
- 		}
+@@ -1884,6 +1884,23 @@ void ScColumn::ReplaceRangeNamesInUse(SCROW nRow1, SCROW nRow2,
+         }
  }
  
 +void ScColumn::ReplaceRangeNamesInUse(SCROW nRow1, SCROW nRow2,
@@ -535,8 +558,10 @@ index c396a27..9e03b31 100644
  
  void ScColumn::SetDirtyVar()
  {
---- sc/source/core/data/documen2.cxx.old	2009-04-06 20:47:37.000000000 +0200
-+++ sc/source/core/data/documen2.cxx	2009-04-06 20:51:29.000000000 +0200
+diff --git sc/source/core/data/documen2.cxx sc/source/core/data/documen2.cxx
+index db40577..8894d1b 100644
+--- sc/source/core/data/documen2.cxx
++++ sc/source/core/data/documen2.cxx
 @@ -95,6 +95,7 @@
  #include "lookupcache.hxx"
  #include "externalrefmgr.hxx"
@@ -545,27 +570,61 @@ index c396a27..9e03b31 100644
  
  // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and
  // dtor plus helpers are convenient.
-@@ -153,6 +154,7 @@ ScDocument::ScDocument( ScDocumentMode	e
- 		pScriptTypeData( NULL ),
+@@ -153,6 +154,7 @@ ScDocument::ScDocument( ScDocumentMode	eMode,
+         pScriptTypeData( NULL ),
          pCacheFieldEditEngine( NULL ),
          pDocProtection( NULL ),
 +        mpClipParam( NULL ),
          pExternalRefMgr( NULL ),
- 		pViewOptions( NULL ),
- 		pDocOptions( NULL ),
-@@ -181,7 +183,6 @@ ScDocument::ScDocument( ScDocumentMode	e
- 		bForcedFormulaPending( FALSE ),
- 		bCalculatingFormulaTree( FALSE ),
- 		bIsClip( eMode == SCDOCMODE_CLIP ),
--		bCutMode( FALSE ),
- 		bIsUndo( eMode == SCDOCMODE_UNDO ),
- 		bIsVisible( FALSE ),
- 		bIsEmbedded( FALSE ),
+         pViewOptions( NULL ),
+         pDocOptions( NULL ),
+@@ -181,7 +183,6 @@ ScDocument::ScDocument( ScDocumentMode	eMode,
+         bForcedFormulaPending( FALSE ),
+         bCalculatingFormulaTree( FALSE ),
+         bIsClip( eMode == SCDOCMODE_CLIP ),
+-        bCutMode( FALSE ),
+         bIsUndo( eMode == SCDOCMODE_UNDO ),
+         bIsVisible( FALSE ),
+         bIsEmbedded( FALSE ),
+@@ -978,23 +979,18 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
+             bOldAutoCalcSrc = pSrcDoc->GetAutoCalc();
+             pSrcDoc->SetAutoCalc( TRUE );	// falls was berechnet werden muss
+         }
+-        SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
+-        SvNumberFormatter* pOtherFormatter = pSrcDoc->xPoolHelper->GetFormTable();
+-        if (pOtherFormatter && pOtherFormatter != pThisFormatter)
++
+         {
+-            SvNumberFormatterIndexTable* pExchangeList =
+-                     pThisFormatter->MergeFormatter(*(pOtherFormatter));
+-            if (pExchangeList->Count() > 0)
+-                pFormatExchangeList = pExchangeList;
+-        }
+-        nDestPos = Min(nDestPos, (SCTAB)(GetTableCount() - 1));
+-        {   // scope for bulk broadcast
+-            ScBulkBroadcast aBulkBroadcast( pBASM);
+-            pSrcDoc->pTab[nSrcPos]->CopyToTable(0, 0, MAXCOL, MAXROW,
+-                    ( bResultsOnly ? IDF_ALL & ~IDF_FORMULA : IDF_ALL),
+-                    FALSE, pTab[nDestPos] );
++            NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc);
++
++            nDestPos = Min(nDestPos, (SCTAB)(GetTableCount() - 1));
++            {   // scope for bulk broadcast
++                ScBulkBroadcast aBulkBroadcast( pBASM);
++                pSrcDoc->pTab[nSrcPos]->CopyToTable(0, 0, MAXCOL, MAXROW,
++                        ( bResultsOnly ? IDF_ALL & ~IDF_FORMULA : IDF_ALL),
++                        FALSE, pTab[nDestPos] );
++            }
+         }
+-        pFormatExchangeList = NULL;
+         pTab[nDestPos]->SetTabNo(nDestPos);
+ 
+         if ( !bResultsOnly )
 diff --git sc/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
-index 071674b..60c8cd9 100644
+index 6143b5b..03267f7 100644
 --- sc/source/core/data/documen3.cxx
 +++ sc/source/core/data/documen3.cxx
-@@ -80,6 +80,7 @@
+@@ -79,6 +79,7 @@
  #include "listenercalls.hxx"
  #include "svtools/PasswordHelper.hxx"
  #include "tabprotection.hxx"
@@ -573,29 +632,55 @@ index 071674b..60c8cd9 100644
  
  #include <memory>
  
-@@ -868,7 +869,7 @@ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode,
- 		{
- 			ScDocument* pClipDoc = SC_MOD()->GetClipDoc();
- 			if (pClipDoc)
--				pClipDoc->bCutMode = FALSE;
+@@ -890,7 +891,7 @@ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode,
+         {
+             ScDocument* pClipDoc = SC_MOD()->GetClipDoc();
+             if (pClipDoc)
+-                pClipDoc->bCutMode = FALSE;
 +				pClipDoc->GetClipParam().mbCutMode = false;
- 		}
- 	}
+         }
+     }
  }
-@@ -878,7 +879,10 @@ void ScDocument::UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDo
+@@ -900,7 +901,10 @@ void ScDocument::UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDo
  {
- 	DBG_ASSERT(pClipDoc->bIsClip, "UpdateTranspose: kein Clip");
+     DBG_ASSERT(pClipDoc->bIsClip, "UpdateTranspose: kein Clip");
  
--	ScRange aSource = pClipDoc->aClipRange;			// Tab wird noch angepasst
+-    ScRange aSource = pClipDoc->aClipRange;			// Tab wird noch angepasst
 +    ScRange aSource;
 +    ScClipParam& rClipParam = GetClipParam();
 +    if (rClipParam.maRanges.Count())
 +        aSource = *rClipParam.maRanges.First();
- 	ScAddress aDest = rDestPos;
+     ScAddress aDest = rDestPos;
+ 
+     SCTAB nClipTab = 0;
+diff --git sc/source/core/data/documen8.cxx sc/source/core/data/documen8.cxx
+index 2e617d7..8cd34a1 100644
+--- sc/source/core/data/documen8.cxx
++++ sc/source/core/data/documen8.cxx
+@@ -318,20 +318,8 @@ void ScDocument::ModifyStyleSheet( SfxStyleSheetBase& rStyleSheet,
+ void ScDocument::CopyStdStylesFrom( ScDocument* pSrcDoc )
+ {
+     // #b5017505# number format exchange list has to be handled here, too
+-
+-    SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
+-    SvNumberFormatter* pOtherFormatter = pSrcDoc->xPoolHelper->GetFormTable();
+-    if (pOtherFormatter && pOtherFormatter != pThisFormatter)
+-    {
+-        SvNumberFormatterIndexTable* pExchangeList =
+-                pThisFormatter->MergeFormatter(*(pOtherFormatter));
+-        if (pExchangeList->Count() > 0)
+-            pFormatExchangeList = pExchangeList;
+-    }
+-
++    NumFmtMergeHandler aNumFmtMergeHdl(this, pSrcDoc);
+     xPoolHelper->GetStylePool()->CopyStdStylesFrom( pSrcDoc->xPoolHelper->GetStylePool() );
+-
+-    pFormatExchangeList = NULL;
+ }
  
- 	SCTAB nClipTab = 0;
+ //------------------------------------------------------------------------
 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
-index 6a97fb5..2df6897 100644
+index 4366571..e477781 100644
 --- sc/source/core/data/document.cxx
 +++ sc/source/core/data/document.cxx
 @@ -94,6 +94,9 @@
@@ -608,74 +693,71 @@ index 6a97fb5..2df6897 100644
  
  namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
  
-@@ -1258,7 +1261,7 @@ void ScDocument::AddUndoTab( SCTAB nTab1, SCTAB nTab2, BOOL bColInfo, BOOL bRowI
+@@ -1214,7 +1217,7 @@ void ScDocument::AddUndoTab( SCTAB nTab1, SCTAB nTab2, BOOL bColInfo, BOOL bRowI
  void ScDocument::SetCutMode( BOOL bVal )
  {
- 	if (bIsClip)
--		bCutMode = bVal;
+     if (bIsClip)
+-        bCutMode = bVal;
 +        GetClipParam().mbCutMode = bVal;
- 	else
- 	{
- 		DBG_ERROR("SetCutMode without bIsClip");
-@@ -1269,7 +1272,7 @@ void ScDocument::SetCutMode( BOOL bVal )
+     else
+     {
+         DBG_ERROR("SetCutMode without bIsClip");
+@@ -1225,7 +1228,7 @@ void ScDocument::SetCutMode( BOOL bVal )
  BOOL ScDocument::IsCutMode()
  {
- 	if (bIsClip)
--		return bCutMode;
+     if (bIsClip)
+-        return bCutMode;
 +		return GetClipParam().mbCutMode;
- 	else
- 	{
- 		DBG_ERROR("IsCutMode ohne bIsClip");
-@@ -1400,33 +1403,16 @@ void ScDocument::CopyToClip(SCCOL nCol1, SCROW nRow1,
- 			pClipDoc = SC_MOD()->GetClipDoc();
- 		}
+     else
+     {
+         DBG_ERROR("IsCutMode ohne bIsClip");
+@@ -1356,33 +1359,16 @@ void ScDocument::CopyToClip(SCCOL nCol1, SCROW nRow1,
+             pClipDoc = SC_MOD()->GetClipDoc();
+         }
  
 +        ScRange aClipRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
 +        ScClipParam& rClipParam = pClipDoc->GetClipParam();
 +        rClipParam.maRanges.RemoveAll();
 +        rClipParam.maRanges.Append(aClipRange);
- 		pClipDoc->aDocName = aDocName;
--		pClipDoc->aClipRange = ScRange( nCol1,nRow1,0, nCol2,nRow2,0 );
--		pClipDoc->ResetClip( this, pMarks );
--		USHORT i;
+         pClipDoc->aDocName = aDocName;
+-        pClipDoc->aClipRange = ScRange( nCol1,nRow1,0, nCol2,nRow2,0 );
+         pClipDoc->ResetClip( this, pMarks );
+-        USHORT i;
 -        SCTAB j;
--
+ 
 -        std::set<USHORT> aUsedNames;        // indexes of named ranges that are used in the copied cells
 -        for (j = 0; j <= MAXTAB; j++)
 -            if (pTab[j] && pClipDoc->pTab[j])
 -                if ( bAllTabs || !pMarks || pMarks->GetTableSelect(j) )
 -                    pTab[j]->FindRangeNamesInUse( nCol1, nRow1, nCol2, nRow2, aUsedNames );
--
--		pClipDoc->pRangeName->FreeAll();
--		for (i = 0; i < pRangeName->GetCount(); i++)		//! DB-Bereiche Pivot-Bereiche auch !!!
--		{
--			USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
--            bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
--			if (bInUse)
--			{
--				ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
--				if (!pClipDoc->pRangeName->Insert(pData))
--					delete pData;
--				else
--					pData->SetIndex(nIndex);
--			}
--		}
--		for (j = 0; j <= MAXTAB; j++)
-+        pClipDoc->ResetClip( this, pMarks );
-+
 +        CopyRangeNamesToClip(pClipDoc, aClipRange, pMarks, bAllTabs);
-+
+ 
+-        pClipDoc->pRangeName->FreeAll();
+-        for (i = 0; i < pRangeName->GetCount(); i++)		//! DB-Bereiche Pivot-Bereiche auch !!!
+-        {
+-            USHORT nIndex = ((ScRangeData*)((*pRangeName)[i]))->GetIndex();
+-            bool bInUse = ( aUsedNames.find(nIndex) != aUsedNames.end() );
+-            if (bInUse)
+-            {
+-                ScRangeData* pData = new ScRangeData(*((*pRangeName)[i]));
+-                if (!pClipDoc->pRangeName->Insert(pData))
+-                    delete pData;
+-                else
+-                    pData->SetIndex(nIndex);
+-            }
+-        }
+-        for (j = 0; j <= MAXTAB; j++)
 +		for (SCTAB j = 0; j <= MAXTAB; j++)
- 			if (pTab[j] && pClipDoc->pTab[j])
- 				if ( bAllTabs || !pMarks || pMarks->GetTableSelect(j) )
- 				{
-@@ -1441,10 +1427,53 @@ void ScDocument::CopyToClip(SCCOL nCol1, SCROW nRow1,
- 					}
- 				}
- 
--		pClipDoc->bCutMode = bCut;
+             if (pTab[j] && pClipDoc->pTab[j])
+                 if ( bAllTabs || !pMarks || pMarks->GetTableSelect(j) )
+                 {
+@@ -1397,10 +1383,53 @@ void ScDocument::CopyToClip(SCCOL nCol1, SCROW nRow1,
+                     }
+                 }
+ 
+-        pClipDoc->bCutMode = bCut;
 +		pClipDoc->GetClipParam().mbCutMode = bCut;
- 	}
+     }
  }
  
 +void ScDocument::CopyToClip(const ScClipParam& rClipParam, 
@@ -723,53 +805,53 @@ index 6a97fb5..2df6897 100644
 +}
  
  void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
- 								SCCOL nCol2, SCROW nRow2,
-@@ -1460,14 +1486,16 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
- 			pClipDoc = SC_MOD()->GetClipDoc();
- 		}
+                                 SCCOL nCol2, SCROW nRow2,
+@@ -1416,14 +1445,16 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
+             pClipDoc = SC_MOD()->GetClipDoc();
+         }
  
 +        ScClipParam& rClipParam = pClipDoc->GetClipParam();
- 		pClipDoc->aDocName = aDocName;
--		pClipDoc->aClipRange = ScRange( nCol1,nRow1,0, nCol2,nRow2,0 );
+         pClipDoc->aDocName = aDocName;
+-        pClipDoc->aClipRange = ScRange( nCol1,nRow1,0, nCol2,nRow2,0 );
 +        rClipParam.maRanges.RemoveAll();
 +        rClipParam.maRanges.Append(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
- 		pClipDoc->ResetClip( this, nTab );
+         pClipDoc->ResetClip( this, nTab );
  
- 		if (pTab[nTab] && pClipDoc->pTab[nTab])
+         if (pTab[nTab] && pClipDoc->pTab[nTab])
              pTab[nTab]->CopyToClip(nCol1, nRow1, nCol2, nRow2, pClipDoc->pTab[nTab], FALSE, TRUE);
  
--		pClipDoc->bCutMode = FALSE;
-+		pClipDoc->GetClipParam().mbCutMode = false;
- 	}
+-        pClipDoc->bCutMode = FALSE;
++        pClipDoc->GetClipParam().mbCutMode = false;
+     }
  }
  
-@@ -1497,6 +1525,7 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
+@@ -1453,6 +1484,7 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
  
- 		//	Daten
+         //	Daten
  
 +    ScRange aClipRange = GetClipParam().getWholeRange();
- 	if ( ValidRow(aClipRange.aEnd.Row()-aClipRange.aStart.Row()) )
- 	{
- 		for (SCTAB i=0; i<=MAXTAB; i++)
-@@ -1525,10 +1554,8 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
- 				}
- 			}
- 
--		pTransClip->aClipRange = ScRange( 0, 0, aClipRange.aStart.Tab(),
+     if ( ValidRow(aClipRange.aEnd.Row()-aClipRange.aStart.Row()) )
+     {
+         for (SCTAB i=0; i<=MAXTAB; i++)
+@@ -1481,10 +1513,8 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
+                 }
+             }
+ 
+-        pTransClip->aClipRange = ScRange( 0, 0, aClipRange.aStart.Tab(),
 -                static_cast<SCCOL>(aClipRange.aEnd.Row() - aClipRange.aStart.Row()),
 -                static_cast<SCROW>(aClipRange.aEnd.Col() - aClipRange.aStart.Col()),
--									aClipRange.aEnd.Tab() );
+-                                    aClipRange.aEnd.Tab() );
 +        pTransClip->SetClipParam(GetClipParam());
 +        pTransClip->GetClipParam().transpose();
- 	}
- 	else
- 	{
-@@ -1537,9 +1564,173 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
+     }
+     else
+     {
+@@ -1493,9 +1523,184 @@ void ScDocument::TransposeClip( ScDocument* pTransClip, USHORT nFlags, BOOL bAsL
  
- 		//	Dies passiert erst beim Einfuegen...
+         //	Dies passiert erst beim Einfuegen...
  
--	bCutMode = FALSE;
-+	GetClipParam().mbCutMode = false;
+-    bCutMode = FALSE;
++    GetClipParam().mbCutMode = false;
 +}
 +
 +void ScDocument::CopyRangeNamesToClip(ScDocument* pClipDoc, const ScRange& rClipRange, const ScMarkData* pMarks, bool bAllTabs)
@@ -798,10 +880,21 @@ index 6a97fb5..2df6897 100644
 +    }
 +}
 +
-+void ScDocument::MergeNumberFormatterFromClip(ScDocument* pClipDoc)
++ScDocument::NumFmtMergeHandler::NumFmtMergeHandler(ScDocument* pDoc, ScDocument* pSrcDoc) :
++        mpDoc(pDoc)
++{
++    mpDoc->MergeNumberFormatter(pSrcDoc);
++}
++
++ScDocument::NumFmtMergeHandler::~NumFmtMergeHandler()
++{
++    mpDoc->pFormatExchangeList = NULL;
++}
++
++void ScDocument::MergeNumberFormatter(ScDocument* pSrcDoc)
 +{
 +    SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
-+    SvNumberFormatter* pOtherFormatter = pClipDoc->xPoolHelper->GetFormTable();
++    SvNumberFormatter* pOtherFormatter = pSrcDoc->xPoolHelper->GetFormTable();
 +    if (pOtherFormatter && pOtherFormatter != pThisFormatter)
 +    {
 +        SvNumberFormatterIndexTable* pExchangeList =
@@ -922,16 +1015,16 @@ index 6a97fb5..2df6897 100644
 +            nR2 = Min((SCROW)(nR1 + nYw), nRow2);
 +        } while (nR1 <= nRow2);
 +    }
- }
- 
++}
++
 +ScClipParam& ScDocument::GetClipParam()
 +{
 +    if (!mpClipParam.get())
 +        mpClipParam.reset(new ScClipParam);
 +
 +    return *mpClipParam;
-+}
-+
+ }
+ 
 +void ScDocument::SetClipParam(const ScClipParam& rParam)
 +{
 +    mpClipParam.reset(new ScClipParam(rParam));
@@ -939,7 +1032,7 @@ index 6a97fb5..2df6897 100644
  
  BOOL ScDocument::IsClipboardSource() const
  {
-@@ -1639,7 +1830,7 @@ void ScDocument::CopyBlockFromClip( SCCOL nCol1, SCROW nRow1,
+@@ -1595,7 +1800,7 @@ void ScDocument::CopyBlockFromClip( SCCOL nCol1, SCROW nRow1,
                          && ppClipTab[nClipTab + nFollow + 1] )
                      ++nFollow;
  
@@ -948,89 +1041,89 @@ index 6a97fb5..2df6897 100644
                  {
                      BOOL bOldInserting = IsInsertingFromOtherDoc();
                      SetInsertingFromOtherDoc( TRUE);
-@@ -1681,7 +1872,9 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1,
+@@ -1637,7 +1842,9 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1,
          pCBFCP->pClipDoc->GetRowFlagsArray( nFlagTab);
  
- 	SCROW nSourceRow = rClipStartRow;
--	SCROW nSourceEnd = pCBFCP->pClipDoc->aClipRange.aEnd.Row();
+     SCROW nSourceRow = rClipStartRow;
+-    SCROW nSourceEnd = pCBFCP->pClipDoc->aClipRange.aEnd.Row();
 +	SCROW nSourceEnd = 0;
 +    if (pCBFCP->pClipDoc->GetClipParam().maRanges.Count())
 +        nSourceEnd = pCBFCP->pClipDoc->GetClipParam().maRanges.First()->aEnd.Row();
- 	SCROW nDestRow = nRow1;
- 
- 	while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 )
-@@ -1727,67 +1920,11 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
- 			BOOL bOldAutoCalc = GetAutoCalc();
- 			SetAutoCalc( FALSE );	// avoid multiple recalculations
- 
--			SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
--			SvNumberFormatter* pOtherFormatter = pClipDoc->xPoolHelper->GetFormTable();
--			if (pOtherFormatter && pOtherFormatter != pThisFormatter)
--			{
--				SvNumberFormatterIndexTable* pExchangeList =
--						 pThisFormatter->MergeFormatter(*(pOtherFormatter));
--				if (pExchangeList->Count() > 0)
--					pFormatExchangeList = pExchangeList;
--			}
-+            MergeNumberFormatterFromClip(pClipDoc);
- 
--			USHORT nClipRangeNames = pClipDoc->pRangeName->GetCount();
--			// array containing range names which might need update of indices
--			ScRangeData** pClipRangeNames = nClipRangeNames ? new ScRangeData* [nClipRangeNames] : NULL;
--			// the index mapping thereof
--			ScIndexMap aClipRangeMap( nClipRangeNames );
--			BOOL bRangeNameReplace = FALSE;
+     SCROW nDestRow = nRow1;
+ 
+     while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 )
+@@ -1683,67 +1890,11 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
+             BOOL bOldAutoCalc = GetAutoCalc();
+             SetAutoCalc( FALSE );	// avoid multiple recalculations
+ 
+-            SvNumberFormatter* pThisFormatter = xPoolHelper->GetFormTable();
+-            SvNumberFormatter* pOtherFormatter = pClipDoc->xPoolHelper->GetFormTable();
+-            if (pOtherFormatter && pOtherFormatter != pThisFormatter)
+-            {
+-                SvNumberFormatterIndexTable* pExchangeList =
+-                         pThisFormatter->MergeFormatter(*(pOtherFormatter));
+-                if (pExchangeList->Count() > 0)
+-                    pFormatExchangeList = pExchangeList;
+-            }
++            NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
+ 
+-            USHORT nClipRangeNames = pClipDoc->pRangeName->GetCount();
+-            // array containing range names which might need update of indices
+-            ScRangeData** pClipRangeNames = nClipRangeNames ? new ScRangeData* [nClipRangeNames] : NULL;
+-            // the index mapping thereof
+-            ScIndexMap aClipRangeMap( nClipRangeNames );
+-            BOOL bRangeNameReplace = FALSE;
 +            ScClipRangeNameData aClipRangeNames;
 +            CopyRangeNamesFromClip(pClipDoc, aClipRangeNames);
  
--			for (USHORT i = 0; i < nClipRangeNames; i++)		//! DB-Bereiche Pivot-Bereiche auch
--			{
--				/*	Copy only if the name doesn't exist in this document.
--					If it exists we use the already existing name instead,
--					another possibility could be to create new names if
--					documents differ.
--					A proper solution would ask the user how to proceed.
--					The adjustment of the indices in the formulas is done later.
--				*/
+-            for (USHORT i = 0; i < nClipRangeNames; i++)		//! DB-Bereiche Pivot-Bereiche auch
+-            {
+-                /*	Copy only if the name doesn't exist in this document.
+-                    If it exists we use the already existing name instead,
+-                    another possibility could be to create new names if
+-                    documents differ.
+-                    A proper solution would ask the user how to proceed.
+-                    The adjustment of the indices in the formulas is done later.
+-                */
 -                ScRangeData* pClipRangeData = (*pClipDoc->pRangeName)[i];
 -                USHORT k;
 -                if ( pRangeName->SearchName( pClipRangeData->GetName(), k ) )
--				{
--					pClipRangeNames[i] = NULL;	// range name not inserted
+-                {
+-                    pClipRangeNames[i] = NULL;	// range name not inserted
 -                    USHORT nOldIndex = pClipRangeData->GetIndex();
--					USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
--					aClipRangeMap.SetPair( i, nOldIndex, nNewIndex );
--					if ( !bRangeNameReplace )
--						bRangeNameReplace = ( nOldIndex != nNewIndex );
--				}
--				else
--				{
+-                    USHORT nNewIndex = ((*pRangeName)[k])->GetIndex();
+-                    aClipRangeMap.SetPair( i, nOldIndex, nNewIndex );
+-                    if ( !bRangeNameReplace )
+-                        bRangeNameReplace = ( nOldIndex != nNewIndex );
+-                }
+-                else
+-                {
 -                    ScRangeData* pData = new ScRangeData( *pClipRangeData );
--					pData->SetDocument(this);
--					if ( pRangeName->FindIndex( pData->GetIndex() ) )
--						pData->SetIndex(0);		// need new index, done in Insert
--					if ( pRangeName->Insert( pData ) )
--					{
--						pClipRangeNames[i] = pData;
+-                    pData->SetDocument(this);
+-                    if ( pRangeName->FindIndex( pData->GetIndex() ) )
+-                        pData->SetIndex(0);		// need new index, done in Insert
+-                    if ( pRangeName->Insert( pData ) )
+-                    {
+-                        pClipRangeNames[i] = pData;
 -                        USHORT nOldIndex = pClipRangeData->GetIndex();
--						USHORT nNewIndex = pData->GetIndex();
--						aClipRangeMap.SetPair( i, nOldIndex, nNewIndex );
--						if ( !bRangeNameReplace )
--							bRangeNameReplace = ( nOldIndex != nNewIndex );
--					}
--					else
--					{	// must be an overflow
--						delete pData;
--						pClipRangeNames[i] = NULL;
+-                        USHORT nNewIndex = pData->GetIndex();
+-                        aClipRangeMap.SetPair( i, nOldIndex, nNewIndex );
+-                        if ( !bRangeNameReplace )
+-                            bRangeNameReplace = ( nOldIndex != nNewIndex );
+-                    }
+-                    else
+-                    {	// must be an overflow
+-                        delete pData;
+-                        pClipRangeNames[i] = NULL;
 -                        aClipRangeMap.SetPair( i, pClipRangeData->GetIndex(), 0 );
--						bRangeNameReplace = TRUE;
--					}
--				}
--			}
- 			SCCOL nAllCol1 = rDestRange.aStart.Col();
- 			SCROW nAllRow1 = rDestRange.aStart.Row();
- 			SCCOL nAllCol2 = rDestRange.aEnd.Col();
-@@ -1795,17 +1932,18 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
+-                        bRangeNameReplace = TRUE;
+-                    }
+-                }
+-            }
+             SCCOL nAllCol1 = rDestRange.aStart.Col();
+             SCROW nAllRow1 = rDestRange.aStart.Row();
+             SCCOL nAllCol2 = rDestRange.aEnd.Col();
+@@ -1751,17 +1902,18 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
  
              SCCOL nXw = 0;
              SCROW nYw = 0;
@@ -1055,9 +1148,9 @@ index 6a97fb5..2df6897 100644
                      if ( nThisEndX > nXw )
                          nXw = nThisEndX;
                      if ( nThisEndY > nYw )
-@@ -1864,10 +2002,10 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
- 			if (bDoDouble)
- 				ScColumn::bDoubleAlloc = TRUE;
+@@ -1820,10 +1972,10 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
+             if (bDoDouble)
+                 ScColumn::bDoubleAlloc = TRUE;
  
 -            SCCOL nClipStartCol = pClipDoc->aClipRange.aStart.Col();
 -            SCROW nClipStartRow = pClipDoc->aClipRange.aStart.Row();
@@ -1069,7 +1162,7 @@ index 6a97fb5..2df6897 100644
              for (ULONG nRange = 0; nRange < pDestRanges->Count(); ++nRange)
              {
                  const ScRange* pRange = pDestRanges->GetObject( nRange);
-@@ -1918,7 +2056,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
+@@ -1874,7 +2026,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
                          nC2 = Min((SCCOL)(nC1 + nXw), nCol2);
                      } while (nC1 <= nCol2);
                      if (nClipStartRow > nClipEndRow)
@@ -1078,22 +1171,21 @@ index 6a97fb5..2df6897 100644
                      nC1 = nCol1;
                      nC2 = nC1 + nXw;
                      if (nC2 > nCol2)
-@@ -1934,76 +2072,118 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
- 				if (pTab[k] && rMark.GetTableSelect(k))
- 					pTab[k]->DecRecalcLevel();
- 
--			bInsertingFromOtherDoc = FALSE;
--			pFormatExchangeList = NULL;
--			if ( bRangeNameReplace )
--			{
--				// first update all inserted named formulas if they contain other
--				// range names and used indices changed
--				for (USHORT i = 0; i < nClipRangeNames; i++)		//! DB-Bereiche Pivot-Bereiche auch
--				{
--					if ( pClipRangeNames[i] )
--						pClipRangeNames[i]->ReplaceRangeNamesInUse( aClipRangeMap );
--				}
--				// then update the formulas, they might need the just updated range names
+@@ -1891,75 +2043,120 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar
+                     pTab[k]->DecRecalcLevel();
+ 
+             bInsertingFromOtherDoc = FALSE;
+-            pFormatExchangeList = NULL;
+-            if ( bRangeNameReplace )
+-            {
+-                // first update all inserted named formulas if they contain other
+-                // range names and used indices changed
+-                for (USHORT i = 0; i < nClipRangeNames; i++)		//! DB-Bereiche Pivot-Bereiche auch
+-                {
+-                    if ( pClipRangeNames[i] )
+-                        pClipRangeNames[i]->ReplaceRangeNamesInUse( aClipRangeMap );
+-                }
+-                // then update the formulas, they might need the just updated range names
 -                for (ULONG nRange = 0; nRange < pDestRanges->Count(); ++nRange)
 -                {
 -                    const ScRange* pRange = pDestRanges->GetObject( nRange);
@@ -1131,24 +1223,22 @@ index 6a97fb5..2df6897 100644
 -                        nR2 = Min((SCROW)(nR1 + nYw), nRow2);
 -                    } while (nR1 <= nRow2);
 -                }
--			}
--			if ( pClipRangeNames )
--				delete [] pClipRangeNames;
-+            bInsertingFromOtherDoc = FALSE;
-+            pFormatExchangeList = NULL;
+-            }
+-            if ( pClipRangeNames )
+-                delete [] pClipRangeNames;
 +
 +            UpdateRangeNamesInFormulas(aClipRangeNames, *pDestRanges, rMark, nXw, nYw);
 +
- 			// Listener aufbauen nachdem alles inserted wurde
- 			StartListeningFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
- 			// nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden
- 			BroadcastFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
- 			if (bResetCut)
--				pClipDoc->bCutMode = FALSE;
-+				pClipDoc->GetClipParam().mbCutMode = false;
- 			SetAutoCalc( bOldAutoCalc );
- 		}
- 	}
+             // Listener aufbauen nachdem alles inserted wurde
+             StartListeningFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
+             // nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden
+             BroadcastFromClip( nAllCol1, nAllRow1, nAllCol2, nAllRow2, rMark, nInsFlag );
+             if (bResetCut)
+-                pClipDoc->bCutMode = FALSE;
++                pClipDoc->GetClipParam().mbCutMode = false;
+             SetAutoCalc( bOldAutoCalc );
+         }
+     }
  }
  
 +void ScDocument::CopyMultiRangeFromClip(
@@ -1165,7 +1255,7 @@ index 6a97fb5..2df6897 100644
 +    BOOL bOldAutoCalc = GetAutoCalc();
 +    SetAutoCalc( FALSE );   // avoid multiple recalculations
 +
-+    MergeNumberFormatterFromClip(pClipDoc);
++    NumFmtMergeHandler aNumFmtMergeHdl(this, pClipDoc);
 +
 +    ScClipRangeNameData aClipRangeNames;
 +    CopyRangeNamesFromClip(pClipDoc, aClipRangeNames);
@@ -1196,6 +1286,8 @@ index 6a97fb5..2df6897 100644
 +        }
 +    }
 +
++    bInsertingFromOtherDoc = TRUE;  // kein Broadcast/Listener aufbauen bei Insert
++
 +    if (!bSkipAttrForEmpty)
 +    {
 +        sal_uInt16 nDelFlag = IDF_CONTENTS;
@@ -1221,74 +1313,71 @@ index 6a97fb5..2df6897 100644
 +        if (pTab[i] && rMark.GetTableSelect(i))
 +            pTab[i]->DecRecalcLevel();
 +
++    bInsertingFromOtherDoc = FALSE;
++
 +    ScRange aDestRange(rDestPos.Col(), rDestPos.Row(), rDestPos.Tab(), 
 +                       rDestPos.Col()+nCols-1, rDestPos.Row()+nRows-1, rDestPos.Tab());
 +    ScRangeList aRanges;
 +    aRanges.Append(aDestRange);
 +    UpdateRangeNamesInFormulas(aClipRangeNames, aRanges, rMark, nCols-1, nRows-1);
 +
-+    if (bResetCut)
-+        pClipDoc->GetClipParam().mbCutMode = false;
-+    SetAutoCalc( bOldAutoCalc );
-+
 +    // Listener aufbauen nachdem alles inserted wurde
 +    StartListeningFromClip(aDestRange.aStart.Col(), aDestRange.aStart.Row(), 
 +                           aDestRange.aEnd.Col(), aDestRange.aEnd.Row(), rMark, nInsFlag );
 +    // nachdem alle Listener aufgebaut wurden, kann gebroadcastet werden
 +    BroadcastFromClip(aDestRange.aStart.Col(), aDestRange.aStart.Row(), 
 +                      aDestRange.aEnd.Col(), aDestRange.aEnd.Row(), rMark, nInsFlag );
++
++    if (bResetCut)
++        pClipDoc->GetClipParam().mbCutMode = false;
++    SetAutoCalc( bOldAutoCalc );
 +}
  
  void ScDocument::SetClipArea( const ScRange& rArea, BOOL bCut )
  {
- 	if (bIsClip)
- 	{
--		aClipRange = rArea;
--		bCutMode = bCut;
+     if (bIsClip)
+     {
+-        aClipRange = rArea;
+-        bCutMode = bCut;
 +        ScClipParam& rClipParam = GetClipParam();
 +        rClipParam.maRanges.RemoveAll();
 +        rClipParam.maRanges.Append(rArea);
 +        rClipParam.mbCutMode = bCut;
- 	}
- 	else
- 	{
-@@ -2014,34 +2194,54 @@ void ScDocument::SetClipArea( const ScRange& rArea, BOOL bCut )
+     }
+     else
+     {
+@@ -1970,33 +2167,53 @@ void ScDocument::SetClipArea( const ScRange& rArea, BOOL bCut )
  
  void ScDocument::GetClipArea(SCCOL& nClipX, SCROW& nClipY, BOOL bIncludeFiltered)
  {
--	if (bIsClip)
--	{
--		nClipX = aClipRange.aEnd.Col() - aClipRange.aStart.Col();
--
--		if ( bIncludeFiltered )
--			nClipY = aClipRange.aEnd.Row() - aClipRange.aStart.Row();
--		else
--		{
--			//	count non-filtered rows
--			//	count on first used table in clipboard
--			SCTAB nCountTab = 0;
--			while ( nCountTab < MAXTAB && !pTab[nCountTab] )
--				++nCountTab;
+-    if (bIsClip)
+-    {
+-        nClipX = aClipRange.aEnd.Col() - aClipRange.aStart.Col();
++    if (!bIsClip)
++    {    
++        DBG_ERROR("GetClipArea: kein Clip");
++        return;
++    }
+ 
+-        if ( bIncludeFiltered )
+-            nClipY = aClipRange.aEnd.Row() - aClipRange.aStart.Row();
+-        else
+-        {
+-            //	count non-filtered rows
+-            //	count on first used table in clipboard
+-            SCTAB nCountTab = 0;
+-            while ( nCountTab < MAXTAB && !pTab[nCountTab] )
+-                ++nCountTab;
 -
 -            SCROW nResult = GetRowFlagsArray( nCountTab).CountForCondition(
 -                    aClipRange.aStart.Row(), aClipRange.aEnd.Row(),
 -                    CR_FILTERED, 0);
 -
--			if ( nResult > 0 )
--				nClipY = nResult - 1;
--			else
--				nClipY = 0;					// always return at least 1 row
--		}
--	}
--	else
--	{
-+    if (!bIsClip)
-+    {    
- 		DBG_ERROR("GetClipArea: kein Clip");
--	}
-+        return;
-+    }
-+
+-            if ( nResult > 0 )
+-                nClipY = nResult - 1;
+-            else
+-                nClipY = 0;					// always return at least 1 row
+-        }
 +    ScRangeList& rClipRanges = GetClipParam().maRanges;
 +    if (!rClipRanges.Count())
 +        // No clip range.  Bail out.
@@ -1309,14 +1398,15 @@ index 6a97fb5..2df6897 100644
 +            nEndCol = p->aEnd.Col();
 +        if (p->aEnd.Row() < nEndRow)
 +            nEndRow = p->aEnd.Row();
-+    }
+     }
 +
 +    nClipX = nEndCol - nStartCol;
 +
 +    if ( bIncludeFiltered )
 +        nClipY = nEndRow - nStartRow;
-+    else
-+    {
+     else
+     {
+-        DBG_ERROR("GetClipArea: kein Clip");
 +        //	count non-filtered rows
 +        //	count on first used table in clipboard
 +        SCTAB nCountTab = 0;
@@ -1330,28 +1420,27 @@ index 6a97fb5..2df6897 100644
 +            nClipY = nResult - 1;
 +        else
 +            nClipY = 0;					// always return at least 1 row
-+    }
+     }
  }
  
- 
-@@ -2049,8 +2249,12 @@ void ScDocument::GetClipStart(SCCOL& nClipX, SCROW& nClipY)
+@@ -2005,8 +2222,12 @@ void ScDocument::GetClipStart(SCCOL& nClipX, SCROW& nClipY)
  {
- 	if (bIsClip)
- 	{
--		nClipX = aClipRange.aStart.Col();
--		nClipY = aClipRange.aStart.Row();
+     if (bIsClip)
+     {
+-        nClipX = aClipRange.aStart.Col();
+-        nClipY = aClipRange.aStart.Row();
 +        ScRangeList& rClipRanges = GetClipParam().maRanges;
 +        if (rClipRanges.Count())
 +        {
 +            nClipX = rClipRanges.First()->aStart.Col();
 +            nClipY = rClipRanges.First()->aStart.Row();
 +        }
- 	}
- 	else
- 	{
-@@ -2066,8 +2270,12 @@ BOOL ScDocument::HasClipFilteredRows()
- 	while ( nCountTab < MAXTAB && !pTab[nCountTab] )
- 		++nCountTab;
+     }
+     else
+     {
+@@ -2022,8 +2243,12 @@ BOOL ScDocument::HasClipFilteredRows()
+     while ( nCountTab < MAXTAB && !pTab[nCountTab] )
+         ++nCountTab;
  
 -    return GetRowFlagsArray( nCountTab).HasCondition( aClipRange.aStart.Row(),
 -            aClipRange.aEnd.Row(), CR_FILTERED, CR_FILTERED);
@@ -1365,23 +1454,23 @@ index 6a97fb5..2df6897 100644
  
  
 diff --git sc/source/core/data/makefile.mk sc/source/core/data/makefile.mk
-index bd0ded7..2abd0d8 100644
+index 9dfc108..8440ee8 100644
 --- sc/source/core/data/makefile.mk
 +++ sc/source/core/data/makefile.mk
 @@ -56,6 +56,7 @@ SLOFILES =  \
- 	$(SLO)$/bcaslot.obj \
- 	$(SLO)$/cell.obj \
- 	$(SLO)$/cell2.obj \
+     $(SLO)$/bcaslot.obj \
+     $(SLO)$/cell.obj \
+     $(SLO)$/cell2.obj \
 +        $(SLO)$/clipparam.obj \
- 	$(SLO)$/column.obj \
- 	$(SLO)$/column2.obj \
- 	$(SLO)$/column3.obj \
+     $(SLO)$/column.obj \
+     $(SLO)$/column2.obj \
+     $(SLO)$/column3.obj \
 diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
-index d32c1d0..ddd1bbb 100644
+index 460abe1..3b2d3c5 100644
 --- sc/source/core/data/table1.cxx
 +++ sc/source/core/data/table1.cxx
-@@ -1310,6 +1310,16 @@ void ScTable::ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1,
- 	}
+@@ -1303,6 +1303,16 @@ void ScTable::ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1,
+     }
  }
  
 +void ScTable::ReplaceRangeNamesInUse(SCCOL nCol1, SCROW nRow1,
@@ -1398,11 +1487,11 @@ index d32c1d0..ddd1bbb 100644
                      SCCOL /* nStartCol */, SCROW nStartRow, SCCOL& rEndCol, SCROW nEndRow )
  {
 diff --git sc/source/core/data/table2.cxx sc/source/core/data/table2.cxx
-index 2f92042..b92cbf8 100644
+index eec97e2..0ef9cbb 100644
 --- sc/source/core/data/table2.cxx
 +++ sc/source/core/data/table2.cxx
 @@ -367,6 +367,16 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- 	}
+     }
  }
  
 +void ScTable::CopyToClip(const ScRangeList& rRanges, ScTable* pTable, 
@@ -1417,13 +1506,13 @@ index 2f92042..b92cbf8 100644
 +}
  
  void ScTable::CopyFromClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
- 							SCsCOL nDx, SCsROW nDy, USHORT nInsFlag,
+                             SCsCOL nDx, SCsROW nDy, USHORT nInsFlag,
 diff --git sc/source/core/tool/rangenam.cxx sc/source/core/tool/rangenam.cxx
-index d4864aa..b68d44d 100644
+index 6029663..d30a3d5 100644
 --- sc/source/core/tool/rangenam.cxx
 +++ sc/source/core/tool/rangenam.cxx
 @@ -585,6 +585,31 @@ void ScRangeData::ReplaceRangeNamesInUse( const ScIndexMap& rMap )
- 	}
+     }
  }
  
 +void ScRangeData::ReplaceRangeNamesInUse( const IndexMap& rMap )
@@ -1455,35 +1544,37 @@ index d4864aa..b68d44d 100644
  void ScRangeData::ValidateTabRefs()
  {
 diff --git sc/source/ui/inc/viewfunc.hxx sc/source/ui/inc/viewfunc.hxx
-index 051a705..3f99bde 100644
+index 17ad51a..f727fb4 100644
 --- sc/source/ui/inc/viewfunc.hxx
 +++ sc/source/ui/inc/viewfunc.hxx
-@@ -359,6 +359,11 @@ private:
- 	void			PasteRTF( SCCOL nCol, SCROW nStartRow,
- 								const ::com::sun::star::uno::Reference<
- 										::com::sun::star::datatransfer::XTransferable >& rxTransferable );
+@@ -354,6 +354,11 @@ private:
+     void			PasteRTF( SCCOL nCol, SCROW nStartRow,
+                                 const ::com::sun::star::uno::Reference<
+                                         ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
 +    bool            PasteMultiRangesFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
 +                                              bool bSkipEmpty, bool bTranspos, bool bAsLink, bool bAllowDialogs,
 +                                              InsCellCmd eMoveMode, sal_uInt16 nCondFlags, sal_uInt16 nUndoFlags );
 +    void            PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& rMark);
 +
- 	USHORT			GetOptimalColWidth( SCCOL nCol, SCTAB nTab, BOOL bFormula );
+     USHORT			GetOptimalColWidth( SCCOL nCol, SCTAB nTab, BOOL bFormula );
  
- 	void			StartFormatArea();
+     void			StartFormatArea();
 diff --git sc/source/ui/view/cellsh.cxx sc/source/ui/view/cellsh.cxx
-index 53e283c..3c047da 100644
+index ddfa8e9..e782dd2 100644
 --- sc/source/ui/view/cellsh.cxx
 +++ sc/source/ui/view/cellsh.cxx
 @@ -206,7 +206,6 @@ void ScCellShell::GetBlockState( SfxItemSet& rSet )
                  break;
  
- 			case SID_COPY:						// Kopieren
--				bDisable = (!bSimpleArea && eMarkType != SC_MARK_SIMPLE_FILTERED);
- 				// nur wegen Matrix nicht editierbar? Matrix nicht zerreissen
- 				//! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit
- 				//! muss man leben.. wird in Copy-Routine abgefangen, sonst
---- sc/source/ui/view/cellsh1.cxx.old	2009-04-06 20:47:37.000000000 +0200
-+++ sc/source/ui/view/cellsh1.cxx	2009-04-06 20:51:29.000000000 +0200
+             case SID_COPY:						// Kopieren
+-                bDisable = (!bSimpleArea && eMarkType != SC_MARK_SIMPLE_FILTERED);
+                 // nur wegen Matrix nicht editierbar? Matrix nicht zerreissen
+                 //! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit
+                 //! muss man leben.. wird in Copy-Routine abgefangen, sonst
+diff --git sc/source/ui/view/cellsh1.cxx sc/source/ui/view/cellsh1.cxx
+index e297ee8..dfb2928 100644
+--- sc/source/ui/view/cellsh1.cxx
++++ sc/source/ui/view/cellsh1.cxx
 @@ -104,6 +104,7 @@
  #include "dpsave.hxx"
  #include "dpgroup.hxx"      // for ScDPNumGroupInfo
@@ -1492,7 +1583,7 @@ index 53e283c..3c047da 100644
  
  #include "globstr.hrc"
  #include "scui_def.hxx" //CHINA001
-@@ -2251,7 +2252,13 @@ void ScCellShell::PasteFromClipboard( Sc
+@@ -2243,7 +2244,13 @@ void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTa
              pTabViewShell->PasteFromSystem();
          else
          {
@@ -1508,20 +1599,20 @@ index 53e283c..3c047da 100644
                      bShowDialog );		// allow warning dialog
          }
 diff --git sc/source/ui/view/tabvwsh4.cxx sc/source/ui/view/tabvwsh4.cxx
-index 551ce8a..3d49c52 100644
+index 4d3dfc1..0e76555 100644
 --- sc/source/ui/view/tabvwsh4.cxx
 +++ sc/source/ui/view/tabvwsh4.cxx
-@@ -1513,7 +1513,7 @@ BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
- 		//	#51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
- 		//	(Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
- 		KeyFuncType eFunc = aCode.GetFunction();
--		if ( eFunc == KEYFUNC_COPY || eFunc == KEYFUNC_CUT )
+@@ -1506,7 +1506,7 @@ BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
+         //	#51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
+         //	(Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
+         KeyFuncType eFunc = aCode.GetFunction();
+-        if ( eFunc == KEYFUNC_COPY || eFunc == KEYFUNC_CUT )
 +		if ( eFunc == KEYFUNC_CUT )
- 		{
- 			ScRange aDummy;
- 			ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy );
+         {
+             ScRange aDummy;
+             ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy );
 diff --git sc/source/ui/view/viewfun3.cxx sc/source/ui/view/viewfun3.cxx
-index a675074..3f5e578 100644
+index 0a97b2a..31fca76 100644
 --- sc/source/ui/view/viewfun3.cxx
 +++ sc/source/ui/view/viewfun3.cxx
 @@ -210,6 +210,7 @@
@@ -1534,21 +1625,21 @@ index a675074..3f5e578 100644
  
 @@ -310,10 +311,10 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
  
- 	ScRange aRange;
- 	ScMarkType eMarkType = GetViewData()->GetSimpleArea( aRange );
+     ScRange aRange;
+     ScMarkType eMarkType = GetViewData()->GetSimpleArea( aRange );
 +    ScDocument* pDoc = GetViewData()->GetDocument();
 +    ScMarkData& rMark = GetViewData()->GetMarkData();
- 	if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
- 	{
--		ScDocument* pDoc = GetViewData()->GetDocument();
--		ScMarkData& rMark = GetViewData()->GetMarkData();
- 		if ( !pDoc->HasSelectedBlockMatrixFragment(
- 						aRange.aStart.Col(), aRange.aStart.Row(),
- 						aRange.aEnd.Col(),   aRange.aEnd.Row(),
-@@ -380,10 +381,126 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
- 				ErrorMessage(STR_MATRIXFRAGMENTERR);
- 		}
- 	}
+     if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
+     {
+-        ScDocument* pDoc = GetViewData()->GetDocument();
+-        ScMarkData& rMark = GetViewData()->GetMarkData();
+         if ( !pDoc->HasSelectedBlockMatrixFragment(
+                         aRange.aStart.Col(), aRange.aStart.Row(),
+                         aRange.aEnd.Col(),   aRange.aEnd.Row(),
+@@ -380,6 +381,122 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
+                 ErrorMessage(STR_MATRIXFRAGMENTERR);
+         }
+     }
 +    else if (eMarkType == SC_MARK_MULTI)
 +    {
 +        bool bSuccess = false;
@@ -1665,15 +1756,9 @@ index a675074..3f5e578 100644
 +
 +        bDone = bSuccess;
 +    }
- 	else
- 	{
--		if (!bApi)
--			ErrorMessage(STR_NOMULTISELECT);
-+        if (!bApi)
-+            ErrorMessage(STR_NOMULTISELECT);
- 	}
- 
- 	return bDone;
+     else
+     {
+         if (!bApi)
 @@ -743,6 +860,52 @@ BOOL lcl_SelHasAttrib( ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2,
  
  //	internes Paste
@@ -1725,8 +1810,8 @@ index a675074..3f5e578 100644
 +}
 +
  BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
- 									USHORT nFunction, BOOL bSkipEmpty,
- 									BOOL bTranspose, BOOL bAsLink,
+                                     USHORT nFunction, BOOL bSkipEmpty,
+                                     BOOL bTranspose, BOOL bAsLink,
 @@ -768,6 +931,12 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
      // do not copy note captions into undo document
      nUndoFlags |= IDF_NOCAPTIONS;
@@ -1737,40 +1822,40 @@ index a675074..3f5e578 100644
 +            nFlags, pClipDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, bAllowDialogs,
 +            eMoveMode, nContFlags, nUndoFlags);
 +
- 	BOOL bCutMode = pClipDoc->IsCutMode();		// if transposing, take from original clipdoc
- 	BOOL bIncludeFiltered = bCutMode;
+     BOOL bCutMode = pClipDoc->IsCutMode();		// if transposing, take from original clipdoc
+     BOOL bIncludeFiltered = bCutMode;
  
 @@ -996,23 +1165,8 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
- 								SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
- 		if ( bAskIfNotEmpty )
- 		{
--			BOOL bIsEmpty = TRUE;
--			SCTAB nTabCount = pDoc->GetTableCount();
--			for (SCTAB nTab=0; nTab<nTabCount && bIsEmpty; nTab++)
--				if ( aFilteredMark.GetTableSelect(nTab) &&
--						!pDoc->IsBlockEmpty( nTab, aUserRange.aStart.Col(), aUserRange.aStart.Row(),
--												   aUserRange.aEnd.Col(), aUserRange.aEnd.Row() ) )
--					bIsEmpty = FALSE;
+                                 SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
+         if ( bAskIfNotEmpty )
+         {
+-            BOOL bIsEmpty = TRUE;
+-            SCTAB nTabCount = pDoc->GetTableCount();
+-            for (SCTAB nTab=0; nTab<nTabCount && bIsEmpty; nTab++)
+-                if ( aFilteredMark.GetTableSelect(nTab) &&
+-                        !pDoc->IsBlockEmpty( nTab, aUserRange.aStart.Col(), aUserRange.aStart.Row(),
+-                                                   aUserRange.aEnd.Col(), aUserRange.aEnd.Row() ) )
+-                    bIsEmpty = FALSE;
 -
--			if ( !bIsEmpty )
--			{
--				ScReplaceWarnBox aBox( GetViewData()->GetDialogParent() );
--				if ( aBox.Execute() != RET_YES )
--				{
--					//	changing the configuration is within the ScReplaceWarnBox
--					return FALSE;
--				}
--			}
+-            if ( !bIsEmpty )
+-            {
+-                ScReplaceWarnBox aBox( GetViewData()->GetDialogParent() );
+-                if ( aBox.Execute() != RET_YES )
+-                {
+-                    //	changing the configuration is within the ScReplaceWarnBox
+-                    return FALSE;
+-                }
+-            }
 +            if (!lcl_checkDestRangeForOverwrite(aUserRange, pDoc, aFilteredMark, GetViewData()->GetDialogParent()))
 +                return false;
- 		}
- 	}
+         }
+     }
  
-@@ -1298,9 +1452,173 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
- 	// AdjustBlockHeight has already been called above
+@@ -1281,7 +1435,171 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
+     // AdjustBlockHeight has already been called above
  
- 	aModificator.SetDocumentModified();
--	pDocSh->UpdateOle(GetViewData());
+     aModificator.SetDocumentModified();
+-    pDocSh->UpdateOle(GetViewData());
 +    PostPasteFromClip(aUserRange, rMark);
 +	return TRUE;
 +}
@@ -1825,8 +1910,7 @@ index a675074..3f5e578 100644
 +    // the clip size.
 +    ScRange aMarkedRange(rCurPos.Col(), rCurPos.Row(), nTab1, 
 +                         rCurPos.Col()+nColSize-1, rCurPos.Row()+nRowSize-1, nTab2);
- 
--	SelectionChanged();
++
 +    bool bAskIfNotEmpty = 
 +        bAllowDialogs && (nFlags & IDF_CONTENTS) && 
 +        nFunction == PASTE_NOFUNC && SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
@@ -1937,12 +2021,10 @@ index a675074..3f5e578 100644
 +    ScDocShell* pDocSh = pViewData->GetDocShell();
 +    ScDocument* pDoc = pViewData->GetDocument();
 +    pDocSh->UpdateOle(pViewData);
-+
-+    SelectionChanged();
  
-     // #i97876# Spreadsheet data changes are not notified
-     ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
-@@ -1312,7 +1630,7 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
+     SelectionChanged();
+ 
+@@ -1295,7 +1613,7 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
          {
              if ( rMark.GetTableSelect( i ) )
              {
@@ -1951,15 +2033,12 @@ index a675074..3f5e578 100644
                  aChangeRange.aStart.SetTab( i );
                  aChangeRange.aEnd.SetTab( i );
                  aChangeRanges.Append( aChangeRange );
-@@ -1320,11 +1638,8 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
+@@ -1303,8 +1621,6 @@ BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
          }
          pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
      }
 -
--	return TRUE;
+-    return TRUE;
  }
  
--
- //----------------------------------------------------------------------------
- //		D R A G   A N D   D R O P
- //
+ 


More information about the ooo-build-commit mailing list