LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/config - slidesorterbaropt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 123 0.0 %
Date: 2012-12-17 Functions: 0 24 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 <svtools/slidesorterbaropt.hxx>
      21             : #include <unotools/configmgr.hxx>
      22             : #include <unotools/configitem.hxx>
      23             : #include <tools/debug.hxx>
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : #include <com/sun/star/uno/Sequence.hxx>
      26             : 
      27             : #include <rtl/logfile.hxx>
      28             : #include <rtl/instance.hxx>
      29             : 
      30             : using namespace ::utl;
      31             : using namespace ::rtl;
      32             : using namespace ::osl;
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star;
      35             : 
      36             : #define ROOTNODE_SLIDESORTERBAR                OUString("Office.Impress/MultiPaneGUI/SlideSorterBar/Visible")
      37             : 
      38             : #define PROPERTYNAME_VISIBLE_IMPRESSVIEW       OUString("ImpressView")
      39             : #define PROPERTYHANDLE_VISIBLE_IMPRESSVIEW     0
      40             : #define PROPERTYNAME_VISIBLE_OUTLINEVIEW       OUString("OutlineView")
      41             : #define PROPERTYHANDLE_VISIBLE_OUTLINEVIEW     1
      42             : #define PROPERTYNAME_VISIBLE_NOTESVIEW         OUString("NotesView")
      43             : #define PROPERTYHANDLE_VISIBLE_NOTESVIEW       2
      44             : #define PROPERTYNAME_VISIBLE_HANDOUTVIEW       OUString("HandoutView")
      45             : #define PROPERTYHANDLE_VISIBLE_HANDOUTVIEW     3
      46             : #define PROPERTYNAME_VISIBLE_SLIDESORTERVIEW   OUString("SlideSorterView")
      47             : #define PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW 4
      48             : #define PROPERTYNAME_VISIBLE_DRAWVIEW          OUString("DrawView")
      49             : #define PROPERTYHANDLE_VISIBLE_DRAWVIEW        5
      50             : 
      51             : #define PROPERTYCOUNT                          6
      52             : 
      53             : class SvtSlideSorterBarOptions_Impl : public ConfigItem
      54             : {
      55             :     Sequence< OUString > m_seqPropertyNames;
      56             : 
      57             :     public:
      58             : 
      59             :          SvtSlideSorterBarOptions_Impl();
      60             :         ~SvtSlideSorterBarOptions_Impl();
      61             : 
      62             :         /** called for notify of configmanager
      63             : 
      64             :             These method is called from the ConfigManager before application ends or from the
      65             :             PropertyChangeListener if the sub tree broadcasts changes. You must update your
      66             :             internal values.
      67             : 
      68             :             \sa baseclass ConfigItem
      69             :             \param[in,out] seqPropertyNames is the list of properties which should be updated.
      70             :         */
      71             :         virtual void Notify( const Sequence< OUString >& seqPropertyNames );
      72             : 
      73             :         /**
      74             :          loads required data from the configuration. It's called in the constructor to
      75             :          read all entries and form ::Notify to re-read changed setting
      76             :         */
      77             :         void Load( const Sequence< OUString >& rPropertyNames );
      78             : 
      79             :         /** write changes to configuration
      80             : 
      81             :             These method writes the changed values into the sub tree
      82             :             and should always called in our destructor to guarantee consistency of config data.
      83             : 
      84             :             \sa baseclass ConfigItem
      85             :         */
      86             :         virtual void Commit();
      87             : 
      88             :         //  public interface
      89             :         bool m_bVisibleImpressView;
      90             :         bool m_bVisibleOutlineView;
      91             :         bool m_bVisibleNotesView;
      92             :         bool m_bVisibleHandoutView;
      93             :         bool m_bVisibleSlideSorterView;
      94             :         bool m_bVisibleDrawView;
      95             : 
      96             :     private:
      97             :         /** return list of key names of our configuration management which represent oue module tree
      98             : 
      99             :             These methods return a static const list of key names. We need it to get needed values from our
     100             :             configuration management.
     101             : 
     102             :             \return A list of needed configuration keys is returned.
     103             :         */
     104             :         static Sequence< OUString > GetPropertyNames();
     105             : 
     106             :     protected:
     107             : };
     108             : 
     109           0 : SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()
     110             :     // Init baseclasses first
     111             :     : ConfigItem( ROOTNODE_SLIDESORTERBAR )
     112             : 
     113             :     , m_bVisibleImpressView( false )
     114             :     , m_bVisibleOutlineView( false )
     115             :     , m_bVisibleNotesView( false )
     116             :     , m_bVisibleHandoutView( false )
     117             :     , m_bVisibleSlideSorterView( false )
     118           0 :     , m_bVisibleDrawView( false )
     119             : 
     120             : {
     121           0 :     m_seqPropertyNames = GetPropertyNames( );
     122             : 
     123             :     // Use our static list of configuration keys to get his values.
     124           0 :     Sequence< Any > seqValues = GetProperties( m_seqPropertyNames  );
     125             : 
     126             :     // Safe impossible cases.
     127             :     // We need values from ALL configuration keys.
     128             :     // Follow assignment use order of values in relation to our list of key names!
     129             :     DBG_ASSERT( !(m_seqPropertyNames.getLength()!=seqValues.getLength()),
     130             :                 "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
     131             : 
     132             :     // Copy values from list in right order to our internal member.
     133           0 :     for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
     134             :     {
     135           0 :         if (seqValues[nProperty].hasValue()==sal_False)
     136           0 :             continue;
     137           0 :         switch( nProperty )
     138             :         {
     139             :             case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW :
     140             :             {
     141           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
     142             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
     143           0 :                 break;
     144             :             }
     145             :             case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
     146             :             {
     147           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
     148             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
     149           0 :                 break;
     150             :             }
     151             :             case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
     152             :             {
     153           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
     154             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
     155           0 :                 break;
     156             :             }
     157             :             case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
     158             :             {
     159           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
     160             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
     161           0 :                 break;
     162             :             }
     163             :             case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
     164             :             {
     165           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
     166             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
     167           0 :                 break;
     168             :             }
     169             :             case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
     170             :             {
     171           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
     172             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
     173           0 :                 break;
     174             :             }
     175             :         }
     176             :     }
     177             : 
     178             :     // Enable notification mechanism of our baseclass.
     179             :     // We need it to get information about changes outside these class on our used configuration keys!
     180           0 :     EnableNotification( m_seqPropertyNames );
     181           0 : }
     182             : 
     183           0 : SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl()
     184             : {
     185           0 :     Commit();
     186           0 : }
     187             : 
     188           0 : static int lcl_MapPropertyName( const ::rtl::OUString rCompare,
     189             :                 const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames)
     190             : {
     191           0 :     for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
     192             :     {
     193           0 :         if( aInternalPropertyNames[nProp] == rCompare )
     194           0 :             return nProp;
     195             :     }
     196           0 :     return -1;
     197             : }
     198             : 
     199           0 : void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
     200             : {
     201           0 :     const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames());
     202           0 :     Sequence< Any > seqValues = GetProperties( rPropertyNames  );
     203             : 
     204             :     // Safe impossible cases.
     205             :     // We need values from ALL configuration keys.
     206             :     // Follow assignment use order of values in relation to our list of key names!
     207             :     DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()),
     208             :                 "SvtSlideSorterBarOptions_Impl::SvtSlideSorterBarOptions_Impl()\nI miss some values of configuration keys!\n" );
     209             : 
     210             :     // Copy values from list in right order to our internal member.
     211           0 :     for( sal_Int32 nProperty=0; nProperty<seqValues.getLength(); ++nProperty )
     212             :     {
     213           0 :         if (seqValues[nProperty].hasValue()==sal_False)
     214           0 :             continue;
     215           0 :         switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
     216             :         {
     217             :             case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
     218             :             {
     219           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleImpressView) )
     220             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleImpressView\"!" );
     221             :             }
     222           0 :             break;
     223             :             case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW :
     224             :             {
     225           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleOutlineView) )
     226             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleOutlineView\"!" );
     227             :             }
     228           0 :             break;
     229             :             case PROPERTYHANDLE_VISIBLE_NOTESVIEW :
     230             :             {
     231           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleNotesView) )
     232             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleNotesView\"!" );
     233             :             }
     234           0 :             break;
     235             :             case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW :
     236             :             {
     237           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleHandoutView) )
     238             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleHandoutView\"!" );
     239             :             }
     240           0 :             break;
     241             :             case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW :
     242             :             {
     243           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleSlideSorterView) )
     244             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleSlideSorterView\"!" );
     245             :             }
     246           0 :             break;
     247             : 
     248             :             case PROPERTYHANDLE_VISIBLE_DRAWVIEW :
     249             :             {
     250           0 :                 if( !(seqValues[nProperty] >>= m_bVisibleDrawView) )
     251             :                     OSL_FAIL("Wrong type of \"SlideSorterBar\\VisibleDrawView\"!" );
     252             :             }
     253           0 :             break;
     254             :        }
     255           0 :     }
     256           0 : }
     257             : 
     258           0 : void SvtSlideSorterBarOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames )
     259             : {
     260           0 :     Load( rPropertyNames );
     261           0 : }
     262             : 
     263           0 : void SvtSlideSorterBarOptions_Impl::Commit()
     264             : {
     265             :     // Get names of supported properties, create a list for values and copy current values to it.
     266           0 :     sal_Int32               nCount      = m_seqPropertyNames.getLength();
     267           0 :     Sequence< Any >         seqValues   ( nCount );
     268           0 :     for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty )
     269             :     {
     270           0 :         switch( nProperty )
     271             :         {
     272             :             case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
     273             :             {
     274           0 :                 seqValues[nProperty] <<= m_bVisibleImpressView;
     275           0 :                 break;
     276             :             }
     277             :             case PROPERTYHANDLE_VISIBLE_OUTLINEVIEW:
     278             :             {
     279           0 :                 seqValues[nProperty] <<= m_bVisibleOutlineView;
     280           0 :                 break;
     281             :             }
     282             :             case PROPERTYHANDLE_VISIBLE_NOTESVIEW:
     283             :             {
     284           0 :                 seqValues[nProperty] <<= m_bVisibleNotesView;
     285           0 :                 break;
     286             :             }
     287             :             case PROPERTYHANDLE_VISIBLE_HANDOUTVIEW:
     288             :             {
     289           0 :                 seqValues[nProperty] <<= m_bVisibleHandoutView;
     290           0 :                 break;
     291             :             }
     292             :             case PROPERTYHANDLE_VISIBLE_SLIDESORTERVIEW:
     293             :             {
     294           0 :                 seqValues[nProperty] <<= m_bVisibleSlideSorterView;
     295           0 :                 break;
     296             :             }
     297             :             case PROPERTYHANDLE_VISIBLE_DRAWVIEW:
     298             :             {
     299           0 :                 seqValues[nProperty] <<= m_bVisibleDrawView;
     300           0 :                 break;
     301             :             }
     302             : 
     303             :         }
     304             :     }
     305             :     // Set properties in configuration.
     306           0 :     PutProperties( m_seqPropertyNames, seqValues );
     307           0 : }
     308             : 
     309           0 : Sequence< OUString > SvtSlideSorterBarOptions_Impl::GetPropertyNames()
     310             : {
     311             :     // Build list of configuration key names.
     312             :     OUString pProperties[] =
     313             :     {
     314             :         PROPERTYNAME_VISIBLE_IMPRESSVIEW,
     315             :         PROPERTYNAME_VISIBLE_OUTLINEVIEW,
     316             :         PROPERTYNAME_VISIBLE_NOTESVIEW,
     317             :         PROPERTYNAME_VISIBLE_HANDOUTVIEW,
     318             :         PROPERTYNAME_VISIBLE_SLIDESORTERVIEW,
     319             :         PROPERTYNAME_VISIBLE_DRAWVIEW,
     320           0 :     };
     321             : 
     322             :     // Initialize return sequence with these list and run
     323           0 :     return Sequence< OUString >( pProperties, SAL_N_ELEMENTS( pProperties ) );
     324             : }
     325             : 
     326             : //  initialize static member, see definition for further information
     327             : //  DON'T DO IT IN YOUR HEADER!
     328             : SvtSlideSorterBarOptions_Impl* SvtSlideSorterBarOptions::m_pDataContainer    = NULL  ;
     329             : sal_Int32                      SvtSlideSorterBarOptions::m_nRefCount = 0     ;
     330             : 
     331           0 : SvtSlideSorterBarOptions::SvtSlideSorterBarOptions()
     332             : {
     333             :     // Global access, must be guarded (multithreading!).
     334           0 :     MutexGuard aGuard( GetInitMutex() );
     335           0 :     ++m_nRefCount;
     336             :     // ... and initialize our data container only if it not already exist!
     337           0 :     if( m_pDataContainer == NULL )
     338             :     {
     339             :        RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtSlideSorterBarOptions_Impl::ctor()");
     340           0 :        m_pDataContainer = new SvtSlideSorterBarOptions_Impl;
     341           0 :     }
     342           0 : }
     343             : 
     344           0 : SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions()
     345             : {
     346             :     // Global access, must be guarded (multithreading!)
     347           0 :     MutexGuard aGuard( GetInitMutex() );
     348           0 :     --m_nRefCount;
     349             :     // If last instance was deleted we must destroy our static data container!
     350           0 :     if( m_nRefCount <= 0 )
     351             :     {
     352           0 :         delete m_pDataContainer;
     353           0 :         m_pDataContainer = NULL;
     354           0 :     }
     355           0 : }
     356             : 
     357           0 : bool SvtSlideSorterBarOptions::GetVisibleImpressView() const
     358             : {
     359           0 :     return m_pDataContainer->m_bVisibleImpressView;
     360             : }
     361             : 
     362           0 : void SvtSlideSorterBarOptions::SetVisibleImpressView(bool bVisible)
     363             : {
     364           0 :     m_pDataContainer->m_bVisibleImpressView = bVisible;
     365           0 : }
     366             : 
     367           0 : bool SvtSlideSorterBarOptions::GetVisibleOutlineView() const
     368             : {
     369           0 :     return m_pDataContainer->m_bVisibleOutlineView;
     370             : }
     371             : 
     372           0 : void SvtSlideSorterBarOptions::SetVisibleOutlineView(bool bVisible)
     373             : {
     374           0 :     m_pDataContainer->m_bVisibleOutlineView = bVisible;
     375           0 : }
     376             : 
     377           0 : bool SvtSlideSorterBarOptions::GetVisibleNotesView() const
     378             : {
     379           0 :     return m_pDataContainer->m_bVisibleNotesView;
     380             : }
     381             : 
     382           0 : void SvtSlideSorterBarOptions::SetVisibleNotesView(bool bVisible)
     383             : {
     384           0 :     m_pDataContainer->m_bVisibleNotesView = bVisible;
     385           0 : }
     386             : 
     387           0 : bool SvtSlideSorterBarOptions::GetVisibleHandoutView() const
     388             : {
     389           0 :     return m_pDataContainer->m_bVisibleHandoutView;
     390             : }
     391             : 
     392           0 : void SvtSlideSorterBarOptions::SetVisibleHandoutView(bool bVisible)
     393             : {
     394           0 :     m_pDataContainer->m_bVisibleHandoutView = bVisible;
     395           0 : }
     396             : 
     397           0 : bool SvtSlideSorterBarOptions::GetVisibleSlideSorterView() const
     398             : {
     399           0 :     return m_pDataContainer->m_bVisibleSlideSorterView;
     400             : }
     401             : 
     402           0 : void SvtSlideSorterBarOptions::SetVisibleSlideSorterView(bool bVisible)
     403             : {
     404           0 :     m_pDataContainer->m_bVisibleSlideSorterView = bVisible;
     405           0 : }
     406             : 
     407           0 : bool SvtSlideSorterBarOptions::GetVisibleDrawView() const
     408             : {
     409           0 :     return m_pDataContainer->m_bVisibleDrawView;
     410             : }
     411             : 
     412           0 : void SvtSlideSorterBarOptions::SetVisibleDrawView(bool bVisible)
     413             : {
     414           0 :     m_pDataContainer->m_bVisibleDrawView = bVisible;
     415           0 : }
     416             : 
     417             : namespace
     418             : {
     419             :     class theSvtSlideSorterBarOptionsMutex :
     420             :         public rtl::Static< osl::Mutex, theSvtSlideSorterBarOptionsMutex > {};
     421             : }
     422             : 
     423           0 : Mutex & SvtSlideSorterBarOptions::GetInitMutex()
     424             : {
     425           0 :     return theSvtSlideSorterBarOptionsMutex::get();
     426             : }
     427             : 
     428             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10