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