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