LCOV - code coverage report
Current view: top level - basctl/source/basicide - iderdll.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 83 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     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 <comphelper/scoped_disposing_ptr.hxx>
      21                 :            : #include <comphelper/processfactory.hxx>
      22                 :            : 
      23                 :            : #include <svheader.hxx>
      24                 :            : #include <sfx2/app.hxx>
      25                 :            : #include <sfx2/dispatch.hxx>
      26                 :            : #include <sfx2/genlink.hxx>
      27                 :            : 
      28                 :            : #include <svl/solar.hrc>
      29                 :            : #include <iderdll.hxx>
      30                 :            : #include <iderdll2.hxx>
      31                 :            : #include <iderid.hxx>
      32                 :            : #include <svx/svxids.hrc>
      33                 :            : #include <basidesh.hxx>
      34                 :            : #include <basidesh.hrc>
      35                 :            : #include <basobj.hxx>
      36                 :            : #include <bastypes.hxx>
      37                 :            : #include <basdoc.hxx>
      38                 :            : #include <basicmod.hxx>
      39                 :            : #include <propbrw.hxx>
      40                 :            : 
      41                 :            : #include <svl/srchitem.hxx>
      42                 :            : #include <com/sun/star/script/XLibraryContainerPassword.hpp>
      43                 :            : 
      44                 :            : using ::rtl::OUString;
      45                 :            : using namespace ::com::sun::star;
      46                 :            : using namespace ::com::sun::star::uno;
      47                 :            : 
      48                 :            : class BasicIDEDLL
      49                 :            : {
      50                 :            :     BasicIDEShell* m_pShell;
      51                 :            :     BasicIDEData* m_pExtraData;
      52                 :            : 
      53                 :            : public:
      54                 :            :     BasicIDEDLL();
      55                 :            :     ~BasicIDEDLL();
      56                 :            : 
      57                 :          0 :     BasicIDEShell* GetShell() const { return m_pShell; }
      58                 :          0 :     void SetShell(BasicIDEShell* pShell) { m_pShell = pShell; }
      59                 :            :     BasicIDEData* GetExtraData();
      60                 :            : };
      61                 :            : 
      62                 :            : namespace
      63                 :            : {
      64                 :            :     //Holds a BasicIDEDLL and release it on exit, or dispose of the
      65                 :            :     //default XComponent, whichever comes first
      66                 :          0 :     class BasicIDEDLLInstance : public comphelper::scoped_disposing_solar_mutex_reset_ptr<BasicIDEDLL>
      67                 :            :     {
      68                 :            :     public:
      69                 :          0 :         BasicIDEDLLInstance() : comphelper::scoped_disposing_solar_mutex_reset_ptr<BasicIDEDLL>(::com::sun::star::uno::Reference<com::sun::star::lang::XComponent>(comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop"))), ::com::sun::star::uno::UNO_QUERY_THROW), new BasicIDEDLL)
      70                 :            :         {
      71                 :          0 :         }
      72                 :            :     };
      73                 :            : 
      74                 :            :     struct theBasicIDEDLLInstance : public rtl::Static<BasicIDEDLLInstance, theBasicIDEDLLInstance> {};
      75                 :            : }
      76                 :            : 
      77                 :            : namespace BasicIDEGlobals
      78                 :            : {
      79                 :          0 :     void ensure()
      80                 :            :     {
      81                 :          0 :         theBasicIDEDLLInstance::get();
      82                 :          0 :     }
      83                 :            : 
      84                 :          0 :     BasicIDEShell* GetShell()
      85                 :            :     {
      86                 :          0 :         BasicIDEDLL *pIDEGlobals = theBasicIDEDLLInstance::get().get();
      87                 :          0 :         return pIDEGlobals ? pIDEGlobals->GetShell() : NULL;
      88                 :            :     }
      89                 :            : 
      90                 :          0 :     void ShellCreated(BasicIDEShell* pShell)
      91                 :            :     {
      92                 :          0 :         BasicIDEDLL *pIDEGlobals = theBasicIDEDLLInstance::get().get();
      93                 :          0 :         if (pIDEGlobals && pIDEGlobals->GetShell() == NULL)
      94                 :          0 :             pIDEGlobals->SetShell(pShell);
      95                 :          0 :     }
      96                 :            : 
      97                 :          0 :     void ShellDestroyed(BasicIDEShell* pShell)
      98                 :            :     {
      99                 :          0 :         BasicIDEDLL *pIDEGlobals = theBasicIDEDLLInstance::get().get();
     100                 :          0 :         if (pIDEGlobals && pIDEGlobals->GetShell() == pShell)
     101                 :          0 :             pIDEGlobals->SetShell(NULL);
     102                 :          0 :     }
     103                 :            : 
     104                 :          0 :     BasicIDEData* GetExtraData()
     105                 :            :     {
     106                 :          0 :         BasicIDEDLL *pIDEGlobals = theBasicIDEDLLInstance::get().get();
     107                 :          0 :         return pIDEGlobals ? pIDEGlobals->GetExtraData() : NULL;
     108                 :            :     }
     109                 :            : }
     110                 :            : 
     111                 :          0 : IDEResId::IDEResId( sal_uInt16 nId ):
     112                 :          0 :     ResId( nId, *(BASIC_MOD())->GetResMgr() )
     113                 :            : {
     114                 :          0 : }
     115                 :            : 
     116                 :          0 : BasicIDEDLL::~BasicIDEDLL()
     117                 :            : {
     118                 :          0 :     delete m_pExtraData;
     119                 :          0 : }
     120                 :            : 
     121                 :          0 : BasicIDEDLL::BasicIDEDLL()
     122                 :            :     : m_pShell(0)
     123                 :          0 :     , m_pExtraData(0)
     124                 :            : {
     125                 :          0 :     SfxObjectFactory* pFact = &BasicDocShell::Factory();
     126                 :            :     (void)pFact;
     127                 :            : 
     128                 :            :     ResMgr* pMgr = ResMgr::CreateResMgr(
     129                 :          0 :         "basctl", Application::GetSettings().GetUILocale() );
     130                 :            : 
     131                 :          0 :     BASIC_MOD() = new BasicIDEModule( pMgr, &BasicDocShell::Factory() );
     132                 :            : 
     133                 :          0 :     GetExtraData(); // to cause GlobalErrorHdl to be set
     134                 :            : 
     135                 :          0 :     SfxModule* pMod = BASIC_MOD();
     136                 :            : 
     137                 :          0 :     SfxObjectFactory& rFactory = BasicDocShell::Factory();
     138                 :          0 :     rFactory.SetDocumentServiceName( rtl::OUString("com.sun.star.script.BasicIDE") );
     139                 :            : 
     140                 :          0 :     BasicDocShell::RegisterInterface( pMod );
     141                 :          0 :     BasicIDEShell::RegisterFactory( SVX_INTERFACE_BASIDE_VIEWSH );
     142                 :          0 :     BasicIDEShell::RegisterInterface( pMod );
     143                 :            : 
     144                 :          0 :     PropBrwMgr::RegisterChildWindow();
     145                 :          0 : }
     146                 :            : 
     147                 :          0 : BasicIDEData* BasicIDEDLL::GetExtraData()
     148                 :            : {
     149                 :          0 :     if (!m_pExtraData)
     150                 :          0 :         m_pExtraData = new BasicIDEData;
     151                 :          0 :     return m_pExtraData;
     152                 :            : }
     153                 :            : 
     154                 :          0 : BasicIDEData::BasicIDEData()
     155                 :            : {
     156                 :          0 :     nBasicDialogCount = 0;
     157                 :          0 :     bChoosingMacro = false;
     158                 :          0 :     bShellInCriticalSection = false;
     159                 :          0 :     pSearchItem = new SvxSearchItem( SID_SEARCH_ITEM );
     160                 :            : 
     161                 :          0 :     StarBASIC::SetGlobalBreakHdl( LINK( this, BasicIDEData, GlobalBasicBreakHdl ) );
     162                 :          0 : }
     163                 :            : 
     164                 :          0 : BasicIDEData::~BasicIDEData()
     165                 :            : {
     166                 :            :     // Resetting ErrorHdl is cleaner indeed but this instance is destroyed
     167                 :            :     // pretty late, after the last Basic, anyway.
     168                 :            :     // Due to the call there is AppData created then though and not
     169                 :            :     // destroyed anymore => MLK's at Purify
     170                 :            : //  StarBASIC::SetGlobalErrorHdl( Link() );
     171                 :            : //  StarBASIC::SetGlobalBreakHdl( Link() );
     172                 :            : //  StarBASIC::setGlobalStarScriptListener( XEngineListenerRef() );
     173                 :            : 
     174                 :          0 :     delete pSearchItem;
     175                 :          0 : }
     176                 :            : 
     177                 :          0 : SvxSearchItem& BasicIDEData::GetSearchItem() const
     178                 :            : {
     179                 :          0 :     return *pSearchItem;
     180                 :            : }
     181                 :            : 
     182                 :          0 : void BasicIDEData::SetSearchItem( const SvxSearchItem& rItem )
     183                 :            : {
     184                 :          0 :     delete pSearchItem;
     185                 :          0 :     pSearchItem = (SvxSearchItem*)rItem.Clone();
     186                 :          0 : }
     187                 :            : 
     188                 :          0 : IMPL_LINK( BasicIDEData, GlobalBasicBreakHdl, StarBASIC *, pBasic )
     189                 :            : {
     190                 :          0 :     long nRet = 0;
     191                 :          0 :     BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
     192                 :          0 :     if ( pIDEShell )
     193                 :            :     {
     194                 :          0 :         BasicManager* pBasMgr = BasicIDE::FindBasicManager( pBasic );
     195                 :          0 :         if ( pBasMgr )
     196                 :            :         {
     197                 :            :             // I do get here twice if Step into protected Basic
     198                 :            :             // => bad, if password query twice, also you don't see
     199                 :            :             // the lib in the PasswordDlg...
     200                 :            :             // => start no password query at this point
     201                 :          0 :             ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
     202                 :            :             OSL_ENSURE( aDocument.isValid(), "BasicIDEData::GlobalBasicBreakHdl: no document for the basic manager!" );
     203                 :          0 :             if ( aDocument.isValid() )
     204                 :            :             {
     205                 :          0 :                 ::rtl::OUString aOULibName( pBasic->GetName() );
     206                 :          0 :                 Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
     207                 :          0 :                 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) )
     208                 :            :                 {
     209                 :          0 :                     Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY );
     210                 :          0 :                     if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) )
     211                 :            :                     {
     212                 :            :                            // a step-out should get me out of the protected area...
     213                 :          0 :                         nRet = SbDEBUG_STEPOUT;
     214                 :            :                     }
     215                 :            :                     else
     216                 :            :                     {
     217                 :          0 :                           nRet = pIDEShell->CallBasicBreakHdl( pBasic );
     218                 :          0 :                     }
     219                 :          0 :                 }
     220                 :          0 :             }
     221                 :            :         }
     222                 :            :     }
     223                 :            : 
     224                 :          0 :     return nRet;
     225                 :            : }
     226                 :            : 
     227                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10