LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/appl - appbas.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 64 10.9 %
Date: 2012-12-27 Functions: 4 10 40.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 <com/sun/star/frame/XDesktop.hpp>
      21             : #include <com/sun/star/script/XLibraryContainer.hpp>
      22             : #include <com/sun/star/uno/Reference.h>
      23             : #include <basic/basrdll.hxx>
      24             : #include <officecfg/Office/Common.hxx>
      25             : #include <svl/macitem.hxx>
      26             : #include <basic/sbxfac.hxx>
      27             : #include <basic/sbx.hxx>
      28             : #include <vcl/gradient.hxx>
      29             : #include <svl/rectitem.hxx>
      30             : #include <svl/intitem.hxx>
      31             : #include <svl/eitem.hxx>
      32             : #include <basic/sbmod.hxx>
      33             : #include <svl/whiter.hxx>
      34             : #include <basic/sbmeth.hxx>
      35             : #include <basic/sbstar.hxx>
      36             : #include <vcl/wrkwin.hxx>
      37             : #include <vcl/msgbox.hxx>
      38             : #include <basic/sbuno.hxx>
      39             : #include <svtools/sfxecode.hxx>
      40             : #include <svtools/ehdl.hxx>
      41             : 
      42             : #include <unotools/pathoptions.hxx>
      43             : #include <unotools/useroptions.hxx>
      44             : #include <unotools/bootstrap.hxx>
      45             : 
      46             : #include <sfx2/appuno.hxx>
      47             : #include <sfx2/module.hxx>
      48             : #include "arrdecl.hxx"
      49             : #include <sfx2/app.hxx>
      50             : #include "sfxtypes.hxx"
      51             : #include "sfx2/sfxresid.hxx"
      52             : #include <sfx2/msg.hxx>
      53             : #include <sfx2/msgpool.hxx>
      54             : #include <sfx2/progress.hxx>
      55             : #include <sfx2/objsh.hxx>
      56             : #include <sfx2/objitem.hxx>
      57             : #include <sfx2/viewfrm.hxx>
      58             : #include <sfx2/viewsh.hxx>
      59             : #include <sfx2/dispatch.hxx>
      60             : #include "sfx2/tplpitem.hxx"
      61             : #include "sfx2/minfitem.hxx"
      62             : #include "app.hrc"
      63             : #include <sfx2/evntconf.hxx>
      64             : #include <sfx2/request.hxx>
      65             : #include <sfx2/dinfdlg.hxx>
      66             : #include "appdata.hxx"
      67             : #include "appbas.hxx"
      68             : #include "sfx2/sfxhelp.hxx"
      69             : #include "sfx2/basmgr.hxx"
      70             : #include "sorgitm.hxx"
      71             : #include "appbaslib.hxx"
      72             : #include <basic/basicmanagerrepository.hxx>
      73             : 
      74             : #define ITEMID_SEARCH SID_SEARCH_ITEM
      75             : 
      76             : #include <svl/srchitem.hxx>
      77             : #include <osl/socket.hxx>
      78             : 
      79             : #if defined(LIBO_MERGELIBS) || defined(IOS)
      80             : /* Avoid clash with the ones from svx/source/form/typemap.cxx */
      81             : #define aSfxBoolItem_Impl sfx2_source_appl_appbas_aSfxBoolItem_Impl
      82             : #ifdef IOS
      83             : #define aSfxInt16Item_Impl sfx2_source_appl_appbas_aSfxInt16Item_Impl
      84             : #endif
      85             : #define aSfxStringItem_Impl sfx2_source_appl_appbas_aSfxStringItem_Impl
      86             : #define aSfxUInt16Item_Impl sfx2_source_appl_appbas_aSfxUInt16Item_Impl
      87             : #define aSfxUInt32Item_Impl sfx2_source_appl_appbas_aSfxUInt32Item_Impl
      88             : #define aSfxVoidItem_Impl sfx2_source_appl_appbas_aSfxVoidtem_Impl
      89             : #endif
      90             : 
      91             : #define SFX_TYPEMAP
      92             : #define Selection
      93             : #include "sfxslots.hxx"
      94             : 
      95             : #if defined(LIBO_MERGELIBS) || defined(IOS)
      96             : #undef aSfxBoolItem_Impl
      97             : #ifdef IOS
      98             : #undef aSfxInt16Item_Impl
      99             : #endif
     100             : #undef aSfxStringItem_Impl
     101             : #undef aSfxUInt16Item_Impl
     102             : #undef aSfxUInt32Item_Impl
     103             : #undef aSfxVoidItem_Impl
     104             : #endif
     105             : 
     106             : using namespace ::com::sun::star;
     107             : using namespace ::com::sun::star::uno;
     108             : using namespace ::com::sun::star::frame;
     109             : using namespace ::com::sun::star::script;
     110             : 
     111             : using ::basic::BasicManagerRepository;
     112             : 
     113             : //=========================================================================
     114           0 : sal_uInt16 SfxApplication::SaveBasicAndDialogContainer() const
     115             : {
     116           0 :     if ( pAppData_Impl->pBasicManager->isValid() )
     117           0 :         pAppData_Impl->pBasicManager->storeAllLibraries();
     118           0 :     return 0;
     119             : }
     120             : 
     121             : //--------------------------------------------------------------------
     122             : 
     123           0 : SbxVariable* MakeVariable( StarBASIC *pBas, SbxObject *pObject,
     124             :            const char *pName, sal_uInt32 nSID, SbxDataType eType, SbxClassType eClassType )
     125             : {
     126             : #ifdef DISABLE_SCRIPTING
     127             :     (void) pBas;
     128             :     (void) pObject;
     129             :     (void) pName;
     130             :     (void) nSID;
     131             :     (void) eType;
     132             :     (void) eClassType;
     133             :     return 0;
     134             : #else
     135           0 :     SbxVariable *pVar = pBas->Make( rtl::OUString::createFromAscii(pName), eClassType, eType ); //SbxCLASS_PROPERTY
     136           0 :     pVar->SetUserData( nSID );
     137           0 :     pVar->SetFlag( SBX_DONTSTORE );
     138           0 :     pObject->StartListening( pVar->GetBroadcaster() );
     139           0 :     return pVar;
     140             : #endif
     141             : }
     142             : 
     143             : //--------------------------------------------------------------------
     144             : 
     145         466 : BasicManager* SfxApplication::GetBasicManager()
     146             : {
     147             : #ifdef DISABLE_SCRIPTING
     148             :     return 0;
     149             : #else
     150         466 :     return BasicManagerRepository::getApplicationBasicManager( true );
     151             : #endif
     152             : }
     153             : 
     154             : //--------------------------------------------------------------------
     155             : 
     156           0 : Reference< XLibraryContainer > SfxApplication::GetDialogContainer()
     157             : {
     158             : #ifdef DISABLE_SCRIPTING
     159             :     Reference< XLibraryContainer >  dummy;
     160             :     return dummy;
     161             : #else
     162           0 :     if ( !pAppData_Impl->pBasicManager->isValid() )
     163           0 :         GetBasicManager();
     164           0 :     return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::DIALOGS );
     165             : #endif
     166             : }
     167             : 
     168             : //--------------------------------------------------------------------
     169             : 
     170           3 : Reference< XLibraryContainer > SfxApplication::GetBasicContainer()
     171             : {
     172             : #ifdef DISABLE_SCRIPTING
     173             :     Reference< XLibraryContainer >  dummy;
     174             :     return dummy;
     175             : #else
     176           3 :     if ( !pAppData_Impl->pBasicManager->isValid() )
     177           1 :         GetBasicManager();
     178           3 :     return pAppData_Impl->pBasicManager->getLibraryContainer( SfxBasicManagerHolder::SCRIPTS );
     179             : #endif
     180             : }
     181             : 
     182             : //--------------------------------------------------------------------
     183             : 
     184           0 : StarBASIC* SfxApplication::GetBasic()
     185             : {
     186             : #ifdef DISABLE_SCRIPTING
     187             :     return 0;
     188             : #else
     189           0 :     return GetBasicManager()->GetLib(0);
     190             : #endif
     191             : }
     192             : 
     193             : //-------------------------------------------------------------------------
     194           0 : void SfxApplication::PropExec_Impl( SfxRequest &rReq )
     195             : {
     196             : #ifdef DISABLE_SCRIPTING
     197             :     (void) rReq;
     198             : #else
     199           0 :     rReq.GetArgs();
     200           0 :     sal_uInt16 nSID = rReq.GetSlot();
     201           0 :     switch ( nSID )
     202             :     {
     203             :         case SID_CREATE_BASICOBJECT:
     204             :         {
     205           0 :             SFX_REQUEST_ARG(rReq, pItem, SfxStringItem, nSID, sal_False);
     206           0 :             if ( pItem )
     207             :             {
     208           0 :                 SbxObject* pObject = SbxBase::CreateObject( pItem->GetValue() );
     209           0 :                 pObject->AddRef();
     210           0 :                 rReq.Done();
     211             :             }
     212           0 :             break;
     213             :         }
     214             : 
     215             :         case SID_DELETE_BASICOBJECT:
     216             :         {
     217           0 :             break;
     218             :         }
     219             : 
     220             :         case SID_ATTR_UNDO_COUNT:
     221             :         {
     222           0 :             SFX_REQUEST_ARG(rReq, pCountItem, SfxUInt16Item, nSID, sal_False);
     223             :             boost::shared_ptr< comphelper::ConfigurationChanges > batch(
     224           0 :                 comphelper::ConfigurationChanges::create());
     225             :             officecfg::Office::Common::Undo::Steps::set(
     226           0 :                 pCountItem->GetValue(), batch);
     227           0 :             batch->commit();
     228           0 :             break;
     229             :         }
     230             : 
     231             :         case SID_WIN_VISIBLE:
     232             :         {
     233           0 :             break;
     234             :         }
     235             : 
     236             :         case SID_OFFICE_CUSTOMERNUMBER:
     237             :         {
     238           0 :             SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, nSID, sal_False);
     239             : 
     240           0 :             if ( pStringItem )
     241           0 :                 SvtUserOptions().SetCustomerNumber( pStringItem->GetValue() );
     242           0 :             break;
     243             :         }
     244             :     }
     245             : #endif
     246           0 : }
     247             : 
     248             : //-------------------------------------------------------------------------
     249           0 : void SfxApplication::PropState_Impl( SfxItemSet &rSet )
     250             : {
     251             : #ifdef DISABLE_SCRIPTING
     252             :     (void) rSet;
     253             : #else
     254           0 :     SfxWhichIter aIter(rSet);
     255           0 :     for ( sal_uInt16 nSID = aIter.FirstWhich(); nSID; nSID = aIter.NextWhich() )
     256             :     {
     257           0 :         switch ( nSID )
     258             :         {
     259             :             case SID_PROGNAME:
     260           0 :                 rSet.Put( SfxStringItem( SID_PROGNAME, GetName() ) );
     261           0 :                 break;
     262             : 
     263             :             case SID_ACTIVEDOCUMENT:
     264           0 :                 rSet.Put( SfxObjectItem( SID_ACTIVEDOCUMENT, SfxObjectShell::Current() ) );
     265           0 :                 break;
     266             : 
     267             :             case SID_APPLICATION:
     268           0 :                 rSet.Put( SfxObjectItem( SID_APPLICATION, this ) );
     269           0 :                 break;
     270             : 
     271             :             case SID_PROGFILENAME:
     272           0 :                 rSet.Put( SfxStringItem( SID_PROGFILENAME, Application::GetAppFileName() ) );
     273           0 :                 break;
     274             : 
     275             :             case SID_ATTR_UNDO_COUNT:
     276             :                 rSet.Put(
     277             :                     SfxUInt16Item(
     278             :                         SID_ATTR_UNDO_COUNT,
     279           0 :                         officecfg::Office::Common::Undo::Steps::get()));
     280           0 :                 break;
     281             : 
     282             :             case SID_UPDATE_VERSION:
     283           0 :                 rSet.Put( SfxUInt32Item( SID_UPDATE_VERSION, SUPD ) );
     284           0 :                 break;
     285             : 
     286             :             case SID_OFFICE_CUSTOMERNUMBER:
     287             :             {
     288           0 :                 rSet.Put( SfxStringItem( nSID, SvtUserOptions().GetCustomerNumber() ) );
     289           0 :                 break;
     290             :             }
     291             :         }
     292           0 :     }
     293             : #endif
     294          66 : }
     295             : 
     296             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10