LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xeview.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 267 0.0 %
Date: 2014-04-14 Functions: 0 31 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10