2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 12:55:51 +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 12:55:51 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:55:51 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2008-04-10 12:55:51 +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 12:55:51 +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 12:55:51 +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:11:24 +00:00
|
|
|
|
2001-10-17 08:48:07 +00:00
|
|
|
#include <hintids.hxx>
|
2001-04-27 15:57:17 +00:00
|
|
|
#include <unotools/collatorwrapper.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <unotools/charclass.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/unolingu.hxx>
|
2001-10-17 08:48:07 +00:00
|
|
|
#include <svx/pageitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/langitem.hxx>
|
|
|
|
#include <editeng/fontitem.hxx>
|
2001-10-17 08:48:07 +00:00
|
|
|
#include <com/sun/star/text/SetVariableType.hpp>
|
2000-11-08 11:45:24 +00:00
|
|
|
#include <unofield.hxx>
|
2010-01-05 16:37:42 +01:00
|
|
|
#include <frmfmt.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <fmtfld.hxx>
|
|
|
|
#include <txtfld.hxx>
|
|
|
|
#include <fmtanchr.hxx>
|
|
|
|
#include <txtftn.hxx>
|
|
|
|
#include <doc.hxx>
|
|
|
|
#include <layfrm.hxx>
|
|
|
|
#include <pagefrm.hxx>
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#include <rootfrm.hxx>
|
2001-10-17 08:48:07 +00:00
|
|
|
#include <tabfrm.hxx>
|
|
|
|
#include <flyfrm.hxx>
|
|
|
|
#include <ftnfrm.hxx>
|
2004-05-03 12:45:37 +00:00
|
|
|
#include <rowfrm.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <expfld.hxx>
|
|
|
|
#include <usrfld.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
2001-10-17 08:48:07 +00:00
|
|
|
#include <calc.hxx>
|
|
|
|
#include <pam.hxx>
|
|
|
|
#include <docfld.hxx>
|
|
|
|
#include <swcache.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <breakit.hxx>
|
2001-07-19 15:32:24 +00:00
|
|
|
#include <SwStyleNameMapper.hxx>
|
2001-10-24 17:56:14 +00:00
|
|
|
#include <unofldmid.h>
|
2008-03-05 16:02:10 +00:00
|
|
|
#include <numrule.hxx>
|
2010-12-17 09:02:23 +01:00
|
|
|
#include <switerator.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::text;
|
2008-03-12 11:19:53 +00:00
|
|
|
using ::rtl::OUString;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
SV_IMPL_PTRARR( _SwSeqFldList, _SeqFldLstElem* )
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Int16 lcl_SubTypeToAPI(sal_uInt16 nSubType)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
sal_Int16 nRet = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
switch(nSubType)
|
|
|
|
{
|
2011-01-03 13:40:23 +01:00
|
|
|
case nsSwGetSetExpType::GSE_EXPR:
|
|
|
|
nRet = SetVariableType::VAR; // 0
|
|
|
|
break;
|
|
|
|
case nsSwGetSetExpType::GSE_SEQ:
|
|
|
|
nRet = SetVariableType::SEQUENCE; // 1
|
|
|
|
break;
|
|
|
|
case nsSwGetSetExpType::GSE_FORMULA:
|
|
|
|
nRet = SetVariableType::FORMULA; // 2
|
|
|
|
break;
|
|
|
|
case nsSwGetSetExpType::GSE_STRING:
|
|
|
|
nRet = SetVariableType::STRING; // 3
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
sal_Int32 lcl_APIToSubType(const uno::Any& rAny)
|
|
|
|
{
|
2007-11-12 15:23:43 +00:00
|
|
|
sal_Int16 nVal = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>= nVal;
|
|
|
|
sal_Int32 nSet = 0;
|
|
|
|
switch(nVal)
|
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
case SetVariableType::VAR: nSet = nsSwGetSetExpType::GSE_EXPR; break;
|
|
|
|
case SetVariableType::SEQUENCE: nSet = nsSwGetSetExpType::GSE_SEQ; break;
|
|
|
|
case SetVariableType::FORMULA: nSet = nsSwGetSetExpType::GSE_FORMULA; break;
|
|
|
|
case SetVariableType::STRING: nSet = nsSwGetSetExpType::GSE_STRING; break;
|
2000-09-18 23:08:29 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("wrong value");
|
2000-09-18 23:08:29 +00:00
|
|
|
nSet = -1;
|
|
|
|
}
|
|
|
|
return nSet;
|
|
|
|
}
|
2008-02-19 12:42:50 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void ReplacePoint( String& rTmpName, sal_Bool bWithCommandType )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-07-20 11:49:57 +00:00
|
|
|
// replace first and last (if bWithCommandType: last two) dot Ersten und letzten Punkt ersetzen, da in Tabellennamen Punkte erlaubt sind
|
|
|
|
// since table names may contain dots
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
xub_StrLen nLen = rTmpName.Len();
|
|
|
|
sal_Unicode *pStr = rTmpName.GetBufferAccess(), *pBackStr = pStr + nLen;
|
|
|
|
|
2001-07-20 11:49:57 +00:00
|
|
|
long nBackCount = bWithCommandType ? 2 : 1;
|
2003-12-01 16:17:12 +00:00
|
|
|
xub_StrLen i;
|
|
|
|
|
|
|
|
for( i = nLen; i; --i, pBackStr-- )
|
2000-09-18 23:08:29 +00:00
|
|
|
if( '.' == *pBackStr )
|
|
|
|
{
|
|
|
|
*pBackStr = DB_DELIM;
|
2001-07-20 11:49:57 +00:00
|
|
|
if(!--nBackCount)
|
|
|
|
break;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
for( i = 0; i < nLen; ++i, ++pStr )
|
|
|
|
if( '.' == *pStr )
|
|
|
|
{
|
|
|
|
*pStr = DB_DELIM;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTxtNode* GetFirstTxtNode( const SwDoc& rDoc, SwPosition& rPos,
|
|
|
|
const SwCntntFrm *pCFrm, Point &rPt )
|
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
SwTxtNode* pTxtNode = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
if ( !pCFrm )
|
|
|
|
{
|
2006-08-14 15:13:16 +00:00
|
|
|
const SwNodes& rNodes = rDoc.GetNodes();
|
|
|
|
rPos.nNode = *rNodes.GetEndOfContent().StartOfSectionNode();
|
2000-09-18 23:08:29 +00:00
|
|
|
SwCntntNode* pCNd;
|
2006-08-14 15:13:16 +00:00
|
|
|
while( 0 != (pCNd = rNodes.GoNext( &rPos.nNode ) ) &&
|
2000-09-18 23:08:29 +00:00
|
|
|
0 == ( pTxtNode = pCNd->GetTxtNode() ) )
|
|
|
|
;
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pTxtNode, "wo ist der 1.TextNode" );
|
2000-09-18 23:08:29 +00:00
|
|
|
rPos.nContent.Assign( pTxtNode, 0 );
|
|
|
|
}
|
|
|
|
else if ( !pCFrm->IsValid() )
|
|
|
|
{
|
|
|
|
pTxtNode = (SwTxtNode*)pCFrm->GetNode();
|
|
|
|
rPos.nNode = *pTxtNode;
|
|
|
|
rPos.nContent.Assign( pTxtNode, 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pCFrm->GetCrsrOfst( &rPos, rPt );
|
|
|
|
pTxtNode = rPos.nNode.GetNode().GetTxtNode();
|
|
|
|
}
|
|
|
|
return pTxtNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTxtNode* GetBodyTxtNode( const SwDoc& rDoc, SwPosition& rPos,
|
|
|
|
const SwFrm& rFrm )
|
|
|
|
{
|
|
|
|
const SwLayoutFrm* pLayout = (SwLayoutFrm*)rFrm.GetUpper();
|
|
|
|
const SwTxtNode* pTxtNode = 0;
|
|
|
|
|
|
|
|
while( pLayout )
|
|
|
|
{
|
|
|
|
if( pLayout->IsFlyFrm() )
|
|
|
|
{
|
|
|
|
// hole das FlyFormat
|
|
|
|
SwFrmFmt* pFlyFmt = ((SwFlyFrm*)pLayout)->GetFmt();
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pFlyFmt, "kein FlyFormat gefunden, wo steht das Feld" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
const SwFmtAnchor &rAnchor = pFlyFmt->GetAnchor();
|
|
|
|
|
|
|
|
if( FLY_AT_FLY == rAnchor.GetAnchorId() )
|
|
|
|
{
|
|
|
|
// und der Fly muss irgendwo angehaengt sein, also
|
|
|
|
// den befragen
|
2004-06-28 12:33:47 +00:00
|
|
|
pLayout = (SwLayoutFrm*)((SwFlyFrm*)pLayout)->GetAnchorFrm();
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-01-05 16:37:41 +01:00
|
|
|
else if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
|
|
|
|
(FLY_AT_CHAR == rAnchor.GetAnchorId()) ||
|
|
|
|
(FLY_AS_CHAR == rAnchor.GetAnchorId()))
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( rAnchor.GetCntntAnchor(), "keine gueltige Position" );
|
2000-09-18 23:08:29 +00:00
|
|
|
rPos = *rAnchor.GetCntntAnchor();
|
|
|
|
pTxtNode = rPos.nNode.GetNode().GetTxtNode();
|
2010-01-05 16:37:41 +01:00
|
|
|
if ( FLY_AT_PARA == rAnchor.GetAnchorId() )
|
|
|
|
{
|
|
|
|
const_cast<SwTxtNode*>(pTxtNode)->MakeStartIndex(
|
|
|
|
&rPos.nContent );
|
2000-09-18 23:08:29 +00:00
|
|
|
// oder doch besser das Ende vom (Anker-)TextNode nehmen ??
|
|
|
|
// ((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent );
|
2010-01-05 16:37:41 +01:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// noch nicht abbrechen, kann ja auch noch im
|
|
|
|
// Header/Footer/Footnote/Fly stehen !!
|
2004-06-28 12:33:47 +00:00
|
|
|
pLayout = ((SwFlyFrm*)pLayout)->GetAnchorFrm()
|
|
|
|
? ((SwFlyFrm*)pLayout)->GetAnchorFrm()->GetUpper() : 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pLayout->FindPageFrm()->GetCntntPosition(
|
|
|
|
pLayout->Frm().Pos(), rPos );
|
|
|
|
pTxtNode = rPos.nNode.GetNode().GetTxtNode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( pLayout->IsFtnFrm() )
|
|
|
|
{
|
|
|
|
// hole den Node vom Anker
|
|
|
|
const SwTxtFtn* pFtn = ((SwFtnFrm*)pLayout)->GetAttr();
|
|
|
|
pTxtNode = &pFtn->GetTxtNode();
|
|
|
|
rPos.nNode = *pTxtNode;
|
|
|
|
rPos.nContent = *pFtn->GetStart();
|
|
|
|
}
|
|
|
|
else if( pLayout->IsHeaderFrm() || pLayout->IsFooterFrm() )
|
|
|
|
{
|
|
|
|
const SwCntntFrm* pCntFrm;
|
|
|
|
const SwPageFrm* pPgFrm = pLayout->FindPageFrm();
|
|
|
|
if( pLayout->IsHeaderFrm() )
|
2001-10-17 08:48:07 +00:00
|
|
|
{
|
|
|
|
const SwTabFrm *pTab;
|
|
|
|
if( 0 != ( pCntFrm = pPgFrm->FindFirstBodyCntnt()) &&
|
|
|
|
0 != (pTab = pCntFrm->FindTabFrm()) && pTab->IsFollow() &&
|
2004-05-03 12:45:37 +00:00
|
|
|
pTab->GetTable()->GetRowsToRepeat() > 0 &&
|
|
|
|
pTab->IsInHeadline( *pCntFrm ) )
|
2001-10-17 08:48:07 +00:00
|
|
|
{
|
|
|
|
// take the next line
|
2004-05-03 12:45:37 +00:00
|
|
|
const SwLayoutFrm* pRow = pTab->GetFirstNonHeadlineRow();
|
2001-10-17 08:48:07 +00:00
|
|
|
pCntFrm = pRow->ContainsCntnt();
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
pCntFrm = pPgFrm->FindLastBodyCntnt();
|
|
|
|
|
|
|
|
if( pCntFrm )
|
|
|
|
{
|
|
|
|
pTxtNode = pCntFrm->GetNode()->GetTxtNode();
|
|
|
|
rPos.nNode = *pTxtNode;
|
|
|
|
((SwTxtNode*)pTxtNode)->MakeEndIndex( &rPos.nContent );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Point aPt( pLayout->Frm().Pos() );
|
|
|
|
aPt.Y()++; // aus dem Header raus
|
2011-01-17 15:06:54 +01:00
|
|
|
pCntFrm = pPgFrm->GetCntntPos( aPt, sal_False, sal_True, sal_False );
|
2000-09-18 23:08:29 +00:00
|
|
|
pTxtNode = GetFirstTxtNode( rDoc, rPos, pCntFrm, aPt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pLayout = pLayout->GetUpper();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break; // gefunden und beende die Schleife
|
|
|
|
}
|
|
|
|
return pTxtNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: SwSetExpFieldType by JP
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2007-09-27 07:48:51 +00:00
|
|
|
SwGetExpFieldType::SwGetExpFieldType(SwDoc* pDc)
|
|
|
|
: SwValueFieldType( pDc, RES_GETEXPFLD )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwGetExpFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwGetExpFieldType(GetDoc());
|
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwGetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* pNew )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( pNew && RES_DOCPOS_UPDATE == pNew->Which() )
|
2010-12-17 09:02:23 +01:00
|
|
|
NotifyClients( 0, pNew );
|
2000-09-18 23:08:29 +00:00
|
|
|
// sonst nichts weiter expandieren
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: SwGetExpField by JP
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
SwGetExpField::SwGetExpField(SwGetExpFieldType* pTyp, const String& rFormel,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nSub, sal_uLong nFmt)
|
2000-09-18 23:08:29 +00:00
|
|
|
: SwFormulaField( pTyp, nFmt, 0.0 ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bIsInBodyTxt( sal_True ),
|
2008-07-07 06:24:48 +00:00
|
|
|
nSubType(nSub),
|
|
|
|
bLateInitialization( false )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SetFormula( rFormel );
|
|
|
|
}
|
|
|
|
|
|
|
|
String SwGetExpField::Expand() const
|
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
if(nSubType & nsSwExtendedSubType::SUB_CMD)
|
2000-09-18 23:08:29 +00:00
|
|
|
return GetFormula();
|
|
|
|
else
|
|
|
|
return sExpand;
|
|
|
|
}
|
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
String SwGetExpField::GetFieldName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 17:14:34 +02:00
|
|
|
String aStr( SwFieldType::GetTypeStr(
|
2011-01-17 15:06:54 +01:00
|
|
|
static_cast<sal_uInt16>(((nsSwGetSetExpType::GSE_FORMULA & nSubType) != 0)
|
2010-10-04 17:14:34 +02:00
|
|
|
? TYP_FORMELFLD
|
|
|
|
: TYP_GETFLD ) ));
|
|
|
|
aStr += ' ';
|
|
|
|
aStr += GetFormula();
|
|
|
|
return aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwGetExpField::Copy() const
|
|
|
|
{
|
|
|
|
SwGetExpField *pTmp = new SwGetExpField((SwGetExpFieldType*)GetTyp(),
|
|
|
|
GetFormula(), nSubType, GetFormat());
|
|
|
|
pTmp->SetLanguage(GetLanguage());
|
|
|
|
pTmp->SwValueField::SetValue(GetValue());
|
|
|
|
pTmp->sExpand = sExpand;
|
|
|
|
pTmp->bIsInBodyTxt = bIsInBodyTxt;
|
2002-11-15 10:17:38 +00:00
|
|
|
pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
|
2008-07-07 06:24:48 +00:00
|
|
|
if( bLateInitialization )
|
|
|
|
pTmp->SetLateInitialization();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwGetExpField::ChangeExpansion( const SwFrm& rFrm, const SwTxtFld& rFld )
|
|
|
|
{
|
|
|
|
if( bIsInBodyTxt ) // nur Felder in Footer, Header, FootNote, Flys
|
|
|
|
return;
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( !rFrm.IsInDocBody(), "Flag ist nicht richtig, Frame steht im DocBody" );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// bestimme mal das Dokument (oder geht es noch einfacher?)
|
|
|
|
const SwTxtNode* pTxtNode = &rFld.GetTxtNode();
|
|
|
|
SwDoc& rDoc = *(SwDoc*)pTxtNode->GetDoc();
|
|
|
|
|
|
|
|
// einen Index fuers bestimmen vom TextNode anlegen
|
|
|
|
SwPosition aPos( SwNodeIndex( rDoc.GetNodes() ) );
|
|
|
|
pTxtNode = GetBodyTxtNode( rDoc, aPos, rFrm );
|
|
|
|
|
|
|
|
// Wenn kein Layout vorhanden, kommt es in Kopf und Fusszeilen dazu
|
|
|
|
// das ChnageExpansion uebers Layout-Formatieren aufgerufen wird
|
|
|
|
// aber kein TxtNode vorhanden ist
|
|
|
|
//
|
|
|
|
if(!pTxtNode)
|
|
|
|
return;
|
2008-07-07 06:24:48 +00:00
|
|
|
// #i82544#
|
|
|
|
if( bLateInitialization )
|
|
|
|
{
|
|
|
|
SwFieldType* pSetExpFld = rDoc.GetFldType(RES_SETEXPFLD, GetFormula(), sal_False);
|
|
|
|
if( pSetExpFld )
|
|
|
|
{
|
|
|
|
bLateInitialization = false;
|
|
|
|
if( !(GetSubType() & nsSwGetSetExpType::GSE_STRING) &&
|
|
|
|
static_cast< SwSetExpFieldType* >(pSetExpFld)->GetType() == nsSwGetSetExpType::GSE_STRING )
|
|
|
|
SetSubType( nsSwGetSetExpType::GSE_STRING );
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
_SetGetExpFld aEndFld( aPos.nNode, &rFld, &aPos.nContent );
|
2007-09-27 07:48:51 +00:00
|
|
|
if(GetSubType() & nsSwGetSetExpType::GSE_STRING)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwHash** ppHashTbl;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nSize;
|
2000-09-18 23:08:29 +00:00
|
|
|
rDoc.FldsToExpand( ppHashTbl, nSize, aEndFld );
|
|
|
|
LookString( ppHashTbl, nSize, GetFormula(), sExpand );
|
|
|
|
::DeleteHashTable( ppHashTbl, nSize ); // HashTabelle loeschen
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fuelle den Calculator mit den Werten
|
|
|
|
SwCalc aCalc( rDoc );
|
2006-08-14 15:13:16 +00:00
|
|
|
rDoc.FldsToCalc(aCalc, aEndFld);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// Wert berechnen
|
|
|
|
SetValue(aCalc.Calculate(GetFormula()).GetDouble());
|
|
|
|
|
|
|
|
// Auswertung nach Format
|
|
|
|
sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue(
|
|
|
|
GetValue(), GetFormat(), GetLanguage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
rtl::OUString SwGetExpField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return GetFormula();
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
void SwGetExpField::SetPar2(const rtl::OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SetFormula(rStr);
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwGetExpField::GetSubType() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwGetExpField::SetSubType(sal_uInt16 nType)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
nSubType = nType;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwGetExpField::SetLanguage(sal_uInt16 nLng)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
if (nSubType & nsSwExtendedSubType::SUB_CMD)
|
2000-09-18 23:08:29 +00:00
|
|
|
SwField::SetLanguage(nLng);
|
|
|
|
else
|
|
|
|
SwValueField::SetLanguage(nLng);
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwGetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_DOUBLE:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= GetValue();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int32)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)nSubType;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= OUString( GetFormula() );
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
{
|
|
|
|
sal_Int16 nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
|
|
|
|
rAny <<= nRet;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD);
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bTmp, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= rtl::OUString(GetExpStr());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:51 +00:00
|
|
|
return SwField::QueryValue(rAny, nWhichId);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwGetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-11-12 15:23:43 +00:00
|
|
|
sal_Int32 nTmp = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
String sTmp;
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_DOUBLE:
|
2000-11-13 07:38:04 +00:00
|
|
|
SwValueField::SetValue(*(double*) rAny.getValue());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>= nTmp;
|
|
|
|
SetFormat(nTmp);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny >>= nTmp;
|
2011-01-17 15:06:54 +01:00
|
|
|
nSubType = static_cast<sal_uInt16>(nTmp);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
SetFormula( ::GetString( rAny, sTmp ));
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
nTmp = lcl_APIToSubType(rAny);
|
|
|
|
if( nTmp >=0 )
|
2011-01-17 15:06:54 +01:00
|
|
|
SetSubType( static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp));
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
if(*(sal_Bool*) rAny.getValue())
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType |= nsSwExtendedSubType::SUB_CMD;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType &= (~nsSwExtendedSubType::SUB_CMD);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
|
|
|
ChgExpStr(::GetString( rAny, sTmp ));
|
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:51 +00:00
|
|
|
return SwField::PutValue(rAny, nWhichId);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const String& rName, sal_uInt16 nTyp )
|
2007-09-27 07:48:51 +00:00
|
|
|
: SwValueFieldType( pDc, RES_SETEXPFLD ),
|
2000-09-18 23:08:29 +00:00
|
|
|
sName( rName ),
|
2007-09-27 07:48:51 +00:00
|
|
|
pOutlChgNd( 0 ),
|
2012-07-02 16:02:38 +01:00
|
|
|
sDelim( rtl::OUString(".") ),
|
2007-09-27 07:48:51 +00:00
|
|
|
nType(nTyp), nLevel( UCHAR_MAX ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bDeleted( sal_False )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
if( ( nsSwGetSetExpType::GSE_SEQ | nsSwGetSetExpType::GSE_STRING ) & nType )
|
2011-01-17 15:06:54 +01:00
|
|
|
EnableFormat(sal_False); // Numberformatter nicht einsetzen
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwSetExpFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwSetExpFieldType* pNew = new SwSetExpFieldType(GetDoc(), sName, nType);
|
|
|
|
pNew->bDeleted = bDeleted;
|
2004-09-20 11:35:32 +00:00
|
|
|
pNew->sDelim = sDelim;
|
2000-09-18 23:08:29 +00:00
|
|
|
pNew->nLevel = nLevel;
|
|
|
|
|
|
|
|
return pNew;
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
const rtl::OUString& SwSetExpFieldType::GetName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return sName;
|
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwSetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return; // nicht weiter expandieren
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwSetExpFieldType::SetSeqFormat(sal_uLong nFmt)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFmtFld,SwFieldType> aIter(*this);
|
|
|
|
for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() )
|
2000-09-18 23:08:29 +00:00
|
|
|
pFld->GetFld()->ChangeFormat( nFmt );
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwSetExpFieldType::GetSeqFormat()
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( !GetDepends() )
|
|
|
|
return SVX_NUM_ARABIC;
|
|
|
|
|
|
|
|
SwField *pFld = ((SwFmtFld*)GetDepends())->GetFld();
|
|
|
|
return pFld->GetFormat();
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwSetExpFieldType::SetSeqRefNo( SwSetExpField& rFld )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
if( !GetDepends() || !(nsSwGetSetExpType::GSE_SEQ & nType) )
|
2000-09-18 23:08:29 +00:00
|
|
|
return USHRT_MAX;
|
|
|
|
|
2011-10-29 13:24:48 +02:00
|
|
|
extern void InsertSort( std::vector<sal_uInt16>& rArr, sal_uInt16 nIdx, sal_uInt16* pInsPos = 0 );
|
|
|
|
std::vector<sal_uInt16> aArr;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 n;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
// dann testmal, ob die Nummer schon vergeben ist oder ob eine neue
|
|
|
|
// bestimmt werden muss.
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFmtFld,SwFieldType> aIter( *this );
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwTxtNode* pNd;
|
2010-12-17 09:02:23 +01:00
|
|
|
for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pF->GetFld() != &rFld && pF->GetTxtFld() &&
|
|
|
|
0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
|
|
|
|
pNd->GetNodes().IsDocNodes() )
|
|
|
|
InsertSort( aArr, ((SwSetExpField*)pF->GetFld())->GetSeqNumber() );
|
|
|
|
|
|
|
|
|
|
|
|
// teste erstmal ob die Nummer schon vorhanden ist:
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nNum = rFld.GetSeqNumber();
|
2000-09-18 23:08:29 +00:00
|
|
|
if( USHRT_MAX != nNum )
|
|
|
|
{
|
2011-10-29 13:24:48 +02:00
|
|
|
for( n = 0; n < aArr.size(); ++n )
|
2000-09-18 23:08:29 +00:00
|
|
|
if( aArr[ n ] > nNum )
|
|
|
|
return nNum; // nicht vorhanden -> also benutzen
|
|
|
|
else if( aArr[ n ] == nNum )
|
|
|
|
break; // schon vorhanden -> neue erzeugen
|
|
|
|
|
2011-10-29 13:24:48 +02:00
|
|
|
if( n == aArr.size() )
|
2000-09-18 23:08:29 +00:00
|
|
|
return nNum; // nicht vorhanden -> also benutzen
|
|
|
|
}
|
|
|
|
|
|
|
|
// alle Nummern entsprechend geflag, also bestimme die richtige Nummer
|
2011-10-29 13:24:48 +02:00
|
|
|
for( n = 0; n < aArr.size(); ++n )
|
2000-09-18 23:08:29 +00:00
|
|
|
if( n != aArr[ n ] )
|
|
|
|
break;
|
|
|
|
|
|
|
|
rFld.SetSeqNumber( n );
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwSetExpFieldType::GetSeqFldList( SwSeqFldList& rList )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( rList.Count() )
|
|
|
|
rList.Remove( 0, rList.Count() );
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwFmtFld,SwFieldType> aIter( *this );
|
2000-09-18 23:08:29 +00:00
|
|
|
const SwTxtNode* pNd;
|
2010-12-17 09:02:23 +01:00
|
|
|
for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pF->GetTxtFld() &&
|
|
|
|
0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
|
|
|
|
pNd->GetNodes().IsDocNodes() )
|
|
|
|
{
|
2008-02-26 09:39:56 +00:00
|
|
|
_SeqFldLstElem* pNew = new _SeqFldLstElem(
|
2012-06-06 23:15:19 +02:00
|
|
|
pNd->GetExpandTxt( 0, USHRT_MAX ),
|
2008-02-26 09:39:56 +00:00
|
|
|
((SwSetExpField*)pF->GetFld())->GetSeqNumber() );
|
2000-09-18 23:08:29 +00:00
|
|
|
rList.InsertSort( pNew );
|
|
|
|
}
|
|
|
|
|
|
|
|
return rList.Count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwSetExpFieldType::SetChapter( SwSetExpField& rFld, const SwNode& rNd )
|
|
|
|
{
|
|
|
|
const SwTxtNode* pTxtNd = rNd.FindOutlineNodeOfLevel( nLevel );
|
2005-11-08 16:20:11 +00:00
|
|
|
if( pTxtNd )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2005-11-08 16:20:11 +00:00
|
|
|
SwNumRule * pRule = pTxtNd->GetNumRule();
|
|
|
|
|
|
|
|
if (pRule)
|
|
|
|
{
|
|
|
|
// --> OD 2005-11-02 #i51089 - TUNING#
|
|
|
|
if ( pTxtNd->GetNum() )
|
|
|
|
{
|
|
|
|
const SwNodeNum & aNum = *(pTxtNd->GetNum());
|
|
|
|
|
|
|
|
// nur die Nummer besorgen, ohne Pre-/Post-fixstrings
|
2011-01-17 15:06:54 +01:00
|
|
|
String sNumber( pRule->MakeNumString(aNum, sal_False ));
|
2005-11-08 16:20:11 +00:00
|
|
|
|
|
|
|
if( sNumber.Len() )
|
|
|
|
rFld.ChgExpStr( ( sNumber += sDelim ) += rFld.GetExpStr() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "<SwSetExpFieldType::SetChapter(..)> - text node with numbering rule, but without number. This is a serious defect -> inform OD" );
|
2005-11-08 16:20:11 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwSetExpFieldType::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
{
|
|
|
|
sal_Int16 nRet = lcl_SubTypeToAPI(GetType());
|
|
|
|
rAny <<= nRet;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
rAny <<= OUString(GetDelimiter());
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_SHORT1:
|
|
|
|
{
|
|
|
|
sal_Int8 nRet = nLevel < MAXLEVEL? nLevel : -1;
|
|
|
|
rAny <<= nRet;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwSetExpFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
{
|
|
|
|
sal_Int32 nSet = lcl_APIToSubType(rAny);
|
|
|
|
if(nSet >=0)
|
2011-01-17 15:06:54 +01:00
|
|
|
SetType(static_cast<sal_uInt16>(nSet));
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
{
|
|
|
|
String sTmp;
|
|
|
|
if( ::GetString( rAny, sTmp ).Len() )
|
2004-09-20 11:35:32 +00:00
|
|
|
SetDelimiter( sTmp );
|
2001-10-24 17:56:14 +00:00
|
|
|
else
|
2012-07-02 16:02:38 +01:00
|
|
|
SetDelimiter(rtl::OUString(" "));
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_SHORT1:
|
|
|
|
{
|
2007-11-12 15:23:43 +00:00
|
|
|
sal_Int8 nLvl = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= nLvl;
|
|
|
|
if(nLvl < 0 || nLvl >= MAXLEVEL)
|
|
|
|
SetOutlineLvl(UCHAR_MAX);
|
|
|
|
else
|
|
|
|
SetOutlineLvl(nLvl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwSeqFldList::InsertSort( _SeqFldLstElem* pNew )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
sal_Unicode* p = pNew->sDlgEntry.GetBufferAccess();
|
|
|
|
while( *p )
|
|
|
|
{
|
|
|
|
if( *p < 0x20 )
|
|
|
|
*p = 0x20;
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos;
|
|
|
|
sal_Bool bRet = SeekEntry( *pNew, &nPos );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( !bRet )
|
|
|
|
C40_INSERT( _SeqFldLstElem, pNew, nPos );
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwSeqFldList::SeekEntry( const _SeqFldLstElem& rNew, sal_uInt16* pP )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nO = Count(), nM, nU = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( nO > 0 )
|
|
|
|
{
|
2001-04-27 15:57:17 +00:00
|
|
|
CollatorWrapper & rCaseColl = ::GetAppCaseCollator(),
|
|
|
|
& rColl = ::GetAppCollator();
|
|
|
|
const CharClass& rCC = GetAppCharClass();
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
//#59900# Die Sortierung soll die Nummer korrekt einordnen
|
|
|
|
//also "10" nach "9" und nicht "10" nach "1"
|
|
|
|
const String& rTmp2 = rNew.sDlgEntry;
|
|
|
|
xub_StrLen nFndPos2 = 0;
|
|
|
|
String sNum2( rTmp2.GetToken( 0, ' ', nFndPos2 ));
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bIsNum2IsNumeric = rCC.isAsciiNumeric( sNum2 );
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_Int32 nNum2 = bIsNum2IsNumeric ? sNum2.ToInt32() : 0;
|
|
|
|
|
|
|
|
nO--;
|
|
|
|
while( nU <= nO )
|
|
|
|
{
|
|
|
|
nM = nU + ( nO - nU ) / 2;
|
|
|
|
|
|
|
|
//#59900# Die Sortierung soll die Nummer korrekt einordnen
|
|
|
|
//also "10" nach "9" und nicht "10" nach "1"
|
|
|
|
const String& rTmp1 = (*((_SeqFldLstElem**)pData + nM))->sDlgEntry;
|
|
|
|
xub_StrLen nFndPos1 = 0;
|
|
|
|
String sNum1( rTmp1.GetToken( 0, ' ', nFndPos1 ));
|
2001-04-27 15:57:17 +00:00
|
|
|
sal_Int32 nCmp;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( bIsNum2IsNumeric && rCC.isNumeric( sNum1 ) )
|
|
|
|
{
|
|
|
|
sal_Int32 nNum1 = sNum1.ToInt32();
|
2001-04-27 15:57:17 +00:00
|
|
|
nCmp = nNum2 - nNum1;
|
|
|
|
if( 0 == nCmp )
|
|
|
|
nCmp = rCaseColl.compareString( rTmp2.Copy( nFndPos2 ),
|
|
|
|
rTmp1.Copy( nFndPos1 ));
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
else
|
2001-04-27 15:57:17 +00:00
|
|
|
nCmp = rColl.compareString( rTmp2, rTmp1 );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2001-04-27 15:57:17 +00:00
|
|
|
if( 0 == nCmp )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
if( pP ) *pP = nM;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-04-27 15:57:17 +00:00
|
|
|
else if( 0 < nCmp )
|
2000-09-18 23:08:29 +00:00
|
|
|
nU = nM + 1;
|
|
|
|
else if( nM == 0 )
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
nO = nM - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pP ) *pP = nU;
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: SwSetExpField by JP
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
SwSetExpField::SwSetExpField(SwSetExpFieldType* pTyp, const String& rFormel,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nFmt)
|
2000-09-18 23:08:29 +00:00
|
|
|
: SwFormulaField( pTyp, nFmt, 0.0 ), nSeqNo( USHRT_MAX ),
|
|
|
|
nSubType(0)
|
|
|
|
{
|
|
|
|
SetFormula(rFormel);
|
|
|
|
// SubType ignorieren !!!
|
2011-01-17 15:06:54 +01:00
|
|
|
bInput = sal_False;
|
2000-09-18 23:08:29 +00:00
|
|
|
if( IsSequenceFld() )
|
|
|
|
{
|
|
|
|
SwValueField::SetValue(1.0);
|
|
|
|
if( !rFormel.Len() )
|
|
|
|
{
|
|
|
|
String sFormel(rFormel);
|
|
|
|
sFormel += pTyp->GetName();
|
|
|
|
sFormel += '+';
|
|
|
|
sFormel += '1';
|
|
|
|
SetFormula(sFormel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
String SwSetExpField::Expand() const
|
|
|
|
{
|
|
|
|
String aStr;
|
2007-09-27 07:48:51 +00:00
|
|
|
if (nSubType & nsSwExtendedSubType::SUB_CMD)
|
2000-09-18 23:08:29 +00:00
|
|
|
{ // Der CommandString ist gefragt
|
|
|
|
aStr = GetTyp()->GetName();
|
|
|
|
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ));
|
|
|
|
aStr += GetFormula();
|
|
|
|
}
|
2007-09-27 07:48:51 +00:00
|
|
|
else if(!(nSubType & nsSwExtendedSubType::SUB_INVISIBLE))
|
2000-09-18 23:08:29 +00:00
|
|
|
{ // Der Wert ist sichtbar
|
|
|
|
aStr = sExpand;
|
|
|
|
}
|
|
|
|
return aStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
2010-10-04 17:14:34 +02:00
|
|
|
@return the field name
|
2000-09-18 23:08:29 +00:00
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
String SwSetExpField::GetFieldName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-07 11:26:03 +02:00
|
|
|
SwFldTypesEnum const nStrType( (IsSequenceFld())
|
2010-10-04 17:14:34 +02:00
|
|
|
? TYP_SEQFLD
|
|
|
|
: (bInput)
|
|
|
|
? TYP_SETINPFLD
|
|
|
|
: TYP_SETFLD );
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
String aStr( SwFieldType::GetTypeStr( static_cast<sal_uInt16>(nStrType) ) );
|
2010-10-04 17:14:34 +02:00
|
|
|
aStr += ' ';
|
|
|
|
aStr += GetTyp()->GetName();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
// Sequence: without formula
|
|
|
|
if (TYP_SEQFLD != nStrType)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 17:14:34 +02:00
|
|
|
aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " = " ) );
|
|
|
|
aStr += GetFormula();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 17:14:34 +02:00
|
|
|
return aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwSetExpField::Copy() const
|
|
|
|
{
|
|
|
|
SwSetExpField *pTmp = new SwSetExpField((SwSetExpFieldType*)GetTyp(),
|
|
|
|
GetFormula(), GetFormat());
|
|
|
|
pTmp->SwValueField::SetValue(GetValue());
|
|
|
|
pTmp->sExpand = sExpand;
|
2002-11-15 10:17:38 +00:00
|
|
|
pTmp->SetAutomaticLanguage(IsAutomaticLanguage());
|
2000-09-18 23:08:29 +00:00
|
|
|
pTmp->SetLanguage(GetLanguage());
|
|
|
|
pTmp->aPText = aPText;
|
|
|
|
pTmp->bInput = bInput;
|
|
|
|
pTmp->nSeqNo = nSeqNo;
|
|
|
|
pTmp->SetSubType(GetSubType());
|
|
|
|
|
|
|
|
return pTmp;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwSetExpField::SetSubType(sal_uInt16 nSub)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
((SwSetExpFieldType*)GetTyp())->SetType(nSub & 0xff);
|
|
|
|
nSubType = nSub & 0xff00;
|
|
|
|
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE( (nSub & 0xff) != 3, "SubType ist illegal!" );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwSetExpField::GetSubType() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return ((SwSetExpFieldType*)GetTyp())->GetType() | nSubType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwSetExpField::SetValue( const double& rAny )
|
|
|
|
{
|
|
|
|
SwValueField::SetValue(rAny);
|
|
|
|
|
|
|
|
if( IsSequenceFld() )
|
2012-07-10 13:44:33 +02:00
|
|
|
sExpand = FormatNumber( (sal_uInt32)GetValue(), GetFormat() );
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
|
|
|
sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue( rAny,
|
|
|
|
GetFormat(), GetLanguage());
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwGetExpField::SetValue( const double& rAny )
|
|
|
|
{
|
|
|
|
SwValueField::SetValue(rAny);
|
|
|
|
sExpand = ((SwValueFieldType*)GetTyp())->ExpandValue( rAny, GetFormat(),
|
|
|
|
GetLanguage());
|
|
|
|
}
|
2011-01-17 21:50:08 +01:00
|
|
|
/* --------------------------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
Description: Find the index of the reference text
|
|
|
|
following the current field
|
2012-07-17 19:00:21 +02:00
|
|
|
nHint: search starting position after the current
|
|
|
|
field (or 0 if default)
|
2000-09-18 23:08:29 +00:00
|
|
|
--------------------------------------------------*/
|
2012-07-17 19:00:21 +02:00
|
|
|
xub_StrLen SwGetExpField::GetReferenceTextPos( const SwFmtFld& rFmt, SwDoc& rDoc, unsigned nHint)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
const SwTxtFld* pTxtFld = rFmt.GetTxtFld();
|
|
|
|
const SwTxtNode& rTxtNode = pTxtFld->GetTxtNode();
|
|
|
|
//
|
2012-07-17 19:00:21 +02:00
|
|
|
xub_StrLen nRet = nHint ? nHint : *pTxtFld->GetStart() + 1;
|
2000-09-18 23:08:29 +00:00
|
|
|
String sNodeText = rTxtNode.GetTxt();
|
|
|
|
sNodeText.Erase(0, nRet);
|
|
|
|
if(sNodeText.Len())
|
|
|
|
{
|
2012-07-17 19:00:21 +02:00
|
|
|
// now check if sNodeText starts with a non-alphanumeric character plus blanks
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nSrcpt = pBreakIt->GetRealScriptOfText( sNodeText, 0 );
|
2001-10-17 08:48:07 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
static sal_uInt16 nIds[] =
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
RES_CHRATR_LANGUAGE, RES_CHRATR_LANGUAGE,
|
|
|
|
RES_CHRATR_FONT, RES_CHRATR_FONT,
|
2001-10-17 08:48:07 +00:00
|
|
|
RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CJK_LANGUAGE,
|
|
|
|
RES_CHRATR_CJK_FONT, RES_CHRATR_CJK_FONT,
|
|
|
|
RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE,
|
|
|
|
RES_CHRATR_CTL_FONT, RES_CHRATR_CTL_FONT,
|
2000-09-18 23:08:29 +00:00
|
|
|
0, 0
|
|
|
|
};
|
|
|
|
SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
|
|
|
|
rTxtNode.GetAttr(aSet, nRet, nRet+1);
|
|
|
|
|
2001-10-17 08:48:07 +00:00
|
|
|
if( RTL_TEXTENCODING_SYMBOL != ((SvxFontItem&)aSet.Get(
|
|
|
|
GetWhichOfScript( RES_CHRATR_FONT, nSrcpt )) ).GetCharSet() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-17 08:48:07 +00:00
|
|
|
LanguageType eLang = ((SvxLanguageItem&)aSet.Get(
|
|
|
|
GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt )) ).GetLanguage();
|
2000-10-24 11:01:31 +00:00
|
|
|
CharClass aCC( SvxCreateLocale( eLang ));
|
2000-09-18 23:08:29 +00:00
|
|
|
sal_Unicode c0 = sNodeText.GetChar(0);
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bIsAlphaNum = aCC.isAlphaNumeric( sNodeText, 0 );
|
2000-10-24 11:01:31 +00:00
|
|
|
if( !bIsAlphaNum ||
|
2000-09-18 23:08:29 +00:00
|
|
|
(c0 == ' ' || c0 == '\t'))
|
|
|
|
{
|
2012-07-17 19:00:21 +02:00
|
|
|
// ignoring blanks
|
2000-09-18 23:08:29 +00:00
|
|
|
nRet++;
|
2012-07-17 19:00:21 +02:00
|
|
|
unsigned i = 1;
|
|
|
|
while (i < sNodeText.Len() &&
|
|
|
|
(sNodeText.GetChar(i) == ' ' ||
|
|
|
|
sNodeText.GetChar(i) == '\t')
|
|
|
|
)
|
|
|
|
nRet++, i++;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Parameter setzen
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
const rtl::OUString& SwSetExpField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-03-07 16:52:06 +00:00
|
|
|
return ((const SwSetExpFieldType*)GetTyp())->GetName();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
rtl::OUString SwSetExpField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nType = ((SwSetExpFieldType*)GetTyp())->GetType();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 07:48:51 +00:00
|
|
|
if (nType & nsSwGetSetExpType::GSE_STRING)
|
2000-09-18 23:08:29 +00:00
|
|
|
return GetFormula();
|
|
|
|
return GetExpandedFormula();
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
void SwSetExpField::SetPar2(const rtl::OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nType = ((SwSetExpFieldType*)GetTyp())->GetType();
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
if( !(nType & nsSwGetSetExpType::GSE_SEQ) || !rStr.isEmpty() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
if (nType & nsSwGetSetExpType::GSE_STRING)
|
2000-09-18 23:08:29 +00:00
|
|
|
SetFormula(rStr);
|
|
|
|
else
|
|
|
|
SetExpandedFormula(rStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Eingabefeld Type
|
|
|
|
---------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
SwInputFieldType::SwInputFieldType( SwDoc* pD )
|
|
|
|
: SwFieldType( RES_INPUTFLD ), pDoc( pD )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwFieldType* SwInputFieldType::Copy() const
|
|
|
|
{
|
|
|
|
SwInputFieldType* pType = new SwInputFieldType( pDoc );
|
|
|
|
return pType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Eingabefeld
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2007-09-27 07:48:51 +00:00
|
|
|
SwInputField::SwInputField(SwInputFieldType* pTyp, const String& rContent,
|
2011-01-17 15:06:54 +01:00
|
|
|
const String& rPrompt, sal_uInt16 nSub, sal_uLong nFmt) :
|
2007-09-27 07:48:51 +00:00
|
|
|
SwField(pTyp, nFmt), aContent(rContent), aPText(rPrompt), nSubType(nSub)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-10-04 17:14:34 +02:00
|
|
|
String SwInputField::GetFieldName() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 17:14:34 +02:00
|
|
|
String aStr(SwField::GetFieldName());
|
|
|
|
if ((nSubType & 0x00ff) == INP_USR)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-10-04 17:14:34 +02:00
|
|
|
aStr += GetTyp()->GetName();
|
|
|
|
aStr += ' ';
|
|
|
|
aStr += aContent;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 17:14:34 +02:00
|
|
|
return aStr;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwField* SwInputField::Copy() const
|
|
|
|
{
|
|
|
|
SwInputField* pFld = new SwInputField((SwInputFieldType*)GetTyp(), aContent,
|
|
|
|
aPText, GetSubType(), GetFormat());
|
2007-03-09 12:14:56 +00:00
|
|
|
|
|
|
|
pFld->SetHelp(aHelp);
|
|
|
|
pFld->SetToolTip(aToolTip);
|
|
|
|
|
2002-11-15 10:17:38 +00:00
|
|
|
pFld->SetAutomaticLanguage(IsAutomaticLanguage());
|
2000-09-18 23:08:29 +00:00
|
|
|
return pFld;
|
|
|
|
}
|
|
|
|
|
|
|
|
String SwInputField::Expand() const
|
|
|
|
{
|
|
|
|
String sRet;
|
|
|
|
if((nSubType & 0x00ff) == INP_TXT)
|
|
|
|
sRet = aContent;
|
|
|
|
|
|
|
|
else if( (nSubType & 0x00ff) == INP_USR )
|
|
|
|
{
|
|
|
|
SwUserFieldType* pUserTyp = (SwUserFieldType*)
|
|
|
|
((SwInputFieldType*)GetTyp())->GetDoc()->
|
2006-08-14 15:13:16 +00:00
|
|
|
GetFldType( RES_USERFLD, aContent, false );
|
2000-09-18 23:08:29 +00:00
|
|
|
if( pUserTyp )
|
|
|
|
sRet = pUserTyp->GetContent();
|
|
|
|
}
|
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwInputField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2001-10-24 17:56:14 +00:00
|
|
|
{
|
|
|
|
case FIELD_PROP_PAR1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= OUString( aContent );
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
rAny <<= OUString( aPText );
|
|
|
|
break;
|
2007-03-09 12:14:56 +00:00
|
|
|
case FIELD_PROP_PAR3:
|
|
|
|
rAny <<= OUString( aHelp );
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
|
|
|
rAny <<= OUString( aToolTip );
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwInputField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
2012-03-07 16:52:06 +00:00
|
|
|
rAny >>= aContent;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
::GetString( rAny, aPText );
|
|
|
|
break;
|
2007-03-09 12:14:56 +00:00
|
|
|
case FIELD_PROP_PAR3:
|
|
|
|
::GetString( rAny, aHelp );
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
|
|
|
::GetString( rAny, aToolTip );
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
default:
|
2011-03-01 19:09:12 +01:00
|
|
|
OSL_FAIL("illegal property");
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: Bedingung setzen
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
void SwInputField::SetPar1(const rtl::OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aContent = rStr;
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
const rtl::OUString& SwInputField::GetPar1() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return aContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
Beschreibung: True/False Text
|
|
|
|
--------------------------------------------------------------------*/
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
void SwInputField::SetPar2(const rtl::OUString& rStr)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
aPText = rStr;
|
|
|
|
}
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
rtl::OUString SwInputField::GetPar2() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return aPText;
|
|
|
|
}
|
|
|
|
|
2007-03-09 12:14:56 +00:00
|
|
|
void SwInputField::SetHelp(const String & rStr)
|
|
|
|
{
|
|
|
|
aHelp = rStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
String SwInputField::GetHelp() const
|
|
|
|
{
|
|
|
|
return aHelp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwInputField::SetToolTip(const String & rStr)
|
|
|
|
{
|
|
|
|
aToolTip = rStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
String SwInputField::GetToolTip() const
|
|
|
|
{
|
|
|
|
return aToolTip;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwInputField::isFormField() const
|
2007-03-09 12:14:56 +00:00
|
|
|
{
|
|
|
|
return aHelp.Len() > 0 || aToolTip.Len() > 0;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwInputField::GetSubType() const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
return nSubType;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwInputField::SetSubType(sal_uInt16 nSub)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
nSubType = nSub;
|
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwSetExpField::QueryValue( uno::Any& rAny, sal_uInt16 nWhichId ) const
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
{
|
2007-09-27 07:48:51 +00:00
|
|
|
sal_Bool bVal = 0 == (nSubType & nsSwExtendedSubType::SUB_INVISIBLE);
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bVal, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int32)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT2:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)GetFormat();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= (sal_Int16)nSeqNo;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
2007-09-27 07:48:51 +00:00
|
|
|
rAny <<= OUString ( SwStyleNameMapper::GetProgName(GetPar1(), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) );
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
{
|
|
|
|
//I18N - if the formula contains only "TypeName+1"
|
|
|
|
//and it's one of the initially created sequence fields
|
|
|
|
//then the localized names has to be replaced by a programmatic name
|
2011-01-17 15:06:54 +01:00
|
|
|
OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, GetFormula(), sal_True);
|
2007-09-27 07:48:51 +00:00
|
|
|
rAny <<= OUString( sMyFormula );
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_DOUBLE:
|
2001-03-23 11:08:40 +00:00
|
|
|
rAny <<= (double)GetValue();
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
{
|
|
|
|
sal_Int16 nRet = 0;
|
|
|
|
nRet = lcl_SubTypeToAPI(GetSubType() & 0xff);
|
|
|
|
rAny <<= nRet;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= OUString( aPText );
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL3:
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bTmp = 0 != (nSubType & nsSwExtendedSubType::SUB_CMD);
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bTmp, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bTmp = GetInputFlag();
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny.setValue(&bTmp, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
2000-09-18 23:08:29 +00:00
|
|
|
rAny <<= rtl::OUString(GetExpStr());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:51 +00:00
|
|
|
return SwField::QueryValue(rAny, nWhichId);
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
bool SwSetExpField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-11-12 15:23:43 +00:00
|
|
|
sal_Int32 nTmp32 = 0;
|
|
|
|
sal_Int16 nTmp16 = 0;
|
2001-10-24 17:56:14 +00:00
|
|
|
String sTmp;
|
2007-09-27 07:48:51 +00:00
|
|
|
switch( nWhichId )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
if(*(sal_Bool*)rAny.getValue())
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType &= ~nsSwExtendedSubType::SUB_INVISIBLE;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType |= nsSwExtendedSubType::SUB_INVISIBLE;
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_FORMAT:
|
|
|
|
rAny >>= nTmp32;
|
|
|
|
SetFormat(nTmp32);
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT2:
|
|
|
|
{
|
|
|
|
rAny >>= nTmp16;
|
|
|
|
if(nTmp16 <= SVX_NUMBER_NONE )
|
|
|
|
SetFormat(nTmp16);
|
2008-04-22 13:58:24 +00:00
|
|
|
else {
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_USHORT1:
|
|
|
|
rAny >>= nTmp16;
|
|
|
|
nSeqNo = nTmp16;
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
SetPar1( SwStyleNameMapper::GetUIName(
|
2007-09-27 07:48:51 +00:00
|
|
|
::GetString( rAny, sTmp ), nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ) );
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR2:
|
|
|
|
{
|
|
|
|
OUString uTmp;
|
|
|
|
rAny >>= uTmp;
|
|
|
|
//I18N - if the formula contains only "TypeName+1"
|
|
|
|
//and it's one of the initially created sequence fields
|
|
|
|
//then the localized names has to be replaced by a programmatic name
|
2011-01-17 15:06:54 +01:00
|
|
|
OUString sMyFormula = SwXFieldMaster::LocalizeFormula(*this, uTmp, sal_False);
|
2007-09-27 07:48:51 +00:00
|
|
|
SetFormula( sMyFormula );
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_DOUBLE:
|
|
|
|
{
|
2010-01-23 12:35:22 +00:00
|
|
|
double fVal = 0.0;
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny >>= fVal;
|
|
|
|
SetValue(fVal);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_SUBTYPE:
|
|
|
|
nTmp32 = lcl_APIToSubType(rAny);
|
|
|
|
if(nTmp32 >= 0)
|
2011-01-17 15:06:54 +01:00
|
|
|
SetSubType(static_cast<sal_uInt16>((GetSubType() & 0xff00) | nTmp32));
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
|
|
|
::GetString( rAny, aPText );
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL3:
|
|
|
|
if(*(sal_Bool*) rAny.getValue())
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType |= nsSwExtendedSubType::SUB_CMD;
|
2000-09-18 23:08:29 +00:00
|
|
|
else
|
2007-09-27 07:48:51 +00:00
|
|
|
nSubType &= (~nsSwExtendedSubType::SUB_CMD);
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
SetInputFlag(*(sal_Bool*) rAny.getValue());
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR4:
|
|
|
|
ChgExpStr( ::GetString( rAny, sTmp ));
|
|
|
|
break;
|
|
|
|
default:
|
2007-09-27 07:48:51 +00:00
|
|
|
return SwField::PutValue(rAny, nWhichId);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2010-10-04 15:23:52 +01:00
|
|
|
return true;
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|