LCOV - code coverage report
Current view: top level - sw/source/ui/fldui - flddb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 260 0.0 %
Date: 2012-08-25 Functions: 0 21 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <swmodule.hxx>
      30                 :            : #include <view.hxx>
      31                 :            : #include <wrtsh.hxx>
      32                 :            : #include <globals.hrc>
      33                 :            : #include <dbfld.hxx>
      34                 :            : #include <fldtdlg.hxx>
      35                 :            : #include <numrule.hxx>
      36                 :            : 
      37                 :            : #include <fldtdlg.hrc>
      38                 :            : #include <fldui.hrc>
      39                 :            : #include <flddb.hxx>
      40                 :            : #include <dbconfig.hxx>
      41                 :            : #include <dbmgr.hxx>
      42                 :            : 
      43                 :            : #define USER_DATA_VERSION_1     "1"
      44                 :            : #define USER_DATA_VERSION USER_DATA_VERSION_1
      45                 :            : 
      46                 :          0 : SwFldDBPage::SwFldDBPage(Window* pParent, const SfxItemSet& rCoreSet ) :
      47                 :            :     SwFldPage( pParent, SW_RES( TP_FLD_DB ), rCoreSet ),
      48                 :            :     aTypeFT     (this, SW_RES(FT_DBTYPE)),
      49                 :            :     aTypeLB     (this, SW_RES(LB_DBTYPE)),
      50                 :            :     aSelectionFT(this, SW_RES(FT_DBSELECTION)),
      51                 :            :     aDatabaseTLB(this, SW_RES(TLB_DBLIST), 0, aEmptyStr, sal_False),
      52                 :            :     aAddDBFT(this,      SW_RES(FT_ADDDB)),
      53                 :            :     aAddDBPB(this,      SW_RES(PB_ADDDB)),
      54                 :            :     aConditionFT(this, SW_RES(FT_DBCONDITION)),
      55                 :            :     aConditionED(this, SW_RES(ED_DBCONDITION)),
      56                 :            :     aValueFT    (this, SW_RES(FT_DBSETNUMBER)),
      57                 :            :     aValueED    (this, SW_RES(ED_DBSETNUMBER)),
      58                 :            :     aDBFormatRB (this, SW_RES(RB_DBOWNFORMAT)),
      59                 :            :     aNewFormatRB(this, SW_RES(RB_DBFORMAT)),
      60                 :            :     aNumFormatLB(this, SW_RES(LB_DBNUMFORMAT)),
      61                 :            :     aFormatLB   (this, SW_RES(LB_DBFORMAT)),
      62                 :            :     aFormatFL   (this, SW_RES(FL_DBFORMAT)),
      63                 :          0 :     aFormatVertFL   (this, SW_RES(FL_DBFORMAT_VERT))
      64                 :            : {
      65                 :          0 :     FreeResource();
      66                 :            : 
      67                 :          0 :     aOldNumSelectHdl = aNumFormatLB.GetSelectHdl();
      68                 :            : 
      69                 :          0 :     aNumFormatLB.SetSelectHdl(LINK(this, SwFldDBPage, NumSelectHdl));
      70                 :          0 :     aDatabaseTLB.SetSelectHdl(LINK(this, SwFldDBPage, TreeSelectHdl));
      71                 :          0 :     aDatabaseTLB.SetDoubleClickHdl(LINK(this, SwFldDBPage, InsertHdl));
      72                 :            : 
      73                 :          0 :     aValueED.SetModifyHdl(LINK(this, SwFldDBPage, ModifyHdl));
      74                 :          0 :     aAddDBPB.SetClickHdl(LINK(this, SwFldDBPage, AddDBHdl));
      75                 :          0 : }
      76                 :            : 
      77                 :          0 : SwFldDBPage::~SwFldDBPage()
      78                 :            : {
      79                 :          0 : }
      80                 :            : 
      81                 :            : /*--------------------------------------------------------------------
      82                 :            :     Description: initialise TabPage
      83                 :            :  --------------------------------------------------------------------*/
      84                 :          0 : void SwFldDBPage::Reset(const SfxItemSet&)
      85                 :            : {
      86                 :          0 :     Init(); // Allgemeine initialisierung
      87                 :            : 
      88                 :          0 :     aTypeLB.SetUpdateMode(sal_False);
      89                 :          0 :     sal_uInt16 nOldPos = aTypeLB.GetSelectEntryPos();
      90                 :          0 :     sOldDBName = aDatabaseTLB.GetDBName(sOldTableName, sOldColumnName);
      91                 :            : 
      92                 :          0 :     aTypeLB.Clear();
      93                 :            : 
      94                 :            :     sal_uInt16 nPos, nTypeId, i;
      95                 :            : 
      96                 :          0 :     if (!IsFldEdit())
      97                 :            :     {
      98                 :            :         // initialise TypeListBox
      99                 :          0 :         const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
     100                 :            : 
     101                 :          0 :         for(i = rRg.nStart; i < rRg.nEnd; ++i)
     102                 :            :         {
     103                 :          0 :             nTypeId = GetFldMgr().GetTypeId(i);
     104                 :          0 :             nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
     105                 :          0 :             aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     106                 :            :         }
     107                 :            :     }
     108                 :            :     else
     109                 :            :     {
     110                 :          0 :         nTypeId = GetCurField()->GetTypeId();
     111                 :          0 :         nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
     112                 :          0 :         aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
     113                 :            :     }
     114                 :            : 
     115                 :            :     // select old Pos
     116                 :          0 :     if (GetTypeSel() != LISTBOX_ENTRY_NOTFOUND)
     117                 :          0 :         aTypeLB.SelectEntryPos(GetTypeSel());
     118                 :            : 
     119                 :          0 :     aFormatLB.Clear();
     120                 :            : 
     121                 :          0 :     sal_uInt16 nSize = GetFldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, sal_False, IsFldDlgHtmlMode());
     122                 :          0 :     for( i = 0; i < nSize; ++i )
     123                 :            :     {
     124                 :          0 :         sal_uInt16 nEntryPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
     125                 :          0 :         sal_uInt16 nFmtId = GetFldMgr().GetFormatId( TYP_DBSETNUMBERFLD, i );
     126                 :          0 :         aFormatLB.SetEntryData( nEntryPos, reinterpret_cast<void*>(nFmtId) );
     127                 :          0 :         if( SVX_NUM_ARABIC == nFmtId )
     128                 :          0 :             aFormatLB.SelectEntryPos( nEntryPos );
     129                 :            :     }
     130                 :            : 
     131                 :          0 :     if (!IsFldEdit())
     132                 :            :     {
     133                 :          0 :         if (nOldPos != LISTBOX_ENTRY_NOTFOUND)
     134                 :          0 :             aTypeLB.SelectEntryPos(nOldPos);
     135                 :            : 
     136                 :          0 :         if (sOldDBName.Len())
     137                 :            :         {
     138                 :          0 :             aDatabaseTLB.Select(sOldDBName, sOldTableName, sOldColumnName);
     139                 :            :         }
     140                 :            :         else
     141                 :            :         {
     142                 :          0 :             SwWrtShell *pSh = GetWrtShell();
     143                 :          0 :             if(!pSh)
     144                 :          0 :                 pSh = ::GetActiveWrtShell();
     145                 :          0 :             if(pSh)
     146                 :            :             {
     147                 :          0 :                 SwDBData aTmp(pSh->GetDBData());
     148                 :          0 :                 aDatabaseTLB.Select(aTmp.sDataSource, aTmp.sCommand, aEmptyStr);
     149                 :            :             }
     150                 :            :         }
     151                 :            :     }
     152                 :            : 
     153                 :          0 :     if( !IsRefresh() )
     154                 :            :     {
     155                 :          0 :         String sUserData = GetUserData();
     156                 :          0 :         if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
     157                 :            :         {
     158                 :          0 :             String sVal = sUserData.GetToken(1, ';');
     159                 :          0 :             sal_uInt16 nVal = (sal_uInt16)sVal.ToInt32();
     160                 :          0 :             if(nVal != USHRT_MAX)
     161                 :            :             {
     162                 :          0 :                 for(i = 0; i < aTypeLB.GetEntryCount(); i++)
     163                 :          0 :                     if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
     164                 :            :                     {
     165                 :          0 :                         aTypeLB.SelectEntryPos(i);
     166                 :          0 :                         break;
     167                 :            :                     }
     168                 :          0 :             }
     169                 :          0 :         }
     170                 :            :     }
     171                 :          0 :     TypeHdl(0);
     172                 :            : 
     173                 :          0 :     aTypeLB.SetUpdateMode(sal_True);
     174                 :          0 :     aTypeLB.SetSelectHdl(LINK(this, SwFldDBPage, TypeHdl));
     175                 :          0 :     aTypeLB.SetDoubleClickHdl(LINK(this, SwFldDBPage, InsertHdl));
     176                 :            : 
     177                 :          0 :     if (IsFldEdit())
     178                 :            :     {
     179                 :          0 :         aConditionED.SaveValue();
     180                 :          0 :         aValueED.SaveValue();
     181                 :          0 :         sOldDBName = aDatabaseTLB.GetDBName(sOldTableName, sOldColumnName);
     182                 :          0 :         nOldFormat = GetCurField()->GetFormat();
     183                 :          0 :         nOldSubType = GetCurField()->GetSubType();
     184                 :            :     }
     185                 :          0 : }
     186                 :            : 
     187                 :          0 : sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& )
     188                 :            : {
     189                 :          0 :     String sTableName, sColumnName;
     190                 :          0 :     SwDBData aData;
     191                 :            :     sal_Bool bIsTable;
     192                 :          0 :     aData.sDataSource = aDatabaseTLB.GetDBName(sTableName, sColumnName, &bIsTable);
     193                 :          0 :     aData.sCommand = sTableName;
     194                 :          0 :     aData.nCommandType = bIsTable ? 0 : 1;
     195                 :          0 :     SwWrtShell *pSh = GetWrtShell();
     196                 :          0 :     if(!pSh)
     197                 :          0 :         pSh = ::GetActiveWrtShell();
     198                 :            : 
     199                 :          0 :     if (aData.sDataSource.isEmpty())
     200                 :          0 :         aData = pSh->GetDBData();
     201                 :            : 
     202                 :          0 :     if(!aData.sDataSource.isEmpty())       // without database no new field command
     203                 :            :     {
     204                 :          0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     205                 :          0 :         String aVal(aValueED.GetText());
     206                 :          0 :         String aName(aConditionED.GetText());
     207                 :          0 :         sal_uLong nFormat = 0;
     208                 :          0 :         sal_uInt16 nSubType = 0;
     209                 :            : 
     210                 :          0 :         String sDBName = aData.sDataSource;
     211                 :          0 :         sDBName += DB_DELIM;
     212                 :          0 :         sDBName += (String)aData.sCommand;
     213                 :          0 :         sDBName += DB_DELIM;
     214                 :          0 :         sDBName += String::CreateFromInt32(aData.nCommandType);
     215                 :          0 :         sDBName += DB_DELIM;
     216                 :          0 :         if(sColumnName.Len())
     217                 :            :         {
     218                 :          0 :             sDBName += sColumnName;
     219                 :          0 :             sDBName += DB_DELIM;
     220                 :            :         }
     221                 :          0 :         aName.Insert(sDBName, 0);
     222                 :            : 
     223                 :          0 :         switch (nTypeId)
     224                 :            :         {
     225                 :            :         case TYP_DBFLD:
     226                 :          0 :             nFormat = aNumFormatLB.GetFormat();
     227                 :          0 :             if (aNewFormatRB.IsEnabled() && aNewFormatRB.IsChecked())
     228                 :          0 :                 nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
     229                 :          0 :             aName = sDBName;
     230                 :          0 :             break;
     231                 :            : 
     232                 :            :         case TYP_DBSETNUMBERFLD:
     233                 :            :             nFormat = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(
     234                 :          0 :                                 aFormatLB.GetSelectEntryPos() );
     235                 :          0 :             break;
     236                 :            :         }
     237                 :            : 
     238                 :            : 
     239                 :          0 :         String sTempDBName, sTempTableName, sTempColumnName;
     240                 :          0 :         sTempDBName = aDatabaseTLB.GetDBName(sTempTableName, sTempColumnName);
     241                 :          0 :         sal_Bool bDBListBoxChanged = sOldDBName != sTempDBName ||
     242                 :          0 :             sOldTableName != sTempTableName || sOldColumnName != sTempColumnName;
     243                 :          0 :         if (!IsFldEdit() ||
     244                 :          0 :             aConditionED.GetSavedValue() != aConditionED.GetText() ||
     245                 :          0 :              aValueED.GetSavedValue() != aValueED.GetText() ||
     246                 :            :              bDBListBoxChanged ||
     247                 :            :              nOldFormat != nFormat || nOldSubType != nSubType)
     248                 :            :         {
     249                 :          0 :             InsertFld( nTypeId, nSubType, aName, aVal, nFormat);
     250                 :          0 :         }
     251                 :            :     }
     252                 :            : 
     253                 :          0 :     return sal_False;
     254                 :            : }
     255                 :            : 
     256                 :          0 : SfxTabPage* SwFldDBPage::Create(    Window* pParent,
     257                 :            :                         const SfxItemSet& rAttrSet )
     258                 :            : {
     259                 :          0 :     return ( new SwFldDBPage( pParent, rAttrSet ) );
     260                 :            : }
     261                 :            : 
     262                 :          0 : sal_uInt16 SwFldDBPage::GetGroup()
     263                 :            : {
     264                 :          0 :     return GRP_DB;
     265                 :            : }
     266                 :            : 
     267                 :          0 : IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox )
     268                 :            : {
     269                 :            :     // save old ListBoxPos
     270                 :          0 :     const sal_uInt16 nOld = GetTypeSel();
     271                 :            : 
     272                 :            :     // current ListBoxPos
     273                 :          0 :     SetTypeSel(aTypeLB.GetSelectEntryPos());
     274                 :            : 
     275                 :          0 :     if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
     276                 :            :     {
     277                 :          0 :         SetTypeSel(0);
     278                 :          0 :         aTypeLB.SelectEntryPos(0);
     279                 :            :     }
     280                 :            : 
     281                 :          0 :     if (nOld != GetTypeSel())
     282                 :            :     {
     283                 :          0 :         SwWrtShell *pSh = GetWrtShell();
     284                 :          0 :         if(!pSh)
     285                 :          0 :             pSh = ::GetActiveWrtShell();
     286                 :          0 :         sal_Bool bCond = sal_False, bSetNo = sal_False, bFormat = sal_False, bDBFormat = sal_False;
     287                 :          0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     288                 :            : 
     289                 :          0 :         aDatabaseTLB.ShowColumns(nTypeId == TYP_DBFLD);
     290                 :            : 
     291                 :          0 :         if (IsFldEdit())
     292                 :            :         {
     293                 :          0 :             SwDBData aData;
     294                 :          0 :             String sColumnName;
     295                 :          0 :             if (nTypeId == TYP_DBFLD)
     296                 :            :             {
     297                 :          0 :                 aData = ((SwDBField*)GetCurField())->GetDBData();
     298                 :          0 :                 sColumnName = ((SwDBFieldType*)GetCurField()->GetTyp())->GetColumnName();
     299                 :            :             }
     300                 :            :             else
     301                 :            :             {
     302                 :          0 :                 aData = ((SwDBNameInfField*)GetCurField())->GetDBData(pSh->GetDoc());
     303                 :            :             }
     304                 :          0 :             aDatabaseTLB.Select(aData.sDataSource, aData.sCommand, sColumnName);
     305                 :            :         }
     306                 :            : 
     307                 :          0 :         switch (nTypeId)
     308                 :            :         {
     309                 :            :             case TYP_DBFLD:
     310                 :          0 :                 bFormat = sal_True;
     311                 :          0 :                 bDBFormat = sal_True;
     312                 :          0 :                 aNumFormatLB.Show();
     313                 :          0 :                 aFormatLB.Hide();
     314                 :            : 
     315                 :          0 :                 if (pBox)   // type was changed by user
     316                 :          0 :                     aDBFormatRB.Check();
     317                 :            : 
     318                 :          0 :                 if (IsFldEdit())
     319                 :            :                 {
     320                 :          0 :                     if (GetCurField()->GetFormat() != 0 && GetCurField()->GetFormat() != SAL_MAX_UINT32)
     321                 :          0 :                         aNumFormatLB.SetDefFormat(GetCurField()->GetFormat());
     322                 :            : 
     323                 :          0 :                     if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_OWN_FMT)
     324                 :          0 :                         aNewFormatRB.Check();
     325                 :            :                     else
     326                 :          0 :                         aDBFormatRB.Check();
     327                 :            :                 }
     328                 :          0 :                 break;
     329                 :            : 
     330                 :            :             case TYP_DBNUMSETFLD:
     331                 :          0 :                 bSetNo = sal_True;
     332                 :            :                 // no break!
     333                 :            :             case TYP_DBNEXTSETFLD:
     334                 :          0 :                 bCond = sal_True;
     335                 :          0 :                 if (IsFldEdit())
     336                 :            :                 {
     337                 :          0 :                     aConditionED.SetText(GetCurField()->GetPar1());
     338                 :          0 :                     aValueED.SetText(GetCurField()->GetPar2());
     339                 :            :                 }
     340                 :          0 :                 break;
     341                 :            : 
     342                 :            :             case TYP_DBNAMEFLD:
     343                 :          0 :                 break;
     344                 :            : 
     345                 :            :             case TYP_DBSETNUMBERFLD:
     346                 :          0 :                 bFormat = sal_True;
     347                 :          0 :                 aNewFormatRB.Check();
     348                 :          0 :                 aNumFormatLB.Hide();
     349                 :          0 :                 aFormatLB.Show();
     350                 :          0 :                 if( IsFldEdit() )
     351                 :            :                 {
     352                 :          0 :                     for( sal_uInt16 nI = aFormatLB.GetEntryCount(); nI; )
     353                 :          0 :                         if( GetCurField()->GetFormat() == (sal_uInt16)(sal_uLong)
     354                 :          0 :                             aFormatLB.GetEntryData( --nI ))
     355                 :            :                         {
     356                 :          0 :                             aFormatLB.SelectEntryPos( nI );
     357                 :          0 :                             break;
     358                 :            :                         }
     359                 :            :                 }
     360                 :          0 :                 break;
     361                 :            :         }
     362                 :            : 
     363                 :          0 :         aConditionFT.Enable(bCond);
     364                 :          0 :         aConditionED.Enable(bCond);
     365                 :          0 :         aValueFT.Enable(bSetNo);
     366                 :          0 :         aValueED.Enable(bSetNo);
     367                 :          0 :         if (nTypeId != TYP_DBFLD)
     368                 :            :         {
     369                 :          0 :             aDBFormatRB.Enable(bDBFormat);
     370                 :          0 :             aNewFormatRB.Enable(bDBFormat|bFormat);
     371                 :          0 :             aNumFormatLB.Enable(bDBFormat);
     372                 :          0 :             aFormatLB.Enable(bFormat);
     373                 :            :         }
     374                 :          0 :         aFormatFL.Enable(bDBFormat|bFormat);
     375                 :            : 
     376                 :          0 :         if (!IsFldEdit())
     377                 :            :         {
     378                 :          0 :             aValueED.SetText(aEmptyStr);
     379                 :          0 :             if (bCond)
     380                 :          0 :                 aConditionED.SetText(rtl::OUString("TRUE"));
     381                 :            :             else
     382                 :          0 :                 aConditionED.SetText(aEmptyStr);
     383                 :            :         }
     384                 :            : 
     385                 :          0 :         CheckInsert();
     386                 :            :     }
     387                 :            : 
     388                 :          0 :     return 0;
     389                 :            : }
     390                 :            : 
     391                 :          0 : IMPL_LINK( SwFldDBPage, NumSelectHdl, NumFormatListBox *, pLB )
     392                 :            : {
     393                 :          0 :     aNewFormatRB.Check();
     394                 :          0 :     aOldNumSelectHdl.Call(pLB);
     395                 :            : 
     396                 :          0 :     return 0;
     397                 :            : }
     398                 :            : 
     399                 :          0 : void SwFldDBPage::CheckInsert()
     400                 :            : {
     401                 :          0 :     sal_Bool bInsert = sal_True;
     402                 :          0 :     sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     403                 :            : 
     404                 :          0 :     SvLBoxEntry* pEntry = aDatabaseTLB.GetCurEntry();
     405                 :            : 
     406                 :          0 :     if (pEntry)
     407                 :            :     {
     408                 :          0 :         pEntry = aDatabaseTLB.GetParent(pEntry);
     409                 :            : 
     410                 :          0 :         if (nTypeId == TYP_DBFLD && pEntry)
     411                 :          0 :             pEntry = aDatabaseTLB.GetParent(pEntry);
     412                 :            : 
     413                 :          0 :         bInsert &= pEntry != 0;
     414                 :            :     }
     415                 :            :     else
     416                 :          0 :         bInsert = sal_False;
     417                 :            : 
     418                 :          0 :     if (nTypeId == TYP_DBNUMSETFLD)
     419                 :            :     {
     420                 :          0 :         sal_Bool bHasValue = aValueED.GetText().Len() != 0;
     421                 :            : 
     422                 :          0 :         bInsert &= bHasValue;
     423                 :            :     }
     424                 :            : 
     425                 :          0 :     EnableInsert(bInsert);
     426                 :          0 : }
     427                 :            : 
     428                 :          0 : IMPL_LINK( SwFldDBPage, TreeSelectHdl, SvTreeListBox *, pBox )
     429                 :            : {
     430                 :            :     SvLBoxEntry* pColEntry;
     431                 :          0 :     SvLBoxEntry* pEntry = pColEntry = pBox->GetCurEntry();
     432                 :          0 :     if (pEntry)
     433                 :            :     {
     434                 :          0 :         sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
     435                 :            : 
     436                 :          0 :         pEntry = aDatabaseTLB.GetParent(pEntry);
     437                 :            : 
     438                 :          0 :         if (nTypeId == TYP_DBFLD && pEntry)
     439                 :          0 :             pEntry = aDatabaseTLB.GetParent(pEntry);
     440                 :            : 
     441                 :          0 :         CheckInsert();
     442                 :            : 
     443                 :          0 :         if (nTypeId == TYP_DBFLD)
     444                 :            :         {
     445                 :          0 :             sal_Bool bNumFormat = sal_False;
     446                 :            : 
     447                 :          0 :             if (pEntry != 0)
     448                 :            :             {
     449                 :          0 :                 String sTableName;
     450                 :          0 :                 String sColumnName;
     451                 :            :                 sal_Bool bIsTable;
     452                 :          0 :                 String sDBName = aDatabaseTLB.GetDBName(sTableName, sColumnName, &bIsTable);
     453                 :          0 :                 bNumFormat = GetFldMgr().IsDBNumeric(sDBName,
     454                 :            :                             sTableName,
     455                 :            :                             bIsTable,
     456                 :          0 :                             sColumnName);
     457                 :          0 :                 if (!IsFldEdit())
     458                 :          0 :                     aDBFormatRB.Check();
     459                 :            :             }
     460                 :            : 
     461                 :          0 :             aDBFormatRB.Enable(bNumFormat);
     462                 :          0 :             aNewFormatRB.Enable(bNumFormat);
     463                 :          0 :             aNumFormatLB.Enable(bNumFormat);
     464                 :          0 :             aFormatFL.Enable(bNumFormat);
     465                 :            :         }
     466                 :            :     }
     467                 :          0 :     return 0;
     468                 :            : }
     469                 :            : 
     470                 :          0 : IMPL_LINK_NOARG(SwFldDBPage, AddDBHdl)
     471                 :            : {
     472                 :          0 :     String sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
     473                 :          0 :     if(sNewDB.Len())
     474                 :            :     {
     475                 :          0 :         aDatabaseTLB.AddDataSource(sNewDB);
     476                 :            :     }
     477                 :          0 :     return 0;
     478                 :            : }
     479                 :            : 
     480                 :            : /*--------------------------------------------------------------------
     481                 :            :     Description: Modify
     482                 :            :  --------------------------------------------------------------------*/
     483                 :          0 : IMPL_LINK_NOARG(SwFldDBPage, ModifyHdl)
     484                 :            : {
     485                 :          0 :     CheckInsert();
     486                 :          0 :     return 0;
     487                 :            : }
     488                 :            : 
     489                 :          0 : void    SwFldDBPage::FillUserData()
     490                 :            : {
     491                 :          0 :     String sData(rtl::OUString(USER_DATA_VERSION));
     492                 :          0 :     sData += ';';
     493                 :          0 :     sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
     494                 :            : 
     495                 :          0 :     if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
     496                 :          0 :         nTypeSel = USHRT_MAX;
     497                 :            :     else
     498                 :          0 :         nTypeSel = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData( nTypeSel );
     499                 :          0 :     sData += String::CreateFromInt32( nTypeSel );
     500                 :          0 :     SetUserData(sData);
     501                 :          0 : }
     502                 :            : 
     503                 :          0 : void SwFldDBPage::ActivateMailMergeAddress()
     504                 :            : {
     505                 :          0 :     sal_uLong nData = TYP_DBFLD;
     506                 :          0 :     aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos( (const void*) nData ));
     507                 :          0 :     aTypeLB.GetSelectHdl().Call(&aTypeLB);
     508                 :          0 :     const SwDBData& rData = SW_MOD()->GetDBConfig()->GetAddressSource();
     509                 :          0 :     aDatabaseTLB.Select(rData.sDataSource, rData.sCommand, aEmptyStr);
     510                 :          0 : }
     511                 :            : 
     512                 :          0 : void SwFldDBPage::SetWrtShell(SwWrtShell& rSh)
     513                 :            : {
     514                 :          0 :     aDatabaseTLB.SetWrtShell(rSh);
     515                 :          0 : }
     516                 :            : 
     517                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10