2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 13:00:01 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:00:01 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:00:01 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:00:01 +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 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:00:01 +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 23:08:29 +00:00
|
|
|
*
|
2008-04-10 13:00:01 +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 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 20:13:15 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <pam.hxx> // fuer GetBodyTxtNode
|
|
|
|
#include <ndtxt.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtfld.hxx>
|
|
|
|
#include <txtfld.hxx>
|
2001-10-24 17:56:14 +00:00
|
|
|
#include <expfld.hxx>
|
|
|
|
#include <docfld.hxx> // fuer _SetGetExpFld
|
|
|
|
#ifndef _UNOFLDMID_H
|
|
|
|
#include <unofldmid.h>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
2008-03-12 11:20:58 +00:00
|
|
|
using ::rtl::OUString;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
SwTblFieldType::SwTblFieldType(SwDoc* pDocPtr)
|
|
|
|
: SwValueFieldType( pDocPtr, RES_TABLEFLD )
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
SwFieldType* SwTblFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwTblFieldType(GetDoc());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SwTblField::CalcField( SwTblCalcPara& rCalcPara )
|
|
|
|
{
|
|
|
|
if( rCalcPara.rCalc.IsCalcError() ) // ist schon Fehler gesetzt ?
|
|
|
|
return;
|
|
|
|
|
|
|
|
// erzeuge aus den BoxNamen die Pointer
|
|
|
|
BoxNmToPtr( rCalcPara.pTbl );
|
|
|
|
String sFml( MakeFormel( rCalcPara ));
|
|
|
|
SetValue( rCalcPara.rCalc.Calculate( sFml ).GetDouble() );
|
|
|
|
ChgValid( !rCalcPara.IsStackOverFlow() ); // ist der Wert wieder gueltig?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-09-27 07:50:33 +00:00
|
|
|
SwTblField::SwTblField( SwTblFieldType* pInitType, const String& rFormel,
|
2000-09-18 23:08:29 +00:00
|
|
|
USHORT nType, ULONG nFmt )
|
2007-09-27 07:50:33 +00:00
|
|
|
: SwValueField( pInitType, nFmt ), SwTableFormula( rFormel ),
|
|
|
|
sExpand( '0' ), nSubType(nType)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SwField* SwTblField::Copy() const
|
|
|
|
{
|
|
|
|
SwTblField* pTmp = new SwTblField( (SwTblFieldType*)GetTyp(),
|
|
|
|
SwTableFormula::GetFormula(), nSubType, GetFormat() );
|
|
|
|
pTmp->sExpand = sExpand;
|
|
|
|
pTmp->SwValueField::SetValue(GetValue());
|
|
|
|
pTmp->SwTableFormula::operator=( *this );
|
2002-11-15 10:17:38 +00:00
|
|
|
pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
|
2000-09-18 23:08:29 +00:00
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String SwTblField::GetCntnt(BOOL bName) const
|
|
|
|
{
|
|
|
|
if( bName )
|
|
|
|
{
|
|
|
|
String aStr(GetTyp()->GetName());
|
|
|
|
aStr += ' ';
|
2001-10-18 08:27:16 +00:00
|
|
|
|
|
|
|
USHORT nOldSubType = nSubType;
|
|
|
|
SwTblField* pThis = (SwTblField*)this;
|
2007-09-27 07:50:33 +00:00
|
|
|
pThis->nSubType |= nsSwExtendedSubType::SUB_CMD;
|
2001-10-18 08:27:16 +00:00
|
|
|
aStr += Expand();
|
|
|
|
pThis->nSubType = nOldSubType;
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
return Expand();
|
|
|
|
}
|
|
|
|
|
|
|
|
// suche den TextNode, in dem das Feld steht
|
|
|
|
const SwNode* SwTblField::GetNodeOfFormula() const
|
|
|
|
{
|
|
|
|
if( !GetTyp()->GetDepends() )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
SwClientIter aIter( *GetTyp() );
|
|
|
|
SwClient * pLast = aIter.GoStart();
|
|
|
|
if( pLast ) // konnte zum Anfang gesprungen werden ??
|
|
|
|
do {
|
|
|
|
const SwFmtFld* pFmtFld = (SwFmtFld*)pLast;
|
|
|
|
if( this == pFmtFld->GetFld() )
|
|
|
|
return (SwTxtNode*)&pFmtFld->GetTxtFld()->GetTxtNode();
|
|
|
|
|
|
|
|
} while( 0 != ( pLast = aIter++ ));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String SwTblField::Expand() const
|
|
|
|
{
|
|
|
|
String aStr;
|
2007-09-27 07:50:33 +00:00
|
|
|
if (nSubType & nsSwExtendedSubType::SUB_CMD)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( EXTRNL_NAME != GetNameType() )
|
|
|
|
{
|
|
|
|
const SwNode* pNd = GetNodeOfFormula();
|
|
|
|
const SwTableNode* pTblNd = pNd ? pNd->FindTableNode() : 0;
|
|
|
|
if( pTblNd )
|
|
|
|
((SwTblField*)this)->PtrToBoxNm( &pTblNd->GetTable() );
|
|
|
|
}
|
|
|
|
if( EXTRNL_NAME == GetNameType() )
|
|
|
|
aStr = SwTableFormula::GetFormula();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aStr = sExpand;
|
2007-09-27 07:50:33 +00:00
|
|
|
if(nSubType & nsSwGetSetExpType::GSE_STRING)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
// es ist ein String
|
|
|
|
aStr = sExpand;
|
|
|
|
aStr.Erase( 0,1 );
|
|
|
|
aStr.Erase( aStr.Len()-1, 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT SwTblField::GetSubType() const
|
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTblField::SetSubType(USHORT nType)
|
|
|
|
{
|
|
|
|
nSubType = nType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwTblField::SetValue( const double& rVal )
|
|
|
|
{
|
|
|
|
SwValueField::SetValue(rVal);
|
|
|
|
sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue(rVal, GetFormat(), GetLanguage());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Parameter setzen
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
String SwTblField::GetPar2() const
|
|
|
|
{
|
|
|
|
return SwTableFormula::GetFormula();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwTblField::SetPar2(const String& rStr)
|
|
|
|
{
|
|
|
|
SetFormula( rStr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-----------------04.03.98 10:33-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2007-09-27 07:50:33 +00:00
|
|
|
BOOL SwTblField::QueryValue( uno::Any& rAny, USHORT nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
BOOL bRet = TRUE;
|
2007-09-27 07:50:33 +00:00
|
|
|
switch ( nWhichId )
|
2001-10-17 12:38:26 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
{
|
|
|
|
USHORT nOldSubType = nSubType;
|
|
|
|
SwTblField* pThis = (SwTblField*)this;
|
2007-09-27 07:50:33 +00:00
|
|
|
pThis->nSubType |= nsSwExtendedSubType::SUB_CMD;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny <<= rtl::OUString( Expand() );
|
|
|
|
pThis->nSubType = nOldSubType;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
2007-09-27 07:50:33 +00:00
|
|
|
BOOL bFormula = 0 != (nsSwExtendedSubType::SUB_CMD & nSubType);
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bFormula, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
2001-10-17 12:38:26 +00:00
|
|
|
rAny <<= rtl::OUString(GetExpStr());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
2001-10-25 10:45:15 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
|
|
|
rAny <<= (sal_Int32)GetFormat();
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2001-10-25 10:45:15 +00:00
|
|
|
bRet = sal_False;
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/*-----------------04.03.98 10:33-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2007-09-27 07:50:33 +00:00
|
|
|
BOOL SwTblField::PutValue( const uno::Any& rAny, USHORT nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
BOOL bRet = TRUE;
|
2001-10-24 17:56:14 +00:00
|
|
|
String sTmp;
|
2007-09-27 07:50:33 +00:00
|
|
|
switch ( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
SetFormula( ::GetString( rAny, sTmp ));
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
if(*(sal_Bool*)rAny.getValue())
|
2007-09-27 07:50:33 +00:00
|
|
|
nSubType = nsSwGetSetExpType::GSE_FORMULA|nsSwExtendedSubType::SUB_CMD;
|
2001-10-17 12:38:26 +00:00
|
|
|
else
|
2007-09-27 07:50:33 +00:00
|
|
|
nSubType = nsSwGetSetExpType::GSE_FORMULA;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
ChgExpStr( ::GetString( rAny, sTmp ));
|
|
|
|
break;
|
2001-10-25 10:45:15 +00:00
|
|
|
case FIELD_PROP_FORMAT:
|
|
|
|
{
|
2007-11-12 15:24:49 +00:00
|
|
|
sal_Int32 nTmp = 0;
|
2001-10-25 10:45:15 +00:00
|
|
|
rAny >>= nTmp;
|
|
|
|
SetFormat(nTmp);
|
|
|
|
}
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2001-10-25 10:45:15 +00:00
|
|
|
bRet = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|