xref: /aoo42x/main/sc/source/ui/miscdlgs/instbdlg.cxx (revision a479921a)
1b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5b3f79822SAndrew Rist  * distributed with this work for additional information
6b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10b3f79822SAndrew Rist  *
11b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12b3f79822SAndrew Rist  *
13b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17b3f79822SAndrew Rist  * specific language governing permissions and limitations
18b3f79822SAndrew Rist  * under the License.
19b3f79822SAndrew Rist  *
20b3f79822SAndrew Rist  *************************************************************/
21b3f79822SAndrew Rist 
22b3f79822SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25*b77af630Sdamjan #include "precompiled_scui.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir 
30cdf0e10cSrcweir //------------------------------------------------------------------
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <sfx2/app.hxx>
33cdf0e10cSrcweir #include <sfx2/docfile.hxx>
34cdf0e10cSrcweir #include <sfx2/docinsert.hxx>
35cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
36cdf0e10cSrcweir #include <svtools/ehdl.hxx>
37cdf0e10cSrcweir #include <svtools/sfxecode.hxx>
38cdf0e10cSrcweir #include <vcl/msgbox.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "global.hxx"
41cdf0e10cSrcweir #include "docsh.hxx"
42cdf0e10cSrcweir #include "viewdata.hxx"
43cdf0e10cSrcweir #include "scresid.hxx"
44cdf0e10cSrcweir #include "instbdlg.hrc"
45cdf0e10cSrcweir #include "globstr.hrc"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #define SC_INSTBDLG_CXX
48cdf0e10cSrcweir #include "instbdlg.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <layout/layout-pre.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #if ENABLE_LAYOUT
53cdf0e10cSrcweir #undef ScResId
54cdf0e10cSrcweir #define ScResId(x) #x
55cdf0e10cSrcweir #undef ModalDialog
56cdf0e10cSrcweir #define ModalDialog( parent, id ) Dialog( parent, "insert-sheet.xml", id )
57cdf0e10cSrcweir #undef ErrorBox
58cdf0e10cSrcweir #define ErrorBox( this, bits, message ) ErrorBox (LAYOUT_THIS_WINDOW (this), bits, message)
59cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
60cdf0e10cSrcweir 
61cdf0e10cSrcweir //==================================================================
62cdf0e10cSrcweir 
ScInsertTableDlg(Window * pParent,ScViewData & rData,SCTAB nTabCount,bool bFromFile)63cdf0e10cSrcweir ScInsertTableDlg::ScInsertTableDlg( Window* pParent, ScViewData& rData, SCTAB nTabCount, bool bFromFile )
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	:	ModalDialog ( pParent, ScResId( RID_SCDLG_INSERT_TABLE ) ),
66cdf0e10cSrcweir 		//
67cdf0e10cSrcweir 		aFlPos			( this, ScResId( FL_POSITION ) ),
68cdf0e10cSrcweir 		aBtnBefore		( this, ScResId( RB_BEFORE ) ),
69cdf0e10cSrcweir 		aBtnBehind		( this, ScResId( RB_BEHIND ) ),
70cdf0e10cSrcweir 		aFlTable    	( this, ScResId( FL_TABLE ) ),
71cdf0e10cSrcweir 		aBtnNew   		( this, ScResId( RB_NEW ) ),
72cdf0e10cSrcweir 		aBtnFromFile    ( this, ScResId( RB_FROMFILE ) ),
73cdf0e10cSrcweir 		aFtCount		( this, ScResId( FT_COUNT ) ),
74cdf0e10cSrcweir 		aNfCount		( this, ScResId( NF_COUNT ) ),
75cdf0e10cSrcweir 		aFtName			( this, ScResId( FT_NAME ) ),
76cdf0e10cSrcweir 		aEdName			( this, ScResId( ED_TABNAME ) ),
77cdf0e10cSrcweir 		aLbTables		( this, ScResId( LB_TABLES ) ),
78cdf0e10cSrcweir 		aFtPath			( this, ScResId( FT_PATH ) ),
79cdf0e10cSrcweir 		aBtnBrowse		( this, ScResId( BTN_BROWSE ) ),
80cdf0e10cSrcweir 		aBtnLink		( this, ScResId( CB_LINK ) ),
81cdf0e10cSrcweir 		aBtnOk			( this, ScResId( BTN_OK ) ),
82cdf0e10cSrcweir 		aBtnCancel		( this, ScResId( BTN_CANCEL ) ),
83cdf0e10cSrcweir 		aBtnHelp		( this, ScResId( BTN_HELP ) ),
84cdf0e10cSrcweir 		rViewData		( rData ),
85cdf0e10cSrcweir 		rDoc			( *rData.GetDocument() ),
86cdf0e10cSrcweir 		pDocShTables	( NULL ),
87cdf0e10cSrcweir         pDocInserter    ( NULL ),
88cdf0e10cSrcweir         bMustClose      ( false ),
89cdf0e10cSrcweir 		nSelTabIndex	( 0 ),
90cdf0e10cSrcweir 		nTableCount		(nTabCount)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir #if ENABLE_LAYOUT
93cdf0e10cSrcweir     SetHelpId (SID_INSERT_TABLE);
94cdf0e10cSrcweir     aFtPath.SetText (EMPTY_STRING);
95cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
96cdf0e10cSrcweir     Init_Impl( bFromFile );
97cdf0e10cSrcweir 	FreeResource();
98cdf0e10cSrcweir 	aLbTables.SetAccessibleName(aBtnFromFile.GetText());
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir //------------------------------------------------------------------------
102cdf0e10cSrcweir 
~ScInsertTableDlg()103cdf0e10cSrcweir __EXPORT ScInsertTableDlg::~ScInsertTableDlg()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir 	if (pDocShTables)
106cdf0e10cSrcweir 		pDocShTables->DoClose();
107cdf0e10cSrcweir     delete pDocInserter;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir //------------------------------------------------------------------------
111cdf0e10cSrcweir 
Init_Impl(bool bFromFile)112cdf0e10cSrcweir void ScInsertTableDlg::Init_Impl( bool bFromFile )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	aBtnBrowse		.SetClickHdl( LINK( this, ScInsertTableDlg, BrowseHdl_Impl ) );
115cdf0e10cSrcweir 	aBtnNew			.SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
116cdf0e10cSrcweir 	aBtnFromFile	.SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
117cdf0e10cSrcweir 	aLbTables		.SetSelectHdl( LINK( this, ScInsertTableDlg, SelectHdl_Impl ) );
118cdf0e10cSrcweir 	aNfCount		.SetModifyHdl( LINK( this, ScInsertTableDlg, CountHdl_Impl));
119cdf0e10cSrcweir 	aBtnOk			.SetClickHdl( LINK( this, ScInsertTableDlg, DoEnterHdl ));
120cdf0e10cSrcweir 	aBtnBefore.Check();
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	aNfCount.SetText( String::CreateFromInt32(nTableCount) );
123cdf0e10cSrcweir 	aNfCount.SetMax( MAXTAB - rDoc.GetTableCount() + 1 );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	if(nTableCount==1)
126cdf0e10cSrcweir 	{
127cdf0e10cSrcweir 		String aName;
128cdf0e10cSrcweir 		rDoc.CreateValidTabName( aName );
129cdf0e10cSrcweir 		aEdName.SetText( aName );
130cdf0e10cSrcweir 	}
131cdf0e10cSrcweir 	else
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir 		String aName=aFlTable.GetText();
134cdf0e10cSrcweir 		aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
135cdf0e10cSrcweir 		aEdName.SetText( aName );
136cdf0e10cSrcweir 		aFtName.Disable();
137cdf0e10cSrcweir 		aEdName.Disable();
138cdf0e10cSrcweir 	}
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     bool bShared = ( rViewData.GetDocShell() ? rViewData.GetDocShell()->IsDocShared() : false );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     if ( !bFromFile || bShared )
143cdf0e10cSrcweir     {
144cdf0e10cSrcweir         aBtnNew.Check();
145cdf0e10cSrcweir         SetNewTable_Impl();
146cdf0e10cSrcweir         if ( bShared )
147cdf0e10cSrcweir         {
148cdf0e10cSrcweir             aBtnFromFile.Disable();
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir     else
152cdf0e10cSrcweir     {
153cdf0e10cSrcweir         aBtnFromFile.Check();
154cdf0e10cSrcweir         SetFromTo_Impl();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir         aBrowseTimer.SetTimeoutHdl( LINK( this, ScInsertTableDlg, BrowseTimeoutHdl ) );
157cdf0e10cSrcweir         aBrowseTimer.SetTimeout( 200 );
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir }
160cdf0e10cSrcweir 
161cdf0e10cSrcweir //------------------------------------------------------------------------
162cdf0e10cSrcweir 
163cdf0e10cSrcweir #if ENABLE_LAYOUT
164cdf0e10cSrcweir #undef ModalDialog
165cdf0e10cSrcweir #define ModalDialog Dialog
166cdf0e10cSrcweir #endif /* ENABLE_LAYOUT */
167cdf0e10cSrcweir 
Execute()168cdf0e10cSrcweir short __EXPORT ScInsertTableDlg::Execute()
169cdf0e10cSrcweir {
170cdf0e10cSrcweir     // set Parent of DocumentInserter and Doc-Manager
171cdf0e10cSrcweir 	Window*	pOldDefParent = Application::GetDefDialogParent();
172cdf0e10cSrcweir 	Application::SetDefDialogParent( LAYOUT_THIS_WINDOW (this) );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     if ( aBtnFromFile.IsChecked() )
175cdf0e10cSrcweir         aBrowseTimer.Start();
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     short nRet = ModalDialog::Execute();
178cdf0e10cSrcweir 	Application::SetDefDialogParent( pOldDefParent );
179cdf0e10cSrcweir 	return nRet;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir 
182cdf0e10cSrcweir //------------------------------------------------------------------------
183cdf0e10cSrcweir 
SetNewTable_Impl()184cdf0e10cSrcweir void ScInsertTableDlg::SetNewTable_Impl()
185cdf0e10cSrcweir {
186cdf0e10cSrcweir 	if (aBtnNew.IsChecked() )
187cdf0e10cSrcweir 	{
188cdf0e10cSrcweir 		aNfCount	.Enable();
189cdf0e10cSrcweir 		aFtCount	.Enable();
190cdf0e10cSrcweir 		aLbTables	.Disable();
191cdf0e10cSrcweir 		aFtPath		.Disable();
192cdf0e10cSrcweir 		aBtnBrowse	.Disable();
193cdf0e10cSrcweir 		aBtnLink	.Disable();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 		if(nTableCount==1)
196cdf0e10cSrcweir 		{
197cdf0e10cSrcweir 			aEdName.Enable();
198cdf0e10cSrcweir 			aFtName.Enable();
199cdf0e10cSrcweir 		}
200cdf0e10cSrcweir 	}
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir //------------------------------------------------------------------------
204cdf0e10cSrcweir 
SetFromTo_Impl()205cdf0e10cSrcweir void ScInsertTableDlg::SetFromTo_Impl()
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	if (aBtnFromFile.IsChecked() )
208cdf0e10cSrcweir 	{
209cdf0e10cSrcweir 		aEdName		.Disable();
210cdf0e10cSrcweir 		aFtName		.Disable();
211cdf0e10cSrcweir 		aFtCount	.Disable();
212cdf0e10cSrcweir 		aNfCount	.Disable();
213cdf0e10cSrcweir 		aLbTables	.Enable();
214cdf0e10cSrcweir 		aFtPath		.Enable();
215cdf0e10cSrcweir 		aBtnBrowse	.Enable();
216cdf0e10cSrcweir 		aBtnLink	.Enable();
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir //------------------------------------------------------------------------
221cdf0e10cSrcweir 
FillTables_Impl(ScDocument * pSrcDoc)222cdf0e10cSrcweir void ScInsertTableDlg::FillTables_Impl( ScDocument* pSrcDoc )
223cdf0e10cSrcweir {
224cdf0e10cSrcweir 	aLbTables.SetUpdateMode( sal_False );
225cdf0e10cSrcweir 	aLbTables.Clear();
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	if ( pSrcDoc )
228cdf0e10cSrcweir 	{
229cdf0e10cSrcweir 		SCTAB nCount = pSrcDoc->GetTableCount();
230cdf0e10cSrcweir 		String aName;
231cdf0e10cSrcweir 
232cdf0e10cSrcweir 		for ( SCTAB i=0; i<nCount; i++ )
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			pSrcDoc->GetName( i, aName );
235cdf0e10cSrcweir 			aLbTables.InsertEntry( aName );
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 	}
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 	aLbTables.SetUpdateMode( sal_True );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir 	if(aLbTables.GetEntryCount()==1)
242cdf0e10cSrcweir 		aLbTables.SelectEntryPos(0);
243cdf0e10cSrcweir }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir //------------------------------------------------------------------------
246cdf0e10cSrcweir 
GetFirstTable(sal_uInt16 * pN)247cdf0e10cSrcweir const String* ScInsertTableDlg::GetFirstTable( sal_uInt16* pN )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir 	const String* pStr = NULL;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	if ( aBtnNew.IsChecked() )
252cdf0e10cSrcweir 	{
253cdf0e10cSrcweir 		aStrCurSelTable = aEdName.GetText();
254cdf0e10cSrcweir 		pStr = &aStrCurSelTable;
255cdf0e10cSrcweir 	}
256cdf0e10cSrcweir 	else if ( nSelTabIndex < aLbTables.GetSelectEntryCount() )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir 		aStrCurSelTable = aLbTables.GetSelectEntry( 0 );
259cdf0e10cSrcweir 		pStr = &aStrCurSelTable;
260cdf0e10cSrcweir 		if ( pN )
261cdf0e10cSrcweir 			*pN = aLbTables.GetSelectEntryPos( 0 );
262cdf0e10cSrcweir 		nSelTabIndex = 1;
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir 
265cdf0e10cSrcweir 	return pStr;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir 
268cdf0e10cSrcweir //------------------------------------------------------------------------
269cdf0e10cSrcweir 
GetNextTable(sal_uInt16 * pN)270cdf0e10cSrcweir const String* ScInsertTableDlg::GetNextTable( sal_uInt16* pN )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir 	const String* pStr = NULL;
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 	if ( !aBtnNew.IsChecked() && nSelTabIndex < aLbTables.GetSelectEntryCount() )
275cdf0e10cSrcweir 	{
276cdf0e10cSrcweir 		aStrCurSelTable = aLbTables.GetSelectEntry( nSelTabIndex );
277cdf0e10cSrcweir 		pStr = &aStrCurSelTable;
278cdf0e10cSrcweir 		if ( pN )
279cdf0e10cSrcweir 			*pN = aLbTables.GetSelectEntryPos( nSelTabIndex );
280cdf0e10cSrcweir 		nSelTabIndex++;
281cdf0e10cSrcweir 	}
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	return pStr;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 
287cdf0e10cSrcweir //------------------------------------------------------------------------
288cdf0e10cSrcweir // Handler:
289cdf0e10cSrcweir //------------------------------------------------------------------------
290cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,CountHdl_Impl,NumericField *,EMPTYARG)291cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, CountHdl_Impl, NumericField*, EMPTYARG )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir     nTableCount = static_cast<SCTAB>(aNfCount.GetValue());
294cdf0e10cSrcweir 	if ( nTableCount==1)
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		String aName;
297cdf0e10cSrcweir 		rDoc.CreateValidTabName( aName );
298cdf0e10cSrcweir 		aEdName.SetText( aName );
299cdf0e10cSrcweir 		aFtName.Enable();
300cdf0e10cSrcweir 		aEdName.Enable();
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 	else
303cdf0e10cSrcweir 	{
304cdf0e10cSrcweir 		String aName=aFlTable.GetText();
305cdf0e10cSrcweir 		aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
306cdf0e10cSrcweir 		aEdName.SetText( aName );
307cdf0e10cSrcweir 		aFtName.Disable();
308cdf0e10cSrcweir 		aEdName.Disable();
309cdf0e10cSrcweir 	}
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 	DoEnable_Impl();
312cdf0e10cSrcweir 	return 0;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir //------------------------------------------------------------------------
IMPL_LINK(ScInsertTableDlg,ChoiceHdl_Impl,RadioButton *,EMPTYARG)316cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, ChoiceHdl_Impl, RadioButton*, EMPTYARG )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir 	if ( aBtnNew.IsChecked() )
319cdf0e10cSrcweir 		SetNewTable_Impl();
320cdf0e10cSrcweir 	else
321cdf0e10cSrcweir 		SetFromTo_Impl();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 	DoEnable_Impl();
324cdf0e10cSrcweir 	return 0;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir 
327cdf0e10cSrcweir //------------------------------------------------------------------------
328cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,BrowseHdl_Impl,PushButton *,EMPTYARG)329cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, BrowseHdl_Impl, PushButton*, EMPTYARG )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir     if ( pDocInserter )
332cdf0e10cSrcweir         delete pDocInserter;
333cdf0e10cSrcweir     pDocInserter = new ::sfx2::DocumentInserter(
334cdf0e10cSrcweir             0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ) );
335cdf0e10cSrcweir     pDocInserter->StartExecuteModal( LINK( this, ScInsertTableDlg, DialogClosedHdl ) );
336cdf0e10cSrcweir     return 0;
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir //------------------------------------------------------------------------
340cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,SelectHdl_Impl,MultiListBox *,EMPTYARG)341cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, SelectHdl_Impl, MultiListBox*, EMPTYARG )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir 	DoEnable_Impl();
344cdf0e10cSrcweir 	return 0;
345cdf0e10cSrcweir }
346cdf0e10cSrcweir 
347cdf0e10cSrcweir //------------------------------------------------------------------------
348cdf0e10cSrcweir 
DoEnable_Impl()349cdf0e10cSrcweir void ScInsertTableDlg::DoEnable_Impl()
350cdf0e10cSrcweir {
351cdf0e10cSrcweir 	if ( aBtnNew.IsChecked() || ( pDocShTables && aLbTables.GetSelectEntryCount() ) )
352cdf0e10cSrcweir 		aBtnOk.Enable();
353cdf0e10cSrcweir 	else
354cdf0e10cSrcweir 		aBtnOk.Disable();
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,DoEnterHdl,PushButton *,EMPTYARG)357cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, DoEnterHdl, PushButton*, EMPTYARG )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir 	if(nTableCount > 1 || rDoc.ValidTabName(aEdName.GetText()))
360cdf0e10cSrcweir 	{
361cdf0e10cSrcweir 		EndDialog(RET_OK);
362cdf0e10cSrcweir 	}
363cdf0e10cSrcweir 	else
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		String aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) );
366cdf0e10cSrcweir 		(void)ErrorBox( this,WinBits( WB_OK | WB_DEF_OK ),aErrMsg).Execute();
367cdf0e10cSrcweir 	}
368cdf0e10cSrcweir 	return 0;
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,BrowseTimeoutHdl,Timer *,EMPTYARG)371cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, BrowseTimeoutHdl, Timer*, EMPTYARG )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     bMustClose = true;
374cdf0e10cSrcweir     BrowseHdl_Impl( &aBtnBrowse );
375cdf0e10cSrcweir     return 0;
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
IMPL_LINK(ScInsertTableDlg,DialogClosedHdl,sfx2::FileDialogHelper *,_pFileDlg)378cdf0e10cSrcweir IMPL_LINK( ScInsertTableDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir     if ( ERRCODE_NONE == _pFileDlg->GetError() )
381cdf0e10cSrcweir     {
382cdf0e10cSrcweir         SfxMedium* pMed = pDocInserter->CreateMedium();
383cdf0e10cSrcweir         if ( pMed )
384cdf0e10cSrcweir         {
385cdf0e10cSrcweir             //  ERRCTX_SFX_OPENDOC -> "Fehler beim Laden des Dokumentes"
386cdf0e10cSrcweir             SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
387cdf0e10cSrcweir 
388cdf0e10cSrcweir             if ( pDocShTables )
389cdf0e10cSrcweir                 pDocShTables->DoClose();        // delete passiert beim Zuweisen auf die Ref
390cdf0e10cSrcweir 
391cdf0e10cSrcweir             pMed->UseInteractionHandler( sal_True );    // to enable the filter options dialog
392cdf0e10cSrcweir 
393cdf0e10cSrcweir             pDocShTables = new ScDocShell;
394cdf0e10cSrcweir             aDocShTablesRef = pDocShTables;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir             Pointer aOldPtr( GetPointer() );
397cdf0e10cSrcweir             SetPointer( Pointer( POINTER_WAIT ) );
398cdf0e10cSrcweir             pDocShTables->DoLoad( pMed );
399cdf0e10cSrcweir             SetPointer( aOldPtr );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir             sal_uLong nErr = pDocShTables->GetErrorCode();
402cdf0e10cSrcweir             if ( nErr )
403cdf0e10cSrcweir                 ErrorHandler::HandleError( nErr );              // auch Warnings
404cdf0e10cSrcweir 
405cdf0e10cSrcweir             if ( !pDocShTables->GetError() )                    // nur Errors
406cdf0e10cSrcweir             {
407cdf0e10cSrcweir                 FillTables_Impl( pDocShTables->GetDocument() );
408cdf0e10cSrcweir                 aFtPath.SetText( pDocShTables->GetTitle( SFX_TITLE_FULLNAME ) );
409cdf0e10cSrcweir             }
410cdf0e10cSrcweir             else
411cdf0e10cSrcweir             {
412cdf0e10cSrcweir                 pDocShTables->DoClose();
413cdf0e10cSrcweir                 aDocShTablesRef.Clear();
414cdf0e10cSrcweir                 pDocShTables = NULL;
415cdf0e10cSrcweir 
416cdf0e10cSrcweir                 FillTables_Impl( NULL );
417cdf0e10cSrcweir                 aFtPath.SetText( EMPTY_STRING );
418cdf0e10cSrcweir             }
419cdf0e10cSrcweir         }
420cdf0e10cSrcweir 
421cdf0e10cSrcweir         DoEnable_Impl();
422cdf0e10cSrcweir     }
423cdf0e10cSrcweir     else if ( bMustClose )
424cdf0e10cSrcweir         // execute slot FID_INS_TABLE_EXT and cancel file dialog
425cdf0e10cSrcweir         EndDialog( RET_CANCEL );
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     return 0;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430