Update to m13
[ooovba.git] / sc / source / filter / xlsx / xlsx-xeview.cxx
blob4cf8efbbb2b22bdc79a97d7e81da4b256f147012
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xeview.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
33 #include "xlsx/xladdress.hxx"
34 #include "xlsx/xlconst.hxx"
35 #include "xlsx/xlformula.hxx"
36 #include "xeview.hxx"
37 #include "document.hxx"
38 #include "scextopt.hxx"
39 #include "viewopti.hxx"
40 #include "xelink.hxx"
41 #include "xestyle.hxx"
43 #include <oox/core/tokens.hxx>
45 using ::rtl::OString;
47 // Workbook view settings records =============================================
49 XclExpWindow1::XclExpWindow1( const XclExpRoot& rRoot ) :
50 XclExpRecord( EXC_ID_WINDOW1, 18 ),
51 mnFlags( 0 ),
52 mnTabBarSize( 600 )
54 const ScViewOptions& rViewOpt = rRoot.GetDoc().GetViewOptions();
55 ::set_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR, rViewOpt.GetOption( VOPT_HSCROLL ) );
56 ::set_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR, rViewOpt.GetOption( VOPT_VSCROLL ) );
57 ::set_flag( mnFlags, EXC_WIN1_TABBAR, rViewOpt.GetOption( VOPT_TABCONTROLS ) );
59 double fTabBarWidth = rRoot.GetExtDocOptions().GetDocSettings().mfTabBarWidth;
60 if( (0.0 <= fTabBarWidth) && (fTabBarWidth <= 1.0) )
61 mnTabBarSize = static_cast< sal_uInt16 >( fTabBarWidth * 1000.0 + 0.5 );
64 void XclExpWindow1::SaveXml( XclExpXmlStream& rStrm )
66 const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
68 rStrm.GetCurrentStream()->singleElement( XML_workbookView,
69 // OOXTODO: XML_visibility, // ST_visibilty
70 // OOXTODO: XML_minimized, // bool
71 XML_showHorizontalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR ) ),
72 XML_showVerticalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR ) ),
73 XML_showSheetTabs, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_TABBAR ) ),
74 XML_xWindow, "0",
75 XML_yWindow, "0",
76 XML_windowWidth, OString::valueOf( (sal_Int32)0x4000 ).getStr(),
77 XML_windowHeight, OString::valueOf( (sal_Int32)0x2000 ).getStr(),
78 XML_tabRatio, OString::valueOf( (sal_Int32)mnTabBarSize ).getStr(),
79 XML_firstSheet, OString::valueOf( (sal_Int32)rTabInfo.GetFirstVisXclTab() ).getStr(),
80 XML_activeTab, OString::valueOf( (sal_Int32)rTabInfo.GetDisplayedXclTab() ).getStr(),
81 // OOXTODO: XML_autoFilterDateGrouping, // bool; AUTOFILTER12? 87Eh
82 FSEND );
85 void XclExpWindow1::WriteBody( XclExpStream& rStrm )
87 const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
89 rStrm << sal_uInt16( 0 ) // X position of the window
90 << sal_uInt16( 0 ) // Y position of the window
91 << sal_uInt16( 0x4000 ) // width of the window
92 << sal_uInt16( 0x2000 ) // height of the window
93 << mnFlags
94 << rTabInfo.GetDisplayedXclTab()
95 << rTabInfo.GetFirstVisXclTab()
96 << rTabInfo.GetXclSelectedCount()
97 << mnTabBarSize;
100 // Sheet view settings records ================================================
102 XclExpWindow2::XclExpWindow2( const XclExpRoot& rRoot,
103 const XclTabViewData& rData, sal_uInt32 nGridColorId ) :
104 XclExpRecord( EXC_ID_WINDOW2, (rRoot.GetBiff() == EXC_BIFF8) ? 18 : 10 ),
105 maGridColor( rData.maGridColor ),
106 mnGridColorId( nGridColorId ),
107 mnFlags( 0 ),
108 maFirstXclPos( rData.maFirstXclPos ),
109 mnNormalZoom( rData.mnNormalZoom ),
110 mnPageZoom( rData.mnPageZoom )
112 ::set_flag( mnFlags, EXC_WIN2_SHOWFORMULAS, rData.mbShowFormulas );
113 ::set_flag( mnFlags, EXC_WIN2_SHOWGRID, rData.mbShowGrid );
114 ::set_flag( mnFlags, EXC_WIN2_SHOWHEADINGS, rData.mbShowHeadings );
115 ::set_flag( mnFlags, EXC_WIN2_FROZEN, rData.mbFrozenPanes );
116 ::set_flag( mnFlags, EXC_WIN2_SHOWZEROS, rData.mbShowZeros );
117 ::set_flag( mnFlags, EXC_WIN2_DEFGRIDCOLOR, rData.mbDefGridColor );
118 ::set_flag( mnFlags, EXC_WIN2_MIRRORED, rData.mbMirrored );
119 ::set_flag( mnFlags, EXC_WIN2_SHOWOUTLINE, rData.mbShowOutline );
120 ::set_flag( mnFlags, EXC_WIN2_FROZENNOSPLIT, rData.mbFrozenPanes );
121 ::set_flag( mnFlags, EXC_WIN2_SELECTED, rData.mbSelected );
122 ::set_flag( mnFlags, EXC_WIN2_DISPLAYED, rData.mbDisplayed );
123 ::set_flag( mnFlags, EXC_WIN2_PAGEBREAKMODE, rData.mbPageMode );
126 void XclExpWindow2::WriteBody( XclExpStream& rStrm )
128 const XclExpRoot& rRoot = rStrm.GetRoot();
130 rStrm << mnFlags
131 << maFirstXclPos;
133 switch( rRoot.GetBiff() )
135 case EXC_BIFF3:
136 case EXC_BIFF4:
137 case EXC_BIFF5:
138 rStrm << maGridColor;
139 break;
140 case EXC_BIFF8:
141 rStrm << rRoot.GetPalette().GetColorIndex( mnGridColorId )
142 << sal_uInt16( 0 )
143 << mnPageZoom
144 << mnNormalZoom
145 << sal_uInt32( 0 );
146 break;
147 default: DBG_ERROR_BIFF();
151 // ----------------------------------------------------------------------------
153 XclExpScl::XclExpScl( sal_uInt16 nZoom ) :
154 XclExpRecord( EXC_ID_SCL, 4 ),
155 mnNum( nZoom ),
156 mnDenom( 100 )
158 Shorten( 2 );
159 Shorten( 5 );
162 void XclExpScl::Shorten( sal_uInt16 nFactor )
164 while( (mnNum % nFactor == 0) && (mnDenom % nFactor == 0) )
166 mnNum = mnNum / nFactor;
167 mnDenom = mnDenom / nFactor;
171 void XclExpScl::WriteBody( XclExpStream& rStrm )
173 DBG_ASSERT_BIFF( rStrm.GetRoot().GetBiff() >= EXC_BIFF4 );
174 rStrm << mnNum << mnDenom;
177 // ----------------------------------------------------------------------------
179 XclExpPane::XclExpPane( const XclTabViewData& rData ) :
180 XclExpRecord( EXC_ID_PANE, 10 ),
181 mnSplitX( rData.mnSplitX ),
182 mnSplitY( rData.mnSplitY ),
183 maSecondXclPos( rData.maSecondXclPos ),
184 mnActivePane( rData.mnActivePane )
186 DBG_ASSERT( rData.IsSplit(), "XclExpPane::XclExpPane - no PANE record for unsplit view" );
189 static const char* lcl_GetActivePane( sal_uInt8 nActivePane )
191 switch( nActivePane )
193 case EXC_PANE_TOPLEFT: return "topLeft"; //break;
194 case EXC_PANE_TOPRIGHT: return "topRight"; //break;
195 case EXC_PANE_BOTTOMLEFT: return "bottomLeft"; //break;
196 case EXC_PANE_BOTTOMRIGHT: return "bottomRight"; //break;
198 return "**error: lcl_GetActivePane";
201 void XclExpPane::SaveXml( XclExpXmlStream& rStrm )
203 rStrm.GetCurrentStream()->singleElement( XML_pane,
204 XML_xSplit, OString::valueOf( (sal_Int32)mnSplitX ).getStr(),
205 XML_ySplit, OString::valueOf( (sal_Int32)mnSplitY ).getStr(),
206 XML_topLeftCell, XclXmlUtils::ToOString( maSecondXclPos ).getStr(),
207 XML_activePane, lcl_GetActivePane( mnActivePane ),
208 // OOXTODO: XML_state,
209 FSEND );
212 void XclExpPane::WriteBody( XclExpStream& rStrm )
214 rStrm << mnSplitX
215 << mnSplitY
216 << maSecondXclPos
217 << mnActivePane;
218 if( rStrm.GetRoot().GetBiff() >= EXC_BIFF5 )
219 rStrm << sal_uInt8( 0 );
222 // ----------------------------------------------------------------------------
224 XclExpSelection::XclExpSelection( const XclTabViewData& rData, sal_uInt8 nPane ) :
225 XclExpRecord( EXC_ID_SELECTION, 15 ),
226 mnPane( nPane )
228 if( const XclSelectionData* pSelData = rData.GetSelectionData( nPane ) )
229 maSelData = *pSelData;
231 // find the cursor position in the selection list (or add it)
232 XclRangeList& rXclSel = maSelData.maXclSelection;
233 bool bFound = false;
234 for( XclRangeList::const_iterator aIt = rXclSel.begin(), aEnd = rXclSel.end(); !bFound && (aIt != aEnd); ++aIt )
235 if( (bFound = aIt->Contains( maSelData.maXclCursor )) == true )
236 maSelData.mnCursorIdx = static_cast< sal_uInt16 >( aIt - rXclSel.begin() );
237 /* Cursor cell not found in list? (e.g. inactive pane, or removed in
238 ConvertRangeList(), because Calc cursor on invalid pos)
239 -> insert the valid Excel cursor. */
240 if( !bFound )
242 maSelData.mnCursorIdx = static_cast< sal_uInt16 >( rXclSel.size() );
243 rXclSel.push_back( XclRange( maSelData.maXclCursor ) );
247 void XclExpSelection::SaveXml( XclExpXmlStream& rStrm )
249 rStrm.GetCurrentStream()->singleElement( XML_selection,
250 XML_pane, lcl_GetActivePane( mnPane ),
251 XML_activeCell, XclXmlUtils::ToOString( maSelData.maXclCursor ).getStr(),
252 XML_activeCellId, OString::valueOf( (sal_Int32) maSelData.mnCursorIdx ).getStr(),
253 XML_sqref, XclXmlUtils::ToOString( maSelData.maXclSelection ).getStr(),
254 FSEND );
257 void XclExpSelection::WriteBody( XclExpStream& rStrm )
259 rStrm << mnPane // pane for this selection
260 << maSelData.maXclCursor // cell cursor
261 << maSelData.mnCursorIdx; // index to range containing cursor
262 maSelData.maXclSelection.Write( rStrm, false );
265 // ----------------------------------------------------------------------------
267 XclExpTabBgColor::XclExpTabBgColor( const XclTabViewData& rTabViewData ) :
268 XclExpRecord( EXC_ID_SHEETEXT, 18 ),
269 mrTabViewData( rTabViewData )
272 //TODO Fix savexml...
273 /*void XclExpTabBgColor::SaveXml( XclExpXmlStream& rStrm )
277 void XclExpTabBgColor::WriteBody( XclExpStream& rStrm )
279 if ( mrTabViewData.IsDefaultTabBgColor() )
280 return;
281 sal_uInt16 rt = 0x0862; //rt
282 sal_uInt16 grbitFrt = 0x0000; //grbit must be set to 0
283 sal_uInt32 unused = 0x00000000; //Use twice...
284 sal_uInt32 cb = 0x00000014; // Record Size, may be larger in future...
285 sal_uInt16 reserved = 0x0000; //trailing bits are 0
286 sal_uInt16 TabBgColorIndex;
287 XclExpPalette& rPal = rStrm.GetRoot().GetPalette();
288 TabBgColorIndex = rPal.GetColorIndex(mrTabViewData.mnTabBgColorId);
289 if (TabBgColorIndex < 8 || TabBgColorIndex > 63 ) // only numbers 8 - 63 are valid numbers
290 TabBgColorIndex = 127; //Excel specs: 127 makes excel ignore tab color information.
291 rStrm << rt << grbitFrt << unused << unused << cb << TabBgColorIndex << reserved;
294 // Sheet view settings ========================================================
296 namespace {
298 /** Converts a Calc zoom factor into an Excel zoom factor. Returns 0 for a default zoom value. */
299 sal_uInt16 lclGetXclZoom( long nScZoom, sal_uInt16 nDefXclZoom )
301 sal_uInt16 nXclZoom = limit_cast< sal_uInt16 >( nScZoom, EXC_ZOOM_MIN, EXC_ZOOM_MAX );
302 return (nXclZoom == nDefXclZoom) ? 0 : nXclZoom;
305 } // namespace
307 // ----------------------------------------------------------------------------
309 XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nScTab ) :
310 XclExpRoot( rRoot ),
311 mnGridColorId( XclExpPalette::GetColorIdFromIndex( EXC_COLOR_WINDOWTEXT ) )
313 // *** sheet flags ***
315 const XclExpTabInfo& rTabInfo = GetTabInfo();
316 maData.mbSelected = rTabInfo.IsSelectedTab( nScTab );
317 maData.mbDisplayed = rTabInfo.IsDisplayedTab( nScTab );
318 maData.mbMirrored = rTabInfo.IsMirroredTab( nScTab );
320 const ScViewOptions& rViewOpt = GetDoc().GetViewOptions();
321 maData.mbShowFormulas = rViewOpt.GetOption( VOPT_FORMULAS );
322 maData.mbShowHeadings = rViewOpt.GetOption( VOPT_HEADER );
323 maData.mbShowZeros = rViewOpt.GetOption( VOPT_NULLVALS );
324 maData.mbShowOutline = rViewOpt.GetOption( VOPT_OUTLINER );
326 // *** sheet options: cursor, selection, splits, grid color, zoom ***
328 if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nScTab ) )
330 const ScExtTabSettings& rTabSett = *pTabSett;
331 XclExpAddressConverter& rAddrConv = GetAddressConverter();
333 // first visible cell in top-left pane
334 if( (rTabSett.maFirstVis.Col() >= 0) && (rTabSett.maFirstVis.Row() >= 0) )
335 maData.maFirstXclPos = rAddrConv.CreateValidAddress( rTabSett.maFirstVis, false );
337 // first visible cell in additional pane(s)
338 if( (rTabSett.maSecondVis.Col() >= 0) && (rTabSett.maSecondVis.Row() >= 0) )
339 maData.maSecondXclPos = rAddrConv.CreateValidAddress( rTabSett.maSecondVis, false );
341 // active pane
342 switch( rTabSett.meActivePane )
344 case SCEXT_PANE_TOPLEFT: maData.mnActivePane = EXC_PANE_TOPLEFT; break;
345 case SCEXT_PANE_TOPRIGHT: maData.mnActivePane = EXC_PANE_TOPRIGHT; break;
346 case SCEXT_PANE_BOTTOMLEFT: maData.mnActivePane = EXC_PANE_BOTTOMLEFT; break;
347 case SCEXT_PANE_BOTTOMRIGHT: maData.mnActivePane = EXC_PANE_BOTTOMRIGHT; break;
350 // freeze/split position
351 maData.mbFrozenPanes = rTabSett.mbFrozenPanes;
352 if( maData.mbFrozenPanes )
354 /* Frozen panes: handle split position as row/column positions.
355 #i35812# Excel uses number of visible rows/columns, Calc uses position of freeze. */
356 SCCOL nFreezeScCol = rTabSett.maFreezePos.Col();
357 if( (0 < nFreezeScCol) && (nFreezeScCol <= GetXclMaxPos().Col()) )
358 maData.mnSplitX = static_cast< sal_uInt16 >( nFreezeScCol ) - maData.maFirstXclPos.mnCol;
359 SCROW nFreezeScRow = rTabSett.maFreezePos.Row();
360 if( (0 < nFreezeScRow) && (nFreezeScRow <= GetXclMaxPos().Row()) )
361 maData.mnSplitY = static_cast< sal_uInt16 >( nFreezeScRow ) - maData.maFirstXclPos.mnRow;
362 // if both splits are left out (address overflow), remove the frozen flag
363 maData.mbFrozenPanes = maData.IsSplit();
365 // #i20671# frozen panes: mostright/mostbottom pane is active regardless of cursor position
366 if( maData.HasPane( EXC_PANE_BOTTOMRIGHT ) )
367 maData.mnActivePane = EXC_PANE_BOTTOMRIGHT;
368 else if( maData.HasPane( EXC_PANE_TOPRIGHT ) )
369 maData.mnActivePane = EXC_PANE_TOPRIGHT;
370 else if( maData.HasPane( EXC_PANE_BOTTOMLEFT ) )
371 maData.mnActivePane = EXC_PANE_BOTTOMLEFT;
373 else
375 // split window: position is in twips
376 maData.mnSplitX = ulimit_cast< sal_uInt16 >( rTabSett.maSplitPos.X() );
377 maData.mnSplitY = ulimit_cast< sal_uInt16 >( rTabSett.maSplitPos.Y() );
380 // selection
381 CreateSelectionData( EXC_PANE_TOPLEFT, rTabSett.maCursor, rTabSett.maSelection );
382 CreateSelectionData( EXC_PANE_TOPRIGHT, rTabSett.maCursor, rTabSett.maSelection );
383 CreateSelectionData( EXC_PANE_BOTTOMLEFT, rTabSett.maCursor, rTabSett.maSelection );
384 CreateSelectionData( EXC_PANE_BOTTOMRIGHT, rTabSett.maCursor, rTabSett.maSelection );
386 // grid color
387 const Color& rGridColor = rTabSett.maGridColor;
388 maData.mbDefGridColor = rGridColor.GetColor() == COL_AUTO;
389 if( !maData.mbDefGridColor )
391 if( GetBiff() == EXC_BIFF8 )
392 mnGridColorId = GetPalette().InsertColor( rGridColor, EXC_COLOR_GRID );
393 else
394 maData.maGridColor = rGridColor;
396 maData.mbShowGrid = rTabSett.mbShowGrid;
398 // view mode and zoom
399 maData.mbPageMode = (GetBiff() == EXC_BIFF8) && rTabSett.mbPageMode;
400 maData.mnNormalZoom = lclGetXclZoom( rTabSett.mnNormalZoom, EXC_WIN2_NORMALZOOM_DEF );
401 maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF );
402 maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom;
404 // Tab Bg Color
405 if ( GetBiff() == EXC_BIFF8 && !rTabSett.IsDefaultTabBgColor() )
407 XclExpPalette& rPal = GetPalette();
408 maData.maTabBgColor = rTabSett.maTabBgColor;
409 maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG );
414 void XclExpTabViewSettings::Save( XclExpStream& rStrm )
416 WriteWindow2( rStrm );
417 WriteScl( rStrm );
418 WritePane( rStrm );
419 WriteSelection( rStrm, EXC_PANE_TOPLEFT );
420 WriteSelection( rStrm, EXC_PANE_TOPRIGHT );
421 WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT );
422 WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT );
423 WriteTabBgColor( rStrm );
426 static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane )
428 if( rData.HasPane( nPane ) )
429 XclExpSelection( rData, nPane ).SaveXml( rStrm );
432 OString lcl_GetZoom( sal_uInt16 nZoom )
434 if( nZoom )
435 return OString::valueOf( (sal_Int32)nZoom );
436 return OString( "100" );
439 void XclExpTabViewSettings::SaveXml( XclExpXmlStream& rStrm )
441 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
442 rWorksheet->startElement( XML_sheetViews, FSEND );
443 rWorksheet->startElement( XML_sheetView,
444 XML_windowProtection, XclXmlUtils::ToPsz( maData.mbFrozenPanes ),
445 XML_showFormulas, XclXmlUtils::ToPsz( maData.mbShowFormulas ),
446 XML_showGridLines, XclXmlUtils::ToPsz( maData.mbShowGrid ),
447 XML_showRowColHeaders, XclXmlUtils::ToPsz( maData.mbShowHeadings ),
448 XML_showZeros, XclXmlUtils::ToPsz( maData.mbShowZeros ),
449 XML_rightToLeft, XclXmlUtils::ToPsz( maData.mbMirrored ),
450 XML_tabSelected, XclXmlUtils::ToPsz( maData.mbSelected ),
451 // OOXTODO: XML_showRuler,
452 XML_showOutlineSymbols, XclXmlUtils::ToPsz( maData.mbShowOutline ),
453 XML_defaultGridColor, mnGridColorId == XclExpPalette::GetColorIdFromIndex( EXC_COLOR_WINDOWTEXT ) ? "true" : "false",
454 // OOXTODO: XML_showWhiteSpace,
455 XML_view, maData.mbPageMode ? "pageBreakPreview" : "normal", // OOXTODO: pageLayout
456 XML_topLeftCell, XclXmlUtils::ToOString( maData.maFirstXclPos ).getStr(),
457 XML_colorId, OString::valueOf( (sal_Int32) rStrm.GetRoot().GetPalette().GetColorIndex( mnGridColorId ) ).getStr(),
458 XML_zoomScale, lcl_GetZoom( maData.mnCurrentZoom ).getStr(),
459 XML_zoomScaleNormal, lcl_GetZoom( maData.mnNormalZoom ).getStr(),
460 // OOXTODO: XML_zoomScaleSheetLayoutView,
461 XML_zoomScalePageLayoutView, lcl_GetZoom( maData.mnPageZoom ).getStr(),
462 XML_workbookViewId, "0", // OOXTODO? 0-based index of document(xl/workbook.xml)/workbook/bookviews/workbookView
463 // should always be 0, as we only generate 1 such element.
464 FSEND );
465 if( maData.IsSplit() )
467 XclExpPane aPane( maData );
468 aPane.SaveXml( rStrm );
470 lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPLEFT );
471 lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPRIGHT );
472 lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMLEFT );
473 lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMRIGHT );
474 rWorksheet->endElement( XML_sheetView );
475 // OOXTODO: XML_extLst
476 rWorksheet->endElement( XML_sheetViews );
479 // private --------------------------------------------------------------------
481 void XclExpTabViewSettings::CreateSelectionData( sal_uInt8 nPane,
482 const ScAddress& rCursor, const ScRangeList& rSelection )
484 if( maData.HasPane( nPane ) )
486 XclSelectionData& rSelData = maData.CreateSelectionData( nPane );
488 // first step: use top-left visible cell as cursor
489 rSelData.maXclCursor.mnCol = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_BOTTOMLEFT)) ?
490 maData.maFirstXclPos.mnCol : maData.maSecondXclPos.mnCol;
491 rSelData.maXclCursor.mnRow = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_TOPRIGHT)) ?
492 maData.maFirstXclPos.mnRow : maData.maSecondXclPos.mnRow;
494 // second step, active pane: create actual selection data with current cursor position
495 if( nPane == maData.mnActivePane )
497 XclExpAddressConverter& rAddrConv = GetAddressConverter();
498 // cursor position (keep top-left pane position from above, if rCursor is invalid)
499 if( (rCursor.Col() >= 0) && (rCursor.Row() >= 0) )
500 rSelData.maXclCursor = rAddrConv.CreateValidAddress( rCursor, false );
501 // selection
502 rAddrConv.ConvertRangeList( rSelData.maXclSelection, rSelection, false );
507 void XclExpTabViewSettings::WriteWindow2( XclExpStream& rStrm ) const
509 // #i43553# GCC 3.3 parse error
510 // XclExpWindow2( GetRoot(), maData, mnGridColorId ).Save( rStrm );
511 XclExpWindow2 aWindow2( GetRoot(), maData, mnGridColorId );
512 aWindow2.Save( rStrm );
515 void XclExpTabViewSettings::WriteScl( XclExpStream& rStrm ) const
517 if( maData.mnCurrentZoom != 0 )
518 XclExpScl( maData.mnCurrentZoom ).Save( rStrm );
521 void XclExpTabViewSettings::WritePane( XclExpStream& rStrm ) const
523 if( maData.IsSplit() )
524 // #i43553# GCC 3.3 parse error
525 // XclExpPane( GetRoot(), maData ).Save( rStrm );
527 XclExpPane aPane( maData );
528 aPane.Save( rStrm );
532 void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane ) const
534 if( maData.HasPane( nPane ) )
535 XclExpSelection( maData, nPane ).Save( rStrm );
538 void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const
540 if ( !maData.IsDefaultTabBgColor() )
541 XclExpTabBgColor( maData ).Save( rStrm );
543 // ============================================================================