xref: /aoo42x/main/sc/source/ui/view/viewdata.cxx (revision 7a980842)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "scitems.hxx"
32cdf0e10cSrcweir #include <editeng/eeitem.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
36cdf0e10cSrcweir #include <editeng/adjitem.hxx>
37cdf0e10cSrcweir #include <svx/algitem.hxx>
38cdf0e10cSrcweir #include <editeng/brshitem.hxx>
39cdf0e10cSrcweir #include <svtools/colorcfg.hxx>
40cdf0e10cSrcweir #include <editeng/editview.hxx>
41cdf0e10cSrcweir #include <editeng/editstat.hxx>
42cdf0e10cSrcweir #include <editeng/outliner.hxx>
43cdf0e10cSrcweir #include <editeng/unolingu.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <vcl/svapp.hxx>
46cdf0e10cSrcweir #include <rtl/math.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "viewdata.hxx"
49cdf0e10cSrcweir #include "docoptio.hxx"
50cdf0e10cSrcweir #include "scmod.hxx"
51cdf0e10cSrcweir #include "global.hxx"
52cdf0e10cSrcweir #include "document.hxx"
53cdf0e10cSrcweir #include "attrib.hxx"
54cdf0e10cSrcweir #include "tabview.hxx"
55cdf0e10cSrcweir #include "tabvwsh.hxx"
56cdf0e10cSrcweir #include "docsh.hxx"
57cdf0e10cSrcweir #include "sc.hrc"
58cdf0e10cSrcweir #include "patattr.hxx"
59cdf0e10cSrcweir #include "editutil.hxx"
60cdf0e10cSrcweir #include "scextopt.hxx"
61cdf0e10cSrcweir #include "miscuno.hxx"
62cdf0e10cSrcweir #include "unonames.hxx"
63cdf0e10cSrcweir #include "inputopt.hxx"
64cdf0e10cSrcweir #include "viewutil.hxx"
65cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
66cdf0e10cSrcweir #include "ViewSettingsSequenceDefines.hxx"
67cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
68cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
69cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
70cdf0e10cSrcweir 
71cdf0e10cSrcweir using namespace com::sun::star;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir #define SC_GROWY_SMALL_EXTRA	100
76cdf0e10cSrcweir #define SC_GROWY_BIG_EXTRA		200
77cdf0e10cSrcweir 
78cdf0e10cSrcweir #define TAG_TABBARWIDTH "tw:"
79cdf0e10cSrcweir 
80cdf0e10cSrcweir static sal_Bool bMoveArea = sal_False;				//! Member?
81cdf0e10cSrcweir sal_uInt16 nEditAdjust = SVX_ADJUST_LEFT;		//! Member !!!
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //==================================================================
84cdf0e10cSrcweir 
ScViewDataTable()85cdf0e10cSrcweir ScViewDataTable::ScViewDataTable() :
86cdf0e10cSrcweir                 eZoomType( SVX_ZOOM_PERCENT ),
87cdf0e10cSrcweir                 aZoomX( 1,1 ),
88cdf0e10cSrcweir                 aZoomY( 1,1 ),
89cdf0e10cSrcweir                 aPageZoomX( 3,5 ),              // Page-Default: 60%
90cdf0e10cSrcweir                 aPageZoomY( 3,5 ),
91cdf0e10cSrcweir 				nHSplitPos( 0 ),
92cdf0e10cSrcweir 				nVSplitPos( 0 ),
93cdf0e10cSrcweir 				eHSplitMode( SC_SPLIT_NONE ),
94cdf0e10cSrcweir 				eVSplitMode( SC_SPLIT_NONE ),
95cdf0e10cSrcweir 				eWhichActive( SC_SPLIT_BOTTOMLEFT ),
96cdf0e10cSrcweir 				nFixPosX( 0 ),
97cdf0e10cSrcweir 				nFixPosY( 0 ),
98cdf0e10cSrcweir 				nCurX( 0 ),
99cdf0e10cSrcweir 				nCurY( 0 ),
100cdf0e10cSrcweir                 bOldCurValid( sal_False )
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	nPosX[0]=nPosX[1]=0;
103cdf0e10cSrcweir 	nPosY[0]=nPosY[1]=0;
104cdf0e10cSrcweir 	nTPosX[0]=nTPosX[1]=0;
105cdf0e10cSrcweir 	nTPosY[0]=nTPosY[1]=0;
106cdf0e10cSrcweir 	nMPosX[0]=nMPosX[1]=0;
107cdf0e10cSrcweir 	nMPosY[0]=nMPosY[1]=0;
108cdf0e10cSrcweir 	nPixPosX[0]=nPixPosX[1]=0;
109cdf0e10cSrcweir 	nPixPosY[0]=nPixPosY[1]=0;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
~ScViewDataTable()112cdf0e10cSrcweir ScViewDataTable::~ScViewDataTable()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
WriteUserDataSequence(uno::Sequence<beans::PropertyValue> & rSettings,const ScViewData &,SCTAB)116cdf0e10cSrcweir void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
119cdf0e10cSrcweir 	beans::PropertyValue* pSettings = rSettings.getArray();
120cdf0e10cSrcweir 	if (pSettings)
121cdf0e10cSrcweir 	{
122cdf0e10cSrcweir 		pSettings[SC_CURSOR_X].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONX));
123cdf0e10cSrcweir 		pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX);
124cdf0e10cSrcweir 		pSettings[SC_CURSOR_Y].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONY));
125cdf0e10cSrcweir 		pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY);
126cdf0e10cSrcweir 		pSettings[SC_HORIZONTAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITMODE));
127cdf0e10cSrcweir 		pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eHSplitMode);
128cdf0e10cSrcweir 		pSettings[SC_VERTICAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITMODE));
129cdf0e10cSrcweir 		pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eVSplitMode);
130cdf0e10cSrcweir 		pSettings[SC_HORIZONTAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITPOSITION));
131cdf0e10cSrcweir 		if (eHSplitMode == SC_SPLIT_FIX)
132cdf0e10cSrcweir 			pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosX);
133cdf0e10cSrcweir 		else
134cdf0e10cSrcweir 			pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nHSplitPos);
135cdf0e10cSrcweir 		pSettings[SC_VERTICAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITPOSITION));
136cdf0e10cSrcweir 		if (eVSplitMode == SC_SPLIT_FIX)
137cdf0e10cSrcweir 			pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY);
138cdf0e10cSrcweir 		else
139cdf0e10cSrcweir 			pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nVSplitPos);
140cdf0e10cSrcweir 		pSettings[SC_ACTIVE_SPLIT_RANGE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVESPLITRANGE));
141cdf0e10cSrcweir 		pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eWhichActive);
142cdf0e10cSrcweir 		pSettings[SC_POSITION_LEFT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONLEFT));
143cdf0e10cSrcweir 		pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
144cdf0e10cSrcweir 		pSettings[SC_POSITION_RIGHT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONRIGHT));
145cdf0e10cSrcweir 		pSettings[SC_POSITION_RIGHT].Value <<= sal_Int32(nPosX[SC_SPLIT_RIGHT]);
146cdf0e10cSrcweir 		pSettings[SC_POSITION_TOP].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONTOP));
147cdf0e10cSrcweir 		pSettings[SC_POSITION_TOP].Value <<= sal_Int32(nPosY[SC_SPLIT_TOP]);
148cdf0e10cSrcweir 		pSettings[SC_POSITION_BOTTOM].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONBOTTOM));
149cdf0e10cSrcweir 		pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir         sal_Int32 nZoomValue ((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator());
152cdf0e10cSrcweir         sal_Int32 nPageZoomValue ((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator());
153cdf0e10cSrcweir         pSettings[SC_TABLE_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
154cdf0e10cSrcweir         pSettings[SC_TABLE_ZOOM_TYPE].Value <<= sal_Int16(eZoomType);
155cdf0e10cSrcweir         pSettings[SC_TABLE_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
156cdf0e10cSrcweir         pSettings[SC_TABLE_ZOOM_VALUE].Value <<= nZoomValue;
157cdf0e10cSrcweir         pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
158cdf0e10cSrcweir         pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
ReadUserDataSequence(const uno::Sequence<beans::PropertyValue> & aSettings,ScViewData & rViewData,SCTAB nTab,bool & rHasZoom)162cdf0e10cSrcweir void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings, ScViewData& rViewData, SCTAB nTab, bool& rHasZoom )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     rHasZoom = false;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	sal_Int32 nCount(aSettings.getLength());
167cdf0e10cSrcweir 	sal_Int32 nTemp32(0);
168cdf0e10cSrcweir 	sal_Int16 nTemp16(0);
169cdf0e10cSrcweir 	sal_Int32 nTempPosV(0);
170cdf0e10cSrcweir 	sal_Int32 nTempPosH(0);
171cdf0e10cSrcweir     sal_Int32 nTempPosVTw(0);
172cdf0e10cSrcweir     sal_Int32 nTempPosHTw(0);
173cdf0e10cSrcweir     bool bHasVSplitInTwips = false;
174cdf0e10cSrcweir     bool bHasHSplitInTwips = false;
175cdf0e10cSrcweir 	for (sal_Int32 i = 0; i < nCount; i++)
176cdf0e10cSrcweir 	{
177cdf0e10cSrcweir 		rtl::OUString sName(aSettings[i].Name);
178cdf0e10cSrcweir 		if (sName.compareToAscii(SC_CURSORPOSITIONX) == 0)
179cdf0e10cSrcweir 		{
180cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
181cdf0e10cSrcweir 			nCurX = SanitizeCol( static_cast<SCCOL>(nTemp32));
182cdf0e10cSrcweir 		}
183cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_CURSORPOSITIONY) == 0)
184cdf0e10cSrcweir 		{
185cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
186cdf0e10cSrcweir 			nCurY = SanitizeRow( static_cast<SCROW>(nTemp32));
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_HORIZONTALSPLITMODE) == 0)
189cdf0e10cSrcweir 		{
190cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp16;
191cdf0e10cSrcweir 			eHSplitMode = static_cast<ScSplitMode>(nTemp16);
192cdf0e10cSrcweir 		}
193cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_VERTICALSPLITMODE) == 0)
194cdf0e10cSrcweir 		{
195cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp16;
196cdf0e10cSrcweir 			eVSplitMode = static_cast<ScSplitMode>(nTemp16);
197cdf0e10cSrcweir 		}
198cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION) == 0)
199cdf0e10cSrcweir 		{
200cdf0e10cSrcweir 			aSettings[i].Value >>= nTempPosH;
201cdf0e10cSrcweir             bHasHSplitInTwips = false;
202cdf0e10cSrcweir 		}
203cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION) == 0)
204cdf0e10cSrcweir 		{
205cdf0e10cSrcweir 			aSettings[i].Value >>= nTempPosV;
206cdf0e10cSrcweir             bHasVSplitInTwips = false;
207cdf0e10cSrcweir 		}
208cdf0e10cSrcweir         else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION_TWIPS) == 0)
209cdf0e10cSrcweir         {
210cdf0e10cSrcweir             aSettings[i].Value >>= nTempPosHTw;
211cdf0e10cSrcweir             bHasHSplitInTwips = true;
212cdf0e10cSrcweir         }
213cdf0e10cSrcweir         else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION_TWIPS) == 0)
214cdf0e10cSrcweir         {
215cdf0e10cSrcweir             aSettings[i].Value >>= nTempPosVTw;
216cdf0e10cSrcweir             bHasVSplitInTwips = true;
217cdf0e10cSrcweir         }
218cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_ACTIVESPLITRANGE) == 0)
219cdf0e10cSrcweir 		{
220cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp16;
221cdf0e10cSrcweir 			eWhichActive = static_cast<ScSplitPos>(nTemp16);
222cdf0e10cSrcweir 		}
223cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_POSITIONLEFT) == 0)
224cdf0e10cSrcweir 		{
225cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
226cdf0e10cSrcweir 			nPosX[SC_SPLIT_LEFT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
227cdf0e10cSrcweir 		}
228cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_POSITIONRIGHT) == 0)
229cdf0e10cSrcweir 		{
230cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
231cdf0e10cSrcweir 			nPosX[SC_SPLIT_RIGHT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
232cdf0e10cSrcweir 		}
233cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_POSITIONTOP) == 0)
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
236cdf0e10cSrcweir 			nPosY[SC_SPLIT_TOP] = SanitizeRow( static_cast<SCROW>(nTemp32));
237cdf0e10cSrcweir 		}
238cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_POSITIONBOTTOM) == 0)
239cdf0e10cSrcweir 		{
240cdf0e10cSrcweir 			aSettings[i].Value >>= nTemp32;
241cdf0e10cSrcweir 			nPosY[SC_SPLIT_BOTTOM] = SanitizeRow( static_cast<SCROW>(nTemp32));
242cdf0e10cSrcweir 		}
243cdf0e10cSrcweir         else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             aSettings[i].Value >>= nTemp16;
246cdf0e10cSrcweir             eZoomType = SvxZoomType(nTemp16);
247cdf0e10cSrcweir             rHasZoom = true;        // set if there is any zoom information
248cdf0e10cSrcweir         }
249cdf0e10cSrcweir         else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
250cdf0e10cSrcweir         {
251cdf0e10cSrcweir             aSettings[i].Value >>= nTemp32;
252cdf0e10cSrcweir             Fraction aZoom(nTemp32, 100);
253cdf0e10cSrcweir             aZoomX = aZoomY = aZoom;
254cdf0e10cSrcweir             rHasZoom = true;
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir         else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
257cdf0e10cSrcweir         {
258cdf0e10cSrcweir             aSettings[i].Value >>= nTemp32;
259cdf0e10cSrcweir             Fraction aZoom(nTemp32, 100);
260cdf0e10cSrcweir             aPageZoomX = aPageZoomY = aZoom;
261cdf0e10cSrcweir             rHasZoom = true;
262cdf0e10cSrcweir         }
263cdf0e10cSrcweir         else if (sName.compareToAscii(SC_TABLESELECTED) == 0)
264cdf0e10cSrcweir         {
265cdf0e10cSrcweir             bool bSelected = false;
266cdf0e10cSrcweir             aSettings[i].Value >>= bSelected;
267cdf0e10cSrcweir             rViewData.GetMarkData().SelectTable( nTab, bSelected );
268cdf0e10cSrcweir         }
269cdf0e10cSrcweir         else if (sName.compareToAscii(SC_UNONAME_TABCOLOR) == 0)
270cdf0e10cSrcweir         {
271cdf0e10cSrcweir             // There are documents out there that have their tab color defined as a view setting.
272cdf0e10cSrcweir             sal_Int32 nColor = COL_AUTO;
273cdf0e10cSrcweir             aSettings[i].Value >>= nColor;
274cdf0e10cSrcweir             if (static_cast<ColorData>(nColor) != COL_AUTO)
275cdf0e10cSrcweir             {
276cdf0e10cSrcweir                 ScDocument* pDoc = rViewData.GetDocument();
277cdf0e10cSrcweir                 pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor)));
278cdf0e10cSrcweir             }
279cdf0e10cSrcweir         }
280cdf0e10cSrcweir 	}
281cdf0e10cSrcweir 	if (eHSplitMode == SC_SPLIT_FIX)
282cdf0e10cSrcweir 		nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
283cdf0e10cSrcweir 	else
284cdf0e10cSrcweir         nHSplitPos = bHasHSplitInTwips ? static_cast< long >( nTempPosHTw * rViewData.GetPPTX() ) : nTempPosH;
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	if (eVSplitMode == SC_SPLIT_FIX)
287cdf0e10cSrcweir 		nFixPosY = SanitizeRow( static_cast<SCROW>( bHasVSplitInTwips ? nTempPosVTw : nTempPosV ));
288cdf0e10cSrcweir 	else
289cdf0e10cSrcweir         nVSplitPos = bHasVSplitInTwips ? static_cast< long >( nTempPosVTw * rViewData.GetPPTY() ) : nTempPosV;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir //==================================================================
293cdf0e10cSrcweir 
ScViewData(ScDocShell * pDocSh,ScTabViewShell * pViewSh)294cdf0e10cSrcweir ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
295cdf0e10cSrcweir 	:	pDocShell	( pDocSh ),
296cdf0e10cSrcweir 		pDoc		( NULL ),
297cdf0e10cSrcweir 		pView		( pViewSh ),
298cdf0e10cSrcweir 		pViewShell	( pViewSh ),
299cdf0e10cSrcweir 		pOptions	( new ScViewOptions ),
300cdf0e10cSrcweir 		pSpellingView ( NULL ),
301cdf0e10cSrcweir 		aLogicMode	( MAP_100TH_MM ),
302cdf0e10cSrcweir         eDefZoomType( SVX_ZOOM_PERCENT ),
303cdf0e10cSrcweir         aDefZoomX   ( 1,1 ),
304cdf0e10cSrcweir         aDefZoomY   ( 1,1 ),
305cdf0e10cSrcweir         aDefPageZoomX( 3,5 ),
306cdf0e10cSrcweir         aDefPageZoomY( 3,5 ),
307cdf0e10cSrcweir 		eRefType	( SC_REFTYPE_NONE ),
308cdf0e10cSrcweir 		nTabNo		( 0 ),
309cdf0e10cSrcweir 		nRefTabNo	( 0 ),
310cdf0e10cSrcweir         eEditActivePart( SC_SPLIT_BOTTOMLEFT ),
311cdf0e10cSrcweir 		bActive		( sal_True ),					//! wie initialisieren?
312cdf0e10cSrcweir 		bIsRefMode	( sal_False ),
313cdf0e10cSrcweir 		bDelMarkValid( sal_False ),
314cdf0e10cSrcweir 		nFillMode	( SC_FILL_NONE ),
315cdf0e10cSrcweir 		bPagebreak	( sal_False ),
316cdf0e10cSrcweir 		bSelCtrlMouseClick( sal_False )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 	SetGridMode		( sal_True );
320cdf0e10cSrcweir 	SetSyntaxMode	( sal_False );
321cdf0e10cSrcweir 	SetHeaderMode	( sal_True );
322cdf0e10cSrcweir 	SetTabMode		( sal_True );
323cdf0e10cSrcweir 	SetVScrollMode	( sal_True );
324cdf0e10cSrcweir 	SetHScrollMode	( sal_True );
325cdf0e10cSrcweir 	SetOutlineMode	( sal_True );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	aScrSize = Size( (long) ( STD_COL_WIDTH 		  * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
328cdf0e10cSrcweir 					 (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
329cdf0e10cSrcweir 	pTabData[0] = new ScViewDataTable;
330cdf0e10cSrcweir 	for ( SCTAB i = 1; i <= MAXTAB; i++ )
331cdf0e10cSrcweir 		pTabData[i] = NULL;
332cdf0e10cSrcweir 	pThisTab = pTabData[nTabNo];
333cdf0e10cSrcweir 	for (sal_uInt16 j=0; j<4; j++)
334cdf0e10cSrcweir 	{
335cdf0e10cSrcweir 		pEditView[j] = NULL;
336cdf0e10cSrcweir 		bEditActive[j] = sal_False;
337cdf0e10cSrcweir 	}
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 	nEditEndCol = nEditStartCol = nEditCol = 0;
340cdf0e10cSrcweir 	nEditEndRow = nEditRow = 0;
341cdf0e10cSrcweir 	nTabStartCol = SC_TABSTART_NONE;
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	if (pDocShell)
344cdf0e10cSrcweir 	{
345cdf0e10cSrcweir 		pDoc = pDocShell->GetDocument();
346cdf0e10cSrcweir 		*pOptions = pDoc->GetViewOptions();
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	//	keine ausgeblendete Tabelle anzeigen:
350cdf0e10cSrcweir 	if (pDoc && !pDoc->IsVisible(nTabNo))
351cdf0e10cSrcweir 	{
352cdf0e10cSrcweir 		while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) )
353cdf0e10cSrcweir 			++nTabNo;
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 		pTabData[nTabNo] = new ScViewDataTable;
356cdf0e10cSrcweir 		pThisTab = pTabData[nTabNo];
357cdf0e10cSrcweir 	}
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	CalcPPT();
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
ScViewData(const ScViewData & rViewData)362cdf0e10cSrcweir ScViewData::ScViewData( const ScViewData& rViewData )
363cdf0e10cSrcweir 	:	pDocShell	( rViewData.pDocShell ),
364cdf0e10cSrcweir 		pDoc		( rViewData.pDoc ),
365cdf0e10cSrcweir 		pView		( rViewData.pView ),
366cdf0e10cSrcweir 		pViewShell	( rViewData.pViewShell ),
367cdf0e10cSrcweir 		pOptions	( new ScViewOptions( *(rViewData.pOptions) )  ),
368cdf0e10cSrcweir 		pSpellingView ( rViewData.pSpellingView ),
369cdf0e10cSrcweir 		aLogicMode	( rViewData.aLogicMode ),
370cdf0e10cSrcweir         eDefZoomType( rViewData.eDefZoomType ),
371cdf0e10cSrcweir         aDefZoomX   ( rViewData.aDefZoomX ),
372cdf0e10cSrcweir         aDefZoomY   ( rViewData.aDefZoomY ),
373cdf0e10cSrcweir         aDefPageZoomX( rViewData.aDefPageZoomX ),
374cdf0e10cSrcweir         aDefPageZoomY( rViewData.aDefPageZoomY ),
375cdf0e10cSrcweir 		eRefType	( SC_REFTYPE_NONE ),
376cdf0e10cSrcweir 		nTabNo		( rViewData.nTabNo ),
377cdf0e10cSrcweir 		nRefTabNo	( rViewData.nTabNo ),			// kein RefMode
378cdf0e10cSrcweir 		eEditActivePart( rViewData.eEditActivePart ),
379cdf0e10cSrcweir 		bActive		( sal_True ),								//! wie initialisieren?
380cdf0e10cSrcweir 		bIsRefMode	( sal_False ),
381cdf0e10cSrcweir 		bDelMarkValid( sal_False ),
382cdf0e10cSrcweir 		nFillMode	( SC_FILL_NONE ),
383cdf0e10cSrcweir 		bPagebreak	( rViewData.bPagebreak ),
384cdf0e10cSrcweir 		bSelCtrlMouseClick( rViewData.bSelCtrlMouseClick )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	SetGridMode		( rViewData.IsGridMode() );
388cdf0e10cSrcweir 	SetSyntaxMode	( rViewData.IsSyntaxMode() );
389cdf0e10cSrcweir 	SetHeaderMode	( rViewData.IsHeaderMode() );
390cdf0e10cSrcweir 	SetTabMode		( rViewData.IsTabMode() );
391cdf0e10cSrcweir 	SetVScrollMode	( rViewData.IsVScrollMode() );
392cdf0e10cSrcweir 	SetHScrollMode	( rViewData.IsHScrollMode() );
393cdf0e10cSrcweir 	SetOutlineMode	( rViewData.IsOutlineMode() );
394cdf0e10cSrcweir 
395cdf0e10cSrcweir 	aScrSize = rViewData.aScrSize;
396cdf0e10cSrcweir 	for ( SCTAB i = 0; i <= MAXTAB; i++ )
397cdf0e10cSrcweir 		if (rViewData.pTabData[i])
398cdf0e10cSrcweir 			pTabData[i] = new ScViewDataTable( *rViewData.pTabData[i] );
399cdf0e10cSrcweir 		else
400cdf0e10cSrcweir 			pTabData[i] = NULL;
401cdf0e10cSrcweir 	pThisTab = pTabData[nTabNo];
402cdf0e10cSrcweir 	for (sal_uInt16 j=0; j<4; j++)
403cdf0e10cSrcweir 	{
404cdf0e10cSrcweir 		pEditView[j] = NULL;
405cdf0e10cSrcweir 		bEditActive[j] = sal_False;
406cdf0e10cSrcweir 	}
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	nEditEndCol = nEditStartCol = nEditCol = 0;
409cdf0e10cSrcweir 	nEditEndRow = nEditRow = 0;
410cdf0e10cSrcweir 	nTabStartCol = SC_TABSTART_NONE;
411cdf0e10cSrcweir 	CalcPPT();
412cdf0e10cSrcweir }
413cdf0e10cSrcweir 
InitData(ScDocument * pDocument)414cdf0e10cSrcweir void ScViewData::InitData( ScDocument* pDocument )
415cdf0e10cSrcweir {
416cdf0e10cSrcweir 	pDoc = pDocument;
417cdf0e10cSrcweir 	*pOptions = pDoc->GetViewOptions();
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //UNUSED2008-05  void ScViewData::InitFrom( const ScViewData* pRef )
421cdf0e10cSrcweir //UNUSED2008-05  {
422cdf0e10cSrcweir //UNUSED2008-05      if (pRef==NULL)
423cdf0e10cSrcweir //UNUSED2008-05      {
424cdf0e10cSrcweir //UNUSED2008-05          DBG_ERROR("ScViewData::InitFrom mit NULL");
425cdf0e10cSrcweir //UNUSED2008-05          return;
426cdf0e10cSrcweir //UNUSED2008-05      }
427cdf0e10cSrcweir //UNUSED2008-05
428cdf0e10cSrcweir //UNUSED2008-05      aScrSize    = pRef->aScrSize;
429cdf0e10cSrcweir //UNUSED2008-05      nTabNo      = pRef->nTabNo;
430cdf0e10cSrcweir //UNUSED2008-05      eDefZoomType = pRef->eDefZoomType;
431cdf0e10cSrcweir //UNUSED2008-05      aDefZoomX   = pRef->aDefZoomX;
432cdf0e10cSrcweir //UNUSED2008-05      aDefZoomY   = pRef->aDefZoomY;
433cdf0e10cSrcweir //UNUSED2008-05      aDefPageZoomX = pRef->aDefPageZoomX;
434cdf0e10cSrcweir //UNUSED2008-05      aDefPageZoomY = pRef->aDefPageZoomY;
435cdf0e10cSrcweir //UNUSED2008-05      bPagebreak  = pRef->bPagebreak;
436cdf0e10cSrcweir //UNUSED2008-05      aLogicMode  = pRef->aLogicMode;
437cdf0e10cSrcweir //UNUSED2008-05
438cdf0e10cSrcweir //UNUSED2008-05      SetGridMode     ( pRef->IsGridMode() );
439cdf0e10cSrcweir //UNUSED2008-05      SetSyntaxMode   ( pRef->IsSyntaxMode() );
440cdf0e10cSrcweir //UNUSED2008-05      SetHeaderMode   ( pRef->IsHeaderMode() );
441cdf0e10cSrcweir //UNUSED2008-05      SetTabMode      ( pRef->IsTabMode() );
442cdf0e10cSrcweir //UNUSED2008-05      SetVScrollMode  ( pRef->IsVScrollMode() );
443cdf0e10cSrcweir //UNUSED2008-05      SetHScrollMode  ( pRef->IsHScrollMode() );
444cdf0e10cSrcweir //UNUSED2008-05      SetOutlineMode  ( pRef->IsOutlineMode() );
445cdf0e10cSrcweir //UNUSED2008-05
446cdf0e10cSrcweir //UNUSED2008-05      for (SCTAB i=0; i<=MAXTAB; i++)
447cdf0e10cSrcweir //UNUSED2008-05      {
448cdf0e10cSrcweir //UNUSED2008-05          delete pTabData[i];
449cdf0e10cSrcweir //UNUSED2008-05          if (pRef->pTabData[i])
450cdf0e10cSrcweir //UNUSED2008-05              pTabData[i] = new ScViewDataTable( *pRef->pTabData[i] );
451cdf0e10cSrcweir //UNUSED2008-05          else
452cdf0e10cSrcweir //UNUSED2008-05              pTabData[i] = NULL;
453cdf0e10cSrcweir //UNUSED2008-05      }
454cdf0e10cSrcweir //UNUSED2008-05      pThisTab = pTabData[nTabNo];
455cdf0e10cSrcweir //UNUSED2008-05      CalcPPT();
456cdf0e10cSrcweir //UNUSED2008-05  }
457cdf0e10cSrcweir //UNUSED2008-05
458cdf0e10cSrcweir //UNUSED2008-05  void ScViewData::SetDocShell( ScDocShell* pShell )
459cdf0e10cSrcweir //UNUSED2008-05  {
460cdf0e10cSrcweir //UNUSED2008-05      pDocShell = pShell;
461cdf0e10cSrcweir //UNUSED2008-05      pDoc = pDocShell->GetDocument();
462cdf0e10cSrcweir //UNUSED2008-05      *pOptions = pDoc->GetViewOptions();
463cdf0e10cSrcweir //UNUSED2008-05      CalcPPT();
464cdf0e10cSrcweir //UNUSED2008-05  }
465cdf0e10cSrcweir 
GetDocument() const466cdf0e10cSrcweir ScDocument* ScViewData::GetDocument() const
467cdf0e10cSrcweir {
468cdf0e10cSrcweir 	if (pDoc)
469cdf0e10cSrcweir 		return pDoc;
470cdf0e10cSrcweir 	else if (pDocShell)
471cdf0e10cSrcweir 		return pDocShell->GetDocument();
472cdf0e10cSrcweir 
473cdf0e10cSrcweir 	DBG_ERROR("kein Document an ViewData");
474cdf0e10cSrcweir 	return NULL;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
~ScViewData()477cdf0e10cSrcweir ScViewData::~ScViewData()
478cdf0e10cSrcweir {
479cdf0e10cSrcweir 	for (SCTAB i=0; i<=MAXTAB; i++)
480cdf0e10cSrcweir 		if (pTabData[i])
481cdf0e10cSrcweir 			delete pTabData[i];
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 	KillEditView();
484cdf0e10cSrcweir 	delete pOptions;
485cdf0e10cSrcweir }
486cdf0e10cSrcweir 
UpdateThis()487cdf0e10cSrcweir void ScViewData::UpdateThis()
488cdf0e10cSrcweir {
489cdf0e10cSrcweir 	do
490cdf0e10cSrcweir 	{
491cdf0e10cSrcweir 		pThisTab = pTabData[nTabNo];
492cdf0e10cSrcweir 		if (!pThisTab)
493cdf0e10cSrcweir 		{
494cdf0e10cSrcweir 			if (nTabNo>0)
495cdf0e10cSrcweir 				--nTabNo;
496cdf0e10cSrcweir 			else
497cdf0e10cSrcweir 				pThisTab = pTabData[0] = new ScViewDataTable;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir 				// hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist!
500cdf0e10cSrcweir 		}
501cdf0e10cSrcweir 	}
502cdf0e10cSrcweir 	while (!pThisTab);
503cdf0e10cSrcweir }
504cdf0e10cSrcweir 
InsertTab(SCTAB nTab)505cdf0e10cSrcweir void ScViewData::InsertTab( SCTAB nTab )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	delete pTabData[MAXTAB];
508cdf0e10cSrcweir 
509cdf0e10cSrcweir 	for (SCTAB i=MAXTAB; i>nTab; i--)
510cdf0e10cSrcweir 		pTabData[i] = pTabData[i-1];
511cdf0e10cSrcweir 
512cdf0e10cSrcweir     pTabData[nTab] = NULL;      // force creating new
513cdf0e10cSrcweir     CreateTabData( nTab );
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 	UpdateThis();
516cdf0e10cSrcweir 	aMarkData.InsertTab( nTab );
517cdf0e10cSrcweir }
518cdf0e10cSrcweir 
DeleteTab(SCTAB nTab)519cdf0e10cSrcweir void ScViewData::DeleteTab( SCTAB nTab )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir 	delete pTabData[nTab];
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 	for (SCTAB i=nTab; i<MAXTAB; i++)
524cdf0e10cSrcweir 		pTabData[i] = pTabData[i+1];
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 	pTabData[MAXTAB] = NULL;
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	UpdateThis();
529cdf0e10cSrcweir 	aMarkData.DeleteTab( nTab );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir 
CopyTab(SCTAB nSrcTab,SCTAB nDestTab)532cdf0e10cSrcweir void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir 	if (nDestTab==SC_TAB_APPEND)
535cdf0e10cSrcweir 		nDestTab = pDoc->GetTableCount() - 1;	// am Doc muss vorher kopiert worden sein
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	if (nDestTab > MAXTAB)
538cdf0e10cSrcweir 	{
539cdf0e10cSrcweir 		DBG_ERROR("Zuviele Tabellen");
540cdf0e10cSrcweir 		return;
541cdf0e10cSrcweir 	}
542cdf0e10cSrcweir 
543cdf0e10cSrcweir 	delete pTabData[MAXTAB];
544cdf0e10cSrcweir 
545cdf0e10cSrcweir 	for (SCTAB i=MAXTAB; i>nDestTab; i--)
546cdf0e10cSrcweir 		pTabData[i] = pTabData[i-1];
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	if ( pTabData[nSrcTab] )
549cdf0e10cSrcweir 		pTabData[nDestTab] = new ScViewDataTable( *pTabData[nSrcTab] );
550cdf0e10cSrcweir 	else
551cdf0e10cSrcweir 		pTabData[nDestTab] = NULL;
552cdf0e10cSrcweir 
553cdf0e10cSrcweir 	UpdateThis();
554cdf0e10cSrcweir 	aMarkData.InsertTab( nDestTab );
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
MoveTab(SCTAB nSrcTab,SCTAB nDestTab)557cdf0e10cSrcweir void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	if (nDestTab==SC_TAB_APPEND)
560cdf0e10cSrcweir 		nDestTab = pDoc->GetTableCount() - 1;
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 	SCTAB i;
563cdf0e10cSrcweir 	ScViewDataTable* pTab = pTabData[nSrcTab];
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 	SCTAB nInsTab = nDestTab;
566cdf0e10cSrcweir 	if ( nSrcTab < nDestTab )
567cdf0e10cSrcweir 	{
568cdf0e10cSrcweir 		--nInsTab;
569cdf0e10cSrcweir 		for (i=nSrcTab; i<nDestTab; i++)
570cdf0e10cSrcweir 			pTabData[i] = pTabData[i+1];
571cdf0e10cSrcweir 	}
572cdf0e10cSrcweir 	else
573cdf0e10cSrcweir 		for (i=nSrcTab; i>nDestTab; i--)
574cdf0e10cSrcweir 			pTabData[i] = pTabData[i-1];
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	pTabData[nDestTab] = pTab;
577cdf0e10cSrcweir 
578cdf0e10cSrcweir 	UpdateThis();
579cdf0e10cSrcweir 	aMarkData.DeleteTab( nSrcTab );
580cdf0e10cSrcweir 	aMarkData.InsertTab( nInsTab );			// ggf. angepasst
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir //UNUSED2008-05  void ScViewData::UpdateOle( ScSplitPos /* eWhich */ )
584cdf0e10cSrcweir //UNUSED2008-05  {
585cdf0e10cSrcweir //UNUSED2008-05      GetDocShell()->UpdateOle(this);
586cdf0e10cSrcweir //UNUSED2008-05  }
587cdf0e10cSrcweir 
SetViewShell(ScTabViewShell * pViewSh)588cdf0e10cSrcweir void ScViewData::SetViewShell( ScTabViewShell* pViewSh )
589cdf0e10cSrcweir {
590cdf0e10cSrcweir 	if (pViewSh)
591cdf0e10cSrcweir 	{
592cdf0e10cSrcweir 		pViewShell	= pViewSh;
593cdf0e10cSrcweir 		pView		= pViewSh;
594cdf0e10cSrcweir 	}
595cdf0e10cSrcweir 	else
596cdf0e10cSrcweir 	{
597cdf0e10cSrcweir 		pViewShell	= NULL;
598cdf0e10cSrcweir 		pView		= NULL;
599cdf0e10cSrcweir 	}
600cdf0e10cSrcweir }
CreateTabData(std::vector<SCTAB> & rvTabs)601cdf0e10cSrcweir void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs )
602cdf0e10cSrcweir {
603cdf0e10cSrcweir     std::vector< SCTAB >::iterator it_end = rvTabs.end();
604cdf0e10cSrcweir     for ( std::vector< SCTAB >::iterator it = rvTabs.begin(); it != it_end; ++it )
605cdf0e10cSrcweir         if ( !pTabData[*it] )
606cdf0e10cSrcweir             CreateTabData( *it );
607cdf0e10cSrcweir }
608cdf0e10cSrcweir 
SetZoomType(SvxZoomType eNew,std::vector<SCTAB> & tabs)609cdf0e10cSrcweir void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir     sal_Bool bAll = ( tabs.size() == 0 );
612cdf0e10cSrcweir 
613cdf0e10cSrcweir     if ( !bAll ) // create associated table data
614cdf0e10cSrcweir         CreateTabData( tabs );
615cdf0e10cSrcweir 
616cdf0e10cSrcweir     if ( bAll )
617cdf0e10cSrcweir     {
618cdf0e10cSrcweir         for ( SCTAB i = 0; i <= MAXTAB; ++i )
619cdf0e10cSrcweir         {
620cdf0e10cSrcweir             if ( pTabData[i] )
621cdf0e10cSrcweir                 pTabData[i]->eZoomType = eNew;
622cdf0e10cSrcweir         }
623cdf0e10cSrcweir         eDefZoomType = eNew;
624cdf0e10cSrcweir     }
625cdf0e10cSrcweir     else
626cdf0e10cSrcweir     {
627cdf0e10cSrcweir         std::vector< SCTAB >::iterator it_end = tabs.end();
628cdf0e10cSrcweir         std::vector< SCTAB >::iterator it = tabs.begin();
629cdf0e10cSrcweir         for ( ; it != it_end; ++it )
630cdf0e10cSrcweir         {
631cdf0e10cSrcweir             SCTAB i = *it;
632cdf0e10cSrcweir             if ( pTabData[i] )
633cdf0e10cSrcweir                 pTabData[i]->eZoomType = eNew;
634cdf0e10cSrcweir         }
635cdf0e10cSrcweir     }
636cdf0e10cSrcweir }
637cdf0e10cSrcweir 
SetZoomType(SvxZoomType eNew,sal_Bool bAll)638cdf0e10cSrcweir void ScViewData::SetZoomType( SvxZoomType eNew, sal_Bool bAll )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir     std::vector< SCTAB > vTabs; // Empty for all tabs
641cdf0e10cSrcweir     if ( !bAll ) // get selected tabs
642cdf0e10cSrcweir     {
643cdf0e10cSrcweir         SCTAB nTabCount = pDoc->GetTableCount();
644cdf0e10cSrcweir         for (SCTAB i=0; i<nTabCount; i++)
645cdf0e10cSrcweir         {
646cdf0e10cSrcweir             if ( aMarkData.GetTableSelect(i)  )
647cdf0e10cSrcweir                 vTabs.push_back( i );
648cdf0e10cSrcweir         }
649cdf0e10cSrcweir     }
650cdf0e10cSrcweir     SetZoomType( eNew, vTabs );
651cdf0e10cSrcweir }
652cdf0e10cSrcweir 
SetZoom(const Fraction & rNewX,const Fraction & rNewY,std::vector<SCTAB> & tabs)653cdf0e10cSrcweir void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir     sal_Bool bAll = ( tabs.size() == 0 );
656cdf0e10cSrcweir     if ( !bAll ) // create associated table data
657cdf0e10cSrcweir         CreateTabData( tabs );
658cdf0e10cSrcweir     Fraction aFrac20( 1,5 );
659cdf0e10cSrcweir     Fraction aFrac400( 4,1 );
660cdf0e10cSrcweir 
661cdf0e10cSrcweir     Fraction aValidX = rNewX;
662cdf0e10cSrcweir     if (aValidX<aFrac20)
663cdf0e10cSrcweir         aValidX = aFrac20;
664cdf0e10cSrcweir     if (aValidX>aFrac400)
665cdf0e10cSrcweir         aValidX = aFrac400;
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     Fraction aValidY = rNewY;
668cdf0e10cSrcweir     if (aValidY<aFrac20)
669cdf0e10cSrcweir         aValidY = aFrac20;
670cdf0e10cSrcweir     if (aValidY>aFrac400)
671cdf0e10cSrcweir         aValidY = aFrac400;
672cdf0e10cSrcweir 
673cdf0e10cSrcweir     if ( bAll )
674cdf0e10cSrcweir     {
675cdf0e10cSrcweir         for ( SCTAB i = 0; i <= MAXTAB; ++i )
676cdf0e10cSrcweir         {
677cdf0e10cSrcweir             if ( pTabData[i] )
678cdf0e10cSrcweir             {
679cdf0e10cSrcweir                 if ( bPagebreak )
680cdf0e10cSrcweir                 {
681cdf0e10cSrcweir                     pTabData[i]->aPageZoomX = aValidX;
682cdf0e10cSrcweir                     pTabData[i]->aPageZoomY = aValidY;
683cdf0e10cSrcweir                 }
684cdf0e10cSrcweir                 else
685cdf0e10cSrcweir                 {
686cdf0e10cSrcweir                     pTabData[i]->aZoomX = aValidX;
687cdf0e10cSrcweir                     pTabData[i]->aZoomY = aValidY;
688cdf0e10cSrcweir                 }
689cdf0e10cSrcweir             }
690cdf0e10cSrcweir         }
691cdf0e10cSrcweir         if ( bPagebreak )
692cdf0e10cSrcweir         {
693cdf0e10cSrcweir             aDefPageZoomX = aValidX;
694cdf0e10cSrcweir             aDefPageZoomY = aValidY;
695cdf0e10cSrcweir         }
696cdf0e10cSrcweir         else
697cdf0e10cSrcweir         {
698cdf0e10cSrcweir             aDefZoomX = aValidX;
699cdf0e10cSrcweir             aDefZoomY = aValidY;
700cdf0e10cSrcweir         }
701cdf0e10cSrcweir     }
702cdf0e10cSrcweir     else
703cdf0e10cSrcweir     {
704cdf0e10cSrcweir         std::vector< SCTAB >::iterator it_end = tabs.end();
705cdf0e10cSrcweir         std::vector< SCTAB >::iterator it = tabs.begin();
706cdf0e10cSrcweir         for ( ; it != it_end; ++it )
707cdf0e10cSrcweir         {
708cdf0e10cSrcweir             SCTAB i = *it;
709cdf0e10cSrcweir             if ( pTabData[i] )
710cdf0e10cSrcweir             {
711cdf0e10cSrcweir                 if ( bPagebreak )
712cdf0e10cSrcweir                 {
713cdf0e10cSrcweir                     pTabData[i]->aPageZoomX = aValidX;
714cdf0e10cSrcweir                     pTabData[i]->aPageZoomY = aValidY;
715cdf0e10cSrcweir                 }
716cdf0e10cSrcweir                 else
717cdf0e10cSrcweir                 {
718cdf0e10cSrcweir                     pTabData[i]->aZoomX = aValidX;
719cdf0e10cSrcweir                     pTabData[i]->aZoomY = aValidY;
720cdf0e10cSrcweir                 }
721cdf0e10cSrcweir             }
722cdf0e10cSrcweir         }
723cdf0e10cSrcweir     }
724cdf0e10cSrcweir     RefreshZoom();
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
SetZoom(const Fraction & rNewX,const Fraction & rNewY,sal_Bool bAll)727cdf0e10cSrcweir void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, sal_Bool bAll )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     std::vector< SCTAB > vTabs;
730cdf0e10cSrcweir     if ( !bAll ) // get selected tabs
731cdf0e10cSrcweir     {
732cdf0e10cSrcweir         SCTAB nTabCount = pDoc->GetTableCount();
733cdf0e10cSrcweir         for (SCTAB i=0; i<nTabCount; i++)
734cdf0e10cSrcweir         {
735cdf0e10cSrcweir             if ( aMarkData.GetTableSelect(i)  )
736cdf0e10cSrcweir                 vTabs.push_back( i );
737cdf0e10cSrcweir         }
738cdf0e10cSrcweir     }
739cdf0e10cSrcweir     SetZoom( rNewX, rNewY, vTabs );
740cdf0e10cSrcweir }
741cdf0e10cSrcweir 
RefreshZoom()742cdf0e10cSrcweir void ScViewData::RefreshZoom()
743cdf0e10cSrcweir {
744cdf0e10cSrcweir     // recalculate zoom-dependent values (only for current sheet)
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 	CalcPPT();
747cdf0e10cSrcweir 	RecalcPixPos();
748cdf0e10cSrcweir 	aScenButSize = Size(0,0);
749cdf0e10cSrcweir 	aLogicMode.SetScaleX( GetZoomX() );
750cdf0e10cSrcweir 	aLogicMode.SetScaleY( GetZoomY() );
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
SetPagebreakMode(sal_Bool bSet)753cdf0e10cSrcweir void ScViewData::SetPagebreakMode( sal_Bool bSet )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir 	bPagebreak = bSet;
756cdf0e10cSrcweir 
757cdf0e10cSrcweir     RefreshZoom();
758cdf0e10cSrcweir }
759cdf0e10cSrcweir 
760cdf0e10cSrcweir 
GetSimpleArea(ScRange & rRange,ScMarkData & rNewMark) const761cdf0e10cSrcweir ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const
762cdf0e10cSrcweir {
763cdf0e10cSrcweir     ScMarkType eMarkType = SC_MARK_NONE;
764cdf0e10cSrcweir 
765cdf0e10cSrcweir     if ( rNewMark.IsMarked() || rNewMark.IsMultiMarked() )
766cdf0e10cSrcweir     {
767cdf0e10cSrcweir         if ( rNewMark.IsMultiMarked() )
768cdf0e10cSrcweir             rNewMark.MarkToSimple();
769cdf0e10cSrcweir 
770cdf0e10cSrcweir         if ( rNewMark.IsMarked() && !rNewMark.IsMultiMarked() )
771cdf0e10cSrcweir         {
772cdf0e10cSrcweir             rNewMark.GetMarkArea( rRange );
773cdf0e10cSrcweir             if (ScViewUtil::HasFiltered( rRange, GetDocument()))
774cdf0e10cSrcweir                 eMarkType = SC_MARK_SIMPLE_FILTERED;
775cdf0e10cSrcweir             else
776cdf0e10cSrcweir                 eMarkType = SC_MARK_SIMPLE;
777cdf0e10cSrcweir         }
778cdf0e10cSrcweir         else
779cdf0e10cSrcweir             eMarkType = SC_MARK_MULTI;
780cdf0e10cSrcweir     }
781cdf0e10cSrcweir     if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
782cdf0e10cSrcweir     {
783cdf0e10cSrcweir         if (eMarkType == SC_MARK_NONE)
784cdf0e10cSrcweir             eMarkType = SC_MARK_SIMPLE;
785cdf0e10cSrcweir         rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() );
786cdf0e10cSrcweir     }
787cdf0e10cSrcweir     return eMarkType;
788cdf0e10cSrcweir }
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 
GetSimpleArea(SCCOL & rStartCol,SCROW & rStartRow,SCTAB & rStartTab,SCCOL & rEndCol,SCROW & rEndRow,SCTAB & rEndTab) const791cdf0e10cSrcweir ScMarkType ScViewData::GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
792cdf0e10cSrcweir 								SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const
793cdf0e10cSrcweir {
794cdf0e10cSrcweir 	//	parameter bMergeMark is no longer needed: The view's selection is never modified
795cdf0e10cSrcweir 	//	(a local copy is used), and a multi selection that adds to a single range can always
796cdf0e10cSrcweir 	//	be treated like a single selection (#108266# - GetSimpleArea isn't used in selection
797cdf0e10cSrcweir 	//	handling itself)
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     ScRange aRange;
800cdf0e10cSrcweir     ScMarkData aNewMark( aMarkData );       // use a local copy for MarkToSimple
801cdf0e10cSrcweir     ScMarkType eMarkType = GetSimpleArea( aRange, aNewMark);
802cdf0e10cSrcweir     aRange.GetVars( rStartCol, rStartRow, rStartTab, rEndCol, rEndRow, rEndTab);
803cdf0e10cSrcweir     return eMarkType;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
GetSimpleArea(ScRange & rRange) const806cdf0e10cSrcweir ScMarkType ScViewData::GetSimpleArea( ScRange& rRange ) const
807cdf0e10cSrcweir {
808cdf0e10cSrcweir 	//	parameter bMergeMark is no longer needed, see above
809cdf0e10cSrcweir 
810cdf0e10cSrcweir     ScMarkData aNewMark( aMarkData );       // use a local copy for MarkToSimple
811cdf0e10cSrcweir     return GetSimpleArea( rRange, aNewMark);
812cdf0e10cSrcweir }
813cdf0e10cSrcweir 
GetMultiArea(ScRangeListRef & rRange) const814cdf0e10cSrcweir void ScViewData::GetMultiArea( ScRangeListRef& rRange ) const
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	//	parameter bMergeMark is no longer needed, see GetSimpleArea
817cdf0e10cSrcweir 
818cdf0e10cSrcweir 	ScMarkData aNewMark( aMarkData );		// use a local copy for MarkToSimple
819cdf0e10cSrcweir 
820cdf0e10cSrcweir 	sal_Bool bMulti = aNewMark.IsMultiMarked();
821cdf0e10cSrcweir 	if (bMulti)
822cdf0e10cSrcweir 	{
823cdf0e10cSrcweir 		aNewMark.MarkToSimple();
824cdf0e10cSrcweir 		bMulti = aNewMark.IsMultiMarked();
825cdf0e10cSrcweir 	}
826cdf0e10cSrcweir 	if (bMulti)
827cdf0e10cSrcweir 	{
828cdf0e10cSrcweir 		rRange = new ScRangeList;
829cdf0e10cSrcweir 		aNewMark.FillRangeListWithMarks( rRange, sal_False );
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 	else
832cdf0e10cSrcweir 	{
833cdf0e10cSrcweir 		ScRange aSimple;
834cdf0e10cSrcweir 		GetSimpleArea(aSimple);
835cdf0e10cSrcweir 		rRange = new ScRangeList;
836cdf0e10cSrcweir 		rRange->Append(aSimple);
837cdf0e10cSrcweir 	}
838cdf0e10cSrcweir }
839cdf0e10cSrcweir 
SimpleColMarked()840cdf0e10cSrcweir sal_Bool ScViewData::SimpleColMarked()
841cdf0e10cSrcweir {
842cdf0e10cSrcweir 	SCCOL nStartCol;
843cdf0e10cSrcweir 	SCROW nStartRow;
844cdf0e10cSrcweir 	SCTAB nStartTab;
845cdf0e10cSrcweir 	SCCOL nEndCol;
846cdf0e10cSrcweir 	SCROW nEndRow;
847cdf0e10cSrcweir 	SCTAB nEndTab;
848cdf0e10cSrcweir 	if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
849cdf0e10cSrcweir 		if (nStartRow==0 && nEndRow==MAXROW)
850cdf0e10cSrcweir 			return sal_True;
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 	return sal_False;
853cdf0e10cSrcweir }
854cdf0e10cSrcweir 
SimpleRowMarked()855cdf0e10cSrcweir sal_Bool ScViewData::SimpleRowMarked()
856cdf0e10cSrcweir {
857cdf0e10cSrcweir 	SCCOL nStartCol;
858cdf0e10cSrcweir 	SCROW nStartRow;
859cdf0e10cSrcweir 	SCTAB nStartTab;
860cdf0e10cSrcweir 	SCCOL nEndCol;
861cdf0e10cSrcweir 	SCROW nEndRow;
862cdf0e10cSrcweir 	SCTAB nEndTab;
863cdf0e10cSrcweir 	if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
864cdf0e10cSrcweir 		if (nStartCol==0 && nEndCol==MAXCOL)
865cdf0e10cSrcweir 			return sal_True;
866cdf0e10cSrcweir 
867cdf0e10cSrcweir 	return sal_False;
868cdf0e10cSrcweir }
869cdf0e10cSrcweir 
IsMultiMarked()870cdf0e10cSrcweir sal_Bool ScViewData::IsMultiMarked()
871cdf0e10cSrcweir {
872cdf0e10cSrcweir     // Test for "real" multi selection, calling MarkToSimple on a local copy,
873cdf0e10cSrcweir     // and taking filtered in simple area marks into account.
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     ScRange aDummy;
876cdf0e10cSrcweir     ScMarkType eType = GetSimpleArea(aDummy);
877cdf0e10cSrcweir     return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
878cdf0e10cSrcweir }
879cdf0e10cSrcweir 
SetFillMode(SCCOL nStartCol,SCROW nStartRow,SCCOL nEndCol,SCROW nEndRow)880cdf0e10cSrcweir void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
881cdf0e10cSrcweir {
882cdf0e10cSrcweir 	nFillMode   = SC_FILL_FILL;
883cdf0e10cSrcweir 	nFillStartX = nStartCol;
884cdf0e10cSrcweir 	nFillStartY = nStartRow;
885cdf0e10cSrcweir 	nFillEndX 	= nEndCol;
886cdf0e10cSrcweir 	nFillEndY 	= nEndRow;
887cdf0e10cSrcweir }
888cdf0e10cSrcweir 
SetDragMode(SCCOL nStartCol,SCROW nStartRow,SCCOL nEndCol,SCROW nEndRow,sal_uInt8 nMode)889cdf0e10cSrcweir void ScViewData::SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
890cdf0e10cSrcweir 								sal_uInt8 nMode )
891cdf0e10cSrcweir {
892cdf0e10cSrcweir 	nFillMode   = nMode;
893cdf0e10cSrcweir 	nFillStartX = nStartCol;
894cdf0e10cSrcweir 	nFillStartY = nStartRow;
895cdf0e10cSrcweir 	nFillEndX 	= nEndCol;
896cdf0e10cSrcweir 	nFillEndY 	= nEndRow;
897cdf0e10cSrcweir }
898cdf0e10cSrcweir 
ResetFillMode()899cdf0e10cSrcweir void ScViewData::ResetFillMode()
900cdf0e10cSrcweir {
901cdf0e10cSrcweir 	nFillMode	= SC_FILL_NONE;
902cdf0e10cSrcweir }
903cdf0e10cSrcweir 
GetFillData(SCCOL & rStartCol,SCROW & rStartRow,SCCOL & rEndCol,SCROW & rEndRow)904cdf0e10cSrcweir void ScViewData::GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
905cdf0e10cSrcweir 								SCCOL& rEndCol, SCROW& rEndRow )
906cdf0e10cSrcweir {
907cdf0e10cSrcweir 	rStartCol = nFillStartX;
908cdf0e10cSrcweir 	rStartRow = nFillStartY;
909cdf0e10cSrcweir 	rEndCol   = nFillEndX;
910cdf0e10cSrcweir 	rEndRow   = nFillEndY;
911cdf0e10cSrcweir }
912cdf0e10cSrcweir 
GetOldCurX() const913cdf0e10cSrcweir SCCOL ScViewData::GetOldCurX() const
914cdf0e10cSrcweir {
915cdf0e10cSrcweir 	if (pThisTab->bOldCurValid)
916cdf0e10cSrcweir 		return pThisTab->nOldCurX;
917cdf0e10cSrcweir 	else
918cdf0e10cSrcweir 		return pThisTab->nCurX;
919cdf0e10cSrcweir }
920cdf0e10cSrcweir 
GetOldCurY() const921cdf0e10cSrcweir SCROW ScViewData::GetOldCurY() const
922cdf0e10cSrcweir {
923cdf0e10cSrcweir 	if (pThisTab->bOldCurValid)
924cdf0e10cSrcweir 		return pThisTab->nOldCurY;
925cdf0e10cSrcweir 	else
926cdf0e10cSrcweir 		return pThisTab->nCurY;
927cdf0e10cSrcweir }
928cdf0e10cSrcweir 
SetOldCursor(SCCOL nNewX,SCROW nNewY)929cdf0e10cSrcweir void ScViewData::SetOldCursor( SCCOL nNewX, SCROW nNewY )
930cdf0e10cSrcweir {
931cdf0e10cSrcweir 	pThisTab->nOldCurX = nNewX;
932cdf0e10cSrcweir 	pThisTab->nOldCurY = nNewY;
933cdf0e10cSrcweir 	pThisTab->bOldCurValid = sal_True;
934cdf0e10cSrcweir }
935cdf0e10cSrcweir 
ResetOldCursor()936cdf0e10cSrcweir void ScViewData::ResetOldCursor()
937cdf0e10cSrcweir {
938cdf0e10cSrcweir 	pThisTab->bOldCurValid = sal_False;
939cdf0e10cSrcweir }
940cdf0e10cSrcweir 
GetEditArea(ScSplitPos eWhich,SCCOL nPosX,SCROW nPosY,Window * pWin,const ScPatternAttr * pPattern,sal_Bool bForceToTop)941cdf0e10cSrcweir Rectangle ScViewData::GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY,
942cdf0e10cSrcweir 									Window* pWin, const ScPatternAttr* pPattern,
943cdf0e10cSrcweir 									sal_Bool bForceToTop )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir 	return ScEditUtil( pDoc, nPosX, nPosY, nTabNo, GetScrPos(nPosX,nPosY,eWhich,sal_True),
946cdf0e10cSrcweir 						pWin, nPPTX, nPPTY, GetZoomX(), GetZoomY() ).
947cdf0e10cSrcweir 							GetEditArea( pPattern, bForceToTop );
948cdf0e10cSrcweir }
949cdf0e10cSrcweir 
SetEditEngine(ScSplitPos eWhich,ScEditEngineDefaulter * pNewEngine,Window * pWin,SCCOL nNewX,SCROW nNewY)950cdf0e10cSrcweir void ScViewData::SetEditEngine( ScSplitPos eWhich,
951cdf0e10cSrcweir 								ScEditEngineDefaulter* pNewEngine,
952cdf0e10cSrcweir 								Window* pWin, SCCOL nNewX, SCROW nNewY )
953cdf0e10cSrcweir {
954cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
955cdf0e10cSrcweir 	ScHSplitPos eHWhich = WhichH(eWhich);
956cdf0e10cSrcweir 
957cdf0e10cSrcweir 	sal_Bool bWasThere = sal_False;
958cdf0e10cSrcweir 	if (pEditView[eWhich])
959cdf0e10cSrcweir 	{
960cdf0e10cSrcweir 		//	Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert
961cdf0e10cSrcweir 
962cdf0e10cSrcweir 		if (bEditActive[eWhich])
963cdf0e10cSrcweir 			bWasThere = sal_True;
964cdf0e10cSrcweir 		else
965cdf0e10cSrcweir 			pEditView[eWhich]->SetEditEngine(pNewEngine);
966cdf0e10cSrcweir 
967cdf0e10cSrcweir 		if (pEditView[eWhich]->GetWindow() != pWin)
968cdf0e10cSrcweir 		{
969cdf0e10cSrcweir 			pEditView[eWhich]->SetWindow(pWin);
970cdf0e10cSrcweir 			DBG_ERROR("EditView Window geaendert");
971cdf0e10cSrcweir 		}
972cdf0e10cSrcweir 	}
973cdf0e10cSrcweir 	else
974cdf0e10cSrcweir 	{
975cdf0e10cSrcweir 		pEditView[eWhich] = new EditView( pNewEngine, pWin );
976cdf0e10cSrcweir 	}
977cdf0e10cSrcweir 
978cdf0e10cSrcweir 	//	bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
979cdf0e10cSrcweir 
980cdf0e10cSrcweir 	sal_uLong nEC = pNewEngine->GetControlWord();
981cdf0e10cSrcweir 	pNewEngine->SetControlWord(nEC & ~EE_CNTRL_DOIDLEFORMAT);
982cdf0e10cSrcweir 
983cdf0e10cSrcweir 	sal_uLong nVC = pEditView[eWhich]->GetControlWord();
984cdf0e10cSrcweir 	pEditView[eWhich]->SetControlWord(nVC & ~EV_CNTRL_AUTOSCROLL);
985cdf0e10cSrcweir 
986cdf0e10cSrcweir 	bEditActive[eWhich] = sal_True;
987cdf0e10cSrcweir 
988cdf0e10cSrcweir 	const ScPatternAttr* pPattern = pDoc->GetPattern( nNewX, nNewY, nTabNo );
989cdf0e10cSrcweir 	SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
990cdf0e10cSrcweir 									pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
991cdf0e10cSrcweir 
992cdf0e10cSrcweir 	sal_Bool bBreak = ( eJust == SVX_HOR_JUSTIFY_BLOCK ) ||
993cdf0e10cSrcweir 					((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue();
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 	sal_Bool bAsianVertical = pNewEngine->IsVertical();		// set by InputHandler
996cdf0e10cSrcweir 
997cdf0e10cSrcweir 	Rectangle aPixRect = ScEditUtil( pDoc, nNewX,nNewY,nTabNo, GetScrPos(nNewX,nNewY,eWhich),
998cdf0e10cSrcweir 										pWin, nPPTX,nPPTY,GetZoomX(),GetZoomY() ).
999cdf0e10cSrcweir 											GetEditArea( pPattern, sal_True );
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir 	//	when right-aligned, leave space for the cursor
1002cdf0e10cSrcweir 	//	in vertical mode, editing is always right-aligned
1003cdf0e10cSrcweir 	if ( nEditAdjust == SVX_ADJUST_RIGHT || bAsianVertical )
1004cdf0e10cSrcweir 		aPixRect.Right() += 1;
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 	Rectangle aOutputArea = pWin->PixelToLogic( aPixRect, GetLogicMode() );
1007cdf0e10cSrcweir 	pEditView[eWhich]->SetOutputArea( aOutputArea );
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir 	if ( bActive && eWhich == GetActivePart() )
1010cdf0e10cSrcweir 	{
1011cdf0e10cSrcweir 	    // keep the part that has the active edit view available after
1012cdf0e10cSrcweir 	    // switching sheets or reference input on a different part
1013cdf0e10cSrcweir         eEditActivePart = eWhich;
1014cdf0e10cSrcweir 
1015cdf0e10cSrcweir 		//	modify members nEditCol etc. only if also extending for needed area
1016cdf0e10cSrcweir 		nEditCol = nNewX;
1017cdf0e10cSrcweir 		nEditRow = nNewY;
1018cdf0e10cSrcweir 		const ScMergeAttr* pMergeAttr = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
1019cdf0e10cSrcweir 		nEditEndCol = nEditCol;
1020cdf0e10cSrcweir 		if (pMergeAttr->GetColMerge() > 1)
1021cdf0e10cSrcweir 			nEditEndCol += pMergeAttr->GetColMerge() - 1;
1022cdf0e10cSrcweir 		nEditEndRow = nEditRow;
1023cdf0e10cSrcweir 		if (pMergeAttr->GetRowMerge() > 1)
1024cdf0e10cSrcweir 			nEditEndRow += pMergeAttr->GetRowMerge() - 1;
1025cdf0e10cSrcweir 		nEditStartCol = nEditCol;
1026cdf0e10cSrcweir 
1027cdf0e10cSrcweir 		//	For growing use only the alignment value from the attribute, numbers
1028cdf0e10cSrcweir 		//	(existing or started) with default aligment extend to the right.
1029cdf0e10cSrcweir 		sal_Bool bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
1030cdf0e10cSrcweir 		sal_Bool bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT );		// visual left
1031cdf0e10cSrcweir 		sal_Bool bGrowBackwards = bGrowToLeft;							// logical left
1032cdf0e10cSrcweir 		if ( bLayoutRTL )
1033cdf0e10cSrcweir 			bGrowBackwards = !bGrowBackwards;						// invert on RTL sheet
1034cdf0e10cSrcweir 		if ( bAsianVertical )
1035cdf0e10cSrcweir 			bGrowCentered = bGrowToLeft = bGrowBackwards = sal_False;	// keep old behavior for asian mode
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 		long nSizeXPix;
1038cdf0e10cSrcweir 		if (bBreak && !bAsianVertical)
1039cdf0e10cSrcweir 			nSizeXPix = aPixRect.GetWidth();	// Papersize -> kein H-Scrolling
1040cdf0e10cSrcweir 		else
1041cdf0e10cSrcweir 		{
1042cdf0e10cSrcweir 			DBG_ASSERT(pView,"keine View fuer EditView");
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir 			if ( bGrowCentered )
1045cdf0e10cSrcweir 			{
1046cdf0e10cSrcweir 				//	growing into both directions until one edge is reached
1047cdf0e10cSrcweir 				//!	should be limited to whole cells in both directions
1048cdf0e10cSrcweir 				long nLeft = aPixRect.Left();
1049cdf0e10cSrcweir 				long nRight = pView->GetGridWidth(eHWhich) - aPixRect.Right();
1050cdf0e10cSrcweir 				nSizeXPix = aPixRect.GetWidth() + 2 * Min( nLeft, nRight );
1051cdf0e10cSrcweir 			}
1052cdf0e10cSrcweir 			else if ( bGrowToLeft )
1053cdf0e10cSrcweir 				nSizeXPix = aPixRect.Right();	// space that's available in the window when growing to the left
1054cdf0e10cSrcweir 			else
1055cdf0e10cSrcweir 				nSizeXPix = pView->GetGridWidth(eHWhich) - aPixRect.Left();
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir 			if ( nSizeXPix <= 0 )
1058cdf0e10cSrcweir 				nSizeXPix = aPixRect.GetWidth();	// editing outside to the right of the window -> keep cell width
1059cdf0e10cSrcweir 		}
1060cdf0e10cSrcweir 		DBG_ASSERT(pView,"keine View fuer EditView");
1061cdf0e10cSrcweir 		long nSizeYPix = pView->GetGridHeight(WhichV(eWhich)) - aPixRect.Top();
1062cdf0e10cSrcweir 		if ( nSizeYPix <= 0 )
1063cdf0e10cSrcweir 			nSizeYPix = aPixRect.GetHeight();	// editing outside below the window -> keep cell height
1064cdf0e10cSrcweir 
1065cdf0e10cSrcweir 		Size aPaperSize = pView->GetActiveWin()->PixelToLogic( Size( nSizeXPix, nSizeYPix ), GetLogicMode() );
1066cdf0e10cSrcweir 		if ( bBreak && !bAsianVertical && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
1067cdf0e10cSrcweir 		{
1068cdf0e10cSrcweir 			//	#95593# if text is formatted for printer, use the exact same paper width
1069cdf0e10cSrcweir 			//	(and same line breaks) as for output.
1070cdf0e10cSrcweir 
1071cdf0e10cSrcweir 			Fraction aFract(1,1);
1072cdf0e10cSrcweir 			Rectangle aUtilRect = ScEditUtil( pDoc,nNewX,nNewY,nTabNo, Point(0,0), pWin,
1073cdf0e10cSrcweir 									HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, sal_False );
1074cdf0e10cSrcweir 			aPaperSize.Width() = aUtilRect.GetWidth();
1075cdf0e10cSrcweir 		}
1076cdf0e10cSrcweir 		pNewEngine->SetPaperSize( aPaperSize );
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir 		// sichtbarer Ausschnitt
1079cdf0e10cSrcweir 		Size aPaper = pNewEngine->GetPaperSize();
1080cdf0e10cSrcweir 		Rectangle aVis = pEditView[eWhich]->GetVisArea();
1081cdf0e10cSrcweir 		long nDiff = aVis.Right() - aVis.Left();
1082cdf0e10cSrcweir 		if ( nEditAdjust == SVX_ADJUST_RIGHT )
1083cdf0e10cSrcweir 		{
1084cdf0e10cSrcweir 			aVis.Right() = aPaper.Width() - 1;
1085cdf0e10cSrcweir 			bMoveArea = !bLayoutRTL;
1086cdf0e10cSrcweir 		}
1087cdf0e10cSrcweir 		else if ( nEditAdjust == SVX_ADJUST_CENTER )
1088cdf0e10cSrcweir 		{
1089cdf0e10cSrcweir 			aVis.Right() = ( aPaper.Width() - 1 + nDiff ) / 2;
1090cdf0e10cSrcweir 			bMoveArea = sal_True;	// always
1091cdf0e10cSrcweir 		}
1092cdf0e10cSrcweir 		else
1093cdf0e10cSrcweir 		{
1094cdf0e10cSrcweir 			aVis.Right() = nDiff;
1095cdf0e10cSrcweir 			bMoveArea = bLayoutRTL;
1096cdf0e10cSrcweir 		}
1097cdf0e10cSrcweir 		aVis.Left() = aVis.Right() - nDiff;
1098cdf0e10cSrcweir         // --> OD 2005-12-22 #i49561#
1099cdf0e10cSrcweir         // Important note:
1100cdf0e10cSrcweir         // The set offset of the visible area of the EditView for centered and
1101cdf0e10cSrcweir         // right alignment in horizontal layout is consider by instances of
1102cdf0e10cSrcweir         // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
1103cdf0e10cSrcweir         // and <PixelToLogic(..)>. This is needed for the correct visibility
1104cdf0e10cSrcweir         // of paragraphs in edit mode at the accessibility API.
1105cdf0e10cSrcweir         // <--
1106cdf0e10cSrcweir 		pEditView[eWhich]->SetVisArea(aVis);
1107cdf0e10cSrcweir 		//
1108cdf0e10cSrcweir 
1109cdf0e10cSrcweir 		//	UpdateMode has been disabled in ScInputHandler::StartTable
1110cdf0e10cSrcweir 		//	must be enabled before EditGrowY (GetTextHeight)
1111cdf0e10cSrcweir 		pNewEngine->SetUpdateMode( sal_True );
1112cdf0e10cSrcweir 
1113cdf0e10cSrcweir 		pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) );
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir 		EditGrowY( sal_True );		// adjust to existing text content
1116cdf0e10cSrcweir 		EditGrowX();
1117cdf0e10cSrcweir 
1118cdf0e10cSrcweir 		Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0);
1119cdf0e10cSrcweir 		if (aDocPos.Y() < aOutputArea.Top())
1120cdf0e10cSrcweir 			pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() );
1121cdf0e10cSrcweir 
1122cdf0e10cSrcweir 		//!		Status (Event) zuruecksetzen
1123cdf0e10cSrcweir 	}
1124cdf0e10cSrcweir 
1125cdf0e10cSrcweir 													// hier muss bEditActive schon gesetzt sein
1126cdf0e10cSrcweir 													// (wegen Map-Mode bei Paint)
1127cdf0e10cSrcweir 	if (!bWasThere)
1128cdf0e10cSrcweir 		pNewEngine->InsertView(pEditView[eWhich]);
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 	//		Hintergrundfarbe der Zelle
1131cdf0e10cSrcweir 	Color aBackCol = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 	ScModule* pScMod = SC_MOD();
1134cdf0e10cSrcweir 	//	#105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed sal_True)
1135cdf0e10cSrcweir 	if ( aBackCol.GetTransparency() > 0 ||
1136cdf0e10cSrcweir 			Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
1137cdf0e10cSrcweir 	{
1138cdf0e10cSrcweir         aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
1139cdf0e10cSrcweir 	}
1140cdf0e10cSrcweir 	pEditView[eWhich]->SetBackgroundColor( aBackCol );
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir 	pEditView[eWhich]->Invalidate();			//	noetig ??
1143cdf0e10cSrcweir 	//	noetig, wenn Position geaendert
1144cdf0e10cSrcweir }
1145cdf0e10cSrcweir 
IMPL_LINK_INLINE_START(ScViewData,EmptyEditHdl,EditStatus *,EMPTYARG)1146cdf0e10cSrcweir IMPL_LINK_INLINE_START( ScViewData, EmptyEditHdl, EditStatus *, EMPTYARG )
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir 	return 0;
1149cdf0e10cSrcweir }
IMPL_LINK_INLINE_END(ScViewData,EmptyEditHdl,EditStatus *,EMPTYARG)1150cdf0e10cSrcweir IMPL_LINK_INLINE_END( ScViewData, EmptyEditHdl, EditStatus *, EMPTYARG )
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir IMPL_LINK( ScViewData, EditEngineHdl, EditStatus *, pStatus )
1153cdf0e10cSrcweir {
1154cdf0e10cSrcweir 	sal_uLong nStatus = pStatus->GetStatusWord();
1155cdf0e10cSrcweir 	if (nStatus & (EE_STAT_HSCROLL | EE_STAT_TEXTHEIGHTCHANGED | EE_STAT_TEXTWIDTHCHANGED | EE_STAT_CURSOROUT))
1156cdf0e10cSrcweir 	{
1157cdf0e10cSrcweir 		EditGrowY();
1158cdf0e10cSrcweir 		EditGrowX();
1159cdf0e10cSrcweir 
1160cdf0e10cSrcweir 		if (nStatus & EE_STAT_CURSOROUT)
1161cdf0e10cSrcweir 		{
1162cdf0e10cSrcweir 			ScSplitPos eWhich = GetActivePart();
1163cdf0e10cSrcweir 			if (pEditView[eWhich])
1164cdf0e10cSrcweir 				pEditView[eWhich]->ShowCursor(sal_False);
1165cdf0e10cSrcweir 		}
1166cdf0e10cSrcweir 	}
1167cdf0e10cSrcweir 	return 0;
1168cdf0e10cSrcweir }
1169cdf0e10cSrcweir 
EditGrowX()1170cdf0e10cSrcweir void ScViewData::EditGrowX()
1171cdf0e10cSrcweir {
1172cdf0e10cSrcweir 	ScDocument* pLocalDoc = GetDocument();
1173cdf0e10cSrcweir 
1174cdf0e10cSrcweir 	ScSplitPos eWhich = GetActivePart();
1175cdf0e10cSrcweir 	ScHSplitPos eHWhich = WhichH(eWhich);
1176cdf0e10cSrcweir 	EditView* pCurView = pEditView[eWhich];
1177cdf0e10cSrcweir 
1178cdf0e10cSrcweir 	if ( !pCurView || !bEditActive[eWhich])
1179cdf0e10cSrcweir 		return;
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pLocalDoc->IsLayoutRTL( nTabNo );
1182cdf0e10cSrcweir 
1183cdf0e10cSrcweir 	ScEditEngineDefaulter* pEngine =
1184cdf0e10cSrcweir 		(ScEditEngineDefaulter*) pCurView->GetEditEngine();
1185cdf0e10cSrcweir 	Window* pWin = pCurView->GetWindow();
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir 	SCCOL nLeft = GetPosX(eHWhich);
1188cdf0e10cSrcweir 	SCCOL nRight = nLeft + VisibleCellsX(eHWhich);
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir 	Size		aSize = pEngine->GetPaperSize();
1191cdf0e10cSrcweir 	Rectangle	aArea = pCurView->GetOutputArea();
1192cdf0e10cSrcweir 	long		nOldRight = aArea.Right();
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir 	//	Margin ist schon bei der urspruenglichen Breite beruecksichtigt
1195cdf0e10cSrcweir 	long nTextWidth = pEngine->CalcTextWidth();
1196cdf0e10cSrcweir 
1197cdf0e10cSrcweir 	sal_Bool bChanged = sal_False;
1198cdf0e10cSrcweir 	sal_Bool bAsianVertical = pEngine->IsVertical();
1199cdf0e10cSrcweir 
1200cdf0e10cSrcweir 	//	get bGrow... variables the same way as in SetEditEngine
1201cdf0e10cSrcweir 	const ScPatternAttr* pPattern = pLocalDoc->GetPattern( nEditCol, nEditRow, nTabNo );
1202cdf0e10cSrcweir 	SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
1203cdf0e10cSrcweir 									pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
1204cdf0e10cSrcweir 	sal_Bool bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
1205cdf0e10cSrcweir 	sal_Bool bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT );		// visual left
1206cdf0e10cSrcweir 	sal_Bool bGrowBackwards = bGrowToLeft;							// logical left
1207cdf0e10cSrcweir 	if ( bLayoutRTL )
1208cdf0e10cSrcweir 		bGrowBackwards = !bGrowBackwards;						// invert on RTL sheet
1209cdf0e10cSrcweir 	if ( bAsianVertical )
1210cdf0e10cSrcweir 		bGrowCentered = bGrowToLeft = bGrowBackwards = sal_False;	// keep old behavior for asian mode
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir 	sal_Bool bUnevenGrow = sal_False;
1213cdf0e10cSrcweir 	if ( bGrowCentered )
1214cdf0e10cSrcweir 	{
1215cdf0e10cSrcweir 		while (aArea.GetWidth() + 0 < nTextWidth && ( nEditStartCol > nLeft || nEditEndCol < nRight ) )
1216cdf0e10cSrcweir 		{
1217cdf0e10cSrcweir 			long nLogicLeft = 0;
1218cdf0e10cSrcweir 			if ( nEditStartCol > nLeft )
1219cdf0e10cSrcweir 			{
1220cdf0e10cSrcweir 				--nEditStartCol;
1221cdf0e10cSrcweir 				long nLeftPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
1222cdf0e10cSrcweir 				nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
1223cdf0e10cSrcweir 			}
1224cdf0e10cSrcweir 			long nLogicRight = 0;
1225cdf0e10cSrcweir 			if ( nEditEndCol < nRight )
1226cdf0e10cSrcweir 			{
1227cdf0e10cSrcweir 				++nEditEndCol;
1228cdf0e10cSrcweir 				long nRightPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
1229cdf0e10cSrcweir 				nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
1230cdf0e10cSrcweir 			}
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 			aArea.Left() -= bLayoutRTL ? nLogicRight : nLogicLeft;
1233cdf0e10cSrcweir 			aArea.Right() += bLayoutRTL ? nLogicLeft : nLogicRight;
1234cdf0e10cSrcweir 
1235cdf0e10cSrcweir 			if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1236cdf0e10cSrcweir 			{
1237cdf0e10cSrcweir 				long nCenter = ( aArea.Left() + aArea.Right() ) / 2;
1238cdf0e10cSrcweir 				long nHalf = aSize.Width() / 2;
1239cdf0e10cSrcweir 				aArea.Left() = nCenter - nHalf + 1;
1240cdf0e10cSrcweir 				aArea.Right() = nCenter + aSize.Width() - nHalf - 1;
1241cdf0e10cSrcweir 			}
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir 			bChanged = sal_True;
1244cdf0e10cSrcweir 			if ( nLogicLeft != nLogicRight )
1245cdf0e10cSrcweir 				bUnevenGrow = sal_True;
1246cdf0e10cSrcweir 		}
1247cdf0e10cSrcweir 	}
1248cdf0e10cSrcweir 	else if ( bGrowBackwards )
1249cdf0e10cSrcweir 	{
1250cdf0e10cSrcweir 		while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
1251cdf0e10cSrcweir 		{
1252cdf0e10cSrcweir 			--nEditStartCol;
1253cdf0e10cSrcweir 			long nPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
1254cdf0e10cSrcweir 			long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
1255cdf0e10cSrcweir 			if ( !bLayoutRTL )
1256cdf0e10cSrcweir 				aArea.Left() -= nLogicWidth;
1257cdf0e10cSrcweir 			else
1258cdf0e10cSrcweir 				aArea.Right() += nLogicWidth;
1259cdf0e10cSrcweir 
1260cdf0e10cSrcweir 			if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1261cdf0e10cSrcweir 			{
1262cdf0e10cSrcweir 				if ( !bLayoutRTL )
1263cdf0e10cSrcweir 					aArea.Left() = aArea.Right() - aSize.Width() + 1;
1264cdf0e10cSrcweir 				else
1265cdf0e10cSrcweir 					aArea.Right() = aArea.Left() + aSize.Width() - 1;
1266cdf0e10cSrcweir 			}
1267cdf0e10cSrcweir 
1268cdf0e10cSrcweir 			bChanged = sal_True;
1269cdf0e10cSrcweir 		}
1270cdf0e10cSrcweir 	}
1271cdf0e10cSrcweir 	else
1272cdf0e10cSrcweir 	{
1273cdf0e10cSrcweir 		while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
1274cdf0e10cSrcweir 		{
1275cdf0e10cSrcweir 			++nEditEndCol;
1276cdf0e10cSrcweir 			long nPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
1277cdf0e10cSrcweir 			long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
1278cdf0e10cSrcweir 			if ( bLayoutRTL )
1279cdf0e10cSrcweir 				aArea.Left() -= nLogicWidth;
1280cdf0e10cSrcweir 			else
1281cdf0e10cSrcweir 				aArea.Right() += nLogicWidth;
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 			if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
1284cdf0e10cSrcweir 			{
1285cdf0e10cSrcweir 				if ( bLayoutRTL )
1286cdf0e10cSrcweir 					aArea.Left() = aArea.Right() - aSize.Width() + 1;
1287cdf0e10cSrcweir 				else
1288cdf0e10cSrcweir 					aArea.Right() = aArea.Left() + aSize.Width() - 1;
1289cdf0e10cSrcweir 			}
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir 			bChanged = sal_True;
1292cdf0e10cSrcweir 		}
1293cdf0e10cSrcweir 	}
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir 	if (bChanged)
1296cdf0e10cSrcweir 	{
1297cdf0e10cSrcweir 		if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL )
1298cdf0e10cSrcweir 		{
1299cdf0e10cSrcweir 			Rectangle aVis = pCurView->GetVisArea();
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir 			if ( bGrowCentered )
1302cdf0e10cSrcweir 			{
1303cdf0e10cSrcweir 				//	switch to center-aligned (undo?) and reset VisArea to center
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir 				pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
1306cdf0e10cSrcweir 
1307cdf0e10cSrcweir 				long nCenter = aSize.Width() / 2;
1308cdf0e10cSrcweir 				long nVisSize = aArea.GetWidth();
1309cdf0e10cSrcweir 				aVis.Left() = nCenter - nVisSize / 2;
1310cdf0e10cSrcweir 				aVis.Right() = aVis.Left() + nVisSize - 1;
1311cdf0e10cSrcweir 			}
1312cdf0e10cSrcweir 			else if ( bGrowToLeft )
1313cdf0e10cSrcweir 			{
1314cdf0e10cSrcweir 				//	switch to right-aligned (undo?) and reset VisArea to the right
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir 				pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
1317cdf0e10cSrcweir 
1318cdf0e10cSrcweir 				aVis.Right() = aSize.Width() - 1;
1319cdf0e10cSrcweir 				aVis.Left() = aSize.Width() - aArea.GetWidth();		// with the new, increased area
1320cdf0e10cSrcweir 			}
1321cdf0e10cSrcweir 			else
1322cdf0e10cSrcweir 			{
1323cdf0e10cSrcweir 				//	switch to left-aligned (undo?) and reset VisArea to the left
1324cdf0e10cSrcweir 
1325cdf0e10cSrcweir 				pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 				long nMove = aVis.Left();
1328cdf0e10cSrcweir 				aVis.Left() = 0;
1329cdf0e10cSrcweir 				aVis.Right() -= nMove;
1330cdf0e10cSrcweir 			}
1331cdf0e10cSrcweir 			pCurView->SetVisArea( aVis );
1332cdf0e10cSrcweir 			bMoveArea = sal_False;
1333cdf0e10cSrcweir 		}
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir 		pCurView->SetOutputArea(aArea);
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 		//	In vertical mode, the whole text is moved to the next cell (right-aligned),
1338cdf0e10cSrcweir 		//	so everything must be repainted. Otherwise, paint only the new area.
1339cdf0e10cSrcweir 		//	If growing in centered alignment, if the cells left and right have different sizes,
1340cdf0e10cSrcweir 		//	the whole text will move, and may not even obscure all of the original display.
1341cdf0e10cSrcweir 		if ( bUnevenGrow )
1342cdf0e10cSrcweir 		{
1343cdf0e10cSrcweir 			aArea.Left() = pWin->PixelToLogic( Point(0,0) ).X();
1344cdf0e10cSrcweir 			aArea.Right() = pWin->PixelToLogic( aScrSize ).Width();
1345cdf0e10cSrcweir 		}
1346cdf0e10cSrcweir 		else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
1347cdf0e10cSrcweir 			aArea.Left() = nOldRight;
1348cdf0e10cSrcweir 		pWin->Invalidate(aArea);
1349cdf0e10cSrcweir 	}
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir 
EditGrowY(sal_Bool bInitial)1352cdf0e10cSrcweir void ScViewData::EditGrowY( sal_Bool bInitial )
1353cdf0e10cSrcweir {
1354cdf0e10cSrcweir 	ScSplitPos eWhich = GetActivePart();
1355cdf0e10cSrcweir 	ScVSplitPos eVWhich = WhichV(eWhich);
1356cdf0e10cSrcweir 	EditView* pCurView = pEditView[eWhich];
1357cdf0e10cSrcweir 
1358cdf0e10cSrcweir 	if ( !pCurView || !bEditActive[eWhich])
1359cdf0e10cSrcweir 		return;
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir 	sal_uLong nControl = pEditView[eWhich]->GetControlWord();
1362cdf0e10cSrcweir 	if ( nControl & EV_CNTRL_AUTOSCROLL )
1363cdf0e10cSrcweir 	{
1364cdf0e10cSrcweir 		//	if end of screen had already been reached and scrolling enabled,
1365cdf0e10cSrcweir 		//	don't further try to grow the edit area
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 		pCurView->SetOutputArea( pCurView->GetOutputArea() );	// re-align to pixels
1368cdf0e10cSrcweir 		return;
1369cdf0e10cSrcweir 	}
1370cdf0e10cSrcweir 
1371cdf0e10cSrcweir 	EditEngine* pEngine = pCurView->GetEditEngine();
1372cdf0e10cSrcweir 	Window* pWin = pCurView->GetWindow();
1373cdf0e10cSrcweir 
1374cdf0e10cSrcweir 	SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
1375cdf0e10cSrcweir 
1376cdf0e10cSrcweir 	Size		aSize = pEngine->GetPaperSize();
1377cdf0e10cSrcweir 	Rectangle	aArea = pCurView->GetOutputArea();
1378cdf0e10cSrcweir 	long		nOldBottom = aArea.Bottom();
1379cdf0e10cSrcweir 	long		nTextHeight = pEngine->GetTextHeight();
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 	//	#106635# When editing a formula in a cell with optimal height, allow a larger portion
1382cdf0e10cSrcweir 	//	to be clipped before extending to following rows, to avoid obscuring cells for
1383cdf0e10cSrcweir 	//	reference input (next row is likely to be useful in formulas).
1384cdf0e10cSrcweir 	long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
1385cdf0e10cSrcweir 	if ( nEditEndRow == nEditRow && !( pDoc->GetRowFlags( nEditRow, nTabNo ) & CR_MANUALSIZE ) &&
1386cdf0e10cSrcweir 			pEngine->GetParagraphCount() <= 1 )
1387cdf0e10cSrcweir 	{
1388cdf0e10cSrcweir 		//	If the (only) paragraph starts with a '=', it's a formula.
1389cdf0e10cSrcweir 		//	If this is the initial call and the text is empty, allow the larger value, too,
1390cdf0e10cSrcweir 		//	because this occurs in the normal progress of editing a formula.
1391cdf0e10cSrcweir 		//	Subsequent calls with empty text might involve changed attributes (including
1392cdf0e10cSrcweir 		//	font height), so they are treated like normal text.
1393*7a980842SDamjanJovanovic 		String aText = pEngine->GetText( 0 );
1394cdf0e10cSrcweir 		if ( ( aText.Len() == 0 && bInitial ) || aText.GetChar(0) == (sal_Unicode)'=' )
1395cdf0e10cSrcweir 			nAllowedExtra = SC_GROWY_BIG_EXTRA;
1396cdf0e10cSrcweir 	}
1397cdf0e10cSrcweir 
1398cdf0e10cSrcweir 	sal_Bool bChanged = sal_False;
1399cdf0e10cSrcweir 	sal_Bool bMaxReached = sal_False;
1400cdf0e10cSrcweir 	while (aArea.GetHeight() + nAllowedExtra < nTextHeight && nEditEndRow < nBottom && !bMaxReached)
1401cdf0e10cSrcweir 	{
1402cdf0e10cSrcweir 		++nEditEndRow;
1403cdf0e10cSrcweir 		ScDocument* pLocalDoc = GetDocument();
1404cdf0e10cSrcweir 		long nPix = ToPixel( pLocalDoc->GetRowHeight( nEditEndRow, nTabNo ), nPPTY );
1405cdf0e10cSrcweir 		aArea.Bottom() += pWin->PixelToLogic(Size(0,nPix)).Height();
1406cdf0e10cSrcweir 
1407cdf0e10cSrcweir 		if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 )
1408cdf0e10cSrcweir 		{
1409cdf0e10cSrcweir 			aArea.Bottom() = aArea.Top() + aSize.Height() - 1;
1410cdf0e10cSrcweir 			bMaxReached = sal_True;		// don't occupy more cells beyond paper size
1411cdf0e10cSrcweir 		}
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir 		bChanged = sal_True;
1414cdf0e10cSrcweir 		nAllowedExtra = SC_GROWY_SMALL_EXTRA;	// larger value is only for first row
1415cdf0e10cSrcweir 	}
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 	if (bChanged)
1418cdf0e10cSrcweir 	{
1419cdf0e10cSrcweir 		pCurView->SetOutputArea(aArea);
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir 		if (nEditEndRow >= nBottom || bMaxReached)
1422cdf0e10cSrcweir 		{
1423cdf0e10cSrcweir 			if ((nControl & EV_CNTRL_AUTOSCROLL) == 0)
1424cdf0e10cSrcweir 				pCurView->SetControlWord( nControl | EV_CNTRL_AUTOSCROLL );
1425cdf0e10cSrcweir 		}
1426cdf0e10cSrcweir 
1427cdf0e10cSrcweir 		aArea.Top() = nOldBottom;
1428cdf0e10cSrcweir 		pWin->Invalidate(aArea);
1429cdf0e10cSrcweir 	}
1430cdf0e10cSrcweir }
1431cdf0e10cSrcweir 
ResetEditView()1432cdf0e10cSrcweir void ScViewData::ResetEditView()
1433cdf0e10cSrcweir {
1434cdf0e10cSrcweir 	EditEngine* pEngine = NULL;
1435cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<4; i++)
1436cdf0e10cSrcweir 		if (pEditView[i])
1437cdf0e10cSrcweir 		{
1438cdf0e10cSrcweir 			if (bEditActive[i])
1439cdf0e10cSrcweir 			{
1440cdf0e10cSrcweir 				pEngine = pEditView[i]->GetEditEngine();
1441cdf0e10cSrcweir 				pEngine->RemoveView(pEditView[i]);
1442cdf0e10cSrcweir 				pEditView[i]->SetOutputArea( Rectangle() );
1443cdf0e10cSrcweir 			}
1444cdf0e10cSrcweir 			bEditActive[i] = sal_False;
1445cdf0e10cSrcweir 		}
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 	if (pEngine)
1448cdf0e10cSrcweir 		pEngine->SetStatusEventHdl( LINK( this, ScViewData, EmptyEditHdl ) );
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir 
KillEditView()1451cdf0e10cSrcweir void ScViewData::KillEditView()
1452cdf0e10cSrcweir {
1453cdf0e10cSrcweir 	for (sal_uInt16 i=0; i<4; i++)
1454cdf0e10cSrcweir 		if (pEditView[i])
1455cdf0e10cSrcweir 		{
1456cdf0e10cSrcweir 			if (bEditActive[i])
1457cdf0e10cSrcweir 				pEditView[i]->GetEditEngine()->RemoveView(pEditView[i]);
1458cdf0e10cSrcweir 			delete pEditView[i];
1459cdf0e10cSrcweir 			pEditView[i] = NULL;
1460cdf0e10cSrcweir 		}
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir 
GetEditView(ScSplitPos eWhich,EditView * & rViewPtr,SCCOL & rCol,SCROW & rRow)1463cdf0e10cSrcweir void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow )
1464cdf0e10cSrcweir {
1465cdf0e10cSrcweir 	rViewPtr = pEditView[eWhich];
1466cdf0e10cSrcweir 	rCol = nEditCol;
1467cdf0e10cSrcweir 	rRow = nEditRow;
1468cdf0e10cSrcweir }
1469cdf0e10cSrcweir 
CreateTabData(SCTAB nNewTab)1470cdf0e10cSrcweir void ScViewData::CreateTabData( SCTAB nNewTab )
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir     if (!pTabData[nNewTab])
1473cdf0e10cSrcweir     {
1474cdf0e10cSrcweir         pTabData[nNewTab] = new ScViewDataTable;
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir         pTabData[nNewTab]->eZoomType  = eDefZoomType;
1477cdf0e10cSrcweir         pTabData[nNewTab]->aZoomX     = aDefZoomX;
1478cdf0e10cSrcweir         pTabData[nNewTab]->aZoomY     = aDefZoomY;
1479cdf0e10cSrcweir         pTabData[nNewTab]->aPageZoomX = aDefPageZoomX;
1480cdf0e10cSrcweir         pTabData[nNewTab]->aPageZoomY = aDefPageZoomY;
1481cdf0e10cSrcweir     }
1482cdf0e10cSrcweir }
1483cdf0e10cSrcweir 
CreateSelectedTabData()1484cdf0e10cSrcweir void ScViewData::CreateSelectedTabData()
1485cdf0e10cSrcweir {
1486cdf0e10cSrcweir     SCTAB nTabCount = pDoc->GetTableCount();
1487cdf0e10cSrcweir     for (SCTAB i=0; i<nTabCount; i++)
1488cdf0e10cSrcweir         if ( aMarkData.GetTableSelect(i) && !pTabData[i] )
1489cdf0e10cSrcweir             CreateTabData( i );
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir 
SetTabNo(SCTAB nNewTab)1492cdf0e10cSrcweir void ScViewData::SetTabNo( SCTAB nNewTab )
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir 	if (!ValidTab(nNewTab))
1495cdf0e10cSrcweir 	{
1496cdf0e10cSrcweir 		DBG_ERROR("falsche Tabellennummer");
1497cdf0e10cSrcweir 		return;
1498cdf0e10cSrcweir 	}
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 	nTabNo = nNewTab;
1501cdf0e10cSrcweir 	CreateTabData(nTabNo);
1502cdf0e10cSrcweir 	pThisTab = pTabData[nTabNo];
1503cdf0e10cSrcweir 
1504cdf0e10cSrcweir 	CalcPPT();			//	for common column width correction
1505cdf0e10cSrcweir 	RecalcPixPos();		//! nicht immer noetig!
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir 
SetActivePart(ScSplitPos eNewActive)1508cdf0e10cSrcweir void ScViewData::SetActivePart( ScSplitPos eNewActive )
1509cdf0e10cSrcweir {
1510cdf0e10cSrcweir 	pThisTab->eWhichActive = eNewActive;
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir 
GetScrPos(SCCOL nWhereX,SCROW nWhereY,ScHSplitPos eWhich) const1513cdf0e10cSrcweir Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const
1514cdf0e10cSrcweir {
1515cdf0e10cSrcweir 	DBG_ASSERT( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "Falsche Position" );
1516cdf0e10cSrcweir 	ScSplitPos ePos = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
1517cdf0e10cSrcweir 	return GetScrPos( nWhereX, nWhereY, ePos );
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir 
GetScrPos(SCCOL nWhereX,SCROW nWhereY,ScVSplitPos eWhich) const1520cdf0e10cSrcweir Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const
1521cdf0e10cSrcweir {
1522cdf0e10cSrcweir 	DBG_ASSERT( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "Falsche Position" );
1523cdf0e10cSrcweir 	ScSplitPos ePos = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
1524cdf0e10cSrcweir 	return GetScrPos( nWhereX, nWhereY, ePos );
1525cdf0e10cSrcweir }
1526cdf0e10cSrcweir 
GetScrPos(SCCOL nWhereX,SCROW nWhereY,ScSplitPos eWhich,sal_Bool bAllowNeg) const1527cdf0e10cSrcweir Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
1528cdf0e10cSrcweir 								sal_Bool bAllowNeg ) const
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir     ScHSplitPos eWhichX = SC_SPLIT_LEFT;
1531cdf0e10cSrcweir     ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
1532cdf0e10cSrcweir 	switch( eWhich )
1533cdf0e10cSrcweir 	{
1534cdf0e10cSrcweir 		case SC_SPLIT_TOPLEFT:
1535cdf0e10cSrcweir 			eWhichX = SC_SPLIT_LEFT;
1536cdf0e10cSrcweir 			eWhichY = SC_SPLIT_TOP;
1537cdf0e10cSrcweir 			break;
1538cdf0e10cSrcweir 		case SC_SPLIT_TOPRIGHT:
1539cdf0e10cSrcweir 			eWhichX = SC_SPLIT_RIGHT;
1540cdf0e10cSrcweir 			eWhichY = SC_SPLIT_TOP;
1541cdf0e10cSrcweir 			break;
1542cdf0e10cSrcweir 		case SC_SPLIT_BOTTOMLEFT:
1543cdf0e10cSrcweir 			eWhichX = SC_SPLIT_LEFT;
1544cdf0e10cSrcweir 			eWhichY = SC_SPLIT_BOTTOM;
1545cdf0e10cSrcweir 			break;
1546cdf0e10cSrcweir 		case SC_SPLIT_BOTTOMRIGHT:
1547cdf0e10cSrcweir 			eWhichX = SC_SPLIT_RIGHT;
1548cdf0e10cSrcweir 			eWhichY = SC_SPLIT_BOTTOM;
1549cdf0e10cSrcweir 			break;
1550cdf0e10cSrcweir 	}
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir 	if (pView)
1553cdf0e10cSrcweir 	{
1554cdf0e10cSrcweir 		((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
1555cdf0e10cSrcweir 		((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
1556cdf0e10cSrcweir 	}
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir 	sal_uInt16 nTSize;
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir 	SCCOL	nPosX = GetPosX(eWhichX);
1561cdf0e10cSrcweir 	SCCOL	nX;
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 	long nScrPosX=0;
1564cdf0e10cSrcweir 	if (nWhereX >= nPosX)
1565cdf0e10cSrcweir 		for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++)
1566cdf0e10cSrcweir 		{
1567cdf0e10cSrcweir 			if ( nX > MAXCOL )
1568cdf0e10cSrcweir 				nScrPosX = 65535;
1569cdf0e10cSrcweir 			else
1570cdf0e10cSrcweir 			{
1571cdf0e10cSrcweir 				nTSize = pDoc->GetColWidth( nX, nTabNo );
1572cdf0e10cSrcweir 				if (nTSize)
1573cdf0e10cSrcweir 				{
1574cdf0e10cSrcweir 					long nSizeXPix = ToPixel( nTSize, nPPTX );
1575cdf0e10cSrcweir 					nScrPosX += nSizeXPix;
1576cdf0e10cSrcweir 				}
1577cdf0e10cSrcweir 			}
1578cdf0e10cSrcweir 		}
1579cdf0e10cSrcweir 	else if (bAllowNeg)
1580cdf0e10cSrcweir 		for (nX=nPosX; nX>nWhereX;)
1581cdf0e10cSrcweir 		{
1582cdf0e10cSrcweir 			--nX;
1583cdf0e10cSrcweir 			nTSize = pDoc->GetColWidth( nX, nTabNo );
1584cdf0e10cSrcweir 			if (nTSize)
1585cdf0e10cSrcweir 			{
1586cdf0e10cSrcweir 				long nSizeXPix = ToPixel( nTSize, nPPTX );
1587cdf0e10cSrcweir 				nScrPosX -= nSizeXPix;
1588cdf0e10cSrcweir 			}
1589cdf0e10cSrcweir 		}
1590cdf0e10cSrcweir 
1591cdf0e10cSrcweir 	SCROW	nPosY = GetPosY(eWhichY);
1592cdf0e10cSrcweir 	SCROW	nY;
1593cdf0e10cSrcweir 
1594cdf0e10cSrcweir 	long nScrPosY=0;
1595cdf0e10cSrcweir 	if (nWhereY >= nPosY)
1596cdf0e10cSrcweir 		for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++)
1597cdf0e10cSrcweir 		{
1598cdf0e10cSrcweir 			if ( nY > MAXROW )
1599cdf0e10cSrcweir 				nScrPosY = 65535;
1600cdf0e10cSrcweir 			else
1601cdf0e10cSrcweir 			{
1602cdf0e10cSrcweir 				nTSize = pDoc->GetRowHeight( nY, nTabNo );
1603cdf0e10cSrcweir 				if (nTSize)
1604cdf0e10cSrcweir 				{
1605cdf0e10cSrcweir 					long nSizeYPix = ToPixel( nTSize, nPPTY );
1606cdf0e10cSrcweir 					nScrPosY += nSizeYPix;
1607cdf0e10cSrcweir 				}
1608cdf0e10cSrcweir                 else if ( nY < MAXROW )
1609cdf0e10cSrcweir                 {
1610cdf0e10cSrcweir                     // skip multiple hidden rows (forward only for now)
1611cdf0e10cSrcweir                     SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
1612cdf0e10cSrcweir                     if ( nNext > MAXROW )
1613cdf0e10cSrcweir                         nY = MAXROW;
1614cdf0e10cSrcweir                     else
1615cdf0e10cSrcweir                         nY = nNext - 1;     // +=nDir advances to next visible row
1616cdf0e10cSrcweir                 }
1617cdf0e10cSrcweir 			}
1618cdf0e10cSrcweir 		}
1619cdf0e10cSrcweir 	else if (bAllowNeg)
1620cdf0e10cSrcweir 		for (nY=nPosY; nY>nWhereY;)
1621cdf0e10cSrcweir 		{
1622cdf0e10cSrcweir 			--nY;
1623cdf0e10cSrcweir 			nTSize = pDoc->GetRowHeight( nY, nTabNo );
1624cdf0e10cSrcweir 			if (nTSize)
1625cdf0e10cSrcweir 			{
1626cdf0e10cSrcweir 				long nSizeYPix = ToPixel( nTSize, nPPTY );
1627cdf0e10cSrcweir 				nScrPosY -= nSizeYPix;
1628cdf0e10cSrcweir 			}
1629cdf0e10cSrcweir 		}
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir 	if ( pDoc->IsLayoutRTL( nTabNo ) )
1632cdf0e10cSrcweir 	{
1633cdf0e10cSrcweir 		//	mirror horizontal position
1634cdf0e10cSrcweir 		nScrPosX = aScrSize.Width() - 1 - nScrPosX;
1635cdf0e10cSrcweir 	}
1636cdf0e10cSrcweir 
1637cdf0e10cSrcweir 	if (nScrPosX > 32767) nScrPosX=32767;
1638cdf0e10cSrcweir 	if (nScrPosY > 32767) nScrPosY=32767;
1639cdf0e10cSrcweir 	return Point( nScrPosX, nScrPosY );
1640cdf0e10cSrcweir }
1641cdf0e10cSrcweir 
1642cdf0e10cSrcweir //
1643cdf0e10cSrcweir //		Anzahl Zellen auf einem Bildschirm
1644cdf0e10cSrcweir //
1645cdf0e10cSrcweir 
CellsAtX(SCsCOL nPosX,SCsCOL nDir,ScHSplitPos eWhichX,sal_uInt16 nScrSizeX) const1646cdf0e10cSrcweir SCCOL ScViewData::CellsAtX( SCsCOL nPosX, SCsCOL nDir, ScHSplitPos eWhichX, sal_uInt16 nScrSizeX ) const
1647cdf0e10cSrcweir {
1648cdf0e10cSrcweir 	DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir 	if (pView)
1651cdf0e10cSrcweir 		((ScViewData*)this)->aScrSize.Width()  = pView->GetGridWidth(eWhichX);
1652cdf0e10cSrcweir 
1653cdf0e10cSrcweir 	SCsCOL	nX;
1654cdf0e10cSrcweir 	sal_uInt16	nScrPosX = 0;
1655cdf0e10cSrcweir 	if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (sal_uInt16) aScrSize.Width();
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir 	if (nDir==1)
1658cdf0e10cSrcweir 		nX = nPosX;				// vorwaerts
1659cdf0e10cSrcweir 	else
1660cdf0e10cSrcweir 		nX = nPosX-1;			// rueckwaerts
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir 	sal_Bool bOut = sal_False;
1663cdf0e10cSrcweir     for ( ; nScrPosX<=nScrSizeX && !bOut; nX = sal::static_int_cast<SCsCOL>(nX + nDir) )
1664cdf0e10cSrcweir 	{
1665cdf0e10cSrcweir 		SCsCOL	nColNo = nX;
1666cdf0e10cSrcweir 		if ( nColNo < 0 || nColNo > MAXCOL )
1667cdf0e10cSrcweir 			bOut = sal_True;
1668cdf0e10cSrcweir 		else
1669cdf0e10cSrcweir 		{
1670cdf0e10cSrcweir 			sal_uInt16 nTSize = pDoc->GetColWidth( nColNo, nTabNo );
1671cdf0e10cSrcweir 			if (nTSize)
1672cdf0e10cSrcweir 			{
1673cdf0e10cSrcweir 				long nSizeXPix = ToPixel( nTSize, nPPTX );
1674cdf0e10cSrcweir                 nScrPosX = sal::static_int_cast<sal_uInt16>( nScrPosX + (sal_uInt16) nSizeXPix );
1675cdf0e10cSrcweir 			}
1676cdf0e10cSrcweir 		}
1677cdf0e10cSrcweir 	}
1678cdf0e10cSrcweir 
1679cdf0e10cSrcweir 	if (nDir==1)
1680cdf0e10cSrcweir         nX = sal::static_int_cast<SCsCOL>( nX - nPosX );
1681cdf0e10cSrcweir 	else
1682cdf0e10cSrcweir 		nX = (nPosX-1)-nX;
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir 	if (nX>0) --nX;
1685cdf0e10cSrcweir 	return nX;
1686cdf0e10cSrcweir }
1687cdf0e10cSrcweir 
CellsAtY(SCsROW nPosY,SCsROW nDir,ScVSplitPos eWhichY,sal_uInt16 nScrSizeY) const1688cdf0e10cSrcweir SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, sal_uInt16 nScrSizeY ) const
1689cdf0e10cSrcweir {
1690cdf0e10cSrcweir     DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
1691cdf0e10cSrcweir 
1692cdf0e10cSrcweir     if (pView)
1693cdf0e10cSrcweir         ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
1694cdf0e10cSrcweir 
1695cdf0e10cSrcweir     if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (sal_uInt16) aScrSize.Height();
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir     SCROW nY;
1698cdf0e10cSrcweir 
1699cdf0e10cSrcweir     if (nDir==1)
1700cdf0e10cSrcweir     {
1701cdf0e10cSrcweir         // forward
1702cdf0e10cSrcweir         nY = nPosY;
1703cdf0e10cSrcweir         long nScrPosY = 0;
1704cdf0e10cSrcweir         AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo);
1705cdf0e10cSrcweir         // Original loop ended on last evaluated +1 or if that was MAXROW even
1706cdf0e10cSrcweir         // on MAXROW+2.
1707cdf0e10cSrcweir         nY += (nY == MAXROW ? 2 : 1);
1708cdf0e10cSrcweir         nY -= nPosY;
1709cdf0e10cSrcweir     }
1710cdf0e10cSrcweir     else
1711cdf0e10cSrcweir     {
1712cdf0e10cSrcweir         // backward
1713cdf0e10cSrcweir         nY = nPosY-1;
1714cdf0e10cSrcweir         long nScrPosY = 0;
1715cdf0e10cSrcweir         AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo);
1716cdf0e10cSrcweir         // Original loop ended on last evaluated -1 or if that was 0 even on
1717cdf0e10cSrcweir         // -2.
1718cdf0e10cSrcweir         nY -= (nY == 0 ? 2 : 1);
1719cdf0e10cSrcweir         nY = (nPosY-1)-nY;
1720cdf0e10cSrcweir     }
1721cdf0e10cSrcweir 
1722cdf0e10cSrcweir     if (nY>0) --nY;
1723cdf0e10cSrcweir     return nY;
1724cdf0e10cSrcweir }
1725cdf0e10cSrcweir 
VisibleCellsX(ScHSplitPos eWhichX) const1726cdf0e10cSrcweir SCCOL ScViewData::VisibleCellsX( ScHSplitPos eWhichX ) const
1727cdf0e10cSrcweir {
1728cdf0e10cSrcweir 	return CellsAtX( GetPosX( eWhichX ), 1, eWhichX, SC_SIZE_NONE );
1729cdf0e10cSrcweir }
1730cdf0e10cSrcweir 
VisibleCellsY(ScVSplitPos eWhichY) const1731cdf0e10cSrcweir SCROW ScViewData::VisibleCellsY( ScVSplitPos eWhichY ) const
1732cdf0e10cSrcweir {
1733cdf0e10cSrcweir 	return CellsAtY( GetPosY( eWhichY ), 1, eWhichY, SC_SIZE_NONE );
1734cdf0e10cSrcweir }
1735cdf0e10cSrcweir 
PrevCellsX(ScHSplitPos eWhichX) const1736cdf0e10cSrcweir SCCOL ScViewData::PrevCellsX( ScHSplitPos eWhichX ) const
1737cdf0e10cSrcweir {
1738cdf0e10cSrcweir 	return CellsAtX( GetPosX( eWhichX ), -1, eWhichX, SC_SIZE_NONE );
1739cdf0e10cSrcweir }
1740cdf0e10cSrcweir 
PrevCellsY(ScVSplitPos eWhichY) const1741cdf0e10cSrcweir SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const
1742cdf0e10cSrcweir {
1743cdf0e10cSrcweir 	return CellsAtY( GetPosY( eWhichY ), -1, eWhichY, SC_SIZE_NONE );
1744cdf0e10cSrcweir }
1745cdf0e10cSrcweir 
1746cdf0e10cSrcweir //UNUSED2008-05  SCCOL ScViewData::LastCellsX( ScHSplitPos eWhichX ) const
1747cdf0e10cSrcweir //UNUSED2008-05  {
1748cdf0e10cSrcweir //UNUSED2008-05      return CellsAtX( MAXCOL+1, -1, eWhichX, SC_SIZE_NONE );
1749cdf0e10cSrcweir //UNUSED2008-05  }
1750cdf0e10cSrcweir //UNUSED2008-05
1751cdf0e10cSrcweir //UNUSED2008-05  SCROW ScViewData::LastCellsY( ScVSplitPos eWhichY ) const
1752cdf0e10cSrcweir //UNUSED2008-05  {
1753cdf0e10cSrcweir //UNUSED2008-05      return CellsAtY( MAXROW+1, -1, eWhichY, SC_SIZE_NONE );
1754cdf0e10cSrcweir //UNUSED2008-05  }
1755cdf0e10cSrcweir 
GetMergeSizePixel(SCCOL nX,SCROW nY,long & rSizeXPix,long & rSizeYPix)1756cdf0e10cSrcweir sal_Bool ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix )
1757cdf0e10cSrcweir {
1758cdf0e10cSrcweir 	const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
1759cdf0e10cSrcweir 	if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
1760cdf0e10cSrcweir 	{
1761cdf0e10cSrcweir 		long nOutWidth = 0;
1762cdf0e10cSrcweir 		long nOutHeight = 0;
1763cdf0e10cSrcweir 		SCCOL nCountX = pMerge->GetColMerge();
1764cdf0e10cSrcweir 		for (SCCOL i=0; i<nCountX; i++)
1765cdf0e10cSrcweir 			nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX );
1766cdf0e10cSrcweir 		SCROW nCountY = pMerge->GetRowMerge();
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir         for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
1769cdf0e10cSrcweir         {
1770cdf0e10cSrcweir             SCROW nLastRow = nRow;
1771cdf0e10cSrcweir             if (pDoc->RowHidden(nRow, nTabNo, NULL, &nLastRow))
1772cdf0e10cSrcweir             {
1773cdf0e10cSrcweir                 nRow = nLastRow;
1774cdf0e10cSrcweir                 continue;
1775cdf0e10cSrcweir             }
1776cdf0e10cSrcweir 
1777cdf0e10cSrcweir             sal_uInt16 nHeight = pDoc->GetRowHeight(nRow, nTabNo);
1778cdf0e10cSrcweir             nOutHeight += ToPixel(nHeight, nPPTY);
1779cdf0e10cSrcweir         }
1780cdf0e10cSrcweir 
1781cdf0e10cSrcweir 		rSizeXPix = nOutWidth;
1782cdf0e10cSrcweir 		rSizeYPix = nOutHeight;
1783cdf0e10cSrcweir 		return sal_True;
1784cdf0e10cSrcweir 	}
1785cdf0e10cSrcweir 	else
1786cdf0e10cSrcweir 	{
1787cdf0e10cSrcweir 		rSizeXPix = ToPixel( pDoc->GetColWidth( nX, nTabNo ), nPPTX );
1788cdf0e10cSrcweir 		rSizeYPix = ToPixel( pDoc->GetRowHeight( nY, nTabNo ), nPPTY );
1789cdf0e10cSrcweir 		return sal_False;
1790cdf0e10cSrcweir 	}
1791cdf0e10cSrcweir }
1792cdf0e10cSrcweir 
GetPosFromPixel(long nClickX,long nClickY,ScSplitPos eWhich,SCsCOL & rPosX,SCsROW & rPosY,sal_Bool bTestMerge,sal_Bool bRepair,sal_Bool bNextIfLarge)1793cdf0e10cSrcweir sal_Bool ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
1794cdf0e10cSrcweir 										SCsCOL& rPosX, SCsROW& rPosY,
1795cdf0e10cSrcweir 										sal_Bool bTestMerge, sal_Bool bRepair, sal_Bool bNextIfLarge )
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir 	//	special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
1798cdf0e10cSrcweir 
1799cdf0e10cSrcweir 	ScHSplitPos eHWhich = WhichH(eWhich);
1800cdf0e10cSrcweir 	ScVSplitPos eVWhich = WhichV(eWhich);
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir 	if ( pDoc->IsLayoutRTL( nTabNo ) )
1803cdf0e10cSrcweir 	{
1804cdf0e10cSrcweir 		//	mirror horizontal position
1805cdf0e10cSrcweir 		if (pView)
1806cdf0e10cSrcweir 			aScrSize.Width() = pView->GetGridWidth(eHWhich);
1807cdf0e10cSrcweir 		nClickX = aScrSize.Width() - 1 - nClickX;
1808cdf0e10cSrcweir 	}
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 	SCsCOL nStartPosX = GetPosX(eHWhich);
1811cdf0e10cSrcweir 	SCsROW nStartPosY = GetPosY(eVWhich);
1812cdf0e10cSrcweir 	rPosX = nStartPosX;
1813cdf0e10cSrcweir 	rPosY = nStartPosY;
1814cdf0e10cSrcweir 	long nScrX = 0;
1815cdf0e10cSrcweir 	long nScrY = 0;
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir 	if (nClickX > 0)
1818cdf0e10cSrcweir 	{
1819cdf0e10cSrcweir 		while ( rPosX<=MAXCOL && nClickX >= nScrX )
1820cdf0e10cSrcweir 		{
1821cdf0e10cSrcweir 			nScrX += ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
1822cdf0e10cSrcweir 			++rPosX;
1823cdf0e10cSrcweir 		}
1824cdf0e10cSrcweir 		--rPosX;
1825cdf0e10cSrcweir 	}
1826cdf0e10cSrcweir 	else
1827cdf0e10cSrcweir 	{
1828cdf0e10cSrcweir 		while ( rPosX>0 && nClickX < nScrX )
1829cdf0e10cSrcweir 		{
1830cdf0e10cSrcweir 			--rPosX;
1831cdf0e10cSrcweir 			nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
1832cdf0e10cSrcweir 		}
1833cdf0e10cSrcweir 	}
1834cdf0e10cSrcweir 
1835cdf0e10cSrcweir 	if (nClickY > 0)
1836cdf0e10cSrcweir         AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo );
1837cdf0e10cSrcweir 	else
1838cdf0e10cSrcweir 	{
1839cdf0e10cSrcweir         /* TODO: could need some "SubPixelsWhileBackward" method */
1840cdf0e10cSrcweir 		while ( rPosY>0 && nClickY < nScrY )
1841cdf0e10cSrcweir 		{
1842cdf0e10cSrcweir 			--rPosY;
1843cdf0e10cSrcweir 			nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY );
1844cdf0e10cSrcweir 		}
1845cdf0e10cSrcweir 	}
1846cdf0e10cSrcweir 
1847cdf0e10cSrcweir 	if (bNextIfLarge)		//	zu grosse Zellen ?
1848cdf0e10cSrcweir 	{
1849cdf0e10cSrcweir 		if ( rPosX == nStartPosX && nClickX > 0 )
1850cdf0e10cSrcweir 		{
1851cdf0e10cSrcweir 			if (pView)
1852cdf0e10cSrcweir 				aScrSize.Width() = pView->GetGridWidth(eHWhich);
1853cdf0e10cSrcweir 			if ( nClickX > aScrSize.Width() )
1854cdf0e10cSrcweir 				++rPosX;
1855cdf0e10cSrcweir 		}
1856cdf0e10cSrcweir 		if ( rPosY == nStartPosY && nClickY > 0 )
1857cdf0e10cSrcweir 		{
1858cdf0e10cSrcweir 			if (pView)
1859cdf0e10cSrcweir 				aScrSize.Height() = pView->GetGridHeight(eVWhich);
1860cdf0e10cSrcweir 			if ( nClickY > aScrSize.Height() )
1861cdf0e10cSrcweir 				++rPosY;
1862cdf0e10cSrcweir 		}
1863cdf0e10cSrcweir 	}
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir 	if (rPosX<0) rPosX=0;
1866cdf0e10cSrcweir 	if (rPosX>MAXCOL) rPosX=MAXCOL;
1867cdf0e10cSrcweir 	if (rPosY<0) rPosY=0;
1868cdf0e10cSrcweir 	if (rPosY>MAXROW) rPosY=MAXROW;
1869cdf0e10cSrcweir 
1870cdf0e10cSrcweir 	if (bTestMerge)
1871cdf0e10cSrcweir 	{
1872cdf0e10cSrcweir 		//!	public Methode um Position anzupassen
1873cdf0e10cSrcweir 
1874cdf0e10cSrcweir 		sal_Bool bHOver = sal_False;
1875cdf0e10cSrcweir 		while (pDoc->IsHorOverlapped( rPosX, rPosY, nTabNo ))
1876cdf0e10cSrcweir 			{ --rPosX; bHOver=sal_True; }
1877cdf0e10cSrcweir 		sal_Bool bVOver = sal_False;
1878cdf0e10cSrcweir 		while (pDoc->IsVerOverlapped( rPosX, rPosY, nTabNo ))
1879cdf0e10cSrcweir 			{ --rPosY; bVOver=sal_True; }
1880cdf0e10cSrcweir 
1881cdf0e10cSrcweir 		if ( bRepair && ( bHOver || bVOver ) )
1882cdf0e10cSrcweir 		{
1883cdf0e10cSrcweir 			const ScMergeAttr* pMerge = (const ScMergeAttr*)
1884cdf0e10cSrcweir 								pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE );
1885cdf0e10cSrcweir 			if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
1886cdf0e10cSrcweir 				 ( bVOver && pMerge->GetRowMerge() <= 1 ) )
1887cdf0e10cSrcweir 			{
1888cdf0e10cSrcweir 				DBG_ERROR("Merge-Fehler gefunden");
1889cdf0e10cSrcweir 
1890cdf0e10cSrcweir 				pDoc->RemoveFlagsTab( 0,0, MAXCOL,MAXROW, nTabNo, SC_MF_HOR | SC_MF_VER );
1891cdf0e10cSrcweir 				SCCOL nEndCol = MAXCOL;
1892cdf0e10cSrcweir 				SCROW nEndRow = MAXROW;
1893cdf0e10cSrcweir 				pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, sal_True, sal_False );
1894cdf0e10cSrcweir 				if (pDocShell)
1895cdf0e10cSrcweir 					pDocShell->PostPaint( ScRange(0,0,nTabNo,MAXCOL,MAXROW,nTabNo), PAINT_GRID );
1896cdf0e10cSrcweir 			}
1897cdf0e10cSrcweir 		}
1898cdf0e10cSrcweir 	}
1899cdf0e10cSrcweir 
1900cdf0e10cSrcweir 	return sal_False;
1901cdf0e10cSrcweir }
1902cdf0e10cSrcweir 
GetMouseQuadrant(const Point & rClickPos,ScSplitPos eWhich,SCsCOL nPosX,SCsROW nPosY,sal_Bool & rLeft,sal_Bool & rTop)1903cdf0e10cSrcweir void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
1904cdf0e10cSrcweir 										SCsCOL nPosX, SCsROW nPosY, sal_Bool& rLeft, sal_Bool& rTop )
1905cdf0e10cSrcweir {
1906cdf0e10cSrcweir 	sal_Bool bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
1907cdf0e10cSrcweir 	long nLayoutSign = bLayoutRTL ? -1 : 1;
1908cdf0e10cSrcweir 
1909cdf0e10cSrcweir 	Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, sal_True );
1910cdf0e10cSrcweir 	long nSizeX;
1911cdf0e10cSrcweir 	long nSizeY;
1912cdf0e10cSrcweir 	GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
1913cdf0e10cSrcweir 	rLeft = ( rClickPos.X() - aCellStart.X() ) * nLayoutSign <= nSizeX / 2;
1914cdf0e10cSrcweir 	rTop  = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2;
1915cdf0e10cSrcweir }
1916cdf0e10cSrcweir 
SetPosX(ScHSplitPos eWhich,SCCOL nNewPosX)1917cdf0e10cSrcweir void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
1918cdf0e10cSrcweir {
1919cdf0e10cSrcweir 	if (nNewPosX != 0)
1920cdf0e10cSrcweir 	{
1921cdf0e10cSrcweir 		SCCOL nOldPosX = pThisTab->nPosX[eWhich];
1922cdf0e10cSrcweir 		long nTPosX = pThisTab->nTPosX[eWhich];
1923cdf0e10cSrcweir 		long nPixPosX = pThisTab->nPixPosX[eWhich];
1924cdf0e10cSrcweir 		SCCOL i;
1925cdf0e10cSrcweir 		if ( nNewPosX > nOldPosX )
1926cdf0e10cSrcweir 			for ( i=nOldPosX; i<nNewPosX; i++ )
1927cdf0e10cSrcweir 			{
1928cdf0e10cSrcweir 				long nThis = pDoc->GetColWidth( i,nTabNo );
1929cdf0e10cSrcweir 				nTPosX -= nThis;
1930cdf0e10cSrcweir                 nPixPosX -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
1931cdf0e10cSrcweir 			}
1932cdf0e10cSrcweir 		else
1933cdf0e10cSrcweir 			for ( i=nNewPosX; i<nOldPosX; i++ )
1934cdf0e10cSrcweir 			{
1935cdf0e10cSrcweir 				long nThis = pDoc->GetColWidth( i,nTabNo );
1936cdf0e10cSrcweir 				nTPosX += nThis;
1937cdf0e10cSrcweir                 nPixPosX += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTX);
1938cdf0e10cSrcweir 			}
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir 		pThisTab->nPosX[eWhich] = nNewPosX;
1941cdf0e10cSrcweir 		pThisTab->nTPosX[eWhich] = nTPosX;
1942cdf0e10cSrcweir 		pThisTab->nMPosX[eWhich] = (long) (nTPosX * HMM_PER_TWIPS);
1943cdf0e10cSrcweir 		pThisTab->nPixPosX[eWhich] = nPixPosX;
1944cdf0e10cSrcweir 	}
1945cdf0e10cSrcweir 	else
1946cdf0e10cSrcweir 		pThisTab->nPixPosX[eWhich] =
1947cdf0e10cSrcweir 		pThisTab->nTPosX[eWhich] =
1948cdf0e10cSrcweir 		pThisTab->nMPosX[eWhich] =
1949cdf0e10cSrcweir 		pThisTab->nPosX[eWhich] = 0;
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir 
SetPosY(ScVSplitPos eWhich,SCROW nNewPosY)1952cdf0e10cSrcweir void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
1953cdf0e10cSrcweir {
1954cdf0e10cSrcweir 	if (nNewPosY != 0)
1955cdf0e10cSrcweir 	{
1956cdf0e10cSrcweir 		SCROW nOldPosY = pThisTab->nPosY[eWhich];
1957cdf0e10cSrcweir 		long nTPosY = pThisTab->nTPosY[eWhich];
1958cdf0e10cSrcweir 		long nPixPosY = pThisTab->nPixPosY[eWhich];
1959cdf0e10cSrcweir 		SCROW i, nHeightEndRow;
1960cdf0e10cSrcweir 		if ( nNewPosY > nOldPosY )
1961cdf0e10cSrcweir 			for ( i=nOldPosY; i<nNewPosY; i++ )
1962cdf0e10cSrcweir 			{
1963cdf0e10cSrcweir 				long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
1964cdf0e10cSrcweir                 SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
1965cdf0e10cSrcweir                 i = nHeightEndRow;
1966cdf0e10cSrcweir 				nTPosY -= nThis * nRows;
1967cdf0e10cSrcweir                 nPixPosY -= ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
1968cdf0e10cSrcweir 			}
1969cdf0e10cSrcweir 		else
1970cdf0e10cSrcweir 			for ( i=nNewPosY; i<nOldPosY; i++ )
1971cdf0e10cSrcweir 			{
1972cdf0e10cSrcweir 				long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
1973cdf0e10cSrcweir                 SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
1974cdf0e10cSrcweir                 i = nHeightEndRow;
1975cdf0e10cSrcweir 				nTPosY += nThis * nRows;
1976cdf0e10cSrcweir                 nPixPosY += ToPixel(sal::static_int_cast<sal_uInt16>(nThis), nPPTY) * nRows;
1977cdf0e10cSrcweir 			}
1978cdf0e10cSrcweir 
1979cdf0e10cSrcweir 		pThisTab->nPosY[eWhich] = nNewPosY;
1980cdf0e10cSrcweir 		pThisTab->nTPosY[eWhich] = nTPosY;
1981cdf0e10cSrcweir 		pThisTab->nMPosY[eWhich] = (long) (nTPosY * HMM_PER_TWIPS);
1982cdf0e10cSrcweir 		pThisTab->nPixPosY[eWhich] = nPixPosY;
1983cdf0e10cSrcweir 	}
1984cdf0e10cSrcweir 	else
1985cdf0e10cSrcweir 		pThisTab->nPixPosY[eWhich] =
1986cdf0e10cSrcweir 		pThisTab->nTPosY[eWhich] =
1987cdf0e10cSrcweir 		pThisTab->nMPosY[eWhich] =
1988cdf0e10cSrcweir 		pThisTab->nPosY[eWhich] = 0;
1989cdf0e10cSrcweir }
1990cdf0e10cSrcweir 
RecalcPixPos()1991cdf0e10cSrcweir void ScViewData::RecalcPixPos()				// nach Zoom-Aenderungen
1992cdf0e10cSrcweir {
1993cdf0e10cSrcweir 	for (sal_uInt16 eWhich=0; eWhich<2; eWhich++)
1994cdf0e10cSrcweir 	{
1995cdf0e10cSrcweir 		long nPixPosX = 0;
1996cdf0e10cSrcweir 		SCCOL nPosX = pThisTab->nPosX[eWhich];
1997cdf0e10cSrcweir 		for (SCCOL i=0; i<nPosX; i++)
1998cdf0e10cSrcweir 			nPixPosX -= ToPixel(pDoc->GetColWidth(i,nTabNo), nPPTX);
1999cdf0e10cSrcweir 		pThisTab->nPixPosX[eWhich] = nPixPosX;
2000cdf0e10cSrcweir 
2001cdf0e10cSrcweir 		long nPixPosY = 0;
2002cdf0e10cSrcweir 		SCROW nPosY = pThisTab->nPosY[eWhich];
2003cdf0e10cSrcweir 		for (SCROW j=0; j<nPosY; j++)
2004cdf0e10cSrcweir 			nPixPosY -= ToPixel(pDoc->GetRowHeight(j,nTabNo), nPPTY);
2005cdf0e10cSrcweir 		pThisTab->nPixPosY[eWhich] = nPixPosY;
2006cdf0e10cSrcweir 	}
2007cdf0e10cSrcweir }
2008cdf0e10cSrcweir 
GetLogicMode(ScSplitPos eWhich)2009cdf0e10cSrcweir const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich )
2010cdf0e10cSrcweir {
2011cdf0e10cSrcweir 	aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)],
2012cdf0e10cSrcweir 									pThisTab->nMPosY[WhichV(eWhich)] ) );
2013cdf0e10cSrcweir 	return aLogicMode;
2014cdf0e10cSrcweir }
2015cdf0e10cSrcweir 
GetLogicMode()2016cdf0e10cSrcweir const MapMode& ScViewData::GetLogicMode()
2017cdf0e10cSrcweir {
2018cdf0e10cSrcweir 	aLogicMode.SetOrigin( Point() );
2019cdf0e10cSrcweir 	return aLogicMode;
2020cdf0e10cSrcweir }
2021cdf0e10cSrcweir 
SetScreen(SCCOL nCol1,SCROW nRow1,SCCOL nCol2,SCROW nRow2)2022cdf0e10cSrcweir void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
2023cdf0e10cSrcweir {
2024cdf0e10cSrcweir 	SCCOL nCol;
2025cdf0e10cSrcweir 	SCROW nRow;
2026cdf0e10cSrcweir 	sal_uInt16 nTSize;
2027cdf0e10cSrcweir 	long nSizePix;
2028cdf0e10cSrcweir 	long nScrPosX = 0;
2029cdf0e10cSrcweir 	long nScrPosY = 0;
2030cdf0e10cSrcweir 
2031cdf0e10cSrcweir 	SetActivePart( SC_SPLIT_BOTTOMLEFT );
2032cdf0e10cSrcweir 	SetPosX( SC_SPLIT_LEFT, nCol1 );
2033cdf0e10cSrcweir 	SetPosY( SC_SPLIT_BOTTOM, nRow1 );
2034cdf0e10cSrcweir 
2035cdf0e10cSrcweir 	for (nCol=nCol1; nCol<=nCol2; nCol++)
2036cdf0e10cSrcweir 	{
2037cdf0e10cSrcweir 		nTSize = pDoc->GetColWidth( nCol, nTabNo );
2038cdf0e10cSrcweir 		if (nTSize)
2039cdf0e10cSrcweir 		{
2040cdf0e10cSrcweir 			nSizePix = ToPixel( nTSize, nPPTX );
2041cdf0e10cSrcweir 			nScrPosX += (sal_uInt16) nSizePix;
2042cdf0e10cSrcweir 		}
2043cdf0e10cSrcweir 	}
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir 	for (nRow=nRow1; nRow<=nRow2; nRow++)
2046cdf0e10cSrcweir 	{
2047cdf0e10cSrcweir 		nTSize = pDoc->GetRowHeight( nRow, nTabNo );
2048cdf0e10cSrcweir 		if (nTSize)
2049cdf0e10cSrcweir 		{
2050cdf0e10cSrcweir 			nSizePix = ToPixel( nTSize, nPPTY );
2051cdf0e10cSrcweir 			nScrPosY += (sal_uInt16) nSizePix;
2052cdf0e10cSrcweir 		}
2053cdf0e10cSrcweir 	}
2054cdf0e10cSrcweir 
2055cdf0e10cSrcweir 	aScrSize = Size( nScrPosX, nScrPosY );
2056cdf0e10cSrcweir }
2057cdf0e10cSrcweir 
SetScreenPos(const Point & rVisAreaStart)2058cdf0e10cSrcweir void ScViewData::SetScreenPos( const Point& rVisAreaStart )
2059cdf0e10cSrcweir {
2060cdf0e10cSrcweir 	long nSize;
2061cdf0e10cSrcweir 	long nTwips;
2062cdf0e10cSrcweir 	long nAdd;
2063cdf0e10cSrcweir 	sal_Bool bEnd;
2064cdf0e10cSrcweir 
2065cdf0e10cSrcweir 	nSize = 0;
2066cdf0e10cSrcweir 	nTwips = (long) (rVisAreaStart.X() / HMM_PER_TWIPS);
2067cdf0e10cSrcweir     if ( pDoc->IsLayoutRTL( nTabNo ) )
2068cdf0e10cSrcweir         nTwips = -nTwips;
2069cdf0e10cSrcweir 	SCCOL nX1 = 0;
2070cdf0e10cSrcweir 	bEnd = sal_False;
2071cdf0e10cSrcweir 	while (!bEnd)
2072cdf0e10cSrcweir 	{
2073cdf0e10cSrcweir 		nAdd = (long) pDoc->GetColWidth(nX1,nTabNo);
2074cdf0e10cSrcweir 		if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL)
2075cdf0e10cSrcweir 		{
2076cdf0e10cSrcweir 			nSize += nAdd;
2077cdf0e10cSrcweir 			++nX1;
2078cdf0e10cSrcweir 		}
2079cdf0e10cSrcweir 		else
2080cdf0e10cSrcweir 			bEnd = sal_True;
2081cdf0e10cSrcweir 	}
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 	nSize = 0;
2084cdf0e10cSrcweir 	nTwips = (long) (rVisAreaStart.Y() / HMM_PER_TWIPS);
2085cdf0e10cSrcweir 	SCROW nY1 = 0;
2086cdf0e10cSrcweir 	bEnd = sal_False;
2087cdf0e10cSrcweir 	while (!bEnd)
2088cdf0e10cSrcweir 	{
2089cdf0e10cSrcweir 		nAdd = (long) pDoc->GetRowHeight(nY1,nTabNo);
2090cdf0e10cSrcweir 		if (nSize+nAdd <= nTwips+1 && nY1<MAXROW)
2091cdf0e10cSrcweir 		{
2092cdf0e10cSrcweir 			nSize += nAdd;
2093cdf0e10cSrcweir 			++nY1;
2094cdf0e10cSrcweir 		}
2095cdf0e10cSrcweir 		else
2096cdf0e10cSrcweir 			bEnd = sal_True;
2097cdf0e10cSrcweir 	}
2098cdf0e10cSrcweir 
2099cdf0e10cSrcweir 	SetActivePart( SC_SPLIT_BOTTOMLEFT );
2100cdf0e10cSrcweir 	SetPosX( SC_SPLIT_LEFT, nX1 );
2101cdf0e10cSrcweir 	SetPosY( SC_SPLIT_BOTTOM, nY1 );
2102cdf0e10cSrcweir 
2103cdf0e10cSrcweir 	SetCurX( nX1 );
2104cdf0e10cSrcweir 	SetCurY( nY1 );
2105cdf0e10cSrcweir }
2106cdf0e10cSrcweir 
SetScreen(const Rectangle & rVisArea)2107cdf0e10cSrcweir void ScViewData::SetScreen( const Rectangle& rVisArea )
2108cdf0e10cSrcweir {
2109cdf0e10cSrcweir 	SetScreenPos( rVisArea.TopLeft() );
2110cdf0e10cSrcweir 
2111cdf0e10cSrcweir 	//	hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir 	aScrSize = rVisArea.GetSize();
2114cdf0e10cSrcweir 	aScrSize.Width() = (long)
2115cdf0e10cSrcweir 		( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS );
2116cdf0e10cSrcweir 	aScrSize.Height() = (long)
2117cdf0e10cSrcweir 		( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS );
2118cdf0e10cSrcweir }
2119cdf0e10cSrcweir 
GetSfxDocShell() const2120cdf0e10cSrcweir SfxObjectShell* ScViewData::GetSfxDocShell() const
2121cdf0e10cSrcweir {
2122cdf0e10cSrcweir 	return pDocShell;
2123cdf0e10cSrcweir }
2124cdf0e10cSrcweir 
GetBindings()2125cdf0e10cSrcweir SfxBindings& ScViewData::GetBindings()
2126cdf0e10cSrcweir {
2127cdf0e10cSrcweir 	DBG_ASSERT( pViewShell, "GetBindings() without ViewShell" );
2128cdf0e10cSrcweir 	return pViewShell->GetViewFrame()->GetBindings();
2129cdf0e10cSrcweir }
2130cdf0e10cSrcweir 
GetDispatcher()2131cdf0e10cSrcweir SfxDispatcher& ScViewData::GetDispatcher()
2132cdf0e10cSrcweir {
2133cdf0e10cSrcweir 	DBG_ASSERT( pViewShell, "GetDispatcher() without ViewShell" );
2134cdf0e10cSrcweir 	return *pViewShell->GetViewFrame()->GetDispatcher();
2135cdf0e10cSrcweir }
2136cdf0e10cSrcweir 
GetDialogParent()2137cdf0e10cSrcweir Window* ScViewData::GetDialogParent()
2138cdf0e10cSrcweir {
2139cdf0e10cSrcweir 	DBG_ASSERT( pViewShell, "GetDialogParent() ohne ViewShell" );
2140cdf0e10cSrcweir 	return pViewShell->GetDialogParent();
2141cdf0e10cSrcweir }
2142cdf0e10cSrcweir 
GetActiveWin()2143cdf0e10cSrcweir Window* ScViewData::GetActiveWin()
2144cdf0e10cSrcweir {
2145cdf0e10cSrcweir 	DBG_ASSERT( pView, "GetActiveWin() ohne View" );
2146cdf0e10cSrcweir 	return pView->GetActiveWin();
2147cdf0e10cSrcweir }
2148cdf0e10cSrcweir 
GetScDrawView()2149cdf0e10cSrcweir ScDrawView* ScViewData::GetScDrawView()
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir 	DBG_ASSERT( pView, "GetScDrawView() ohne View" );
2152cdf0e10cSrcweir 	return pView->GetScDrawView();
2153cdf0e10cSrcweir }
2154cdf0e10cSrcweir 
IsMinimized()2155cdf0e10cSrcweir sal_Bool ScViewData::IsMinimized()
2156cdf0e10cSrcweir {
2157cdf0e10cSrcweir 	DBG_ASSERT( pView, "IsMinimized() ohne View" );
2158cdf0e10cSrcweir 	return pView->IsMinimized();
2159cdf0e10cSrcweir }
2160cdf0e10cSrcweir 
UpdateScreenZoom(const Fraction & rNewX,const Fraction & rNewY)2161cdf0e10cSrcweir void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY )
2162cdf0e10cSrcweir {
2163cdf0e10cSrcweir 	Fraction aOldX = GetZoomX();
2164cdf0e10cSrcweir 	Fraction aOldY = GetZoomY();
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir     SetZoom( rNewX, rNewY, sal_False );
2167cdf0e10cSrcweir 
2168cdf0e10cSrcweir 	Fraction aWidth = GetZoomX();
2169cdf0e10cSrcweir 	aWidth *= Fraction( aScrSize.Width(),1 );
2170cdf0e10cSrcweir 	aWidth /= aOldX;
2171cdf0e10cSrcweir 
2172cdf0e10cSrcweir 	Fraction aHeight = GetZoomY();
2173cdf0e10cSrcweir 	aHeight *= Fraction( aScrSize.Height(),1 );
2174cdf0e10cSrcweir 	aHeight /= aOldY;
2175cdf0e10cSrcweir 
2176cdf0e10cSrcweir 	aScrSize.Width()  = (long) aWidth;
2177cdf0e10cSrcweir 	aScrSize.Height() = (long) aHeight;
2178cdf0e10cSrcweir }
2179cdf0e10cSrcweir 
CalcPPT()2180cdf0e10cSrcweir void ScViewData::CalcPPT()
2181cdf0e10cSrcweir {
2182cdf0e10cSrcweir 	nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX();
2183cdf0e10cSrcweir 	if (pDocShell)
2184cdf0e10cSrcweir 		nPPTX = nPPTX / pDocShell->GetOutputFactor();	// Faktor ist Drucker zu Bildschirm
2185cdf0e10cSrcweir 	nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY();
2186cdf0e10cSrcweir 
2187cdf0e10cSrcweir 	//	#83616# if detective objects are present,
2188cdf0e10cSrcweir 	//	try to adjust horizontal scale so the most common column width has minimal rounding errors,
2189cdf0e10cSrcweir 	//	to avoid differences between cell and drawing layer output
2190cdf0e10cSrcweir 
2191cdf0e10cSrcweir 	if ( pDoc && pDoc->HasDetectiveObjects(nTabNo) )
2192cdf0e10cSrcweir 	{
2193cdf0e10cSrcweir 		SCCOL nEndCol = 0;
2194cdf0e10cSrcweir 		SCROW nDummy = 0;
2195cdf0e10cSrcweir 		pDoc->GetTableArea( nTabNo, nEndCol, nDummy );
2196cdf0e10cSrcweir 		if (nEndCol<20)
2197cdf0e10cSrcweir 			nEndCol = 20;			// same end position as when determining draw scale
2198cdf0e10cSrcweir 
2199cdf0e10cSrcweir 		sal_uInt16 nTwips = pDoc->GetCommonWidth( nEndCol, nTabNo );
2200cdf0e10cSrcweir 		if ( nTwips )
2201cdf0e10cSrcweir 		{
2202cdf0e10cSrcweir 			double fOriginal = nTwips * nPPTX;
2203cdf0e10cSrcweir 			if ( fOriginal < static_cast<double>(nEndCol) )
2204cdf0e10cSrcweir 			{
2205cdf0e10cSrcweir 				//	if one column is smaller than the column count,
2206cdf0e10cSrcweir 				//	rounding errors are likely to add up to a whole column.
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir 				double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 );
2209cdf0e10cSrcweir 				if ( fRounded > 0.0 )
2210cdf0e10cSrcweir 				{
2211cdf0e10cSrcweir 					double fScale = fRounded / fOriginal + 1E-6;
2212cdf0e10cSrcweir 					if ( fScale >= 0.9 && fScale <= 1.1 )
2213cdf0e10cSrcweir 						nPPTX *= fScale;
2214cdf0e10cSrcweir 				}
2215cdf0e10cSrcweir 			}
2216cdf0e10cSrcweir 		}
2217cdf0e10cSrcweir 	}
2218cdf0e10cSrcweir }
2219cdf0e10cSrcweir 
2220cdf0e10cSrcweir //------------------------------------------------------------------
2221cdf0e10cSrcweir 
2222cdf0e10cSrcweir #define SC_OLD_TABSEP	'/'
2223cdf0e10cSrcweir #define SC_NEW_TABSEP	'+'
2224cdf0e10cSrcweir 
WriteUserData(String & rData)2225cdf0e10cSrcweir void ScViewData::WriteUserData(String& rData)
2226cdf0e10cSrcweir {
2227cdf0e10cSrcweir 	//	nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
2228cdf0e10cSrcweir 	//	nTab
2229cdf0e10cSrcweir 	//  Tab-ControlBreite
2230cdf0e10cSrcweir 	//	pro Tabelle:
2231cdf0e10cSrcweir 	//	CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
2232cdf0e10cSrcweir 	//	PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
2233cdf0e10cSrcweir 	//	wenn Zeilen groesser 8192, "+" statt "/"
2234cdf0e10cSrcweir 
2235cdf0e10cSrcweir     sal_uInt16 nZoom = (sal_uInt16)((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
2236cdf0e10cSrcweir 	rData = String::CreateFromInt32( nZoom );
2237cdf0e10cSrcweir 	rData += '/';
2238cdf0e10cSrcweir     nZoom = (sal_uInt16)((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
2239cdf0e10cSrcweir 	rData += String::CreateFromInt32( nZoom );
2240cdf0e10cSrcweir 	rData += '/';
2241cdf0e10cSrcweir 	if (bPagebreak)
2242cdf0e10cSrcweir 		rData += '1';
2243cdf0e10cSrcweir 	else
2244cdf0e10cSrcweir 		rData += '0';
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir 	rData += ';';
2247cdf0e10cSrcweir 	rData += String::CreateFromInt32( nTabNo );
2248cdf0e10cSrcweir 	rData += ';';
2249cdf0e10cSrcweir 	rData.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH ));
2250cdf0e10cSrcweir 	rData += String::CreateFromInt32( pView->GetTabBarWidth() );
2251cdf0e10cSrcweir 
2252cdf0e10cSrcweir 	SCTAB nTabCount = pDoc->GetTableCount();
2253cdf0e10cSrcweir 	for (SCTAB i=0; i<nTabCount; i++)
2254cdf0e10cSrcweir 	{
2255cdf0e10cSrcweir 		rData += ';';					// Numerierung darf auf keinen Fall durcheinanderkommen
2256cdf0e10cSrcweir 		if (pTabData[i])
2257cdf0e10cSrcweir 		{
2258cdf0e10cSrcweir 			sal_Unicode cTabSep = SC_OLD_TABSEP;				// wie 3.1
2259cdf0e10cSrcweir 			if ( pTabData[i]->nCurY > MAXROW_30 ||
2260cdf0e10cSrcweir 				 pTabData[i]->nPosY[0] > MAXROW_30 || pTabData[i]->nPosY[1] > MAXROW_30 ||
2261cdf0e10cSrcweir 				 ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
2262cdf0e10cSrcweir 					pTabData[i]->nFixPosY > MAXROW_30 ) )
2263cdf0e10cSrcweir 			{
2264cdf0e10cSrcweir 				cTabSep = SC_NEW_TABSEP;		// um eine 3.1-Version nicht umzubringen
2265cdf0e10cSrcweir 			}
2266cdf0e10cSrcweir 
2267cdf0e10cSrcweir 
2268cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nCurX );
2269cdf0e10cSrcweir 			rData += cTabSep;
2270cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nCurY );
2271cdf0e10cSrcweir 			rData += cTabSep;
2272cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->eHSplitMode );
2273cdf0e10cSrcweir 			rData += cTabSep;
2274cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->eVSplitMode );
2275cdf0e10cSrcweir 			rData += cTabSep;
2276cdf0e10cSrcweir 			if ( pTabData[i]->eHSplitMode == SC_SPLIT_FIX )
2277cdf0e10cSrcweir 				rData += String::CreateFromInt32( pTabData[i]->nFixPosX );
2278cdf0e10cSrcweir 			else
2279cdf0e10cSrcweir 				rData += String::CreateFromInt32( pTabData[i]->nHSplitPos );
2280cdf0e10cSrcweir 			rData += cTabSep;
2281cdf0e10cSrcweir 			if ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX )
2282cdf0e10cSrcweir 				rData += String::CreateFromInt32( pTabData[i]->nFixPosY );
2283cdf0e10cSrcweir 			else
2284cdf0e10cSrcweir 				rData += String::CreateFromInt32( pTabData[i]->nVSplitPos );
2285cdf0e10cSrcweir 			rData += cTabSep;
2286cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->eWhichActive );
2287cdf0e10cSrcweir 			rData += cTabSep;
2288cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nPosX[0] );
2289cdf0e10cSrcweir 			rData += cTabSep;
2290cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nPosX[1] );
2291cdf0e10cSrcweir 			rData += cTabSep;
2292cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nPosY[0] );
2293cdf0e10cSrcweir 			rData += cTabSep;
2294cdf0e10cSrcweir 			rData += String::CreateFromInt32( pTabData[i]->nPosY[1] );
2295cdf0e10cSrcweir 		}
2296cdf0e10cSrcweir 	}
2297cdf0e10cSrcweir }
2298cdf0e10cSrcweir 
ReadUserData(const String & rData)2299cdf0e10cSrcweir void ScViewData::ReadUserData(const String& rData)
2300cdf0e10cSrcweir {
2301cdf0e10cSrcweir 	if (!rData.Len())		// Leerer String kommt bei "neu Laden"
2302cdf0e10cSrcweir 		return;				// dann auch ohne Assertion beenden
2303cdf0e10cSrcweir 
2304cdf0e10cSrcweir 	xub_StrLen nCount = rData.GetTokenCount(';');
2305cdf0e10cSrcweir 	if ( nCount <= 2 )
2306cdf0e10cSrcweir 	{
2307cdf0e10cSrcweir 		//	#45208# beim Reload in der Seitenansicht sind evtl. die Preview-UserData
2308cdf0e10cSrcweir 		//	stehengelassen worden. Den Zoom von der Preview will man hier nicht...
2309cdf0e10cSrcweir 		DBG_ERROR("ReadUserData: das sind nicht meine Daten");
2310cdf0e10cSrcweir 		return;
2311cdf0e10cSrcweir 	}
2312cdf0e10cSrcweir 
2313cdf0e10cSrcweir 	String aTabOpt;
2314cdf0e10cSrcweir 	xub_StrLen nTagLen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(TAG_TABBARWIDTH)).Len();
2315cdf0e10cSrcweir 
2316cdf0e10cSrcweir 	//-------------------
2317cdf0e10cSrcweir 	// nicht pro Tabelle:
2318cdf0e10cSrcweir 	//-------------------
2319cdf0e10cSrcweir 	SCTAB nTabStart = 2;
2320cdf0e10cSrcweir 
2321cdf0e10cSrcweir     Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY;    //! evaluate (all sheets?)
2322cdf0e10cSrcweir 
2323cdf0e10cSrcweir 	String aZoomStr = rData.GetToken(0);						// Zoom/PageZoom/Modus
2324cdf0e10cSrcweir     sal_uInt16 nNormZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.GetToken(0,'/').ToInt32());
2325cdf0e10cSrcweir 	if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
2326cdf0e10cSrcweir 		aZoomX = aZoomY = Fraction( nNormZoom, 100 );			//	"normaler" Zoom (immer)
2327cdf0e10cSrcweir     sal_uInt16 nPageZoom = sal::static_int_cast<sal_uInt16>(aZoomStr.GetToken(1,'/').ToInt32());
2328cdf0e10cSrcweir 	if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM )
2329cdf0e10cSrcweir 		aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 );	// Pagebreak-Zoom, wenn gesetzt
2330cdf0e10cSrcweir 	sal_Unicode cMode = aZoomStr.GetToken(2,'/').GetChar(0);	// 0 oder "0"/"1"
2331cdf0e10cSrcweir 	SetPagebreakMode( cMode == '1' );
2332cdf0e10cSrcweir 	// SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
2333cdf0e10cSrcweir 
2334cdf0e10cSrcweir 	//
2335cdf0e10cSrcweir 	//	Tabelle kann ungueltig geworden sein (z.B. letzte Version):
2336cdf0e10cSrcweir 	//
2337cdf0e10cSrcweir 	SCTAB nNewTab = static_cast<SCTAB>(rData.GetToken(1).ToInt32());
2338cdf0e10cSrcweir 	if (pDoc->HasTable( nNewTab ))
2339cdf0e10cSrcweir 		SetTabNo(nNewTab);
2340cdf0e10cSrcweir 
2341cdf0e10cSrcweir 	//
2342cdf0e10cSrcweir 	// wenn vorhanden, TabBar-Breite holen:
2343cdf0e10cSrcweir 	//
2344cdf0e10cSrcweir 	aTabOpt = rData.GetToken(2);
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir 	if ( nTagLen && aTabOpt.Copy(0,nTagLen).EqualsAscii(TAG_TABBARWIDTH) )
2347cdf0e10cSrcweir 	{
2348cdf0e10cSrcweir 		pView->SetTabBarWidth( aTabOpt.Copy(nTagLen).ToInt32() );
2349cdf0e10cSrcweir 		nTabStart = 3;
2350cdf0e10cSrcweir 	}
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir 	//-------------
2353cdf0e10cSrcweir 	// pro Tabelle:
2354cdf0e10cSrcweir 	//-------------
2355cdf0e10cSrcweir 	SCTAB nPos = 0;
2356cdf0e10cSrcweir 	while ( nCount > nPos+nTabStart )
2357cdf0e10cSrcweir 	{
2358cdf0e10cSrcweir 		aTabOpt = rData.GetToken(static_cast<xub_StrLen>(nPos+nTabStart));
2359cdf0e10cSrcweir 		if (!pTabData[nPos])
2360cdf0e10cSrcweir 			pTabData[nPos] = new ScViewDataTable;
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir 		sal_Unicode cTabSep = 0;
2363cdf0e10cSrcweir 		if (aTabOpt.GetTokenCount(SC_OLD_TABSEP) >= 11)
2364cdf0e10cSrcweir 			cTabSep = SC_OLD_TABSEP;
2365cdf0e10cSrcweir #ifndef SC_LIMIT_ROWS
2366cdf0e10cSrcweir 		else if (aTabOpt.GetTokenCount(SC_NEW_TABSEP) >= 11)
2367cdf0e10cSrcweir 			cTabSep = SC_NEW_TABSEP;
2368cdf0e10cSrcweir 		// '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
2369cdf0e10cSrcweir #endif
2370cdf0e10cSrcweir 
2371cdf0e10cSrcweir 		if (cTabSep)
2372cdf0e10cSrcweir 		{
2373cdf0e10cSrcweir 			pTabData[nPos]->nCurX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(0,cTabSep).ToInt32()));
2374cdf0e10cSrcweir 			pTabData[nPos]->nCurY = SanitizeRow( aTabOpt.GetToken(1,cTabSep).ToInt32());
2375cdf0e10cSrcweir 			pTabData[nPos]->eHSplitMode = (ScSplitMode) aTabOpt.GetToken(2,cTabSep).ToInt32();
2376cdf0e10cSrcweir 			pTabData[nPos]->eVSplitMode = (ScSplitMode) aTabOpt.GetToken(3,cTabSep).ToInt32();
2377cdf0e10cSrcweir 
2378cdf0e10cSrcweir 			if ( pTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
2379cdf0e10cSrcweir 			{
2380cdf0e10cSrcweir 				pTabData[nPos]->nFixPosX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(4,cTabSep).ToInt32()));
2381cdf0e10cSrcweir 				UpdateFixX(nPos);
2382cdf0e10cSrcweir 			}
2383cdf0e10cSrcweir 			else
2384cdf0e10cSrcweir 				pTabData[nPos]->nHSplitPos = aTabOpt.GetToken(4,cTabSep).ToInt32();
2385cdf0e10cSrcweir 
2386cdf0e10cSrcweir 			if ( pTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
2387cdf0e10cSrcweir 			{
2388cdf0e10cSrcweir 				pTabData[nPos]->nFixPosY = SanitizeRow( aTabOpt.GetToken(5,cTabSep).ToInt32());
2389cdf0e10cSrcweir 				UpdateFixY(nPos);
2390cdf0e10cSrcweir 			}
2391cdf0e10cSrcweir 			else
2392cdf0e10cSrcweir 				pTabData[nPos]->nVSplitPos = aTabOpt.GetToken(5,cTabSep).ToInt32();
2393cdf0e10cSrcweir 
2394cdf0e10cSrcweir 			pTabData[nPos]->eWhichActive = (ScSplitPos) aTabOpt.GetToken(6,cTabSep).ToInt32();
2395cdf0e10cSrcweir 			pTabData[nPos]->nPosX[0] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(7,cTabSep).ToInt32()));
2396cdf0e10cSrcweir 			pTabData[nPos]->nPosX[1] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(8,cTabSep).ToInt32()));
2397cdf0e10cSrcweir 			pTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.GetToken(9,cTabSep).ToInt32());
2398cdf0e10cSrcweir 			pTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.GetToken(10,cTabSep).ToInt32());
2399cdf0e10cSrcweir 
2400cdf0e10cSrcweir 			//	Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
2401cdf0e10cSrcweir 			//	(Bug #44516#)
2402cdf0e10cSrcweir 			ScSplitPos eTest = pTabData[nPos]->eWhichActive;
2403cdf0e10cSrcweir 			if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT &&
2404cdf0e10cSrcweir 					pTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) ||
2405cdf0e10cSrcweir 				 ( WhichV( eTest ) == SC_SPLIT_TOP &&
2406cdf0e10cSrcweir 					pTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) )
2407cdf0e10cSrcweir 			{
2408cdf0e10cSrcweir 				//	dann wieder auf Default (unten links)
2409cdf0e10cSrcweir 				pTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT;
2410cdf0e10cSrcweir 				DBG_ERROR("SplitPos musste korrigiert werden");
2411cdf0e10cSrcweir 			}
2412cdf0e10cSrcweir 		}
2413cdf0e10cSrcweir 		++nPos;
2414cdf0e10cSrcweir 	}
2415cdf0e10cSrcweir 
2416cdf0e10cSrcweir 	RecalcPixPos();
2417cdf0e10cSrcweir }
2418cdf0e10cSrcweir 
WriteExtOptions(ScExtDocOptions & rDocOpt) const2419cdf0e10cSrcweir void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const
2420cdf0e10cSrcweir {
2421cdf0e10cSrcweir     // *** Fill extended document data for export filters ***
2422cdf0e10cSrcweir 
2423cdf0e10cSrcweir 	// document settings
2424cdf0e10cSrcweir     ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
2425cdf0e10cSrcweir 
2426cdf0e10cSrcweir     // displayed sheet
2427cdf0e10cSrcweir     rDocSett.mnDisplTab = GetTabNo();
2428cdf0e10cSrcweir 
2429cdf0e10cSrcweir     // width of the tabbar, relative to frame window width
2430cdf0e10cSrcweir     rDocSett.mfTabBarWidth = pView->GetPendingRelTabBarWidth();
2431cdf0e10cSrcweir     if( rDocSett.mfTabBarWidth < 0.0 )
2432cdf0e10cSrcweir         rDocSett.mfTabBarWidth = pView->GetRelTabBarWidth();
2433cdf0e10cSrcweir 
2434cdf0e10cSrcweir     // sheet settings
2435cdf0e10cSrcweir     for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
2436cdf0e10cSrcweir 	{
2437cdf0e10cSrcweir         if( const ScViewDataTable* pViewTab = pTabData[ nTab ] )
2438cdf0e10cSrcweir 		{
2439cdf0e10cSrcweir             ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab );
2440cdf0e10cSrcweir 
2441cdf0e10cSrcweir             // split mode
2442cdf0e10cSrcweir             ScSplitMode eHSplit = pViewTab->eHSplitMode;
2443cdf0e10cSrcweir             ScSplitMode eVSplit = pViewTab->eVSplitMode;
2444cdf0e10cSrcweir             bool bHSplit = eHSplit != SC_SPLIT_NONE;
2445cdf0e10cSrcweir             bool bVSplit = eVSplit != SC_SPLIT_NONE;
2446cdf0e10cSrcweir             bool bRealSplit = (eHSplit == SC_SPLIT_NORMAL) || (eVSplit == SC_SPLIT_NORMAL);
2447cdf0e10cSrcweir             bool bFrozen    = (eHSplit == SC_SPLIT_FIX)    || (eVSplit == SC_SPLIT_FIX);
2448cdf0e10cSrcweir             DBG_ASSERT( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
2449cdf0e10cSrcweir             rTabSett.mbFrozenPanes = !bRealSplit && bFrozen;
2450cdf0e10cSrcweir 
2451cdf0e10cSrcweir             // split and freeze position
2452cdf0e10cSrcweir             rTabSett.maSplitPos = Point( 0, 0 );
2453cdf0e10cSrcweir             rTabSett.maFreezePos.Set( 0, 0, nTab );
2454cdf0e10cSrcweir             if( bRealSplit )
2455cdf0e10cSrcweir 			{
2456cdf0e10cSrcweir                 Point& rSplitPos = rTabSett.maSplitPos;
2457cdf0e10cSrcweir                 rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 );
2458cdf0e10cSrcweir                 rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MAP_TWIP ) );
2459cdf0e10cSrcweir                 if( pDocShell )
2460cdf0e10cSrcweir                     rSplitPos.X() = (long)((double)rSplitPos.X() / pDocShell->GetOutputFactor());
2461cdf0e10cSrcweir 			}
2462cdf0e10cSrcweir             else if( bFrozen )
2463cdf0e10cSrcweir 			{
2464cdf0e10cSrcweir                 if( bHSplit ) rTabSett.maFreezePos.SetCol( pViewTab->nFixPosX );
2465cdf0e10cSrcweir                 if( bVSplit ) rTabSett.maFreezePos.SetRow( pViewTab->nFixPosY );
2466cdf0e10cSrcweir 			}
2467cdf0e10cSrcweir 
2468cdf0e10cSrcweir             // first visible cell in top-left and additional panes
2469cdf0e10cSrcweir             rTabSett.maFirstVis.Set( pViewTab->nPosX[ SC_SPLIT_LEFT ], pViewTab->nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ], nTab );
2470cdf0e10cSrcweir             rTabSett.maSecondVis.Set( pViewTab->nPosX[ SC_SPLIT_RIGHT ], pViewTab->nPosY[ SC_SPLIT_BOTTOM ], nTab );
2471cdf0e10cSrcweir 
2472cdf0e10cSrcweir             // active pane
2473cdf0e10cSrcweir 			switch( pViewTab->eWhichActive )
2474cdf0e10cSrcweir 			{
2475cdf0e10cSrcweir                 // no horizontal split -> always use left panes
2476cdf0e10cSrcweir                 // no vertical split -> always use top panes
2477cdf0e10cSrcweir                 case SC_SPLIT_TOPLEFT:
2478cdf0e10cSrcweir                     rTabSett.meActivePane = SCEXT_PANE_TOPLEFT;
2479cdf0e10cSrcweir                 break;
2480cdf0e10cSrcweir                 case SC_SPLIT_TOPRIGHT:
2481cdf0e10cSrcweir                     rTabSett.meActivePane = bHSplit ? SCEXT_PANE_TOPRIGHT : SCEXT_PANE_TOPLEFT;
2482cdf0e10cSrcweir                 break;
2483cdf0e10cSrcweir                 case SC_SPLIT_BOTTOMLEFT:
2484cdf0e10cSrcweir                     rTabSett.meActivePane = bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT;
2485cdf0e10cSrcweir                 break;
2486cdf0e10cSrcweir                 case SC_SPLIT_BOTTOMRIGHT:
2487cdf0e10cSrcweir                     rTabSett.meActivePane = bHSplit ?
2488cdf0e10cSrcweir                         (bVSplit ? SCEXT_PANE_BOTTOMRIGHT : SCEXT_PANE_TOPRIGHT) :
2489cdf0e10cSrcweir                         (bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT);
2490cdf0e10cSrcweir                 break;
2491cdf0e10cSrcweir 			}
2492cdf0e10cSrcweir 
2493cdf0e10cSrcweir             // cursor position
2494cdf0e10cSrcweir             rTabSett.maCursor.Set( pViewTab->nCurX, pViewTab->nCurY, nTab );
2495cdf0e10cSrcweir 
2496cdf0e10cSrcweir             // sheet selection and selected ranges
2497cdf0e10cSrcweir             const ScMarkData& rMarkData = GetMarkData();
2498cdf0e10cSrcweir             rTabSett.mbSelected = rMarkData.GetTableSelect( nTab );
2499cdf0e10cSrcweir             rMarkData.FillRangeListWithMarks( &rTabSett.maSelection, sal_True );
2500cdf0e10cSrcweir 
2501cdf0e10cSrcweir             // grid color
2502cdf0e10cSrcweir             rTabSett.maGridColor.SetColor( COL_AUTO );
2503cdf0e10cSrcweir             if( pOptions )
2504cdf0e10cSrcweir             {
2505cdf0e10cSrcweir                 const Color& rGridColor = pOptions->GetGridColor();
2506cdf0e10cSrcweir                 if( rGridColor.GetColor() != SC_STD_GRIDCOLOR )
2507cdf0e10cSrcweir                     rTabSett.maGridColor = rGridColor;
2508cdf0e10cSrcweir             }
2509cdf0e10cSrcweir 
2510cdf0e10cSrcweir             // view mode and zoom
2511cdf0e10cSrcweir             rTabSett.mbPageMode = bPagebreak;
2512cdf0e10cSrcweir             rTabSett.mnNormalZoom = static_cast< long >( pViewTab->aZoomY * Fraction( 100.0 ) );
2513cdf0e10cSrcweir             rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) );
2514cdf0e10cSrcweir 		}
2515cdf0e10cSrcweir 	}
2516cdf0e10cSrcweir }
2517cdf0e10cSrcweir 
ReadExtOptions(const ScExtDocOptions & rDocOpt)2518cdf0e10cSrcweir void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
2519cdf0e10cSrcweir {
2520cdf0e10cSrcweir     // *** Get extended document data from import filters ***
2521cdf0e10cSrcweir 
2522cdf0e10cSrcweir     if( !rDocOpt.IsChanged() ) return;
2523cdf0e10cSrcweir 
2524cdf0e10cSrcweir     // document settings
2525cdf0e10cSrcweir     const ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
2526cdf0e10cSrcweir 
2527cdf0e10cSrcweir     // displayed sheet
2528cdf0e10cSrcweir     SetTabNo( rDocSett.mnDisplTab );
2529cdf0e10cSrcweir 
2530cdf0e10cSrcweir     /*  Width of the tabbar, relative to frame window width. We do not have the
2531cdf0e10cSrcweir         correct width of the frame window here -> store in ScTabView, which sets
2532cdf0e10cSrcweir         the size in the next resize. */
2533cdf0e10cSrcweir     pView->SetPendingRelTabBarWidth( rDocSett.mfTabBarWidth );
2534cdf0e10cSrcweir 
2535cdf0e10cSrcweir     // sheet settings
2536cdf0e10cSrcweir     for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
2537cdf0e10cSrcweir 	{
2538cdf0e10cSrcweir         if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
2539cdf0e10cSrcweir 		{
2540cdf0e10cSrcweir             if( !pTabData[ nTab ] )
2541cdf0e10cSrcweir                 pTabData[ nTab ] = new ScViewDataTable;
2542cdf0e10cSrcweir 
2543cdf0e10cSrcweir             const ScExtTabSettings& rTabSett = *pTabSett;
2544cdf0e10cSrcweir             ScViewDataTable& rViewTab = *pTabData[ nTab ];
2545cdf0e10cSrcweir 
2546cdf0e10cSrcweir             // split mode initialization
2547cdf0e10cSrcweir             bool bFrozen = rTabSett.mbFrozenPanes;
2548cdf0e10cSrcweir             bool bHSplit = bFrozen ? (rTabSett.maFreezePos.Col() > 0) : (rTabSett.maSplitPos.X() > 0);
2549cdf0e10cSrcweir             bool bVSplit = bFrozen ? (rTabSett.maFreezePos.Row() > 0) : (rTabSett.maSplitPos.Y() > 0);
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir             // first visible cell of top-left pane and additional panes
2552cdf0e10cSrcweir             rViewTab.nPosX[ SC_SPLIT_LEFT ] = rTabSett.maFirstVis.Col();
2553cdf0e10cSrcweir             rViewTab.nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ] = rTabSett.maFirstVis.Row();
2554cdf0e10cSrcweir             if( bHSplit ) rViewTab.nPosX[ SC_SPLIT_RIGHT ] = rTabSett.maSecondVis.Col();
2555cdf0e10cSrcweir             if( bVSplit ) rViewTab.nPosY[ SC_SPLIT_BOTTOM ] = rTabSett.maSecondVis.Row();
2556cdf0e10cSrcweir 
2557cdf0e10cSrcweir             // split mode, split and freeze position
2558cdf0e10cSrcweir             rViewTab.eHSplitMode = rViewTab.eVSplitMode = SC_SPLIT_NONE;
2559cdf0e10cSrcweir             rViewTab.nHSplitPos = rViewTab.nVSplitPos = 0;
2560cdf0e10cSrcweir             rViewTab.nFixPosX = 0;
2561cdf0e10cSrcweir             rViewTab.nFixPosY = 0;
2562cdf0e10cSrcweir             if( bFrozen )
2563cdf0e10cSrcweir             {
2564cdf0e10cSrcweir                 if( bHSplit )
2565cdf0e10cSrcweir                 {
2566cdf0e10cSrcweir                     rViewTab.eHSplitMode = SC_SPLIT_FIX;
2567cdf0e10cSrcweir                     rViewTab.nFixPosX = rTabSett.maFreezePos.Col();
2568cdf0e10cSrcweir                     UpdateFixX( nTab );
2569cdf0e10cSrcweir                 }
2570cdf0e10cSrcweir                 if( bVSplit )
2571cdf0e10cSrcweir                 {
2572cdf0e10cSrcweir                     rViewTab.eVSplitMode = SC_SPLIT_FIX;
2573cdf0e10cSrcweir                     rViewTab.nFixPosY = rTabSett.maFreezePos.Row();
2574cdf0e10cSrcweir                     UpdateFixY( nTab );
2575cdf0e10cSrcweir                 }
2576cdf0e10cSrcweir             }
2577cdf0e10cSrcweir             else
2578cdf0e10cSrcweir             {
2579cdf0e10cSrcweir                 Point aPixel = Application::GetDefaultDevice()->LogicToPixel(
2580cdf0e10cSrcweir                                 rTabSett.maSplitPos, MapMode( MAP_TWIP ) );  //! Zoom?
2581cdf0e10cSrcweir                 // #109648# - the test for use of printer metrics for text formatting here
2582cdf0e10cSrcweir                 // effectively results in the nFactor = 1.0 regardless of the Option setting.
2583cdf0e10cSrcweir                 if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg())
2584cdf0e10cSrcweir                 {
2585cdf0e10cSrcweir                     double nFactor = pDocShell->GetOutputFactor();
2586cdf0e10cSrcweir                     aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 );
2587cdf0e10cSrcweir                 }
25884f32937cSAndre Fischer 
25894f32937cSAndre Fischer                 bHSplit = bHSplit && aPixel.X() > 0;
25904f32937cSAndre Fischer                 bVSplit = bVSplit && aPixel.Y() > 0;
2591cdf0e10cSrcweir                 if( bHSplit )
2592cdf0e10cSrcweir                 {
2593cdf0e10cSrcweir                     rViewTab.eHSplitMode = SC_SPLIT_NORMAL;
2594cdf0e10cSrcweir                     rViewTab.nHSplitPos = aPixel.X();
2595cdf0e10cSrcweir                 }
2596cdf0e10cSrcweir                 if( bVSplit )
2597cdf0e10cSrcweir                 {
2598cdf0e10cSrcweir                     rViewTab.eVSplitMode = SC_SPLIT_NORMAL;
2599cdf0e10cSrcweir                     rViewTab.nVSplitPos = aPixel.Y();
2600cdf0e10cSrcweir                 }
2601cdf0e10cSrcweir             }
2602cdf0e10cSrcweir 
2603cdf0e10cSrcweir             // active pane
2604cdf0e10cSrcweir             ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
2605cdf0e10cSrcweir             switch( rTabSett.meActivePane )
2606cdf0e10cSrcweir             {
2607cdf0e10cSrcweir                 // no horizontal split -> always use left panes
2608cdf0e10cSrcweir                 // no vertical split -> always use *bottom* panes
2609cdf0e10cSrcweir                 case SCEXT_PANE_TOPLEFT:
2610cdf0e10cSrcweir                     ePos = bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
2611cdf0e10cSrcweir                 break;
2612cdf0e10cSrcweir                 case SCEXT_PANE_TOPRIGHT:
2613cdf0e10cSrcweir                     ePos = bHSplit ?
2614cdf0e10cSrcweir                         (bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT) :
2615cdf0e10cSrcweir                         (bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT);
2616cdf0e10cSrcweir                 break;
2617cdf0e10cSrcweir                 case SCEXT_PANE_BOTTOMLEFT:
2618cdf0e10cSrcweir                     ePos = SC_SPLIT_BOTTOMLEFT;
2619cdf0e10cSrcweir                 break;
2620cdf0e10cSrcweir                 case SCEXT_PANE_BOTTOMRIGHT:
2621cdf0e10cSrcweir                     ePos = bHSplit ? SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_BOTTOMLEFT;
2622cdf0e10cSrcweir                 break;
2623cdf0e10cSrcweir             }
2624cdf0e10cSrcweir             rViewTab.eWhichActive = ePos;
2625cdf0e10cSrcweir 
2626cdf0e10cSrcweir             // cursor position
2627cdf0e10cSrcweir             const ScAddress& rCursor = rTabSett.maCursor;
2628cdf0e10cSrcweir             if( rCursor.IsValid() )
2629cdf0e10cSrcweir             {
2630cdf0e10cSrcweir                 rViewTab.nCurX = rCursor.Col();
2631cdf0e10cSrcweir                 rViewTab.nCurY = rCursor.Row();
2632cdf0e10cSrcweir             }
2633cdf0e10cSrcweir 
2634cdf0e10cSrcweir             // sheet selection and selected ranges
2635cdf0e10cSrcweir             ScMarkData& rMarkData = GetMarkData();
2636cdf0e10cSrcweir             rMarkData.SelectTable( nTab, rTabSett.mbSelected );
2637cdf0e10cSrcweir 
2638cdf0e10cSrcweir             // zoom for each sheet
2639cdf0e10cSrcweir             if( rTabSett.mnNormalZoom )
2640cdf0e10cSrcweir                 rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
2641cdf0e10cSrcweir             if( rTabSett.mnPageZoom )
2642cdf0e10cSrcweir                 rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
2643cdf0e10cSrcweir 
2644cdf0e10cSrcweir             // get some settings from displayed Excel sheet, set at Calc document
2645cdf0e10cSrcweir             if( nTab == GetTabNo() )
2646cdf0e10cSrcweir             {
2647cdf0e10cSrcweir                 // selection only for displayed sheet, do not select single cell
2648cdf0e10cSrcweir // Disabled, does not work correctly. Anyway, our own XML filters do not import a selection at all.
2649cdf0e10cSrcweir //                const ScRangeList& rSel = rTabSett.maSelection;
2650cdf0e10cSrcweir //                if( (rSel.Count() >= 2) || ((rSel.Count() == 1) && (*rSel.GetObject( 0 ) != ScRange( rCursor ))) )
2651cdf0e10cSrcweir //                    rMarkData.MarkFromRangeList( rTabSett.maSelection, sal_False );
2652cdf0e10cSrcweir 
2653cdf0e10cSrcweir                 // grid color -- #i47435# set automatic grid color explicitly
2654cdf0e10cSrcweir                 if( pOptions )
2655cdf0e10cSrcweir                 {
2656cdf0e10cSrcweir                     Color aGridColor( rTabSett.maGridColor );
2657cdf0e10cSrcweir                     if( aGridColor.GetColor() == COL_AUTO )
2658cdf0e10cSrcweir                         aGridColor.SetColor( SC_STD_GRIDCOLOR );
2659cdf0e10cSrcweir                     pOptions->SetGridColor( aGridColor, EMPTY_STRING );
2660cdf0e10cSrcweir                 }
2661cdf0e10cSrcweir 
2662cdf0e10cSrcweir                 // view mode and default zoom (for new sheets) from current sheet
2663cdf0e10cSrcweir                 if( rTabSett.mnNormalZoom )
2664cdf0e10cSrcweir                     aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
2665cdf0e10cSrcweir                 if( rTabSett.mnPageZoom )
2666cdf0e10cSrcweir                     aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
2667cdf0e10cSrcweir                 /*  #i46820# set pagebreak mode via SetPagebreakMode(), this will
2668cdf0e10cSrcweir                     update map modes that are needed to draw text correctly. */
2669cdf0e10cSrcweir                 SetPagebreakMode( rTabSett.mbPageMode );
2670cdf0e10cSrcweir             }
2671cdf0e10cSrcweir 		}
2672cdf0e10cSrcweir 	}
2673cdf0e10cSrcweir 
2674cdf0e10cSrcweir 	// RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
2675cdf0e10cSrcweir }
2676cdf0e10cSrcweir 
WriteUserDataSequence(uno::Sequence<beans::PropertyValue> & rSettings)2677cdf0e10cSrcweir void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings)
2678cdf0e10cSrcweir {
2679cdf0e10cSrcweir 	rSettings.realloc(SC_VIEWSETTINGS_COUNT);
2680cdf0e10cSrcweir 	// + 1, because we have to put the view id in the sequence
2681cdf0e10cSrcweir 	beans::PropertyValue* pSettings = rSettings.getArray();
2682cdf0e10cSrcweir 	if (pSettings)
2683cdf0e10cSrcweir 	{
2684cdf0e10cSrcweir 		sal_uInt16 nViewID(pViewShell->GetViewFrame()->GetCurViewId());
2685cdf0e10cSrcweir 		pSettings[SC_VIEW_ID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
2686cdf0e10cSrcweir 		rtl::OUStringBuffer sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
2687cdf0e10cSrcweir 		SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
2688cdf0e10cSrcweir 		pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear();
2689cdf0e10cSrcweir 
2690cdf0e10cSrcweir 		SCTAB nTabCount (pDoc->GetTableCount());
2691cdf0e10cSrcweir 		uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
2692cdf0e10cSrcweir 										comphelper::getProcessServiceFactory();
2693cdf0e10cSrcweir 		DBG_ASSERT( xServiceFactory.is(), "got no service manager" );
2694cdf0e10cSrcweir 		if( xServiceFactory.is() )
2695cdf0e10cSrcweir 		{
2696cdf0e10cSrcweir 			rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues"));
2697cdf0e10cSrcweir 			uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY);
2698cdf0e10cSrcweir 			if (xNameContainer.is())
2699cdf0e10cSrcweir 			{
2700cdf0e10cSrcweir 				for (SCTAB nTab=0; nTab<nTabCount; nTab++)
2701cdf0e10cSrcweir 				{
2702cdf0e10cSrcweir 					if (pTabData[nTab])
2703cdf0e10cSrcweir 					{
2704cdf0e10cSrcweir 						uno::Sequence <beans::PropertyValue> aTableViewSettings;
2705cdf0e10cSrcweir                         pTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab);
2706cdf0e10cSrcweir 						String sTabName;
2707cdf0e10cSrcweir 						GetDocument()->GetName( nTab, sTabName );
2708cdf0e10cSrcweir 						rtl::OUString sOUName(sTabName);
2709cdf0e10cSrcweir 						uno::Any aAny;
2710cdf0e10cSrcweir 						aAny <<= aTableViewSettings;
2711cdf0e10cSrcweir                         try
2712cdf0e10cSrcweir                         {
2713cdf0e10cSrcweir 						    xNameContainer->insertByName(sTabName, aAny);
2714cdf0e10cSrcweir                         }
2715cdf0e10cSrcweir                         //#101739#; two tables with the same name are possible
2716cdf0e10cSrcweir                         catch ( container::ElementExistException& )
2717cdf0e10cSrcweir                         {
2718cdf0e10cSrcweir                             DBG_ERRORFILE("seems there are two tables with the same name");
2719cdf0e10cSrcweir                         }
2720cdf0e10cSrcweir                         catch ( uno::RuntimeException& )
2721cdf0e10cSrcweir                         {
2722cdf0e10cSrcweir                             DBG_ERRORFILE("something went wrong");
2723cdf0e10cSrcweir                         }
2724cdf0e10cSrcweir 					}
2725cdf0e10cSrcweir 				}
2726cdf0e10cSrcweir 				pSettings[SC_TABLE_VIEWSETTINGS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES));
2727cdf0e10cSrcweir 				pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
2728cdf0e10cSrcweir 			}
2729cdf0e10cSrcweir 		}
2730cdf0e10cSrcweir 
2731cdf0e10cSrcweir 		String sName;
2732cdf0e10cSrcweir 		GetDocument()->GetName( nTabNo, sName );
2733cdf0e10cSrcweir 		rtl::OUString sOUName(sName);
2734cdf0e10cSrcweir 		pSettings[SC_ACTIVE_TABLE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
2735cdf0e10cSrcweir 		pSettings[SC_ACTIVE_TABLE].Value <<= sOUName;
2736cdf0e10cSrcweir 		pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSCROLLBARWIDTH));
2737cdf0e10cSrcweir 		pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth());
2738cdf0e10cSrcweir         sal_Int32 nZoomValue ((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
2739cdf0e10cSrcweir         sal_Int32 nPageZoomValue ((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
2740cdf0e10cSrcweir 		pSettings[SC_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
2741cdf0e10cSrcweir 		pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType);
2742cdf0e10cSrcweir 		pSettings[SC_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
2743cdf0e10cSrcweir 		pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
2744cdf0e10cSrcweir 		pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
2745cdf0e10cSrcweir 		pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
2746cdf0e10cSrcweir 		pSettings[SC_PAGE_BREAK_PREVIEW].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SHOWPAGEBREAKPREVIEW));
2747cdf0e10cSrcweir 		ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_PAGE_BREAK_PREVIEW].Value, bPagebreak);
2748cdf0e10cSrcweir 
2749cdf0e10cSrcweir 		if (pOptions)
2750cdf0e10cSrcweir 		{
2751cdf0e10cSrcweir 			pSettings[SC_SHOWZERO].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWZERO));
2752cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWZERO].Value, pOptions->GetOption( VOPT_NULLVALS ) );
2753cdf0e10cSrcweir 			pSettings[SC_SHOWNOTES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWNOTES));
2754cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWNOTES].Value, pOptions->GetOption( VOPT_NOTES ) );
2755cdf0e10cSrcweir 			pSettings[SC_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
2756cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWGRID].Value, pOptions->GetOption( VOPT_GRID ) );
2757cdf0e10cSrcweir 			pSettings[SC_GRIDCOLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_GRIDCOLOR));
2758cdf0e10cSrcweir 			String aColorName;
2759cdf0e10cSrcweir 			Color aColor = pOptions->GetGridColor(&aColorName);
2760cdf0e10cSrcweir 			pSettings[SC_GRIDCOLOR].Value <<= static_cast<sal_Int64>(aColor.GetColor());
2761cdf0e10cSrcweir 			pSettings[SC_SHOWPAGEBR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWPAGEBR));
2762cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWPAGEBR].Value, pOptions->GetOption( VOPT_PAGEBREAKS ) );
2763cdf0e10cSrcweir 			pSettings[SC_COLROWHDR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COLROWHDR));
2764cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_COLROWHDR].Value, pOptions->GetOption( VOPT_HEADER ) );
2765cdf0e10cSrcweir 			pSettings[SC_SHEETTABS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETTABS));
2766cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHEETTABS].Value, pOptions->GetOption( VOPT_TABCONTROLS ) );
2767cdf0e10cSrcweir 			pSettings[SC_OUTLSYMB].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_OUTLSYMB));
2768cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_OUTLSYMB].Value, pOptions->GetOption( VOPT_OUTLINER ) );
2769b7caab40STsutomu Uchino 			pSettings[SC_VALUE_HIGHLIGHTING].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VALUEHIGH ) );
2770b7caab40STsutomu Uchino 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_VALUE_HIGHLIGHTING].Value, pOptions->GetOption( VOPT_SYNTAX ) );
2771cdf0e10cSrcweir 
2772cdf0e10cSrcweir 			const ScGridOptions& aGridOpt = pOptions->GetGridOptions();
2773cdf0e10cSrcweir 			pSettings[SC_SNAPTORASTER].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SNAPTORASTER));
2774cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SNAPTORASTER].Value, aGridOpt.GetUseGridSnap() );
2775cdf0e10cSrcweir 			pSettings[SC_RASTERVIS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERVIS));
2776cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERVIS].Value, aGridOpt.GetGridVisible() );
2777cdf0e10cSrcweir 			pSettings[SC_RASTERRESX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESX));
2778cdf0e10cSrcweir 			pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
2779cdf0e10cSrcweir 			pSettings[SC_RASTERRESY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESY));
2780cdf0e10cSrcweir 			pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
2781cdf0e10cSrcweir 			pSettings[SC_RASTERSUBX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBX));
2782cdf0e10cSrcweir 			pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
2783cdf0e10cSrcweir 			pSettings[SC_RASTERSUBY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBY));
2784cdf0e10cSrcweir 			pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
2785cdf0e10cSrcweir 			pSettings[SC_RASTERSYNC].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSYNC));
2786cdf0e10cSrcweir 			ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERSYNC].Value, aGridOpt.GetSynchronize() );
2787cdf0e10cSrcweir 		}
2788cdf0e10cSrcweir 	}
2789cdf0e10cSrcweir }
2790cdf0e10cSrcweir 
ReadUserDataSequence(const uno::Sequence<beans::PropertyValue> & rSettings)2791cdf0e10cSrcweir void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
2792cdf0e10cSrcweir {
2793cdf0e10cSrcweir     Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY;    //! evaluate (all sheets?)
2794cdf0e10cSrcweir 
2795cdf0e10cSrcweir     std::vector<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
2796cdf0e10cSrcweir 
2797cdf0e10cSrcweir 	sal_Int32 nCount(rSettings.getLength());
2798cdf0e10cSrcweir 	sal_Int32 nTemp32(0);
2799cdf0e10cSrcweir 	sal_Int16 nTemp16(0);
2800cdf0e10cSrcweir 	sal_Bool bPageMode(sal_False);
2801cdf0e10cSrcweir 	for (sal_Int32 i = 0; i < nCount; i++)
2802cdf0e10cSrcweir 	{
2803cdf0e10cSrcweir 		// SC_VIEWID has to parse and use by mba
2804cdf0e10cSrcweir 		rtl::OUString sName(rSettings[i].Name);
2805cdf0e10cSrcweir 		if (sName.compareToAscii(SC_TABLES) == 0)
2806cdf0e10cSrcweir 		{
2807cdf0e10cSrcweir 			uno::Reference<container::XNameContainer> xNameContainer;
2808cdf0e10cSrcweir 			if ((rSettings[i].Value >>= xNameContainer) && xNameContainer->hasElements())
2809cdf0e10cSrcweir 			{
2810cdf0e10cSrcweir 				uno::Sequence< rtl::OUString > aNames(xNameContainer->getElementNames());
2811cdf0e10cSrcweir 				for (sal_Int32 nTabPos = 0; nTabPos < aNames.getLength(); nTabPos++)
2812cdf0e10cSrcweir 				{
2813cdf0e10cSrcweir 					String sTabName(aNames[nTabPos]);
2814cdf0e10cSrcweir 					SCTAB nTab(0);
2815cdf0e10cSrcweir 					if (GetDocument()->GetTable(sTabName, nTab))
2816cdf0e10cSrcweir 					{
2817cdf0e10cSrcweir 						uno::Any aAny = xNameContainer->getByName(aNames[nTabPos]);
2818cdf0e10cSrcweir 						uno::Sequence<beans::PropertyValue> aTabSettings;
2819cdf0e10cSrcweir 						if (aAny >>= aTabSettings)
2820cdf0e10cSrcweir 						{
282111daf541SHerbert Dürr 							delete pTabData[nTab];
2822cdf0e10cSrcweir 							pTabData[nTab] = new ScViewDataTable;
2823cdf0e10cSrcweir                             bool bHasZoom = false;
2824cdf0e10cSrcweir                             pTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom);
2825cdf0e10cSrcweir                             aHasZoomVect[nTab] = bHasZoom;
2826cdf0e10cSrcweir 						}
2827cdf0e10cSrcweir 					}
2828cdf0e10cSrcweir 				}
2829cdf0e10cSrcweir 			}
2830cdf0e10cSrcweir 		}
2831cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_ACTIVETABLE) == 0)
2832cdf0e10cSrcweir 		{
2833cdf0e10cSrcweir 			rtl::OUString sValue;
2834cdf0e10cSrcweir 			if(rSettings[i].Value >>= sValue)
2835cdf0e10cSrcweir 			{
2836cdf0e10cSrcweir 				String sTabName(sValue);
2837cdf0e10cSrcweir 				SCTAB nTab(0);
2838cdf0e10cSrcweir 				if (GetDocument()->GetTable(sTabName, nTab))
2839cdf0e10cSrcweir 					nTabNo = nTab;
2840cdf0e10cSrcweir 			}
2841cdf0e10cSrcweir 		}
2842cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_HORIZONTALSCROLLBARWIDTH) == 0)
2843cdf0e10cSrcweir 		{
2844cdf0e10cSrcweir 			if (rSettings[i].Value >>= nTemp32)
2845cdf0e10cSrcweir 				pView->SetTabBarWidth(nTemp32);
2846cdf0e10cSrcweir 		}
2847cdf0e10cSrcweir         else if (sName.compareToAscii(SC_RELHORIZONTALTABBARWIDTH) == 0)
2848cdf0e10cSrcweir         {
2849cdf0e10cSrcweir             double fWidth = 0.0;
2850cdf0e10cSrcweir             if (rSettings[i].Value >>= fWidth)
2851cdf0e10cSrcweir                 pView->SetPendingRelTabBarWidth( fWidth );
2852cdf0e10cSrcweir         }
2853cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
2854cdf0e10cSrcweir 		{
2855cdf0e10cSrcweir 			if (rSettings[i].Value >>= nTemp16)
2856cdf0e10cSrcweir                 eDefZoomType = SvxZoomType(nTemp16);
2857cdf0e10cSrcweir 		}
2858cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
2859cdf0e10cSrcweir 		{
2860cdf0e10cSrcweir 			if (rSettings[i].Value >>= nTemp32)
2861cdf0e10cSrcweir 			{
2862cdf0e10cSrcweir 				Fraction aZoom(nTemp32, 100);
2863cdf0e10cSrcweir                 aDefZoomX = aDefZoomY = aZoom;
2864cdf0e10cSrcweir 			}
2865cdf0e10cSrcweir 		}
2866cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
2867cdf0e10cSrcweir 		{
2868cdf0e10cSrcweir 			if (rSettings[i].Value >>= nTemp32)
2869cdf0e10cSrcweir 			{
2870cdf0e10cSrcweir 				Fraction aZoom(nTemp32, 100);
2871cdf0e10cSrcweir                 aDefPageZoomX = aDefPageZoomY = aZoom;
2872cdf0e10cSrcweir 			}
2873cdf0e10cSrcweir 		}
2874cdf0e10cSrcweir 		else if (sName.compareToAscii(SC_SHOWPAGEBREAKPREVIEW) == 0)
2875cdf0e10cSrcweir 			bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value );
2876cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
2877cdf0e10cSrcweir 			pOptions->SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2878cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
2879cdf0e10cSrcweir 			pOptions->SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2880cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
2881cdf0e10cSrcweir 			pOptions->SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2882cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
2883cdf0e10cSrcweir 		{
2884cdf0e10cSrcweir 			sal_Int64 nColor = 0;
2885cdf0e10cSrcweir 			if (rSettings[i].Value >>= nColor)
2886cdf0e10cSrcweir 			{
2887cdf0e10cSrcweir 				String aColorName;
2888cdf0e10cSrcweir 				Color aColor(static_cast<sal_uInt32>(nColor));
2889cdf0e10cSrcweir                 // #i47435# set automatic grid color explicitly
2890cdf0e10cSrcweir                 if( aColor.GetColor() == COL_AUTO )
2891cdf0e10cSrcweir                     aColor.SetColor( SC_STD_GRIDCOLOR );
2892cdf0e10cSrcweir 				pOptions->SetGridColor(aColor, aColorName);
2893cdf0e10cSrcweir 			}
2894cdf0e10cSrcweir 		}
2895cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
2896cdf0e10cSrcweir 			pOptions->SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2897cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
2898cdf0e10cSrcweir 			pOptions->SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2899cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
2900cdf0e10cSrcweir 			pOptions->SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2901cdf0e10cSrcweir 		else if ( sName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
2902cdf0e10cSrcweir 			pOptions->SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2903cdf0e10cSrcweir         else if ( sName.compareToAscii( SC_UNO_SHOWOBJ ) == 0 )
2904cdf0e10cSrcweir         {
2905cdf0e10cSrcweir             // #i80528# placeholders not supported anymore
2906cdf0e10cSrcweir             if ( rSettings[i].Value >>= nTemp16 )
2907cdf0e10cSrcweir                 pOptions->SetObjMode( VOBJ_TYPE_OLE, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
2908cdf0e10cSrcweir         }
2909cdf0e10cSrcweir         else if ( sName.compareToAscii( SC_UNO_SHOWCHARTS ) == 0 )
2910cdf0e10cSrcweir         {
2911cdf0e10cSrcweir             // #i80528# placeholders not supported anymore
2912cdf0e10cSrcweir             if ( rSettings[i].Value >>= nTemp16 )
2913cdf0e10cSrcweir                 pOptions->SetObjMode( VOBJ_TYPE_CHART, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
2914cdf0e10cSrcweir         }
2915cdf0e10cSrcweir         else if ( sName.compareToAscii( SC_UNO_SHOWDRAW ) == 0 )
2916cdf0e10cSrcweir         {
2917cdf0e10cSrcweir             // #i80528# placeholders not supported anymore
2918cdf0e10cSrcweir             if ( rSettings[i].Value >>= nTemp16 )
2919cdf0e10cSrcweir                 pOptions->SetObjMode( VOBJ_TYPE_DRAW, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
2920cdf0e10cSrcweir         }
2921b7caab40STsutomu Uchino         else if ( sName.compareToAscii( SC_UNO_VALUEHIGH ) == 0 )
2922b7caab40STsutomu Uchino             pOptions->SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2923cdf0e10cSrcweir 		else
2924cdf0e10cSrcweir 		{
2925cdf0e10cSrcweir 			ScGridOptions aGridOpt(pOptions->GetGridOptions());
2926cdf0e10cSrcweir 			if ( sName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
2927cdf0e10cSrcweir 				aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2928cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
2929cdf0e10cSrcweir 				aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2930cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
2931cdf0e10cSrcweir 				aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
2932cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
2933cdf0e10cSrcweir 				aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
2934cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
2935cdf0e10cSrcweir 				aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
2936cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
2937cdf0e10cSrcweir 				aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
2938cdf0e10cSrcweir 			else if ( sName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
2939cdf0e10cSrcweir 				aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
2940cdf0e10cSrcweir 			pOptions->SetGridOptions(aGridOpt);
2941cdf0e10cSrcweir 		}
2942cdf0e10cSrcweir 	}
2943cdf0e10cSrcweir 
2944cdf0e10cSrcweir     // copy default zoom to sheets where a different one wasn't specified
2945cdf0e10cSrcweir     for (SCTAB nZoomTab=0; nZoomTab<=MAXTAB; ++nZoomTab)
2946cdf0e10cSrcweir         if (pTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
2947cdf0e10cSrcweir         {
2948cdf0e10cSrcweir             pTabData[nZoomTab]->eZoomType  = eDefZoomType;
2949cdf0e10cSrcweir             pTabData[nZoomTab]->aZoomX     = aDefZoomX;
2950cdf0e10cSrcweir             pTabData[nZoomTab]->aZoomY     = aDefZoomY;
2951cdf0e10cSrcweir             pTabData[nZoomTab]->aPageZoomX = aDefPageZoomX;
2952cdf0e10cSrcweir             pTabData[nZoomTab]->aPageZoomY = aDefPageZoomY;
2953cdf0e10cSrcweir         }
2954cdf0e10cSrcweir 
2955cdf0e10cSrcweir 	if (nCount)
2956cdf0e10cSrcweir 		SetPagebreakMode( bPageMode );
2957cdf0e10cSrcweir 
2958cdf0e10cSrcweir     // #i47426# write view options to document, needed e.g. for Excel export
2959cdf0e10cSrcweir     pDoc->SetViewOptions( *pOptions );
2960cdf0e10cSrcweir }
2961cdf0e10cSrcweir 
SetOptions(const ScViewOptions & rOpt)2962cdf0e10cSrcweir void ScViewData::SetOptions( const ScViewOptions& rOpt )
2963cdf0e10cSrcweir {
2964cdf0e10cSrcweir 	//	if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
2965cdf0e10cSrcweir 	sal_Bool bHScrollChanged = ( rOpt.GetOption(VOPT_HSCROLL) != pOptions->GetOption(VOPT_HSCROLL) );
2966cdf0e10cSrcweir 
2967cdf0e10cSrcweir 	//	if graphics are turned on or off, animation has to be started or stopped
2968cdf0e10cSrcweir 	//	graphics are controlled by VOBJ_TYPE_OLE
2969cdf0e10cSrcweir 	sal_Bool bGraphicsChanged =	( pOptions->GetObjMode(VOBJ_TYPE_OLE) !=
2970cdf0e10cSrcweir 								   rOpt.GetObjMode(VOBJ_TYPE_OLE) );
2971cdf0e10cSrcweir 
2972cdf0e10cSrcweir 	*pOptions = rOpt;
2973cdf0e10cSrcweir 	DBG_ASSERT( pView, "No View" );
2974cdf0e10cSrcweir 
2975cdf0e10cSrcweir 	if( pView )
2976cdf0e10cSrcweir 	{
2977cdf0e10cSrcweir 		pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
2978cdf0e10cSrcweir 	}
2979cdf0e10cSrcweir }
2980cdf0e10cSrcweir 
GetMousePosPixel()2981cdf0e10cSrcweir Point ScViewData::GetMousePosPixel()
2982cdf0e10cSrcweir {
2983cdf0e10cSrcweir 	DBG_ASSERT( pView, "GetMousePosPixel() ohne View" );
2984cdf0e10cSrcweir 	return pView->GetMousePosPixel();
2985cdf0e10cSrcweir }
2986cdf0e10cSrcweir 
UpdateInputHandler(sal_Bool bForce,sal_Bool bStopEditing)2987cdf0e10cSrcweir void ScViewData::UpdateInputHandler( sal_Bool bForce, sal_Bool bStopEditing )
2988cdf0e10cSrcweir {
2989cdf0e10cSrcweir 	if (pViewShell)
2990cdf0e10cSrcweir 		pViewShell->UpdateInputHandler( bForce, bStopEditing );
2991cdf0e10cSrcweir }
2992cdf0e10cSrcweir 
IsOle()2993cdf0e10cSrcweir sal_Bool ScViewData::IsOle()
2994cdf0e10cSrcweir {
2995cdf0e10cSrcweir 	return pDocShell && pDocShell->IsOle();
2996cdf0e10cSrcweir }
2997cdf0e10cSrcweir 
UpdateFixX(SCTAB nTab)2998cdf0e10cSrcweir sal_Bool ScViewData::UpdateFixX( SCTAB nTab )				// sal_True = Wert geaendert
2999cdf0e10cSrcweir {
3000cdf0e10cSrcweir 	if (!ValidTab(nTab))		// Default
3001cdf0e10cSrcweir 		nTab=nTabNo;		// akuelle Tabelle
3002cdf0e10cSrcweir 
3003cdf0e10cSrcweir 	if (!pView || pTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
3004cdf0e10cSrcweir 		return sal_False;
3005cdf0e10cSrcweir 
3006cdf0e10cSrcweir     ScDocument* pLocalDoc = GetDocument();
3007cdf0e10cSrcweir     if (!pLocalDoc->HasTable(nTab))          // #114007# if called from reload, the sheet may not exist
3008cdf0e10cSrcweir         return sal_False;
3009cdf0e10cSrcweir 
3010cdf0e10cSrcweir 	SCCOL nFix = pTabData[nTab]->nFixPosX;
3011cdf0e10cSrcweir 	long nNewPos = 0;
3012cdf0e10cSrcweir 	for (SCCOL nX=pTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++)
3013cdf0e10cSrcweir 	{
3014cdf0e10cSrcweir 		sal_uInt16 nTSize = pLocalDoc->GetColWidth( nX, nTab );
3015cdf0e10cSrcweir 		if (nTSize)
3016cdf0e10cSrcweir 		{
3017cdf0e10cSrcweir 			long nPix = ToPixel( nTSize, nPPTX );
3018cdf0e10cSrcweir 			nNewPos += nPix;
3019cdf0e10cSrcweir 		}
3020cdf0e10cSrcweir 	}
3021cdf0e10cSrcweir 	nNewPos += pView->GetGridOffset().X();
3022cdf0e10cSrcweir 	if (nNewPos != pTabData[nTab]->nHSplitPos)
3023cdf0e10cSrcweir 	{
3024cdf0e10cSrcweir 		pTabData[nTab]->nHSplitPos = nNewPos;
3025cdf0e10cSrcweir 		if (nTab == nTabNo)
3026cdf0e10cSrcweir 			RecalcPixPos();					//! sollte nicht noetig sein !!!
3027cdf0e10cSrcweir 		return sal_True;
3028cdf0e10cSrcweir 	}
3029cdf0e10cSrcweir 
3030cdf0e10cSrcweir 	return sal_False;
3031cdf0e10cSrcweir }
3032cdf0e10cSrcweir 
UpdateFixY(SCTAB nTab)3033cdf0e10cSrcweir sal_Bool ScViewData::UpdateFixY( SCTAB nTab )				// sal_True = Wert geaendert
3034cdf0e10cSrcweir {
3035cdf0e10cSrcweir 	if (!ValidTab(nTab))		// Default
3036cdf0e10cSrcweir 		nTab=nTabNo;		// akuelle Tabelle
3037cdf0e10cSrcweir 
3038cdf0e10cSrcweir 	if (!pView || pTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
3039cdf0e10cSrcweir 		return sal_False;
3040cdf0e10cSrcweir 
3041cdf0e10cSrcweir     ScDocument* pLocalDoc = GetDocument();
3042cdf0e10cSrcweir     if (!pLocalDoc->HasTable(nTab))          // #114007# if called from reload, the sheet may not exist
3043cdf0e10cSrcweir         return sal_False;
3044cdf0e10cSrcweir 
3045cdf0e10cSrcweir 	SCROW nFix = pTabData[nTab]->nFixPosY;
3046cdf0e10cSrcweir 	long nNewPos = 0;
3047cdf0e10cSrcweir 	for (SCROW nY=pTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++)
3048cdf0e10cSrcweir 	{
3049cdf0e10cSrcweir 		sal_uInt16 nTSize = pLocalDoc->GetRowHeight( nY, nTab );
3050cdf0e10cSrcweir 		if (nTSize)
3051cdf0e10cSrcweir 		{
3052cdf0e10cSrcweir 			long nPix = ToPixel( nTSize, nPPTY );
3053cdf0e10cSrcweir 			nNewPos += nPix;
3054cdf0e10cSrcweir 		}
3055cdf0e10cSrcweir 	}
3056cdf0e10cSrcweir 	nNewPos += pView->GetGridOffset().Y();
3057cdf0e10cSrcweir 	if (nNewPos != pTabData[nTab]->nVSplitPos)
3058cdf0e10cSrcweir 	{
3059cdf0e10cSrcweir 		pTabData[nTab]->nVSplitPos = nNewPos;
3060cdf0e10cSrcweir 		if (nTab == nTabNo)
3061cdf0e10cSrcweir 			RecalcPixPos();					//! sollte nicht noetig sein !!!
3062cdf0e10cSrcweir 		return sal_True;
3063cdf0e10cSrcweir 	}
3064cdf0e10cSrcweir 
3065cdf0e10cSrcweir 	return sal_False;
3066cdf0e10cSrcweir }
3067cdf0e10cSrcweir 
UpdateOutlinerFlags(Outliner & rOutl) const3068cdf0e10cSrcweir void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) const
3069cdf0e10cSrcweir {
3070cdf0e10cSrcweir 	ScDocument* pLocalDoc = GetDocument();
3071cdf0e10cSrcweir 	sal_Bool bOnlineSpell = pLocalDoc->GetDocOptions().IsAutoSpell();
3072cdf0e10cSrcweir 
3073cdf0e10cSrcweir 	sal_uLong nCntrl = rOutl.GetControlWord();
3074cdf0e10cSrcweir 	nCntrl |= EE_CNTRL_URLSFXEXECUTE;
3075cdf0e10cSrcweir 	nCntrl |= EE_CNTRL_MARKFIELDS;
3076cdf0e10cSrcweir 	nCntrl |= EE_CNTRL_AUTOCORRECT;
3077cdf0e10cSrcweir 	if( bOnlineSpell )
3078cdf0e10cSrcweir 		nCntrl |= EE_CNTRL_ONLINESPELLING;
3079cdf0e10cSrcweir 	else
3080cdf0e10cSrcweir 		nCntrl &= ~EE_CNTRL_ONLINESPELLING;
3081cdf0e10cSrcweir 	rOutl.SetControlWord(nCntrl);
3082cdf0e10cSrcweir 
3083cdf0e10cSrcweir 	rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) );
3084cdf0e10cSrcweir 
3085cdf0e10cSrcweir 	//	#97417# don't call GetSpellChecker if online spelling isn't enabled.
3086cdf0e10cSrcweir 	//	The language for AutoCorrect etc. is taken from the pool defaults
3087cdf0e10cSrcweir 	//	(set in ScDocument::UpdateDrawLanguages)
3088cdf0e10cSrcweir 
3089cdf0e10cSrcweir 	if ( bOnlineSpell )
3090cdf0e10cSrcweir 	{
3091cdf0e10cSrcweir 	    com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
3092cdf0e10cSrcweir 		rOutl.SetSpeller( xXSpellChecker1 );
3093cdf0e10cSrcweir 	}
3094cdf0e10cSrcweir 
3095cdf0e10cSrcweir 	rOutl.SetDefaultHorizontalTextDirection(
3096cdf0e10cSrcweir 		(EEHorizontalTextDirection)pLocalDoc->GetEditTextDirection( nTabNo ) );
3097cdf0e10cSrcweir }
3098cdf0e10cSrcweir 
GetCurPos() const3099cdf0e10cSrcweir ScAddress ScViewData::GetCurPos() const
3100cdf0e10cSrcweir {
3101cdf0e10cSrcweir 	return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
3102cdf0e10cSrcweir }
3103cdf0e10cSrcweir 
3104cdf0e10cSrcweir 
3105cdf0e10cSrcweir // static
AddPixelsWhile(long & rScrY,long nEndPixels,SCROW & rPosY,SCROW nEndRow,double nPPTY,const ScDocument * pDoc,SCTAB nTabNo)3106cdf0e10cSrcweir void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
3107cdf0e10cSrcweir         SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
3108cdf0e10cSrcweir {
3109cdf0e10cSrcweir     SCROW nRow = rPosY;
3110cdf0e10cSrcweir     while (rScrY <= nEndPixels && nRow <= nEndRow)
3111cdf0e10cSrcweir     {
3112cdf0e10cSrcweir         SCROW nHeightEndRow;
3113cdf0e10cSrcweir         sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow);
3114cdf0e10cSrcweir         if (nHeightEndRow > nEndRow)
3115cdf0e10cSrcweir             nHeightEndRow = nEndRow;
3116cdf0e10cSrcweir         if (!nHeight)
3117cdf0e10cSrcweir             nRow = nHeightEndRow + 1;
3118cdf0e10cSrcweir         else
3119cdf0e10cSrcweir         {
3120cdf0e10cSrcweir             SCROW nRows = nHeightEndRow - nRow + 1;
3121cdf0e10cSrcweir             sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
3122cdf0e10cSrcweir             sal_Int64 nAdd = nPixel * nRows;
3123cdf0e10cSrcweir             if (nAdd + rScrY > nEndPixels)
3124cdf0e10cSrcweir             {
3125cdf0e10cSrcweir                 sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
3126cdf0e10cSrcweir                 nRows -= static_cast<SCROW>(nDiff / nPixel);
3127cdf0e10cSrcweir                 nAdd = nPixel * nRows;
3128cdf0e10cSrcweir                 // We're looking for a value that satisfies loop condition.
3129cdf0e10cSrcweir                 if (nAdd + rScrY <= nEndPixels)
3130cdf0e10cSrcweir                 {
3131cdf0e10cSrcweir                     ++nRows;
3132cdf0e10cSrcweir                     nAdd += nPixel;
3133cdf0e10cSrcweir                 }
3134cdf0e10cSrcweir             }
3135cdf0e10cSrcweir             rScrY += static_cast<long>(nAdd);
3136cdf0e10cSrcweir             nRow += nRows;
3137cdf0e10cSrcweir         }
3138cdf0e10cSrcweir     }
3139cdf0e10cSrcweir     if (nRow > rPosY)
3140cdf0e10cSrcweir         --nRow;
3141cdf0e10cSrcweir     rPosY = nRow;
3142cdf0e10cSrcweir }
3143cdf0e10cSrcweir 
3144cdf0e10cSrcweir 
3145cdf0e10cSrcweir // static
AddPixelsWhileBackward(long & rScrY,long nEndPixels,SCROW & rPosY,SCROW nStartRow,double nPPTY,const ScDocument * pDoc,SCTAB nTabNo)3146cdf0e10cSrcweir void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
3147cdf0e10cSrcweir         SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
3148cdf0e10cSrcweir         SCTAB nTabNo )
3149cdf0e10cSrcweir {
3150cdf0e10cSrcweir     SCROW nRow = rPosY;
3151cdf0e10cSrcweir     while (rScrY <= nEndPixels && nRow >= nStartRow)
3152cdf0e10cSrcweir     {
3153cdf0e10cSrcweir         SCROW nHeightStartRow;
3154cdf0e10cSrcweir         sal_uInt16 nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL);
3155cdf0e10cSrcweir         if (nHeightStartRow < nStartRow)
3156cdf0e10cSrcweir             nHeightStartRow = nStartRow;
3157cdf0e10cSrcweir         if (!nHeight)
3158cdf0e10cSrcweir             nRow = nHeightStartRow - 1;
3159cdf0e10cSrcweir         else
3160cdf0e10cSrcweir         {
3161cdf0e10cSrcweir             SCROW nRows = nRow - nHeightStartRow + 1;
3162cdf0e10cSrcweir             sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
3163cdf0e10cSrcweir             sal_Int64 nAdd = nPixel * nRows;
3164cdf0e10cSrcweir             if (nAdd + rScrY > nEndPixels)
3165cdf0e10cSrcweir             {
3166cdf0e10cSrcweir                 sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
3167cdf0e10cSrcweir                 nRows -= static_cast<SCROW>(nDiff / nPixel);
3168cdf0e10cSrcweir                 nAdd = nPixel * nRows;
3169cdf0e10cSrcweir                 // We're looking for a value that satisfies loop condition.
3170cdf0e10cSrcweir                 if (nAdd + rScrY <= nEndPixels)
3171cdf0e10cSrcweir                 {
3172cdf0e10cSrcweir                     ++nRows;
3173cdf0e10cSrcweir                     nAdd += nPixel;
3174cdf0e10cSrcweir                 }
3175cdf0e10cSrcweir             }
3176cdf0e10cSrcweir             rScrY += static_cast<long>(nAdd);
3177cdf0e10cSrcweir             nRow -= nRows;
3178cdf0e10cSrcweir         }
3179cdf0e10cSrcweir     }
3180cdf0e10cSrcweir     if (nRow < rPosY)
3181cdf0e10cSrcweir         ++nRow;
3182cdf0e10cSrcweir     rPosY = nRow;
3183cdf0e10cSrcweir }
3184