2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 21:12:43 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:12:43 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:12:43 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 21:12:43 +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
|
|
|
*
|
2008-04-10 21:12:43 +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
|
|
|
*
|
2008-04-10 21:12:43 +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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 12:40:49 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// System - Includes -----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "scitems.hxx"
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
#include <sfx2/app.hxx>
|
|
|
|
#include <sfx2/bindings.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/smplhint.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-08-08 12:05:31 +00:00
|
|
|
#include <com/sun/star/sdbc/XResultSet.hpp>
|
2010-11-02 15:36:45 +00:00
|
|
|
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// INCLUDE ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "docsh.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "globstr.hrc"
|
2011-03-24 23:14:28 -04:00
|
|
|
#include "globalnames.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "undodat.hxx"
|
|
|
|
#include "undotab.hxx"
|
|
|
|
#include "undoblk.hxx"
|
|
|
|
#include "dpobject.hxx"
|
|
|
|
#include "dpshttab.hxx"
|
|
|
|
#include "dbdocfun.hxx"
|
|
|
|
#include "consoli.hxx"
|
|
|
|
#include "dbcolect.hxx"
|
|
|
|
#include "olinetab.hxx"
|
|
|
|
#include "patattr.hxx"
|
|
|
|
#include "attrib.hxx"
|
|
|
|
#include "docpool.hxx"
|
|
|
|
#include "uiitems.hxx"
|
|
|
|
#include "sc.hrc"
|
|
|
|
#include "waitoff.hxx"
|
2001-05-11 16:11:53 +00:00
|
|
|
#include "sizedev.hxx"
|
2010-03-02 12:39:31 +00:00
|
|
|
#include <basic/sbstar.hxx>
|
|
|
|
#include <basic/basmgr.hxx>
|
|
|
|
|
2010-12-14 18:57:04 -05:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
2010-03-02 12:39:31 +00:00
|
|
|
// defined in docfunc.cxx
|
|
|
|
void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-11-02 15:36:45 +00:00
|
|
|
using com::sun::star::script::XLibraryContainer;
|
|
|
|
using com::sun::star::script::vba::XVBACompatibility;
|
|
|
|
using com::sun::star::container::XNameContainer;
|
|
|
|
using com::sun::star::uno::Reference;
|
|
|
|
using com::sun::star::uno::UNO_QUERY;
|
|
|
|
|
2010-12-14 18:57:04 -05:00
|
|
|
using ::std::auto_ptr;
|
|
|
|
using ::std::vector;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
2010-10-01 21:45:05 -04:00
|
|
|
// former viewfunc/dbfunc methods
|
2000-09-18 16:07:07 +00:00
|
|
|
//
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScDocShell::ErrorMessage( sal_uInt16 nGlobStrId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
//! StopMarking an der (aktiven) View?
|
|
|
|
|
2007-02-27 12:07:51 +00:00
|
|
|
Window* pParent = GetActiveDialogParent();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScWaitCursorOff aWaitOff( pParent );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bFocus = pParent && pParent->HasFocus();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if(nGlobStrId==STR_PROTECTIONERR)
|
|
|
|
{
|
|
|
|
if(IsReadOnly())
|
|
|
|
{
|
|
|
|
nGlobStrId=STR_READONLYERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) );
|
|
|
|
aBox.Execute();
|
|
|
|
if (bFocus)
|
|
|
|
pParent->GrabFocus();
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScDocShell::IsEditable() const
|
2000-10-09 09:26:00 +00:00
|
|
|
{
|
|
|
|
// import into read-only document is possible - must be extended if other filters use api
|
2010-01-26 13:49:49 +01:00
|
|
|
// #i108547# MSOOXML filter uses "IsChangeReadOnlyEnabled" property
|
2000-10-09 09:26:00 +00:00
|
|
|
|
2010-01-26 13:49:49 +01:00
|
|
|
return !IsReadOnly() || aDocument.IsImportingXML() || aDocument.IsChangeReadOnlyEnabled();
|
2000-10-09 09:26:00 +00:00
|
|
|
}
|
|
|
|
|
2007-02-27 12:07:51 +00:00
|
|
|
void ScDocShell::DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW /* nY2 */ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
aDocument.RemoveFlagsTab( nX1, nY1, nX2, nY1, nTab, SC_MF_AUTO );
|
|
|
|
PostPaint( nX1, nY1, nTab, nX2, nY1, nTab, PAINT_GRID );
|
2004-07-23 09:52:25 +00:00
|
|
|
// No SetDocumentModified, as the unnamed database range might have to be restored later.
|
|
|
|
// The UNO hint is broadcast directly instead, to keep UNO objects in valid state.
|
|
|
|
aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 12:16:42 +01:00
|
|
|
ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nCol = rMarked.aStart.Col();
|
|
|
|
SCROW nRow = rMarked.aStart.Row();
|
|
|
|
SCTAB nTab = rMarked.aStart.Tab();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nStartCol = nCol;
|
|
|
|
SCROW nStartRow = nRow;
|
|
|
|
SCTAB nStartTab = nTab;
|
|
|
|
SCCOL nEndCol = rMarked.aEnd.Col();
|
|
|
|
SCROW nEndRow = rMarked.aEnd.Row();
|
|
|
|
SCTAB nEndTab = rMarked.aEnd.Tab();
|
2011-03-01 14:29:24 +01:00
|
|
|
// Nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich
|
2000-09-18 16:07:07 +00:00
|
|
|
// fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein
|
|
|
|
// benannter DB-Bereich dort gesucht werden.
|
2011-03-24 23:14:28 -04:00
|
|
|
ScDBCollection* pColl = aDocument.GetDBCollection();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
|
2011-03-24 23:14:28 -04:00
|
|
|
if (!pData && pColl)
|
|
|
|
pData = pColl->GetDBNearCursor(nCol, nRow, nTab );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bSelected = ( eSel == SC_DBSEL_FORCE_MARK ||
|
2010-02-24 12:16:42 +01:00
|
|
|
(rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) );
|
|
|
|
bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bUseThis = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
// Bereich nehmen, wenn nichts anderes markiert
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nDummy;
|
|
|
|
SCCOL nOldCol1;
|
|
|
|
SCROW nOldRow1;
|
|
|
|
SCCOL nOldCol2;
|
|
|
|
SCROW nOldRow2;
|
2000-09-18 16:07:07 +00:00
|
|
|
pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
|
2011-03-24 23:14:28 -04:00
|
|
|
sal_Bool bIsNoName = ( rtl::OUString(pData->GetName()) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME)) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (!bSelected)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
bUseThis = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bIsNoName && eMode == SC_DB_MAKE )
|
|
|
|
{
|
2010-02-24 12:16:42 +01:00
|
|
|
// If nothing marked or only one row marked, adapt
|
|
|
|
// "unbenannt"/"unnamed" to contiguous area.
|
2000-09-18 16:07:07 +00:00
|
|
|
nStartCol = nCol;
|
|
|
|
nStartRow = nRow;
|
2010-02-24 12:16:42 +01:00
|
|
|
if (bOnlyDown)
|
|
|
|
{
|
|
|
|
nEndCol = rMarked.aEnd.Col();
|
|
|
|
nEndRow = rMarked.aEnd.Row();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nEndCol = nStartCol;
|
|
|
|
nEndRow = nStartRow;
|
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
|
2011-03-10 16:55:21 -05:00
|
|
|
bUseThis = false; // passt gar nicht
|
2000-09-18 16:07:07 +00:00
|
|
|
else if ( nOldRow2 != nEndRow )
|
|
|
|
{
|
|
|
|
// Bereich auf neue End-Zeile erweitern
|
|
|
|
pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
|
|
|
|
nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // genau markiert?
|
2011-01-17 13:20:22 +01:00
|
|
|
bUseThis = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2011-03-10 16:55:21 -05:00
|
|
|
bUseThis = false; // immer Markierung nehmen (Bug 11964)
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// fuer Import nie "unbenannt" nehmen
|
|
|
|
|
|
|
|
if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName )
|
2011-03-10 16:55:21 -05:00
|
|
|
bUseThis = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bUseThis )
|
|
|
|
{
|
|
|
|
pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
|
|
|
|
nEndTab = nStartTab;
|
|
|
|
}
|
|
|
|
else if ( eMode == SC_DB_OLD )
|
|
|
|
{
|
|
|
|
pData = NULL; // nichts gefunden
|
|
|
|
nStartCol = nEndCol = nCol;
|
|
|
|
nStartRow = nEndRow = nRow;
|
|
|
|
nStartTab = nEndTab = nTab;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-16 19:21:03 +01:00
|
|
|
if ( !bSelected )
|
2000-09-18 16:07:07 +00:00
|
|
|
{ // zusammenhaengender Bereich
|
|
|
|
nStartCol = nCol;
|
|
|
|
nStartRow = nRow;
|
2010-02-24 12:16:42 +01:00
|
|
|
if (bOnlyDown)
|
|
|
|
{
|
|
|
|
nEndCol = rMarked.aEnd.Col();
|
|
|
|
nEndRow = rMarked.aEnd.Row();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nEndCol = nStartCol;
|
|
|
|
nEndRow = nStartRow;
|
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, bOnlyDown );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-03-24 23:14:28 -04:00
|
|
|
ScDBData* pNoNameData = aDocument.GetAnonymousDBData(nTab);
|
|
|
|
if ( eMode != SC_DB_IMPORT && pNoNameData)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
|
2004-07-23 09:52:25 +00:00
|
|
|
if ( !pOldAutoDBRange )
|
|
|
|
{
|
|
|
|
// store the old unnamed database range with its settings for undo
|
|
|
|
// (store at the first change, get the state before all changes)
|
|
|
|
pOldAutoDBRange = new ScDBData( *pNoNameData );
|
|
|
|
}
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nOldX1; // alten Bereich sauber wegnehmen
|
|
|
|
SCROW nOldY1; //! (UNDO ???)
|
|
|
|
SCCOL nOldX2;
|
|
|
|
SCROW nOldY2;
|
|
|
|
SCTAB nOldTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
|
|
|
|
DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
|
|
|
|
|
|
|
|
pNoNameData->SetSortParam( ScSortParam() ); // Parameter zuruecksetzen
|
|
|
|
pNoNameData->SetQueryParam( ScQueryParam() );
|
|
|
|
pNoNameData->SetSubTotalParam( ScSubTotalParam() );
|
|
|
|
|
|
|
|
pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // neu setzen
|
2011-01-17 13:20:22 +01:00
|
|
|
pNoNameData->SetByRow( sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
pNoNameData->SetHeader( bHasHeader );
|
2011-03-10 16:55:21 -05:00
|
|
|
pNoNameData->SetAutoFilter( false );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScDBCollection* pUndoColl = NULL;
|
|
|
|
|
|
|
|
String aNewName;
|
|
|
|
if (eMode==SC_DB_IMPORT)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
aDocument.CompileDBFormula( sal_True ); // CreateFormulaString
|
2000-09-18 16:07:07 +00:00
|
|
|
pUndoColl = new ScDBCollection( *pColl ); // Undo fuer Import1-Bereich
|
|
|
|
|
|
|
|
String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT );
|
|
|
|
long nCount = 0;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nDummy;
|
2000-09-18 16:07:07 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
++nCount;
|
|
|
|
aNewName = aImport;
|
|
|
|
aNewName += String::CreateFromInt32( nCount );
|
|
|
|
}
|
|
|
|
while (pColl->SearchName( aNewName, nDummy ));
|
2011-03-24 23:14:28 -04:00
|
|
|
pNoNameData = new ScDBData( aNewName, nTab,
|
|
|
|
nStartCol,nStartRow, nEndCol,nEndRow,
|
|
|
|
sal_True, bHasHeader );
|
|
|
|
pColl->Insert( pNoNameData );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
2011-03-24 23:14:28 -04:00
|
|
|
{
|
|
|
|
aNewName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_DB_LOCAL_NONAME));
|
|
|
|
pNoNameData = new ScDBData(aNewName , nTab,
|
2000-09-18 16:07:07 +00:00
|
|
|
nStartCol,nStartRow, nEndCol,nEndRow,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_True, bHasHeader );
|
2011-03-24 23:14:28 -04:00
|
|
|
aDocument.SetAnonymousDBData(nTab, pNoNameData);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( pUndoColl )
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.CompileDBFormula( false ); // CompileFormulaString
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ScDBCollection* pRedoColl = new ScDBCollection( *pColl );
|
|
|
|
GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// neuen Bereich am Sba anmelden nicht mehr noetig
|
|
|
|
|
|
|
|
// "Import1" etc am Navigator bekanntmachen
|
|
|
|
if (eMode==SC_DB_IMPORT)
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
|
|
|
|
}
|
|
|
|
pData = pNoNameData;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pData;
|
|
|
|
}
|
|
|
|
|
2004-07-23 09:52:25 +00:00
|
|
|
ScDBData* ScDocShell::GetOldAutoDBRange()
|
|
|
|
{
|
|
|
|
ScDBData* pRet = pOldAutoDBRange;
|
|
|
|
pOldAutoDBRange = NULL;
|
|
|
|
return pRet; // has to be deleted by caller!
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocShell::CancelAutoDBRange()
|
|
|
|
{
|
|
|
|
// called when dialog is cancelled
|
2011-03-24 23:14:28 -04:00
|
|
|
//moggi:TODO
|
2004-07-23 09:52:25 +00:00
|
|
|
if ( pOldAutoDBRange )
|
|
|
|
{
|
2011-03-24 23:14:28 -04:00
|
|
|
SCTAB nTab = GetCurTab();
|
|
|
|
ScDBData* pDBData = aDocument.GetAnonymousDBData(nTab);
|
|
|
|
if ( pDBData )
|
2004-07-23 09:52:25 +00:00
|
|
|
{
|
|
|
|
SCCOL nRangeX1;
|
|
|
|
SCROW nRangeY1;
|
|
|
|
SCCOL nRangeX2;
|
|
|
|
SCROW nRangeY2;
|
|
|
|
SCTAB nRangeTab;
|
2011-03-24 23:14:28 -04:00
|
|
|
pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
|
2004-07-23 09:52:25 +00:00
|
|
|
DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
|
|
|
|
|
2011-03-24 23:14:28 -04:00
|
|
|
*pDBData = *pOldAutoDBRange; // restore old settings
|
2004-07-23 09:52:25 +00:00
|
|
|
|
|
|
|
if ( pOldAutoDBRange->HasAutoFilter() )
|
|
|
|
{
|
|
|
|
// restore AutoFilter buttons
|
|
|
|
pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
|
|
|
|
aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
|
|
|
|
PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pOldAutoDBRange;
|
|
|
|
pOldAutoDBRange = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Hoehen anpassen
|
|
|
|
//! mit docfunc zusammenfassen
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-11 16:11:53 +00:00
|
|
|
ScSizeDeviceProvider aProv(this);
|
2000-09-18 16:07:07 +00:00
|
|
|
Fraction aZoom(1,1);
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bChange = aDocument.SetOptimalHeight( nStartRow,nEndRow, nTab, 0, aProv.GetDevice(),
|
2011-03-10 16:55:21 -05:00
|
|
|
aProv.GetPPTX(),aProv.GetPPTY(), aZoom,aZoom, false );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bChange)
|
|
|
|
PostPaint( 0,nStartRow,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID|PAINT_LEFT );
|
|
|
|
|
|
|
|
return bChange;
|
|
|
|
}
|
|
|
|
|
2009-07-03 12:42:53 +00:00
|
|
|
void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark )
|
2001-02-09 19:03:36 +00:00
|
|
|
{
|
|
|
|
// update automatic row heights
|
|
|
|
|
2001-05-11 16:11:53 +00:00
|
|
|
ScSizeDeviceProvider aProv(this);
|
2001-02-09 19:03:36 +00:00
|
|
|
Fraction aZoom(1,1);
|
2009-07-03 12:42:53 +00:00
|
|
|
aDocument.UpdateAllRowHeights( aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, pTabMark );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bIsUndoEnabled = aDocument.IsUndoEnabled();
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.EnableUndo( false );
|
2009-09-07 15:38:19 +00:00
|
|
|
aDocument.LockStreamValid( true ); // ignore draw page size (but not formula results)
|
2009-07-03 12:42:53 +00:00
|
|
|
if ( bBefore ) // check all sheets up to nUpdateTab
|
|
|
|
{
|
|
|
|
SCTAB nTabCount = aDocument.GetTableCount();
|
|
|
|
if ( nUpdateTab >= nTabCount )
|
|
|
|
nUpdateTab = nTabCount-1; // nUpdateTab is inclusive
|
|
|
|
|
|
|
|
ScMarkData aUpdateSheets;
|
|
|
|
SCTAB nTab;
|
|
|
|
for (nTab=0; nTab<=nUpdateTab; ++nTab)
|
|
|
|
if ( aDocument.IsPendingRowHeights( nTab ) )
|
2011-01-17 13:20:22 +01:00
|
|
|
aUpdateSheets.SelectTable( nTab, sal_True );
|
2009-07-03 12:42:53 +00:00
|
|
|
|
|
|
|
if (aUpdateSheets.GetSelectCount())
|
|
|
|
UpdateAllRowHeights(&aUpdateSheets); // update with a single progress bar
|
|
|
|
|
|
|
|
for (nTab=0; nTab<=nUpdateTab; ++nTab)
|
|
|
|
if ( aUpdateSheets.GetTableSelect( nTab ) )
|
|
|
|
{
|
|
|
|
aDocument.UpdatePageBreaks( nTab );
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.SetPendingRowHeights( nTab, false );
|
2009-07-03 12:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // only nUpdateTab
|
|
|
|
{
|
|
|
|
if ( aDocument.IsPendingRowHeights( nUpdateTab ) )
|
|
|
|
{
|
|
|
|
AdjustRowHeight( 0, MAXROW, nUpdateTab );
|
|
|
|
aDocument.UpdatePageBreaks( nUpdateTab );
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.SetPendingRowHeights( nUpdateTab, false );
|
2009-07-03 12:42:53 +00:00
|
|
|
}
|
|
|
|
}
|
2009-09-07 15:38:19 +00:00
|
|
|
aDocument.LockStreamValid( false );
|
2009-07-03 12:42:53 +00:00
|
|
|
aDocument.EnableUndo( bIsUndoEnabled );
|
2001-02-09 19:03:36 +00:00
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ScDocShell::RefreshPivotTables( const ScRange& rSource )
|
|
|
|
{
|
|
|
|
//! rename to RefreshDataPilotTables?
|
|
|
|
|
|
|
|
ScDPCollection* pColl = aDocument.GetDPCollection();
|
|
|
|
if ( pColl )
|
|
|
|
{
|
|
|
|
// DataPilotUpdate doesn't modify the collection order like PivotUpdate did,
|
|
|
|
// so a simple loop can be used.
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nCount = pColl->GetCount();
|
|
|
|
for ( sal_uInt16 i=0; i<nCount; i++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDPObject* pOld = (*pColl)[i];
|
|
|
|
if ( pOld )
|
|
|
|
{
|
|
|
|
const ScSheetSourceDesc* pSheetDesc = pOld->GetSheetDesc();
|
2011-01-21 14:59:06 -05:00
|
|
|
if ( pSheetDesc && pSheetDesc->GetSourceRange().Intersects( rSource ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDPObject* pNew = new ScDPObject( *pOld );
|
|
|
|
ScDBDocFunc aFunc( *this );
|
2011-03-10 16:55:21 -05:00
|
|
|
aFunc.DataPilotUpdate( pOld, pNew, sal_True, false );
|
2000-09-18 16:07:07 +00:00
|
|
|
delete pNew; // DataPilotUpdate copies settings from "new" object
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea )
|
|
|
|
{
|
|
|
|
String aName;
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bOk = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart,
|
|
|
|
pArea->nColEnd, pArea->nRowEnd );
|
|
|
|
if (pData)
|
|
|
|
{
|
|
|
|
pData->GetName( aName );
|
2011-03-24 23:14:28 -04:00
|
|
|
bOk = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!bOk)
|
|
|
|
pDoc->GetName( pArea->nTab, aName );
|
|
|
|
|
|
|
|
return aName;
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, sal_Bool bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScConsData aData;
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nPos;
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nColSize = 0;
|
|
|
|
SCROW nRowSize = 0;
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bErr = false;
|
2000-09-18 16:07:07 +00:00
|
|
|
for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
|
|
|
|
{
|
|
|
|
ScArea* pArea = rParam.ppDataAreas[nPos];
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
nColSize = Max( nColSize, SCCOL( pArea->nColEnd - pArea->nColStart + 1 ) );
|
|
|
|
nRowSize = Max( nRowSize, SCROW( pArea->nRowEnd - pArea->nRowStart + 1 ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Test, ob Quelldaten verschoben wuerden
|
|
|
|
if (rParam.bReferenceData)
|
|
|
|
if (pArea->nTab == rParam.nTab && pArea->nRowEnd >= rParam.nRow)
|
2011-01-17 13:20:22 +01:00
|
|
|
bErr = sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bErr)
|
|
|
|
{
|
2007-02-27 12:07:51 +00:00
|
|
|
InfoBox aBox( GetActiveDialogParent(),
|
2000-09-18 16:07:07 +00:00
|
|
|
ScGlobal::GetRscString( STR_CONSOLIDATE_ERR1 ) );
|
|
|
|
aBox.Execute();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ausfuehren
|
|
|
|
|
2007-02-27 12:07:51 +00:00
|
|
|
WaitObject aWait( GetActiveDialogParent() );
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
|
|
|
|
ScRange aOldDest;
|
2011-01-17 13:20:22 +01:00
|
|
|
ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (pDestData)
|
|
|
|
pDestData->GetArea(aOldDest);
|
|
|
|
|
|
|
|
aData.SetSize( nColSize, nRowSize );
|
|
|
|
aData.SetFlags( rParam.eFunction, rParam.bByCol, rParam.bByRow, rParam.bReferenceData );
|
|
|
|
if ( rParam.bByCol || rParam.bByRow )
|
|
|
|
for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
|
|
|
|
{
|
|
|
|
ScArea* pArea = rParam.ppDataAreas[nPos];
|
|
|
|
aData.AddFields( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart,
|
|
|
|
pArea->nColEnd, pArea->nRowEnd );
|
|
|
|
}
|
|
|
|
aData.DoneFields();
|
|
|
|
for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
|
|
|
|
{
|
|
|
|
ScArea* pArea = rParam.ppDataAreas[nPos];
|
|
|
|
aData.AddData( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart,
|
|
|
|
pArea->nColEnd, pArea->nRowEnd );
|
|
|
|
aData.AddName( lcl_GetAreaName(&aDocument,pArea) );
|
|
|
|
}
|
|
|
|
|
|
|
|
aData.GetSize( nColSize, nRowSize );
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
if (bRecord && nColSize > 0 && nRowSize > 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDBData* pUndoData = pDestData ? new ScDBData(*pDestData) : NULL;
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nDestTab = rParam.nTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow,
|
|
|
|
rParam.nCol+nColSize-1, rParam.nRow+nRowSize-1 );
|
|
|
|
if (rParam.bByCol) ++aDestArea.nColEnd;
|
|
|
|
if (rParam.bByRow) ++aDestArea.nRowEnd;
|
|
|
|
|
|
|
|
if (rParam.bReferenceData)
|
|
|
|
{
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nTabCount = aDocument.GetTableCount();
|
|
|
|
SCROW nInsertCount = aData.GetInsertCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// alte Outlines
|
|
|
|
ScOutlineTable* pTable = aDocument.GetOutlineTable( nDestTab );
|
|
|
|
ScOutlineTable* pUndoTab = pTable ? new ScOutlineTable( *pTable ) : NULL;
|
|
|
|
|
|
|
|
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
2011-03-10 16:55:21 -05:00
|
|
|
pUndoDoc->InitUndo( &aDocument, 0, nTabCount-1, false, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Zeilenstatus
|
|
|
|
aDocument.CopyToDocument( 0,0,nDestTab, MAXCOL,MAXROW,nDestTab,
|
2011-03-10 16:55:21 -05:00
|
|
|
IDF_NONE, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// alle Formeln
|
|
|
|
aDocument.CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
|
2011-03-10 16:55:21 -05:00
|
|
|
IDF_FORMULA, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// komplette Ausgangszeilen
|
|
|
|
aDocument.CopyToDocument( 0,aDestArea.nRowStart,nDestTab,
|
|
|
|
MAXCOL,aDestArea.nRowEnd,nDestTab,
|
2011-03-10 16:55:21 -05:00
|
|
|
IDF_ALL, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// alten Ausgabebereich
|
|
|
|
if (pDestData)
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.CopyToDocument( aOldDest, IDF_ALL, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc,
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_True, nInsertCount, pUndoTab, pUndoData ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( &aDocument, aDestArea.nTab, aDestArea.nTab );
|
|
|
|
|
|
|
|
aDocument.CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, aDestArea.nTab,
|
|
|
|
aDestArea.nColEnd, aDestArea.nRowEnd, aDestArea.nTab,
|
2011-03-10 16:55:21 -05:00
|
|
|
IDF_ALL, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// alten Ausgabebereich
|
|
|
|
if (pDestData)
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.CopyToDocument( aOldDest, IDF_ALL, false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc,
|
2011-03-10 16:55:21 -05:00
|
|
|
false, 0, NULL, pUndoData ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pDestData) // Zielbereich loeschen / anpassen
|
|
|
|
{
|
|
|
|
aDocument.DeleteAreaTab(aOldDest, IDF_CONTENTS);
|
|
|
|
pDestData->SetArea( rParam.nTab, rParam.nCol, rParam.nRow,
|
|
|
|
rParam.nCol + nColSize - 1, rParam.nRow + nRowSize - 1 );
|
|
|
|
pDestData->SetHeader( rParam.bByRow );
|
|
|
|
}
|
|
|
|
|
|
|
|
aData.OutputToDocument( &aDocument, rParam.nCol, rParam.nRow, rParam.nTab );
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nPaintStartCol = rParam.nCol;
|
|
|
|
SCROW nPaintStartRow = rParam.nRow;
|
|
|
|
SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
|
|
|
|
SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nPaintFlags = PAINT_GRID;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (rParam.bByCol)
|
|
|
|
++nPaintEndRow;
|
|
|
|
if (rParam.bByRow)
|
|
|
|
++nPaintEndCol;
|
|
|
|
if (rParam.bReferenceData)
|
|
|
|
{
|
|
|
|
nPaintStartCol = 0;
|
|
|
|
nPaintEndCol = MAXCOL;
|
|
|
|
nPaintEndRow = MAXROW;
|
|
|
|
nPaintFlags |= PAINT_LEFT | PAINT_SIZE;
|
|
|
|
}
|
|
|
|
if (pDestData)
|
|
|
|
{
|
|
|
|
if ( aOldDest.aEnd.Col() > nPaintEndCol )
|
|
|
|
nPaintEndCol = aOldDest.aEnd.Col();
|
|
|
|
if ( aOldDest.aEnd.Row() > nPaintEndRow )
|
|
|
|
nPaintEndRow = aOldDest.aEnd.Row();
|
|
|
|
}
|
|
|
|
PostPaint( nPaintStartCol, nPaintStartRow, rParam.nTab,
|
|
|
|
nPaintEndCol, nPaintEndRow, rParam.nTab, nPaintFlags );
|
|
|
|
aModificator.SetDocumentModified();
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
void ScDocShell::UseScenario( SCTAB nTab, const String& rName, sal_Bool bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (!aDocument.IsScenario(nTab))
|
|
|
|
{
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nTabCount = aDocument.GetTableCount();
|
|
|
|
SCTAB nSrcTab = SCTAB_MAX;
|
|
|
|
SCTAB nEndTab = nTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
String aCompare;
|
|
|
|
while ( nEndTab+1 < nTabCount && aDocument.IsScenario(nEndTab+1) )
|
|
|
|
{
|
|
|
|
++nEndTab;
|
|
|
|
if (nSrcTab > MAXTAB) // noch auf der Suche nach dem Szenario?
|
|
|
|
{
|
|
|
|
aDocument.GetName( nEndTab, aCompare );
|
|
|
|
if (aCompare == rName)
|
|
|
|
nSrcTab = nEndTab; // gefunden
|
|
|
|
}
|
|
|
|
}
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
if (ValidTab(nSrcTab))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( aDocument.TestCopyScenario( nSrcTab, nTab ) ) // Zellschutz testen
|
|
|
|
{
|
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
ScMarkData aScenMark;
|
|
|
|
aDocument.MarkScenario( nSrcTab, nTab, aScenMark );
|
|
|
|
ScRange aMultiRange;
|
|
|
|
aScenMark.GetMultiMarkArea( aMultiRange );
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCCOL nStartCol = aMultiRange.aStart.Col();
|
|
|
|
SCROW nStartRow = aMultiRange.aStart.Row();
|
|
|
|
SCCOL nEndCol = aMultiRange.aEnd.Col();
|
|
|
|
SCROW nEndRow = aMultiRange.aEnd.Row();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bRecord)
|
|
|
|
{
|
|
|
|
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( &aDocument, nTab,nEndTab ); // auch alle Szenarien
|
|
|
|
// angezeigte Tabelle:
|
|
|
|
aDocument.CopyToDocument( nStartCol,nStartRow,nTab,
|
2011-01-17 13:20:22 +01:00
|
|
|
nEndCol,nEndRow,nTab, IDF_ALL,sal_True, pUndoDoc, &aScenMark );
|
2000-09-18 16:07:07 +00:00
|
|
|
// Szenarien
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
for (SCTAB i=nTab+1; i<=nEndTab; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
pUndoDoc->SetScenario( i, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nScenFlags;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetScenarioData( i, aComment, aColor, nScenFlags );
|
|
|
|
pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bActive = aDocument.IsActiveScenario( i );
|
2000-09-18 16:07:07 +00:00
|
|
|
pUndoDoc->SetActiveScenario( i, bActive );
|
|
|
|
// Bei Zurueckkopier-Szenarios auch Inhalte
|
|
|
|
if ( nScenFlags & SC_SCENARIO_TWOWAY )
|
|
|
|
aDocument.CopyToDocument( 0,0,i, MAXCOL,MAXROW,i,
|
2011-03-10 16:55:21 -05:00
|
|
|
IDF_ALL,false, pUndoDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoUseScenario( this, aScenMark,
|
|
|
|
ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
|
|
|
|
pUndoDoc, rName ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
aDocument.CopyScenario( nSrcTab, nTab );
|
|
|
|
aDocument.SetDirty();
|
|
|
|
|
|
|
|
// alles painten, weil in anderen Bereichen das aktive Szenario
|
|
|
|
// geaendert sein kann
|
|
|
|
//! nur, wenn sichtbare Rahmen vorhanden?
|
|
|
|
PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
|
|
|
|
aModificator.SetDocumentModified();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-27 12:07:51 +00:00
|
|
|
InfoBox aBox(GetActiveDialogParent(),
|
2000-09-18 16:07:07 +00:00
|
|
|
ScGlobal::GetRscString( STR_PROTECTIONERR ) );
|
|
|
|
aBox.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-02-27 12:07:51 +00:00
|
|
|
InfoBox aBox(GetActiveDialogParent(),
|
2000-09-18 16:07:07 +00:00
|
|
|
ScGlobal::GetRscString( STR_SCENARIO_NOTFOUND ) );
|
|
|
|
aBox.Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-01-29 14:41:57 +00:00
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL( "UseScenario auf Szenario-Blatt" );
|
2008-01-29 14:41:57 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
void ScDocShell::ModifyScenario( SCTAB nTab, const String& rName, const String& rComment,
|
2011-01-17 13:20:22 +01:00
|
|
|
const Color& rColor, sal_uInt16 nFlags )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Undo
|
|
|
|
String aOldName;
|
|
|
|
aDocument.GetName( nTab, aOldName );
|
|
|
|
String aOldComment;
|
|
|
|
Color aOldColor;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nOldFlags;
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
|
|
|
|
GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoScenarioFlags( this, nTab,
|
|
|
|
aOldName, rName, aOldComment, rComment,
|
|
|
|
aOldColor, rColor, nOldFlags, nFlags ) );
|
|
|
|
|
|
|
|
// ausfuehren
|
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
aDocument.RenameTab( nTab, rName );
|
|
|
|
aDocument.SetScenarioData( nTab, rComment, rColor, nFlags );
|
|
|
|
PostPaintGridAll();
|
|
|
|
aModificator.SetDocumentModified();
|
|
|
|
|
|
|
|
if ( rName != aOldName )
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxBindings* pBindings = GetViewBindings();
|
|
|
|
if (pBindings)
|
|
|
|
pBindings->Invalidate( SID_SELECT_SCENARIO );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB ScDocShell::MakeScenario( SCTAB nTab, const String& rName, const String& rComment,
|
2011-01-17 13:20:22 +01:00
|
|
|
const Color& rColor, sal_uInt16 nFlags,
|
|
|
|
ScMarkData& rMark, sal_Bool bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
rMark.MarkToMulti();
|
|
|
|
if (rMark.IsMultiMarked())
|
|
|
|
{
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nNewTab = nTab + 1;
|
2000-09-18 16:07:07 +00:00
|
|
|
while (aDocument.IsScenario(nNewTab))
|
|
|
|
++nNewTab;
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bCopyAll = ( (nFlags & SC_SCENARIO_COPYALL) != 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
const ScMarkData* pCopyMark = NULL;
|
|
|
|
if (!bCopyAll)
|
|
|
|
pCopyMark = &rMark;
|
|
|
|
|
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
|
2008-07-11 06:09:32 +00:00
|
|
|
if (bRecord)
|
|
|
|
aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (aDocument.CopyTab( nTab, nNewTab, pCopyMark ))
|
|
|
|
{
|
|
|
|
if (bRecord)
|
|
|
|
{
|
|
|
|
GetUndoManager()->AddUndoAction(
|
2008-07-11 06:09:32 +00:00
|
|
|
new ScUndoMakeScenario( this, nTab, nNewTab,
|
2000-09-18 16:07:07 +00:00
|
|
|
rName, rComment, rColor, nFlags, rMark ));
|
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.RenameTab( nNewTab, rName, false ); // ohne Formel-Update
|
2011-01-17 13:20:22 +01:00
|
|
|
aDocument.SetScenario( nNewTab, sal_True );
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.SetScenarioData( nNewTab, rComment, rColor, nFlags );
|
|
|
|
|
|
|
|
ScMarkData aDestMark = rMark;
|
|
|
|
aDestMark.SelectOneTable( nNewTab );
|
|
|
|
|
|
|
|
//! auf Filter / Buttons / Merging testen !
|
|
|
|
|
|
|
|
ScPatternAttr aProtPattern( aDocument.GetPool() );
|
2011-01-17 13:20:22 +01:00
|
|
|
aProtPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nNewTab, aProtPattern );
|
|
|
|
|
|
|
|
ScPatternAttr aPattern( aDocument.GetPool() );
|
|
|
|
aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
|
2011-01-17 13:20:22 +01:00
|
|
|
aPattern.GetItemSet().Put( ScProtectionAttr( sal_True ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
aDocument.ApplySelectionPattern( aPattern, aDestMark );
|
|
|
|
|
|
|
|
if (!bCopyAll)
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.SetVisible( nNewTab, false );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// dies ist dann das aktive Szenario
|
2011-01-17 13:20:22 +01:00
|
|
|
aDocument.CopyScenario( nNewTab, nTab, sal_True ); // sal_True - nicht aus Szenario kopieren
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (nFlags & SC_SCENARIO_SHOWFRAME)
|
|
|
|
PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); // Rahmen painten
|
|
|
|
PostPaintExtras(); // Tabellenreiter
|
|
|
|
aModificator.SetDocumentModified();
|
|
|
|
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
|
|
|
|
return nNewTab;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nTab;
|
|
|
|
}
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uLong ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
|
|
|
|
SCTAB nDestPos, sal_Bool bInsertNew,
|
|
|
|
sal_Bool bNotifyAndPaint )
|
2010-10-06 10:15:43 +01:00
|
|
|
{
|
|
|
|
ScDocument* pSrcDoc = rSrcDocShell.GetDocument();
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uLong nErrVal = aDocument.TransferTab( pSrcDoc, nSrcPos, nDestPos,
|
2010-10-06 10:15:43 +01:00
|
|
|
bInsertNew ); // no insert
|
|
|
|
|
|
|
|
// TransferTab doesn't copy drawing objects with bInsertNew=FALSE
|
|
|
|
if ( nErrVal > 0 && !bInsertNew)
|
|
|
|
aDocument.TransferDrawPage( pSrcDoc, nSrcPos, nDestPos );
|
|
|
|
|
|
|
|
if(nErrVal>0 && pSrcDoc->IsScenario( nSrcPos ))
|
|
|
|
{
|
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_uInt16 nFlags;
|
2010-10-06 10:15:43 +01:00
|
|
|
|
|
|
|
pSrcDoc->GetScenarioData( nSrcPos, aComment,aColor, nFlags);
|
2011-03-10 16:55:21 -05:00
|
|
|
aDocument.SetScenario(nDestPos,true);
|
2010-10-06 10:15:43 +01:00
|
|
|
aDocument.SetScenarioData(nDestPos,aComment,aColor,nFlags);
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bActive = pSrcDoc->IsActiveScenario(nSrcPos);
|
2010-10-06 10:15:43 +01:00
|
|
|
aDocument.SetActiveScenario(nDestPos, bActive );
|
|
|
|
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bVisible=pSrcDoc->IsVisible(nSrcPos);
|
2010-10-06 10:15:43 +01:00
|
|
|
aDocument.SetVisible(nDestPos,bVisible );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nErrVal > 0 && pSrcDoc->IsTabProtected( nSrcPos ) )
|
|
|
|
aDocument.SetTabProtection(nDestPos, pSrcDoc->GetTabProtection(nSrcPos));
|
|
|
|
if ( bNotifyAndPaint )
|
|
|
|
{
|
|
|
|
Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
|
|
|
|
PostPaintExtras();
|
|
|
|
PostPaintGridAll();
|
|
|
|
}
|
|
|
|
return nErrVal;
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, sal_Bool bCopy, sal_Bool bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShellModificator aModificator( *this );
|
|
|
|
|
2008-11-20 13:27:25 +00:00
|
|
|
// #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append"
|
2009-10-23 12:55:31 +00:00
|
|
|
// #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.)
|
2008-11-20 13:27:25 +00:00
|
|
|
if ( nDestTab >= aDocument.GetTableCount() )
|
2009-10-23 12:55:31 +00:00
|
|
|
nDestTab = aDocument.GetTableCount();
|
2008-11-20 13:27:25 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bCopy)
|
|
|
|
{
|
|
|
|
if (bRecord)
|
|
|
|
aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
|
|
|
|
|
2010-03-02 12:39:31 +00:00
|
|
|
String sSrcCodeName;
|
|
|
|
aDocument.GetCodeName( nSrcTab, sSrcCodeName );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!aDocument.CopyTab( nSrcTab, nDestTab ))
|
|
|
|
{
|
|
|
|
//! EndDrawUndo?
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2003-04-28 14:44:31 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
INTEGRATION: CWS rowlimit (1.10.178); FILE MERGED
2004/04/29 16:31:42 er 1.10.178.6: RESYNC: (1.10-1.11); FILE MERGED
2004/03/25 21:36:02 er 1.10.178.5: #i1967# use ValidCol,ValidRow,ValidTab
2004/02/27 11:01:40 er 1.10.178.4: #i1967# type correctness
2004/02/25 01:17:53 er 1.10.178.3: #i1967# type correctness
2004/02/13 11:33:23 er 1.10.178.2: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004/01/14 15:50:12 er 1.10.178.1: #i1967# SCCOL,SCROW,SCTAB replace USHORT; SCsCOL,SCsROW,SCsTAB replace short
2004-06-04 10:24:25 +00:00
|
|
|
SCTAB nAdjSource = nSrcTab;
|
2003-04-28 14:44:31 +00:00
|
|
|
if ( nDestTab <= nSrcTab )
|
|
|
|
++nAdjSource; // new position of source table after CopyTab
|
|
|
|
|
|
|
|
if ( aDocument.IsTabProtected( nAdjSource ) )
|
CWS-TOOLING: integrate CWS scsheetprotection02
2009-06-18 16:48:14 +0200 kohei r273124 : #i102906# Fix a crasher when loading an xls document with unsupported
encrytpion.
2009-06-15 14:02:00 +0200 dr r272982 : #i10000# compiler warnings
2009-04-13 23:06:21 +0200 kohei r270740 : Renamed SetData() to SetDataFromDocument(), in order to resolve name clash
with the method of the same name in class Window. This caused a compiler
warning on Solaris Intel.
2009-04-13 04:09:59 +0200 kohei r270729 : CWS-TOOLING: rebase CWS scsheetprotection02 to trunk@270723 (milestone: DEV300:m46)
2009-02-23 16:13:45 +0100 kohei r268361 : added tabprotection.obj to the exception file list. Apparently the older
versions of boost::shared_ptr rely on C++ exceptions for its implementation.
2009-02-18 19:59:05 +0100 kohei r268253 : Switched to using ::boost::shared_ptr to wrap a pimpl class, because using
::std::auto_ptr in this header breaks the build on win32. The MSVC
implementation of ::std::auto_ptr has some weird quirks...
2009-02-17 21:47:13 +0100 kohei r268192 : fixed linkage issue due to library split.
2009-02-17 04:50:34 +0100 kohei r267842 : CWS-TOOLING: rebase CWS scsheetprotection02 to trunk@267171 (milestone: DEV300:m41)
2009-02-17 02:36:10 +0100 kohei r267841 : reverted the last commit, to re-surrect the removed src files.
2009-02-03 22:02:34 +0100 kohei r267342 : removed the src files to prevent them from being entered into the translation
process. The dialogs that need the strings are not yet enabled in the code,
so their removal will not cause any harm.
2009-01-14 12:24:29 +0100 dr r266280 : #i10000# wntmsci12 compiler warnings #4
2009-01-14 09:35:46 +0100 dr r266267 : #i10000# wntmsci12 compiler warnings #3
2009-01-13 15:42:07 +0100 dr r266231 : #i10000# wntmsci12 compiler warnings #2
2009-01-13 13:18:28 +0100 dr r266216 : #i10000# wntmsci12 compiler warnings
2009-01-07 03:59:11 +0100 kohei r265943 : remove the fscking compiler warnings.
2009-01-06 15:55:32 +0100 kohei r265925 : removed compiler warnings that caused the buildbot build to fail....
2009-01-05 23:24:59 +0100 kohei r265888 : Undoing my own local build fix to work around the libmoz... issue.
2008-12-30 21:39:58 +0100 kohei r265833 : Duh! Sheet protection was supposed to be disabled. :-/
2008-12-23 20:25:55 +0100 kohei r265792 : recovered the code block that was accidentally removed during cws rebase.
2008-12-23 19:03:19 +0100 kohei r265791 : fixed breakage in ods export filter due to rebase to m38.
2008-12-23 16:41:49 +0100 kohei r265787 : CWS-TOOLING: rebase CWS scsheetprotection02 to trunk@265758 (milestone: DEV300:m38)
2008-12-23 05:37:47 +0100 kohei r265768 : deliberately forget document and sheet passwords when importing from or
exporting to excel, to emulate the current behavior.
2008-12-23 05:12:59 +0100 kohei r265767 : removed commented-out unused method ScDocument::SetAutoFilterFlags().
2008-12-23 05:05:19 +0100 kohei r265766 : removed one duplicate method and made associated changes with the removal,
and a little more code cleanup.
2008-12-23 04:24:58 +0100 kohei r265765 : a typo in in-line comment
2008-12-23 04:23:08 +0100 kohei r265764 : remove fprintf statement that blatantly prints out document encryption
password to stdout. not a good practice.
2008-12-23 04:14:21 +0100 kohei r265763 : we actually don't want to clear all options, because if we do, then
we would no longer be able to select any cells on a protected sheet.
2008-12-23 04:07:10 +0100 kohei r265762 : * minor code cleanup (indentation inconsistencies & use of tab)
* fixed unprotecting a sheet with password to make it work again.
2008-12-23 03:22:50 +0100 kohei r265761 : reverted all the new functionalities to the existing ones, while keeping the new code in
as much as I could.
2008-12-22 23:11:08 +0100 kohei r265760 : in xls export filter, renamed two unknown records into records of known name.
2008-12-22 22:34:50 +0100 kohei r265759 : temporarily disable password capability on file export for MS Excel 97.
2008-12-22 17:01:21 +0100 kohei r265754 : CWS-TOOLING: rebase CWS scsheetprotection02 to trunk@264807 (milestone: DEV300:m37)
2008-11-26 03:12:58 +0100 kohei r264335 : recovered a method that was actually used.
2008-11-25 21:51:10 +0100 kohei r264334 : CWS-TOOLING: rebase CWS scsheetprotection02 to trunk@264325 (milestone: DEV300:m36)
2008-10-08 19:57:35 +0200 kohei r262094 : changed description string to make it less technical.
2008-10-01 05:56:58 +0200 kohei r261986 : migrated from the cvs-based cws.
2008-10-01 05:55:19 +0200 kohei r261985 : migrated from the cvs-based cws.
2008-10-01 05:55:00 +0200 kohei r261984 : migrated from the cvs-based cws.
2009-07-01 08:58:41 +00:00
|
|
|
aDocument.CopyTabProtection(nAdjSource, nDestTab);
|
2003-04-28 14:44:31 +00:00
|
|
|
|
|
|
|
if (bRecord)
|
|
|
|
{
|
2010-12-14 18:57:04 -05:00
|
|
|
auto_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
|
|
|
|
auto_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
|
2003-04-28 14:44:31 +00:00
|
|
|
GetUndoManager()->AddUndoAction(
|
2010-12-14 18:57:04 -05:00
|
|
|
new ScUndoCopyTab(this, pSrcList.release(), pDestList.release()));
|
2003-04-28 14:44:31 +00:00
|
|
|
}
|
2010-03-02 12:39:31 +00:00
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bVbaEnabled = aDocument.IsInVBAMode();
|
2010-03-03 16:47:55 +00:00
|
|
|
if ( bVbaEnabled )
|
|
|
|
{
|
|
|
|
String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
|
2010-11-02 15:36:45 +00:00
|
|
|
Reference< XLibraryContainer > xLibContainer = GetBasicContainer();
|
|
|
|
Reference< XVBACompatibility > xVBACompat( xLibContainer, UNO_QUERY );
|
|
|
|
|
|
|
|
if ( xVBACompat.is() )
|
2010-03-03 16:47:55 +00:00
|
|
|
{
|
2010-11-02 15:36:45 +00:00
|
|
|
aLibName = xVBACompat->getProjectName();
|
2010-03-03 16:47:55 +00:00
|
|
|
}
|
2010-11-02 15:36:45 +00:00
|
|
|
|
2010-03-03 16:47:55 +00:00
|
|
|
SCTAB nTabToUse = nDestTab;
|
|
|
|
if ( nDestTab == SC_TAB_APPEND )
|
|
|
|
nTabToUse = aDocument.GetMaxTableNumber() - 1;
|
|
|
|
String sCodeName;
|
|
|
|
String sSource;
|
2010-11-02 15:36:45 +00:00
|
|
|
Reference< XNameContainer > xLib;
|
2010-03-03 16:47:55 +00:00
|
|
|
if( xLibContainer.is() )
|
|
|
|
{
|
|
|
|
com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName );
|
|
|
|
aLibAny >>= xLib;
|
|
|
|
}
|
|
|
|
if( xLib.is() )
|
|
|
|
{
|
|
|
|
rtl::OUString sRTLSource;
|
|
|
|
xLib->getByName( sSrcCodeName ) >>= sRTLSource;
|
|
|
|
sSource = sRTLSource;
|
|
|
|
}
|
|
|
|
VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource );
|
|
|
|
}
|
2010-03-03 18:36:44 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( aDocument.GetChangeTrack() )
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND )
|
|
|
|
nDestTab--;
|
|
|
|
|
|
|
|
if ( nSrcTab == nDestTab )
|
|
|
|
{
|
|
|
|
//! allow only for api calls?
|
2011-01-17 13:20:22 +01:00
|
|
|
return sal_True; // nothing to do, but valid
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aDocument.MoveTab( nSrcTab, nDestTab ))
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (bRecord)
|
|
|
|
{
|
2010-12-14 18:57:04 -05:00
|
|
|
auto_ptr< vector<SCTAB> > pSrcList(new vector<SCTAB>(1, nSrcTab));
|
|
|
|
auto_ptr< vector<SCTAB> > pDestList(new vector<SCTAB>(1, nDestTab));
|
2000-09-18 16:07:07 +00:00
|
|
|
GetUndoManager()->AddUndoAction(
|
2010-12-14 18:57:04 -05:00
|
|
|
new ScUndoMoveTab(this, pSrcList.release(), pDestList.release()));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
PostPaintGridAll();
|
|
|
|
PostPaintExtras();
|
|
|
|
aModificator.SetDocumentModified();
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
return sal_True;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-19 15:12:47 +00:00
|
|
|
IMPL_LINK( ScDocShell, RefreshDBDataHdl, ScRefreshTimer*, pRefreshTimer )
|
2001-04-21 19:31:39 +00:00
|
|
|
{
|
|
|
|
ScDBDocFunc aFunc(*this);
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool bContinue = sal_True;
|
2004-03-19 15:12:47 +00:00
|
|
|
ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer);
|
2001-04-21 19:31:39 +00:00
|
|
|
ScImportParam aImportParam;
|
|
|
|
pDBData->GetImportParam( aImportParam );
|
|
|
|
if (aImportParam.bImport && !pDBData->HasImportSelection())
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
pDBData->GetArea( aRange );
|
2010-11-02 15:36:45 +00:00
|
|
|
Reference< ::com::sun::star::sdbc::XResultSet> xResultSet;
|
2011-03-10 16:55:21 -05:00
|
|
|
bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, xResultSet, NULL, true, false ); //! Api-Flag as parameter
|
2001-04-21 19:31:39 +00:00
|
|
|
// internal operations (sort, query, subtotal) only if no error
|
|
|
|
if (bContinue)
|
|
|
|
{
|
2011-01-17 13:20:22 +01:00
|
|
|
aFunc.RepeatDB( pDBData->GetName(), sal_True, sal_True );
|
2001-04-21 19:31:39 +00:00
|
|
|
RefreshPivotTables(aRange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bContinue != 0;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|