1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "scitems.hxx"
22 #include <editeng/eeitem.hxx>
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>
36 #include <vcl/svapp.hxx>
37 #include <rtl/math.hxx>
39 #include <sax/tools/converter.hxx>
41 #include "viewdata.hxx"
42 #include "docoptio.hxx"
45 #include "document.hxx"
47 #include "tabview.hxx"
48 #include "tabvwsh.hxx"
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>
67 using namespace com::sun::star
;
69 #define SC_GROWY_SMALL_EXTRA 100
70 #define SC_GROWY_BIG_EXTRA 200
72 #define TAG_TABBARWIDTH "tw:"
74 static sal_Bool bMoveArea
= false; //! Member?
75 sal_uInt16 nEditAdjust
= SVX_ADJUST_LEFT
; //! Member !!!
77 ScViewDataTable::ScViewDataTable() :
78 eZoomType( SVX_ZOOM_PERCENT
),
81 aPageZoomX( 3,5 ), // Page-Default: 60%
85 eHSplitMode( SC_SPLIT_NONE
),
86 eVSplitMode( SC_SPLIT_NONE
),
87 eWhichActive( SC_SPLIT_BOTTOMLEFT
),
93 mbOldCursorValid( false )
97 nTPosX
[0]=nTPosX
[1]=0;
98 nTPosY
[0]=nTPosY
[1]=0;
99 nMPosX
[0]=nMPosX
[1]=0;
100 nMPosY
[0]=nMPosY
[1]=0;
101 nPixPosX
[0]=nPixPosX
[1]=0;
102 nPixPosY
[0]=nPixPosY
[1]=0;
105 ScViewDataTable::~ScViewDataTable()
109 void ScViewDataTable::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
, const ScViewData
& /*rViewData*/, SCTAB
/*nTab*/) const
111 rSettings
.realloc(SC_TABLE_VIEWSETTINGS_COUNT
);
112 beans::PropertyValue
* pSettings
= rSettings
.getArray();
115 pSettings
[SC_CURSOR_X
].Name
= OUString(SC_CURSORPOSITIONX
);
116 pSettings
[SC_CURSOR_X
].Value
<<= sal_Int32(nCurX
);
117 pSettings
[SC_CURSOR_Y
].Name
= OUString(SC_CURSORPOSITIONY
);
118 pSettings
[SC_CURSOR_Y
].Value
<<= sal_Int32(nCurY
);
119 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Name
= OUString(SC_HORIZONTALSPLITMODE
);
120 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Value
<<= sal_Int16(eHSplitMode
);
121 pSettings
[SC_VERTICAL_SPLIT_MODE
].Name
= OUString(SC_VERTICALSPLITMODE
);
122 pSettings
[SC_VERTICAL_SPLIT_MODE
].Value
<<= sal_Int16(eVSplitMode
);
123 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Name
= OUString(SC_HORIZONTALSPLITPOSITION
);
124 if (eHSplitMode
== SC_SPLIT_FIX
)
125 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosX
);
127 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nHSplitPos
);
128 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Name
= OUString(SC_VERTICALSPLITPOSITION
);
129 if (eVSplitMode
== SC_SPLIT_FIX
)
130 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosY
);
132 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nVSplitPos
);
133 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Name
= OUString(SC_ACTIVESPLITRANGE
);
134 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Value
<<= sal_Int16(eWhichActive
);
135 pSettings
[SC_POSITION_LEFT
].Name
= OUString(SC_POSITIONLEFT
);
136 pSettings
[SC_POSITION_LEFT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_LEFT
]);
137 pSettings
[SC_POSITION_RIGHT
].Name
= OUString(SC_POSITIONRIGHT
);
138 pSettings
[SC_POSITION_RIGHT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_RIGHT
]);
139 pSettings
[SC_POSITION_TOP
].Name
= OUString(SC_POSITIONTOP
);
140 pSettings
[SC_POSITION_TOP
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_TOP
]);
141 pSettings
[SC_POSITION_BOTTOM
].Name
= OUString(SC_POSITIONBOTTOM
);
142 pSettings
[SC_POSITION_BOTTOM
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_BOTTOM
]);
144 sal_Int32
nZoomValue ((aZoomY
.GetNumerator() * 100) / aZoomY
.GetDenominator());
145 sal_Int32
nPageZoomValue ((aPageZoomY
.GetNumerator() * 100) / aPageZoomY
.GetDenominator());
146 pSettings
[SC_TABLE_ZOOM_TYPE
].Name
= OUString(SC_ZOOMTYPE
);
147 pSettings
[SC_TABLE_ZOOM_TYPE
].Value
<<= sal_Int16(eZoomType
);
148 pSettings
[SC_TABLE_ZOOM_VALUE
].Name
= OUString(SC_ZOOMVALUE
);
149 pSettings
[SC_TABLE_ZOOM_VALUE
].Value
<<= nZoomValue
;
150 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Name
= OUString(SC_PAGEVIEWZOOMVALUE
);
151 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
153 pSettings
[SC_TABLE_SHOWGRID
].Name
= OUString(SC_UNO_SHOWGRID
);
154 pSettings
[SC_TABLE_SHOWGRID
].Value
<<= static_cast<sal_Bool
>(bShowGrid
);
158 void ScViewDataTable::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& aSettings
, ScViewData
& rViewData
, SCTAB nTab
, bool& rHasZoom
)
162 sal_Int32
nCount(aSettings
.getLength());
163 sal_Int32
nTemp32(0);
164 sal_Int16
nTemp16(0);
165 sal_Int32
nTempPosV(0);
166 sal_Int32
nTempPosH(0);
167 sal_Int32
nTempPosVTw(0);
168 sal_Int32
nTempPosHTw(0);
169 bool bHasVSplitInTwips
= false;
170 bool bHasHSplitInTwips
= false;
171 for (sal_Int32 i
= 0; i
< nCount
; i
++)
173 OUString
sName(aSettings
[i
].Name
);
174 if (sName
.equalsAscii(SC_CURSORPOSITIONX
) )
176 aSettings
[i
].Value
>>= nTemp32
;
177 nCurX
= SanitizeCol( static_cast<SCCOL
>(nTemp32
));
179 else if (sName
.equalsAscii(SC_CURSORPOSITIONY
) )
181 aSettings
[i
].Value
>>= nTemp32
;
182 nCurY
= SanitizeRow( static_cast<SCROW
>(nTemp32
));
184 else if (sName
.equalsAscii(SC_HORIZONTALSPLITMODE
) )
186 aSettings
[i
].Value
>>= nTemp16
;
187 eHSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
189 else if (sName
.equalsAscii(SC_VERTICALSPLITMODE
) )
191 aSettings
[i
].Value
>>= nTemp16
;
192 eVSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
194 else if (sName
.equalsAscii(SC_HORIZONTALSPLITPOSITION
) )
196 aSettings
[i
].Value
>>= nTempPosH
;
197 bHasHSplitInTwips
= false;
199 else if (sName
.equalsAscii(SC_VERTICALSPLITPOSITION
) )
201 aSettings
[i
].Value
>>= nTempPosV
;
202 bHasVSplitInTwips
= false;
204 else if (sName
.equalsAscii(SC_HORIZONTALSPLITPOSITION_TWIPS
) )
206 aSettings
[i
].Value
>>= nTempPosHTw
;
207 bHasHSplitInTwips
= true;
209 else if (sName
.equalsAscii(SC_VERTICALSPLITPOSITION_TWIPS
) )
211 aSettings
[i
].Value
>>= nTempPosVTw
;
212 bHasVSplitInTwips
= true;
214 else if (sName
.equalsAscii(SC_ACTIVESPLITRANGE
) )
216 aSettings
[i
].Value
>>= nTemp16
;
217 eWhichActive
= static_cast<ScSplitPos
>(nTemp16
);
219 else if (sName
.equalsAscii(SC_POSITIONLEFT
) )
221 aSettings
[i
].Value
>>= nTemp32
;
222 nPosX
[SC_SPLIT_LEFT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
224 else if (sName
.equalsAscii(SC_POSITIONRIGHT
) )
226 aSettings
[i
].Value
>>= nTemp32
;
227 nPosX
[SC_SPLIT_RIGHT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
229 else if (sName
.equalsAscii(SC_POSITIONTOP
) )
231 aSettings
[i
].Value
>>= nTemp32
;
232 nPosY
[SC_SPLIT_TOP
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
234 else if (sName
.equalsAscii(SC_POSITIONBOTTOM
) )
236 aSettings
[i
].Value
>>= nTemp32
;
237 nPosY
[SC_SPLIT_BOTTOM
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
239 else if (sName
.equalsAscii(SC_ZOOMTYPE
) )
241 aSettings
[i
].Value
>>= nTemp16
;
242 eZoomType
= SvxZoomType(nTemp16
);
243 rHasZoom
= true; // set if there is any zoom information
245 else if (sName
.equalsAscii(SC_ZOOMVALUE
) )
247 aSettings
[i
].Value
>>= nTemp32
;
248 Fraction
aZoom(nTemp32
, 100);
249 aZoomX
= aZoomY
= aZoom
;
252 else if (sName
.equalsAscii(SC_PAGEVIEWZOOMVALUE
) )
254 aSettings
[i
].Value
>>= nTemp32
;
255 Fraction
aZoom(nTemp32
, 100);
256 aPageZoomX
= aPageZoomY
= aZoom
;
259 else if (sName
.equalsAscii(SC_UNO_SHOWGRID
) )
261 aSettings
[i
].Value
>>= bShowGrid
;
263 else if (sName
.equalsAscii(SC_TABLESELECTED
) )
265 bool bSelected
= false;
266 aSettings
[i
].Value
>>= bSelected
;
267 rViewData
.GetMarkData().SelectTable( nTab
, bSelected
);
269 else if (sName
.equalsAscii(SC_UNONAME_TABCOLOR
) )
271 // There are documents out there that have their tab color defined as a view setting.
272 sal_Int32 nColor
= COL_AUTO
;
273 aSettings
[i
].Value
>>= nColor
;
274 if (static_cast<ColorData
>(nColor
) != COL_AUTO
)
276 ScDocument
* pDoc
= rViewData
.GetDocument();
277 pDoc
->SetTabBgColor(nTab
, Color(static_cast<ColorData
>(nColor
)));
281 if (eHSplitMode
== SC_SPLIT_FIX
)
282 nFixPosX
= SanitizeCol( static_cast<SCCOL
>( bHasHSplitInTwips
? nTempPosHTw
: nTempPosH
));
284 nHSplitPos
= bHasHSplitInTwips
? static_cast< long >( nTempPosHTw
* rViewData
.GetPPTX() ) : nTempPosH
;
286 if (eVSplitMode
== SC_SPLIT_FIX
)
287 nFixPosY
= SanitizeRow( static_cast<SCROW
>( bHasVSplitInTwips
? nTempPosVTw
: nTempPosV
));
289 nVSplitPos
= bHasVSplitInTwips
? static_cast< long >( nTempPosVTw
* rViewData
.GetPPTY() ) : nTempPosV
;
292 ScViewData::ScViewData( ScDocShell
* pDocSh
, ScTabViewShell
* pViewSh
) :
293 mpMarkData(new ScMarkData
),
294 pDocShell ( pDocSh
),
297 pViewShell ( pViewSh
),
298 pOptions ( new ScViewOptions
),
299 pSpellingView ( NULL
),
300 aLogicMode ( MAP_100TH_MM
),
301 eDefZoomType( SVX_ZOOM_PERCENT
),
304 aDefPageZoomX( 3,5 ),
305 aDefPageZoomY( 3,5 ),
306 eRefType ( SC_REFTYPE_NONE
),
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 bSelCtrlMouseClick( false )
318 mpMarkData
->SelectOneTable(0); // Sync with nTabNo.
320 SetGridMode ( sal_True
);
321 SetSyntaxMode ( false );
322 SetHeaderMode ( sal_True
);
323 SetTabMode ( sal_True
);
324 SetVScrollMode ( sal_True
);
325 SetHScrollMode ( sal_True
);
326 SetOutlineMode ( sal_True
);
328 aScrSize
= Size( (long) ( STD_COL_WIDTH
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_X
),
329 (long) ( ScGlobal::nStdRowHeight
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_Y
) );
330 maTabData
.push_back( new ScViewDataTable
);
331 pThisTab
= maTabData
[nTabNo
];
332 for (sal_uInt16 j
=0; j
<4; j
++)
335 bEditActive
[j
] = false;
338 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
339 nEditEndRow
= nEditRow
= 0;
340 nTabStartCol
= SC_TABSTART_NONE
;
344 pDoc
= pDocShell
->GetDocument();
345 *pOptions
= pDoc
->GetViewOptions();
348 // keine ausgeblendete Tabelle anzeigen:
349 if (pDoc
&& !pDoc
->IsVisible(nTabNo
))
351 while ( !pDoc
->IsVisible(nTabNo
) && pDoc
->HasTable(nTabNo
+1) )
354 maTabData
.push_back(NULL
);
356 maTabData
[nTabNo
] = new ScViewDataTable() ;
357 pThisTab
= maTabData
[nTabNo
];
363 ScViewData::ScViewData( const ScViewData
& rViewData
) :
364 maTabData( rViewData
.maTabData
),
365 mpMarkData(new ScMarkData(*rViewData
.mpMarkData
)),
366 pDocShell ( rViewData
.pDocShell
),
367 pDoc ( rViewData
.pDoc
),
368 pView ( rViewData
.pView
),
369 pViewShell ( rViewData
.pViewShell
),
370 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 bSelCtrlMouseClick( rViewData
.bSelCtrlMouseClick
)
390 SetGridMode ( rViewData
.IsGridMode() );
391 SetSyntaxMode ( rViewData
.IsSyntaxMode() );
392 SetHeaderMode ( rViewData
.IsHeaderMode() );
393 SetTabMode ( rViewData
.IsTabMode() );
394 SetVScrollMode ( rViewData
.IsVScrollMode() );
395 SetHScrollMode ( rViewData
.IsHScrollMode() );
396 SetOutlineMode ( rViewData
.IsOutlineMode() );
398 aScrSize
= rViewData
.aScrSize
;
400 pThisTab
= maTabData
[nTabNo
];
401 for (sal_uInt16 j
=0; j
<4; j
++)
404 bEditActive
[j
] = false;
407 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
408 nEditEndRow
= nEditRow
= 0;
409 nTabStartCol
= SC_TABSTART_NONE
;
413 void ScViewData::InitData( ScDocument
* pDocument
)
416 *pOptions
= pDoc
->GetViewOptions();
420 ScDocument
* ScViewData::GetDocument() const
425 return pDocShell
->GetDocument();
427 OSL_FAIL("kein Document an ViewData");
431 ScViewData::~ScViewData()
436 maTabData
.begin(), maTabData
.end(), ScDeleteObjectByPtr
<ScViewDataTable
>());
439 void ScViewData::UpdateCurrentTab()
441 pThisTab
= maTabData
[nTabNo
];
445 pThisTab
= maTabData
[--nTabNo
];
447 pThisTab
= maTabData
[0] = new ScViewDataTable
;
451 void ScViewData::InsertTab( SCTAB nTab
)
453 if( nTab
>= static_cast<SCTAB
>(maTabData
.size()))
454 maTabData
.resize(nTab
+1, NULL
);
456 maTabData
.insert( maTabData
.begin() + nTab
, (ScViewDataTable
*)NULL
);
457 CreateTabData( nTab
);
460 mpMarkData
->InsertTab( nTab
);
463 void ScViewData::InsertTabs( SCTAB nTab
, SCTAB nNewSheets
)
465 if( nTab
+nNewSheets
>= static_cast<SCTAB
>(maTabData
.size()))
466 maTabData
.resize(nTab
+nNewSheets
, NULL
);
469 maTabData
.insert( maTabData
.begin() + nTab
, nNewSheets
, NULL
);
471 for (SCTAB i
= nTab
; i
< nTab
+ nNewSheets
; ++i
)
474 mpMarkData
->InsertTab( i
);
479 void ScViewData::DeleteTab( SCTAB nTab
)
481 delete maTabData
.at(nTab
);
483 maTabData
.erase(maTabData
.begin() + nTab
);
485 mpMarkData
->DeleteTab( nTab
);
488 void ScViewData::DeleteTabs( SCTAB nTab
, SCTAB nSheets
)
490 for (SCTAB i
= 0; i
< nSheets
; ++i
)
492 mpMarkData
->DeleteTab( nTab
+ i
);
493 delete maTabData
.at(nTab
+ i
);
496 maTabData
.erase(maTabData
.begin() + nTab
, maTabData
.begin()+ nTab
+nSheets
);
500 void ScViewData::CopyTab( SCTAB nSrcTab
, SCTAB nDestTab
)
502 if (nDestTab
==SC_TAB_APPEND
)
503 nDestTab
= pDoc
->GetTableCount() - 1; // am Doc muss vorher kopiert worden sein
505 if (nDestTab
> MAXTAB
)
507 OSL_FAIL("Zuviele Tabellen");
511 if (nSrcTab
>= static_cast<SCTAB
>(maTabData
.size()))
512 OSL_FAIL("pTabData out of bounds, FIX IT");
514 EnsureTabDataSize(nDestTab
+ 1);
516 if ( maTabData
[nSrcTab
] )
517 maTabData
.insert(maTabData
.begin() + nDestTab
, new ScViewDataTable( *maTabData
[nSrcTab
] ));
519 maTabData
.insert(maTabData
.begin() + nDestTab
, (ScViewDataTable
*)NULL
);
522 mpMarkData
->InsertTab( nDestTab
);
525 void ScViewData::MoveTab( SCTAB nSrcTab
, SCTAB nDestTab
)
527 if (nDestTab
==SC_TAB_APPEND
)
528 nDestTab
= pDoc
->GetTableCount() - 1;
529 ScViewDataTable
* pTab
= NULL
;
530 if (nSrcTab
< static_cast<SCTAB
>(maTabData
.size()))
532 pTab
= maTabData
[nSrcTab
];
533 maTabData
.erase( maTabData
.begin() + nSrcTab
);
536 if (nDestTab
< static_cast<SCTAB
>(maTabData
.size()))
537 maTabData
.insert( maTabData
.begin() + nDestTab
, pTab
);
540 EnsureTabDataSize(nDestTab
+ 1);
541 maTabData
[nDestTab
] = pTab
;
545 mpMarkData
->DeleteTab( nSrcTab
);
546 mpMarkData
->InsertTab( nDestTab
); // ggf. angepasst
549 void ScViewData::CreateTabData( std::vector
< SCTAB
>& rvTabs
)
551 std::vector
< SCTAB
>::iterator it_end
= rvTabs
.end();
552 for ( std::vector
< SCTAB
>::iterator it
= rvTabs
.begin(); it
!= it_end
; ++it
)
556 void ScViewData::SetZoomType( SvxZoomType eNew
, std::vector
< SCTAB
>& tabs
)
558 sal_Bool bAll
= ( tabs
.empty() );
560 if ( !bAll
) // create associated table data
561 CreateTabData( tabs
);
565 for ( SCTAB i
= 0; i
< static_cast<SCTAB
>(maTabData
.size()); ++i
)
568 maTabData
[i
]->eZoomType
= eNew
;
574 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
575 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
576 for ( ; it
!= it_end
; ++it
)
579 if ( i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
] )
580 maTabData
[i
]->eZoomType
= eNew
;
585 void ScViewData::SetZoomType( SvxZoomType eNew
, sal_Bool bAll
)
587 std::vector
< SCTAB
> vTabs
; // Empty for all tabs
588 if ( !bAll
) // get selected tabs
590 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
591 vTabs
.insert(vTabs
.begin(), itr
, itrEnd
);
593 SetZoomType( eNew
, vTabs
);
596 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, std::vector
< SCTAB
>& tabs
)
598 sal_Bool bAll
= ( tabs
.empty() );
599 if ( !bAll
) // create associated table data
600 CreateTabData( tabs
);
601 Fraction
aFrac20( 1,5 );
602 Fraction
aFrac400( 4,1 );
604 Fraction aValidX
= rNewX
;
607 if (aValidX
>aFrac400
)
610 Fraction aValidY
= rNewY
;
613 if (aValidY
>aFrac400
)
618 for ( SCTAB i
= 0; i
< static_cast<SCTAB
>(maTabData
.size()); ++i
)
624 maTabData
[i
]->aPageZoomX
= aValidX
;
625 maTabData
[i
]->aPageZoomY
= aValidY
;
629 maTabData
[i
]->aZoomX
= aValidX
;
630 maTabData
[i
]->aZoomY
= aValidY
;
636 aDefPageZoomX
= aValidX
;
637 aDefPageZoomY
= aValidY
;
647 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
648 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
649 for ( ; it
!= it_end
; ++it
)
652 if ( i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
] )
656 maTabData
[i
]->aPageZoomX
= aValidX
;
657 maTabData
[i
]->aPageZoomY
= aValidY
;
661 maTabData
[i
]->aZoomX
= aValidX
;
662 maTabData
[i
]->aZoomY
= aValidY
;
670 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, sal_Bool bAll
)
672 std::vector
< SCTAB
> vTabs
;
673 if ( !bAll
) // get selected tabs
675 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
676 vTabs
.insert(vTabs
.begin(), itr
, itrEnd
);
678 SetZoom( rNewX
, rNewY
, vTabs
);
681 void ScViewData::SetShowGrid( bool bShow
)
683 CreateSelectedTabData();
684 maTabData
[nTabNo
]->bShowGrid
= bShow
;
687 void ScViewData::RefreshZoom()
689 // recalculate zoom-dependent values (only for current sheet)
693 aScenButSize
= Size(0,0);
694 aLogicMode
.SetScaleX( GetZoomX() );
695 aLogicMode
.SetScaleY( GetZoomY() );
698 void ScViewData::SetPagebreakMode( bool bSet
)
706 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
, ScMarkData
& rNewMark
) const
708 ScMarkType eMarkType
= SC_MARK_NONE
;
710 if ( rNewMark
.IsMarked() || rNewMark
.IsMultiMarked() )
712 if ( rNewMark
.IsMultiMarked() )
713 rNewMark
.MarkToSimple();
715 if ( rNewMark
.IsMarked() && !rNewMark
.IsMultiMarked() )
717 rNewMark
.GetMarkArea( rRange
);
718 if (ScViewUtil::HasFiltered( rRange
, GetDocument()))
719 eMarkType
= SC_MARK_SIMPLE_FILTERED
;
721 eMarkType
= SC_MARK_SIMPLE
;
724 eMarkType
= SC_MARK_MULTI
;
726 if (eMarkType
!= SC_MARK_SIMPLE
&& eMarkType
!= SC_MARK_SIMPLE_FILTERED
)
728 if (eMarkType
== SC_MARK_NONE
)
729 eMarkType
= SC_MARK_SIMPLE
;
730 rRange
= ScRange( GetCurX(), GetCurY(), GetTabNo() );
736 ScMarkType
ScViewData::GetSimpleArea( SCCOL
& rStartCol
, SCROW
& rStartRow
, SCTAB
& rStartTab
,
737 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB
& rEndTab
) const
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
745 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
746 ScMarkType eMarkType
= GetSimpleArea( aRange
, aNewMark
);
747 aRange
.GetVars( rStartCol
, rStartRow
, rStartTab
, rEndCol
, rEndRow
, rEndTab
);
751 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
) const
753 // parameter bMergeMark is no longer needed, see above
755 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
756 return GetSimpleArea( rRange
, aNewMark
);
759 void ScViewData::GetMultiArea( ScRangeListRef
& rRange
) const
761 // parameter bMergeMark is no longer needed, see GetSimpleArea
763 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
765 sal_Bool bMulti
= aNewMark
.IsMultiMarked();
768 aNewMark
.MarkToSimple();
769 bMulti
= aNewMark
.IsMultiMarked();
773 rRange
= new ScRangeList
;
774 aNewMark
.FillRangeListWithMarks( rRange
, false );
779 GetSimpleArea(aSimple
);
780 rRange
= new ScRangeList
;
781 rRange
->Append(aSimple
);
785 sal_Bool
ScViewData::SimpleColMarked()
793 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
794 if (nStartRow
==0 && nEndRow
==MAXROW
)
800 sal_Bool
ScViewData::SimpleRowMarked()
808 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
809 if (nStartCol
==0 && nEndCol
==MAXCOL
)
815 sal_Bool
ScViewData::IsMultiMarked()
817 // Test for "real" multi selection, calling MarkToSimple on a local copy,
818 // and taking filtered in simple area marks into account.
821 ScMarkType eType
= GetSimpleArea(aDummy
);
822 return (eType
& SC_MARK_SIMPLE
) != SC_MARK_SIMPLE
;
825 void ScViewData::SetFillMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
)
827 nFillMode
= SC_FILL_FILL
;
828 nFillStartX
= nStartCol
;
829 nFillStartY
= nStartRow
;
834 void ScViewData::SetDragMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
838 nFillStartX
= nStartCol
;
839 nFillStartY
= nStartRow
;
844 void ScViewData::ResetFillMode()
846 nFillMode
= SC_FILL_NONE
;
849 void ScViewData::GetFillData( SCCOL
& rStartCol
, SCROW
& rStartRow
,
850 SCCOL
& rEndCol
, SCROW
& rEndRow
)
852 rStartCol
= nFillStartX
;
853 rStartRow
= nFillStartY
;
858 SCCOL
ScViewData::GetOldCurX() const
860 if (pThisTab
->mbOldCursorValid
)
861 return pThisTab
->nOldCurX
;
863 return pThisTab
->nCurX
;
866 SCROW
ScViewData::GetOldCurY() const
868 if (pThisTab
->mbOldCursorValid
)
869 return pThisTab
->nOldCurY
;
871 return pThisTab
->nCurY
;
874 void ScViewData::SetOldCursor( SCCOL nNewX
, SCROW nNewY
)
876 pThisTab
->nOldCurX
= nNewX
;
877 pThisTab
->nOldCurY
= nNewY
;
878 pThisTab
->mbOldCursorValid
= true;
881 void ScViewData::ResetOldCursor()
883 pThisTab
->mbOldCursorValid
= false;
886 Rectangle
ScViewData::GetEditArea( ScSplitPos eWhich
, SCCOL nPosX
, SCROW nPosY
,
887 Window
* pWin
, const ScPatternAttr
* pPattern
,
888 sal_Bool bForceToTop
)
890 return ScEditUtil( pDoc
, nPosX
, nPosY
, nTabNo
, GetScrPos(nPosX
,nPosY
,eWhich
,sal_True
),
891 pWin
, nPPTX
, nPPTY
, GetZoomX(), GetZoomY() ).
892 GetEditArea( pPattern
, bForceToTop
);
895 void ScViewData::SetEditEngine( ScSplitPos eWhich
,
896 ScEditEngineDefaulter
* pNewEngine
,
897 Window
* pWin
, SCCOL nNewX
, SCROW nNewY
)
899 sal_Bool bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
900 ScHSplitPos eHWhich
= WhichH(eWhich
);
902 sal_Bool bWasThere
= false;
903 if (pEditView
[eWhich
])
905 // Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert
907 if (bEditActive
[eWhich
])
908 bWasThere
= sal_True
;
910 pEditView
[eWhich
]->SetEditEngine(pNewEngine
);
912 if (pEditView
[eWhich
]->GetWindow() != pWin
)
914 pEditView
[eWhich
]->SetWindow(pWin
);
915 OSL_FAIL("EditView Window geaendert");
920 pEditView
[eWhich
] = new EditView( pNewEngine
, pWin
);
923 // bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
925 sal_uLong nEC
= pNewEngine
->GetControlWord();
926 pNewEngine
->SetControlWord(nEC
& ~EE_CNTRL_DOIDLEFORMAT
);
928 sal_uLong nVC
= pEditView
[eWhich
]->GetControlWord();
929 pEditView
[eWhich
]->SetControlWord(nVC
& ~EV_CNTRL_AUTOSCROLL
);
931 bEditActive
[eWhich
] = true;
933 const ScPatternAttr
* pPattern
= pDoc
->GetPattern( nNewX
, nNewY
, nTabNo
);
934 SvxCellHorJustify eJust
= (SvxCellHorJustify
)((const SvxHorJustifyItem
&)
935 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
937 sal_Bool bBreak
= ( eJust
== SVX_HOR_JUSTIFY_BLOCK
) ||
938 ((SfxBoolItem
&)pPattern
->GetItem(ATTR_LINEBREAK
)).GetValue();
940 sal_Bool bAsianVertical
= pNewEngine
->IsVertical(); // set by InputHandler
942 Rectangle aPixRect
= ScEditUtil( pDoc
, nNewX
,nNewY
,nTabNo
, GetScrPos(nNewX
,nNewY
,eWhich
),
943 pWin
, nPPTX
,nPPTY
,GetZoomX(),GetZoomY() ).
944 GetEditArea( pPattern
, sal_True
);
946 // when right-aligned, leave space for the cursor
947 // in vertical mode, editing is always right-aligned
948 if ( nEditAdjust
== SVX_ADJUST_RIGHT
|| bAsianVertical
)
949 aPixRect
.Right() += 1;
951 Rectangle aOutputArea
= pWin
->PixelToLogic( aPixRect
, GetLogicMode() );
952 pEditView
[eWhich
]->SetOutputArea( aOutputArea
);
954 if ( bActive
&& eWhich
== GetActivePart() )
956 // keep the part that has the active edit view available after
957 // switching sheets or reference input on a different part
958 eEditActivePart
= eWhich
;
960 // modify members nEditCol etc. only if also extending for needed area
963 const ScMergeAttr
* pMergeAttr
= (ScMergeAttr
*)&pPattern
->GetItem(ATTR_MERGE
);
964 nEditEndCol
= nEditCol
;
965 if (pMergeAttr
->GetColMerge() > 1)
966 nEditEndCol
+= pMergeAttr
->GetColMerge() - 1;
967 nEditEndRow
= nEditRow
;
968 if (pMergeAttr
->GetRowMerge() > 1)
969 nEditEndRow
+= pMergeAttr
->GetRowMerge() - 1;
970 nEditStartCol
= nEditCol
;
972 // For growing use only the alignment value from the attribute, numbers
973 // (existing or started) with default aligment extend to the right.
974 sal_Bool bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
975 sal_Bool bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
976 sal_Bool bGrowBackwards
= bGrowToLeft
; // logical left
978 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
979 if ( bAsianVertical
)
980 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= false; // keep old behavior for asian mode
983 if (bBreak
&& !bAsianVertical
)
984 nSizeXPix
= aPixRect
.GetWidth(); // Papersize -> kein H-Scrolling
987 OSL_ENSURE(pView
,"keine View fuer EditView");
991 // growing into both directions until one edge is reached
992 //! should be limited to whole cells in both directions
993 long nLeft
= aPixRect
.Left();
994 long nRight
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Right();
995 nSizeXPix
= aPixRect
.GetWidth() + 2 * std::min( nLeft
, nRight
);
997 else if ( bGrowToLeft
)
998 nSizeXPix
= aPixRect
.Right(); // space that's available in the window when growing to the left
1000 nSizeXPix
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Left();
1002 if ( nSizeXPix
<= 0 )
1003 nSizeXPix
= aPixRect
.GetWidth(); // editing outside to the right of the window -> keep cell width
1005 OSL_ENSURE(pView
,"keine View fuer EditView");
1006 long nSizeYPix
= pView
->GetGridHeight(WhichV(eWhich
)) - aPixRect
.Top();
1007 if ( nSizeYPix
<= 0 )
1008 nSizeYPix
= aPixRect
.GetHeight(); // editing outside below the window -> keep cell height
1010 Size aPaperSize
= pView
->GetActiveWin()->PixelToLogic( Size( nSizeXPix
, nSizeYPix
), GetLogicMode() );
1011 if ( bBreak
&& !bAsianVertical
&& SC_MOD()->GetInputOptions().GetTextWysiwyg() )
1013 // if text is formatted for printer, use the exact same paper width
1014 // (and same line breaks) as for output.
1016 Fraction
aFract(1,1);
1017 Rectangle aUtilRect
= ScEditUtil( pDoc
,nNewX
,nNewY
,nTabNo
, Point(0,0), pWin
,
1018 HMM_PER_TWIPS
, HMM_PER_TWIPS
, aFract
, aFract
).GetEditArea( pPattern
, false );
1019 aPaperSize
.Width() = aUtilRect
.GetWidth();
1021 pNewEngine
->SetPaperSize( aPaperSize
);
1023 // sichtbarer Ausschnitt
1024 Size aPaper
= pNewEngine
->GetPaperSize();
1025 Rectangle aVis
= pEditView
[eWhich
]->GetVisArea();
1026 long nDiff
= aVis
.Right() - aVis
.Left();
1027 if ( nEditAdjust
== SVX_ADJUST_RIGHT
)
1029 aVis
.Right() = aPaper
.Width() - 1;
1030 bMoveArea
= !bLayoutRTL
;
1032 else if ( nEditAdjust
== SVX_ADJUST_CENTER
)
1034 aVis
.Right() = ( aPaper
.Width() - 1 + nDiff
) / 2;
1035 bMoveArea
= sal_True
; // always
1039 aVis
.Right() = nDiff
;
1040 bMoveArea
= bLayoutRTL
;
1042 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 pEditView
[eWhich
]->SetVisArea(aVis
);
1050 // UpdateMode has been disabled in ScInputHandler::StartTable
1051 // must be enabled before EditGrowY (GetTextHeight)
1052 pNewEngine
->SetUpdateMode( sal_True
);
1054 pNewEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EditEngineHdl
) );
1056 EditGrowY( sal_True
); // adjust to existing text content
1059 Point aDocPos
= pEditView
[eWhich
]->GetWindowPosTopLeft(0);
1060 if (aDocPos
.Y() < aOutputArea
.Top())
1061 pEditView
[eWhich
]->Scroll( 0, aOutputArea
.Top() - aDocPos
.Y() );
1064 // hier muss bEditActive schon gesetzt sein
1065 // (wegen Map-Mode bei Paint)
1067 pNewEngine
->InsertView(pEditView
[eWhich
]);
1069 // background color of the cell
1070 Color aBackCol
= ((const SvxBrushItem
&)pPattern
->GetItem(ATTR_BACKGROUND
)).GetColor();
1072 ScModule
* pScMod
= SC_MOD();
1073 if ( aBackCol
.GetTransparency() > 0 )
1075 aBackCol
.SetColor( pScMod
->GetColorConfig().GetColorValue(svtools::DOCCOLOR
).nColor
);
1077 pEditView
[eWhich
]->SetBackgroundColor( aBackCol
);
1079 pEditView
[eWhich
]->Invalidate(); // needed ??
1080 // needed, wenn position changed
1083 IMPL_LINK_NOARG_INLINE_START(ScViewData
, EmptyEditHdl
)
1087 IMPL_LINK_NOARG_INLINE_END(ScViewData
, EmptyEditHdl
)
1089 IMPL_LINK( ScViewData
, EditEngineHdl
, EditStatus
*, pStatus
)
1091 sal_uLong nStatus
= pStatus
->GetStatusWord();
1092 if (nStatus
& (EE_STAT_HSCROLL
| EE_STAT_TEXTHEIGHTCHANGED
| EE_STAT_TEXTWIDTHCHANGED
| EE_STAT_CURSOROUT
))
1097 if (nStatus
& EE_STAT_CURSOROUT
)
1099 ScSplitPos eWhich
= GetActivePart();
1100 if (pEditView
[eWhich
])
1101 pEditView
[eWhich
]->ShowCursor(false);
1107 void ScViewData::EditGrowX()
1109 ScDocument
* pLocalDoc
= GetDocument();
1111 ScSplitPos eWhich
= GetActivePart();
1112 ScHSplitPos eHWhich
= WhichH(eWhich
);
1113 EditView
* pCurView
= pEditView
[eWhich
];
1115 if ( !pCurView
|| !bEditActive
[eWhich
])
1118 sal_Bool bLayoutRTL
= pLocalDoc
->IsLayoutRTL( nTabNo
);
1120 ScEditEngineDefaulter
* pEngine
=
1121 (ScEditEngineDefaulter
*) pCurView
->GetEditEngine();
1122 Window
* pWin
= pCurView
->GetWindow();
1124 SCCOL nLeft
= GetPosX(eHWhich
);
1125 SCCOL nRight
= nLeft
+ VisibleCellsX(eHWhich
);
1127 Size aSize
= pEngine
->GetPaperSize();
1128 Rectangle aArea
= pCurView
->GetOutputArea();
1129 long nOldRight
= aArea
.Right();
1131 // Margin ist schon bei der urspruenglichen Breite beruecksichtigt
1132 long nTextWidth
= pEngine
->CalcTextWidth();
1134 sal_Bool bChanged
= false;
1135 sal_Bool bAsianVertical
= pEngine
->IsVertical();
1137 // get bGrow... variables the same way as in SetEditEngine
1138 const ScPatternAttr
* pPattern
= pLocalDoc
->GetPattern( nEditCol
, nEditRow
, nTabNo
);
1139 SvxCellHorJustify eJust
= (SvxCellHorJustify
)((const SvxHorJustifyItem
&)
1140 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
1141 sal_Bool bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
1142 sal_Bool bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
1143 sal_Bool bGrowBackwards
= bGrowToLeft
; // logical left
1145 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
1146 if ( bAsianVertical
)
1147 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= false; // keep old behavior for asian mode
1149 sal_Bool bUnevenGrow
= false;
1150 if ( bGrowCentered
)
1152 while (aArea
.GetWidth() + 0 < nTextWidth
&& ( nEditStartCol
> nLeft
|| nEditEndCol
< nRight
) )
1154 long nLogicLeft
= 0;
1155 if ( nEditStartCol
> nLeft
)
1158 long nLeftPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1159 nLogicLeft
= pWin
->PixelToLogic(Size(nLeftPix
,0)).Width();
1161 long nLogicRight
= 0;
1162 if ( nEditEndCol
< nRight
)
1165 long nRightPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1166 nLogicRight
= pWin
->PixelToLogic(Size(nRightPix
,0)).Width();
1169 aArea
.Left() -= bLayoutRTL
? nLogicRight
: nLogicLeft
;
1170 aArea
.Right() += bLayoutRTL
? nLogicLeft
: nLogicRight
;
1172 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1174 long nCenter
= ( aArea
.Left() + aArea
.Right() ) / 2;
1175 long nHalf
= aSize
.Width() / 2;
1176 aArea
.Left() = nCenter
- nHalf
+ 1;
1177 aArea
.Right() = nCenter
+ aSize
.Width() - nHalf
- 1;
1180 bChanged
= sal_True
;
1181 if ( nLogicLeft
!= nLogicRight
)
1182 bUnevenGrow
= sal_True
;
1185 else if ( bGrowBackwards
)
1187 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditStartCol
> nLeft
)
1190 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1191 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1193 aArea
.Left() -= nLogicWidth
;
1195 aArea
.Right() += nLogicWidth
;
1197 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1200 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1202 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1205 bChanged
= sal_True
;
1210 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditEndCol
< nRight
)
1213 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1214 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1216 aArea
.Left() -= nLogicWidth
;
1218 aArea
.Right() += nLogicWidth
;
1220 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1223 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1225 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1228 bChanged
= sal_True
;
1234 if ( bMoveArea
|| bGrowCentered
|| bGrowBackwards
|| bLayoutRTL
)
1236 Rectangle aVis
= pCurView
->GetVisArea();
1238 if ( bGrowCentered
)
1240 // switch to center-aligned (undo?) and reset VisArea to center
1242 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
1244 long nCenter
= aSize
.Width() / 2;
1245 long nVisSize
= aArea
.GetWidth();
1246 aVis
.Left() = nCenter
- nVisSize
/ 2;
1247 aVis
.Right() = aVis
.Left() + nVisSize
- 1;
1249 else if ( bGrowToLeft
)
1251 // switch to right-aligned (undo?) and reset VisArea to the right
1253 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
1255 aVis
.Right() = aSize
.Width() - 1;
1256 aVis
.Left() = aSize
.Width() - aArea
.GetWidth(); // with the new, increased area
1260 // switch to left-aligned (undo?) and reset VisArea to the left
1262 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
1264 long nMove
= aVis
.Left();
1266 aVis
.Right() -= nMove
;
1268 pCurView
->SetVisArea( aVis
);
1272 pCurView
->SetOutputArea(aArea
);
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.
1280 aArea
.Left() = pWin
->PixelToLogic( Point(0,0) ).X();
1281 aArea
.Right() = pWin
->PixelToLogic( aScrSize
).Width();
1283 else if ( !bAsianVertical
&& !bGrowToLeft
&& !bGrowCentered
)
1284 aArea
.Left() = nOldRight
;
1285 pWin
->Invalidate(aArea
);
1289 void ScViewData::EditGrowY( sal_Bool bInitial
)
1291 ScSplitPos eWhich
= GetActivePart();
1292 ScVSplitPos eVWhich
= WhichV(eWhich
);
1293 EditView
* pCurView
= pEditView
[eWhich
];
1295 if ( !pCurView
|| !bEditActive
[eWhich
])
1298 sal_uLong nControl
= pEditView
[eWhich
]->GetControlWord();
1299 if ( nControl
& EV_CNTRL_AUTOSCROLL
)
1301 // if end of screen had already been reached and scrolling enabled,
1302 // don't further try to grow the edit area
1304 pCurView
->SetOutputArea( pCurView
->GetOutputArea() ); // re-align to pixels
1308 EditEngine
* pEngine
= pCurView
->GetEditEngine();
1309 Window
* pWin
= pCurView
->GetWindow();
1311 SCROW nBottom
= GetPosY(eVWhich
) + VisibleCellsY(eVWhich
);
1313 Size aSize
= pEngine
->GetPaperSize();
1314 Rectangle aArea
= pCurView
->GetOutputArea();
1315 long nOldBottom
= aArea
.Bottom();
1316 long nTextHeight
= pEngine
->GetTextHeight();
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 long nAllowedExtra
= SC_GROWY_SMALL_EXTRA
;
1322 if ( nEditEndRow
== nEditRow
&& !( pDoc
->GetRowFlags( nEditRow
, nTabNo
) & CR_MANUALSIZE
) &&
1323 pEngine
->GetParagraphCount() <= 1 )
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 OUString aText
= pEngine
->GetText( 0 );
1331 if ( ( aText
.isEmpty() && bInitial
) || (!aText
.isEmpty() && aText
[0] == '=') )
1332 nAllowedExtra
= SC_GROWY_BIG_EXTRA
;
1335 sal_Bool bChanged
= false;
1336 sal_Bool bMaxReached
= false;
1337 while (aArea
.GetHeight() + nAllowedExtra
< nTextHeight
&& nEditEndRow
< nBottom
&& !bMaxReached
)
1340 ScDocument
* pLocalDoc
= GetDocument();
1341 long nPix
= ToPixel( pLocalDoc
->GetRowHeight( nEditEndRow
, nTabNo
), nPPTY
);
1342 aArea
.Bottom() += pWin
->PixelToLogic(Size(0,nPix
)).Height();
1344 if ( aArea
.Bottom() > aArea
.Top() + aSize
.Height() - 1 )
1346 aArea
.Bottom() = aArea
.Top() + aSize
.Height() - 1;
1347 bMaxReached
= sal_True
; // don't occupy more cells beyond paper size
1350 bChanged
= sal_True
;
1351 nAllowedExtra
= SC_GROWY_SMALL_EXTRA
; // larger value is only for first row
1356 pCurView
->SetOutputArea(aArea
);
1358 if (nEditEndRow
>= nBottom
|| bMaxReached
)
1360 if ((nControl
& EV_CNTRL_AUTOSCROLL
) == 0)
1361 pCurView
->SetControlWord( nControl
| EV_CNTRL_AUTOSCROLL
);
1364 aArea
.Top() = nOldBottom
;
1365 pWin
->Invalidate(aArea
);
1369 void ScViewData::ResetEditView()
1371 EditEngine
* pEngine
= NULL
;
1372 for (sal_uInt16 i
=0; i
<4; i
++)
1377 pEngine
= pEditView
[i
]->GetEditEngine();
1378 pEngine
->RemoveView(pEditView
[i
]);
1379 pEditView
[i
]->SetOutputArea( Rectangle() );
1381 bEditActive
[i
] = false;
1385 pEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EmptyEditHdl
) );
1388 void ScViewData::KillEditView()
1390 for (sal_uInt16 i
=0; i
<4; i
++)
1394 pEditView
[i
]->GetEditEngine()->RemoveView(pEditView
[i
]);
1395 delete pEditView
[i
];
1396 pEditView
[i
] = NULL
;
1400 void ScViewData::GetEditView( ScSplitPos eWhich
, EditView
*& rViewPtr
, SCCOL
& rCol
, SCROW
& rRow
)
1402 rViewPtr
= pEditView
[eWhich
];
1407 void ScViewData::CreateTabData( SCTAB nNewTab
)
1409 EnsureTabDataSize(nNewTab
+ 1);
1411 if (!maTabData
[nNewTab
])
1413 maTabData
[nNewTab
] = new ScViewDataTable
;
1415 maTabData
[nNewTab
]->eZoomType
= eDefZoomType
;
1416 maTabData
[nNewTab
]->aZoomX
= aDefZoomX
;
1417 maTabData
[nNewTab
]->aZoomY
= aDefZoomY
;
1418 maTabData
[nNewTab
]->aPageZoomX
= aDefPageZoomX
;
1419 maTabData
[nNewTab
]->aPageZoomY
= aDefPageZoomY
;
1423 void ScViewData::CreateSelectedTabData()
1425 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
1426 for (; itr
!= itrEnd
; ++itr
)
1427 CreateTabData(*itr
);
1430 void ScViewData::EnsureTabDataSize(size_t nSize
)
1432 if (nSize
>= maTabData
.size())
1434 size_t n
= nSize
- maTabData
.size() + 1;
1435 maTabData
.insert(maTabData
.end(), n
, NULL
);
1439 void ScViewData::SetTabNo( SCTAB nNewTab
)
1441 if (!ValidTab(nNewTab
))
1443 OSL_FAIL("falsche Tabellennummer");
1448 CreateTabData(nTabNo
);
1449 pThisTab
= maTabData
[nTabNo
];
1451 CalcPPT(); // for common column width correction
1452 RecalcPixPos(); //! nicht immer noetig!
1455 void ScViewData::SetActivePart( ScSplitPos eNewActive
)
1457 pThisTab
->eWhichActive
= eNewActive
;
1460 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScHSplitPos eWhich
) const
1462 OSL_ENSURE( eWhich
==SC_SPLIT_LEFT
|| eWhich
==SC_SPLIT_RIGHT
, "Falsche Position" );
1463 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_LEFT
) ? SC_SPLIT_BOTTOMLEFT
: SC_SPLIT_BOTTOMRIGHT
;
1464 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1467 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScVSplitPos eWhich
) const
1469 OSL_ENSURE( eWhich
==SC_SPLIT_TOP
|| eWhich
==SC_SPLIT_BOTTOM
, "Falsche Position" );
1470 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_TOP
) ? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
1471 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1474 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScSplitPos eWhich
,
1475 sal_Bool bAllowNeg
) const
1477 ScHSplitPos eWhichX
= SC_SPLIT_LEFT
;
1478 ScVSplitPos eWhichY
= SC_SPLIT_BOTTOM
;
1481 case SC_SPLIT_TOPLEFT
:
1482 eWhichX
= SC_SPLIT_LEFT
;
1483 eWhichY
= SC_SPLIT_TOP
;
1485 case SC_SPLIT_TOPRIGHT
:
1486 eWhichX
= SC_SPLIT_RIGHT
;
1487 eWhichY
= SC_SPLIT_TOP
;
1489 case SC_SPLIT_BOTTOMLEFT
:
1490 eWhichX
= SC_SPLIT_LEFT
;
1491 eWhichY
= SC_SPLIT_BOTTOM
;
1493 case SC_SPLIT_BOTTOMRIGHT
:
1494 eWhichX
= SC_SPLIT_RIGHT
;
1495 eWhichY
= SC_SPLIT_BOTTOM
;
1501 ((ScViewData
*)this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1502 ((ScViewData
*)this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1507 SCCOL nPosX
= GetPosX(eWhichX
);
1511 if (nWhereX
>= nPosX
)
1512 for (nX
=nPosX
; nX
<nWhereX
&& (bAllowNeg
|| nScrPosX
<=aScrSize
.Width()); nX
++)
1518 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1521 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1522 nScrPosX
+= nSizeXPix
;
1527 for (nX
=nPosX
; nX
>nWhereX
;)
1530 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1533 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1534 nScrPosX
-= nSizeXPix
;
1538 SCROW nPosY
= GetPosY(eWhichY
);
1542 if (nWhereY
>= nPosY
)
1543 for (nY
=nPosY
; nY
<nWhereY
&& (bAllowNeg
|| nScrPosY
<=aScrSize
.Height()); nY
++)
1549 nTSize
= pDoc
->GetRowHeight( nY
, nTabNo
);
1552 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1553 nScrPosY
+= nSizeYPix
;
1555 else if ( nY
< MAXROW
)
1557 // skip multiple hidden rows (forward only for now)
1558 SCROW nNext
= pDoc
->FirstVisibleRow(nY
+ 1, MAXROW
, nTabNo
);
1559 if ( nNext
> MAXROW
)
1562 nY
= nNext
- 1; // +=nDir advances to next visible row
1567 for (nY
=nPosY
; nY
>nWhereY
;)
1570 nTSize
= pDoc
->GetRowHeight( nY
, nTabNo
);
1573 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1574 nScrPosY
-= nSizeYPix
;
1578 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1580 // mirror horizontal position
1581 nScrPosX
= aScrSize
.Width() - 1 - nScrPosX
;
1584 if (nScrPosX
> 32767) nScrPosX
=32767;
1585 if (nScrPosY
> 32767) nScrPosY
=32767;
1586 return Point( nScrPosX
, nScrPosY
);
1590 // Number of cells on a screen
1593 SCCOL
ScViewData::CellsAtX( SCsCOL nPosX
, SCsCOL nDir
, ScHSplitPos eWhichX
, sal_uInt16 nScrSizeX
) const
1595 OSL_ENSURE( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1598 ((ScViewData
*)this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1601 sal_uInt16 nScrPosX
= 0;
1602 if (nScrSizeX
== SC_SIZE_NONE
) nScrSizeX
= (sal_uInt16
) aScrSize
.Width();
1605 nX
= nPosX
; // vorwaerts
1607 nX
= nPosX
-1; // rueckwaerts
1609 sal_Bool bOut
= false;
1610 for ( ; nScrPosX
<=nScrSizeX
&& !bOut
; nX
= sal::static_int_cast
<SCsCOL
>(nX
+ nDir
) )
1613 if ( nColNo
< 0 || nColNo
> MAXCOL
)
1617 sal_uInt16 nTSize
= pDoc
->GetColWidth( nColNo
, nTabNo
);
1620 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1621 nScrPosX
= sal::static_int_cast
<sal_uInt16
>( nScrPosX
+ (sal_uInt16
) nSizeXPix
);
1627 nX
= sal::static_int_cast
<SCsCOL
>( nX
- nPosX
);
1635 SCROW
ScViewData::CellsAtY( SCsROW nPosY
, SCsROW nDir
, ScVSplitPos eWhichY
, sal_uInt16 nScrSizeY
) const
1637 OSL_ENSURE( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1640 ((ScViewData
*)this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1642 if (nScrSizeY
== SC_SIZE_NONE
) nScrSizeY
= (sal_uInt16
) aScrSize
.Height();
1651 AddPixelsWhile( nScrPosY
, nScrSizeY
, nY
, MAXROW
, nPPTY
, pDoc
, nTabNo
);
1652 // Original loop ended on last evaluated +1 or if that was MAXROW even
1654 nY
+= (nY
== MAXROW
? 2 : 1);
1662 AddPixelsWhileBackward( nScrPosY
, nScrSizeY
, nY
, 0, nPPTY
, pDoc
, nTabNo
);
1663 // Original loop ended on last evaluated -1 or if that was 0 even on
1665 nY
-= (nY
== 0 ? 2 : 1);
1673 SCCOL
ScViewData::VisibleCellsX( ScHSplitPos eWhichX
) const
1675 return CellsAtX( GetPosX( eWhichX
), 1, eWhichX
, SC_SIZE_NONE
);
1678 SCROW
ScViewData::VisibleCellsY( ScVSplitPos eWhichY
) const
1680 return CellsAtY( GetPosY( eWhichY
), 1, eWhichY
, SC_SIZE_NONE
);
1683 SCCOL
ScViewData::PrevCellsX( ScHSplitPos eWhichX
) const
1685 return CellsAtX( GetPosX( eWhichX
), -1, eWhichX
, SC_SIZE_NONE
);
1688 SCROW
ScViewData::PrevCellsY( ScVSplitPos eWhichY
) const
1690 return CellsAtY( GetPosY( eWhichY
), -1, eWhichY
, SC_SIZE_NONE
);
1694 bool ScViewData::GetMergeSizePixel( SCCOL nX
, SCROW nY
, long& rSizeXPix
, long& rSizeYPix
) const
1696 const ScMergeAttr
* pMerge
= (const ScMergeAttr
*) pDoc
->GetAttr( nX
,nY
,nTabNo
, ATTR_MERGE
);
1697 if ( pMerge
->GetColMerge() > 1 || pMerge
->GetRowMerge() > 1 )
1700 long nOutHeight
= 0;
1701 SCCOL nCountX
= pMerge
->GetColMerge();
1702 for (SCCOL i
=0; i
<nCountX
; i
++)
1703 nOutWidth
+= ToPixel( pDoc
->GetColWidth(nX
+i
,nTabNo
), nPPTX
);
1704 SCROW nCountY
= pMerge
->GetRowMerge();
1706 for (SCROW nRow
= nY
; nRow
<= nY
+nCountY
-1; ++nRow
)
1708 SCROW nLastRow
= nRow
;
1709 if (pDoc
->RowHidden(nRow
, nTabNo
, NULL
, &nLastRow
))
1715 sal_uInt16 nHeight
= pDoc
->GetRowHeight(nRow
, nTabNo
);
1716 nOutHeight
+= ToPixel(nHeight
, nPPTY
);
1719 rSizeXPix
= nOutWidth
;
1720 rSizeYPix
= nOutHeight
;
1725 rSizeXPix
= ToPixel( pDoc
->GetColWidth( nX
, nTabNo
), nPPTX
);
1726 rSizeYPix
= ToPixel( pDoc
->GetRowHeight( nY
, nTabNo
), nPPTY
);
1731 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
)
1735 // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
1737 ScHSplitPos eHWhich
= WhichH(eWhich
);
1738 ScVSplitPos eVWhich
= WhichV(eWhich
);
1740 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1742 // mirror horizontal position
1744 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1745 nClickX
= aScrSize
.Width() - 1 - nClickX
;
1748 SCsCOL nStartPosX
= GetPosX(eHWhich
);
1749 SCsROW nStartPosY
= GetPosY(eVWhich
);
1757 while ( rPosX
<=MAXCOL
&& nClickX
>= nScrX
)
1759 nScrX
+= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1766 while ( rPosX
>0 && nClickX
< nScrX
)
1769 nScrX
-= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1774 AddPixelsWhile( nScrY
, nClickY
, rPosY
, MAXROW
, nPPTY
, pDoc
, nTabNo
);
1777 /* TODO: could need some "SubPixelsWhileBackward" method */
1778 while ( rPosY
>0 && nClickY
< nScrY
)
1781 nScrY
-= ToPixel( pDoc
->GetRowHeight( rPosY
, nTabNo
), nPPTY
);
1785 if (bNextIfLarge
) // zu grosse Zellen ?
1787 if ( rPosX
== nStartPosX
&& nClickX
> 0 )
1790 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1791 if ( nClickX
> aScrSize
.Width() )
1794 if ( rPosY
== nStartPosY
&& nClickY
> 0 )
1797 aScrSize
.Height() = pView
->GetGridHeight(eVWhich
);
1798 if ( nClickY
> aScrSize
.Height() )
1803 if (rPosX
<0) rPosX
=0;
1804 if (rPosX
>MAXCOL
) rPosX
=MAXCOL
;
1805 if (rPosY
<0) rPosY
=0;
1806 if (rPosY
>MAXROW
) rPosY
=MAXROW
;
1810 //! public Methode um Position anzupassen
1812 SCCOL nOrigX
= rPosX
;
1813 SCROW nOrigY
= rPosY
;
1814 pDoc
->SkipOverlapped(rPosX
, rPosY
, nTabNo
);
1815 bool bHOver
= (nOrigX
!= rPosX
);
1816 bool bVOver
= (nOrigY
!= rPosY
);
1818 if ( bRepair
&& ( bHOver
|| bVOver
) )
1820 const ScMergeAttr
* pMerge
= (const ScMergeAttr
*)
1821 pDoc
->GetAttr( rPosX
, rPosY
, nTabNo
, ATTR_MERGE
);
1822 if ( ( bHOver
&& pMerge
->GetColMerge() <= 1 ) ||
1823 ( bVOver
&& pMerge
->GetRowMerge() <= 1 ) )
1825 OSL_FAIL("Merge-Fehler gefunden");
1827 pDoc
->RemoveFlagsTab( 0,0, MAXCOL
,MAXROW
, nTabNo
, SC_MF_HOR
| SC_MF_VER
);
1828 SCCOL nEndCol
= MAXCOL
;
1829 SCROW nEndRow
= MAXROW
;
1830 pDoc
->ExtendMerge( 0,0, nEndCol
,nEndRow
, nTabNo
, sal_True
);
1832 pDocShell
->PostPaint( ScRange(0,0,nTabNo
,MAXCOL
,MAXROW
,nTabNo
), PAINT_GRID
);
1840 void ScViewData::GetMouseQuadrant( const Point
& rClickPos
, ScSplitPos eWhich
,
1841 SCsCOL nPosX
, SCsROW nPosY
, sal_Bool
& rLeft
, sal_Bool
& rTop
)
1843 sal_Bool bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
1844 long nLayoutSign
= bLayoutRTL
? -1 : 1;
1846 Point aCellStart
= GetScrPos( nPosX
, nPosY
, eWhich
, sal_True
);
1849 GetMergeSizePixel( nPosX
, nPosY
, nSizeX
, nSizeY
);
1850 rLeft
= ( rClickPos
.X() - aCellStart
.X() ) * nLayoutSign
<= nSizeX
/ 2;
1851 rTop
= rClickPos
.Y() - aCellStart
.Y() <= nSizeY
/ 2;
1854 void ScViewData::SetPosX( ScHSplitPos eWhich
, SCCOL nNewPosX
)
1858 SCCOL nOldPosX
= pThisTab
->nPosX
[eWhich
];
1859 long nTPosX
= pThisTab
->nTPosX
[eWhich
];
1860 long nPixPosX
= pThisTab
->nPixPosX
[eWhich
];
1862 if ( nNewPosX
> nOldPosX
)
1863 for ( i
=nOldPosX
; i
<nNewPosX
; i
++ )
1865 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1867 nPixPosX
-= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTX
);
1870 for ( i
=nNewPosX
; i
<nOldPosX
; i
++ )
1872 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1874 nPixPosX
+= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTX
);
1877 pThisTab
->nPosX
[eWhich
] = nNewPosX
;
1878 pThisTab
->nTPosX
[eWhich
] = nTPosX
;
1879 pThisTab
->nMPosX
[eWhich
] = (long) (nTPosX
* HMM_PER_TWIPS
);
1880 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
1883 pThisTab
->nPixPosX
[eWhich
] =
1884 pThisTab
->nTPosX
[eWhich
] =
1885 pThisTab
->nMPosX
[eWhich
] =
1886 pThisTab
->nPosX
[eWhich
] = 0;
1889 void ScViewData::SetPosY( ScVSplitPos eWhich
, SCROW nNewPosY
)
1893 SCROW nOldPosY
= pThisTab
->nPosY
[eWhich
];
1894 long nTPosY
= pThisTab
->nTPosY
[eWhich
];
1895 long nPixPosY
= pThisTab
->nPixPosY
[eWhich
];
1896 SCROW i
, nHeightEndRow
;
1897 if ( nNewPosY
> nOldPosY
)
1898 for ( i
=nOldPosY
; i
<nNewPosY
; i
++ )
1900 long nThis
= pDoc
->GetRowHeight( i
, nTabNo
, NULL
, &nHeightEndRow
);
1901 SCROW nRows
= std::min( nNewPosY
, nHeightEndRow
+ 1) - i
;
1903 nTPosY
-= nThis
* nRows
;
1904 nPixPosY
-= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTY
) * nRows
;
1907 for ( i
=nNewPosY
; i
<nOldPosY
; i
++ )
1909 long nThis
= pDoc
->GetRowHeight( i
, nTabNo
, NULL
, &nHeightEndRow
);
1910 SCROW nRows
= std::min( nOldPosY
, nHeightEndRow
+ 1) - i
;
1912 nTPosY
+= nThis
* nRows
;
1913 nPixPosY
+= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTY
) * nRows
;
1916 pThisTab
->nPosY
[eWhich
] = nNewPosY
;
1917 pThisTab
->nTPosY
[eWhich
] = nTPosY
;
1918 pThisTab
->nMPosY
[eWhich
] = (long) (nTPosY
* HMM_PER_TWIPS
);
1919 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
1922 pThisTab
->nPixPosY
[eWhich
] =
1923 pThisTab
->nTPosY
[eWhich
] =
1924 pThisTab
->nMPosY
[eWhich
] =
1925 pThisTab
->nPosY
[eWhich
] = 0;
1928 void ScViewData::RecalcPixPos() // nach Zoom-Aenderungen
1930 for (sal_uInt16 eWhich
=0; eWhich
<2; eWhich
++)
1933 SCCOL nPosX
= pThisTab
->nPosX
[eWhich
];
1934 for (SCCOL i
=0; i
<nPosX
; i
++)
1935 nPixPosX
-= ToPixel(pDoc
->GetColWidth(i
,nTabNo
), nPPTX
);
1936 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
1939 SCROW nPosY
= pThisTab
->nPosY
[eWhich
];
1940 for (SCROW j
=0; j
<nPosY
; j
++)
1941 nPixPosY
-= ToPixel(pDoc
->GetRowHeight(j
,nTabNo
), nPPTY
);
1942 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
1946 const MapMode
& ScViewData::GetLogicMode( ScSplitPos eWhich
)
1948 aLogicMode
.SetOrigin( Point( pThisTab
->nMPosX
[WhichH(eWhich
)],
1949 pThisTab
->nMPosY
[WhichV(eWhich
)] ) );
1953 const MapMode
& ScViewData::GetLogicMode()
1955 aLogicMode
.SetOrigin( Point() );
1959 void ScViewData::SetScreen( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
)
1968 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
1969 SetPosX( SC_SPLIT_LEFT
, nCol1
);
1970 SetPosY( SC_SPLIT_BOTTOM
, nRow1
);
1972 for (nCol
=nCol1
; nCol
<=nCol2
; nCol
++)
1974 nTSize
= pDoc
->GetColWidth( nCol
, nTabNo
);
1977 nSizePix
= ToPixel( nTSize
, nPPTX
);
1978 nScrPosX
+= (sal_uInt16
) nSizePix
;
1982 for (nRow
=nRow1
; nRow
<=nRow2
; nRow
++)
1984 nTSize
= pDoc
->GetRowHeight( nRow
, nTabNo
);
1987 nSizePix
= ToPixel( nTSize
, nPPTY
);
1988 nScrPosY
+= (sal_uInt16
) nSizePix
;
1992 aScrSize
= Size( nScrPosX
, nScrPosY
);
1995 void ScViewData::SetScreenPos( const Point
& rVisAreaStart
)
2003 nTwips
= (long) (rVisAreaStart
.X() / HMM_PER_TWIPS
);
2004 if ( pDoc
->IsLayoutRTL( nTabNo
) )
2010 nAdd
= (long) pDoc
->GetColWidth(nX1
,nTabNo
);
2011 if (nSize
+nAdd
<= nTwips
+1 && nX1
<MAXCOL
)
2021 nTwips
= (long) (rVisAreaStart
.Y() / HMM_PER_TWIPS
);
2026 nAdd
= (long) pDoc
->GetRowHeight(nY1
,nTabNo
);
2027 if (nSize
+nAdd
<= nTwips
+1 && nY1
<MAXROW
)
2036 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
2037 SetPosX( SC_SPLIT_LEFT
, nX1
);
2038 SetPosY( SC_SPLIT_BOTTOM
, nY1
);
2044 void ScViewData::SetScreen( const Rectangle
& rVisArea
)
2046 SetScreenPos( rVisArea
.TopLeft() );
2048 // hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile
2050 aScrSize
= rVisArea
.GetSize();
2051 aScrSize
.Width() = (long)
2052 ( aScrSize
.Width() * ScGlobal::nScreenPPTX
/ HMM_PER_TWIPS
);
2053 aScrSize
.Height() = (long)
2054 ( aScrSize
.Height() * ScGlobal::nScreenPPTY
/ HMM_PER_TWIPS
);
2057 SfxObjectShell
* ScViewData::GetSfxDocShell() const
2062 ScDocFunc
& ScViewData::GetDocFunc() const
2064 return pDocShell
->GetDocFunc();
2067 SfxBindings
& ScViewData::GetBindings()
2069 OSL_ENSURE( pViewShell
, "GetBindings() without ViewShell" );
2070 return pViewShell
->GetViewFrame()->GetBindings();
2073 SfxDispatcher
& ScViewData::GetDispatcher()
2075 OSL_ENSURE( pViewShell
, "GetDispatcher() without ViewShell" );
2076 return *pViewShell
->GetViewFrame()->GetDispatcher();
2079 ScMarkData
& ScViewData::GetMarkData()
2084 const ScMarkData
& ScViewData::GetMarkData() const
2089 Window
* ScViewData::GetDialogParent()
2091 OSL_ENSURE( pViewShell
, "GetDialogParent() ohne ViewShell" );
2092 return pViewShell
->GetDialogParent();
2095 Window
* ScViewData::GetActiveWin()
2097 OSL_ENSURE( pView
, "GetActiveWin() ohne View" );
2098 return pView
->GetActiveWin();
2101 ScDrawView
* ScViewData::GetScDrawView()
2103 OSL_ENSURE( pView
, "GetScDrawView() ohne View" );
2104 return pView
->GetScDrawView();
2107 sal_Bool
ScViewData::IsMinimized()
2109 OSL_ENSURE( pView
, "IsMinimized() ohne View" );
2110 return pView
->IsMinimized();
2113 void ScViewData::UpdateScreenZoom( const Fraction
& rNewX
, const Fraction
& rNewY
)
2115 Fraction aOldX
= GetZoomX();
2116 Fraction aOldY
= GetZoomY();
2118 SetZoom( rNewX
, rNewY
, false );
2120 Fraction aWidth
= GetZoomX();
2121 aWidth
*= Fraction( aScrSize
.Width(),1 );
2124 Fraction aHeight
= GetZoomY();
2125 aHeight
*= Fraction( aScrSize
.Height(),1 );
2128 aScrSize
.Width() = (long) aWidth
;
2129 aScrSize
.Height() = (long) aHeight
;
2132 void ScViewData::CalcPPT()
2134 nPPTX
= ScGlobal::nScreenPPTX
* (double) GetZoomX();
2136 nPPTX
= nPPTX
/ pDocShell
->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
2137 nPPTY
= ScGlobal::nScreenPPTY
* (double) GetZoomY();
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
2143 if ( pDoc
&& pDoc
->HasDetectiveObjects(nTabNo
) )
2147 pDoc
->GetTableArea( nTabNo
, nEndCol
, nDummy
);
2149 nEndCol
= 20; // same end position as when determining draw scale
2151 sal_uInt16 nTwips
= pDoc
->GetCommonWidth( nEndCol
, nTabNo
);
2154 double fOriginal
= nTwips
* nPPTX
;
2155 if ( fOriginal
< static_cast<double>(nEndCol
) )
2157 // if one column is smaller than the column count,
2158 // rounding errors are likely to add up to a whole column.
2160 double fRounded
= ::rtl::math::approxFloor( fOriginal
+ 0.5 );
2161 if ( fRounded
> 0.0 )
2163 double fScale
= fRounded
/ fOriginal
+ 1E-6;
2164 if ( fScale
>= 0.9 && fScale
<= 1.1 )
2172 #define SC_OLD_TABSEP '/'
2173 #define SC_NEW_TABSEP '+'
2175 void ScViewData::WriteUserData(OUString
& rData
)
2177 // nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
2179 // Tab-ControlBreite
2181 // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
2182 // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
2183 // wenn Zeilen groesser 8192, "+" statt "/"
2185 sal_uInt16 nZoom
= (sal_uInt16
)((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2186 rData
= OUString::number( nZoom
) + "/";
2187 nZoom
= (sal_uInt16
)((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2188 rData
+= OUString::number( nZoom
) + "/";
2194 rData
+= ";" + OUString::number( nTabNo
) + ";" + TAG_TABBARWIDTH
+
2195 OUString::number( pView
->GetTabBarWidth() );
2197 SCTAB nTabCount
= pDoc
->GetTableCount();
2198 for (SCTAB i
=0; i
<nTabCount
; i
++)
2200 rData
+= ";"; // Numerierung darf auf keinen Fall durcheinanderkommen
2201 if (i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
])
2203 OUString cTabSep
= OUString(SC_OLD_TABSEP
); // wie 3.1
2204 if ( maTabData
[i
]->nCurY
> MAXROW_30
||
2205 maTabData
[i
]->nPosY
[0] > MAXROW_30
|| maTabData
[i
]->nPosY
[1] > MAXROW_30
||
2206 ( maTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
&&
2207 maTabData
[i
]->nFixPosY
> MAXROW_30
) )
2209 cTabSep
= OUString(SC_NEW_TABSEP
); // um eine 3.1-Version nicht umzubringen
2213 rData
+= OUString::number( maTabData
[i
]->nCurX
) + cTabSep
+
2214 OUString::number( maTabData
[i
]->nCurY
) + cTabSep
+
2215 OUString::number( maTabData
[i
]->eHSplitMode
) + cTabSep
+
2216 OUString::number( maTabData
[i
]->eVSplitMode
) + cTabSep
;
2217 if ( maTabData
[i
]->eHSplitMode
== SC_SPLIT_FIX
)
2218 rData
+= OUString::number( maTabData
[i
]->nFixPosX
);
2220 rData
+= OUString::number( maTabData
[i
]->nHSplitPos
);
2222 if ( maTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
)
2223 rData
+= OUString::number( maTabData
[i
]->nFixPosY
);
2225 rData
+= OUString::number( maTabData
[i
]->nVSplitPos
);
2227 OUString::number( maTabData
[i
]->eWhichActive
) + cTabSep
+
2228 OUString::number( maTabData
[i
]->nPosX
[0] ) + cTabSep
+
2229 OUString::number( maTabData
[i
]->nPosX
[1] ) + cTabSep
+
2230 OUString::number( maTabData
[i
]->nPosY
[0] ) + cTabSep
+
2231 OUString::number( maTabData
[i
]->nPosY
[1] );
2236 void ScViewData::ReadUserData(const OUString
& rData
)
2238 if (rData
.isEmpty()) // Leerer String kommt bei "neu Laden"
2239 return; // dann auch ohne Assertion beenden
2241 sal_Int32 nCount
= comphelper::string::getTokenCount(rData
, ';');
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");
2250 // nicht pro Tabelle:
2251 SCTAB nTabStart
= 2;
2253 Fraction aZoomX
, aZoomY
, aPageZoomX
, aPageZoomY
; //! evaluate (all sheets?)
2255 OUString aZoomStr
= rData
.getToken(0, ';'); // Zoom/PageZoom/Modus
2256 sal_uInt16 nNormZoom
= sal::static_int_cast
<sal_uInt16
>(aZoomStr
.getToken(0,'/').toInt32());
2257 if ( nNormZoom
>= MINZOOM
&& nNormZoom
<= MAXZOOM
)
2258 aZoomX
= aZoomY
= Fraction( nNormZoom
, 100 ); // "normaler" Zoom (immer)
2259 sal_uInt16 nPageZoom
= sal::static_int_cast
<sal_uInt16
>(aZoomStr
.getToken(1,'/').toInt32());
2260 if ( nPageZoom
>= MINZOOM
&& nPageZoom
<= MAXZOOM
)
2261 aPageZoomX
= aPageZoomY
= Fraction( nPageZoom
, 100 ); // Pagebreak-Zoom, wenn gesetzt
2262 sal_Unicode cMode
= aZoomStr
.getToken(2,'/')[0]; // 0 oder "0"/"1"
2263 SetPagebreakMode( cMode
== '1' );
2264 // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
2267 // Tabelle kann ungueltig geworden sein (z.B. letzte Version):
2269 SCTAB nNewTab
= static_cast<SCTAB
>(rData
.getToken(1, ';').toInt32());
2270 if (pDoc
->HasTable( nNewTab
))
2274 // wenn vorhanden, TabBar-Breite holen:
2276 OUString aTabOpt
= rData
.getToken(2, ';');
2278 if (aTabOpt
.startsWith(TAG_TABBARWIDTH
))
2280 sal_Int32 nTagLen
= RTL_CONSTASCII_LENGTH(TAG_TABBARWIDTH
);
2281 pView
->SetTabBarWidth(aTabOpt
.copy(nTagLen
).toInt32());
2287 while ( nCount
> nPos
+nTabStart
)
2289 aTabOpt
= rData
.getToken(static_cast<sal_Int32
>(nPos
+nTabStart
), ';');
2290 EnsureTabDataSize(nPos
+ 1);
2291 if (!maTabData
[nPos
])
2292 maTabData
[nPos
] = new ScViewDataTable
;
2294 sal_Unicode cTabSep
= 0;
2295 if (comphelper::string::getTokenCount(aTabOpt
, SC_OLD_TABSEP
) >= 11)
2296 cTabSep
= SC_OLD_TABSEP
;
2297 #ifndef SC_LIMIT_ROWS
2298 else if (comphelper::string::getTokenCount(aTabOpt
, SC_NEW_TABSEP
) >= 11)
2299 cTabSep
= SC_NEW_TABSEP
;
2300 // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
2305 maTabData
[nPos
]->nCurX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(0,cTabSep
).toInt32()));
2306 maTabData
[nPos
]->nCurY
= SanitizeRow( aTabOpt
.getToken(1,cTabSep
).toInt32());
2307 maTabData
[nPos
]->eHSplitMode
= (ScSplitMode
) aTabOpt
.getToken(2,cTabSep
).toInt32();
2308 maTabData
[nPos
]->eVSplitMode
= (ScSplitMode
) aTabOpt
.getToken(3,cTabSep
).toInt32();
2310 if ( maTabData
[nPos
]->eHSplitMode
== SC_SPLIT_FIX
)
2312 maTabData
[nPos
]->nFixPosX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(4,cTabSep
).toInt32()));
2316 maTabData
[nPos
]->nHSplitPos
= aTabOpt
.getToken(4,cTabSep
).toInt32();
2318 if ( maTabData
[nPos
]->eVSplitMode
== SC_SPLIT_FIX
)
2320 maTabData
[nPos
]->nFixPosY
= SanitizeRow( aTabOpt
.getToken(5,cTabSep
).toInt32());
2324 maTabData
[nPos
]->nVSplitPos
= aTabOpt
.getToken(5,cTabSep
).toInt32();
2326 maTabData
[nPos
]->eWhichActive
= (ScSplitPos
) aTabOpt
.getToken(6,cTabSep
).toInt32();
2327 maTabData
[nPos
]->nPosX
[0] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(7,cTabSep
).toInt32()));
2328 maTabData
[nPos
]->nPosX
[1] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(8,cTabSep
).toInt32()));
2329 maTabData
[nPos
]->nPosY
[0] = SanitizeRow( aTabOpt
.getToken(9,cTabSep
).toInt32());
2330 maTabData
[nPos
]->nPosY
[1] = SanitizeRow( aTabOpt
.getToken(10,cTabSep
).toInt32());
2332 // Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
2334 ScSplitPos eTest
= maTabData
[nPos
]->eWhichActive
;
2335 if ( ( WhichH( eTest
) == SC_SPLIT_RIGHT
&&
2336 maTabData
[nPos
]->eHSplitMode
== SC_SPLIT_NONE
) ||
2337 ( WhichV( eTest
) == SC_SPLIT_TOP
&&
2338 maTabData
[nPos
]->eVSplitMode
== SC_SPLIT_NONE
) )
2340 // dann wieder auf Default (unten links)
2341 maTabData
[nPos
]->eWhichActive
= SC_SPLIT_BOTTOMLEFT
;
2342 OSL_FAIL("SplitPos musste korrigiert werden");
2351 void ScViewData::WriteExtOptions( ScExtDocOptions
& rDocOpt
) const
2353 // *** Fill extended document data for export filters ***
2355 // document settings
2356 ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2359 rDocSett
.mnDisplTab
= GetTabNo();
2361 // width of the tabbar, relative to frame window width
2362 rDocSett
.mfTabBarWidth
= pView
->GetPendingRelTabBarWidth();
2363 if( rDocSett
.mfTabBarWidth
< 0.0 )
2364 rDocSett
.mfTabBarWidth
= pView
->GetRelTabBarWidth();
2367 for( SCTAB nTab
= 0; nTab
< static_cast<SCTAB
>(maTabData
.size()); ++nTab
)
2369 if( const ScViewDataTable
* pViewTab
= maTabData
[ nTab
] )
2371 ScExtTabSettings
& rTabSett
= rDocOpt
.GetOrCreateTabSettings( nTab
);
2374 ScSplitMode eHSplit
= pViewTab
->eHSplitMode
;
2375 ScSplitMode eVSplit
= pViewTab
->eVSplitMode
;
2376 bool bHSplit
= eHSplit
!= SC_SPLIT_NONE
;
2377 bool bVSplit
= eVSplit
!= SC_SPLIT_NONE
;
2378 bool bRealSplit
= (eHSplit
== SC_SPLIT_NORMAL
) || (eVSplit
== SC_SPLIT_NORMAL
);
2379 bool bFrozen
= (eHSplit
== SC_SPLIT_FIX
) || (eVSplit
== SC_SPLIT_FIX
);
2380 OSL_ENSURE( !bRealSplit
|| !bFrozen
, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
2381 rTabSett
.mbFrozenPanes
= !bRealSplit
&& bFrozen
;
2383 // split and freeze position
2384 rTabSett
.maSplitPos
= Point( 0, 0 );
2385 rTabSett
.maFreezePos
.Set( 0, 0, nTab
);
2388 Point
& rSplitPos
= rTabSett
.maSplitPos
;
2389 rSplitPos
= Point( bHSplit
? pViewTab
->nHSplitPos
: 0, bVSplit
? pViewTab
->nVSplitPos
: 0 );
2390 rSplitPos
= Application::GetDefaultDevice()->PixelToLogic( rSplitPos
, MapMode( MAP_TWIP
) );
2392 rSplitPos
.X() = (long)((double)rSplitPos
.X() / pDocShell
->GetOutputFactor());
2396 if( bHSplit
) rTabSett
.maFreezePos
.SetCol( pViewTab
->nFixPosX
);
2397 if( bVSplit
) rTabSett
.maFreezePos
.SetRow( pViewTab
->nFixPosY
);
2400 // first visible cell in top-left and additional panes
2401 rTabSett
.maFirstVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_LEFT
], pViewTab
->nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
], nTab
);
2402 rTabSett
.maSecondVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_RIGHT
], pViewTab
->nPosY
[ SC_SPLIT_BOTTOM
], nTab
);
2405 switch( pViewTab
->eWhichActive
)
2407 // no horizontal split -> always use left panes
2408 // no vertical split -> always use top panes
2409 case SC_SPLIT_TOPLEFT
:
2410 rTabSett
.meActivePane
= SCEXT_PANE_TOPLEFT
;
2412 case SC_SPLIT_TOPRIGHT
:
2413 rTabSett
.meActivePane
= bHSplit
? SCEXT_PANE_TOPRIGHT
: SCEXT_PANE_TOPLEFT
;
2415 case SC_SPLIT_BOTTOMLEFT
:
2416 rTabSett
.meActivePane
= bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
;
2418 case SC_SPLIT_BOTTOMRIGHT
:
2419 rTabSett
.meActivePane
= bHSplit
?
2420 (bVSplit
? SCEXT_PANE_BOTTOMRIGHT
: SCEXT_PANE_TOPRIGHT
) :
2421 (bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
);
2426 rTabSett
.maCursor
.Set( pViewTab
->nCurX
, pViewTab
->nCurY
, nTab
);
2428 // sheet selection and selected ranges
2429 const ScMarkData
& rMarkData
= GetMarkData();
2430 rTabSett
.mbSelected
= rMarkData
.GetTableSelect( nTab
);
2431 rMarkData
.FillRangeListWithMarks( &rTabSett
.maSelection
, sal_True
);
2434 rTabSett
.maGridColor
.SetColor( COL_AUTO
);
2437 const Color
& rGridColor
= pOptions
->GetGridColor();
2438 if( rGridColor
.GetColor() != SC_STD_GRIDCOLOR
)
2439 rTabSett
.maGridColor
= rGridColor
;
2441 rTabSett
.mbShowGrid
= pViewTab
->bShowGrid
;
2443 // view mode and zoom
2444 rTabSett
.mbPageMode
= bPagebreak
;
2445 rTabSett
.mnNormalZoom
= static_cast< long >( pViewTab
->aZoomY
* Fraction( 100.0 ) );
2446 rTabSett
.mnPageZoom
= static_cast< long >( pViewTab
->aPageZoomY
* Fraction( 100.0 ) );
2451 void ScViewData::ReadExtOptions( const ScExtDocOptions
& rDocOpt
)
2453 // *** Get extended document data from import filters ***
2455 if( !rDocOpt
.IsChanged() ) return;
2457 // document settings
2458 const ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2461 SetTabNo( rDocSett
.mnDisplTab
);
2463 /* Width of the tabbar, relative to frame window width. We do not have the
2464 correct width of the frame window here -> store in ScTabView, which sets
2465 the size in the next resize. */
2466 pView
->SetPendingRelTabBarWidth( rDocSett
.mfTabBarWidth
);
2469 for( SCTAB nTab
= 0; nTab
< static_cast<SCTAB
>(maTabData
.size()); ++nTab
)
2471 if( const ScExtTabSettings
* pTabSett
= rDocOpt
.GetTabSettings( nTab
) )
2473 if( !maTabData
[ nTab
] )
2474 maTabData
[ nTab
] = new ScViewDataTable
;
2476 const ScExtTabSettings
& rTabSett
= *pTabSett
;
2477 ScViewDataTable
& rViewTab
= *maTabData
[ nTab
];
2479 // split mode initialization
2480 bool bFrozen
= rTabSett
.mbFrozenPanes
;
2481 bool bHSplit
= bFrozen
? (rTabSett
.maFreezePos
.Col() > 0) : (rTabSett
.maSplitPos
.X() > 0);
2482 bool bVSplit
= bFrozen
? (rTabSett
.maFreezePos
.Row() > 0) : (rTabSett
.maSplitPos
.Y() > 0);
2484 // first visible cell of top-left pane and additional panes
2485 rViewTab
.nPosX
[ SC_SPLIT_LEFT
] = rTabSett
.maFirstVis
.Col();
2486 rViewTab
.nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
] = rTabSett
.maFirstVis
.Row();
2487 if( bHSplit
) rViewTab
.nPosX
[ SC_SPLIT_RIGHT
] = rTabSett
.maSecondVis
.Col();
2488 if( bVSplit
) rViewTab
.nPosY
[ SC_SPLIT_BOTTOM
] = rTabSett
.maSecondVis
.Row();
2490 // split mode, split and freeze position
2491 rViewTab
.eHSplitMode
= rViewTab
.eVSplitMode
= SC_SPLIT_NONE
;
2492 rViewTab
.nHSplitPos
= rViewTab
.nVSplitPos
= 0;
2493 rViewTab
.nFixPosX
= 0;
2494 rViewTab
.nFixPosY
= 0;
2499 rViewTab
.eHSplitMode
= SC_SPLIT_FIX
;
2500 rViewTab
.nFixPosX
= rTabSett
.maFreezePos
.Col();
2505 rViewTab
.eVSplitMode
= SC_SPLIT_FIX
;
2506 rViewTab
.nFixPosY
= rTabSett
.maFreezePos
.Row();
2512 Point aPixel
= Application::GetDefaultDevice()->LogicToPixel(
2513 rTabSett
.maSplitPos
, MapMode( MAP_TWIP
) ); //! Zoom?
2514 // the test for use of printer metrics for text formatting here
2515 // effectively results in the nFactor = 1.0 regardless of the Option setting.
2516 if( pDocShell
&& SC_MOD()->GetInputOptions().GetTextWysiwyg())
2518 double nFactor
= pDocShell
->GetOutputFactor();
2519 aPixel
.X() = (long)( aPixel
.X() * nFactor
+ 0.5 );
2522 bHSplit
= bHSplit
&& aPixel
.X() > 0;
2523 bVSplit
= bVSplit
&& aPixel
.Y() > 0;
2526 rViewTab
.eHSplitMode
= SC_SPLIT_NORMAL
;
2527 rViewTab
.nHSplitPos
= aPixel
.X();
2531 rViewTab
.eVSplitMode
= SC_SPLIT_NORMAL
;
2532 rViewTab
.nVSplitPos
= aPixel
.Y();
2537 ScSplitPos ePos
= SC_SPLIT_BOTTOMLEFT
;
2538 switch( rTabSett
.meActivePane
)
2540 // no horizontal split -> always use left panes
2541 // no vertical split -> always use *bottom* panes
2542 case SCEXT_PANE_TOPLEFT
:
2543 ePos
= bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
2545 case SCEXT_PANE_TOPRIGHT
:
2547 (bVSplit
? SC_SPLIT_TOPRIGHT
: SC_SPLIT_BOTTOMRIGHT
) :
2548 (bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
);
2550 case SCEXT_PANE_BOTTOMLEFT
:
2551 ePos
= SC_SPLIT_BOTTOMLEFT
;
2553 case SCEXT_PANE_BOTTOMRIGHT
:
2554 ePos
= bHSplit
? SC_SPLIT_BOTTOMRIGHT
: SC_SPLIT_BOTTOMLEFT
;
2557 rViewTab
.eWhichActive
= ePos
;
2560 const ScAddress
& rCursor
= rTabSett
.maCursor
;
2561 if( rCursor
.IsValid() )
2563 rViewTab
.nCurX
= rCursor
.Col();
2564 rViewTab
.nCurY
= rCursor
.Row();
2567 // sheet selection and selected ranges
2568 ScMarkData
& rMarkData
= GetMarkData();
2569 rMarkData
.SelectTable( nTab
, rTabSett
.mbSelected
);
2571 // zoom for each sheet
2572 if( rTabSett
.mnNormalZoom
)
2573 rViewTab
.aZoomX
= rViewTab
.aZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2574 if( rTabSett
.mnPageZoom
)
2575 rViewTab
.aPageZoomX
= rViewTab
.aPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2577 rViewTab
.bShowGrid
= rTabSett
.mbShowGrid
;
2579 // get some settings from displayed Excel sheet, set at Calc document
2580 if( nTab
== GetTabNo() )
2582 // grid color -- #i47435# set automatic grid color explicitly
2585 Color
aGridColor( rTabSett
.maGridColor
);
2586 if( aGridColor
.GetColor() == COL_AUTO
)
2587 aGridColor
.SetColor( SC_STD_GRIDCOLOR
);
2588 pOptions
->SetGridColor( aGridColor
, EMPTY_OUSTRING
);
2591 // view mode and default zoom (for new sheets) from current sheet
2592 if( rTabSett
.mnNormalZoom
)
2593 aDefZoomX
= aDefZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2594 if( rTabSett
.mnPageZoom
)
2595 aDefPageZoomX
= aDefPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2596 /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
2597 update map modes that are needed to draw text correctly. */
2598 SetPagebreakMode( rTabSett
.mbPageMode
);
2603 // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
2606 void ScViewData::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
) const
2608 rSettings
.realloc(SC_VIEWSETTINGS_COUNT
);
2609 // + 1, because we have to put the view id in the sequence
2610 beans::PropertyValue
* pSettings
= rSettings
.getArray();
2613 sal_uInt16
nViewID(pViewShell
->GetViewFrame()->GetCurViewId());
2614 pSettings
[SC_VIEW_ID
].Name
= OUString(SC_VIEWID
);
2615 OUStringBuffer
sBuffer(OUString(SC_VIEW
));
2616 ::sax::Converter::convertNumber(sBuffer
,
2617 static_cast<sal_Int32
>(nViewID
));
2618 pSettings
[SC_VIEW_ID
].Value
<<= sBuffer
.makeStringAndClear();
2620 uno::Reference
<container::XNameContainer
> xNameContainer
=
2621 document::NamedPropertyValues::create( comphelper::getProcessComponentContext() );
2622 for (SCTAB nTab
=0; nTab
<static_cast<SCTAB
>(maTabData
.size()); nTab
++)
2624 if (maTabData
[nTab
])
2626 uno::Sequence
<beans::PropertyValue
> aTableViewSettings
;
2627 maTabData
[nTab
]->WriteUserDataSequence(aTableViewSettings
, *this, nTab
);
2629 GetDocument()->GetName( nTab
, sTabName
);
2631 aAny
<<= aTableViewSettings
;
2634 xNameContainer
->insertByName(sTabName
, aAny
);
2636 //#101739#; two tables with the same name are possible
2637 catch ( container::ElementExistException
& )
2639 OSL_FAIL("seems there are two tables with the same name");
2641 catch ( uno::RuntimeException
& )
2643 OSL_FAIL("something went wrong");
2647 pSettings
[SC_TABLE_VIEWSETTINGS
].Name
= OUString(SC_TABLES
);
2648 pSettings
[SC_TABLE_VIEWSETTINGS
].Value
<<= xNameContainer
;
2651 GetDocument()->GetName( nTabNo
, sName
);
2652 pSettings
[SC_ACTIVE_TABLE
].Name
= OUString(SC_ACTIVETABLE
);
2653 pSettings
[SC_ACTIVE_TABLE
].Value
<<= sName
;
2654 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Name
= OUString(SC_HORIZONTALSCROLLBARWIDTH
);
2655 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Value
<<= sal_Int32(pView
->GetTabBarWidth());
2656 sal_Int32
nZoomValue ((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2657 sal_Int32
nPageZoomValue ((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2658 pSettings
[SC_ZOOM_TYPE
].Name
= OUString(SC_ZOOMTYPE
);
2659 pSettings
[SC_ZOOM_TYPE
].Value
<<= sal_Int16(pThisTab
->eZoomType
);
2660 pSettings
[SC_ZOOM_VALUE
].Name
= OUString(SC_ZOOMVALUE
);
2661 pSettings
[SC_ZOOM_VALUE
].Value
<<= nZoomValue
;
2662 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Name
= OUString(SC_PAGEVIEWZOOMVALUE
);
2663 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
2664 pSettings
[SC_PAGE_BREAK_PREVIEW
].Name
= OUString(SC_SHOWPAGEBREAKPREVIEW
);
2665 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_PAGE_BREAK_PREVIEW
].Value
, bPagebreak
);
2669 pSettings
[SC_SHOWZERO
].Name
= OUString(SC_UNO_SHOWZERO
);
2670 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWZERO
].Value
, pOptions
->GetOption( VOPT_NULLVALS
) );
2671 pSettings
[SC_SHOWNOTES
].Name
= OUString(SC_UNO_SHOWNOTES
);
2672 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWNOTES
].Value
, pOptions
->GetOption( VOPT_NOTES
) );
2673 pSettings
[SC_SHOWGRID
].Name
= OUString(SC_UNO_SHOWGRID
);
2674 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWGRID
].Value
, pOptions
->GetOption( VOPT_GRID
) );
2675 pSettings
[SC_GRIDCOLOR
].Name
= OUString(SC_UNO_GRIDCOLOR
);
2676 OUString aColorName
;
2677 Color aColor
= pOptions
->GetGridColor(&aColorName
);
2678 pSettings
[SC_GRIDCOLOR
].Value
<<= static_cast<sal_Int64
>(aColor
.GetColor());
2679 pSettings
[SC_SHOWPAGEBR
].Name
= OUString(SC_UNO_SHOWPAGEBR
);
2680 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWPAGEBR
].Value
, pOptions
->GetOption( VOPT_PAGEBREAKS
) );
2681 pSettings
[SC_COLROWHDR
].Name
= OUString(SC_UNO_COLROWHDR
);
2682 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_COLROWHDR
].Value
, pOptions
->GetOption( VOPT_HEADER
) );
2683 pSettings
[SC_SHEETTABS
].Name
= OUString(SC_UNO_SHEETTABS
);
2684 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHEETTABS
].Value
, pOptions
->GetOption( VOPT_TABCONTROLS
) );
2685 pSettings
[SC_OUTLSYMB
].Name
= OUString(SC_UNO_OUTLSYMB
);
2686 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_OUTLSYMB
].Value
, pOptions
->GetOption( VOPT_OUTLINER
) );
2688 const ScGridOptions
& aGridOpt
= pOptions
->GetGridOptions();
2689 pSettings
[SC_SNAPTORASTER
].Name
= OUString(SC_UNO_SNAPTORASTER
);
2690 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SNAPTORASTER
].Value
, aGridOpt
.GetUseGridSnap() );
2691 pSettings
[SC_RASTERVIS
].Name
= OUString(SC_UNO_RASTERVIS
);
2692 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERVIS
].Value
, aGridOpt
.GetGridVisible() );
2693 pSettings
[SC_RASTERRESX
].Name
= OUString(SC_UNO_RASTERRESX
);
2694 pSettings
[SC_RASTERRESX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDrawX() );
2695 pSettings
[SC_RASTERRESY
].Name
= OUString(SC_UNO_RASTERRESY
);
2696 pSettings
[SC_RASTERRESY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDrawY() );
2697 pSettings
[SC_RASTERSUBX
].Name
= OUString(SC_UNO_RASTERSUBX
);
2698 pSettings
[SC_RASTERSUBX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDivisionX() );
2699 pSettings
[SC_RASTERSUBY
].Name
= OUString(SC_UNO_RASTERSUBY
);
2700 pSettings
[SC_RASTERSUBY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFldDivisionY() );
2701 pSettings
[SC_RASTERSYNC
].Name
= OUString(SC_UNO_RASTERSYNC
);
2702 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERSYNC
].Value
, aGridOpt
.GetSynchronize() );
2707 void ScViewData::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& rSettings
)
2709 std::vector
<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
2711 sal_Int32
nCount(rSettings
.getLength());
2712 sal_Int32
nTemp32(0);
2713 sal_Int16
nTemp16(0);
2714 sal_Bool
bPageMode(false);
2716 EnsureTabDataSize(GetDocument()->GetTableCount()-1);
2718 for (sal_Int32 i
= 0; i
< nCount
; i
++)
2720 // SC_VIEWID has to parse and use by mba
2721 OUString
sName(rSettings
[i
].Name
);
2722 if (sName
.equalsAscii(SC_TABLES
) )
2724 uno::Reference
<container::XNameContainer
> xNameContainer
;
2725 if ((rSettings
[i
].Value
>>= xNameContainer
) && xNameContainer
->hasElements())
2727 uno::Sequence
< OUString
> aNames(xNameContainer
->getElementNames());
2728 for (sal_Int32 nTabPos
= 0; nTabPos
< aNames
.getLength(); nTabPos
++)
2730 OUString
sTabName(aNames
[nTabPos
]);
2732 if (GetDocument()->GetTable(sTabName
, nTab
))
2734 uno::Any aAny
= xNameContainer
->getByName(aNames
[nTabPos
]);
2735 uno::Sequence
<beans::PropertyValue
> aTabSettings
;
2736 if (aAny
>>= aTabSettings
)
2738 EnsureTabDataSize(nTab
+ 1);
2739 if (!maTabData
[nTab
])
2740 maTabData
[nTab
] = new ScViewDataTable
;
2742 bool bHasZoom
= false;
2743 maTabData
[nTab
]->ReadUserDataSequence(aTabSettings
, *this, nTab
, bHasZoom
);
2744 aHasZoomVect
[nTab
] = bHasZoom
;
2750 else if (sName
.equalsAscii(SC_ACTIVETABLE
) )
2753 if(rSettings
[i
].Value
>>= sValue
)
2755 OUString
sTabName(sValue
);
2757 if (GetDocument()->GetTable(sTabName
, nTab
))
2761 else if (sName
.equalsAscii(SC_HORIZONTALSCROLLBARWIDTH
) )
2763 if (rSettings
[i
].Value
>>= nTemp32
)
2764 pView
->SetTabBarWidth(nTemp32
);
2766 else if (sName
.equalsAscii(SC_RELHORIZONTALTABBARWIDTH
) )
2768 double fWidth
= 0.0;
2769 if (rSettings
[i
].Value
>>= fWidth
)
2770 pView
->SetPendingRelTabBarWidth( fWidth
);
2772 else if (sName
.equalsAscii(SC_ZOOMTYPE
) )
2774 if (rSettings
[i
].Value
>>= nTemp16
)
2775 eDefZoomType
= SvxZoomType(nTemp16
);
2777 else if (sName
.equalsAscii(SC_ZOOMVALUE
) )
2779 if (rSettings
[i
].Value
>>= nTemp32
)
2781 Fraction
aZoom(nTemp32
, 100);
2782 aDefZoomX
= aDefZoomY
= aZoom
;
2785 else if (sName
.equalsAscii(SC_PAGEVIEWZOOMVALUE
) )
2787 if (rSettings
[i
].Value
>>= nTemp32
)
2789 Fraction
aZoom(nTemp32
, 100);
2790 aDefPageZoomX
= aDefPageZoomY
= aZoom
;
2793 else if (sName
.equalsAscii(SC_SHOWPAGEBREAKPREVIEW
) )
2794 bPageMode
= ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
);
2795 else if ( sName
.equalsAscii( SC_UNO_SHOWZERO
) )
2796 pOptions
->SetOption(VOPT_NULLVALS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2797 else if ( sName
.equalsAscii( SC_UNO_SHOWNOTES
) )
2798 pOptions
->SetOption(VOPT_NOTES
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2799 else if ( sName
.equalsAscii( SC_UNO_SHOWGRID
) )
2800 pOptions
->SetOption(VOPT_GRID
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2801 else if ( sName
.equalsAscii( SC_UNO_GRIDCOLOR
) )
2803 sal_Int64 nColor
= 0;
2804 if (rSettings
[i
].Value
>>= nColor
)
2806 OUString aColorName
;
2807 Color
aColor(static_cast<sal_uInt32
>(nColor
));
2808 // #i47435# set automatic grid color explicitly
2809 if( aColor
.GetColor() == COL_AUTO
)
2810 aColor
.SetColor( SC_STD_GRIDCOLOR
);
2811 pOptions
->SetGridColor(aColor
, aColorName
);
2814 else if ( sName
.equalsAscii( SC_UNO_SHOWPAGEBR
) )
2815 pOptions
->SetOption(VOPT_PAGEBREAKS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2816 else if ( sName
.equalsAscii( SC_UNO_COLROWHDR
) )
2817 pOptions
->SetOption(VOPT_HEADER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2818 else if ( sName
.equalsAscii( SC_UNO_SHEETTABS
) )
2819 pOptions
->SetOption(VOPT_TABCONTROLS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2820 else if ( sName
.equalsAscii( SC_UNO_OUTLSYMB
) )
2821 pOptions
->SetOption(VOPT_OUTLINER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2822 else if ( sName
.equalsAscii( SC_UNO_SHOWOBJ
) )
2824 // #i80528# placeholders not supported anymore
2825 if ( rSettings
[i
].Value
>>= nTemp16
)
2826 pOptions
->SetObjMode( VOBJ_TYPE_OLE
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2828 else if ( sName
.equalsAscii( SC_UNO_SHOWCHARTS
) )
2830 // #i80528# placeholders not supported anymore
2831 if ( rSettings
[i
].Value
>>= nTemp16
)
2832 pOptions
->SetObjMode( VOBJ_TYPE_CHART
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2834 else if ( sName
.equalsAscii( SC_UNO_SHOWDRAW
) )
2836 // #i80528# placeholders not supported anymore
2837 if ( rSettings
[i
].Value
>>= nTemp16
)
2838 pOptions
->SetObjMode( VOBJ_TYPE_DRAW
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2842 ScGridOptions
aGridOpt(pOptions
->GetGridOptions());
2843 if ( sName
.equalsAscii( SC_UNO_SNAPTORASTER
) )
2844 aGridOpt
.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2845 else if ( sName
.equalsAscii( SC_UNO_RASTERVIS
) )
2846 aGridOpt
.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2847 else if ( sName
.equalsAscii( SC_UNO_RASTERRESX
) )
2848 aGridOpt
.SetFldDrawX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2849 else if ( sName
.equalsAscii( SC_UNO_RASTERRESY
))
2850 aGridOpt
.SetFldDrawY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2851 else if ( sName
.equalsAscii( SC_UNO_RASTERSUBX
) )
2852 aGridOpt
.SetFldDivisionX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2853 else if ( sName
.equalsAscii( SC_UNO_RASTERSUBY
) )
2854 aGridOpt
.SetFldDivisionY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2855 else if ( sName
.equalsAscii( SC_UNO_RASTERSYNC
) )
2856 aGridOpt
.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2857 pOptions
->SetGridOptions(aGridOpt
);
2861 // copy default zoom to sheets where a different one wasn't specified
2862 for (SCTAB nZoomTab
=0; nZoomTab
< static_cast<SCTAB
>(maTabData
.size()); ++nZoomTab
)
2863 if (maTabData
[nZoomTab
] && ( nZoomTab
>= static_cast<SCTAB
>(aHasZoomVect
.size()) || !aHasZoomVect
[nZoomTab
] ))
2865 maTabData
[nZoomTab
]->eZoomType
= eDefZoomType
;
2866 maTabData
[nZoomTab
]->aZoomX
= aDefZoomX
;
2867 maTabData
[nZoomTab
]->aZoomY
= aDefZoomY
;
2868 maTabData
[nZoomTab
]->aPageZoomX
= aDefPageZoomX
;
2869 maTabData
[nZoomTab
]->aPageZoomY
= aDefPageZoomY
;
2873 SetPagebreakMode( bPageMode
);
2875 // #i47426# write view options to document, needed e.g. for Excel export
2876 pDoc
->SetViewOptions( *pOptions
);
2879 void ScViewData::SetOptions( const ScViewOptions
& rOpt
)
2881 // if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
2882 sal_Bool bHScrollChanged
= ( rOpt
.GetOption(VOPT_HSCROLL
) != pOptions
->GetOption(VOPT_HSCROLL
) );
2884 // if graphics are turned on or off, animation has to be started or stopped
2885 // graphics are controlled by VOBJ_TYPE_OLE
2886 sal_Bool bGraphicsChanged
= ( pOptions
->GetObjMode(VOBJ_TYPE_OLE
) !=
2887 rOpt
.GetObjMode(VOBJ_TYPE_OLE
) );
2890 OSL_ENSURE( pView
, "No View" );
2894 pView
->ViewOptionsHasChanged( bHScrollChanged
, bGraphicsChanged
);
2898 Point
ScViewData::GetMousePosPixel()
2900 OSL_ENSURE( pView
, "GetMousePosPixel() ohne View" );
2901 return pView
->GetMousePosPixel();
2904 void ScViewData::UpdateInputHandler( sal_Bool bForce
, sal_Bool bStopEditing
)
2907 pViewShell
->UpdateInputHandler( bForce
, bStopEditing
);
2910 sal_Bool
ScViewData::IsOle()
2912 return pDocShell
&& pDocShell
->IsOle();
2915 sal_Bool
ScViewData::UpdateFixX( SCTAB nTab
) // sal_True = Wert geaendert
2917 if (!ValidTab(nTab
)) // Default
2918 nTab
=nTabNo
; // akuelle Tabelle
2920 if (!pView
|| maTabData
[nTab
]->eHSplitMode
!= SC_SPLIT_FIX
)
2923 ScDocument
* pLocalDoc
= GetDocument();
2924 if (!pLocalDoc
->HasTable(nTab
)) // if called from reload, the sheet may not exist
2927 SCCOL nFix
= maTabData
[nTab
]->nFixPosX
;
2929 for (SCCOL nX
=maTabData
[nTab
]->nPosX
[SC_SPLIT_LEFT
]; nX
<nFix
; nX
++)
2931 sal_uInt16 nTSize
= pLocalDoc
->GetColWidth( nX
, nTab
);
2934 long nPix
= ToPixel( nTSize
, nPPTX
);
2938 nNewPos
+= pView
->GetGridOffset().X();
2939 if (nNewPos
!= maTabData
[nTab
]->nHSplitPos
)
2941 maTabData
[nTab
]->nHSplitPos
= nNewPos
;
2943 RecalcPixPos(); //! sollte nicht noetig sein !!!
2950 sal_Bool
ScViewData::UpdateFixY( SCTAB nTab
) // sal_True = Wert geaendert
2952 if (!ValidTab(nTab
)) // Default
2953 nTab
=nTabNo
; // akuelle Tabelle
2955 if (!pView
|| maTabData
[nTab
]->eVSplitMode
!= SC_SPLIT_FIX
)
2958 ScDocument
* pLocalDoc
= GetDocument();
2959 if (!pLocalDoc
->HasTable(nTab
)) // if called from reload, the sheet may not exist
2962 SCROW nFix
= maTabData
[nTab
]->nFixPosY
;
2964 for (SCROW nY
=maTabData
[nTab
]->nPosY
[SC_SPLIT_TOP
]; nY
<nFix
; nY
++)
2966 sal_uInt16 nTSize
= pLocalDoc
->GetRowHeight( nY
, nTab
);
2969 long nPix
= ToPixel( nTSize
, nPPTY
);
2973 nNewPos
+= pView
->GetGridOffset().Y();
2974 if (nNewPos
!= maTabData
[nTab
]->nVSplitPos
)
2976 maTabData
[nTab
]->nVSplitPos
= nNewPos
;
2978 RecalcPixPos(); //! sollte nicht noetig sein !!!
2985 void ScViewData::UpdateOutlinerFlags( Outliner
& rOutl
) const
2987 ScDocument
* pLocalDoc
= GetDocument();
2988 sal_Bool bOnlineSpell
= pLocalDoc
->GetDocOptions().IsAutoSpell();
2990 sal_uLong nCntrl
= rOutl
.GetControlWord();
2991 nCntrl
|= EE_CNTRL_URLSFXEXECUTE
;
2992 nCntrl
|= EE_CNTRL_MARKFIELDS
;
2993 nCntrl
|= EE_CNTRL_AUTOCORRECT
;
2995 nCntrl
|= EE_CNTRL_ONLINESPELLING
;
2997 nCntrl
&= ~EE_CNTRL_ONLINESPELLING
;
2998 rOutl
.SetControlWord(nCntrl
);
3000 rOutl
.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule
, CalcFieldValueHdl
) );
3002 // don't call GetSpellChecker if online spelling isn't enabled.
3003 // The language for AutoCorrect etc. is taken from the pool defaults
3004 // (set in ScDocument::UpdateDrawLanguages)
3008 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellChecker1
> xXSpellChecker1( LinguMgr::GetSpellChecker() );
3009 rOutl
.SetSpeller( xXSpellChecker1
);
3012 rOutl
.SetDefaultHorizontalTextDirection(
3013 (EEHorizontalTextDirection
)pLocalDoc
->GetEditTextDirection( nTabNo
) );
3016 ScAddress
ScViewData::GetCurPos() const
3018 return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
3022 void ScViewData::AddPixelsWhile( long & rScrY
, long nEndPixels
, SCROW
& rPosY
,
3023 SCROW nEndRow
, double nPPTY
, const ScDocument
* pDoc
, SCTAB nTabNo
)
3026 while (rScrY
<= nEndPixels
&& nRow
<= nEndRow
)
3028 SCROW nHeightEndRow
;
3029 sal_uInt16 nHeight
= pDoc
->GetRowHeight( nRow
, nTabNo
, NULL
, &nHeightEndRow
);
3030 if (nHeightEndRow
> nEndRow
)
3031 nHeightEndRow
= nEndRow
;
3033 nRow
= nHeightEndRow
+ 1;
3036 SCROW nRows
= nHeightEndRow
- nRow
+ 1;
3037 sal_Int64 nPixel
= ToPixel( nHeight
, nPPTY
);
3038 sal_Int64 nAdd
= nPixel
* nRows
;
3039 if (nAdd
+ rScrY
> nEndPixels
)
3041 sal_Int64 nDiff
= rScrY
+ nAdd
- nEndPixels
;
3042 nRows
-= static_cast<SCROW
>(nDiff
/ nPixel
);
3043 nAdd
= nPixel
* nRows
;
3044 // We're looking for a value that satisfies loop condition.
3045 if (nAdd
+ rScrY
<= nEndPixels
)
3051 rScrY
+= static_cast<long>(nAdd
);
3061 void ScViewData::AddPixelsWhileBackward( long & rScrY
, long nEndPixels
,
3062 SCROW
& rPosY
, SCROW nStartRow
, double nPPTY
, const ScDocument
* pDoc
,
3066 while (rScrY
<= nEndPixels
&& nRow
>= nStartRow
)
3068 SCROW nHeightStartRow
;
3069 sal_uInt16 nHeight
= pDoc
->GetRowHeight( nRow
, nTabNo
, &nHeightStartRow
, NULL
);
3070 if (nHeightStartRow
< nStartRow
)
3071 nHeightStartRow
= nStartRow
;
3073 nRow
= nHeightStartRow
- 1;
3076 SCROW nRows
= nRow
- nHeightStartRow
+ 1;
3077 sal_Int64 nPixel
= ToPixel( nHeight
, nPPTY
);
3078 sal_Int64 nAdd
= nPixel
* nRows
;
3079 if (nAdd
+ rScrY
> nEndPixels
)
3081 sal_Int64 nDiff
= nAdd
+ rScrY
- nEndPixels
;
3082 nRows
-= static_cast<SCROW
>(nDiff
/ nPixel
);
3083 nAdd
= nPixel
* nRows
;
3084 // We're looking for a value that satisfies loop condition.
3085 if (nAdd
+ rScrY
<= nEndPixels
)
3091 rScrY
+= static_cast<long>(nAdd
);
3100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */