Bug Summary

File:home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx
Warning:line 122, column 36
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name basobj3.cxx -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/11.0.0 -D BOOST_ERROR_CODE_HEADER_ONLY -D BOOST_SYSTEM_NO_DEPRECATED -D CPPU_ENV=gcc3 -D LINUX -D OSL_DEBUG_LEVEL=1 -D SAL_LOG_INFO -D SAL_LOG_WARN -D UNIX -D UNX -D X86_64 -D _PTHREADS -D _REENTRANT -D EXCEPTIONS_ON -D LIBO_INTERNAL_ONLY -I /home/maarten/src/libreoffice/core/external/boost/include -I /home/maarten/src/libreoffice/core/workdir/UnpackedTarball/boost -I /home/maarten/src/libreoffice/core/basctl/inc -I /home/maarten/src/libreoffice/core/basctl/sdi -I /home/maarten/src/libreoffice/core/basctl/source/inc -I /home/maarten/src/libreoffice/core/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include -I /usr/lib/jvm/java-11-openjdk-11.0.9.10-0.0.ea.fc33.x86_64/include/linux -I /home/maarten/src/libreoffice/core/config_host -I /home/maarten/src/libreoffice/core/workdir/SdiTarget/basctl/sdi -I /home/maarten/src/libreoffice/core/workdir/CustomTarget/officecfg/registry -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/udkapi/normal -I /home/maarten/src/libreoffice/core/workdir/UnoApiHeadersTarget/offapi/normal -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/11.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-missing-braces -std=c++17 -fdeprecated-macro -fdebug-compilation-dir /home/maarten/src/libreoffice/core -ferror-limit 19 -fvisibility hidden -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -debug-info-kind=constructor -analyzer-output=html -faddrsig -o /home/maarten/tmp/wis/scan-build-libreoffice/output/report/2020-10-07-141433-9725-1 -x c++ /home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx
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 <vcl/errinf.hxx>
21#include <vcl/svapp.hxx>
22#include <vcl/weld.hxx>
23#include <basic/basmgr.hxx>
24#include <basic/sbmeth.hxx>
25#include <unotools/moduleoptions.hxx>
26
27#include <iderdll.hxx>
28#include "iderdll2.hxx"
29#include "basdoc.hxx"
30#include <iderid.hxx>
31#include <strings.hrc>
32
33#include <baside3.hxx>
34#include <basidesh.hxx>
35#include <basobj.hxx>
36#include <localizationmgr.hxx>
37#include <dlged.hxx>
38#include <com/sun/star/script/XLibraryContainerPassword.hpp>
39#include <sfx2/app.hxx>
40#include <sfx2/dispatch.hxx>
41#include <sfx2/sfxsids.hrc>
42#include <sfx2/request.hxx>
43#include <sfx2/viewfrm.hxx>
44#include <sal/log.hxx>
45#include <osl/diagnose.h>
46#include <tools/debug.hxx>
47
48namespace basctl
49{
50
51using namespace comphelper;
52using namespace ::com::sun::star;
53using namespace ::com::sun::star::uno;
54using namespace ::com::sun::star::container;
55
56extern "C" {
57 SAL_DLLPUBLIC_EXPORT__attribute__ ((visibility("default"))) long basicide_handle_basic_error( void const * pPtr )
58 {
59 return HandleBasicError( static_cast<StarBASIC const *>(pPtr) );
60 }
61}
62
63SbMethod* CreateMacro( SbModule* pModule, const OUString& rMacroName )
64{
65 SfxDispatcher* pDispatcher = GetDispatcher();
66 if( pDispatcher
0.1
'pDispatcher' is null
)
1
Taking false branch
67 {
68 pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES( (30000 + 768) + 16 ) );
69 }
70
71 if ( pModule->FindMethod( rMacroName, SbxClassType::Method ) )
2
Value assigned to field 'pParent'
3
Assuming the condition is false
4
Taking false branch
72 return nullptr;
73
74 OUString aMacroName( rMacroName );
75 if ( aMacroName.isEmpty() )
5
Taking false branch
76 {
77 if ( !pModule->GetMethods()->Count32() )
78 aMacroName = "Main" ;
79 else
80 {
81 bool bValid = false;
82 sal_Int32 nMacro = 1;
83 while ( !bValid )
84 {
85 aMacroName = "Macro" + OUString::number( nMacro );
86 // test whether existing...
87 bValid = pModule->FindMethod( aMacroName, SbxClassType::Method ) == nullptr;
88 nMacro++;
89 }
90 }
91 }
92
93 OUString aOUSource( pModule->GetSource32() );
94
95 // don't produce too many empty lines...
96 sal_Int32 nSourceLen = aOUSource.getLength();
97 if ( nSourceLen > 2 )
6
Assuming 'nSourceLen' is <= 2
7
Taking false branch
98 {
99 const sal_Unicode* pStr = aOUSource.getStr();
100 if ( pStr[ nSourceLen - 1 ] != LINE_SEP0x0A )
101 aOUSource += "\n\n" ;
102 else if ( pStr[ nSourceLen - 2 ] != LINE_SEP0x0A )
103 aOUSource += "\n" ;
104 else if ( pStr[ nSourceLen - 3 ] == LINE_SEP0x0A )
105 aOUSource = aOUSource.copy( 0, nSourceLen-1 );
106 }
107
108 OUString aSubStr = "Sub " + aMacroName + "\n\nEnd Sub";
109
110 aOUSource += aSubStr;
111
112 // update module in library
113 StarBASIC* pBasic = dynamic_cast<StarBASIC*>(pModule->GetParent());
8
'pBasic' initialized here
114 BasicManager* pBasMgr = pBasic ? FindBasicManager(pBasic) : nullptr;
9
Assuming 'pBasic' is null
10
'?' condition is false
115 SAL_WARN_IF(!pBasMgr, "basctl.basicide", "No BasicManager found!")do { if (true && (!pBasMgr)) { switch (sal_detail_log_report
(::SAL_DETAIL_LOG_LEVEL_WARN, "basctl.basicide")) { case SAL_DETAIL_LOG_ACTION_IGNORE
: break; case SAL_DETAIL_LOG_ACTION_LOG: if (sizeof ::sal::detail
::getResult( ::sal::detail::StreamStart() << "No BasicManager found!"
) == 1) { ::sal_detail_log( (::SAL_DETAIL_LOG_LEVEL_WARN), ("basctl.basicide"
), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "115" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "No BasicManager found!"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"No BasicManager found!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("basctl.basicide"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "115" ": "), sal_detail_stream, 0); }; break; case SAL_DETAIL_LOG_ACTION_FATAL
: if (sizeof ::sal::detail::getResult( ::sal::detail::StreamStart
() << "No BasicManager found!") == 1) { ::sal_detail_log
( (::SAL_DETAIL_LOG_LEVEL_WARN), ("basctl.basicide"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "115" ": "), ::sal::detail::unwrapStream( ::sal::detail::
StreamStart() << "No BasicManager found!"), 0); } else {
::std::ostringstream sal_detail_stream; sal_detail_stream <<
"No BasicManager found!"; ::sal::detail::log( (::SAL_DETAIL_LOG_LEVEL_WARN
), ("basctl.basicide"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "115" ": "), sal_detail_stream, 0); }; std::abort(); break
; } } } while (false)
;
11
Taking true branch
12
'Default' branch taken. Execution continues on line 115
13
Loop condition is false. Exiting loop
116 ScriptDocument aDocument = pBasMgr
13.1
'pBasMgr' is null
14
'?' condition is false
117 ? ScriptDocument::getDocumentForBasicManager(pBasMgr) 118 : ScriptDocument(ScriptDocument::NoDocument); 119 120 if (aDocument.isValid())
15
Assuming the condition is true
16
Taking true branch
121 { 122 const OUString& aLibName = pBasic->GetName();
17
Called C++ object pointer is null
123 const OUString& aModName = pModule->GetName(); 124 OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aOUSource ) )do { if (!(aDocument.updateModule( aLibName, aModName, aOUSource
))) do { if (true && (!(0))) { sal_detail_logFormat(
(SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "124" ": "), "OSL_ASSERT: %s", "0"); } } while (false); }
while (0)
; 125 } 126 127 SbMethod* pMethod = pModule->FindMethod( aMacroName, SbxClassType::Method ); 128 129 if( pDispatcher ) 130 { 131 pDispatcher->Execute( SID_BASICIDE_UPDATEALLMODULESOURCES( (30000 + 768) + 17 ) ); 132 } 133 134 if (aDocument.isAlive()) 135 MarkDocumentModified(aDocument); 136 137 return pMethod; 138} 139 140bool RenameDialog ( 141 weld::Widget* pErrorParent, 142 ScriptDocument const& rDocument, 143 OUString const& rLibName, 144 OUString const& rOldName, 145 OUString const& rNewName 146) 147{ 148 if ( !rDocument.hasDialog( rLibName, rOldName ) ) 149 { 150 OSL_FAIL( "basctl::RenameDialog: old module name is invalid!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "150" ": "), "%s", "basctl::RenameDialog: old module name is invalid!"
); } } while (false)
; 151 return false; 152 } 153 154 if ( rDocument.hasDialog( rLibName, rNewName ) ) 155 { 156 std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(pErrorParent, 157 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2reinterpret_cast<char const *>("RID_STR_SBXNAMEALLREADYUSED2"
"\004" u8"Object with same name already exists")
))); 158 xError->run(); 159 return false; 160 } 161 162 // #i74440 163 if ( rNewName.isEmpty() ) 164 { 165 std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(pErrorParent, 166 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAMEreinterpret_cast<char const *>("RID_STR_BADSBXNAME" "\004"
u8"Invalid Name")
))); 167 xError->run(); 168 return false; 169 } 170 171 Shell* pShell = GetShell(); 172 VclPtr<DialogWindow> pWin = pShell ? pShell->FindDlgWin(rDocument, rLibName, rOldName) : nullptr; 173 Reference< XNameContainer > xExistingDialog; 174 if ( pWin ) 175 xExistingDialog = pWin->GetEditor().GetDialog(); 176 177 if ( xExistingDialog.is() ) 178 LocalizationMgr::renameStringResourceIDs( rDocument, rLibName, rNewName, xExistingDialog ); 179 180 if ( !rDocument.renameDialog( rLibName, rOldName, rNewName, xExistingDialog ) ) 181 return false; 182 183 if (pWin && pShell) 184 { 185 // set new name in window 186 pWin->SetName( rNewName ); 187 188 // update property browser 189 pWin->UpdateBrowser(); 190 191 // update tabwriter 192 sal_uInt16 nId = pShell->GetWindowId( pWin ); 193 DBG_ASSERT( nId, "No entry in Tabbar!" )do { if (true && (!(nId))) { sal_detail_logFormat((SAL_DETAIL_LOG_LEVEL_WARN
), ("legacy.tools"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "193" ": "), "%s", "No entry in Tabbar!"); } } while (false
)
; 194 if ( nId ) 195 { 196 TabBar& rTabBar = pShell->GetTabBar(); 197 rTabBar.SetPageText( nId, rNewName ); 198 rTabBar.Sort(); 199 rTabBar.MakeVisible( rTabBar.GetCurPageId() ); 200 } 201 } 202 return true; 203} 204 205bool RemoveDialog( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rDlgName ) 206{ 207 if (Shell* pShell = GetShell()) 208 { 209 if (VclPtr<DialogWindow> pDlgWin = pShell->FindDlgWin(rDocument, rLibName, rDlgName)) 210 { 211 Reference< container::XNameContainer > xDialogModel = pDlgWin->GetDialog(); 212 LocalizationMgr::removeResourceForDialog( rDocument, rLibName, rDlgName, xDialogModel ); 213 } 214 } 215 216 return rDocument.removeDialog( rLibName, rDlgName ); 217} 218 219StarBASIC* FindBasic( const SbxVariable* pVar ) 220{ 221 SbxVariable const* pSbx = pVar; 222 while (pSbx && !dynamic_cast<StarBASIC const*>(pSbx)) 223 pSbx = pSbx->GetParent(); 224 return const_cast<StarBASIC*>(static_cast<const StarBASIC*>(pSbx)); 225} 226 227BasicManager* FindBasicManager( StarBASIC const * pLib ) 228{ 229 ScriptDocuments aDocuments( ScriptDocument::getAllScriptDocuments( ScriptDocument::AllWithApplication ) ); 230 for (auto const& doc : aDocuments) 231 { 232 BasicManager* pBasicMgr = doc.getBasicManager(); 233 OSL_ENSURE( pBasicMgr, "basctl::FindBasicManager: no basic manager for the document!" )do { if (true && (!(pBasicMgr))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "233" ": "), "%s", "basctl::FindBasicManager: no basic manager for the document!"
); } } while (false)
; 234 if ( !pBasicMgr ) 235 continue; 236 237 Sequence< OUString > aLibNames( doc.getLibraryNames() ); 238 sal_Int32 nLibCount = aLibNames.getLength(); 239 const OUString* pLibNames = aLibNames.getConstArray(); 240 241 for ( sal_Int32 i = 0 ; i < nLibCount ; i++ ) 242 { 243 StarBASIC* pL = pBasicMgr->GetLib( pLibNames[ i ] ); 244 if ( pL == pLib ) 245 return pBasicMgr; 246 } 247 } 248 return nullptr; 249} 250 251void MarkDocumentModified( const ScriptDocument& rDocument ) 252{ 253 Shell* pShell = GetShell(); 254 255 // does not have to come from a document... 256 if ( rDocument.isApplication() ) 257 { 258 if (pShell) 259 pShell->SetAppBasicModified(true); 260 } 261 else 262 { 263 rDocument.setDocumentModified(); 264 } 265 266 // tdf#130161 in all cases call UpdateObjectCatalog 267 if (pShell) 268 pShell->UpdateObjectCatalog(); 269 270 if (SfxBindings* pBindings = GetBindingsPtr()) 271 { 272 pBindings->Invalidate( SID_SIGNATURE(5000 + 1643) ); 273 pBindings->Invalidate( SID_SAVEDOC(5000 + 505) ); 274 pBindings->Update( SID_SAVEDOC(5000 + 505) ); 275 } 276} 277 278void RunMethod( SbMethod const * pMethod ) 279{ 280 SbxValues aRes; 281 aRes.eType = SbxVOID; 282 pMethod->Get( aRes ); 283} 284 285void StopBasic() 286{ 287 StarBASIC::Stop(); 288 if (Shell* pShell = GetShell()) 289 { 290 Shell::WindowTable& rWindows = pShell->GetWindowTable(); 291 for (auto const& window : rWindows) 292 { 293 BaseWindow* pWin = window.second; 294 // call BasicStopped manually because the Stop-Notify 295 // might not get through otherwise 296 pWin->BasicStopped(); 297 } 298 } 299 BasicStopped(); 300} 301 302void BasicStopped( 303 bool* pbAppWindowDisabled, 304 bool* pbDispatcherLocked, 305 sal_uInt16* pnWaitCount, 306 SfxUInt16Item** ppSWActionCount, SfxUInt16Item** ppSWLockViewCount 307) 308{ 309 // maybe there are some locks to be removed after an error 310 // or an explicit cancelling of the basic... 311 if ( pbAppWindowDisabled ) 312 *pbAppWindowDisabled = false; 313 if ( pbDispatcherLocked ) 314 *pbDispatcherLocked = false; 315 if ( pnWaitCount ) 316 *pnWaitCount = 0; 317 if ( ppSWActionCount ) 318 *ppSWActionCount = nullptr; 319 if ( ppSWLockViewCount ) 320 *ppSWLockViewCount = nullptr; 321 322 // AppWait? 323 if (Shell* pShell = GetShell()) 324 { 325 sal_uInt16 nWait = 0; 326 while ( pShell->GetViewFrame()->GetWindow().IsWait() ) 327 { 328 pShell->GetViewFrame()->GetWindow().LeaveWait(); 329 nWait++; 330 } 331 if ( pnWaitCount ) 332 *pnWaitCount = nWait; 333 } 334 335 vcl::Window* pDefParent = Application::GetDefDialogParent(); 336 if ( pDefParent && !pDefParent->IsEnabled() ) 337 { 338 pDefParent->Enable(); 339 if ( pbAppWindowDisabled ) 340 *pbAppWindowDisabled = true; 341 } 342 343} 344 345void InvalidateDebuggerSlots() 346{ 347 SfxBindings* pBindings = GetBindingsPtr(); 348 if (!pBindings) 349 return; 350 351 pBindings->Invalidate( SID_BASICSTOP(5000 + 958) ); 352 pBindings->Update( SID_BASICSTOP(5000 + 958) ); 353 pBindings->Invalidate( SID_BASICRUN(5000 + 955) ); 354 pBindings->Update( SID_BASICRUN(5000 + 955) ); 355 pBindings->Invalidate( SID_BASICCOMPILE(5000 + 954) ); 356 pBindings->Update( SID_BASICCOMPILE(5000 + 954) ); 357 pBindings->Invalidate( SID_BASICSTEPOVER(5000 + 957) ); 358 pBindings->Update( SID_BASICSTEPOVER(5000 + 957) ); 359 pBindings->Invalidate( SID_BASICSTEPINTO(5000 + 956) ); 360 pBindings->Update( SID_BASICSTEPINTO(5000 + 956) ); 361 pBindings->Invalidate( SID_BASICSTEPOUT(5000 + 963) ); 362 pBindings->Update( SID_BASICSTEPOUT(5000 + 963) ); 363 pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT( (30000 + 768) + 0 ) ); 364 pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT( (30000 + 768) + 0 ) ); 365 pBindings->Invalidate( SID_BASICIDE_STAT_POS( (30000 + 768) + 38 ) ); 366 pBindings->Update( SID_BASICIDE_STAT_POS( (30000 + 768) + 38 ) ); 367 pBindings->Invalidate( SID_BASICIDE_STAT_TITLE( (30000 + 768) + 40 ) ); 368 pBindings->Update( SID_BASICIDE_STAT_TITLE( (30000 + 768) + 40 ) ); 369} 370 371long HandleBasicError( StarBASIC const * pBasic ) 372{ 373 EnsureIde(); 374 BasicStopped(); 375 376 // no error output during macro choosing 377 if (GetExtraData()->ChoosingMacro()) 378 return 1; 379 if (GetExtraData()->ShellInCriticalSection()) 380 return 2; 381 382 long nRet = 0; 383 Shell* pShell = nullptr; 384 if ( SvtModuleOptions::IsBasicIDE() ) 385 { 386 BasicManager* pBasMgr = FindBasicManager( pBasic ); 387 if ( pBasMgr ) 388 { 389 bool bProtected = false; 390 ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) ); 391 OSL_ENSURE( aDocument.isValid(), "basctl::HandleBasicError: no document for the given BasicManager!" )do { if (true && (!(aDocument.isValid()))) { sal_detail_logFormat
((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/home/maarten/src/libreoffice/core/basctl/source/basicide/basobj3.cxx"
":" "391" ": "), "%s", "basctl::HandleBasicError: no document for the given BasicManager!"
); } } while (false)
; 392 if ( aDocument.isValid() ) 393 { 394 const OUString& aOULibName( pBasic->GetName() ); 395 Reference< script::XLibraryContainer > xModLibContainer( aDocument.getLibraryContainer( E_SCRIPTS ) ); 396 if ( xModLibContainer.is() && xModLibContainer->hasByName( aOULibName ) ) 397 { 398 Reference< script::XLibraryContainerPassword > xPasswd( xModLibContainer, UNO_QUERY ); 399 if ( xPasswd.is() && xPasswd->isLibraryPasswordProtected( aOULibName ) && !xPasswd->isLibraryPasswordVerified( aOULibName ) ) 400 { 401 bProtected = true; 402 } 403 } 404 } 405 406 if ( !bProtected ) 407 { 408 pShell = GetShell(); 409 if ( !pShell ) 410 { 411 SfxAllItemSet aArgs( SfxGetpApp()->GetPool() ); 412 SfxRequest aRequest( SID_BASICIDE_APPEAR( (30000 + 768) + 15 ), SfxCallMode::SYNCHRON, aArgs ); 413 SfxGetpApp()->ExecuteSlot( aRequest ); 414 pShell = GetShell(); 415 } 416 } 417 } 418 } 419 420 if ( pShell ) 421 nRet = long(pShell->CallBasicErrorHdl( pBasic )); 422 else 423 ErrorHandler::HandleError( StarBASIC::GetErrorCode() ); 424 425 return nRet; 426} 427 428SfxBindings* GetBindingsPtr() 429{ 430 SfxBindings* pBindings = nullptr; 431 432 SfxViewFrame* pFrame = nullptr; 433 if (Shell* pShell = GetShell()) 434 { 435 pFrame = pShell->GetViewFrame(); 436 } 437 else 438 { 439 SfxViewFrame* pView = SfxViewFrame::GetFirst(); 440 while ( pView ) 441 { 442 if (dynamic_cast<DocShell*>(pView->GetObjectShell())) 443 { 444 pFrame = pView; 445 break; 446 } 447 pView = SfxViewFrame::GetNext( *pView ); 448 } 449 } 450 if ( pFrame != nullptr ) 451 pBindings = &pFrame->GetBindings(); 452 453 return pBindings; 454} 455 456SfxDispatcher* GetDispatcher () 457{ 458 if (Shell* pShell = GetShell()) 459 if (SfxViewFrame* pViewFrame = pShell->GetViewFrame()) 460 if (SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher()) 461 return pDispatcher; 462 return nullptr; 463} 464} // namespace basctl 465 466/* vim:set shiftwidth=4 softtabstop=4 expandtab: */