1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: iderdll.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basctl.hxx"
35 #include <ide_pch.hxx>
38 #include <svheader.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/dispatch.hxx>
41 #include <sfx2/genlink.hxx>
44 #include <svtools/solar.hrc>
45 #include <iderdll.hxx>
46 #include <iderdll2.hxx>
48 #include <svx/svxids.hrc>
49 #include <basidesh.hxx>
50 #include <basidesh.hrc>
52 #include <bastypes.hxx>
54 #include <basicmod.hxx>
55 #include <propbrw.hxx>
58 #define ITEMID_SEARCH 0
59 #include <svx/srchitem.hxx>
60 #include <com/sun/star/script/XLibraryContainerPassword.hpp>
62 using ::rtl::OUString
;
63 using namespace ::com::sun::star
;
64 using namespace ::com::sun::star::uno
;
67 static BasicIDEDLL
* pBasicIDEDLL
= 0;
69 BasicIDEDLL
* BasicIDEDLL::GetDLL()
74 IDEResId::IDEResId( USHORT nId
):
75 ResId( nId
, *(*(BasicIDEModule
**)GetAppData(SHL_IDE
))->GetResMgr() )
79 BasicIDEDLL::BasicIDEDLL()
85 GetExtraData(); // damit GlobalErrorHdl gesetzt wird.
88 BasicIDEDLL::~BasicIDEDLL()
91 *(BasicIDEDLL
**)GetAppData(SHL_IDE
) = NULL
;
94 void BasicIDEDLL::Init()
99 SfxObjectFactory
* pFact
= &BasicDocShell::Factory();
102 ByteString
aResMgrName( "basctl" );
103 ResMgr
* pMgr
= ResMgr::CreateResMgr(
104 aResMgrName
.GetBuffer(), Application::GetSettings().GetUILocale() );
106 BASIC_MOD() = new BasicIDEModule( pMgr
, &BasicDocShell::Factory() );
109 SfxModule
* pMod
= BASIC_MOD();
111 SfxObjectFactory
& rFactory
= BasicDocShell::Factory();
112 rFactory
.SetDocumentServiceName( String::CreateFromAscii( "com.sun.star.script.BasicIDE" ) );
114 BasicDocShell::RegisterInterface( pMod
);
115 BasicIDEShell::RegisterFactory( SVX_INTERFACE_BASIDE_VIEWSH
);
116 BasicIDEShell::RegisterInterface( pMod
);
118 PropBrwMgr::RegisterChildWindow();
121 /*************************************************************************
125 \************************************************************************/
126 void BasicIDEDLL::Exit()
128 // the BasicIDEModule must be destroyed
129 BasicIDEModule
** ppShlPtr
= (BasicIDEModule
**) GetAppData(SHL_IDE
);
132 DELETEZ( pBasicIDEDLL
);
135 BasicIDEData
* BasicIDEDLL::GetExtraData()
138 pExtraData
= new BasicIDEData
;
142 BasicIDEData::BasicIDEData() : aObjCatPos( INVPOSITION
, INVPOSITION
)
144 nBasicDialogCount
= 0;
145 bChoosingMacro
= FALSE
;
146 bShellInCriticalSection
= FALSE
;
147 pSearchItem
= new SvxSearchItem( SID_SEARCH_ITEM
);
149 StarBASIC::SetGlobalBreakHdl( LINK( this, BasicIDEData
, GlobalBasicBreakHdl
) );
154 BasicIDEData::~BasicIDEData()
156 // ErrorHdl zuruecksetzen ist zwar sauberer, aber diese Instanz wird
157 // sowieso sehr spaet, nach dem letzten Basic, zerstoert.
158 // Durch den Aufruf werden dann aber wieder AppDaten erzeugt und nicht
159 // mehr zerstoert => MLK's beim Purify
160 // StarBASIC::SetGlobalErrorHdl( Link() );
161 // StarBASIC::SetGlobalBreakHdl( Link() );
162 // StarBASIC::setGlobalStarScriptListener( XEngineListenerRef() );
165 //delete pAccelerator;
168 SvxSearchItem
& BasicIDEData::GetSearchItem() const
173 void BasicIDEData::SetSearchItem( const SvxSearchItem
& rItem
)
176 pSearchItem
= (SvxSearchItem
*)rItem
.Clone();
179 IMPL_LINK( BasicIDEData
, GlobalBasicBreakHdl
, StarBASIC
*, pBasic
)
182 BasicIDEShell
* pIDEShell
= IDE_DLL()->GetShell();
185 BasicManager
* pBasMgr
= BasicIDE::FindBasicManager( pBasic
);
188 // Hier lande ich zweimal, wenn Step into protected Basic
189 // => schlecht, wenn Passwortabfrage 2x, ausserdem sieht man in
190 // dem PasswordDlg nicht, fuer welche Lib...
191 // => An dieser Stelle keine Passwort-Abfrage starten
192 ScriptDocument
aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr
) );
193 OSL_ENSURE( aDocument
.isValid(), "BasicIDEData::GlobalBasicBreakHdl: no document for the basic manager!" );
194 if ( aDocument
.isValid() )
196 ::rtl::OUString
aOULibName( pBasic
->GetName() );
197 Reference
< script::XLibraryContainer
> xModLibContainer( aDocument
.getLibraryContainer( E_SCRIPTS
), UNO_QUERY
);
198 if ( xModLibContainer
.is() && xModLibContainer
->hasByName( aOULibName
) )
200 Reference
< script::XLibraryContainerPassword
> xPasswd( xModLibContainer
, UNO_QUERY
);
201 if ( xPasswd
.is() && xPasswd
->isLibraryPasswordProtected( aOULibName
) && !xPasswd
->isLibraryPasswordVerified( aOULibName
) )
203 // Ein Step-Out muesste mich aus den geschuetzten Bereich befoerdern...
204 nRet
= SbDEBUG_STEPOUT
;
208 nRet
= pIDEShell
->CallBasicBreakHdl( pBasic
);
218 IMPL_LINK( BasicIDEData
, ExecuteMacroEvent
, void *, pData
)
222 SFX_APP()->EnterBasicCall();
223 SbMethod
* pMethod
= (SbMethod
*)pData
;
225 // Ist es eine StarScript-Methode? Am Parent erkennen
226 DBG_ASSERT( pMethod
->GetParent()->GetFlags() & SBX_EXTSEARCH
, "Kein EXTSEARCH!" );
227 BasicIDE::RunMethod( pMethod
);
228 pMethod
->ReleaseRef(); // muss vorher inkrementiert worden sein!
229 SFX_APP()->LeaveBasicCall();