LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xeview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 265 0.4 %
Date: 2012-08-25 Functions: 2 31 6.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 295 0.7 %

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

Generated by: LCOV version 1.10