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