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: basides3.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 #define SI_NOSBXCONTROLS
37 #include <basidesh.hrc>
38 #include <ide_pch.hxx>
41 #define _SOLAR__PRIVATE 1
43 #include <basidesh.hxx>
44 #include <baside3.hxx>
46 #include <localizationmgr.hxx>
47 #include <dlgedview.hxx>
48 #include <comphelper/processfactory.hxx>
49 #include <com/sun/star/script/XLibraryContainer.hpp>
50 #include <com/sun/star/container/XNameContainer.hpp>
51 #include <xmlscript/xmldlg_imexp.hxx>
52 #include <tools/diagnose_ex.h>
54 using namespace comphelper
;
55 using namespace ::com::sun::star
;
56 using namespace ::com::sun::star::uno
;
57 using namespace ::com::sun::star::io
;
60 DialogWindow
* BasicIDEShell::CreateDlgWin( const ScriptDocument
& rDocument
, const String
& rLibName
, const String
& rDlgName
)
62 bCreatingWindow
= TRUE
;
65 DialogWindow
* pWin
= 0;
66 String
aLibName( rLibName
);
67 String
aDlgName( rDlgName
);
69 if ( !aLibName
.Len() )
70 aLibName
= String::CreateFromAscii( "Standard" );
72 rDocument
.getOrCreateLibrary( E_DIALOGS
, aLibName
);
74 if ( !aDlgName
.Len() )
75 aDlgName
= rDocument
.createObjectName( E_DIALOGS
, aLibName
);
77 // Vielleicht gibt es ein suspendiertes?
78 pWin
= FindDlgWin( rDocument
, aLibName
, aDlgName
, FALSE
, TRUE
);
84 Reference
< io::XInputStreamProvider
> xISP
;
85 if ( rDocument
.hasDialog( aLibName
, aDlgName
) )
86 rDocument
.getDialog( aLibName
, aDlgName
, xISP
);
88 rDocument
.createDialog( aLibName
, aDlgName
, xISP
);
92 // create dialog model
93 Reference
< lang::XMultiServiceFactory
> xMSF
= getProcessServiceFactory();
94 Reference
< container::XNameContainer
> xDialogModel( xMSF
->createInstance
95 ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY
);
96 Reference
< XInputStream
> xInput( xISP
->createInputStream() );
97 Reference
< XComponentContext
> xContext
;
98 Reference
< beans::XPropertySet
> xProps( xMSF
, UNO_QUERY
);
99 OSL_ASSERT( xProps
.is() );
100 OSL_VERIFY( xProps
->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext
);
101 ::xmlscript::importDialogModel( xInput
, xDialogModel
, xContext
, rDocument
.getDocument() );
102 LocalizationMgr::setStringResourceAtDialog( rDocument
, rLibName
, aDlgName
, xDialogModel
);
105 pWin
= new DialogWindow( &GetViewFrame()->GetWindow(), rDocument
, aLibName
, aDlgName
, xDialogModel
);
106 nKey
= InsertWindowInTable( pWin
);
109 catch ( uno::Exception
& )
111 DBG_UNHANDLED_EXCEPTION();
116 pWin
->SetStatus( pWin
->GetStatus() & ~BASWIN_SUSPENDED
);
117 IDEBaseWindow
* pTmp
= aIDEWindowTable
.First();
118 while ( pTmp
&& !nKey
)
121 nKey
= aIDEWindowTable
.GetCurKey();
122 pTmp
= aIDEWindowTable
.Next();
124 DBG_ASSERT( nKey
, "CreateDlgWin: Kein Key - Fenster nicht gefunden!" );
129 pWin
->GrabScrollBars( &aHScrollBar
, &aVScrollBar
);
130 pTabBar
->InsertPage( (USHORT
)nKey
, aDlgName
);
133 SetCurWindow( pWin
, FALSE
, FALSE
);
136 bCreatingWindow
= FALSE
;
140 DialogWindow
* BasicIDEShell::FindDlgWin( const ScriptDocument
& rDocument
, const String
& rLibName
, const String
& rDlgName
, BOOL bCreateIfNotExist
, BOOL bFindSuspended
)
142 DialogWindow
* pDlgWin
= 0;
143 IDEBaseWindow
* pWin
= aIDEWindowTable
.First();
144 while ( pWin
&& !pDlgWin
)
146 if ( ( !pWin
->IsSuspended() || bFindSuspended
) && pWin
->IsA( TYPE( DialogWindow
) ) )
148 if ( !rLibName
.Len() ) // nur irgendeins finden...
149 pDlgWin
= (DialogWindow
*)pWin
;
150 else if ( pWin
->IsDocument( rDocument
) && pWin
->GetLibName() == rLibName
&& pWin
->GetName() == rDlgName
)
151 pDlgWin
= (DialogWindow
*)pWin
;
153 pWin
= aIDEWindowTable
.Next();
155 if ( !pDlgWin
&& bCreateIfNotExist
)
156 pDlgWin
= CreateDlgWin( rDocument
, rLibName
, rDlgName
);
161 SdrView
* BasicIDEShell::GetCurDlgView() const
163 if ( !pCurWin
|| !pCurWin
->IsA( TYPE( DialogWindow
) ) )
166 DialogWindow
* pWin
= (DialogWindow
*)pCurWin
;
167 return pWin
->GetView();
170 // Nur wenn Dialogfenster oben:
171 void __EXPORT
BasicIDEShell::ExecuteDialog( SfxRequest
& rReq
)
173 if ( !pCurWin
|| !pCurWin
->IsA( TYPE( DialogWindow
) ) )
176 pCurWin
->ExecuteCommand( rReq
);