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