1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_scfilt.hxx"
26 #include "xeview.hxx"
27 #include "document.hxx"
28 #include "scextopt.hxx"
29 #include "viewopti.hxx"
30 #include "xelink.hxx"
31 #include "xestyle.hxx"
32
33 using namespace ::oox;
34
35 using ::rtl::OString;
36
37 // Workbook view settings records =============================================
38
XclExpWindow1(const XclExpRoot & rRoot)39 XclExpWindow1::XclExpWindow1( const XclExpRoot& rRoot ) :
40 XclExpRecord( EXC_ID_WINDOW1, 18 ),
41 mnFlags( 0 ),
42 mnTabBarSize( 600 )
43 {
44 const ScViewOptions& rViewOpt = rRoot.GetDoc().GetViewOptions();
45 ::set_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR, rViewOpt.GetOption( VOPT_HSCROLL ) );
46 ::set_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR, rViewOpt.GetOption( VOPT_VSCROLL ) );
47 ::set_flag( mnFlags, EXC_WIN1_TABBAR, rViewOpt.GetOption( VOPT_TABCONTROLS ) );
48
49 double fTabBarWidth = rRoot.GetExtDocOptions().GetDocSettings().mfTabBarWidth;
50 if( (0.0 <= fTabBarWidth) && (fTabBarWidth <= 1.0) )
51 mnTabBarSize = static_cast< sal_uInt16 >( fTabBarWidth * 1000.0 + 0.5 );
52 }
53
SaveXml(XclExpXmlStream & rStrm)54 void XclExpWindow1::SaveXml( XclExpXmlStream& rStrm )
55 {
56 const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
57
58 rStrm.GetCurrentStream()->singleElement( XML_workbookView,
59 // OOXTODO: XML_visibility, // ST_visibilty
60 // OOXTODO: XML_minimized, // bool
61 XML_showHorizontalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR ) ),
62 XML_showVerticalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR ) ),
63 XML_showSheetTabs, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_TABBAR ) ),
64 XML_xWindow, "0",
65 XML_yWindow, "0",
66 XML_windowWidth, OString::valueOf( (sal_Int32)0x4000 ).getStr(),
67 XML_windowHeight, OString::valueOf( (sal_Int32)0x2000 ).getStr(),
68 XML_tabRatio, OString::valueOf( (sal_Int32)mnTabBarSize ).getStr(),
69 XML_firstSheet, OString::valueOf( (sal_Int32)rTabInfo.GetFirstVisXclTab() ).getStr(),
70 XML_activeTab, OString::valueOf( (sal_Int32)rTabInfo.GetDisplayedXclTab() ).getStr(),
71 // OOXTODO: XML_autoFilterDateGrouping, // bool; AUTOFILTER12? 87Eh
72 FSEND );
73 }
74
WriteBody(XclExpStream & rStrm)75 void XclExpWindow1::WriteBody( XclExpStream& rStrm )
76 {
77 const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
78
79 rStrm << sal_uInt16( 0 ) // X position of the window
80 << sal_uInt16( 0 ) // Y position of the window
81 << sal_uInt16( 0x4000 ) // width of the window
82 << sal_uInt16( 0x2000 ) // height of the window
83 << mnFlags
84 << rTabInfo.GetDisplayedXclTab()
85 << rTabInfo.GetFirstVisXclTab()
86 << rTabInfo.GetXclSelectedCount()
87 << mnTabBarSize;
88 }
89
90 // Sheet view settings records ================================================
91
XclExpWindow2(const XclExpRoot & rRoot,const XclTabViewData & rData,sal_uInt32 nGridColorId)92 XclExpWindow2::XclExpWindow2( const XclExpRoot& rRoot,
93 const XclTabViewData& rData, sal_uInt32 nGridColorId ) :
94 XclExpRecord( EXC_ID_WINDOW2, (rRoot.GetBiff() == EXC_BIFF8) ? 18 : 10 ),
95 maGridColor( rData.maGridColor ),
96 mnGridColorId( nGridColorId ),
97 mnFlags( 0 ),
98 maFirstXclPos( rData.maFirstXclPos ),
99 mnNormalZoom( rData.mnNormalZoom ),
100 mnPageZoom( rData.mnPageZoom )
101 {
102 ::set_flag( mnFlags, EXC_WIN2_SHOWFORMULAS, rData.mbShowFormulas );
103 ::set_flag( mnFlags, EXC_WIN2_SHOWGRID, rData.mbShowGrid );
104 ::set_flag( mnFlags, EXC_WIN2_SHOWHEADINGS, rData.mbShowHeadings );
105 ::set_flag( mnFlags, EXC_WIN2_FROZEN, rData.mbFrozenPanes );
106 ::set_flag( mnFlags, EXC_WIN2_SHOWZEROS, rData.mbShowZeros );
107 ::set_flag( mnFlags, EXC_WIN2_DEFGRIDCOLOR, rData.mbDefGridColor );
108 ::set_flag( mnFlags, EXC_WIN2_MIRRORED, rData.mbMirrored );
109 ::set_flag( mnFlags, EXC_WIN2_SHOWOUTLINE, rData.mbShowOutline );
110 ::set_flag( mnFlags, EXC_WIN2_FROZENNOSPLIT, rData.mbFrozenPanes );
111 ::set_flag( mnFlags, EXC_WIN2_SELECTED, rData.mbSelected );
112 ::set_flag( mnFlags, EXC_WIN2_DISPLAYED, rData.mbDisplayed );
113 ::set_flag( mnFlags, EXC_WIN2_PAGEBREAKMODE, rData.mbPageMode );
114 }
115
WriteBody(XclExpStream & rStrm)116 void XclExpWindow2::WriteBody( XclExpStream& rStrm )
117 {
118 const XclExpRoot& rRoot = rStrm.GetRoot();
119
120 rStrm << mnFlags
121 << maFirstXclPos;
122
123 switch( rRoot.GetBiff() )
124 {
125 case EXC_BIFF3:
126 case EXC_BIFF4:
127 case EXC_BIFF5:
128 rStrm << maGridColor;
129 break;
130 case EXC_BIFF8:
131 rStrm << rRoot.GetPalette().GetColorIndex( mnGridColorId )
132 << sal_uInt16( 0 )
133 << mnPageZoom
134 << mnNormalZoom
135 << sal_uInt32( 0 );
136 break;
137 default: DBG_ERROR_BIFF();
138 }
139 }
140
141 // ----------------------------------------------------------------------------
142
XclExpScl(sal_uInt16 nZoom)143 XclExpScl::XclExpScl( sal_uInt16 nZoom ) :
144 XclExpRecord( EXC_ID_SCL, 4 ),
145 mnNum( nZoom ),
146 mnDenom( 100 )
147 {
148 Shorten( 2 );
149 Shorten( 5 );
150 }
151
Shorten(sal_uInt16 nFactor)152 void XclExpScl::Shorten( sal_uInt16 nFactor )
153 {
154 while( (mnNum % nFactor == 0) && (mnDenom % nFactor == 0) )
155 {
156 mnNum = mnNum / nFactor;
157 mnDenom = mnDenom / nFactor;
158 }
159 }
160
WriteBody(XclExpStream & rStrm)161 void XclExpScl::WriteBody( XclExpStream& rStrm )
162 {
163 DBG_ASSERT_BIFF( rStrm.GetRoot().GetBiff() >= EXC_BIFF4 );
164 rStrm << mnNum << mnDenom;
165 }
166
167 // ----------------------------------------------------------------------------
168
XclExpPane(const XclTabViewData & rData)169 XclExpPane::XclExpPane( const XclTabViewData& rData ) :
170 XclExpRecord( EXC_ID_PANE, 10 ),
171 mnSplitX( rData.mnSplitX ),
172 mnSplitY( rData.mnSplitY ),
173 maSecondXclPos( rData.maSecondXclPos ),
174 mnActivePane( rData.mnActivePane )
175 {
176 DBG_ASSERT( rData.IsSplit(), "XclExpPane::XclExpPane - no PANE record for unsplit view" );
177 }
178
lcl_GetActivePane(sal_uInt8 nActivePane)179 static const char* lcl_GetActivePane( sal_uInt8 nActivePane )
180 {
181 switch( nActivePane )
182 {
183 case EXC_PANE_TOPLEFT: return "topLeft"; //break;
184 case EXC_PANE_TOPRIGHT: return "topRight"; //break;
185 case EXC_PANE_BOTTOMLEFT: return "bottomLeft"; //break;
186 case EXC_PANE_BOTTOMRIGHT: return "bottomRight"; //break;
187 }
188 return "**error: lcl_GetActivePane";
189 }
190
SaveXml(XclExpXmlStream & rStrm)191 void XclExpPane::SaveXml( XclExpXmlStream& rStrm )
192 {
193 rStrm.GetCurrentStream()->singleElement( XML_pane,
194 XML_xSplit, OString::valueOf( (sal_Int32)mnSplitX ).getStr(),
195 XML_ySplit, OString::valueOf( (sal_Int32)mnSplitY ).getStr(),
196 XML_topLeftCell, XclXmlUtils::ToOString( maSecondXclPos ).getStr(),
197 XML_activePane, lcl_GetActivePane( mnActivePane ),
198 // OOXTODO: XML_state,
199 FSEND );
200 }
201
WriteBody(XclExpStream & rStrm)202 void XclExpPane::WriteBody( XclExpStream& rStrm )
203 {
204 rStrm << mnSplitX
205 << mnSplitY
206 << maSecondXclPos
207 << mnActivePane;
208 if( rStrm.GetRoot().GetBiff() >= EXC_BIFF5 )
209 rStrm << sal_uInt8( 0 );
210 }
211
212 // ----------------------------------------------------------------------------
213
XclExpSelection(const XclTabViewData & rData,sal_uInt8 nPane)214 XclExpSelection::XclExpSelection( const XclTabViewData& rData, sal_uInt8 nPane ) :
215 XclExpRecord( EXC_ID_SELECTION, 15 ),
216 mnPane( nPane )
217 {
218 if( const XclSelectionData* pSelData = rData.GetSelectionData( nPane ) )
219 maSelData = *pSelData;
220
221 // find the cursor position in the selection list (or add it)
222 XclRangeList& rXclSel = maSelData.maXclSelection;
223 bool bFound = false;
224 for( XclRangeList::const_iterator aIt = rXclSel.begin(), aEnd = rXclSel.end(); !bFound && (aIt != aEnd); ++aIt )
225 if( (bFound = aIt->Contains( maSelData.maXclCursor )) == true )
226 maSelData.mnCursorIdx = static_cast< sal_uInt16 >( aIt - rXclSel.begin() );
227 /* Cursor cell not found in list? (e.g. inactive pane, or removed in
228 ConvertRangeList(), because Calc cursor on invalid pos)
229 -> insert the valid Excel cursor. */
230 if( !bFound )
231 {
232 maSelData.mnCursorIdx = static_cast< sal_uInt16 >( rXclSel.size() );
233 rXclSel.push_back( XclRange( maSelData.maXclCursor ) );
234 }
235 }
236
SaveXml(XclExpXmlStream & rStrm)237 void XclExpSelection::SaveXml( XclExpXmlStream& rStrm )
238 {
239 rStrm.GetCurrentStream()->singleElement( XML_selection,
240 XML_pane, lcl_GetActivePane( mnPane ),
241 XML_activeCell, XclXmlUtils::ToOString( maSelData.maXclCursor ).getStr(),
242 XML_activeCellId, OString::valueOf( (sal_Int32) maSelData.mnCursorIdx ).getStr(),
243 XML_sqref, XclXmlUtils::ToOString( maSelData.maXclSelection ).getStr(),
244 FSEND );
245 }
246
WriteBody(XclExpStream & rStrm)247 void XclExpSelection::WriteBody( XclExpStream& rStrm )
248 {
249 rStrm << mnPane // pane for this selection
250 << maSelData.maXclCursor // cell cursor
251 << maSelData.mnCursorIdx; // index to range containing cursor
252 maSelData.maXclSelection.Write( rStrm, false );
253 }
254
255 // ----------------------------------------------------------------------------
256
XclExpTabBgColor(const XclTabViewData & rTabViewData)257 XclExpTabBgColor::XclExpTabBgColor( const XclTabViewData& rTabViewData ) :
258 XclExpRecord( EXC_ID_SHEETEXT, 18 ),
259 mrTabViewData( rTabViewData )
260 {
261 }
262 //TODO Fix savexml...
263 /*void XclExpTabBgColor::SaveXml( XclExpXmlStream& rStrm )
264 {
265 }*/
266
WriteBody(XclExpStream & rStrm)267 void XclExpTabBgColor::WriteBody( XclExpStream& rStrm )
268 {
269 if ( mrTabViewData.IsDefaultTabBgColor() )
270 return;
271 sal_uInt16 rt = 0x0862; //rt
272 sal_uInt16 grbitFrt = 0x0000; //grbit must be set to 0
273 sal_uInt32 unused = 0x00000000; //Use twice...
274 sal_uInt32 cb = 0x00000014; // Record Size, may be larger in future...
275 sal_uInt16 reserved = 0x0000; //trailing bits are 0
276 sal_uInt16 TabBgColorIndex;
277 XclExpPalette& rPal = rStrm.GetRoot().GetPalette();
278 TabBgColorIndex = rPal.GetColorIndex(mrTabViewData.mnTabBgColorId);
279 if (TabBgColorIndex < 8 || TabBgColorIndex > 63 ) // only numbers 8 - 63 are valid numbers
280 TabBgColorIndex = 127; //Excel specs: 127 makes excel ignore tab color information.
281 rStrm << rt << grbitFrt << unused << unused << cb << TabBgColorIndex << reserved;
282 }
283
284 // Sheet view settings ========================================================
285
286 namespace {
287
288 /** Converts a Calc zoom factor into an Excel zoom factor. Returns 0 for a default zoom value. */
lclGetXclZoom(long nScZoom,sal_uInt16 nDefXclZoom)289 sal_uInt16 lclGetXclZoom( long nScZoom, sal_uInt16 nDefXclZoom )
290 {
291 sal_uInt16 nXclZoom = limit_cast< sal_uInt16 >( nScZoom, EXC_ZOOM_MIN, EXC_ZOOM_MAX );
292 return (nXclZoom == nDefXclZoom) ? 0 : nXclZoom;
293 }
294
295 } // namespace
296
297 // ----------------------------------------------------------------------------
298
XclExpTabViewSettings(const XclExpRoot & rRoot,SCTAB nScTab)299 XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nScTab ) :
300 XclExpRoot( rRoot ),
301 mnGridColorId( XclExpPalette::GetColorIdFromIndex( EXC_COLOR_WINDOWTEXT ) )
302 {
303 // *** sheet flags ***
304
305 const XclExpTabInfo& rTabInfo = GetTabInfo();
306 maData.mbSelected = rTabInfo.IsSelectedTab( nScTab );
307 maData.mbDisplayed = rTabInfo.IsDisplayedTab( nScTab );
308 maData.mbMirrored = rTabInfo.IsMirroredTab( nScTab );
309
310 const ScViewOptions& rViewOpt = GetDoc().GetViewOptions();
311 maData.mbShowFormulas = rViewOpt.GetOption( VOPT_FORMULAS );
312 maData.mbShowGrid = rViewOpt.GetOption( VOPT_GRID );
313 maData.mbShowHeadings = rViewOpt.GetOption( VOPT_HEADER );
314 maData.mbShowZeros = rViewOpt.GetOption( VOPT_NULLVALS );
315 maData.mbShowOutline = rViewOpt.GetOption( VOPT_OUTLINER );
316
317 // *** sheet options: cursor, selection, splits, grid color, zoom ***
318
319 if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nScTab ) )
320 {
321 const ScExtTabSettings& rTabSett = *pTabSett;
322 XclExpAddressConverter& rAddrConv = GetAddressConverter();
323
324 // first visible cell in top-left pane
325 if( (rTabSett.maFirstVis.Col() >= 0) && (rTabSett.maFirstVis.Row() >= 0) )
326 maData.maFirstXclPos = rAddrConv.CreateValidAddress( rTabSett.maFirstVis, false );
327
328 // first visible cell in additional pane(s)
329 if( (rTabSett.maSecondVis.Col() >= 0) && (rTabSett.maSecondVis.Row() >= 0) )
330 maData.maSecondXclPos = rAddrConv.CreateValidAddress( rTabSett.maSecondVis, false );
331
332 // active pane
333 switch( rTabSett.meActivePane )
334 {
335 case SCEXT_PANE_TOPLEFT: maData.mnActivePane = EXC_PANE_TOPLEFT; break;
336 case SCEXT_PANE_TOPRIGHT: maData.mnActivePane = EXC_PANE_TOPRIGHT; break;
337 case SCEXT_PANE_BOTTOMLEFT: maData.mnActivePane = EXC_PANE_BOTTOMLEFT; break;
338 case SCEXT_PANE_BOTTOMRIGHT: maData.mnActivePane = EXC_PANE_BOTTOMRIGHT; break;
339 }
340
341 // freeze/split position
342 maData.mbFrozenPanes = rTabSett.mbFrozenPanes;
343 if( maData.mbFrozenPanes )
344 {
345 /* Frozen panes: handle split position as row/column positions.
346 #i35812# Excel uses number of visible rows/columns, Calc uses position of freeze. */
347 SCCOL nFreezeScCol = rTabSett.maFreezePos.Col();
348 if( (0 < nFreezeScCol) && (nFreezeScCol <= GetXclMaxPos().Col()) )
349 maData.mnSplitX = static_cast< sal_uInt16 >( nFreezeScCol ) - maData.maFirstXclPos.mnCol;
350 SCROW nFreezeScRow = rTabSett.maFreezePos.Row();
351 if( (0 < nFreezeScRow) && (nFreezeScRow <= GetXclMaxPos().Row()) )
352 maData.mnSplitY = static_cast< sal_uInt16 >( nFreezeScRow ) - maData.maFirstXclPos.mnRow;
353 // if both splits are left out (address overflow), remove the frozen flag
354 maData.mbFrozenPanes = maData.IsSplit();
355
356 // #i20671# frozen panes: mostright/mostbottom pane is active regardless of cursor position
357 if( maData.HasPane( EXC_PANE_BOTTOMRIGHT ) )
358 maData.mnActivePane = EXC_PANE_BOTTOMRIGHT;
359 else if( maData.HasPane( EXC_PANE_TOPRIGHT ) )
360 maData.mnActivePane = EXC_PANE_TOPRIGHT;
361 else if( maData.HasPane( EXC_PANE_BOTTOMLEFT ) )
362 maData.mnActivePane = EXC_PANE_BOTTOMLEFT;
363 }
364 else
365 {
366 // split window: position is in twips
367 maData.mnSplitX = ulimit_cast< sal_uInt16 >( rTabSett.maSplitPos.X() );
368 maData.mnSplitY = ulimit_cast< sal_uInt16 >( rTabSett.maSplitPos.Y() );
369 }
370
371 // selection
372 CreateSelectionData( EXC_PANE_TOPLEFT, rTabSett.maCursor, rTabSett.maSelection );
373 CreateSelectionData( EXC_PANE_TOPRIGHT, rTabSett.maCursor, rTabSett.maSelection );
374 CreateSelectionData( EXC_PANE_BOTTOMLEFT, rTabSett.maCursor, rTabSett.maSelection );
375 CreateSelectionData( EXC_PANE_BOTTOMRIGHT, rTabSett.maCursor, rTabSett.maSelection );
376
377 // grid color
378 const Color& rGridColor = rTabSett.maGridColor;
379 maData.mbDefGridColor = rGridColor.GetColor() == COL_AUTO;
380 if( !maData.mbDefGridColor )
381 {
382 if( GetBiff() == EXC_BIFF8 )
383 mnGridColorId = GetPalette().InsertColor( rGridColor, EXC_COLOR_GRID );
384 else
385 maData.maGridColor = rGridColor;
386 }
387
388 // view mode and zoom
389 maData.mbPageMode = (GetBiff() == EXC_BIFF8) && rTabSett.mbPageMode;
390 maData.mnNormalZoom = lclGetXclZoom( rTabSett.mnNormalZoom, EXC_WIN2_NORMALZOOM_DEF );
391 maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF );
392 maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom;
393 }
394
395 // Tab Bg Color
396 if ( GetBiff() == EXC_BIFF8 && !GetDoc().IsDefaultTabBgColor(nScTab) )
397 {
398 XclExpPalette& rPal = GetPalette();
399 maData.maTabBgColor = GetDoc().GetTabBgColor(nScTab);
400 maData.mnTabBgColorId = rPal.InsertColor(maData.maTabBgColor, EXC_COLOR_TABBG, EXC_COLOR_NOTABBG );
401 }
402 }
403
Save(XclExpStream & rStrm)404 void XclExpTabViewSettings::Save( XclExpStream& rStrm )
405 {
406 WriteWindow2( rStrm );
407 WriteScl( rStrm );
408 WritePane( rStrm );
409 WriteSelection( rStrm, EXC_PANE_TOPLEFT );
410 WriteSelection( rStrm, EXC_PANE_TOPRIGHT );
411 WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT );
412 WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT );
413 WriteTabBgColor( rStrm );
414 }
415
lcl_WriteSelection(XclExpXmlStream & rStrm,const XclTabViewData & rData,sal_uInt8 nPane)416 static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane )
417 {
418 if( rData.HasPane( nPane ) )
419 XclExpSelection( rData, nPane ).SaveXml( rStrm );
420 }
421
lcl_GetZoom(sal_uInt16 nZoom)422 OString lcl_GetZoom( sal_uInt16 nZoom )
423 {
424 if( nZoom )
425 return OString::valueOf( (sal_Int32)nZoom );
426 return OString( "100" );
427 }
428
SaveXml(XclExpXmlStream & rStrm)429 void XclExpTabViewSettings::SaveXml( XclExpXmlStream& rStrm )
430 {
431 sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
432 rWorksheet->startElement( XML_sheetViews, FSEND );
433 rWorksheet->startElement( XML_sheetView,
434 XML_windowProtection, XclXmlUtils::ToPsz( maData.mbFrozenPanes ),
435 XML_showFormulas, XclXmlUtils::ToPsz( maData.mbShowFormulas ),
436 XML_showGridLines, XclXmlUtils::ToPsz( maData.mbShowGrid ),
437 XML_showRowColHeaders, XclXmlUtils::ToPsz( maData.mbShowHeadings ),
438 XML_showZeros, XclXmlUtils::ToPsz( maData.mbShowZeros ),
439 XML_rightToLeft, XclXmlUtils::ToPsz( maData.mbMirrored ),
440 XML_tabSelected, XclXmlUtils::ToPsz( maData.mbSelected ),
441 // OOXTODO: XML_showRuler,
442 XML_showOutlineSymbols, XclXmlUtils::ToPsz( maData.mbShowOutline ),
443 XML_defaultGridColor, mnGridColorId == XclExpPalette::GetColorIdFromIndex( EXC_COLOR_WINDOWTEXT ) ? "true" : "false",
444 // OOXTODO: XML_showWhiteSpace,
445 XML_view, maData.mbPageMode ? "pageBreakPreview" : "normal", // OOXTODO: pageLayout
446 XML_topLeftCell, XclXmlUtils::ToOString( maData.maFirstXclPos ).getStr(),
447 XML_colorId, OString::valueOf( (sal_Int32) rStrm.GetRoot().GetPalette().GetColorIndex( mnGridColorId ) ).getStr(),
448 XML_zoomScale, lcl_GetZoom( maData.mnCurrentZoom ).getStr(),
449 XML_zoomScaleNormal, lcl_GetZoom( maData.mnNormalZoom ).getStr(),
450 // OOXTODO: XML_zoomScaleSheetLayoutView,
451 XML_zoomScalePageLayoutView, lcl_GetZoom( maData.mnPageZoom ).getStr(),
452 XML_workbookViewId, "0", // OOXTODO? 0-based index of document(xl/workbook.xml)/workbook/bookviews/workbookView
453 // should always be 0, as we only generate 1 such element.
454 FSEND );
455 if( maData.IsSplit() )
456 {
457 XclExpPane aPane( maData );
458 aPane.SaveXml( rStrm );
459 }
460 lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPLEFT );
461 lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPRIGHT );
462 lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMLEFT );
463 lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMRIGHT );
464 rWorksheet->endElement( XML_sheetView );
465 // OOXTODO: XML_extLst
466 rWorksheet->endElement( XML_sheetViews );
467 }
468
469 // private --------------------------------------------------------------------
470
CreateSelectionData(sal_uInt8 nPane,const ScAddress & rCursor,const ScRangeList & rSelection)471 void XclExpTabViewSettings::CreateSelectionData( sal_uInt8 nPane,
472 const ScAddress& rCursor, const ScRangeList& rSelection )
473 {
474 if( maData.HasPane( nPane ) )
475 {
476 XclSelectionData& rSelData = maData.CreateSelectionData( nPane );
477
478 // first step: use top-left visible cell as cursor
479 rSelData.maXclCursor.mnCol = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_BOTTOMLEFT)) ?
480 maData.maFirstXclPos.mnCol : maData.maSecondXclPos.mnCol;
481 rSelData.maXclCursor.mnRow = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_TOPRIGHT)) ?
482 maData.maFirstXclPos.mnRow : maData.maSecondXclPos.mnRow;
483
484 // second step, active pane: create actual selection data with current cursor position
485 if( nPane == maData.mnActivePane )
486 {
487 XclExpAddressConverter& rAddrConv = GetAddressConverter();
488 // cursor position (keep top-left pane position from above, if rCursor is invalid)
489 if( (rCursor.Col() >= 0) && (rCursor.Row() >= 0) )
490 rSelData.maXclCursor = rAddrConv.CreateValidAddress( rCursor, false );
491 // selection
492 rAddrConv.ConvertRangeList( rSelData.maXclSelection, rSelection, false );
493 }
494 }
495 }
496
WriteWindow2(XclExpStream & rStrm) const497 void XclExpTabViewSettings::WriteWindow2( XclExpStream& rStrm ) const
498 {
499 // #i43553# GCC 3.3 parse error
500 // XclExpWindow2( GetRoot(), maData, mnGridColorId ).Save( rStrm );
501 XclExpWindow2 aWindow2( GetRoot(), maData, mnGridColorId );
502 aWindow2.Save( rStrm );
503 }
504
WriteScl(XclExpStream & rStrm) const505 void XclExpTabViewSettings::WriteScl( XclExpStream& rStrm ) const
506 {
507 if( maData.mnCurrentZoom != 0 )
508 XclExpScl( maData.mnCurrentZoom ).Save( rStrm );
509 }
510
WritePane(XclExpStream & rStrm) const511 void XclExpTabViewSettings::WritePane( XclExpStream& rStrm ) const
512 {
513 if( maData.IsSplit() )
514 // #i43553# GCC 3.3 parse error
515 // XclExpPane( GetRoot(), maData ).Save( rStrm );
516 {
517 XclExpPane aPane( maData );
518 aPane.Save( rStrm );
519 }
520 }
521
WriteSelection(XclExpStream & rStrm,sal_uInt8 nPane) const522 void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane ) const
523 {
524 if( maData.HasPane( nPane ) )
525 XclExpSelection( maData, nPane ).Save( rStrm );
526 }
527
WriteTabBgColor(XclExpStream & rStrm) const528 void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const
529 {
530 if ( !maData.IsDefaultTabBgColor() )
531 XclExpTabBgColor( maData ).Save( rStrm );
532 }
533 // ============================================================================
534
535