LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/dbgui - dbnamdlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 328 0.3 %
Date: 2012-12-17 Functions: 2 31 6.5 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10