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 : using ::rtl::OString;
30 :
31 : // Workbook view settings records =============================================
32 :
33 1 : XclExpWindow1::XclExpWindow1( const XclExpRoot& rRoot ) :
34 : XclExpRecord( EXC_ID_WINDOW1, 18 ),
35 : mnFlags( 0 ),
36 1 : mnTabBarSize( 600 )
37 : {
38 1 : const ScViewOptions& rViewOpt = rRoot.GetDoc().GetViewOptions();
39 1 : ::set_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR, rViewOpt.GetOption( VOPT_HSCROLL ) );
40 1 : ::set_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR, rViewOpt.GetOption( VOPT_VSCROLL ) );
41 1 : ::set_flag( mnFlags, EXC_WIN1_TABBAR, rViewOpt.GetOption( VOPT_TABCONTROLS ) );
42 :
43 1 : double fTabBarWidth = rRoot.GetExtDocOptions().GetDocSettings().mfTabBarWidth;
44 1 : if( (0.0 <= fTabBarWidth) && (fTabBarWidth <= 1.0) )
45 0 : mnTabBarSize = static_cast< sal_uInt16 >( fTabBarWidth * 1000.0 + 0.5 );
46 1 : }
47 :
48 1 : void XclExpWindow1::SaveXml( XclExpXmlStream& rStrm )
49 : {
50 1 : const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
51 :
52 1 : rStrm.GetCurrentStream()->singleElement( XML_workbookView,
53 : // OOXTODO: XML_visibility, // ST_visibilty
54 : // OOXTODO: XML_minimized, // bool
55 1 : XML_showHorizontalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_HOR_SCROLLBAR ) ),
56 1 : XML_showVerticalScroll, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_VER_SCROLLBAR ) ),
57 1 : XML_showSheetTabs, XclXmlUtils::ToPsz( ::get_flag( mnFlags, EXC_WIN1_TABBAR ) ),
58 : XML_xWindow, "0",
59 : XML_yWindow, "0",
60 : XML_windowWidth, OString::valueOf( (sal_Int32)0x4000 ).getStr(),
61 : XML_windowHeight, OString::valueOf( (sal_Int32)0x2000 ).getStr(),
62 : XML_tabRatio, OString::valueOf( (sal_Int32)mnTabBarSize ).getStr(),
63 1 : XML_firstSheet, OString::valueOf( (sal_Int32)rTabInfo.GetFirstVisXclTab() ).getStr(),
64 1 : XML_activeTab, OString::valueOf( (sal_Int32)rTabInfo.GetDisplayedXclTab() ).getStr(),
65 : // OOXTODO: XML_autoFilterDateGrouping, // bool; AUTOFILTER12? 87Eh
66 6 : FSEND );
67 1 : }
68 :
69 0 : void XclExpWindow1::WriteBody( XclExpStream& rStrm )
70 : {
71 0 : const XclExpTabInfo& rTabInfo = rStrm.GetRoot().GetTabInfo();
72 :
73 0 : rStrm << sal_uInt16( 0 ) // X position of the window
74 0 : << sal_uInt16( 0 ) // Y position of the window
75 0 : << sal_uInt16( 0x4000 ) // width of the window
76 0 : << sal_uInt16( 0x2000 ) // height of the window
77 0 : << mnFlags
78 0 : << rTabInfo.GetDisplayedXclTab()
79 0 : << rTabInfo.GetFirstVisXclTab()
80 0 : << rTabInfo.GetXclSelectedCount()
81 0 : << mnTabBarSize;
82 0 : }
83 :
84 : // Sheet view settings records ================================================
85 :
86 0 : XclExpWindow2::XclExpWindow2( const XclExpRoot& rRoot,
87 : const XclTabViewData& rData, sal_uInt32 nGridColorId ) :
88 0 : XclExpRecord( EXC_ID_WINDOW2, (rRoot.GetBiff() == EXC_BIFF8) ? 18 : 10 ),
89 : maGridColor( rData.maGridColor ),
90 : mnGridColorId( nGridColorId ),
91 : mnFlags( 0 ),
92 : maFirstXclPos( rData.maFirstXclPos ),
93 : mnNormalZoom( rData.mnNormalZoom ),
94 0 : mnPageZoom( rData.mnPageZoom )
95 : {
96 0 : ::set_flag( mnFlags, EXC_WIN2_SHOWFORMULAS, rData.mbShowFormulas );
97 0 : ::set_flag( mnFlags, EXC_WIN2_SHOWGRID, rData.mbShowGrid );
98 0 : ::set_flag( mnFlags, EXC_WIN2_SHOWHEADINGS, rData.mbShowHeadings );
99 0 : ::set_flag( mnFlags, EXC_WIN2_FROZEN, rData.mbFrozenPanes );
100 0 : ::set_flag( mnFlags, EXC_WIN2_SHOWZEROS, rData.mbShowZeros );
101 0 : ::set_flag( mnFlags, EXC_WIN2_DEFGRIDCOLOR, rData.mbDefGridColor );
102 0 : ::set_flag( mnFlags, EXC_WIN2_MIRRORED, rData.mbMirrored );
103 0 : ::set_flag( mnFlags, EXC_WIN2_SHOWOUTLINE, rData.mbShowOutline );
104 0 : ::set_flag( mnFlags, EXC_WIN2_FROZENNOSPLIT, rData.mbFrozenPanes );
105 0 : ::set_flag( mnFlags, EXC_WIN2_SELECTED, rData.mbSelected );
106 0 : ::set_flag( mnFlags, EXC_WIN2_DISPLAYED, rData.mbDisplayed );
107 0 : ::set_flag( mnFlags, EXC_WIN2_PAGEBREAKMODE, rData.mbPageMode );
108 0 : }
109 :
110 0 : void XclExpWindow2::WriteBody( XclExpStream& rStrm )
111 : {
112 0 : const XclExpRoot& rRoot = rStrm.GetRoot();
113 :
114 0 : rStrm << mnFlags
115 0 : << maFirstXclPos;
116 :
117 0 : switch( rRoot.GetBiff() )
118 : {
119 : case EXC_BIFF3:
120 : case EXC_BIFF4:
121 : case EXC_BIFF5:
122 0 : rStrm << maGridColor;
123 0 : break;
124 : case EXC_BIFF8:
125 0 : rStrm << rRoot.GetPalette().GetColorIndex( mnGridColorId )
126 0 : << sal_uInt16( 0 )
127 0 : << mnPageZoom
128 0 : << mnNormalZoom
129 0 : << sal_uInt32( 0 );
130 0 : break;
131 : default: DBG_ERROR_BIFF();
132 : }
133 0 : }
134 :
135 : // ----------------------------------------------------------------------------
136 :
137 0 : XclExpScl::XclExpScl( sal_uInt16 nZoom ) :
138 : XclExpRecord( EXC_ID_SCL, 4 ),
139 : mnNum( nZoom ),
140 0 : mnDenom( 100 )
141 : {
142 0 : Shorten( 2 );
143 0 : Shorten( 5 );
144 0 : }
145 :
146 0 : void XclExpScl::Shorten( sal_uInt16 nFactor )
147 : {
148 0 : while( (mnNum % nFactor == 0) && (mnDenom % nFactor == 0) )
149 : {
150 0 : mnNum = mnNum / nFactor;
151 0 : mnDenom = mnDenom / nFactor;
152 : }
153 0 : }
154 :
155 0 : void XclExpScl::WriteBody( XclExpStream& rStrm )
156 : {
157 : OSL_ENSURE_BIFF( rStrm.GetRoot().GetBiff() >= EXC_BIFF4 );
158 0 : rStrm << mnNum << mnDenom;
159 0 : }
160 :
161 : // ----------------------------------------------------------------------------
162 :
163 0 : XclExpPane::XclExpPane( const XclTabViewData& rData ) :
164 : XclExpRecord( EXC_ID_PANE, 10 ),
165 : mnSplitX( rData.mnSplitX ),
166 : mnSplitY( rData.mnSplitY ),
167 : maSecondXclPos( rData.maSecondXclPos ),
168 0 : mnActivePane( rData.mnActivePane )
169 : {
170 : OSL_ENSURE( rData.IsSplit(), "XclExpPane::XclExpPane - no PANE record for unsplit view" );
171 0 : }
172 :
173 1 : static const char* lcl_GetActivePane( sal_uInt8 nActivePane )
174 : {
175 1 : switch( nActivePane )
176 : {
177 1 : 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 : // OOXTODO: XML_state,
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 1 : XclExpSelection::XclExpSelection( const XclTabViewData& rData, sal_uInt8 nPane ) :
209 : XclExpRecord( EXC_ID_SELECTION, 15 ),
210 1 : mnPane( nPane )
211 : {
212 1 : if( const XclSelectionData* pSelData = rData.GetSelectionData( nPane ) )
213 0 : maSelData = *pSelData;
214 :
215 : // find the cursor position in the selection list (or add it)
216 1 : XclRangeList& rXclSel = maSelData.maXclSelection;
217 1 : bool bFound = false;
218 1 : 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 1 : if( !bFound )
225 : {
226 1 : maSelData.mnCursorIdx = static_cast< sal_uInt16 >( rXclSel.size() );
227 1 : rXclSel.push_back( XclRange( maSelData.maXclCursor ) );
228 : }
229 1 : }
230 :
231 1 : void XclExpSelection::SaveXml( XclExpXmlStream& rStrm )
232 : {
233 1 : 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 2 : FSEND );
239 1 : }
240 :
241 0 : void XclExpSelection::WriteBody( XclExpStream& rStrm )
242 : {
243 0 : rStrm << mnPane // pane for this selection
244 0 : << maSelData.maXclCursor // cell cursor
245 0 : << maSelData.mnCursorIdx; // index to range containing cursor
246 0 : maSelData.maXclSelection.Write( rStrm, false );
247 0 : }
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 0 : sal_uInt16 lclGetXclZoom( long nScZoom, sal_uInt16 nDefXclZoom )
284 : {
285 0 : sal_uInt16 nXclZoom = limit_cast< sal_uInt16 >( nScZoom, EXC_ZOOM_MIN, EXC_ZOOM_MAX );
286 0 : return (nXclZoom == nDefXclZoom) ? 0 : nXclZoom;
287 : }
288 :
289 : } // namespace
290 :
291 : // ----------------------------------------------------------------------------
292 :
293 1 : XclExpTabViewSettings::XclExpTabViewSettings( const XclExpRoot& rRoot, SCTAB nScTab ) :
294 : XclExpRoot( rRoot ),
295 1 : mnGridColorId( XclExpPalette::GetColorIdFromIndex( EXC_COLOR_WINDOWTEXT ) )
296 : {
297 : // *** sheet flags ***
298 :
299 1 : const XclExpTabInfo& rTabInfo = GetTabInfo();
300 1 : maData.mbSelected = rTabInfo.IsSelectedTab( nScTab );
301 1 : maData.mbDisplayed = rTabInfo.IsDisplayedTab( nScTab );
302 1 : maData.mbMirrored = rTabInfo.IsMirroredTab( nScTab );
303 :
304 1 : const ScViewOptions& rViewOpt = GetDoc().GetViewOptions();
305 1 : maData.mbShowFormulas = rViewOpt.GetOption( VOPT_FORMULAS );
306 1 : maData.mbShowHeadings = rViewOpt.GetOption( VOPT_HEADER );
307 1 : maData.mbShowZeros = rViewOpt.GetOption( VOPT_NULLVALS );
308 1 : maData.mbShowOutline = rViewOpt.GetOption( VOPT_OUTLINER );
309 :
310 : // *** sheet options: cursor, selection, splits, grid color, zoom ***
311 :
312 1 : if( const ScExtTabSettings* pTabSett = GetExtDocOptions().GetTabSettings( nScTab ) )
313 : {
314 0 : const ScExtTabSettings& rTabSett = *pTabSett;
315 0 : XclExpAddressConverter& rAddrConv = GetAddressConverter();
316 :
317 : // first visible cell in top-left pane
318 0 : if( (rTabSett.maFirstVis.Col() >= 0) && (rTabSett.maFirstVis.Row() >= 0) )
319 0 : maData.maFirstXclPos = rAddrConv.CreateValidAddress( rTabSett.maFirstVis, false );
320 :
321 : // first visible cell in additional pane(s)
322 0 : if( (rTabSett.maSecondVis.Col() >= 0) && (rTabSett.maSecondVis.Row() >= 0) )
323 0 : maData.maSecondXclPos = rAddrConv.CreateValidAddress( rTabSett.maSecondVis, false );
324 :
325 : // active pane
326 0 : switch( rTabSett.meActivePane )
327 : {
328 0 : 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 0 : maData.mbFrozenPanes = rTabSett.mbFrozenPanes;
336 0 : 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 0 : maData.mnSplitX = static_cast<sal_uInt16>(rTabSett.maSplitPos.X());
361 0 : maData.mnSplitY = static_cast<sal_uInt32>(rTabSett.maSplitPos.Y());
362 : }
363 :
364 : // selection
365 0 : CreateSelectionData( EXC_PANE_TOPLEFT, rTabSett.maCursor, rTabSett.maSelection );
366 0 : CreateSelectionData( EXC_PANE_TOPRIGHT, rTabSett.maCursor, rTabSett.maSelection );
367 0 : CreateSelectionData( EXC_PANE_BOTTOMLEFT, rTabSett.maCursor, rTabSett.maSelection );
368 0 : CreateSelectionData( EXC_PANE_BOTTOMRIGHT, rTabSett.maCursor, rTabSett.maSelection );
369 :
370 : // grid color
371 0 : const Color& rGridColor = rTabSett.maGridColor;
372 0 : maData.mbDefGridColor = rGridColor.GetColor() == COL_AUTO;
373 0 : 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 0 : maData.mbShowGrid = rTabSett.mbShowGrid;
381 :
382 : // view mode and zoom
383 0 : maData.mbPageMode = (GetBiff() == EXC_BIFF8) && rTabSett.mbPageMode;
384 0 : maData.mnNormalZoom = lclGetXclZoom( rTabSett.mnNormalZoom, EXC_WIN2_NORMALZOOM_DEF );
385 0 : maData.mnPageZoom = lclGetXclZoom( rTabSett.mnPageZoom, EXC_WIN2_PAGEZOOM_DEF );
386 0 : maData.mnCurrentZoom = maData.mbPageMode ? maData.mnPageZoom : maData.mnNormalZoom;
387 : }
388 :
389 : // Tab Bg Color
390 1 : 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 1 : }
397 :
398 0 : void XclExpTabViewSettings::Save( XclExpStream& rStrm )
399 : {
400 0 : WriteWindow2( rStrm );
401 0 : WriteScl( rStrm );
402 0 : WritePane( rStrm );
403 0 : WriteSelection( rStrm, EXC_PANE_TOPLEFT );
404 0 : WriteSelection( rStrm, EXC_PANE_TOPRIGHT );
405 0 : WriteSelection( rStrm, EXC_PANE_BOTTOMLEFT );
406 0 : WriteSelection( rStrm, EXC_PANE_BOTTOMRIGHT );
407 0 : WriteTabBgColor( rStrm );
408 0 : }
409 :
410 4 : static void lcl_WriteSelection( XclExpXmlStream& rStrm, const XclTabViewData& rData, sal_uInt8 nPane )
411 : {
412 4 : if( rData.HasPane( nPane ) )
413 1 : XclExpSelection( rData, nPane ).SaveXml( rStrm );
414 4 : }
415 :
416 3 : static OString lcl_GetZoom( sal_uInt16 nZoom )
417 : {
418 3 : if( nZoom )
419 2 : return OString::valueOf( (sal_Int32)nZoom );
420 1 : return OString( "100" );
421 : }
422 :
423 1 : void XclExpTabViewSettings::SaveXml( XclExpXmlStream& rStrm )
424 : {
425 1 : sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
426 1 : 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 1 : 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 1 : 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 3 : FSEND );
449 1 : if( maData.IsSplit() )
450 : {
451 0 : XclExpPane aPane( maData );
452 0 : aPane.SaveXml( rStrm );
453 : }
454 1 : lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPLEFT );
455 1 : lcl_WriteSelection( rStrm, maData, EXC_PANE_TOPRIGHT );
456 1 : lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMLEFT );
457 1 : lcl_WriteSelection( rStrm, maData, EXC_PANE_BOTTOMRIGHT );
458 1 : rWorksheet->endElement( XML_sheetView );
459 : // OOXTODO: XML_extLst
460 1 : rWorksheet->endElement( XML_sheetViews );
461 1 : }
462 :
463 : // private --------------------------------------------------------------------
464 :
465 0 : void XclExpTabViewSettings::CreateSelectionData( sal_uInt8 nPane,
466 : const ScAddress& rCursor, const ScRangeList& rSelection )
467 : {
468 0 : if( maData.HasPane( nPane ) )
469 : {
470 0 : XclSelectionData& rSelData = maData.CreateSelectionData( nPane );
471 :
472 : // first step: use top-left visible cell as cursor
473 : rSelData.maXclCursor.mnCol = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_BOTTOMLEFT)) ?
474 0 : maData.maFirstXclPos.mnCol : maData.maSecondXclPos.mnCol;
475 : rSelData.maXclCursor.mnRow = ((nPane == EXC_PANE_TOPLEFT) || (nPane == EXC_PANE_TOPRIGHT)) ?
476 0 : maData.maFirstXclPos.mnRow : maData.maSecondXclPos.mnRow;
477 :
478 : // second step, active pane: create actual selection data with current cursor position
479 0 : if( nPane == maData.mnActivePane )
480 : {
481 0 : XclExpAddressConverter& rAddrConv = GetAddressConverter();
482 : // cursor position (keep top-left pane position from above, if rCursor is invalid)
483 0 : if( (rCursor.Col() >= 0) && (rCursor.Row() >= 0) )
484 0 : rSelData.maXclCursor = rAddrConv.CreateValidAddress( rCursor, false );
485 : // selection
486 0 : rAddrConv.ConvertRangeList( rSelData.maXclSelection, rSelection, false );
487 : }
488 : }
489 0 : }
490 :
491 0 : void XclExpTabViewSettings::WriteWindow2( XclExpStream& rStrm ) const
492 : {
493 : // #i43553# GCC 3.3 parse error
494 : // XclExpWindow2( GetRoot(), maData, mnGridColorId ).Save( rStrm );
495 0 : XclExpWindow2 aWindow2( GetRoot(), maData, mnGridColorId );
496 0 : aWindow2.Save( rStrm );
497 0 : }
498 :
499 0 : void XclExpTabViewSettings::WriteScl( XclExpStream& rStrm ) const
500 : {
501 0 : if( maData.mnCurrentZoom != 0 )
502 0 : XclExpScl( maData.mnCurrentZoom ).Save( rStrm );
503 0 : }
504 :
505 0 : void XclExpTabViewSettings::WritePane( XclExpStream& rStrm ) const
506 : {
507 0 : 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 0 : }
515 :
516 0 : void XclExpTabViewSettings::WriteSelection( XclExpStream& rStrm, sal_uInt8 nPane ) const
517 : {
518 0 : if( maData.HasPane( nPane ) )
519 0 : XclExpSelection( maData, nPane ).Save( rStrm );
520 0 : }
521 :
522 0 : void XclExpTabViewSettings::WriteTabBgColor( XclExpStream& rStrm ) const
523 : {
524 0 : if ( !maData.IsDefaultTabBgColor() )
525 0 : XclExpTabBgColor( maData ).Save( rStrm );
526 9 : }
527 : // ============================================================================
528 :
529 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|