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 .
20 #include "scitems.hxx"
21 #include <editeng/eeitem.hxx>
23 #include <sfx2/viewfrm.hxx>
24 #include <editeng/adjustitem.hxx>
25 #include <svx/algitem.hxx>
26 #include <editeng/brushitem.hxx>
27 #include <svtools/colorcfg.hxx>
28 #include <editeng/editview.hxx>
29 #include <editeng/editstat.hxx>
30 #include <editeng/outliner.hxx>
31 #include <editeng/unolingu.hxx>
32 #include <editeng/justifyitem.hxx>
34 #include <vcl/svapp.hxx>
35 #include <rtl/math.hxx>
37 #include <sax/tools/converter.hxx>
39 #include "viewdata.hxx"
40 #include "docoptio.hxx"
43 #include "document.hxx"
45 #include "tabview.hxx"
46 #include "tabvwsh.hxx"
49 #include "patattr.hxx"
50 #include "editutil.hxx"
51 #include "scextopt.hxx"
52 #include "miscuno.hxx"
53 #include "unonames.hxx"
54 #include "inputopt.hxx"
55 #include "viewutil.hxx"
56 #include "markdata.hxx"
57 #include "stlalgorithm.hxx"
58 #include "ViewSettingsSequenceDefines.hxx"
59 #include <gridwin.hxx>
60 #include <rtl/ustrbuf.hxx>
61 #include <boost/checked_delete.hpp>
62 #include <comphelper/processfactory.hxx>
63 #include <comphelper/string.hxx>
65 #include <com/sun/star/container/XNameContainer.hpp>
66 #include <com/sun/star/document/NamedPropertyValues.hpp>
68 using namespace com::sun::star
;
70 #define SC_GROWY_SMALL_EXTRA 100
71 #define SC_GROWY_BIG_EXTRA 200
73 #define TAG_TABBARWIDTH "tw:"
75 static bool bMoveArea
= false; // Member?
76 sal_uInt16 nEditAdjust
= SVX_ADJUST_LEFT
; // Member!
78 ScViewDataTable::ScViewDataTable() :
79 eZoomType( SvxZoomType::PERCENT
),
82 aPageZoomX( 3,5 ), // Page-Default: 60%
86 eHSplitMode( SC_SPLIT_NONE
),
87 eVSplitMode( SC_SPLIT_NONE
),
88 eWhichActive( SC_SPLIT_BOTTOMLEFT
),
96 mbOldCursorValid( false )
100 nTPosX
[0]=nTPosX
[1]=0;
101 nTPosY
[0]=nTPosY
[1]=0;
102 nMPosX
[0]=nMPosX
[1]=0;
103 nMPosY
[0]=nMPosY
[1]=0;
104 nPixPosX
[0]=nPixPosX
[1]=0;
105 nPixPosY
[0]=nPixPosY
[1]=0;
108 ScViewDataTable::~ScViewDataTable()
112 void ScViewDataTable::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
, const ScViewData
& /*rViewData*/, SCTAB
/*nTab*/) const
114 rSettings
.realloc(SC_TABLE_VIEWSETTINGS_COUNT
);
115 beans::PropertyValue
* pSettings
= rSettings
.getArray();
118 pSettings
[SC_CURSOR_X
].Name
= SC_CURSORPOSITIONX
;
119 pSettings
[SC_CURSOR_X
].Value
<<= sal_Int32(nCurX
);
120 pSettings
[SC_CURSOR_Y
].Name
= SC_CURSORPOSITIONY
;
121 pSettings
[SC_CURSOR_Y
].Value
<<= sal_Int32(nCurY
);
122 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Name
= SC_HORIZONTALSPLITMODE
;
123 pSettings
[SC_HORIZONTAL_SPLIT_MODE
].Value
<<= sal_Int16(eHSplitMode
);
124 pSettings
[SC_VERTICAL_SPLIT_MODE
].Name
= SC_VERTICALSPLITMODE
;
125 pSettings
[SC_VERTICAL_SPLIT_MODE
].Value
<<= sal_Int16(eVSplitMode
);
126 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Name
= SC_HORIZONTALSPLITPOSITION
;
127 if (eHSplitMode
== SC_SPLIT_FIX
)
128 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosX
);
130 pSettings
[SC_HORIZONTAL_SPLIT_POSITION
].Value
<<= sal_Int32(nHSplitPos
);
131 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Name
= SC_VERTICALSPLITPOSITION
;
132 if (eVSplitMode
== SC_SPLIT_FIX
)
133 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nFixPosY
);
135 pSettings
[SC_VERTICAL_SPLIT_POSITION
].Value
<<= sal_Int32(nVSplitPos
);
136 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Name
= SC_ACTIVESPLITRANGE
;
137 pSettings
[SC_ACTIVE_SPLIT_RANGE
].Value
<<= sal_Int16(eWhichActive
);
138 pSettings
[SC_POSITION_LEFT
].Name
= SC_POSITIONLEFT
;
139 pSettings
[SC_POSITION_LEFT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_LEFT
]);
140 pSettings
[SC_POSITION_RIGHT
].Name
= SC_POSITIONRIGHT
;
141 pSettings
[SC_POSITION_RIGHT
].Value
<<= sal_Int32(nPosX
[SC_SPLIT_RIGHT
]);
142 pSettings
[SC_POSITION_TOP
].Name
= SC_POSITIONTOP
;
143 pSettings
[SC_POSITION_TOP
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_TOP
]);
144 pSettings
[SC_POSITION_BOTTOM
].Name
= SC_POSITIONBOTTOM
;
145 pSettings
[SC_POSITION_BOTTOM
].Value
<<= sal_Int32(nPosY
[SC_SPLIT_BOTTOM
]);
147 sal_Int32
nZoomValue ((aZoomY
.GetNumerator() * 100) / aZoomY
.GetDenominator());
148 sal_Int32
nPageZoomValue ((aPageZoomY
.GetNumerator() * 100) / aPageZoomY
.GetDenominator());
149 pSettings
[SC_TABLE_ZOOM_TYPE
].Name
= SC_ZOOMTYPE
;
150 pSettings
[SC_TABLE_ZOOM_TYPE
].Value
<<= sal_Int16(eZoomType
);
151 pSettings
[SC_TABLE_ZOOM_VALUE
].Name
= SC_ZOOMVALUE
;
152 pSettings
[SC_TABLE_ZOOM_VALUE
].Value
<<= nZoomValue
;
153 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Name
= SC_PAGEVIEWZOOMVALUE
;
154 pSettings
[SC_TABLE_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
156 pSettings
[SC_TABLE_SHOWGRID
].Name
= SC_UNO_SHOWGRID
;
157 pSettings
[SC_TABLE_SHOWGRID
].Value
<<= bShowGrid
;
161 void ScViewDataTable::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& aSettings
, ScViewData
& rViewData
, SCTAB nTab
, bool& rHasZoom
)
165 sal_Int32
nCount(aSettings
.getLength());
166 sal_Int32
nTemp32(0);
167 sal_Int16
nTemp16(0);
168 sal_Int32
nTempPosV(0);
169 sal_Int32
nTempPosH(0);
170 sal_Int32
nTempPosVTw(0);
171 sal_Int32
nTempPosHTw(0);
172 bool bHasVSplitInTwips
= false;
173 bool bHasHSplitInTwips
= false;
174 for (sal_Int32 i
= 0; i
< nCount
; i
++)
176 OUString
sName(aSettings
[i
].Name
);
177 if (sName
== SC_CURSORPOSITIONX
)
179 aSettings
[i
].Value
>>= nTemp32
;
180 nCurX
= SanitizeCol( static_cast<SCCOL
>(nTemp32
));
182 else if (sName
== SC_CURSORPOSITIONY
)
184 aSettings
[i
].Value
>>= nTemp32
;
185 nCurY
= SanitizeRow( static_cast<SCROW
>(nTemp32
));
187 else if (sName
== SC_HORIZONTALSPLITMODE
)
189 aSettings
[i
].Value
>>= nTemp16
;
190 eHSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
192 else if (sName
== SC_VERTICALSPLITMODE
)
194 aSettings
[i
].Value
>>= nTemp16
;
195 eVSplitMode
= static_cast<ScSplitMode
>(nTemp16
);
197 else if (sName
== SC_HORIZONTALSPLITPOSITION
)
199 aSettings
[i
].Value
>>= nTempPosH
;
200 bHasHSplitInTwips
= false;
202 else if (sName
== SC_VERTICALSPLITPOSITION
)
204 aSettings
[i
].Value
>>= nTempPosV
;
205 bHasVSplitInTwips
= false;
207 else if (sName
== SC_HORIZONTALSPLITPOSITION_TWIPS
)
209 aSettings
[i
].Value
>>= nTempPosHTw
;
210 bHasHSplitInTwips
= true;
212 else if (sName
== SC_VERTICALSPLITPOSITION_TWIPS
)
214 aSettings
[i
].Value
>>= nTempPosVTw
;
215 bHasVSplitInTwips
= true;
217 else if (sName
== SC_ACTIVESPLITRANGE
)
219 aSettings
[i
].Value
>>= nTemp16
;
220 eWhichActive
= static_cast<ScSplitPos
>(nTemp16
);
222 else if (sName
== SC_POSITIONLEFT
)
224 aSettings
[i
].Value
>>= nTemp32
;
225 nPosX
[SC_SPLIT_LEFT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
227 else if (sName
== SC_POSITIONRIGHT
)
229 aSettings
[i
].Value
>>= nTemp32
;
230 nPosX
[SC_SPLIT_RIGHT
] = SanitizeCol( static_cast<SCCOL
>(nTemp32
));
232 else if (sName
== SC_POSITIONTOP
)
234 aSettings
[i
].Value
>>= nTemp32
;
235 nPosY
[SC_SPLIT_TOP
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
237 else if (sName
== SC_POSITIONBOTTOM
)
239 aSettings
[i
].Value
>>= nTemp32
;
240 nPosY
[SC_SPLIT_BOTTOM
] = SanitizeRow( static_cast<SCROW
>(nTemp32
));
242 else if (sName
== SC_ZOOMTYPE
)
244 aSettings
[i
].Value
>>= nTemp16
;
245 eZoomType
= SvxZoomType(nTemp16
);
246 rHasZoom
= true; // set if there is any zoom information
248 else if (sName
== SC_ZOOMVALUE
)
250 aSettings
[i
].Value
>>= nTemp32
;
251 Fraction
aZoom(nTemp32
, 100);
252 aZoomX
= aZoomY
= aZoom
;
255 else if (sName
== SC_PAGEVIEWZOOMVALUE
)
257 aSettings
[i
].Value
>>= nTemp32
;
258 Fraction
aZoom(nTemp32
, 100);
259 aPageZoomX
= aPageZoomY
= aZoom
;
262 else if (sName
== SC_UNO_SHOWGRID
)
264 aSettings
[i
].Value
>>= bShowGrid
;
266 else if (sName
== SC_TABLESELECTED
)
268 bool bSelected
= false;
269 aSettings
[i
].Value
>>= bSelected
;
270 rViewData
.GetMarkData().SelectTable( nTab
, bSelected
);
272 else if (sName
== SC_UNONAME_TABCOLOR
)
274 // There are documents out there that have their tab color defined as a view setting.
275 sal_Int32 nColor
= COL_AUTO
;
276 aSettings
[i
].Value
>>= nColor
;
277 if (static_cast<ColorData
>(nColor
) != COL_AUTO
)
279 ScDocument
* pDoc
= rViewData
.GetDocument();
280 pDoc
->SetTabBgColor(nTab
, Color(static_cast<ColorData
>(nColor
)));
284 if (eHSplitMode
== SC_SPLIT_FIX
)
285 nFixPosX
= SanitizeCol( static_cast<SCCOL
>( bHasHSplitInTwips
? nTempPosHTw
: nTempPosH
));
287 nHSplitPos
= bHasHSplitInTwips
? static_cast< long >( nTempPosHTw
* rViewData
.GetPPTX() ) : nTempPosH
;
289 if (eVSplitMode
== SC_SPLIT_FIX
)
290 nFixPosY
= SanitizeRow( static_cast<SCROW
>( bHasVSplitInTwips
? nTempPosVTw
: nTempPosV
));
292 nVSplitPos
= bHasVSplitInTwips
? static_cast< long >( nTempPosVTw
* rViewData
.GetPPTY() ) : nTempPosV
;
295 ScViewData::ScViewData( ScDocShell
* pDocSh
, ScTabViewShell
* pViewSh
) :
296 mpMarkData(new ScMarkData
),
297 pDocShell ( pDocSh
),
300 pViewShell ( pViewSh
),
301 pOptions ( new ScViewOptions
),
302 pSpellingView ( NULL
),
303 aLogicMode ( MAP_100TH_MM
),
304 eDefZoomType( SvxZoomType::PERCENT
),
307 aDefPageZoomX( 3,5 ),
308 aDefPageZoomY( 3,5 ),
309 eRefType ( SC_REFTYPE_NONE
),
322 nPasteFlags ( SC_PASTE_NONE
),
323 eEditActivePart( SC_SPLIT_BOTTOMLEFT
),
324 nFillMode ( SC_FILL_NONE
),
325 bActive ( true ), // how to initialize?
326 bIsRefMode ( false ),
327 bDelMarkValid( false ),
328 bPagebreak ( false ),
329 bSelCtrlMouseClick( false )
331 mpMarkData
->SelectOneTable(0); // Sync with nTabNo
333 SetGridMode ( true );
334 SetSyntaxMode ( false );
335 SetHeaderMode ( true );
337 SetVScrollMode ( true );
338 SetHScrollMode ( true );
339 SetOutlineMode ( true );
341 aScrSize
= Size( (long) ( STD_COL_WIDTH
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_X
),
342 (long) ( ScGlobal::nStdRowHeight
* PIXEL_PER_TWIPS
* OLE_STD_CELLS_Y
) );
343 maTabData
.push_back( new ScViewDataTable
);
344 pThisTab
= maTabData
[nTabNo
];
345 for (sal_uInt16 j
=0; j
<4; j
++)
348 bEditActive
[j
] = false;
351 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
352 nEditEndRow
= nEditRow
= 0;
353 nTabStartCol
= SC_TABSTART_NONE
;
357 pDoc
= &pDocShell
->GetDocument();
358 *pOptions
= pDoc
->GetViewOptions();
361 // don't show hidden tables
362 if (pDoc
&& !pDoc
->IsVisible(nTabNo
))
364 while ( !pDoc
->IsVisible(nTabNo
) && pDoc
->HasTable(nTabNo
+1) )
367 maTabData
.push_back(NULL
);
369 maTabData
[nTabNo
] = new ScViewDataTable() ;
370 pThisTab
= maTabData
[nTabNo
];
375 SCTAB nTableCount
= pDoc
->GetTableCount();
376 EnsureTabDataSize(nTableCount
);
382 ScViewData::ScViewData( const ScViewData
& rViewData
) :
383 maTabData( rViewData
.maTabData
),
384 mpMarkData(new ScMarkData(*rViewData
.mpMarkData
)),
385 pDocShell ( rViewData
.pDocShell
),
386 pDoc ( rViewData
.pDoc
),
387 pView ( rViewData
.pView
),
388 pViewShell ( rViewData
.pViewShell
),
389 pOptions ( new ScViewOptions( *(rViewData
.pOptions
) ) ),
390 pSpellingView ( rViewData
.pSpellingView
),
391 aLogicMode ( rViewData
.aLogicMode
),
392 eDefZoomType( rViewData
.eDefZoomType
),
393 aDefZoomX ( rViewData
.aDefZoomX
),
394 aDefZoomY ( rViewData
.aDefZoomY
),
395 aDefPageZoomX( rViewData
.aDefPageZoomX
),
396 aDefPageZoomY( rViewData
.aDefPageZoomY
),
397 eRefType ( SC_REFTYPE_NONE
),
398 nTabNo ( rViewData
.nTabNo
),
399 nRefTabNo ( rViewData
.nTabNo
), // no RefMode
410 nPasteFlags ( SC_PASTE_NONE
),
411 eEditActivePart( rViewData
.eEditActivePart
),
412 nFillMode ( SC_FILL_NONE
),
413 bActive ( true ), // how to initialize?
414 bIsRefMode ( false ),
415 bDelMarkValid( false ),
416 bPagebreak ( rViewData
.bPagebreak
),
417 bSelCtrlMouseClick( rViewData
.bSelCtrlMouseClick
)
420 SetGridMode ( rViewData
.IsGridMode() );
421 SetSyntaxMode ( rViewData
.IsSyntaxMode() );
422 SetHeaderMode ( rViewData
.IsHeaderMode() );
423 SetTabMode ( rViewData
.IsTabMode() );
424 SetVScrollMode ( rViewData
.IsVScrollMode() );
425 SetHScrollMode ( rViewData
.IsHScrollMode() );
426 SetOutlineMode ( rViewData
.IsOutlineMode() );
428 aScrSize
= rViewData
.aScrSize
;
430 pThisTab
= maTabData
[nTabNo
];
431 for (sal_uInt16 j
=0; j
<4; j
++)
434 bEditActive
[j
] = false;
437 nEditEndCol
= nEditStartCol
= nEditCol
= 0;
438 nEditEndRow
= nEditRow
= 0;
439 nTabStartCol
= SC_TABSTART_NONE
;
443 void ScViewData::InitData( ScDocument
* pDocument
)
446 *pOptions
= pDoc
->GetViewOptions();
449 ScDocument
* ScViewData::GetDocument() const
454 return &pDocShell
->GetDocument();
456 OSL_FAIL("kein Document an ViewData");
460 ScViewData::~ScViewData()
465 maTabData
.begin(), maTabData
.end(), boost::checked_deleter
<ScViewDataTable
>());
468 void ScViewData::UpdateCurrentTab()
470 pThisTab
= maTabData
[nTabNo
];
474 pThisTab
= maTabData
[--nTabNo
];
476 pThisTab
= maTabData
[0] = new ScViewDataTable
;
480 void ScViewData::InsertTab( SCTAB nTab
)
482 if( nTab
>= static_cast<SCTAB
>(maTabData
.size()))
483 maTabData
.resize(nTab
+1, NULL
);
485 maTabData
.insert( maTabData
.begin() + nTab
, (ScViewDataTable
*)NULL
);
486 CreateTabData( nTab
);
489 mpMarkData
->InsertTab( nTab
);
492 void ScViewData::InsertTabs( SCTAB nTab
, SCTAB nNewSheets
)
494 if( nTab
+nNewSheets
>= static_cast<SCTAB
>(maTabData
.size()))
495 maTabData
.resize(nTab
+nNewSheets
, NULL
);
498 maTabData
.insert( maTabData
.begin() + nTab
, nNewSheets
, NULL
);
500 for (SCTAB i
= nTab
; i
< nTab
+ nNewSheets
; ++i
)
503 mpMarkData
->InsertTab( i
);
508 void ScViewData::DeleteTab( SCTAB nTab
)
510 delete maTabData
.at(nTab
);
512 maTabData
.erase(maTabData
.begin() + nTab
);
514 mpMarkData
->DeleteTab( nTab
);
517 void ScViewData::DeleteTabs( SCTAB nTab
, SCTAB nSheets
)
519 for (SCTAB i
= 0; i
< nSheets
; ++i
)
521 mpMarkData
->DeleteTab( nTab
+ i
);
522 delete maTabData
.at(nTab
+ i
);
525 maTabData
.erase(maTabData
.begin() + nTab
, maTabData
.begin()+ nTab
+nSheets
);
529 void ScViewData::CopyTab( SCTAB nSrcTab
, SCTAB nDestTab
)
531 if (nDestTab
==SC_TAB_APPEND
)
532 nDestTab
= pDoc
->GetTableCount() - 1; // something had to have been copied
534 if (nDestTab
> MAXTAB
)
536 OSL_FAIL("Zuviele Tabellen");
540 if (nSrcTab
>= static_cast<SCTAB
>(maTabData
.size()))
541 OSL_FAIL("pTabData out of bounds, FIX IT");
543 EnsureTabDataSize(nDestTab
+ 1);
545 if ( maTabData
[nSrcTab
] )
546 maTabData
.insert(maTabData
.begin() + nDestTab
, new ScViewDataTable( *maTabData
[nSrcTab
] ));
548 maTabData
.insert(maTabData
.begin() + nDestTab
, (ScViewDataTable
*)NULL
);
551 mpMarkData
->InsertTab( nDestTab
);
554 void ScViewData::MoveTab( SCTAB nSrcTab
, SCTAB nDestTab
)
556 if (nDestTab
==SC_TAB_APPEND
)
557 nDestTab
= pDoc
->GetTableCount() - 1;
558 ScViewDataTable
* pTab
= NULL
;
559 if (nSrcTab
< static_cast<SCTAB
>(maTabData
.size()))
561 pTab
= maTabData
[nSrcTab
];
562 maTabData
.erase( maTabData
.begin() + nSrcTab
);
565 if (nDestTab
< static_cast<SCTAB
>(maTabData
.size()))
566 maTabData
.insert( maTabData
.begin() + nDestTab
, pTab
);
569 EnsureTabDataSize(nDestTab
+ 1);
570 maTabData
[nDestTab
] = pTab
;
574 mpMarkData
->DeleteTab( nSrcTab
);
575 mpMarkData
->InsertTab( nDestTab
); // adapted if needed
578 void ScViewData::CreateTabData( std::vector
< SCTAB
>& rvTabs
)
580 std::vector
< SCTAB
>::iterator it_end
= rvTabs
.end();
581 for ( std::vector
< SCTAB
>::iterator it
= rvTabs
.begin(); it
!= it_end
; ++it
)
585 void ScViewData::SetZoomType( SvxZoomType eNew
, std::vector
< SCTAB
>& tabs
)
587 bool bAll
= ( tabs
.empty() );
589 if ( !bAll
) // create associated table data
590 CreateTabData( tabs
);
594 for ( SCTAB i
= 0; i
< static_cast<SCTAB
>(maTabData
.size()); ++i
)
597 maTabData
[i
]->eZoomType
= eNew
;
603 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
604 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
605 for ( ; it
!= it_end
; ++it
)
608 if ( i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
] )
609 maTabData
[i
]->eZoomType
= eNew
;
614 void ScViewData::SetZoomType( SvxZoomType eNew
, bool bAll
)
616 std::vector
< SCTAB
> vTabs
; // Empty for all tabs
617 if ( !bAll
) // get selected tabs
619 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
620 vTabs
.insert(vTabs
.begin(), itr
, itrEnd
);
622 SetZoomType( eNew
, vTabs
);
625 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, std::vector
< SCTAB
>& tabs
)
627 bool bAll
= ( tabs
.empty() );
628 if ( !bAll
) // create associated table data
629 CreateTabData( tabs
);
631 // sanity check - we shouldn't need something this low / big
632 assert(rNewX
> Fraction(1, 100) && rNewX
< Fraction(100, 1));
633 assert(rNewY
> Fraction(1, 100) && rNewY
< Fraction(100, 1));
637 for ( SCTAB i
= 0; i
< static_cast<SCTAB
>(maTabData
.size()); ++i
)
643 maTabData
[i
]->aPageZoomX
= rNewX
;
644 maTabData
[i
]->aPageZoomY
= rNewY
;
648 maTabData
[i
]->aZoomX
= rNewX
;
649 maTabData
[i
]->aZoomY
= rNewY
;
655 aDefPageZoomX
= rNewX
;
656 aDefPageZoomY
= rNewY
;
666 std::vector
< SCTAB
>::iterator it_end
= tabs
.end();
667 std::vector
< SCTAB
>::iterator it
= tabs
.begin();
668 for ( ; it
!= it_end
; ++it
)
671 if ( i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
] )
675 maTabData
[i
]->aPageZoomX
= rNewX
;
676 maTabData
[i
]->aPageZoomY
= rNewY
;
680 maTabData
[i
]->aZoomX
= rNewX
;
681 maTabData
[i
]->aZoomY
= rNewY
;
689 void ScViewData::SetZoom( const Fraction
& rNewX
, const Fraction
& rNewY
, bool bAll
)
691 std::vector
< SCTAB
> vTabs
;
692 if ( !bAll
) // get selected tabs
694 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
695 vTabs
.insert(vTabs
.begin(), itr
, itrEnd
);
697 SetZoom( rNewX
, rNewY
, vTabs
);
700 void ScViewData::SetShowGrid( bool bShow
)
702 CreateSelectedTabData();
703 maTabData
[nTabNo
]->bShowGrid
= bShow
;
706 void ScViewData::RefreshZoom()
708 // recalculate zoom-dependent values (only for current sheet)
712 aScenButSize
= Size(0,0);
713 aLogicMode
.SetScaleX( GetZoomX() );
714 aLogicMode
.SetScaleY( GetZoomY() );
717 void ScViewData::SetPagebreakMode( bool bSet
)
724 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
, ScMarkData
& rNewMark
) const
726 ScMarkType eMarkType
= SC_MARK_NONE
;
728 if ( rNewMark
.IsMarked() || rNewMark
.IsMultiMarked() )
730 if ( rNewMark
.IsMultiMarked() )
731 rNewMark
.MarkToSimple();
733 if ( rNewMark
.IsMarked() && !rNewMark
.IsMultiMarked() )
735 rNewMark
.GetMarkArea( rRange
);
736 if (ScViewUtil::HasFiltered( rRange
, GetDocument()))
737 eMarkType
= SC_MARK_SIMPLE_FILTERED
;
739 eMarkType
= SC_MARK_SIMPLE
;
742 eMarkType
= SC_MARK_MULTI
;
744 if (eMarkType
!= SC_MARK_SIMPLE
&& eMarkType
!= SC_MARK_SIMPLE_FILTERED
)
746 if (eMarkType
== SC_MARK_NONE
)
747 eMarkType
= SC_MARK_SIMPLE
;
748 rRange
= ScRange( GetCurX(), GetCurY(), GetTabNo() );
753 ScMarkType
ScViewData::GetSimpleArea( SCCOL
& rStartCol
, SCROW
& rStartRow
, SCTAB
& rStartTab
,
754 SCCOL
& rEndCol
, SCROW
& rEndRow
, SCTAB
& rEndTab
) const
756 // parameter bMergeMark is no longer needed: The view's selection is never modified
757 // (a local copy is used), and a multi selection that adds to a single range can always
758 // be treated like a single selection (GetSimpleArea isn't used in selection
762 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
763 ScMarkType eMarkType
= GetSimpleArea( aRange
, aNewMark
);
764 aRange
.GetVars( rStartCol
, rStartRow
, rStartTab
, rEndCol
, rEndRow
, rEndTab
);
768 ScMarkType
ScViewData::GetSimpleArea( ScRange
& rRange
) const
770 // parameter bMergeMark is no longer needed, see above
772 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
773 return GetSimpleArea( rRange
, aNewMark
);
776 void ScViewData::GetMultiArea( ScRangeListRef
& rRange
) const
778 // parameter bMergeMark is no longer needed, see GetSimpleArea
780 ScMarkData
aNewMark(*mpMarkData
); // use a local copy for MarkToSimple
782 bool bMulti
= aNewMark
.IsMultiMarked();
785 aNewMark
.MarkToSimple();
786 bMulti
= aNewMark
.IsMultiMarked();
790 rRange
= new ScRangeList
;
791 aNewMark
.FillRangeListWithMarks( rRange
, false );
796 GetSimpleArea(aSimple
);
797 rRange
= new ScRangeList
;
798 rRange
->Append(aSimple
);
802 bool ScViewData::SimpleColMarked()
810 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
811 if (nStartRow
==0 && nEndRow
==MAXROW
)
817 bool ScViewData::SimpleRowMarked()
825 if (GetSimpleArea(nStartCol
,nStartRow
,nStartTab
,nEndCol
,nEndRow
,nEndTab
) == SC_MARK_SIMPLE
)
826 if (nStartCol
==0 && nEndCol
==MAXCOL
)
832 bool ScViewData::IsMultiMarked()
834 // Test for "real" multi selection, calling MarkToSimple on a local copy,
835 // and taking filtered in simple area marks into account.
838 ScMarkType eType
= GetSimpleArea(aDummy
);
839 return (eType
& SC_MARK_SIMPLE
) != SC_MARK_SIMPLE
;
842 void ScViewData::SetFillMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
)
844 nFillMode
= SC_FILL_FILL
;
845 nFillStartX
= nStartCol
;
846 nFillStartY
= nStartRow
;
851 void ScViewData::SetDragMode( SCCOL nStartCol
, SCROW nStartRow
, SCCOL nEndCol
, SCROW nEndRow
,
855 nFillStartX
= nStartCol
;
856 nFillStartY
= nStartRow
;
861 void ScViewData::ResetFillMode()
863 nFillMode
= SC_FILL_NONE
;
866 void ScViewData::GetFillData( SCCOL
& rStartCol
, SCROW
& rStartRow
,
867 SCCOL
& rEndCol
, SCROW
& rEndRow
)
869 rStartCol
= nFillStartX
;
870 rStartRow
= nFillStartY
;
875 SCCOL
ScViewData::GetOldCurX() const
877 if (pThisTab
->mbOldCursorValid
)
878 return pThisTab
->nOldCurX
;
880 return pThisTab
->nCurX
;
883 SCROW
ScViewData::GetOldCurY() const
885 if (pThisTab
->mbOldCursorValid
)
886 return pThisTab
->nOldCurY
;
888 return pThisTab
->nCurY
;
891 void ScViewData::SetOldCursor( SCCOL nNewX
, SCROW nNewY
)
893 pThisTab
->nOldCurX
= nNewX
;
894 pThisTab
->nOldCurY
= nNewY
;
895 pThisTab
->mbOldCursorValid
= true;
898 void ScViewData::ResetOldCursor()
900 pThisTab
->mbOldCursorValid
= false;
903 Rectangle
ScViewData::GetEditArea( ScSplitPos eWhich
, SCCOL nPosX
, SCROW nPosY
,
904 vcl::Window
* pWin
, const ScPatternAttr
* pPattern
,
907 return ScEditUtil( pDoc
, nPosX
, nPosY
, nTabNo
, GetScrPos(nPosX
,nPosY
,eWhich
,true),
908 pWin
, nPPTX
, nPPTY
, GetZoomX(), GetZoomY() ).
909 GetEditArea( pPattern
, bForceToTop
);
912 void ScViewData::SetEditEngine( ScSplitPos eWhich
,
913 ScEditEngineDefaulter
* pNewEngine
,
914 vcl::Window
* pWin
, SCCOL nNewX
, SCROW nNewY
)
916 bool bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
917 ScHSplitPos eHWhich
= WhichH(eWhich
);
919 bool bWasThere
= false;
920 if (pEditView
[eWhich
])
922 // if the view is already therem don't call anything that changes the cursor position
923 if (bEditActive
[eWhich
])
926 pEditView
[eWhich
]->SetEditEngine(pNewEngine
);
928 if (pEditView
[eWhich
]->GetWindow() != pWin
)
930 pEditView
[eWhich
]->SetWindow(pWin
);
931 OSL_FAIL("EditView Window geaendert");
936 pEditView
[eWhich
] = new EditView( pNewEngine
, pWin
);
938 if (pDoc
->GetDrawLayer() && pDoc
->GetDrawLayer()->isTiledRendering())
940 pEditView
[eWhich
]->registerLibreOfficeKitCallback(pDoc
->GetDrawLayer()->getLibreOfficeKitCallback(),
941 pDoc
->GetDrawLayer()->getLibreOfficeKitData());
942 pEditView
[eWhich
]->setTiledRendering(true);
946 // bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
948 EEControlBits nEC
= pNewEngine
->GetControlWord();
949 pNewEngine
->SetControlWord(nEC
& ~EEControlBits::DOIDLEFORMAT
);
951 EVControlBits nVC
= pEditView
[eWhich
]->GetControlWord();
952 pEditView
[eWhich
]->SetControlWord(nVC
& ~EVControlBits::AUTOSCROLL
);
954 bEditActive
[eWhich
] = true;
956 const ScPatternAttr
* pPattern
= pDoc
->GetPattern( nNewX
, nNewY
, nTabNo
);
957 SvxCellHorJustify eJust
= (SvxCellHorJustify
)static_cast<const SvxHorJustifyItem
&>(
958 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
960 bool bBreak
= ( eJust
== SVX_HOR_JUSTIFY_BLOCK
) ||
961 static_cast<const SfxBoolItem
&>(pPattern
->GetItem(ATTR_LINEBREAK
)).GetValue();
963 bool bAsianVertical
= pNewEngine
->IsVertical(); // set by InputHandler
965 Rectangle aPixRect
= ScEditUtil( pDoc
, nNewX
,nNewY
,nTabNo
, GetScrPos(nNewX
,nNewY
,eWhich
),
966 pWin
, nPPTX
,nPPTY
,GetZoomX(),GetZoomY() ).
967 GetEditArea( pPattern
, true );
969 // when right-aligned, leave space for the cursor
970 // in vertical mode, editing is always right-aligned
971 if ( nEditAdjust
== SVX_ADJUST_RIGHT
|| bAsianVertical
)
972 aPixRect
.Right() += 1;
974 Rectangle aOutputArea
= pWin
->PixelToLogic( aPixRect
, GetLogicMode() );
975 pEditView
[eWhich
]->SetOutputArea( aOutputArea
);
977 if ( bActive
&& eWhich
== GetActivePart() )
979 // keep the part that has the active edit view available after
980 // switching sheets or reference input on a different part
981 eEditActivePart
= eWhich
;
983 // modify members nEditCol etc. only if also extending for needed area
986 const ScMergeAttr
* pMergeAttr
= static_cast<const ScMergeAttr
*>(&pPattern
->GetItem(ATTR_MERGE
));
987 nEditEndCol
= nEditCol
;
988 if (pMergeAttr
->GetColMerge() > 1)
989 nEditEndCol
+= pMergeAttr
->GetColMerge() - 1;
990 nEditEndRow
= nEditRow
;
991 if (pMergeAttr
->GetRowMerge() > 1)
992 nEditEndRow
+= pMergeAttr
->GetRowMerge() - 1;
993 nEditStartCol
= nEditCol
;
995 // For growing use only the alignment value from the attribute, numbers
996 // (existing or started) with default alignment extend to the right.
997 bool bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
998 bool bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
999 bool bGrowBackwards
= bGrowToLeft
; // logical left
1001 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
1002 if ( bAsianVertical
)
1003 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= false; // keep old behavior for asian mode
1006 if (bBreak
&& !bAsianVertical
)
1007 nSizeXPix
= aPixRect
.GetWidth(); // Papersize -> kein H-Scrolling
1010 OSL_ENSURE(pView
,"keine View fuer EditView");
1012 if ( bGrowCentered
)
1014 // growing into both directions until one edge is reached
1015 //! should be limited to whole cells in both directions
1016 long nLeft
= aPixRect
.Left();
1017 long nRight
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Right();
1018 nSizeXPix
= aPixRect
.GetWidth() + 2 * std::min( nLeft
, nRight
);
1020 else if ( bGrowToLeft
)
1021 nSizeXPix
= aPixRect
.Right(); // space that's available in the window when growing to the left
1023 nSizeXPix
= pView
->GetGridWidth(eHWhich
) - aPixRect
.Left();
1025 if ( nSizeXPix
<= 0 )
1026 nSizeXPix
= aPixRect
.GetWidth(); // editing outside to the right of the window -> keep cell width
1028 OSL_ENSURE(pView
,"keine View fuer EditView");
1029 long nSizeYPix
= pView
->GetGridHeight(WhichV(eWhich
)) - aPixRect
.Top();
1030 if ( nSizeYPix
<= 0 )
1031 nSizeYPix
= aPixRect
.GetHeight(); // editing outside below the window -> keep cell height
1033 Size aPaperSize
= pView
->GetActiveWin()->PixelToLogic( Size( nSizeXPix
, nSizeYPix
), GetLogicMode() );
1034 if ( bBreak
&& !bAsianVertical
&& SC_MOD()->GetInputOptions().GetTextWysiwyg() )
1036 // if text is formatted for printer, use the exact same paper width
1037 // (and same line breaks) as for output.
1039 Fraction
aFract(1,1);
1040 Rectangle aUtilRect
= ScEditUtil( pDoc
,nNewX
,nNewY
,nTabNo
, Point(0,0), pWin
,
1041 HMM_PER_TWIPS
, HMM_PER_TWIPS
, aFract
, aFract
).GetEditArea( pPattern
, false );
1042 aPaperSize
.Width() = aUtilRect
.GetWidth();
1044 pNewEngine
->SetPaperSize( aPaperSize
);
1046 // sichtbarer Ausschnitt
1047 Size aPaper
= pNewEngine
->GetPaperSize();
1048 Rectangle aVis
= pEditView
[eWhich
]->GetVisArea();
1049 long nDiff
= aVis
.Right() - aVis
.Left();
1050 if ( nEditAdjust
== SVX_ADJUST_RIGHT
)
1052 aVis
.Right() = aPaper
.Width() - 1;
1053 bMoveArea
= !bLayoutRTL
;
1055 else if ( nEditAdjust
== SVX_ADJUST_CENTER
)
1057 aVis
.Right() = ( aPaper
.Width() - 1 + nDiff
) / 2;
1058 bMoveArea
= true; // always
1062 aVis
.Right() = nDiff
;
1063 bMoveArea
= bLayoutRTL
;
1065 aVis
.Left() = aVis
.Right() - nDiff
;
1066 // #i49561# Important note:
1067 // The set offset of the visible area of the EditView for centered and
1068 // right alignment in horizontal layout is consider by instances of
1069 // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
1070 // and <PixelToLogic(..)>. This is needed for the correct visibility
1071 // of paragraphs in edit mode at the accessibility API.
1072 pEditView
[eWhich
]->SetVisArea(aVis
);
1073 // UpdateMode has been disabled in ScInputHandler::StartTable
1074 // must be enabled before EditGrowY (GetTextHeight)
1075 pNewEngine
->SetUpdateMode( true );
1077 pNewEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EditEngineHdl
) );
1079 EditGrowY( true ); // adjust to existing text content
1082 Point aDocPos
= pEditView
[eWhich
]->GetWindowPosTopLeft(0);
1083 if (aDocPos
.Y() < aOutputArea
.Top())
1084 pEditView
[eWhich
]->Scroll( 0, aOutputArea
.Top() - aDocPos
.Y() );
1087 // here bEditActive needs to be set already
1088 // (due to Map-Mode during Paint)
1090 pNewEngine
->InsertView(pEditView
[eWhich
]);
1092 // background color of the cell
1093 Color aBackCol
= static_cast<const SvxBrushItem
&>(pPattern
->GetItem(ATTR_BACKGROUND
)).GetColor();
1095 ScModule
* pScMod
= SC_MOD();
1096 if ( aBackCol
.GetTransparency() > 0 )
1098 aBackCol
.SetColor( pScMod
->GetColorConfig().GetColorValue(svtools::DOCCOLOR
).nColor
);
1100 pEditView
[eWhich
]->SetBackgroundColor( aBackCol
);
1102 pEditView
[eWhich
]->Invalidate(); // needed?
1103 // needed, wenn position changed
1106 IMPL_STATIC_LINK_NOARG(ScViewData
, EmptyEditHdl
)
1111 IMPL_LINK( ScViewData
, EditEngineHdl
, EditStatus
*, pStatus
)
1113 EditStatusFlags nStatus
= pStatus
->GetStatusWord();
1114 if (nStatus
& (EditStatusFlags::HSCROLL
| EditStatusFlags::TEXTHEIGHTCHANGED
| EditStatusFlags::TEXTWIDTHCHANGED
| EditStatusFlags::CURSOROUT
))
1119 if (nStatus
& EditStatusFlags::CURSOROUT
)
1121 ScSplitPos eWhich
= GetActivePart();
1122 if (pEditView
[eWhich
])
1123 pEditView
[eWhich
]->ShowCursor(false);
1129 void ScViewData::EditGrowX()
1131 ScDocument
* pLocalDoc
= GetDocument();
1133 ScSplitPos eWhich
= GetActivePart();
1134 ScHSplitPos eHWhich
= WhichH(eWhich
);
1135 EditView
* pCurView
= pEditView
[eWhich
];
1137 if ( !pCurView
|| !bEditActive
[eWhich
])
1140 bool bLayoutRTL
= pLocalDoc
->IsLayoutRTL( nTabNo
);
1142 ScEditEngineDefaulter
* pEngine
=
1143 static_cast<ScEditEngineDefaulter
*>( pCurView
->GetEditEngine() );
1144 vcl::Window
* pWin
= pCurView
->GetWindow();
1146 SCCOL nLeft
= GetPosX(eHWhich
);
1147 SCCOL nRight
= nLeft
+ VisibleCellsX(eHWhich
);
1149 Size aSize
= pEngine
->GetPaperSize();
1150 Rectangle aArea
= pCurView
->GetOutputArea();
1151 long nOldRight
= aArea
.Right();
1153 // Margin ist schon bei der urspruenglichen Breite beruecksichtigt
1154 long nTextWidth
= pEngine
->CalcTextWidth();
1156 bool bChanged
= false;
1157 bool bAsianVertical
= pEngine
->IsVertical();
1159 // get bGrow... variables the same way as in SetEditEngine
1160 const ScPatternAttr
* pPattern
= pLocalDoc
->GetPattern( nEditCol
, nEditRow
, nTabNo
);
1161 SvxCellHorJustify eJust
= (SvxCellHorJustify
)static_cast<const SvxHorJustifyItem
&>(
1162 pPattern
->GetItem( ATTR_HOR_JUSTIFY
)).GetValue();
1163 bool bGrowCentered
= ( eJust
== SVX_HOR_JUSTIFY_CENTER
);
1164 bool bGrowToLeft
= ( eJust
== SVX_HOR_JUSTIFY_RIGHT
); // visual left
1165 bool bGrowBackwards
= bGrowToLeft
; // logical left
1167 bGrowBackwards
= !bGrowBackwards
; // invert on RTL sheet
1168 if ( bAsianVertical
)
1169 bGrowCentered
= bGrowToLeft
= bGrowBackwards
= false; // keep old behavior for asian mode
1171 bool bUnevenGrow
= false;
1172 if ( bGrowCentered
)
1174 while (aArea
.GetWidth() + 0 < nTextWidth
&& ( nEditStartCol
> nLeft
|| nEditEndCol
< nRight
) )
1176 long nLogicLeft
= 0;
1177 if ( nEditStartCol
> nLeft
)
1180 long nLeftPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1181 nLogicLeft
= pWin
->PixelToLogic(Size(nLeftPix
,0)).Width();
1183 long nLogicRight
= 0;
1184 if ( nEditEndCol
< nRight
)
1187 long nRightPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1188 nLogicRight
= pWin
->PixelToLogic(Size(nRightPix
,0)).Width();
1191 aArea
.Left() -= bLayoutRTL
? nLogicRight
: nLogicLeft
;
1192 aArea
.Right() += bLayoutRTL
? nLogicLeft
: nLogicRight
;
1194 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1196 long nCenter
= ( aArea
.Left() + aArea
.Right() ) / 2;
1197 long nHalf
= aSize
.Width() / 2;
1198 aArea
.Left() = nCenter
- nHalf
+ 1;
1199 aArea
.Right() = nCenter
+ aSize
.Width() - nHalf
- 1;
1203 if ( nLogicLeft
!= nLogicRight
)
1207 else if ( bGrowBackwards
)
1209 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditStartCol
> nLeft
)
1212 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditStartCol
, nTabNo
), nPPTX
);
1213 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1215 aArea
.Left() -= nLogicWidth
;
1217 aArea
.Right() += nLogicWidth
;
1219 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1222 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1224 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1232 while (aArea
.GetWidth() + 0 < nTextWidth
&& nEditEndCol
< nRight
)
1235 long nPix
= ToPixel( pLocalDoc
->GetColWidth( nEditEndCol
, nTabNo
), nPPTX
);
1236 long nLogicWidth
= pWin
->PixelToLogic(Size(nPix
,0)).Width();
1238 aArea
.Left() -= nLogicWidth
;
1240 aArea
.Right() += nLogicWidth
;
1242 if ( aArea
.Right() > aArea
.Left() + aSize
.Width() - 1 )
1245 aArea
.Left() = aArea
.Right() - aSize
.Width() + 1;
1247 aArea
.Right() = aArea
.Left() + aSize
.Width() - 1;
1256 if ( bMoveArea
|| bGrowCentered
|| bGrowBackwards
|| bLayoutRTL
)
1258 Rectangle aVis
= pCurView
->GetVisArea();
1260 if ( bGrowCentered
)
1262 // switch to center-aligned (undo?) and reset VisArea to center
1264 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER
, EE_PARA_JUST
) );
1266 long nCenter
= aSize
.Width() / 2;
1267 long nVisSize
= aArea
.GetWidth();
1268 aVis
.Left() = nCenter
- nVisSize
/ 2;
1269 aVis
.Right() = aVis
.Left() + nVisSize
- 1;
1271 else if ( bGrowToLeft
)
1273 // switch to right-aligned (undo?) and reset VisArea to the right
1275 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT
, EE_PARA_JUST
) );
1277 aVis
.Right() = aSize
.Width() - 1;
1278 aVis
.Left() = aSize
.Width() - aArea
.GetWidth(); // with the new, increased area
1282 // switch to left-aligned (undo?) and reset VisArea to the left
1284 pEngine
->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT
, EE_PARA_JUST
) );
1286 long nMove
= aVis
.Left();
1288 aVis
.Right() -= nMove
;
1290 pCurView
->SetVisArea( aVis
);
1294 pCurView
->SetOutputArea(aArea
);
1296 // In vertical mode, the whole text is moved to the next cell (right-aligned),
1297 // so everything must be repainted. Otherwise, paint only the new area.
1298 // If growing in centered alignment, if the cells left and right have different sizes,
1299 // the whole text will move, and may not even obscure all of the original display.
1302 aArea
.Left() = pWin
->PixelToLogic( Point(0,0) ).X();
1303 aArea
.Right() = pWin
->PixelToLogic( aScrSize
).Width();
1305 else if ( !bAsianVertical
&& !bGrowToLeft
&& !bGrowCentered
)
1306 aArea
.Left() = nOldRight
;
1307 pWin
->Invalidate(aArea
);
1311 void ScViewData::EditGrowY( bool bInitial
)
1313 ScSplitPos eWhich
= GetActivePart();
1314 ScVSplitPos eVWhich
= WhichV(eWhich
);
1315 EditView
* pCurView
= pEditView
[eWhich
];
1317 if ( !pCurView
|| !bEditActive
[eWhich
])
1320 EVControlBits nControl
= pEditView
[eWhich
]->GetControlWord();
1321 if ( nControl
& EVControlBits::AUTOSCROLL
)
1323 // if end of screen had already been reached and scrolling enabled,
1324 // don't further try to grow the edit area
1326 pCurView
->SetOutputArea( pCurView
->GetOutputArea() ); // re-align to pixels
1330 EditEngine
* pEngine
= pCurView
->GetEditEngine();
1331 vcl::Window
* pWin
= pCurView
->GetWindow();
1333 SCROW nBottom
= GetPosY(eVWhich
) + VisibleCellsY(eVWhich
);
1335 Size aSize
= pEngine
->GetPaperSize();
1336 Rectangle aArea
= pCurView
->GetOutputArea();
1337 long nOldBottom
= aArea
.Bottom();
1338 long nTextHeight
= pEngine
->GetTextHeight();
1340 // When editing a formula in a cell with optimal height, allow a larger portion
1341 // to be clipped before extending to following rows, to avoid obscuring cells for
1342 // reference input (next row is likely to be useful in formulas).
1343 long nAllowedExtra
= SC_GROWY_SMALL_EXTRA
;
1344 if ( nEditEndRow
== nEditRow
&& !( pDoc
->GetRowFlags( nEditRow
, nTabNo
) & CR_MANUALSIZE
) &&
1345 pEngine
->GetParagraphCount() <= 1 )
1347 // If the (only) paragraph starts with a '=', it's a formula.
1348 // If this is the initial call and the text is empty, allow the larger value, too,
1349 // because this occurs in the normal progress of editing a formula.
1350 // Subsequent calls with empty text might involve changed attributes (including
1351 // font height), so they are treated like normal text.
1352 OUString aText
= pEngine
->GetText( 0 );
1353 if ( ( aText
.isEmpty() && bInitial
) || aText
.startsWith("=") )
1354 nAllowedExtra
= SC_GROWY_BIG_EXTRA
;
1357 bool bChanged
= false;
1358 bool bMaxReached
= false;
1359 while (aArea
.GetHeight() + nAllowedExtra
< nTextHeight
&& nEditEndRow
< nBottom
&& !bMaxReached
)
1362 ScDocument
* pLocalDoc
= GetDocument();
1363 long nPix
= ToPixel( pLocalDoc
->GetRowHeight( nEditEndRow
, nTabNo
), nPPTY
);
1364 aArea
.Bottom() += pWin
->PixelToLogic(Size(0,nPix
)).Height();
1366 if ( aArea
.Bottom() > aArea
.Top() + aSize
.Height() - 1 )
1368 aArea
.Bottom() = aArea
.Top() + aSize
.Height() - 1;
1369 bMaxReached
= true; // don't occupy more cells beyond paper size
1373 nAllowedExtra
= SC_GROWY_SMALL_EXTRA
; // larger value is only for first row
1378 pCurView
->SetOutputArea(aArea
);
1380 if (nEditEndRow
>= nBottom
|| bMaxReached
)
1382 if (!(nControl
& EVControlBits::AUTOSCROLL
))
1383 pCurView
->SetControlWord( nControl
| EVControlBits::AUTOSCROLL
);
1386 aArea
.Top() = nOldBottom
;
1387 pWin
->Invalidate(aArea
);
1391 void ScViewData::ResetEditView()
1393 EditEngine
* pEngine
= NULL
;
1394 for (sal_uInt16 i
=0; i
<4; i
++)
1399 pEngine
= pEditView
[i
]->GetEditEngine();
1400 pEngine
->RemoveView(pEditView
[i
]);
1401 pEditView
[i
]->SetOutputArea( Rectangle() );
1403 bEditActive
[i
] = false;
1407 pEngine
->SetStatusEventHdl( LINK( this, ScViewData
, EmptyEditHdl
) );
1410 void ScViewData::KillEditView()
1412 for (sal_uInt16 i
=0; i
<4; i
++)
1416 pEditView
[i
]->GetEditEngine()->RemoveView(pEditView
[i
]);
1417 delete pEditView
[i
];
1418 pEditView
[i
] = NULL
;
1422 void ScViewData::GetEditView( ScSplitPos eWhich
, EditView
*& rViewPtr
, SCCOL
& rCol
, SCROW
& rRow
)
1424 rViewPtr
= pEditView
[eWhich
];
1429 void ScViewData::CreateTabData( SCTAB nNewTab
)
1431 EnsureTabDataSize(nNewTab
+ 1);
1433 if (!maTabData
[nNewTab
])
1435 maTabData
[nNewTab
] = new ScViewDataTable
;
1437 maTabData
[nNewTab
]->eZoomType
= eDefZoomType
;
1438 maTabData
[nNewTab
]->aZoomX
= aDefZoomX
;
1439 maTabData
[nNewTab
]->aZoomY
= aDefZoomY
;
1440 maTabData
[nNewTab
]->aPageZoomX
= aDefPageZoomX
;
1441 maTabData
[nNewTab
]->aPageZoomY
= aDefPageZoomY
;
1445 void ScViewData::CreateSelectedTabData()
1447 ScMarkData::iterator itr
= mpMarkData
->begin(), itrEnd
= mpMarkData
->end();
1448 for (; itr
!= itrEnd
; ++itr
)
1449 CreateTabData(*itr
);
1452 void ScViewData::EnsureTabDataSize(size_t nSize
)
1454 if (nSize
>= maTabData
.size())
1456 size_t n
= nSize
- maTabData
.size() + 1;
1457 maTabData
.insert(maTabData
.end(), n
, NULL
);
1461 void ScViewData::SetTabNo( SCTAB nNewTab
)
1463 if (!ValidTab(nNewTab
))
1465 OSL_FAIL("falsche Tabellennummer");
1470 CreateTabData(nTabNo
);
1471 pThisTab
= maTabData
[nTabNo
];
1473 CalcPPT(); // for common column width correction
1474 RecalcPixPos(); //! nicht immer noetig!
1477 void ScViewData::SetActivePart( ScSplitPos eNewActive
)
1479 pThisTab
->eWhichActive
= eNewActive
;
1482 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScHSplitPos eWhich
) const
1484 OSL_ENSURE( eWhich
==SC_SPLIT_LEFT
|| eWhich
==SC_SPLIT_RIGHT
, "Falsche Position" );
1485 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_LEFT
) ? SC_SPLIT_BOTTOMLEFT
: SC_SPLIT_BOTTOMRIGHT
;
1486 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1489 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScVSplitPos eWhich
) const
1491 OSL_ENSURE( eWhich
==SC_SPLIT_TOP
|| eWhich
==SC_SPLIT_BOTTOM
, "Falsche Position" );
1492 ScSplitPos ePos
= ( eWhich
== SC_SPLIT_TOP
) ? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
1493 return GetScrPos( nWhereX
, nWhereY
, ePos
);
1496 Point
ScViewData::GetScrPos( SCCOL nWhereX
, SCROW nWhereY
, ScSplitPos eWhich
,
1497 bool bAllowNeg
) const
1499 ScHSplitPos eWhichX
= SC_SPLIT_LEFT
;
1500 ScVSplitPos eWhichY
= SC_SPLIT_BOTTOM
;
1503 case SC_SPLIT_TOPLEFT
:
1504 eWhichX
= SC_SPLIT_LEFT
;
1505 eWhichY
= SC_SPLIT_TOP
;
1507 case SC_SPLIT_TOPRIGHT
:
1508 eWhichX
= SC_SPLIT_RIGHT
;
1509 eWhichY
= SC_SPLIT_TOP
;
1511 case SC_SPLIT_BOTTOMLEFT
:
1512 eWhichX
= SC_SPLIT_LEFT
;
1513 eWhichY
= SC_SPLIT_BOTTOM
;
1515 case SC_SPLIT_BOTTOMRIGHT
:
1516 eWhichX
= SC_SPLIT_RIGHT
;
1517 eWhichY
= SC_SPLIT_BOTTOM
;
1523 const_cast<ScViewData
*>(this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1524 const_cast<ScViewData
*>(this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1528 ScDrawLayer
* pModel
= GetDocument()->GetDrawLayer();
1529 bool bIsTiledRendering
= pModel
&& pModel
->isTiledRendering();
1531 SCCOL nPosX
= GetPosX(eWhichX
);
1535 if (nWhereX
>= nPosX
)
1536 for (nX
= nPosX
; nX
< nWhereX
&& (bAllowNeg
|| bIsTiledRendering
|| nScrPosX
<= aScrSize
.Width()); nX
++)
1542 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1545 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1546 nScrPosX
+= nSizeXPix
;
1551 for (nX
=nPosX
; nX
>nWhereX
;)
1554 nTSize
= pDoc
->GetColWidth( nX
, nTabNo
);
1557 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1558 nScrPosX
-= nSizeXPix
;
1562 SCROW nPosY
= GetPosY(eWhichY
);
1566 if (nWhereY
>= nPosY
)
1567 for (nY
= nPosY
; nY
< nWhereY
&& (bAllowNeg
|| bIsTiledRendering
|| nScrPosY
<= aScrSize
.Height()); nY
++)
1573 nTSize
= pDoc
->GetRowHeight( nY
, nTabNo
);
1576 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1577 nScrPosY
+= nSizeYPix
;
1579 else if ( nY
< MAXROW
)
1581 // skip multiple hidden rows (forward only for now)
1582 SCROW nNext
= pDoc
->FirstVisibleRow(nY
+ 1, MAXROW
, nTabNo
);
1583 if ( nNext
> MAXROW
)
1586 nY
= nNext
- 1; // +=nDir advances to next visible row
1591 for (nY
=nPosY
; nY
>nWhereY
;)
1594 nTSize
= pDoc
->GetRowHeight( nY
, nTabNo
);
1597 long nSizeYPix
= ToPixel( nTSize
, nPPTY
);
1598 nScrPosY
-= nSizeYPix
;
1602 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1604 // mirror horizontal position
1605 nScrPosX
= aScrSize
.Width() - 1 - nScrPosX
;
1608 if (!bIsTiledRendering
)
1610 if (nScrPosX
> 32767)
1612 if (nScrPosY
> 32767)
1616 return Point( nScrPosX
, nScrPosY
);
1619 // Number of cells on a screen
1620 SCCOL
ScViewData::CellsAtX( SCsCOL nPosX
, SCsCOL nDir
, ScHSplitPos eWhichX
, sal_uInt16 nScrSizeX
) const
1622 OSL_ENSURE( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1625 const_cast<ScViewData
*>(this)->aScrSize
.Width() = pView
->GetGridWidth(eWhichX
);
1628 sal_uInt16 nScrPosX
= 0;
1629 if (nScrSizeX
== SC_SIZE_NONE
) nScrSizeX
= (sal_uInt16
) aScrSize
.Width();
1632 nX
= nPosX
; // vorwaerts
1634 nX
= nPosX
-1; // rueckwaerts
1637 for ( ; nScrPosX
<=nScrSizeX
&& !bOut
; nX
= sal::static_int_cast
<SCsCOL
>(nX
+ nDir
) )
1640 if ( nColNo
< 0 || nColNo
> MAXCOL
)
1644 sal_uInt16 nTSize
= pDoc
->GetColWidth( nColNo
, nTabNo
);
1647 long nSizeXPix
= ToPixel( nTSize
, nPPTX
);
1648 nScrPosX
= sal::static_int_cast
<sal_uInt16
>( nScrPosX
+ (sal_uInt16
) nSizeXPix
);
1654 nX
= sal::static_int_cast
<SCsCOL
>( nX
- nPosX
);
1662 SCROW
ScViewData::CellsAtY( SCsROW nPosY
, SCsROW nDir
, ScVSplitPos eWhichY
, sal_uInt16 nScrSizeY
) const
1664 OSL_ENSURE( nDir
==1 || nDir
==-1, "falscher CellsAt Aufruf" );
1667 const_cast<ScViewData
*>(this)->aScrSize
.Height() = pView
->GetGridHeight(eWhichY
);
1669 if (nScrSizeY
== SC_SIZE_NONE
) nScrSizeY
= (sal_uInt16
) aScrSize
.Height();
1678 AddPixelsWhile( nScrPosY
, nScrSizeY
, nY
, MAXROW
, nPPTY
, pDoc
, nTabNo
);
1679 // Original loop ended on last evaluated +1 or if that was MAXROW even
1681 nY
+= (nY
== MAXROW
? 2 : 1);
1689 AddPixelsWhileBackward( nScrPosY
, nScrSizeY
, nY
, 0, nPPTY
, pDoc
, nTabNo
);
1690 // Original loop ended on last evaluated -1 or if that was 0 even on
1692 nY
-= (nY
== 0 ? 2 : 1);
1700 SCCOL
ScViewData::VisibleCellsX( ScHSplitPos eWhichX
) const
1702 return CellsAtX( GetPosX( eWhichX
), 1, eWhichX
, SC_SIZE_NONE
);
1705 SCROW
ScViewData::VisibleCellsY( ScVSplitPos eWhichY
) const
1707 return CellsAtY( GetPosY( eWhichY
), 1, eWhichY
, SC_SIZE_NONE
);
1710 SCCOL
ScViewData::PrevCellsX( ScHSplitPos eWhichX
) const
1712 return CellsAtX( GetPosX( eWhichX
), -1, eWhichX
, SC_SIZE_NONE
);
1715 SCROW
ScViewData::PrevCellsY( ScVSplitPos eWhichY
) const
1717 return CellsAtY( GetPosY( eWhichY
), -1, eWhichY
, SC_SIZE_NONE
);
1720 bool ScViewData::GetMergeSizePixel( SCCOL nX
, SCROW nY
, long& rSizeXPix
, long& rSizeYPix
) const
1722 const ScMergeAttr
* pMerge
= static_cast<const ScMergeAttr
*>( pDoc
->GetAttr( nX
,nY
,nTabNo
, ATTR_MERGE
) );
1723 if ( pMerge
->GetColMerge() > 1 || pMerge
->GetRowMerge() > 1 )
1726 long nOutHeight
= 0;
1727 SCCOL nCountX
= pMerge
->GetColMerge();
1728 for (SCCOL i
=0; i
<nCountX
; i
++)
1729 nOutWidth
+= ToPixel( pDoc
->GetColWidth(nX
+i
,nTabNo
), nPPTX
);
1730 SCROW nCountY
= pMerge
->GetRowMerge();
1732 for (SCROW nRow
= nY
; nRow
<= nY
+nCountY
-1; ++nRow
)
1734 SCROW nLastRow
= nRow
;
1735 if (pDoc
->RowHidden(nRow
, nTabNo
, NULL
, &nLastRow
))
1741 sal_uInt16 nHeight
= pDoc
->GetRowHeight(nRow
, nTabNo
);
1742 nOutHeight
+= ToPixel(nHeight
, nPPTY
);
1745 rSizeXPix
= nOutWidth
;
1746 rSizeYPix
= nOutHeight
;
1751 rSizeXPix
= ToPixel( pDoc
->GetColWidth( nX
, nTabNo
), nPPTX
);
1752 rSizeYPix
= ToPixel( pDoc
->GetRowHeight( nY
, nTabNo
), nPPTY
);
1757 bool ScViewData::GetPosFromPixel( long nClickX
, long nClickY
, ScSplitPos eWhich
,
1758 SCsCOL
& rPosX
, SCsROW
& rPosY
,
1759 bool bTestMerge
, bool bRepair
, bool bNextIfLarge
)
1761 // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
1763 ScHSplitPos eHWhich
= WhichH(eWhich
);
1764 ScVSplitPos eVWhich
= WhichV(eWhich
);
1766 if ( pDoc
->IsLayoutRTL( nTabNo
) )
1768 // mirror horizontal position
1770 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1771 nClickX
= aScrSize
.Width() - 1 - nClickX
;
1774 SCsCOL nStartPosX
= GetPosX(eHWhich
);
1775 SCsROW nStartPosY
= GetPosY(eVWhich
);
1783 while ( rPosX
<=MAXCOL
&& nClickX
>= nScrX
)
1785 nScrX
+= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1792 while ( rPosX
>0 && nClickX
< nScrX
)
1795 nScrX
-= ToPixel( pDoc
->GetColWidth( rPosX
, nTabNo
), nPPTX
);
1800 AddPixelsWhile( nScrY
, nClickY
, rPosY
, MAXROW
, nPPTY
, pDoc
, nTabNo
);
1803 /* TODO: could need some "SubPixelsWhileBackward" method */
1804 while ( rPosY
>0 && nClickY
< nScrY
)
1807 nScrY
-= ToPixel( pDoc
->GetRowHeight( rPosY
, nTabNo
), nPPTY
);
1811 if (bNextIfLarge
) // cells to big?
1813 if ( rPosX
== nStartPosX
&& nClickX
> 0 )
1816 aScrSize
.Width() = pView
->GetGridWidth(eHWhich
);
1817 if ( nClickX
> aScrSize
.Width() )
1820 if ( rPosY
== nStartPosY
&& nClickY
> 0 )
1823 aScrSize
.Height() = pView
->GetGridHeight(eVWhich
);
1824 if ( nClickY
> aScrSize
.Height() )
1829 if (rPosX
<0) rPosX
=0;
1830 if (rPosX
>MAXCOL
) rPosX
=MAXCOL
;
1831 if (rPosY
<0) rPosY
=0;
1832 if (rPosY
>MAXROW
) rPosY
=MAXROW
;
1836 // public method to adapt position
1837 SCCOL nOrigX
= rPosX
;
1838 SCROW nOrigY
= rPosY
;
1839 pDoc
->SkipOverlapped(rPosX
, rPosY
, nTabNo
);
1840 bool bHOver
= (nOrigX
!= rPosX
);
1841 bool bVOver
= (nOrigY
!= rPosY
);
1843 if ( bRepair
&& ( bHOver
|| bVOver
) )
1845 const ScMergeAttr
* pMerge
= static_cast<const ScMergeAttr
*>(
1846 pDoc
->GetAttr( rPosX
, rPosY
, nTabNo
, ATTR_MERGE
) );
1847 if ( ( bHOver
&& pMerge
->GetColMerge() <= 1 ) ||
1848 ( bVOver
&& pMerge
->GetRowMerge() <= 1 ) )
1850 OSL_FAIL("Merge-Fehler gefunden");
1852 pDoc
->RemoveFlagsTab( 0,0, MAXCOL
,MAXROW
, nTabNo
, SC_MF_HOR
| SC_MF_VER
);
1853 SCCOL nEndCol
= MAXCOL
;
1854 SCROW nEndRow
= MAXROW
;
1855 pDoc
->ExtendMerge( 0,0, nEndCol
,nEndRow
, nTabNo
, true );
1857 pDocShell
->PostPaint( ScRange(0,0,nTabNo
,MAXCOL
,MAXROW
,nTabNo
), PAINT_GRID
);
1865 void ScViewData::GetMouseQuadrant( const Point
& rClickPos
, ScSplitPos eWhich
,
1866 SCsCOL nPosX
, SCsROW nPosY
, bool& rLeft
, bool& rTop
)
1868 bool bLayoutRTL
= pDoc
->IsLayoutRTL( nTabNo
);
1869 long nLayoutSign
= bLayoutRTL
? -1 : 1;
1871 Point aCellStart
= GetScrPos( nPosX
, nPosY
, eWhich
, true );
1874 GetMergeSizePixel( nPosX
, nPosY
, nSizeX
, nSizeY
);
1875 rLeft
= ( rClickPos
.X() - aCellStart
.X() ) * nLayoutSign
<= nSizeX
/ 2;
1876 rTop
= rClickPos
.Y() - aCellStart
.Y() <= nSizeY
/ 2;
1879 void ScViewData::SetPosX( ScHSplitPos eWhich
, SCCOL nNewPosX
)
1881 // in the tiled rendering case, nPosX [the leftmost visible column] must be 0
1882 ScDrawLayer
* pModel
= GetDocument()->GetDrawLayer();
1883 bool bIsTiledRendering
= pModel
&& pModel
->isTiledRendering();
1884 if (nNewPosX
!= 0 && !bIsTiledRendering
)
1886 SCCOL nOldPosX
= pThisTab
->nPosX
[eWhich
];
1887 long nTPosX
= pThisTab
->nTPosX
[eWhich
];
1888 long nPixPosX
= pThisTab
->nPixPosX
[eWhich
];
1890 if ( nNewPosX
> nOldPosX
)
1891 for ( i
=nOldPosX
; i
<nNewPosX
; i
++ )
1893 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1895 nPixPosX
-= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTX
);
1898 for ( i
=nNewPosX
; i
<nOldPosX
; i
++ )
1900 long nThis
= pDoc
->GetColWidth( i
,nTabNo
);
1902 nPixPosX
+= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTX
);
1905 pThisTab
->nPosX
[eWhich
] = nNewPosX
;
1906 pThisTab
->nTPosX
[eWhich
] = nTPosX
;
1907 pThisTab
->nMPosX
[eWhich
] = (long) (nTPosX
* HMM_PER_TWIPS
);
1908 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
1912 pThisTab
->nPixPosX
[eWhich
] =
1913 pThisTab
->nTPosX
[eWhich
] =
1914 pThisTab
->nMPosX
[eWhich
] =
1915 pThisTab
->nPosX
[eWhich
] = 0;
1919 void ScViewData::SetPosY( ScVSplitPos eWhich
, SCROW nNewPosY
)
1921 // in the tiled rendering case, nPosY [the topmost visible row] must be 0
1922 ScDrawLayer
* pModel
= GetDocument()->GetDrawLayer();
1923 bool bIsTiledRendering
= pModel
&& pModel
->isTiledRendering();
1924 if (nNewPosY
!= 0 && !bIsTiledRendering
)
1926 SCROW nOldPosY
= pThisTab
->nPosY
[eWhich
];
1927 long nTPosY
= pThisTab
->nTPosY
[eWhich
];
1928 long nPixPosY
= pThisTab
->nPixPosY
[eWhich
];
1929 SCROW i
, nHeightEndRow
;
1930 if ( nNewPosY
> nOldPosY
)
1931 for ( i
=nOldPosY
; i
<nNewPosY
; i
++ )
1933 long nThis
= pDoc
->GetRowHeight( i
, nTabNo
, NULL
, &nHeightEndRow
);
1934 SCROW nRows
= std::min( nNewPosY
, nHeightEndRow
+ 1) - i
;
1936 nTPosY
-= nThis
* nRows
;
1937 nPixPosY
-= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTY
) * nRows
;
1940 for ( i
=nNewPosY
; i
<nOldPosY
; i
++ )
1942 long nThis
= pDoc
->GetRowHeight( i
, nTabNo
, NULL
, &nHeightEndRow
);
1943 SCROW nRows
= std::min( nOldPosY
, nHeightEndRow
+ 1) - i
;
1945 nTPosY
+= nThis
* nRows
;
1946 nPixPosY
+= ToPixel(sal::static_int_cast
<sal_uInt16
>(nThis
), nPPTY
) * nRows
;
1949 pThisTab
->nPosY
[eWhich
] = nNewPosY
;
1950 pThisTab
->nTPosY
[eWhich
] = nTPosY
;
1951 pThisTab
->nMPosY
[eWhich
] = (long) (nTPosY
* HMM_PER_TWIPS
);
1952 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
1956 pThisTab
->nPixPosY
[eWhich
] =
1957 pThisTab
->nTPosY
[eWhich
] =
1958 pThisTab
->nMPosY
[eWhich
] =
1959 pThisTab
->nPosY
[eWhich
] = 0;
1963 void ScViewData::RecalcPixPos() // after zoom changes
1965 for (sal_uInt16 eWhich
=0; eWhich
<2; eWhich
++)
1968 SCCOL nPosX
= pThisTab
->nPosX
[eWhich
];
1969 for (SCCOL i
=0; i
<nPosX
; i
++)
1970 nPixPosX
-= ToPixel(pDoc
->GetColWidth(i
,nTabNo
), nPPTX
);
1971 pThisTab
->nPixPosX
[eWhich
] = nPixPosX
;
1974 SCROW nPosY
= pThisTab
->nPosY
[eWhich
];
1975 for (SCROW j
=0; j
<nPosY
; j
++)
1976 nPixPosY
-= ToPixel(pDoc
->GetRowHeight(j
,nTabNo
), nPPTY
);
1977 pThisTab
->nPixPosY
[eWhich
] = nPixPosY
;
1981 const MapMode
& ScViewData::GetLogicMode( ScSplitPos eWhich
)
1983 aLogicMode
.SetOrigin( Point( pThisTab
->nMPosX
[WhichH(eWhich
)],
1984 pThisTab
->nMPosY
[WhichV(eWhich
)] ) );
1988 const MapMode
& ScViewData::GetLogicMode()
1990 aLogicMode
.SetOrigin( Point() );
1994 void ScViewData::SetScreen( SCCOL nCol1
, SCROW nRow1
, SCCOL nCol2
, SCROW nRow2
)
2003 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
2004 SetPosX( SC_SPLIT_LEFT
, nCol1
);
2005 SetPosY( SC_SPLIT_BOTTOM
, nRow1
);
2007 for (nCol
=nCol1
; nCol
<=nCol2
; nCol
++)
2009 nTSize
= pDoc
->GetColWidth( nCol
, nTabNo
);
2012 nSizePix
= ToPixel( nTSize
, nPPTX
);
2013 nScrPosX
+= (sal_uInt16
) nSizePix
;
2017 for (nRow
=nRow1
; nRow
<=nRow2
; nRow
++)
2019 nTSize
= pDoc
->GetRowHeight( nRow
, nTabNo
);
2022 nSizePix
= ToPixel( nTSize
, nPPTY
);
2023 nScrPosY
+= (sal_uInt16
) nSizePix
;
2027 aScrSize
= Size( nScrPosX
, nScrPosY
);
2030 void ScViewData::SetScreenPos( const Point
& rVisAreaStart
)
2038 nTwips
= (long) (rVisAreaStart
.X() / HMM_PER_TWIPS
);
2039 if ( pDoc
->IsLayoutRTL( nTabNo
) )
2045 nAdd
= (long) pDoc
->GetColWidth(nX1
,nTabNo
);
2046 if (nSize
+nAdd
<= nTwips
+1 && nX1
<MAXCOL
)
2056 nTwips
= (long) (rVisAreaStart
.Y() / HMM_PER_TWIPS
);
2061 nAdd
= (long) pDoc
->GetRowHeight(nY1
,nTabNo
);
2062 if (nSize
+nAdd
<= nTwips
+1 && nY1
<MAXROW
)
2071 SetActivePart( SC_SPLIT_BOTTOMLEFT
);
2072 SetPosX( SC_SPLIT_LEFT
, nX1
);
2073 SetPosY( SC_SPLIT_BOTTOM
, nY1
);
2079 void ScViewData::SetScreen( const Rectangle
& rVisArea
)
2081 SetScreenPos( rVisArea
.TopLeft() );
2083 // here without GetOutputFactor(), since it's for the output into a Metafile
2085 aScrSize
= rVisArea
.GetSize();
2086 aScrSize
.Width() = (long)
2087 ( aScrSize
.Width() * ScGlobal::nScreenPPTX
/ HMM_PER_TWIPS
);
2088 aScrSize
.Height() = (long)
2089 ( aScrSize
.Height() * ScGlobal::nScreenPPTY
/ HMM_PER_TWIPS
);
2092 ScDocFunc
& ScViewData::GetDocFunc() const
2094 return pDocShell
->GetDocFunc();
2097 SfxBindings
& ScViewData::GetBindings()
2099 OSL_ENSURE( pViewShell
, "GetBindings() without ViewShell" );
2100 return pViewShell
->GetViewFrame()->GetBindings();
2103 SfxDispatcher
& ScViewData::GetDispatcher()
2105 OSL_ENSURE( pViewShell
, "GetDispatcher() without ViewShell" );
2106 return *pViewShell
->GetViewFrame()->GetDispatcher();
2109 ScMarkData
& ScViewData::GetMarkData()
2114 const ScMarkData
& ScViewData::GetMarkData() const
2119 vcl::Window
* ScViewData::GetDialogParent()
2121 OSL_ENSURE( pViewShell
, "GetDialogParent() ohne ViewShell" );
2122 return pViewShell
->GetDialogParent();
2125 ScGridWindow
* ScViewData::GetActiveWin()
2127 OSL_ENSURE( pView
, "GetActiveWin() ohne View" );
2128 return pView
->GetActiveWin();
2131 const ScGridWindow
* ScViewData::GetActiveWin() const
2133 OSL_ENSURE( pView
, "GetActiveWin() ohne View" );
2134 return pView
->GetActiveWin();
2137 ScDrawView
* ScViewData::GetScDrawView()
2139 OSL_ENSURE( pView
, "GetScDrawView() ohne View" );
2140 return pView
->GetScDrawView();
2143 bool ScViewData::IsMinimized()
2145 OSL_ENSURE( pView
, "IsMinimized() ohne View" );
2146 return pView
->IsMinimized();
2149 void ScViewData::UpdateScreenZoom( const Fraction
& rNewX
, const Fraction
& rNewY
)
2151 Fraction aOldX
= GetZoomX();
2152 Fraction aOldY
= GetZoomY();
2154 SetZoom( rNewX
, rNewY
, false );
2156 Fraction aWidth
= GetZoomX();
2157 aWidth
*= Fraction( aScrSize
.Width(),1 );
2160 Fraction aHeight
= GetZoomY();
2161 aHeight
*= Fraction( aScrSize
.Height(),1 );
2164 aScrSize
.Width() = (long) aWidth
;
2165 aScrSize
.Height() = (long) aHeight
;
2168 void ScViewData::CalcPPT()
2170 nPPTX
= ScGlobal::nScreenPPTX
* (double) GetZoomX();
2172 nPPTX
= nPPTX
/ pDocShell
->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
2173 nPPTY
= ScGlobal::nScreenPPTY
* (double) GetZoomY();
2175 // if detective objects are present,
2176 // try to adjust horizontal scale so the most common column width has minimal rounding errors,
2177 // to avoid differences between cell and drawing layer output
2179 if ( pDoc
&& pDoc
->HasDetectiveObjects(nTabNo
) )
2183 pDoc
->GetTableArea( nTabNo
, nEndCol
, nDummy
);
2185 nEndCol
= 20; // same end position as when determining draw scale
2187 sal_uInt16 nTwips
= pDoc
->GetCommonWidth( nEndCol
, nTabNo
);
2190 double fOriginal
= nTwips
* nPPTX
;
2191 if ( fOriginal
< static_cast<double>(nEndCol
) )
2193 // if one column is smaller than the column count,
2194 // rounding errors are likely to add up to a whole column.
2196 double fRounded
= ::rtl::math::approxFloor( fOriginal
+ 0.5 );
2197 if ( fRounded
> 0.0 )
2199 double fScale
= fRounded
/ fOriginal
+ 1E-6;
2200 if ( fScale
>= 0.9 && fScale
<= 1.1 )
2208 #define SC_OLD_TABSEP '/'
2209 #define SC_NEW_TABSEP '+'
2211 void ScViewData::WriteUserData(OUString
& rData
)
2213 // nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
2215 // Tab-ControlBreite
2217 // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
2218 // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
2219 // wenn Zeilen groesser 8192, "+" statt "/"
2221 sal_uInt16 nZoom
= (sal_uInt16
)((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2222 rData
= OUString::number( nZoom
) + "/";
2223 nZoom
= (sal_uInt16
)((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2224 rData
+= OUString::number( nZoom
) + "/";
2230 rData
+= ";" + OUString::number( nTabNo
) + ";" TAG_TABBARWIDTH
+
2231 OUString::number( pView
->GetTabBarWidth() );
2233 SCTAB nTabCount
= pDoc
->GetTableCount();
2234 for (SCTAB i
=0; i
<nTabCount
; i
++)
2236 rData
+= ";"; // Numerierung darf auf keinen Fall durcheinanderkommen
2237 if (i
< static_cast<SCTAB
>(maTabData
.size()) && maTabData
[i
])
2239 OUString cTabSep
= OUString(SC_OLD_TABSEP
); // like 3.1
2240 if ( maTabData
[i
]->nCurY
> MAXROW_30
||
2241 maTabData
[i
]->nPosY
[0] > MAXROW_30
|| maTabData
[i
]->nPosY
[1] > MAXROW_30
||
2242 ( maTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
&&
2243 maTabData
[i
]->nFixPosY
> MAXROW_30
) )
2245 cTabSep
= OUStringLiteral1
<SC_NEW_TABSEP
>(); // in order to not kill a 3.1-version
2248 rData
+= OUString::number( maTabData
[i
]->nCurX
) + cTabSep
+
2249 OUString::number( maTabData
[i
]->nCurY
) + cTabSep
+
2250 OUString::number( maTabData
[i
]->eHSplitMode
) + cTabSep
+
2251 OUString::number( maTabData
[i
]->eVSplitMode
) + cTabSep
;
2252 if ( maTabData
[i
]->eHSplitMode
== SC_SPLIT_FIX
)
2253 rData
+= OUString::number( maTabData
[i
]->nFixPosX
);
2255 rData
+= OUString::number( maTabData
[i
]->nHSplitPos
);
2257 if ( maTabData
[i
]->eVSplitMode
== SC_SPLIT_FIX
)
2258 rData
+= OUString::number( maTabData
[i
]->nFixPosY
);
2260 rData
+= OUString::number( maTabData
[i
]->nVSplitPos
);
2262 OUString::number( maTabData
[i
]->eWhichActive
) + cTabSep
+
2263 OUString::number( maTabData
[i
]->nPosX
[0] ) + cTabSep
+
2264 OUString::number( maTabData
[i
]->nPosX
[1] ) + cTabSep
+
2265 OUString::number( maTabData
[i
]->nPosY
[0] ) + cTabSep
+
2266 OUString::number( maTabData
[i
]->nPosY
[1] );
2271 void ScViewData::ReadUserData(const OUString
& rData
)
2273 if (rData
.isEmpty()) // Leerer String kommt bei "neu Laden"
2274 return; // then exit without assertion
2276 sal_Int32 nCount
= comphelper::string::getTokenCount(rData
, ';');
2279 // beim Reload in der Seitenansicht sind evtl. die Preview-UserData
2280 // stehengelassen worden. Den Zoom von der Preview will man hier nicht...
2281 OSL_FAIL("ReadUserData: das sind nicht meine Daten");
2285 // nicht pro Tabelle:
2286 SCTAB nTabStart
= 2;
2288 Fraction aZoomX
, aZoomY
, aPageZoomX
, aPageZoomY
; // evaluate (all sheets?)
2290 OUString aZoomStr
= rData
.getToken(0, ';'); // Zoom/PageZoom/Modus
2291 sal_uInt16 nNormZoom
= sal::static_int_cast
<sal_uInt16
>(aZoomStr
.getToken(0,'/').toInt32());
2292 if ( nNormZoom
>= MINZOOM
&& nNormZoom
<= MAXZOOM
)
2293 aZoomX
= aZoomY
= Fraction( nNormZoom
, 100 ); // "normal" zoom (always)
2294 sal_uInt16 nPageZoom
= sal::static_int_cast
<sal_uInt16
>(aZoomStr
.getToken(1,'/').toInt32());
2295 if ( nPageZoom
>= MINZOOM
&& nPageZoom
<= MAXZOOM
)
2296 aPageZoomX
= aPageZoomY
= Fraction( nPageZoom
, 100 ); // Pagebreak-zoom, if set
2297 sal_Unicode cMode
= aZoomStr
.getToken(2,'/')[0]; // 0 or "0"/"1"
2298 SetPagebreakMode( cMode
== '1' );
2299 // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
2301 // Tabelle kann ungueltig geworden sein (z.B. letzte Version):
2302 SCTAB nNewTab
= static_cast<SCTAB
>(rData
.getToken(1, ';').toInt32());
2303 if (pDoc
->HasTable( nNewTab
))
2306 // wenn vorhanden, TabBar-Breite holen:
2307 OUString aTabOpt
= rData
.getToken(2, ';');
2309 if (aTabOpt
.startsWith(TAG_TABBARWIDTH
))
2311 sal_Int32 nTagLen
= RTL_CONSTASCII_LENGTH(TAG_TABBARWIDTH
);
2312 pView
->SetTabBarWidth(aTabOpt
.copy(nTagLen
).toInt32());
2318 while ( nCount
> nPos
+nTabStart
)
2320 aTabOpt
= rData
.getToken(static_cast<sal_Int32
>(nPos
+nTabStart
), ';');
2321 EnsureTabDataSize(nPos
+ 1);
2322 if (!maTabData
[nPos
])
2323 maTabData
[nPos
] = new ScViewDataTable
;
2325 sal_Unicode cTabSep
= 0;
2326 if (comphelper::string::getTokenCount(aTabOpt
, SC_OLD_TABSEP
) >= 11)
2327 cTabSep
= SC_OLD_TABSEP
;
2328 else if (comphelper::string::getTokenCount(aTabOpt
, SC_NEW_TABSEP
) >= 11)
2329 cTabSep
= SC_NEW_TABSEP
;
2330 // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
2334 maTabData
[nPos
]->nCurX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(0,cTabSep
).toInt32()));
2335 maTabData
[nPos
]->nCurY
= SanitizeRow( aTabOpt
.getToken(1,cTabSep
).toInt32());
2336 maTabData
[nPos
]->eHSplitMode
= (ScSplitMode
) aTabOpt
.getToken(2,cTabSep
).toInt32();
2337 maTabData
[nPos
]->eVSplitMode
= (ScSplitMode
) aTabOpt
.getToken(3,cTabSep
).toInt32();
2339 if ( maTabData
[nPos
]->eHSplitMode
== SC_SPLIT_FIX
)
2341 maTabData
[nPos
]->nFixPosX
= SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(4,cTabSep
).toInt32()));
2345 maTabData
[nPos
]->nHSplitPos
= aTabOpt
.getToken(4,cTabSep
).toInt32();
2347 if ( maTabData
[nPos
]->eVSplitMode
== SC_SPLIT_FIX
)
2349 maTabData
[nPos
]->nFixPosY
= SanitizeRow( aTabOpt
.getToken(5,cTabSep
).toInt32());
2353 maTabData
[nPos
]->nVSplitPos
= aTabOpt
.getToken(5,cTabSep
).toInt32();
2355 maTabData
[nPos
]->eWhichActive
= (ScSplitPos
) aTabOpt
.getToken(6,cTabSep
).toInt32();
2356 maTabData
[nPos
]->nPosX
[0] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(7,cTabSep
).toInt32()));
2357 maTabData
[nPos
]->nPosX
[1] = SanitizeCol( static_cast<SCCOL
>(aTabOpt
.getToken(8,cTabSep
).toInt32()));
2358 maTabData
[nPos
]->nPosY
[0] = SanitizeRow( aTabOpt
.getToken(9,cTabSep
).toInt32());
2359 maTabData
[nPos
]->nPosY
[1] = SanitizeRow( aTabOpt
.getToken(10,cTabSep
).toInt32());
2361 // Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
2363 ScSplitPos eTest
= maTabData
[nPos
]->eWhichActive
;
2364 if ( ( WhichH( eTest
) == SC_SPLIT_RIGHT
&&
2365 maTabData
[nPos
]->eHSplitMode
== SC_SPLIT_NONE
) ||
2366 ( WhichV( eTest
) == SC_SPLIT_TOP
&&
2367 maTabData
[nPos
]->eVSplitMode
== SC_SPLIT_NONE
) )
2369 // dann wieder auf Default (unten links)
2370 maTabData
[nPos
]->eWhichActive
= SC_SPLIT_BOTTOMLEFT
;
2371 OSL_FAIL("SplitPos musste korrigiert werden");
2380 void ScViewData::WriteExtOptions( ScExtDocOptions
& rDocOpt
) const
2382 // *** Fill extended document data for export filters ***
2384 // document settings
2385 ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2388 rDocSett
.mnDisplTab
= GetTabNo();
2390 // width of the tabbar, relative to frame window width
2391 rDocSett
.mfTabBarWidth
= pView
->GetPendingRelTabBarWidth();
2392 if( rDocSett
.mfTabBarWidth
< 0.0 )
2393 rDocSett
.mfTabBarWidth
= pView
->GetRelTabBarWidth();
2396 for( SCTAB nTab
= 0; nTab
< static_cast<SCTAB
>(maTabData
.size()); ++nTab
)
2398 if( const ScViewDataTable
* pViewTab
= maTabData
[ nTab
] )
2400 ScExtTabSettings
& rTabSett
= rDocOpt
.GetOrCreateTabSettings( nTab
);
2403 ScSplitMode eHSplit
= pViewTab
->eHSplitMode
;
2404 ScSplitMode eVSplit
= pViewTab
->eVSplitMode
;
2405 bool bHSplit
= eHSplit
!= SC_SPLIT_NONE
;
2406 bool bVSplit
= eVSplit
!= SC_SPLIT_NONE
;
2407 bool bRealSplit
= (eHSplit
== SC_SPLIT_NORMAL
) || (eVSplit
== SC_SPLIT_NORMAL
);
2408 bool bFrozen
= (eHSplit
== SC_SPLIT_FIX
) || (eVSplit
== SC_SPLIT_FIX
);
2409 OSL_ENSURE( !bRealSplit
|| !bFrozen
, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
2410 rTabSett
.mbFrozenPanes
= !bRealSplit
&& bFrozen
;
2412 // split and freeze position
2413 rTabSett
.maSplitPos
= Point( 0, 0 );
2414 rTabSett
.maFreezePos
.Set( 0, 0, nTab
);
2417 Point
& rSplitPos
= rTabSett
.maSplitPos
;
2418 rSplitPos
= Point( bHSplit
? pViewTab
->nHSplitPos
: 0, bVSplit
? pViewTab
->nVSplitPos
: 0 );
2419 rSplitPos
= Application::GetDefaultDevice()->PixelToLogic( rSplitPos
, MapMode( MAP_TWIP
) );
2421 rSplitPos
.X() = (long)((double)rSplitPos
.X() / pDocShell
->GetOutputFactor());
2425 if( bHSplit
) rTabSett
.maFreezePos
.SetCol( pViewTab
->nFixPosX
);
2426 if( bVSplit
) rTabSett
.maFreezePos
.SetRow( pViewTab
->nFixPosY
);
2429 // first visible cell in top-left and additional panes
2430 rTabSett
.maFirstVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_LEFT
], pViewTab
->nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
], nTab
);
2431 rTabSett
.maSecondVis
.Set( pViewTab
->nPosX
[ SC_SPLIT_RIGHT
], pViewTab
->nPosY
[ SC_SPLIT_BOTTOM
], nTab
);
2434 switch( pViewTab
->eWhichActive
)
2436 // no horizontal split -> always use left panes
2437 // no vertical split -> always use top panes
2438 case SC_SPLIT_TOPLEFT
:
2439 rTabSett
.meActivePane
= SCEXT_PANE_TOPLEFT
;
2441 case SC_SPLIT_TOPRIGHT
:
2442 rTabSett
.meActivePane
= bHSplit
? SCEXT_PANE_TOPRIGHT
: SCEXT_PANE_TOPLEFT
;
2444 case SC_SPLIT_BOTTOMLEFT
:
2445 rTabSett
.meActivePane
= bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
;
2447 case SC_SPLIT_BOTTOMRIGHT
:
2448 rTabSett
.meActivePane
= bHSplit
?
2449 (bVSplit
? SCEXT_PANE_BOTTOMRIGHT
: SCEXT_PANE_TOPRIGHT
) :
2450 (bVSplit
? SCEXT_PANE_BOTTOMLEFT
: SCEXT_PANE_TOPLEFT
);
2455 rTabSett
.maCursor
.Set( pViewTab
->nCurX
, pViewTab
->nCurY
, nTab
);
2457 // sheet selection and selected ranges
2458 const ScMarkData
& rMarkData
= GetMarkData();
2459 rTabSett
.mbSelected
= rMarkData
.GetTableSelect( nTab
);
2460 rMarkData
.FillRangeListWithMarks( &rTabSett
.maSelection
, true );
2463 rTabSett
.maGridColor
.SetColor( COL_AUTO
);
2466 const Color
& rGridColor
= pOptions
->GetGridColor();
2467 if( rGridColor
.GetColor() != SC_STD_GRIDCOLOR
)
2468 rTabSett
.maGridColor
= rGridColor
;
2470 rTabSett
.mbShowGrid
= pViewTab
->bShowGrid
;
2472 // view mode and zoom
2473 rTabSett
.mbPageMode
= bPagebreak
;
2474 rTabSett
.mnNormalZoom
= static_cast< long >( pViewTab
->aZoomY
* Fraction( 100.0 ) );
2475 rTabSett
.mnPageZoom
= static_cast< long >( pViewTab
->aPageZoomY
* Fraction( 100.0 ) );
2480 void ScViewData::ReadExtOptions( const ScExtDocOptions
& rDocOpt
)
2482 // *** Get extended document data from import filters ***
2484 if( !rDocOpt
.IsChanged() ) return;
2486 // document settings
2487 const ScExtDocSettings
& rDocSett
= rDocOpt
.GetDocSettings();
2490 SetTabNo( rDocSett
.mnDisplTab
);
2492 /* Width of the tabbar, relative to frame window width. We do not have the
2493 correct width of the frame window here -> store in ScTabView, which sets
2494 the size in the next resize. */
2495 pView
->SetPendingRelTabBarWidth( rDocSett
.mfTabBarWidth
);
2498 SCTAB nLastTab
= rDocOpt
.GetLastTab();
2499 if (static_cast<SCTAB
>(maTabData
.size()) <= nLastTab
)
2500 maTabData
.resize(nLastTab
+1);
2502 for( SCTAB nTab
= 0; nTab
< static_cast<SCTAB
>(maTabData
.size()); ++nTab
)
2504 if( const ScExtTabSettings
* pTabSett
= rDocOpt
.GetTabSettings( nTab
) )
2506 if( !maTabData
[ nTab
] )
2507 maTabData
[ nTab
] = new ScViewDataTable
;
2509 const ScExtTabSettings
& rTabSett
= *pTabSett
;
2510 ScViewDataTable
& rViewTab
= *maTabData
[ nTab
];
2512 // split mode initialization
2513 bool bFrozen
= rTabSett
.mbFrozenPanes
;
2514 bool bHSplit
= bFrozen
? (rTabSett
.maFreezePos
.Col() > 0) : (rTabSett
.maSplitPos
.X() > 0);
2515 bool bVSplit
= bFrozen
? (rTabSett
.maFreezePos
.Row() > 0) : (rTabSett
.maSplitPos
.Y() > 0);
2517 // first visible cell of top-left pane and additional panes
2518 if (rTabSett
.maFirstVis
.IsValid())
2520 rViewTab
.nPosX
[ SC_SPLIT_LEFT
] = rTabSett
.maFirstVis
.Col();
2521 rViewTab
.nPosY
[ bVSplit
? SC_SPLIT_TOP
: SC_SPLIT_BOTTOM
] = rTabSett
.maFirstVis
.Row();
2524 if (rTabSett
.maSecondVis
.IsValid())
2527 rViewTab
.nPosX
[ SC_SPLIT_RIGHT
] = rTabSett
.maSecondVis
.Col();
2529 rViewTab
.nPosY
[ SC_SPLIT_BOTTOM
] = rTabSett
.maSecondVis
.Row();
2532 // split mode, split and freeze position
2533 rViewTab
.eHSplitMode
= rViewTab
.eVSplitMode
= SC_SPLIT_NONE
;
2534 rViewTab
.nHSplitPos
= rViewTab
.nVSplitPos
= 0;
2535 rViewTab
.nFixPosX
= 0;
2536 rViewTab
.nFixPosY
= 0;
2541 rViewTab
.eHSplitMode
= SC_SPLIT_FIX
;
2542 rViewTab
.nFixPosX
= rTabSett
.maFreezePos
.Col();
2547 rViewTab
.eVSplitMode
= SC_SPLIT_FIX
;
2548 rViewTab
.nFixPosY
= rTabSett
.maFreezePos
.Row();
2554 Point aPixel
= Application::GetDefaultDevice()->LogicToPixel(
2555 rTabSett
.maSplitPos
, MapMode( MAP_TWIP
) ); //! Zoom?
2556 // the test for use of printer metrics for text formatting here
2557 // effectively results in the nFactor = 1.0 regardless of the Option setting.
2558 if( pDocShell
&& SC_MOD()->GetInputOptions().GetTextWysiwyg())
2560 double nFactor
= pDocShell
->GetOutputFactor();
2561 aPixel
.X() = (long)( aPixel
.X() * nFactor
+ 0.5 );
2564 bHSplit
= bHSplit
&& aPixel
.X() > 0;
2565 bVSplit
= bVSplit
&& aPixel
.Y() > 0;
2568 rViewTab
.eHSplitMode
= SC_SPLIT_NORMAL
;
2569 rViewTab
.nHSplitPos
= aPixel
.X();
2573 rViewTab
.eVSplitMode
= SC_SPLIT_NORMAL
;
2574 rViewTab
.nVSplitPos
= aPixel
.Y();
2579 ScSplitPos ePos
= SC_SPLIT_BOTTOMLEFT
;
2580 switch( rTabSett
.meActivePane
)
2582 // no horizontal split -> always use left panes
2583 // no vertical split -> always use *bottom* panes
2584 case SCEXT_PANE_TOPLEFT
:
2585 ePos
= bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
;
2587 case SCEXT_PANE_TOPRIGHT
:
2589 (bVSplit
? SC_SPLIT_TOPRIGHT
: SC_SPLIT_BOTTOMRIGHT
) :
2590 (bVSplit
? SC_SPLIT_TOPLEFT
: SC_SPLIT_BOTTOMLEFT
);
2592 case SCEXT_PANE_BOTTOMLEFT
:
2593 ePos
= SC_SPLIT_BOTTOMLEFT
;
2595 case SCEXT_PANE_BOTTOMRIGHT
:
2596 ePos
= bHSplit
? SC_SPLIT_BOTTOMRIGHT
: SC_SPLIT_BOTTOMLEFT
;
2599 rViewTab
.eWhichActive
= ePos
;
2602 const ScAddress
& rCursor
= rTabSett
.maCursor
;
2603 if( rCursor
.IsValid() )
2605 rViewTab
.nCurX
= rCursor
.Col();
2606 rViewTab
.nCurY
= rCursor
.Row();
2609 // sheet selection and selected ranges
2610 ScMarkData
& rMarkData
= GetMarkData();
2611 rMarkData
.SelectTable( nTab
, rTabSett
.mbSelected
);
2613 // zoom for each sheet
2614 if( rTabSett
.mnNormalZoom
)
2615 rViewTab
.aZoomX
= rViewTab
.aZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2616 if( rTabSett
.mnPageZoom
)
2617 rViewTab
.aPageZoomX
= rViewTab
.aPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2619 rViewTab
.bShowGrid
= rTabSett
.mbShowGrid
;
2621 // get some settings from displayed Excel sheet, set at Calc document
2622 if( nTab
== GetTabNo() )
2624 // grid color -- #i47435# set automatic grid color explicitly
2627 Color
aGridColor( rTabSett
.maGridColor
);
2628 if( aGridColor
.GetColor() == COL_AUTO
)
2629 aGridColor
.SetColor( SC_STD_GRIDCOLOR
);
2630 pOptions
->SetGridColor( aGridColor
, EMPTY_OUSTRING
);
2633 // view mode and default zoom (for new sheets) from current sheet
2634 if( rTabSett
.mnNormalZoom
)
2635 aDefZoomX
= aDefZoomY
= Fraction( rTabSett
.mnNormalZoom
, 100L );
2636 if( rTabSett
.mnPageZoom
)
2637 aDefPageZoomX
= aDefPageZoomY
= Fraction( rTabSett
.mnPageZoom
, 100L );
2638 /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
2639 update map modes that are needed to draw text correctly. */
2640 SetPagebreakMode( rTabSett
.mbPageMode
);
2645 // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
2648 void ScViewData::WriteUserDataSequence(uno::Sequence
<beans::PropertyValue
>& rSettings
) const
2650 rSettings
.realloc(SC_VIEWSETTINGS_COUNT
);
2651 // + 1, because we have to put the view id in the sequence
2652 beans::PropertyValue
* pSettings
= rSettings
.getArray();
2655 sal_uInt16
nViewID(pViewShell
->GetViewFrame()->GetCurViewId());
2656 pSettings
[SC_VIEW_ID
].Name
= SC_VIEWID
;
2657 OUStringBuffer
sBuffer(SC_VIEW
);
2658 ::sax::Converter::convertNumber(sBuffer
,
2659 static_cast<sal_Int32
>(nViewID
));
2660 pSettings
[SC_VIEW_ID
].Value
<<= sBuffer
.makeStringAndClear();
2662 uno::Reference
<container::XNameContainer
> xNameContainer
=
2663 document::NamedPropertyValues::create( comphelper::getProcessComponentContext() );
2664 for (SCTAB nTab
=0; nTab
<static_cast<SCTAB
>(maTabData
.size()); nTab
++)
2666 if (maTabData
[nTab
])
2668 uno::Sequence
<beans::PropertyValue
> aTableViewSettings
;
2669 maTabData
[nTab
]->WriteUserDataSequence(aTableViewSettings
, *this, nTab
);
2671 GetDocument()->GetName( nTab
, sTabName
);
2673 aAny
<<= aTableViewSettings
;
2676 xNameContainer
->insertByName(sTabName
, aAny
);
2678 //#101739#; two tables with the same name are possible
2679 catch ( container::ElementExistException
& )
2681 OSL_FAIL("seems there are two tables with the same name");
2683 catch ( uno::RuntimeException
& )
2685 OSL_FAIL("something went wrong");
2689 pSettings
[SC_TABLE_VIEWSETTINGS
].Name
= SC_TABLES
;
2690 pSettings
[SC_TABLE_VIEWSETTINGS
].Value
<<= xNameContainer
;
2693 GetDocument()->GetName( nTabNo
, sName
);
2694 pSettings
[SC_ACTIVE_TABLE
].Name
= SC_ACTIVETABLE
;
2695 pSettings
[SC_ACTIVE_TABLE
].Value
<<= sName
;
2696 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Name
= SC_HORIZONTALSCROLLBARWIDTH
;
2697 pSettings
[SC_HORIZONTAL_SCROLL_BAR_WIDTH
].Value
<<= sal_Int32(pView
->GetTabBarWidth());
2698 sal_Int32
nZoomValue ((pThisTab
->aZoomY
.GetNumerator() * 100) / pThisTab
->aZoomY
.GetDenominator());
2699 sal_Int32
nPageZoomValue ((pThisTab
->aPageZoomY
.GetNumerator() * 100) / pThisTab
->aPageZoomY
.GetDenominator());
2700 pSettings
[SC_ZOOM_TYPE
].Name
= SC_ZOOMTYPE
;
2701 pSettings
[SC_ZOOM_TYPE
].Value
<<= sal_Int16(pThisTab
->eZoomType
);
2702 pSettings
[SC_ZOOM_VALUE
].Name
= SC_ZOOMVALUE
;
2703 pSettings
[SC_ZOOM_VALUE
].Value
<<= nZoomValue
;
2704 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Name
= SC_PAGEVIEWZOOMVALUE
;
2705 pSettings
[SC_PAGE_VIEW_ZOOM_VALUE
].Value
<<= nPageZoomValue
;
2706 pSettings
[SC_PAGE_BREAK_PREVIEW
].Name
= SC_SHOWPAGEBREAKPREVIEW
;
2707 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_PAGE_BREAK_PREVIEW
].Value
, bPagebreak
);
2711 pSettings
[SC_SHOWZERO
].Name
= SC_UNO_SHOWZERO
;
2712 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWZERO
].Value
, pOptions
->GetOption( VOPT_NULLVALS
) );
2713 pSettings
[SC_SHOWNOTES
].Name
= SC_UNO_SHOWNOTES
;
2714 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWNOTES
].Value
, pOptions
->GetOption( VOPT_NOTES
) );
2715 pSettings
[SC_SHOWGRID
].Name
= SC_UNO_SHOWGRID
;
2716 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWGRID
].Value
, pOptions
->GetOption( VOPT_GRID
) );
2717 pSettings
[SC_GRIDCOLOR
].Name
= SC_UNO_GRIDCOLOR
;
2718 OUString aColorName
;
2719 Color aColor
= pOptions
->GetGridColor(&aColorName
);
2720 pSettings
[SC_GRIDCOLOR
].Value
<<= static_cast<sal_Int64
>(aColor
.GetColor());
2721 pSettings
[SC_SHOWPAGEBR
].Name
= SC_UNO_SHOWPAGEBR
;
2722 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHOWPAGEBR
].Value
, pOptions
->GetOption( VOPT_PAGEBREAKS
) );
2723 pSettings
[SC_COLROWHDR
].Name
= SC_UNO_COLROWHDR
;
2724 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_COLROWHDR
].Value
, pOptions
->GetOption( VOPT_HEADER
) );
2725 pSettings
[SC_SHEETTABS
].Name
= SC_UNO_SHEETTABS
;
2726 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SHEETTABS
].Value
, pOptions
->GetOption( VOPT_TABCONTROLS
) );
2727 pSettings
[SC_OUTLSYMB
].Name
= SC_UNO_OUTLSYMB
;
2728 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_OUTLSYMB
].Value
, pOptions
->GetOption( VOPT_OUTLINER
) );
2729 pSettings
[SC_VALUE_HIGHLIGHTING
].Name
= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VALUEHIGH
) );
2730 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_VALUE_HIGHLIGHTING
].Value
, pOptions
->GetOption( VOPT_SYNTAX
) );
2732 const ScGridOptions
& aGridOpt
= pOptions
->GetGridOptions();
2733 pSettings
[SC_SNAPTORASTER
].Name
= SC_UNO_SNAPTORASTER
;
2734 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_SNAPTORASTER
].Value
, aGridOpt
.GetUseGridSnap() );
2735 pSettings
[SC_RASTERVIS
].Name
= SC_UNO_RASTERVIS
;
2736 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERVIS
].Value
, aGridOpt
.GetGridVisible() );
2737 pSettings
[SC_RASTERRESX
].Name
= SC_UNO_RASTERRESX
;
2738 pSettings
[SC_RASTERRESX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDrawX() );
2739 pSettings
[SC_RASTERRESY
].Name
= SC_UNO_RASTERRESY
;
2740 pSettings
[SC_RASTERRESY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDrawY() );
2741 pSettings
[SC_RASTERSUBX
].Name
= SC_UNO_RASTERSUBX
;
2742 pSettings
[SC_RASTERSUBX
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDivisionX() );
2743 pSettings
[SC_RASTERSUBY
].Name
= SC_UNO_RASTERSUBY
;
2744 pSettings
[SC_RASTERSUBY
].Value
<<= static_cast<sal_Int32
> ( aGridOpt
.GetFieldDivisionY() );
2745 pSettings
[SC_RASTERSYNC
].Name
= SC_UNO_RASTERSYNC
;
2746 ScUnoHelpFunctions::SetBoolInAny( pSettings
[SC_RASTERSYNC
].Value
, aGridOpt
.GetSynchronize() );
2751 void ScViewData::ReadUserDataSequence(const uno::Sequence
<beans::PropertyValue
>& rSettings
)
2753 std::vector
<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
2755 sal_Int32
nCount(rSettings
.getLength());
2756 sal_Int32
nTemp32(0);
2757 sal_Int16
nTemp16(0);
2758 bool bPageMode(false);
2760 EnsureTabDataSize(GetDocument()->GetTableCount()-1);
2762 for (sal_Int32 i
= 0; i
< nCount
; i
++)
2764 // SC_VIEWID has to parse and use by mba
2765 OUString
sName(rSettings
[i
].Name
);
2766 if (sName
== SC_TABLES
)
2768 uno::Reference
<container::XNameContainer
> xNameContainer
;
2769 if ((rSettings
[i
].Value
>>= xNameContainer
) && xNameContainer
->hasElements())
2771 uno::Sequence
< OUString
> aNames(xNameContainer
->getElementNames());
2772 for (sal_Int32 nTabPos
= 0; nTabPos
< aNames
.getLength(); nTabPos
++)
2774 OUString
sTabName(aNames
[nTabPos
]);
2776 if (GetDocument()->GetTable(sTabName
, nTab
))
2778 uno::Any aAny
= xNameContainer
->getByName(aNames
[nTabPos
]);
2779 uno::Sequence
<beans::PropertyValue
> aTabSettings
;
2780 if (aAny
>>= aTabSettings
)
2782 EnsureTabDataSize(nTab
+ 1);
2783 if (!maTabData
[nTab
])
2784 maTabData
[nTab
] = new ScViewDataTable
;
2786 bool bHasZoom
= false;
2787 maTabData
[nTab
]->ReadUserDataSequence(aTabSettings
, *this, nTab
, bHasZoom
);
2788 aHasZoomVect
[nTab
] = bHasZoom
;
2794 else if (sName
== SC_ACTIVETABLE
)
2797 if(rSettings
[i
].Value
>>= sValue
)
2799 OUString
sTabName(sValue
);
2801 if (GetDocument()->GetTable(sTabName
, nTab
))
2805 else if (sName
== SC_HORIZONTALSCROLLBARWIDTH
)
2807 if (rSettings
[i
].Value
>>= nTemp32
)
2808 pView
->SetTabBarWidth(nTemp32
);
2810 else if (sName
== SC_RELHORIZONTALTABBARWIDTH
)
2812 double fWidth
= 0.0;
2813 if (rSettings
[i
].Value
>>= fWidth
)
2814 pView
->SetPendingRelTabBarWidth( fWidth
);
2816 else if (sName
== SC_ZOOMTYPE
)
2818 if (rSettings
[i
].Value
>>= nTemp16
)
2819 eDefZoomType
= SvxZoomType(nTemp16
);
2821 else if (sName
== SC_ZOOMVALUE
)
2823 if (rSettings
[i
].Value
>>= nTemp32
)
2825 Fraction
aZoom(nTemp32
, 100);
2826 aDefZoomX
= aDefZoomY
= aZoom
;
2829 else if (sName
== SC_PAGEVIEWZOOMVALUE
)
2831 if (rSettings
[i
].Value
>>= nTemp32
)
2833 Fraction
aZoom(nTemp32
, 100);
2834 aDefPageZoomX
= aDefPageZoomY
= aZoom
;
2837 else if (sName
== SC_SHOWPAGEBREAKPREVIEW
)
2838 bPageMode
= ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
);
2839 else if ( sName
== SC_UNO_SHOWZERO
)
2840 pOptions
->SetOption(VOPT_NULLVALS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2841 else if ( sName
== SC_UNO_SHOWNOTES
)
2842 pOptions
->SetOption(VOPT_NOTES
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2843 else if ( sName
== SC_UNO_SHOWGRID
)
2844 pOptions
->SetOption(VOPT_GRID
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2845 else if ( sName
== SC_UNO_GRIDCOLOR
)
2847 sal_Int64 nColor
= 0;
2848 if (rSettings
[i
].Value
>>= nColor
)
2850 OUString aColorName
;
2851 Color
aColor(static_cast<sal_uInt32
>(nColor
));
2852 // #i47435# set automatic grid color explicitly
2853 if( aColor
.GetColor() == COL_AUTO
)
2854 aColor
.SetColor( SC_STD_GRIDCOLOR
);
2855 pOptions
->SetGridColor(aColor
, aColorName
);
2858 else if ( sName
== SC_UNO_SHOWPAGEBR
)
2859 pOptions
->SetOption(VOPT_PAGEBREAKS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2860 else if ( sName
== SC_UNO_COLROWHDR
)
2861 pOptions
->SetOption(VOPT_HEADER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2862 else if ( sName
== SC_UNO_SHEETTABS
)
2863 pOptions
->SetOption(VOPT_TABCONTROLS
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2864 else if ( sName
== SC_UNO_OUTLSYMB
)
2865 pOptions
->SetOption(VOPT_OUTLINER
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2866 else if ( sName
== SC_UNO_SHOWOBJ
)
2868 // #i80528# placeholders not supported anymore
2869 if ( rSettings
[i
].Value
>>= nTemp16
)
2870 pOptions
->SetObjMode( VOBJ_TYPE_OLE
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2872 else if ( sName
== SC_UNO_SHOWCHARTS
)
2874 // #i80528# placeholders not supported anymore
2875 if ( rSettings
[i
].Value
>>= nTemp16
)
2876 pOptions
->SetObjMode( VOBJ_TYPE_CHART
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2878 else if ( sName
== SC_UNO_SHOWDRAW
)
2880 // #i80528# placeholders not supported anymore
2881 if ( rSettings
[i
].Value
>>= nTemp16
)
2882 pOptions
->SetObjMode( VOBJ_TYPE_DRAW
, (nTemp16
== 1) ? VOBJ_MODE_HIDE
: VOBJ_MODE_SHOW
);
2884 else if ( sName
.compareToAscii( SC_UNO_VALUEHIGH
) == 0 )
2885 pOptions
->SetOption( VOPT_SYNTAX
, ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2888 ScGridOptions
aGridOpt(pOptions
->GetGridOptions());
2889 if ( sName
== SC_UNO_SNAPTORASTER
)
2890 aGridOpt
.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2891 else if ( sName
== SC_UNO_RASTERVIS
)
2892 aGridOpt
.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2893 else if ( sName
== SC_UNO_RASTERRESX
)
2894 aGridOpt
.SetFieldDrawX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2895 else if ( sName
== SC_UNO_RASTERRESY
)
2896 aGridOpt
.SetFieldDrawY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2897 else if ( sName
== SC_UNO_RASTERSUBX
)
2898 aGridOpt
.SetFieldDivisionX( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2899 else if ( sName
== SC_UNO_RASTERSUBY
)
2900 aGridOpt
.SetFieldDivisionY( static_cast <sal_uInt32
> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings
[i
].Value
) ) );
2901 else if ( sName
== SC_UNO_RASTERSYNC
)
2902 aGridOpt
.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings
[i
].Value
) );
2903 pOptions
->SetGridOptions(aGridOpt
);
2907 // copy default zoom to sheets where a different one wasn't specified
2908 for (SCTAB nZoomTab
=0; nZoomTab
< static_cast<SCTAB
>(maTabData
.size()); ++nZoomTab
)
2909 if (maTabData
[nZoomTab
] && ( nZoomTab
>= static_cast<SCTAB
>(aHasZoomVect
.size()) || !aHasZoomVect
[nZoomTab
] ))
2911 maTabData
[nZoomTab
]->eZoomType
= eDefZoomType
;
2912 maTabData
[nZoomTab
]->aZoomX
= aDefZoomX
;
2913 maTabData
[nZoomTab
]->aZoomY
= aDefZoomY
;
2914 maTabData
[nZoomTab
]->aPageZoomX
= aDefPageZoomX
;
2915 maTabData
[nZoomTab
]->aPageZoomY
= aDefPageZoomY
;
2919 SetPagebreakMode( bPageMode
);
2921 // #i47426# write view options to document, needed e.g. for Excel export
2922 pDoc
->SetViewOptions( *pOptions
);
2925 void ScViewData::SetOptions( const ScViewOptions
& rOpt
)
2927 // if visibility of horizontal ScrollBar is changed, TabBar may have to be resized...
2928 bool bHScrollChanged
= ( rOpt
.GetOption(VOPT_HSCROLL
) != pOptions
->GetOption(VOPT_HSCROLL
) );
2930 // if graphics are turned on or off, animation has to be started or stopped
2931 // graphics are controlled by VOBJ_TYPE_OLE
2932 bool bGraphicsChanged
= ( pOptions
->GetObjMode(VOBJ_TYPE_OLE
) !=
2933 rOpt
.GetObjMode(VOBJ_TYPE_OLE
) );
2936 OSL_ENSURE( pView
, "No View" );
2940 pView
->ViewOptionsHasChanged( bHScrollChanged
, bGraphicsChanged
);
2944 Point
ScViewData::GetMousePosPixel()
2946 OSL_ENSURE( pView
, "GetMousePosPixel() ohne View" );
2947 return pView
->GetMousePosPixel();
2950 void ScViewData::UpdateInputHandler( bool bForce
, bool bStopEditing
)
2953 pViewShell
->UpdateInputHandler( bForce
, bStopEditing
);
2956 bool ScViewData::IsOle()
2958 return pDocShell
&& pDocShell
->IsOle();
2961 bool ScViewData::UpdateFixX( SCTAB nTab
) // true = value changed
2963 if (!ValidTab(nTab
)) // Default
2964 nTab
=nTabNo
; // current table
2966 if (!pView
|| maTabData
[nTab
]->eHSplitMode
!= SC_SPLIT_FIX
)
2969 ScDocument
* pLocalDoc
= GetDocument();
2970 if (!pLocalDoc
->HasTable(nTab
)) // if called from reload, the sheet may not exist
2973 SCCOL nFix
= maTabData
[nTab
]->nFixPosX
;
2975 for (SCCOL nX
=maTabData
[nTab
]->nPosX
[SC_SPLIT_LEFT
]; nX
<nFix
; nX
++)
2977 sal_uInt16 nTSize
= pLocalDoc
->GetColWidth( nX
, nTab
);
2980 long nPix
= ToPixel( nTSize
, nPPTX
);
2984 nNewPos
+= pView
->GetGridOffset().X();
2985 if (nNewPos
!= maTabData
[nTab
]->nHSplitPos
)
2987 maTabData
[nTab
]->nHSplitPos
= nNewPos
;
2989 RecalcPixPos(); // should not be needed
2996 bool ScViewData::UpdateFixY( SCTAB nTab
) // true = value changed
2998 if (!ValidTab(nTab
)) // Default
2999 nTab
=nTabNo
; // current table
3001 if (!pView
|| maTabData
[nTab
]->eVSplitMode
!= SC_SPLIT_FIX
)
3004 ScDocument
* pLocalDoc
= GetDocument();
3005 if (!pLocalDoc
->HasTable(nTab
)) // if called from reload, the sheet may not exist
3008 SCROW nFix
= maTabData
[nTab
]->nFixPosY
;
3010 for (SCROW nY
=maTabData
[nTab
]->nPosY
[SC_SPLIT_TOP
]; nY
<nFix
; nY
++)
3012 sal_uInt16 nTSize
= pLocalDoc
->GetRowHeight( nY
, nTab
);
3015 long nPix
= ToPixel( nTSize
, nPPTY
);
3019 nNewPos
+= pView
->GetGridOffset().Y();
3020 if (nNewPos
!= maTabData
[nTab
]->nVSplitPos
)
3022 maTabData
[nTab
]->nVSplitPos
= nNewPos
;
3024 RecalcPixPos(); // should not be needed
3031 void ScViewData::UpdateOutlinerFlags( Outliner
& rOutl
) const
3033 ScDocument
* pLocalDoc
= GetDocument();
3034 bool bOnlineSpell
= pLocalDoc
->GetDocOptions().IsAutoSpell();
3036 EEControlBits nCntrl
= rOutl
.GetControlWord();
3037 nCntrl
|= EEControlBits::MARKFIELDS
;
3038 nCntrl
|= EEControlBits::AUTOCORRECT
;
3040 nCntrl
|= EEControlBits::ONLINESPELLING
;
3042 nCntrl
&= ~EEControlBits::ONLINESPELLING
;
3043 rOutl
.SetControlWord(nCntrl
);
3045 rOutl
.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule
, CalcFieldValueHdl
) );
3047 // don't call GetSpellChecker if online spelling isn't enabled.
3048 // The language for AutoCorrect etc. is taken from the pool defaults
3049 // (set in ScDocument::UpdateDrawLanguages)
3053 com::sun::star::uno::Reference
<com::sun::star::linguistic2::XSpellChecker1
> xXSpellChecker1( LinguMgr::GetSpellChecker() );
3054 rOutl
.SetSpeller( xXSpellChecker1
);
3057 rOutl
.SetDefaultHorizontalTextDirection(
3058 (EEHorizontalTextDirection
)pLocalDoc
->GetEditTextDirection( nTabNo
) );
3061 ScAddress
ScViewData::GetCurPos() const
3063 return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
3066 void ScViewData::SetRefStart( SCCOL nNewX
, SCROW nNewY
, SCTAB nNewZ
)
3068 nRefStartX
= nNewX
; nRefStartY
= nNewY
; nRefStartZ
= nNewZ
;
3071 void ScViewData::SetRefEnd( SCCOL nNewX
, SCROW nNewY
, SCTAB nNewZ
)
3073 nRefEndX
= nNewX
; nRefEndY
= nNewY
; nRefEndZ
= nNewZ
;
3076 void ScViewData::AddPixelsWhile( long & rScrY
, long nEndPixels
, SCROW
& rPosY
,
3077 SCROW nEndRow
, double nPPTY
, const ScDocument
* pDoc
, SCTAB nTabNo
)
3080 while (rScrY
<= nEndPixels
&& nRow
<= nEndRow
)
3082 SCROW nHeightEndRow
;
3083 sal_uInt16 nHeight
= pDoc
->GetRowHeight( nRow
, nTabNo
, NULL
, &nHeightEndRow
);
3084 if (nHeightEndRow
> nEndRow
)
3085 nHeightEndRow
= nEndRow
;
3087 nRow
= nHeightEndRow
+ 1;
3090 SCROW nRows
= nHeightEndRow
- nRow
+ 1;
3091 sal_Int64 nPixel
= ToPixel( nHeight
, nPPTY
);
3092 sal_Int64 nAdd
= nPixel
* nRows
;
3093 if (nAdd
+ rScrY
> nEndPixels
)
3095 sal_Int64 nDiff
= rScrY
+ nAdd
- nEndPixels
;
3096 nRows
-= static_cast<SCROW
>(nDiff
/ nPixel
);
3097 nAdd
= nPixel
* nRows
;
3098 // We're looking for a value that satisfies loop condition.
3099 if (nAdd
+ rScrY
<= nEndPixels
)
3105 rScrY
+= static_cast<long>(nAdd
);
3114 void ScViewData::AddPixelsWhileBackward( long & rScrY
, long nEndPixels
,
3115 SCROW
& rPosY
, SCROW nStartRow
, double nPPTY
, const ScDocument
* pDoc
,
3119 while (rScrY
<= nEndPixels
&& nRow
>= nStartRow
)
3121 SCROW nHeightStartRow
;
3122 sal_uInt16 nHeight
= pDoc
->GetRowHeight( nRow
, nTabNo
, &nHeightStartRow
, NULL
);
3123 if (nHeightStartRow
< nStartRow
)
3124 nHeightStartRow
= nStartRow
;
3126 nRow
= nHeightStartRow
- 1;
3129 SCROW nRows
= nRow
- nHeightStartRow
+ 1;
3130 sal_Int64 nPixel
= ToPixel( nHeight
, nPPTY
);
3131 sal_Int64 nAdd
= nPixel
* nRows
;
3132 if (nAdd
+ rScrY
> nEndPixels
)
3134 sal_Int64 nDiff
= nAdd
+ rScrY
- nEndPixels
;
3135 nRows
-= static_cast<SCROW
>(nDiff
/ nPixel
);
3136 nAdd
= nPixel
* nRows
;
3137 // We're looking for a value that satisfies loop condition.
3138 if (nAdd
+ rScrY
<= nEndPixels
)
3144 rScrY
+= static_cast<long>(nAdd
);
3153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */