fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / scextopt.cxx
blob47be2d29991a37ad5dc406573bff08ea6b13bde6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "scextopt.hxx"
22 #include <osl/diagnose.h>
24 #include <vector>
25 #include <map>
26 #include <boost/shared_ptr.hpp>
28 ScExtDocSettings::ScExtDocSettings() :
29 mfTabBarWidth( -1.0 ),
30 mnLinkCnt( 0 ),
31 mnDisplTab( 0 )
35 ScExtTabSettings::ScExtTabSettings() :
36 maUsedArea( ScAddress::INITIALIZE_INVALID ),
37 maCursor( ScAddress::INITIALIZE_INVALID ),
38 maFirstVis( ScAddress::INITIALIZE_INVALID ),
39 maSecondVis( ScAddress::INITIALIZE_INVALID ),
40 maFreezePos( 0, 0, 0 ),
41 maSplitPos( 0, 0 ),
42 meActivePane( SCEXT_PANE_TOPLEFT ),
43 maGridColor( COL_AUTO ),
44 mnNormalZoom( 0 ),
45 mnPageZoom( 0 ),
46 mbSelected( false ),
47 mbFrozenPanes( false ),
48 mbPageMode( false ),
49 mbShowGrid( true )
53 /** A container for ScExtTabSettings objects.
54 @descr Internally, a std::map with shared pointers to ScExtTabSettings is
55 used. The copy constructor and assignment operator make deep copies of the
56 objects. */
57 class ScExtTabSettingsCont
59 public:
60 explicit ScExtTabSettingsCont();
61 ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc );
62 ScExtTabSettingsCont& operator=( const ScExtTabSettingsCont& rSrc );
64 const ScExtTabSettings* GetTabSettings( SCTAB nTab ) const;
65 ScExtTabSettings& GetOrCreateTabSettings( SCTAB nTab );
67 SCTAB GetLastTab() const;
69 private:
70 typedef ::boost::shared_ptr< ScExtTabSettings > ScExtTabSettingsRef;
71 typedef ::std::map< SCTAB, ScExtTabSettingsRef > ScExtTabSettingsMap;
73 /** Makes a deep copy of all objects in the passed map. */
74 void CopyFromMap( const ScExtTabSettingsMap& rMap );
76 ScExtTabSettingsMap maMap;
79 ScExtTabSettingsCont::ScExtTabSettingsCont()
83 ScExtTabSettingsCont::ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc )
85 CopyFromMap( rSrc.maMap );
88 ScExtTabSettingsCont& ScExtTabSettingsCont::operator=( const ScExtTabSettingsCont& rSrc )
90 CopyFromMap( rSrc.maMap );
91 return *this;
94 const ScExtTabSettings* ScExtTabSettingsCont::GetTabSettings( SCTAB nTab ) const
96 ScExtTabSettingsMap::const_iterator aIt = maMap.find( nTab );
97 return (aIt == maMap.end()) ? 0 : aIt->second.get();
100 ScExtTabSettings& ScExtTabSettingsCont::GetOrCreateTabSettings( SCTAB nTab )
102 ScExtTabSettingsRef& rxTabSett = maMap[ nTab ];
103 if( !rxTabSett )
104 rxTabSett.reset( new ScExtTabSettings );
105 return *rxTabSett;
108 SCTAB ScExtTabSettingsCont::GetLastTab() const
110 return maMap.empty() ? -1 : maMap.rbegin()->first;
113 void ScExtTabSettingsCont::CopyFromMap( const ScExtTabSettingsMap& rMap )
115 maMap.clear();
116 for( ScExtTabSettingsMap::const_iterator aIt = rMap.begin(), aEnd = rMap.end(); aIt != aEnd; ++aIt )
117 maMap[ aIt->first ].reset( new ScExtTabSettings( *aIt->second ) );
120 /** Implementation struct for ScExtDocOptions containing all members. */
121 struct ScExtDocOptionsImpl
123 typedef ::std::vector< OUString > StringVec;
125 ScExtDocSettings maDocSett; /// Global document settings.
126 ScExtTabSettingsCont maTabSett; /// Settings for all sheets.
127 StringVec maCodeNames; /// Codenames for all sheets (VBA module names).
128 bool mbChanged; /// Use only if something has been changed.
130 explicit ScExtDocOptionsImpl();
133 ScExtDocOptionsImpl::ScExtDocOptionsImpl() :
134 mbChanged( false )
138 ScExtDocOptions::ScExtDocOptions() :
139 mxImpl( new ScExtDocOptionsImpl )
143 ScExtDocOptions::ScExtDocOptions( const ScExtDocOptions& rSrc ) :
144 mxImpl( new ScExtDocOptionsImpl( *rSrc.mxImpl ) )
148 ScExtDocOptions::~ScExtDocOptions()
152 ScExtDocOptions& ScExtDocOptions::operator=( const ScExtDocOptions& rSrc )
154 *mxImpl = *rSrc.mxImpl;
155 return *this;
158 bool ScExtDocOptions::IsChanged() const
160 return mxImpl->mbChanged;
163 void ScExtDocOptions::SetChanged( bool bChanged )
165 mxImpl->mbChanged = bChanged;
168 const ScExtDocSettings& ScExtDocOptions::GetDocSettings() const
170 return mxImpl->maDocSett;
173 ScExtDocSettings& ScExtDocOptions::GetDocSettings()
175 return mxImpl->maDocSett;
178 const ScExtTabSettings* ScExtDocOptions::GetTabSettings( SCTAB nTab ) const
180 return mxImpl->maTabSett.GetTabSettings( nTab );
183 SCTAB ScExtDocOptions::GetLastTab() const
185 return mxImpl->maTabSett.GetLastTab();
188 ScExtTabSettings& ScExtDocOptions::GetOrCreateTabSettings( SCTAB nTab )
190 return mxImpl->maTabSett.GetOrCreateTabSettings( nTab );
193 SCTAB ScExtDocOptions::GetCodeNameCount() const
195 return static_cast< SCTAB >( mxImpl->maCodeNames.size() );
198 const OUString& ScExtDocOptions::GetCodeName( SCTAB nTab ) const
200 OSL_ENSURE( (0 <= nTab) && (nTab < GetCodeNameCount()), "ScExtDocOptions::GetCodeName - invalid sheet index" );
201 return ((0 <= nTab) && (nTab < GetCodeNameCount())) ? mxImpl->maCodeNames[ static_cast< size_t >( nTab ) ] : EMPTY_OUSTRING;
204 void ScExtDocOptions::SetCodeName( SCTAB nTab, const OUString& rCodeName )
206 OSL_ENSURE( nTab >= 0, "ScExtDocOptions::SetCodeName - invalid sheet index" );
207 if( nTab >= 0 )
209 size_t nIndex = static_cast< size_t >( nTab );
210 if( nIndex >= mxImpl->maCodeNames.size() )
211 mxImpl->maCodeNames.resize( nIndex + 1 );
212 mxImpl->maCodeNames[ nIndex ] = rCodeName;
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */