summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/calc.hxx17
-rw-r--r--sw/source/core/bastyp/calc.cxx97
-rw-r--r--sw/source/ui/fldui/fldvar.cxx161
-rw-r--r--sw/source/ui/frmdlg/cption.cxx27
4 files changed, 177 insertions, 125 deletions
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 8bc3bd350bd7..f6834e79b5b7 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: calc.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: jp $ $Date: 2000-11-21 14:22:40 $
+ * last change: $Author: jp $ $Date: 2001-02-13 20:31:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -253,11 +253,14 @@ public:
void SetCalcError( SwCalcError eErr ) { eError = eErr; }
BOOL IsCalcError() const { return eError; }
- static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
- double& rVal,
- const LocaleDataWrapper* pData = 0 );
- static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
- double& rVal, SwDoc* pDoc );
+ static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
+ double& rVal,
+ const LocaleDataWrapper* pData = 0 );
+ static FASTBOOL Str2Double( const String& rStr, xub_StrLen& rPos,
+ double& rVal, SwDoc* pDoc );
+
+ static FASTBOOL IsValidVarName( const String& rStr,
+ String* pValidName = 0 );
};
#endif
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 057ba9396c8b..2cfc896d2ffc 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: calc.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: jp $ $Date: 2001-02-09 14:50:49 $
+ * last change: $Author: jp $ $Date: 2001-02-13 20:32:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -225,6 +225,18 @@ double __READONLY_DATA nKorrVal[] = {
9e-9, 9e-10, 9e-11, 9e-12, 9e-13, 9e-14
};
+ // First character may be any alphabetic or underscore.
+const sal_Int32 coStartFlags =
+ ::com::sun::star::i18n::KParseTokens::ANY_LETTER_OR_NUMBER |
+ ::com::sun::star::i18n::KParseTokens::ASC_UNDERSCORE |
+ ::com::sun::star::i18n::KParseTokens::IGNORE_LEADING_WS;
+
+ // Continuing characters may be any alphanumeric or underscore or dot.
+const sal_Int32 coContFlags =
+ ( coStartFlags | ::com::sun::star::i18n::KParseTokens::ASC_DOT )
+ & ~::com::sun::star::i18n::KParseTokens::IGNORE_LEADING_WS;
+
+
extern "C" {
static int
#if defined( WNT )
@@ -798,36 +810,28 @@ if( !nUseOld )
using namespace ::com::sun::star::i18n;
{
- // First character may be any alphabetic or underscore.
- sal_Int32 nStartFlags = KParseTokens::ANY_LETTER_OR_NUMBER |
- KParseTokens::ASC_UNDERSCORE |
- KParseTokens::IGNORE_LEADING_WS;
- // Continuing characters may be any alphanumeric or underscore or dot.
- sal_Int32 nContFlags = ( nStartFlags | KParseTokens::ASC_DOT )
- & ~KParseTokens::IGNORE_LEADING_WS;
-
// Parse any token.
- ParseResult rRes = pCharClass->parseAnyToken( sCommand, nCommandPos,
- nStartFlags, aEmptyStr,
- nContFlags, aEmptyStr );
+ ParseResult aRes = pCharClass->parseAnyToken( sCommand, nCommandPos,
+ coStartFlags, aEmptyStr,
+ coContFlags, aEmptyStr );
BOOL bSetError = TRUE;
- xub_StrLen nRealStt = nCommandPos + (xub_StrLen)rRes.LeadingWhiteSpace;
- if( rRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER) )
+ xub_StrLen nRealStt = nCommandPos + (xub_StrLen)aRes.LeadingWhiteSpace;
+ if( aRes.TokenType & (KParseType::ASC_NUMBER | KParseType::UNI_NUMBER) )
{
- nNumberValue.PutDouble( rRes.Value );
+ nNumberValue.PutDouble( aRes.Value );
eCurrOper = CALC_NUMBER;
bSetError = FALSE;
}
- else if( rRes.TokenType & KParseType::IDENTNAME )
+ else if( aRes.TokenType & KParseType::IDENTNAME )
{
- String aName( sCommand.Copy( nRealStt, rRes.EndPos - nRealStt ));
+ String aName( sCommand.Copy( nRealStt, aRes.EndPos - nRealStt ));
pCharClass->toLower( aName );
// Currency-Symbol abfangen
if( aName == sCurrSym )
{
- nCommandPos = (xub_StrLen)rRes.EndPos;
+ nCommandPos = (xub_StrLen)aRes.EndPos;
return GetToken(); // also nochmal aufrufen
}
@@ -842,22 +846,22 @@ if( !nUseOld )
case CALC_MIN : eCurrListOper = CALC_MIN_IN; break;
case CALC_MAX : eCurrListOper = CALC_MAX_IN; break;
}
- nCommandPos = (xub_StrLen)rRes.EndPos;
+ nCommandPos = (xub_StrLen)aRes.EndPos;
return eCurrOper;
}
aVarName = aName;
eCurrOper = CALC_NAME;
bSetError = FALSE;
}
- else if ( rRes.TokenType & KParseType::DOUBLE_QUOTE_STRING )
+ else if ( aRes.TokenType & KParseType::DOUBLE_QUOTE_STRING )
{
- nNumberValue.PutString( String( rRes.DequotedNameOrString ));
+ nNumberValue.PutString( String( aRes.DequotedNameOrString ));
eCurrOper = CALC_NUMBER;
bSetError = FALSE;
}
- else if( rRes.TokenType & KParseType::ONE_SINGLE_CHAR )
+ else if( aRes.TokenType & KParseType::ONE_SINGLE_CHAR )
{
- String aName( sCommand.Copy( nRealStt, rRes.EndPos - nRealStt ));
+ String aName( sCommand.Copy( nRealStt, aRes.EndPos - nRealStt ));
if( 1 == aName.Len() )
{
bSetError = FALSE;
@@ -887,11 +891,11 @@ if( !nUseOld )
else
eCurrOper = CALC_NOT, eTmp2 = CALC_NEQ;
- if( rRes.EndPos < sCommand.Len() &&
- '=' == sCommand.GetChar( (xub_StrLen)rRes.EndPos ) )
+ if( aRes.EndPos < sCommand.Len() &&
+ '=' == sCommand.GetChar( (xub_StrLen)aRes.EndPos ) )
{
eCurrOper = eTmp2;
- ++rRes.EndPos;
+ ++aRes.EndPos;
}
}
break;
@@ -901,10 +905,10 @@ if( !nUseOld )
break;
case '[':
- if( rRes.EndPos < sCommand.Len() )
+ if( aRes.EndPos < sCommand.Len() )
{
aVarName.Erase();
- xub_StrLen nFndPos = (xub_StrLen)rRes.EndPos,
+ xub_StrLen nFndPos = (xub_StrLen)aRes.EndPos,
nSttPos = nFndPos;
do{
@@ -928,7 +932,7 @@ if( !nUseOld )
if( nSttPos != nFndPos )
aVarName += sCommand.Copy( nSttPos,
nFndPos - nSttPos );
- rRes.EndPos = nFndPos + 1;
+ aRes.EndPos = nFndPos + 1;
eCurrOper = CALC_NAME;
}
else
@@ -944,9 +948,9 @@ if( !nUseOld )
}
}
}
- else if( rRes.TokenType & KParseType::BOOLEAN )
+ else if( aRes.TokenType & KParseType::BOOLEAN )
{
- String aName( sCommand.Copy( nRealStt, rRes.EndPos - nRealStt ));
+ String aName( sCommand.Copy( nRealStt, aRes.EndPos - nRealStt ));
if( aName.Len() )
{
bSetError = FALSE;
@@ -979,7 +983,7 @@ if( !nUseOld )
eError = CALC_SYNTAX;
eCurrOper = CALC_PRINT;
}
- nCommandPos = (xub_StrLen)rRes.EndPos;
+ nCommandPos = (xub_StrLen)aRes.EndPos;
};
#ifdef DEBUG
@@ -1646,6 +1650,33 @@ FASTBOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos,
return 0 == nErrno && nCurrCmdPos != rCommandPos;
}
+//------------------------------------------------------------------------------
+
+FASTBOOL SwCalc::IsValidVarName( const String& rStr,
+ String* pValidName )
+{
+ FASTBOOL bRet = FALSE;
+ using namespace ::com::sun::star::i18n;
+ {
+ // Parse any token.
+ ParseResult aRes = GetAppCharClass().parseAnyToken( rStr, 0,
+ coStartFlags, aEmptyStr,
+ coContFlags, aEmptyStr );
+
+ if( aRes.TokenType & KParseType::IDENTNAME )
+ {
+ bRet = aRes.EndPos == rStr.Len();
+ if( pValidName )
+ {
+ xub_StrLen nRealStt = (xub_StrLen)aRes.LeadingWhiteSpace;
+ *pValidName = rStr.Copy( nRealStt, aRes.EndPos - nRealStt );
+ }
+ }
+ else if( pValidName )
+ pValidName->Erase();
+ }
+ return bRet;
+}
//------------------------------------------------------------------------------
diff --git a/sw/source/ui/fldui/fldvar.cxx b/sw/source/ui/fldui/fldvar.cxx
index 4e8db6cf9e79..665438e52972 100644
--- a/sw/source/ui/fldui/fldvar.cxx
+++ b/sw/source/ui/fldui/fldvar.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fldvar.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: os $ $Date: 2001-02-09 07:44:09 $
+ * last change: $Author: jp $ $Date: 2001-02-13 20:30:37 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -106,6 +106,9 @@
#ifndef _FLDVAR_HXX
#include <fldvar.hxx>
#endif
+#ifndef _CALC_HXX
+#include <calc.hxx>
+#endif
#ifndef _GLOBALS_HRC
#include <globals.hrc>
@@ -235,8 +238,8 @@ void __EXPORT SwFldVarPage::Reset(const SfxItemSet& rSet)
if(!IsRefresh() && sUserData.GetToken(0, ';').EqualsIgnoreCaseAscii(USER_DATA_VERSION_1))
{
String sVal = sUserData.GetToken(1, ';');
- USHORT nVal = sVal.ToInt32();
- if(nVal != USHRT_MAX)
+ USHORT nVal = (USHORT)sVal.ToInt32();
+ if( USHRT_MAX != nVal )
{
for(USHORT i = 0; i < aTypeLB.GetEntryCount(); i++)
if(nVal == (USHORT)(ULONG)aTypeLB.GetEntryData(i))
@@ -911,102 +914,105 @@ IMPL_LINK( SwFldVarPage, ModifyHdl, Edit *, EMPTYARG )
USHORT nTypeId = (USHORT)(ULONG)aTypeLB.GetEntryData(GetTypeSel());
BOOL bInsert = FALSE, bApply = FALSE, bDelete = FALSE;
- String sName(aNameED.GetText());
- const USHORT nOldLen = sName.Len();
- Selection aSel(aNameED.GetSelection());
+ String sName( aNameED.GetText() );
+ xub_StrLen nLen = sName.Len();
- if( nTypeId == TYP_DDEFLD ||
- nTypeId == TYP_USERFLD ||
- nTypeId == TYP_SETFLD ||
- nTypeId == TYP_SEQFLD)
+ switch( nTypeId )
{
- sName.EraseAllChars(' ');
- sName.EraseAllChars('-');
+ case TYP_DDEFLD:
+ case TYP_USERFLD:
+ case TYP_SETFLD:
+ case TYP_SEQFLD:
+ SwCalc::IsValidVarName( sName, &sName );
+ if( sName.Len() != nLen )
+ {
+ nLen = sName.Len();
+ Selection aSel(aNameED.GetSelection());
+ aNameED.SetText( sName );
+ aNameED.SetSelection( aSel ); // Cursorpos restaurieren
+ }
+ break;
}
- const USHORT nLen = sName.Len();
- if (nOldLen != nLen)
- {
- aNameED.SetText(sName);
- aNameED.SetSelection(aSel); // Cursorpos restaurieren
- }
// Buttons ueberpruefen
switch (nTypeId)
{
- case TYP_DDEFLD:
- {
- // Gibts schon einen entsprechenden Type
- bInsert = bApply = sName.Len() > 0;
-
- SwFieldType* pType = GetFldMgr().GetFldType(RES_DDEFLD, sName);
+ case TYP_DDEFLD:
+ if( nLen )
+ {
+ // Gibts schon einen entsprechenden Type
+ bInsert = bApply = TRUE;
- if (pType)
- bDelete = !::GetActiveView()->GetWrtShell().IsUsed( *pType );
- }
- break;
+ SwFieldType* pType = GetFldMgr().GetFldType(RES_DDEFLD, sName);
- case TYP_USERFLD:
- {
- // Gibts schon einen entsprechenden Type
- SwFieldType* pType = GetFldMgr().GetFldType(RES_USERFLD, sName);
+ if (pType)
+ bDelete = !::GetActiveView()->GetWrtShell().IsUsed( *pType );
+ }
+ break;
- if (pType)
- bDelete = !::GetActiveView()->GetWrtShell().IsUsed( *pType );
+ case TYP_USERFLD:
+ if( nLen )
+ {
+ // Gibts schon einen entsprechenden Type
+ SwFieldType* pType = GetFldMgr().GetFldType(RES_USERFLD, sName);
- pType = GetFldMgr().GetFldType(RES_SETEXPFLD, sName);
- if (!pType) // Kein Namenskonflikt mit Variablen
- {
- // Benutzerfelder duerfen auch ohne Inhalt eingefuegt werden!
- // Bug #56845
- bInsert = bApply = sName.Len() > 0;
- }
- }
- break;
+ if (pType)
+ bDelete = !::GetActiveView()->GetWrtShell().IsUsed( *pType );
- default:
+ pType = GetFldMgr().GetFldType(RES_SETEXPFLD, sName);
+ if (!pType) // Kein Namenskonflikt mit Variablen
{
- bInsert = TRUE;
-
- if (nTypeId == TYP_SETFLD || nTypeId == TYP_SEQFLD)
- {
- SwSetExpFieldType* pFldType = (SwSetExpFieldType*)
- GetFldMgr().GetFldType(RES_SETEXPFLD, sName);
-
- if (pFldType)
- {
+ // Benutzerfelder duerfen auch ohne Inhalt eingefuegt werden!
+ // Bug #56845
+ bInsert = bApply = TRUE;
+ }
+ }
+ break;
- SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
- const SwFldTypes* p = rSh.GetDoc()->GetFldTypes();
- USHORT i;
+ default:
+ bInsert = TRUE;
- for (i = 0; i < INIT_FLDTYPES; i++)
- {
- SwFieldType* pType = (*p)[ i ];
- if (pType == pFldType)
- break;
- }
+ if (nTypeId == TYP_SETFLD || nTypeId == TYP_SEQFLD)
+ {
+ SwSetExpFieldType* pFldType = (SwSetExpFieldType*)
+ GetFldMgr().GetFldType(RES_SETEXPFLD, sName);
- if (i >= INIT_FLDTYPES && !rSh.IsUsed(*pFldType))
- bDelete = TRUE;
+ if (pFldType)
+ {
- if (nTypeId == TYP_SEQFLD && !(pFldType->GetType() & GSE_SEQ))
- bInsert = FALSE;
+ SwWrtShell &rSh = ::GetActiveView()->GetWrtShell();
+ const SwFldTypes* p = rSh.GetDoc()->GetFldTypes();
+ USHORT i;
- if (nTypeId == TYP_SETFLD && (pFldType->GetType() & GSE_SEQ))
- bInsert = FALSE;
- }
- if (GetFldMgr().GetFldType(RES_USERFLD, sName))
- bInsert = FALSE;
+ for (i = 0; i < INIT_FLDTYPES; i++)
+ {
+ SwFieldType* pType = (*p)[ i ];
+ if (pType == pFldType)
+ break;
}
- if (nLen == 0 && (nTypeId == TYP_SETFLD || (!IsFldEdit() && nTypeId == TYP_GETFLD)))
+ if (i >= INIT_FLDTYPES && !rSh.IsUsed(*pFldType))
+ bDelete = TRUE;
+
+ if (nTypeId == TYP_SEQFLD && !(pFldType->GetType() & GSE_SEQ))
bInsert = FALSE;
- if ((nTypeId == TYP_SETFLD || nTypeId == TYP_FORMELFLD) && !bHasValue)
+ if (nTypeId == TYP_SETFLD && (pFldType->GetType() & GSE_SEQ))
bInsert = FALSE;
}
- break;
+ if (GetFldMgr().GetFldType(RES_USERFLD, sName))
+ bInsert = FALSE;
+ }
+
+ if( !nLen && ( nTypeId == TYP_SETFLD ||
+ (!IsFldEdit() && nTypeId == TYP_GETFLD ) ) )
+ bInsert = FALSE;
+
+ if( (nTypeId == TYP_SETFLD || nTypeId == TYP_FORMELFLD) &&
+ !bHasValue )
+ bInsert = FALSE;
+ break;
}
aNewDelTBX.EnableItem(BT_VARAPPLY, bApply);
@@ -1384,13 +1390,16 @@ void SwFldVarPage::FillUserData()
if( LISTBOX_ENTRY_NOTFOUND == nTypeSel )
nTypeSel = USHRT_MAX;
else
- nTypeSel = (ULONG)aTypeLB.GetEntryData( nTypeSel );
+ nTypeSel = (USHORT)(ULONG)aTypeLB.GetEntryData( nTypeSel );
sData += String::CreateFromInt32( nTypeSel );
SetUserData(sData);
}
/*------------------------------------------------------------------------
$Log: not supported by cvs2svn $
+ Revision 1.2 2001/02/09 07:44:09 os
+ TabPage size changed
+
Revision 1.1.1.1 2000/09/18 17:14:37 hr
initial import
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index fbfcc4af463c..6b6922e3eaee 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: cption.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:14:37 $
+ * last change: $Author: jp $ $Date: 2001-02-13 20:28:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -89,12 +89,15 @@
#ifndef _POOLFMT_HXX
#include <poolfmt.hxx>
#endif
-#ifndef _SWDOCSH_HXX //autogen
+#ifndef _SWDOCSH_HXX
#include <docsh.hxx>
#endif
-#ifndef _FRMFMT_HXX //autogen
+#ifndef _FRMFMT_HXX
#include <frmfmt.hxx>
#endif
+#ifndef _CALC_HXX
+#include <calc.hxx>
+#endif
#ifndef _COM_SUN_STAR_FRAME_XSTORABLE_HPP_
#include <com/sun/star/frame/XStorable.hpp>
@@ -410,11 +413,14 @@ IMPL_LINK( SwCaptionDialog, ModifyHdl, Edit *, pEdit )
!xNameAccess.is() || !xNameAccess->hasByName(sNewName)));
SwWrtShell &rSh = rView.GetWrtShell();
String sFldTypeName = aCategoryBox.GetText();
- SwFieldType* pType = sFldTypeName.Len() ? rSh.GetFldType(RES_SETEXPFLD, sFldTypeName) : 0;
-
- aOKButton.Enable( bCorrectName &&
- (!pType || ((SwSetExpFieldType*)pType)->GetType() == GSE_SEQ)
- && sFldTypeName.Len() != 0 );
+ sal_Bool bCorrectFldName = SwCalc::IsValidVarName( sFldTypeName );
+ SwFieldType* pType = bCorrectFldName
+ ? rSh.GetFldType( RES_SETEXPFLD, sFldTypeName )
+ : 0;
+ aOKButton.Enable( bCorrectName && bCorrectFldName &&
+ (!pType ||
+ ((SwSetExpFieldType*)pType)->GetType() == GSE_SEQ)
+ && 0 != sFldTypeName.Len() );
aOptionButton.Enable( aOKButton.IsEnabled() );
if(pEdit != &aObjectNameED)
@@ -567,6 +573,9 @@ void SwSequenceOptionDialog::Apply()
/*-----------------25.02.94 21:56-------------------
$Log: not supported by cvs2svn $
+ Revision 1.1.1.1 2000/09/18 17:14:37 hr
+ initial import
+
Revision 1.74 2000/09/18 16:05:32 willem.vandorp
OpenOffice header added.