LCOV - code coverage report
Current view: top level - sc/source/ui/view - scextopt.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 71 0.0 %
Date: 2014-04-14 Functions: 0 28 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 "scextopt.hxx"
      21             : 
      22             : #include <vector>
      23             : #include <map>
      24             : #include <boost/shared_ptr.hpp>
      25             : 
      26           0 : ScExtDocSettings::ScExtDocSettings() :
      27             :     mfTabBarWidth( -1.0 ),
      28             :     mnLinkCnt( 0 ),
      29           0 :     mnDisplTab( 0 )
      30             : {
      31           0 : }
      32             : 
      33           0 : ScExtTabSettings::ScExtTabSettings() :
      34             :     maUsedArea( ScAddress::INITIALIZE_INVALID ),
      35             :     maCursor( ScAddress::INITIALIZE_INVALID ),
      36             :     maFirstVis( ScAddress::INITIALIZE_INVALID ),
      37             :     maSecondVis( ScAddress::INITIALIZE_INVALID ),
      38             :     maFreezePos( 0, 0, 0 ),
      39             :     maSplitPos( 0, 0 ),
      40             :     meActivePane( SCEXT_PANE_TOPLEFT ),
      41             :     maGridColor( COL_AUTO ),
      42             :     mnNormalZoom( 0 ),
      43             :     mnPageZoom( 0 ),
      44             :     mbSelected( false ),
      45             :     mbFrozenPanes( false ),
      46             :     mbPageMode( false ),
      47           0 :     mbShowGrid( true )
      48             : {
      49           0 : }
      50             : 
      51             : /** A container for ScExtTabSettings objects.
      52             :     @descr  Internally, a std::map with shared pointers to ScExtTabSettings is
      53             :     used. The copy constructor and assignment operator make deep copies of the
      54             :     objects. */
      55           0 : class ScExtTabSettingsCont
      56             : {
      57             : public:
      58             :     explicit            ScExtTabSettingsCont();
      59             :                         ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc );
      60             :     ScExtTabSettingsCont& operator=( const ScExtTabSettingsCont& rSrc );
      61             : 
      62             :     const ScExtTabSettings* GetTabSettings( SCTAB nTab ) const;
      63             :     ScExtTabSettings&   GetOrCreateTabSettings( SCTAB nTab );
      64             : 
      65             :     SCTAB GetLastTab() const;
      66             : 
      67             : private:
      68             :     typedef ::boost::shared_ptr< ScExtTabSettings >     ScExtTabSettingsRef;
      69             :     typedef ::std::map< SCTAB, ScExtTabSettingsRef >    ScExtTabSettingsMap;
      70             : 
      71             :     /** Makes a deep copy of all objects in the passed map. */
      72             :     void                CopyFromMap( const ScExtTabSettingsMap& rMap );
      73             : 
      74             :     ScExtTabSettingsMap maMap;
      75             : };
      76             : 
      77           0 : ScExtTabSettingsCont::ScExtTabSettingsCont()
      78             : {
      79           0 : }
      80             : 
      81           0 : ScExtTabSettingsCont::ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc )
      82             : {
      83           0 :     CopyFromMap( rSrc.maMap );
      84           0 : }
      85             : 
      86           0 : ScExtTabSettingsCont& ScExtTabSettingsCont::operator=( const ScExtTabSettingsCont& rSrc )
      87             : {
      88           0 :     CopyFromMap( rSrc.maMap );
      89           0 :     return *this;
      90             : }
      91             : 
      92           0 : const ScExtTabSettings* ScExtTabSettingsCont::GetTabSettings( SCTAB nTab ) const
      93             : {
      94           0 :     ScExtTabSettingsMap::const_iterator aIt = maMap.find( nTab );
      95           0 :     return (aIt == maMap.end()) ? 0 : aIt->second.get();
      96             : }
      97             : 
      98           0 : ScExtTabSettings& ScExtTabSettingsCont::GetOrCreateTabSettings( SCTAB nTab )
      99             : {
     100           0 :     ScExtTabSettingsRef& rxTabSett = maMap[ nTab ];
     101           0 :     if( !rxTabSett )
     102           0 :         rxTabSett.reset( new ScExtTabSettings );
     103           0 :     return *rxTabSett;
     104             : }
     105             : 
     106           0 : SCTAB ScExtTabSettingsCont::GetLastTab() const
     107             : {
     108           0 :     return maMap.empty() ? -1 : maMap.rbegin()->first;
     109             : }
     110             : 
     111           0 : void ScExtTabSettingsCont::CopyFromMap( const ScExtTabSettingsMap& rMap )
     112             : {
     113           0 :     maMap.clear();
     114           0 :     for( ScExtTabSettingsMap::const_iterator aIt = rMap.begin(), aEnd = rMap.end(); aIt != aEnd; ++aIt )
     115           0 :         maMap[ aIt->first ].reset( new ScExtTabSettings( *aIt->second ) );
     116           0 : }
     117             : 
     118             : /** Implementation struct for ScExtDocOptions containing all members. */
     119           0 : struct ScExtDocOptionsImpl
     120             : {
     121             :     typedef ::std::vector< OUString > StringVec;
     122             : 
     123             :     ScExtDocSettings    maDocSett;          /// Global document settings.
     124             :     ScExtTabSettingsCont maTabSett;         /// Settings for all sheets.
     125             :     StringVec           maCodeNames;        /// Codenames for all sheets (VBA module names).
     126             :     bool                mbChanged;          /// Use only if something has been changed.
     127             : 
     128             :     explicit            ScExtDocOptionsImpl();
     129             : };
     130             : 
     131           0 : ScExtDocOptionsImpl::ScExtDocOptionsImpl() :
     132           0 :     mbChanged( false )
     133             : {
     134           0 : }
     135             : 
     136           0 : ScExtDocOptions::ScExtDocOptions() :
     137           0 :     mxImpl( new ScExtDocOptionsImpl )
     138             : {
     139           0 : }
     140             : 
     141           0 : ScExtDocOptions::ScExtDocOptions( const ScExtDocOptions& rSrc ) :
     142           0 :     mxImpl( new ScExtDocOptionsImpl( *rSrc.mxImpl ) )
     143             : {
     144           0 : }
     145             : 
     146           0 : ScExtDocOptions::~ScExtDocOptions()
     147             : {
     148           0 : }
     149             : 
     150           0 : ScExtDocOptions& ScExtDocOptions::operator=( const ScExtDocOptions& rSrc )
     151             : {
     152           0 :     *mxImpl = *rSrc.mxImpl;
     153           0 :     return *this;
     154             : }
     155             : 
     156           0 : bool ScExtDocOptions::IsChanged() const
     157             : {
     158           0 :     return mxImpl->mbChanged;
     159             : }
     160             : 
     161           0 : void ScExtDocOptions::SetChanged( bool bChanged )
     162             : {
     163           0 :     mxImpl->mbChanged = bChanged;
     164           0 : }
     165             : 
     166           0 : const ScExtDocSettings& ScExtDocOptions::GetDocSettings() const
     167             : {
     168           0 :     return mxImpl->maDocSett;
     169             : }
     170             : 
     171           0 : ScExtDocSettings& ScExtDocOptions::GetDocSettings()
     172             : {
     173           0 :     return mxImpl->maDocSett;
     174             : }
     175             : 
     176           0 : const ScExtTabSettings* ScExtDocOptions::GetTabSettings( SCTAB nTab ) const
     177             : {
     178           0 :     return mxImpl->maTabSett.GetTabSettings( nTab );
     179             : }
     180             : 
     181           0 : SCTAB ScExtDocOptions::GetLastTab() const
     182             : {
     183           0 :     return mxImpl->maTabSett.GetLastTab();
     184             : }
     185             : 
     186           0 : ScExtTabSettings& ScExtDocOptions::GetOrCreateTabSettings( SCTAB nTab )
     187             : {
     188           0 :     return mxImpl->maTabSett.GetOrCreateTabSettings( nTab );
     189             : }
     190             : 
     191           0 : SCTAB ScExtDocOptions::GetCodeNameCount() const
     192             : {
     193           0 :     return static_cast< SCTAB >( mxImpl->maCodeNames.size() );
     194             : }
     195             : 
     196           0 : const OUString& ScExtDocOptions::GetCodeName( SCTAB nTab ) const
     197             : {
     198             :     OSL_ENSURE( (0 <= nTab) && (nTab < GetCodeNameCount()), "ScExtDocOptions::GetCodeName - invalid sheet index" );
     199           0 :     return ((0 <= nTab) && (nTab < GetCodeNameCount())) ? mxImpl->maCodeNames[ static_cast< size_t >( nTab ) ] : EMPTY_OUSTRING;
     200             : }
     201             : 
     202           0 : void ScExtDocOptions::SetCodeName( SCTAB nTab, const OUString& rCodeName )
     203             : {
     204             :     OSL_ENSURE( nTab >= 0, "ScExtDocOptions::SetCodeName - invalid sheet index" );
     205           0 :     if( nTab >= 0 )
     206             :     {
     207           0 :         size_t nIndex = static_cast< size_t >( nTab );
     208           0 :         if( nIndex >= mxImpl->maCodeNames.size() )
     209           0 :             mxImpl->maCodeNames.resize( nIndex + 1 );
     210           0 :         mxImpl->maCodeNames[ nIndex ] = rCodeName;
     211             :     }
     212           0 : }
     213             : 
     214             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10