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