diff options
author | Oliver Specht <os@openoffice.org> | 2000-11-16 11:30:48 +0000 |
---|---|---|
committer | Oliver Specht <os@openoffice.org> | 2000-11-16 11:30:48 +0000 |
commit | 8ff71b59a7f714835e1faa2781b34b4c5b811a84 (patch) | |
tree | d8364153d72d4059754f4b6e068a4382298a4582 /sw/source/core | |
parent | cfc62f2605ff3eb4f46f79691f7e52ddab29e04d (diff) |
TextField and FieldMaster 'Bibliography' completed
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/fields/authfld.cxx | 220 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 28 | ||||
-rw-r--r-- | sw/source/core/unocore/unofield.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/unocore/unoprnms.cxx | 12 |
4 files changed, 281 insertions, 12 deletions
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index 4c8f2df3a41e..31078a3f01ce 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -2,9 +2,9 @@ * * $RCSfile: authfld.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jp $ $Date: 2000-10-20 11:11:17 $ + * last change: $Author: os $ $Date: 2000-11-16 12:30:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -116,7 +116,17 @@ #ifndef _SV_SYSTEM_HXX #include <vcl/system.hxx> #endif +#ifndef _UNOPRNMS_HXX +#include <unoprnms.hxx> +#endif +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUES_HPP_ +#include <com/sun/star/beans/PropertyValues.hpp> +#endif +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace rtl; +#define C2U(cChar) rtl::OUString::createFromAscii(cChar) typedef SwAuthEntry* SwAuthEntryPtr; SV_DECL_PTRARR_DEL( SwAuthDataArr, SwAuthEntryPtr, 5, 5 ) SV_IMPL_PTRARR( SwAuthDataArr, SwAuthEntryPtr ) @@ -561,7 +571,115 @@ USHORT SwAuthorityFieldType::GetSequencePos(long nHandle) ASSERT(nRet, "Handle not found") return nRet; } +/* -----------------------------15.11.00 17:33-------------------------------- + ---------------------------------------------------------------------------*/ +BOOL SwAuthorityFieldType::QueryValue( Any& rVal, const String& rProperty ) const +{ + if(rProperty.EqualsAscii(UNO_NAME_BRACKET_BEFORE.pName, 0, UNO_NAME_BRACKET_BEFORE.nNameLen)) + { + OUString sVal(m_cPrefix); + rVal <<= sVal; + } + else if(rProperty.EqualsAscii(UNO_NAME_BRACKET_AFTER .pName, 0, UNO_NAME_BRACKET_AFTER .nNameLen)) + { + OUString sVal(m_cSuffix); + rVal <<= sVal; + } + else if(rProperty.EqualsAscii(UNO_NAME_IS_NUMBER_ENTRIES .pName, 0, UNO_NAME_IS_NUMBER_ENTRIES .nNameLen)) + { + sal_Bool bVal = m_bIsSequence; + rVal.setValue(&bVal, ::getBooleanCppuType()); + } + else if(rProperty.EqualsAscii(UNO_NAME_IS_SORT_BY_POSITION .pName, 0, UNO_NAME_IS_SORT_BY_POSITION.nNameLen)) + { + sal_Bool bVal = m_bSortByDocument; + rVal.setValue(&bVal, ::getBooleanCppuType()); + } + else if(rProperty.EqualsAscii(UNO_NAME_SORT_KEYS .pName, 0, UNO_NAME_SORT_KEYS .nNameLen)) + { + Sequence<PropertyValues> aRet(m_pSortKeyArr->Count()); + PropertyValues* pValues = aRet.getArray(); + for(sal_Int32 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 = C2U(UNO_NAME_SORT_KEY.pName); + pValue[0].Value <<= sal_Int16(pKey->eField); + pValue[1].Name = C2U(UNO_NAME_IS_SORT_ASCENDING.pName); + pValue[1].Value.setValue(&pKey->bSortAscending, ::getBooleanCppuType()); + } + rVal <<= aRet; + } + else + return FALSE; + return TRUE; +} +/* -----------------------------15.11.00 17:33-------------------------------- + + ---------------------------------------------------------------------------*/ +BOOL SwAuthorityFieldType::PutValue( const Any& rVal, const String& rProperty ) +{ + sal_Bool bRet = TRUE; + if(rProperty.EqualsAscii(UNO_NAME_BRACKET_BEFORE.pName, 0, UNO_NAME_BRACKET_BEFORE.nNameLen)) + { + OUString sVal; rVal >>= sVal; + if(sVal.getLength()) + m_cPrefix = sVal[0]; + } + else if(rProperty.EqualsAscii(UNO_NAME_BRACKET_AFTER .pName, 0, UNO_NAME_BRACKET_AFTER .nNameLen)) + { + OUString sVal; rVal >>= sVal; + if(sVal.getLength()) + m_cSuffix = sVal[0]; + } + else if(rProperty.EqualsAscii(UNO_NAME_IS_NUMBER_ENTRIES .pName, 0, UNO_NAME_IS_NUMBER_ENTRIES .nNameLen)) + { + sal_Bool bValue = *(sal_Bool*)rVal.getValue(); + m_bIsSequence = bValue; + + } + else if(rProperty.EqualsAscii(UNO_NAME_IS_SORT_BY_POSITION .pName, 0, UNO_NAME_IS_SORT_BY_POSITION.nNameLen)) + { + sal_Bool bValue = *(sal_Bool*)rVal.getValue(); + m_bSortByDocument = bValue; + } + else if(rProperty.EqualsAscii(UNO_NAME_SORT_KEYS .pName, 0, UNO_NAME_SORT_KEYS .nNameLen)) + { + Sequence<PropertyValues> aSeq; + bRet = rVal >>= aSeq; + if(bRet) + { + const PropertyValues* pValues = aSeq.getConstArray(); + for(sal_Int32 i = 0; i < aSeq.getLength() && i < USHRT_MAX / 4; i++) + { + m_pSortKeyArr->DeleteAndDestroy(0, m_pSortKeyArr->Count()); + const PropertyValue* pValue = pValues[i].getConstArray(); + SwTOXSortKey* pSortKey = new SwTOXSortKey; + for(sal_Int32 j = 0; j < pValues[i].getLength(); i++) + { + if(pValue[i].Name.equalsAsciiL(UNO_NAME_SORT_KEY.pName, UNO_NAME_SORT_KEY.nNameLen)) + { + sal_Int16 nVal = -1; pValue[i].Value >>= nVal; + if(nVal >= 0 && nVal < AUTH_FIELD_END) + pSortKey->eField = (ToxAuthorityField) nVal; + else + bRet = FALSE; + } + else if(pValue[i].Name.equalsAsciiL(UNO_NAME_IS_SORT_ASCENDING.pName, UNO_NAME_IS_SORT_ASCENDING.nNameLen)) + { + pSortKey->bSortAscending = *(sal_Bool*)pValue[i].Value.getValue(); + } + } + m_pSortKeyArr->Insert(pSortKey, m_pSortKeyArr->Count()); + } + } + } + else + bRet = FALSE; + return bRet; +} /* -----------------19.10.99 13:25------------------- --------------------------------------------------*/ @@ -684,8 +802,106 @@ USHORT SwAuthorityField::GetHandlePosition() const DBG_ASSERT(pAuthType, "no field type") return pAuthType->GetPosition(nHandle); } +/* -----------------------------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-------------------------------- + + ---------------------------------------------------------------------------*/ +BOOL SwAuthorityField::QueryValue( Any& rVal, const String& rProperty ) const +{ + 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); + pValues[i].Value <<= OUString(rField); + } + rVal <<= aRet; + return FALSE; +} +/* -----------------------------15.11.00 17:33-------------------------------- + ---------------------------------------------------------------------------*/ +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; +} +//---------------------------------------------------------------------------- +BOOL SwAuthorityField::PutValue( const Any& rVal, const String& rProperty ) +{ + if(!GetTyp() || !((SwAuthorityFieldType*)GetTyp())->GetEntryByHandle(nHandle)) + return FALSE; + + Sequence <PropertyValue> aParam; + if(!(rVal >>= aParam)) + return FALSE; + 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; + pParam[i].Value >>= sContent; + sToSet.SetToken(nFound, TOX_STYLE_DELIMITER, sContent); + } + } + + ((SwAuthorityFieldType*)GetTyp())->RemoveField(nHandle); + ((SwAuthorityFieldType*)GetTyp())->AddField(sToSet); + + return FALSE; +} +/* -----------------11.10.99 09:43------------------- + + --------------------------------------------------*/ SwFieldType* SwAuthorityField::ChgTyp( SwFieldType* pFldTyp ) { SwAuthorityFieldType* pSrcTyp = (SwAuthorityFieldType*)GetTyp(), diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 6ed27f076673..d454567c990f 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unocoll.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: os $ $Date: 2000-11-09 10:43:36 $ + * last change: $Author: os $ $Date: 2000-11-16 12:29:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,6 +158,9 @@ #ifndef _SV_SVAPP_HXX //autogen #include <vcl/svapp.hxx> #endif +#ifndef _AUTHFLD_HXX +#include <authfld.hxx> +#endif using namespace ::rtl; using namespace ::com::sun::star; @@ -256,7 +259,7 @@ const char* __FAR_DATA aProvNames[] = "com.sun.star.text.FieldMaster.DDE",//SW_SERVICE_FIELDMASTER_DDE "com.sun.star.text.FieldMaster.SetExpression",//SW_SERVICE_FIELDMASTER_SET_EXP "com.sun.star.text.FieldMaster.Database",//SW_SERVICE_FIELDMASTER_DATABASE - "",//SW_SERVICE_FIELDMASTER_DUMMY1 + "com.sun.star.text.FieldMaster.Bibliography",//SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY "",//SW_SERVICE_FIELDMASTER_DUMMY2 "",//SW_SERVICE_FIELDMASTER_DUMMY3 "",//SW_SERVICE_FIELDMASTER_DUMMY4 @@ -523,6 +526,25 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 xRet = (cppu::OWeakObject*)new SwXFieldMaster(pDoc, nResId); } break; + case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY: + { + SwFieldType* pType = pDoc->GetFldType(RES_AUTHORITY, aEmptyStr); + if(!pType) + { + SwAuthorityFieldType aType(pDoc); + pType = pDoc->InsertFldType(aType); + } + else + { + SwClientIter aIter( *pType ); + SwXFieldMaster* pMaster = (SwXFieldMaster*)aIter.First( TYPE( SwXFieldMaster )); + if(pMaster) + xRet = (cppu::OWeakObject*)pMaster; + } + if(!xRet.is()) + xRet = (cppu::OWeakObject*)new SwXFieldMaster(*pType, pDoc); + } + break; case SW_SERVICE_PARAGRAPH : xRet = (cppu::OWeakObject*)new SwXParagraph(); break; diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 7e377e731647..efa415bec2a4 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unofield.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: os $ $Date: 2000-11-10 13:49:21 $ + * last change: $Author: os $ $Date: 2000-11-16 12:29:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -797,7 +797,6 @@ const SfxItemPropertyMap* SwFieldPropMapProvider::GetPropertyMap(USHORT nService pRet = aDBFieldTypePropMap; } break; - case SW_SERVICE_FIELDMASTER_DUMMY1 : case SW_SERVICE_FIELDMASTER_DUMMY2 : case SW_SERVICE_FIELDMASTER_DUMMY3 : case SW_SERVICE_FIELDMASTER_DUMMY4 : @@ -820,11 +819,34 @@ const SfxItemPropertyMap* SwFieldPropMapProvider::GetPropertyMap(USHORT nService { static SfxItemPropertyMap aBibliographyFieldMap[] = { +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) + {SW_PROP_NAME(UNO_NAME_FIELDS ) , 0, new uno::Type(::getCppuType((Sequence<PropertyValue>*)0)),PROPERTY_NONE, 0}, +#else + {SW_PROP_NAME(UNO_NAME_FIELDS ) , 0, &::getCppuType((Sequence<PropertyValue>*)0),PROPERTY_NONE, 0}, +#endif {0,0,0,0} }; pRet = aBibliographyFieldMap; } break; + case SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY: + { + static SfxItemPropertyMap aBibliographyFieldMasterMap[] = + { + {SW_PROP_NAME(UNO_NAME_BRACKET_BEFORE ) , 0, &::getCppuType((OUString*)0), PROPERTY_NONE, 0}, + {SW_PROP_NAME(UNO_NAME_BRACKET_AFTER ) , 0, &::getCppuType((OUString*)0), PROPERTY_NONE, 0}, + {SW_PROP_NAME(UNO_NAME_IS_NUMBER_ENTRIES ) , 0, &::getBooleanCppuType(), PROPERTY_NONE, 0}, + {SW_PROP_NAME(UNO_NAME_IS_SORT_BY_POSITION) , 0, &::getBooleanCppuType(), PROPERTY_NONE, 0}, +#if (defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)) || (defined(__GNUC__) && defined(__APPLE__)) + {SW_PROP_NAME(UNO_NAME_SORT_KEYS ) , 0, new uno::Type(::getCppuType((Sequence<PropertyValues>*)0)),PROPERTY_NONE, 0}, +#else + {SW_PROP_NAME(UNO_NAME_SORT_KEYS ) , 0, &::getCppuType((Sequence<PropertyValues>*)0),PROPERTY_NONE, 0}, +#endif + {0,0,0,0} + }; + pRet = aBibliographyFieldMasterMap; + } + break; } DBG_ASSERT(pRet, "illegal service id") return pRet; @@ -998,7 +1020,6 @@ SwXFieldMaster::SwXFieldMaster(SwDoc* pDoc, sal_uInt16 nResId) : bParam1(FALSE), nParam1(-1) { - } /*-- 14.12.98 11:08:33--------------------------------------------------- @@ -1029,7 +1050,7 @@ uno::Reference< XPropertySetInfo > SwXFieldMaster::getPropertySetInfo(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - const SfxItemPropertyMap* pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_DUMMY1); + const SfxItemPropertyMap* pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_DUMMY2); if(nResTypeId == RES_USERFLD) pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_USER); else if(nResTypeId == RES_DBFLD) @@ -1038,6 +1059,8 @@ uno::Reference< XPropertySetInfo > SwXFieldMaster::getPropertySetInfo(void) pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_SET_EXP); else if(nResTypeId == RES_DDEFLD) pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_DDE); + else if(nResTypeId == RES_AUTHORITY) + pCreate = SwFieldPropMapProvider::GetPropertyMap(SW_SERVICE_FIELDMASTER_BIBLIOGRAPHY); uno::Reference< XPropertySetInfo > aRef = new SfxItemPropertySetInfo(pCreate); return aRef; } diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index 7b05947564a6..731da8c585cf 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unoprnms.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: os $ $Date: 2000-11-15 15:00:48 $ + * last change: $Author: os $ $Date: 2000-11-16 12:29:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -592,4 +592,12 @@ const SwPropNameLen __FAR_DATA UNO_NAME_ENDNOTE_NUMBERING_TYPE (MAP const SwPropNameLen __FAR_DATA UNO_NAME_ENDNOTE_NUMBERING_PREFIX (MAP_CHAR_LEN("EndnoteNumberingPrefix")); const SwPropNameLen __FAR_DATA UNO_NAME_ENDNOTE_NUMBERING_SUFFIX (MAP_CHAR_LEN("EndnoteNumberingSuffix")); +const SwPropNameLen __FAR_DATA UNO_NAME_BRACKET_BEFORE (MAP_CHAR_LEN("BracketBefore")); +const SwPropNameLen __FAR_DATA UNO_NAME_BRACKET_AFTER (MAP_CHAR_LEN("BracketAfter")); +const SwPropNameLen __FAR_DATA UNO_NAME_IS_NUMBER_ENTRIES (MAP_CHAR_LEN("IsNumberEntries")); +const SwPropNameLen __FAR_DATA UNO_NAME_IS_SORT_BY_POSITION (MAP_CHAR_LEN("IsSortByPosition")); +const SwPropNameLen __FAR_DATA UNO_NAME_SORT_KEYS (MAP_CHAR_LEN("SortKeys")); +const SwPropNameLen __FAR_DATA UNO_NAME_IS_SORT_ASCENDING (MAP_CHAR_LEN("IsSortAscending")); +const SwPropNameLen __FAR_DATA UNO_NAME_SORT_KEY (MAP_CHAR_LEN("SortKey")); +const SwPropNameLen __FAR_DATA UNO_NAME_FIELDS (MAP_CHAR_LEN("Fields")); |