1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: authfld.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #define _SVSTDARR_STRINGSDTOR
36 #define _SVSTDARR_USHORTS
37 #define _SVSTDARR_LONGS
38 #define _SVSTDARR_ULONGS
39 #include <hintids.hxx>
41 #include <svtools/svstdarr.hxx>
42 #include <svx/unolingu.hxx>
43 #include <svx/langitem.hxx>
44 #include <swtypes.hxx>
45 #include <tools/resid.hxx>
47 #include <comcore.hrc>
49 #include <authfld.hxx>
61 #include <unofldmid.h>
63 #include <unoprnms.hxx>
67 using namespace ::com::sun::star::uno
;
68 using namespace ::com::sun::star::beans
;
69 using namespace ::com::sun::star::lang
;
73 typedef SwAuthEntry
* SwAuthEntryPtr
;
74 SV_DECL_PTRARR_DEL( SwAuthDataArr
, SwAuthEntryPtr
, 5, 5 )
75 SV_IMPL_PTRARR( SwAuthDataArr
, SwAuthEntryPtr
)
78 typedef SwTOXSortKey
* TOXSortKeyPtr
;
79 SV_DECL_PTRARR_DEL( SortKeyArr
, TOXSortKeyPtr
, 5, 5 )
80 SV_IMPL_PTRARR( SortKeyArr
, TOXSortKeyPtr
)
83 /* -----------------16.09.99 11:53-------------------
85 --------------------------------------------------*/
86 SwAuthEntry::SwAuthEntry(const SwAuthEntry
& rCopy
)
89 for(USHORT i
= 0; i
< AUTH_FIELD_END
; i
++)
90 aAuthFields
[i
] = rCopy
.aAuthFields
[i
];
92 // --------------------------------------------------------
93 BOOL
SwAuthEntry::operator==(const SwAuthEntry
& rComp
)
95 for(USHORT i
= 0; i
< AUTH_FIELD_END
; i
++)
96 if(aAuthFields
[i
] != rComp
.aAuthFields
[i
])
100 // --------------------------------------------------------
102 /* -----------------14.09.99 16:15-------------------
104 --------------------------------------------------*/
105 SwAuthorityFieldType::SwAuthorityFieldType(SwDoc
* pDoc
)
106 : SwFieldType( RES_AUTHORITY
),
108 m_pDataArr(new SwAuthDataArr
),
109 m_pSequArr(new SvLongs(5, 5)),
110 m_pSortKeyArr(new SortKeyArr(3, 3)),
113 m_bIsSequence(FALSE
),
114 m_bSortByDocument(TRUE
),
115 m_eLanguage((LanguageType
)::GetAppLanguage())
119 SwAuthorityFieldType::SwAuthorityFieldType( const SwAuthorityFieldType
& rFType
)
120 : SwFieldType( RES_AUTHORITY
),
121 m_pDataArr(new SwAuthDataArr
),
122 m_pSequArr(new SvLongs(5, 5)),
123 m_pSortKeyArr(new SortKeyArr(3, 3)),
124 m_cPrefix(rFType
.m_cPrefix
),
125 m_cSuffix(rFType
.m_cSuffix
),
126 m_bIsSequence(rFType
.m_bIsSequence
),
127 m_bSortByDocument(rFType
.m_bSortByDocument
),
128 m_eLanguage(rFType
.m_eLanguage
),
129 m_sSortAlgorithm(rFType
.m_sSortAlgorithm
)
131 for(USHORT i
= 0; i
< rFType
.m_pSortKeyArr
->Count(); i
++)
132 m_pSortKeyArr
->Insert((*rFType
.m_pSortKeyArr
)[i
], i
);
135 /* -----------------17.09.99 13:52-------------------
137 --------------------------------------------------*/
138 SwAuthorityFieldType::~SwAuthorityFieldType()
140 // DBG_ASSERT(!m_pDataArr->Count(), "Array is not empty");
141 m_pSortKeyArr
->DeleteAndDestroy(0, m_pSortKeyArr
->Count());
142 delete m_pSortKeyArr
;
146 /*-- 14.09.99 16:22:09---------------------------------------------------
148 -----------------------------------------------------------------------*/
149 SwFieldType
* SwAuthorityFieldType::Copy() const
151 return new SwAuthorityFieldType(m_pDoc
);
153 /* -----------------17.09.99 13:43-------------------
155 --------------------------------------------------*/
156 void SwAuthorityFieldType::RemoveField(long nHandle
)
159 BOOL bRemoved
= FALSE
;
161 for(USHORT j
= 0; j
< m_pDataArr
->Count(); j
++)
163 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
164 long nRet
= (long)(void*)pTemp
;
171 if(!pTemp
->GetRefCount())
173 m_pDataArr
->DeleteAndDestroy(j
, 1);
174 //re-generate positions of the fields
181 DBG_ASSERT(bRemoved
, "Field unknown" );
184 /* -----------------17.09.99 13:43-------------------
186 --------------------------------------------------*/
187 long SwAuthorityFieldType::AddField(const String
& rFieldContents
)
190 SwAuthEntry
* pEntry
= new SwAuthEntry
;
191 for( USHORT i
= 0; i
< AUTH_FIELD_END
; ++i
)
192 pEntry
->SetAuthorField( (ToxAuthorityField
)i
,
193 rFieldContents
.GetToken( i
, TOX_STYLE_DELIMITER
));
195 for(USHORT j
= 0; j
< m_pDataArr
->Count() && pEntry
; j
++)
197 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
198 if(*pTemp
== *pEntry
)
201 nRet
= (long)(void*)pTemp
;
205 //if it is a new Entry - insert
208 nRet
= (long)(void*)pEntry
;
210 m_pDataArr
->Insert(pEntry
, m_pDataArr
->Count());
211 //re-generate positions of the fields
216 /* -----------------17.09.99 14:18-------------------
218 --------------------------------------------------*/
219 BOOL
SwAuthorityFieldType::AddField(long nHandle
)
222 for( USHORT j
= 0; j
< m_pDataArr
->Count(); j
++ )
224 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
225 long nTmp
= (long)(void*)pTemp
;
226 if( nTmp
== nHandle
)
230 //re-generate positions of the fields
235 DBG_ASSERT(bRet
, "::AddField(long) failed");
238 /* -----------------17.09.99 14:52-------------------
240 --------------------------------------------------*/
241 const SwAuthEntry
* SwAuthorityFieldType::GetEntryByHandle(long nHandle
) const
243 const SwAuthEntry
* pRet
= 0;
244 for(USHORT j
= 0; j
< m_pDataArr
->Count(); j
++)
246 const SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
247 long nTmp
= (long)(void*)pTemp
;
248 if( nTmp
== nHandle
)
254 ASSERT( pRet
, "invalid Handle" );
257 /* -----------------21.09.99 13:34-------------------
259 --------------------------------------------------*/
260 void SwAuthorityFieldType::GetAllEntryIdentifiers(
261 SvStringsDtor
& rToFill
)const
263 for(USHORT j
= 0; j
< m_pDataArr
->Count(); j
++)
265 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
266 rToFill
.Insert( new String( pTemp
->GetAuthorField(
267 AUTH_FIELD_IDENTIFIER
)), rToFill
.Count() );
270 /* -----------------21.09.99 13:34-------------------
272 --------------------------------------------------*/
273 const SwAuthEntry
* SwAuthorityFieldType::GetEntryByIdentifier(
274 const String
& rIdentifier
)const
276 const SwAuthEntry
* pRet
= 0;
277 for( USHORT j
= 0; j
< m_pDataArr
->Count(); ++j
)
279 const SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
280 if( rIdentifier
== pTemp
->GetAuthorField( AUTH_FIELD_IDENTIFIER
))
288 /* -----------------------------21.12.99 13:20--------------------------------
290 ---------------------------------------------------------------------------*/
291 bool SwAuthorityFieldType::ChangeEntryContent(const SwAuthEntry
* pNewEntry
)
293 bool bChanged
= false;
294 for( USHORT j
= 0; j
< m_pDataArr
->Count(); ++j
)
296 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(j
);
297 if(pTemp
->GetAuthorField(AUTH_FIELD_IDENTIFIER
) ==
298 pNewEntry
->GetAuthorField(AUTH_FIELD_IDENTIFIER
))
300 for(USHORT i
= 0; i
< AUTH_FIELD_END
; i
++)
301 pTemp
->SetAuthorField((ToxAuthorityField
) i
,
302 pNewEntry
->GetAuthorField((ToxAuthorityField
)i
));
309 /*-- 11.10.99 08:49:22---------------------------------------------------
310 Description: appends a new entry (if new) and returns the array position
312 -----------------------------------------------------------------------*/
313 USHORT
SwAuthorityFieldType::AppendField( const SwAuthEntry
& rInsert
)
316 for( nRet
= 0; nRet
< m_pDataArr
->Count(); ++nRet
)
318 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject( nRet
);
319 if( *pTemp
== rInsert
)
322 //ref count unchanged
326 //if it is a new Entry - insert
327 if( nRet
== m_pDataArr
->Count() )
328 m_pDataArr
->Insert( new SwAuthEntry( rInsert
), nRet
);
333 /*-- 11.10.99 08:49:24---------------------------------------------------
335 -----------------------------------------------------------------------*/
336 long SwAuthorityFieldType::GetHandle(USHORT nPos
)
339 if( nPos
< m_pDataArr
->Count() )
341 SwAuthEntry
* pTemp
= m_pDataArr
->GetObject(nPos
);
342 nRet
= (long)(void*)pTemp
;
346 /* -----------------19.10.99 13:46-------------------
348 --------------------------------------------------*/
349 USHORT
SwAuthorityFieldType::GetSequencePos(long nHandle
)
351 //find the field in a sorted array of handles,
353 sal_Bool bCurrentFieldWithoutTextNode
= sal_False
;
355 if(m_pSequArr
->Count() && m_pSequArr
->Count() != m_pDataArr
->Count())
357 if(!m_pSequArr
->Count())
359 SwTOXSortTabBases aSortArr
;
360 SwClientIter
aIter( *this );
362 SwTOXInternational
aIntl(m_eLanguage
, 0, m_sSortAlgorithm
);
364 for( SwFmtFld
* pFmtFld
= (SwFmtFld
*)aIter
.First( TYPE(SwFmtFld
) );
365 pFmtFld
; pFmtFld
= (SwFmtFld
*)aIter
.Next() )
367 const SwTxtFld
* pTxtFld
= pFmtFld
->GetTxtFld();
368 if(!pTxtFld
|| !pTxtFld
->GetpTxtNode())
371 if(nHandle
== ((SwAuthorityField
*)pFmtFld
->GetFld())->GetHandle())
372 bCurrentFieldWithoutTextNode
= sal_True
;
376 const SwTxtNode
& rFldTxtNode
= pTxtFld
->GetTxtNode();
377 SwPosition
aFldPos(rFldTxtNode
);
378 SwDoc
& rDoc
= *(SwDoc
*)rFldTxtNode
.GetDoc();
379 SwCntntFrm
*pFrm
= rFldTxtNode
.GetFrm();
380 const SwTxtNode
* pTxtNode
= 0;
381 if(pFrm
&& !pFrm
->IsInDocBody())
382 pTxtNode
= GetBodyTxtNode( rDoc
, aFldPos
, *pFrm
);
383 //if no text node could be found or the field is in the document
384 //body the directly available text node will be used
386 pTxtNode
= &rFldTxtNode
;
387 if( pTxtNode
->GetTxt().Len() && pTxtNode
->GetFrm() &&
388 pTxtNode
->GetNodes().IsDocNodes() )
390 SwTOXAuthority
* pNew
= new SwTOXAuthority( *pTxtNode
,
393 for(short i
= 0; i
< aSortArr
.Count(); ++i
)
395 SwTOXSortTabBase
* pOld
= aSortArr
[i
];
398 //only the first occurence in the document
399 //has to be in the array
402 else // remove the old content
403 aSortArr
.DeleteAndDestroy( i
, 1 );
407 //if it still exists - insert at the correct position
412 for( j
= 0; j
< aSortArr
.Count(); ++j
)
414 SwTOXSortTabBase
* pOld
= aSortArr
[j
];
418 aSortArr
.Insert(pNew
, j
);
423 for(USHORT i
= 0; i
< aSortArr
.Count(); i
++)
425 const SwTOXSortTabBase
& rBase
= *aSortArr
[i
];
426 SwFmtFld
& rFmtFld
= ((SwTOXAuthority
&)rBase
).GetFldFmt();
427 SwAuthorityField
* pAFld
= (SwAuthorityField
*)rFmtFld
.GetFld();
428 m_pSequArr
->Insert(pAFld
->GetHandle(), i
);
430 aSortArr
.DeleteAndDestroy(0, aSortArr
.Count());
434 for(USHORT i
= 0; i
< m_pSequArr
->Count(); i
++)
436 if((*m_pSequArr
)[i
] == nHandle
)
442 ASSERT(bCurrentFieldWithoutTextNode
|| nRet
, "Handle not found")
445 /* -----------------------------15.11.00 17:33--------------------------------
447 ---------------------------------------------------------------------------*/
448 BOOL
SwAuthorityFieldType::QueryValue( Any
& rVal
, USHORT nWhichId
) const
452 case FIELD_PROP_PAR1
:
453 case FIELD_PROP_PAR2
:
456 sal_Unicode uRet
= FIELD_PROP_PAR1
== nWhichId
? m_cPrefix
: m_cSuffix
;
458 sVal
= OUString(uRet
);
462 case FIELD_PROP_PAR3
:
463 rVal
<<= OUString(GetSortAlgorithm());
466 case FIELD_PROP_BOOL1
:
467 case FIELD_PROP_BOOL2
:
469 sal_Bool bVal
= FIELD_PROP_BOOL1
== nWhichId
? m_bIsSequence
: m_bSortByDocument
;
470 rVal
.setValue(&bVal
, ::getBooleanCppuType());
474 case FIELD_PROP_LOCALE
:
475 rVal
<<= SvxCreateLocale(GetLanguage());
478 case FIELD_PROP_PROP_SEQ
:
480 Sequence
<PropertyValues
> aRet(m_pSortKeyArr
->Count());
481 PropertyValues
* pValues
= aRet
.getArray();
482 OUString
sProp1( C2U(SW_PROP_NAME_STR(UNO_NAME_SORT_KEY
)) ),
483 sProp2( C2U(SW_PROP_NAME_STR(UNO_NAME_IS_SORT_ASCENDING
)));
484 for(sal_uInt16 i
= 0; i
< m_pSortKeyArr
->Count(); i
++)
486 const SwTOXSortKey
* pKey
= (*m_pSortKeyArr
)[i
];
487 pValues
[i
].realloc(2);
488 PropertyValue
* pValue
= pValues
[i
].getArray();
489 pValue
[0].Name
= sProp1
;
490 pValue
[0].Value
<<= sal_Int16(pKey
->eField
);
491 pValue
[1].Name
= sProp2
;
492 pValue
[1].Value
.setValue(&pKey
->bSortAscending
, ::getBooleanCppuType());
498 DBG_ERROR("illegal property");
502 /* -----------------------------15.11.00 17:33--------------------------------
504 ---------------------------------------------------------------------------*/
505 BOOL
SwAuthorityFieldType::PutValue( const Any
& rAny
, USHORT nWhichId
)
507 sal_Bool bRet
= TRUE
;
511 case FIELD_PROP_PAR1
:
512 case FIELD_PROP_PAR2
:
514 ::GetString( rAny
, sTmp
);
515 sal_Unicode uSet
= sTmp
.GetChar(0);
516 if( FIELD_PROP_PAR1
== nWhichId
)
522 case FIELD_PROP_PAR3
:
523 SetSortAlgorithm( ::GetString( rAny
, sTmp
));
526 case FIELD_PROP_BOOL1
:
527 m_bIsSequence
= *(sal_Bool
*)rAny
.getValue();
529 case FIELD_PROP_BOOL2
:
530 m_bSortByDocument
= *(sal_Bool
*)rAny
.getValue();
533 case FIELD_PROP_LOCALE
:
536 if( 0 != (bRet
= rAny
>>= aLocale
))
537 SetLanguage( SvxLocaleToLanguage( aLocale
));
541 case FIELD_PROP_PROP_SEQ
:
543 Sequence
<PropertyValues
> aSeq
;
544 if( 0 != (bRet
= rAny
>>= aSeq
) )
546 m_pSortKeyArr
->DeleteAndDestroy(0, m_pSortKeyArr
->Count());
547 const PropertyValues
* pValues
= aSeq
.getConstArray();
548 for(sal_Int32 i
= 0; i
< aSeq
.getLength() && i
< USHRT_MAX
/ 4; i
++)
550 const PropertyValue
* pValue
= pValues
[i
].getConstArray();
551 SwTOXSortKey
* pSortKey
= new SwTOXSortKey
;
552 for(sal_Int32 j
= 0; j
< pValues
[i
].getLength(); j
++)
554 if(pValue
[j
].Name
.equalsAsciiL(SW_PROP_NAME(UNO_NAME_SORT_KEY
)))
556 sal_Int16 nVal
= -1; pValue
[j
].Value
>>= nVal
;
557 if(nVal
>= 0 && nVal
< AUTH_FIELD_END
)
558 pSortKey
->eField
= (ToxAuthorityField
) nVal
;
562 else if(pValue
[j
].Name
.equalsAsciiL(SW_PROP_NAME(UNO_NAME_IS_SORT_ASCENDING
)))
564 pSortKey
->bSortAscending
= *(sal_Bool
*)pValue
[j
].Value
.getValue();
567 m_pSortKeyArr
->Insert(pSortKey
, m_pSortKeyArr
->Count());
573 DBG_ERROR("illegal property");
577 /* -----------------19.10.99 13:25-------------------
579 --------------------------------------------------*/
580 void SwAuthorityFieldType::Modify( SfxPoolItem
*pOld
, SfxPoolItem
*pNew
)
582 //re-generate positions of the fields
584 SwModify::Modify( pOld
, pNew
);
586 /* -----------------20.10.99 13:38-------------------
588 --------------------------------------------------*/
589 USHORT
SwAuthorityFieldType::GetSortKeyCount() const
591 return m_pSortKeyArr
->Count();
593 /* -----------------20.10.99 13:38-------------------
595 --------------------------------------------------*/
596 const SwTOXSortKey
* SwAuthorityFieldType::GetSortKey(USHORT nIdx
) const
598 SwTOXSortKey
* pRet
= 0;
599 if(m_pSortKeyArr
->Count() > nIdx
)
600 pRet
= (*m_pSortKeyArr
)[nIdx
];
601 DBG_ASSERT(pRet
, "Sort key not found");
604 /* -----------------20.10.99 13:38-------------------
606 --------------------------------------------------*/
607 void SwAuthorityFieldType::SetSortKeys(USHORT nKeyCount
, SwTOXSortKey aKeys
[])
609 m_pSortKeyArr
->DeleteAndDestroy(0, m_pSortKeyArr
->Count());
611 for(USHORT i
= 0; i
< nKeyCount
; i
++)
612 if(aKeys
[i
].eField
< AUTH_FIELD_END
)
613 m_pSortKeyArr
->Insert(new SwTOXSortKey(aKeys
[i
]), nArrIdx
++);
616 /* -----------------14.09.99 16:15-------------------
618 --------------------------------------------------*/
619 SwAuthorityField::SwAuthorityField( SwAuthorityFieldType
* pInitType
,
620 const String
& rFieldContents
)
621 : SwField(pInitType
),
622 m_nTempSequencePos( -1 )
624 m_nHandle
= pInitType
->AddField( rFieldContents
);
626 /* -----------------17.09.99 14:24-------------------
628 --------------------------------------------------*/
629 SwAuthorityField::SwAuthorityField( SwAuthorityFieldType
* pInitType
,
631 : SwField( pInitType
),
632 m_nHandle( nSetHandle
),
633 m_nTempSequencePos( -1 )
635 pInitType
->AddField( m_nHandle
);
637 /* -----------------15.09.99 15:00-------------------
639 --------------------------------------------------*/
640 SwAuthorityField::~SwAuthorityField()
642 ((SwAuthorityFieldType
* )GetTyp())->RemoveField(m_nHandle
);
644 /*-- 14.09.99 16:20:59---------------------------------------------------
646 -----------------------------------------------------------------------*/
647 String
SwAuthorityField::Expand() const
649 SwAuthorityFieldType
* pAuthType
= (SwAuthorityFieldType
*)GetTyp();
651 if(pAuthType
->GetPrefix())
652 sRet
.Assign(pAuthType
->GetPrefix());
654 if( pAuthType
->IsSequence() )
656 if(!pAuthType
->GetDoc()->IsExpFldsLocked())
657 m_nTempSequencePos
= pAuthType
->GetSequencePos( m_nHandle
);
658 if( m_nTempSequencePos
>= 0 )
659 sRet
+= String::CreateFromInt32( m_nTempSequencePos
);
663 const SwAuthEntry
* pEntry
= pAuthType
->GetEntryByHandle(m_nHandle
);
664 //TODO: Expand to: identifier, number sequence, ...
666 sRet
+= pEntry
->GetAuthorField(AUTH_FIELD_IDENTIFIER
);
668 if(pAuthType
->GetSuffix())
669 sRet
+= pAuthType
->GetSuffix();
672 /*-- 14.09.99 16:21:00---------------------------------------------------
674 -----------------------------------------------------------------------*/
675 SwField
* SwAuthorityField::Copy() const
677 SwAuthorityFieldType
* pAuthType
= (SwAuthorityFieldType
*)GetTyp();
678 return new SwAuthorityField(pAuthType
, m_nHandle
);
680 /* -----------------21.09.99 12:55-------------------
682 --------------------------------------------------*/
683 const String
& SwAuthorityField::GetFieldText(ToxAuthorityField eField
) const
685 SwAuthorityFieldType
* pAuthType
= (SwAuthorityFieldType
*)GetTyp();
686 const SwAuthEntry
* pEntry
= pAuthType
->GetEntryByHandle( m_nHandle
);
687 return pEntry
->GetAuthorField( eField
);
689 /* -----------------21.09.99 14:57-------------------
691 --------------------------------------------------*/
692 void SwAuthorityField::SetPar1(const String
& rStr
)
694 SwAuthorityFieldType
* pInitType
= (SwAuthorityFieldType
* )GetTyp();
695 pInitType
->RemoveField(m_nHandle
);
696 m_nHandle
= pInitType
->AddField(rStr
);
698 /* -----------------11.10.99 09:43-------------------
700 --------------------------------------------------*/
701 String
SwAuthorityField::GetDescription() const
703 return SW_RES(STR_AUTHORITY_ENTRY
);
708 /* -----------------------------15.11.00 17:33--------------------------------
710 ---------------------------------------------------------------------------*/
711 const char* aFieldNames
[] =
714 "BibiliographicType",
745 /* -----------------------------16.11.00 12:27--------------------------------
747 ---------------------------------------------------------------------------*/
748 BOOL
SwAuthorityField::QueryValue( Any
& rAny
, USHORT
/*nWhichId*/ ) const
752 const SwAuthEntry
* pAuthEntry
= ((SwAuthorityFieldType
*)GetTyp())->GetEntryByHandle(m_nHandle
);
755 Sequence
<PropertyValue
> aRet(AUTH_FIELD_END
);
756 PropertyValue
* pValues
= aRet
.getArray();
757 for(sal_Int16 i
= 0; i
< AUTH_FIELD_END
; i
++)
759 pValues
[i
].Name
= C2U(aFieldNames
[i
]);
760 const String
& rField
= pAuthEntry
->GetAuthorField((ToxAuthorityField
) i
);
761 if(i
== AUTH_FIELD_AUTHORITY_TYPE
)
762 pValues
[i
].Value
<<= sal_Int16(rField
.ToInt32());
764 pValues
[i
].Value
<<= OUString(rField
);
769 /* -----------------------------15.11.00 17:33--------------------------------
771 ---------------------------------------------------------------------------*/
772 sal_Int16
lcl_Find(const OUString
& rFieldName
)
774 for(sal_Int16 i
= 0; i
< AUTH_FIELD_END
; i
++)
775 if(!rFieldName
.compareToAscii(aFieldNames
[i
]))
779 //----------------------------------------------------------------------------
780 BOOL
SwAuthorityField::PutValue( const Any
& rAny
, USHORT
/*nWhichId*/ )
782 if(!GetTyp() || !((SwAuthorityFieldType
*)GetTyp())->GetEntryByHandle(m_nHandle
))
785 Sequence
<PropertyValue
> aParam
;
786 if(!(rAny
>>= aParam
))
790 sToSet
.Fill(AUTH_FIELD_ISBN
, TOX_STYLE_DELIMITER
);
791 const PropertyValue
* pParam
= aParam
.getConstArray();
792 for(sal_Int32 i
= 0; i
< aParam
.getLength(); i
++)
794 sal_Int16 nFound
= lcl_Find(pParam
[i
].Name
);
798 if(AUTH_FIELD_AUTHORITY_TYPE
== nFound
)
801 pParam
[i
].Value
>>= nVal
;
802 sContent
= OUString::valueOf((sal_Int32
)nVal
);
805 pParam
[i
].Value
>>= sContent
;
806 sToSet
.SetToken(nFound
, TOX_STYLE_DELIMITER
, sContent
);
810 ((SwAuthorityFieldType
*)GetTyp())->RemoveField(m_nHandle
);
811 m_nHandle
= ((SwAuthorityFieldType
*)GetTyp())->AddField(sToSet
);
815 /* -----------------11.10.99 09:43-------------------
817 --------------------------------------------------*/
818 SwFieldType
* SwAuthorityField::ChgTyp( SwFieldType
* pFldTyp
)
820 SwAuthorityFieldType
* pSrcTyp
= (SwAuthorityFieldType
*)GetTyp(),
821 * pDstTyp
= (SwAuthorityFieldType
*)pFldTyp
;
822 if( pSrcTyp
!= pDstTyp
)
825 const SwAuthEntry
* pEntry
= pSrcTyp
->GetEntryByHandle( m_nHandle
);
826 USHORT nHdlPos
= pDstTyp
->AppendField( *pEntry
);
827 pSrcTyp
->RemoveField( m_nHandle
);
828 m_nHandle
= pDstTyp
->GetHandle( nHdlPos
);
829 pDstTyp
->AddField( m_nHandle
);
830 SwField::ChgTyp( pFldTyp
);