xref: /AOO41X/main/basctl/source/basicide/baside3.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 //svdraw.hxx
32*cdf0e10cSrcweir //#define _SVDRAW_HXX ***
33*cdf0e10cSrcweir #define _SDR_NOITEMS
34*cdf0e10cSrcweir #define _SDR_NOTOUCH
35*cdf0e10cSrcweir #define _SDR_NOTRANSFORM
36*cdf0e10cSrcweir #define _SDR_NOOBJECTS
37*cdf0e10cSrcweir //#define _SDR_NOVIEWS ***
38*cdf0e10cSrcweir #define _SDR_NOVIEWMARKER
39*cdf0e10cSrcweir #define _SDR_NODRAGMETHODS
40*cdf0e10cSrcweir //#define _SDR_NOUNDO ***
41*cdf0e10cSrcweir #define _SDR_NOXOUTDEV
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <ide_pch.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include <vector>
47*cdf0e10cSrcweir #include <basidesh.hrc>
48*cdf0e10cSrcweir #include <baside3.hxx>
49*cdf0e10cSrcweir #include <localizationmgr.hxx>
50*cdf0e10cSrcweir #include <accessibledialogwindow.hxx>
51*cdf0e10cSrcweir #include <dlged.hxx>
52*cdf0e10cSrcweir #include <dlgedmod.hxx>
53*cdf0e10cSrcweir #include <dlgedview.hxx>
54*cdf0e10cSrcweir #include <dlgeddef.hxx>
55*cdf0e10cSrcweir #include <propbrw.hxx>
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #include <basobj.hxx>
58*cdf0e10cSrcweir #include <iderdll.hxx>
59*cdf0e10cSrcweir #include <basidesh.hxx>
60*cdf0e10cSrcweir #include <idetemp.hxx>
61*cdf0e10cSrcweir #include <helpid.hrc>
62*cdf0e10cSrcweir #include <bastype2.hxx>
63*cdf0e10cSrcweir #include <svx/svdview.hxx>
64*cdf0e10cSrcweir #include <editeng/unolingu.hxx>
65*cdf0e10cSrcweir #include <tools/diagnose_ex.h>
66*cdf0e10cSrcweir #include <tools/urlobj.hxx>
67*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
68*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
69*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
70*cdf0e10cSrcweir #include <xmlscript/xmldlg_imexp.hxx>
71*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_
72*cdf0e10cSrcweir #include <com/sun/star/script/XLibraryContainer2.hpp>
73*cdf0e10cSrcweir #endif
74*cdf0e10cSrcweir #include <svtools/ehdl.hxx>
75*cdf0e10cSrcweir #include <svtools/langtab.hxx>
76*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
77*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
78*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
79*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
80*cdf0e10cSrcweir #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
81*cdf0e10cSrcweir #include <com/sun/star/ucb/XSimpleFileAccess.hpp>
82*cdf0e10cSrcweir #include <com/sun/star/resource/XStringResourceResolver.hpp>
83*cdf0e10cSrcweir #include <com/sun/star/resource/StringResourceWithLocation.hpp>
84*cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir using namespace comphelper;
87*cdf0e10cSrcweir using namespace	::com::sun::star;
88*cdf0e10cSrcweir using namespace	::com::sun::star::uno;
89*cdf0e10cSrcweir using namespace	::com::sun::star::ucb;
90*cdf0e10cSrcweir using namespace	::com::sun::star::io;
91*cdf0e10cSrcweir using namespace	::com::sun::star::resource;
92*cdf0e10cSrcweir using namespace	::com::sun::star::ui::dialogs;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir #if defined(UNX)
95*cdf0e10cSrcweir #define FILTERMASK_ALL "*"
96*cdf0e10cSrcweir #elif defined(PM2)
97*cdf0e10cSrcweir #define FILTERMASK_ALL ""
98*cdf0e10cSrcweir #else
99*cdf0e10cSrcweir #define FILTERMASK_ALL "*.*"
100*cdf0e10cSrcweir #endif
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir DBG_NAME( DialogWindow )
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir TYPEINIT1( DialogWindow, IDEBaseWindow );
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir DialogWindow::DialogWindow( Window* pParent, const ScriptDocument& rDocument, String aLibName, String aName,
107*cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& xDialogModel )
108*cdf0e10cSrcweir 		:IDEBaseWindow( pParent, rDocument, aLibName, aName )
109*cdf0e10cSrcweir 		,pUndoMgr(NULL)
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir 	InitSettings( sal_True, sal_True, sal_True );
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	pEditor = new DlgEditor();
114*cdf0e10cSrcweir 	pEditor->SetWindow( this );
115*cdf0e10cSrcweir 	pEditor->SetDialog( xDialogModel );
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir 	// Undo einrichten
118*cdf0e10cSrcweir 	pUndoMgr = new SfxUndoManager;
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir 	Link aDummyLink;
121*cdf0e10cSrcweir 	aOldNotifyUndoActionHdl = pEditor->GetModel()->GetNotifyUndoActionHdl();
122*cdf0e10cSrcweir 	pEditor->GetModel()->SetNotifyUndoActionHdl(
123*cdf0e10cSrcweir 		LINK(this, DialogWindow, NotifyUndoActionHdl));
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir 	SetHelpId( HID_BASICIDE_DIALOGWINDOW );
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     // set readonly mode for readonly libraries
128*cdf0e10cSrcweir     ::rtl::OUString aOULibName( aLibName );
129*cdf0e10cSrcweir     Reference< script::XLibraryContainer2 > xDlgLibContainer( GetDocument().getLibraryContainer( E_DIALOGS ), UNO_QUERY );
130*cdf0e10cSrcweir     if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aOULibName ) && xDlgLibContainer->isLibraryReadOnly( aOULibName ) )
131*cdf0e10cSrcweir         SetReadOnly( sal_True );
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     if ( rDocument.isDocument() && rDocument.isReadOnly() )
134*cdf0e10cSrcweir         SetReadOnly( sal_True );
135*cdf0e10cSrcweir }
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir DialogWindow::~DialogWindow()
138*cdf0e10cSrcweir {
139*cdf0e10cSrcweir 	delete pEditor;
140*cdf0e10cSrcweir 	delete pUndoMgr;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir void DialogWindow::LoseFocus()
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	if ( IsModified() )
146*cdf0e10cSrcweir         StoreData();
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir     Window::LoseFocus();
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir void DialogWindow::Paint( const Rectangle& rRect )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir 	pEditor->Paint( rRect );
156*cdf0e10cSrcweir }
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir void DialogWindow::Resize()
161*cdf0e10cSrcweir {
162*cdf0e10cSrcweir 	if ( GetHScrollBar() && GetVScrollBar() ) {
163*cdf0e10cSrcweir 		pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
164*cdf0e10cSrcweir 	}
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir void DialogWindow::MouseButtonDown( const MouseEvent& rMEvt )
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir 	pEditor->MouseButtonDown( rMEvt );
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir     SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
174*cdf0e10cSrcweir     if ( pBindings )
175*cdf0e10cSrcweir         pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir void DialogWindow::MouseButtonUp( const MouseEvent& rMEvt )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir 	pEditor->MouseButtonUp( rMEvt );
183*cdf0e10cSrcweir     SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
184*cdf0e10cSrcweir 	if( (pEditor->GetMode() == DLGED_INSERT) && !pEditor->IsCreateOK() )
185*cdf0e10cSrcweir 	{
186*cdf0e10cSrcweir 		pEditor->SetMode( DLGED_SELECT );
187*cdf0e10cSrcweir         if ( pBindings )
188*cdf0e10cSrcweir             pBindings->Invalidate( SID_CHOOSE_CONTROLS );
189*cdf0e10cSrcweir 	}
190*cdf0e10cSrcweir     if ( pBindings )
191*cdf0e10cSrcweir     {
192*cdf0e10cSrcweir         pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
193*cdf0e10cSrcweir         pBindings->Invalidate( SID_DOC_MODIFIED );
194*cdf0e10cSrcweir         pBindings->Invalidate( SID_SAVEDOC );
195*cdf0e10cSrcweir     }
196*cdf0e10cSrcweir }
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir void DialogWindow::MouseMove( const MouseEvent& rMEvt )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir 	pEditor->MouseMove( rMEvt );
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir void DialogWindow::KeyInput( const KeyEvent& rKEvt )
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	if( rKEvt.GetKeyCode() == KEY_BACKSPACE )
210*cdf0e10cSrcweir 	{
211*cdf0e10cSrcweir         BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
212*cdf0e10cSrcweir         SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
213*cdf0e10cSrcweir 	    SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
214*cdf0e10cSrcweir         if( pDispatcher )
215*cdf0e10cSrcweir 		{
216*cdf0e10cSrcweir 			pDispatcher->Execute( SID_BACKSPACE );
217*cdf0e10cSrcweir 		}
218*cdf0e10cSrcweir 	}
219*cdf0e10cSrcweir 	else
220*cdf0e10cSrcweir 	{
221*cdf0e10cSrcweir 	    SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
222*cdf0e10cSrcweir 		if( pBindings && rKEvt.GetKeyCode() == KEY_TAB )
223*cdf0e10cSrcweir 	        pBindings->Invalidate( SID_SHOW_PROPERTYBROWSER );
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir 		if( !pEditor->KeyInput( rKEvt ) )
226*cdf0e10cSrcweir 		{
227*cdf0e10cSrcweir 			if( !SfxViewShell::Current()->KeyInput( rKEvt ) )
228*cdf0e10cSrcweir 				Window::KeyInput( rKEvt );
229*cdf0e10cSrcweir 		}
230*cdf0e10cSrcweir 	}
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void DialogWindow::Command( const CommandEvent& rCEvt )
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir 	if ( ( rCEvt.GetCommand() == COMMAND_WHEEL ) ||
236*cdf0e10cSrcweir 			( rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL ) ||
237*cdf0e10cSrcweir 			( rCEvt.GetCommand() == COMMAND_AUTOSCROLL ) )
238*cdf0e10cSrcweir 	{
239*cdf0e10cSrcweir 		HandleScrollCommand( rCEvt, GetHScrollBar(), GetVScrollBar() );
240*cdf0e10cSrcweir 	}
241*cdf0e10cSrcweir 	else if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
242*cdf0e10cSrcweir 	{
243*cdf0e10cSrcweir         BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
244*cdf0e10cSrcweir         SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
245*cdf0e10cSrcweir 	    SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL;
246*cdf0e10cSrcweir         if ( pDispatcher )
247*cdf0e10cSrcweir         {
248*cdf0e10cSrcweir 	        SdrView* pView = GetView();
249*cdf0e10cSrcweir         	if( !rCEvt.IsMouseEvent() && pView->AreObjectsMarked() )
250*cdf0e10cSrcweir             {
251*cdf0e10cSrcweir             	Rectangle aMarkedRect( pView->GetMarkedRect() );
252*cdf0e10cSrcweir                 Point MarkedCenter( aMarkedRect.Center() );
253*cdf0e10cSrcweir                 Point PosPixel( LogicToPixel( MarkedCenter ) );
254*cdf0e10cSrcweir     			pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED), this, &PosPixel );
255*cdf0e10cSrcweir             }
256*cdf0e10cSrcweir             else
257*cdf0e10cSrcweir             {
258*cdf0e10cSrcweir 			    pDispatcher->ExecutePopup( IDEResId(RID_POPUP_DLGED) );
259*cdf0e10cSrcweir             }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         }
262*cdf0e10cSrcweir     }
263*cdf0e10cSrcweir     else
264*cdf0e10cSrcweir 		IDEBaseWindow::Command( rCEvt );
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir IMPL_LINK( DialogWindow, NotifyUndoActionHdl, SfxUndoAction *, pUndoAction )
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir 	(void)pUndoAction;
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir 	// not working yet for unocontrols
275*cdf0e10cSrcweir 	/*
276*cdf0e10cSrcweir 	if (pUndoAction)
277*cdf0e10cSrcweir 	{
278*cdf0e10cSrcweir 		pUndoMgr->AddUndoAction( pUndoAction );
279*cdf0e10cSrcweir         SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
280*cdf0e10cSrcweir         if ( pBindings )
281*cdf0e10cSrcweir             pBindings->Invalidate( SID_UNDO );
282*cdf0e10cSrcweir 	}
283*cdf0e10cSrcweir 	*/
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir 	return 0;
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir void __EXPORT DialogWindow::DoInit()
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	GetHScrollBar()->Show();
293*cdf0e10cSrcweir 	GetVScrollBar()->Show();
294*cdf0e10cSrcweir 	pEditor->SetScrollBars( GetHScrollBar(), GetVScrollBar() );
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir void __EXPORT DialogWindow::DoScroll( ScrollBar* pCurScrollBar )
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	pEditor->DoScroll( pCurScrollBar );
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void __EXPORT DialogWindow::GetState( SfxItemSet& rSet )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	SfxWhichIter aIter(rSet);
307*cdf0e10cSrcweir 	for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
308*cdf0e10cSrcweir 	{
309*cdf0e10cSrcweir 		switch ( nWh )
310*cdf0e10cSrcweir 		{
311*cdf0e10cSrcweir 			case SID_PASTE:
312*cdf0e10cSrcweir             {
313*cdf0e10cSrcweir                 if ( !IsPasteAllowed() )
314*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir                 if ( IsReadOnly() )
317*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
318*cdf0e10cSrcweir             }
319*cdf0e10cSrcweir 			break;
320*cdf0e10cSrcweir 			case SID_COPY:
321*cdf0e10cSrcweir             {
322*cdf0e10cSrcweir 				// any object selected?
323*cdf0e10cSrcweir                 if ( !pEditor->GetView()->AreObjectsMarked() )
324*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
325*cdf0e10cSrcweir             }
326*cdf0e10cSrcweir             break;
327*cdf0e10cSrcweir             case SID_CUT:
328*cdf0e10cSrcweir             case SID_DELETE:
329*cdf0e10cSrcweir 			case SID_BACKSPACE:
330*cdf0e10cSrcweir             {
331*cdf0e10cSrcweir 				// any object selected?
332*cdf0e10cSrcweir                 if ( !pEditor->GetView()->AreObjectsMarked() )
333*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir                 if ( IsReadOnly() )
336*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
337*cdf0e10cSrcweir 			}
338*cdf0e10cSrcweir 			break;
339*cdf0e10cSrcweir 			case SID_REDO:
340*cdf0e10cSrcweir 			{
341*cdf0e10cSrcweir 				if ( !pUndoMgr->GetUndoActionCount() )
342*cdf0e10cSrcweir 					rSet.DisableItem( nWh );
343*cdf0e10cSrcweir 			}
344*cdf0e10cSrcweir 			break;
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir 			// Nur Dialogfenster:
347*cdf0e10cSrcweir 			case SID_DIALOG_TESTMODE:
348*cdf0e10cSrcweir 			{
349*cdf0e10cSrcweir 				// ist die IDE noch aktiv?
350*cdf0e10cSrcweir 				if( IDE_DLL()->GetShell()->GetFrame() )
351*cdf0e10cSrcweir 				{
352*cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( SID_DIALOG_TESTMODE,
353*cdf0e10cSrcweir 							  (pEditor->GetMode() == DLGED_TEST) ? sal_True : sal_False) );
354*cdf0e10cSrcweir 				}
355*cdf0e10cSrcweir 				else
356*cdf0e10cSrcweir 					rSet.Put( SfxBoolItem( SID_DIALOG_TESTMODE,sal_False ));
357*cdf0e10cSrcweir 			}
358*cdf0e10cSrcweir 			break;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 			case SID_CHOOSE_CONTROLS:
361*cdf0e10cSrcweir 			{
362*cdf0e10cSrcweir                 if ( IsReadOnly() )
363*cdf0e10cSrcweir                 {
364*cdf0e10cSrcweir 					rSet.DisableItem( nWh );
365*cdf0e10cSrcweir                 }
366*cdf0e10cSrcweir                 else
367*cdf0e10cSrcweir                 {
368*cdf0e10cSrcweir                     SfxAllEnumItem aItem( SID_CHOOSE_CONTROLS );
369*cdf0e10cSrcweir 				    if ( GetEditor()->GetMode() == DLGED_SELECT )
370*cdf0e10cSrcweir 					    aItem.SetValue( SVX_SNAP_SELECT );
371*cdf0e10cSrcweir 				    else
372*cdf0e10cSrcweir 				    {
373*cdf0e10cSrcweir 					    sal_uInt16 nObj;
374*cdf0e10cSrcweir 					    switch( pEditor->GetInsertObj() )
375*cdf0e10cSrcweir 					    {
376*cdf0e10cSrcweir 						    case OBJ_DLG_PUSHBUTTON:        nObj = SVX_SNAP_PUSHBUTTON; break;
377*cdf0e10cSrcweir 						    case OBJ_DLG_RADIOBUTTON:       nObj = SVX_SNAP_RADIOBUTTON; break;
378*cdf0e10cSrcweir                             case OBJ_DLG_CHECKBOX:          nObj = SVX_SNAP_CHECKBOX; break;
379*cdf0e10cSrcweir 						    case OBJ_DLG_LISTBOX:           nObj = SVX_SNAP_LISTBOX; break;
380*cdf0e10cSrcweir 						    case OBJ_DLG_COMBOBOX:          nObj = SVX_SNAP_COMBOBOX; break;
381*cdf0e10cSrcweir                             case OBJ_DLG_GROUPBOX:          nObj = SVX_SNAP_GROUPBOX; break;
382*cdf0e10cSrcweir 						    case OBJ_DLG_EDIT:              nObj = SVX_SNAP_EDIT; break;
383*cdf0e10cSrcweir                             case OBJ_DLG_FIXEDTEXT:         nObj = SVX_SNAP_FIXEDTEXT; break;
384*cdf0e10cSrcweir                             case OBJ_DLG_IMAGECONTROL:	    nObj = SVX_SNAP_IMAGECONTROL; break;
385*cdf0e10cSrcweir 						    case OBJ_DLG_PROGRESSBAR:	    nObj = SVX_SNAP_PROGRESSBAR; break;
386*cdf0e10cSrcweir                             case OBJ_DLG_HSCROLLBAR:        nObj = SVX_SNAP_HSCROLLBAR; break;
387*cdf0e10cSrcweir 						    case OBJ_DLG_VSCROLLBAR:        nObj = SVX_SNAP_VSCROLLBAR; break;
388*cdf0e10cSrcweir                             case OBJ_DLG_HFIXEDLINE:	    nObj = SVX_SNAP_HFIXEDLINE; break;
389*cdf0e10cSrcweir 						    case OBJ_DLG_VFIXEDLINE:	    nObj = SVX_SNAP_VFIXEDLINE; break;
390*cdf0e10cSrcweir 						    case OBJ_DLG_DATEFIELD:	        nObj = SVX_SNAP_DATEFIELD; break;
391*cdf0e10cSrcweir 						    case OBJ_DLG_TIMEFIELD:	        nObj = SVX_SNAP_TIMEFIELD; break;
392*cdf0e10cSrcweir 						    case OBJ_DLG_NUMERICFIELD:	    nObj = SVX_SNAP_NUMERICFIELD; break;
393*cdf0e10cSrcweir 						    case OBJ_DLG_CURRENCYFIELD:	    nObj = SVX_SNAP_CURRENCYFIELD; break;
394*cdf0e10cSrcweir 						    case OBJ_DLG_FORMATTEDFIELD:	nObj = SVX_SNAP_FORMATTEDFIELD; break;
395*cdf0e10cSrcweir 						    case OBJ_DLG_PATTERNFIELD:	    nObj = SVX_SNAP_PATTERNFIELD; break;
396*cdf0e10cSrcweir 						    case OBJ_DLG_FILECONTROL:	    nObj = SVX_SNAP_FILECONTROL; break;
397*cdf0e10cSrcweir 							case OBJ_DLG_TREECONTROL:	    nObj = SVX_SNAP_TREECONTROL; break;
398*cdf0e10cSrcweir                             default:					    nObj = 0;
399*cdf0e10cSrcweir 					    }
400*cdf0e10cSrcweir #ifdef DBG_UTIL
401*cdf0e10cSrcweir 					    if( !nObj )
402*cdf0e10cSrcweir 					    {
403*cdf0e10cSrcweir 						    DBG_WARNING( "SID_CHOOSE_CONTROLS: Unbekannt!" );
404*cdf0e10cSrcweir 					    }
405*cdf0e10cSrcweir #endif
406*cdf0e10cSrcweir 					    aItem.SetValue( nObj );
407*cdf0e10cSrcweir 				    }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 				    rSet.Put( aItem );
410*cdf0e10cSrcweir                 }
411*cdf0e10cSrcweir             }
412*cdf0e10cSrcweir 			break;
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir 			case SID_SHOW_PROPERTYBROWSER:
415*cdf0e10cSrcweir 			{
416*cdf0e10cSrcweir                 BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
417*cdf0e10cSrcweir                 SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
418*cdf0e10cSrcweir                 if ( pViewFrame && !pViewFrame->HasChildWindow( SID_SHOW_PROPERTYBROWSER ) && !pEditor->GetView()->AreObjectsMarked() )
419*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir                 if ( IsReadOnly() )
422*cdf0e10cSrcweir                     rSet.DisableItem( nWh );
423*cdf0e10cSrcweir             }
424*cdf0e10cSrcweir 			break;
425*cdf0e10cSrcweir 		}
426*cdf0e10cSrcweir 	}
427*cdf0e10cSrcweir }
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir void __EXPORT DialogWindow::ExecuteCommand( SfxRequest& rReq )
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir 	switch ( rReq.GetSlot() )
434*cdf0e10cSrcweir 	{
435*cdf0e10cSrcweir 		case SID_CUT:
436*cdf0e10cSrcweir             if ( !IsReadOnly() )
437*cdf0e10cSrcweir             {
438*cdf0e10cSrcweir                 GetEditor()->Cut();
439*cdf0e10cSrcweir                 SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
440*cdf0e10cSrcweir                 if ( pBindings )
441*cdf0e10cSrcweir 			        pBindings->Invalidate( SID_DOC_MODIFIED );
442*cdf0e10cSrcweir             }
443*cdf0e10cSrcweir 			break;
444*cdf0e10cSrcweir 		case SID_DELETE:
445*cdf0e10cSrcweir             if ( !IsReadOnly() )
446*cdf0e10cSrcweir             {
447*cdf0e10cSrcweir                 GetEditor()->Delete();
448*cdf0e10cSrcweir                 SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
449*cdf0e10cSrcweir                 if ( pBindings )
450*cdf0e10cSrcweir                     pBindings->Invalidate( SID_DOC_MODIFIED );
451*cdf0e10cSrcweir             }
452*cdf0e10cSrcweir 			break;
453*cdf0e10cSrcweir 		case SID_COPY:
454*cdf0e10cSrcweir 			GetEditor()->Copy();
455*cdf0e10cSrcweir 			break;
456*cdf0e10cSrcweir 		case SID_PASTE:
457*cdf0e10cSrcweir             if ( !IsReadOnly() )
458*cdf0e10cSrcweir             {
459*cdf0e10cSrcweir                 GetEditor()->Paste();
460*cdf0e10cSrcweir                 SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
461*cdf0e10cSrcweir                 if ( pBindings )
462*cdf0e10cSrcweir                     pBindings->Invalidate( SID_DOC_MODIFIED );
463*cdf0e10cSrcweir             }
464*cdf0e10cSrcweir 			break;
465*cdf0e10cSrcweir 		case SID_CHOOSE_CONTROLS:
466*cdf0e10cSrcweir 		{
467*cdf0e10cSrcweir 			const SfxItemSet* pArgs = rReq.GetArgs();
468*cdf0e10cSrcweir 			DBG_ASSERT( pArgs, "Nix Args" );
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir 			const SfxAllEnumItem& rItem = (SfxAllEnumItem&)pArgs->Get( SID_CHOOSE_CONTROLS );
471*cdf0e10cSrcweir 			switch( rItem.GetValue() )
472*cdf0e10cSrcweir 			{
473*cdf0e10cSrcweir 				case SVX_SNAP_PUSHBUTTON:
474*cdf0e10cSrcweir 				{
475*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
476*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_PUSHBUTTON );
477*cdf0e10cSrcweir 				}
478*cdf0e10cSrcweir 				break;
479*cdf0e10cSrcweir 				case SVX_SNAP_RADIOBUTTON:
480*cdf0e10cSrcweir 				{
481*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
482*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_RADIOBUTTON );
483*cdf0e10cSrcweir 				}
484*cdf0e10cSrcweir 				break;
485*cdf0e10cSrcweir 				case SVX_SNAP_CHECKBOX:
486*cdf0e10cSrcweir 				{
487*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
488*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_CHECKBOX);
489*cdf0e10cSrcweir 				}
490*cdf0e10cSrcweir 				break;
491*cdf0e10cSrcweir 				case SVX_SNAP_LISTBOX:
492*cdf0e10cSrcweir 				{
493*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
494*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_LISTBOX );
495*cdf0e10cSrcweir 				}
496*cdf0e10cSrcweir 				break;
497*cdf0e10cSrcweir 				case SVX_SNAP_COMBOBOX:
498*cdf0e10cSrcweir 				{
499*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
500*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_COMBOBOX );
501*cdf0e10cSrcweir 				}
502*cdf0e10cSrcweir 				break;
503*cdf0e10cSrcweir 				case SVX_SNAP_GROUPBOX:
504*cdf0e10cSrcweir 				{
505*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
506*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_GROUPBOX );
507*cdf0e10cSrcweir 				}
508*cdf0e10cSrcweir 				break;
509*cdf0e10cSrcweir                 case SVX_SNAP_EDIT:
510*cdf0e10cSrcweir 				{
511*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
512*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_EDIT );
513*cdf0e10cSrcweir 				}
514*cdf0e10cSrcweir 				break;
515*cdf0e10cSrcweir                 case SVX_SNAP_FIXEDTEXT:
516*cdf0e10cSrcweir 				{
517*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
518*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_FIXEDTEXT );
519*cdf0e10cSrcweir 				}
520*cdf0e10cSrcweir 				break;
521*cdf0e10cSrcweir 				case SVX_SNAP_IMAGECONTROL:
522*cdf0e10cSrcweir 				{
523*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
524*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_IMAGECONTROL );
525*cdf0e10cSrcweir 				}
526*cdf0e10cSrcweir 				break;
527*cdf0e10cSrcweir 				case SVX_SNAP_PROGRESSBAR:
528*cdf0e10cSrcweir 				{
529*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
530*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_PROGRESSBAR );
531*cdf0e10cSrcweir 				}
532*cdf0e10cSrcweir 				break;
533*cdf0e10cSrcweir                 case SVX_SNAP_HSCROLLBAR:
534*cdf0e10cSrcweir 				{
535*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
536*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_HSCROLLBAR );
537*cdf0e10cSrcweir 				}
538*cdf0e10cSrcweir 				break;
539*cdf0e10cSrcweir 				case SVX_SNAP_VSCROLLBAR:
540*cdf0e10cSrcweir 				{
541*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
542*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_VSCROLLBAR );
543*cdf0e10cSrcweir 				}
544*cdf0e10cSrcweir 				break;
545*cdf0e10cSrcweir                 case SVX_SNAP_HFIXEDLINE:
546*cdf0e10cSrcweir 				{
547*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
548*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_HFIXEDLINE );
549*cdf0e10cSrcweir 				}
550*cdf0e10cSrcweir 				break;
551*cdf0e10cSrcweir 				case SVX_SNAP_VFIXEDLINE:
552*cdf0e10cSrcweir 				{
553*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
554*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_VFIXEDLINE );
555*cdf0e10cSrcweir 				}
556*cdf0e10cSrcweir 				break;
557*cdf0e10cSrcweir 				case SVX_SNAP_DATEFIELD:
558*cdf0e10cSrcweir 				{
559*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
560*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_DATEFIELD );
561*cdf0e10cSrcweir 				}
562*cdf0e10cSrcweir 				break;
563*cdf0e10cSrcweir 				case SVX_SNAP_TIMEFIELD:
564*cdf0e10cSrcweir 				{
565*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
566*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_TIMEFIELD );
567*cdf0e10cSrcweir 				}
568*cdf0e10cSrcweir 				break;
569*cdf0e10cSrcweir 				case SVX_SNAP_NUMERICFIELD:
570*cdf0e10cSrcweir 				{
571*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
572*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_NUMERICFIELD );
573*cdf0e10cSrcweir 				}
574*cdf0e10cSrcweir 				break;
575*cdf0e10cSrcweir 				case SVX_SNAP_CURRENCYFIELD:
576*cdf0e10cSrcweir 				{
577*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
578*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_CURRENCYFIELD );
579*cdf0e10cSrcweir 				}
580*cdf0e10cSrcweir 				break;
581*cdf0e10cSrcweir 				case SVX_SNAP_FORMATTEDFIELD:
582*cdf0e10cSrcweir 				{
583*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
584*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_FORMATTEDFIELD );
585*cdf0e10cSrcweir 				}
586*cdf0e10cSrcweir 				break;
587*cdf0e10cSrcweir 				case SVX_SNAP_PATTERNFIELD:
588*cdf0e10cSrcweir 				{
589*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
590*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_PATTERNFIELD );
591*cdf0e10cSrcweir 				}
592*cdf0e10cSrcweir 				break;
593*cdf0e10cSrcweir 				case SVX_SNAP_FILECONTROL:
594*cdf0e10cSrcweir 				{
595*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
596*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_FILECONTROL );
597*cdf0e10cSrcweir 				}
598*cdf0e10cSrcweir 				break;
599*cdf0e10cSrcweir 				case SVX_SNAP_TREECONTROL:
600*cdf0e10cSrcweir 				{
601*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_INSERT );
602*cdf0e10cSrcweir 					GetEditor()->SetInsertObj( OBJ_DLG_TREECONTROL );
603*cdf0e10cSrcweir 				}
604*cdf0e10cSrcweir 				break;
605*cdf0e10cSrcweir 
606*cdf0e10cSrcweir                 case SVX_SNAP_SELECT:
607*cdf0e10cSrcweir 				{
608*cdf0e10cSrcweir 					GetEditor()->SetMode( DLGED_SELECT );
609*cdf0e10cSrcweir 				}
610*cdf0e10cSrcweir 				break;
611*cdf0e10cSrcweir 			}
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 			if ( rReq.GetModifier() & KEY_MOD1 )
614*cdf0e10cSrcweir 			{
615*cdf0e10cSrcweir 				if ( GetEditor()->GetMode() == DLGED_INSERT )
616*cdf0e10cSrcweir 					GetEditor()->CreateDefaultObject();
617*cdf0e10cSrcweir 			}
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir             SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
620*cdf0e10cSrcweir             if ( pBindings )
621*cdf0e10cSrcweir                 pBindings->Invalidate( SID_DOC_MODIFIED );
622*cdf0e10cSrcweir 		}
623*cdf0e10cSrcweir 		break;
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 		case SID_DIALOG_TESTMODE:
626*cdf0e10cSrcweir 		{
627*cdf0e10cSrcweir 			DlgEdMode eOldMode = GetEditor()->GetMode();
628*cdf0e10cSrcweir 			GetEditor()->SetMode( DLGED_TEST );
629*cdf0e10cSrcweir 			GetEditor()->SetMode( eOldMode );
630*cdf0e10cSrcweir 			rReq.Done();
631*cdf0e10cSrcweir             SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
632*cdf0e10cSrcweir             if ( pBindings )
633*cdf0e10cSrcweir                 pBindings->Invalidate( SID_DIALOG_TESTMODE );
634*cdf0e10cSrcweir 			return;
635*cdf0e10cSrcweir 		}
636*cdf0e10cSrcweir 		case SID_EXPORT_DIALOG:
637*cdf0e10cSrcweir 			SaveDialog();
638*cdf0e10cSrcweir 			break;
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir 		case SID_IMPORT_DIALOG:
641*cdf0e10cSrcweir 			ImportDialog();
642*cdf0e10cSrcweir 			break;
643*cdf0e10cSrcweir 	}
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	rReq.Done();
646*cdf0e10cSrcweir }
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir Reference< container::XNameContainer > DialogWindow::GetDialog() const
649*cdf0e10cSrcweir {
650*cdf0e10cSrcweir 	return pEditor->GetDialog();
651*cdf0e10cSrcweir }
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir sal_Bool DialogWindow::RenameDialog( const String& rNewName )
654*cdf0e10cSrcweir {
655*cdf0e10cSrcweir 	if ( !BasicIDE::RenameDialog( this, GetDocument(), GetLibName(), GetName(), rNewName ) )
656*cdf0e10cSrcweir         return sal_False;
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir     SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
659*cdf0e10cSrcweir     if ( pBindings )
660*cdf0e10cSrcweir         pBindings->Invalidate( SID_DOC_MODIFIED );
661*cdf0e10cSrcweir 
662*cdf0e10cSrcweir 	return sal_True;
663*cdf0e10cSrcweir }
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir void DialogWindow::DisableBrowser()
666*cdf0e10cSrcweir {
667*cdf0e10cSrcweir     BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
668*cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
669*cdf0e10cSrcweir 	SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow(SID_SHOW_PROPERTYBROWSER) : NULL;
670*cdf0e10cSrcweir     if( pChildWin )
671*cdf0e10cSrcweir 		((PropBrw*)(pChildWin->GetWindow()))->Update( NULL );
672*cdf0e10cSrcweir }
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir void DialogWindow::UpdateBrowser()
675*cdf0e10cSrcweir {
676*cdf0e10cSrcweir     BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
677*cdf0e10cSrcweir     SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL;
678*cdf0e10cSrcweir 	SfxChildWindow* pChildWin = pViewFrame ? pViewFrame->GetChildWindow(SID_SHOW_PROPERTYBROWSER) : NULL;
679*cdf0e10cSrcweir     if( pChildWin )
680*cdf0e10cSrcweir 		((PropBrw*)(pChildWin->GetWindow()))->Update( pIDEShell );
681*cdf0e10cSrcweir }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir static ::rtl::OUString aResourceResolverPropName =
684*cdf0e10cSrcweir 	::rtl::OUString::createFromAscii( "ResourceResolver" );
685*cdf0e10cSrcweir 
686*cdf0e10cSrcweir sal_Bool DialogWindow::SaveDialog()
687*cdf0e10cSrcweir {
688*cdf0e10cSrcweir 	DBG_CHKTHIS( DialogWindow, 0 );
689*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
692*cdf0e10cSrcweir     Reference < XFilePicker > xFP;
693*cdf0e10cSrcweir     if( xMSF.is() )
694*cdf0e10cSrcweir     {
695*cdf0e10cSrcweir 		Sequence <Any> aServiceType(1);
696*cdf0e10cSrcweir 		aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
697*cdf0e10cSrcweir         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
698*cdf0e10cSrcweir 					::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
699*cdf0e10cSrcweir     }
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir 	Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
702*cdf0e10cSrcweir 	xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
703*cdf0e10cSrcweir     Any aValue;
704*cdf0e10cSrcweir     aValue <<= (sal_Bool) sal_True;
705*cdf0e10cSrcweir 	xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir 	if ( aCurPath.Len() )
708*cdf0e10cSrcweir 		xFP->setDisplayDirectory ( aCurPath );
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 	xFP->setDefaultName( ::rtl::OUString( GetName() ) );
711*cdf0e10cSrcweir 
712*cdf0e10cSrcweir 	String aDialogStr( IDEResId( RID_STR_STDDIALOGNAME ) );
713*cdf0e10cSrcweir     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
714*cdf0e10cSrcweir 	xFltMgr->appendFilter( aDialogStr, String( RTL_CONSTASCII_USTRINGPARAM( "*.xdl" ) ) );
715*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
716*cdf0e10cSrcweir 	xFltMgr->setCurrentFilter( aDialogStr );
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir     if( xFP->execute() == RET_OK )
719*cdf0e10cSrcweir 	{
720*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
721*cdf0e10cSrcweir 		aCurPath = aPaths[0];
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir 		// export dialog model to xml
724*cdf0e10cSrcweir 		Reference< container::XNameContainer > xDialogModel = GetDialog();
725*cdf0e10cSrcweir 		Reference< XComponentContext > xContext;
726*cdf0e10cSrcweir 		Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
727*cdf0e10cSrcweir 		OSL_ASSERT( xProps.is() );
728*cdf0e10cSrcweir 		OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
729*cdf0e10cSrcweir 		Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
730*cdf0e10cSrcweir 		Reference< XInputStream > xInput( xISP->createInputStream() );
731*cdf0e10cSrcweir 
732*cdf0e10cSrcweir 		Reference< XSimpleFileAccess > xSFI( xMSF->createInstance
733*cdf0e10cSrcweir 			( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY );
734*cdf0e10cSrcweir 
735*cdf0e10cSrcweir 		Reference< XOutputStream > xOutput;
736*cdf0e10cSrcweir 		try
737*cdf0e10cSrcweir 		{
738*cdf0e10cSrcweir 			if( xSFI->exists( aCurPath ) )
739*cdf0e10cSrcweir 				xSFI->kill( aCurPath );
740*cdf0e10cSrcweir 			xOutput = xSFI->openFileWrite( aCurPath );
741*cdf0e10cSrcweir         }
742*cdf0e10cSrcweir         catch( Exception& )
743*cdf0e10cSrcweir         {}
744*cdf0e10cSrcweir 
745*cdf0e10cSrcweir 		if( xOutput.is() )
746*cdf0e10cSrcweir 		{
747*cdf0e10cSrcweir 			Sequence< sal_Int8 > bytes;
748*cdf0e10cSrcweir 			sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
749*cdf0e10cSrcweir 			for (;;)
750*cdf0e10cSrcweir 			{
751*cdf0e10cSrcweir 				if( nRead )
752*cdf0e10cSrcweir 					xOutput->writeBytes( bytes );
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir 				nRead = xInput->readBytes( bytes, 1024 );
755*cdf0e10cSrcweir 				if (! nRead)
756*cdf0e10cSrcweir 					break;
757*cdf0e10cSrcweir 			}
758*cdf0e10cSrcweir 			bDone = true;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir 			// With resource?
761*cdf0e10cSrcweir 			Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
762*cdf0e10cSrcweir 			Reference< resource::XStringResourceResolver > xStringResourceResolver;
763*cdf0e10cSrcweir 			if( xDialogModelPropSet.is() )
764*cdf0e10cSrcweir 			{
765*cdf0e10cSrcweir 				try
766*cdf0e10cSrcweir 				{
767*cdf0e10cSrcweir 					Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
768*cdf0e10cSrcweir 					aResourceResolver >>= xStringResourceResolver;
769*cdf0e10cSrcweir 				}
770*cdf0e10cSrcweir 				catch( beans::UnknownPropertyException& )
771*cdf0e10cSrcweir 				{}
772*cdf0e10cSrcweir 			}
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir 			bool bResource = false;
775*cdf0e10cSrcweir 			if( xStringResourceResolver.is() )
776*cdf0e10cSrcweir 			{
777*cdf0e10cSrcweir 				Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
778*cdf0e10cSrcweir 				sal_Int32 nLocaleCount = aLocaleSeq.getLength();
779*cdf0e10cSrcweir 				if( nLocaleCount > 0 )
780*cdf0e10cSrcweir 					bResource = true;
781*cdf0e10cSrcweir 			}
782*cdf0e10cSrcweir 
783*cdf0e10cSrcweir 			if( bResource )
784*cdf0e10cSrcweir 			{
785*cdf0e10cSrcweir 				INetURLObject aURLObj( aCurPath );
786*cdf0e10cSrcweir 				aURLObj.removeExtension();
787*cdf0e10cSrcweir 				::rtl::OUString aDialogName( aURLObj.getName() );
788*cdf0e10cSrcweir 				aURLObj.removeSegment();
789*cdf0e10cSrcweir 				::rtl::OUString aURL( aURLObj.GetMainURL( INetURLObject::NO_DECODE ) );
790*cdf0e10cSrcweir 				sal_Bool bReadOnly = sal_False;
791*cdf0e10cSrcweir 				::rtl::OUString aComment( ::rtl::OUString::createFromAscii( "# " ) );
792*cdf0e10cSrcweir 				aComment += aDialogName;
793*cdf0e10cSrcweir 				aComment += ::rtl::OUString::createFromAscii( " strings" );
794*cdf0e10cSrcweir 				Reference< task::XInteractionHandler > xDummyHandler;
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir 				// Remove old properties files in case of overwriting Dialog files
797*cdf0e10cSrcweir 				if( xSFI->isFolder( aURL ) )
798*cdf0e10cSrcweir 				{
799*cdf0e10cSrcweir 					Sequence< ::rtl::OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
800*cdf0e10cSrcweir 
801*cdf0e10cSrcweir 					::rtl::OUString aDialogName_( aDialogName );
802*cdf0e10cSrcweir 					aDialogName_ += ::rtl::OUString::createFromAscii( "_" );
803*cdf0e10cSrcweir 					sal_Int32 nCount = aContentSeq.getLength();
804*cdf0e10cSrcweir 					const ::rtl::OUString* pFiles = aContentSeq.getConstArray();
805*cdf0e10cSrcweir 					for( int i = 0 ; i < nCount ; i++ )
806*cdf0e10cSrcweir 					{
807*cdf0e10cSrcweir 						::rtl::OUString aCompleteName = pFiles[i];
808*cdf0e10cSrcweir 						rtl::OUString aPureName;
809*cdf0e10cSrcweir 						rtl::OUString aExtension;
810*cdf0e10cSrcweir 						sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
811*cdf0e10cSrcweir 						sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
812*cdf0e10cSrcweir 						if( iDot != -1 )
813*cdf0e10cSrcweir 						{
814*cdf0e10cSrcweir 							sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
815*cdf0e10cSrcweir 							aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
816*cdf0e10cSrcweir 							aExtension = aCompleteName.copy( iDot + 1 );
817*cdf0e10cSrcweir 						}
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir 						if( aExtension.equalsAscii( "properties" ) ||
820*cdf0e10cSrcweir 							aExtension.equalsAscii( "default" ) )
821*cdf0e10cSrcweir 						{
822*cdf0e10cSrcweir 							if( aPureName.indexOf( aDialogName_ ) == 0 )
823*cdf0e10cSrcweir 							{
824*cdf0e10cSrcweir 								try
825*cdf0e10cSrcweir 								{
826*cdf0e10cSrcweir 									xSFI->kill( aCompleteName );
827*cdf0e10cSrcweir 								}
828*cdf0e10cSrcweir 								catch( uno::Exception& )
829*cdf0e10cSrcweir 								{}
830*cdf0e10cSrcweir 							}
831*cdf0e10cSrcweir 						}
832*cdf0e10cSrcweir 					}
833*cdf0e10cSrcweir 				}
834*cdf0e10cSrcweir 
835*cdf0e10cSrcweir 				Reference< XStringResourceWithLocation > xStringResourceWithLocation =
836*cdf0e10cSrcweir 					StringResourceWithLocation::create( xContext, aURL, bReadOnly,
837*cdf0e10cSrcweir 						xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir 				// Add locales
840*cdf0e10cSrcweir 				Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
841*cdf0e10cSrcweir 				const lang::Locale* pLocales = aLocaleSeq.getConstArray();
842*cdf0e10cSrcweir 				sal_Int32 nLocaleCount = aLocaleSeq.getLength();
843*cdf0e10cSrcweir 				for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
844*cdf0e10cSrcweir 				{
845*cdf0e10cSrcweir 					const lang::Locale& rLocale = pLocales[ iLocale ];
846*cdf0e10cSrcweir 					xStringResourceWithLocation->newLocale( rLocale );
847*cdf0e10cSrcweir 				}
848*cdf0e10cSrcweir 
849*cdf0e10cSrcweir 				Reference< XStringResourceManager > xTargetStringResourceManager( xStringResourceWithLocation, uno::UNO_QUERY );
850*cdf0e10cSrcweir 
851*cdf0e10cSrcweir 				LocalizationMgr::copyResourceForDialog( xDialogModel,
852*cdf0e10cSrcweir 					xStringResourceResolver, xTargetStringResourceManager );
853*cdf0e10cSrcweir 
854*cdf0e10cSrcweir 				xStringResourceWithLocation->store();
855*cdf0e10cSrcweir 			}
856*cdf0e10cSrcweir 		}
857*cdf0e10cSrcweir 		else
858*cdf0e10cSrcweir 			ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTWRITE) ) ).Execute();
859*cdf0e10cSrcweir 	}
860*cdf0e10cSrcweir 
861*cdf0e10cSrcweir 	return bDone;
862*cdf0e10cSrcweir }
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir extern bool localesAreEqual( const ::com::sun::star::lang::Locale& rLocaleLeft,
865*cdf0e10cSrcweir 							 const ::com::sun::star::lang::Locale& rLocaleRight );
866*cdf0e10cSrcweir 
867*cdf0e10cSrcweir std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq
868*cdf0e10cSrcweir 	( Sequence< lang::Locale > aFirstSeq, Sequence< lang::Locale > aSecondSeq )
869*cdf0e10cSrcweir {
870*cdf0e10cSrcweir 	std::vector< lang::Locale > avRet;
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 	const lang::Locale* pFirst = aFirstSeq.getConstArray();
873*cdf0e10cSrcweir 	const lang::Locale* pSecond = aSecondSeq.getConstArray();
874*cdf0e10cSrcweir 	sal_Int32 nFirstCount = aFirstSeq.getLength();
875*cdf0e10cSrcweir 	sal_Int32 nSecondCount = aSecondSeq.getLength();
876*cdf0e10cSrcweir 
877*cdf0e10cSrcweir 	for( sal_Int32 iFirst = 0 ; iFirst < nFirstCount ; iFirst++ )
878*cdf0e10cSrcweir 	{
879*cdf0e10cSrcweir 		const lang::Locale& rFirstLocale = pFirst[ iFirst ];
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 		bool bAlsoContainedInSecondSeq = false;
882*cdf0e10cSrcweir 		for( sal_Int32 iSecond = 0 ; iSecond < nSecondCount ; iSecond++ )
883*cdf0e10cSrcweir 		{
884*cdf0e10cSrcweir 			const lang::Locale& rSecondLocale = pSecond[ iSecond ];
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir 			bool bMatch = localesAreEqual( rFirstLocale, rSecondLocale );
887*cdf0e10cSrcweir 			if( bMatch )
888*cdf0e10cSrcweir 			{
889*cdf0e10cSrcweir 				bAlsoContainedInSecondSeq = true;
890*cdf0e10cSrcweir 				break;
891*cdf0e10cSrcweir 			}
892*cdf0e10cSrcweir 		}
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir 		if( !bAlsoContainedInSecondSeq )
895*cdf0e10cSrcweir 			avRet.push_back( rFirstLocale );
896*cdf0e10cSrcweir 	}
897*cdf0e10cSrcweir 
898*cdf0e10cSrcweir 	return avRet;
899*cdf0e10cSrcweir }
900*cdf0e10cSrcweir 
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir class NameClashQueryBox : public MessBox
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir public:
905*cdf0e10cSrcweir 	NameClashQueryBox( Window* pParent,
906*cdf0e10cSrcweir 		const XubString& rTitle, const XubString& rMessage );
907*cdf0e10cSrcweir };
908*cdf0e10cSrcweir 
909*cdf0e10cSrcweir NameClashQueryBox::NameClashQueryBox( Window* pParent,
910*cdf0e10cSrcweir 	const XubString& rTitle, const XubString& rMessage )
911*cdf0e10cSrcweir 		: MessBox( pParent, 0, rTitle, rMessage )
912*cdf0e10cSrcweir {
913*cdf0e10cSrcweir 	if ( rTitle.Len() )
914*cdf0e10cSrcweir 		SetText( rTitle );
915*cdf0e10cSrcweir 
916*cdf0e10cSrcweir 	maMessText = rMessage;
917*cdf0e10cSrcweir 
918*cdf0e10cSrcweir 	AddButton( String( IDEResId( RID_STR_DLGIMP_CLASH_RENAME ) ), RET_YES,
919*cdf0e10cSrcweir 		BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
920*cdf0e10cSrcweir 	AddButton( String( IDEResId( RID_STR_DLGIMP_CLASH_REPLACE ) ), RET_NO, 0 );
921*cdf0e10cSrcweir 	AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
922*cdf0e10cSrcweir 
923*cdf0e10cSrcweir 	SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ?
924*cdf0e10cSrcweir         QueryBox::GetStandardImageHC() : QueryBox::GetStandardImage() );
925*cdf0e10cSrcweir }
926*cdf0e10cSrcweir 
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir class LanguageMismatchQueryBox : public MessBox
929*cdf0e10cSrcweir {
930*cdf0e10cSrcweir public:
931*cdf0e10cSrcweir 	LanguageMismatchQueryBox( Window* pParent,
932*cdf0e10cSrcweir 		const XubString& rTitle, const XubString& rMessage );
933*cdf0e10cSrcweir };
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir LanguageMismatchQueryBox::LanguageMismatchQueryBox( Window* pParent,
936*cdf0e10cSrcweir 	const XubString& rTitle, const XubString& rMessage )
937*cdf0e10cSrcweir 		: MessBox( pParent, 0, rTitle, rMessage )
938*cdf0e10cSrcweir {
939*cdf0e10cSrcweir 	if ( rTitle.Len() )
940*cdf0e10cSrcweir 		SetText( rTitle );
941*cdf0e10cSrcweir 
942*cdf0e10cSrcweir 	maMessText = rMessage;
943*cdf0e10cSrcweir 	AddButton( String( IDEResId( RID_STR_DLGIMP_MISMATCH_ADD ) ), RET_YES,
944*cdf0e10cSrcweir 		BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_OKBUTTON | BUTTONDIALOG_FOCUSBUTTON );
945*cdf0e10cSrcweir 	AddButton( String( IDEResId( RID_STR_DLGIMP_MISMATCH_OMIT ) ), RET_NO, 0 );
946*cdf0e10cSrcweir 	AddButton( BUTTON_CANCEL, RET_CANCEL, BUTTONDIALOG_CANCELBUTTON );
947*cdf0e10cSrcweir 	AddButton( BUTTON_HELP, BUTTONID_HELP, BUTTONDIALOG_HELPBUTTON, 4 );
948*cdf0e10cSrcweir 
949*cdf0e10cSrcweir 	SetImage( GetSettings().GetStyleSettings().GetHighContrastMode() ?
950*cdf0e10cSrcweir         QueryBox::GetStandardImageHC() : QueryBox::GetStandardImage() );
951*cdf0e10cSrcweir }
952*cdf0e10cSrcweir 
953*cdf0e10cSrcweir sal_Bool implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName )
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir 	sal_Bool bDone = sal_False;
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
958*cdf0e10cSrcweir     Reference < XFilePicker > xFP;
959*cdf0e10cSrcweir     if( xMSF.is() )
960*cdf0e10cSrcweir     {
961*cdf0e10cSrcweir 		Sequence <Any> aServiceType(1);
962*cdf0e10cSrcweir 		aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
963*cdf0e10cSrcweir         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
964*cdf0e10cSrcweir 					::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
965*cdf0e10cSrcweir     }
966*cdf0e10cSrcweir 
967*cdf0e10cSrcweir 	Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
968*cdf0e10cSrcweir 	xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
969*cdf0e10cSrcweir     Any aValue;
970*cdf0e10cSrcweir     aValue <<= (sal_Bool) sal_True;
971*cdf0e10cSrcweir 	xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
972*cdf0e10cSrcweir 
973*cdf0e10cSrcweir 	String aCurPath( rCurPath );
974*cdf0e10cSrcweir 	if ( aCurPath.Len() )
975*cdf0e10cSrcweir 		xFP->setDisplayDirectory ( aCurPath );
976*cdf0e10cSrcweir 
977*cdf0e10cSrcweir 	String aDialogStr( IDEResId( RID_STR_STDDIALOGNAME ) );
978*cdf0e10cSrcweir     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
979*cdf0e10cSrcweir 	xFltMgr->appendFilter( aDialogStr, String( RTL_CONSTASCII_USTRINGPARAM( "*.xdl" ) ) );
980*cdf0e10cSrcweir 	xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
981*cdf0e10cSrcweir 	xFltMgr->setCurrentFilter( aDialogStr );
982*cdf0e10cSrcweir 
983*cdf0e10cSrcweir     if( xFP->execute() == RET_OK )
984*cdf0e10cSrcweir 	{
985*cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
986*cdf0e10cSrcweir 		aCurPath = aPaths[0];
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir 		::rtl::OUString aBasePath;
989*cdf0e10cSrcweir 		::rtl::OUString aOUCurPath( aCurPath );
990*cdf0e10cSrcweir 		sal_Int32 iSlash = aOUCurPath.lastIndexOf( '/' );
991*cdf0e10cSrcweir 		if( iSlash != -1 )
992*cdf0e10cSrcweir 			aBasePath = aOUCurPath.copy( 0, iSlash + 1 );
993*cdf0e10cSrcweir 
994*cdf0e10cSrcweir 		try
995*cdf0e10cSrcweir 		{
996*cdf0e10cSrcweir 			// create dialog model
997*cdf0e10cSrcweir 			Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
998*cdf0e10cSrcweir 				( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY_THROW );
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir 			Reference< XSimpleFileAccess > xSFI( xMSF->createInstance
1001*cdf0e10cSrcweir 				( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY_THROW );
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir 			Reference< XInputStream > xInput;
1004*cdf0e10cSrcweir 			if( xSFI->exists( aCurPath ) )
1005*cdf0e10cSrcweir 				xInput = xSFI->openFileRead( aCurPath );
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir 			Reference< XComponentContext > xContext;
1008*cdf0e10cSrcweir 			Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
1009*cdf0e10cSrcweir 			OSL_ASSERT( xProps.is() );
1010*cdf0e10cSrcweir 			OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
1011*cdf0e10cSrcweir 			::xmlscript::importDialogModel( xInput, xDialogModel, xContext );
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir 			String aXmlDlgName;
1014*cdf0e10cSrcweir 			Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
1015*cdf0e10cSrcweir 			if( xDialogModelPropSet.is() )
1016*cdf0e10cSrcweir 			{
1017*cdf0e10cSrcweir 				try
1018*cdf0e10cSrcweir 				{
1019*cdf0e10cSrcweir 					Any aXmlDialogNameAny = xDialogModelPropSet->getPropertyValue( DLGED_PROP_NAME );
1020*cdf0e10cSrcweir 					::rtl::OUString aOUXmlDialogName;
1021*cdf0e10cSrcweir 					aXmlDialogNameAny >>= aOUXmlDialogName;
1022*cdf0e10cSrcweir 					aXmlDlgName = aOUXmlDialogName;
1023*cdf0e10cSrcweir 				}
1024*cdf0e10cSrcweir 				catch( beans::UnknownPropertyException& )
1025*cdf0e10cSrcweir 				{}
1026*cdf0e10cSrcweir 			}
1027*cdf0e10cSrcweir 			bool bValidName = (aXmlDlgName.Len() != 0);
1028*cdf0e10cSrcweir 			OSL_ASSERT( bValidName );
1029*cdf0e10cSrcweir 			if( !bValidName )
1030*cdf0e10cSrcweir 				return bDone;
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir 			bool bDialogAlreadyExists = rDocument.hasDialog( aLibName, aXmlDlgName );
1033*cdf0e10cSrcweir 
1034*cdf0e10cSrcweir 			String aNewDlgName = aXmlDlgName;
1035*cdf0e10cSrcweir 			enum NameClashMode
1036*cdf0e10cSrcweir 			{
1037*cdf0e10cSrcweir 				NO_CLASH,
1038*cdf0e10cSrcweir 				CLASH_OVERWRITE_DIALOG,
1039*cdf0e10cSrcweir 				CLASH_RENAME_DIALOG,
1040*cdf0e10cSrcweir 			};
1041*cdf0e10cSrcweir 			NameClashMode eNameClashMode = NO_CLASH;
1042*cdf0e10cSrcweir 			if( bDialogAlreadyExists )
1043*cdf0e10cSrcweir 			{
1044*cdf0e10cSrcweir 				String aQueryBoxTitle( IDEResId( RID_STR_DLGIMP_CLASH_TITLE ) );
1045*cdf0e10cSrcweir 				String aQueryBoxText( IDEResId( RID_STR_DLGIMP_CLASH_TEXT ) );
1046*cdf0e10cSrcweir 				aQueryBoxText.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "$(ARG1)" ) ), aXmlDlgName );
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir 				NameClashQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
1049*cdf0e10cSrcweir 				sal_uInt16 nRet = aQueryBox.Execute();
1050*cdf0e10cSrcweir 				if( RET_YES == nRet )
1051*cdf0e10cSrcweir 				{
1052*cdf0e10cSrcweir 					// RET_YES == Rename, see NameClashQueryBox::NameClashQueryBox
1053*cdf0e10cSrcweir 					eNameClashMode = CLASH_RENAME_DIALOG;
1054*cdf0e10cSrcweir 
1055*cdf0e10cSrcweir 					aNewDlgName = rDocument.createObjectName( E_DIALOGS, aLibName );
1056*cdf0e10cSrcweir 				}
1057*cdf0e10cSrcweir 				else if( RET_NO == nRet )
1058*cdf0e10cSrcweir 				{
1059*cdf0e10cSrcweir 					// RET_NO == Replace, see NameClashQueryBox::NameClashQueryBox
1060*cdf0e10cSrcweir 					eNameClashMode = CLASH_OVERWRITE_DIALOG;
1061*cdf0e10cSrcweir 				}
1062*cdf0e10cSrcweir 				else if( RET_CANCEL == nRet )
1063*cdf0e10cSrcweir 				{
1064*cdf0e10cSrcweir 					return bDone;
1065*cdf0e10cSrcweir 				}
1066*cdf0e10cSrcweir 			}
1067*cdf0e10cSrcweir 
1068*cdf0e10cSrcweir 			BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
1069*cdf0e10cSrcweir 			if( pIDEShell == NULL )
1070*cdf0e10cSrcweir 			{
1071*cdf0e10cSrcweir 				OSL_ASSERT( pIDEShell != NULL );
1072*cdf0e10cSrcweir 				return bDone;
1073*cdf0e10cSrcweir 			}
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir 			// Resource?
1076*cdf0e10cSrcweir 			::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
1077*cdf0e10cSrcweir 			Reference< task::XInteractionHandler > xDummyHandler;
1078*cdf0e10cSrcweir 			bool bReadOnly = true;
1079*cdf0e10cSrcweir 			Reference< XStringResourceWithLocation > xImportStringResource =
1080*cdf0e10cSrcweir 				StringResourceWithLocation::create( xContext, aBasePath, bReadOnly,
1081*cdf0e10cSrcweir 				aLocale, aXmlDlgName, ::rtl::OUString(), xDummyHandler );
1082*cdf0e10cSrcweir 
1083*cdf0e10cSrcweir 			Sequence< lang::Locale > aImportLocaleSeq = xImportStringResource->getLocales();
1084*cdf0e10cSrcweir 			sal_Int32 nImportLocaleCount = aImportLocaleSeq.getLength();
1085*cdf0e10cSrcweir 
1086*cdf0e10cSrcweir 			Reference< container::XNameContainer > xDialogLib( rDocument.getLibrary( E_DIALOGS, aLibName, sal_True ) );
1087*cdf0e10cSrcweir 			Reference< resource::XStringResourceManager > xLibStringResourceManager = LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
1088*cdf0e10cSrcweir 			sal_Int32 nLibLocaleCount = 0;
1089*cdf0e10cSrcweir 			Sequence< lang::Locale > aLibLocaleSeq;
1090*cdf0e10cSrcweir 			if( xLibStringResourceManager.is() )
1091*cdf0e10cSrcweir 			{
1092*cdf0e10cSrcweir 				aLibLocaleSeq = xLibStringResourceManager->getLocales();
1093*cdf0e10cSrcweir 				nLibLocaleCount = aLibLocaleSeq.getLength();
1094*cdf0e10cSrcweir 			}
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir 			// Check language matches
1097*cdf0e10cSrcweir 			std::vector< lang::Locale > aOnlyInImportLanguages =
1098*cdf0e10cSrcweir 				implGetLanguagesOnlyContainedInFirstSeq( aImportLocaleSeq, aLibLocaleSeq );
1099*cdf0e10cSrcweir 			int nOnlyInImportLanguageCount = aOnlyInImportLanguages.size();
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir 			// For now: Keep languages from lib
1102*cdf0e10cSrcweir 			bool bLibLocalized = (nLibLocaleCount > 0);
1103*cdf0e10cSrcweir 			bool bImportLocalized = (nImportLocaleCount > 0);
1104*cdf0e10cSrcweir 
1105*cdf0e10cSrcweir 			bool bAddDialogLanguagesToLib = false;
1106*cdf0e10cSrcweir 			if( nOnlyInImportLanguageCount > 0 )
1107*cdf0e10cSrcweir 			{
1108*cdf0e10cSrcweir 				String aQueryBoxTitle( IDEResId( RID_STR_DLGIMP_MISMATCH_TITLE ) );
1109*cdf0e10cSrcweir 				String aQueryBoxText( IDEResId( RID_STR_DLGIMP_MISMATCH_TEXT ) );
1110*cdf0e10cSrcweir 				LanguageMismatchQueryBox aQueryBox( pWin, aQueryBoxTitle, aQueryBoxText );
1111*cdf0e10cSrcweir 				sal_uInt16 nRet = aQueryBox.Execute();
1112*cdf0e10cSrcweir 				if( RET_YES == nRet )
1113*cdf0e10cSrcweir 				{
1114*cdf0e10cSrcweir 					// RET_YES == Add, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
1115*cdf0e10cSrcweir 					bAddDialogLanguagesToLib = true;
1116*cdf0e10cSrcweir 				}
1117*cdf0e10cSrcweir 				// RET_NO == Omit, see LanguageMismatchQueryBox::LanguageMismatchQueryBox
1118*cdf0e10cSrcweir 				// -> nothing to do here
1119*cdf0e10cSrcweir 				//else if( RET_NO == nRet )
1120*cdf0e10cSrcweir 				//{
1121*cdf0e10cSrcweir 				//}
1122*cdf0e10cSrcweir 				else if( RET_CANCEL == nRet )
1123*cdf0e10cSrcweir 				{
1124*cdf0e10cSrcweir 					return bDone;
1125*cdf0e10cSrcweir 				}
1126*cdf0e10cSrcweir 			}
1127*cdf0e10cSrcweir 
1128*cdf0e10cSrcweir 			if( bImportLocalized )
1129*cdf0e10cSrcweir 			{
1130*cdf0e10cSrcweir 				bool bCopyResourcesForDialog = true;
1131*cdf0e10cSrcweir 				if( bAddDialogLanguagesToLib )
1132*cdf0e10cSrcweir 				{
1133*cdf0e10cSrcweir 					LocalizationMgr* pCurMgr = pIDEShell->GetCurLocalizationMgr();
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir 					lang::Locale aFirstLocale;
1136*cdf0e10cSrcweir 					aFirstLocale = aOnlyInImportLanguages[0];
1137*cdf0e10cSrcweir 					if( nOnlyInImportLanguageCount > 1 )
1138*cdf0e10cSrcweir 					{
1139*cdf0e10cSrcweir 						// Check if import default belongs to only import languages and use it then
1140*cdf0e10cSrcweir 						lang::Locale aImportDefaultLocale = xImportStringResource->getDefaultLocale();
1141*cdf0e10cSrcweir 						lang::Locale aTmpLocale;
1142*cdf0e10cSrcweir 						for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
1143*cdf0e10cSrcweir 						{
1144*cdf0e10cSrcweir 							aTmpLocale = aOnlyInImportLanguages[i];
1145*cdf0e10cSrcweir 							if( localesAreEqual( aImportDefaultLocale, aTmpLocale ) )
1146*cdf0e10cSrcweir 							{
1147*cdf0e10cSrcweir 								aFirstLocale = aImportDefaultLocale;
1148*cdf0e10cSrcweir 								break;
1149*cdf0e10cSrcweir 							}
1150*cdf0e10cSrcweir 						}
1151*cdf0e10cSrcweir 					}
1152*cdf0e10cSrcweir 
1153*cdf0e10cSrcweir 					Sequence< lang::Locale > aFirstLocaleSeq( 1 );
1154*cdf0e10cSrcweir 					aFirstLocaleSeq[0] = aFirstLocale;
1155*cdf0e10cSrcweir 					pCurMgr->handleAddLocales( aFirstLocaleSeq );
1156*cdf0e10cSrcweir 
1157*cdf0e10cSrcweir 					if( nOnlyInImportLanguageCount > 1 )
1158*cdf0e10cSrcweir 					{
1159*cdf0e10cSrcweir 						Sequence< lang::Locale > aRemainingLocaleSeq( nOnlyInImportLanguageCount - 1 );
1160*cdf0e10cSrcweir 						lang::Locale aTmpLocale;
1161*cdf0e10cSrcweir 						int iSeq = 0;
1162*cdf0e10cSrcweir 						for( int i = 0 ; i < nOnlyInImportLanguageCount ; ++i )
1163*cdf0e10cSrcweir 						{
1164*cdf0e10cSrcweir 							aTmpLocale = aOnlyInImportLanguages[i];
1165*cdf0e10cSrcweir 							if( !localesAreEqual( aFirstLocale, aTmpLocale ) )
1166*cdf0e10cSrcweir 								aRemainingLocaleSeq[iSeq++] = aTmpLocale;
1167*cdf0e10cSrcweir 						}
1168*cdf0e10cSrcweir 						pCurMgr->handleAddLocales( aRemainingLocaleSeq );
1169*cdf0e10cSrcweir 					}
1170*cdf0e10cSrcweir 				}
1171*cdf0e10cSrcweir 				else if( !bLibLocalized )
1172*cdf0e10cSrcweir 				{
1173*cdf0e10cSrcweir 					Reference< resource::XStringResourceManager > xImportStringResourceManager( xImportStringResource, UNO_QUERY );
1174*cdf0e10cSrcweir 					LocalizationMgr::resetResourceForDialog( xDialogModel, xImportStringResourceManager );
1175*cdf0e10cSrcweir 					bCopyResourcesForDialog = false;
1176*cdf0e10cSrcweir 				}
1177*cdf0e10cSrcweir 
1178*cdf0e10cSrcweir 				if( bCopyResourcesForDialog )
1179*cdf0e10cSrcweir 				{
1180*cdf0e10cSrcweir 					Reference< resource::XStringResourceResolver > xImportStringResourceResolver( xImportStringResource, UNO_QUERY );
1181*cdf0e10cSrcweir 					LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, aXmlDlgName,
1182*cdf0e10cSrcweir 						xLibStringResourceManager, xImportStringResourceResolver );
1183*cdf0e10cSrcweir 				}
1184*cdf0e10cSrcweir 			}
1185*cdf0e10cSrcweir 			else if( bLibLocalized )
1186*cdf0e10cSrcweir 			{
1187*cdf0e10cSrcweir 				LocalizationMgr::setResourceIDsForDialog( xDialogModel, xLibStringResourceManager );
1188*cdf0e10cSrcweir 			}
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir 
1191*cdf0e10cSrcweir 			LocalizationMgr::setStringResourceAtDialog( rDocument, aLibName, aNewDlgName, xDialogModel );
1192*cdf0e10cSrcweir 
1193*cdf0e10cSrcweir 			if( eNameClashMode == CLASH_OVERWRITE_DIALOG )
1194*cdf0e10cSrcweir 			{
1195*cdf0e10cSrcweir                 if ( BasicIDE::RemoveDialog( rDocument, aLibName, aNewDlgName ) )
1196*cdf0e10cSrcweir                 {
1197*cdf0e10cSrcweir 					IDEBaseWindow* pDlgWin = pIDEShell->FindDlgWin( rDocument, aLibName, aNewDlgName, sal_False, sal_True );
1198*cdf0e10cSrcweir 					if( pDlgWin != NULL )
1199*cdf0e10cSrcweir 					    pIDEShell->RemoveWindow( pDlgWin, sal_True );
1200*cdf0e10cSrcweir 				    BasicIDE::MarkDocumentModified( rDocument );
1201*cdf0e10cSrcweir                 }
1202*cdf0e10cSrcweir 				else
1203*cdf0e10cSrcweir 				{
1204*cdf0e10cSrcweir 					// TODO: Assertion?
1205*cdf0e10cSrcweir 					return bDone;
1206*cdf0e10cSrcweir 				}
1207*cdf0e10cSrcweir 			}
1208*cdf0e10cSrcweir 
1209*cdf0e10cSrcweir 			if( eNameClashMode == CLASH_RENAME_DIALOG )
1210*cdf0e10cSrcweir 			{
1211*cdf0e10cSrcweir 				bool bRenamed = false;
1212*cdf0e10cSrcweir 				if( xDialogModelPropSet.is() )
1213*cdf0e10cSrcweir 				{
1214*cdf0e10cSrcweir 					try
1215*cdf0e10cSrcweir 					{
1216*cdf0e10cSrcweir 						Any aXmlDialogNameAny;
1217*cdf0e10cSrcweir 						aXmlDialogNameAny <<= ::rtl::OUString( aNewDlgName );
1218*cdf0e10cSrcweir 						xDialogModelPropSet->setPropertyValue( DLGED_PROP_NAME, aXmlDialogNameAny );
1219*cdf0e10cSrcweir 						bRenamed = true;
1220*cdf0e10cSrcweir 					}
1221*cdf0e10cSrcweir 					catch( beans::UnknownPropertyException& )
1222*cdf0e10cSrcweir 					{}
1223*cdf0e10cSrcweir 				}
1224*cdf0e10cSrcweir 
1225*cdf0e10cSrcweir 
1226*cdf0e10cSrcweir 				if( bRenamed )
1227*cdf0e10cSrcweir 				{
1228*cdf0e10cSrcweir 			        LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel );
1229*cdf0e10cSrcweir 				}
1230*cdf0e10cSrcweir 				else
1231*cdf0e10cSrcweir 				{
1232*cdf0e10cSrcweir 					// TODO: Assertion?
1233*cdf0e10cSrcweir 					return bDone;
1234*cdf0e10cSrcweir 				}
1235*cdf0e10cSrcweir 			}
1236*cdf0e10cSrcweir 
1237*cdf0e10cSrcweir 			Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
1238*cdf0e10cSrcweir 			bool bSuccess = rDocument.insertDialog( aLibName, aNewDlgName, xISP );
1239*cdf0e10cSrcweir 			if( bSuccess )
1240*cdf0e10cSrcweir 			{
1241*cdf0e10cSrcweir 				DialogWindow* pNewDlgWin = pIDEShell->CreateDlgWin( rDocument, aLibName, aNewDlgName );
1242*cdf0e10cSrcweir 				pIDEShell->SetCurWindow( pNewDlgWin, sal_True );
1243*cdf0e10cSrcweir 			}
1244*cdf0e10cSrcweir 
1245*cdf0e10cSrcweir 			bDone = sal_True;
1246*cdf0e10cSrcweir         }
1247*cdf0e10cSrcweir         catch( Exception& )
1248*cdf0e10cSrcweir         {}
1249*cdf0e10cSrcweir 	}
1250*cdf0e10cSrcweir 
1251*cdf0e10cSrcweir 	return bDone;
1252*cdf0e10cSrcweir }
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir sal_Bool DialogWindow::ImportDialog()
1255*cdf0e10cSrcweir {
1256*cdf0e10cSrcweir 	DBG_CHKTHIS( DialogWindow, 0 );
1257*cdf0e10cSrcweir 
1258*cdf0e10cSrcweir 	const ScriptDocument& rDocument = GetDocument();
1259*cdf0e10cSrcweir 	String aLibName = GetLibName();
1260*cdf0e10cSrcweir 	sal_Bool bRet = implImportDialog( this, aCurPath, rDocument, aLibName );
1261*cdf0e10cSrcweir 	return bRet;
1262*cdf0e10cSrcweir }
1263*cdf0e10cSrcweir 
1264*cdf0e10cSrcweir DlgEdModel* DialogWindow::GetModel() const
1265*cdf0e10cSrcweir {
1266*cdf0e10cSrcweir 	return pEditor ? pEditor->GetModel() : NULL;
1267*cdf0e10cSrcweir }
1268*cdf0e10cSrcweir 
1269*cdf0e10cSrcweir DlgEdPage* DialogWindow::GetPage() const
1270*cdf0e10cSrcweir {
1271*cdf0e10cSrcweir 	return pEditor ? pEditor->GetPage() : NULL;
1272*cdf0e10cSrcweir }
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir DlgEdView* DialogWindow::GetView() const
1275*cdf0e10cSrcweir {
1276*cdf0e10cSrcweir 	return pEditor ? pEditor->GetView() : NULL;
1277*cdf0e10cSrcweir }
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir sal_Bool __EXPORT DialogWindow::IsModified()
1280*cdf0e10cSrcweir {
1281*cdf0e10cSrcweir 	return pEditor->IsModified();
1282*cdf0e10cSrcweir }
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir ::svl::IUndoManager* __EXPORT DialogWindow::GetUndoManager()
1285*cdf0e10cSrcweir {
1286*cdf0e10cSrcweir 	return pUndoMgr;
1287*cdf0e10cSrcweir }
1288*cdf0e10cSrcweir 
1289*cdf0e10cSrcweir String DialogWindow::GetTitle()
1290*cdf0e10cSrcweir {
1291*cdf0e10cSrcweir 	return GetName();
1292*cdf0e10cSrcweir }
1293*cdf0e10cSrcweir 
1294*cdf0e10cSrcweir BasicEntryDescriptor DialogWindow::CreateEntryDescriptor()
1295*cdf0e10cSrcweir {
1296*cdf0e10cSrcweir     ScriptDocument aDocument( GetDocument() );
1297*cdf0e10cSrcweir     String aLibName( GetLibName() );
1298*cdf0e10cSrcweir     String aLibSubName;
1299*cdf0e10cSrcweir     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
1300*cdf0e10cSrcweir     return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, GetName(), OBJ_TYPE_DIALOG );
1301*cdf0e10cSrcweir }
1302*cdf0e10cSrcweir 
1303*cdf0e10cSrcweir void DialogWindow::SetReadOnly( sal_Bool b )
1304*cdf0e10cSrcweir {
1305*cdf0e10cSrcweir     if ( pEditor )
1306*cdf0e10cSrcweir     {
1307*cdf0e10cSrcweir         if ( b )
1308*cdf0e10cSrcweir             pEditor->SetMode( DLGED_READONLY );
1309*cdf0e10cSrcweir         else
1310*cdf0e10cSrcweir             pEditor->SetMode( DLGED_SELECT );
1311*cdf0e10cSrcweir     }
1312*cdf0e10cSrcweir }
1313*cdf0e10cSrcweir 
1314*cdf0e10cSrcweir sal_Bool DialogWindow::IsReadOnly()
1315*cdf0e10cSrcweir {
1316*cdf0e10cSrcweir     sal_Bool bReadOnly = sal_False;
1317*cdf0e10cSrcweir 
1318*cdf0e10cSrcweir     if ( pEditor && pEditor->GetMode() == DLGED_READONLY )
1319*cdf0e10cSrcweir         bReadOnly = sal_True;
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir     return bReadOnly;
1322*cdf0e10cSrcweir }
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir sal_Bool DialogWindow::IsPasteAllowed()
1325*cdf0e10cSrcweir {
1326*cdf0e10cSrcweir     return pEditor ? pEditor->IsPasteAllowed() : sal_False;
1327*cdf0e10cSrcweir }
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir void DialogWindow::StoreData()
1330*cdf0e10cSrcweir {
1331*cdf0e10cSrcweir 	if ( IsModified() )
1332*cdf0e10cSrcweir 	{
1333*cdf0e10cSrcweir 		try
1334*cdf0e10cSrcweir 		{
1335*cdf0e10cSrcweir 			Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir 			if( xLib.is() )
1338*cdf0e10cSrcweir 			{
1339*cdf0e10cSrcweir 				Reference< container::XNameContainer > xDialogModel = pEditor->GetDialog();
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir 				if( xDialogModel.is() )
1342*cdf0e10cSrcweir 				{
1343*cdf0e10cSrcweir                     Reference< XComponentContext > xContext;
1344*cdf0e10cSrcweir                     Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
1345*cdf0e10cSrcweir                     OSL_ASSERT( xProps.is() );
1346*cdf0e10cSrcweir                     OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
1347*cdf0e10cSrcweir 					Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext );
1348*cdf0e10cSrcweir 					xLib->replaceByName( ::rtl::OUString( GetName() ), makeAny( xISP ) );
1349*cdf0e10cSrcweir 				}
1350*cdf0e10cSrcweir 			}
1351*cdf0e10cSrcweir 		}
1352*cdf0e10cSrcweir 		catch ( uno::Exception& )
1353*cdf0e10cSrcweir 		{
1354*cdf0e10cSrcweir 			DBG_UNHANDLED_EXCEPTION();
1355*cdf0e10cSrcweir 		}
1356*cdf0e10cSrcweir         BasicIDE::MarkDocumentModified( GetDocument() );
1357*cdf0e10cSrcweir         pEditor->ClearModifyFlag();
1358*cdf0e10cSrcweir 	}
1359*cdf0e10cSrcweir }
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir void DialogWindow::Deactivating()
1362*cdf0e10cSrcweir {
1363*cdf0e10cSrcweir 	if ( IsModified() )
1364*cdf0e10cSrcweir 		BasicIDE::MarkDocumentModified( GetDocument() );
1365*cdf0e10cSrcweir }
1366*cdf0e10cSrcweir 
1367*cdf0e10cSrcweir sal_Int32 DialogWindow::countPages( Printer* pPrinter )
1368*cdf0e10cSrcweir {
1369*cdf0e10cSrcweir     return pEditor->countPages( pPrinter );
1370*cdf0e10cSrcweir }
1371*cdf0e10cSrcweir 
1372*cdf0e10cSrcweir void DialogWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
1373*cdf0e10cSrcweir {
1374*cdf0e10cSrcweir     pEditor->printPage( nPage, pPrinter, CreateQualifiedName() );
1375*cdf0e10cSrcweir }
1376*cdf0e10cSrcweir 
1377*cdf0e10cSrcweir void DialogWindow::DataChanged( const DataChangedEvent& rDCEvt )
1378*cdf0e10cSrcweir {
1379*cdf0e10cSrcweir 	if( (rDCEvt.GetType()==DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
1380*cdf0e10cSrcweir 	{
1381*cdf0e10cSrcweir 		InitSettings( sal_True, sal_True, sal_True );
1382*cdf0e10cSrcweir 		Invalidate();
1383*cdf0e10cSrcweir 	}
1384*cdf0e10cSrcweir 	else
1385*cdf0e10cSrcweir 		IDEBaseWindow::DataChanged( rDCEvt );
1386*cdf0e10cSrcweir }
1387*cdf0e10cSrcweir 
1388*cdf0e10cSrcweir void DialogWindow::InitSettings(sal_Bool bFont,sal_Bool bForeground,sal_Bool bBackground)
1389*cdf0e10cSrcweir {
1390*cdf0e10cSrcweir 	const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
1391*cdf0e10cSrcweir 	if( bFont )
1392*cdf0e10cSrcweir 	{
1393*cdf0e10cSrcweir 		Font aFont;
1394*cdf0e10cSrcweir 		aFont = rStyleSettings.GetFieldFont();
1395*cdf0e10cSrcweir 		SetPointFont( aFont );
1396*cdf0e10cSrcweir 	}
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir 	if( bForeground || bFont )
1399*cdf0e10cSrcweir 	{
1400*cdf0e10cSrcweir 		SetTextColor( rStyleSettings.GetFieldTextColor() );
1401*cdf0e10cSrcweir 		SetTextFillColor();
1402*cdf0e10cSrcweir 	}
1403*cdf0e10cSrcweir 
1404*cdf0e10cSrcweir 	if( bBackground )
1405*cdf0e10cSrcweir 		SetBackground( rStyleSettings.GetFieldColor() );
1406*cdf0e10cSrcweir }
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > DialogWindow::CreateAccessible()
1409*cdf0e10cSrcweir {
1410*cdf0e10cSrcweir 	return (::com::sun::star::accessibility::XAccessible*) new AccessibleDialogWindow( this );
1411*cdf0e10cSrcweir }
1412