summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorOliver Specht <os@openoffice.org>2000-11-07 08:58:56 +0000
committerOliver Specht <os@openoffice.org>2000-11-07 08:58:56 +0000
commit20becce7800d426a1bca6c64a0dbb52c6ae0bdd9 (patch)
treee7839fe78797ed3d5f2ebf043bf74accf035de8c /sw/source/core
parentda72d9af1eefec13f12d61a469caeeaf9c04ddc6 (diff)
#76423# programmatic names for initially created sequence fields
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/unocore/unofield.cxx146
-rw-r--r--sw/source/core/unocore/unostyle.cxx27
2 files changed, 144 insertions, 29 deletions
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 9e0757d920f2..ade732534654 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.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: os $ $Date: 2000-10-27 13:01:41 $
+ * last change: $Author: os $ $Date: 2000-11-07 09:58:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -209,6 +209,9 @@
#ifndef _POOLFMT_HXX
#include <poolfmt.hxx>
#endif
+#ifndef _POOLFMT_HRC
+#include <poolfmt.hrc>
+#endif
#ifndef _PAGEDESC_HXX //autogen
#include <pagedesc.hxx>
#endif
@@ -1073,7 +1076,8 @@ void SwXFieldMaster::setPropertyValue(const OUString& rPropertyName, const uno::
aValue >>= uTmp;
String sTypeName(uTmp);
SwFieldType* pType = m_pDoc->GetFldType(nResTypeId, sTypeName);
- if(pType)
+ if(pType ||
+ (RES_SETEXPFLD == nResTypeId && sTypeName != String(SwXFieldMaster::GetSetExpProgrammaticName(sTypeName))))
{
throw IllegalArgumentException();
}
@@ -1218,7 +1222,9 @@ uno::Any SwXFieldMaster::getPropertyValue(const OUString& rPropertyName)
if(pType)
{
if(COMPARE_EQUAL == rPropertyName.compareToAscii("Name"))
- aRet <<= OUString(pType->GetName());
+ {
+ aRet <<= OUString(SwXFieldMaster::GetProgrammaticName(*pType, *GetDoc()));
+ }
else if(COMPARE_EQUAL == rPropertyName.compareToAscii(UNO_NAME_DEPENDENT_TEXT_FIELDS))
{
//fill all text fields into a sequence
@@ -1364,6 +1370,116 @@ void SwXFieldMaster::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
m_pDoc = 0;
}
}
+/* -----------------------------06.11.00 09:44--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Programmatic2UIName_Impl* lcl_GetFieldNameTable()
+{
+ static BOOL bInitialized = FALSE;
+ static Programmatic2UIName_Impl aFieldNames[5];
+ if(!bInitialized)
+ {
+ bInitialized = TRUE;
+ int nName = 0;
+ aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_ABB ));
+ aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_ABB));
+ aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_TABLE ));
+ aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_TABLE));
+ aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_FRAME));
+ aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_FRAME));
+ aFieldNames[nName].sUIName = String (SW_RES(STR_POOLCOLL_LABEL_DRAWING ));
+ aFieldNames[nName++].sProgrammaticName = String (SW_RES(STR_POCO_PRGM_LABEL_DRAWING));
+ }
+ return &aFieldNames[0];
+}
+/* -----------------------------06.11.00 10:26--------------------------------
+
+ ---------------------------------------------------------------------------*/
+OUString SwXFieldMaster::GetProgrammaticName(const SwFieldType& rType, SwDoc& rDoc)
+{
+ OUString sRet(rType.GetName());
+ if(RES_SETEXPFLD == rType.Which())
+ {
+ const SwFldTypes* pTypes = rDoc.GetFldTypes();
+ for( sal_uInt16 i = 0; i <= INIT_FLDTYPES; i++ )
+ {
+ if((*pTypes)[i] == &rType)
+ {
+ const Programmatic2UIName_Impl* pTable = lcl_GetFieldNameTable();
+ while(pTable->sUIName.Len())
+ {
+ if(sRet == OUString(pTable->sUIName))
+ {
+ sRet = pTable->sProgrammaticName;
+ break;
+ }
+ ++pTable;
+ }
+ break;
+ }
+ }
+ }
+ return sRet;
+}
+/* -----------------------------06.11.00 10:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+OUString SwXFieldMaster::GetSetExpProgrammaticName(const OUString& rUIName)
+{
+ const Programmatic2UIName_Impl* pTable = lcl_GetFieldNameTable();
+ OUString sRet(rUIName);
+ while(pTable->sUIName.Len())
+ {
+ if(sRet == OUString(pTable->sUIName))
+ {
+ sRet = pTable->sProgrammaticName;
+ break;
+ }
+ ++pTable;
+ }
+ return sRet;
+}
+/* -----------------------------06.11.00 10:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+OUString SwXFieldMaster::GetSetExpUIName(const rtl::OUString& rName)
+{
+ const Programmatic2UIName_Impl* pTable = lcl_GetFieldNameTable();
+ OUString sRet(rName);
+ while(pTable->sUIName.Len())
+ {
+ if(sRet == OUString(pTable->sProgrammaticName))
+ {
+ sRet = pTable->sUIName;
+ break;
+ }
+ ++pTable;
+ }
+ return sRet;
+}
+/* -----------------------------06.11.00 14:12--------------------------------
+
+ ---------------------------------------------------------------------------*/
+OUString SwXFieldMaster::LocalizeFormula(
+ const SwSetExpField& rFld,
+ const OUString& rFormula,
+ sal_Bool bQuery)
+{
+ OUString sTypeName(rFld.GetTyp()->GetName());
+ OUString sProgName = SwXFieldMaster::GetSetExpProgrammaticName(sTypeName);
+ if(sProgName != sTypeName)
+ {
+ OUString sSource = bQuery ? sTypeName : sProgName;
+ OUString sDest = bQuery ? sProgName : sTypeName;
+ if(!rFormula.compareTo(sSource, sSource.getLength()))
+ {
+ OUString sTmpFormula = sDest;
+ sTmpFormula += rFormula.copy(sSource.getLength());
+ return sTmpFormula;
+ }
+ }
+ return rFormula;
+}
/******************************************************************
*
******************************************************************/
@@ -1400,13 +1516,6 @@ struct SwFieldProperties_Impl
};
TYPEINIT1(SwXTextField, SwClient);
-/*-- 14.12.98 11:37:14---------------------------------------------------
-
- -----------------------------------------------------------------------*/
-/*uno::Reference< uno::XInterface > SwXTextField_NewInstance_Impl()
-{
- return (UsrObject *)new SwXTextField(USHRT_MAX);
-};
/* -----------------------------13.03.00 12:15--------------------------------
---------------------------------------------------------------------------*/
@@ -2526,7 +2635,13 @@ uno::Any SwXTextFieldMasters::getByName(const OUString& rName)
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("DDE"))
nResId = RES_DDEFLD;
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("SetExpression"))
+ {
nResId = RES_SETEXPFLD;
+ OUString sTypeName(sName.GetToken(1, '.'));
+ OUString sUIName = SwXFieldMaster::GetSetExpUIName(sTypeName);
+ if(sUIName != sTypeName)
+ sName.SetToken(1, '.', sUIName);
+ }
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("DataBase"))
{
if(!lcl_ConvertDatabaseName(sName))
@@ -2585,7 +2700,7 @@ uno::Sequence< OUString > SwXTextFieldMasters::getElementNames(void)
{
String* pString = new String(sPrefix);
*pString += C2S("SetExpression.");
- *pString += rFldType.GetName();
+ *pString += String(SwXFieldMaster::GetSetExpProgrammaticName(rFldType.GetName()));
aFldNames.Insert(pString, aFldNames.Count());
}
if(RES_DBFLD == nWhich)
@@ -2630,7 +2745,13 @@ sal_Bool SwXTextFieldMasters::hasByName(const OUString& rName) throw( RuntimeExc
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("DDE"))
nResId = RES_DDEFLD;
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("SetExpression"))
+ {
nResId = RES_SETEXPFLD;
+ OUString sTypeName(sName.GetToken(1, '.'));
+ OUString sUIName = SwXFieldMaster::GetSetExpUIName(sTypeName);
+ if(sUIName != sTypeName)
+ sName.SetToken(1, '.', sUIName);
+ }
else if(COMPARE_EQUAL == sTypeName.CompareToAscii("DataBase"))
{
if(!lcl_ConvertDatabaseName(sName))
@@ -2924,4 +3045,3 @@ void SwXFieldEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew)
pDoc = 0;
}
-
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 437c0ec3c741..8ed8f6286919 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unostyle.cxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jp $ $Date: 2000-11-01 10:14:03 $
+ * last change: $Author: os $ $Date: 2000-11-07 09:58:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -252,20 +252,15 @@ const unsigned short aStyleByIndex[] =
SFX_STYLE_FAMILY_PSEUDO
};
-struct Programmatic2UIName
+const Programmatic2UIName_Impl* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
{
- String sProgrammaticName;
- String sUIName;
-};
-const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
-{
- const Programmatic2UIName* pRet = 0;
+ const Programmatic2UIName_Impl* pRet = 0;
switch(eFamily)
{
case SFX_STYLE_FAMILY_CHAR:
{
static BOOL bInitialized = FALSE;
- static Programmatic2UIName aCharFamilyNames[(STR_POOLCHR_PRGM_CURRENT_END - RC_POOLCHRFMT_PRGM_BEGIN) +
+ static Programmatic2UIName_Impl aCharFamilyNames[(STR_POOLCHR_PRGM_CURRENT_END - RC_POOLCHRFMT_PRGM_BEGIN) +
(STR_POOLCHR_PRGM_HTML_CURRENT_END - RC_POOLCHRFMT_PRGM_HTML_BEGIN) + 3];
if(!bInitialized)
{
@@ -292,7 +287,7 @@ const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
case SFX_STYLE_FAMILY_PARA:
{
static BOOL bInitialized = FALSE;
- static Programmatic2UIName aParaFamilyNames[
+ static Programmatic2UIName_Impl aParaFamilyNames[
( STR_POCO_PRGM_HEADLINE10 - STR_POCO_PRGM_STANDARD ) +
( STR_POCO_PRGM_BUL_NONUM5 - STR_POCO_PRGM_NUMBUL_BASE )+
( STR_POCO_PRGM_LABEL_DRAWING - STR_POCO_PRGM_HEADER )+
@@ -335,7 +330,7 @@ const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
case SFX_STYLE_FAMILY_FRAME:
{
static BOOL bInitialized = FALSE;
- static Programmatic2UIName aFrameFamilyNames[(STR_POOLFRM_PRGM_LABEL - STR_POOLFRM_PRGM_FRAME) + 2];
+ static Programmatic2UIName_Impl aFrameFamilyNames[(STR_POOLFRM_PRGM_LABEL - STR_POOLFRM_PRGM_FRAME) + 2];
if(!bInitialized)
{
bInitialized = TRUE;
@@ -355,7 +350,7 @@ const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
case SFX_STYLE_FAMILY_PAGE:
{
static BOOL bInitialized = FALSE;
- static Programmatic2UIName aPageFamilyNames[(STR_POOLPAGE_PRGM_ENDNOTE - STR_POOLPAGE_PRGM_STANDARD) + 2];
+ static Programmatic2UIName_Impl aPageFamilyNames[(STR_POOLPAGE_PRGM_ENDNOTE - STR_POOLPAGE_PRGM_STANDARD) + 2];
if(!bInitialized)
{
bInitialized = TRUE;
@@ -375,7 +370,7 @@ const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
case SFX_STYLE_FAMILY_PSEUDO:
{
static BOOL bInitialized = FALSE;
- static Programmatic2UIName aNumFamilyNames[(STR_POOLNUMRULE_PRGM_BUL5 - STR_POOLNUMRULE_PRGM_NUM1) + 2];
+ static Programmatic2UIName_Impl aNumFamilyNames[(STR_POOLNUMRULE_PRGM_BUL5 - STR_POOLNUMRULE_PRGM_NUM1) + 2];
if(!bInitialized)
{
bInitialized = TRUE;
@@ -397,7 +392,7 @@ const Programmatic2UIName* lcl_GetStyleNameTable(SfxStyleFamily eFamily)
}
const String& SwXStyleFamilies::GetProgrammaticName(const String& rUIName, SfxStyleFamily eFamily)
{
- const Programmatic2UIName* pNames =lcl_GetStyleNameTable(eFamily);
+ const Programmatic2UIName_Impl* pNames =lcl_GetStyleNameTable(eFamily);
DBG_ASSERT(pNames, "no mapping found!!!")
if(pNames)
do
@@ -410,7 +405,7 @@ const String& SwXStyleFamilies::GetProgrammaticName(const String& rUIName, Sfx
}
const String& SwXStyleFamilies::GetUIName(const String& rProgrammaticName, SfxStyleFamily eFamily)
{
- const Programmatic2UIName* pNames = lcl_GetStyleNameTable(eFamily);
+ const Programmatic2UIName_Impl* pNames = lcl_GetStyleNameTable(eFamily);
do
{
if(pNames->sProgrammaticName == rProgrammaticName)