/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: sc_viewdata.cxx,v $
 *
 *  $Revision: 1.10 $
 *
 *  last change: $Author: rt $ $Date: 2006/10/27 17:18:32 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    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.
 *
 *    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.
 *
 *    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
 *
 ************************************************************************/
#ifdef PCH
#endif

#pragma hdrstop

// INCLUDE ---------------------------------------------------------------

#include "scitems.hxx"
#define ITEMID_FIELD EE_FEATURE_FIELD

#include <bf_svx/editview.hxx>
#include <bf_svx/outliner.hxx>

//#include <vcl/system.hxx>

#include "attrib.hxx"
#include "tabvwsh.hxx"
#include "docsh.hxx"
#include "bf_sc.hrc"
#include "editutil.hxx"
#include "miscuno.hxx"
#include "unonames.hxx"
#include "tabcont.hxx"

#ifndef _XMLOFF_XMLUCONV_HXX
#include <bf_xmloff/xmluconv.hxx>
#endif

#ifndef _SC_VIEWSETTINGSSEQUENCEDEFINES_HXX
#include "ViewSettingsSequenceDefines.hxx"
#endif

#ifndef _RTL_USTRBUF_HXX_
#include <rtl/ustrbuf.hxx>
#endif
#ifndef _LEGACYBINFILTERMGR_HXX
#include <legacysmgr/legacy_binfilters_smgr.hxx>	//STRIP002 
#endif
namespace binfilter {
using namespace ::com::sun::star;

// STATIC DATA -----------------------------------------------------------

#define SC_GROWY_SMALL_EXTRA	100
#define SC_GROWY_BIG_EXTRA		200

#define TAG_TABBARWIDTH "tw:"

static BOOL bMoveArea = FALSE;				//! Member?
USHORT nEditAdjust = SVX_ADJUST_LEFT;		//! Member !!!

//==================================================================

/*N*/ ScViewDataTable::ScViewDataTable() :
/*N*/ 				nCurX( 0 ),
/*N*/ 				nCurY( 0 ),
/*N*/ 				bOldCurValid( FALSE ),
/*N*/ 				eHSplitMode( SC_SPLIT_NONE ),
/*N*/ 				eVSplitMode( SC_SPLIT_NONE ),
/*N*/ 				nHSplitPos( 0 ),
/*N*/ 				nVSplitPos( 0 ),
/*N*/ 				nFixPosX( 0 ),
/*N*/ 				nFixPosY( 0 ),
/*N*/ 				eWhichActive( SC_SPLIT_BOTTOMLEFT )
/*N*/ {
/*N*/ 	nPosX[0]=nPosX[1]=
/*N*/ 	nPosY[0]=nPosY[1]=0;
/*N*/ 	nTPosX[0]=nTPosX[1]=
/*N*/ 	nTPosY[0]=nTPosY[1]=0;
/*N*/ 	nMPosX[0]=nMPosX[1]=
/*N*/ 	nMPosY[0]=nMPosY[1]=0;
/*N*/ 	nPixPosX[0]=nPixPosX[1]=
/*N*/ 	nPixPosY[0]=nPixPosY[1]=0;
/*N*/ }


/*N*/ ScViewDataTable::~ScViewDataTable()
/*N*/ {
/*N*/ }

/*N*/ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings)
/*N*/ {
/*N*/ 	rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
/*N*/ 	beans::PropertyValue* pSettings = rSettings.getArray();
/*N*/ 	if (pSettings)
/*N*/ 	{
/*N*/ 		pSettings[SC_CURSOR_X].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONX));
/*N*/ 		pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX);
/*N*/ 		pSettings[SC_CURSOR_Y].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONY));
/*N*/ 		pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY);
/*N*/ 		pSettings[SC_HORIZONTAL_SPLIT_MODE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITMODE));
/*N*/ 		pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eHSplitMode);
/*N*/ 		pSettings[SC_VERTICAL_SPLIT_MODE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITMODE));
/*N*/ 		pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eVSplitMode);
/*N*/ 		pSettings[SC_HORIZONTAL_SPLIT_POSITION].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITPOSITION));
/*N*/ 		if (eHSplitMode == SC_SPLIT_FIX)
/*N*/ 			pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosX);
/*N*/ 		else
/*N*/ 			pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= nHSplitPos;
/*N*/ 		pSettings[SC_VERTICAL_SPLIT_POSITION].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITPOSITION));
/*N*/ 		if (eVSplitMode == SC_SPLIT_FIX)
/*N*/ 			pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY);
/*N*/ 		else
/*N*/ 			pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= nVSplitPos;
/*N*/ 		pSettings[SC_ACTIVE_SPLIT_RANGE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVESPLITRANGE));
/*N*/ 		pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eWhichActive);
/*N*/ 		pSettings[SC_POSITION_LEFT].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONLEFT));
/*N*/ 		pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
/*N*/ 		pSettings[SC_POSITION_RIGHT].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONRIGHT));
/*N*/ 		pSettings[SC_POSITION_RIGHT].Value <<= sal_Int32(nPosX[SC_SPLIT_RIGHT]);
/*N*/ 		pSettings[SC_POSITION_TOP].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONTOP));
/*N*/ 		pSettings[SC_POSITION_TOP].Value <<= sal_Int32(nPosY[SC_SPLIT_TOP]);
/*N*/ 		pSettings[SC_POSITION_BOTTOM].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONBOTTOM));
/*N*/ 		pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]);
/*N*/ 	}
/*N*/ }

// #116578#
void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings)
{
	sal_Int32 nCount(aSettings.getLength());
	DBG_ASSERT(nCount == SC_TABLE_VIEWSETTINGS_COUNT, " wrong Table View Settings count");
	sal_Int32 nTemp32(0);
	sal_Int16 nTemp16(0);
	sal_Int32 nTempPosV(0);
	sal_Int32 nTempPosH(0);
	for (sal_Int32 i = 0; i < nCount; i++)
	{
		::rtl::OUString sName(aSettings[i].Name);
		if (sName.compareToAscii(SC_CURSORPOSITIONX) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nCurX = static_cast<sal_uInt16>(nTemp32);
		}
		else if (sName.compareToAscii(SC_CURSORPOSITIONY) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nCurY = static_cast<sal_uInt16>(nTemp32);
		}
		else if (sName.compareToAscii(SC_HORIZONTALSPLITMODE) == 0)
		{
			aSettings[i].Value >>= nTemp16;
			eHSplitMode = static_cast<ScSplitMode>(nTemp16);
		}
		else if (sName.compareToAscii(SC_VERTICALSPLITMODE) == 0)
		{
			aSettings[i].Value >>= nTemp16;
			eVSplitMode = static_cast<ScSplitMode>(nTemp16);
		}
		else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION) == 0)
		{
			aSettings[i].Value >>= nTempPosH;
		}
		else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION) == 0)
		{
			aSettings[i].Value >>= nTempPosV;
		}
		else if (sName.compareToAscii(SC_ACTIVESPLITRANGE) == 0)
		{
			aSettings[i].Value >>= nTemp16;
			eWhichActive = static_cast<ScSplitPos>(nTemp16);
		}
		else if (sName.compareToAscii(SC_POSITIONLEFT) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nPosX[SC_SPLIT_LEFT] = static_cast<sal_uInt16>(nTemp32);
		}
		else if (sName.compareToAscii(SC_POSITIONRIGHT) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nPosX[SC_SPLIT_RIGHT] = static_cast<sal_uInt16>(nTemp32);
		}
		else if (sName.compareToAscii(SC_POSITIONTOP) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nPosY[SC_SPLIT_TOP] = static_cast<sal_uInt16>(nTemp32);
		}
		else if (sName.compareToAscii(SC_POSITIONBOTTOM) == 0)
		{
			aSettings[i].Value >>= nTemp32;
			nPosY[SC_SPLIT_BOTTOM] = static_cast<sal_uInt16>(nTemp32);
		}
	}
	if (eHSplitMode == SC_SPLIT_FIX)
		nFixPosX = static_cast<sal_uInt16>(nTempPosH);
	else
		nHSplitPos = nTempPosH;
	if (eVSplitMode == SC_SPLIT_FIX)
		nFixPosY = static_cast<sal_uInt16>(nTempPosV);
	else
		nVSplitPos = nTempPosV;
}

//==================================================================

/*N*/ ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
/*N*/ 	:	pDocShell	( pDocSh ),
/*N*/ 		pViewShell	( pViewSh ),
/*N*/ 		pDoc		( NULL ),
/*N*/ 		pView		( pViewSh ),
/*N*/ 		pOptions	( new ScViewOptions ),
/*N*/ 		nTabNo		( 0 ),
/*N*/ 		nRefTabNo	( 0 ),
/*N*/ 		aZoomX		( 1,1 ),
/*N*/ 		aZoomY		( 1,1 ),
/*N*/ 		aPageZoomX	( 3,5 ),					// Page-Default: 60%
/*N*/ 		aPageZoomY	( 3,5 ),
/*N*/ 		aLogicMode	( MAP_100TH_MM ),
/*N*/ 		bIsRefMode	( FALSE ),
/*N*/ 		eRefType	( SC_REFTYPE_NONE ),
/*N*/ 		nFillMode	( SC_FILL_NONE ),
/*N*/ 		bDelMarkValid( FALSE ),
/*N*/ 		bActive		( TRUE ),					//! wie initialisieren?
/*N*/ 		bPagebreak	( FALSE ),
            nTabBarWidth( SC_TABBAR_DEFWIDTH ),     // #116578#
/*N*/ 		pSpellingView ( NULL )
/*N*/ {
/*N*/ 	SetGridMode		( TRUE );
/*N*/ 	SetSyntaxMode	( FALSE );
/*N*/ 	SetHeaderMode	( TRUE );
/*N*/ 	SetTabMode		( TRUE );
/*N*/ 	SetVScrollMode	( TRUE );
/*N*/ 	SetHScrollMode	( TRUE );
/*N*/ 	SetOutlineMode	( TRUE );
/*N*/ 
/*N*/ 	aScrSize = Size( (long) ( STD_COL_WIDTH 		  * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
/*N*/ 					 (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
/*N*/ 	pTabData[0] = new ScViewDataTable;
/*N*/   USHORT i;
/*N*/ 	for (i=1; i<=MAXTAB; i++) pTabData[i] = NULL;
/*N*/ 	pThisTab = pTabData[nTabNo];
/*N*/ 	for (i=0; i<4; i++)
/*N*/ 	{
/*N*/ 		pEditView[i] = NULL;
/*N*/ 		bEditActive[i] = FALSE;
/*N*/ 	}
/*N*/ 
/*N*/ 	nEditEndCol = nEditCol = nEditEndRow = nEditRow = 0;
/*N*/ 	nTabStartCol = SC_TABSTART_NONE;
/*N*/ 
/*N*/ 	if (pDocShell)
/*N*/ 	{
/*N*/ 		pDoc = pDocShell->GetDocument();
/*N*/ 		*pOptions = pDoc->GetViewOptions();
/*N*/ 	}
/*N*/ 
/*N*/ 	//	keine ausgeblendete Tabelle anzeigen:
/*N*/ 	if (pDoc && !pDoc->IsVisible(nTabNo))
/*N*/ 	{
/*?*/ 		while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) )
/*?*/ 			++nTabNo;
/*?*/ 
/*?*/ 		pTabData[nTabNo] = new ScViewDataTable;
/*?*/ 		pThisTab = pTabData[nTabNo];
/*N*/ 	}
/*N*/ 
/*N*/ 	CalcPPT();
/*N*/ }





/*N*/ ScDocument* ScViewData::GetDocument() const
/*N*/ {
/*N*/ 	if (pDoc)
/*N*/ 		return pDoc;
/*N*/ 	else if (pDocShell)
/*?*/ 		return pDocShell->GetDocument();
/*N*/ 
/*N*/ 	DBG_ERROR("kein Document an ViewData");
/*N*/ 	return NULL;
/*N*/ }

/*N*/ ScViewData::~ScViewData()
/*N*/ {
/*N*/ 	for (USHORT i=0; i<=MAXTAB; i++)
/*N*/ 		if (pTabData[i])
/*N*/ 			delete pTabData[i];
/*N*/ 
/*N*/ 	KillEditView();
/*N*/ 	delete pOptions;
/*N*/ }

/*N*/ void ScViewData::UpdateThis()
/*N*/ {
/*N*/ 	do
/*N*/ 	{
/*N*/ 		pThisTab = pTabData[nTabNo];
/*N*/ 		if (!pThisTab)
/*N*/ 		{
/*N*/ 			if (nTabNo>0)
/*N*/ 				--nTabNo;
/*N*/ 			else
/*?*/ 				pThisTab = pTabData[0] = new ScViewDataTable;
/*N*/ 
/*N*/ 				// hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist!
/*N*/ 		}
/*N*/ 	}
/*N*/ 	while (!pThisTab);
/*N*/ }

/*N*/ void ScViewData::InsertTab( USHORT nTab )
/*N*/ {
/*N*/ 	delete pTabData[MAXTAB];
/*N*/ 
/*N*/ 	for (USHORT i=MAXTAB; i>nTab; i--)
/*N*/ 		pTabData[i] = pTabData[i-1];
/*N*/ 
/*N*/ 	pTabData[nTab] = new ScViewDataTable;
/*N*/ 
/*N*/ 	UpdateThis();
/*N*/ 	aMarkData.InsertTab( nTab );
/*N*/ }





/*N*/ void ScViewData::SetViewShell( ScTabViewShell* pViewSh )
/*N*/ {
/*N*/ 	if (pViewSh)
/*N*/ 	{
/*N*/ 		pViewShell	= pViewSh;
/*N*/ 		pView		= pViewSh;
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		pViewShell	= NULL;
/*N*/ 		pView		= NULL;
/*N*/ 	}
/*N*/ }

/*N*/ void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY )
/*N*/ {
/*N*/ 	Fraction aFrac20( 1,5 );
/*N*/ 	Fraction aFrac400( 4,1 );
/*N*/ 
/*N*/ 	Fraction aValidX = rNewX;
/*N*/ 	if (aValidX<aFrac20) aValidX = aFrac20;
/*N*/ 	if (aValidX>aFrac400) aValidX = aFrac400;
/*N*/ 
/*N*/ 	Fraction aValidY = rNewY;
/*N*/ 	if (aValidY<aFrac20) aValidY = aFrac20;
/*N*/ 	if (aValidY>aFrac400) aValidY = aFrac400;
/*N*/ 
/*N*/ 	if ( bPagebreak )
/*N*/ 	{
/*N*/ 		aPageZoomX = aValidX;
/*N*/ 		aPageZoomY = aValidY;
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		aZoomX = aValidX;
/*N*/ 		aZoomY = aValidY;
/*N*/ 	}
/*N*/ 
/*N*/ 	CalcPPT();
/*N*/ 	RecalcPixPos();
/*N*/ 	aScenButSize = Size(0,0);
/*N*/ 	aLogicMode.SetScaleX( aValidX );
/*N*/ 	aLogicMode.SetScaleY( aValidY );
/*N*/ }

// #116578#
void ScViewData::SetPagebreakMode( BOOL bSet )
{
	bPagebreak = bSet;

	CalcPPT();
	RecalcPixPos();
	aScenButSize = Size(0,0);
	aLogicMode.SetScaleX( GetZoomX() );
	aLogicMode.SetScaleY( GetZoomY() );
}

/*M*/ BOOL ScViewData::GetSimpleArea( USHORT& rStartCol, USHORT& rStartRow, USHORT& rStartTab,
/*N*/ 								USHORT& rEndCol, USHORT& rEndRow, USHORT& rEndTab )
/*N*/ {
/*N*/ 	//	parameter bMergeMark is no longer needed: The view's selection is never modified
/*N*/ 	//	(a local copy is used), and a multi selection that adds to a single range can always
/*N*/ 	//	be treated like a single selection (#108266# - GetSimpleArea isn't used in selection
/*N*/ 	//	handling itself)
/*N*/ 
/*N*/ 	ScMarkData aNewMark( aMarkData );		// use a local copy for MarkToSimple
/*N*/ 
/*N*/ 	if ( aNewMark.IsMarked() || aNewMark.IsMultiMarked() )
/*N*/ 	{
/*N*/ 		if ( aNewMark.IsMultiMarked() )
/*N*/ 			aNewMark.MarkToSimple();
/*M*/ 
/*M*/ 		if ( aNewMark.IsMarked() && !aNewMark.IsMultiMarked() )
/*M*/ 		{
/*M*/ 			ScRange aMarkRange;
/*M*/ 			aNewMark.GetMarkArea( aMarkRange );
/*M*/ 			rStartCol = aMarkRange.aStart.Col();
/*M*/ 			rStartRow = aMarkRange.aStart.Row();
/*M*/ 			rStartTab = aMarkRange.aStart.Tab();
/*M*/ 			rEndCol = aMarkRange.aEnd.Col();
/*M*/ 			rEndRow = aMarkRange.aEnd.Row();
/*M*/ 			rEndTab = aMarkRange.aEnd.Tab();
/*M*/ 		}
/*M*/ 		else
/*M*/ 		{
/*M*/ 			rStartCol = rEndCol = GetCurX();
/*M*/ 			rStartRow = rEndRow = GetCurY();
/*M*/ 			rStartTab = rEndTab = GetTabNo();
/*M*/ 			return FALSE;
/*M*/ 		}
/*M*/ 	}
/*M*/ 	else
/*M*/ 	{
/*M*/ 		rStartCol = rEndCol = GetCurX();
/*M*/ 		rStartRow = rEndRow = GetCurY();
/*M*/ 		rStartTab = rEndTab = GetTabNo();
/*M*/ 	}
/*M*/ 	return TRUE;
/*M*/ }

/*N*/ BOOL ScViewData::GetSimpleArea( ScRange& rRange )
/*N*/ {
/*N*/ 	//	parameter bMergeMark is no longer needed, see above
/*N*/ 
/*N*/ 	ScMarkData aNewMark( aMarkData );		// use a local copy for MarkToSimple
/*N*/ 
/*N*/ 	if ( aNewMark.IsMarked() || aNewMark.IsMultiMarked() )
/*N*/ 	{
/*?*/ 		if ( aNewMark.IsMultiMarked() )
/*?*/ 			aNewMark.MarkToSimple();
/*?*/ 
/*?*/ 		if ( aNewMark.IsMarked() && !aNewMark.IsMultiMarked() )
/*?*/ 			aNewMark.GetMarkArea( rRange );
/*?*/ 		else
/*?*/ 		{
/*?*/ 			rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() );
/*?*/ 			return FALSE;
/*?*/ 		}
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() );
/*N*/ 	}
/*N*/ 	return TRUE;
/*N*/ }




/*M*/ BOOL ScViewData::IsMultiMarked()
/*M*/ {
/*M*/ 	// test for "real" multi selection, calling MarkToSimple on a local copy
/*M*/ 
/*M*/ 	if ( aMarkData.IsMultiMarked() )
/*M*/ 	{
/*M*/ 		ScMarkData aNewMark( aMarkData );		// use a local copy for MarkToSimple
/*M*/ 		aNewMark.MarkToSimple();
/*M*/ 		if ( aNewMark.IsMultiMarked() )
/*M*/ 			return TRUE;
/*M*/ 	}
/*M*/ 	return FALSE;
/*M*/ }










/*N*/ void ScViewData::ResetEditView()
/*N*/ {
/*N*/ 	EditEngine* pEngine = NULL;
/*N*/ 	for (USHORT i=0; i<4; i++)
/*N*/ 		if (pEditView[i])
/*N*/ 		{
/*?*/ 			if (bEditActive[i])
/*?*/ 			{
/*?*/ 				pEngine = pEditView[i]->GetEditEngine();
/*?*/ 				pEngine->RemoveView(pEditView[i]);
/*?*/ 				pEditView[i]->SetOutputArea( Rectangle() );
/*?*/ 			}
/*?*/ 			bEditActive[i] = FALSE;
/*N*/ 		}
/*N*/ 
/*N*/ 	if (pEngine)
			{DBG_BF_ASSERT(0, "STRIP");} //STRIP001 /*?*/ 		pEngine->SetStatusEventHdl( LINK( this, ScViewData, EmptyEditHdl ) );
/*N*/ }

/*N*/ void ScViewData::KillEditView()
/*N*/ {
/*N*/ 	for (USHORT i=0; i<4; i++)
/*N*/ 		if (pEditView[i])
/*N*/ 		{
/*?*/ 			if (bEditActive[i])
/*?*/ 				pEditView[i]->GetEditEngine()->RemoveView(pEditView[i]);
/*?*/ 			delete pEditView[i];
/*?*/ 			pEditView[i] = NULL;
/*N*/ 		}
/*N*/ }


// #116578#
void ScViewData::SetTabNo( USHORT nNewTab )
{
	if (nNewTab>MAXTAB)
	{
		DBG_ERROR("falsche Tabellennummer");
		return;
	}

	nTabNo = nNewTab;
	if (!pTabData[nTabNo])
		pTabData[nTabNo] = new ScViewDataTable;
	pThisTab = pTabData[nTabNo];

	CalcPPT();			//	for common column width correction
	RecalcPixPos();		//! nicht immer noetig!
}


/*N*/ Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScHSplitPos eWhich ) const
/*N*/ {
/*N*/ 	DBG_ASSERT( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "Falsche Position" );
/*N*/ 	ScSplitPos ePos = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
/*N*/ 	return GetScrPos( nWhereX, nWhereY, ePos );
/*N*/ }

/*N*/ Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScVSplitPos eWhich ) const
/*N*/ {
/*N*/ 	DBG_ASSERT( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "Falsche Position" );
/*N*/ 	ScSplitPos ePos = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
/*N*/ 	return GetScrPos( nWhereX, nWhereY, ePos );
/*N*/ }

/*N*/ Point ScViewData::GetScrPos( USHORT nWhereX, USHORT nWhereY, ScSplitPos eWhich,
/*N*/ 								BOOL bAllowNeg ) const
/*N*/ {
/*N*/ 	ScHSplitPos eWhichX;
/*N*/ 	ScVSplitPos eWhichY;
/*N*/ 	switch( eWhich )
/*N*/ 	{
/*N*/ 		case SC_SPLIT_TOPLEFT:
/*N*/ 			eWhichX = SC_SPLIT_LEFT;
/*N*/ 			eWhichY = SC_SPLIT_TOP;
/*N*/ 			break;
/*N*/ 		case SC_SPLIT_TOPRIGHT:
/*N*/ 			eWhichX = SC_SPLIT_RIGHT;
/*N*/ 			eWhichY = SC_SPLIT_TOP;
/*N*/ 			break;
/*N*/ 		case SC_SPLIT_BOTTOMLEFT:
/*N*/ 			eWhichX = SC_SPLIT_LEFT;
/*N*/ 			eWhichY = SC_SPLIT_BOTTOM;
/*N*/ 			break;
/*N*/ 		case SC_SPLIT_BOTTOMRIGHT:
/*N*/ 			eWhichX = SC_SPLIT_RIGHT;
/*N*/ 			eWhichY = SC_SPLIT_BOTTOM;
/*N*/ 			break;
/*N*/ 	}
/*N*/ 
/*N*/ 	if (pView)
/*N*/ 	{
/*N*/ 		((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
/*N*/ 		((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
/*N*/ 	}
/*N*/ 
/*N*/ 	USHORT nTSize;
/*N*/ 
/*N*/ 	USHORT	nPosX = GetPosX(eWhichX);
/*N*/ 	USHORT	nX;
/*N*/ 
/*N*/ 	long nScrPosX=0;
/*N*/ 	if (nWhereX >= nPosX)
/*N*/ 		for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++)
/*N*/ 		{
/*N*/ 			if ( nX > MAXCOL )
/*N*/ 				nScrPosX = 65535;
/*N*/ 			else
/*N*/ 			{
/*N*/ 				nTSize = pDoc->GetColWidth( nX, nTabNo );
/*N*/ 				if (nTSize)
/*N*/ 				{
/*N*/ 					long nSizeXPix = ToPixel( nTSize, nPPTX );
/*N*/ 					nScrPosX += nSizeXPix;
/*N*/ 				}
/*N*/ 			}
/*N*/ 		}
/*N*/ 	else if (bAllowNeg)
/*?*/ 		for (nX=nPosX; nX>nWhereX;)
/*?*/ 		{
/*?*/ 			--nX;
/*?*/ 			nTSize = pDoc->GetColWidth( nX, nTabNo );
/*?*/ 			if (nTSize)
/*?*/ 			{
/*?*/ 				long nSizeXPix = ToPixel( nTSize, nPPTX );
/*?*/ 				nScrPosX -= nSizeXPix;
/*?*/ 			}
/*?*/ 		}
/*N*/ 
/*N*/ 	USHORT	nPosY = GetPosY(eWhichY);
/*N*/ 	USHORT	nY;
/*N*/ 
/*N*/ 	long nScrPosY=0;
/*N*/ 	if (nWhereY >= nPosY)
/*N*/ 		for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++)
/*N*/ 		{
/*N*/ 			if ( nY > MAXROW )
/*N*/ 				nScrPosY = 65535;
/*N*/ 			else
/*N*/ 			{
/*N*/ 				nTSize = pDoc->FastGetRowHeight( nY, nTabNo );
/*N*/ 				if (nTSize)
/*N*/ 				{
/*N*/ 					long nSizeYPix = ToPixel( nTSize, nPPTY );
/*N*/ 					nScrPosY += nSizeYPix;
/*N*/ 				}
/*N*/ 			}
/*N*/ 		}
/*N*/ 	else if (bAllowNeg)
/*?*/ 		for (nY=nPosY; nY>nWhereY;)
/*?*/ 		{
/*?*/ 			--nY;
/*?*/ 			nTSize = pDoc->FastGetRowHeight( nY, nTabNo );
/*?*/ 			if (nTSize)
/*?*/ 			{
/*?*/ 				long nSizeYPix = ToPixel( nTSize, nPPTY );
/*?*/ 				nScrPosY -= nSizeYPix;
/*?*/ 			}
/*?*/ 		}
/*N*/ 
/*N*/ 	if (nScrPosX > 32767) nScrPosX=32767;
/*N*/ 	if (nScrPosY > 32767) nScrPosY=32767;
/*N*/ 	return Point( nScrPosX, nScrPosY );
/*N*/ }

//
//		Anzahl Zellen auf einem Bildschirm
//

/*N*/ USHORT ScViewData::CellsAtX( short nPosX, short nDir, ScHSplitPos eWhichX, USHORT nScrSizeX ) const
/*N*/ {
/*N*/ 	DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
/*N*/ 
/*N*/ 	if (pView)
/*N*/ 		((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
/*N*/ 
/*N*/ 	short	nX;
/*N*/ 	USHORT	nScrPosX = 0;
/*N*/ 	if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (USHORT) aScrSize.Width();
/*N*/ 
/*N*/ 	if (nDir==1)
/*N*/ 		nX = nPosX;				// vorwaerts
/*N*/ 	else
/*N*/ 		nX = nPosX-1;			// rueckwaerts
/*N*/ 
/*N*/ 	BOOL bOut = FALSE;
/*N*/ 	for ( ; nScrPosX<=nScrSizeX && !bOut; nX+=nDir )
/*N*/ 	{
/*N*/ 		short	nColNo = nX;
/*N*/ 		if ( nColNo < 0 || nColNo > MAXCOL )
/*N*/ 			bOut = TRUE;
/*N*/ 		else
/*N*/ 		{
/*N*/ 			USHORT nTSize = pDoc->GetColWidth( nColNo, nTabNo );
/*N*/ 			if (nTSize)
/*N*/ 			{
/*N*/ 				long nSizeXPix = ToPixel( nTSize, nPPTX );
/*N*/ 				nScrPosX += (USHORT) nSizeXPix;
/*N*/ 			}
/*N*/ 		}
/*N*/ 	}
/*N*/ 
/*N*/ 	if (nDir==1)
/*N*/ 		nX -= nPosX;
/*N*/ 	else
/*N*/ 		nX = (nPosX-1)-nX;
/*N*/ 
/*N*/ 	if (nX>0) --nX;
/*N*/ 	return nX;
/*N*/ }

/*N*/ USHORT ScViewData::CellsAtY( short nPosY, short nDir, ScVSplitPos eWhichY, USHORT nScrSizeY ) const
/*N*/ {
/*N*/ 	DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
/*N*/ 
/*N*/ 	if (pView)
/*N*/ 		((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
/*N*/ 
/*N*/ 	short	nY;
/*N*/ 	USHORT	nScrPosY = 0;
/*N*/ 
/*N*/ 	if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (USHORT) aScrSize.Height();
/*N*/ 
/*N*/ 	if (nDir==1)
/*N*/ 		nY = nPosY;				// vorwaerts
/*N*/ 	else
/*N*/ 		nY = nPosY-1;			// rueckwaerts
/*N*/ 
/*N*/ 	BOOL bOut = FALSE;
/*N*/ 	for ( ; nScrPosY<=nScrSizeY && !bOut; nY+=nDir )
/*N*/ 	{
/*N*/ 		short	nRowNo = nY;
/*N*/ 		if ( nRowNo < 0 || nRowNo > MAXROW )
/*N*/ 			bOut = TRUE;
/*N*/ 		else
/*N*/ 		{
/*N*/ //			USHORT nTSize = pDoc->GetRowHeight( nRowNo, nTabNo );
/*N*/ 			USHORT nTSize = pDoc->FastGetRowHeight( nRowNo, nTabNo );
/*N*/ 			if (nTSize)
/*N*/ 			{
/*N*/ 				long nSizeYPix = ToPixel( nTSize, nPPTY );
/*N*/ 				nScrPosY += (USHORT) nSizeYPix;
/*N*/ 			}
/*N*/ 		}
/*N*/ 	}
/*N*/ 
/*N*/ 	if (nDir==1)
/*N*/ 		nY -= nPosY;
/*N*/ 	else
/*N*/ 		nY = (nPosY-1)-nY;
/*N*/ 
/*N*/ 	if (nY>0) --nY;
/*N*/ 	return nY;
/*N*/ }

/*N*/ USHORT ScViewData::VisibleCellsX( ScHSplitPos eWhichX ) const
/*N*/ {
/*N*/ 	return CellsAtX( GetPosX( eWhichX ), 1, eWhichX, SC_SIZE_NONE );
/*N*/ }

/*N*/ USHORT ScViewData::VisibleCellsY( ScVSplitPos eWhichY ) const
/*N*/ {
/*N*/ 	return CellsAtY( GetPosY( eWhichY ), 1, eWhichY, SC_SIZE_NONE );
/*N*/ }


/*N*/ BOOL ScViewData::GetMergeSizePixel( USHORT nX, USHORT nY, long& rSizeXPix, long& rSizeYPix )
/*N*/ {
/*N*/ 	const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
/*N*/ 	if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
/*N*/ 	{
/*N*/ 		long nOutWidth = 0;
/*N*/ 		long nOutHeight = 0;
/*N*/ 		USHORT i;
/*N*/ 		USHORT nCountX = pMerge->GetColMerge();
/*N*/ 		for (i=0; i<nCountX; i++)
/*N*/ 			nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX );
/*N*/ 		USHORT nCountY = pMerge->GetRowMerge();
/*N*/ 		for (i=0; i<nCountY; i++)
/*N*/ 			nOutHeight += ToPixel( pDoc->GetRowHeight(nY+i,nTabNo), nPPTY );
/*N*/ 
/*N*/ 		rSizeXPix = nOutWidth;
/*N*/ 		rSizeYPix = nOutHeight;
/*N*/ 		return TRUE;
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		rSizeXPix = ToPixel( pDoc->GetColWidth( nX, nTabNo ), nPPTX );
/*N*/ 		rSizeYPix = ToPixel( pDoc->GetRowHeight( nY, nTabNo ), nPPTY );
/*N*/ 		return FALSE;
/*N*/ 	}
/*N*/ }

/*N*/ BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
/*N*/ 										short& rPosX, short& rPosY,
/*N*/ 										BOOL bTestMerge, BOOL bRepair, BOOL bNextIfLarge )
/*N*/ {
/*M*/ 	//	special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
/*N*/ 
/*N*/ 	ScHSplitPos eHWhich = WhichH(eWhich);
/*N*/ 	ScVSplitPos eVWhich = WhichV(eWhich);
/*N*/ 	short nStartPosX = GetPosX(eHWhich);
/*N*/ 	short nStartPosY = GetPosY(eVWhich);
/*N*/ 	rPosX = nStartPosX;
/*N*/ 	rPosY = nStartPosY;
/*N*/ 	long nScrX = 0;
/*N*/ 	long nScrY = 0;
/*N*/ 
/*N*/ 	if (nClickX > 0)
/*N*/ 	{
/*N*/ 		while ( rPosX<=MAXCOL && nClickX >= nScrX )
/*N*/ 		{
/*N*/ 			nScrX += ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
/*N*/ 			++rPosX;
/*N*/ 		}
/*N*/ 		--rPosX;
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		while ( rPosX>0 && nClickX < nScrX )
/*N*/ 		{
/*N*/ 			--rPosX;
/*N*/ 			nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
/*N*/ 		}
/*N*/ 	}
/*N*/ 
/*N*/ 	if (nClickY > 0)
/*N*/ 	{
/*N*/ 		while ( rPosY<=MAXROW && nClickY >= nScrY )
/*N*/ 		{
/*N*/ 			nScrY += ToPixel( pDoc->FastGetRowHeight( rPosY, nTabNo ), nPPTY );
/*N*/ 			++rPosY;
/*N*/ 		}
/*N*/ 		--rPosY;
/*N*/ 	}
/*N*/ 	else
/*N*/ 	{
/*N*/ 		while ( rPosY>0 && nClickY < nScrY )
/*N*/ 		{
/*N*/ 			--rPosY;
/*N*/ 			nScrY -= ToPixel( pDoc->FastGetRowHeight( rPosY, nTabNo ), nPPTY );
/*N*/ 		}
/*N*/ 	}
/*N*/ 
/*N*/ 	if (bNextIfLarge)		//	zu grosse Zellen ?
/*N*/ 	{
/*N*/ 		if ( rPosX == nStartPosX && nClickX > 0 )
/*N*/ 		{
/*N*/ 			if (pView)
/*N*/ 				aScrSize.Width() = pView->GetGridWidth(eHWhich);
/*N*/ 			if ( nClickX > aScrSize.Width() )
/*N*/ 				++rPosX;
/*N*/ 		}
/*N*/ 		if ( rPosY == nStartPosY && nClickY > 0 )
/*N*/ 		{
/*N*/ 			if (pView)
/*N*/ 				aScrSize.Height() = pView->GetGridHeight(eVWhich);
/*N*/ 			if ( nClickY > aScrSize.Height() )
/*N*/ 				++rPosY;
/*N*/ 		}
/*N*/ 	}
/*N*/ 
/*N*/ 	if (rPosX<0) rPosX=0;
/*N*/ 	if (rPosX>MAXCOL) rPosX=MAXCOL;
/*N*/ 	if (rPosY<0) rPosY=0;
/*N*/ 	if (rPosY>MAXROW) rPosY=MAXROW;
/*N*/ 
/*N*/ 	if (bTestMerge)
/*N*/ 	{
/*?*/ 		//!	public Methode um Position anzupassen
/*?*/ 
/*?*/ 		DBG_BF_ASSERT(0, "STRIP"); //STRIP001 BOOL bHOver = FALSE;
/*N*/ 	}
/*N*/ 
/*N*/ 	return FALSE;
/*N*/ }




/*N*/ void ScViewData::RecalcPixPos()				// nach Zoom-Aenderungen
/*N*/ {
/*N*/ 	USHORT i;
/*N*/ 
/*N*/ 	for (USHORT eWhich=0; eWhich<2; eWhich++)
/*N*/ 	{
/*N*/ 		long nPixPosX = 0;
/*N*/ 		USHORT nPosX = pThisTab->nPosX[eWhich];
/*N*/ 		for (i=0; i<nPosX; i++)
/*?*/ 			nPixPosX -= ToPixel(pDoc->GetColWidth(i,nTabNo), nPPTX);
/*N*/ 		pThisTab->nPixPosX[eWhich] = nPixPosX;
/*N*/ 
/*N*/ 		long nPixPosY = 0;
/*N*/ 		USHORT nPosY = pThisTab->nPosY[eWhich];
/*N*/ 		for (i=0; i<nPosY; i++)
/*?*/ 			nPixPosY -= ToPixel(pDoc->FastGetRowHeight(i,nTabNo), nPPTY);
/*N*/ 		pThisTab->nPixPosY[eWhich] = nPixPosY;
/*N*/ 	}
/*N*/ }

/*N*/ const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich )
/*N*/ {
/*N*/ 	aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)],
/*N*/ 									pThisTab->nMPosY[WhichV(eWhich)] ) );
/*N*/ 	return aLogicMode;
/*N*/ }

/*N*/ const MapMode& ScViewData::GetLogicMode()
/*N*/ {
/*N*/ 	aLogicMode.SetOrigin( Point() );
/*N*/ 	return aLogicMode;
/*N*/ }




/*N*/ SfxObjectShell* ScViewData::GetSfxDocShell() const
/*N*/ {
/*N*/ 	return pDocShell;
/*N*/ }

/*N*/ SfxBindings& ScViewData::GetBindings()
/*N*/ {
/*N*/ 	DBG_ASSERT( pViewShell, "GetBindings() without ViewShell" );
/*N*/ 	return pViewShell->GetViewFrame()->GetBindings();
/*N*/ }

/*N*/ SfxDispatcher& ScViewData::GetDispatcher()
/*N*/ {
/*N*/ 	DBG_ASSERT( pViewShell, "GetDispatcher() without ViewShell" );
/*N*/ 	return *pViewShell->GetViewFrame()->GetDispatcher();
/*N*/ }


/*N*/ Window* ScViewData::GetActiveWin()
/*N*/ {
/*N*/ 	DBG_ASSERT( pView, "GetActiveWin() ohne View" );
/*N*/ 	return pView->GetActiveWin();
/*N*/ }

/*N*/ ScDrawView* ScViewData::GetScDrawView()
/*N*/ {
/*N*/ 	DBG_ASSERT( pView, "GetScDrawView() ohne View" );
/*N*/ 	return pView->GetScDrawView();
/*N*/ }

/*N*/ BOOL ScViewData::IsMinimized()
/*N*/ {
/*N*/ 	DBG_ASSERT( pView, "IsMinimized() ohne View" );
/*N*/ 	return pView->IsMinimized();
/*N*/ }


/*N*/ void ScViewData::CalcPPT()
/*N*/ {
/*N*/ 	nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX();
/*N*/ 	if (pDocShell)
/*N*/ 		nPPTX = nPPTX / pDocShell->GetOutputFactor();	// Faktor ist Drucker zu Bildschirm
/*N*/ 	nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY();
/*N*/ 
/*N*/ 	//	#83616# if detective objects are present,
/*N*/ 	//	try to adjust horizontal scale so the most common column width has minimal rounding errors,
/*N*/ 	//	to avoid differences between cell and drawing layer output
/*N*/ 
/*N*/ 	if ( pDoc && pDoc->HasDetectiveObjects(nTabNo) )
/*N*/ 	{
/*?*/ 		DBG_BF_ASSERT(0, "STRIP"); //STRIP001 USHORT nEndCol = 0;
/*N*/ 	}
/*N*/ }

//------------------------------------------------------------------

#define SC_OLD_TABSEP	'/'
#define SC_NEW_TABSEP	'+'

// #116578# WriteUserData must not access pView
/*N*/ void ScViewData::WriteUserData(String& rData)
/*N*/ {
/*N*/ 	//	nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
/*N*/ 	//	nTab
/*N*/ 	//  Tab-ControlBreite
/*N*/ 	//	pro Tabelle:
/*N*/ 	//	CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
/*N*/ 	//	PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
/*N*/ 	//	wenn Zeilen groesser 8192, "+" statt "/"
/*N*/ 
/*N*/ 	USHORT nZoom = (USHORT)((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator());
/*N*/ 	rData = String::CreateFromInt32( nZoom );
/*N*/ 	rData += '/';
/*N*/ 	nZoom = (USHORT)((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator());
/*N*/ 	rData += String::CreateFromInt32( nZoom );
/*N*/ 	rData += '/';
/*N*/ 	if (bPagebreak)
/*N*/ 		rData += '1';
/*N*/ 	else
/*N*/ 		rData += '0';
/*N*/ 
/*N*/ 	rData += ';';
/*N*/ 	rData += String::CreateFromInt32( nTabNo );
/*N*/ 	rData += ';';
/*N*/ 	rData.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH ));
/*N*/ 	rData += String::CreateFromInt32( nTabBarWidth );   // #116578#
/*N*/ 
/*N*/ 	USHORT nTabCount = pDoc->GetTableCount();
/*N*/ 	for (USHORT i=0; i<nTabCount; i++)
/*N*/ 	{
/*N*/ 		rData += ';';					// Numerierung darf auf keinen Fall durcheinanderkommen
/*N*/ 		if (pTabData[i])
/*N*/ 		{
/*N*/ 			sal_Unicode cTabSep = SC_OLD_TABSEP;				// wie 3.1
/*N*/ 			if ( pTabData[i]->nCurY > MAXROW_30 ||
/*N*/ 				 pTabData[i]->nPosY[0] > MAXROW_30 || pTabData[i]->nPosY[1] > MAXROW_30 ||
/*N*/ 				 ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
/*N*/ 					pTabData[i]->nFixPosY > MAXROW_30 ) )
/*N*/ 			{
/*N*/ 				cTabSep = SC_NEW_TABSEP;		// um eine 3.1-Version nicht umzubringen
/*N*/ 			}
/*N*/ 
/*N*/ 
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nCurX );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nCurY );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->eHSplitMode );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->eVSplitMode );
/*N*/ 			rData += cTabSep;
/*N*/ 			if ( pTabData[i]->eHSplitMode == SC_SPLIT_FIX )
/*N*/ 				rData += String::CreateFromInt32( pTabData[i]->nFixPosX );
/*N*/ 			else
/*N*/ 				rData += String::CreateFromInt32( pTabData[i]->nHSplitPos );
/*N*/ 			rData += cTabSep;
/*N*/ 			if ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX )
/*N*/ 				rData += String::CreateFromInt32( pTabData[i]->nFixPosY );
/*N*/ 			else
/*N*/ 				rData += String::CreateFromInt32( pTabData[i]->nVSplitPos );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->eWhichActive );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nPosX[0] );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nPosX[1] );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nPosY[0] );
/*N*/ 			rData += cTabSep;
/*N*/ 			rData += String::CreateFromInt32( pTabData[i]->nPosY[1] );
/*N*/ 		}
/*N*/ 	}
/*N*/ }

// #116578# ReadUserData is needed, must not access pView
void ScViewData::ReadUserData(const String& rData)
{
	if (!rData.Len())		// Leerer String kommt bei "neu Laden"
		return;				// dann auch ohne Assertion beenden

	xub_StrLen nCount = rData.GetTokenCount(';');
	if ( nCount <= 2 )
	{
		//	#45208# beim Reload in der Seitenansicht sind evtl. die Preview-UserData
		//	stehengelassen worden. Den Zoom von der Preview will man hier nicht...
		DBG_ERROR("ReadUserData: das sind nicht meine Daten");
		return;
	}

	String aTabOpt;
	xub_StrLen nTagLen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(TAG_TABBARWIDTH)).Len();

	//-------------------
	// nicht pro Tabelle:
	//-------------------
	USHORT nTabStart = 2;

	String aZoomStr = rData.GetToken(0);						// Zoom/PageZoom/Modus
	USHORT nNormZoom = aZoomStr.GetToken(0,'/').ToInt32();
	if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
		aZoomX = aZoomY = Fraction( nNormZoom, 100 );			//	"normaler" Zoom (immer)
	USHORT nPageZoom = aZoomStr.GetToken(1,'/').ToInt32();
	if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM )
		aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 );	// Pagebreak-Zoom, wenn gesetzt
	sal_Unicode cMode = aZoomStr.GetToken(2,'/').GetChar(0);	// 0 oder "0"/"1"
	SetPagebreakMode( cMode == '1' );
	// SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()

	//
	//	Tabelle kann ungueltig geworden sein (z.B. letzte Version):
	//
	USHORT nNewTab = rData.GetToken(1).ToInt32();
	if (pDoc->HasTable( nNewTab ))
		SetTabNo(nNewTab);

	//
	// wenn vorhanden, TabBar-Breite holen:
	//
	aTabOpt = rData.GetToken(2);

	if ( nTagLen && aTabOpt.Copy(0,nTagLen).EqualsAscii(TAG_TABBARWIDTH) )
	{
        // #116578# store tab bar width locally
        nTabBarWidth = aTabOpt.Copy(nTagLen).ToInt32();
		nTabStart = 3;
	}

	//-------------
	// pro Tabelle:
	//-------------
	USHORT nPos = 0;
	while ( nCount > nPos+nTabStart )
	{
		aTabOpt = rData.GetToken(nPos+nTabStart);
		if (!pTabData[nPos])
			pTabData[nPos] = new ScViewDataTable;

		sal_Unicode cTabSep = 0;
		if (aTabOpt.GetTokenCount(SC_OLD_TABSEP) >= 11)
			cTabSep = SC_OLD_TABSEP;
#ifndef SC_LIMIT_ROWS
		else if (aTabOpt.GetTokenCount(SC_NEW_TABSEP) >= 11)
			cTabSep = SC_NEW_TABSEP;
		// '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
#endif

		if (cTabSep)
		{
			pTabData[nPos]->nCurX = aTabOpt.GetToken(0,cTabSep).ToInt32();
			pTabData[nPos]->nCurY = aTabOpt.GetToken(1,cTabSep).ToInt32();
			pTabData[nPos]->eHSplitMode = (ScSplitMode) aTabOpt.GetToken(2,cTabSep).ToInt32();
			pTabData[nPos]->eVSplitMode = (ScSplitMode) aTabOpt.GetToken(3,cTabSep).ToInt32();

			if ( pTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
			{
				pTabData[nPos]->nFixPosX = aTabOpt.GetToken(4,cTabSep).ToInt32();
//				UpdateFixX(nPos);
			}
			else
				pTabData[nPos]->nHSplitPos = aTabOpt.GetToken(4,cTabSep).ToInt32();

			if ( pTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
			{
				pTabData[nPos]->nFixPosY = aTabOpt.GetToken(5,cTabSep).ToInt32();
//				UpdateFixY(nPos);
			}
			else
				pTabData[nPos]->nVSplitPos = aTabOpt.GetToken(5,cTabSep).ToInt32();

			pTabData[nPos]->eWhichActive = (ScSplitPos) aTabOpt.GetToken(6,cTabSep).ToInt32();
			pTabData[nPos]->nPosX[0] = aTabOpt.GetToken(7,cTabSep).ToInt32();
			pTabData[nPos]->nPosX[1] = aTabOpt.GetToken(8,cTabSep).ToInt32();
			pTabData[nPos]->nPosY[0] = aTabOpt.GetToken(9,cTabSep).ToInt32();
			pTabData[nPos]->nPosY[1] = aTabOpt.GetToken(10,cTabSep).ToInt32();

			//	Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
			//	(Bug #44516#)
			ScSplitPos eTest = pTabData[nPos]->eWhichActive;
			if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT &&
					pTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) ||
				 ( WhichV( eTest ) == SC_SPLIT_TOP &&
					pTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) )
			{
				//	dann wieder auf Default (unten links)
				pTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT;
				DBG_ERROR("SplitPos musste korrigiert werden");
			}
		}
		++nPos;
	}

	RecalcPixPos();
}



// #116578# WriteUserDataSequence must not access pView
/*N*/ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings)
/*N*/ {
/*N*/ 	rSettings.realloc(SC_VIEWSETTINGS_COUNT);
/*N*/ 	// + 1, because we have to put the view id in the sequence
/*N*/ 	beans::PropertyValue* pSettings = rSettings.getArray();
/*N*/ 	if (pSettings)
/*N*/ 	{
            sal_uInt16 nViewID = 1;     // #116578# always ScTabViewShell (ID from ScDLL::Init)
/*N*/ 		pSettings[SC_VIEW_ID].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
/*N*/ 		::rtl::OUStringBuffer sBuffer(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
/*N*/ 		SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
/*N*/ 		pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear();
/*N*/ 
/*N*/ 		USHORT nTabCount (pDoc->GetTableCount());
/*N*/ 		uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
/*N*/ 										::legacy_binfilters::getLegacyProcessServiceFactory();
/*N*/ 		DBG_ASSERT( xServiceFactory.is(), "got no service manager" );
/*N*/ 		if( xServiceFactory.is() )
/*N*/ 		{
/*N*/ 			::rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues"));
/*N*/ 			uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY);
/*N*/ 			if (xNameContainer.is())
/*N*/ 			{
/*N*/ 				for (USHORT nTab=0; nTab<nTabCount; nTab++)
/*N*/ 				{
/*N*/ 					if (pTabData[nTab])
/*N*/ 					{
/*N*/ 						uno::Sequence <beans::PropertyValue> aTableViewSettings;
/*N*/ 						pTabData[nTab]->WriteUserDataSequence(aTableViewSettings);
/*N*/ 						String sName;
/*N*/ 						GetDocument()->GetName( nTab, sName );
/*N*/ 						::rtl::OUString sOUName(sName);
/*N*/ 						uno::Any aAny;
/*N*/ 						aAny <<= aTableViewSettings;
/*N*/                         try
/*N*/                         {
/*N*/ 						    xNameContainer->insertByName(sName, aAny);
/*N*/                         }
/*N*/                         //#101739#; two tables with the same name are possible
/*N*/                         catch ( container::ElementExistException& )
/*N*/                         {
/*N*/                             DBG_ERRORFILE("seems there are two tables with the same name");
/*N*/                         }
/*N*/                         catch ( uno::RuntimeException& )
/*N*/                         {
/*N*/                             DBG_ERRORFILE("something went wrong");
/*N*/                         }
/*N*/ 					}
/*N*/ 				}
/*N*/ 				pSettings[SC_TABLE_VIEWSETTINGS].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES));
/*N*/ 				pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
/*N*/ 			}
/*N*/ 		}
/*N*/ 
/*N*/ 		String sName;
/*N*/ 		GetDocument()->GetName( nTabNo, sName );
/*N*/ 		::rtl::OUString sOUName(sName);
/*N*/ 		pSettings[SC_ACTIVE_TABLE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
/*N*/ 		pSettings[SC_ACTIVE_TABLE].Value <<= sOUName;
/*N*/ 		pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSCROLLBARWIDTH));
            pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32( nTabBarWidth );  // #116578# use stored value
/*N*/ 		sal_Int32 nZoomValue ((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator());
/*N*/ 		sal_Int32 nPageZoomValue ((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator());
/*N*/ 		pSettings[SC_ZOOM_TYPE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
            pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16( SVX_ZOOM_PERCENT );  // #116578# always direct value for old files
/*N*/ 		pSettings[SC_ZOOM_VALUE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
/*N*/ 		pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
/*N*/ 		pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
/*N*/ 		pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
/*N*/ 		pSettings[SC_PAGE_BREAK_PREVIEW].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SHOWPAGEBREAKPREVIEW));
/*N*/ 		ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_PAGE_BREAK_PREVIEW].Value, bPagebreak);
/*N*/ 
/*N*/ 		if (pOptions)
/*N*/ 		{
/*N*/ 			pSettings[SC_SHOWZERO].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWZERO));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWZERO].Value, pOptions->GetOption( VOPT_NULLVALS ) );
/*N*/ 			pSettings[SC_SHOWNOTES].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWNOTES));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWNOTES].Value, pOptions->GetOption( VOPT_NOTES ) );
/*N*/ 			pSettings[SC_SHOWGRID].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWGRID].Value, pOptions->GetOption( VOPT_GRID ) );
/*N*/ 			pSettings[SC_GRIDCOLOR].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_GRIDCOLOR));
/*N*/ 			String aColorName;
/*N*/ 			Color aColor = pOptions->GetGridColor(&aColorName);
/*N*/ 			pSettings[SC_GRIDCOLOR].Value <<= static_cast<sal_Int64>(aColor.GetColor());
/*N*/ 			pSettings[SC_SHOWPAGEBR].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWPAGEBR));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWPAGEBR].Value, pOptions->GetOption( VOPT_PAGEBREAKS ) );
/*N*/ 			pSettings[SC_COLROWHDR].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COLROWHDR));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_COLROWHDR].Value, pOptions->GetOption( VOPT_HEADER ) );
/*N*/ 			pSettings[SC_SHEETTABS].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETTABS));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHEETTABS].Value, pOptions->GetOption( VOPT_TABCONTROLS ) );
/*N*/ 			pSettings[SC_OUTLSYMB].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_OUTLSYMB));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_OUTLSYMB].Value, pOptions->GetOption( VOPT_OUTLINER ) );
/*N*/ 
/*N*/ 			const ScGridOptions& aGridOpt = pOptions->GetGridOptions();
/*N*/ 			pSettings[SC_SNAPTORASTER].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SNAPTORASTER));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SNAPTORASTER].Value, aGridOpt.GetUseGridSnap() );
/*N*/ 			pSettings[SC_RASTERVIS].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERVIS));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERVIS].Value, aGridOpt.GetGridVisible() );
/*N*/ 			pSettings[SC_RASTERRESX].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESX));
/*N*/ 			pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
/*N*/ 			pSettings[SC_RASTERRESY].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESY));
/*N*/ 			pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
/*N*/ 			pSettings[SC_RASTERSUBX].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBX));
/*N*/ 			pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
/*N*/ 			pSettings[SC_RASTERSUBY].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBY));
/*N*/ 			pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
/*N*/ 			pSettings[SC_RASTERSYNC].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSYNC));
/*N*/ 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERSYNC].Value, aGridOpt.GetSynchronize() );
/*N*/ 		}
/*N*/ 	}
/*N*/ }

// #116578# ReadUserDataSequence is needed, must not access pView
void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
{
	sal_Int32 nCount(rSettings.getLength());
	sal_Int32 nTemp32(0);
	sal_Int16 nTemp16(0);
	sal_Bool bPageMode(sal_False);
	for (sal_Int32 i = 0; i < nCount; i++)
	{
		// SC_VIEWID has to parse and use by mba
		::rtl::OUString sName(rSettings[i].Name);
		if (sName.compareToAscii(SC_TABLES) == 0)
		{
			uno::Reference<container::XNameContainer> xNameContainer;
			if ((rSettings[i].Value >>= xNameContainer) && xNameContainer->hasElements())
			{
				uno::Sequence< ::rtl::OUString > aNames(xNameContainer->getElementNames());
				for (sal_Int32 i = 0; i < aNames.getLength(); i++)
				{
					String sTabName(aNames[i]);
					sal_uInt16 nTab(0);
					if (GetDocument()->GetTable(sTabName, nTab))
					{
						uno::Any aAny = xNameContainer->getByName(aNames[i]);
						uno::Sequence<beans::PropertyValue> aTabSettings;
						if (aAny >>= aTabSettings)
						{
							pTabData[nTab] = new ScViewDataTable;
							pTabData[nTab]->ReadUserDataSequence(aTabSettings);
						}
					}
				}
			}
		}
		else if (sName.compareToAscii(SC_ACTIVETABLE) == 0)
		{
			::rtl::OUString sName;
			if(rSettings[i].Value >>= sName)
			{
				String sTabName(sName);
				sal_uInt16 nTab(0);
				if (GetDocument()->GetTable(sTabName, nTab))
					nTabNo = nTab;
			}
		}
		else if (sName.compareToAscii(SC_HORIZONTALSCROLLBARWIDTH) == 0)
		{
			if (rSettings[i].Value >>= nTemp32)
                nTabBarWidth = nTemp32;             // #116578# store locally
		}
		else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
		{
            // #116578# zoom type is ignored for conversion to binary
		}
		else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
		{
			if (rSettings[i].Value >>= nTemp32)
			{
				Fraction aZoom(nTemp32, 100);
				aZoomX = aZoomY = aZoom;
			}
		}
		else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
		{
			if (rSettings[i].Value >>= nTemp32)
			{
				Fraction aZoom(nTemp32, 100);
				aPageZoomX = aPageZoomY = aZoom;
			}
		}
		else if (sName.compareToAscii(SC_SHOWPAGEBREAKPREVIEW) == 0)
			bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value );
		else if ( sName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
			pOptions->SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
			pOptions->SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
			pOptions->SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
		{
			sal_Int64 nColor;
			if (rSettings[i].Value >>= nColor)
			{
				String aColorName;
				Color aColor(static_cast<sal_uInt32>(nColor));
				pOptions->SetGridColor(aColor, aColorName);
			}
		}
		else if ( sName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
			pOptions->SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
			pOptions->SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
			pOptions->SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else if ( sName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
			pOptions->SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
		else
		{
			ScGridOptions aGridOpt(pOptions->GetGridOptions());
			if ( sName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
				aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
				aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
				aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
				aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
				aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
				aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
			else if ( sName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
				aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
			pOptions->SetGridOptions(aGridOpt);
		}
	}
	if (nCount)
		SetPagebreakMode( bPageMode );
}

/*N*/ void ScViewData::SetOptions( const ScViewOptions& rOpt )
/*N*/ {
/*N*/ 	//	if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
/*N*/ 	BOOL bHScrollChanged = ( rOpt.GetOption(VOPT_HSCROLL) != pOptions->GetOption(VOPT_HSCROLL) );
/*N*/ 
/*N*/ 	//	if graphics are turned on or off, animation has to be started or stopped
/*N*/ 	//	graphics are controlled by VOBJ_TYPE_OLE
/*N*/ 	BOOL bGraphicsChanged =	( pOptions->GetObjMode(VOBJ_TYPE_OLE) !=
/*N*/ 								   rOpt.GetObjMode(VOBJ_TYPE_OLE) );
/*N*/ 
/*N*/ 	*pOptions = rOpt;
/*N*/ 	DBG_ASSERT( pView, "No View" );
/*N*/ 
/*N*/ 	if( pView )
/*N*/ 	{
/*N*/ 		pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
/*N*/ 	}
/*N*/ }











}
