2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 09:48:52 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2010-10-04 17:14:34 +02:00
|
|
|
#ifndef SW_AUTHFLD_HXX
|
|
|
|
#define SW_AUTHFLD_HXX
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-08-23 07:27:43 +00:00
|
|
|
#include "swdllapi.h"
|
2000-09-18 16:15:01 +00:00
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <toxe.hxx>
|
2011-02-24 11:36:36 +00:00
|
|
|
#include <vector>
|
2012-05-10 15:07:32 +02:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
2001-02-14 09:43:38 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
class SwAuthEntry
|
|
|
|
{
|
|
|
|
String aAuthFields[AUTH_FIELD_END];
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRefCount;
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
|
|
|
SwAuthEntry() : nRefCount(0){}
|
|
|
|
SwAuthEntry( const SwAuthEntry& rCopy );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool operator==(const SwAuthEntry& rComp);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
inline const String& GetAuthorField(ToxAuthorityField ePos)const;
|
|
|
|
inline void SetAuthorField(ToxAuthorityField ePos,
|
|
|
|
const String& rField);
|
|
|
|
|
|
|
|
void AddRef() { ++nRefCount; }
|
|
|
|
void RemoveRef() { --nRefCount; }
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 GetRefCount() { return nRefCount; }
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SwTOXSortKey
|
|
|
|
{
|
|
|
|
ToxAuthorityField eField;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bSortAscending;
|
2000-09-18 16:15:01 +00:00
|
|
|
SwTOXSortKey() :
|
|
|
|
eField(AUTH_FIELD_END),
|
2011-01-17 15:06:54 +01:00
|
|
|
bSortAscending(sal_True){}
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SwAuthorityField;
|
2012-05-10 15:07:32 +02:00
|
|
|
typedef boost::ptr_vector<SwTOXSortKey> SortKeyArr;
|
2012-05-10 15:25:41 +02:00
|
|
|
typedef boost::ptr_vector<SwAuthEntry> SwAuthDataArr;
|
2004-08-23 07:27:43 +00:00
|
|
|
|
|
|
|
class SW_DLLPUBLIC SwAuthorityFieldType : public SwFieldType
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SwDoc* m_pDoc;
|
2012-05-10 15:25:41 +02:00
|
|
|
SwAuthDataArr m_DataArr;
|
2011-02-24 11:36:36 +00:00
|
|
|
std::vector<long> m_SequArr;
|
2012-05-10 15:07:32 +02:00
|
|
|
SortKeyArr m_SortKeyArr;
|
2001-01-18 13:06:33 +00:00
|
|
|
sal_Unicode m_cPrefix;
|
|
|
|
sal_Unicode m_cSuffix;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool m_bIsSequence :1;
|
|
|
|
sal_Bool m_bSortByDocument :1;
|
2001-06-06 09:41:26 +00:00
|
|
|
LanguageType m_eLanguage;
|
|
|
|
String m_sSortAlgorithm;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
protected:
|
|
|
|
virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew );
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
|
|
|
SwAuthorityFieldType(SwDoc* pDoc);
|
|
|
|
~SwAuthorityFieldType();
|
|
|
|
|
|
|
|
virtual SwFieldType* Copy() const;
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
|
|
|
|
virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
|
2000-11-16 11:30:48 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
inline void SetDoc(SwDoc* pNewDoc) { m_pDoc = pNewDoc; }
|
2008-08-27 11:53:52 +00:00
|
|
|
SwDoc* GetDoc(){ return m_pDoc; }
|
2000-09-18 16:15:01 +00:00
|
|
|
void RemoveField(long nHandle);
|
|
|
|
long AddField(const String& rFieldContents);
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool AddField(long nHandle);
|
2001-02-14 09:43:38 +00:00
|
|
|
void DelSequenceArray()
|
|
|
|
{
|
2011-02-24 11:36:36 +00:00
|
|
|
m_SequArr.clear();
|
2001-02-14 09:43:38 +00:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
const SwAuthEntry* GetEntryByHandle(long nHandle) const;
|
|
|
|
|
2012-01-13 18:23:08 -05:00
|
|
|
void GetAllEntryIdentifiers( std::vector<String>& rToFill )const;
|
2000-09-18 16:15:01 +00:00
|
|
|
const SwAuthEntry* GetEntryByIdentifier(const String& rIdentifier)const;
|
|
|
|
|
2009-07-07 08:58:17 +00:00
|
|
|
bool ChangeEntryContent(const SwAuthEntry* pNewEntry);
|
2000-09-18 16:15:01 +00:00
|
|
|
// import interface
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 AppendField(const SwAuthEntry& rInsert);
|
|
|
|
long GetHandle(sal_uInt16 nPos);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 GetSequencePos(long nHandle);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool IsSequence() const {return m_bIsSequence;}
|
|
|
|
void SetSequence(sal_Bool bSet)
|
2001-02-14 09:43:38 +00:00
|
|
|
{
|
|
|
|
DelSequenceArray();
|
|
|
|
m_bIsSequence = bSet;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-01-18 13:06:33 +00:00
|
|
|
void SetPreSuffix( sal_Unicode cPre, sal_Unicode cSuf)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
m_cPrefix = cPre;
|
|
|
|
m_cSuffix = cSuf;
|
|
|
|
}
|
2001-01-18 13:06:33 +00:00
|
|
|
sal_Unicode GetPrefix() const { return m_cPrefix;}
|
|
|
|
sal_Unicode GetSuffix() const { return m_cSuffix;}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool IsSortByDocument() const {return m_bSortByDocument;}
|
|
|
|
void SetSortByDocument(sal_Bool bSet)
|
2001-02-14 09:43:38 +00:00
|
|
|
{
|
|
|
|
DelSequenceArray();
|
|
|
|
m_bSortByDocument = bSet;
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 GetSortKeyCount() const ;
|
|
|
|
const SwTOXSortKey* GetSortKey(sal_uInt16 nIdx) const ;
|
|
|
|
void SetSortKeys(sal_uInt16 nKeyCount, SwTOXSortKey nKeys[]);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
//initui.cxx
|
|
|
|
static const String& GetAuthFieldName(ToxAuthorityField eType);
|
|
|
|
static const String& GetAuthTypeName(ToxAuthorityType eType);
|
|
|
|
|
2001-06-06 09:41:26 +00:00
|
|
|
LanguageType GetLanguage() const {return m_eLanguage;}
|
|
|
|
void SetLanguage(LanguageType nLang) {m_eLanguage = nLang;}
|
|
|
|
|
|
|
|
const String& GetSortAlgorithm()const {return m_sSortAlgorithm;}
|
|
|
|
void SetSortAlgorithm(const String& rSet) {m_sSortAlgorithm = rSet;}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class SwAuthorityField : public SwField
|
|
|
|
{
|
2008-08-27 11:53:52 +00:00
|
|
|
long m_nHandle;
|
|
|
|
mutable long m_nTempSequencePos;
|
2010-10-04 17:14:34 +02:00
|
|
|
|
|
|
|
virtual String Expand() const;
|
|
|
|
virtual SwField* Copy() const;
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
public:
|
|
|
|
SwAuthorityField(SwAuthorityFieldType* pType, const String& rFieldContents);
|
|
|
|
SwAuthorityField(SwAuthorityFieldType* pType, long nHandle);
|
|
|
|
~SwAuthorityField();
|
|
|
|
|
|
|
|
const String& GetFieldText(ToxAuthorityField eField) const;
|
|
|
|
|
2012-03-07 16:52:06 +00:00
|
|
|
virtual void SetPar1(const rtl::OUString& rStr);
|
2000-09-18 16:15:01 +00:00
|
|
|
virtual SwFieldType* ChgTyp( SwFieldType* );
|
|
|
|
|
2011-03-14 16:51:14 +00:00
|
|
|
virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId ) const;
|
|
|
|
virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt16 nWhichId );
|
2000-11-16 11:30:48 +00:00
|
|
|
|
2008-08-27 11:53:52 +00:00
|
|
|
long GetHandle() const { return m_nHandle; }
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-09-08 13:48:46 +00:00
|
|
|
virtual String GetDescription() const;
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
2010-11-15 23:37:49 +01:00
|
|
|
// --- inlines -----------------------------------------------------------
|
2000-09-18 16:15:01 +00:00
|
|
|
inline const String& SwAuthEntry::GetAuthorField(ToxAuthorityField ePos)const
|
|
|
|
{
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(AUTH_FIELD_END > ePos, "wrong index");
|
2001-02-14 09:43:38 +00:00
|
|
|
return aAuthFields[ePos];
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
inline void SwAuthEntry::SetAuthorField(ToxAuthorityField ePos, const String& rField)
|
|
|
|
{
|
2011-05-08 22:14:45 +02:00
|
|
|
OSL_ENSURE(AUTH_FIELD_END > ePos, "wrong index");
|
2000-09-18 16:15:01 +00:00
|
|
|
if(AUTH_FIELD_END > ePos)
|
|
|
|
aAuthFields[ePos] = rField;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:30:41 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|