2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* $RCSfile: viewfun2.cxx,v $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-02-27 13:00:54 +00:00
|
|
|
* $Revision: 1.32 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2007-02-27 13:00:54 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2007-02-27 14:00:54 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2005-09-08 22:12:51 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 14:21:51 +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 "scitems.hxx"
|
2002-03-04 18:38:57 +00:00
|
|
|
#include <svx/eeitem.hxx>
|
|
|
|
#define ITEMID_FIELD EE_FEATURE_FIELD
|
2006-05-02 14:53:53 +00:00
|
|
|
#include <sfx2/app.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#define _SVSTDARR_STRINGS
|
|
|
|
#include <svx/boxitem.hxx>
|
|
|
|
#include <svx/fontitem.hxx>
|
2001-11-14 14:44:41 +00:00
|
|
|
#include <svx/scripttypeitem.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/srchitem.hxx>
|
|
|
|
#include <svx/linkmgr.hxx>
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#include <sfx2/docfilt.hxx>
|
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <sfx2/objitem.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#include <svtools/zforlist.hxx>
|
|
|
|
#include <svtools/svstdarr.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#include <vcl/sound.hxx>
|
|
|
|
#include <vcl/waitobj.hxx>
|
|
|
|
|
|
|
|
#include "viewfunc.hxx"
|
|
|
|
|
|
|
|
#include "sc.hrc"
|
|
|
|
#include "globstr.hrc"
|
|
|
|
|
|
|
|
#include "attrib.hxx"
|
|
|
|
#include "autoform.hxx"
|
|
|
|
#include "cell.hxx" // EnterAutoSum
|
|
|
|
#include "compiler.hxx"
|
|
|
|
#include "docfunc.hxx"
|
|
|
|
#include "docpool.hxx"
|
|
|
|
#include "docsh.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "patattr.hxx"
|
|
|
|
#include "printfun.hxx"
|
|
|
|
#include "rangenam.hxx"
|
|
|
|
#include "rangeutl.hxx"
|
|
|
|
#include "refundo.hxx"
|
|
|
|
#include "tablink.hxx"
|
|
|
|
#include "tabvwsh.hxx"
|
|
|
|
#include "uiitems.hxx"
|
|
|
|
#include "undoblk.hxx"
|
|
|
|
#include "undocell.hxx"
|
|
|
|
#include "undotab.hxx"
|
2001-05-11 16:11:53 +00:00
|
|
|
#include "sizedev.hxx"
|
2002-11-20 13:36:29 +00:00
|
|
|
#include "editable.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
// STATIC DATA ---------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::AdjustBlockHeight( BOOL bPaint, ScMarkData* pMarkData )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
if (!pMarkData)
|
|
|
|
pMarkData = &GetViewData()->GetMarkData();
|
|
|
|
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
|
|
|
|
SCCOLROW nRangeCnt = pMarkData->GetMarkRowRanges( pRanges );
|
|
|
|
if (nRangeCnt == 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pRanges[0] = pRanges[1] = GetViewData()->GetCurY();
|
|
|
|
nRangeCnt = 1;
|
|
|
|
}
|
|
|
|
|
2001-05-11 16:11:53 +00:00
|
|
|
double nPPTX = GetViewData()->GetPPTX();
|
|
|
|
double nPPTY = GetViewData()->GetPPTY();
|
|
|
|
Fraction aZoomX = GetViewData()->GetZoomX();
|
|
|
|
Fraction aZoomY = GetViewData()->GetZoomY();
|
|
|
|
|
|
|
|
ScSizeDeviceProvider aProv(pDocSh);
|
|
|
|
if (aProv.IsPrinter())
|
|
|
|
{
|
|
|
|
nPPTX = aProv.GetPPTX();
|
|
|
|
nPPTY = aProv.GetPPTY();
|
|
|
|
aZoomX = aZoomY = Fraction( 1, 1 );
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bAnyChanged = FALSE;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTabCount = pDoc->GetTableCount();
|
|
|
|
for (SCTAB nTab=0; nTab<nTabCount; nTab++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pMarkData->GetTableSelect(nTab))
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOLROW* pOneRange = pRanges;
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bChanged = FALSE;
|
2007-02-27 13:00:54 +00:00
|
|
|
SCROW nPaintY = 0;
|
2004-06-04 11:09:45 +00:00
|
|
|
for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCROW nStartNo = *(pOneRange++);
|
|
|
|
SCROW nEndNo = *(pOneRange++);
|
2001-05-11 16:11:53 +00:00
|
|
|
if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
|
|
|
|
nPPTX, nPPTY, aZoomX, aZoomY, FALSE ))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (!bChanged)
|
|
|
|
nPaintY = nStartNo;
|
|
|
|
bAnyChanged = bChanged = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bPaint && bChanged )
|
|
|
|
pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab,
|
|
|
|
PAINT_GRID | PAINT_LEFT );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete[] pRanges;
|
|
|
|
|
|
|
|
if ( bPaint && bAnyChanged )
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
|
|
|
|
return bAnyChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, BOOL bPaint )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-05-11 16:11:53 +00:00
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
double nPPTX = GetViewData()->GetPPTX();
|
|
|
|
double nPPTY = GetViewData()->GetPPTY();
|
2001-05-11 16:11:53 +00:00
|
|
|
Fraction aZoomX = GetViewData()->GetZoomX();
|
|
|
|
Fraction aZoomY = GetViewData()->GetZoomY();
|
2007-02-27 13:00:54 +00:00
|
|
|
USHORT nOldPixel = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nStartRow == nEndRow)
|
|
|
|
nOldPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
|
|
|
|
|
2001-05-11 16:11:53 +00:00
|
|
|
ScSizeDeviceProvider aProv(pDocSh);
|
|
|
|
if (aProv.IsPrinter())
|
|
|
|
{
|
|
|
|
nPPTX = aProv.GetPPTX();
|
|
|
|
nPPTY = aProv.GetPPTY();
|
|
|
|
aZoomX = aZoomY = Fraction( 1, 1 );
|
|
|
|
}
|
|
|
|
BOOL bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
|
|
|
|
nPPTX, nPPTY, aZoomX, aZoomY, FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bChanged && ( nStartRow == nEndRow ))
|
|
|
|
{
|
|
|
|
USHORT nNewPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
|
|
|
|
if ( nNewPixel == nOldPixel )
|
|
|
|
bChanged = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bPaint && bChanged )
|
2001-05-11 16:11:53 +00:00
|
|
|
pDocSh->PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab,
|
2000-09-18 16:07:07 +00:00
|
|
|
PAINT_GRID | PAINT_LEFT );
|
|
|
|
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
enum ScAutoSum
|
|
|
|
{
|
|
|
|
ScAutoSumNone = 0,
|
|
|
|
ScAutoSumData,
|
|
|
|
ScAutoSumSum
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, SCCOL nCol, SCROW nRow,
|
|
|
|
SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScBaseCell* pCell;
|
|
|
|
pDoc->GetCell( nCol, nRow, nTab, pCell );
|
|
|
|
if ( pCell && pCell->HasValueData() )
|
|
|
|
{
|
|
|
|
if ( pCell->GetCellType() == CELLTYPE_FORMULA )
|
|
|
|
{
|
|
|
|
ScTokenArray* pCode = ((ScFormulaCell*)pCell)->GetCode();
|
|
|
|
if ( pCode && pCode->GetOuterFuncOpCode() == ocSum )
|
|
|
|
{
|
|
|
|
if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend,
|
|
|
|
ScAddress( nCol, nRow, nTab ), eDir ) )
|
|
|
|
return ScAutoSumSum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ScAutoSumData;
|
|
|
|
}
|
|
|
|
return ScAutoSumNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define SC_AUTOSUM_MAXCOUNT 20
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
ScAutoSum lcl_SeekAutoSumData( ScDocument* pDoc, SCCOL& nCol, SCROW& nRow,
|
|
|
|
SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
USHORT nCount = 0;
|
|
|
|
while (nCount < SC_AUTOSUM_MAXCOUNT)
|
|
|
|
{
|
|
|
|
if ( eDir == DIR_TOP )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
if (nRow > 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
--nRow;
|
|
|
|
else
|
|
|
|
return ScAutoSumNone;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
if (nCol > 0)
|
2000-09-18 16:07:07 +00:00
|
|
|
--nCol;
|
|
|
|
else
|
|
|
|
return ScAutoSumNone;
|
|
|
|
}
|
|
|
|
ScAutoSum eSum;
|
|
|
|
if ( (eSum = lcl_IsAutoSumData(
|
|
|
|
pDoc, nCol, nRow, nTab, eDir, nExtend )) != ScAutoSumNone )
|
|
|
|
return eSum;
|
|
|
|
++nCount;
|
|
|
|
}
|
|
|
|
return ScAutoSumNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SC_AUTOSUM_MAXCOUNT
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::GetAutoSumArea( ScRangeList& rRangeList )
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nCol = GetViewData()->GetCurX();
|
|
|
|
SCROW nRow = GetViewData()->GetCurY();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol = nCol;
|
|
|
|
SCROW nStartRow = nRow;
|
|
|
|
SCCOL nEndCol = nCol;
|
|
|
|
SCROW nEndRow = nRow;
|
|
|
|
SCCOL nSeekCol = nCol;
|
|
|
|
SCROW nSeekRow = nRow;
|
|
|
|
SCCOLROW nExtend; // wird per Reference gueltig bei ScAutoSumSum
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL bCol = FALSE;
|
|
|
|
BOOL bRow = FALSE;
|
|
|
|
|
|
|
|
ScAutoSum eSum;
|
2004-06-04 11:09:45 +00:00
|
|
|
if ( nRow != 0
|
2000-09-18 16:07:07 +00:00
|
|
|
&& ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
|
|
|
|
DIR_TOP, nExtend )) == ScAutoSumData )
|
|
|
|
&& ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
|
|
|
|
DIR_LEFT, nExtend )) == ScAutoSumData )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
bRow = TRUE;
|
|
|
|
nSeekRow = nRow - 1;
|
|
|
|
}
|
2004-06-04 11:09:45 +00:00
|
|
|
else if ( nCol != 0 && (eSum = lcl_IsAutoSumData( pDoc, nCol-1, nRow, nTab,
|
2000-09-18 16:07:07 +00:00
|
|
|
DIR_LEFT, nExtend )) == ScAutoSumData )
|
|
|
|
{
|
|
|
|
bCol = TRUE;
|
|
|
|
nSeekCol = nCol - 1;
|
|
|
|
}
|
2007-02-27 13:00:54 +00:00
|
|
|
else if ( (eSum = lcl_SeekAutoSumData( pDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend )) != ScAutoSumNone )
|
2000-09-18 16:07:07 +00:00
|
|
|
bRow = TRUE;
|
2007-02-27 13:00:54 +00:00
|
|
|
else if (( eSum = lcl_SeekAutoSumData( pDoc, nSeekCol, nRow, nTab, DIR_LEFT, nExtend )) != ScAutoSumNone )
|
2000-09-18 16:07:07 +00:00
|
|
|
bCol = TRUE;
|
|
|
|
|
|
|
|
if ( bCol || bRow )
|
|
|
|
{
|
|
|
|
if ( bRow )
|
|
|
|
{
|
|
|
|
nStartRow = nSeekRow; // nSeekRow evtl. per Reference angepasst
|
|
|
|
if ( eSum == ScAutoSumSum )
|
|
|
|
nEndRow = nStartRow; // nur Summen summieren
|
|
|
|
else
|
|
|
|
nEndRow = nRow - 1; // Datenbereich evtl. nach unten erweitern
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nStartCol = nSeekCol; // nSeekCol evtl. per Reference angepasst
|
|
|
|
if ( eSum == ScAutoSumSum )
|
|
|
|
nEndCol = nStartCol; // nur Summen summieren
|
|
|
|
else
|
|
|
|
nEndCol = nCol - 1; // Datenbereich evtl. nach rechts erweitern
|
|
|
|
}
|
|
|
|
BOOL bContinue = FALSE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ( eSum == ScAutoSumData )
|
|
|
|
{
|
|
|
|
if ( bRow )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
while ( nStartRow != 0 && lcl_IsAutoSumData( pDoc, nCol,
|
2000-09-18 16:07:07 +00:00
|
|
|
nStartRow-1, nTab, DIR_TOP, nExtend ) == eSum )
|
|
|
|
--nStartRow;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
while ( nStartCol != 0 && lcl_IsAutoSumData( pDoc, nStartCol-1,
|
2000-09-18 16:07:07 +00:00
|
|
|
nRow, nTab, DIR_LEFT, nExtend ) == eSum )
|
|
|
|
--nStartCol;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rRangeList.Append(
|
|
|
|
ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ) );
|
|
|
|
if ( eSum == ScAutoSumSum )
|
|
|
|
{
|
|
|
|
if ( bRow )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
nEndRow = nExtend;
|
|
|
|
SCROW nTmp = nEndRow ;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScAutoSum eSkip;
|
|
|
|
while ( (eSkip = lcl_IsAutoSumData( pDoc, nCol,
|
|
|
|
nEndRow, nTab, DIR_TOP, nExtend )) == ScAutoSumData
|
2004-06-04 11:09:45 +00:00
|
|
|
&& nEndRow != 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
--nEndRow;
|
|
|
|
if ( eSkip == ScAutoSumSum && nEndRow < nTmp )
|
|
|
|
{
|
|
|
|
bContinue = TRUE;
|
|
|
|
nStartRow = nEndRow;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bContinue = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
nEndCol = static_cast<SCCOL>(nExtend);;
|
|
|
|
SCCOL nTmp = nEndCol ;
|
2000-09-18 16:07:07 +00:00
|
|
|
ScAutoSum eSkip;
|
|
|
|
while ( (eSkip = lcl_IsAutoSumData( pDoc, nEndCol,
|
|
|
|
nRow, nTab, DIR_LEFT, nExtend )) == ScAutoSumData
|
2004-06-04 11:09:45 +00:00
|
|
|
&& nEndCol != 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
--nEndCol;
|
|
|
|
if ( eSkip == ScAutoSumSum && nEndCol < nTmp )
|
|
|
|
{
|
|
|
|
bContinue = TRUE;
|
|
|
|
nStartCol = nEndCol;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bContinue = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while ( bContinue );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2002-11-19 14:07:16 +00:00
|
|
|
void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, sal_Bool bSubTotal) // Block mit Summen fuellen
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
String aRef;
|
|
|
|
rRangeList.Format( aRef, SCA_VALID, pDoc );
|
|
|
|
|
|
|
|
String aFormula = '=';
|
|
|
|
ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
|
2004-03-08 11:01:19 +00:00
|
|
|
const ScFuncDesc* pDesc = NULL;
|
2002-11-19 14:07:16 +00:00
|
|
|
if (!bSubTotal)
|
|
|
|
pDesc = pFuncMgr->Get( SC_OPCODE_SUM );
|
|
|
|
else
|
|
|
|
pDesc = pFuncMgr->Get( SC_OPCODE_SUB_TOTAL );
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( pDesc && pDesc->pFuncName )
|
|
|
|
{
|
|
|
|
aFormula += *pDesc->pFuncName;
|
2002-11-19 14:07:16 +00:00
|
|
|
if (bSubTotal)
|
|
|
|
aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "(9;" ));
|
|
|
|
else
|
|
|
|
aFormula += '(';
|
2000-09-18 16:07:07 +00:00
|
|
|
aFormula += aRef;
|
|
|
|
aFormula += ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterBlock( aFormula, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::EnterBlock( const String& rString, const EditTextObject* pData )
|
|
|
|
{
|
|
|
|
// Mehrfachselektion vorher abfragen...
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nCol = GetViewData()->GetCurX();
|
|
|
|
SCROW nRow = GetViewData()->GetCurY();
|
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
if ( rMark.IsMultiMarked() )
|
|
|
|
{
|
|
|
|
rMark.MarkToSimple();
|
|
|
|
if ( rMark.IsMultiMarked() )
|
|
|
|
{ // "Einfuegen auf Mehrfachselektion nicht moeglich"
|
|
|
|
ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
|
|
|
|
|
|
|
|
// insert into single cell
|
|
|
|
if ( pData )
|
|
|
|
EnterData( nCol, nRow, nTab, pData );
|
|
|
|
else
|
|
|
|
EnterData( nCol, nRow, nTab, rString );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
String aNewStr = rString;
|
|
|
|
if ( pData )
|
|
|
|
{
|
|
|
|
const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
|
|
|
|
ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() );
|
|
|
|
aEngine.SetText(*pData);
|
|
|
|
|
|
|
|
ScEditAttrTester aTester( &aEngine );
|
|
|
|
if (!aTester.NeedsObject())
|
|
|
|
{
|
|
|
|
aNewStr = aEngine.GetText();
|
|
|
|
pData = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Einfuegen per PasteFromClip
|
|
|
|
|
|
|
|
WaitObject aWait( GetFrameWin() );
|
|
|
|
|
|
|
|
ScAddress aPos( nCol, nRow, nTab );
|
|
|
|
|
|
|
|
ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP );
|
|
|
|
pInsDoc->ResetClip( pDoc, nTab );
|
|
|
|
|
|
|
|
if (aNewStr.GetChar(0) == '=') // Formel ?
|
|
|
|
{
|
|
|
|
// SetString geht nicht, weil in Clipboard-Dokumenten nicht kompiliert wird!
|
|
|
|
ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aPos, aNewStr );
|
|
|
|
pInsDoc->PutCell( nCol, nRow, nTab, pFCell );
|
|
|
|
}
|
|
|
|
else if ( pData )
|
|
|
|
pInsDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pData, pDoc, NULL ) );
|
|
|
|
else
|
|
|
|
pInsDoc->SetString( nCol, nRow, nTab, aNewStr );
|
|
|
|
|
|
|
|
pInsDoc->SetClipArea( ScRange(aPos) );
|
|
|
|
// auf Block einfuegen, mit Undo etc.
|
|
|
|
if ( PasteFromClip( IDF_CONTENTS, pInsDoc, PASTE_NOFUNC, FALSE, FALSE,
|
|
|
|
FALSE, INS_NONE, IDF_ATTRIB ) )
|
|
|
|
{
|
|
|
|
const SfxUInt32Item* pItem = (SfxUInt32Item*) pInsDoc->GetAttr(
|
|
|
|
nCol, nRow, nTab, ATTR_VALUE_FORMAT );
|
|
|
|
if ( pItem )
|
|
|
|
{ // Numberformat setzen wenn inkompatibel
|
|
|
|
// MarkData wurde bereits in PasteFromClip MarkToSimple'ed
|
|
|
|
ScRange aRange;
|
|
|
|
rMark.GetMarkArea( aRange );
|
|
|
|
ScPatternAttr* pPattern = new ScPatternAttr( pDoc->GetPool() );
|
|
|
|
pPattern->GetItemSet().Put( *pItem );
|
|
|
|
short nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() );
|
|
|
|
pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark,
|
|
|
|
*pPattern, nNewType );
|
|
|
|
delete pPattern;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pInsDoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
void ScViewFunc::PaintWidthHeight( BOOL bColumns, SCCOLROW nStart, SCCOLROW nEnd )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
|
|
|
|
USHORT nParts = PAINT_GRID;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol = 0;
|
|
|
|
SCROW nStartRow = 0;
|
|
|
|
SCCOL nEndCol = MAXCOL; // fuer Test auf Merge
|
|
|
|
SCROW nEndRow = MAXROW;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bColumns )
|
|
|
|
{
|
|
|
|
nParts |= PAINT_TOP;
|
2004-06-04 11:09:45 +00:00
|
|
|
nStartCol = static_cast<SCCOL>(nStart);
|
|
|
|
nEndCol = static_cast<SCCOL>(nEnd);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nParts |= PAINT_LEFT;
|
|
|
|
nStartRow = nStart;
|
|
|
|
nEndRow = nEnd;
|
|
|
|
}
|
|
|
|
if (pDoc->HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
|
|
|
|
HASATTR_MERGED | HASATTR_OVERLAPPED ))
|
|
|
|
{
|
|
|
|
nStartCol = 0;
|
|
|
|
nStartRow = 0;
|
|
|
|
}
|
|
|
|
GetViewData()->GetDocShell()->PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// manueller Seitenumbruch
|
|
|
|
|
|
|
|
void ScViewFunc::InsertPageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos,
|
|
|
|
BOOL bSetModified )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScAddress aCursor;
|
|
|
|
if (pPos)
|
|
|
|
aCursor = *pPos;
|
|
|
|
else
|
|
|
|
aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
|
|
|
|
|
|
|
|
BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
|
|
|
|
InsertPageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE );
|
|
|
|
|
|
|
|
if ( bSuccess && bSetModified )
|
|
|
|
UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::DeletePageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos,
|
|
|
|
BOOL bSetModified )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScAddress aCursor;
|
|
|
|
if (pPos)
|
|
|
|
aCursor = *pPos;
|
|
|
|
else
|
|
|
|
aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
|
|
|
|
|
|
|
|
BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
|
|
|
|
RemovePageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE );
|
|
|
|
|
|
|
|
if ( bSuccess && bSetModified )
|
|
|
|
UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::RemoveManualBreaks()
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo(pDoc->IsUndoEnabled());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
{
|
|
|
|
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
|
|
|
|
pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pUndoDoc );
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
2000-09-18 16:07:07 +00:00
|
|
|
new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
|
2001-02-14 14:34:08 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
pDoc->RemoveManualBreaks(nTab);
|
|
|
|
pDoc->UpdatePageBreaks(nTab);
|
|
|
|
|
|
|
|
UpdatePageBreakData( TRUE );
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::SetPrintZoom(USHORT nScale, USHORT nPages)
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
pDocSh->SetPrintZoom( nTab, nScale, nPages );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScViewFunc::AdjustPrintZoom()
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
2003-04-08 15:34:38 +00:00
|
|
|
if ( !GetViewData()->GetSimpleArea( aRange ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
GetViewData()->GetMarkData().GetMultiMarkArea( aRange );
|
|
|
|
GetViewData()->GetDocShell()->AdjustPrintZoom( aRange );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2003-12-01 08:56:11 +00:00
|
|
|
void ScViewFunc::SetPrintRanges( BOOL bEntireSheet, const String* pPrint,
|
2000-09-18 16:07:07 +00:00
|
|
|
const String* pRepCol, const String* pRepRow,
|
|
|
|
BOOL bAddPrint )
|
|
|
|
{
|
2000-11-15 18:46:03 +00:00
|
|
|
// on all selected tables
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTabCount = pDoc->GetTableCount();
|
2000-11-15 18:46:03 +00:00
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab;
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo (pDoc->IsUndoEnabled());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
|
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
for (nTab=0; nTab<nTabCount; nTab++)
|
|
|
|
if (rMark.GetTableSelect(nTab))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-11-15 18:46:03 +00:00
|
|
|
ScRange aRange( 0,0,nTab );
|
|
|
|
|
|
|
|
// print ranges
|
|
|
|
|
2003-12-01 08:56:11 +00:00
|
|
|
if( !bAddPrint )
|
|
|
|
pDoc->ClearPrintRanges( nTab );
|
|
|
|
|
|
|
|
if( bEntireSheet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-12-01 08:56:11 +00:00
|
|
|
pDoc->SetPrintEntireSheet( nTab );
|
|
|
|
}
|
|
|
|
else if ( pPrint )
|
|
|
|
{
|
|
|
|
if ( pPrint->Len() )
|
2000-11-15 18:46:03 +00:00
|
|
|
{
|
|
|
|
USHORT nTCount = pPrint->GetTokenCount();
|
|
|
|
for (USHORT i=0; i<nTCount; i++)
|
|
|
|
{
|
|
|
|
String aToken = pPrint->GetToken(i);
|
|
|
|
if ( aRange.ParseAny( aToken, pDoc ) & SCA_VALID )
|
2003-12-01 08:56:11 +00:00
|
|
|
pDoc->AddPrintRange( nTab, aRange );
|
2000-11-15 18:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2003-12-01 08:56:11 +00:00
|
|
|
else // NULL = use selection (print range is always set), use empty string to delete all ranges
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2003-04-08 15:34:38 +00:00
|
|
|
if ( GetViewData()->GetSimpleArea( aRange ) )
|
2000-11-15 18:46:03 +00:00
|
|
|
{
|
2003-12-01 08:56:11 +00:00
|
|
|
pDoc->AddPrintRange( nTab, aRange );
|
2000-11-15 18:46:03 +00:00
|
|
|
}
|
|
|
|
else if ( rMark.IsMultiMarked() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-09-16 15:23:22 +00:00
|
|
|
rMark.MarkToMulti();
|
2000-11-15 18:46:03 +00:00
|
|
|
ScRangeListRef aList( new ScRangeList );
|
|
|
|
rMark.FillRangeListWithMarks( aList, FALSE );
|
|
|
|
USHORT nCnt = (USHORT) aList->Count();
|
|
|
|
if ( nCnt )
|
|
|
|
{
|
|
|
|
ScRangePtr pR;
|
|
|
|
USHORT i;
|
|
|
|
for ( pR = aList->First(), i=0; i < nCnt;
|
|
|
|
pR = aList->Next(), i++ )
|
|
|
|
{
|
2003-12-01 08:56:11 +00:00
|
|
|
pDoc->AddPrintRange( nTab, *pR );
|
2000-11-15 18:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
// repeat columns
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
if ( pRepCol )
|
|
|
|
{
|
|
|
|
if ( !pRepCol->Len() )
|
|
|
|
pDoc->SetRepeatColRange( nTab, NULL );
|
|
|
|
else
|
|
|
|
if ( aRange.ParseAny( *pRepCol, pDoc ) & SCA_VALID )
|
|
|
|
pDoc->SetRepeatColRange( nTab, &aRange );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
// repeat rows
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
if ( pRepRow )
|
|
|
|
{
|
|
|
|
if ( !pRepRow->Len() )
|
|
|
|
pDoc->SetRepeatRowRange( nTab, NULL );
|
|
|
|
else
|
|
|
|
if ( aRange.ParseAny( *pRepRow, pDoc ) & SCA_VALID )
|
|
|
|
pDoc->SetRepeatRowRange( nTab, &aRange );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
// undo (for all tables)
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nCurTab = GetViewData()->GetTabNo();
|
2001-02-14 14:34:08 +00:00
|
|
|
ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoPrintRange( pDocSh, nCurTab, pOldRanges, pNewRanges ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-11-15 18:46:03 +00:00
|
|
|
// update page breaks
|
|
|
|
|
|
|
|
for (nTab=0; nTab<nTabCount; nTab++)
|
|
|
|
if (rMark.GetTableSelect(nTab))
|
|
|
|
ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxBindings& rBindings = GetViewData()->GetBindings();
|
2000-09-18 16:07:07 +00:00
|
|
|
rBindings.Invalidate( SID_DELETE_PRINTAREA );
|
|
|
|
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Zellen zusammenfassen
|
|
|
|
|
|
|
|
BOOL ScViewFunc::TestMergeCells() // Vorab-Test (fuer Menue)
|
|
|
|
{
|
2002-08-30 14:09:23 +00:00
|
|
|
// simple test: TRUE if there's a selection but no multi selection
|
|
|
|
|
|
|
|
const ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
if ( rMark.IsMultiMarked() )
|
|
|
|
{
|
|
|
|
ScMarkData aNewMark( rMark ); // use local copy for MarkToSimple
|
|
|
|
aNewMark.MarkToSimple();
|
|
|
|
return aNewMark.IsMarked() && !aNewMark.IsMultiMarked();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return rMark.IsMarked();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::MergeCells( BOOL bApi, BOOL& rDoContents, BOOL bRecord )
|
|
|
|
{
|
|
|
|
// Editable- und Verschachtelungs-Abfrage muss vorneweg sein (auch in DocFunc),
|
|
|
|
// damit dann nicht die Inhalte-QueryBox kommt
|
2002-11-20 13:36:29 +00:00
|
|
|
ScEditableTester aTester( this );
|
|
|
|
if (!aTester.IsEditable())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ErrorMessage(aTester.GetMessageId());
|
2000-09-18 16:07:07 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
rMark.MarkToSimple();
|
|
|
|
if (!rMark.IsMarked())
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
|
|
|
|
|
|
|
ScRange aMarkRange;
|
|
|
|
rMark.GetMarkArea( aMarkRange );
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol = aMarkRange.aStart.Col();
|
|
|
|
SCROW nStartRow = aMarkRange.aStart.Row();
|
|
|
|
SCTAB nStartTab = aMarkRange.aStart.Tab();
|
|
|
|
SCCOL nEndCol = aMarkRange.aEnd.Col();
|
|
|
|
SCROW nEndRow = aMarkRange.aEnd.Row();
|
|
|
|
SCTAB nEndTab = aMarkRange.aEnd.Tab();
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nStartCol == nEndCol && nStartRow == nEndRow )
|
|
|
|
{
|
|
|
|
// nichts zu tun
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
|
|
|
|
HASATTR_MERGED | HASATTR_OVERLAPPED ) )
|
|
|
|
{ // "Zusammenfassen nicht verschachteln !"
|
|
|
|
ErrorMessage(STR_MSSG_MERGECELLS_0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bOk = TRUE;
|
|
|
|
BOOL bNeedContents = FALSE;
|
|
|
|
|
|
|
|
if ( !pDoc->IsBlockEmpty( nStartTab, nStartCol,nStartRow+1, nStartCol,nEndRow ) ||
|
|
|
|
!pDoc->IsBlockEmpty( nStartTab, nStartCol+1,nStartRow, nEndCol,nEndRow ) )
|
|
|
|
{
|
|
|
|
bNeedContents = TRUE;
|
|
|
|
if (!bApi)
|
|
|
|
{
|
|
|
|
MessBox aBox( GetViewData()->GetDialogParent(),
|
|
|
|
WinBits(WB_YES_NO_CANCEL | WB_DEF_NO),
|
|
|
|
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
|
|
|
|
ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) );
|
|
|
|
USHORT nRetVal = aBox.Execute();
|
|
|
|
|
|
|
|
if ( nRetVal == RET_YES )
|
|
|
|
rDoContents = TRUE;
|
|
|
|
else if ( nRetVal == RET_CANCEL )
|
|
|
|
bOk = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bOk)
|
|
|
|
{
|
|
|
|
HideCursor();
|
|
|
|
bOk = pDocSh->GetDocFunc().MergeCells( aMarkRange, rDoContents, bRecord, bApi );
|
|
|
|
ShowCursor();
|
|
|
|
|
|
|
|
if (bOk)
|
|
|
|
{
|
|
|
|
SetCursor( nStartCol, nStartRow );
|
|
|
|
//DoneBlockMode( FALSE);
|
|
|
|
Unmark();
|
|
|
|
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
UpdateInputLine();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bOk;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::TestRemoveMerge()
|
|
|
|
{
|
|
|
|
BOOL bMerged = FALSE;
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea( aRange ))
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) )
|
|
|
|
bMerged = TRUE;
|
|
|
|
}
|
|
|
|
return bMerged;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::RemoveMerge( BOOL bRecord )
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea( aRange ))
|
|
|
|
{
|
2006-07-25 08:59:51 +00:00
|
|
|
ScRange aExtended( aRange );
|
|
|
|
GetViewData()->GetDocument()->ExtendMerge( aExtended );
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
2006-07-25 08:59:51 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
HideCursor();
|
|
|
|
BOOL bOk = pDocSh->GetDocFunc().UnmergeCells( aRange, bRecord, FALSE );
|
2006-07-25 08:59:51 +00:00
|
|
|
MarkRange( aExtended );
|
2000-09-18 16:07:07 +00:00
|
|
|
ShowCursor();
|
2006-07-25 08:59:51 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bOk)
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
}
|
|
|
|
return TRUE; //! bOk ??
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::FillSimple( FillDir eDir, BOOL bRecord )
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea(aRange))
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
const ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
BOOL bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
UpdateScrollBars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
|
|
|
|
double fStart, double fStep, double fMax, BOOL bRecord )
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea(aRange))
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
const ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
BOOL bSuccess = pDocSh->GetDocFunc().
|
|
|
|
FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd,
|
|
|
|
fStart, fStep, fMax, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
UpdateScrollBars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
|
|
|
|
SCCOL nEndCol, SCROW nEndRow, ULONG nCount, BOOL bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab );
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
const ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
BOOL bSuccess = pDocSh->GetDocFunc().
|
|
|
|
FillAuto( aRange, &rMark, eDir, nCount, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
MarkRange( aRange, FALSE ); // aRange ist in FillAuto veraendert worden
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
UpdateScrollBars();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::FillTab( USHORT nFlags, USHORT nFunction, BOOL bSkipEmpty, BOOL bAsLink )
|
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
//! allow source sheet to be protected
|
|
|
|
ScEditableTester aTester( this );
|
|
|
|
if (!aTester.IsEditable())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ErrorMessage(aTester.GetMessageId());
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo(pDoc->IsUndoEnabled());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ScRange aMarkRange;
|
|
|
|
rMark.MarkToSimple();
|
|
|
|
BOOL bMulti = rMark.IsMultiMarked();
|
|
|
|
if (bMulti)
|
|
|
|
rMark.GetMultiMarkArea( aMarkRange );
|
|
|
|
else if (rMark.IsMarked())
|
|
|
|
rMark.GetMarkArea( aMarkRange );
|
|
|
|
else
|
|
|
|
aMarkRange = ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
|
|
|
|
|
|
|
|
ScDocument* pUndoDoc = NULL;
|
|
|
|
// if ( bRecord )
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( pDoc, nTab, nTab );
|
|
|
|
// pUndoDoc->SelectTable( nTab, TRUE ); // nur fuer Markierung
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTabCount = pDoc->GetTableCount();
|
|
|
|
for (SCTAB i=0; i<nTabCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
if (i != nTab && rMark.GetTableSelect(i))
|
|
|
|
{
|
|
|
|
pUndoDoc->AddUndoTab( i, i );
|
|
|
|
aMarkRange.aStart.SetTab( i );
|
|
|
|
aMarkRange.aEnd.SetTab( i );
|
|
|
|
pDoc->CopyToDocument( aMarkRange, IDF_ALL, bMulti, pUndoDoc );
|
|
|
|
// pUndoDoc->SelectTable( i, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bMulti)
|
|
|
|
pDoc->FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aMarkRange.aStart.SetTab( nTab );
|
|
|
|
aMarkRange.aEnd.SetTab( nTab );
|
|
|
|
pDoc->FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
|
|
|
|
}
|
|
|
|
|
|
|
|
// if ( bRecord )
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
{ //! fuer ChangeTrack erst zum Schluss
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoFillTable( pDocSh, rMark,
|
|
|
|
aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
|
|
|
|
aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
|
|
|
|
pUndoDoc, bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocSh->PostPaintGridAll();
|
|
|
|
pDocSh->PostDataChanged();
|
|
|
|
}
|
|
|
|
|
2001-03-26 18:26:30 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-09-20 12:49:17 +00:00
|
|
|
/** Downward fill of selected cell(s) by double-clicking cross-hair cursor
|
|
|
|
|
|
|
|
Extends a current selection down to the last non-empty cell of an adjacent
|
|
|
|
column when the lower-right corner of the selection is double-clicked. It
|
|
|
|
uses a left-adjoining non-empty column as a guide if such is available,
|
|
|
|
otherwise a right-adjoining non-empty column is used.
|
|
|
|
|
|
|
|
@author Kohei Yoshida (kohei@openoffice.org)
|
|
|
|
|
|
|
|
@return No return value
|
|
|
|
|
|
|
|
@see #i12313#
|
|
|
|
*/
|
|
|
|
void ScViewFunc::FillCrossDblClick()
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
GetViewData()->GetSimpleArea( aRange );
|
|
|
|
aRange.Justify();
|
|
|
|
|
|
|
|
SCTAB nTab = GetViewData()->GetCurPos().Tab();
|
|
|
|
SCCOL nStartX = aRange.aStart.Col();
|
|
|
|
SCROW nStartY = aRange.aStart.Row();
|
|
|
|
SCCOL nEndX = aRange.aEnd.Col();
|
|
|
|
SCROW nEndY = aRange.aEnd.Row();
|
|
|
|
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
|
|
|
|
// Make sure the selection is not empty
|
|
|
|
if ( pDoc->IsBlockEmpty( nTab, nStartX, nStartY, nEndX, nEndY ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( nEndY < MAXROW )
|
|
|
|
{
|
|
|
|
if ( nStartX > 0 )
|
|
|
|
{
|
|
|
|
SCCOL nMovX = nStartX - 1;
|
|
|
|
SCROW nMovY = nStartY;
|
|
|
|
|
|
|
|
if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
|
|
|
|
pDoc->HasData( nMovX, nStartY + 1, nTab ) )
|
|
|
|
{
|
|
|
|
pDoc->FindAreaPos( nMovX, nMovY, nTab, 0, 1 );
|
|
|
|
|
|
|
|
if ( nMovY > nEndY )
|
|
|
|
{
|
|
|
|
FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
|
|
|
|
nMovY - nEndY );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nEndX < MAXCOL )
|
|
|
|
{
|
|
|
|
SCCOL nMovX = nEndX + 1;
|
|
|
|
SCROW nMovY = nStartY;
|
|
|
|
|
|
|
|
if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
|
|
|
|
pDoc->HasData( nMovX, nStartY + 1, nTab ) )
|
|
|
|
{
|
|
|
|
pDoc->FindAreaPos( nMovX, nMovY, nTab, 0, 1 );
|
|
|
|
|
|
|
|
if ( nMovY > nEndY )
|
|
|
|
{
|
|
|
|
FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
|
|
|
|
nMovY - nEndY );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2001-03-26 18:26:30 +00:00
|
|
|
void ScViewFunc::TransliterateText( sal_Int32 nType )
|
|
|
|
{
|
|
|
|
ScMarkData aFuncMark = GetViewData()->GetMarkData();
|
|
|
|
if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
|
|
|
|
{
|
|
|
|
// no selection -> use cursor position
|
|
|
|
|
|
|
|
ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
|
|
|
|
aFuncMark.SetMarkArea( ScRange( aCursor ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
|
|
|
|
TransliterateText( aFuncMark, nType, TRUE, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
GetViewData()->GetViewShell()->UpdateInputHandler();
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// AutoFormat
|
|
|
|
|
|
|
|
ScAutoFormatData* ScViewFunc::CreateAutoFormatData()
|
|
|
|
{
|
|
|
|
ScAutoFormatData* pData = NULL;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol;
|
|
|
|
SCROW nStartRow;
|
|
|
|
SCTAB nStartTab;
|
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
|
|
|
SCTAB nEndTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab))
|
|
|
|
{
|
|
|
|
if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 )
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
pData = new ScAutoFormatData;
|
|
|
|
pDoc->GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pData;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::AutoFormat( USHORT nFormatNo, BOOL bRecord )
|
|
|
|
{
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea(aRange))
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
|
|
|
|
BOOL bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
// nur wegen Matrix nicht editierbar? Attribute trotzdem ok
|
|
|
|
BOOL bOnlyNotBecauseOfMatrix;
|
|
|
|
if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_PROTECTIONERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol;
|
|
|
|
SCROW nStartRow;
|
|
|
|
SCTAB nStartTab;
|
|
|
|
SCCOL nEndCol;
|
|
|
|
SCROW nEndRow;
|
|
|
|
SCTAB nEndTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab))
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
BOOL bSize = (*ScGlobal::GetAutoFormat())[nFormatNo]->GetIncludeWidthHeight();
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bRecord && !pDoc->IsUndoEnabled())
|
|
|
|
bRecord = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ScDocument* pUndoDoc = NULL;
|
|
|
|
if ( bRecord )
|
|
|
|
{
|
|
|
|
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bSize, bSize );
|
|
|
|
pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
|
|
|
|
IDF_ATTRIB, FALSE, pUndoDoc );
|
|
|
|
if (bSize)
|
|
|
|
{
|
|
|
|
pDoc->CopyToDocument( nStartCol,0,nStartTab, nEndCol,MAXROW,nEndTab,
|
|
|
|
IDF_NONE, FALSE, pUndoDoc );
|
|
|
|
pDoc->CopyToDocument( 0,nStartRow,nStartTab, MAXCOL,nEndRow,nEndTab,
|
|
|
|
IDF_NONE, FALSE, pUndoDoc );
|
|
|
|
}
|
|
|
|
pDoc->BeginDrawUndo();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFrameWin()->EnterWait();
|
|
|
|
pDoc->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, rMark );
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
|
|
|
|
if (bSize)
|
|
|
|
{
|
|
|
|
SetMarkedWidthOrHeight( TRUE, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, FALSE, FALSE );
|
|
|
|
SetMarkedWidthOrHeight( FALSE, SC_SIZE_VISOPT, 0, FALSE, FALSE );
|
|
|
|
pDocSh->PostPaint( 0,0,nStartTab, MAXCOL,MAXROW,nStartTab,
|
|
|
|
PAINT_GRID | PAINT_LEFT | PAINT_TOP );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL bAdj = AdjustBlockHeight( FALSE );
|
|
|
|
if (bAdj)
|
|
|
|
pDocSh->PostPaint( 0,nStartRow,nStartTab, MAXCOL,MAXROW,nStartTab,
|
|
|
|
PAINT_GRID | PAINT_LEFT );
|
|
|
|
else
|
|
|
|
pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
|
|
|
|
nEndCol, nEndRow, nEndTab, PAINT_GRID );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
|
|
|
|
{
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoAutoFormat( pDocSh,
|
|
|
|
ScRange(nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab),
|
|
|
|
pUndoDoc, rMark, bSize, nFormatNo ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
pDocSh->UpdateOle(GetViewData());
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Suchen & Ersetzen
|
|
|
|
|
|
|
|
void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
|
|
|
|
BOOL bAddUndo, BOOL bIsApi )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bAddUndo && !pDoc->IsUndoEnabled())
|
|
|
|
bAddUndo = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nCol = GetViewData()->GetCurX();
|
|
|
|
SCROW nRow = GetViewData()->GetCurY();
|
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2007-02-27 13:00:54 +00:00
|
|
|
// BOOL bAttrib = pSearchItem->GetPattern();
|
2000-09-18 16:07:07 +00:00
|
|
|
USHORT nCommand = pSearchItem->GetCommand();
|
|
|
|
BOOL bAllTables = pSearchItem->IsAllTables();
|
|
|
|
BOOL* pOldSelectedTables = NULL;
|
|
|
|
USHORT nOldSelectedCount = 0;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nOldTab = nTab;
|
|
|
|
SCTAB nLastTab = pDoc->GetTableCount() - 1;
|
|
|
|
SCTAB nStartTab, nEndTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bAllTables )
|
|
|
|
{
|
|
|
|
nStartTab = 0;
|
|
|
|
nEndTab = nLastTab;
|
|
|
|
pOldSelectedTables = new BOOL [ nEndTab + 1 ];
|
2004-06-04 11:09:45 +00:00
|
|
|
for ( SCTAB j = 0; j <= nEndTab; j++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pOldSelectedTables[j] = rMark.GetTableSelect( j );
|
|
|
|
if ( pOldSelectedTables[j] )
|
|
|
|
++nOldSelectedCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //! mindestens eine ist immer selektiert
|
|
|
|
nStartTab = nEndTab = rMark.GetFirstSelected();
|
2004-06-04 11:09:45 +00:00
|
|
|
for ( SCTAB j = nStartTab + 1; j <= nLastTab; j++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( rMark.GetTableSelect( j ) )
|
|
|
|
nEndTab = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_REPLACE
|
|
|
|
|| nCommand == SVX_SEARCHCMD_REPLACE_ALL )
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( (bAllTables || rMark.GetTableSelect( j )) &&
|
|
|
|
pDoc->IsTabProtected( j ) )
|
|
|
|
{
|
|
|
|
if ( pOldSelectedTables )
|
|
|
|
delete [] pOldSelectedTables;
|
|
|
|
ErrorMessage(STR_PROTECTIONERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_FIND
|
|
|
|
|| nCommand == SVX_SEARCHCMD_FIND_ALL)
|
|
|
|
bAddUndo = FALSE;
|
|
|
|
|
|
|
|
//! bAttrib bei Undo beruecksichtigen !!!
|
|
|
|
|
|
|
|
ScDocument* pUndoDoc = NULL;
|
|
|
|
ScMarkData* pUndoMark = NULL;
|
|
|
|
String aUndoStr;
|
|
|
|
if (bAddUndo)
|
|
|
|
{
|
|
|
|
pUndoMark = new ScMarkData( rMark ); // Markierung wird veraendert
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_REPLACE_ALL )
|
|
|
|
{
|
|
|
|
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bAllTables )
|
|
|
|
{ //! alles selektieren, erst nachdem pUndoMark erzeugt wurde
|
2004-06-04 11:09:45 +00:00
|
|
|
for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
rMark.SelectTable( j, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DoneBlockMode(TRUE); // Markierung nicht loeschen!
|
|
|
|
InitOwnBlockMode();
|
|
|
|
|
|
|
|
// wenn vom Anfang an gesucht wird, nicht nochmal fragen ob vom Anfang gesucht werden soll
|
|
|
|
BOOL bFirst = TRUE;
|
|
|
|
if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward() )
|
|
|
|
bFirst = FALSE;
|
|
|
|
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
GetFrameWin()->EnterWait();
|
|
|
|
if (pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab, rMark, aUndoStr, pUndoDoc ) )
|
|
|
|
{
|
|
|
|
bFound = TRUE;
|
|
|
|
bFirst = TRUE;
|
|
|
|
if (bAddUndo)
|
|
|
|
{
|
|
|
|
GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoReplace( GetViewData()->GetDocShell(), *pUndoMark,
|
|
|
|
nCol, nRow, nTab,
|
|
|
|
aUndoStr, pUndoDoc, pSearchItem ) );
|
|
|
|
pUndoDoc = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
break; // Abbruch while True
|
|
|
|
}
|
|
|
|
else if ( bFirst && (nCommand == SVX_SEARCHCMD_FIND ||
|
|
|
|
nCommand == SVX_SEARCHCMD_REPLACE) )
|
|
|
|
{
|
|
|
|
bFirst = FALSE;
|
|
|
|
USHORT nRetVal;
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
if ( bIsApi )
|
|
|
|
nRetVal = RET_NO;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Suchen-Dialog als Parent, wenn vorhanden
|
|
|
|
Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
|
|
|
|
USHORT nStrId;
|
|
|
|
if ( pSearchItem->GetBackward() )
|
|
|
|
{
|
|
|
|
if ( nStartTab == nEndTab )
|
|
|
|
nStrId = STR_MSSG_SEARCHANDREPLACE_1;
|
|
|
|
else
|
|
|
|
nStrId = STR_MSSG_SEARCHANDREPLACE_4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nStartTab == nEndTab )
|
|
|
|
nStrId = STR_MSSG_SEARCHANDREPLACE_2;
|
|
|
|
else
|
|
|
|
nStrId = STR_MSSG_SEARCHANDREPLACE_5;
|
|
|
|
}
|
|
|
|
MessBox aBox( pParent, WinBits(WB_YES_NO | WB_DEF_YES),
|
|
|
|
ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_3 ),
|
|
|
|
ScGlobal::GetRscString( nStrId ) );
|
|
|
|
nRetVal = aBox.Execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nRetVal == RET_YES )
|
|
|
|
{
|
|
|
|
ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
|
|
|
|
if (pSearchItem->GetBackward())
|
|
|
|
nTab = nEndTab;
|
|
|
|
else
|
|
|
|
nTab = nStartTab;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break; // Abbruch while True
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // nichts gefunden
|
|
|
|
{
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
|
|
|
|
{
|
|
|
|
pDocSh->PostPaintGridAll(); // Markierung
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
if (!bIsApi)
|
|
|
|
{
|
|
|
|
// Suchen-Dialog als Parent, wenn vorhanden
|
|
|
|
Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
|
|
|
|
// "nichts gefunden"
|
|
|
|
InfoBox aBox( pParent, ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_0 ) );
|
|
|
|
aBox.Execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
break; // Abbruch while True
|
|
|
|
}
|
|
|
|
} // of while TRUE
|
|
|
|
|
|
|
|
if ( pOldSelectedTables )
|
|
|
|
{ // urspruenglich selektierte Tabellen wiederherstellen
|
2004-06-04 11:09:45 +00:00
|
|
|
for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
rMark.SelectTable( j, pOldSelectedTables[j] );
|
|
|
|
}
|
|
|
|
if ( bFound )
|
|
|
|
{ // durch Fundstelle neu selektierte Tabelle bleibt
|
|
|
|
rMark.SelectTable( nTab, TRUE );
|
|
|
|
// wenn vorher nur eine selektiert war, ist es ein Tausch
|
|
|
|
//! wenn nicht, ist jetzt evtl. eine mehr selektiert
|
|
|
|
if ( nOldSelectedCount == 1 && nTab != nOldTab )
|
|
|
|
rMark.SelectTable( nOldTab, FALSE );
|
|
|
|
}
|
|
|
|
delete [] pOldSelectedTables;
|
|
|
|
}
|
|
|
|
if ( bFound )
|
|
|
|
{
|
|
|
|
if ( nTab != GetViewData()->GetTabNo() )
|
|
|
|
SetTabNo( nTab );
|
|
|
|
|
|
|
|
// wenn nichts markiert ist, DoneBlockMode, damit von hier aus
|
|
|
|
// direkt per Shift-Cursor markiert werden kann:
|
|
|
|
if (!rMark.IsMarked() && !rMark.IsMultiMarked())
|
|
|
|
DoneBlockMode(TRUE);
|
|
|
|
|
|
|
|
AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
|
|
|
|
SetCursor( nCol, nRow, TRUE );
|
|
|
|
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_REPLACE
|
|
|
|
|| nCommand == SVX_SEARCHCMD_REPLACE_ALL )
|
|
|
|
{
|
|
|
|
if ( nCommand == SVX_SEARCHCMD_REPLACE )
|
|
|
|
pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID );
|
|
|
|
else
|
|
|
|
pDocSh->PostPaintGridAll();
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
else if ( nCommand == SVX_SEARCHCMD_FIND_ALL )
|
|
|
|
pDocSh->PostPaintGridAll(); // Markierung
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
}
|
|
|
|
|
|
|
|
delete pUndoDoc; // loeschen wenn nicht benutzt
|
|
|
|
delete pUndoMark; // kann immer geloescht werden
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Zielwertsuche
|
|
|
|
|
|
|
|
void ScViewFunc::Solve( const ScSolveParam& rParam )
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nDestCol = rParam.aRefVariableCell.Col();
|
|
|
|
SCROW nDestRow = rParam.aRefVariableCell.Row();
|
|
|
|
SCTAB nDestTab = rParam.aRefVariableCell.Tab();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-11-20 13:36:29 +00:00
|
|
|
ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow );
|
|
|
|
if (!aTester.IsEditable())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ErrorMessage(aTester.GetMessageId());
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pDoc )
|
|
|
|
{
|
|
|
|
String aTargetValStr;
|
|
|
|
if ( rParam.pStrTargetVal != NULL )
|
|
|
|
aTargetValStr = *(rParam.pStrTargetVal);
|
|
|
|
|
|
|
|
String aMsgStr;
|
|
|
|
String aResStr;
|
|
|
|
double nSolveResult;
|
|
|
|
|
|
|
|
GetFrameWin()->EnterWait();
|
|
|
|
|
|
|
|
BOOL bExact =
|
|
|
|
pDoc->Solver(
|
|
|
|
rParam.aRefFormulaCell.Col(),
|
|
|
|
rParam.aRefFormulaCell.Row(),
|
|
|
|
rParam.aRefFormulaCell.Tab(),
|
|
|
|
nDestCol, nDestRow, nDestTab,
|
|
|
|
aTargetValStr,
|
|
|
|
nSolveResult );
|
|
|
|
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
|
|
|
|
SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
|
|
|
|
ULONG nFormat = 0;
|
|
|
|
const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab );
|
|
|
|
if ( pPattern )
|
|
|
|
nFormat = pPattern->GetNumberFormat( pFormatter );
|
|
|
|
Color* p;
|
|
|
|
pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p );
|
|
|
|
|
|
|
|
if ( bExact )
|
|
|
|
{
|
|
|
|
aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_0 );
|
|
|
|
aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_1 );
|
|
|
|
aMsgStr += String( aResStr );
|
|
|
|
aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_2 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_3 );
|
|
|
|
aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_4 );
|
|
|
|
aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_5 );
|
|
|
|
aMsgStr += String( aResStr );
|
|
|
|
aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_6 );
|
|
|
|
}
|
|
|
|
|
|
|
|
MessBox aBox( GetViewData()->GetDialogParent(),
|
|
|
|
WinBits(WB_YES_NO | WB_DEF_NO),
|
|
|
|
ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr );
|
|
|
|
USHORT nRetVal = aBox.Execute();
|
|
|
|
|
|
|
|
if ( RET_YES == nRetVal )
|
|
|
|
EnterData( nDestCol, nDestRow, nDestTab, nSolveResult );
|
|
|
|
|
|
|
|
GetViewData()->GetViewShell()->UpdateInputHandler( TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Mehrfachoperation
|
|
|
|
|
|
|
|
void ScViewFunc::TabOp( const ScTabOpParam& rParam, BOOL bRecord )
|
|
|
|
{
|
|
|
|
ScRange aRange;
|
|
|
|
if (GetViewData()->GetSimpleArea(aRange))
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
|
|
|
pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, FALSE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_NOMULTISELECT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::MakeScenario( const String& rName, const String& rComment,
|
|
|
|
const Color& rColor, USHORT nFlags )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark );
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nFlags & SC_SCENARIO_COPYALL)
|
|
|
|
SetTabNo( nNewTab, TRUE ); // SC_SCENARIO_COPYALL -> sichtbar
|
|
|
|
else
|
|
|
|
{
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxBindings& rBindings = GetViewData()->GetBindings();
|
2000-09-18 16:07:07 +00:00
|
|
|
rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
|
|
|
|
rBindings.Invalidate( SID_TABLES_COUNT );
|
|
|
|
rBindings.Invalidate( SID_SELECT_SCENARIO );
|
|
|
|
rBindings.Invalidate( FID_TABLE_SHOW );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::ExtendScenario()
|
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ScEditableTester aTester( this );
|
|
|
|
if (!aTester.IsEditable())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ErrorMessage(aTester.GetMessageId());
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Undo: Attribute anwenden
|
|
|
|
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
ScPatternAttr aPattern( pDoc->GetPool() );
|
|
|
|
aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
|
|
|
|
aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
|
|
|
|
ApplySelectionPattern(aPattern);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::UseScenario( const String& rName )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
DoneBlockMode();
|
|
|
|
InitOwnBlockMode();
|
|
|
|
pDocSh->UseScenario( nTab, rName );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Tabelle einfuegen
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::InsertTable( const String& rName, SCTAB nTab, BOOL bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt
|
|
|
|
BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
|
|
|
|
InsertTable( nTab, rName, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
SetTabNo( nTab, TRUE );
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Tabellen einfuegen
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::InsertTables(SvStrings *pNames, SCTAB nTab,
|
|
|
|
SCTAB nCount, BOOL bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2001-02-26 13:12:11 +00:00
|
|
|
if (bRecord && !pDoc->IsUndoEnabled())
|
2001-02-14 14:34:08 +00:00
|
|
|
bRecord = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
SvStrings *pNameList= NULL;
|
|
|
|
|
|
|
|
WaitObject aWait( GetFrameWin() );
|
|
|
|
|
|
|
|
if (bRecord)
|
|
|
|
{
|
|
|
|
pNameList= new SvStrings;
|
|
|
|
pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL bFlag=FALSE;
|
|
|
|
|
|
|
|
String aValTabName;
|
|
|
|
String *pStr;
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
for(SCTAB i=0;i<nCount;i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if(pNames!=NULL)
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
pStr=pNames->GetObject(static_cast<USHORT>(i));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aValTabName.Erase();
|
|
|
|
pDoc->CreateValidTabName( aValTabName);
|
|
|
|
pStr=&aValTabName;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pDoc->InsertTab( nTab+i,*pStr))
|
|
|
|
{
|
|
|
|
bFlag=TRUE;
|
|
|
|
pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pNameList!=NULL)
|
|
|
|
pNameList->Insert(new String(*pStr),pNameList->Count());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFlag)
|
|
|
|
{
|
|
|
|
if (bRecord)
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoInsertTables( pDocSh, nTab, FALSE, pNameList));
|
|
|
|
|
|
|
|
// Views updaten:
|
|
|
|
|
|
|
|
SetTabNo( nTab, TRUE );
|
|
|
|
pDocSh->PostPaintExtras();
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL ScViewFunc::AppendTable( const String& rName, BOOL bRecord )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2001-02-26 13:12:11 +00:00
|
|
|
if (bRecord && !pDoc->IsUndoEnabled())
|
2001-02-14 14:34:08 +00:00
|
|
|
bRecord = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
WaitObject aWait( GetFrameWin() );
|
|
|
|
|
|
|
|
if (bRecord)
|
|
|
|
pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
|
|
|
|
|
|
|
|
if (pDoc->InsertTab( SC_TAB_APPEND, rName ))
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = pDoc->GetTableCount()-1;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (bRecord)
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoInsertTab( pDocSh, nTab, TRUE, rName));
|
|
|
|
GetViewData()->InsertTab( nTab );
|
|
|
|
SetTabNo( nTab, TRUE );
|
|
|
|
pDocSh->PostPaintExtras();
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::DeleteTable( SCTAB nTab, BOOL bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
|
|
|
|
|
|
|
BOOL bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nNewTab = nTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( nNewTab >= pDoc->GetTableCount() )
|
|
|
|
--nNewTab;
|
|
|
|
SetTabNo( nNewTab, TRUE );
|
|
|
|
}
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nNewTab = TheTabs[0];
|
2000-09-18 16:07:07 +00:00
|
|
|
int i;
|
|
|
|
WaitObject aWait( GetFrameWin() );
|
2001-02-26 13:12:11 +00:00
|
|
|
if (bRecord && !pDoc->IsUndoEnabled())
|
2001-02-14 14:34:08 +00:00
|
|
|
bRecord = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2000-10-05 09:55:35 +00:00
|
|
|
while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
|
|
|
|
--nNewTab;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bWasLinked = FALSE;
|
|
|
|
ScDocument* pUndoDoc = NULL;
|
|
|
|
ScRefUndoData* pUndoData = NULL;
|
|
|
|
if (bRecord)
|
|
|
|
{
|
|
|
|
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
|
|
|
|
// pUndoDoc->InitDrawLayer( pDocSh );
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nCount = pDoc->GetTableCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// pUndoDoc->InitUndo( pDoc, 0, nCount-1 ); // incl. Ref.
|
|
|
|
|
|
|
|
String aOldName;
|
|
|
|
for(i=0;i<TheTabs.Count();i++)
|
|
|
|
{
|
2007-02-27 13:00:54 +00:00
|
|
|
SCTAB nTab = TheTabs[sal::static_int_cast<USHORT>(i)];
|
2000-09-18 16:07:07 +00:00
|
|
|
if (i==0)
|
|
|
|
pUndoDoc->InitUndo( pDoc, nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags
|
|
|
|
else
|
|
|
|
pUndoDoc->AddUndoTab( nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags
|
|
|
|
|
|
|
|
pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pUndoDoc );
|
|
|
|
pDoc->GetName( nTab, aOldName );
|
|
|
|
pUndoDoc->RenameTab( nTab, aOldName, FALSE );
|
|
|
|
if (pDoc->IsLinked(nTab))
|
|
|
|
{
|
|
|
|
bWasLinked = TRUE;
|
|
|
|
pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab),
|
|
|
|
pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
|
2001-04-18 11:14:41 +00:00
|
|
|
pDoc->GetLinkTab(nTab),
|
|
|
|
pDoc->GetLinkRefreshDelay(nTab) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
if ( pDoc->IsScenario(nTab) )
|
|
|
|
{
|
|
|
|
pUndoDoc->SetScenario( nTab, TRUE );
|
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
|
|
|
USHORT nScenFlags;
|
|
|
|
pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
|
|
|
|
pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
|
|
|
|
BOOL bActive = pDoc->IsActiveScenario( nTab );
|
|
|
|
pUndoDoc->SetActiveScenario( nTab, bActive );
|
|
|
|
}
|
2000-10-05 09:55:35 +00:00
|
|
|
pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2003-04-28 14:46:04 +00:00
|
|
|
if ( pDoc->IsTabProtected( nTab ) )
|
|
|
|
pUndoDoc->SetTabProtection( nTab, TRUE, pDoc->GetTabPassword( nTab ) );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Drawing-Layer muss sein Undo selbst in der Hand behalten !!!
|
|
|
|
// pUndoDoc->TransferDrawPage(pDoc, nTab,nTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
pUndoDoc->AddUndoTab( 0, nCount-1 ); // alle Tabs fuer Referenzen
|
|
|
|
|
|
|
|
pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage
|
|
|
|
|
|
|
|
pUndoData = new ScRefUndoData( pDoc );
|
|
|
|
}
|
|
|
|
|
2000-10-05 09:55:35 +00:00
|
|
|
BOOL bDelDone = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
for(i=TheTabs.Count()-1;i>=0;i--)
|
|
|
|
{
|
2007-02-27 13:00:54 +00:00
|
|
|
if (pDoc->DeleteTab( TheTabs[sal::static_int_cast<USHORT>(i)], pUndoDoc ))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-10-05 09:55:35 +00:00
|
|
|
bDelDone = TRUE;
|
2007-02-27 13:00:54 +00:00
|
|
|
pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bRecord)
|
|
|
|
{
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoDeleteTab( GetViewData()->GetDocShell(), TheTabs,
|
|
|
|
pUndoDoc, pUndoData ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-05 09:55:35 +00:00
|
|
|
if (bDelDone)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( nNewTab >= pDoc->GetTableCount() )
|
2000-10-05 09:55:35 +00:00
|
|
|
nNewTab = pDoc->GetTableCount() - 1;
|
|
|
|
|
|
|
|
SetTabNo( nNewTab, TRUE );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (bWasLinked)
|
|
|
|
{
|
|
|
|
pDocSh->UpdateLinks(); // Link-Manager updaten
|
2000-09-22 17:57:10 +00:00
|
|
|
GetViewData()->GetBindings().Invalidate(SID_LINKS);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pDocSh->PostPaintExtras();
|
|
|
|
pDocSh->SetDocumentModified();
|
2005-09-28 11:19:59 +00:00
|
|
|
|
|
|
|
SfxApplication* pSfxApp = SFX_APP(); // Navigator
|
|
|
|
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
|
|
|
|
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete pUndoDoc;
|
|
|
|
delete pUndoData;
|
|
|
|
}
|
2000-10-05 09:55:35 +00:00
|
|
|
return bDelDone;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
BOOL ScViewFunc::RenameTable( const String& rName, SCTAB nTab )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
// Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt
|
|
|
|
BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
|
|
|
|
RenameTable( nTab, rName, TRUE, FALSE );
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
// Der Tabellenname koennte in einer Formel vorkommen...
|
|
|
|
GetViewData()->GetViewShell()->UpdateInputHandler();
|
|
|
|
}
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::InsertAreaLink( const String& rFile,
|
|
|
|
const String& rFilter, const String& rOptions,
|
2001-04-05 09:52:34 +00:00
|
|
|
const String& rSource, ULONG nRefresh )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nPosX = GetViewData()->GetCurX();
|
|
|
|
SCROW nPosY = GetViewData()->GetCurY();
|
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
ScAddress aPos( nPosX, nPosY, nTab );
|
|
|
|
|
2005-09-28 11:19:59 +00:00
|
|
|
pDocSh->GetDocFunc().InsertAreaLink( rFile, rFilter, rOptions, rSource, aPos, nRefresh, FALSE, FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::InsertTableLink( const String& rFile,
|
|
|
|
const String& rFilter, const String& rOptions,
|
|
|
|
const String& rTabName )
|
|
|
|
{
|
|
|
|
String aFilterName = rFilter;
|
|
|
|
String aOpt = rOptions;
|
|
|
|
ScDocumentLoader aLoader( rFile, aFilterName, aOpt );
|
|
|
|
if (!aLoader.IsError())
|
|
|
|
{
|
|
|
|
ScDocShell* pSrcSh = aLoader.GetDocShell();
|
|
|
|
ScDocument* pSrcDoc = pSrcSh->GetDocument();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = MAXTAB+1;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (!rTabName.Len()) // kein Name angegeben -> erste Tabelle
|
|
|
|
nTab = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
String aTemp;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nCount = pSrcDoc->GetTableCount();
|
|
|
|
for (SCTAB i=0; i<nCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pSrcDoc->GetName( i, aTemp );
|
|
|
|
if ( aTemp == rTabName )
|
|
|
|
nTab = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nTab <= MAXTAB )
|
|
|
|
ImportTables( pSrcSh, 1, &nTab, TRUE,
|
|
|
|
GetViewData()->GetTabNo() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Tabellen aus anderem Dokument kopieren / linken
|
|
|
|
|
|
|
|
void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nCount, const SCTAB* pSrcTabs, BOOL bLink,SCTAB nTab )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocument* pSrcDoc = pSrcShell->GetDocument();
|
|
|
|
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo(pDoc->IsUndoEnabled());
|
2004-06-04 11:09:45 +00:00
|
|
|
//SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL bError = FALSE;
|
|
|
|
BOOL bRefs = FALSE;
|
|
|
|
BOOL bName = FALSE;
|
|
|
|
|
|
|
|
if (pSrcDoc->GetDrawLayer())
|
|
|
|
pDocSh->MakeDrawLayer();
|
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nInsCount = 0;
|
|
|
|
SCTAB i;
|
2000-09-18 16:07:07 +00:00
|
|
|
for( i=0; i<nCount; i++ )
|
|
|
|
{ // #63304# insert sheets first and update all references
|
|
|
|
String aName;
|
|
|
|
pSrcDoc->GetName( pSrcTabs[i], aName );
|
|
|
|
pDoc->CreateValidTabName( aName );
|
|
|
|
if ( !pDoc->InsertTab( nTab+i, aName ) )
|
|
|
|
{
|
|
|
|
bError = TRUE; // total error
|
|
|
|
break; // for
|
|
|
|
}
|
|
|
|
++nInsCount;
|
|
|
|
}
|
|
|
|
for (i=0; i<nCount && !bError; i++)
|
|
|
|
{
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nSrcTab = pSrcTabs[i];
|
|
|
|
SCTAB nDestTab1=nTab+i;
|
2000-09-18 16:07:07 +00:00
|
|
|
ULONG nErrVal = pDoc->TransferTab( pSrcDoc, nSrcTab, nDestTab1,
|
|
|
|
FALSE ); // no insert
|
|
|
|
|
|
|
|
switch (nErrVal)
|
|
|
|
{
|
|
|
|
case 0: // interner Fehler oder voll Fehler
|
|
|
|
bError = TRUE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
bRefs = TRUE;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
bName = TRUE;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
bRefs = bName = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TransferTab doesn't copy drawing objects with bInsertNew=FALSE
|
|
|
|
if ( !bError )
|
|
|
|
pDoc->TransferDrawPage( pSrcDoc, nSrcTab, nDestTab1 );
|
|
|
|
|
|
|
|
if(!bError &&pSrcDoc->IsScenario(nSrcTab))
|
|
|
|
{
|
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
|
|
|
USHORT nFlags;
|
|
|
|
|
|
|
|
pSrcDoc->GetScenarioData(nSrcTab, aComment,aColor, nFlags);
|
|
|
|
pDoc->SetScenario( nDestTab1,TRUE);
|
|
|
|
pDoc->SetScenarioData( nTab+i,aComment,aColor,nFlags);
|
|
|
|
BOOL bActive = pSrcDoc->IsActiveScenario(nSrcTab );
|
|
|
|
pDoc->SetActiveScenario( nDestTab1, bActive );
|
|
|
|
BOOL bVisible=pSrcDoc->IsVisible(nSrcTab);
|
|
|
|
pDoc->SetVisible(nDestTab1,bVisible );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bLink)
|
|
|
|
{
|
|
|
|
SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
|
|
|
|
|
|
|
|
SfxMedium* pMed = pSrcShell->GetMedium();
|
|
|
|
String aFileName = pMed->GetName();
|
|
|
|
String aFilterName;
|
|
|
|
if (pMed->GetFilter())
|
|
|
|
aFilterName = pMed->GetFilter()->GetFilterName();
|
|
|
|
String aOptions = ScDocumentLoader::GetOptions(*pMed);
|
|
|
|
|
|
|
|
BOOL bWasThere = pDoc->HasLink( aFileName, aFilterName, aOptions );
|
|
|
|
|
2001-04-18 11:14:41 +00:00
|
|
|
ULONG nRefresh = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
String aTabStr;
|
|
|
|
for (i=0; i<nInsCount; i++)
|
|
|
|
{
|
|
|
|
pSrcDoc->GetName( pSrcTabs[i], aTabStr );
|
|
|
|
pDoc->SetLink( nTab+i, SC_LINK_NORMAL,
|
2001-04-18 11:14:41 +00:00
|
|
|
aFileName, aFilterName, aOptions, aTabStr, nRefresh );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!bWasThere) // Link pro Quelldokument nur einmal eintragen
|
|
|
|
{
|
2001-04-18 11:14:41 +00:00
|
|
|
ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions, nRefresh );
|
2000-09-18 16:07:07 +00:00
|
|
|
pLink->SetInCreate( TRUE );
|
|
|
|
pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName );
|
|
|
|
pLink->Update();
|
|
|
|
pLink->SetInCreate( FALSE );
|
|
|
|
|
2000-09-22 17:57:10 +00:00
|
|
|
SfxBindings& rBindings = GetViewData()->GetBindings();
|
2000-09-18 16:07:07 +00:00
|
|
|
rBindings.Invalidate( SID_LINKS );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
{
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoImportTab( pDocSh, nTab, nCount, bLink ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
for (i=0; i<nInsCount; i++)
|
|
|
|
GetViewData()->InsertTab(nTab);
|
|
|
|
SetTabNo(nTab,TRUE);
|
|
|
|
pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
|
|
|
|
PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS );
|
|
|
|
|
|
|
|
SfxApplication* pSfxApp = SFX_APP();
|
|
|
|
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
|
|
|
|
|
|
|
|
pDocSh->PostPaintExtras();
|
|
|
|
pDocSh->PostPaintGridAll();
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
|
|
|
|
if (bRefs)
|
|
|
|
ErrorMessage(STR_ABSREFLOST);
|
|
|
|
if (bName)
|
|
|
|
ErrorMessage(STR_NAMECONFLICT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// Tabelle in anderes Dokument verschieben / kopieren
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
ScDocShell* pDocShell = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDestDoc = NULL;
|
|
|
|
ScDocShell* pDestShell = NULL;
|
|
|
|
ScTabViewShell* pDestViewSh = NULL;
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo (pDoc->IsUndoEnabled());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
BOOL bNewDoc = ( nDestDocNo == SC_DOC_NEW );
|
|
|
|
if ( bNewDoc )
|
|
|
|
{
|
2005-02-16 17:12:00 +00:00
|
|
|
nDestTab = 0; // als erstes einfuegen
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// ohne SFX_CALLMODE_RECORD ausfuehren, weil schon im Move-Befehl enthalten:
|
|
|
|
|
|
|
|
String aUrl = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("private:factory/"));
|
2001-01-30 13:40:37 +00:00
|
|
|
aUrl.AppendAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP )); // "scalc"
|
2000-09-18 16:07:07 +00:00
|
|
|
SfxStringItem aItem( SID_FILE_NAME, aUrl );
|
2001-01-30 13:40:37 +00:00
|
|
|
SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-01-30 13:40:37 +00:00
|
|
|
const SfxPoolItem* pRetItem = GetViewData()->GetDispatcher().Execute(
|
|
|
|
SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aItem, &aTarget, 0L );
|
|
|
|
if ( pRetItem )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-30 13:40:37 +00:00
|
|
|
if ( pRetItem->ISA( SfxObjectItem ) )
|
|
|
|
pDestShell = PTR_CAST( ScDocShell, ((const SfxObjectItem*)pRetItem)->GetShell() );
|
|
|
|
else if ( pRetItem->ISA( SfxViewFrameItem ) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-01-30 13:40:37 +00:00
|
|
|
SfxViewFrame* pFrm = ((const SfxViewFrameItem*)pRetItem)->GetFrame();
|
|
|
|
if (pFrm)
|
|
|
|
pDestShell = PTR_CAST( ScDocShell, pFrm->GetObjectShell() );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-01-30 13:40:37 +00:00
|
|
|
if (pDestShell)
|
|
|
|
pDestViewSh = pDestShell->GetBestViewShell();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDestShell = ScDocShell::GetShellByNum( nDestDocNo );
|
|
|
|
|
|
|
|
if (!pDestShell)
|
|
|
|
{
|
|
|
|
DBG_ERROR("Dest-Doc nicht gefunden !!!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDestDoc = pDestShell->GetDocument();
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTab = GetViewData()->GetTabNo();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if (pDestDoc != pDoc)
|
|
|
|
{
|
|
|
|
if (bNewDoc)
|
|
|
|
{
|
|
|
|
while (pDestDoc->GetTableCount() > 1)
|
|
|
|
pDestDoc->DeleteTab(0);
|
|
|
|
pDestDoc->RenameTab( 0,
|
|
|
|
String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("______42_____")),
|
|
|
|
FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTabCount = pDoc->GetTableCount();
|
|
|
|
SCTAB nTabSelCount = rMark.GetSelectCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SvShorts TheTabs;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
for(SCTAB i=0;i<nTabCount;i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if(rMark.GetTableSelect(i))
|
|
|
|
{
|
|
|
|
String aTabName;
|
|
|
|
pDoc->GetName( i, aTabName);
|
|
|
|
TheTabs.Insert(i,TheTabs.Count());
|
2004-06-04 11:09:45 +00:00
|
|
|
for(SCTAB j=i+1;j<nTabCount;j++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
|
|
|
|
{
|
|
|
|
pDoc->GetName( j, aTabName);
|
|
|
|
TheTabs.Insert(j,TheTabs.Count());
|
|
|
|
i=j;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFrameWin()->EnterWait();
|
|
|
|
|
|
|
|
if (pDoc->GetDrawLayer())
|
|
|
|
pDestShell->MakeDrawLayer();
|
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (!bNewDoc && bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
pDestDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
|
|
|
|
|
|
|
|
ULONG nErrVal =1;
|
2004-06-04 11:09:45 +00:00
|
|
|
if(nDestTab==SC_TAB_APPEND)
|
|
|
|
nDestTab=pDestDoc->GetTableCount();
|
|
|
|
SCTAB nDestTab1=nDestTab;
|
|
|
|
for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
|
2000-09-18 16:07:07 +00:00
|
|
|
{ // #63304# insert sheets first and update all references
|
|
|
|
String aName;
|
2004-06-04 11:09:45 +00:00
|
|
|
pDoc->GetName( TheTabs[j], aName );
|
2000-09-18 16:07:07 +00:00
|
|
|
pDestDoc->CreateValidTabName( aName );
|
|
|
|
if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
|
|
|
|
{
|
|
|
|
nErrVal = 0; // total error
|
|
|
|
break; // for
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( nErrVal > 0 )
|
|
|
|
{
|
|
|
|
nDestTab1 = nDestTab;
|
2004-06-04 11:09:45 +00:00
|
|
|
for(USHORT i=0;i<TheTabs.Count();i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
nErrVal = pDestDoc->TransferTab( pDoc, TheTabs[i], nDestTab1,
|
|
|
|
FALSE ); // no insert
|
|
|
|
|
|
|
|
// TransferTab doesn't copy drawing objects with bInsertNew=FALSE
|
|
|
|
if ( nErrVal > 0 )
|
|
|
|
pDestDoc->TransferDrawPage( pDoc, TheTabs[i], nDestTab1 );
|
|
|
|
|
|
|
|
if(nErrVal>0 && pDoc->IsScenario(TheTabs[i]))
|
|
|
|
{
|
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
|
|
|
USHORT nFlags;
|
|
|
|
|
|
|
|
pDoc->GetScenarioData(TheTabs[i], aComment,aColor, nFlags);
|
|
|
|
pDestDoc->SetScenario(nDestTab1,TRUE);
|
|
|
|
pDestDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
|
|
|
|
BOOL bActive = pDoc->IsActiveScenario(TheTabs[i]);
|
|
|
|
pDestDoc->SetActiveScenario(nDestTab1, bActive );
|
|
|
|
|
|
|
|
BOOL bVisible=pDoc->IsVisible(TheTabs[i]);
|
|
|
|
pDestDoc->SetVisible(nDestTab1,bVisible );
|
|
|
|
|
|
|
|
}
|
2003-04-28 14:46:04 +00:00
|
|
|
|
|
|
|
if ( nErrVal > 0 && pDoc->IsTabProtected( TheTabs[i] ) )
|
|
|
|
pDestDoc->SetTabProtection( nDestTab1, TRUE, pDoc->GetTabPassword( TheTabs[i] ) );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
nDestTab1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String sName;
|
2001-02-14 14:34:08 +00:00
|
|
|
if (!bNewDoc && bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pDestDoc->GetName(nDestTab, sName);
|
|
|
|
pDestShell->GetUndoManager()->AddUndoAction(
|
2004-06-04 11:09:45 +00:00
|
|
|
new ScUndoImportTab( pDestShell, nDestTab,
|
|
|
|
static_cast<SCTAB>(TheTabs.Count()), FALSE));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDestShell->GetUndoManager()->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
GetFrameWin()->LeaveWait();
|
|
|
|
switch (nErrVal)
|
|
|
|
{
|
|
|
|
case 0: // interner Fehler oder voll Fehler
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_TABINSERT_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
2007-02-27 13:00:54 +00:00
|
|
|
//break;
|
2000-09-18 16:07:07 +00:00
|
|
|
case 2:
|
|
|
|
ErrorMessage(STR_ABSREFLOST);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ErrorMessage(STR_NAMECONFLICT);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_ABSREFLOST);
|
|
|
|
ErrorMessage(STR_NAMECONFLICT);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//pDestShell->GetUndoManager()->Clear(); //! Undo implementieren !!!
|
|
|
|
/*
|
|
|
|
String sName;
|
|
|
|
pDestDoc->GetName(nDestTab, sName);
|
|
|
|
pDestShell->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoInsertTab( pDestShell, nDestTab, TRUE, sName ) );
|
|
|
|
*/
|
|
|
|
if (!bCopy)
|
|
|
|
{
|
|
|
|
if(nTabCount!=nTabSelCount)
|
|
|
|
DeleteTables(TheTabs);// incl. Paint & Undo
|
|
|
|
else
|
|
|
|
ErrorMessage(STR_TABREMOVE_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bNewDoc)
|
|
|
|
{
|
|
|
|
// ChartListenerCollection must be updated before DeleteTab
|
|
|
|
if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
|
|
|
|
pDestDoc->UpdateChartListenerCollection();
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.Count())); // alte erste Tabelle
|
2000-09-18 16:07:07 +00:00
|
|
|
//? pDestDoc->SelectTable(0, TRUE); // neue erste Tabelle selektieren
|
|
|
|
if (pDestViewSh)
|
|
|
|
pDestViewSh->TabChanged(); // Pages auf dem Drawing-Layer
|
|
|
|
pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
|
|
|
|
PAINT_GRID | PAINT_TOP | PAINT_LEFT |
|
|
|
|
PAINT_EXTRAS | PAINT_SIZE );
|
|
|
|
// PAINT_SIZE fuer Gliederung
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) );
|
|
|
|
pDestShell->PostPaintExtras();
|
|
|
|
pDestShell->PostPaintGridAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
TheTabs.Remove(0,TheTabs.Count());
|
|
|
|
|
|
|
|
pDestShell->SetDocumentModified();
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
}
|
|
|
|
else // innerhalb des Dokuments
|
|
|
|
{
|
|
|
|
|
|
|
|
ScMarkData& rMark = GetViewData()->GetMarkData();
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nTabCount = pDoc->GetTableCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SvShorts TheTabs;
|
|
|
|
SvShorts TheDestTabs;
|
2000-09-18 16:07:07 +00:00
|
|
|
SvStrings TheTabNames;
|
|
|
|
String aDestName;
|
|
|
|
String *pString;
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
for(SCTAB i=0;i<nTabCount;i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if(rMark.GetTableSelect(i))
|
|
|
|
{
|
|
|
|
String aTabName;
|
|
|
|
pDoc->GetName( i, aTabName);
|
|
|
|
TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
for(SCTAB j=i+1;j<nTabCount;j++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
|
|
|
|
{
|
|
|
|
pDoc->GetName( j, aTabName);
|
|
|
|
TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
|
|
|
|
i=j;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bCopy && bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
|
|
|
|
|
|
|
|
pDoc->GetName( nDestTab, aDestName);
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nDestTab1=nDestTab;
|
|
|
|
SCTAB nMovTab=0;
|
|
|
|
for(int j=0;j<TheTabNames.Count();j++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
nTabCount = pDoc->GetTableCount();
|
2007-02-27 13:00:54 +00:00
|
|
|
pString=TheTabNames[sal::static_int_cast<USHORT>(j)];
|
2000-09-18 16:07:07 +00:00
|
|
|
if(!pDoc->GetTable(*pString,nMovTab))
|
|
|
|
{
|
|
|
|
nMovTab=nTabCount;
|
|
|
|
}
|
|
|
|
if(!pDoc->GetTable(aDestName,nDestTab1))
|
|
|
|
{
|
|
|
|
nDestTab1=nTabCount;
|
|
|
|
}
|
|
|
|
pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, FALSE ); // Undo ist hier
|
|
|
|
|
|
|
|
if(bCopy && pDoc->IsScenario(nMovTab))
|
|
|
|
{
|
|
|
|
String aComment;
|
|
|
|
Color aColor;
|
|
|
|
USHORT nFlags;
|
|
|
|
|
|
|
|
pDoc->GetScenarioData(nMovTab, aComment,aColor, nFlags);
|
|
|
|
pDoc->SetScenario(nDestTab1,TRUE);
|
|
|
|
pDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
|
|
|
|
BOOL bActive = pDoc->IsActiveScenario(nMovTab );
|
|
|
|
pDoc->SetActiveScenario( nDestTab1, bActive );
|
|
|
|
BOOL bVisible=pDoc->IsVisible(nMovTab);
|
|
|
|
pDoc->SetVisible(nDestTab1,bVisible );
|
|
|
|
}
|
|
|
|
|
|
|
|
TheTabs.Insert(nMovTab,TheTabs.Count());
|
|
|
|
|
|
|
|
if(!bCopy)
|
|
|
|
{
|
|
|
|
if(!pDoc->GetTable(*pString,nDestTab1))
|
|
|
|
{
|
|
|
|
nDestTab1=nTabCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TheDestTabs.Insert(nDestTab1,TheDestTabs.Count());
|
|
|
|
delete pString;
|
|
|
|
}
|
|
|
|
|
|
|
|
nTab = GetViewData()->GetTabNo();
|
|
|
|
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bCopy)
|
|
|
|
{
|
|
|
|
pDocShell->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pDocShell->GetUndoManager()->AddUndoAction(
|
|
|
|
new ScUndoMoveTab( pDocShell, TheTabs, TheDestTabs));
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nNewTab = nDestTab;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nNewTab == SC_TAB_APPEND)
|
|
|
|
nNewTab = pDoc->GetTableCount()-1;
|
|
|
|
else if (!bCopy && nTab<nDestTab)
|
|
|
|
nNewTab--;
|
|
|
|
|
|
|
|
SetTabNo( nNewTab, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::ShowTable( const String& rName )
|
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo(pDoc->IsUndoEnabled());
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bFound = FALSE;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nPos = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
String aTabName;
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nCount = pDoc->GetTableCount();
|
|
|
|
for (SCTAB i=0; i<nCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
pDoc->GetName( i, aTabName );
|
|
|
|
if ( aTabName == rName )
|
|
|
|
{
|
|
|
|
nPos = i;
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFound)
|
|
|
|
{
|
|
|
|
pDoc->SetVisible( nPos, TRUE );
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
{
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nPos, TRUE ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
SetTabNo( nPos, TRUE );
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 11:09:45 +00:00
|
|
|
void ScViewFunc::HideTable( SCTAB nTab )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
ScDocument* pDoc = pDocSh->GetDocument();
|
2001-02-14 14:34:08 +00:00
|
|
|
BOOL bUndo(pDoc->IsUndoEnabled());
|
2004-06-04 11:09:45 +00:00
|
|
|
SCTAB nVisible = 0;
|
|
|
|
SCTAB nCount = pDoc->GetTableCount();
|
|
|
|
for (SCTAB i=0; i<nCount; i++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (pDoc->IsVisible(i))
|
|
|
|
++nVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nVisible > 1)
|
|
|
|
{
|
|
|
|
pDoc->SetVisible( nTab, FALSE );
|
2001-02-14 14:34:08 +00:00
|
|
|
if (bUndo)
|
|
|
|
{
|
|
|
|
pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nTab, FALSE ) );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// Views updaten:
|
|
|
|
pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
|
|
|
|
|
|
|
|
SetTabNo( nTab, TRUE );
|
|
|
|
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
|
|
|
|
pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::InsertSpecialChar( const String& rStr, const Font& rFont )
|
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ScEditableTester aTester( this );
|
|
|
|
if (!aTester.IsEditable())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-11-20 13:36:29 +00:00
|
|
|
ErrorMessage(aTester.GetMessageId());
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const sal_Unicode* pChar = rStr.GetBuffer();
|
|
|
|
ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
|
|
|
|
SvxFontItem aFontItem( rFont.GetFamily(),
|
|
|
|
rFont.GetName(),
|
|
|
|
rFont.GetStyleName(),
|
|
|
|
rFont.GetPitch(),
|
|
|
|
rFont.GetCharSet(),
|
|
|
|
ATTR_FONT );
|
2001-11-14 14:44:41 +00:00
|
|
|
|
|
|
|
// if string contains WEAK characters, set all fonts
|
|
|
|
BYTE nScript;
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
if ( pDoc->HasStringWeakCharacters( rStr ) )
|
|
|
|
nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
|
|
|
|
else
|
|
|
|
nScript = pDoc->GetStringScriptType( rStr );
|
|
|
|
|
|
|
|
SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, pViewShell->GetPool() );
|
|
|
|
aSetItem.PutItemForScriptType( nScript, aFontItem );
|
|
|
|
ApplyUserItemSet( aSetItem.GetItemSet() );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
while ( *pChar )
|
|
|
|
pViewShell->TabKeyInput( KeyEvent( *(pChar++), KeyCode() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine,
|
|
|
|
const SvxBorderLine* pDestLine,
|
|
|
|
const SvxBorderLine* pSrcLine,
|
|
|
|
BOOL bColor )
|
|
|
|
{
|
|
|
|
if ( pSrcLine && pDestLine )
|
|
|
|
{
|
|
|
|
if ( bColor )
|
|
|
|
{
|
|
|
|
rLine.SetColor ( pSrcLine->GetColor() );
|
|
|
|
rLine.SetOutWidth ( pDestLine->GetOutWidth() );
|
|
|
|
rLine.SetInWidth ( pDestLine->GetInWidth() );
|
|
|
|
rLine.SetDistance ( pDestLine->GetDistance() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rLine.SetColor ( pDestLine->GetColor() );
|
|
|
|
rLine.SetOutWidth ( pSrcLine->GetOutWidth() );
|
|
|
|
rLine.SetInWidth ( pSrcLine->GetInWidth() );
|
|
|
|
rLine.SetDistance ( pSrcLine->GetDistance() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \
|
|
|
|
pBoxLine = aBoxItem.Get##LINE(); \
|
|
|
|
if ( pBoxLine ) \
|
|
|
|
{ \
|
|
|
|
if ( pLine ) \
|
|
|
|
{ \
|
|
|
|
UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly ); \
|
|
|
|
aBoxItem.SetLine( &aLine, BOXLINE ); \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
aBoxItem.SetLine( NULL, BOXLINE ); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine,
|
|
|
|
BOOL bColorOnly )
|
|
|
|
{
|
|
|
|
// nur wegen Matrix nicht editierbar? Attribute trotzdem ok
|
|
|
|
BOOL bOnlyNotBecauseOfMatrix;
|
|
|
|
if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
|
|
|
|
{
|
|
|
|
ErrorMessage(STR_PROTECTIONERR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
2004-09-09 08:30:59 +00:00
|
|
|
ScMarkData aFuncMark( GetViewData()->GetMarkData() ); // local copy for UnmarkFiltered
|
|
|
|
ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
|
2000-09-18 16:07:07 +00:00
|
|
|
ScDocShell* pDocSh = GetViewData()->GetDocShell();
|
|
|
|
const ScPatternAttr* pSelAttrs = GetSelectionPattern();
|
2004-09-20 12:49:17 +00:00
|
|
|
const SfxItemSet& rSelItemSet = pSelAttrs->GetItemSet();
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
const SfxPoolItem* pBorderAttr = NULL;
|
2004-09-20 12:49:17 +00:00
|
|
|
SfxItemState eItemState = rSelItemSet.GetItemState( ATTR_BORDER, TRUE, &pBorderAttr );
|
|
|
|
|
|
|
|
const SfxPoolItem* pTLBRItem = 0;
|
|
|
|
SfxItemState eTLBRState = rSelItemSet.GetItemState( ATTR_BORDER_TLBR, TRUE, &pTLBRItem );
|
|
|
|
|
|
|
|
const SfxPoolItem* pBLTRItem = 0;
|
|
|
|
SfxItemState eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, TRUE, &pBLTRItem );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-09-20 12:49:17 +00:00
|
|
|
// any of the lines visible?
|
|
|
|
if( (eItemState != SFX_ITEM_DEFAULT) || (eTLBRState != SFX_ITEM_DEFAULT) || (eBLTRState != SFX_ITEM_DEFAULT) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-09-20 12:49:17 +00:00
|
|
|
// none of the lines don't care?
|
|
|
|
if( (eItemState != SFX_ITEM_DONTCARE) && (eTLBRState != SFX_ITEM_DONTCARE) && (eBLTRState != SFX_ITEM_DONTCARE) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
SfxItemSet* pOldSet = new SfxItemSet(
|
|
|
|
*(pDoc->GetPool()),
|
|
|
|
ATTR_PATTERN_START,
|
|
|
|
ATTR_PATTERN_END );
|
|
|
|
SfxItemSet* pNewSet = new SfxItemSet(
|
|
|
|
*(pDoc->GetPool()),
|
|
|
|
ATTR_PATTERN_START,
|
|
|
|
ATTR_PATTERN_END );
|
|
|
|
|
|
|
|
//------------------------------------------------------------
|
|
|
|
const SvxBorderLine* pBoxLine = NULL;
|
|
|
|
SvxBorderLine aLine;
|
|
|
|
|
|
|
|
// hier wird die pBoxLine benutzt:
|
|
|
|
|
2004-09-20 12:49:17 +00:00
|
|
|
if( pBorderAttr )
|
|
|
|
{
|
|
|
|
SvxBoxItem aBoxItem( *(const SvxBoxItem*)pBorderAttr );
|
|
|
|
SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
|
|
|
|
|
|
|
|
SET_LINE_ATTRIBUTES(Top,BOX_LINE_TOP)
|
|
|
|
SET_LINE_ATTRIBUTES(Bottom,BOX_LINE_BOTTOM)
|
|
|
|
SET_LINE_ATTRIBUTES(Left,BOX_LINE_LEFT)
|
|
|
|
SET_LINE_ATTRIBUTES(Right,BOX_LINE_RIGHT)
|
|
|
|
|
|
|
|
aBoxInfoItem.SetLine( aBoxItem.GetTop(), BOXINFO_LINE_HORI );
|
|
|
|
aBoxInfoItem.SetLine( aBoxItem.GetLeft(), BOXINFO_LINE_VERT );
|
|
|
|
aBoxInfoItem.ResetFlags(); // Lines auf Valid setzen
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-09-20 12:49:17 +00:00
|
|
|
pOldSet->Put( *pBorderAttr );
|
|
|
|
pNewSet->Put( aBoxItem );
|
|
|
|
pNewSet->Put( aBoxInfoItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pTLBRItem && ((const SvxLineItem*)pTLBRItem)->GetLine() )
|
|
|
|
{
|
|
|
|
SvxLineItem aTLBRItem( *(const SvxLineItem*)pTLBRItem );
|
|
|
|
UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly );
|
|
|
|
aTLBRItem.SetLine( &aLine );
|
|
|
|
pOldSet->Put( *pTLBRItem );
|
|
|
|
pNewSet->Put( aTLBRItem );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-09-20 12:49:17 +00:00
|
|
|
if( pBLTRItem && ((const SvxLineItem*)pBLTRItem)->GetLine() )
|
|
|
|
{
|
|
|
|
SvxLineItem aBLTRItem( *(const SvxLineItem*)pBLTRItem );
|
|
|
|
UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly );
|
|
|
|
aBLTRItem.SetLine( &aLine );
|
|
|
|
pOldSet->Put( *pBLTRItem );
|
|
|
|
pNewSet->Put( aBLTRItem );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
ApplyAttributes( pNewSet, pOldSet );
|
|
|
|
|
|
|
|
delete pOldSet;
|
|
|
|
delete pNewSet;
|
|
|
|
}
|
|
|
|
else // if ( eItemState == SFX_ITEM_DONTCARE )
|
|
|
|
{
|
2004-09-09 08:30:59 +00:00
|
|
|
aFuncMark.MarkToMulti();
|
|
|
|
pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScRange aMarkRange;
|
2004-09-09 08:30:59 +00:00
|
|
|
aFuncMark.GetMultiMarkArea( aMarkRange );
|
2004-06-04 11:09:45 +00:00
|
|
|
SCCOL nStartCol = aMarkRange.aStart.Col();
|
|
|
|
SCROW nStartRow = aMarkRange.aStart.Row();
|
|
|
|
SCTAB nStartTab = aMarkRange.aStart.Tab();
|
|
|
|
SCCOL nEndCol = aMarkRange.aEnd.Col();
|
|
|
|
SCROW nEndRow = aMarkRange.aEnd.Row();
|
|
|
|
SCTAB nEndTab = aMarkRange.aEnd.Tab();
|
2000-09-18 16:07:07 +00:00
|
|
|
pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
|
|
|
|
nEndCol, nEndRow, nEndTab,
|
|
|
|
PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
|
|
|
|
|
|
|
|
pDocSh->UpdateOle( GetViewData() );
|
|
|
|
pDocSh->SetDocumentModified();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef SET_LINE_ATTRIBUTES
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::SetConditionalFormat( const ScConditionalFormat& rNew )
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
ULONG nIndex = pDoc->AddCondFormat(rNew); // dafuer gibt's kein Undo
|
|
|
|
SfxUInt32Item aItem( ATTR_CONDITIONAL, nIndex );
|
|
|
|
|
|
|
|
ApplyAttr( aItem ); // mit Paint und Undo...
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ScViewFunc::SetValidation( const ScValidationData& rNew )
|
|
|
|
{
|
|
|
|
ScDocument* pDoc = GetViewData()->GetDocument();
|
|
|
|
ULONG nIndex = pDoc->AddValidationEntry(rNew); // dafuer gibt's kein Undo
|
|
|
|
SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex );
|
|
|
|
|
|
|
|
ApplyAttr( aItem ); // mit Paint und Undo...
|
|
|
|
}
|
|
|
|
|
|
|
|
|