LCOV - code coverage report
Current view: top level - sc/source/filter/excel - xltoolbar.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 229 8.3 %
Date: 2012-08-25 Functions: 6 28 21.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 442 1.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4                 :            :  *
       5                 :            :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :            :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :            :  * the License or as specified alternatively below. You may obtain a copy of
       8                 :            :  * the License at http://www.mozilla.org/MPL/
       9                 :            :  *
      10                 :            :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :            :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :            :  * for the specific language governing rights and limitations under the
      13                 :            :  * License.
      14                 :            :  *
      15                 :            :  * The Initial Developer of the Original Code is
      16                 :            :  *       Noel Power <noel.power@novell.com>
      17                 :            :  * Portions created by the Initial Developer are Copyright (C) 2010 the
      18                 :            :  * Initial Developer. All Rights Reserved.
      19                 :            :  *
      20                 :            :  * Contributor(s):
      21                 :            :  *       Noel Power <noel.power@novell.com>
      22                 :            :  *
      23                 :            :  * For minor contributions see the git repository.
      24                 :            :  *
      25                 :            :  * Alternatively, the contents of this file may be used under the terms of
      26                 :            :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      27                 :            :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      28                 :            :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      29                 :            :  * instead of those above.
      30                 :            :  */
      31                 :            : #include "xltoolbar.hxx"
      32                 :            : #include <rtl/ustrbuf.hxx>
      33                 :            : #include <stdarg.h>
      34                 :            : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
      35                 :            : #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
      36                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      37                 :            : #include <com/sun/star/lang/XSingleComponentFactory.hpp>
      38                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      39                 :            : #include <com/sun/star/ui/XImageManager.hpp>
      40                 :            : #include <com/sun/star/ui/ItemType.hpp>
      41                 :            : #include <fstream>
      42                 :            : #include <comphelper/processfactory.hxx>
      43                 :            : #include <vcl/graph.hxx>
      44                 :            : #include <map>
      45                 :            : using namespace com::sun::star;
      46                 :            : 
      47                 :            : typedef std::map< sal_Int16, rtl::OUString > IdToString;
      48                 :            : 
      49         [ #  # ]:          0 : class MSOExcelCommandConvertor : public MSOCommandConvertor
      50                 :            : {
      51                 :            :    IdToString msoToOOcmd;
      52                 :            :    IdToString tcidToOOcmd;
      53                 :            : public:
      54                 :            :     MSOExcelCommandConvertor();
      55                 :            :     virtual rtl::OUString MSOCommandToOOCommand( sal_Int16 msoCmd );
      56                 :            :     virtual rtl::OUString MSOTCIDToOOCommand( sal_Int16 key );
      57                 :            : };
      58                 :            : 
      59 [ #  # ][ #  # ]:          0 : MSOExcelCommandConvertor::MSOExcelCommandConvertor()
      60                 :            : {
      61                 :            : /*
      62                 :            :     // mso command id to ooo command string
      63                 :            :     // #FIXME and *HUNDREDS* of id's to added here
      64                 :            :     msoToOOcmd[ 0x20b ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:CloseDoc") );
      65                 :            :     msoToOOcmd[ 0x50 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Open") );
      66                 :            : 
      67                 :            :    // mso tcid to ooo command string
      68                 :            :     // #FIXME and *HUNDREDS* of id's to added here
      69                 :            :    tcidToOOcmd[ 0x9d9 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".uno:Print") );
      70                 :            : */
      71                 :          0 : }
      72                 :            : 
      73                 :          0 : rtl::OUString MSOExcelCommandConvertor::MSOCommandToOOCommand( sal_Int16 key )
      74                 :            : {
      75                 :          0 :     rtl::OUString sResult;
      76         [ #  # ]:          0 :     IdToString::iterator it = msoToOOcmd.find( key );
      77         [ #  # ]:          0 :     if ( it != msoToOOcmd.end() )
      78                 :          0 :         sResult = it->second;
      79                 :          0 :     return sResult;
      80                 :            : }
      81                 :            : 
      82                 :          0 : rtl::OUString MSOExcelCommandConvertor::MSOTCIDToOOCommand( sal_Int16 key )
      83                 :            : {
      84                 :          0 :     rtl::OUString sResult;
      85         [ #  # ]:          0 :     IdToString::iterator it = tcidToOOcmd.find( key );
      86         [ #  # ]:          0 :     if ( it != tcidToOOcmd.end() )
      87                 :          0 :         sResult = it->second;
      88                 :          0 :     return sResult;
      89                 :            : }
      90                 :            : 
      91                 :            : 
      92                 :            : 
      93                 :         13 : CTBS::CTBS() : bSignature(0), bVersion(0), reserved1(0), reserved2(0), reserved3(0), ctb(0), ctbViews(0), ictbView(0)
      94                 :            : {
      95                 :         13 : }
      96                 :            : 
      97 [ #  # ][ #  # ]:          0 : CTB::CTB() : nViews( 0 ), ectbid(0)
                 [ #  # ]
      98                 :            : {
      99                 :          0 : }
     100                 :            : 
     101 [ #  # ][ #  # ]:          0 : CTB::CTB(sal_uInt16 nNum ) : nViews( nNum ), ectbid(0)
                 [ #  # ]
     102                 :            : {
     103                 :          0 : }
     104                 :            : 
     105                 :          0 : bool CTB::Read( SvStream &rS )
     106                 :            : {
     107                 :            :     OSL_TRACE("CTB::Read() stream pos 0x%x", rS.Tell() );
     108                 :          0 :     nOffSet = rS.Tell();
     109                 :          0 :     tb.Read( rS );
     110         [ #  # ]:          0 :     for ( sal_uInt16 index = 0; index < nViews; ++index )
     111                 :            :     {
     112         [ #  # ]:          0 :         TBVisualData aVisData;
     113         [ #  # ]:          0 :         aVisData.Read( rS );
     114         [ #  # ]:          0 :         rVisualData.push_back( aVisData );
     115         [ #  # ]:          0 :     }
     116                 :          0 :     rS >> ectbid;
     117                 :            : 
     118         [ #  # ]:          0 :     for ( sal_Int16 index = 0; index < tb.getcCL(); ++index )
     119                 :            :     {
     120         [ #  # ]:          0 :         TBC aTBC;
     121         [ #  # ]:          0 :         aTBC.Read( rS );
     122         [ #  # ]:          0 :         rTBC.push_back( aTBC );
     123         [ #  # ]:          0 :     }
     124                 :          0 :     return true;
     125                 :            : }
     126                 :            : 
     127                 :          0 : void CTB::Print( FILE* fp )
     128                 :            : {
     129         [ #  # ]:          0 :     Indent a;
     130         [ #  # ]:          0 :     indent_printf( fp, "[ 0x%x ] CTB -- dump\n", nOffSet );
     131         [ #  # ]:          0 :     indent_printf( fp, "  nViews 0x%x\n", nViews);
     132         [ #  # ]:          0 :     tb.Print( fp );
     133                 :            : 
     134                 :          0 :     std::vector<TBVisualData>::iterator visData_end = rVisualData.end();
     135                 :          0 :     sal_Int32 counter = 0;
     136 [ #  # ][ #  # ]:          0 :     for ( std::vector<TBVisualData>::iterator it = rVisualData.begin(); it != visData_end; ++it )
                 [ #  # ]
     137                 :            :     {
     138                 :            : 
     139         [ #  # ]:          0 :         indent_printf( fp, "  TBVisualData [%d]\n", counter++ );
     140         [ #  # ]:          0 :         Indent b;
     141 [ #  # ][ #  # ]:          0 :         it->Print( fp );
     142                 :          0 :     }
     143         [ #  # ]:          0 :     indent_printf( fp, "  ectbid 0x%x\n", ectbid);
     144                 :          0 :     std::vector<TBC>::iterator it_end = rTBC.end();
     145                 :          0 :     counter = 0;
     146 [ #  # ][ #  # ]:          0 :     for ( std::vector<TBC>::iterator it = rTBC.begin(); it != it_end; ++it )
     147                 :            :     {
     148         [ #  # ]:          0 :         indent_printf( fp, "  TBC [%d]\n", counter++);
     149         [ #  # ]:          0 :         Indent c;
     150         [ #  # ]:          0 :         it->Print( fp );
     151                 :          0 :     }
     152                 :          0 : }
     153                 :            : 
     154                 :          0 : bool CTB::IsMenuToolbar()
     155                 :            : {
     156                 :          0 :     return tb.IsMenuToolbar();
     157                 :            : }
     158                 :            : 
     159                 :          0 : bool CTB::ImportMenuTB( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& xMenuDesc, CustomToolBarImportHelper& helper )
     160                 :            : {
     161                 :          0 :     sal_Int32 index = 0;
     162 [ #  # ][ #  # ]:          0 :     for ( std::vector< TBC >::iterator it =  rTBC.begin(); it != rTBC.end(); ++it, ++index )
     163                 :            :     {
     164 [ #  # ][ #  # ]:          0 :         if ( !it->ImportToolBarControl( rWrapper, xMenuDesc, helper, IsMenuToolbar() ) )
     165                 :          0 :             return false;
     166                 :            :     }
     167                 :          0 :     return true;
     168                 :            : }
     169                 :            : 
     170                 :          0 : bool CTB::ImportCustomToolBar( CTBWrapper& rWrapper, CustomToolBarImportHelper& helper )
     171                 :            : {
     172                 :            : 
     173 [ #  # ][ #  # ]:          0 :     static rtl::OUString sToolbarPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/custom_" ) );
         [ #  # ][ #  # ]
     174                 :          0 :     bool bRes = false;
     175                 :            :     try
     176                 :            :     {
     177 [ #  # ][ #  # ]:          0 :         if ( !tb.IsEnabled() )
     178                 :          0 :             return true;  // didn't fail, just ignoring
     179                 :            : 
     180                 :            :         // Create default setting
     181 [ #  # ][ #  # ]:          0 :         uno::Reference< container::XIndexContainer > xIndexContainer( helper.getCfgManager()->createSettings(), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     182         [ #  # ]:          0 :         uno::Reference< container::XIndexAccess > xIndexAccess( xIndexContainer, uno::UNO_QUERY_THROW );
     183         [ #  # ]:          0 :         uno::Reference< beans::XPropertySet > xProps( xIndexContainer, uno::UNO_QUERY_THROW );
     184                 :          0 :         WString& name = tb.getName();
     185                 :            :         // set UI name for toolbar
     186 [ #  # ][ #  # ]:          0 :         xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UIName") ), uno::makeAny( name.getString() ) );
         [ #  # ][ #  # ]
     187                 :            : 
     188                 :          0 :         rtl::OUString sToolBarName = sToolbarPrefix.concat( name.getString() );
     189 [ #  # ][ #  # ]:          0 :         for ( std::vector< TBC >::iterator it =  rTBC.begin(); it != rTBC.end(); ++it )
     190                 :            :         {
     191 [ #  # ][ #  # ]:          0 :             if ( !it->ImportToolBarControl( rWrapper, xIndexContainer, helper, IsMenuToolbar() ) )
     192                 :          0 :                 return false;
     193                 :            :         }
     194                 :            : 
     195                 :            :         OSL_TRACE("Name of toolbar :-/ %s", rtl::OUStringToOString( sToolBarName, RTL_TEXTENCODING_UTF8 ).getStr() );
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :         helper.getCfgManager()->insertSettings( sToolBarName, xIndexAccess );
                 [ #  # ]
     198         [ #  # ]:          0 :         helper.applyIcons();
     199                 :            : 
     200 [ #  # ][ #  # ]:          0 :         uno::Reference< ui::XUIConfigurationPersistence > xPersistence( helper.getCfgManager()->getImageManager(), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     201 [ #  # ][ #  # ]:          0 :         xPersistence->store();
     202                 :            : 
     203 [ #  # ][ #  # ]:          0 :         xPersistence.set( helper.getCfgManager(), uno::UNO_QUERY_THROW );
     204 [ #  # ][ #  # ]:          0 :         xPersistence->store();
     205                 :            : 
     206 [ #  # ][ #  # ]:          0 :         bRes = true;
         [ #  # ][ #  # ]
                 [ #  # ]
     207                 :            :     }
     208                 :          0 :     catch( uno::Exception& )
     209                 :            :     {
     210                 :          0 :        bRes = false;
     211                 :            :     }
     212                 :          0 :     return bRes;
     213                 :            : }
     214                 :         13 : bool CTBS::Read( SvStream &rS )
     215                 :            : {
     216                 :            :     OSL_TRACE("CTBS::Read() stream pos 0x%x", rS.Tell() );
     217                 :         13 :     nOffSet = rS.Tell();
     218                 :         13 :     rS >> bSignature >> bVersion >> reserved1 >> reserved2 >> reserved3 >> ctb >> ctbViews >> ictbView;
     219                 :         13 :     return true;
     220                 :            : }
     221                 :            : 
     222                 :          0 : void CTBS::Print( FILE* fp )
     223                 :            : {
     224         [ #  # ]:          0 :     Indent a;
     225         [ #  # ]:          0 :     indent_printf( fp, "[ 0x%x ] CTBS -- dump\n", nOffSet );
     226                 :            : 
     227         [ #  # ]:          0 :     indent_printf( fp, "  bSignature 0x%x\n", bSignature);
     228         [ #  # ]:          0 :     indent_printf( fp, "  bVersion 0x%x\n", bVersion);
     229                 :            : 
     230         [ #  # ]:          0 :     indent_printf( fp, "  reserved1 0x%x\n", reserved1 );
     231         [ #  # ]:          0 :     indent_printf( fp, "  reserved2 0x%x\n", reserved2 );
     232         [ #  # ]:          0 :     indent_printf( fp, "  reserved3 0x%x\n", reserved3 );
     233                 :            : 
     234         [ #  # ]:          0 :     indent_printf( fp, "  ctb 0x%x\n", ctb );
     235         [ #  # ]:          0 :     indent_printf( fp, "  ctbViews 0x%x\n", ctbViews );
     236         [ #  # ]:          0 :     indent_printf( fp, "  ictbView 0x%x\n", ictbView );
     237                 :          0 : }
     238                 :            : 
     239 [ #  # ][ #  # ]:          0 : TBC::TBC()
                 [ #  # ]
     240                 :            : {
     241                 :          0 : }
     242                 :            : 
     243                 :            : bool
     244                 :          0 : TBC::Read(SvStream &rS)
     245                 :            : {
     246                 :            :     OSL_TRACE("TBC::Read() stream pos 0x%x", rS.Tell() );
     247                 :          0 :     nOffSet = rS.Tell();
     248         [ #  # ]:          0 :     if ( !tbch.Read( rS ) )
     249                 :          0 :         return false;
     250                 :          0 :     sal_uInt16 tcid = tbch.getTcID();
     251                 :          0 :     sal_uInt8 tct = tbch.getTct();
     252 [ #  # ][ #  # ]:          0 :     if (  ( tcid != 0x0001 && tcid != 0x06CC && tcid != 0x03D8 && tcid != 0x03EC && tcid != 0x1051 ) && ( ( tct > 0 && tct < 0x0B ) || ( ( tct > 0x0B && tct < 0x10 ) || tct == 0x15 ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     253                 :            :     {
     254                 :          0 :         tbcCmd.reset( new TBCCmd );
     255         [ #  # ]:          0 :         if ( !  tbcCmd->Read( rS ) )
     256                 :          0 :             return false;
     257                 :            :     }
     258         [ #  # ]:          0 :     if ( tct != 0x16 )
     259                 :            :     {
     260         [ #  # ]:          0 :         tbcd.reset( new TBCData( tbch ) );
     261         [ #  # ]:          0 :         if ( !tbcd->Read( rS ) )
     262                 :          0 :             return false;
     263                 :            :     }
     264                 :          0 :     return true;
     265                 :            : }
     266                 :            : 
     267                 :            : 
     268                 :            : void
     269                 :          0 : TBC::Print(FILE* fp)
     270                 :            : {
     271         [ #  # ]:          0 :     Indent a;
     272         [ #  # ]:          0 :     indent_printf( fp, "[ 0x%x ] TBC -- dump\n", nOffSet );
     273         [ #  # ]:          0 :     tbch.Print( fp );
     274         [ #  # ]:          0 :     if ( tbcCmd.get() )
     275         [ #  # ]:          0 :         tbcCmd->Print( fp );
     276         [ #  # ]:          0 :     if ( tbcd.get() )
     277         [ #  # ]:          0 :         tbcd->Print( fp );
     278                 :          0 : }
     279                 :            : 
     280                 :          0 : bool TBC::ImportToolBarControl( CTBWrapper& rWrapper, const css::uno::Reference< css::container::XIndexContainer >& toolbarcontainer, CustomToolBarImportHelper& helper, bool bIsMenuToolbar )
     281                 :            : {
     282                 :            :     // how to identify built-in-command ?
     283                 :            : //    bool bBuiltin = false;
     284         [ #  # ]:          0 :     if ( tbcd.get() )
     285                 :            :     {
     286         [ #  # ]:          0 :         std::vector< css::beans::PropertyValue > props;
     287                 :          0 :         bool bBeginGroup = false;
     288 [ #  # ][ #  # ]:          0 :         if ( ! tbcd->ImportToolBarControl( helper, props, bBeginGroup, bIsMenuToolbar ) )
     289                 :          0 :             return false;
     290         [ #  # ]:          0 :         TBCMenuSpecific* pMenu = tbcd->getMenuSpecific();
     291         [ #  # ]:          0 :         if ( pMenu )
     292                 :            :         {
     293                 :            :             // search for CTB with the appropriate name ( it contains the
     294                 :            :             // menu items, although we cannot import ( or create ) a menu on
     295                 :            :             // a custom toolbar we can import the menu items in a separate
     296                 :            :             // toolbar ( better than nothing )
     297 [ #  # ][ #  # ]:          0 :             CTB* pCustTB = rWrapper.GetCustomizationData( pMenu->Name() );
     298         [ #  # ]:          0 :             if ( pCustTB )
     299                 :            :             {
     300                 :          0 :                  uno::Reference< container::XIndexContainer > xMenuDesc;
     301 [ #  # ][ #  # ]:          0 :                  uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
     302 [ #  # ][ #  # ]:          0 :                  xMenuDesc.set( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.IndexedPropertyValues" ) ) ), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     303 [ #  # ][ #  # ]:          0 :                  if ( !pCustTB->ImportMenuTB( rWrapper, xMenuDesc, helper ) )
     304                 :          0 :                      return false;
     305         [ #  # ]:          0 :                  if ( !bIsMenuToolbar )
     306                 :            :                  {
     307 [ #  # ][ #  # ]:          0 :                      if ( !helper.createMenu( pMenu->Name(), uno::Reference< container::XIndexAccess >( xMenuDesc, uno::UNO_QUERY ), true ) )
         [ #  # ][ #  # ]
     308                 :          0 :                          return false;
     309                 :            :                  }
     310                 :            :                  else
     311                 :            :                  {
     312                 :          0 :                      beans::PropertyValue aProp;
     313         [ #  # ]:          0 :                      aProp.Name =  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ItemDescriptorContainer") );
     314         [ #  # ]:          0 :                      aProp.Value <<= xMenuDesc;
     315         [ #  # ]:          0 :                      props.push_back( aProp );
     316 [ #  # ][ #  # ]:          0 :                  }
     317                 :            :             }
     318                 :            :         }
     319                 :            : 
     320         [ #  # ]:          0 :         if ( bBeginGroup )
     321                 :            :         {
     322                 :            :             // insert spacer
     323         [ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > sProps( 1 );
     324 [ #  # ][ #  # ]:          0 :             sProps[ 0 ].Name =  rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Type") );
     325 [ #  # ][ #  # ]:          0 :             sProps[ 0 ].Value = uno::makeAny( ui::ItemType::SEPARATOR_LINE );
     326 [ #  # ][ #  # ]:          0 :             toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     327                 :            :         }
     328         [ #  # ]:          0 :         uno::Sequence< beans::PropertyValue > sProps( props.size() );
     329         [ #  # ]:          0 :         beans::PropertyValue* pProp = sProps.getArray();
     330                 :            : 
     331 [ #  # ][ #  # ]:          0 :         for ( std::vector< css::beans::PropertyValue >::iterator it = props.begin(); it != props.end(); ++it, ++pProp )
     332                 :          0 :             *pProp = *it;
     333                 :            : 
     334 [ #  # ][ #  # ]:          0 :         toolbarcontainer->insertByIndex( toolbarcontainer->getCount(), uno::makeAny( sProps ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     335                 :            :     }
     336                 :          0 :     return true;
     337                 :            : }
     338                 :            : 
     339                 :            : void
     340                 :          0 : TBCCmd::Print(FILE* fp)
     341                 :            : {
     342         [ #  # ]:          0 :     Indent a;
     343         [ #  # ]:          0 :     indent_printf( fp, " TBCCmd -- dump\n" );
     344         [ #  # ]:          0 :     indent_printf( fp, "   cmdID 0x%x\n", cmdID );
     345 [ #  # ][ #  # ]:          0 :     indent_printf( fp, "   A ( fHideDrawing ) %s\n", A ? "true" : "false" );
     346 [ #  # ][ #  # ]:          0 :     indent_printf( fp, "   B ( reserved - ignored ) %s\n", A ? "true" : "false" );
     347         [ #  # ]:          0 :     indent_printf( fp, "   cmdType 0x%x\n", cmdType );
     348 [ #  # ][ #  # ]:          0 :     indent_printf( fp, "   C ( reserved - ignored ) %s\n", A ? "true" : "false" );
     349         [ #  # ]:          0 :     indent_printf( fp, "   reserved3 0x%x\n", reserved3 );
     350                 :          0 : }
     351                 :            : 
     352                 :          0 : bool TBCCmd::Read( SvStream &rS )
     353                 :            : {
     354                 :            :     OSL_TRACE("TBCCmd::Read() stream pos 0x%x", rS.Tell() );
     355                 :          0 :     nOffSet = rS.Tell();
     356         [ #  # ]:          0 :     rS >> cmdID;
     357                 :            :     sal_uInt16 temp;
     358         [ #  # ]:          0 :     rS >> temp;
     359                 :            :     OSL_TRACE("TBCmd temp = 0x%x", temp );
     360                 :          0 :     A = (temp & 0x8000 ) == 0x8000;
     361                 :          0 :     B = (temp & 0x4000) == 0x4000;
     362                 :          0 :     cmdType = ( temp & 0x3E00 ) >> 9;
     363                 :          0 :     C = ( temp & 0x100 ) == 0x100;
     364                 :          0 :     reserved3 = ( temp & 0xFF );
     365                 :          0 :     return true;
     366                 :            : }
     367                 :            : 
     368         [ +  - ]:         13 : CTBWrapper::CTBWrapper()
     369                 :            : {
     370                 :         13 : }
     371                 :            : 
     372                 :         13 : CTBWrapper::~CTBWrapper()
     373                 :            : {
     374         [ -  + ]:         13 : }
     375                 :            : 
     376                 :            : bool
     377                 :         13 : CTBWrapper::Read( SvStream &rS)
     378                 :            : {
     379                 :            :     OSL_TRACE("CTBWrapper::Read() stream pos 0x%x", rS.Tell() );
     380                 :         13 :     nOffSet = rS.Tell();
     381         [ -  + ]:         13 :     if ( !ctbSet.Read( rS ) )
     382                 :          0 :         return false;
     383         [ -  + ]:         13 :     for ( sal_uInt16 index = 0; index < ctbSet.ctb; ++index )
     384                 :            :     {
     385         [ #  # ]:          0 :         CTB aCTB( ctbSet.ctbViews );
     386 [ #  # ][ #  # ]:          0 :         if ( !aCTB.Read( rS ) )
     387                 :          0 :             return false;
     388 [ #  # ][ #  # ]:          0 :         rCTB.push_back( aCTB );
     389                 :          0 :     }
     390                 :         13 :     return true;
     391                 :            : }
     392                 :            : 
     393                 :            : void
     394                 :          0 : CTBWrapper::Print( FILE* fp )
     395                 :            : {
     396         [ #  # ]:          0 :     Indent a;
     397         [ #  # ]:          0 :     indent_printf( fp, "[ 0x%x ] CTBWrapper -- dump\n", nOffSet );
     398         [ #  # ]:          0 :     ctbSet.Print( fp );
     399                 :          0 :     std::vector<CTB>::iterator it_end = rCTB.end();
     400 [ #  # ][ #  # ]:          0 :     for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
     401                 :            :     {
     402         [ #  # ]:          0 :         Indent b;
     403         [ #  # ]:          0 :         it->Print( fp );
     404                 :          0 :     }
     405                 :          0 : }
     406                 :            : 
     407                 :          0 : CTB* CTBWrapper::GetCustomizationData( const rtl::OUString& sTBName )
     408                 :            : {
     409                 :          0 :     CTB* pCTB = NULL;
     410 [ #  # ][ #  # ]:          0 :     for ( std::vector< CTB >::iterator it = rCTB.begin(); it != rCTB.end(); ++it )
     411                 :            :     {
     412         [ #  # ]:          0 :         if ( it->GetName().equals( sTBName ) )
     413                 :            :         {
     414                 :          0 :             pCTB = &(*it);
     415                 :          0 :             break;
     416                 :            :         }
     417                 :            :     }
     418                 :          0 :     return pCTB;
     419                 :            : }
     420                 :            : 
     421                 :         13 : bool CTBWrapper::ImportCustomToolBar( SfxObjectShell& rDocSh )
     422                 :            : {
     423                 :         13 :     std::vector<CTB>::iterator it_end = rCTB.end();
     424 [ +  - ][ -  + ]:         13 :     for ( std::vector<CTB>::iterator it = rCTB.begin(); it != it_end; ++it )
     425                 :            :     {
     426                 :            :         // for each customtoolbar
     427 [ #  # ][ #  # ]:          0 :         uno::Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
     428 [ #  # ][ #  # ]:          0 :         uno::Reference< ui::XModuleUIConfigurationManagerSupplier > xAppCfgSupp( xMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.ModuleUIConfigurationManagerSupplier" ) ) ), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
     429 [ #  # ][ #  # ]:          0 :         CustomToolBarImportHelper helper( rDocSh, xAppCfgSupp->getUIConfigurationManager( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument" ) ) ) );
         [ #  # ][ #  # ]
     430 [ #  # ][ #  # ]:          0 :         helper.setMSOCommandMap( new  MSOExcelCommandConvertor() );
     431                 :            :         // Ignore menu toolbars, excel doesn't ( afaics ) store
     432                 :            :         // menu customizations ( but you can have menus in a customtoolbar
     433                 :            :         // such menus will be dealt with when they are encountered
     434                 :            :         // as part of importing the appropriate MenuSpecific toolbar control )
     435                 :            : 
     436                 :            : 
     437         [ #  # ]:          0 :         if ( !(*it).IsMenuToolbar() )
     438                 :            :         {
     439 [ #  # ][ #  # ]:          0 :             if ( !(*it).ImportCustomToolBar( *this, helper ) )
     440                 :          0 :                 return false;
     441                 :            :         }
     442 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
     443                 :         13 :     return true;
     444                 :            : }
     445                 :            : 
     446                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10