Files
libreoffice/sc/source/ui/docshell/docsh3.cxx

1388 lines
50 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:07:07 +00:00
*
* Copyright 2008 by Sun Microsystems, Inc.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* $RCSfile: docsh3.cxx,v $
* $Revision: 1.37.32.2 $
2000-09-18 16:07:07 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
2000-09-18 16:07:07 +00:00
// INCLUDE ---------------------------------------------------------------
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/document/XDocumentProperties.hpp>
2000-09-18 16:07:07 +00:00
#include "scitems.hxx"
#include "rangelst.hxx"
#include <svx/flstitem.hxx>
#include <svx/pageitem.hxx>
#include <svx/paperinf.hxx>
#include <svx/postattr.hxx>
//#include <svx/postdlg.hxx>
#include <svx/sizeitem.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/app.hxx>
#include <sfx2/docfile.hxx>
#include <svtools/misccfg.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/printer.hxx>
#include <svtools/ctrltool.hxx>
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
#include <vcl/msgbox.hxx>
#include <unotools/localedatawrapper.hxx>
2000-09-18 16:07:07 +00:00
#include "docsh.hxx"
#include "docshimp.hxx"
2000-09-18 16:07:07 +00:00
#include "scmod.hxx"
#include "tabvwsh.hxx"
#include "viewdata.hxx"
#include "docpool.hxx"
#include "stlpool.hxx"
#include "patattr.hxx"
#include "uiitems.hxx"
#include "hints.hxx"
#include "docoptio.hxx"
#include "viewopti.hxx"
#include "pntlock.hxx"
#include "chgtrack.hxx"
#include "docfunc.hxx"
#include "cell.hxx"
#include "chgviset.hxx"
#include "progress.hxx"
#include "redcom.hxx"
#include "sc.hrc"
2001-05-11 16:09:50 +00:00
#include "inputopt.hxx"
#include "drwlayer.hxx"
#include "inputhdl.hxx"
#include "conflictsdlg.hxx"
#include "globstr.hrc"
2000-09-18 16:07:07 +00:00
#if DEBUG_CHANGETRACK
#include <stdio.h>
#endif // DEBUG_CHANGETRACK
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------
//
// Redraw - Benachrichtigungen
//
void ScDocShell::PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos )
{
// Broadcast( ScEditViewHint( pEditEngine, rCursorPos ) );
// Test: nur aktive ViewShell
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
if (pViewSh && pViewSh->GetViewData()->GetDocShell() == this)
{
ScEditViewHint aHint( pEditEngine, rCursorPos );
pViewSh->Notify( *this, aHint );
}
}
void ScDocShell::PostDataChanged()
{
Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
aDocument.ResetChanged( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB) );
SFX_APP()->Broadcast(SfxSimpleHint( FID_ANYDATACHANGED )); // Navigator
//! Navigator direkt benachrichtigen!
}
void ScDocShell::PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, USHORT nPart,
2000-09-18 16:07:07 +00:00
USHORT nExtFlags )
{
if (!ValidCol(nStartCol)) nStartCol = MAXCOL;
if (!ValidRow(nStartRow)) nStartRow = MAXROW;
if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
if (!ValidRow(nEndRow)) nEndRow = MAXROW;
2000-09-18 16:07:07 +00:00
if ( pPaintLockData )
{
// #i54081# PAINT_EXTRAS still has to be brodcast because it changes the
// current sheet if it's invalid. All other flags added to pPaintLockData.
USHORT nLockPart = nPart & ~PAINT_EXTRAS;
if ( nLockPart )
{
//! nExtFlags ???
pPaintLockData->AddRange( ScRange( nStartCol, nStartRow, nStartTab,
nEndCol, nEndRow, nEndTab ), nLockPart );
}
nPart &= PAINT_EXTRAS; // for broadcasting
if ( !nPart )
return;
2000-09-18 16:07:07 +00:00
}
if (nExtFlags & SC_PF_LINES) // Platz fuer Linien beruecksichtigen
2000-09-18 16:07:07 +00:00
{
//! Abfrage auf versteckte Spalten/Zeilen!
if (nStartCol>0) --nStartCol;
if (nEndCol<MAXCOL) ++nEndCol;
if (nStartRow>0) --nStartRow;
if (nEndRow<MAXROW) ++nEndRow;
}
// um zusammengefasste erweitern
if (nExtFlags & SC_PF_TESTMERGE)
aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nStartTab );
if ( nStartCol != 0 || nEndCol != MAXCOL )
2000-09-18 16:07:07 +00:00
{
// Extend to whole rows if SC_PF_WHOLEROWS is set, or rotated or non-left
// aligned cells are contained (see UpdatePaintExt).
// Special handling for RTL text (#i9731#) is unnecessary now with full
// support of right-aligned text.
if ( ( nExtFlags & SC_PF_WHOLEROWS ) ||
aDocument.HasAttrib( nStartCol,nStartRow,nStartTab,
MAXCOL,nEndRow,nEndTab, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
2000-09-18 16:07:07 +00:00
{
nStartCol = 0;
nEndCol = MAXCOL;
}
}
Broadcast( ScPaintHint( ScRange( nStartCol, nStartRow, nStartTab,
nEndCol, nEndRow, nEndTab ), nPart ) );
if ( nPart & PAINT_GRID )
aDocument.ResetChanged( ScRange(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) );
}
void ScDocShell::PostPaint( const ScRange& rRange, USHORT nPart, USHORT nExtFlags )
{
PostPaint( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(),
nPart, nExtFlags );
}
void ScDocShell::PostPaintGridAll()
{
PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
}
void ScDocShell::PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
2000-09-18 16:07:07 +00:00
{
PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, SC_PF_TESTMERGE );
}
void ScDocShell::PostPaintExtras()
{
PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS );
}
void ScDocShell::UpdatePaintExt( USHORT& rExtFlags, const ScRange& rRange )
{
if ( ( rExtFlags & SC_PF_LINES ) == 0 && aDocument.HasAttrib( rRange, HASATTR_PAINTEXT ) )
{
// If the range contains lines, shadow or conditional formats,
// set SC_PF_LINES to include one extra cell in all directions.
rExtFlags |= SC_PF_LINES;
}
if ( ( rExtFlags & SC_PF_WHOLEROWS ) == 0 &&
( rRange.aStart.Col() != 0 || rRange.aEnd.Col() != MAXCOL ) &&
aDocument.HasAttrib( rRange, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
{
// If the range contains (logically) right- or center-aligned cells,
// or rotated cells, set SC_PF_WHOLEROWS to paint the whole rows.
// This test isn't needed after the cell changes, because it's also
// tested in PostPaint. UpdatePaintExt may later be changed to do this
// only if called before the changes.
rExtFlags |= SC_PF_WHOLEROWS;
}
}
void ScDocShell::UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab )
{
UpdatePaintExt( rExtFlags, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ) );
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------
void ScDocShell::LockPaint_Impl(BOOL bDoc)
2000-09-18 16:07:07 +00:00
{
if ( !pPaintLockData )
2000-09-18 16:07:07 +00:00
pPaintLockData = new ScPaintLockData(0); //! Modus...
pPaintLockData->IncLevel(bDoc);
2000-09-18 16:07:07 +00:00
}
void ScDocShell::UnlockPaint_Impl(BOOL bDoc)
2000-09-18 16:07:07 +00:00
{
if ( pPaintLockData )
{
if ( pPaintLockData->GetLevel(bDoc) )
pPaintLockData->DecLevel(bDoc);
if (!pPaintLockData->GetLevel(!bDoc) && !pPaintLockData->GetLevel(bDoc))
2000-09-18 16:07:07 +00:00
{
// Paint jetzt ausfuehren
ScPaintLockData* pPaint = pPaintLockData;
pPaintLockData = NULL; // nicht weitersammeln
ScRangeListRef xRangeList = pPaint->GetRangeList();
if (xRangeList)
{
USHORT nParts = pPaint->GetParts();
ULONG nCount = xRangeList->Count();
for ( ULONG i=0; i<nCount; i++ )
{
//! nExtFlags ???
ScRange aRange = *xRangeList->GetObject(i);
PostPaint( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab(),
aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab(),
nParts );
}
}
if ( pPaint->GetModified() )
SetDocumentModified();
delete pPaint;
}
}
else
{
2000-09-18 16:07:07 +00:00
DBG_ERROR("UnlockPaint ohne LockPaint");
}
2000-09-18 16:07:07 +00:00
}
void ScDocShell::LockDocument_Impl(USHORT nNew)
{
if (!nDocumentLock)
{
ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
if (pDrawLayer)
pDrawLayer->setLock(TRUE);
}
nDocumentLock = nNew;
}
void ScDocShell::UnlockDocument_Impl(USHORT nNew)
{
nDocumentLock = nNew;
if (!nDocumentLock)
{
ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
if (pDrawLayer)
pDrawLayer->setLock(FALSE);
}
}
USHORT ScDocShell::GetLockCount() const
{
return nDocumentLock;
}
void ScDocShell::SetLockCount(USHORT nNew)
{
if (nNew) // setzen
{
if ( !pPaintLockData )
pPaintLockData = new ScPaintLockData(0); //! Modus...
pPaintLockData->SetLevel(nNew-1, TRUE);
LockDocument_Impl(nNew);
}
else if (pPaintLockData) // loeschen
{
pPaintLockData->SetLevel(0, TRUE); // bei Unlock sofort ausfuehren
UnlockPaint_Impl(TRUE); // jetzt
UnlockDocument_Impl(0);
}
}
void ScDocShell::LockPaint()
{
LockPaint_Impl(FALSE);
}
void ScDocShell::UnlockPaint()
{
UnlockPaint_Impl(FALSE);
}
void ScDocShell::LockDocument()
{
LockPaint_Impl(TRUE);
LockDocument_Impl(nDocumentLock + 1);
}
void ScDocShell::UnlockDocument()
{
if (nDocumentLock)
{
UnlockPaint_Impl(TRUE);
UnlockDocument_Impl(nDocumentLock - 1);
}
else
{
DBG_ERROR("UnlockDocument without LockDocument");
}
}
2000-09-18 16:07:07 +00:00
//------------------------------------------------------------------
void ScDocShell::SetInplace( BOOL bInplace )
{
if (bIsInplace != bInplace)
{
bIsInplace = bInplace;
CalcOutputFactor();
}
}
void ScDocShell::CalcOutputFactor()
{
if (bIsInplace)
{
nPrtToScreenFactor = 1.0; // passt sonst nicht zur inaktiven Darstellung
return;
}
2001-05-11 16:09:50 +00:00
BOOL bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
if (bTextWysiwyg)
{
nPrtToScreenFactor = 1.0;
return;
}
2000-09-18 16:07:07 +00:00
String aTestString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789" ));
long nPrinterWidth = 0;
long nWindowWidth = 0;
const ScPatternAttr* pPattern = (const ScPatternAttr*)&aDocument.GetPool()->
GetDefaultItem(ATTR_PATTERN);
Font aDefFont;
OutputDevice* pRefDev = GetRefDevice();
MapMode aOldMode = pRefDev->GetMapMode();
Font aOldFont = pRefDev->GetFont();
pRefDev->SetMapMode(MAP_PIXEL);
pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pRefDev); // font color doesn't matter here
pRefDev->SetFont(aDefFont);
nPrinterWidth = pRefDev->PixelToLogic( Size( pRefDev->GetTextWidth(aTestString), 0 ), MAP_100TH_MM ).Width();
pRefDev->SetFont(aOldFont);
pRefDev->SetMapMode(aOldMode);
2000-09-18 16:07:07 +00:00
VirtualDevice aVirtWindow( *Application::GetDefaultDevice() );
aVirtWindow.SetMapMode(MAP_PIXEL);
pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here
2000-09-18 16:07:07 +00:00
aVirtWindow.SetFont(aDefFont);
nWindowWidth = aVirtWindow.GetTextWidth(aTestString);
nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS );
if (nPrinterWidth && nWindowWidth)
nPrtToScreenFactor = nPrinterWidth / (double) nWindowWidth;
else
{
DBG_ERROR("GetTextSize gibt 0 ??");
nPrtToScreenFactor = 1.0;
}
}
double ScDocShell::GetOutputFactor() const
{
return nPrtToScreenFactor;
}
//---------------------------------------------------------------------
void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs)
{
// Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions
2000-11-26 12:56:47 +00:00
USHORT nDefLang, nCjkLang, nCtlLang;
2008-12-15 12:01:46 +00:00
BOOL bAutoSpell;
ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell );
2000-09-18 16:07:07 +00:00
ScModule* pScMod = SC_MOD();
ScDocOptions aDocOpt = pScMod->GetDocOptions();
ScViewOptions aViewOpt = pScMod->GetViewOptions();
aDocOpt.SetAutoSpell( bAutoSpell );
// zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges
aDocOpt.SetYear2000( sal::static_int_cast<USHORT>( SFX_APP()->GetMiscConfig()->GetYear2000() ) );
2000-09-18 16:07:07 +00:00
aDocument.SetDocOptions( aDocOpt );
aDocument.SetViewOptions( aViewOpt );
// Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
2000-11-26 12:56:47 +00:00
aDocument.SetLanguage( (LanguageType) nDefLang, (LanguageType) nCjkLang, (LanguageType) nCtlLang );
2000-09-18 16:07:07 +00:00
}
//---------------------------------------------------------------------
Printer* ScDocShell::GetDocumentPrinter() // fuer OLE
{
return aDocument.GetPrinter();
}
SfxPrinter* ScDocShell::GetPrinter(BOOL bCreateIfNotExist)
2000-09-18 16:07:07 +00:00
{
return aDocument.GetPrinter(bCreateIfNotExist);
2000-09-18 16:07:07 +00:00
}
void ScDocShell::UpdateFontList()
{
delete pImpl->pFontList;
// pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
pImpl->pFontList = new FontList( GetRefDevice(), NULL, FALSE ); // FALSE or TRUE???
SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
2000-09-18 16:07:07 +00:00
PutItem( aFontListItem );
CalcOutputFactor();
}
OutputDevice* ScDocShell::GetRefDevice()
{
return aDocument.GetRefDevice();
}
2000-09-18 16:07:07 +00:00
USHORT ScDocShell::SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags )
{
if (nDiffFlags & SFX_PRINTER_PRINTER)
{
if ( aDocument.GetPrinter() != pNewPrinter )
{
aDocument.SetPrinter( pNewPrinter );
aDocument.SetPrintOptions();
// MT: Use UpdateFontList: Will use Printer fonts only if needed!
/*
delete pImpl->pFontList;
pImpl->pFontList = new FontList( pNewPrinter, Application::GetDefaultDevice() );
SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
2000-09-18 16:07:07 +00:00
PutItem( aFontListItem );
CalcOutputFactor();
*/
if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
UpdateFontList();
ScModule* pScMod = SC_MOD();
SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
while (pFrame)
{
SfxViewShell* pSh = pFrame->GetViewShell();
if (pSh && pSh->ISA(ScTabViewShell))
{
ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
ScInputHandler* pInputHdl = pScMod->GetInputHdl(pViewSh);
if (pInputHdl)
pInputHdl->UpdateRefDevice();
}
pFrame = SfxViewFrame::GetNext( *pFrame, this );
}
2000-09-18 16:07:07 +00:00
}
}
else if (nDiffFlags & SFX_PRINTER_JOBSETUP)
{
SfxPrinter* pOldPrinter = aDocument.GetPrinter();
if (pOldPrinter)
{
2000-09-18 16:07:07 +00:00
pOldPrinter->SetJobSetup( pNewPrinter->GetJobSetup() );
// #i6706# Call SetPrinter with the old printer again, so the drawing layer
// RefDevice is set (calling ReformatAllTextObjects and rebuilding charts),
// because the JobSetup (printer device settings) may affect text layout.
aDocument.SetPrinter( pOldPrinter );
CalcOutputFactor(); // also with the new settings
}
2000-09-18 16:07:07 +00:00
}
if (nDiffFlags & SFX_PRINTER_OPTIONS)
{
aDocument.SetPrintOptions(); //! aus neuem Printer ???
}
if (nDiffFlags & (SFX_PRINTER_CHG_ORIENTATION | SFX_PRINTER_CHG_SIZE))
{
String aStyle = aDocument.GetPageStyle( GetCurTab() );
ScStyleSheetPool* pStPl = aDocument.GetStyleSheetPool();
SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStPl->Find(aStyle, SFX_STYLE_FAMILY_PAGE);
if (pStyleSheet)
{
SfxItemSet& rSet = pStyleSheet->GetItemSet();
if (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION)
{
const SvxPageItem& rOldItem = (const SvxPageItem&)rSet.Get(ATTR_PAGE);
BOOL bWasLand = rOldItem.IsLandscape();
BOOL bNewLand = ( pNewPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
if (bNewLand != bWasLand)
{
SvxPageItem aNewItem( rOldItem );
aNewItem.SetLandscape( bNewLand );
rSet.Put( aNewItem );
// Groesse umdrehen
Size aOldSize = ((const SvxSizeItem&)rSet.Get(ATTR_PAGE_SIZE)).GetSize();
Size aNewSize(aOldSize.Height(),aOldSize.Width());
SvxSizeItem aNewSItem(ATTR_PAGE_SIZE,aNewSize);
rSet.Put( aNewSItem );
}
}
if (nDiffFlags & SFX_PRINTER_CHG_SIZE)
{
SvxSizeItem aPaperSizeItem( ATTR_PAGE_SIZE, SvxPaperInfo::GetPaperSize(pNewPrinter) );
rSet.Put( aPaperSizeItem );
}
}
}
PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_ALL);
return 0;
}
//---------------------------------------------------------------------
ScChangeAction* ScDocShell::GetChangeAction( const ScAddress& rPos )
{
ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
if (!pTrack)
return NULL;
SCTAB nTab = rPos.Tab();
2000-09-18 16:07:07 +00:00
const ScChangeAction* pFound = NULL;
const ScChangeAction* pFoundContent = NULL;
const ScChangeAction* pFoundMove = NULL;
long nModified = 0;
const ScChangeAction* pAction = pTrack->GetFirst();
while (pAction)
{
ScChangeActionType eType = pAction->GetType();
//! ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc )...
if ( pAction->IsVisible() && eType != SC_CAT_DELETE_TABS )
{
const ScBigRange& rBig = pAction->GetBigRange();
if ( rBig.aStart.Tab() == nTab )
{
ScRange aRange = rBig.MakeRange();
if ( eType == SC_CAT_DELETE_ROWS )
aRange.aEnd.SetRow( aRange.aStart.Row() );
else if ( eType == SC_CAT_DELETE_COLS )
aRange.aEnd.SetCol( aRange.aStart.Col() );
if ( aRange.In( rPos ) )
{
pFound = pAction; // der letzte gewinnt
switch ( pAction->GetType() )
{
case SC_CAT_CONTENT :
pFoundContent = pAction;
break;
case SC_CAT_MOVE :
pFoundMove = pAction;
break;
default:
{
// added to avoid warnings
}
2000-09-18 16:07:07 +00:00
}
++nModified;
}
}
if ( pAction->GetType() == SC_CAT_MOVE )
{
ScRange aRange =
((const ScChangeActionMove*)pAction)->
GetFromRange().MakeRange();
if ( aRange.In( rPos ) )
{
pFound = pAction;
++nModified;
}
}
}
pAction = pAction->GetNext();
}
return (ScChangeAction*)pFound;
}
void ScDocShell::SetChangeComment( ScChangeAction* pAction, const String& rComment )
{
if (pAction)
{
pAction->SetComment( rComment );
//! Undo ???
SetDocumentModified();
// Dialog-Notify
ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
if (pTrack)
{
ULONG nNumber = pAction->GetActionNumber();
pTrack->NotifyModified( SC_CTM_CHANGE, nNumber, nNumber );
}
}
}
void ScDocShell::ExecuteChangeCommentDialog( ScChangeAction* pAction, Window* pParent,BOOL bPrevNext)
{
if (!pAction) return; // ohne Aktion ist nichts..
String aComment = pAction->GetComment();
String aAuthor = pAction->GetUser();
DateTime aDT = pAction->GetDateTime();
String aDate = ScGlobal::pLocaleData->getDate( aDT );
2000-09-18 16:07:07 +00:00
aDate += ' ';
aDate += ScGlobal::pLocaleData->getTime( aDT, FALSE, FALSE );
2000-09-18 16:07:07 +00:00
SfxItemSet aSet( GetPool(),
SID_ATTR_POSTIT_AUTHOR, SID_ATTR_POSTIT_AUTHOR,
SID_ATTR_POSTIT_DATE, SID_ATTR_POSTIT_DATE,
SID_ATTR_POSTIT_TEXT, SID_ATTR_POSTIT_TEXT,
0 );
aSet.Put( SvxPostItTextItem ( aComment, SID_ATTR_POSTIT_TEXT ) );
aSet.Put( SvxPostItAuthorItem( aAuthor, SID_ATTR_POSTIT_AUTHOR ) );
aSet.Put( SvxPostItDateItem ( aDate, SID_ATTR_POSTIT_DATE ) );
ScRedComDialog* pDlg = new ScRedComDialog( pParent, aSet,this,pAction,bPrevNext);
pDlg->Execute();
delete pDlg;
}
//---------------------------------------------------------------------
void ScDocShell::CompareDocument( ScDocument& rOtherDoc )
{
ScChangeTrack* pTrack = aDocument.GetChangeTrack();
if ( pTrack && pTrack->GetFirst() )
{
//! Changes vorhanden -> Nachfrage ob geloescht werden soll
}
aDocument.EndChangeTracking();
aDocument.StartChangeTracking();
String aOldUser;
pTrack = aDocument.GetChangeTrack();
if ( pTrack )
{
aOldUser = pTrack->GetUser();
// check if comparing to same document
String aThisFile;
const SfxMedium* pThisMed = GetMedium();
if (pThisMed)
aThisFile = pThisMed->GetName();
String aOtherFile;
SfxObjectShell* pOtherSh = rOtherDoc.GetDocumentShell();
if (pOtherSh)
{
const SfxMedium* pOtherMed = pOtherSh->GetMedium();
if (pOtherMed)
aOtherFile = pOtherMed->GetName();
}
BOOL bSameDoc = ( aThisFile == aOtherFile && aThisFile.Len() );
if ( !bSameDoc )
{
// create change actions from comparing with the name of the user
// who last saved the document
// (only if comparing different documents)
using namespace ::com::sun::star;
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
GetModel(), uno::UNO_QUERY_THROW);
uno::Reference<document::XDocumentProperties> xDocProps(
xDPS->getDocumentProperties());
DBG_ASSERT(xDocProps.is(), "no DocumentProperties");
String aDocUser = xDocProps->getModifiedBy();
if ( aDocUser.Len() )
pTrack->SetUser( aDocUser );
}
}
2000-09-18 16:07:07 +00:00
aDocument.CompareDocument( rOtherDoc );
pTrack = aDocument.GetChangeTrack();
if ( pTrack )
pTrack->SetUser( aOldUser );
2000-09-18 16:07:07 +00:00
PostPaintGridAll();
SetDocumentModified();
}
//---------------------------------------------------------------------
//
// Merge (Aenderungen zusammenfuehren)
//
//---------------------------------------------------------------------
inline BOOL lcl_Equal( const ScChangeAction* pA, const ScChangeAction* pB, BOOL bIgnore100Sec )
2000-09-18 16:07:07 +00:00
{
return pA && pB &&
pA->GetActionNumber() == pB->GetActionNumber() &&
pA->GetType() == pB->GetType() &&
pA->GetUser() == pB->GetUser() &&
(bIgnore100Sec ?
pA->GetDateTimeUTC().IsEqualIgnore100Sec( pB->GetDateTimeUTC() ) :
pA->GetDateTimeUTC() == pB->GetDateTimeUTC());
2000-09-18 16:07:07 +00:00
// State nicht vergleichen, falls eine alte Aenderung akzeptiert wurde
}
bool lcl_FindAction( ScDocument* pDoc, const ScChangeAction* pAction, ScDocument* pSearchDoc, const ScChangeAction* pFirstSearchAction, const ScChangeAction* pLastSearchAction, BOOL bIgnore100Sec )
{
if ( !pDoc || !pAction || !pSearchDoc || !pFirstSearchAction || !pLastSearchAction )
{
return false;
}
ULONG nLastSearchAction = pLastSearchAction->GetActionNumber();
const ScChangeAction* pA = pFirstSearchAction;
while ( pA && pA->GetActionNumber() <= nLastSearchAction )
{
if ( pAction->GetType() == pA->GetType() &&
pAction->GetUser() == pA->GetUser() &&
(bIgnore100Sec ?
pAction->GetDateTimeUTC().IsEqualIgnore100Sec( pA->GetDateTimeUTC() ) :
pAction->GetDateTimeUTC() == pA->GetDateTimeUTC() ) &&
pAction->GetBigRange() == pA->GetBigRange() )
{
String aActionDesc;
pAction->GetDescription( aActionDesc, pDoc, TRUE );
String aADesc;
pA->GetDescription( aADesc, pSearchDoc, TRUE );
if ( aActionDesc.Equals( aADesc ) )
{
DBG_ERROR( "lcl_FindAction(): found equal action!" );
return true;
}
}
pA = pA->GetNext();
}
return false;
}
void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheckDuplicates, ULONG nOffset, ScChangeActionMergeMap* pMergeMap, bool bInverseMap )
2000-09-18 16:07:07 +00:00
{
ScTabViewShell* pViewSh = GetBestViewShell( FALSE ); //! Funktionen an die DocShell
2000-09-18 16:07:07 +00:00
if (!pViewSh)
return;
ScChangeTrack* pSourceTrack = rOtherDoc.GetChangeTrack();
if (!pSourceTrack)
return; //! nichts zu tun - Fehlermeldung?
ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
if ( !pThisTrack )
{ // anschalten
aDocument.StartChangeTracking();
pThisTrack = aDocument.GetChangeTrack();
DBG_ASSERT(pThisTrack,"ChangeTracking nicht angeschaltet?");
if ( !bShared )
{
// #51138# visuelles RedLining einschalten
ScChangeViewSettings aChangeViewSet;
aChangeViewSet.SetShowChanges(TRUE);
aDocument.SetChangeViewSettings(aChangeViewSet);
}
2000-09-18 16:07:07 +00:00
}
// #97286# include 100th seconds in compare?
BOOL bIgnore100Sec = !pSourceTrack->IsTime100thSeconds() ||
!pThisTrack->IsTime100thSeconds();
2000-09-18 16:07:07 +00:00
// gemeinsame Ausgangsposition suchen
ULONG nFirstNewNumber = 0;
const ScChangeAction* pSourceAction = pSourceTrack->GetFirst();
const ScChangeAction* pThisAction = pThisTrack->GetFirst();
// skip identical actions
while ( lcl_Equal( pSourceAction, pThisAction, bIgnore100Sec ) )
2000-09-18 16:07:07 +00:00
{
nFirstNewNumber = pSourceAction->GetActionNumber() + 1;
pSourceAction = pSourceAction->GetNext();
pThisAction = pThisAction->GetNext();
}
// pSourceAction und pThisAction zeigen jetzt auf die ersten "eigenen" Aktionen
// Die gemeinsamen Aktionen davor interessieren ueberhaupt nicht
//! Abfrage, ob die Dokumente vor dem Change-Tracking gleich waren !!!
const ScChangeAction* pFirstMergeAction = pSourceAction;
const ScChangeAction* pFirstSearchAction = pThisAction;
// #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
const ScChangeAction* pLastSearchAction = pThisTrack->GetLast();
2000-09-18 16:07:07 +00:00
// MergeChangeData aus den folgenden Aktionen erzeugen
ULONG nNewActionCount = 0;
const ScChangeAction* pCount = pSourceAction;
while ( pCount )
{
if ( bShared || !ScChangeTrack::MergeIgnore( *pCount, nFirstNewNumber ) )
2000-09-18 16:07:07 +00:00
++nNewActionCount;
pCount = pCount->GetNext();
}
if (!nNewActionCount)
return; //! nichts zu tun - Fehlermeldung?
// ab hier kein return mehr
ScProgress aProgress( this,
String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")),
nNewActionCount );
ULONG nLastMergeAction = pSourceTrack->GetLast()->GetActionNumber();
// UpdateReference-Undo, gueltige Referenzen fuer den letzten gemeinsamen Zustand
pSourceTrack->MergePrepare( (ScChangeAction*) pFirstMergeAction, bShared );
2000-09-18 16:07:07 +00:00
// MergeChangeData an alle noch folgenden Aktionen in diesem Dokument anpassen
// -> Referenzen gueltig fuer dieses Dokument
while ( pThisAction )
{
// #i87049# [Collaboration] Conflict between delete row and insert content is not merged correctly
if ( !bShared || !ScChangeTrack::MergeIgnore( *pThisAction, nFirstNewNumber ) )
2000-09-18 16:07:07 +00:00
{
ScChangeActionType eType = pThisAction->GetType();
switch ( eType )
2000-09-18 16:07:07 +00:00
{
case SC_CAT_INSERT_COLS :
case SC_CAT_INSERT_ROWS :
case SC_CAT_INSERT_TABS :
pSourceTrack->AppendInsert( pThisAction->GetBigRange().MakeRange() );
break;
case SC_CAT_DELETE_COLS :
case SC_CAT_DELETE_ROWS :
case SC_CAT_DELETE_TABS :
{
const ScChangeActionDel* pDel = (const ScChangeActionDel*) pThisAction;
if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
{ // deleted Table enthaelt deleted Cols, die nicht
ULONG nStart, nEnd;
pSourceTrack->AppendDeleteRange(
pDel->GetOverAllRange().MakeRange(), NULL, nStart, nEnd );
}
}
break;
case SC_CAT_MOVE :
{
const ScChangeActionMove* pMove = (const ScChangeActionMove*) pThisAction;
pSourceTrack->AppendMove( pMove->GetFromRange().MakeRange(),
pMove->GetBigRange().MakeRange(), NULL );
}
break;
default:
{
// added to avoid warnings
2000-09-18 16:07:07 +00:00
}
}
2000-09-18 16:07:07 +00:00
}
pThisAction = pThisAction->GetNext();
}
LockPaint(); // #i73877# no repainting after each action
2000-09-18 16:07:07 +00:00
// MergeChangeData in das aktuelle Dokument uebernehmen
BOOL bHasRejected = FALSE;
String aOldUser = pThisTrack->GetUser();
pThisTrack->SetUseFixDateTime( TRUE );
ScMarkData& rMarkData = pViewSh->GetViewData()->GetMarkData();
ScMarkData aOldMarkData( rMarkData );
pSourceAction = pFirstMergeAction;
while ( pSourceAction && pSourceAction->GetActionNumber() <= nLastMergeAction )
{
bool bMergeAction = false;
if ( bShared )
{
if ( !bCheckDuplicates || !lcl_FindAction( &rOtherDoc, pSourceAction, &aDocument, pFirstSearchAction, pLastSearchAction, bIgnore100Sec ) )
{
bMergeAction = true;
}
}
else
{
if ( !ScChangeTrack::MergeIgnore( *pSourceAction, nFirstNewNumber ) )
{
bMergeAction = true;
}
}
if ( bMergeAction )
2000-09-18 16:07:07 +00:00
{
ScChangeActionType eSourceType = pSourceAction->GetType();
if ( !bShared && pSourceAction->IsDeletedIn() )
2000-09-18 16:07:07 +00:00
{
//! muss hier noch festgestellt werden, ob wirklich in
//! _diesem_ Dokument geloescht?
// liegt in einem Bereich, der in diesem Dokument geloescht wurde
// -> wird weggelassen
//! ??? Loesch-Aktion rueckgaengig machen ???
//! ??? Aktion irgendwo anders speichern ???
#ifndef PRODUCT
String aValue;
if ( eSourceType == SC_CAT_CONTENT )
((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
ByteString aError( aValue, gsl_getSystemTextEncoding() );
aError += " weggelassen";
DBG_ERROR( aError.GetBuffer() );
#endif
}
else
{
//! Datum/Autor/Kommentar der Source-Aktion uebernehmen!
pThisTrack->SetUser( pSourceAction->GetUser() );
pThisTrack->SetFixDateTimeUTC( pSourceAction->GetDateTimeUTC() );
ULONG nOldActionMax = pThisTrack->GetActionMax();
2000-09-18 16:07:07 +00:00
bool bExecute = true;
2000-09-18 16:07:07 +00:00
ULONG nReject = pSourceAction->GetRejectAction();
if ( nReject )
2000-09-18 16:07:07 +00:00
{
if ( bShared )
2000-09-18 16:07:07 +00:00
{
if ( nReject >= nFirstNewNumber )
{
nReject += nOffset;
}
ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
if ( pOldAction && pOldAction->IsVirgin() )
{
pThisTrack->Reject( pOldAction );
bHasRejected = TRUE;
bExecute = false;
}
}
else
{
// alte Aktion (aus den gemeinsamen) ablehnen
ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
if (pOldAction && pOldAction->GetState() == SC_CAS_VIRGIN)
{
//! was passiert bei Aktionen, die in diesem Dokument accepted worden sind???
//! Fehlermeldung oder was???
//! oder Reject-Aenderung normal ausfuehren
2000-09-18 16:07:07 +00:00
pThisTrack->Reject(pOldAction);
bHasRejected = TRUE; // fuer Paint
}
bExecute = false;
2000-09-18 16:07:07 +00:00
}
}
if ( bExecute )
2000-09-18 16:07:07 +00:00
{
// normal ausfuehren
ScRange aSourceRange = pSourceAction->GetBigRange().MakeRange();
rMarkData.SelectOneTable( aSourceRange.aStart.Tab() );
switch ( eSourceType )
{
case SC_CAT_CONTENT:
{
//! Test, ob es ganz unten im Dokument war, dann automatisches
//! Zeilen-Einfuegen ???
DBG_ASSERT( aSourceRange.aStart == aSourceRange.aEnd, "huch?" );
ScAddress aPos = aSourceRange.aStart;
String aValue;
((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
BYTE eMatrix = MM_NONE;
const ScBaseCell* pCell = ((const ScChangeActionContent*)pSourceAction)->GetNewCell();
if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
2000-09-18 16:07:07 +00:00
eMatrix = ((const ScFormulaCell*)pCell)->GetMatrixFlag();
switch ( eMatrix )
{
case MM_NONE :
pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
break;
case MM_FORMULA :
{
SCCOL nCols;
SCROW nRows;
2000-09-18 16:07:07 +00:00
((const ScFormulaCell*)pCell)->GetMatColsRows( nCols, nRows );
aSourceRange.aEnd.SetCol( aPos.Col() + nCols - 1 );
aSourceRange.aEnd.SetRow( aPos.Row() + nRows - 1 );
aValue.Erase( 0, 1 );
aValue.Erase( aValue.Len()-1, 1 );
GetDocFunc().EnterMatrix( aSourceRange,
NULL, NULL, aValue, FALSE, FALSE,
CWS-TOOLING: integrate CWS frmdlg 2008-12-18 09:13:09 +0100 oj r265667 : merge from odff05 2008-12-18 07:58:16 +0100 oj r265658 : #i94555# patch from <regina>, ODFF: Add GAMMA, CHISQDIST, CHISQINV. Make the 'cumulative' parameter of GAMMADIST optional. Adapt the domain of CHIDIST to allow negative x. Remove the constraint "degrees of freedom < 1.0E5" from CHIDIST and CHIINV. Plus a mechanism to write the now optional parameter of GAMMADIST to PODF and ODFF if omitted, for backwards compatibility. 2008-12-15 14:06:11 +0100 oj r265490 : CWS-TOOLING: rebase CWS frmdlg to trunk@264807 (milestone: DEV300:m37) 2008-12-15 13:55:28 +0100 oj r265488 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:55:07 +0100 oj r265487 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:54:48 +0100 oj r265486 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:54:36 +0100 oj r265485 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:54:24 +0100 oj r265484 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:48:11 +0100 oj r265483 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:31:12 +0100 oj r265479 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:13:58 +0100 oj r265477 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:10:09 +0100 oj r265476 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 13:05:11 +0100 oj r265475 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 10:47:17 +0100 oj r265467 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 10:46:19 +0100 oj r265466 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 10:45:47 +0100 oj r265465 : CWS-TOOLING: do not delete this file, it's needed for 'cws rebase -C' CWS: frmdlg New MWS: DEV300 New milestone: m37 2008-12-15 07:35:07 +0100 oj r265458 : add dependency to formula 2008-12-15 07:34:24 +0100 oj r265457 : add dependency to formula 2008-12-12 13:22:00 +0100 msc r265413 : #i97089# 2008-12-12 13:20:25 +0100 msc r265412 : #i97089# 2008-12-12 12:35:12 +0100 msc r265406 : #i97089# 2008-12-12 12:34:16 +0100 msc r265405 : #i97089# 2008-12-12 12:33:05 +0100 msc r265404 : #i97089# 2008-12-12 12:31:11 +0100 msc r265403 : #i97089# 2008-12-08 11:59:10 +0100 oj r264981 : insert RTL_LOG 2008-12-08 11:50:17 +0100 oj r264980 : some small changes 2008-12-05 12:57:57 +0100 oj r264902 : eof changed 2008-12-05 12:56:46 +0100 oj r264901 : eof changed 2008-12-05 12:28:47 +0100 oj r264899 : wrong var used 2008-12-05 10:08:57 +0100 oj r264890 : token order reversed 2008-12-04 13:49:22 +0100 oc r264843 : #i96688: Adapt autotests because of outsourced functionwizard 2008-12-04 13:45:27 +0100 oc r264842 : #i96688: Adapt autotests because of outsourced functionwizard 2008-12-04 13:42:54 +0100 oc r264841 : #i96688: Adapt autotests because of outsourced functionwizard 2008-12-04 13:37:41 +0100 oc r264840 : #i96688: Adapt autotests because of outsourced functionwizard 2008-12-04 13:34:11 +0100 oc r264839 : #i96688: Adapt autotests because of outsourced functionwizard 2008-12-04 12:35:31 +0100 oj r264835 : new help ids for struct and function tabpage 2008-12-04 12:00:35 +0100 oj r264828 : set explicit help id 2008-12-03 14:53:27 +0100 oj r264786 : #i96845# change ref button 2008-12-03 14:51:49 +0100 oj r264785 : #i96845# change ref button 2008-12-03 08:51:57 +0100 oj r264746 : convert dos to unix lineends 2008-12-03 08:50:45 +0100 oj r264745 : convert dos to unix lineends 2008-12-03 08:50:05 +0100 oj r264744 : convert dos to unix lineends 2008-12-02 12:28:33 +0100 oj r264686 : clear help text when new helpid is set 2008-12-02 12:28:02 +0100 oj r264685 : set help id for listbox category 2008-12-02 07:15:56 +0100 oj r264655 : remove define to auto generate help ids 2008-12-01 14:36:43 +0100 oj r264604 : use temp var 2008-12-01 14:18:31 +0100 oj r264601 : moved ScJumpToken to formula 2008-12-01 14:18:11 +0100 oj r264600 : moved ScJumpToken to formula 2008-12-01 14:14:35 +0100 oj r264599 : moved ScJumpToken from sc 2008-12-01 10:48:51 +0100 oj r264589 : change quickhelptext from Shrink to Select 2008-12-01 10:28:41 +0100 oj r264588 : fix opcode data, has to be Any.Void 2008-11-28 11:16:48 +0100 oj r264532 : add help ids 2008-11-28 10:16:56 +0100 oj r264529 : set help id 2008-11-28 10:16:43 +0100 oj r264528 : set help id 2008-11-26 13:55:04 +0100 oj r264381 : #94535# use of optional instead of deleting a string myself and some small changes 2008-11-26 09:53:20 +0100 oj r264346 : compile error with debug/without debug 2008-11-25 07:41:28 +0100 oj r264271 : put static into the method which make use of them 2008-11-24 08:16:07 +0100 oj r264196 : removed not needed classes for op code 2008-11-24 08:13:44 +0100 oj r264195 : removed not needed classes for op code 2008-11-21 14:05:53 +0100 oj r264135 : make GetOpCode inline 2008-11-21 12:35:27 +0100 oj r264124 : hold symbols 2008-11-20 09:27:27 +0100 oj r264028 : merged code from DEV300_m35 which got lost 2008-11-19 20:42:12 +0100 oj r264022 : more changes for formula dialog remove 2008-11-19 20:37:41 +0100 oj r264021 : removed unused var 2008-11-19 20:35:35 +0100 oj r264020 : some more changes at token 2008-11-19 10:59:47 +0100 oj r263967 : deleted 2008-11-19 10:58:24 +0100 oj r263966 : add forui and for res files 2008-11-18 15:27:36 +0100 oj r263777 : unused para removed 2008-11-18 15:23:23 +0100 oj r263775 : add insert button to add field dlg 2008-11-18 13:39:53 +0100 oj r263764 : enable the formula dialog as well for conditional print as for conditional formatting 2008-11-18 12:03:25 +0100 oj r263760 : rename isRef in IsRef 2008-11-17 11:46:16 +0100 oj r263711 : patches for function handling 2008-11-17 11:36:22 +0100 oj r263710 : add new for forui and res file 2008-11-17 09:21:12 +0100 oj r263704 : patches for some resource for libformula 2008-11-15 12:45:30 +0100 oj r263701 : changes for formula editor extraction 2008-11-07 08:23:27 +0100 oj r263416 : merge from DEV300:m35 2008-11-07 08:22:35 +0100 oj r263415 : merge from DEV300:m35 2008-11-07 08:22:16 +0100 oj r263414 : merge from DEV300:m35 2008-11-07 08:21:41 +0100 oj r263413 : merge from DEV300:m35 2008-11-07 08:21:31 +0100 oj r263412 : merge from DEV300:m35 2008-11-07 08:20:38 +0100 oj r263411 : merge from DEV300:m35 2008-11-07 08:20:00 +0100 oj r263410 : merge from DEV300:m35 2008-11-07 08:18:50 +0100 oj r263409 : merge from DEV300:m35 2008-11-07 08:18:19 +0100 oj r263408 : merge from DEV300:m35 2008-11-07 08:10:27 +0100 oj r263407 : merge from DEV300:m35 2008-10-21 07:43:46 +0200 oj r262560 : some compile errors resolved 2008-10-17 16:40:01 +0200 oj r262291 : dep for 1st target 2008-10-07 10:08:39 +0200 oj r262077 : copy 2008-10-07 09:45:31 +0200 oj r262076 : #i94535# 2008-10-07 09:44:26 +0200 oj r262075 : #i94535# new base class 2008-10-07 09:43:21 +0200 oj r262074 : moved to formula 2008-10-07 09:41:51 +0200 oj r262073 : new images 2008-10-07 09:03:01 +0200 oj r262072 : new ids for formula 2008-10-02 08:46:27 +0200 oj r262024 : #i94535# move the formula compiler to formula 2008-10-02 08:08:54 +0200 oj r262023 : #i94535# 2008-10-02 08:06:28 +0200 oj r262022 : #i94535# 2008-10-02 08:05:52 +0200 oj r262021 : #i94535# 2008-10-01 17:15:29 +0200 oj r262014 : #i94535# 2008-10-01 17:12:40 +0200 oj r262013 : new module formula 2008-10-01 17:04:55 +0200 oj r262012 : #i94535# 2008-10-01 16:49:03 +0200 oj r262010 : #i94535# 2008-10-01 16:46:59 +0200 oj r262009 : #i94535#
2009-01-08 10:47:13 +00:00
formula::FormulaGrammar::GRAM_DEFAULT );
2000-09-18 16:07:07 +00:00
}
break;
case MM_REFERENCE : // do nothing
break;
case MM_FAKE :
DBG_WARNING( "MergeDocument: MatrixFlag MM_FAKE" );
pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
break;
default:
DBG_ERROR( "MergeDocument: unknown MatrixFlag" );
}
}
break;
case SC_CAT_INSERT_TABS :
{
String aName;
aDocument.CreateValidTabName( aName );
GetDocFunc().InsertTable( aSourceRange.aStart.Tab(), aName, TRUE, FALSE );
}
break;
case SC_CAT_INSERT_ROWS:
CWS-TOOLING: integrate CWS calc47 2008-12-10 20:38:34 +0100 oc r265231 : #i97115# 2008-12-09 14:19:59 +0100 oc r265084 : #i96939# 2008-12-09 11:55:29 +0100 oc r265073 : #i97061# 2008-12-09 11:37:05 +0100 oc r265067 : #i97061# 2008-12-09 11:31:49 +0100 oc r265066 : #i97061# 2008-12-09 11:30:30 +0100 oc r265065 : #i97061# 2008-12-04 17:13:43 +0100 er r264859 : DBG_ERROR needs semicolon 2008-12-04 02:34:13 +0100 er r264811 : unxsols4 needs to be compiled with exceptions when using STL 2008-12-04 02:24:30 +0100 er r264810 : WaE unxsols4: ScZoomSliderWnd::Update hides the function Window::Update() 2008-12-04 01:40:22 +0100 er r264809 : DBG_ASSERT needs semicolon 2008-12-03 11:00:55 +0100 er r264753 : CWS-TOOLING: rebase CWS calc47 to trunk@264325 (milestone: DEV300:m36) 2008-10-31 12:30:09 +0100 nn r262863 : #i90362# call CheckNeedsRepaint in UpdateFormulas 2008-10-29 14:49:48 +0100 nn r262802 : #i88521# initialization order (gcc warning) 2008-10-29 12:31:38 +0100 nn r262782 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:31:00 +0100 nn r262781 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:28:45 +0100 nn r262780 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-28 17:01:37 +0100 nn r262756 : resolve gcc warnings 2008-10-28 13:46:07 +0100 nn r262742 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-28 13:45:44 +0100 nn r262741 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-27 20:55:51 +0100 nn r262689 : #i44349# refresh auto filter flags in ScUndoDragDrop::Redo (patch from gaozm) 2008-10-27 20:40:06 +0100 nn r262688 : #i4517# rename sheet with double click (patch from kohei) 2008-10-27 20:28:55 +0100 nn r262687 : #i20491# ensure stable sorting (patch from maoyg) 2008-10-27 20:13:19 +0100 nn r262686 : #i22758# direct sort (toolbar buttons): detect headers (patch from maoyg) 2008-10-27 19:42:51 +0100 nn r262685 : #i7277# default for sorting is cursor column (patch from maoyg) 2008-10-27 19:18:57 +0100 nn r262684 : #i7088# insert/delete columns/rows across selected sheets (patch from maoyg) 2008-10-27 18:59:43 +0100 nn r262683 : #i86856# show formula syntax in tip help (patch from maoyg) 2008-10-27 18:30:45 +0100 nn r262682 : #i89145# scroll wheel handling in page preview (patch from maoyg) 2008-10-27 18:03:10 +0100 nn r262681 : #i85226# take care of subtotal formulas in ScUndoQuery::Undo (patch from gaozm) 2008-10-27 17:41:16 +0100 nn r262680 : #i88437# add zoom slider in status bar also for Calc (patch from maoyg) 2008-10-27 15:53:52 +0100 nn r262678 : #i88467# undo for page margins/column widths in page preview (patch from maoyg)
2008-12-11 08:36:38 +00:00
GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSROWS, TRUE, FALSE );
2000-09-18 16:07:07 +00:00
break;
case SC_CAT_INSERT_COLS:
CWS-TOOLING: integrate CWS calc47 2008-12-10 20:38:34 +0100 oc r265231 : #i97115# 2008-12-09 14:19:59 +0100 oc r265084 : #i96939# 2008-12-09 11:55:29 +0100 oc r265073 : #i97061# 2008-12-09 11:37:05 +0100 oc r265067 : #i97061# 2008-12-09 11:31:49 +0100 oc r265066 : #i97061# 2008-12-09 11:30:30 +0100 oc r265065 : #i97061# 2008-12-04 17:13:43 +0100 er r264859 : DBG_ERROR needs semicolon 2008-12-04 02:34:13 +0100 er r264811 : unxsols4 needs to be compiled with exceptions when using STL 2008-12-04 02:24:30 +0100 er r264810 : WaE unxsols4: ScZoomSliderWnd::Update hides the function Window::Update() 2008-12-04 01:40:22 +0100 er r264809 : DBG_ASSERT needs semicolon 2008-12-03 11:00:55 +0100 er r264753 : CWS-TOOLING: rebase CWS calc47 to trunk@264325 (milestone: DEV300:m36) 2008-10-31 12:30:09 +0100 nn r262863 : #i90362# call CheckNeedsRepaint in UpdateFormulas 2008-10-29 14:49:48 +0100 nn r262802 : #i88521# initialization order (gcc warning) 2008-10-29 12:31:38 +0100 nn r262782 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:31:00 +0100 nn r262781 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:28:45 +0100 nn r262780 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-28 17:01:37 +0100 nn r262756 : resolve gcc warnings 2008-10-28 13:46:07 +0100 nn r262742 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-28 13:45:44 +0100 nn r262741 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-27 20:55:51 +0100 nn r262689 : #i44349# refresh auto filter flags in ScUndoDragDrop::Redo (patch from gaozm) 2008-10-27 20:40:06 +0100 nn r262688 : #i4517# rename sheet with double click (patch from kohei) 2008-10-27 20:28:55 +0100 nn r262687 : #i20491# ensure stable sorting (patch from maoyg) 2008-10-27 20:13:19 +0100 nn r262686 : #i22758# direct sort (toolbar buttons): detect headers (patch from maoyg) 2008-10-27 19:42:51 +0100 nn r262685 : #i7277# default for sorting is cursor column (patch from maoyg) 2008-10-27 19:18:57 +0100 nn r262684 : #i7088# insert/delete columns/rows across selected sheets (patch from maoyg) 2008-10-27 18:59:43 +0100 nn r262683 : #i86856# show formula syntax in tip help (patch from maoyg) 2008-10-27 18:30:45 +0100 nn r262682 : #i89145# scroll wheel handling in page preview (patch from maoyg) 2008-10-27 18:03:10 +0100 nn r262681 : #i85226# take care of subtotal formulas in ScUndoQuery::Undo (patch from gaozm) 2008-10-27 17:41:16 +0100 nn r262680 : #i88437# add zoom slider in status bar also for Calc (patch from maoyg) 2008-10-27 15:53:52 +0100 nn r262678 : #i88467# undo for page margins/column widths in page preview (patch from maoyg)
2008-12-11 08:36:38 +00:00
GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSCOLS, TRUE, FALSE );
2000-09-18 16:07:07 +00:00
break;
case SC_CAT_DELETE_TABS :
GetDocFunc().DeleteTable( aSourceRange.aStart.Tab(), TRUE, FALSE );
break;
case SC_CAT_DELETE_ROWS:
{
const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
if ( pDel->IsTopDelete() )
{
aSourceRange = pDel->GetOverAllRange().MakeRange();
CWS-TOOLING: integrate CWS calc47 2008-12-10 20:38:34 +0100 oc r265231 : #i97115# 2008-12-09 14:19:59 +0100 oc r265084 : #i96939# 2008-12-09 11:55:29 +0100 oc r265073 : #i97061# 2008-12-09 11:37:05 +0100 oc r265067 : #i97061# 2008-12-09 11:31:49 +0100 oc r265066 : #i97061# 2008-12-09 11:30:30 +0100 oc r265065 : #i97061# 2008-12-04 17:13:43 +0100 er r264859 : DBG_ERROR needs semicolon 2008-12-04 02:34:13 +0100 er r264811 : unxsols4 needs to be compiled with exceptions when using STL 2008-12-04 02:24:30 +0100 er r264810 : WaE unxsols4: ScZoomSliderWnd::Update hides the function Window::Update() 2008-12-04 01:40:22 +0100 er r264809 : DBG_ASSERT needs semicolon 2008-12-03 11:00:55 +0100 er r264753 : CWS-TOOLING: rebase CWS calc47 to trunk@264325 (milestone: DEV300:m36) 2008-10-31 12:30:09 +0100 nn r262863 : #i90362# call CheckNeedsRepaint in UpdateFormulas 2008-10-29 14:49:48 +0100 nn r262802 : #i88521# initialization order (gcc warning) 2008-10-29 12:31:38 +0100 nn r262782 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:31:00 +0100 nn r262781 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:28:45 +0100 nn r262780 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-28 17:01:37 +0100 nn r262756 : resolve gcc warnings 2008-10-28 13:46:07 +0100 nn r262742 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-28 13:45:44 +0100 nn r262741 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-27 20:55:51 +0100 nn r262689 : #i44349# refresh auto filter flags in ScUndoDragDrop::Redo (patch from gaozm) 2008-10-27 20:40:06 +0100 nn r262688 : #i4517# rename sheet with double click (patch from kohei) 2008-10-27 20:28:55 +0100 nn r262687 : #i20491# ensure stable sorting (patch from maoyg) 2008-10-27 20:13:19 +0100 nn r262686 : #i22758# direct sort (toolbar buttons): detect headers (patch from maoyg) 2008-10-27 19:42:51 +0100 nn r262685 : #i7277# default for sorting is cursor column (patch from maoyg) 2008-10-27 19:18:57 +0100 nn r262684 : #i7088# insert/delete columns/rows across selected sheets (patch from maoyg) 2008-10-27 18:59:43 +0100 nn r262683 : #i86856# show formula syntax in tip help (patch from maoyg) 2008-10-27 18:30:45 +0100 nn r262682 : #i89145# scroll wheel handling in page preview (patch from maoyg) 2008-10-27 18:03:10 +0100 nn r262681 : #i85226# take care of subtotal formulas in ScUndoQuery::Undo (patch from gaozm) 2008-10-27 17:41:16 +0100 nn r262680 : #i88437# add zoom slider in status bar also for Calc (patch from maoyg) 2008-10-27 15:53:52 +0100 nn r262678 : #i88467# undo for page margins/column widths in page preview (patch from maoyg)
2008-12-11 08:36:38 +00:00
GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELROWS, TRUE, FALSE );
2000-09-18 16:07:07 +00:00
}
}
break;
case SC_CAT_DELETE_COLS:
{
const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
{ // deleted Table enthaelt deleted Cols, die nicht
aSourceRange = pDel->GetOverAllRange().MakeRange();
CWS-TOOLING: integrate CWS calc47 2008-12-10 20:38:34 +0100 oc r265231 : #i97115# 2008-12-09 14:19:59 +0100 oc r265084 : #i96939# 2008-12-09 11:55:29 +0100 oc r265073 : #i97061# 2008-12-09 11:37:05 +0100 oc r265067 : #i97061# 2008-12-09 11:31:49 +0100 oc r265066 : #i97061# 2008-12-09 11:30:30 +0100 oc r265065 : #i97061# 2008-12-04 17:13:43 +0100 er r264859 : DBG_ERROR needs semicolon 2008-12-04 02:34:13 +0100 er r264811 : unxsols4 needs to be compiled with exceptions when using STL 2008-12-04 02:24:30 +0100 er r264810 : WaE unxsols4: ScZoomSliderWnd::Update hides the function Window::Update() 2008-12-04 01:40:22 +0100 er r264809 : DBG_ASSERT needs semicolon 2008-12-03 11:00:55 +0100 er r264753 : CWS-TOOLING: rebase CWS calc47 to trunk@264325 (milestone: DEV300:m36) 2008-10-31 12:30:09 +0100 nn r262863 : #i90362# call CheckNeedsRepaint in UpdateFormulas 2008-10-29 14:49:48 +0100 nn r262802 : #i88521# initialization order (gcc warning) 2008-10-29 12:31:38 +0100 nn r262782 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:31:00 +0100 nn r262781 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-29 12:28:45 +0100 nn r262780 : #i88521# toolbar entry for scaling factor in page preview (patch from maoyg) 2008-10-28 17:01:37 +0100 nn r262756 : resolve gcc warnings 2008-10-28 13:46:07 +0100 nn r262742 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-28 13:45:44 +0100 nn r262741 : #i9709# always use system encoding for DDE (patch from rail) 2008-10-27 20:55:51 +0100 nn r262689 : #i44349# refresh auto filter flags in ScUndoDragDrop::Redo (patch from gaozm) 2008-10-27 20:40:06 +0100 nn r262688 : #i4517# rename sheet with double click (patch from kohei) 2008-10-27 20:28:55 +0100 nn r262687 : #i20491# ensure stable sorting (patch from maoyg) 2008-10-27 20:13:19 +0100 nn r262686 : #i22758# direct sort (toolbar buttons): detect headers (patch from maoyg) 2008-10-27 19:42:51 +0100 nn r262685 : #i7277# default for sorting is cursor column (patch from maoyg) 2008-10-27 19:18:57 +0100 nn r262684 : #i7088# insert/delete columns/rows across selected sheets (patch from maoyg) 2008-10-27 18:59:43 +0100 nn r262683 : #i86856# show formula syntax in tip help (patch from maoyg) 2008-10-27 18:30:45 +0100 nn r262682 : #i89145# scroll wheel handling in page preview (patch from maoyg) 2008-10-27 18:03:10 +0100 nn r262681 : #i85226# take care of subtotal formulas in ScUndoQuery::Undo (patch from gaozm) 2008-10-27 17:41:16 +0100 nn r262680 : #i88437# add zoom slider in status bar also for Calc (patch from maoyg) 2008-10-27 15:53:52 +0100 nn r262678 : #i88467# undo for page margins/column widths in page preview (patch from maoyg)
2008-12-11 08:36:38 +00:00
GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELCOLS, TRUE, FALSE );
2000-09-18 16:07:07 +00:00
}
}
break;
case SC_CAT_MOVE :
{
const ScChangeActionMove* pMove = (const ScChangeActionMove*) pSourceAction;
ScRange aFromRange( pMove->GetFromRange().MakeRange() );
GetDocFunc().MoveBlock( aFromRange,
aSourceRange.aStart, TRUE, TRUE, FALSE, FALSE );
}
break;
default:
{
// added to avoid warnings
}
2000-09-18 16:07:07 +00:00
}
}
const String& rComment = pSourceAction->GetComment();
if ( rComment.Len() )
{
ScChangeAction* pAct = pThisTrack->GetLast();
if ( pAct && pAct->GetActionNumber() > nOldActionMax )
2000-09-18 16:07:07 +00:00
pAct->SetComment( rComment );
#ifndef PRODUCT
else
DBG_ERROR( "MergeDocument: wohin mit dem Kommentar?!?" );
#endif
}
// Referenzen anpassen
pSourceTrack->MergeOwn( (ScChangeAction*) pSourceAction, nFirstNewNumber, bShared );
// merge action state
if ( bShared && !pSourceAction->IsRejected() )
{
ScChangeAction* pAct = pThisTrack->GetLast();
if ( pAct && pAct->GetActionNumber() > nOldActionMax )
{
pThisTrack->MergeActionState( pAct, pSourceAction );
}
}
// fill merge map
if ( bShared && pMergeMap )
{
ScChangeAction* pAct = pThisTrack->GetLast();
if ( pAct && pAct->GetActionNumber() > nOldActionMax )
{
ULONG nActionMax = pAct->GetActionNumber();
ULONG nActionCount = nActionMax - nOldActionMax;
ULONG nAction = nActionMax - nActionCount + 1;
ULONG nSourceAction = pSourceAction->GetActionNumber() - nActionCount + 1;
while ( nAction <= nActionMax )
{
if ( bInverseMap )
{
(*pMergeMap)[ nAction++ ] = nSourceAction++;
}
else
{
(*pMergeMap)[ nSourceAction++ ] = nAction++;
}
}
}
}
2000-09-18 16:07:07 +00:00
}
aProgress.SetStateCountDown( --nNewActionCount );
}
pSourceAction = pSourceAction->GetNext();
}
2000-09-18 16:07:07 +00:00
rMarkData = aOldMarkData;
pThisTrack->SetUser(aOldUser);
pThisTrack->SetUseFixDateTime( FALSE );
pSourceTrack->Clear(); //! der ist jetzt verhunzt
if (bHasRejected)
PostPaintGridAll(); // Reject() paintet nicht selber
UnlockPaint();
2000-09-18 16:07:07 +00:00
}
bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell )
{
if ( !pSharedDocShell )
{
return false;
}
ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
if ( !pThisTrack )
{
return false;
}
2000-09-18 16:07:07 +00:00
ScDocument& rSharedDoc = *( pSharedDocShell->GetDocument() );
ScChangeTrack* pSharedTrack = rSharedDoc.GetChangeTrack();
if ( !pSharedTrack )
{
return false;
}
2000-09-18 16:07:07 +00:00
#if DEBUG_CHANGETRACK
::rtl::OUString aMessage = ::rtl::OUString::createFromAscii( "\nbefore merge:\n" );
aMessage += pThisTrack->ToString();
::rtl::OString aMsg = ::rtl::OUStringToOString( aMessage, RTL_TEXTENCODING_UTF8 );
OSL_ENSURE( false, aMsg.getStr() );
//fprintf( stdout, "%s ", aMsg.getStr() );
//fflush( stdout );
#endif // DEBUG_CHANGETRACK
2000-09-18 16:07:07 +00:00
// reset show changes
ScChangeViewSettings aChangeViewSet;
aChangeViewSet.SetShowChanges( FALSE );
aDocument.SetChangeViewSettings( aChangeViewSet );
2000-09-18 16:07:07 +00:00
// find first merge action in this document
BOOL bIgnore100Sec = !pThisTrack->IsTime100thSeconds() || !pSharedTrack->IsTime100thSeconds();
ScChangeAction* pThisAction = pThisTrack->GetFirst();
ScChangeAction* pSharedAction = pSharedTrack->GetFirst();
while ( lcl_Equal( pThisAction, pSharedAction, bIgnore100Sec ) )
{
pThisAction = pThisAction->GetNext();
pSharedAction = pSharedAction->GetNext();
}
if ( pSharedAction )
{
if ( pThisAction )
{
// merge own changes into shared document
ULONG nActStartShared = pSharedAction->GetActionNumber();
ULONG nActEndShared = pSharedTrack->GetActionMax();
ScDocument* pTmpDoc = new ScDocument;
for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
{
String sTabName;
pTmpDoc->CreateValidTabName( sTabName );
pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
}
aDocument.GetChangeTrack()->Clone( pTmpDoc );
ScChangeActionMergeMap aOwnInverseMergeMap;
pSharedDocShell->MergeDocument( *pTmpDoc, true, true, 0, &aOwnInverseMergeMap, true );
delete pTmpDoc;
ULONG nActStartOwn = nActEndShared + 1;
ULONG nActEndOwn = pSharedTrack->GetActionMax();
// find conflicts
ScConflictsList aConflictsList;
ScConflictsFinder aFinder( pSharedTrack, nActStartShared, nActEndShared, nActStartOwn, nActEndOwn, aConflictsList );
if ( aFinder.Find() )
{
ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnInverseMergeMap );
bool bLoop = true;
while ( bLoop )
{
bLoop = false;
ScConflictsDlg aDlg( GetActiveDialogParent(), GetViewData(), &rSharedDoc, aConflictsList );
if ( aDlg.Execute() == RET_CANCEL )
{
QueryBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
ScGlobal::GetRscString( STR_DOC_WILLNOTBESAVED ) );
if ( aBox.Execute() == RET_YES )
{
return false;
}
else
{
bLoop = true;
}
}
}
}
// undo own changes in shared document
pSharedTrack->Undo( nActStartOwn, nActEndOwn );
// clone change track for merging into own document
pTmpDoc = new ScDocument;
for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
{
String sTabName;
pTmpDoc->CreateValidTabName( sTabName );
pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
}
pThisTrack->Clone( pTmpDoc );
// undo own changes since last save in own document
ULONG nStartShared = pThisAction->GetActionNumber();
ScChangeAction* pAction = pThisTrack->GetLast();
while ( pAction && pAction->GetActionNumber() >= nStartShared )
{
pThisTrack->Reject( pAction );
pAction = pAction->GetPrev();
}
// #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
pThisTrack->Undo( nStartShared, pThisTrack->GetActionMax(), true );
// merge shared changes into own document
ScChangeActionMergeMap aSharedMergeMap;
MergeDocument( rSharedDoc, true, true, 0, &aSharedMergeMap );
ULONG nEndShared = pThisTrack->GetActionMax();
// resolve conflicts for shared non-content actions
if ( !aConflictsList.empty() )
{
ScConflictsListHelper::TransformConflictsList( aConflictsList, &aSharedMergeMap, NULL );
ScConflictsResolver aResolver( pThisTrack, aConflictsList );
pAction = pThisTrack->GetAction( nEndShared );
while ( pAction && pAction->GetActionNumber() >= nStartShared )
{
aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
false /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
pAction = pAction->GetPrev();
}
}
nEndShared = pThisTrack->GetActionMax();
// only show changes from shared document
aChangeViewSet.SetShowChanges( TRUE );
aChangeViewSet.SetShowAccepted( TRUE );
aChangeViewSet.SetHasActionRange( true );
aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
aDocument.SetChangeViewSettings( aChangeViewSet );
// merge own changes back into own document
ULONG nStartOwn = nEndShared + 1;
ScChangeActionMergeMap aOwnMergeMap;
MergeDocument( *pTmpDoc, true, true, nEndShared - nStartShared + 1, &aOwnMergeMap );
delete pTmpDoc;
ULONG nEndOwn = pThisTrack->GetActionMax();
// resolve conflicts for shared content actions and own actions
if ( !aConflictsList.empty() )
{
ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnMergeMap );
ScConflictsResolver aResolver( pThisTrack, aConflictsList );
pAction = pThisTrack->GetAction( nEndShared );
while ( pAction && pAction->GetActionNumber() >= nStartShared )
{
aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
true /*bHandleContentAction*/, false /*bHandleNonContentAction*/ );
pAction = pAction->GetPrev();
}
pAction = pThisTrack->GetAction( nEndOwn );
while ( pAction && pAction->GetActionNumber() >= nStartOwn )
{
aResolver.HandleAction( pAction, false /*bIsSharedAction*/,
true /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
pAction = pAction->GetPrev();
}
}
nEndOwn = pThisTrack->GetActionMax();
}
else
{
// merge shared changes into own document
ULONG nStartShared = pThisTrack->GetActionMax() + 1;
MergeDocument( rSharedDoc, true, true );
ULONG nEndShared = pThisTrack->GetActionMax();
// only show changes from shared document
aChangeViewSet.SetShowChanges( TRUE );
aChangeViewSet.SetShowAccepted( TRUE );
aChangeViewSet.SetHasActionRange( true );
aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
aDocument.SetChangeViewSettings( aChangeViewSet );
}
// update view
PostPaintExtras();
PostPaintGridAll();
InfoBox aInfoBox( GetActiveDialogParent(), ScGlobal::GetRscString( STR_DOC_UPDATED ) );
aInfoBox.Execute();
}
#if DEBUG_CHANGETRACK
aMessage = ::rtl::OUString::createFromAscii( "\nafter merge:\n" );
aMessage += pThisTrack->ToString();
aMsg = ::rtl::OUStringToOString( aMessage, RTL_TEXTENCODING_UTF8 );
OSL_ENSURE( false, aMsg.getStr() );
//fprintf( stdout, "%s ", aMsg.getStr() );
//fflush( stdout );
#endif // DEBUG_CHANGETRACK
return ( pThisAction != NULL );
}