1*31598a22SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*31598a22SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*31598a22SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*31598a22SAndrew Rist * distributed with this work for additional information
6*31598a22SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*31598a22SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*31598a22SAndrew Rist * "License"); you may not use this file except in compliance
9*31598a22SAndrew Rist * with the License. You may obtain a copy of the License at
10*31598a22SAndrew Rist *
11*31598a22SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*31598a22SAndrew Rist *
13*31598a22SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*31598a22SAndrew Rist * software distributed under the License is distributed on an
15*31598a22SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*31598a22SAndrew Rist * KIND, either express or implied. See the License for the
17*31598a22SAndrew Rist * specific language governing permissions and limitations
18*31598a22SAndrew Rist * under the License.
19*31598a22SAndrew Rist *
20*31598a22SAndrew Rist *************************************************************/
21*31598a22SAndrew Rist
22*31598a22SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_basctl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #define SI_NOCONTROL
28cdf0e10cSrcweir #define SI_NOSBXCONTROLS
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <basidesh.hrc>
31cdf0e10cSrcweir #include <ide_pch.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir
34cdf0e10cSrcweir #define _SOLAR__PRIVATE 1
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <basidesh.hxx>
37cdf0e10cSrcweir #include <baside2.hxx>
38cdf0e10cSrcweir #include <baside3.hxx>
39cdf0e10cSrcweir #include <basobj.hxx>
40cdf0e10cSrcweir #include <localizationmgr.hxx>
41cdf0e10cSrcweir #include <dlgedview.hxx>
42cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
43cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
45cdf0e10cSrcweir #include <xmlscript/xmldlg_imexp.hxx>
46cdf0e10cSrcweir #include <tools/diagnose_ex.h>
47cdf0e10cSrcweir
48cdf0e10cSrcweir using namespace comphelper;
49cdf0e10cSrcweir using namespace ::com::sun::star;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir using namespace ::com::sun::star::io;
52cdf0e10cSrcweir
53cdf0e10cSrcweir
CreateDlgWin(const ScriptDocument & rDocument,const String & rLibName,const String & rDlgName)54cdf0e10cSrcweir DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName )
55cdf0e10cSrcweir {
56cdf0e10cSrcweir bCreatingWindow = sal_True;
57cdf0e10cSrcweir
58cdf0e10cSrcweir sal_uLong nKey = 0;
59cdf0e10cSrcweir DialogWindow* pWin = 0;
60cdf0e10cSrcweir String aLibName( rLibName );
61cdf0e10cSrcweir String aDlgName( rDlgName );
62cdf0e10cSrcweir
63cdf0e10cSrcweir if ( !aLibName.Len() )
64cdf0e10cSrcweir aLibName = String::CreateFromAscii( "Standard" );
65cdf0e10cSrcweir
66cdf0e10cSrcweir rDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
67cdf0e10cSrcweir
68cdf0e10cSrcweir if ( !aDlgName.Len() )
69cdf0e10cSrcweir aDlgName = rDocument.createObjectName( E_DIALOGS, aLibName );
70cdf0e10cSrcweir
71cdf0e10cSrcweir // Vielleicht gibt es ein suspendiertes?
72cdf0e10cSrcweir pWin = FindDlgWin( rDocument, aLibName, aDlgName, sal_False, sal_True );
73cdf0e10cSrcweir
74cdf0e10cSrcweir if ( !pWin )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir try
77cdf0e10cSrcweir {
78cdf0e10cSrcweir Reference< io::XInputStreamProvider > xISP;
79cdf0e10cSrcweir if ( rDocument.hasDialog( aLibName, aDlgName ) )
80cdf0e10cSrcweir rDocument.getDialog( aLibName, aDlgName, xISP );
81cdf0e10cSrcweir else
82cdf0e10cSrcweir rDocument.createDialog( aLibName, aDlgName, xISP );
83cdf0e10cSrcweir
84cdf0e10cSrcweir if ( xISP.is() )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir // create dialog model
87cdf0e10cSrcweir Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
88cdf0e10cSrcweir Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
89cdf0e10cSrcweir ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
90cdf0e10cSrcweir Reference< XInputStream > xInput( xISP->createInputStream() );
91cdf0e10cSrcweir Reference< XComponentContext > xContext;
92cdf0e10cSrcweir Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
93cdf0e10cSrcweir OSL_ASSERT( xProps.is() );
94cdf0e10cSrcweir OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
95cdf0e10cSrcweir ::xmlscript::importDialogModel( xInput, xDialogModel, xContext );
96cdf0e10cSrcweir LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel );
97cdf0e10cSrcweir
98cdf0e10cSrcweir // new dialog window
99cdf0e10cSrcweir pWin = new DialogWindow( &GetViewFrame()->GetWindow(), rDocument, aLibName, aDlgName, xDialogModel );
100cdf0e10cSrcweir nKey = InsertWindowInTable( pWin );
101cdf0e10cSrcweir }
102cdf0e10cSrcweir }
103cdf0e10cSrcweir catch ( uno::Exception& )
104cdf0e10cSrcweir {
105cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION();
106cdf0e10cSrcweir }
107cdf0e10cSrcweir }
108cdf0e10cSrcweir else
109cdf0e10cSrcweir {
110cdf0e10cSrcweir pWin->SetStatus( pWin->GetStatus() & ~BASWIN_SUSPENDED );
111cdf0e10cSrcweir IDEBaseWindow* pTmp = aIDEWindowTable.First();
112cdf0e10cSrcweir while ( pTmp && !nKey )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir if ( pTmp == pWin )
115cdf0e10cSrcweir nKey = aIDEWindowTable.GetCurKey();
116cdf0e10cSrcweir pTmp = aIDEWindowTable.Next();
117cdf0e10cSrcweir }
118cdf0e10cSrcweir DBG_ASSERT( nKey, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir
121cdf0e10cSrcweir if( pWin )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir pWin->GrabScrollBars( &aHScrollBar, &aVScrollBar );
124cdf0e10cSrcweir pTabBar->InsertPage( (sal_uInt16)nKey, aDlgName );
125cdf0e10cSrcweir pTabBar->Sort();
126cdf0e10cSrcweir if ( !pCurWin )
127cdf0e10cSrcweir SetCurWindow( pWin, sal_False, sal_False );
128cdf0e10cSrcweir }
129cdf0e10cSrcweir
130cdf0e10cSrcweir bCreatingWindow = sal_False;
131cdf0e10cSrcweir return pWin;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
FindDlgWin(const ScriptDocument & rDocument,const String & rLibName,const String & rDlgName,sal_Bool bCreateIfNotExist,sal_Bool bFindSuspended)134cdf0e10cSrcweir DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const String& rLibName, const String& rDlgName, sal_Bool bCreateIfNotExist, sal_Bool bFindSuspended )
135cdf0e10cSrcweir {
136cdf0e10cSrcweir DialogWindow* pDlgWin = 0;
137cdf0e10cSrcweir IDEBaseWindow* pWin = aIDEWindowTable.First();
138cdf0e10cSrcweir while ( pWin && !pDlgWin )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir if ( !rLibName.Len() ) // nur irgendeins finden...
143cdf0e10cSrcweir pDlgWin = (DialogWindow*)pWin;
144cdf0e10cSrcweir else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName )
145cdf0e10cSrcweir pDlgWin = (DialogWindow*)pWin;
146cdf0e10cSrcweir }
147cdf0e10cSrcweir pWin = aIDEWindowTable.Next();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir if ( !pDlgWin && bCreateIfNotExist )
150cdf0e10cSrcweir pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName );
151cdf0e10cSrcweir
152cdf0e10cSrcweir return pDlgWin;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir
GetCurDlgView() const155cdf0e10cSrcweir SdrView* BasicIDEShell::GetCurDlgView() const
156cdf0e10cSrcweir {
157cdf0e10cSrcweir if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) )
158cdf0e10cSrcweir return NULL;
159cdf0e10cSrcweir
160cdf0e10cSrcweir DialogWindow* pWin = (DialogWindow*)pCurWin;
161cdf0e10cSrcweir return pWin->GetView();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir // Nur wenn Dialogfenster oben:
ExecuteDialog(SfxRequest & rReq)165cdf0e10cSrcweir void __EXPORT BasicIDEShell::ExecuteDialog( SfxRequest& rReq )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir if ( pCurWin && ( pCurWin->IsA( TYPE( DialogWindow) ) ||
168cdf0e10cSrcweir (rReq.GetSlot() == SID_IMPORT_DIALOG &&pCurWin->IsA( TYPE( ModulWindow) ) ) ) )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir pCurWin->ExecuteCommand( rReq );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir }
173cdf0e10cSrcweir
174