2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 18:18:39 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 21:57:08 +00:00
|
|
|
|
2004-08-23 07:52:23 +00:00
|
|
|
#ifdef SW_DLLIMPLEMENTATION
|
|
|
|
#undef SW_DLLIMPLEMENTATION
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#include <swmodule.hxx>
|
|
|
|
#include <view.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <globals.hrc>
|
|
|
|
#include <dbfld.hxx>
|
|
|
|
#include <fldtdlg.hxx>
|
|
|
|
#include <numrule.hxx>
|
|
|
|
|
|
|
|
#include <fldtdlg.hrc>
|
|
|
|
#include <fldui.hrc>
|
|
|
|
#include <flddb.hxx>
|
2002-12-12 15:10:53 +00:00
|
|
|
#include <dbconfig.hxx>
|
2004-08-02 13:22:02 +00:00
|
|
|
#include <dbmgr.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#define USER_DATA_VERSION_1 "1"
|
|
|
|
#define USER_DATA_VERSION USER_DATA_VERSION_1
|
|
|
|
|
|
|
|
SwFldDBPage::SwFldDBPage(Window* pParent, const SfxItemSet& rCoreSet ) :
|
|
|
|
SwFldPage( pParent, SW_RES( TP_FLD_DB ), rCoreSet ),
|
|
|
|
aTypeFT (this, SW_RES(FT_DBTYPE)),
|
|
|
|
aTypeLB (this, SW_RES(LB_DBTYPE)),
|
|
|
|
aSelectionFT(this, SW_RES(FT_DBSELECTION)),
|
2011-01-17 15:06:54 +01:00
|
|
|
aDatabaseTLB(this, SW_RES(TLB_DBLIST), 0, aEmptyStr, sal_False),
|
2007-04-26 08:10:13 +00:00
|
|
|
aAddDBFT(this, SW_RES(FT_ADDDB)),
|
|
|
|
aAddDBPB(this, SW_RES(PB_ADDDB)),
|
2000-09-18 16:15:01 +00:00
|
|
|
aConditionFT(this, SW_RES(FT_DBCONDITION)),
|
|
|
|
aConditionED(this, SW_RES(ED_DBCONDITION)),
|
|
|
|
aValueFT (this, SW_RES(FT_DBSETNUMBER)),
|
|
|
|
aValueED (this, SW_RES(ED_DBSETNUMBER)),
|
|
|
|
aDBFormatRB (this, SW_RES(RB_DBOWNFORMAT)),
|
|
|
|
aNewFormatRB(this, SW_RES(RB_DBFORMAT)),
|
|
|
|
aNumFormatLB(this, SW_RES(LB_DBNUMFORMAT)),
|
|
|
|
aFormatLB (this, SW_RES(LB_DBFORMAT)),
|
2001-05-25 13:43:23 +00:00
|
|
|
aFormatFL (this, SW_RES(FL_DBFORMAT)),
|
|
|
|
aFormatVertFL (this, SW_RES(FL_DBFORMAT_VERT))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
FreeResource();
|
|
|
|
|
|
|
|
aOldNumSelectHdl = aNumFormatLB.GetSelectHdl();
|
|
|
|
|
|
|
|
aNumFormatLB.SetSelectHdl(LINK(this, SwFldDBPage, NumSelectHdl));
|
|
|
|
aDatabaseTLB.SetSelectHdl(LINK(this, SwFldDBPage, TreeSelectHdl));
|
|
|
|
aDatabaseTLB.SetDoubleClickHdl(LINK(this, SwFldDBPage, InsertHdl));
|
|
|
|
|
|
|
|
aValueED.SetModifyHdl(LINK(this, SwFldDBPage, ModifyHdl));
|
2004-08-02 13:22:02 +00:00
|
|
|
aAddDBPB.SetClickHdl(LINK(this, SwFldDBPage, AddDBHdl));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-12-12 00:08:03 +01:00
|
|
|
SwFldDBPage::~SwFldDBPage()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
2011-03-08 14:50:12 +01:00
|
|
|
Description: initialise TabPage
|
2000-09-18 16:15:01 +00:00
|
|
|
--------------------------------------------------------------------*/
|
2010-12-11 15:42:15 +01:00
|
|
|
void SwFldDBPage::Reset(const SfxItemSet&)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
Init(); // Allgemeine initialisierung
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
aTypeLB.SetUpdateMode(sal_False);
|
|
|
|
sal_uInt16 nOldPos = aTypeLB.GetSelectEntryPos();
|
2000-09-18 16:15:01 +00:00
|
|
|
sOldDBName = aDatabaseTLB.GetDBName(sOldTableName, sOldColumnName);
|
|
|
|
|
|
|
|
aTypeLB.Clear();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos, nTypeId, i;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if (!IsFldEdit())
|
|
|
|
{
|
2011-03-08 14:50:12 +01:00
|
|
|
// initialise TypeListBox
|
2000-09-18 16:15:01 +00:00
|
|
|
const SwFldGroupRgn& rRg = GetFldMgr().GetGroupRange(IsFldDlgHtmlMode(), GetGroup());
|
|
|
|
|
|
|
|
for(i = rRg.nStart; i < rRg.nEnd; ++i)
|
|
|
|
{
|
|
|
|
nTypeId = GetFldMgr().GetTypeId(i);
|
|
|
|
nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(i));
|
2007-09-27 10:45:59 +00:00
|
|
|
aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nTypeId = GetCurField()->GetTypeId();
|
|
|
|
nPos = aTypeLB.InsertEntry(GetFldMgr().GetTypeStr(GetFldMgr().GetPos(nTypeId)));
|
2007-09-27 10:45:59 +00:00
|
|
|
aTypeLB.SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2011-03-08 14:50:12 +01:00
|
|
|
// select old Pos
|
2000-09-18 16:15:01 +00:00
|
|
|
if (GetTypeSel() != LISTBOX_ENTRY_NOTFOUND)
|
|
|
|
aTypeLB.SelectEntryPos(GetTypeSel());
|
|
|
|
|
|
|
|
aFormatLB.Clear();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nSize = GetFldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, sal_False, IsFldDlgHtmlMode());
|
2000-09-18 16:15:01 +00:00
|
|
|
for( i = 0; i < nSize; ++i )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nEntryPos = aFormatLB.InsertEntry(GetFldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
|
|
|
|
sal_uInt16 nFmtId = GetFldMgr().GetFormatId( TYP_DBSETNUMBERFLD, i );
|
2007-09-27 10:45:59 +00:00
|
|
|
aFormatLB.SetEntryData( nEntryPos, reinterpret_cast<void*>(nFmtId) );
|
2000-09-18 16:15:01 +00:00
|
|
|
if( SVX_NUM_ARABIC == nFmtId )
|
2007-09-27 10:45:59 +00:00
|
|
|
aFormatLB.SelectEntryPos( nEntryPos );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsFldEdit())
|
|
|
|
{
|
|
|
|
if (nOldPos != LISTBOX_ENTRY_NOTFOUND)
|
|
|
|
aTypeLB.SelectEntryPos(nOldPos);
|
|
|
|
|
|
|
|
if (sOldDBName.Len())
|
|
|
|
{
|
|
|
|
aDatabaseTLB.Select(sOldDBName, sOldTableName, sOldColumnName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-01-31 17:34:19 +00:00
|
|
|
SwWrtShell *pSh = GetWrtShell();
|
|
|
|
if(!pSh)
|
|
|
|
pSh = ::GetActiveWrtShell();
|
|
|
|
if(pSh)
|
|
|
|
{
|
|
|
|
SwDBData aTmp(pSh->GetDBData());
|
|
|
|
aDatabaseTLB.Select(aTmp.sDataSource, aTmp.sCommand, aEmptyStr);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !IsRefresh() )
|
|
|
|
{
|
|
|
|
String sUserData = GetUserData();
|
|
|
|
if(sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
|
|
|
|
{
|
|
|
|
String sVal = sUserData.GetToken(1, ';');
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nVal = (sal_uInt16)sVal.ToInt32();
|
2000-09-18 16:15:01 +00:00
|
|
|
if(nVal != USHRT_MAX)
|
|
|
|
{
|
2007-09-27 10:45:59 +00:00
|
|
|
for(i = 0; i < aTypeLB.GetEntryCount(); i++)
|
2011-01-17 15:06:54 +01:00
|
|
|
if(nVal == (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(i))
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
aTypeLB.SelectEntryPos(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TypeHdl(0);
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
aTypeLB.SetUpdateMode(sal_True);
|
2000-09-18 16:15:01 +00:00
|
|
|
aTypeLB.SetSelectHdl(LINK(this, SwFldDBPage, TypeHdl));
|
|
|
|
aTypeLB.SetDoubleClickHdl(LINK(this, SwFldDBPage, InsertHdl));
|
|
|
|
|
|
|
|
if (IsFldEdit())
|
|
|
|
{
|
|
|
|
aConditionED.SaveValue();
|
|
|
|
aValueED.SaveValue();
|
|
|
|
sOldDBName = aDatabaseTLB.GetDBName(sOldTableName, sOldColumnName);
|
|
|
|
nOldFormat = GetCurField()->GetFormat();
|
|
|
|
nOldSubType = GetCurField()->GetSubType();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
sal_Bool SwFldDBPage::FillItemSet(SfxItemSet& )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
String sTableName, sColumnName;
|
2001-02-21 11:27:37 +00:00
|
|
|
SwDBData aData;
|
2001-07-18 12:25:54 +00:00
|
|
|
sal_Bool bIsTable;
|
|
|
|
aData.sDataSource = aDatabaseTLB.GetDBName(sTableName, sColumnName, &bIsTable);
|
2001-02-21 11:27:37 +00:00
|
|
|
aData.sCommand = sTableName;
|
2001-07-18 12:25:54 +00:00
|
|
|
aData.nCommandType = bIsTable ? 0 : 1;
|
2006-01-31 17:34:19 +00:00
|
|
|
SwWrtShell *pSh = GetWrtShell();
|
|
|
|
if(!pSh)
|
|
|
|
pSh = ::GetActiveWrtShell();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-02-21 11:27:37 +00:00
|
|
|
if (!aData.sDataSource.getLength())
|
|
|
|
aData = pSh->GetDBData();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-03-08 14:50:12 +01:00
|
|
|
if(aData.sDataSource.getLength()) // without database no new field command
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
|
2000-09-18 16:15:01 +00:00
|
|
|
String aVal(aValueED.GetText());
|
|
|
|
String aName(aConditionED.GetText());
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nFormat = 0;
|
|
|
|
sal_uInt16 nSubType = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-02-21 11:27:37 +00:00
|
|
|
String sDBName = aData.sDataSource;
|
2000-09-18 16:15:01 +00:00
|
|
|
sDBName += DB_DELIM;
|
2001-02-21 11:27:37 +00:00
|
|
|
sDBName += (String)aData.sCommand;
|
2000-09-18 16:15:01 +00:00
|
|
|
sDBName += DB_DELIM;
|
2001-07-11 11:10:54 +00:00
|
|
|
sDBName += String::CreateFromInt32(aData.nCommandType);
|
|
|
|
sDBName += DB_DELIM;
|
2000-09-18 16:15:01 +00:00
|
|
|
if(sColumnName.Len())
|
|
|
|
{
|
|
|
|
sDBName += sColumnName;
|
|
|
|
sDBName += DB_DELIM;
|
|
|
|
}
|
|
|
|
aName.Insert(sDBName, 0);
|
|
|
|
|
|
|
|
switch (nTypeId)
|
|
|
|
{
|
|
|
|
case TYP_DBFLD:
|
|
|
|
nFormat = aNumFormatLB.GetFormat();
|
|
|
|
if (aNewFormatRB.IsEnabled() && aNewFormatRB.IsChecked())
|
2007-09-27 10:45:59 +00:00
|
|
|
nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
|
2000-09-18 16:15:01 +00:00
|
|
|
aName = sDBName;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYP_DBSETNUMBERFLD:
|
2011-01-17 15:06:54 +01:00
|
|
|
nFormat = (sal_uInt16)(sal_uLong)aFormatLB.GetEntryData(
|
2000-09-18 16:15:01 +00:00
|
|
|
aFormatLB.GetSelectEntryPos() );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String sTempDBName, sTempTableName, sTempColumnName;
|
|
|
|
sTempDBName = aDatabaseTLB.GetDBName(sTempTableName, sTempColumnName);
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bDBListBoxChanged = sOldDBName != sTempDBName ||
|
2000-09-18 16:15:01 +00:00
|
|
|
sOldTableName != sTempTableName || sOldColumnName != sTempColumnName;
|
|
|
|
if (!IsFldEdit() ||
|
|
|
|
aConditionED.GetSavedValue() != aConditionED.GetText() ||
|
|
|
|
aValueED.GetSavedValue() != aValueED.GetText() ||
|
|
|
|
bDBListBoxChanged ||
|
|
|
|
nOldFormat != nFormat || nOldSubType != nSubType)
|
|
|
|
{
|
|
|
|
InsertFld( nTypeId, nSubType, aName, aVal, nFormat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 15:42:15 +01:00
|
|
|
SfxTabPage* SwFldDBPage::Create( Window* pParent,
|
2000-09-18 16:15:01 +00:00
|
|
|
const SfxItemSet& rAttrSet )
|
|
|
|
{
|
|
|
|
return ( new SwFldDBPage( pParent, rAttrSet ) );
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwFldDBPage::GetGroup()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
return GRP_DB;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SwFldDBPage, TypeHdl, ListBox *, pBox )
|
|
|
|
{
|
2011-03-08 14:50:12 +01:00
|
|
|
// save old ListBoxPos
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 nOld = GetTypeSel();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-03-08 14:50:12 +01:00
|
|
|
// current ListBoxPos
|
2000-09-18 16:15:01 +00:00
|
|
|
SetTypeSel(aTypeLB.GetSelectEntryPos());
|
|
|
|
|
|
|
|
if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
|
|
|
|
{
|
|
|
|
SetTypeSel(0);
|
|
|
|
aTypeLB.SelectEntryPos(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nOld != GetTypeSel())
|
|
|
|
{
|
2006-01-31 17:34:19 +00:00
|
|
|
SwWrtShell *pSh = GetWrtShell();
|
|
|
|
if(!pSh)
|
|
|
|
pSh = ::GetActiveWrtShell();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCond = sal_False, bSetNo = sal_False, bFormat = sal_False, bDBFormat = sal_False;
|
|
|
|
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
aDatabaseTLB.ShowColumns(nTypeId == TYP_DBFLD);
|
|
|
|
|
|
|
|
if (IsFldEdit())
|
|
|
|
{
|
2001-02-21 11:27:37 +00:00
|
|
|
SwDBData aData;
|
|
|
|
String sColumnName;
|
2000-09-18 16:15:01 +00:00
|
|
|
if (nTypeId == TYP_DBFLD)
|
|
|
|
{
|
2001-02-21 11:27:37 +00:00
|
|
|
aData = ((SwDBField*)GetCurField())->GetDBData();
|
2000-09-18 16:15:01 +00:00
|
|
|
sColumnName = ((SwDBFieldType*)GetCurField()->GetTyp())->GetColumnName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-21 11:27:37 +00:00
|
|
|
aData = ((SwDBNameInfField*)GetCurField())->GetDBData(pSh->GetDoc());
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-02-21 11:27:37 +00:00
|
|
|
aDatabaseTLB.Select(aData.sDataSource, aData.sCommand, sColumnName);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (nTypeId)
|
|
|
|
{
|
|
|
|
case TYP_DBFLD:
|
2011-01-17 15:06:54 +01:00
|
|
|
bFormat = sal_True;
|
|
|
|
bDBFormat = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
aNumFormatLB.Show();
|
|
|
|
aFormatLB.Hide();
|
|
|
|
|
2011-03-08 14:50:12 +01:00
|
|
|
if (pBox) // type was changed by user
|
2000-09-18 16:15:01 +00:00
|
|
|
aDBFormatRB.Check();
|
|
|
|
|
|
|
|
if (IsFldEdit())
|
|
|
|
{
|
2007-11-21 12:54:44 +00:00
|
|
|
if (GetCurField()->GetFormat() != 0 && GetCurField()->GetFormat() != SAL_MAX_UINT32)
|
2000-09-18 16:15:01 +00:00
|
|
|
aNumFormatLB.SetDefFormat(GetCurField()->GetFormat());
|
|
|
|
|
2007-09-27 10:45:59 +00:00
|
|
|
if (GetCurField()->GetSubType() & nsSwExtendedSubType::SUB_OWN_FMT)
|
2000-09-18 16:15:01 +00:00
|
|
|
aNewFormatRB.Check();
|
|
|
|
else
|
|
|
|
aDBFormatRB.Check();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYP_DBNUMSETFLD:
|
2011-01-17 15:06:54 +01:00
|
|
|
bSetNo = sal_True;
|
2011-03-08 14:50:12 +01:00
|
|
|
// no break!
|
2000-09-18 16:15:01 +00:00
|
|
|
case TYP_DBNEXTSETFLD:
|
2011-01-17 15:06:54 +01:00
|
|
|
bCond = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
if (IsFldEdit())
|
|
|
|
{
|
|
|
|
aConditionED.SetText(GetCurField()->GetPar1());
|
|
|
|
aValueED.SetText(GetCurField()->GetPar2());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYP_DBNAMEFLD:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TYP_DBSETNUMBERFLD:
|
2011-01-17 15:06:54 +01:00
|
|
|
bFormat = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
aNewFormatRB.Check();
|
|
|
|
aNumFormatLB.Hide();
|
|
|
|
aFormatLB.Show();
|
|
|
|
if( IsFldEdit() )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 nI = aFormatLB.GetEntryCount(); nI; )
|
|
|
|
if( GetCurField()->GetFormat() == (sal_uInt16)(sal_uLong)
|
2000-09-18 16:15:01 +00:00
|
|
|
aFormatLB.GetEntryData( --nI ))
|
|
|
|
{
|
|
|
|
aFormatLB.SelectEntryPos( nI );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aConditionFT.Enable(bCond);
|
|
|
|
aConditionED.Enable(bCond);
|
|
|
|
aValueFT.Enable(bSetNo);
|
|
|
|
aValueED.Enable(bSetNo);
|
|
|
|
if (nTypeId != TYP_DBFLD)
|
|
|
|
{
|
|
|
|
aDBFormatRB.Enable(bDBFormat);
|
|
|
|
aNewFormatRB.Enable(bDBFormat|bFormat);
|
|
|
|
aNumFormatLB.Enable(bDBFormat);
|
|
|
|
aFormatLB.Enable(bFormat);
|
|
|
|
}
|
2001-05-25 13:43:23 +00:00
|
|
|
aFormatFL.Enable(bDBFormat|bFormat);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if (!IsFldEdit())
|
|
|
|
{
|
|
|
|
aValueED.SetText(aEmptyStr);
|
|
|
|
if (bCond)
|
|
|
|
aConditionED.SetText( String::CreateFromAscii(
|
2011-04-14 07:25:24 +02:00
|
|
|
RTL_CONSTASCII_STRINGPARAM( "TRUE" )));
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
|
|
|
aConditionED.SetText(aEmptyStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
CheckInsert();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SwFldDBPage, NumSelectHdl, NumFormatListBox *, pLB )
|
|
|
|
{
|
|
|
|
aNewFormatRB.Check();
|
|
|
|
aOldNumSelectHdl.Call(pLB);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwFldDBPage::CheckInsert()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bInsert = sal_True;
|
|
|
|
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
SvLBoxEntry* pEntry = aDatabaseTLB.GetCurEntry();
|
|
|
|
|
|
|
|
if (pEntry)
|
|
|
|
{
|
|
|
|
pEntry = aDatabaseTLB.GetParent(pEntry);
|
|
|
|
|
|
|
|
if (nTypeId == TYP_DBFLD && pEntry)
|
|
|
|
pEntry = aDatabaseTLB.GetParent(pEntry);
|
|
|
|
|
|
|
|
bInsert &= pEntry != 0;
|
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
bInsert = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if (nTypeId == TYP_DBNUMSETFLD)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bHasValue = aValueED.GetText().Len() != 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
bInsert &= bHasValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnableInsert(bInsert);
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SwFldDBPage, TreeSelectHdl, SvTreeListBox *, pBox )
|
|
|
|
{
|
|
|
|
SvLBoxEntry* pColEntry;
|
|
|
|
SvLBoxEntry* pEntry = pColEntry = pBox->GetCurEntry();
|
|
|
|
if (pEntry)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nTypeId = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData(GetTypeSel());
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
pEntry = aDatabaseTLB.GetParent(pEntry);
|
|
|
|
|
|
|
|
if (nTypeId == TYP_DBFLD && pEntry)
|
|
|
|
pEntry = aDatabaseTLB.GetParent(pEntry);
|
|
|
|
|
|
|
|
CheckInsert();
|
|
|
|
|
|
|
|
if (nTypeId == TYP_DBFLD)
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bNumFormat = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if (pEntry != 0)
|
|
|
|
{
|
|
|
|
String sTableName;
|
|
|
|
String sColumnName;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bIsTable;
|
2000-09-18 16:15:01 +00:00
|
|
|
String sDBName = aDatabaseTLB.GetDBName(sTableName, sColumnName, &bIsTable);
|
|
|
|
bNumFormat = GetFldMgr().IsDBNumeric(sDBName,
|
|
|
|
sTableName,
|
|
|
|
bIsTable,
|
|
|
|
sColumnName);
|
|
|
|
if (!IsFldEdit())
|
|
|
|
aDBFormatRB.Check();
|
|
|
|
}
|
|
|
|
|
|
|
|
aDBFormatRB.Enable(bNumFormat);
|
|
|
|
aNewFormatRB.Enable(bNumFormat);
|
|
|
|
aNumFormatLB.Enable(bNumFormat);
|
2001-05-25 13:43:23 +00:00
|
|
|
aFormatFL.Enable(bNumFormat);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-02 13:22:02 +00:00
|
|
|
|
|
|
|
IMPL_LINK( SwFldDBPage, AddDBHdl, PushButton *, EMPTYARG )
|
|
|
|
{
|
|
|
|
String sNewDB = SwNewDBMgr::LoadAndRegisterDataSource();
|
|
|
|
if(sNewDB.Len())
|
|
|
|
{
|
|
|
|
aDatabaseTLB.AddDataSource(sNewDB);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
2011-03-08 14:50:12 +01:00
|
|
|
Description: Modify
|
2000-09-18 16:15:01 +00:00
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
IMPL_LINK( SwFldDBPage, ModifyHdl, Edit *, EMPTYARG )
|
|
|
|
{
|
|
|
|
CheckInsert();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwFldDBPage::FillUserData()
|
|
|
|
{
|
|
|
|
String sData( String::CreateFromAscii(
|
|
|
|
RTL_CONSTASCII_STRINGPARAM( USER_DATA_VERSION )));
|
|
|
|
sData += ';';
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nTypeSel = aTypeLB.GetSelectEntryPos();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
|
|
|
|
nTypeSel = USHRT_MAX;
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
nTypeSel = (sal_uInt16)(sal_uLong)aTypeLB.GetEntryData( nTypeSel );
|
2000-09-18 16:15:01 +00:00
|
|
|
sData += String::CreateFromInt32( nTypeSel );
|
|
|
|
SetUserData(sData);
|
|
|
|
}
|
2010-10-10 13:47:31 -05:00
|
|
|
|
2002-12-12 15:10:53 +00:00
|
|
|
void SwFldDBPage::ActivateMailMergeAddress()
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nData = TYP_DBFLD;
|
2002-12-12 15:10:53 +00:00
|
|
|
aTypeLB.SelectEntryPos(aTypeLB.GetEntryPos( (const void*) nData ));
|
|
|
|
aTypeLB.GetSelectHdl().Call(&aTypeLB);
|
|
|
|
const SwDBData& rData = SW_MOD()->GetDBConfig()->GetAddressSource();
|
|
|
|
aDatabaseTLB.Select(rData.sDataSource, rData.sCommand, aEmptyStr);
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2003-12-01 08:45:14 +00:00
|
|
|
void SwFldDBPage::SetWrtShell(SwWrtShell& rSh)
|
|
|
|
{
|
|
|
|
aDatabaseTLB.SetWrtShell(rSh);
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|