1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_basctl.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define SI_NOCONTROL 32*cdf0e10cSrcweir #define SI_NOSBXCONTROLS 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <basidesh.hrc> 35*cdf0e10cSrcweir #include <ide_pch.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir 38*cdf0e10cSrcweir #define _SOLAR__PRIVATE 1 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include <basidesh.hxx> 41*cdf0e10cSrcweir #include <baside2.hxx> 42*cdf0e10cSrcweir #include <baside3.hxx> 43*cdf0e10cSrcweir #include <basobj.hxx> 44*cdf0e10cSrcweir #include <localizationmgr.hxx> 45*cdf0e10cSrcweir #include <dlgedview.hxx> 46*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 47*cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp> 49*cdf0e10cSrcweir #include <xmlscript/xmldlg_imexp.hxx> 50*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace comphelper; 53*cdf0e10cSrcweir using namespace ::com::sun::star; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir using namespace ::com::sun::star::io; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName ) 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir bCreatingWindow = sal_True; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir sal_uLong nKey = 0; 63*cdf0e10cSrcweir DialogWindow* pWin = 0; 64*cdf0e10cSrcweir String aLibName( rLibName ); 65*cdf0e10cSrcweir String aDlgName( rDlgName ); 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir if ( !aLibName.Len() ) 68*cdf0e10cSrcweir aLibName = String::CreateFromAscii( "Standard" ); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir rDocument.getOrCreateLibrary( E_DIALOGS, aLibName ); 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir if ( !aDlgName.Len() ) 73*cdf0e10cSrcweir aDlgName = rDocument.createObjectName( E_DIALOGS, aLibName ); 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // Vielleicht gibt es ein suspendiertes? 76*cdf0e10cSrcweir pWin = FindDlgWin( rDocument, aLibName, aDlgName, sal_False, sal_True ); 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir if ( !pWin ) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir try 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir Reference< io::XInputStreamProvider > xISP; 83*cdf0e10cSrcweir if ( rDocument.hasDialog( aLibName, aDlgName ) ) 84*cdf0e10cSrcweir rDocument.getDialog( aLibName, aDlgName, xISP ); 85*cdf0e10cSrcweir else 86*cdf0e10cSrcweir rDocument.createDialog( aLibName, aDlgName, xISP ); 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir if ( xISP.is() ) 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir // create dialog model 91*cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); 92*cdf0e10cSrcweir Reference< container::XNameContainer > xDialogModel( xMSF->createInstance 93*cdf0e10cSrcweir ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); 94*cdf0e10cSrcweir Reference< XInputStream > xInput( xISP->createInputStream() ); 95*cdf0e10cSrcweir Reference< XComponentContext > xContext; 96*cdf0e10cSrcweir Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); 97*cdf0e10cSrcweir OSL_ASSERT( xProps.is() ); 98*cdf0e10cSrcweir OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); 99*cdf0e10cSrcweir ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); 100*cdf0e10cSrcweir LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel ); 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir // new dialog window 103*cdf0e10cSrcweir pWin = new DialogWindow( &GetViewFrame()->GetWindow(), rDocument, aLibName, aDlgName, xDialogModel ); 104*cdf0e10cSrcweir nKey = InsertWindowInTable( pWin ); 105*cdf0e10cSrcweir } 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir catch ( uno::Exception& ) 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir else 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED ); 115*cdf0e10cSrcweir IDEBaseWindow* pTmp = aIDEWindowTable.First(); 116*cdf0e10cSrcweir while ( pTmp && !nKey ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir if ( pTmp == pWin ) 119*cdf0e10cSrcweir nKey = aIDEWindowTable.GetCurKey(); 120*cdf0e10cSrcweir pTmp = aIDEWindowTable.Next(); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir DBG_ASSERT( nKey, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" ); 123*cdf0e10cSrcweir } 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if( pWin ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar ); 128*cdf0e10cSrcweir pTabBar->InsertPage( (sal_uInt16)nKey, aDlgName ); 129*cdf0e10cSrcweir pTabBar->Sort(); 130*cdf0e10cSrcweir if ( !pCurWin ) 131*cdf0e10cSrcweir SetCurWindow( pWin, sal_False, sal_False ); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir bCreatingWindow = sal_False; 135*cdf0e10cSrcweir return pWin; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir DialogWindow* pDlgWin = 0; 141*cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.First(); 142*cdf0e10cSrcweir while ( pWin && !pDlgWin ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir if ( !rLibName.Len() ) // nur irgendeins finden... 147*cdf0e10cSrcweir pDlgWin = (DialogWindow*)pWin; 148*cdf0e10cSrcweir else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName ) 149*cdf0e10cSrcweir pDlgWin = (DialogWindow*)pWin; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir pWin = aIDEWindowTable.Next(); 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir if ( !pDlgWin && bCreateIfNotExist ) 154*cdf0e10cSrcweir pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName ); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir return pDlgWin; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir SdrView* BasicIDEShell::GetCurDlgView() const 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) ) 162*cdf0e10cSrcweir return NULL; 163*cdf0e10cSrcweir 164*cdf0e10cSrcweir DialogWindow* pWin = (DialogWindow*)pCurWin; 165*cdf0e10cSrcweir return pWin->GetView(); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // Nur wenn Dialogfenster oben: 169*cdf0e10cSrcweir void __EXPORT BasicIDEShell::ExecuteDialog( SfxRequest& rReq ) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir if ( pCurWin && ( pCurWin->IsA( TYPE( DialogWindow) ) || 172*cdf0e10cSrcweir (rReq.GetSlot() == SID_IMPORT_DIALOG &&pCurWin->IsA( TYPE( ModulWindow) ) ) ) ) 173*cdf0e10cSrcweir { 174*cdf0e10cSrcweir pCurWin->ExecuteCommand( rReq ); 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178