2000-09-18 23:08:29 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* $RCSfile: authfld.cxx,v $
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2007-09-27 07:47:39 +00:00
|
|
|
* $Revision: 1.30 $
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2007-09-27 07:47:39 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2007-09-27 08:47:39 $
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* This library 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 for more details.
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
2005-09-09 02:31:50 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 23:08:29 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 20:09:39 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#define _SVSTDARR_STRINGSDTOR
|
|
|
|
#define _SVSTDARR_USHORTS
|
|
|
|
#define _SVSTDARR_LONGS
|
2001-10-24 17:56:14 +00:00
|
|
|
#define _SVSTDARR_ULONGS
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#ifndef _HINTIDS_HXX
|
|
|
|
#include <hintids.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <svtools/svstdarr.hxx>
|
2001-10-24 17:56:14 +00:00
|
|
|
#ifndef _UNO_LINGU_HXX
|
|
|
|
#include <svx/unolingu.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_LANGITEM_HXX
|
|
|
|
#include <svx/langitem.hxx>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
#ifndef _SWTYPES_HXX
|
|
|
|
#include <swtypes.hxx>
|
|
|
|
#endif
|
2004-09-08 13:55:05 +00:00
|
|
|
#ifndef _TOOLS_RESID_HXX
|
|
|
|
#include <tools/resid.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _COMCORE_HRC
|
|
|
|
#include <comcore.hrc>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
#ifndef _AUTHFLD_HXX
|
|
|
|
#include <authfld.hxx>
|
|
|
|
#endif
|
2003-03-27 14:45:43 +00:00
|
|
|
#ifndef _EXPFLD_HXX
|
|
|
|
#include <expfld.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _PAM_HXX
|
|
|
|
#include <pam.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _CNTFRM_HXX
|
|
|
|
#include <cntfrm.hxx>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
#ifndef _TOX_HXX
|
|
|
|
#include <tox.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TXMSRT_HXX
|
|
|
|
#include <txmsrt.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _DOCTXM_HXX
|
|
|
|
#include <doctxm.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _FMTFLD_HXX
|
|
|
|
#include <fmtfld.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _TXTFLD_HXX
|
|
|
|
#include <txtfld.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _NDTXT_HXX
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#endif
|
2001-10-24 17:56:14 +00:00
|
|
|
#ifndef _DOC_HXX
|
2000-09-18 23:08:29 +00:00
|
|
|
#include <doc.hxx>
|
|
|
|
#endif
|
2001-10-24 17:56:14 +00:00
|
|
|
#ifndef _UNOFLDMID_H
|
|
|
|
#include <unofldmid.h>
|
2000-09-18 23:08:29 +00:00
|
|
|
#endif
|
2000-11-16 11:30:48 +00:00
|
|
|
#ifndef _UNOPRNMS_HXX
|
|
|
|
#include <unoprnms.hxx>
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2007-09-27 07:47:39 +00:00
|
|
|
#include <unomid.h>
|
|
|
|
|
2000-11-16 11:30:48 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
2001-06-06 09:41:26 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
2000-11-16 11:30:48 +00:00
|
|
|
using namespace rtl;
|
2001-10-24 17:56:14 +00:00
|
|
|
|
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
typedef SwAuthEntry* SwAuthEntryPtr;
|
|
|
|
SV_DECL_PTRARR_DEL( SwAuthDataArr, SwAuthEntryPtr, 5, 5 )
|
|
|
|
SV_IMPL_PTRARR( SwAuthDataArr, SwAuthEntryPtr )
|
|
|
|
|
|
|
|
|
|
|
|
typedef SwTOXSortKey* TOXSortKeyPtr;
|
|
|
|
SV_DECL_PTRARR_DEL( SortKeyArr, TOXSortKeyPtr, 5, 5 )
|
|
|
|
SV_IMPL_PTRARR( SortKeyArr, TOXSortKeyPtr )
|
|
|
|
|
|
|
|
|
|
|
|
/* -----------------16.09.99 11:53-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
SwAuthEntry::SwAuthEntry(const SwAuthEntry& rCopy)
|
|
|
|
: nRefCount(0)
|
|
|
|
{
|
|
|
|
for(USHORT i = 0; i < AUTH_FIELD_END; i++)
|
|
|
|
aAuthFields[i] = rCopy.aAuthFields[i];
|
|
|
|
}
|
|
|
|
// --------------------------------------------------------
|
|
|
|
BOOL SwAuthEntry::operator==(const SwAuthEntry& rComp)
|
|
|
|
{
|
|
|
|
for(USHORT i = 0; i < AUTH_FIELD_END; i++)
|
|
|
|
if(aAuthFields[i] != rComp.aAuthFields[i])
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// --------------------------------------------------------
|
|
|
|
|
|
|
|
/* -----------------14.09.99 16:15-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
SwAuthorityFieldType::SwAuthorityFieldType(SwDoc* pDoc)
|
|
|
|
: SwFieldType( RES_AUTHORITY ),
|
|
|
|
m_pDoc(pDoc),
|
|
|
|
m_pDataArr(new SwAuthDataArr ),
|
|
|
|
m_pSequArr(new SvLongs(5, 5)),
|
|
|
|
m_pSortKeyArr(new SortKeyArr(3, 3)),
|
|
|
|
m_cPrefix('['),
|
2001-06-06 09:41:26 +00:00
|
|
|
m_cSuffix(']'),
|
2007-09-27 07:47:39 +00:00
|
|
|
m_bIsSequence(FALSE),
|
|
|
|
m_bSortByDocument(TRUE),
|
2001-06-06 09:41:26 +00:00
|
|
|
m_eLanguage((LanguageType)::GetAppLanguage())
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwAuthorityFieldType::SwAuthorityFieldType( const SwAuthorityFieldType& rFType)
|
|
|
|
: SwFieldType( RES_AUTHORITY ),
|
|
|
|
m_pDataArr(new SwAuthDataArr ),
|
|
|
|
m_pSequArr(new SvLongs(5, 5)),
|
|
|
|
m_pSortKeyArr(new SortKeyArr(3, 3)),
|
|
|
|
m_cPrefix(rFType.m_cPrefix),
|
2001-06-06 09:41:26 +00:00
|
|
|
m_cSuffix(rFType.m_cSuffix),
|
2007-09-27 07:47:39 +00:00
|
|
|
m_bIsSequence(rFType.m_bIsSequence),
|
|
|
|
m_bSortByDocument(rFType.m_bSortByDocument),
|
2001-06-06 09:41:26 +00:00
|
|
|
m_eLanguage(rFType.m_eLanguage),
|
|
|
|
m_sSortAlgorithm(rFType.m_sSortAlgorithm)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
for(USHORT i = 0; i < rFType.m_pSortKeyArr->Count(); i++)
|
|
|
|
m_pSortKeyArr->Insert((*rFType.m_pSortKeyArr)[i], i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------17.09.99 13:52-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
SwAuthorityFieldType::~SwAuthorityFieldType()
|
|
|
|
{
|
2001-04-26 19:46:28 +00:00
|
|
|
// DBG_ASSERT(!m_pDataArr->Count(), "Array is not empty")
|
2000-09-18 23:08:29 +00:00
|
|
|
m_pSortKeyArr->DeleteAndDestroy(0, m_pSortKeyArr->Count());
|
|
|
|
delete m_pSortKeyArr;
|
|
|
|
delete m_pSequArr;
|
|
|
|
delete m_pDataArr;
|
|
|
|
}
|
|
|
|
/*-- 14.09.99 16:22:09---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
SwFieldType* SwAuthorityFieldType::Copy() const
|
|
|
|
{
|
|
|
|
return new SwAuthorityFieldType(m_pDoc);
|
|
|
|
}
|
|
|
|
/* -----------------17.09.99 13:43-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwAuthorityFieldType::RemoveField(long nHandle)
|
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
BOOL bRemoved = FALSE;
|
|
|
|
#endif
|
|
|
|
for(USHORT j = 0; j < m_pDataArr->Count(); j++)
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
long nRet = (long)(void*)pTemp;
|
|
|
|
if(nRet == nHandle)
|
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
bRemoved = TRUE;
|
|
|
|
#endif
|
|
|
|
pTemp->RemoveRef();
|
|
|
|
if(!pTemp->GetRefCount())
|
|
|
|
{
|
|
|
|
m_pDataArr->DeleteAndDestroy(j, 1);
|
2001-02-09 06:52:57 +00:00
|
|
|
//re-generate positions of the fields
|
2001-02-14 09:43:38 +00:00
|
|
|
DelSequenceArray();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef DBG_UTIL
|
|
|
|
DBG_ASSERT(bRemoved, "Field unknown" )
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* -----------------17.09.99 13:43-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
long SwAuthorityFieldType::AddField(const String& rFieldContents)
|
|
|
|
{
|
|
|
|
long nRet = 0;
|
|
|
|
SwAuthEntry* pEntry = new SwAuthEntry;
|
|
|
|
for( USHORT i = 0; i < AUTH_FIELD_END; ++i )
|
|
|
|
pEntry->SetAuthorField( (ToxAuthorityField)i,
|
|
|
|
rFieldContents.GetToken( i, TOX_STYLE_DELIMITER ));
|
|
|
|
|
|
|
|
for(USHORT j = 0; j < m_pDataArr->Count() && pEntry; j++)
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
if(*pTemp == *pEntry)
|
|
|
|
{
|
|
|
|
DELETEZ(pEntry);
|
|
|
|
nRet = (long)(void*)pTemp;
|
|
|
|
pTemp->AddRef();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//if it is a new Entry - insert
|
|
|
|
if(pEntry)
|
|
|
|
{
|
|
|
|
nRet = (long)(void*)pEntry;
|
|
|
|
pEntry->AddRef();
|
|
|
|
m_pDataArr->Insert(pEntry, m_pDataArr->Count());
|
2001-02-09 06:52:57 +00:00
|
|
|
//re-generate positions of the fields
|
2001-02-14 09:43:38 +00:00
|
|
|
DelSequenceArray();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
/* -----------------17.09.99 14:18-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
BOOL SwAuthorityFieldType::AddField(long nHandle)
|
|
|
|
{
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
for( USHORT j = 0; j < m_pDataArr->Count(); j++ )
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
long nTmp = (long)(void*)pTemp;
|
|
|
|
if( nTmp == nHandle )
|
|
|
|
{
|
|
|
|
bRet = TRUE;
|
|
|
|
pTemp->AddRef();
|
2001-02-14 09:43:38 +00:00
|
|
|
//re-generate positions of the fields
|
|
|
|
DelSequenceArray();
|
2000-09-18 23:08:29 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-02-14 09:43:38 +00:00
|
|
|
DBG_ASSERT(bRet, "::AddField(long) failed");
|
2000-09-18 23:08:29 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
/* -----------------17.09.99 14:52-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
const SwAuthEntry* SwAuthorityFieldType::GetEntryByHandle(long nHandle) const
|
|
|
|
{
|
|
|
|
const SwAuthEntry* pRet = 0;
|
|
|
|
for(USHORT j = 0; j < m_pDataArr->Count(); j++)
|
|
|
|
{
|
|
|
|
const SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
long nTmp = (long)(void*)pTemp;
|
|
|
|
if( nTmp == nHandle )
|
|
|
|
{
|
|
|
|
pRet = pTemp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT( pRet, "invalid Handle" );
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
/* -----------------21.09.99 13:34-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwAuthorityFieldType::GetAllEntryIdentifiers(
|
|
|
|
SvStringsDtor& rToFill )const
|
|
|
|
{
|
|
|
|
for(USHORT j = 0; j < m_pDataArr->Count(); j++)
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
rToFill.Insert( new String( pTemp->GetAuthorField(
|
|
|
|
AUTH_FIELD_IDENTIFIER )), rToFill.Count() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -----------------21.09.99 13:34-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
const SwAuthEntry* SwAuthorityFieldType::GetEntryByIdentifier(
|
|
|
|
const String& rIdentifier)const
|
|
|
|
{
|
|
|
|
const SwAuthEntry* pRet = 0;
|
|
|
|
for( USHORT j = 0; j < m_pDataArr->Count(); ++j )
|
|
|
|
{
|
|
|
|
const SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
if( rIdentifier == pTemp->GetAuthorField( AUTH_FIELD_IDENTIFIER ))
|
|
|
|
{
|
|
|
|
pRet = pTemp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
/* -----------------------------21.12.99 13:20--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
void SwAuthorityFieldType::ChangeEntryContent(const SwAuthEntry* pNewEntry)
|
|
|
|
{
|
|
|
|
for( USHORT j = 0; j < m_pDataArr->Count(); ++j )
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(j);
|
|
|
|
if(pTemp->GetAuthorField(AUTH_FIELD_IDENTIFIER) ==
|
|
|
|
pNewEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER))
|
|
|
|
{
|
|
|
|
for(USHORT i = 0; i < AUTH_FIELD_END; i++)
|
|
|
|
pTemp->SetAuthorField((ToxAuthorityField) i,
|
|
|
|
pNewEntry->GetAuthorField((ToxAuthorityField)i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*-- 11.10.99 08:49:22---------------------------------------------------
|
|
|
|
Description: appends a new entry (if new) and returns the array position
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
USHORT SwAuthorityFieldType::AppendField( const SwAuthEntry& rInsert )
|
|
|
|
{
|
|
|
|
USHORT nRet = 0;
|
|
|
|
for( nRet = 0; nRet < m_pDataArr->Count(); ++nRet )
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject( nRet );
|
|
|
|
if( *pTemp == rInsert )
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
//ref count unchanged
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//if it is a new Entry - insert
|
|
|
|
if( nRet == m_pDataArr->Count() )
|
|
|
|
m_pDataArr->Insert( new SwAuthEntry( rInsert ), nRet );
|
|
|
|
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-- 11.10.99 08:49:24---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
long SwAuthorityFieldType::GetHandle(USHORT nPos)
|
|
|
|
{
|
|
|
|
long nRet = 0;
|
|
|
|
if( nPos < m_pDataArr->Count() )
|
|
|
|
{
|
|
|
|
SwAuthEntry* pTemp = m_pDataArr->GetObject(nPos);
|
|
|
|
nRet = (long)(void*)pTemp;
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
/* -----------------19.10.99 13:46-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
USHORT SwAuthorityFieldType::GetSequencePos(long nHandle)
|
|
|
|
{
|
|
|
|
//find the field in a sorted array of handles,
|
2001-02-14 09:43:38 +00:00
|
|
|
#ifdef DBG_UTIL
|
|
|
|
sal_Bool bCurrentFieldWithoutTextNode = sal_False;
|
|
|
|
#endif
|
|
|
|
if(m_pSequArr->Count() && m_pSequArr->Count() != m_pDataArr->Count())
|
|
|
|
DelSequenceArray();
|
2000-09-18 23:08:29 +00:00
|
|
|
if(!m_pSequArr->Count())
|
|
|
|
{
|
|
|
|
SwTOXSortTabBases aSortArr;
|
2000-10-20 10:11:17 +00:00
|
|
|
SwClientIter aIter( *this );
|
|
|
|
|
2002-06-26 08:32:38 +00:00
|
|
|
SwTOXInternational aIntl(m_eLanguage, 0, m_sSortAlgorithm);
|
2000-10-20 10:11:17 +00:00
|
|
|
|
2000-09-18 23:08:29 +00:00
|
|
|
for( SwFmtFld* pFmtFld = (SwFmtFld*)aIter.First( TYPE(SwFmtFld) );
|
2000-10-20 10:11:17 +00:00
|
|
|
pFmtFld; pFmtFld = (SwFmtFld*)aIter.Next() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld();
|
2003-06-25 09:34:07 +00:00
|
|
|
if(!pTxtFld || !pTxtFld->GetpTxtNode())
|
2001-02-14 09:43:38 +00:00
|
|
|
{
|
|
|
|
#ifdef DBG_UTIL
|
2007-09-27 07:47:39 +00:00
|
|
|
if(nHandle == ((SwAuthorityField*)pFmtFld->GetFld())->GetHandle())
|
2001-02-14 09:43:38 +00:00
|
|
|
bCurrentFieldWithoutTextNode = sal_True;
|
|
|
|
#endif
|
2000-09-18 23:08:29 +00:00
|
|
|
continue;
|
2001-02-14 09:43:38 +00:00
|
|
|
}
|
2003-03-27 14:45:43 +00:00
|
|
|
const SwTxtNode& rFldTxtNode = pTxtFld->GetTxtNode();
|
|
|
|
SwPosition aFldPos(rFldTxtNode);
|
|
|
|
SwDoc& rDoc = *(SwDoc*)rFldTxtNode.GetDoc();
|
|
|
|
SwCntntFrm *pFrm = rFldTxtNode.GetFrm();
|
|
|
|
const SwTxtNode* pTxtNode = 0;
|
|
|
|
if(pFrm && !pFrm->IsInDocBody())
|
|
|
|
pTxtNode = GetBodyTxtNode( rDoc, aFldPos, *pFrm );
|
|
|
|
//if no text node could be found or the field is in the document
|
|
|
|
//body the directly available text node will be used
|
|
|
|
if(!pTxtNode)
|
|
|
|
pTxtNode = &rFldTxtNode;
|
|
|
|
if( pTxtNode->GetTxt().Len() && pTxtNode->GetFrm() &&
|
|
|
|
pTxtNode->GetNodes().IsDocNodes() )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2003-03-27 14:45:43 +00:00
|
|
|
SwTOXAuthority* pNew = new SwTOXAuthority( *pTxtNode,
|
2000-10-20 10:11:17 +00:00
|
|
|
*pFmtFld, aIntl );
|
2001-02-14 09:43:38 +00:00
|
|
|
|
|
|
|
for(short i = 0; i < aSortArr.Count(); ++i)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
|
|
|
SwTOXSortTabBase* pOld = aSortArr[i];
|
|
|
|
if(*pOld == *pNew)
|
|
|
|
{
|
|
|
|
//only the first occurence in the document
|
|
|
|
//has to be in the array
|
|
|
|
if(*pOld < *pNew)
|
2001-02-09 06:52:57 +00:00
|
|
|
DELETEZ(pNew);
|
2001-02-14 09:43:38 +00:00
|
|
|
else // remove the old content
|
2000-09-18 23:08:29 +00:00
|
|
|
aSortArr.DeleteAndDestroy( i, 1 );
|
|
|
|
break;
|
2001-02-14 09:43:38 +00:00
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
2001-02-14 09:43:38 +00:00
|
|
|
//if it still exists - insert at the correct position
|
2001-02-09 06:52:57 +00:00
|
|
|
if(pNew)
|
2001-02-14 09:43:38 +00:00
|
|
|
{
|
2003-12-01 16:17:00 +00:00
|
|
|
short j;
|
|
|
|
|
|
|
|
for( j = 0; j < aSortArr.Count(); ++j)
|
2001-02-14 09:43:38 +00:00
|
|
|
{
|
|
|
|
SwTOXSortTabBase* pOld = aSortArr[j];
|
|
|
|
if(*pNew < *pOld)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
aSortArr.Insert(pNew, j );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(USHORT i = 0; i < aSortArr.Count(); i++)
|
|
|
|
{
|
|
|
|
const SwTOXSortTabBase& rBase = *aSortArr[i];
|
|
|
|
SwFmtFld& rFmtFld = ((SwTOXAuthority&)rBase).GetFldFmt();
|
|
|
|
SwAuthorityField* pAFld = (SwAuthorityField*)rFmtFld.GetFld();
|
|
|
|
m_pSequArr->Insert(pAFld->GetHandle(), i);
|
|
|
|
}
|
|
|
|
aSortArr.DeleteAndDestroy(0, aSortArr.Count());
|
|
|
|
}
|
|
|
|
//find nHandle
|
2001-02-09 06:52:57 +00:00
|
|
|
USHORT nRet = 0;
|
2000-09-18 23:08:29 +00:00
|
|
|
for(USHORT i = 0; i < m_pSequArr->Count(); i++)
|
|
|
|
{
|
|
|
|
if((*m_pSequArr)[i] == nHandle)
|
|
|
|
{
|
|
|
|
nRet = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-02-14 09:43:38 +00:00
|
|
|
ASSERT(bCurrentFieldWithoutTextNode || nRet, "Handle not found")
|
2000-09-18 23:08:29 +00:00
|
|
|
return nRet;
|
|
|
|
}
|
2000-11-16 11:30:48 +00:00
|
|
|
/* -----------------------------15.11.00 17:33--------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2000-11-16 11:30:48 +00:00
|
|
|
---------------------------------------------------------------------------*/
|
2007-09-27 07:47:39 +00:00
|
|
|
BOOL SwAuthorityFieldType::QueryValue( Any& rVal, USHORT nWhichId ) const
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
switch( nWhichId )
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
case FIELD_PROP_PAR2:
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2002-10-30 09:41:06 +00:00
|
|
|
OUString sVal;
|
2007-09-27 07:47:39 +00:00
|
|
|
sal_Unicode uRet = FIELD_PROP_PAR1 == nWhichId ? m_cPrefix : m_cSuffix;
|
2002-10-30 09:41:06 +00:00
|
|
|
if(uRet)
|
|
|
|
sVal = OUString(uRet);
|
2001-10-24 17:56:14 +00:00
|
|
|
rVal <<= sVal;
|
2000-11-16 11:30:48 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
case FIELD_PROP_PAR3:
|
2001-06-12 14:39:50 +00:00
|
|
|
rVal <<= OUString(GetSortAlgorithm());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
sal_Bool bVal = FIELD_PROP_BOOL1 == nWhichId ? m_bIsSequence: m_bSortByDocument;
|
2001-10-24 17:56:14 +00:00
|
|
|
rVal.setValue(&bVal, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_LOCALE:
|
2001-06-06 09:41:26 +00:00
|
|
|
rVal <<= SvxCreateLocale(GetLanguage());
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_PROP_SEQ:
|
|
|
|
{
|
|
|
|
Sequence<PropertyValues> aRet(m_pSortKeyArr->Count());
|
|
|
|
PropertyValues* pValues = aRet.getArray();
|
|
|
|
OUString sProp1( C2U(SW_PROP_NAME_STR(UNO_NAME_SORT_KEY)) ),
|
|
|
|
sProp2( C2U(SW_PROP_NAME_STR(UNO_NAME_IS_SORT_ASCENDING)));
|
|
|
|
for(sal_uInt16 i = 0; i < m_pSortKeyArr->Count(); i++)
|
|
|
|
{
|
|
|
|
const SwTOXSortKey* pKey = (*m_pSortKeyArr)[i];
|
|
|
|
pValues[i].realloc(2);
|
|
|
|
PropertyValue* pValue = pValues[i].getArray();
|
|
|
|
pValue[0].Name = sProp1;
|
|
|
|
pValue[0].Value <<= sal_Int16(pKey->eField);
|
|
|
|
pValue[1].Name = sProp2;
|
|
|
|
pValue[1].Value.setValue(&pKey->bSortAscending, ::getBooleanCppuType());
|
|
|
|
}
|
|
|
|
rVal <<= aRet;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2001-10-26 09:33:01 +00:00
|
|
|
DBG_ERROR("illegal property");
|
2001-10-24 17:56:14 +00:00
|
|
|
}
|
2000-11-16 11:30:48 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
/* -----------------------------15.11.00 17:33--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2007-09-27 07:47:39 +00:00
|
|
|
BOOL SwAuthorityFieldType::PutValue( const Any& rAny, USHORT nWhichId )
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
|
|
|
sal_Bool bRet = TRUE;
|
2001-10-24 17:56:14 +00:00
|
|
|
String sTmp;
|
2007-09-27 07:47:39 +00:00
|
|
|
switch( nWhichId )
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR1:
|
|
|
|
case FIELD_PROP_PAR2:
|
2002-10-30 09:41:06 +00:00
|
|
|
{
|
|
|
|
::GetString( rAny, sTmp );
|
|
|
|
sal_Unicode uSet = sTmp.GetChar(0);
|
2007-09-27 07:47:39 +00:00
|
|
|
if( FIELD_PROP_PAR1 == nWhichId )
|
2002-10-30 09:41:06 +00:00
|
|
|
m_cPrefix = uSet;
|
|
|
|
else
|
|
|
|
m_cSuffix = uSet;
|
|
|
|
}
|
|
|
|
break;
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PAR3:
|
|
|
|
SetSortAlgorithm( ::GetString( rAny, sTmp ));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_BOOL1:
|
|
|
|
m_bIsSequence = *(sal_Bool*)rAny.getValue();
|
|
|
|
break;
|
|
|
|
case FIELD_PROP_BOOL2:
|
|
|
|
m_bSortByDocument = *(sal_Bool*)rAny.getValue();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FIELD_PROP_LOCALE:
|
|
|
|
{
|
|
|
|
Locale aLocale;
|
|
|
|
if( 0 != (bRet = rAny >>= aLocale ))
|
|
|
|
SetLanguage( SvxLocaleToLanguage( aLocale ));
|
|
|
|
}
|
|
|
|
break;
|
2000-11-16 11:30:48 +00:00
|
|
|
|
2001-10-24 17:56:14 +00:00
|
|
|
case FIELD_PROP_PROP_SEQ:
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
Sequence<PropertyValues> aSeq;
|
|
|
|
if( 0 != (bRet = rAny >>= aSeq) )
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
m_pSortKeyArr->DeleteAndDestroy(0, m_pSortKeyArr->Count());
|
|
|
|
const PropertyValues* pValues = aSeq.getConstArray();
|
|
|
|
for(sal_Int32 i = 0; i < aSeq.getLength() && i < USHRT_MAX / 4; i++)
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
const PropertyValue* pValue = pValues[i].getConstArray();
|
|
|
|
SwTOXSortKey* pSortKey = new SwTOXSortKey;
|
|
|
|
for(sal_Int32 j = 0; j < pValues[i].getLength(); j++)
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
2001-10-24 17:56:14 +00:00
|
|
|
if(pValue[j].Name.equalsAsciiL(SW_PROP_NAME(UNO_NAME_SORT_KEY)))
|
|
|
|
{
|
|
|
|
sal_Int16 nVal = -1; pValue[j].Value >>= nVal;
|
|
|
|
if(nVal >= 0 && nVal < AUTH_FIELD_END)
|
|
|
|
pSortKey->eField = (ToxAuthorityField) nVal;
|
|
|
|
else
|
|
|
|
bRet = FALSE;
|
|
|
|
}
|
|
|
|
else if(pValue[j].Name.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SORT_ASCENDING)))
|
|
|
|
{
|
|
|
|
pSortKey->bSortAscending = *(sal_Bool*)pValue[j].Value.getValue();
|
|
|
|
}
|
2000-11-16 11:30:48 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
m_pSortKeyArr->Insert(pSortKey, m_pSortKeyArr->Count());
|
2000-11-16 11:30:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-10-26 09:33:01 +00:00
|
|
|
DBG_ERROR("illegal property");
|
2000-11-16 11:30:48 +00:00
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
/* -----------------19.10.99 13:25-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwAuthorityFieldType::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew )
|
|
|
|
{
|
|
|
|
//re-generate positions of the fields
|
2001-02-14 09:43:38 +00:00
|
|
|
DelSequenceArray();
|
2000-09-18 23:08:29 +00:00
|
|
|
SwModify::Modify( pOld, pNew );
|
|
|
|
}
|
|
|
|
/* -----------------20.10.99 13:38-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
USHORT SwAuthorityFieldType::GetSortKeyCount() const
|
|
|
|
{
|
|
|
|
return m_pSortKeyArr->Count();
|
|
|
|
}
|
|
|
|
/* -----------------20.10.99 13:38-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
const SwTOXSortKey* SwAuthorityFieldType::GetSortKey(USHORT nIdx) const
|
|
|
|
{
|
|
|
|
SwTOXSortKey* pRet = 0;
|
|
|
|
if(m_pSortKeyArr->Count() > nIdx)
|
|
|
|
pRet = (*m_pSortKeyArr)[nIdx];
|
|
|
|
DBG_ASSERT(pRet, "Sort key not found")
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
/* -----------------20.10.99 13:38-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwAuthorityFieldType::SetSortKeys(USHORT nKeyCount, SwTOXSortKey aKeys[])
|
|
|
|
{
|
|
|
|
m_pSortKeyArr->DeleteAndDestroy(0, m_pSortKeyArr->Count());
|
|
|
|
USHORT nArrIdx = 0;
|
|
|
|
for(USHORT i = 0; i < nKeyCount; i++)
|
|
|
|
if(aKeys[i].eField < AUTH_FIELD_END)
|
|
|
|
m_pSortKeyArr->Insert(new SwTOXSortKey(aKeys[i]), nArrIdx++);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -----------------14.09.99 16:15-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2007-09-27 07:47:39 +00:00
|
|
|
SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType,
|
2000-09-18 23:08:29 +00:00
|
|
|
const String& rFieldContents )
|
2007-09-27 07:47:39 +00:00
|
|
|
: SwField(pInitType)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
nHandle = pInitType->AddField( rFieldContents );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
/* -----------------17.09.99 14:24-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2007-09-27 07:47:39 +00:00
|
|
|
SwAuthorityField::SwAuthorityField( SwAuthorityFieldType* pInitType,
|
2000-09-18 23:08:29 +00:00
|
|
|
long nSetHandle )
|
2007-09-27 07:47:39 +00:00
|
|
|
: SwField( pInitType ),
|
2000-09-18 23:08:29 +00:00
|
|
|
nHandle( nSetHandle )
|
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
pInitType->AddField( nHandle );
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
/* -----------------15.09.99 15:00-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
SwAuthorityField::~SwAuthorityField()
|
|
|
|
{
|
|
|
|
((SwAuthorityFieldType* )GetTyp())->RemoveField(nHandle);
|
|
|
|
}
|
|
|
|
/*-- 14.09.99 16:20:59---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
String SwAuthorityField::Expand() const
|
|
|
|
{
|
|
|
|
SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp();
|
2002-10-30 09:41:06 +00:00
|
|
|
String sRet;
|
|
|
|
if(pAuthType->GetPrefix())
|
|
|
|
sRet.Assign(pAuthType->GetPrefix());
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
if( pAuthType->IsSequence() )
|
|
|
|
{
|
|
|
|
sRet += String::CreateFromInt32( pAuthType->GetSequencePos( nHandle ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle(nHandle);
|
|
|
|
//TODO: Expand to: identifier, number sequence, ...
|
|
|
|
if(pEntry)
|
|
|
|
sRet += pEntry->GetAuthorField(AUTH_FIELD_IDENTIFIER);
|
|
|
|
}
|
2002-10-30 09:41:06 +00:00
|
|
|
if(pAuthType->GetSuffix())
|
|
|
|
sRet += pAuthType->GetSuffix();
|
2000-09-18 23:08:29 +00:00
|
|
|
return sRet;
|
|
|
|
}
|
|
|
|
/*-- 14.09.99 16:21:00---------------------------------------------------
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------*/
|
|
|
|
SwField* SwAuthorityField::Copy() const
|
|
|
|
{
|
|
|
|
SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp();
|
|
|
|
return new SwAuthorityField(pAuthType, nHandle);
|
|
|
|
}
|
|
|
|
/* -----------------21.09.99 12:55-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
const String& SwAuthorityField::GetFieldText(ToxAuthorityField eField) const
|
|
|
|
{
|
|
|
|
SwAuthorityFieldType* pAuthType = (SwAuthorityFieldType*)GetTyp();
|
|
|
|
const SwAuthEntry* pEntry = pAuthType->GetEntryByHandle( nHandle );
|
|
|
|
return pEntry->GetAuthorField( eField );
|
|
|
|
}
|
|
|
|
/* -----------------21.09.99 14:57-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
|
|
|
void SwAuthorityField::SetPar1(const String& rStr)
|
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
SwAuthorityFieldType* pInitType = (SwAuthorityFieldType* )GetTyp();
|
|
|
|
pInitType->RemoveField(nHandle);
|
|
|
|
nHandle = pInitType->AddField(rStr);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
/* -----------------11.10.99 09:43-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2004-09-08 13:55:05 +00:00
|
|
|
String SwAuthorityField::GetDescription() const
|
|
|
|
{
|
2007-09-27 07:47:39 +00:00
|
|
|
return SW_RES(STR_AUTHORITY_ENTRY);
|
2004-09-08 13:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-11-16 11:30:48 +00:00
|
|
|
/* -----------------------------15.11.00 17:33--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
const char* aFieldNames[] =
|
|
|
|
{
|
|
|
|
"Identifier",
|
|
|
|
"BibiliographicType",
|
|
|
|
"Address",
|
|
|
|
"Annote",
|
|
|
|
"Author",
|
|
|
|
"Booktitle",
|
|
|
|
"Chapter",
|
|
|
|
"Edition",
|
|
|
|
"Editor",
|
|
|
|
"Howpublished",
|
|
|
|
"Institution",
|
|
|
|
"Journal",
|
|
|
|
"Month",
|
|
|
|
"Note",
|
|
|
|
"Number",
|
|
|
|
"Organizations",
|
|
|
|
"Pages",
|
|
|
|
"Publisher",
|
|
|
|
"School",
|
|
|
|
"Series",
|
|
|
|
"Title",
|
|
|
|
"Report_Type",
|
|
|
|
"Volume",
|
|
|
|
"Year",
|
|
|
|
"URL",
|
|
|
|
"Custom1",
|
|
|
|
"Custom2",
|
|
|
|
"Custom3",
|
|
|
|
"Custom4",
|
|
|
|
"Custom5",
|
|
|
|
"ISBN"
|
|
|
|
};
|
|
|
|
/* -----------------------------16.11.00 12:27--------------------------------
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------*/
|
2007-09-27 07:47:39 +00:00
|
|
|
BOOL SwAuthorityField::QueryValue( Any& rAny, USHORT /*nWhichId*/ ) const
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
|
|
|
if(!GetTyp())
|
|
|
|
return FALSE;
|
|
|
|
const SwAuthEntry* pAuthEntry = ((SwAuthorityFieldType*)GetTyp())->GetEntryByHandle(nHandle);
|
|
|
|
if(!pAuthEntry)
|
|
|
|
return FALSE;
|
|
|
|
Sequence <PropertyValue> aRet(AUTH_FIELD_END);
|
|
|
|
PropertyValue* pValues = aRet.getArray();
|
|
|
|
for(sal_Int16 i = 0; i < AUTH_FIELD_END; i++)
|
|
|
|
{
|
|
|
|
pValues[i].Name = C2U(aFieldNames[i]);
|
|
|
|
const String& rField = pAuthEntry->GetAuthorField((ToxAuthorityField) i);
|
2000-11-28 07:58:23 +00:00
|
|
|
if(i == AUTH_FIELD_AUTHORITY_TYPE)
|
|
|
|
pValues[i].Value <<= sal_Int16(rField.ToInt32());
|
|
|
|
else
|
|
|
|
pValues[i].Value <<= OUString(rField);
|
2000-11-16 11:30:48 +00:00
|
|
|
}
|
2001-10-24 17:56:14 +00:00
|
|
|
rAny <<= aRet;
|
2000-11-16 11:30:48 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* -----------------------------15.11.00 17:33--------------------------------
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2000-11-16 11:30:48 +00:00
|
|
|
---------------------------------------------------------------------------*/
|
|
|
|
sal_Int16 lcl_Find(const OUString& rFieldName)
|
|
|
|
{
|
|
|
|
for(sal_Int16 i = 0; i < AUTH_FIELD_END; i++)
|
|
|
|
if(!rFieldName.compareToAscii(aFieldNames[i]))
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
2007-09-27 07:47:39 +00:00
|
|
|
BOOL SwAuthorityField::PutValue( const Any& rAny, USHORT /*nWhichId*/ )
|
2000-11-16 11:30:48 +00:00
|
|
|
{
|
|
|
|
if(!GetTyp() || !((SwAuthorityFieldType*)GetTyp())->GetEntryByHandle(nHandle))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
Sequence <PropertyValue> aParam;
|
2001-10-24 17:56:14 +00:00
|
|
|
if(!(rAny >>= aParam))
|
2000-11-16 11:30:48 +00:00
|
|
|
return FALSE;
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2000-11-16 11:30:48 +00:00
|
|
|
String sToSet;
|
|
|
|
sToSet.Fill(AUTH_FIELD_ISBN, TOX_STYLE_DELIMITER);
|
|
|
|
const PropertyValue* pParam = aParam.getConstArray();
|
|
|
|
for(sal_Int32 i = 0; i < aParam.getLength(); i++)
|
|
|
|
{
|
|
|
|
sal_Int16 nFound = lcl_Find(pParam[i].Name);
|
|
|
|
if(nFound >= 0)
|
|
|
|
{
|
|
|
|
OUString sContent;
|
2000-12-04 13:43:50 +00:00
|
|
|
if(AUTH_FIELD_AUTHORITY_TYPE == nFound)
|
|
|
|
{
|
|
|
|
sal_Int16 nVal;
|
|
|
|
pParam[i].Value >>= nVal;
|
|
|
|
sContent = OUString::valueOf((sal_Int32)nVal);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pParam[i].Value >>= sContent;
|
2000-11-16 11:30:48 +00:00
|
|
|
sToSet.SetToken(nFound, TOX_STYLE_DELIMITER, sContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
((SwAuthorityFieldType*)GetTyp())->RemoveField(nHandle);
|
2000-12-01 09:57:46 +00:00
|
|
|
nHandle = ((SwAuthorityFieldType*)GetTyp())->AddField(sToSet);
|
2000-11-16 11:30:48 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* -----------------11.10.99 09:43-------------------
|
|
|
|
|
|
|
|
--------------------------------------------------*/
|
2000-09-18 23:08:29 +00:00
|
|
|
SwFieldType* SwAuthorityField::ChgTyp( SwFieldType* pFldTyp )
|
|
|
|
{
|
|
|
|
SwAuthorityFieldType* pSrcTyp = (SwAuthorityFieldType*)GetTyp(),
|
|
|
|
* pDstTyp = (SwAuthorityFieldType*)pFldTyp;
|
|
|
|
if( pSrcTyp != pDstTyp )
|
|
|
|
{
|
|
|
|
|
|
|
|
const SwAuthEntry* pEntry = pSrcTyp->GetEntryByHandle( nHandle );
|
|
|
|
USHORT nHdlPos = pDstTyp->AppendField( *pEntry );
|
|
|
|
pSrcTyp->RemoveField( nHandle );
|
|
|
|
nHandle = pDstTyp->GetHandle( nHdlPos );
|
|
|
|
pDstTyp->AddField( nHandle );
|
|
|
|
SwField::ChgTyp( pFldTyp );
|
|
|
|
}
|
|
|
|
return pSrcTyp;
|
|
|
|
}
|
|
|
|
|