Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <comphelper/string.hxx>
21 : #include <vcl/msgbox.hxx>
22 :
23 : #include "reffact.hxx"
24 : #include "document.hxx"
25 : #include "scresid.hxx"
26 : #include "globstr.hrc"
27 : #include "dbnamdlg.hrc"
28 : #include "rangenam.hxx" // IsNameValid
29 : #include "globalnames.hxx"
30 :
31 : #define _DBNAMDLG_CXX
32 : #include "dbnamdlg.hxx"
33 : #undef _DBNAMDLG_CXX
34 :
35 :
36 : //============================================================================
37 :
38 : #define ABS_SREF SCA_VALID \
39 : | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
40 : #define ABS_DREF ABS_SREF \
41 : | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
42 : #define ABS_DREF3D ABS_DREF | SCA_TAB_3D
43 :
44 : //----------------------------------------------------------------------------
45 :
46 : class DBSaveData;
47 :
48 : static DBSaveData* pSaveObj = NULL;
49 :
50 : #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
51 :
52 : //============================================================================
53 : // class DBSaveData
54 :
55 0 : class DBSaveData
56 : {
57 : public:
58 0 : DBSaveData( Edit& rEd, CheckBox& rHdr, CheckBox& rSize, CheckBox& rFmt,
59 : CheckBox& rStrip, ScRange& rArea )
60 : : rEdAssign(rEd),
61 : rBtnHeader(rHdr), rBtnSize(rSize), rBtnFormat(rFmt), rBtnStrip(rStrip),
62 : rCurArea(rArea),
63 0 : bHeader(false), bSize(false), bFormat(false), bDirty(false) {}
64 : void Save();
65 : void Restore();
66 :
67 : private:
68 : Edit& rEdAssign;
69 : CheckBox& rBtnHeader;
70 : CheckBox& rBtnSize;
71 : CheckBox& rBtnFormat;
72 : CheckBox& rBtnStrip;
73 : ScRange& rCurArea;
74 : String aStr;
75 : ScRange aArea;
76 : sal_Bool bHeader:1;
77 : sal_Bool bSize:1;
78 : sal_Bool bFormat:1;
79 : sal_Bool bStrip:1;
80 : sal_Bool bDirty:1;
81 : };
82 :
83 :
84 :
85 : //----------------------------------------------------------------------------
86 :
87 0 : void DBSaveData::Save()
88 : {
89 0 : aArea = rCurArea;
90 0 : aStr = rEdAssign.GetText();
91 0 : bHeader = rBtnHeader.IsChecked();
92 0 : bSize = rBtnSize.IsChecked();
93 0 : bFormat = rBtnFormat.IsChecked();
94 0 : bStrip = rBtnStrip.IsChecked();
95 0 : bDirty = sal_True;
96 0 : }
97 :
98 :
99 : //----------------------------------------------------------------------------
100 :
101 0 : void DBSaveData::Restore()
102 : {
103 0 : if ( bDirty )
104 : {
105 0 : rCurArea = aArea;
106 0 : rEdAssign.SetText( aStr );
107 0 : rBtnHeader.Check ( bHeader );
108 0 : rBtnSize.Check ( bSize );
109 0 : rBtnFormat.Check ( bFormat );
110 0 : rBtnStrip.Check ( bStrip );
111 0 : bDirty = false;
112 : }
113 0 : }
114 :
115 :
116 : //============================================================================
117 : // class ScDbNameDlg
118 :
119 : //----------------------------------------------------------------------------
120 :
121 0 : ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
122 : ScViewData* ptrViewData )
123 :
124 : : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_DBNAMES ),
125 : //
126 : aFlName ( this, ScResId( FL_NAME ) ),
127 : aEdName ( this, ScResId( ED_NAME ) ),
128 :
129 : aFlAssign ( this, ScResId( FL_ASSIGN ) ),
130 : aEdAssign ( this, this, &aFlAssign, ScResId( ED_DBAREA ) ),
131 : aRbAssign ( this, ScResId( RB_DBAREA ), &aEdAssign, this ),
132 :
133 : aFlOptions ( this, ScResId( FL_OPTIONS ) ),
134 : aBtnHeader ( this, ScResId( BTN_HEADER ) ),
135 : aBtnDoSize ( this, ScResId( BTN_SIZE ) ),
136 : aBtnKeepFmt ( this, ScResId( BTN_FORMAT ) ),
137 : aBtnStripData ( this, ScResId( BTN_STRIPDATA ) ),
138 : aFTSource ( this, ScResId( FT_SOURCE ) ),
139 : aFTOperations ( this, ScResId( FT_OPERATIONS ) ),
140 :
141 : aBtnOk ( this, ScResId( BTN_OK ) ),
142 : aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
143 : aBtnHelp ( this, ScResId( BTN_HELP ) ),
144 : aBtnAdd ( this, ScResId( BTN_ADD ) ),
145 : aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
146 : aBtnMore ( this, ScResId( BTN_MORE ) ),
147 :
148 : aStrAdd ( ScResId( STR_ADD ) ),
149 : aStrModify ( ScResId( STR_MODIFY ) ),
150 : aStrInvalid ( ScResId( STR_DB_INVALID ) ),
151 : //
152 : pViewData ( ptrViewData ),
153 0 : pDoc ( ptrViewData->GetDocument() ),
154 : bRefInputMode ( false ),
155 : aAddrDetails ( pDoc->GetAddressConvention(), 0, 0 ),
156 0 : aLocalDbCol ( *(pDoc->GetDBCollection()) )
157 : {
158 : // WB_NOLABEL can't be set in resource...
159 0 : aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
160 0 : aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );
161 :
162 : // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
163 0 : aStrSource = aFTSource.GetText();
164 0 : aStrOperations = aFTOperations.GetText();
165 :
166 : pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
167 0 : aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
168 0 : Init();
169 0 : FreeResource();
170 0 : aRbAssign.SetAccessibleRelationMemberOf(&aFlAssign);
171 0 : }
172 :
173 :
174 : //----------------------------------------------------------------------------
175 :
176 0 : ScDbNameDlg::~ScDbNameDlg()
177 : {
178 0 : DELETEZ( pSaveObj );
179 0 : }
180 :
181 :
182 : //----------------------------------------------------------------------------
183 :
184 0 : void ScDbNameDlg::Init()
185 : {
186 0 : aBtnHeader.Check( sal_True ); // Default: mit Spaltenkoepfen
187 :
188 0 : aBtnMore.AddWindow( &aFlOptions );
189 0 : aBtnMore.AddWindow( &aBtnHeader );
190 0 : aBtnMore.AddWindow( &aBtnDoSize );
191 0 : aBtnMore.AddWindow( &aBtnKeepFmt );
192 0 : aBtnMore.AddWindow( &aBtnStripData );
193 0 : aBtnMore.AddWindow( &aFTSource );
194 0 : aBtnMore.AddWindow( &aFTOperations );
195 :
196 0 : aBtnOk.SetClickHdl ( LINK( this, ScDbNameDlg, OkBtnHdl ) );
197 0 : aBtnCancel.SetClickHdl ( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
198 0 : aBtnAdd.SetClickHdl ( LINK( this, ScDbNameDlg, AddBtnHdl ) );
199 0 : aBtnRemove.SetClickHdl ( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
200 0 : aEdName.SetModifyHdl ( LINK( this, ScDbNameDlg, NameModifyHdl ) );
201 0 : aEdAssign.SetModifyHdl ( LINK( this, ScDbNameDlg, AssModifyHdl ) );
202 0 : UpdateNames();
203 :
204 0 : String theAreaStr;
205 :
206 0 : if ( pViewData && pDoc )
207 : {
208 0 : SCCOL nStartCol = 0;
209 0 : SCROW nStartRow = 0;
210 0 : SCTAB nStartTab = 0;
211 0 : SCCOL nEndCol = 0;
212 0 : SCROW nEndRow = 0;
213 0 : SCTAB nEndTab = 0;
214 :
215 0 : ScDBCollection* pDBColl = pDoc->GetDBCollection();
216 0 : ScDBData* pDBData = NULL;
217 :
218 : pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
219 0 : nEndCol, nEndRow, nEndTab );
220 :
221 0 : theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
222 0 : ScAddress( nEndCol, nEndRow, nEndTab ) );
223 :
224 0 : theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails );
225 :
226 0 : if ( pDBColl )
227 : {
228 : // Feststellen, ob definierter DB-Bereich markiert wurde:
229 0 : pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, sal_True );
230 0 : if ( pDBData )
231 : {
232 0 : ScAddress& rStart = theCurArea.aStart;
233 0 : ScAddress& rEnd = theCurArea.aEnd;
234 : SCCOL nCol1;
235 : SCCOL nCol2;
236 : SCROW nRow1;
237 : SCROW nRow2;
238 : SCTAB nTab;
239 :
240 0 : pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
241 :
242 0 : if ( (rStart.Tab() == nTab)
243 0 : && (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
244 0 : && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) )
245 : {
246 0 : OUString aDBName = pDBData->GetName();
247 0 : if ( aDBName != STR_DB_LOCAL_NONAME )
248 0 : aEdName.SetText(aDBName);
249 :
250 0 : aBtnHeader.Check( pDBData->HasHeader() );
251 0 : aBtnDoSize.Check( pDBData->IsDoSize() );
252 0 : aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
253 0 : aBtnStripData.Check( pDBData->IsStripData() );
254 0 : SetInfoStrings( pDBData );
255 : }
256 : }
257 : }
258 : }
259 :
260 0 : aEdAssign.SetText( theAreaStr );
261 0 : aEdName.GrabFocus();
262 0 : bSaved=sal_True;
263 0 : pSaveObj->Save();
264 0 : NameModifyHdl( 0 );
265 0 : }
266 :
267 :
268 0 : void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
269 : {
270 0 : OUStringBuffer aBuf;
271 0 : aBuf.append(aStrSource);
272 0 : if (pDBData)
273 : {
274 0 : aBuf.append(sal_Unicode(' '));
275 0 : aBuf.append(pDBData->GetSourceString());
276 : }
277 0 : aFTSource.SetText(aBuf.makeStringAndClear());
278 :
279 0 : aBuf.append(aStrOperations);
280 0 : if (pDBData)
281 : {
282 0 : aBuf.append(sal_Unicode(' '));
283 0 : aBuf.append(pDBData->GetOperations());
284 : }
285 0 : aFTOperations.SetText(aBuf.makeStringAndClear());
286 0 : }
287 :
288 : //----------------------------------------------------------------------------
289 : // Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
290 : // neue Selektion im Referenz-Fenster angezeigt wird.
291 :
292 0 : void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
293 : {
294 0 : if ( aEdAssign.IsEnabled() )
295 : {
296 0 : if ( rRef.aStart != rRef.aEnd )
297 0 : RefInputStart( &aEdAssign );
298 :
299 0 : theCurArea = rRef;
300 :
301 0 : String aRefStr;
302 0 : theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
303 0 : aEdAssign.SetRefString( aRefStr );
304 0 : aBtnHeader.Enable();
305 0 : aBtnDoSize.Enable();
306 0 : aBtnKeepFmt.Enable();
307 0 : aBtnStripData.Enable();
308 0 : aFTSource.Enable();
309 0 : aFTOperations.Enable();
310 0 : aBtnAdd.Enable();
311 0 : bSaved=sal_True;
312 0 : pSaveObj->Save();
313 : }
314 0 : }
315 :
316 :
317 : //----------------------------------------------------------------------------
318 :
319 0 : sal_Bool ScDbNameDlg::Close()
320 : {
321 0 : return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
322 : }
323 :
324 : //------------------------------------------------------------------------
325 :
326 0 : void ScDbNameDlg::SetActive()
327 : {
328 0 : aEdAssign.GrabFocus();
329 :
330 : // kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
331 : // (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
332 : // (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
333 :
334 0 : RefInputDone();
335 0 : }
336 :
337 : //------------------------------------------------------------------------
338 :
339 0 : void ScDbNameDlg::UpdateNames()
340 : {
341 : typedef ScDBCollection::NamedDBs DBsType;
342 :
343 0 : const DBsType& rDBs = aLocalDbCol.getNamedDBs();
344 :
345 0 : aEdName.SetUpdateMode( false );
346 : //-----------------------------------------------------------
347 0 : aEdName.Clear();
348 0 : aEdAssign.SetText( EMPTY_STRING );
349 :
350 0 : if (!rDBs.empty())
351 : {
352 0 : DBsType::const_iterator itr = rDBs.begin(), itrEnd = rDBs.end();
353 0 : for (; itr != itrEnd; ++itr)
354 0 : aEdName.InsertEntry(itr->GetName());
355 : }
356 : else
357 : {
358 0 : aBtnAdd.SetText( aStrAdd );
359 0 : aBtnAdd.Disable();
360 0 : aBtnRemove.Disable();
361 : }
362 : //-----------------------------------------------------------
363 0 : aEdName.SetUpdateMode( sal_True );
364 0 : aEdName.Invalidate();
365 0 : }
366 :
367 : //------------------------------------------------------------------------
368 :
369 0 : void ScDbNameDlg::UpdateDBData( const String& rStrName )
370 : {
371 :
372 0 : const ScDBData* pData = aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(rStrName));
373 :
374 0 : if ( pData )
375 : {
376 0 : SCCOL nColStart = 0;
377 0 : SCROW nRowStart = 0;
378 0 : SCCOL nColEnd = 0;
379 0 : SCROW nRowEnd = 0;
380 0 : SCTAB nTab = 0;
381 :
382 0 : pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
383 0 : theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
384 0 : ScAddress( nColEnd, nRowEnd, nTab ) );
385 0 : OUString theArea;
386 0 : theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
387 0 : aEdAssign.SetText( theArea );
388 0 : aBtnAdd.SetText( aStrModify );
389 0 : aBtnHeader.Check( pData->HasHeader() );
390 0 : aBtnDoSize.Check( pData->IsDoSize() );
391 0 : aBtnKeepFmt.Check( pData->IsKeepFmt() );
392 0 : aBtnStripData.Check( pData->IsStripData() );
393 0 : SetInfoStrings( pData );
394 : }
395 :
396 0 : aBtnAdd.SetText( aStrModify );
397 0 : aBtnAdd.Enable();
398 0 : aBtnRemove.Enable();
399 0 : aBtnHeader.Enable();
400 0 : aBtnDoSize.Enable();
401 0 : aBtnKeepFmt.Enable();
402 0 : aBtnStripData.Enable();
403 0 : aFTSource.Enable();
404 0 : aFTOperations.Enable();
405 0 : }
406 :
407 : //------------------------------------------------------------------------
408 :
409 :
410 0 : sal_Bool ScDbNameDlg::IsRefInputMode() const
411 : {
412 0 : return bRefInputMode;
413 : }
414 :
415 : //------------------------------------------------------------------------
416 : // Handler:
417 : // ========
418 :
419 0 : IMPL_LINK_NOARG(ScDbNameDlg, OkBtnHdl)
420 : {
421 0 : AddBtnHdl( 0 );
422 :
423 : // Der View die Aenderungen und die Remove-Liste uebergeben:
424 : // beide werden nur als Referenz uebergeben, so dass an dieser
425 : // Stelle keine Speicherleichen entstehen koennen:
426 0 : if ( pViewData )
427 : pViewData->GetView()->
428 0 : NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
429 :
430 0 : Close();
431 0 : return 0;
432 : }
433 :
434 : //------------------------------------------------------------------------
435 :
436 0 : IMPL_LINK_NOARG_INLINE_START(ScDbNameDlg, CancelBtnHdl)
437 : {
438 0 : Close();
439 0 : return 0;
440 : }
441 0 : IMPL_LINK_NOARG_INLINE_END(ScDbNameDlg, CancelBtnHdl)
442 :
443 : //------------------------------------------------------------------------
444 :
445 0 : IMPL_LINK_NOARG(ScDbNameDlg, AddBtnHdl)
446 : {
447 0 : String aNewName = comphelper::string::strip(aEdName.GetText(), ' ');
448 0 : String aNewArea = aEdAssign.GetText();
449 :
450 0 : if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
451 : {
452 0 : if ( ScRangeData::IsNameValid( aNewName, pDoc ) && !aNewName.EqualsAscii(STR_DB_LOCAL_NONAME) )
453 : {
454 : // weil jetzt editiert werden kann, muss erst geparst werden
455 0 : ScRange aTmpRange;
456 0 : String aText = aEdAssign.GetText();
457 0 : if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
458 : {
459 0 : theCurArea = aTmpRange;
460 0 : ScAddress aStart = theCurArea.aStart;
461 0 : ScAddress aEnd = theCurArea.aEnd;
462 :
463 0 : ScDBData* pOldEntry = aLocalDbCol.getNamedDBs().findByUpperName(ScGlobal::pCharClass->uppercase(aNewName));
464 0 : if (pOldEntry)
465 : {
466 : // Bereich veraendern
467 :
468 0 : pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
469 0 : aEnd.Col(), aEnd.Row() );
470 0 : pOldEntry->SetByRow( sal_True );
471 0 : pOldEntry->SetHeader( aBtnHeader.IsChecked() );
472 0 : pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
473 0 : pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
474 0 : pOldEntry->SetStripData( aBtnStripData.IsChecked() );
475 : }
476 : else
477 : {
478 : // neuen Bereich einfuegen
479 :
480 0 : ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
481 0 : aStart.Col(), aStart.Row(),
482 0 : aEnd.Col(), aEnd.Row(),
483 0 : sal_True, aBtnHeader.IsChecked() );
484 0 : pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
485 0 : pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
486 0 : pNewEntry->SetStripData( aBtnStripData.IsChecked() );
487 :
488 0 : aLocalDbCol.getNamedDBs().insert(pNewEntry);
489 : }
490 :
491 0 : UpdateNames();
492 :
493 0 : aEdName.SetText( EMPTY_STRING );
494 0 : aEdName.GrabFocus();
495 0 : aBtnAdd.SetText( aStrAdd );
496 0 : aBtnAdd.Disable();
497 0 : aBtnRemove.Disable();
498 0 : aEdAssign.SetText( EMPTY_STRING );
499 0 : aBtnHeader.Check( sal_True ); // Default: mit Spaltenkoepfen
500 0 : aBtnDoSize.Check( false );
501 0 : aBtnKeepFmt.Check( false );
502 0 : aBtnStripData.Check( false );
503 0 : SetInfoStrings( NULL ); // leer
504 0 : theCurArea = ScRange();
505 0 : bSaved=sal_True;
506 0 : pSaveObj->Save();
507 0 : NameModifyHdl( 0 );
508 : }
509 : else
510 : {
511 0 : ERRORBOX( aStrInvalid );
512 0 : aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
513 0 : aEdAssign.GrabFocus();
514 0 : }
515 : }
516 : else
517 : {
518 0 : ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
519 0 : aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
520 0 : aEdName.GrabFocus();
521 : }
522 : }
523 0 : return 0;
524 : }
525 :
526 : namespace {
527 :
528 : class FindByName : public ::std::unary_function<ScDBData, bool>
529 : {
530 : const OUString& mrName;
531 : public:
532 0 : FindByName(const OUString& rName) : mrName(rName) {}
533 0 : bool operator() (const ScDBData& r) const
534 : {
535 0 : return r.GetName().equals(mrName);
536 : }
537 : };
538 :
539 : }
540 :
541 0 : IMPL_LINK_NOARG(ScDbNameDlg, RemoveBtnHdl)
542 : {
543 0 : OUString aStrEntry = aEdName.GetText();
544 0 : ScDBCollection::NamedDBs& rDBs = aLocalDbCol.getNamedDBs();
545 : ScDBCollection::NamedDBs::iterator itr =
546 0 : ::std::find_if(rDBs.begin(), rDBs.end(), FindByName(aStrEntry));
547 :
548 0 : if (itr != rDBs.end())
549 : {
550 0 : String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
551 :
552 0 : OUStringBuffer aBuf;
553 0 : aBuf.append(aStrDelMsg.GetToken(0, '#'));
554 0 : aBuf.append(aStrEntry);
555 0 : aBuf.append(aStrDelMsg.GetToken(1, '#'));
556 0 : QueryBox aBox(this, WinBits(WB_YES_NO|WB_DEF_YES), aBuf.makeStringAndClear());
557 :
558 0 : if (RET_YES == aBox.Execute())
559 : {
560 : SCTAB nTab;
561 : SCCOL nColStart, nColEnd;
562 : SCROW nRowStart, nRowEnd;
563 0 : itr->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
564 : aRemoveList.push_back(
565 : ScRange( ScAddress( nColStart, nRowStart, nTab ),
566 0 : ScAddress( nColEnd, nRowEnd, nTab ) ) );
567 :
568 0 : rDBs.erase(itr);
569 :
570 0 : UpdateNames();
571 :
572 0 : aEdName.SetText( EMPTY_STRING );
573 0 : aEdName.GrabFocus();
574 0 : aBtnAdd.SetText( aStrAdd );
575 0 : aBtnAdd.Disable();
576 0 : aBtnRemove.Disable();
577 0 : aEdAssign.SetText( EMPTY_STRING );
578 0 : theCurArea = ScRange();
579 0 : aBtnHeader.Check( sal_True ); // Default: mit Spaltenkoepfen
580 0 : aBtnDoSize.Check( false );
581 0 : aBtnKeepFmt.Check( false );
582 0 : aBtnStripData.Check( false );
583 0 : SetInfoStrings( NULL ); // leer
584 0 : bSaved=false;
585 0 : pSaveObj->Restore();
586 0 : NameModifyHdl( 0 );
587 0 : }
588 : }
589 0 : return 0;
590 : }
591 :
592 : //------------------------------------------------------------------------
593 :
594 0 : IMPL_LINK_NOARG(ScDbNameDlg, NameModifyHdl)
595 : {
596 0 : OUString theName = aEdName.GetText();
597 : sal_Bool bNameFound = (COMBOBOX_ENTRY_NOTFOUND
598 0 : != aEdName.GetEntryPos( theName ));
599 :
600 0 : if ( theName.isEmpty() )
601 : {
602 0 : if (aBtnAdd.GetText() != aStrAdd)
603 0 : aBtnAdd.SetText( aStrAdd );
604 0 : aBtnAdd .Disable();
605 0 : aBtnRemove .Disable();
606 0 : aFlAssign .Disable();
607 0 : aBtnHeader .Disable();
608 0 : aBtnDoSize .Disable();
609 0 : aBtnKeepFmt .Disable();
610 0 : aBtnStripData.Disable();
611 0 : aFTSource .Disable();
612 0 : aFTOperations.Disable();
613 0 : aEdAssign .Disable();
614 0 : aRbAssign .Disable();
615 : //bSaved=sal_False;
616 : //pSaveObj->Restore();
617 : //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
618 : //SFX_APPWINDOW->Disable(sal_False); //! allgemeine Methode im ScAnyRefDlg
619 0 : bRefInputMode = false;
620 : }
621 : else
622 : {
623 0 : if ( bNameFound )
624 : {
625 0 : if (aBtnAdd.GetText() != aStrModify)
626 0 : aBtnAdd.SetText( aStrModify );
627 :
628 0 : if(!bSaved)
629 : {
630 0 : bSaved=sal_True;
631 0 : pSaveObj->Save();
632 : }
633 0 : UpdateDBData( theName );
634 : }
635 : else
636 : {
637 0 : if (aBtnAdd.GetText() != aStrAdd)
638 0 : aBtnAdd.SetText( aStrAdd );
639 :
640 0 : bSaved=false;
641 0 : pSaveObj->Restore();
642 :
643 0 : if ( !aEdAssign.GetText().isEmpty() )
644 : {
645 0 : aBtnAdd.Enable();
646 0 : aBtnHeader.Enable();
647 0 : aBtnDoSize.Enable();
648 0 : aBtnKeepFmt.Enable();
649 0 : aBtnStripData.Enable();
650 0 : aFTSource.Enable();
651 0 : aFTOperations.Enable();
652 : }
653 : else
654 : {
655 0 : aBtnAdd.Disable();
656 0 : aBtnHeader.Disable();
657 0 : aBtnDoSize.Disable();
658 0 : aBtnKeepFmt.Disable();
659 0 : aBtnStripData.Disable();
660 0 : aFTSource.Disable();
661 0 : aFTOperations.Disable();
662 : }
663 0 : aBtnRemove.Disable();
664 : }
665 :
666 0 : aFlAssign.Enable();
667 0 : aEdAssign.Enable();
668 0 : aRbAssign.Enable();
669 :
670 : //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
671 : //SFX_APPWINDOW->Enable();
672 0 : bRefInputMode = true;
673 : }
674 0 : return 0;
675 : }
676 :
677 : //------------------------------------------------------------------------
678 :
679 0 : IMPL_LINK_NOARG(ScDbNameDlg, AssModifyHdl)
680 : {
681 : // hier parsen fuer Save() etc.
682 :
683 0 : ScRange aTmpRange;
684 0 : String aText = aEdAssign.GetText();
685 0 : if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
686 0 : theCurArea = aTmpRange;
687 :
688 0 : return 0;
689 93 : }
690 :
691 :
692 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|