summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basctl/source/basicide/baside2b.cxx29
-rw-r--r--basctl/source/basicide/basidesh.cxx8
-rw-r--r--basic/inc/basic/basmgr.hxx40
-rw-r--r--basic/inc/basic/modsizeexceeded.hxx2
-rw-r--r--basic/inc/basic/sbdef.hxx8
-rw-r--r--basic/inc/basic/sbmeth.hxx20
-rw-r--r--basic/inc/basic/sbmod.hxx34
-rw-r--r--basic/inc/basic/sbstar.hxx6
-rw-r--r--basic/inc/basic/sbx.hxx6
-rw-r--r--basic/inc/basic/sbxbase.hxx2
-rw-r--r--basic/inc/basic/sbxcore.hxx16
-rw-r--r--basic/inc/basic/sbxprop.hxx2
-rw-r--r--basic/inc/basic/sbxvar.hxx6
-rw-r--r--basic/source/basmgr/basmgr.cxx4
-rw-r--r--basic/source/classes/errobject.cxx2
-rw-r--r--basic/source/classes/image.cxx54
-rw-r--r--basic/source/classes/sb.cxx9
-rw-r--r--basic/source/classes/sbunoobj.cxx83
-rw-r--r--basic/source/classes/sbxmod.cxx41
-rw-r--r--basic/source/comp/codegen.cxx42
-rw-r--r--basic/source/comp/dim.cxx118
-rw-r--r--basic/source/comp/exprgen.cxx42
-rw-r--r--basic/source/comp/exprtree.cxx221
-rw-r--r--basic/source/comp/loops.cxx20
-rw-r--r--basic/source/comp/parser.cxx16
-rw-r--r--basic/source/comp/sbcomp.cxx86
-rw-r--r--basic/source/comp/symtbl.cxx35
-rw-r--r--basic/source/comp/token.cxx120
-rw-r--r--basic/source/runtime/iosys.cxx153
-rw-r--r--basic/source/runtime/methods.cxx465
-rw-r--r--basic/source/runtime/methods1.cxx669
-rw-r--r--basic/source/runtime/sbdiagnose.cxx4
-rw-r--r--basic/source/runtime/stdobj.cxx4
-rw-r--r--basic/source/runtime/step0.cxx156
-rw-r--r--basic/source/runtime/step2.cxx9
-rw-r--r--basic/source/sbx/sbxarray.cxx18
-rw-r--r--basic/source/sbx/sbxcoll.cxx20
-rw-r--r--basic/source/sbx/sbxexec.cxx14
-rw-r--r--basic/source/sbx/sbxform.cxx10
-rw-r--r--basic/source/sbx/sbxobj.cxx165
-rw-r--r--basic/source/sbx/sbxscan.cxx6
-rw-r--r--basic/source/sbx/sbxvalue.cxx9
-rw-r--r--basic/source/sbx/sbxvar.cxx76
-rw-r--r--basic/source/uno/namecont.cxx579
-rw-r--r--basic/source/uno/scriptcont.cxx250
-rw-r--r--sc/source/core/tool/interpr4.cxx45
46 files changed, 2669 insertions, 1055 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 2986b82e530b..8fdf123d3c60 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1568,21 +1568,29 @@ void StackWindow::UpdateCalls()
SbxVariable* pVar = pParams->Get( nParam );
DBG_ASSERT( pVar, "Parameter?!" );
if ( pVar->GetName().Len() )
+ {
aEntry += pVar->GetName();
+ }
else if ( pInfo )
{
const SbxParamInfo* pParam = pInfo->GetParam( nParam );
if ( pParam )
+ {
aEntry += pParam->aName;
+ }
}
aEntry += '=';
SbxDataType eType = pVar->GetType();
if( eType & SbxARRAY )
+ {
aEntry += OUString( "..." );
+ }
else if( eType != SbxOBJECT )
aEntry += pVar->GetString();
if ( nParam < ( pParams->Count() - 1 ) )
+ {
aEntry += OUString( ", " );
+ }
}
aEntry += ')';
}
@@ -2086,11 +2094,13 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
}
else if( pNewArray == NULL || pOldArray == NULL )
+ {
bArrayChanged = true;
-
+ }
if( pNewArray )
+ {
implEnableChildren( pEntry, true );
-
+ }
// #i37227 Clear always and replace array
if( pNewArray != pOldArray )
{
@@ -2106,12 +2116,15 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
}
if( bArrayChanged && pOldArray != NULL )
+ {
bCollapse = true;
-
+ }
aTypeStr = implCreateTypeStringForDimArray( pItem, eType );
}
else
+ {
aWatchStr += OUString( "<?>" );
+ }
}
else if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT )
{
@@ -2134,7 +2147,9 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
}
}
if( bObjChanged )
+ {
bCollapse = true;
+ }
}
pItem->mpObject = pObj;
@@ -2169,20 +2184,28 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
aWatchStr += aStrStr;
aWatchStr += pVar->GetString();
if( bString )
+ {
aWatchStr += aStrStr;
+ }
}
if( !aTypeStr.Len() )
{
if( !pVar->IsFixed() )
+ {
aTypeStr = OUString( "Variant/" );
+ }
aTypeStr += getBasicTypeName( pVar->GetType() );
}
}
else if( !bArrayElement )
+ {
aWatchStr += OUString( "<Out of Scope>" );
+ }
if( bCollapse )
+ {
implCollapseModifiedObjectEntry( pEntry, this );
+ }
}
else if( bBasicStopped )
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index 4639b4eaf734..58d71de8b30b 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -790,7 +790,9 @@ void Shell::UpdateWindows()
if ( bChangeCurWindow )
{
if ( !pNextActiveWindow )
+ {
pNextActiveWindow = FindApplicationWindow();
+ }
SetCurWindow( pNextActiveWindow, true );
}
}
@@ -804,9 +806,13 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange
if ( pWindow_ == pCurWin )
{
if ( bAllowChangeCurWindow )
+ {
SetCurWindow( FindApplicationWindow(), true );
+ }
else
+ {
SetCurWindow( NULL, false );
+ }
}
if ( bDestroy )
{
@@ -826,7 +832,9 @@ void Shell::RemoveWindow( BaseWindow* pWindow_, bool bDestroy, bool bAllowChange
{
SbModule* pMod = StarBASIC::GetActiveModule();
if ( !pMod || ( pMod && ( !pMod->GetName().Equals(pWindow_->GetName()) ) ) )
+ {
bStop = false;
+ }
}
if ( bStop )
{
diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx
index 6ff8a69bf0f2..f59b4149120c 100644
--- a/basic/inc/basic/basmgr.hxx
+++ b/basic/inc/basic/basmgr.hxx
@@ -55,13 +55,13 @@ public:
BasicError( const BasicError& rErr );
BasicError( sal_uIntPtr nId, sal_uInt16 nR, const OUString& rErrStr );
- sal_uIntPtr GetErrorId() const { return nErrorId; }
+ sal_uIntPtr GetErrorId() const { return nErrorId; }
sal_uInt16 GetReason() const { return nReason; }
- OUString GetErrorStr() { return aErrStr; }
+ OUString GetErrorStr() { return aErrStr; }
void SetErrorId( sal_uIntPtr n ) { nErrorId = n; }
void SetReason( sal_uInt16 n ) { nReason = n; }
- void SetErrorStr( const OUString& rStr) { aErrStr = rStr; }
+ void SetErrorStr( const OUString& rStr) { aErrStr = rStr; }
};
class BasicLibs;
@@ -74,9 +74,9 @@ namespace basic { class BasicManagerCleaner; }
class BASIC_DLLPUBLIC OldBasicPassword
{
public:
- virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) = 0;
+ virtual void setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword ) = 0;
virtual OUString getLibraryPassword( const OUString& rLibraryName ) = 0;
- virtual void clearLibraryPassword( const OUString& rLibraryName ) = 0;
+ virtual void clearLibraryPassword( const OUString& rLibraryName ) = 0;
virtual sal_Bool hasLibraryPassword( const OUString& rLibraryName ) = 0;
protected:
@@ -122,8 +122,8 @@ private:
BasicLibs* pLibs;
std::vector<BasicError> aErrors;
- OUString aName;
- OUString maStorageName;
+ OUString aName;
+ OUString maStorageName;
bool mbDocMgr;
BasicManagerImpl* mpImpl;
@@ -131,15 +131,15 @@ private:
BASIC_DLLPRIVATE void Init();
protected:
- sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo ) const;
- sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False );
+ sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo ) const;
+ sal_Bool ImpLoadLibrary( BasicLibInfo* pLibInfo, SotStorage* pCurStorage, sal_Bool bInfosOnly = sal_False );
void ImpCreateStdLib( StarBASIC* pParentFromStdLib );
void ImpMgrNotLoaded( const OUString& rStorageName );
BasicLibInfo* CreateLibInfo();
void LoadBasicManager( SotStorage& rStorage, const OUString& rBaseURL, sal_Bool bLoadBasics = sal_True );
void LoadOldBasicManager( SotStorage& rStorage );
- sal_Bool ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) const;
- sal_Bool ImplEncryptStream( SvStream& rStream ) const;
+ sal_Bool ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) const;
+ sal_Bool ImplEncryptStream( SvStream& rStream ) const;
BasicLibInfo* FindLibInfo( StarBASIC* pBasic ) const;
void CheckModules( StarBASIC* pBasic, sal_Bool bReference ) const;
~BasicManager();
@@ -159,17 +159,17 @@ public:
static void LegacyDeleteBasicManager( BasicManager*& _rpManager );
void SetStorageName( const OUString& rName ) { maStorageName = rName; }
- OUString GetStorageName() const { return maStorageName; }
+ OUString GetStorageName() const { return maStorageName; }
void SetName( const OUString& rName ) { aName = rName; }
- OUString GetName() const { return aName; }
+ OUString GetName() const { return aName; }
- sal_uInt16 GetLibCount() const;
+ sal_uInt16 GetLibCount() const;
StarBASIC* GetLib( sal_uInt16 nLib ) const;
StarBASIC* GetLib( const OUString& rName ) const;
- sal_uInt16 GetLibId( const OUString& rName ) const;
+ sal_uInt16 GetLibId( const OUString& rName ) const;
- OUString GetLibName( sal_uInt16 nLib );
+ OUString GetLibName( sal_uInt16 nLib );
/** announces the library containers which belong to this BasicManager
@@ -183,11 +183,11 @@ public:
const ::com::sun::star::uno::Reference< com::sun::star::script::XPersistentLibraryContainer >&
GetScriptLibraryContainer() const;
- sal_Bool LoadLib( sal_uInt16 nLib );
- sal_Bool RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage );
+ sal_Bool LoadLib( sal_uInt16 nLib );
+ sal_Bool RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage );
// Modify-Flag will be reset only during save.
- sal_Bool IsBasicModified() const;
+ sal_Bool IsBasicModified() const;
std::vector<BasicError>& GetErrors();
@@ -231,7 +231,7 @@ private:
// For XML import/export:
BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName );
BASIC_DLLPRIVATE StarBASIC* CreateLib( const OUString& rLibName, const OUString& Password,
- const OUString& LinkTargetURL );
+ const OUString& LinkTargetURL );
};
#endif //_BASMGR_HXX
diff --git a/basic/inc/basic/modsizeexceeded.hxx b/basic/inc/basic/modsizeexceeded.hxx
index 83176f0a62ee..e736348e14a6 100644
--- a/basic/inc/basic/modsizeexceeded.hxx
+++ b/basic/inc/basic/modsizeexceeded.hxx
@@ -43,7 +43,7 @@ class BASIC_DLLPUBLIC ModuleSizeExceeded : public ::cppu::WeakImplHelper1< ::com
// member
private:
- rtl::OUString m_sMods;
+ OUString m_sMods;
com::sun::star::uno::Any m_aRequest;
com::sun::star::uno::Sequence< com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > > m_lContinuations;
com::sun::star::uno::Reference< com::sun::star::task::XInteractionContinuation > m_xAbort;
diff --git a/basic/inc/basic/sbdef.hxx b/basic/inc/basic/sbdef.hxx
index 1d3409f802b6..2bc29cbb08c3 100644
--- a/basic/inc/basic/sbdef.hxx
+++ b/basic/inc/basic/sbdef.hxx
@@ -26,13 +26,13 @@
// Returns type name for Basic type, array flag is ignored
// implementation: basic/source/runtime/methods.cxx
-BASIC_DLLPUBLIC ::rtl::OUString getBasicTypeName( SbxDataType eType );
+BASIC_DLLPUBLIC OUString getBasicTypeName( SbxDataType eType );
// Returns type name for Basic objects, especially
// important for SbUnoObj instances
// implementation: basic/source/classes/sbunoobj.cxx
class SbxObject;
-BASIC_DLLPUBLIC ::rtl::OUString getBasicObjectTypeName( SbxObject* pObj );
+BASIC_DLLPUBLIC OUString getBasicObjectTypeName( SbxObject* pObj );
// Allows Basic IDE to set watch mode to suppress errors
// implementation: basic/source/runtime/runtime.cxx
@@ -52,8 +52,8 @@ BASIC_DLLPUBLIC void setBasicWatchMode( bool bOn );
#define SBXID_JSCRIPTMOD 0x6a62 // jm: JavaScript Module
#define SBXID_JSCRIPTMETH 0x6a64 // jm: JavaScript Module
-#define SBX_HINT_BASICSTART SFX_HINT_USER04
-#define SBX_HINT_BASICSTOP SFX_HINT_USER05
+#define SBX_HINT_BASICSTART SFX_HINT_USER04
+#define SBX_HINT_BASICSTOP SFX_HINT_USER05
enum PropertyMode
{
diff --git a/basic/inc/basic/sbmeth.hxx b/basic/inc/basic/sbmeth.hxx
index 6963c0db288f..0f24d4a9800e 100644
--- a/basic/inc/basic/sbmeth.hxx
+++ b/basic/inc/basic/sbmeth.hxx
@@ -37,8 +37,8 @@ class BASIC_DLLPUBLIC SbMethod : public SbxMethod
friend class SbJScriptMethod;
friend class SbIfaceMapperMethod;
- SbxVariable* mCaller; // caller
- SbModule* pMod;
+ SbxVariable* mCaller; // caller
+ SbModule* pMod;
sal_uInt16 nDebugFlags;
sal_uInt16 nLine1, nLine2;
sal_uInt32 nStart;
@@ -54,17 +54,17 @@ public:
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMETHOD,2);
TYPEINFO();
virtual SbxInfo* GetInfo();
- SbxArray* GetStatics();
- void ClearStatics();
- SbModule* GetModule() { return pMod; }
- sal_uInt32 GetId() const { return nStart; }
- sal_uInt16 GetDebugFlags() { return nDebugFlags; }
- void SetDebugFlags( sal_uInt16 n ) { nDebugFlags = n; }
- void GetLineRange( sal_uInt16&, sal_uInt16& );
+ SbxArray* GetStatics();
+ void ClearStatics();
+ SbModule* GetModule() { return pMod; }
+ sal_uInt32 GetId() const { return nStart; }
+ sal_uInt16 GetDebugFlags() { return nDebugFlags; }
+ void SetDebugFlags( sal_uInt16 n ) { nDebugFlags = n; }
+ void GetLineRange( sal_uInt16&, sal_uInt16& );
// Interface to execute a method from the applications
virtual ErrCode Call( SbxValue* pRet = NULL, SbxVariable* pCaller = NULL );
- virtual void Broadcast( sal_uIntPtr nHintId );
+ virtual void Broadcast( sal_uIntPtr nHintId );
};
SV_DECL_IMPL_REF(SbMethod)
diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx
index 464ebf2ca227..7d32abc41f09 100644
--- a/basic/inc/basic/sbmod.hxx
+++ b/basic/inc/basic/sbmod.hxx
@@ -74,15 +74,15 @@ protected:
SbProcedureProperty* GetProcedureProperty( const String&, SbxDataType );
SbIfaceMapperMethod* GetIfaceMapperMethod( const String&, SbMethod* );
void EndDefinitions( sal_Bool=sal_False );
- sal_uInt16 Run( SbMethod* );
+ sal_uInt16 Run( SbMethod* );
void RunInit();
void ClearPrivateVars();
void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
void GlobalRunInit( bool bBasicStart ); // for all modules
void GlobalRunDeInit( void );
- const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
- const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
- sal_Bool bFollowJumps, const SbiImage* pImg=NULL ) const;
+ const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16& ) const;
+ const sal_uInt8* FindNextStmnt( const sal_uInt8*, sal_uInt16&, sal_uInt16&,
+ sal_Bool bFollowJumps, const SbiImage* pImg=NULL ) const;
virtual sal_Bool LoadData( SvStream&, sal_uInt16 );
virtual sal_Bool StoreData( SvStream& ) const;
virtual sal_Bool LoadCompleted();
@@ -109,27 +109,27 @@ public:
virtual sal_Bool IsCompiled() const;
const SbxObject* FindType( String aTypeName ) const;
- virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const;
- virtual size_t GetBPCount() const;
- virtual sal_uInt16 GetBP( size_t n ) const;
- virtual sal_Bool IsBP( sal_uInt16 nLine ) const;
- virtual sal_Bool SetBP( sal_uInt16 nLine );
- virtual sal_Bool ClearBP( sal_uInt16 nLine );
- virtual void ClearAllBP();
+ virtual sal_Bool IsBreakable( sal_uInt16 nLine ) const;
+ virtual size_t GetBPCount() const;
+ virtual sal_uInt16 GetBP( size_t n ) const;
+ virtual sal_Bool IsBP( sal_uInt16 nLine ) const;
+ virtual sal_Bool SetBP( sal_uInt16 nLine );
+ virtual sal_Bool ClearBP( sal_uInt16 nLine );
+ virtual void ClearAllBP();
// Lines of Subs
virtual SbMethod* GetFunctionForLine( sal_uInt16 );
// Store only image, no source (needed for new password protection)
- sal_Bool StoreBinaryData( SvStream& );
- sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
+ sal_Bool StoreBinaryData( SvStream& );
+ sal_Bool StoreBinaryData( SvStream&, sal_uInt16 nVer );
sal_Bool LoadBinaryData( SvStream&, sal_uInt16 nVer );
sal_Bool LoadBinaryData( SvStream& );
sal_Bool ExceedsLegacyModuleSize();
- void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
- bool HasExeCode();
- bool IsVBACompat() const;
- void SetVBACompat( bool bCompat );
+ void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
+ bool HasExeCode();
+ bool IsVBACompat() const;
+ void SetVBACompat( bool bCompat );
sal_Int32 GetModuleType() { return mnType; }
void SetModuleType( sal_Int32 nType ) { mnType = nType; }
bool isProxyModule() { return bIsProxyModule; }
diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx
index cffd4ad70645..af3fa605381b 100644
--- a/basic/inc/basic/sbstar.hxx
+++ b/basic/inc/basic/sbstar.hxx
@@ -134,9 +134,9 @@ public:
void ClearAllModuleVars( void );
// Calls for error and break handler
- static sal_uInt16 GetLine();
- static sal_uInt16 GetCol1();
- static sal_uInt16 GetCol2();
+ static sal_uInt16 GetLine();
+ static sal_uInt16 GetCol1();
+ static sal_uInt16 GetCol2();
static void SetErrorData( SbError nCode, sal_uInt16 nLine,
sal_uInt16 nCol1, sal_uInt16 nCol2 );
diff --git a/basic/inc/basic/sbx.hxx b/basic/inc/basic/sbx.hxx
index 30dac56c42d1..f6e924ef096e 100644
--- a/basic/inc/basic/sbx.hxx
+++ b/basic/inc/basic/sbx.hxx
@@ -68,7 +68,7 @@ class BASIC_DLLPUBLIC SbxInfo : public SvRefBase
String aComment;
String aHelpFile;
- sal_uInt32 nHelpId;
+ sal_uInt32 nHelpId;
SbxParams aParams;
protected:
@@ -209,8 +209,8 @@ public:
void AddDim32( sal_Int32, sal_Int32 );
void unoAddDim32( sal_Int32, sal_Int32 );
sal_Bool GetDim32( sal_Int32, sal_Int32&, sal_Int32& ) const;
- bool hasFixedSize() { return mbHasFixedSize; };
- void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
+ bool hasFixedSize() { return mbHasFixedSize; };
+ void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
};
class BASIC_DLLPUBLIC SbxCollection : public SbxObject
diff --git a/basic/inc/basic/sbxbase.hxx b/basic/inc/basic/sbxbase.hxx
index 37142a9c865f..7b088bedda1e 100644
--- a/basic/inc/basic/sbxbase.hxx
+++ b/basic/inc/basic/sbxbase.hxx
@@ -39,7 +39,7 @@ struct SbxAppData
SbxBasicFormater *pBasicFormater; // Pointer to Format()-Command helper class
LanguageType eBasicFormaterLangType;
- // It might be useful to store this class 'global' because some string reosurces are saved here
+ // It might be useful to store this class 'global' because some string reosurces are saved here
SbxAppData() : eSbxError( SbxERR_OK ), aFacs(), pBasicFormater( NULL ) {}
~SbxAppData();
diff --git a/basic/inc/basic/sbxcore.hxx b/basic/inc/basic/sbxcore.hxx
index e1ff9be77923..ce86fd695e0e 100644
--- a/basic/inc/basic/sbxcore.hxx
+++ b/basic/inc/basic/sbxcore.hxx
@@ -68,10 +68,10 @@ protected:
SBX_DECL_PERSIST(0,0,0);
public:
TYPEINFO();
- inline void SetFlags( sal_uInt16 n );
+ inline void SetFlags( sal_uInt16 n );
inline sal_uInt16 GetFlags() const;
- inline void SetFlag( sal_uInt16 n );
- inline void ResetFlag( sal_uInt16 n );
+ inline void SetFlag( sal_uInt16 n );
+ inline void ResetFlag( sal_uInt16 n );
inline sal_Bool IsSet( sal_uInt16 n ) const;
inline sal_Bool IsReset( sal_uInt16 n ) const;
inline sal_Bool CanRead() const;
@@ -81,17 +81,17 @@ public:
inline sal_Bool IsHidden() const;
inline sal_Bool IsVisible() const;
- virtual sal_Bool IsFixed() const;
- virtual void SetModified( sal_Bool );
+ virtual sal_Bool IsFixed() const;
+ virtual void SetModified( sal_Bool );
- virtual SbxDataType GetType() const;
+ virtual SbxDataType GetType() const;
virtual SbxClassType GetClass() const;
virtual void Clear();
static SbxBase* Load( SvStream& );
- static void Skip( SvStream& );
- sal_Bool Store( SvStream& );
+ static void Skip( SvStream& );
+ sal_Bool Store( SvStream& );
virtual sal_Bool LoadCompleted();
virtual sal_Bool StoreCompleted();
diff --git a/basic/inc/basic/sbxprop.hxx b/basic/inc/basic/sbxprop.hxx
index 8b3bdb90d1f8..34e58778bf39 100644
--- a/basic/inc/basic/sbxprop.hxx
+++ b/basic/inc/basic/sbxprop.hxx
@@ -32,7 +32,7 @@ public:
SbxProperty( const SbxProperty& r ) : SvRefBase( r ), SbxVariable( r ) {}
virtual ~SbxProperty();
SbxProperty& operator=( const SbxProperty& r )
- { SbxVariable::operator=( r ); return *this; }
+ { SbxVariable::operator=( r ); return *this; }
virtual SbxClassType GetClass() const;
};
diff --git a/basic/inc/basic/sbxvar.hxx b/basic/inc/basic/sbxvar.hxx
index 8bbd87b4871b..c02c2a1fabfd 100644
--- a/basic/inc/basic/sbxvar.hxx
+++ b/basic/inc/basic/sbxvar.hxx
@@ -167,8 +167,8 @@ public:
SbxBase* GetObject() const;
sal_uInt8 GetByte() const;
- sal_uInt16 GetUShort() const;
- sal_uInt32 GetULong() const;
+ sal_uInt16 GetUShort() const;
+ sal_uInt32 GetULong() const;
sal_Bool PutInteger( sal_Int16 );
sal_Bool PutLong( sal_Int32 );
@@ -293,7 +293,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue
SfxBroadcaster* pCst; // Broadcaster, if needed
String maName; // Name, if available
SbxArrayRef mpPar; // Parameter-Array, if set
- sal_uInt16 nHash; // Hash-ID for search
+ sal_uInt16 nHash; // Hash-ID for search
BASIC_DLLPRIVATE SbxVariableImpl* getImpl( void );
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index d6812738a11b..a0c25e809d6b 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -2361,7 +2361,9 @@ void LibraryContainer_Impl::removeByName( const ::rtl::OUString& Name )
{
StarBASIC* pLib = mpMgr->GetLib( Name );
if( !pLib )
+ {
throw container::NoSuchElementException();
+ }
sal_uInt16 nLibId = mpMgr->GetLibId( Name );
mpMgr->RemoveLib( nLibId );
}
@@ -2433,7 +2435,9 @@ void SAL_CALL StarBasicAccess_Impl::addModule
StarBASIC* pLib = mpMgr->GetLib( LibraryName );
DBG_ASSERT( pLib, "XML Import: Lib for module unknown");
if( pLib )
+ {
pLib->MakeModule32( ModuleName, Source );
+ }
}
void SAL_CALL StarBasicAccess_Impl::addDialog
diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx
index e40809ef75fd..c5bd012a529b 100644
--- a/basic/source/classes/errobject.cxx
+++ b/basic/source/classes/errobject.cxx
@@ -210,7 +210,9 @@ void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OU
throw (uno::RuntimeException)
{
if( m_pErrObject != NULL )
+ {
m_pErrObject->setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 3c91470aacf9..1d756701ca63 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -135,8 +135,9 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
r >> nSign >> nLen >> nCount;
nNext += nLen + 8;
if( r.GetError() == SVSTREAM_OK )
- switch( nSign )
{
+ switch( nSign )
+ {
case B_NAME:
aName = r.ReadUniOrByteString(eCharSet);
break;
@@ -212,20 +213,26 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
memcpy( pStrings + nOff2, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( sal_Unicode ) );
}
delete[] pByteStrings;
- } break;
+ }
+ break;
case B_MODEND:
goto done;
default:
break;
+ }
}
else
+ {
break;
+ }
r.Seek( nNext );
}
done:
r.Seek( nLast );
if( !SbiGood( r ) )
+ {
bError = true;
+ }
return !bError;
}
@@ -248,15 +255,19 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
eCharSet = GetSOStoreTextEncoding( eCharSet );
if ( bLegacy )
+ {
r << (sal_Int32) B_LEGACYVERSION;
+ }
else
+ {
r << (sal_Int32) B_CURVERSION;
+ }
r << (sal_Int32) eCharSet
- << (sal_Int32) nDimBase
- << (sal_Int16) nFlags
- << (sal_Int16) 0
- << (sal_Int32) 0
- << (sal_Int32) 0;
+ << (sal_Int32) nDimBase
+ << (sal_Int16) nFlags
+ << (sal_Int16) 0
+ << (sal_Int32) 0
+ << (sal_Int32) 0;
// Name?
if( aName.Len() && SbiGood( r ) )
@@ -280,9 +291,13 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
sal_Int32 nLen = aOUSource.getLength();
const sal_Int32 nMaxUnitSize = STRING_MAXLEN - 1;
if( nLen > STRING_MAXLEN )
+ {
aTmp = aOUSource.copy( 0, nMaxUnitSize );
+ }
else
+ {
aTmp = aOUSource;
+ }
r.WriteUniOrByteString( aTmp, eCharSet );
SbiCloseRecord( r, nPos );
@@ -313,10 +328,12 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
aNewToLegacy.convert();
pLegacyPCode = (char*)aNewToLegacy.GetBuffer();
nLegacyCodeSize = aNewToLegacy.GetSize();
- r.Write( pLegacyPCode, nLegacyCodeSize );
+ r.Write( pLegacyPCode, nLegacyCodeSize );
}
else
+ {
r.Write( pCode, nCodeSize );
+ }
SbiCloseRecord( r, nPos );
}
// String-Pool?
@@ -328,8 +345,9 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
short i;
for( i = 0; i < nStrings && SbiGood( r ); i++ )
+ {
r << (sal_uInt32) pStringOff[ i ];
-
+ }
// Then the String-Block
char* pByteStrings = new char[ nStringSize ];
for( i = 0; i < nStrings; i++ )
@@ -347,7 +365,9 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
// Set overall length
SbiCloseRecord( r, nStart );
if( !SbiGood( r ) )
+ {
bError = true;
+ }
return !bError;
}
@@ -372,7 +392,9 @@ void SbiImage::MakeStrings( short nSize )
memset( pStrings, 0, nStringSize * sizeof( sal_Unicode ) );
}
else
+ {
bError = true;
+ }
}
// Add a string to StringPool. The String buffer is dynamically
@@ -380,19 +402,25 @@ void SbiImage::MakeStrings( short nSize )
void SbiImage::AddString( const String& r )
{
if( nStringIdx >= nStrings )
+ {
bError = true;
+ }
if( !bError )
{
xub_StrLen len = r.Len() + 1;
sal_uInt32 needed = nStringOff + len;
if( needed > 0xFFFFFF00L )
+ {
bError = true; // out of mem!
+ }
else if( needed > nStringSize )
{
sal_uInt32 nNewLen = needed + 1024;
nNewLen &= 0xFFFFFC00; // trim to 1K border
if( nNewLen > 0xFFFFFF00L )
+ {
nNewLen = 0xFFFFFF00L;
+ }
sal_Unicode* p = NULL;
if( (p = new sal_Unicode[ nNewLen ]) != NULL )
{
@@ -402,7 +430,9 @@ void SbiImage::AddString( const String& r )
nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen);
}
else
+ {
bError = true;
+ }
}
if( !bError )
{
@@ -411,7 +441,9 @@ void SbiImage::AddString( const String& r )
nStringOff = nStringOff + len;
// Last String? The update the size of the buffer
if( nStringIdx >= nStrings )
+ {
nStringSize = nStringOff;
+ }
}
}
}
@@ -430,7 +462,9 @@ void SbiImage::AddCode( char* p, sal_uInt32 s )
void SbiImage::AddType(SbxObject* pObject)
{
if( !rTypes.Is() )
+ {
rTypes = new SbxArray;
+ }
SbxObject *pCopyObject = new SbxObject(*pObject);
rTypes->Insert (pCopyObject,rTypes->Count());
}
@@ -438,7 +472,9 @@ void SbiImage::AddType(SbxObject* pObject)
void SbiImage::AddEnum(SbxObject* pObject) // Register enum type
{
if( !rEnums.Is() )
+ {
rEnums = new SbxArray;
+ }
rEnums->Insert( pObject, rEnums->Count() );
}
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index bb375ee8d055..24cc887c5e65 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -876,10 +876,15 @@ SbxObject* SbClassFactory::CreateObject( const rtl::OUString& rClassName )
SbxObjectRef xToUseClassModules = xClassModules;
if( SbModule* pMod = GetSbData()->pMod )
+ {
if( StarBASIC* pDocBasic = lclGetDocBasicForModule( pMod ) )
+ {
if( const DocBasicItem* pDocBasicItem = lclFindDocBasicItem( pDocBasic ) )
+ {
xToUseClassModules = pDocBasicItem->getClassModules();
-
+ }
+ }
+ }
SbxVariable* pVar = xToUseClassModules->Find( rClassName, SbxCLASS_OBJECT );
SbxObject* pRet = NULL;
if( pVar )
@@ -1723,7 +1728,9 @@ sal_Bool StarBASIC::RTError( SbError code, const String& rMsg, sal_uInt16 l, sal
SbError c = code;
if( (c & ERRCODE_CLASS_MASK) == ERRCODE_CLASS_COMPILER )
+ {
c = 0;
+ }
MakeErrorText( c, rMsg );
// Implementation of the code for the string transport to SFX-Error
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 6b635aa0d58c..4519cee47286 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -308,7 +308,9 @@ namespace
void lcl_indent( ::rtl::OUStringBuffer& _inout_rBuffer, sal_Int32 _nLevel )
{
while ( _nLevel-- > 0 )
+ {
_inout_rBuffer.appendAscii( " " );
+ }
}
}
@@ -2705,7 +2707,9 @@ SbxVariable* SbUnoObject::Find( const rtl::OUString& rName, SbxClassType t )
{
::rtl::OUString aUExactName = mxExactNameInvocation->getExactName( aUName );
if( !aUExactName.isEmpty() )
+ {
aUName = aUExactName;
+ }
}
try
@@ -2920,11 +2924,17 @@ void createAllObjectProperties( SbxObject* pObj )
SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj);
SbUnoStructRefObject* pUnoStructObj = PTR_CAST(SbUnoStructRefObject,pObj);
if( pUnoObj )
+ {
pUnoObj->createAllProperties();
+ }
else if ( pUnoStructObj )
+ {
pUnoStructObj->createAllProperties();
+ }
else
+ {
pObj->GetAll( SbxCLASS_DONTCARE );
+ }
}
@@ -2946,8 +2956,9 @@ void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
// try to create Struct with the same name
SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName );
if( !xUnoObj )
+ {
return;
-
+ }
// return the object
SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( (SbUnoObject*)xUnoObj );
@@ -3109,20 +3120,24 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite
// get the Uno-Object
SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
if( !(pObj && pObj->ISA(SbUnoObject)) )
+ {
return;
+ }
Any aAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
TypeClass eType = aAny.getValueType().getTypeClass();
if( eType != TypeClass_INTERFACE )
+ {
return;
-
+ }
// get the interface out of the Any
Reference< XInterface > x = *(Reference< XInterface >*)aAny.getValue();
// get CoreReflection
Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl();
if( !xCoreReflection.is() )
+ {
return;
-
+ }
for( sal_uInt16 i = 2 ; i < nParCount ; i++ )
{
// get the name of the interface of the struct
@@ -3131,13 +3146,16 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite
// search for the class
Reference< XIdlClass > xClass = xCoreReflection->forName( aIfaceName );
if( !xClass.is() )
+ {
return;
-
+ }
// check if the interface will be supported
::rtl::OUString aClassName = xClass->getName();
Type aClassType( xClass->getTypeClass(), aClassName.getStr() );
if( !x->queryInterface( aClassType ).hasValue() )
+ {
return;
+ }
}
// Every thing works; then return TRUE
@@ -3163,14 +3181,20 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
// get the Uno-Object
SbxVariableRef xParam = rPar.Get( 1 );
if( !xParam->IsObject() )
+ {
return;
+ }
SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
if( !(pObj && pObj->ISA(SbUnoObject)) )
+ {
return;
+ }
Any aAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
TypeClass eType = aAny.getValueType().getTypeClass();
if( eType == TypeClass_STRUCT )
+ {
refVar->PutBool( sal_True );
+ }
}
@@ -3192,32 +3216,46 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
// get the Uno-Objects
SbxVariableRef xParam1 = rPar.Get( 1 );
if( !xParam1->IsObject() )
+ {
return;
+ }
SbxBaseRef pObj1 = (SbxBase*)xParam1->GetObject();
if( !(pObj1 && pObj1->ISA(SbUnoObject)) )
+ {
return;
+ }
Any aAny1 = ((SbUnoObject*)(SbxBase*)pObj1)->getUnoAny();
TypeClass eType1 = aAny1.getValueType().getTypeClass();
if( eType1 != TypeClass_INTERFACE )
+ {
return;
+ }
Reference< XInterface > x1;
aAny1 >>= x1;
SbxVariableRef xParam2 = rPar.Get( 2 );
if( !xParam2->IsObject() )
+ {
return;
+ }
SbxBaseRef pObj2 = (SbxBase*)xParam2->GetObject();
if( !(pObj2 && pObj2->ISA(SbUnoObject)) )
+ {
return;
+ }
Any aAny2 = ((SbUnoObject*)(SbxBase*)pObj2)->getUnoAny();
TypeClass eType2 = aAny2.getValueType().getTypeClass();
if( eType2 != TypeClass_INTERFACE )
+ {
return;
+ }
Reference< XInterface > x2;
aAny2 >>= x2;
if( x1 == x2 )
+ {
refVar->PutBool( sal_True );
+ }
}
@@ -3254,8 +3292,7 @@ VBAConstantHelper::instance()
return aHelper;
}
-void
-VBAConstantHelper::init()
+void VBAConstantHelper::init()
{
if ( !isInited )
{
@@ -3263,9 +3300,10 @@ VBAConstantHelper::init()
types[ 0 ] = TypeClass_CONSTANTS;
Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( rtl::OUString(defaultNameSpace), types, TypeDescriptionSearchDepth_INFINITE );
- if ( !xEnum.is() )
+ if ( !xEnum.is())
+ {
return; //NULL;
-
+ }
while ( xEnum->hasMoreElements() )
{
Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY );
@@ -3823,7 +3861,9 @@ void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
unoToSbxValue( pVar, aRetAny );
}
else
+ {
SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+ }
}
@@ -3852,10 +3892,7 @@ public:
//========================================================================
-BasicAllListener_Impl::BasicAllListener_Impl
-(
- const ::rtl::OUString & aPrefixName_
-)
+BasicAllListener_Impl::BasicAllListener_Impl(const OUString& aPrefixName_)
: aPrefixName( aPrefixName_ )
{
}
@@ -4367,8 +4404,9 @@ void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty,
Any SAL_CALL ModuleInvocationProxy::getValue( const ::rtl::OUString& rProperty ) throw( UnknownPropertyException )
{
if( !m_bProxyIsClassModuleObject )
+ {
throw UnknownPropertyException();
-
+ }
SolarMutexGuard guard;
::rtl::OUString aPropertyFunctionName( "Property Get " );
@@ -4647,8 +4685,9 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
::rtl::OUString aPureIfaceName = aIfaceName;
sal_Int32 indexLastDot = aIfaceName.lastIndexOf('.');
if ( indexLastDot > -1 )
+ {
aPureIfaceName = aIfaceName.copy( indexLastDot + 1 );
-
+ }
Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject );
Sequence<Any> args( 2 );
@@ -4748,7 +4787,9 @@ rtl::OUString StructRefInfo::getTypeName() const
{
rtl::OUString sTypeName;
if ( mpTD )
+ {
sTypeName = mpTD->pTypeName;
+ }
return sTypeName;
}
@@ -4913,8 +4954,9 @@ Any SbUnoStructRefObject::getUnoAny( void )
{
::rtl::OUStringBuffer aPropStr;
if( (i % nPropsPerLine) == 0 )
+ {
aPropStr.appendAscii( "\n" );
-
+ }
// output the type and name
// Is it in Uno a sequence?
SbxDataType eType = pVar->GetFullType();
@@ -4930,20 +4972,27 @@ Any SbUnoStructRefObject::getUnoAny( void )
if( eType == SbxOBJECT )
{
if( rPropInfo.getTypeClass() == TypeClass_SEQUENCE )
+ {
eType = (SbxDataType) ( SbxOBJECT | SbxARRAY );
+ }
}
}
aPropStr.append( Dbg_SbxDataType2String( eType ) );
if( bMaybeVoid )
+ {
aPropStr.appendAscii( "/void" );
+ }
aPropStr.appendAscii( " " );
aPropStr.append( pVar->GetName() );
if( i == nPropCount - 1 )
+ {
aPropStr.appendAscii( "\n" );
+ }
else
+ {
aPropStr.appendAscii( "; " );
-
+ }
aRet.append( aPropStr.makeStringAndClear() );
}
}
@@ -5029,7 +5078,9 @@ void SbUnoStructRefObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCTyp
StructRefInfo SbUnoStructRefObject::getStructMember( const rtl::OUString& rMemberName )
{
if (!mbMemberCacheInit)
+ {
initMemberCache();
+ }
StructFieldInfo::iterator it = maFields.find( rMemberName );
typelib_TypeDescription * pFoundTD = NULL;
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 759b9b25f74b..d6c2a9bc0e45 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -202,7 +202,9 @@ DocObjectWrapper::release() throw ()
delete this;
}
else
+ {
OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount );
+ }
}
DocObjectWrapper::~DocObjectWrapper()
@@ -216,15 +218,21 @@ Sequence< Type > SAL_CALL DocObjectWrapper::getTypes()
{
Sequence< Type > sTypes;
if ( m_xAggregateTypeProv.is() )
+ {
sTypes = m_xAggregateTypeProv->getTypes();
+ }
m_Types.realloc( sTypes.getLength() + 1 );
Type* pPtr = m_Types.getArray();
for ( int i=0; i<m_Types.getLength(); ++i, ++pPtr )
{
if ( i == 0 )
+ {
*pPtr = XInvocation::static_type( NULL );
+ }
else
+ {
*pPtr = sTypes[ i - 1 ];
+ }
}
}
return m_Types;
@@ -504,7 +512,9 @@ SbModule::SbModule( const String& rName, sal_Bool bVBACompat )
// #i92642: Set name property to intitial name
SbxVariable* pNameProp = pProps->Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
if( pNameProp != NULL )
+ {
pNameProp->PutString( GetName() );
+ }
}
SbModule::~SbModule()
@@ -571,7 +581,9 @@ SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t )
SbxVariable* p = pMethods->Find( rName, SbxCLASS_METHOD );
SbMethod* pMeth = p ? PTR_CAST(SbMethod,p) : NULL;
if( p && !pMeth )
+ {
pMethods->Remove( p );
+ }
if( !pMeth )
{
pMeth = new SbMethod( rName, t, this );
@@ -588,7 +600,9 @@ SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t )
pMeth->SetType( t );
pMeth->ResetFlag( SBX_WRITE );
if( t != SbxVARIANT )
+ {
pMeth->SetFlag( SBX_FIXED );
+ }
return pMeth;
}
@@ -599,7 +613,9 @@ SbProperty* SbModule::GetProperty( const String& rName, SbxDataType t )
SbxVariable* p = pProps->Find( rName, SbxCLASS_PROPERTY );
SbProperty* pProp = p ? PTR_CAST(SbProperty,p) : NULL;
if( p && !pProp )
+ {
pProps->Remove( p );
+ }
if( !pProp )
{
pProp = new SbProperty( rName, t, this );
@@ -617,7 +633,9 @@ SbProcedureProperty* SbModule::GetProcedureProperty
SbxVariable* p = pProps->Find( rName, SbxCLASS_PROPERTY );
SbProcedureProperty* pProp = p ? PTR_CAST(SbProcedureProperty,p) : NULL;
if( p && !pProp )
+ {
pProps->Remove( p );
+ }
if( !pProp )
{
pProp = new SbProcedureProperty( rName, t );
@@ -635,7 +653,9 @@ SbIfaceMapperMethod* SbModule::GetIfaceMapperMethod
SbxVariable* p = pMethods->Find( rName, SbxCLASS_METHOD );
SbIfaceMapperMethod* pMapperMethod = p ? PTR_CAST(SbIfaceMapperMethod,p) : NULL;
if( p && !pMapperMethod )
+ {
pMethods->Remove( p );
+ }
if( !pMapperMethod )
{
pMapperMethod = new SbIfaceMapperMethod( rName, pImplMeth );
@@ -691,7 +711,9 @@ SbxVariable* SbModule::Find( const rtl::OUString& rName, SbxClassType t )
// make sure a search in an uninstatiated class module will fail
SbxVariable* pRes = SbxObject::Find( rName, t );
if ( bIsProxyModule && !GetSbData()->bRunInit )
+ {
return NULL;
+ }
if( !pRes && pImage )
{
SbiInstance* pInst = GetSbData()->pInst;
@@ -714,7 +736,9 @@ SbxVariable* SbModule::Find( const rtl::OUString& rName, SbxClassType t )
pRes->SetParent( this );
pRes->SetFlag( SBX_READ );
if( bPrivate )
+ {
pRes->SetFlag( SBX_PRIVATE );
+ }
pRes->PutObject( pEnumObject );
}
}
@@ -837,8 +861,10 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( pHint->GetId() == SBX_HINT_DATAWANTED )
{
if( pMeth->bInvalid && !Compile() )
+ {
// auto compile has not worked!
StarBASIC::Error( SbERR_BAD_PROP_VALUE );
+ }
else
{
// Call of a subprogram
@@ -858,10 +884,13 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
sal_uIntPtr nId = pHint->GetId();
if( (nId == SBX_HINT_DATAWANTED || nId == SBX_HINT_DATACHANGED) &&
pVar->GetName().EqualsIgnoreCaseAscii( "name" ) )
+ {
bForwardToSbxObject = false;
-
+ }
if( bForwardToSbxObject )
+ {
SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+ }
}
}
}
@@ -881,7 +910,7 @@ void SbModule::SetSource32( const ::rtl::OUString& r )
aOUSource = r;
StartDefinitions();
SbiTokenizer aTok( r );
- aTok.SetCompatible( IsVBACompat() );
+ aTok.SetCompatible( IsVBACompat() );
while( !aTok.IsEof() )
{
SbiToken eEndTok = NIL;
@@ -910,11 +939,13 @@ void SbModule::SetSource32( const ::rtl::OUString& r )
{
eCurTok = aTok.Next();
if( eCurTok == COMPATIBLE )
+ {
aTok.SetCompatible( true );
+ }
else if ( ( eCurTok == VBASUPPORT ) && ( aTok.Next() == NUMBER ) )
{
- sal_Bool bIsVBA = ( aTok.GetDbl()== 1 );
- SetVBACompat( bIsVBA );
+ sal_Bool bIsVBA = ( aTok.GetDbl()== 1 );
+ SetVBACompat( bIsVBA );
aTok.SetCompatible( bIsVBA );
}
}
@@ -1083,7 +1114,7 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth )
sal_uInt16 nRes = 0;
bool bDelInst = ( GetSbData()->pInst == NULL );
- bool bQuit = false;
+ bool bQuit = false;
StarBASICRef xBasic;
uno::Reference< frame::XModel > xModel;
uno::Reference< script::vba::XVBACompatibility > xVBACompat;
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index 6642cb13f6f1..3f389eb04188 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -149,17 +149,21 @@ void SbiCodeGen::Save()
{
GetSbData()->pClassFac->RemoveClassModule( &rMod );
// Only a ClassModule can revert to Normal
- if ( rMod.mnType == com::sun::star::script::ModuleType::CLASS )
+ if ( rMod.mnType == com::sun::star::script::ModuleType::CLASS )
+ {
rMod.mnType = com::sun::star::script::ModuleType::NORMAL;
+ }
rMod.bIsProxyModule = false;
}
// GlobalCode-Flag
if( pParser->HasGlobalCode() )
+ {
p->SetFlag( SBIMG_INITCODE );
+ }
// Die Entrypoints:
for( SbiSymDef* pDef = pParser->aPublics.First(); pDef;
- pDef = pParser->aPublics.Next() )
+ pDef = pParser->aPublics.Next() )
{
SbiProcDef* pProc = pDef->GetProcDef();
if( pProc && pProc->IsDefined() )
@@ -198,8 +202,9 @@ void SbiCodeGen::Save()
for( sal_uInt16 nPass = 0 ; nPass < nPassCount ; nPass++ )
{
if( nPass == 1 )
+ {
aProcName = aIfaceProcName;
-
+ }
PropertyMode ePropMode = pProc->getPropertyMode();
if( ePropMode != PROPERTY_MODE_NONE )
{
@@ -249,8 +254,9 @@ void SbiCodeGen::Save()
// Declare? -> Hidden
if( pProc->GetLib().Len() > 0 )
+ {
pMeth->SetFlag( SBX_HIDDEN );
-
+ }
pMeth->nStart = pProc->GetAddr();
pMeth->nLine1 = pProc->GetLine1();
pMeth->nLine2 = pProc->GetLine2();
@@ -275,24 +281,35 @@ void SbiCodeGen::Save()
SbiSymDef* pPar = pPool->Get( i );
SbxDataType t = pPar->GetType();
if( !pPar->IsByVal() )
+ {
t = (SbxDataType) ( t | SbxBYREF );
+ }
if( pPar->GetDims() )
+ {
t = (SbxDataType) ( t | SbxARRAY );
+ }
// #33677 hand-over an Optional-Info
sal_uInt16 nFlags = SBX_READ;
if( pPar->IsOptional() )
+ {
nFlags |= SBX_OPTIONAL;
-
+ }
pInfo->AddParam( pPar->GetName(), t, nFlags );
sal_uInt32 nUserData = 0;
sal_uInt16 nDefaultId = pPar->GetDefaultId();
if( nDefaultId )
+ {
nUserData |= nDefaultId;
+ }
if( pPar->IsParamArray() )
+ {
nUserData |= PARAM_INFO_PARAMARRAY;
+ }
if( pPar->IsWithBrackets() )
+ {
nUserData |= PARAM_INFO_WITHBRACKETS;
+ }
if( nUserData )
{
SbxParamInfo* pParam = (SbxParamInfo*)pInfo->GetParam( i );
@@ -301,7 +318,6 @@ void SbiCodeGen::Save()
}
pMeth->SetInfo( pInfo );
}
-
} // for( iPass...
}
}
@@ -314,23 +330,29 @@ void SbiCodeGen::Save()
p->MakeStrings( nSize );
sal_uInt16 i;
for( i = 1; i <= nSize; i++ )
+ {
p->AddString( pPool->Find( i ) );
-
+ }
// Insert types
sal_uInt16 nCount = pParser->rTypeArray->Count();
for (i = 0; i < nCount; i++)
+ {
p->AddType((SbxObject *)pParser->rTypeArray->Get(i));
-
+ }
// Insert enum objects
nCount = pParser->rEnumArray->Count();
for (i = 0; i < nCount; i++)
+ {
p->AddEnum((SbxObject *)pParser->rEnumArray->Get(i));
-
+ }
if( !p->IsError() )
+ {
rMod.pImage = p;
+ }
else
+ {
delete p;
-
+ }
rMod.EndDefinitions();
}
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 70d441e8003a..b2f5dc55080b 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -824,17 +824,25 @@ SbiProcDef* SbiParser::ProcDecl( bool bDecl )
{
Next();
if( Next() == FIXSTRING )
+ {
pDef->GetLib() = aSym;
+ }
else
+ {
Error( SbERR_SYNTAX );
+ }
}
if( Peek() == ALIAS )
{
Next();
if( Next() == FIXSTRING )
+ {
pDef->GetAlias() = aSym;
+ }
else
+ {
Error( SbERR_SYNTAX );
+ }
}
if( !bDecl )
{
@@ -844,7 +852,9 @@ SbiProcDef* SbiParser::ProcDecl( bool bDecl )
if( pDef->GetAlias().Len() )
Error( SbERR_UNEXPECTED, ALIAS );
if( pDef->IsCdecl() )
+ {
Error( SbERR_UNEXPECTED, _CDECL_ );
+ }
pDef->SetCdecl( false );
pDef->GetLib().Erase();
pDef->GetAlias().Erase();
@@ -853,9 +863,13 @@ SbiProcDef* SbiParser::ProcDecl( bool bDecl )
{
// ALIAS and CDECL only together with LIB
if( pDef->GetAlias().Len() )
+ {
Error( SbERR_UNEXPECTED, ALIAS );
+ }
if( pDef->IsCdecl() )
+ {
Error( SbERR_UNEXPECTED, _CDECL_ );
+ }
pDef->SetCdecl( false );
pDef->GetAlias().Erase();
}
@@ -927,9 +941,13 @@ SbiProcDef* SbiParser::ProcDecl( bool bDecl )
}
TypeDecl( *pDef );
if( eType != SbxVARIANT && pDef->GetType() != eType )
+ {
Error( SbERR_BAD_DECLARATION, aName );
+ }
if( pDef->GetType() == SbxVARIANT && !( bFunc || bProp ) )
+ {
pDef->SetType( SbxEMPTY );
+ }
return pDef;
}
@@ -944,7 +962,9 @@ void SbiParser::DefDeclare( bool bPrivate )
{
Next();
if( eCurTok != SUB && eCurTok != FUNCTION )
+ {
Error( SbERR_UNEXPECTED, eCurTok );
+ }
else
{
bool bFunction = (eCurTok == FUNCTION);
@@ -953,7 +973,9 @@ void SbiParser::DefDeclare( bool bPrivate )
if( pDef )
{
if( !pDef->GetLib().Len() )
+ {
Error( SbERR_EXPECTED, LIB );
+ }
// Is it already there?
SbiSymDef* pOld = aPublics.Find( pDef->GetName() );
if( pOld )
@@ -967,11 +989,14 @@ void SbiParser::DefDeclare( bool bPrivate )
pDef = NULL;
}
else
+ {
pDef->Match( p );
+ }
}
else
+ {
aPublics.Add( pDef );
-
+ }
if ( pDef )
{
pDef->SetPublic( !bPrivate );
@@ -996,8 +1021,9 @@ void SbiParser::DefDeclare( bool bPrivate )
SbxDataType eType = pDef->GetType();
if( bFunction )
+ {
aGen.Gen( _PARAM, 0, sal::static_int_cast< sal_uInt16 >( eType ) );
-
+ }
if( nParCount > 1 )
{
aGen.Gen( _ARGC );
@@ -1026,14 +1052,19 @@ void SbiParser::DefDeclare( bool bPrivate )
SbiOpcode eOp = pDef->IsCdecl() ? _CALLC : _CALL;
sal_uInt16 nId = pDef->GetId();
if( pDef->GetAlias().Len() )
+ {
nId = ( nId & 0x8000 ) | aGblStrings.Add( pDef->GetAlias() );
+ }
if( nParCount > 1 )
+ {
nId |= 0x8000;
+ }
aGen.Gen( eOp, nId, sal::static_int_cast< sal_uInt16 >( eType ) );
if( bFunction )
+ {
aGen.Gen( _PUT );
-
+ }
aGen.Gen( _LEAVE );
}
}
@@ -1047,14 +1078,19 @@ void SbiParser::Attribute()
while( Next() != EQ )
{
if( Next() != DOT)
+ {
break;
+ }
}
if( eCurTok != EQ )
+ {
Error( SbERR_SYNTAX );
+ }
else
+ {
SbiExpression aValue( this );
-
+ }
// Don't generate any code - just discard it.
}
@@ -1086,19 +1122,29 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
{
Next();
if( eCurTok == GET )
+ {
ePropertyMode = PROPERTY_MODE_GET;
+ }
else if( eCurTok == LET )
+ {
ePropertyMode = PROPERTY_MODE_LET;
+ }
else if( eCurTok == SET )
+ {
ePropertyMode = PROPERTY_MODE_SET;
+ }
else
+ {
Error( SbERR_EXPECTED, "Get or Let or Set" );
+ }
}
SbiToken eExit = eCurTok;
SbiProcDef* pDef = ProcDecl( false );
if( !pDef )
+ {
return;
+ }
pDef->setPropertyMode( ePropertyMode );
// Is the Proc already declared?
@@ -1137,10 +1183,13 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
}
}
else
+ {
aPublics.Add( pDef ), pProc = pDef;
-
+ }
if( !pProc )
+ {
return;
+ }
pProc->SetPublic( !bPrivate );
// Now we set the search hierarchy for symbols as well as the
@@ -1148,16 +1197,20 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
aPublics.SetProcId( pProc->GetId() );
pProc->GetParams().SetParent( &aPublics );
if( bStatic )
- {
+ {
if ( bVBASupportOn )
+ {
pProc->SetStatic( sal_True );
+ }
else
+ {
Error( SbERR_NOT_IMPLEMENTED ); // STATIC SUB ...
}
- else
+ }
+ else
{
pProc->SetStatic( sal_False );
- }
+ }
// Normal case: Local variable->parameter->global variable
pProc->GetLocals().SetParent( &pProc->GetParams() );
pPool = &pProc->GetLocals();
@@ -1186,30 +1239,35 @@ void SbiParser::Static()
void SbiParser::DefStatic( bool bPrivate )
{
+ SbiSymPool* p;
+
switch( Peek() )
{
- case SUB:
- case FUNCTION:
- case PROPERTY:
- // End global chain if necessary (not done in
- // SbiParser::Parse() under these conditions
- if( bNewGblDefs && nGblChain == 0 )
- {
- nGblChain = aGen.Gen( _JUMP, 0 );
- bNewGblDefs = false;
- }
- Next();
- DefProc( true, bPrivate );
- break;
- default: {
- if( !pProc )
- Error( SbERR_NOT_IN_SUBR );
- // Reset the Pool, so that STATIC-Declarations go into the
- // global Pool
- SbiSymPool* p = pPool; pPool = &aPublics;
- DefVar( _STATIC, true );
- pPool = p;
- } break;
+ case SUB:
+ case FUNCTION:
+ case PROPERTY:
+ // End global chain if necessary (not done in
+ // SbiParser::Parse() under these conditions
+ if( bNewGblDefs && nGblChain == 0 )
+ {
+ nGblChain = aGen.Gen( _JUMP, 0 );
+ bNewGblDefs = false;
+ }
+ Next();
+ DefProc( true, bPrivate );
+ break;
+ default:
+ if( !pProc )
+ {
+ Error( SbERR_NOT_IN_SUBR );
+ }
+ // Reset the Pool, so that STATIC-Declarations go into the
+ // global Pool
+ p = pPool;
+ pPool = &aPublics;
+ DefVar( _STATIC, true );
+ pPool = p;
+ break;
}
}
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index d752993b07fa..13ce100fe1cb 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -57,22 +57,26 @@ static OpTable aOpTable [] = {
// Output of an element
void SbiExprNode::Gen( RecursiveMode eRecMode )
{
+ sal_uInt16 nStringId;
+
if( IsConstant() )
{
switch( GetType() )
{
- case SbxEMPTY: pGen->Gen( _EMPTY ); break;
- case SbxINTEGER: pGen->Gen( _CONST, (short) nVal ); break;
- case SbxSTRING:
- {
- sal_uInt16 nStringId = pGen->GetParser()->aGblStrings.Add( aStrVal, sal_True );
- pGen->Gen( _SCONST, nStringId ); break;
- }
- default:
- {
- sal_uInt16 nStringId = pGen->GetParser()->aGblStrings.Add( nVal, eType );
- pGen->Gen( _NUMBER, nStringId );
- }
+ case SbxEMPTY:
+ pGen->Gen( _EMPTY );
+ break;
+ case SbxINTEGER:
+ pGen->Gen( _CONST, (short) nVal );
+ break;
+ case SbxSTRING:
+ nStringId = pGen->GetParser()->aGblStrings.Add( aStrVal, sal_True );
+ pGen->Gen( _SCONST, nStringId );
+ break;
+ default:
+ nStringId = pGen->GetParser()->aGblStrings.Add( nVal, eType );
+ pGen->Gen( _NUMBER, nStringId );
+ break;
}
}
else if( IsOperand() )
@@ -92,10 +96,14 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
else if( eRecMode == UNDEFINED )
{
if( aVar.pPar && aVar.pPar->IsBracket() )
+ {
bTreatFunctionAsParam = false;
+ }
}
if( !bTreatFunctionAsParam )
+ {
eOp = aVar.pDef->IsGlobal() ? _FIND_G : _FIND;
+ }
}
}
// special treatment for WITH
@@ -114,7 +122,9 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
SbiProcDef* pProc = aVar.pDef->GetProcDef();
if ( pGen->GetParser()->bClassModule )
+ {
eOp = _FIND_CM;
+ }
else if ( aVar.pDef->IsStatic() || (pProc && pProc->IsStatic()) )
{
eOp = _FIND_STATIC;
@@ -123,7 +133,9 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
for( SbiExprNode* p = this; p; p = p->aVar.pNext )
{
if( p == this && pWithParent_ != NULL )
+ {
pWithParent_->Gen();
+ }
p->GenElement( eOp );
eOp = _ELEM;
}
@@ -141,7 +153,9 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
{
pLeft->Gen();
if( pRight )
+ {
pRight->Gen();
+ }
for( OpTable* p = aOpTable; p->eTok != NIL; p++ )
{
if( p->eTok == eTok )
@@ -247,12 +261,16 @@ void SbiExpression::Gen( RecursiveMode eRecMode )
// If pExpr == .-term in With, approximately Gen for Basis-Object
pExpr->Gen( eRecMode );
if( bByVal )
+ {
pParser->aGen.Gen( _BYVAL );
+ }
if( bBased )
{
sal_uInt16 uBase = pParser->nBase;
if( pParser->IsCompatible() )
+ {
uBase |= 0x8000; // #109275 Flag compatiblity
+ }
pParser->aGen.Gen( _BASED, uBase );
pParser->aGen.Gen( _ARGV );
}
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index 1a4b465ded02..33857568b8bc 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -39,11 +39,17 @@ SbiExpression::SbiExpression( SbiParser* p, SbiExprType t,
pNext = NULL;
pExpr = (t != SbSTDEXPR ) ? Term( pKeywordSymbolInfo ) : Boolean();
if( t != SbSYMBOL )
+ {
pExpr->Optimize();
+ }
if( t == SbLVALUE && !pExpr->IsLvalue() )
+ {
p->Error( SbERR_LVALUE_EXPECTED );
+ }
if( t == SbOPERAND && !IsVariable() )
+ {
p->Error( SbERR_VAR_EXPECTED );
+ }
}
SbiExpression::SbiExpression( SbiParser* p, double n, SbxDataType t )
@@ -82,12 +88,16 @@ SbiExpression::~SbiExpression()
static sal_Bool DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTok )
{
if( eTok == LPAREN )
+ {
return sal_True;
+ }
// but only if similar to CALL!
if( !p->WhiteSpace() || eCurExpr != SbSYMBOL )
+ {
return sal_False;
- if ( eTok == NUMBER || eTok == MINUS || eTok == FIXSTRING
- || eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT || eTok == BYVAL )
+ }
+ if ( eTok == NUMBER || eTok == MINUS || eTok == FIXSTRING ||
+ eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT || eTok == BYVAL )
{
return sal_True;
}
@@ -97,7 +107,9 @@ static sal_Bool DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken
// Urk the Next() / Peek() symantics are... weird
tokens.Next();
if ( tokens.Peek() == ASSIGN )
+ {
return sal_True;
+ }
}
return sal_False;
}
@@ -118,13 +130,16 @@ static SbiSymDef* AddSym
// procs must always get into a public pool
SbiSymPool* pPool = &rPool;
if( pPool->GetScope() != SbPUBLIC )
+ {
pPool = &rPool.GetParser()->aPublics;
+ }
SbiProcDef* pProc = pPool->AddProc( rName );
// special treatment for Colls like Documents(1)
if( eCurExpr == SbSTDEXPR )
+ {
bHasType = sal_True;
-
+ }
pDef = pProc;
pDef->SetType( bHasType ? eType : SbxEMPTY );
if( pPar )
@@ -166,7 +181,9 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
{
pNd = ObjTerm( *pDef );
if( pNd )
+ {
pNd->SetWithParent( pWithVar );
+ }
}
if( !pNd )
{
@@ -220,7 +237,9 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
while( eTok == LPAREN )
{
if( pvMoreParLcl == NULL )
+ {
pvMoreParLcl = new SbiExprListVector();
+ }
SbiParameters* pAddPar = new SbiParameters( pParser );
pvMoreParLcl->push_back( pAddPar );
bError = bError || !pAddPar->IsValid();
@@ -236,7 +255,9 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
{
bBracket = false; // Now the bracket for the first term is obsolete
if( eType == SbxVARIANT )
+ {
eType = SbxOBJECT;
+ }
else
{
// Name%. really does not work!
@@ -257,18 +278,24 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
SbModule& rMod = pParser->aGen.GetModule();
SbxArray* pModMethods = rMod.GetMethods();
if( pModMethods->Find( aSym, SbxCLASS_DONTCARE ) )
+ {
pDef = NULL;
+ }
}
if( !pDef )
{
if( bObj )
+ {
eType = SbxOBJECT;
+ }
pDef = AddSym( eTok, *pParser->pPool, eCurExpr, aSym, eType, pPar );
// Looks like this is a local ( but undefined variable )
// if it is in a static procedure then make this Symbol
// static
if ( !bObj && pParser->pProc && pParser->pProc->IsStatic() )
+ {
pDef->SetStatic();
+ }
}
else
{
@@ -277,16 +304,22 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
if( pConst )
{
if( pConst->GetType() == SbxSTRING )
+ {
return new SbiExprNode( pParser, pConst->GetString() );
+ }
else
+ {
return new SbiExprNode( pParser, pConst->GetValue(), pConst->GetType() );
+ }
}
// 0 parameters come up to ()
if( pDef->GetDims() )
{
if( pPar && pPar->GetSize() && pPar->GetSize() != pDef->GetDims() )
+ {
pParser->Error( SbERR_WRONG_DIMS );
+ }
}
if( pDef->IsDefinedAs() )
{
@@ -347,7 +380,9 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
}
}
if( !bError )
+ {
pNd->aVar.pNext = ObjTerm( *pDef );
+ }
}
pParser->UnlockColumn();
@@ -393,19 +428,22 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
while( eTok == LPAREN )
{
if( pvMoreParLcl == NULL )
+ {
pvMoreParLcl = new SbiExprListVector();
+ }
SbiParameters* pAddPar = new SbiParameters( pParser );
pvMoreParLcl->push_back( pAddPar );
bError = bError || !pPar->IsValid();
eTok = pParser->Peek();
}
-
}
sal_Bool bObj = sal_Bool( ( eTok == DOT || eTok == EXCLAM ) && !pParser->WhiteSpace() );
if( bObj )
{
if( eType == SbxVARIANT )
+ {
eType = SbxOBJECT;
+ }
else
{
// Name%. does really not work!
@@ -430,8 +468,9 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
if( bObj )
{
if( pDef->GetType() == SbxVARIANT )
+ {
pDef->SetType( SbxOBJECT );
-
+ }
if( pDef->GetType() != SbxOBJECT )
{
pParser->Error( SbERR_BAD_DECLARATION, aSym );
@@ -462,67 +501,78 @@ SbiExprNode* SbiExpression::Operand( bool bUsedForTypeOf )
// test operand:
switch( eTok = pParser->Peek() )
{
- case SYMBOL:
- pRes = Term();
- // process something like "IF Not r Is Nothing Then .."
- if( !bUsedForTypeOf && pParser->IsVBASupportOn() && pParser->Peek() == IS )
- {
- eTok = pParser->Next();
- pRes = new SbiExprNode( pParser, pRes, eTok, Like() );
- }
- break;
- case DOT: // .with
- pRes = Term(); break;
- case NUMBER:
+ case SYMBOL:
+ pRes = Term();
+ // process something like "IF Not r Is Nothing Then .."
+ if( !bUsedForTypeOf && pParser->IsVBASupportOn() && pParser->Peek() == IS )
+ {
+ eTok = pParser->Next();
+ pRes = new SbiExprNode( pParser, pRes, eTok, Like() );
+ }
+ break;
+ case DOT: // .with
+ pRes = Term(); break;
+ case NUMBER:
+ pParser->Next();
+ pRes = new SbiExprNode( pParser, pParser->GetDbl(), pParser->GetType() );
+ break;
+ case FIXSTRING:
+ pParser->Next();
+ pRes = new SbiExprNode( pParser, pParser->GetSym() ); break;
+ case LPAREN:
+ pParser->Next();
+ if( nParenLevel == 0 && m_eMode == EXPRMODE_LPAREN_PENDING && pParser->Peek() == RPAREN )
+ {
+ m_eMode = EXPRMODE_EMPTY_PAREN;
+ pRes = new SbiExprNode(); // Dummy node
pParser->Next();
- pRes = new SbiExprNode( pParser, pParser->GetDbl(), pParser->GetType() );
break;
- case FIXSTRING:
- pParser->Next();
- pRes = new SbiExprNode( pParser, pParser->GetSym() ); break;
- case LPAREN:
- pParser->Next();
- if( nParenLevel == 0 && m_eMode == EXPRMODE_LPAREN_PENDING && pParser->Peek() == RPAREN )
+ }
+ nParenLevel++;
+ pRes = Boolean();
+ if( pParser->Peek() != RPAREN )
+ {
+ // If there was a LPARAM, it does not belong to the expression
+ if( nParenLevel == 1 && m_eMode == EXPRMODE_LPAREN_PENDING )
{
- m_eMode = EXPRMODE_EMPTY_PAREN;
- pRes = new SbiExprNode(); // Dummy node
- pParser->Next();
- break;
+ m_eMode = EXPRMODE_LPAREN_NOT_NEEDED;
}
- nParenLevel++;
- pRes = Boolean();
- if( pParser->Peek() != RPAREN )
+ else
{
- // If there was a LPARAM, it does not belong to the expression
- if( nParenLevel == 1 && m_eMode == EXPRMODE_LPAREN_PENDING )
- m_eMode = EXPRMODE_LPAREN_NOT_NEEDED;
- else
- pParser->Error( SbERR_BAD_BRACKETS );
+ pParser->Error( SbERR_BAD_BRACKETS );
}
- else
+ }
+ else
+ {
+ pParser->Next();
+ if( nParenLevel == 1 && m_eMode == EXPRMODE_LPAREN_PENDING )
{
- pParser->Next();
- if( nParenLevel == 1 && m_eMode == EXPRMODE_LPAREN_PENDING )
+ SbiToken eTokAfterRParen = pParser->Peek();
+ if( eTokAfterRParen == EQ || eTokAfterRParen == LPAREN || eTokAfterRParen == DOT )
{
- SbiToken eTokAfterRParen = pParser->Peek();
- if( eTokAfterRParen == EQ || eTokAfterRParen == LPAREN || eTokAfterRParen == DOT )
- m_eMode = EXPRMODE_ARRAY_OR_OBJECT;
- else
- m_eMode = EXPRMODE_STANDARD;
+ m_eMode = EXPRMODE_ARRAY_OR_OBJECT;
+ }
+ else
+ {
+ m_eMode = EXPRMODE_STANDARD;
}
}
- nParenLevel--;
- break;
- default:
- // keywords here are OK at the moment!
- if( pParser->IsKwd( eTok ) )
- pRes = Term();
- else
- {
- pParser->Next();
- pRes = new SbiExprNode( pParser, 1.0, SbxDOUBLE );
- pParser->Error( SbERR_UNEXPECTED, eTok );
- }
+ }
+ nParenLevel--;
+ break;
+ default:
+ // keywords here are OK at the moment!
+ if( pParser->IsKwd( eTok ) )
+ {
+ pRes = Term();
+ }
+ else
+ {
+ pParser->Next();
+ pRes = new SbiExprNode( pParser, 1.0, SbxDOUBLE );
+ pParser->Error( SbERR_UNEXPECTED, eTok );
+ }
+ break;
}
return pRes;
}
@@ -585,7 +635,8 @@ SbiExprNode* SbiExpression::Exp()
SbiExprNode* pNd = Unary();
if( m_eMode != EXPRMODE_EMPTY_PAREN )
{
- while( pParser->Peek() == EXPON ) {
+ while( pParser->Peek() == EXPON )
+ {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Unary() );
}
@@ -602,7 +653,9 @@ SbiExprNode* SbiExpression::MulDiv()
{
SbiToken eTok = pParser->Peek();
if( eTok != MUL && eTok != DIV )
+ {
break;
+ }
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Exp() );
}
@@ -615,7 +668,8 @@ SbiExprNode* SbiExpression::IntDiv()
SbiExprNode* pNd = MulDiv();
if( m_eMode != EXPRMODE_EMPTY_PAREN )
{
- while( pParser->Peek() == IDIV ) {
+ while( pParser->Peek() == IDIV )
+ {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, MulDiv() );
}
@@ -628,7 +682,8 @@ SbiExprNode* SbiExpression::Mod()
SbiExprNode* pNd = IntDiv();
if( m_eMode != EXPRMODE_EMPTY_PAREN )
{
- while( pParser->Peek() == MOD ) {
+ while( pParser->Peek() == MOD )
+ {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, IntDiv() );
}
@@ -645,7 +700,9 @@ SbiExprNode* SbiExpression::AddSub()
{
SbiToken eTok = pParser->Peek();
if( eTok != PLUS && eTok != MINUS )
+ {
break;
+ }
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Mod() );
}
@@ -662,7 +719,9 @@ SbiExprNode* SbiExpression::Cat()
{
SbiToken eTok = pParser->Peek();
if( eTok != CAT )
+ {
break;
+ }
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, AddSub() );
}
@@ -820,10 +879,13 @@ short SbiConstExpression::GetShortValue()
{
double n = nVal;
if( n > 0 )
+ {
n += .5;
+ }
else
+ {
n -= .5;
-
+ }
if( n > SbxMAXINT )
{
n = SbxMAXINT;
@@ -872,7 +934,9 @@ SbiExpression* SbiExprList::Get( short n )
{
SbiExpression* p = pFirst;
while( n-- && p )
+ {
p = p->pNext;
+ }
return p;
}
@@ -886,8 +950,9 @@ void SbiExprList::addExpression( SbiExpression* pExpr )
SbiExpression* p = pFirst;
while( p->pNext )
+ {
p = p->pNext;
-
+ }
p->pNext = pExpr;
}
@@ -911,8 +976,9 @@ SbiParameters::SbiParameters( SbiParser* p, bool bStandaloneExpression, bool bPa
SbiExprList( p )
{
if( !bPar )
+ {
return;
-
+ }
SbiExpression *pExpr;
SbiToken eTok = pParser->Peek();
@@ -985,16 +1051,20 @@ SbiParameters::SbiParameters( SbiParser* p, bool bStandaloneExpression, bool bPa
bBracket = true;
delete pExpr;
if( bByVal )
+ {
pParser->Error( SbERR_LVALUE_EXPECTED );
+ }
return;
}
}
else
+ {
pExpr = new SbiExpression( pParser );
-
+ }
if( bByVal && pExpr->IsLvalue() )
+ {
pExpr->SetByVal();
-
+ }
if( !bAssumeArrayMode )
{
if( pParser->Peek() == ASSIGN )
@@ -1011,24 +1081,29 @@ SbiParameters::SbiParameters( SbiParser* p, bool bStandaloneExpression, bool bPa
}
pExpr->pNext = NULL;
if( !pLast )
+ {
pFirst = pLast = pExpr;
+ }
else
+ {
pLast->pNext = pExpr, pLast = pExpr;
+ }
nExpr++;
bError = bError || !pExpr->IsValid();
if( bAssumeArrayMode )
+ {
break;
-
+ }
// next element?
eTok = pParser->Peek();
if( eTok != COMMA )
{
if( ( bBracket && eTok == RPAREN ) || pParser->IsEoln( eTok ) )
+ {
break;
- pParser->Error( bBracket
- ? SbERR_BAD_BRACKETS
- : SbERR_EXPECTED, COMMA );
+ }
+ pParser->Error( bBracket ? SbERR_BAD_BRACKETS : SbERR_EXPECTED, COMMA );
bError = true;
}
else
@@ -1036,7 +1111,9 @@ SbiParameters::SbiParameters( SbiParser* p, bool bStandaloneExpression, bool bPa
pParser->Next();
eTok = pParser->Peek();
if( ( bBracket && eTok == RPAREN ) || pParser->IsEoln( eTok ) )
+ {
break;
+ }
}
}
// closing bracket
@@ -1089,9 +1166,13 @@ SbiDimList::SbiDimList( SbiParser* p ) : SbiExprList( p )
bError = bError || !pExpr1->IsValid() || !pExpr2->IsValid();
pExpr1->pNext = pExpr2;
if( !pLast )
+ {
pFirst = pExpr1;
+ }
else
+ {
pLast->pNext = pExpr1;
+ }
pLast = pExpr2;
nExpr += 2;
}
@@ -1102,9 +1183,13 @@ SbiDimList::SbiDimList( SbiParser* p ) : SbiExprList( p )
bConst = bConst && pExpr1->IsIntConstant();
bError = bError || !pExpr1->IsValid();
if( !pLast )
+ {
pFirst = pLast = pExpr1;
+ }
else
+ {
pLast->pNext = pExpr1, pLast = pExpr1;
+ }
nExpr++;
}
nDim++;
diff --git a/basic/source/comp/loops.cxx b/basic/source/comp/loops.cxx
index b2e7eb7736c4..51953e068ca9 100644
--- a/basic/source/comp/loops.cxx
+++ b/basic/source/comp/loops.cxx
@@ -460,11 +460,19 @@ void SbiParser::On()
SbiToken eTok = Peek();
String aString = SbiTokenizer::Symbol(eTok);
if (aString.EqualsIgnoreCaseAscii("ERROR"))
+ {
eTok = _ERROR_; // Error comes as SYMBOL
- if( eTok != _ERROR_ && eTok != LOCAL ) OnGoto();
+ }
+ if( eTok != _ERROR_ && eTok != LOCAL )
+ {
+ OnGoto();
+ }
else
{
- if( eTok == LOCAL ) Next();
+ if( eTok == LOCAL )
+ {
+ Next();
+ }
Next (); // no more TestToken, as there'd be an error otherwise
Next(); // get token after error
@@ -476,7 +484,9 @@ void SbiParser::On()
if( MayBeLabel() )
{
if( eCurTok == NUMBER && !nVal )
+ {
aGen.Gen( _STDERROR );
+ }
else
{
sal_uInt32 nOff = pProc->GetLabels().Reference( aSym );
@@ -487,12 +497,18 @@ void SbiParser::On()
{
Next();
if( eCurTok == NUMBER && nVal == 1 )
+ {
aGen.Gen( _STDERROR );
+ }
else
+ {
bError_ = true;
+ }
}
if( bError_ )
+ {
Error( SbERR_LABEL_EXPECTED );
+ }
}
else if( eCurTok == RESUME )
{
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index c1f175206a23..587b478fcf9e 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -628,11 +628,15 @@ void SbiParser::LSet()
{
SbiExpression aLvalue( this, SbLVALUE );
if( aLvalue.GetType() != SbxSTRING )
+ {
Error( SbERR_INVALID_OBJECT );
+ }
TestToken( EQ );
SbiSymDef* pDef = aLvalue.GetRealVar();
if( pDef && pDef->GetConstDef() )
+ {
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
+ }
SbiExpression aExpr( this );
aLvalue.Gen();
aExpr.Gen();
@@ -644,7 +648,9 @@ void SbiParser::RSet()
{
SbiExpression aLvalue( this, SbLVALUE );
if( aLvalue.GetType() != SbxSTRING )
+ {
Error( SbERR_INVALID_OBJECT );
+ }
TestToken( EQ );
SbiSymDef* pDef = aLvalue.GetRealVar();
if( pDef && pDef->GetConstDef() )
@@ -772,11 +778,17 @@ void SbiParser::Option()
{
SbiToken eTok = Next();
if( eTok == BINARY )
+ {
bText = false;
+ }
else if( eTok == SYMBOL && GetSym().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("text")) )
+ {
bText = true;
+ }
else
+ {
Error( SbERR_EXPECTED, "Text/Binary" );
+ }
break;
}
case COMPATIBLE:
@@ -794,11 +806,15 @@ void SbiParser::Option()
{
bVBASupportOn = ( nVal == 1 );
if ( bVBASupportOn )
+ {
EnableCompatibility();
+ }
// if the module setting is different
// reset it to what the Option tells us
if ( bVBASupportOn != aGen.GetModule().IsVBACompat() )
+ {
aGen.GetModule().SetVBACompat( bVBASupportOn );
+ }
break;
}
}
diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx
index b3ee0a18f5ec..a9288d3d1d2a 100644
--- a/basic/source/comp/sbcomp.cxx
+++ b/basic/source/comp/sbcomp.cxx
@@ -284,8 +284,9 @@ String lcl_dumpMethodParameters( SbMethod* pMethod )
{
String aStr;
if( pMethod == NULL )
+ {
return aStr;
-
+ }
SbxError eOld = SbxBase::GetError();
SbxArray* pParams = pMethod->GetParameters();
@@ -299,12 +300,16 @@ String lcl_dumpMethodParameters( SbMethod* pMethod )
SbxVariable* pVar = pParams->Get( nParam );
DBG_ASSERT( pVar, "Parameter?!" );
if ( pVar->GetName().Len() )
+ {
aStr += pVar->GetName();
+ }
else if ( pInfo )
{
const SbxParamInfo* pParam = pInfo->GetParam( nParam );
if ( pParam )
+ {
aStr += pParam->aName;
+ }
}
aStr += '=';
SbxDataType eType = pVar->GetType();
@@ -320,8 +325,9 @@ String lcl_dumpMethodParameters( SbMethod* pMethod )
SbxBase::ResetError();
if( eOld != SbxERR_OK )
+ {
SbxBase::SetError( eOld );
-
+ }
return aStr;
}
@@ -386,7 +392,9 @@ void lcl_printTimeOutput( void )
{
FunctionItem* pFunctionItem = it->second;
if( pFunctionItem != NULL )
+ {
avFunctionItems.push_back( pFunctionItem );
+ }
}
std::sort( avFunctionItems.begin(), avFunctionItems.end(), compareFunctionNetTime );
@@ -407,10 +415,12 @@ void lcl_printTimeOutput( void )
double dFctNetTimePercent = 100.0 * dFctNetTime / dTotalTime;
int nSpaceCount = 30 - nNameLen;
if( nSpaceCount < 0 )
+ {
nSpaceCount = 2;
+ }
sprintf( TimeBuffer, "%s:%sCalled %d times\t%f ms (%f%%) / net %f (%f%%) ms",
- pName, lcl_getSpaces( nSpaceCount ), pFunctionItem->m_nCallCount,
- dFctTotalTime*1000.0, dFctTotalTimePercent, dFctNetTime*1000.0, dFctNetTimePercent );
+ pName, lcl_getSpaces( nSpaceCount ), pFunctionItem->m_nCallCount,
+ dFctTotalTime*1000.0, dFctTotalTimePercent, dFctNetTime*1000.0, dFctNetTimePercent );
lcl_lineOut( TimeBuffer );
}
}
@@ -427,7 +437,9 @@ void dbg_InitTrace( void )
{
#ifdef DBG_TRACE_PROFILING
if( GbTimerOn )
+ {
GpTimer->continueTimer();
+ }
#endif
GpGlobalFile = fopen( GpTraceFileName, "a+" );
return;
@@ -435,15 +447,19 @@ void dbg_InitTrace( void )
GbInitTraceAlreadyCalled = true;
if( const sal_Char* pcIniFileName = ::getenv( "OOO_BASICTRACEINI" ) )
+ {
lcl_ReadIniFile( pcIniFileName );
+ }
else if( GpTraceIniFile != NULL )
+ {
lcl_ReadIniFile( GpTraceIniFile );
-
+ }
GpGlobalFile = fopen( GpTraceFileName, "w" );
GbSavTraceOn = GbTraceOn;
if( !GbTraceOn )
+ {
lcl_lineOut( "### Program started with trace off ###" );
-
+ }
#ifdef DBG_TRACE_PROFILING
GpTimer = new canvas::tools::ElapsedTime();
GdStartTime = GpTimer->getElapsedTime();
@@ -459,14 +475,19 @@ void dbg_DeInitTrace( void )
#ifdef DBG_TRACE_PROFILING
while( !GaCallEnterTimeStack.empty() )
+ {
GaCallEnterTimeStack.pop();
+ }
while( !GaFunctionItemStack.empty() )
+ {
GaFunctionItemStack.pop();
-
+ }
lcl_printTimeOutput();
for( FunctionItemMap::iterator it = GaFunctionItemMap.begin() ; it != GaFunctionItemMap.end() ; ++it )
+ {
delete it->second;
+ }
GaFunctionItemMap.clear();
if( GpGlobalFile )
@@ -478,7 +499,9 @@ void dbg_DeInitTrace( void )
if( GbInitOnlyAtOfficeStart )
{
if( GbTimerOn )
+ {
GpTimer->pauseTimer();
+ }
}
else
{
@@ -492,8 +515,9 @@ static sal_Int32 GnLastCallLvl = 0;
void dbg_tracePrint( const String& aStr, sal_Int32 nCallLvl, bool bCallLvlRelativeToCurrent )
{
if( bCallLvlRelativeToCurrent )
+ {
nCallLvl += GnLastCallLvl;
-
+ }
int nIndent = nCallLvl * GnIndentPerCallLevel;
lcl_lineOut( OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) );
}
@@ -501,12 +525,14 @@ void dbg_tracePrint( const String& aStr, sal_Int32 nCallLvl, bool bCallLvlRelati
void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
{
if( !GbTraceOn )
+ {
return;
-
+ }
#ifdef DBG_TRACE_PROFILING
if( GbBlockSteps || GbBlockAll )
+ {
return;
-
+ }
double dCurTime = 0.0;
bool bPrintTimeStamp = false;
if( GbTimerOn )
@@ -562,8 +588,9 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
const rtl::OString& rStr_STMNT = rTraceTextData.m_aTraceStr_STMNT;
bool bSTMT = false;
if( rStr_STMNT.getLength() )
+ {
bSTMT = true;
-
+ }
char TimeBuffer[200];
#ifdef DBG_TRACE_PROFILING
if( bPrintTimeStamp )
@@ -577,14 +604,16 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
if( bSTMT )
{
lcl_lineOut( rStr_STMNT.getStr(), lcl_getSpaces( nIndent ),
- (bPrintTimeStamp && !GbIncludePCodes) ? TimeBuffer : NULL );
+ (bPrintTimeStamp && !GbIncludePCodes) ? TimeBuffer : NULL );
}
if( !GbIncludePCodes )
{
#ifdef DBG_TRACE_PROFILING
if( GbTimerOn )
+ {
GpTimer->continueTimer();
+ }
#endif
return;
}
@@ -594,12 +623,14 @@ void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl )
if( rStr_PCode.getLength() )
{
lcl_lineOut( rStr_PCode.getStr(), lcl_getSpaces( nIndent ),
- bPrintTimeStamp ? TimeBuffer : NULL );
+ bPrintTimeStamp ? TimeBuffer : NULL );
}
#ifdef DBG_TRACE_PROFILING
if( GbTimerOn )
+ {
GpTimer->continueTimer();
+ }
#endif
}
@@ -609,8 +640,9 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
static const char* pSeparator = "' ================================================================================";
if( !GbTraceOn )
+ {
return;
-
+ }
#ifdef DBG_TRACE_PROFILING
double dCurTime = 0.0;
double dExecutionTime = 0.0;
@@ -651,8 +683,9 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
{
FunctionItemMap::iterator itFunctionItem = GaFunctionItemMap.find( aCompleteFunctionName );
if( itFunctionItem != GaFunctionItemMap.end() )
+ {
pFunctionItem = itFunctionItem->second;
-
+ }
if( pFunctionItem == NULL )
{
DBG_ASSERT( !bLeave, "No FunctionItem in leave!" );
@@ -710,13 +743,17 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
if( bOwnBlockAll )
{
if( GbTimerOn )
+ {
GpTimer->continueTimer();
+ }
return;
}
#endif
if( nCallLvl > 0 )
+ {
nCallLvl--;
+ }
int nIndent = nCallLvl * GnIndentPerCallLevel;
if( !bLeave && !bOwnBlockSteps )
{
@@ -747,8 +784,9 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
aStr.AppendAscii( "]" );
}
if( !bLeave )
+ {
aStr += lcl_dumpMethodParameters( pMethod );
-
+ }
const char* pPostStr = NULL;
#ifdef DBG_TRACE_PROFILING
char TimeBuffer[200];
@@ -759,26 +797,34 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallL
}
#endif
lcl_lineOut( (!bLeave || !bOwnBlockSteps) ? OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr() : "}",
- lcl_getSpaces( nIndent ), pPostStr );
+ lcl_getSpaces( nIndent ), pPostStr );
if( !bLeave )
+ {
lcl_lineOut( "{", lcl_getSpaces( nIndent ) );
-
+ }
if( bLeave && !bOwnBlockSteps )
+ {
lcl_lineOut( "" );
-
+ }
#ifdef DBG_TRACE_PROFILING
if( GbTimerOn )
+ {
GpTimer->continueTimer();
+ }
#endif
}
void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, sal_Int32 nCallLvl )
{
if( !GbTraceOn )
+ {
return;
+ }
#ifdef DBG_TRACE_PROFILING
if( GbBlockSteps || GbBlockAll )
+ {
return;
+ }
#endif
GnLastCallLvl = nCallLvl;
@@ -871,7 +917,9 @@ void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
lcl_lineOut( Buffer, lcl_getSpaces( nIndent ) );
if( eOld != SbxERR_OK )
+ {
SbxBase::SetError( eOld );
+ }
}
}
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 395f19aa24ca..4c550497a423 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -168,7 +168,9 @@ void SbiSymPool::Add( SbiSymDef* pDef )
}
if( !pDef->GetProcDef() )
+ {
pDef->nProcId = nProcId;
+ }
pDef->pIn = this;
aData.insert( aData.begin() + pDef->nPos, pDef );
}
@@ -186,9 +188,13 @@ SbiSymDef* SbiSymPool::Find( const String& rName ) const
return p;
}
if( pParent )
+ {
return pParent->Find( rName );
+ }
else
+ {
return NULL;
+ }
}
@@ -198,12 +204,18 @@ SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const
{
SbiSymDef* p = aData[ i ];
if( p->nId == n && ( !p->nProcId || ( p->nProcId == nProcId ) ) )
+ {
return p;
+ }
}
if( pParent )
+ {
return pParent->FindId( n );
+ }
else
+ {
return NULL;
+ }
}
// find via position (from 0)
@@ -211,20 +223,29 @@ SbiSymDef* SbiSymPool::FindId( sal_uInt16 n ) const
SbiSymDef* SbiSymPool::Get( sal_uInt16 n ) const
{
if( n >= aData.size() )
+ {
return NULL;
+ }
else
+ {
return aData[ n ];
+ }
}
sal_uInt32 SbiSymPool::Define( const String& rName )
{
SbiSymDef* p = Find( rName );
if( p )
- { if( p->IsDefined() )
+ {
+ if( p->IsDefined() )
+ {
pParser->Error( SbERR_LABEL_DEFINED, rName );
+ }
}
else
+ {
p = AddSym( rName );
+ }
return p->Define();
}
@@ -232,7 +253,9 @@ sal_uInt32 SbiSymPool::Reference( const String& rName )
{
SbiSymDef* p = Find( rName );
if( !p )
+ {
p = AddSym( rName );
+ }
// to be sure
pParser->aGen.GenStmnt();
return p->Reference();
@@ -245,7 +268,9 @@ void SbiSymPool::CheckRefs()
{
SbiSymDef* p = aData[ i ];
if( !p->IsDefined() )
+ {
pParser->Error( SbERR_UNDEF_LABEL, p->GetName() );
+ }
}
}
@@ -300,7 +325,9 @@ SbiConstDef* SbiSymDef::GetConstDef()
const String& SbiSymDef::GetName()
{
if( pIn )
+ {
aName = pIn->rStrings.Find( nId );
+ }
return aName;
}
@@ -354,7 +381,9 @@ sal_uInt32 SbiSymDef::Define()
SbiSymPool& SbiSymDef::GetPool()
{
if( !pPool )
+ {
pPool = new SbiSymPool( pIn->pParser->aGblStrings, SbLOCAL ); // is dumped
+ }
return *pPool;
}
@@ -422,7 +451,9 @@ void SbiProcDef::Match( SbiProcDef* pOld )
// no type matching - that is done during running
// but is it maybe called with too little parameters?
if( !po && !pn->IsOptional() && !pn->IsParamArray() )
+ {
break;
+ }
po = pOld->aParams.Next();
}
@@ -498,7 +529,9 @@ SbiConstDef* SbiConstDef::GetConstDef()
SbiSymbols::~SbiSymbols()
{
for( const_iterator it = begin(); it != end(); ++it )
+ {
delete *it;
+ }
};
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index 0de57e6356b0..7ebcb17eeb43 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -28,7 +28,6 @@ static short nToken; // number of tokens
static TokenTable* pTokTable;
static TokenTable aTokTable_Basic [] = {
-
{ CAT, "&" },
{ MUL, "*" },
{ PLUS, "+" },
@@ -188,16 +187,19 @@ TokenLabelInfo::TokenLabelInfo( void )
{
m_pTokenCanBeLabelTab = new bool[VBASUPPORT+1];
for( int i = 0 ; i <= VBASUPPORT ; ++i )
+ {
m_pTokenCanBeLabelTab[i] = false;
-
+ }
// Token accepted as label by VBA
SbiToken eLabelToken[] = { ACCESS, ALIAS, APPEND, BASE, BINARY, CLASSMODULE,
- COMPARE, COMPATIBLE, DEFERR, _ERROR_, EXPLICIT, LIB, LINE, LPRINT, NAME,
- TOBJECT, OUTPUT, PROPERTY, RANDOM, READ, STEP, STOP, TEXT, VBASUPPORT, NIL };
+ COMPARE, COMPATIBLE, DEFERR, _ERROR_, EXPLICIT, LIB, LINE, LPRINT, NAME,
+ TOBJECT, OUTPUT, PROPERTY, RANDOM, READ, STEP, STOP, TEXT, VBASUPPORT, NIL };
SbiToken* pTok = eLabelToken;
SbiToken eTok;
for( pTok = eLabelToken ; (eTok = *pTok) != NIL ; ++pTok )
+ {
m_pTokenCanBeLabelTab[eTok] = true;
+ }
}
TokenLabelInfo::~TokenLabelInfo()
@@ -218,7 +220,10 @@ SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb )
ePush = NIL;
bEos = bKeywords = bErrorIsSymbol = true;
if( !nToken )
- for( nToken = 0, tp = pTokTable; tp->t; nToken++, tp++ ) {}
+ {
+ for( nToken = 0, tp = pTokTable; tp->t; nToken++, tp++ )
+ {}
+ }
}
SbiTokenizer::~SbiTokenizer()
@@ -280,16 +285,17 @@ const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t )
}
switch( t )
{
- case NEG :
- aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
- return aSym;
- case EOS :
- aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":/CRLF"));
- return aSym;
- case EOLN :
- aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CRLF"));
- return aSym;
- default: break;
+ case NEG :
+ aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-"));
+ return aSym;
+ case EOS :
+ aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":/CRLF"));
+ return aSym;
+ case EOLN :
+ aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CRLF"));
+ return aSym;
+ default:
+ break;
}
TokenTable* tp = pTokTable;
for( short i = 0; i < nToken; i++, tp++ )
@@ -302,7 +308,9 @@ const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t )
}
const sal_Unicode *p = aSym.getStr();
if (*p <= ' ')
+ {
aSym = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("???"));
+ }
return aSym;
}
@@ -313,7 +321,10 @@ const ::rtl::OUString& SbiTokenizer::Symbol( SbiToken t )
SbiToken SbiTokenizer::Next()
{
- if (bEof) return EOLN;
+ if (bEof)
+ {
+ return EOLN;
+ }
// have read in one already?
if( ePush != NIL )
{
@@ -340,16 +351,23 @@ SbiToken SbiTokenizer::Next()
bEos = false;
if( bNumber )
+ {
return eCurTok = NUMBER;
-
+ }
else if( ( eScanType == SbxDATE || eScanType == SbxSTRING ) && !bSymbol )
+ {
return eCurTok = FIXSTRING;
+ }
// Special cases of characters that are between "Z" and "a". ICompare()
// evaluates the position of these characters in different ways.
else if( aSym[0] == '^' )
+ {
return eCurTok = EXPON;
+ }
else if( aSym[0] == '\\' )
+ {
return eCurTok = IDIV;
+ }
else
{
if( eScanType != SbxVARIANT
@@ -366,32 +384,52 @@ SbiToken SbiTokenizer::Next()
sal_Int32 res = aSym.compareToIgnoreAsciiCaseAscii( tp->s );
if( res == 0 )
+ {
goto special;
-
+ }
if( res < 0 )
{
- if ((ub - lb) == 2) ub = lb;
- else ub = ub - delta;
+ if ((ub - lb) == 2)
+ {
+ ub = lb;
+ }
+ else
+ {
+ ub = ub - delta;
+ }
}
else
{
- if ((ub -lb) == 2) lb = ub;
- else lb = lb + delta;
+ if ((ub -lb) == 2)
+ {
+ lb = ub;
+ }
+ else
+ {
+ lb = lb + delta;
+ }
}
- } while( delta );
+ }
+ while( delta );
// Symbol? if not >= token
sal_Unicode ch = aSym[0];
if( !theBasicCharClass::get().isAlpha( ch, bCompatible ) && !bSymbol )
+ {
return eCurTok = (SbiToken) (ch & 0x00FF);
+ }
return eCurTok = SYMBOL;
}
special:
// #i92642
bool bStartOfLine = (eCurTok == NIL || eCurTok == REM || eCurTok == EOLN);
if( !bStartOfLine && (tp->t == NAME || tp->t == LINE) )
+ {
return eCurTok = SYMBOL;
+ }
else if( tp->t == TEXT )
+ {
return eCurTok = SYMBOL;
+ }
// maybe we can expand this for other statements that have parameters
// that are keywords ( and those keywords are only used within such
// statements )
@@ -400,8 +438,9 @@ special:
// we just treat keyword 'append' as a normal 'SYMBOL'.
// Also we accept Dim APPEND
else if ( ( !bInStatement || eCurTok == DIM ) && tp->t == APPEND )
+ {
return eCurTok = SYMBOL;
-
+ }
// #i92642: Special LINE token handling -> SbiParser::Line()
// END IF, CASE, SUB, DEF, FUNCTION, TYPE, CLASS, WITH
@@ -419,15 +458,15 @@ special:
eCurTok = Peek();
switch( eCurTok )
{
- case IF: Next(); eCurTok = ENDIF; break;
- case SELECT: Next(); eCurTok = ENDSELECT; break;
- case SUB: Next(); eCurTok = ENDSUB; break;
- case FUNCTION: Next(); eCurTok = ENDFUNC; break;
- case PROPERTY: Next(); eCurTok = ENDPROPERTY; break;
- case TYPE: Next(); eCurTok = ENDTYPE; break;
- case ENUM: Next(); eCurTok = ENDENUM; break;
- case WITH: Next(); eCurTok = ENDWITH; break;
- default : eCurTok = END;
+ case IF: Next(); eCurTok = ENDIF; break;
+ case SELECT: Next(); eCurTok = ENDSELECT; break;
+ case SUB: Next(); eCurTok = ENDSUB; break;
+ case FUNCTION: Next(); eCurTok = ENDFUNC; break;
+ case PROPERTY: Next(); eCurTok = ENDPROPERTY; break;
+ case TYPE: Next(); eCurTok = ENDTYPE; break;
+ case ENUM: Next(); eCurTok = ENDENUM; break;
+ case WITH: Next(); eCurTok = ENDWITH; break;
+ default : eCurTok = END; break;
}
nCol1 = nOldCol1;
if( eCurTok == END )
@@ -447,13 +486,19 @@ special:
eCurTok = tp->t;
// AS: data types are keywords
if( tp->t == AS )
+ {
bAs = true;
+ }
else
{
if( bAs )
+ {
bAs = false;
+ }
else if( eCurTok >= DATATYPE1 && eCurTok <= DATATYPE2 && (bErrorIsSymbol || eCurTok != _ERROR_) )
+ {
eCurTok = SYMBOL;
+ }
}
// CLASSMODULE, PROPERTY, GET, ENUM token only visible in compatible mode
@@ -462,10 +507,13 @@ special:
{
// #129904 Suppress system
if( eTok == STOP && aSym.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("system")) )
+ {
eCurTok = SYMBOL;
-
+ }
if( eTok == GET && bStartOfLine )
+ {
eCurTok = SYMBOL;
+ }
}
else
{
@@ -493,11 +541,15 @@ special:
bool SbiTokenizer::MayBeLabel( bool bNeedsColon )
{
if( eCurTok == SYMBOL || m_aTokenLabelInfo.canTokenBeLabel( eCurTok ) )
+ {
return bNeedsColon ? DoesColonFollow() : true;
+ }
else
+ {
return ( eCurTok == NUMBER
&& eScanType == SbxINTEGER
&& nVal >= 0 );
+ }
}
#ifdef _MSC_VER
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index d03b8a67d58d..d1d7c32631cc 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -142,32 +142,42 @@ SbiStream::~SbiStream()
void SbiStream::MapError()
{
if( pStrm )
- switch( pStrm->GetError() )
- {
+ {
+ switch( pStrm->GetError() )
+ {
case SVSTREAM_OK:
- nError = 0; break;
+ nError = 0;
+ break;
case SVSTREAM_FILE_NOT_FOUND:
- nError = SbERR_FILE_NOT_FOUND; break;
+ nError = SbERR_FILE_NOT_FOUND;
+ break;
case SVSTREAM_PATH_NOT_FOUND:
- nError = SbERR_PATH_NOT_FOUND; break;
+ nError = SbERR_PATH_NOT_FOUND;
+ break;
case SVSTREAM_TOO_MANY_OPEN_FILES:
- nError = SbERR_TOO_MANY_FILES; break;
+ nError = SbERR_TOO_MANY_FILES;
+ break;
case SVSTREAM_ACCESS_DENIED:
- nError = SbERR_ACCESS_DENIED; break;
+ nError = SbERR_ACCESS_DENIED;
+ break;
case SVSTREAM_INVALID_PARAMETER:
- nError = SbERR_BAD_ARGUMENT; break;
+ nError = SbERR_BAD_ARGUMENT;
+ break;
case SVSTREAM_OUTOFMEMORY:
- nError = SbERR_NO_MEMORY; break;
+ nError = SbERR_NO_MEMORY;
+ break;
default:
- nError = SbERR_IO_ERROR; break;
+ nError = SbERR_IO_ERROR;
+ break;
+ }
}
}
// TODO: Code is copied from daemons2/source/uno/asciiEncoder.cxx
-::rtl::OUString findUserInDescription( const ::rtl::OUString& aDescription )
+OUString findUserInDescription( const ::rtl::OUString& aDescription )
{
- ::rtl::OUString user;
+ OUString user;
sal_Int32 index;
sal_Int32 lastIndex = 0;
@@ -175,13 +185,13 @@ void SbiStream::MapError()
do
{
index = aDescription.indexOf((sal_Unicode) ',', lastIndex);
- ::rtl::OUString token = (index == -1) ? aDescription.copy(lastIndex) : aDescription.copy(lastIndex, index - lastIndex);
+ OUString token = (index == -1) ? aDescription.copy(lastIndex) : aDescription.copy(lastIndex, index - lastIndex);
lastIndex = index + 1;
sal_Int32 eindex = token.indexOf((sal_Unicode)'=');
- ::rtl::OUString left = token.copy(0, eindex).toAsciiLowerCase().trim();
- ::rtl::OUString right = INetURLObject::decode( token.copy(eindex + 1).trim(), '%',
+ OUString left = token.copy(0, eindex).toAsciiLowerCase().trim();
+ OUString right = INetURLObject::decode( token.copy(eindex + 1).trim(), '%',
INetURLObject::DECODE_WITH_CHARSET );
if( left == "user" )
@@ -206,7 +216,7 @@ bool needSecurityRestrictions( void )
// Get system user to compare to portal user
oslSecurity aSecurity = osl_getCurrentSecurity();
- ::rtl::OUString aSystemUser;
+ OUString aSystemUser;
sal_Bool bRet = osl_getUserName( aSecurity, &aSystemUser.pData );
if( !bRet )
{
@@ -234,8 +244,8 @@ bool needSecurityRestrictions( void )
for( i = 0 ; i < nBridgeCount ; i++ )
{
const Reference< XBridge >& rxBridge = pBridges[ i ];
- ::rtl::OUString aDescription = rxBridge->getDescription();
- ::rtl::OUString aPortalUser = findUserInDescription( aDescription );
+ OUString aDescription = rxBridge->getDescription();
+ OUString aPortalUser = findUserInDescription( aDescription );
if( !aPortalUser.isEmpty() )
{
// User Found, compare to system user
@@ -297,12 +307,12 @@ class OslStream : public SvStream
public:
OslStream( const String& rName, short nStrmMode );
- ~OslStream();
+ ~OslStream();
virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize );
virtual sal_uIntPtr PutData( const void* pData, sal_uIntPtr nSize );
virtual sal_uIntPtr SeekPos( sal_uIntPtr nPos );
- virtual void FlushData();
- virtual void SetSize( sal_uIntPtr nSize );
+ virtual void FlushData();
+ virtual void SetSize( sal_uIntPtr nSize );
};
OslStream::OslStream( const String& rName, short nStrmMode )
@@ -360,9 +370,13 @@ sal_uIntPtr OslStream::SeekPos( sal_uIntPtr nPos )
{
::osl::FileBase::RC rc = ::osl::FileBase::E_None;
if( nPos == STREAM_SEEK_TO_END )
+ {
rc = maFile.setPos( osl_Pos_End, 0 );
+ }
else
+ {
rc = maFile.setPos( osl_Pos_Absolut, (sal_uInt64)nPos );
+ }
OSL_VERIFY(rc == ::osl::FileBase::E_None);
sal_uInt64 nRealPos(0);
maFile.getPos( nRealPos );
@@ -385,14 +399,14 @@ class UCBStream : public SvStream
Reference< XStream > xS;
Reference< XSeekable > xSeek;
public:
- UCBStream( Reference< XInputStream > & xIS );
- UCBStream( Reference< XStream > & xS );
- ~UCBStream();
+ UCBStream( Reference< XInputStream > & xIS );
+ UCBStream( Reference< XStream > & xS );
+ ~UCBStream();
virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize );
virtual sal_uIntPtr PutData( const void* pData, sal_uIntPtr nSize );
virtual sal_uIntPtr SeekPos( sal_uIntPtr nPos );
- virtual void FlushData();
- virtual void SetSize( sal_uIntPtr nSize );
+ virtual void FlushData();
+ virtual void SetSize( sal_uIntPtr nSize );
};
UCBStream::UCBStream( Reference< XInputStream > & rStm )
@@ -413,12 +427,16 @@ UCBStream::~UCBStream()
try
{
if( xIS.is() )
+ {
xIS->closeInput();
+ }
else if( xS.is() )
{
Reference< XInputStream > xIS_ = xS->getInputStream();
if( xIS_.is() )
+ {
xIS_->closeInput();
+ }
}
}
catch(const Exception & )
@@ -447,7 +465,9 @@ sal_uIntPtr UCBStream::GetData( void* pData, sal_uIntPtr nSize )
return nSize;
}
else
+ {
SetError( ERRCODE_IO_GENERAL );
+ }
}
catch(const Exception & )
{
@@ -468,7 +488,9 @@ sal_uIntPtr UCBStream::PutData( const void* pData, sal_uIntPtr nSize )
return nSize;
}
else
+ {
SetError( ERRCODE_IO_GENERAL );
+ }
}
catch(const Exception & )
{
@@ -485,12 +507,16 @@ sal_uIntPtr UCBStream::SeekPos( sal_uIntPtr nPos )
{
sal_uIntPtr nLen = sal::static_int_cast<sal_uIntPtr>( xSeek->getLength() );
if( nPos > nLen )
+ {
nPos = nLen;
+ }
xSeek->seek( nPos );
return nPos;
}
else
+ {
SetError( ERRCODE_IO_GENERAL );
+ }
}
catch(const Exception & )
{
@@ -499,15 +525,19 @@ sal_uIntPtr UCBStream::SeekPos( sal_uIntPtr nPos )
return 0;
}
-void UCBStream::FlushData()
+void UCBStream::FlushData()
{
try
{
Reference< XOutputStream > xOSFromS;
if( xS.is() && (xOSFromS = xS->getOutputStream()).is() )
+ {
xOSFromS->flush();
+ }
else
+ {
SetError( ERRCODE_IO_GENERAL );
+ }
}
catch(const Exception & )
{
@@ -583,10 +613,14 @@ SbError SbiStream::Open
pStrm = new OslStream( aNameStr, nStrmMode );
}
if( IsAppend() )
+ {
pStrm->Seek( STREAM_SEEK_TO_END );
+ }
MapError();
if( nError )
+ {
delete pStrm, pStrm = NULL;
+ }
return nError;
}
@@ -613,9 +647,13 @@ SbError SbiStream::Read(rtl::OString& rBuf, sal_uInt16 n, bool bForceReadingPerB
else
{
if( !n )
+ {
n = nLen;
+ }
if( !n )
+ {
return nError = SbERR_BAD_RECORD_LENGTH;
+ }
rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*pStrm, n));
//Pad it out with ' ' to the requested length on short read
sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n);
@@ -624,7 +662,9 @@ SbError SbiStream::Read(rtl::OString& rBuf, sal_uInt16 n, bool bForceReadingPerB
}
MapError();
if( !nError && pStrm->IsEof() )
+ {
nError = SbERR_READ_PAST_EOF;
+ }
return nError;
}
@@ -651,7 +691,9 @@ void SbiStream::ExpandFile()
sal_uIntPtr nDiff = nExpandOnWriteTo - nCur;
char c = 0;
while( nDiff-- )
+ {
*pStrm << c;
+ }
}
else
{
@@ -675,8 +717,9 @@ SbError SbiStream::Write( const rtl::OString& rBuf, sal_uInt16 n )
{
ExpandFile();
if( IsAppend() )
+ {
pStrm->Seek( STREAM_SEEK_TO_END );
-
+ }
if( IsText() )
{
aLine = aLine + rBuf;
@@ -687,7 +730,9 @@ SbError SbiStream::Write( const rtl::OString& rBuf, sal_uInt16 n )
{
aLine = aLine.copy(0, nLineLen);
if (nLineLen && aLine[--nLineLen] == 0x0D)
+ {
aLine = aLine.copy(0, nLineLen);
+ }
WriteLines(*pStrm, aLine);
aLine = rtl::OString();
}
@@ -695,9 +740,13 @@ SbError SbiStream::Write( const rtl::OString& rBuf, sal_uInt16 n )
else
{
if( !n )
+ {
n = nLen;
+ }
if( !n )
+ {
return nError = SbERR_BAD_RECORD_LENGTH;
+ }
pStrm->Write(rBuf.getStr(), n);
MapError();
}
@@ -716,7 +765,9 @@ SbiIoSystem* SbGetIoSystem()
SbiIoSystem::SbiIoSystem()
{
for( short i = 0; i < CHANNELS; i++ )
+ {
pChan[ i ] = NULL;
+ }
nChan = 0;
nError = 0;
}
@@ -736,15 +787,21 @@ void SbiIoSystem::Open(short nCh, const rtl::OString& rName, short nMode, short
{
nError = 0;
if( nCh >= CHANNELS || !nCh )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else if( pChan[ nCh ] )
+ {
nError = SbERR_FILE_ALREADY_OPEN;
+ }
else
{
pChan[ nCh ] = new SbiStream;
nError = pChan[ nCh ]->Open( nCh, rName, nMode, nFlags, nLen );
- if( nError )
+ if( nError )
+ {
delete pChan[ nCh ], pChan[ nCh ] = NULL;
+ }
}
nChan = 0;
}
@@ -753,9 +810,13 @@ void SbiIoSystem::Open(short nCh, const rtl::OString& rName, short nMode, short
void SbiIoSystem::Close()
{
if( !nChan )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else if( !pChan[ nChan ] )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else
{
nError = pChan[ nChan ]->Close();
@@ -776,7 +837,9 @@ void SbiIoSystem::Shutdown()
delete pChan[ i ];
pChan[ i ] = NULL;
if( n && !nError )
+ {
nError = n;
+ }
}
}
nChan = 0;
@@ -798,11 +861,17 @@ void SbiIoSystem::Shutdown()
void SbiIoSystem::Read(rtl::OString& rBuf, short n)
{
if( !nChan )
+ {
ReadCon( rBuf );
+ }
else if( !pChan[ nChan ] )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else
+ {
nError = pChan[ nChan ]->Read( rBuf, n );
+ }
}
char SbiIoSystem::Read()
@@ -819,20 +888,30 @@ char SbiIoSystem::Read()
aIn = aIn.copy(1);
}
else if( !pChan[ nChan ] )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else
+ {
nError = pChan[ nChan ]->Read( ch );
+ }
return ch;
}
void SbiIoSystem::Write(const rtl::OString& rBuf, short n)
{
if( !nChan )
+ {
WriteCon( rBuf );
+ }
else if( !pChan[ nChan ] )
+ {
nError = SbERR_BAD_CHANNEL;
+ }
else
+ {
nError = pChan[ nChan ]->Write( rBuf, n );
+ }
}
// nChannel == 0..CHANNELS-1
@@ -841,7 +920,9 @@ SbiStream* SbiIoSystem::GetStream( short nChannel ) const
{
SbiStream* pRet = 0;
if( nChannel >= 0 && nChannel < CHANNELS )
+ {
pRet = pChan[ nChannel ];
+ }
return pRet;
}
@@ -855,7 +936,9 @@ void SbiIoSystem::CloseAll(void)
delete pChan[ i ];
pChan[ i ] = NULL;
if( n && !nError )
+ {
nError = n;
+ }
}
}
}
@@ -869,12 +952,16 @@ void SbiIoSystem::CloseAll(void)
void SbiIoSystem::ReadCon(rtl::OString& rIn)
{
- rtl::OUString aPromptStr(rtl::OStringToOUString(aPrompt, osl_getThreadTextEncoding()));
+ OUString aPromptStr(rtl::OStringToOUString(aPrompt, osl_getThreadTextEncoding()));
SbiInputDialog aDlg( NULL, aPromptStr );
if( aDlg.Execute() )
+ {
rIn = rtl::OUStringToOString(aDlg.GetInput(), osl_getThreadTextEncoding());
+ }
else
+ {
nError = SbERR_USER_ABORT;
+ }
aPrompt = rtl::OString();
}
@@ -888,9 +975,13 @@ void SbiIoSystem::WriteCon(const rtl::OString& rText)
if( n1 != -1 || n2 != -1 )
{
if( n1 == -1 )
+ {
n1 = n2;
+ }
else if( n2 == -1 )
+ {
n2 = n1;
+ }
if( n1 > n2 )
n1 = n2;
rtl::OString s(aOut.copy(0, n1));
@@ -903,7 +994,9 @@ void SbiIoSystem::WriteCon(const rtl::OString& rText)
if( !MessBox( GetpApp()->GetDefDialogParent(),
WinBits( WB_OK_CANCEL | WB_DEF_OK ),
String(), aStr ).Execute() )
+ {
nError = SbERR_USER_ABORT;
+ }
}
}
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 5dd64ff522a9..e189b2866d6d 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -154,7 +154,7 @@ static inline bool isFolder( FileStatus::Type aType )
// according to the setting done by ChDir/ChDrive
String getFullPath( const String& aRelPath )
{
- ::rtl::OUString aFileURL;
+ OUString aFileURL;
// #80204 Try first if it already is a valid URL
INetURLObject aURLObj( aRelPath );
@@ -178,7 +178,7 @@ static uno::Reference< ucb::XSimpleFileAccess3 > getFileAccess( void )
if( xSMgr.is() )
{
xSFI = uno::Reference< ucb::XSimpleFileAccess3 >( xSMgr->createInstance
- ( ::rtl::OUString("com.sun.star.ucb.SimpleFileAccess" ) ), uno::UNO_QUERY );
+ ( OUString("com.sun.star.ucb.SimpleFileAccess" ) ), uno::UNO_QUERY );
}
}
return xSFI;
@@ -229,9 +229,13 @@ RTLFUNC(Error)
{
nCode = rPar.Get( 1 )->GetLong();
if( nCode > 65535L )
+ {
StarBASIC::Error( SbERR_CONVERSION );
+ }
else
+ {
nErr = StarBASIC::GetSfxFromVBError( (sal_uInt16)nCode );
+ }
}
bool bVBA = SbiRuntime::isVBAEnabled();
@@ -252,7 +256,9 @@ RTLFUNC(Error)
{
uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() );
if ( xErrObj.is() && xErrObj->getNumber() == nCode && !xErrObj->getDescription().isEmpty() )
+ {
tmpErrMsg = xErrObj->getDescription();
+ }
}
rPar.Get( 0 )->PutString( tmpErrMsg );
}
@@ -312,7 +318,9 @@ RTLFUNC(Abs)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -327,7 +335,9 @@ RTLFUNC(Asc)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -348,12 +358,14 @@ RTLFUNC(Asc)
void implChr( SbxArray& rPar, bool bChrW )
{
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
- rtl::OUString aStr;
+ OUString aStr;
if( !bChrW && SbiRuntime::isVBAEnabled() )
{
sal_Char c = static_cast<sal_Char>(pArg->GetByte());
@@ -362,7 +374,7 @@ void implChr( SbxArray& rPar, bool bChrW )
else
{
sal_Unicode aCh = static_cast<sal_Unicode>(pArg->GetUShort());
- aStr = rtl::OUString(aCh);
+ aStr = OUString(aCh);
}
rPar.Get(0)->PutString( aStr );
}
@@ -421,14 +433,20 @@ RTLFUNC(CurDir)
return;
}
else
+ {
nCurDir -= ( 'A' - 1 );
+ }
}
}
char* pBuffer = new char[ _MAX_PATH ];
if ( _getdcwd( nCurDir, pBuffer, _MAX_PATH ) != 0 )
+ {
rPar.Get(0)->PutString( rtl::OUString::createFromAscii( pBuffer ) );
+ }
else
+ {
StarBASIC::Error( SbERR_NO_DEVICE );
+ }
delete [] pBuffer;
#elif defined( UNX )
@@ -471,6 +489,9 @@ RTLFUNC(ChDir)
{
// VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.)
if( SbiRuntime::isVBAEnabled() )
+ {
+ ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetOUString() );
+ }
::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() );
}
else
@@ -505,9 +526,13 @@ void implStepRenameUCB( const String& aSource, const String& aDest )
String aDestFullPath = getFullPath( aDest );
if( xSFI->exists( aDestFullPath ) )
+ {
StarBASIC::Error( SbERR_FILE_EXISTS );
+ }
else
+ {
xSFI->move( aSourceFullPath, aDestFullPath );
+ }
}
catch(const Exception & )
{
@@ -601,7 +626,9 @@ RTLFUNC(Kill)
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(MkDir)
@@ -635,7 +662,9 @@ RTLFUNC(MkDir)
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
@@ -744,7 +773,9 @@ RTLFUNC(RmDir)
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(SendKeys)
@@ -778,7 +809,9 @@ RTLFUNC(FileLen)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -818,7 +851,9 @@ RTLFUNC(Hex)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -890,8 +925,9 @@ RTLFUNC(InStr)
bTextMode = 1;;
}
if ( nArgCount == 4 )
+ {
bTextMode = rPar.Get(4)->GetInteger();
-
+ }
sal_uInt16 nPos;
const String& rToken = rPar.Get(nFirstStringPos+1)->GetString();
@@ -941,7 +977,9 @@ RTLFUNC(InStrRev)
sal_uIntPtr nArgCount = rPar.Count()-1;
if ( nArgCount < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aStr1 = rPar.Get(1)->GetString();
@@ -1073,7 +1111,9 @@ RTLFUNC(LCase)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
const CharClass& rCharClass = GetCharClass();
@@ -1089,7 +1129,9 @@ RTLFUNC(Left)
(void)bWrite;
if ( rPar.Count() < 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aStr( rPar.Get(1)->GetString() );
@@ -1114,7 +1156,9 @@ RTLFUNC(Log)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double aArg = rPar.Get(1)->GetDouble();
@@ -1125,7 +1169,9 @@ RTLFUNC(Log)
rPar.Get( 0 )->PutDouble( d );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
}
@@ -1135,10 +1181,12 @@ RTLFUNC(LTrim)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
- rtl::OUString aStr(string::stripStart(rPar.Get(1)->GetString(), ' '));
+ OUString aStr(comphelper::string::stripStart(rPar.Get(1)->GetOUString(), ' '));
rPar.Get(0)->PutString(aStr);
}
}
@@ -1153,7 +1201,9 @@ RTLFUNC(Mid)
sal_uIntPtr nArgCount = rPar.Count()-1;
if ( nArgCount < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// #23178: replicate the functionality of Mid$ as a command
@@ -1240,15 +1290,21 @@ RTLFUNC(Oct)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
char aBuffer[16];
SbxVariableRef pArg = rPar.Get( 1 );
if ( pArg->IsInteger() )
+ {
snprintf( aBuffer, sizeof(aBuffer), "%o", pArg->GetInteger() );
+ }
else
+ {
snprintf( aBuffer, sizeof(aBuffer), "%lo", static_cast<long unsigned int>(pArg->GetLong()) );
+ }
rPar.Get(0)->PutString( rtl::OUString::createFromAscii( aBuffer ) );
}
}
@@ -1262,7 +1318,9 @@ RTLFUNC(Replace)
sal_uIntPtr nArgCount = rPar.Count()-1;
if ( nArgCount < 3 || nArgCount > 6 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aExpStr = rPar.Get(1)->GetString();
@@ -1273,7 +1331,9 @@ RTLFUNC(Replace)
if ( nArgCount >= 4 )
{
if( rPar.Get(4)->GetType() != SbxEMPTY )
+ {
lStartPos = rPar.Get(4)->GetLong();
+ }
if( lStartPos < 1 || lStartPos > 0xffff )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -1285,7 +1345,9 @@ RTLFUNC(Replace)
if( nArgCount >=5 )
{
if( rPar.Get(5)->GetType() != SbxEMPTY )
+ {
lCount = rPar.Get(5)->GetLong();
+ }
if( lCount < -1 || lCount > 0xffff )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -1347,7 +1409,9 @@ RTLFUNC(Right)
(void)bWrite;
if ( rPar.Count() < 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
const OUString& rStr = rPar.Get(1)->GetOUString();
@@ -1381,10 +1445,12 @@ RTLFUNC(RTrim)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
- rtl::OUString aStr(string::stripEnd(rPar.Get(1)->GetString(), ' '));
+ OUString aStr(comphelper::string::stripEnd(rPar.Get(1)->GetOUString(), ' '));
rPar.Get(0)->PutString(aStr);
}
}
@@ -1395,15 +1461,21 @@ RTLFUNC(Sgn)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double aDouble = rPar.Get(1)->GetDouble();
sal_Int16 nResult = 0;
if ( aDouble > 0 )
+ {
nResult = 1;
+ }
else if ( aDouble < 0 )
+ {
nResult = -1;
+ }
rPar.Get(0)->PutInteger( nResult );
}
}
@@ -1414,7 +1486,9 @@ RTLFUNC(Space)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
rtl::OUStringBuffer aBuf;
@@ -1429,7 +1503,9 @@ RTLFUNC(Spc)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
rtl::OUStringBuffer aBuf;
@@ -1444,14 +1520,20 @@ RTLFUNC(Sqr)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double aDouble = rPar.Get(1)->GetDouble();
if ( aDouble >= 0 )
+ {
rPar.Get(0)->PutDouble( sqrt( aDouble ));
+ }
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
}
@@ -1461,7 +1543,9 @@ RTLFUNC(Str)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aStr;
@@ -1572,7 +1656,9 @@ RTLFUNC(String)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Unicode aFiller;
@@ -1599,7 +1685,9 @@ RTLFUNC(Tan)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -1613,7 +1701,9 @@ RTLFUNC(UCase)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
const CharClass& rCharClass = GetCharClass();
@@ -1630,7 +1720,9 @@ RTLFUNC(Val)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double nResult = 0.0;
@@ -1644,9 +1736,13 @@ RTLFUNC(Val)
int nRadix = 10;
char aChar = (char)aStr.GetBuffer()[1];
if ( aChar == 'h' || aChar == 'H' )
+ {
nRadix = 16;
+ }
else if ( aChar == 'o' || aChar == 'O' )
+ {
nRadix = 8;
+ }
if ( nRadix != 10 )
{
rtl::OString aByteStr(rtl::OUStringToOString(aStr, osl_getThreadTextEncoding()));
@@ -1715,7 +1811,9 @@ RTLFUNC(CDateToIso)
rPar.Get(0)->PutString( aRetStr );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
// Function to convert date from ISO 8601 date format
@@ -1740,7 +1838,9 @@ RTLFUNC(CDateFromIso)
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(DateSerial)
@@ -1759,7 +1859,9 @@ RTLFUNC(DateSerial)
double dDate;
if( implDateSerial( nYear, nMonth, nDay, dDate ) )
+ {
rPar.Get(0)->PutDate( dDate );
+ }
}
RTLFUNC(TimeSerial)
@@ -1774,7 +1876,9 @@ RTLFUNC(TimeSerial)
}
sal_Int16 nHour = rPar.Get(1)->GetInteger();
if ( nHour == 24 )
+ {
nHour = 0; // because of UNO DateTimes, which go till 24 o'clock
+ }
sal_Int16 nMinute = rPar.Get(2)->GetInteger();
sal_Int16 nSecond = rPar.Get(3)->GetInteger();
if ((nHour < 0 || nHour > 23) ||
@@ -1799,13 +1903,17 @@ RTLFUNC(DateValue)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// #39629 check GetSbData()->pInst, can be called from the URL line
SvNumberFormatter* pFormatter = NULL;
if( GetSbData()->pInst )
+ {
pFormatter = GetSbData()->pInst->GetNumberFormatter();
+ }
else
{
sal_uInt32 n; // Dummy
@@ -1839,18 +1947,25 @@ RTLFUNC(DateValue)
{
// cut time
if ( fResult > 0.0 )
+ {
fResult = floor( fResult );
+ }
else
+ {
fResult = ceil( fResult );
+ }
}
rPar.Get(0)->PutDate( fResult );
}
else
+ {
StarBASIC::Error( SbERR_CONVERSION );
-
+ }
// #39629 pFormatter can be requested itself
if( !GetSbData()->pInst )
+ {
delete pFormatter;
+ }
}
}
@@ -1860,7 +1975,9 @@ RTLFUNC(TimeValue)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SvNumberFormatter* pFormatter = NULL;
@@ -1880,15 +1997,20 @@ RTLFUNC(TimeValue)
if(bSuccess && (nType==NUMBERFORMAT_TIME||nType==NUMBERFORMAT_DATETIME))
{
if ( nType == NUMBERFORMAT_DATETIME )
+ {
// cut days
fResult = fmod( fResult, 1 );
+ }
rPar.Get(0)->PutDate( fResult );
}
else
+ {
StarBASIC::Error( SbERR_CONVERSION );
-
+ }
if( !GetSbData()->pInst )
+ {
delete pFormatter;
+ }
}
}
@@ -1898,7 +2020,9 @@ RTLFUNC(Day)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariableRef pArg = rPar.Get( 1 );
@@ -1915,7 +2039,9 @@ RTLFUNC(Year)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nYear = implGetDateYear( rPar.Get(1)->GetDate() );
@@ -1926,7 +2052,9 @@ RTLFUNC(Year)
sal_Int16 implGetHour( double dDate )
{
if( dDate < 0.0 )
+ {
dDate *= -1.0;
+ }
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -1940,7 +2068,9 @@ RTLFUNC(Hour)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double nArg = rPar.Get(1)->GetDate();
@@ -1955,7 +2085,9 @@ RTLFUNC(Minute)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double nArg = rPar.Get(1)->GetDate();
@@ -1970,7 +2102,9 @@ RTLFUNC(Month)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nMonth = implGetDateMonth( rPar.Get(1)->GetDate() );
@@ -1981,7 +2115,9 @@ RTLFUNC(Month)
sal_Int16 implGetSecond( double dDate )
{
if( dDate < 0.0 )
+ {
dDate *= -1.0;
+ }
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -2000,7 +2136,9 @@ RTLFUNC(Second)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double nArg = rPar.Get(1)->GetDate();
@@ -2027,8 +2165,8 @@ double Now_Impl()
RTLFUNC(Now)
{
- (void)pBasic;
- (void)bWrite;
+ (void)pBasic;
+ (void)bWrite;
rPar.Get(0)->PutDate( Now_Impl() );
}
@@ -2077,7 +2215,9 @@ RTLFUNC(Time)
pFormatter->GetOutputString( nDays, nIndex, aRes, &pCol );
if( !GetSbData()->pInst )
+ {
delete pFormatter;
+ }
}
pMeth->PutString( aRes );
}
@@ -2133,10 +2273,14 @@ RTLFUNC(Date)
pMeth->PutString( aRes );
if( !GetSbData()->pInst )
+ {
delete pFormatter;
+ }
}
else
+ {
pMeth->PutDate( nDays );
+ }
}
else
{
@@ -2150,9 +2294,13 @@ RTLFUNC(IsArray)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
+ {
rPar.Get(0)->PutBool((rPar.Get(1)->GetType() & SbxARRAY) ? sal_True : sal_False );
+ }
}
RTLFUNC(IsObject)
@@ -2161,7 +2309,9 @@ RTLFUNC(IsObject)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariable* pVar = rPar.Get(1);
@@ -2190,7 +2340,9 @@ RTLFUNC(IsDate)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// #46134 only string is converted, all other types result in sal_False
@@ -2225,19 +2377,25 @@ RTLFUNC(IsEmpty)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariable* pVar = NULL;
if( SbiRuntime::isVBAEnabled() )
+ {
pVar = getDefaultProp( rPar.Get(1) );
+ }
if ( pVar )
{
pVar->Broadcast( SBX_HINT_DATAWANTED );
rPar.Get( 0 )->PutBool( pVar->IsEmpty() );
}
else
+ {
rPar.Get( 0 )->PutBool( rPar.Get(1)->IsEmpty() );
+ }
}
}
@@ -2247,23 +2405,33 @@ RTLFUNC(IsError)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxVariable* pVar =rPar.Get( 1 );
SbUnoObject* pObj = PTR_CAST(SbUnoObject,pVar );
- if ( !pObj )
- {
- if ( SbxBase* pBaseObj = pVar->GetObject() )
- pObj = PTR_CAST(SbUnoObject, pBaseObj );
- }
+ if ( !pObj )
+ {
+ if ( SbxBase* pBaseObj = pVar->GetObject() )
+ {
+ pObj = PTR_CAST(SbUnoObject, pBaseObj );
+ }
+ }
uno::Reference< script::XErrorQuery > xError;
if ( pObj )
+ {
xError.set( pObj->getUnoAny(), uno::UNO_QUERY );
+ }
if ( xError.is() )
+ {
rPar.Get( 0 )->PutBool( xError->hasError() );
+ }
else
+ {
rPar.Get( 0 )->PutBool( rPar.Get(1)->IsErr() );
+ }
}
}
@@ -2273,7 +2441,9 @@ RTLFUNC(IsNull)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// #51475 because of Uno-objects return true
@@ -2284,7 +2454,9 @@ RTLFUNC(IsNull)
{
SbxBase* pObj = pArg->GetObject();
if( !pObj )
+ {
bNull = sal_True;
+ }
}
rPar.Get( 0 )->PutBool( bNull );
}
@@ -2296,9 +2468,13 @@ RTLFUNC(IsNumeric)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
+ {
rPar.Get( 0 )->PutBool( rPar.Get( 1 )->IsNumericRTL() );
+ }
}
@@ -2309,10 +2485,14 @@ RTLFUNC(IsMissing)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
+ {
// #57915 Missing is reported by an error
rPar.Get( 0 )->PutBool( rPar.Get(1)->IsErr() );
+ }
}
// Function looks for wildcards, removes them and always returns the pure path
@@ -2381,7 +2561,9 @@ inline sal_Bool implCheckWildcard( const String& rName, SbiRTLData* pRTLData )
sal_Bool bMatch = sal_True;
if( pRTLData->pWildCard )
+ {
bMatch = pRTLData->pWildCard->Matches( rName );
+ }
return bMatch;
}
@@ -2404,9 +2586,9 @@ bool isRootDir( String aDirURLStr )
// or Windows "file:///c:/" -> root
else if( nCount == 1 )
{
- ::rtl::OUString aSeg1 = aDirURLObj.getName( 0, sal_True,
- INetURLObject::DECODE_WITH_CHARSET );
- if( aSeg1.getStr()[1] == (sal_Unicode)':' )
+ OUString aSeg1 = aDirURLObj.getName( 0, sal_True,
+ INetURLObject::DECODE_WITH_CHARSET );
+ if( aSeg1[1] == (sal_Unicode)':' )
{
bRoot = true;
}
@@ -2426,7 +2608,9 @@ RTLFUNC(Dir)
sal_uInt16 nParCount = rPar.Count();
if( nParCount > 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbiRTLData* pRTLData = GetSbData()->pInst->GetRTLData();
@@ -2434,8 +2618,9 @@ RTLFUNC(Dir)
// #34645: can also be called from the URL line via 'macro: Dir'
// there's no pRTLDate existing in that case and the method must be left
if( !pRTLData )
+ {
return;
-
+ }
if( hasUno() )
{
uno::Reference< ucb::XSimpleFileAccess3 > xSFI = getFileAccess();
@@ -2480,10 +2665,13 @@ RTLFUNC(Dir)
sal_uInt16 nFlags = 0;
if ( nParCount > 2 )
+ {
pRTLData->nDirFlags = nFlags = rPar.Get(2)->GetInteger();
+ }
else
+ {
pRTLData->nDirFlags = 0;
-
+ }
// Read directory
sal_Bool bIncludeFolders = ((nFlags & Sb_ATTR_DIRECTORY) != 0);
pRTLData->aDirSeq = xSFI->getFolderContents( aDirURLStr, bIncludeFolders );
@@ -2538,7 +2726,7 @@ RTLFUNC(Dir)
}
else
{
- ::rtl::OUString aFile = pRTLData->aDirSeq.getConstArray()[pRTLData->nCurDirPos++];
+ OUString aFile = pRTLData->aDirSeq.getConstArray()[pRTLData->nCurDirPos++];
if( bCompatibility )
{
@@ -2546,7 +2734,9 @@ RTLFUNC(Dir)
{
sal_Bool bFolder = xSFI->isFolder( aFile );
if( bFolder )
+ {
continue;
+ }
}
}
else
@@ -2556,19 +2746,22 @@ RTLFUNC(Dir)
{
sal_Bool bFolder = xSFI->isFolder( aFile );
if( !bFolder )
+ {
continue;
+ }
}
}
INetURLObject aURL( aFile );
aPath = aURL.getName( INetURLObject::LAST_SEGMENT, sal_True,
- INetURLObject::DECODE_WITH_CHARSET );
+ INetURLObject::DECODE_WITH_CHARSET );
}
sal_Bool bMatch = implCheckWildcard( aPath, pRTLData );
if( !bMatch )
+ {
continue;
-
+ }
break;
}
}
@@ -2586,9 +2779,13 @@ RTLFUNC(Dir)
sal_uInt16 nFlags = 0;
if ( nParCount > 2 )
+ {
pRTLData->nDirFlags = nFlags = rPar.Get(2)->GetInteger();
+ }
else
+ {
pRTLData->nDirFlags = 0;
+ }
// Read directory
bool bIncludeFolders = ((nFlags & Sb_ATTR_DIRECTORY) != 0);
@@ -2659,7 +2856,9 @@ RTLFUNC(Dir)
FileStatus::Type aType = aFileStatus.getFileType();
bool bFolder = isFolder( aType );
if( !bFolder )
+ {
continue;
+ }
}
aPath = aFileStatus.getFileName();
@@ -2667,8 +2866,9 @@ RTLFUNC(Dir)
sal_Bool bMatch = implCheckWildcard( aPath, pRTLData );
if( !bMatch )
+ {
continue;
-
+ }
break;
}
}
@@ -2702,12 +2902,15 @@ RTLFUNC(GetAttr)
if (nRealFlags != 0xffffffff)
{
if (nRealFlags == FILE_ATTRIBUTE_NORMAL)
+ {
nRealFlags = 0;
+ }
nFlags = (sal_Int16) (nRealFlags);
}
else
+ {
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
-
+ }
rPar.Get(0)->PutInteger( nFlags );
return;
@@ -2735,11 +2938,17 @@ RTLFUNC(GetAttr)
sal_Bool bHidden = xSFI->isHidden( aPath );
sal_Bool bDirectory = xSFI->isFolder( aPath );
if( bReadOnly )
+ {
nFlags |= Sb_ATTR_READONLY;
+ }
if( bHidden )
+ {
nFlags |= Sb_ATTR_HIDDEN;
+ }
if( bDirectory )
+ {
nFlags |= Sb_ATTR_DIRECTORY;
+ }
}
catch(const Exception & )
{
@@ -2759,14 +2968,20 @@ RTLFUNC(GetAttr)
FileStatus::Type aType = aFileStatus.getFileType();
bool bDirectory = isFolder( aType );
if( bReadOnly )
+ {
nFlags |= Sb_ATTR_READONLY;
+ }
if( bDirectory )
+ {
nFlags |= Sb_ATTR_DIRECTORY;
+ }
}
rPar.Get(0)->PutInteger( nFlags );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
@@ -2776,7 +2991,9 @@ RTLFUNC(FileDateTime)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aPath = rPar.Get(1)->GetString();
@@ -2841,7 +3058,9 @@ RTLFUNC(FileDateTime)
rPar.Get(0)->PutString( aRes );
if( !GetSbData()->pInst )
+ {
delete pFormatter;
+ }
}
}
@@ -2853,7 +3072,9 @@ RTLFUNC(EOF)
// No changes for UCB
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nChannel = rPar.Get(1)->GetInteger();
@@ -2872,10 +3093,14 @@ RTLFUNC(EOF)
(*pSvStrm) >> cBla; // can we read another character?
bIsEof = pSvStrm->IsEof();
if ( !bIsEof )
+ {
pSvStrm->SeekRel( -1 );
+ }
}
else
+ {
bIsEof = pSvStrm->IsEof(); // for binary data!
+ }
rPar.Get(0)->PutBool( bIsEof );
}
}
@@ -2891,7 +3116,9 @@ RTLFUNC(FileAttr)
// already opened files and the name doesn't matter there.
if ( rPar.Count() != 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nChannel = rPar.Get(1)->GetInteger();
@@ -2904,10 +3131,13 @@ RTLFUNC(FileAttr)
}
sal_Int16 nRet;
if ( rPar.Get(2)->GetInteger() == 1 )
+ {
nRet = (sal_Int16)(pSbStrm->GetMode());
+ }
else
+ {
nRet = 0; // System file handle not supported
-
+ }
rPar.Get(0)->PutInteger( nRet );
}
}
@@ -2918,7 +3148,9 @@ RTLFUNC(Loc)
// No changes for UCB
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nChannel = rPar.Get(1)->GetInteger();
@@ -2938,13 +3170,21 @@ RTLFUNC(Loc)
nPos++; // block positions starting at 1
}
else if ( pSbStrm->IsText() )
+ {
nPos = pSbStrm->GetLine();
+ }
else if( pSbStrm->IsBinary() )
+ {
nPos = pSvStrm->Tell();
+ }
else if ( pSbStrm->IsSeq() )
+ {
nPos = ( pSvStrm->Tell()+1 ) / 128;
+ }
else
+ {
nPos = pSvStrm->Tell();
+ }
rPar.Get(0)->PutLong( (sal_Int32)nPos );
}
}
@@ -2956,7 +3196,9 @@ RTLFUNC(Lof)
// No changes for UCB
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_Int16 nChannel = rPar.Get(1)->GetInteger();
@@ -3002,7 +3244,9 @@ RTLFUNC(Seek)
{
sal_uIntPtr nPos = pStrm->Tell();
if( pSbStrm->IsRandom() )
+ {
nPos = nPos / pSbStrm->GetBlockLen();
+ }
nPos++; // Basic counts from 1
rPar.Get(0)->PutLong( (sal_Int32)nPos );
}
@@ -3017,7 +3261,9 @@ RTLFUNC(Seek)
nPos--; // Basic counts from 1, SvStreams count from 0
pSbStrm->SetExpandOnWriteTo( 0 );
if ( pSbStrm->IsRandom() )
+ {
nPos *= pSbStrm->GetBlockLen();
+ }
pStrm->Seek( (sal_uIntPtr)nPos );
pSbStrm->SetExpandOnWriteTo( nPos );
}
@@ -3030,12 +3276,16 @@ RTLFUNC(Format)
sal_uInt16 nArgCount = (sal_uInt16)rPar.Count();
if ( nArgCount < 2 || nArgCount > 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
String aResult;
if( nArgCount == 2 )
+ {
rPar.Get(1)->Format( aResult );
+ }
else
{
String aFmt( rPar.Get(2)->GetString() );
@@ -3051,12 +3301,18 @@ RTLFUNC(Randomize)
(void)bWrite;
if ( rPar.Count() > 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
sal_Int16 nSeed;
if( rPar.Count() == 2 )
+ {
nSeed = (sal_Int16)rPar.Get(1)->GetInteger();
+ }
else
+ {
nSeed = (sal_Int16)rand();
+ }
srand( nSeed );
}
@@ -3066,7 +3322,9 @@ RTLFUNC(Rnd)
(void)bWrite;
if ( rPar.Count() > 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double nRand = (double)rand();
@@ -3193,9 +3451,13 @@ RTLFUNC(Shell)
sal_Bool bSync = sal_False;
if( nArgCount >= 5 )
+ {
bSync = rPar.Get(4)->GetBool();
+ }
if( bSync )
+ {
nOptions |= osl_Process_WAIT;
+ }
}
// #72471 work parameter(s) up
@@ -3241,9 +3503,13 @@ RTLFUNC(Shell)
}
if( !bSucc )
+ {
StarBASIC::Error( SbERR_FILE_NOT_FOUND );
+ }
else
+ {
rPar.Get(0)->PutLong( 0 );
+ }
}
}
@@ -3253,7 +3519,9 @@ RTLFUNC(VarType)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxDataType eType = rPar.Get(1)->GetType();
@@ -3309,13 +3577,15 @@ rtl::OUString getBasicTypeName( SbxDataType eType )
int nPos = ((int)eType) & 0x0FFF;
sal_uInt16 nTypeNameCount = sizeof( pTypeNames ) / sizeof( char* );
if ( nPos < 0 || nPos >= nTypeNameCount )
+ {
nPos = nTypeNameCount - 1;
+ }
return rtl::OUString::createFromAscii(pTypeNames[nPos]);
}
String getObjectTypeName( SbxVariable* pVar )
{
- rtl::OUString sRet( "Object" );
+ OUString sRet( "Object" );
if ( pVar )
{
SbxBase* pObj = pVar->GetObject();
@@ -3327,7 +3597,9 @@ String getObjectTypeName( SbxVariable* pVar )
if ( !pUnoObj )
{
if ( SbxBase* pBaseObj = pVar->GetObject() )
+ {
pUnoObj = PTR_CAST(SbUnoObject, pBaseObj );
+ }
}
if ( pUnoObj )
{
@@ -3343,7 +3615,9 @@ String getObjectTypeName( SbxVariable* pVar )
uno::Reference< ooo::vba::XHelperInterface > xVBA( aObj, uno::UNO_QUERY );
Sequence< rtl::OUString > sServices = xServInfo->getSupportedServiceNames();
if ( sServices.getLength() )
+ {
sRet = sServices[ 0 ];
+ }
}
else
{
@@ -3365,7 +3639,9 @@ String getObjectTypeName( SbxVariable* pVar )
}
sal_Int32 nDot = sRet.lastIndexOf( '.' );
if ( nDot != -1 && nDot < sRet.getLength() )
- sRet = sRet.copy( nDot + 1 );
+ {
+ sRet = sRet.copy( nDot + 1 );
+ }
}
}
}
@@ -3378,7 +3654,9 @@ RTLFUNC(TypeName)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxDataType eType = rPar.Get(1)->GetType();
@@ -3386,9 +3664,13 @@ RTLFUNC(TypeName)
String aRetStr;
if ( SbiRuntime::isVBAEnabled() && eType == SbxOBJECT )
+ {
aRetStr = getObjectTypeName( rPar.Get(1) );
+ }
else
+ {
aRetStr = getBasicTypeName( eType );
+ }
if( bIsArray )
aRetStr.AppendAscii( "()" );
rPar.Get(0)->PutString( aRetStr );
@@ -3401,7 +3683,9 @@ RTLFUNC(Len)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
const String& rStr = rPar.Get(1)->GetString();
@@ -3773,17 +4057,25 @@ RTLFUNC(StrConv)
aOldStr = rCharClass.titlecase( aOldStr.ToLowerAscii(), 0, nOldLen );
}
else if ( (nConversion & 0x01) == 1 ) // vbUpperCase
+ {
nType |= i18n::TransliterationModules_LOWERCASE_UPPERCASE;
+ }
else if ( (nConversion & 0x02) == 2 ) // vbLowerCase
+ {
nType |= i18n::TransliterationModules_UPPERCASE_LOWERCASE;
-
+ }
if ( (nConversion & 0x04) == 4 ) // vbWide
+ {
nType |= i18n::TransliterationModules_HALFWIDTH_FULLWIDTH;
+ }
else if ( (nConversion & 0x08) == 8 ) // vbNarrow
+ {
nType |= i18n::TransliterationModules_FULLWIDTH_HALFWIDTH;
-
+ }
if ( (nConversion & 0x10) == 16) // vbKatakana
+ {
nType |= i18n::TransliterationModules_HIRAGANA_KATAKANA;
+ }
else if ( (nConversion & 0x20) == 32 ) // vbHiragana
nType |= i18n::TransliterationModules_KATAKANA_HIRAGANA;
@@ -3831,9 +4123,13 @@ RTLFUNC(StrConv)
if(nArraySize)
{
if( bIncIndex )
+ {
pArray->AddDim( 1, nArraySize );
+ }
else
+ {
pArray->AddDim( 0, nArraySize-1 );
+ }
}
else
{
@@ -3848,7 +4144,9 @@ RTLFUNC(StrConv)
pNew->SetFlag( SBX_WRITE );
short index = i;
if( bIncIndex )
+ {
++index;
+ }
pArray->Put( pNew, &index );
}
@@ -3858,9 +4156,8 @@ RTLFUNC(StrConv)
refVar->PutObject( pArray );
refVar->SetFlags( nFlags );
refVar->SetParameters( NULL );
- return;
+ return;
}
-
rPar.Get(0)->PutString(aNewStr);
}
@@ -3901,7 +4198,9 @@ RTLFUNC(Load)
SbxVariable* pVar = ((SbxObject*)pObj)->
Find( String( RTL_CONSTASCII_USTRINGPARAM("Load") ), SbxCLASS_METHOD );
if( pVar )
+ {
pVar->GetInteger();
+ }
}
}
}
@@ -3932,7 +4231,9 @@ RTLFUNC(Unload)
SbxVariable* pVar = ((SbxObject*)pObj)->
Find( String( RTL_CONSTASCII_USTRINGPARAM("Unload") ), SbxCLASS_METHOD );
if( pVar )
+ {
pVar->GetInteger();
+ }
}
}
}
@@ -4031,8 +4332,9 @@ RTLFUNC(MsgBox)
WinBits nStyle = nType;
nStyle &= 15; // delete bits 4-16
if( nStyle > 5 )
+ {
nStyle = 0;
-
+ }
nWinBits = nStyleMap[ nStyle ];
WinBits nWinDefBits;
@@ -4040,21 +4342,33 @@ RTLFUNC(MsgBox)
if( nType & 256 )
{
if( nStyle == 5 )
+ {
nWinDefBits = WB_DEF_CANCEL;
+ }
else if( nStyle == 2 )
+ {
nWinDefBits = WB_DEF_RETRY;
+ }
else
+ {
nWinDefBits = (WB_DEF_CANCEL | WB_DEF_RETRY | WB_DEF_NO);
+ }
}
else if( nType & 512 )
{
if( nStyle == 2)
+ {
nWinDefBits = WB_DEF_IGNORE;
+ }
else
+ {
nWinDefBits = WB_DEF_CANCEL;
+ }
}
else if( nStyle == 2)
+ {
nWinDefBits = WB_DEF_CANCEL;
+ }
nWinBits |= nWinDefBits;
String aMsg = rPar.Get(1)->GetString();
@@ -4062,43 +4376,49 @@ RTLFUNC(MsgBox)
if( nArgCount >= 4 )
aTitle = rPar.Get(3)->GetString();
else
+ {
aTitle = GetpApp()->GetAppName();
+ }
nType &= (16+32+64);
MessBox* pBox = 0;
Window* pParent = GetpApp()->GetDefDialogParent();
switch( nType )
{
- case 16:
- pBox = new ErrorBox( pParent, nWinBits, aMsg );
- break;
- case 32:
- pBox = new QueryBox( pParent, nWinBits, aMsg );
- break;
- case 48:
- pBox = new WarningBox( pParent, nWinBits, aMsg );
- break;
- case 64:
- pBox = new InfoBox( pParent, aMsg );
- break;
- default:
- pBox = new MessBox( pParent, nWinBits, aTitle, aMsg );
+ case 16:
+ pBox = new ErrorBox( pParent, nWinBits, aMsg );
+ break;
+ case 32:
+ pBox = new QueryBox( pParent, nWinBits, aMsg );
+ break;
+ case 48:
+ pBox = new WarningBox( pParent, nWinBits, aMsg );
+ break;
+ case 64:
+ pBox = new InfoBox( pParent, aMsg );
+ break;
+ default:
+ pBox = new MessBox( pParent, nWinBits, aTitle, aMsg );
}
pBox->SetText( aTitle );
sal_uInt16 nRet = (sal_uInt16)pBox->Execute();
if( nRet == sal_True )
+ {
nRet = 1;
-
+ }
sal_Int16 nMappedRet;
if( nStyle == 2 )
{
nMappedRet = nRet;
if( nMappedRet == 0 )
+ {
nMappedRet = 3; // Abort
+ }
}
else
+ {
nMappedRet = nButtonMap[ nRet ];
-
+ }
rPar.Get(0)->PutInteger( nMappedRet );
delete pBox;
}
@@ -4134,7 +4454,9 @@ RTLFUNC(SetAttr)
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(Reset)
@@ -4145,7 +4467,9 @@ RTLFUNC(Reset)
SbiIoSystem* pIO = GetSbData()->pInst->GetIoSystem();
if (pIO)
+ {
pIO->CloseAll();
+ }
}
RTLFUNC(DumpAllObjects)
@@ -4155,9 +4479,13 @@ RTLFUNC(DumpAllObjects)
sal_uInt16 nArgCount = (sal_uInt16)rPar.Count();
if( nArgCount < 2 || nArgCount > 3 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else if( !pBasic )
+ {
StarBASIC::Error( SbERR_INTERNAL_ERROR );
+ }
else
{
SbxObject* p = pBasic;
@@ -4168,7 +4496,9 @@ RTLFUNC(DumpAllObjects)
p->Dump( aStrm, rPar.Get( 2 )->GetBool() );
aStrm.Close();
if( aStrm.GetError() != SVSTREAM_OK )
+ {
StarBASIC::Error( SbERR_IO_ERROR );
+ }
}
}
@@ -4207,7 +4537,9 @@ RTLFUNC(FileExists)
rPar.Get(0)->PutBool( bExists );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(Partition)
@@ -4239,15 +4571,15 @@ RTLFUNC(Partition)
// will be handled properly during any subsequent sort operation.
// calculate the maximun number of characters before lowervalue and uppervalue
- ::rtl::OUString aBeforeStart = ::rtl::OUString::valueOf( nStart - 1 );
- ::rtl::OUString aAfterStop = ::rtl::OUString::valueOf( nStop + 1 );
+ OUString aBeforeStart = ::rtl::OUString::valueOf( nStart - 1 );
+ OUString aAfterStop = ::rtl::OUString::valueOf( nStop + 1 );
sal_Int32 nLen1 = aBeforeStart.getLength();
sal_Int32 nLen2 = aAfterStop.getLength();
sal_Int32 nLen = nLen1 >= nLen2 ? nLen1:nLen2;
- ::rtl::OUStringBuffer aRetStr( nLen * 2 + 1);
- ::rtl::OUString aLowerValue;
- ::rtl::OUString aUpperValue;
+ OUStringBuffer aRetStr( nLen * 2 + 1);
+ OUString aLowerValue;
+ OUString aUpperValue;
if( nNumber < nStart )
{
aUpperValue = aBeforeStart;
@@ -4265,7 +4597,6 @@ RTLFUNC(Partition)
nLowerValue = ((( nNumber - nStart ) / nInterval ) * nInterval ) + nStart;
nUpperValue = nLowerValue + nInterval - 1;
}
-
aLowerValue = ::rtl::OUString::valueOf( nLowerValue );
aUpperValue = ::rtl::OUString::valueOf( nUpperValue );
}
@@ -4277,14 +4608,18 @@ RTLFUNC(Partition)
{
// appending the leading spaces for the lowervalue
for ( sal_Int32 i= (nLen - nLen1) ; i > 0; --i )
+ {
aRetStr.appendAscii(" ");
+ }
}
aRetStr.append( aLowerValue ).appendAscii(":");
if( nLen > nLen2 )
{
// appending the leading spaces for the uppervalue
for ( sal_Int32 i= (nLen - nLen2) ; i > 0; --i )
+ {
aRetStr.appendAscii(" ");
+ }
}
aRetStr.append( aUpperValue );
rPar.Get(0)->PutString( String(aRetStr.makeStringAndClear()) );
@@ -4302,7 +4637,9 @@ static long GetDayDiff( const Date& rDate )
nDiffDays *= -1;
}
else
+ {
nDiffDays = (long)(rDate - aRefDate);
+ }
nDiffDays += 2; // adjustment VisualBasic: 1.Jan.1900 == 2
return nDiffDays;
}
@@ -4321,11 +4658,17 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
{
#ifndef DISABLE_SCRIPTING
if ( nYear < 30 && SbiRuntime::isVBAEnabled() )
+ {
nYear += 2000;
+ }
else
#endif
+ {
if ( nYear < 100 )
+ {
nYear += 1900;
+ }
+ }
Date aCurDate( nDay, nMonth, nYear );
if ((nYear < 100 || nYear > 9999) )
{
@@ -4340,7 +4683,7 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
#endif
{
if ( (nMonth < 1 || nMonth > 12 )||
- (nDay < 1 || nDay > 31 ) )
+ (nDay < 1 || nDay > 31 ) )
{
#ifndef DISABLE_SCRIPTING
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -4363,7 +4706,9 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
// just modify the months directory
sal_Int16 nYearAdj = ( nMonth /12 ); // default to positive months inputed
if ( nMonth <=0 )
+ {
nYearAdj = ( ( nMonth -12 ) / 12 );
+ }
aCurDate.SetYear( aCurDate.GetYear() + nYearAdj );
}
@@ -4371,9 +4716,13 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
// e.g. 2000, 2, 0 = 2000, 1, 31 or the last day of the previous month
// 2000, 1, 32 = 2000, 2, 1 or the first day of the following month
if( ( nDay < 1 ) || ( nDay > aCurDate.GetDaysInMonth() ) )
+ {
aCurDate += nDay - 1;
+ }
else
+ {
aCurDate.SetDay( nDay );
+ }
}
#endif
@@ -4385,7 +4734,9 @@ bool implDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, double&
sal_Int16 implGetMinute( double dDate )
{
if( dDate < 0.0 )
+ {
dDate *= -1.0;
+ }
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 6dae3f4bbb63..0d55f47b1be1 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -143,74 +143,76 @@ RTLFUNC(CallByName)
switch( nCallType )
{
- case vbGet:
+ case vbGet:
+ {
+ SbxValues aVals;
+ aVals.eType = SbxVARIANT;
+ pFindVar->Get( aVals );
+
+ SbxVariableRef refVar = rPar.Get(0);
+ refVar->Put( aVals );
+ }
+ break;
+ case vbLet:
+ case vbSet:
+ {
+ if ( nParCount != 5 )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+ SbxVariableRef pValVar = rPar.Get(4);
+ if( nCallType == vbLet )
{
SbxValues aVals;
aVals.eType = SbxVARIANT;
- pFindVar->Get( aVals );
-
- SbxVariableRef refVar = rPar.Get(0);
- refVar->Put( aVals );
+ pValVar->Get( aVals );
+ pFindVar->Put( aVals );
}
- break;
- case vbLet:
- case vbSet:
+ else
{
- if ( nParCount != 5 )
+ SbxVariableRef rFindVar = pFindVar;
+ SbiInstance* pInst = GetSbData()->pInst;
+ SbiRuntime* pRT = pInst ? pInst->pRun : NULL;
+ if( pRT != NULL )
{
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return;
- }
- SbxVariableRef pValVar = rPar.Get(4);
- if( nCallType == vbLet )
- {
- SbxValues aVals;
- aVals.eType = SbxVARIANT;
- pValVar->Get( aVals );
- pFindVar->Put( aVals );
- }
- else
- {
- SbxVariableRef rFindVar = pFindVar;
- SbiInstance* pInst = GetSbData()->pInst;
- SbiRuntime* pRT = pInst ? pInst->pRun : NULL;
- if( pRT != NULL )
- pRT->StepSET_Impl( pValVar, rFindVar, false );
+ pRT->StepSET_Impl( pValVar, rFindVar, false );
}
}
- break;
- case vbMethod:
+ }
+ break;
+ case vbMethod:
+ {
+ SbMethod* pMeth = PTR_CAST(SbMethod,pFindVar);
+ if( pMeth == NULL )
{
- SbMethod* pMeth = PTR_CAST(SbMethod,pFindVar);
- if( pMeth == NULL )
- {
- StarBASIC::Error( SbERR_PROC_UNDEFINED );
- return;
- }
+ StarBASIC::Error( SbERR_PROC_UNDEFINED );
+ return;
+ }
- // Setup parameters
- SbxArrayRef xArray;
- sal_uInt16 nMethParamCount = nParCount - 4;
- if( nMethParamCount > 0 )
+ // Setup parameters
+ SbxArrayRef xArray;
+ sal_uInt16 nMethParamCount = nParCount - 4;
+ if( nMethParamCount > 0 )
+ {
+ xArray = new SbxArray;
+ for( sal_uInt16 i = 0 ; i < nMethParamCount ; i++ )
{
- xArray = new SbxArray;
- for( sal_uInt16 i = 0 ; i < nMethParamCount ; i++ )
- {
- SbxVariable* pPar = rPar.Get( i + 4 );
- xArray->Put( pPar, i + 1 );
- }
+ SbxVariable* pPar = rPar.Get( i + 4 );
+ xArray->Put( pPar, i + 1 );
}
-
- // Call method
- SbxVariableRef refVar = rPar.Get(0);
- if( xArray.Is() )
- pMeth->SetParameters( xArray );
- pMeth->Call( refVar );
- pMeth->SetParameters( NULL );
}
- break;
- default:
- StarBASIC::Error( SbERR_PROC_UNDEFINED );
+
+ // Call method
+ SbxVariableRef refVar = rPar.Get(0);
+ if( xArray.Is() )
+ pMeth->SetParameters( xArray );
+ pMeth->Call( refVar );
+ pMeth->SetParameters( NULL );
+ }
+ break;
+ default:
+ StarBASIC::Error( SbERR_PROC_UNDEFINED );
}
}
@@ -226,8 +228,9 @@ RTLFUNC(CBool) // JSM
bVal = pSbxVariable->GetBool();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutBool(bVal);
}
@@ -243,8 +246,9 @@ RTLFUNC(CByte) // JSM
nByte = pSbxVariable->GetByte();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutByte(nByte);
}
@@ -260,8 +264,9 @@ RTLFUNC(CCur)
nCur = pSbxVariable->GetCurrency();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutCurrency( nCur );
}
@@ -278,8 +283,9 @@ RTLFUNC(CDec)
pDec = pSbxVariable->GetDecimal();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutDecimal( pDec );
#else
rPar.Get(0)->PutEmpty();
@@ -299,8 +305,9 @@ RTLFUNC(CDate) // JSM
nVal = pSbxVariable->GetDate();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutDate(nVal);
}
@@ -319,7 +326,9 @@ RTLFUNC(CDbl) // JSM
String aScanStr = pSbxVariable->GetString();
SbError Error = SbxValue::ScanNumIntnl( aScanStr, nVal );
if( Error != SbxERR_OK )
+ {
StarBASIC::Error( Error );
+ }
}
else
{
@@ -327,7 +336,9 @@ RTLFUNC(CDbl) // JSM
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
rPar.Get(0)->PutDouble(nVal);
}
@@ -344,8 +355,9 @@ RTLFUNC(CInt) // JSM
nVal = pSbxVariable->GetInteger();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutInteger(nVal);
}
@@ -361,8 +373,9 @@ RTLFUNC(CLng) // JSM
nVal = pSbxVariable->GetLong();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutLong(nVal);
}
@@ -382,7 +395,9 @@ RTLFUNC(CSng) // JSM
String aScanStr = pSbxVariable->GetString();
SbError Error = SbxValue::ScanNumIntnl( aScanStr, dVal, /*bSingle=*/true );
if( SbxBase::GetError() == SbxERR_OK && Error != SbxERR_OK )
+ {
StarBASIC::Error( Error );
+ }
nVal = (float)dVal;
}
else
@@ -391,8 +406,9 @@ RTLFUNC(CSng) // JSM
}
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutSingle(nVal);
}
@@ -408,8 +424,9 @@ RTLFUNC(CStr) // JSM
aString = pSbxVariable->GetString();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutString(aString);
}
@@ -425,8 +442,9 @@ RTLFUNC(CVar) // JSM
pSbxVariable->Get( aVals );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->Put( aVals );
}
@@ -442,8 +460,9 @@ RTLFUNC(CVErr)
nErrCode = pSbxVariable->GetInteger();
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
-
+ }
rPar.Get(0)->PutErr( nErrCode );
}
@@ -455,12 +474,18 @@ RTLFUNC(Iif) // JSM
if ( rPar.Count() == 4 )
{
if (rPar.Get(1)->GetBool())
+ {
*rPar.Get(0) = *rPar.Get(2);
+ }
else
+ {
*rPar.Get(0) = *rPar.Get(3);
+ }
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(GetSystemType)
@@ -469,10 +494,14 @@ RTLFUNC(GetSystemType)
(void)bWrite;
if ( rPar.Count() != 1 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
+ {
// Removed for SRC595
rPar.Get(0)->PutInteger( -1 );
+ }
}
RTLFUNC(GetGUIType)
@@ -481,7 +510,9 @@ RTLFUNC(GetGUIType)
(void)bWrite;
if ( rPar.Count() != 1 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// 17.7.2000 Make simple solution for testtool / fat office
@@ -501,7 +532,9 @@ RTLFUNC(Red)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_uIntPtr nRGB = (sal_uIntPtr)rPar.Get(1)->GetLong();
@@ -517,7 +550,9 @@ RTLFUNC(Green)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_uIntPtr nRGB = (sal_uIntPtr)rPar.Get(1)->GetLong();
@@ -533,7 +568,9 @@ RTLFUNC(Blue)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
sal_uIntPtr nRGB = (sal_uIntPtr)rPar.Get(1)->GetLong();
@@ -550,8 +587,10 @@ RTLFUNC(Switch)
sal_uInt16 nCount = rPar.Count();
if( !(nCount & 0x0001 ))
+ {
// number of arguments must be odd
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
sal_uInt16 nCurExpr = 1;
while( nCurExpr < (nCount-1) )
{
@@ -583,7 +622,9 @@ void Wait_Impl( bool bDurationBased, SbxArray& rPar )
nWait = (long)( dSecs * 1000 ); // wait in thousands of sec
}
else
+ {
nWait = rPar.Get(1)->GetLong();
+ }
if( nWait < 0 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -594,7 +635,9 @@ void Wait_Impl( bool bDurationBased, SbxArray& rPar )
aTimer.SetTimeout( nWait );
aTimer.Start();
while ( aTimer.IsActive() )
+ {
Application::Yield();
+ }
}
//i#64882#
@@ -633,7 +676,9 @@ RTLFUNC(GetGUIVersion)
(void)bWrite;
if ( rPar.Count() != 1 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
// Removed for SRC595
@@ -647,7 +692,9 @@ RTLFUNC(Choose)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
sal_Int16 nIndex = rPar.Get(1)->GetInteger();
sal_uInt16 nCount = rPar.Count();
nCount--;
@@ -666,7 +713,9 @@ RTLFUNC(Trim)
(void)bWrite;
if ( rPar.Count() < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
rtl::OUString aStr(comphelper::string::strip(rPar.Get(1)->GetString(), ' '));
@@ -733,7 +782,9 @@ bool IsBaseIndexOne()
{
sal_uInt16 res = GetSbData()->pInst->pRun->GetBase();
if ( res )
+ {
result = true;
+ }
}
return result;
}
@@ -751,9 +802,13 @@ RTLFUNC(Array)
if( nArraySize )
{
if ( bIncIndex )
+ {
pArray->AddDim( 1, nArraySize );
+ }
else
+ {
pArray->AddDim( 0, nArraySize-1 );
+ }
}
else
{
@@ -771,7 +826,9 @@ RTLFUNC(Array)
pNew->SetFlag( SBX_WRITE );
short index = static_cast< short >(i);
if ( bIncIndex )
+ {
++index;
+ }
pArray->Put( pNew, &index );
}
@@ -813,8 +870,9 @@ RTLFUNC(DimArray)
}
}
else
+ {
pArray->unoAddDim( 0, -1 );
-
+ }
SbxVariableRef refVar = rPar.Get(0);
sal_uInt16 nFlags = refVar->GetFlags();
refVar->ResetFlag( SBX_FIXED );
@@ -863,8 +921,9 @@ RTLFUNC(FindObject)
SbxBase* pFind = StarBASIC::FindSBXInCurrentScope( aNameStr );
SbxObject* pFindObj = NULL;
if( pFind )
+ {
pFindObj = PTR_CAST(SbxObject,pFind);
-
+ }
SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( pFindObj );
}
@@ -886,7 +945,9 @@ RTLFUNC(FindPropertyObject)
SbxBase* pObjVar = (SbxObject*)rPar.Get(1)->GetObject();
SbxObject* pObj = NULL;
if( pObjVar )
+ {
pObj = PTR_CAST(SbxObject,pObjVar);
+ }
if( !pObj && pObjVar && pObjVar->ISA(SbxVariable) )
{
SbxBase* pObjVarObj = ((SbxVariable*)pObjVar)->GetObject();
@@ -902,8 +963,9 @@ RTLFUNC(FindPropertyObject)
pFindObj = PTR_CAST(SbxObject,pFindVar);
}
else
+ {
StarBASIC::Error( SbERR_BAD_PARAMETER );
-
+ }
SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( pFindObj );
@@ -912,7 +974,7 @@ RTLFUNC(FindPropertyObject)
static sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm,
- sal_Bool bBinary, short nBlockLen, sal_Bool bIsArray )
+ sal_Bool bBinary, short nBlockLen, sal_Bool bIsArray )
{
sal_uIntPtr nFPos = pStrm->Tell();
@@ -921,84 +983,100 @@ static sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm,
switch( eType )
{
- case SbxBOOL:
- case SbxCHAR:
- case SbxBYTE:
- if( bIsVariant )
- *pStrm << (sal_uInt16)SbxBYTE; // VarType Id
- *pStrm << rVar.GetByte();
- break;
+ case SbxBOOL:
+ case SbxCHAR:
+ case SbxBYTE:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)SbxBYTE; // VarType Id
+ }
+ *pStrm << rVar.GetByte();
+ break;
+
+ case SbxEMPTY:
+ case SbxNULL:
+ case SbxVOID:
+ case SbxINTEGER:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)SbxINTEGER; // VarType Id
+ }
+ *pStrm << rVar.GetInteger();
+ break;
- case SbxEMPTY:
- case SbxNULL:
- case SbxVOID:
- case SbxINTEGER:
- case SbxUSHORT:
- case SbxINT:
- case SbxUINT:
- if( bIsVariant )
- *pStrm << (sal_uInt16)SbxINTEGER; // VarType Id
- *pStrm << rVar.GetInteger();
- break;
+ case SbxLONG:
+ case SbxULONG:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)SbxLONG; // VarType Id
+ }
+ *pStrm << rVar.GetLong();
+ break;
+ case SbxSALINT64:
+ case SbxSALUINT64:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)SbxSALINT64; // VarType Id
+ }
+ *pStrm << (sal_uInt64)rVar.GetInt64();
+ break;
+ case SbxSINGLE:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)eType; // VarType Id
+ }
+ *pStrm << rVar.GetSingle();
+ break;
- case SbxLONG:
- case SbxULONG:
- if( bIsVariant )
- *pStrm << (sal_uInt16)SbxLONG; // VarType Id
- *pStrm << rVar.GetLong();
- break;
- case SbxSALINT64:
- case SbxSALUINT64:
- if( bIsVariant )
- *pStrm << (sal_uInt16)SbxSALINT64; // VarType Id
- *pStrm << (sal_uInt64)rVar.GetInt64();
- break;
- case SbxSINGLE:
- if( bIsVariant )
- *pStrm << (sal_uInt16)eType; // VarType Id
- *pStrm << rVar.GetSingle();
- break;
+ case SbxDOUBLE:
+ case SbxCURRENCY:
+ case SbxDATE:
+ if( bIsVariant )
+ {
+ *pStrm << (sal_uInt16)eType; // VarType Id
+ }
+ *pStrm << rVar.GetDouble();
+ break;
- case SbxDOUBLE:
- case SbxCURRENCY:
- case SbxDATE:
+ case SbxSTRING:
+ case SbxLPSTR:
+ {
+ const OUString& rStr = rVar.GetOUString();
+ if( !bBinary || bIsArray )
+ {
if( bIsVariant )
- *pStrm << (sal_uInt16)eType; // VarType Id
- *pStrm << rVar.GetDouble();
- break;
-
- case SbxSTRING:
- case SbxLPSTR:
- {
- const String& rStr = rVar.GetString();
- if( !bBinary || bIsArray )
- {
- if( bIsVariant )
- *pStrm << (sal_uInt16)SbxSTRING;
- pStrm->WriteUniOrByteString( rStr, osl_getThreadTextEncoding() );
- }
- else
{
- // without any length information! without end-identifier!
- // What does that mean for Unicode?! Choosing conversion to ByteString...
- rtl::OString aByteStr(rtl::OUStringToOString(rStr, osl_getThreadTextEncoding()));
- *pStrm << (const char*)aByteStr.getStr();
+ *pStrm << (sal_uInt16)SbxSTRING;
}
- }
- break;
+ pStrm->WriteUniOrByteString( rStr, osl_getThreadTextEncoding() );
+ }
+ else
+ {
+ // without any length information! without end-identifier!
+ // What does that mean for Unicode?! Choosing conversion to ByteString...
+ rtl::OString aByteStr(rtl::OUStringToOString(rStr, osl_getThreadTextEncoding()));
+ *pStrm << (const char*)aByteStr.getStr();
+ }
+ }
+ break;
- default:
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return sal_False;
+ default:
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return sal_False;
}
if( nBlockLen )
+ {
pStrm->Seek( nFPos + nBlockLen );
+ }
return pStrm->GetErrorCode() ? sal_False : sal_True;
}
static sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm,
- sal_Bool bBinary, short nBlockLen, sal_Bool bIsArray )
+ sal_Bool bBinary, short nBlockLen, sal_Bool bIsArray )
{
(void)bBinary;
(void)bIsArray;
@@ -1020,88 +1098,91 @@ static sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm,
switch( eSrcType )
{
- case SbxBOOL:
- case SbxCHAR:
- case SbxBYTE:
- {
- sal_uInt8 aByte;
- *pStrm >> aByte;
-
- if( bBinary && SbiRuntime::isVBAEnabled() && aByte == 1 && pStrm->IsEof() )
- aByte = 0;
-
- rVar.PutByte( aByte );
- }
- break;
+ case SbxBOOL:
+ case SbxCHAR:
+ case SbxBYTE:
+ {
+ sal_uInt8 aByte;
+ *pStrm >> aByte;
- case SbxEMPTY:
- case SbxNULL:
- case SbxVOID:
- case SbxINTEGER:
- case SbxUSHORT:
- case SbxINT:
- case SbxUINT:
- {
- sal_Int16 aInt;
- *pStrm >> aInt;
- rVar.PutInteger( aInt );
- }
- break;
+ if( bBinary && SbiRuntime::isVBAEnabled() && aByte == 1 && pStrm->IsEof() )
+ {
+ aByte = 0;
+ }
+ rVar.PutByte( aByte );
+ }
+ break;
+
+ case SbxEMPTY:
+ case SbxNULL:
+ case SbxVOID:
+ case SbxINTEGER:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ {
+ sal_Int16 aInt;
+ *pStrm >> aInt;
+ rVar.PutInteger( aInt );
+ }
+ break;
- case SbxLONG:
- case SbxULONG:
- {
- sal_Int32 aInt;
- *pStrm >> aInt;
- rVar.PutLong( aInt );
- }
- break;
- case SbxSALINT64:
- case SbxSALUINT64:
- {
- sal_uInt32 aInt;
- *pStrm >> aInt;
- rVar.PutInt64( (sal_Int64)aInt );
- }
- break;
- case SbxSINGLE:
- {
- float nS;
- *pStrm >> nS;
- rVar.PutSingle( nS );
- }
- break;
+ case SbxLONG:
+ case SbxULONG:
+ {
+ sal_Int32 aInt;
+ *pStrm >> aInt;
+ rVar.PutLong( aInt );
+ }
+ break;
+ case SbxSALINT64:
+ case SbxSALUINT64:
+ {
+ sal_uInt32 aInt;
+ *pStrm >> aInt;
+ rVar.PutInt64( (sal_Int64)aInt );
+ }
+ break;
+ case SbxSINGLE:
+ {
+ float nS;
+ *pStrm >> nS;
+ rVar.PutSingle( nS );
+ }
+ break;
- case SbxDOUBLE:
- case SbxCURRENCY:
- {
- *pStrm >> aDouble;
- rVar.PutDouble( aDouble );
- }
- break;
+ case SbxDOUBLE:
+ case SbxCURRENCY:
+ {
+ *pStrm >> aDouble;
+ rVar.PutDouble( aDouble );
+ }
+ break;
- case SbxDATE:
- {
- *pStrm >> aDouble;
- rVar.PutDate( aDouble );
- }
- break;
+ case SbxDATE:
+ {
+ *pStrm >> aDouble;
+ rVar.PutDate( aDouble );
+ }
+ break;
- case SbxSTRING:
- case SbxLPSTR:
- {
- String aStr = pStrm->ReadUniOrByteString(osl_getThreadTextEncoding());
- rVar.PutString( aStr );
- }
- break;
+ case SbxSTRING:
+ case SbxLPSTR:
+ {
+ OUString aStr = pStrm->ReadUniOrByteString(osl_getThreadTextEncoding());
+ rVar.PutString( aStr );
+ }
+ break;
- default:
- StarBASIC::Error( SbERR_BAD_ARGUMENT );
- return sal_False;
+ default:
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return sal_False;
}
if( nBlockLen )
+ {
pStrm->Seek( nFPos + nBlockLen );
+ }
return pStrm->GetErrorCode() ? sal_False : sal_True;
}
@@ -1239,7 +1320,9 @@ RTLFUNC(Environ)
osl_getThreadTextEncoding()));
const char* pEnvStr = getenv(aByteStr.getStr());
if ( pEnvStr )
+ {
aResult = rtl::OUString::createFromAscii( pEnvStr );
+ }
rPar.Get(0)->PutString( aResult );
}
@@ -1350,7 +1433,9 @@ RTLFUNC(ResolvePath)
rPar.Get(0)->PutString( aStr );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(TypeLen)
@@ -1359,70 +1444,73 @@ RTLFUNC(TypeLen)
(void)bWrite;
if ( rPar.Count() != 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
SbxDataType eType = rPar.Get(1)->GetType();
sal_Int16 nLen = 0;
switch( eType )
{
- case SbxEMPTY:
- case SbxNULL:
- case SbxVECTOR:
- case SbxARRAY:
- case SbxBYREF:
- case SbxVOID:
- case SbxHRESULT:
- case SbxPOINTER:
- case SbxDIMARRAY:
- case SbxCARRAY:
- case SbxUSERDEF:
- nLen = 0;
- break;
+ case SbxEMPTY:
+ case SbxNULL:
+ case SbxVECTOR:
+ case SbxARRAY:
+ case SbxBYREF:
+ case SbxVOID:
+ case SbxHRESULT:
+ case SbxPOINTER:
+ case SbxDIMARRAY:
+ case SbxCARRAY:
+ case SbxUSERDEF:
+ nLen = 0;
+ break;
- case SbxINTEGER:
- case SbxERROR:
- case SbxUSHORT:
- case SbxINT:
- case SbxUINT:
- nLen = 2;
- break;
+ case SbxINTEGER:
+ case SbxERROR:
+ case SbxUSHORT:
+ case SbxINT:
+ case SbxUINT:
+ nLen = 2;
+ break;
- case SbxLONG:
- case SbxSINGLE:
- case SbxULONG:
- nLen = 4;
- break;
+ case SbxLONG:
+ case SbxSINGLE:
+ case SbxULONG:
+ nLen = 4;
+ break;
- case SbxDOUBLE:
- case SbxCURRENCY:
- case SbxDATE:
- case SbxSALINT64:
- case SbxSALUINT64:
- nLen = 8;
- break;
+ case SbxDOUBLE:
+ case SbxCURRENCY:
+ case SbxDATE:
+ case SbxSALINT64:
+ case SbxSALUINT64:
+ nLen = 8;
+ break;
- case SbxOBJECT:
- case SbxVARIANT:
- case SbxDATAOBJECT:
- nLen = 0;
- break;
+ case SbxOBJECT:
+ case SbxVARIANT:
+ case SbxDATAOBJECT:
+ nLen = 0;
+ break;
- case SbxCHAR:
- case SbxBYTE:
- case SbxBOOL:
- nLen = 1;
+ case SbxCHAR:
+ case SbxBYTE:
+ case SbxBOOL:
+ nLen = 1;
break;
- case SbxLPSTR:
- case SbxLPWSTR:
- case SbxCoreSTRING:
- case SbxSTRING:
- nLen = (sal_Int16)rPar.Get(1)->GetString().Len();
- break;
+ case SbxLPSTR:
+ case SbxLPWSTR:
+ case SbxCoreSTRING:
+ case SbxSTRING:
+ nLen = (sal_Int16)rPar.Get(1)->GetOUString().getLength();
+ break;
- default:
- nLen = 0;
+ default:
+ nLen = 0;
+ break;
}
rPar.Get(0)->PutInteger( nLen );
}
@@ -1534,8 +1622,9 @@ RTLFUNC(GlobalScope)
SbxObject* p = pBasic;
while( p->GetParent() )
+ {
p = p->GetParent();
-
+ }
SbxVariableRef refVar = rPar.Get(0);
refVar->PutObject( p );
}
@@ -1550,15 +1639,20 @@ RTLFUNC(ConvertToUrl)
{
String aStr = rPar.Get(1)->GetString();
INetURLObject aURLObj( aStr, INET_PROT_FILE );
- ::rtl::OUString aFileURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE );
+ OUString aFileURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE );
if( aFileURL.isEmpty() )
+ {
::osl::File::getFileURLFromSystemPath( aFileURL, aFileURL );
+ }
if( aFileURL.isEmpty() )
+ {
aFileURL = aStr;
- rPar.Get(0)->PutString( String(aFileURL) );
+ }
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
RTLFUNC(ConvertFromUrl)
@@ -1569,14 +1663,16 @@ RTLFUNC(ConvertFromUrl)
if ( rPar.Count() == 2 )
{
String aStr = rPar.Get(1)->GetString();
- ::rtl::OUString aSysPath;
+ OUString aSysPath;
::osl::File::getSystemPathFromFileURL( aStr, aSysPath );
if( aSysPath.isEmpty() )
aSysPath = aStr;
rPar.Get(0)->PutString( String(aSysPath) );
}
else
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
}
@@ -1628,12 +1724,16 @@ RTLFUNC(Join)
String aStr = pArr->Get( &i )->GetString();
aRetStr += aStr;
if( i != nUpper )
+ {
aRetStr += aDelim;
+ }
}
rPar.Get(0)->PutString( aRetStr );
}
else
+ {
StarBASIC::Error( SbERR_MUST_HAVE_DIMS );
+ }
}
@@ -1757,8 +1857,8 @@ RTLFUNC(MonthName)
const CalendarItem2* pCalendarItems = aMonthSeq.getConstArray();
const CalendarItem2& rItem = pCalendarItems[nVal - 1];
- ::rtl::OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
- rPar.Get(0)->PutString( String(aRetStr) );
+ OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
+ rPar.Get(0)->PutString(aRetStr);
}
// WeekdayName(weekday, abbreviate, firstdayofweek)
@@ -1795,8 +1895,9 @@ RTLFUNC(WeekdayName)
}
}
if( nFirstDay == 0 )
+ {
nFirstDay = sal_Int16( xCalendar->getFirstDayOfWeek() + 1 );
-
+ }
nDay = 1 + (nDay + nDayCount + nFirstDay - 2) % nDayCount;
if( nDay < 1 || nDay > nDayCount )
{
@@ -1809,14 +1910,16 @@ RTLFUNC(WeekdayName)
{
SbxVariable* pPar2 = rPar.Get(2);
if( !pPar2->IsErr() )
+ {
bAbbreviate = pPar2->GetBool();
+ }
}
const CalendarItem2* pCalendarItems = aDaySeq.getConstArray();
const CalendarItem2& rItem = pCalendarItems[nDay - 1];
- ::rtl::OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
- rPar.Get(0)->PutString( String(aRetStr) );
+ OUString aRetStr = ( bAbbreviate ? rItem.AbbrevName : rItem.FullName );
+ rPar.Get(0)->PutString( aRetStr );
}
RTLFUNC(Weekday)
@@ -1826,7 +1929,9 @@ RTLFUNC(Weekday)
sal_uInt16 nParCount = rPar.Count();
if ( nParCount < 2 )
+ {
StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ }
else
{
double aDate = rPar.Get(1)->GetDate();
@@ -1912,9 +2017,13 @@ inline void implGetDayMonthYear( sal_Int16& rnYear, sal_Int16& rnMonth, sal_Int1
inline sal_Int16 limitToINT16( sal_Int32 n32 )
{
if( n32 > 32767 )
+ {
n32 = 32767;
+ }
else if( n32 < -32768 )
+ {
n32 = -32768;
+ }
return (sal_Int16)n32;
}
@@ -2432,8 +2541,9 @@ RTLFUNC(FormatDateTime)
pFormatter->GetOutputString( dDate, nIndex, aRetStr, &pCol );
if( !GetSbData()->pInst )
+ {
delete pFormatter;
-
+ }
break;
}
@@ -2550,7 +2660,7 @@ void CallFunctionAccessFunction( const Sequence< Any >& aArgs, const rtl::OUStri
Reference< XMultiServiceFactory > xFactory( getProcessServiceFactory() );
if( xFactory.is() )
{
- xFunc.set( xFactory->createInstance(::rtl::OUString("com.sun.star.sheet.FunctionAccess")), UNO_QUERY_THROW);
+ xFunc.set( xFactory->createInstance(OUString("com.sun.star.sheet.FunctionAccess")), UNO_QUERY_THROW);
}
}
Any aRet = xFunc->callFunction( sFuncName, aArgs );
@@ -2585,7 +2695,7 @@ RTLFUNC(SYD)
aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
aParams[ 3 ] <<= makeAny( rPar.Get(4)->GetDouble() );
- CallFunctionAccessFunction( aParams, rtl::OUString( "SYD" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "SYD" ), rPar.Get( 0 ) );
}
RTLFUNC(SLN)
@@ -2608,7 +2718,7 @@ RTLFUNC(SLN)
aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() );
aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
- CallFunctionAccessFunction( aParams, rtl::OUString( "SLN" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "SLN" ), rPar.Get( 0 ) );
}
RTLFUNC(Pmt)
@@ -2653,7 +2763,7 @@ RTLFUNC(Pmt)
aParams[ 3 ] <<= fv;
aParams[ 4 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "Pmt" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "Pmt" ), rPar.Get( 0 ) );
}
RTLFUNC(PPmt)
@@ -2700,7 +2810,7 @@ RTLFUNC(PPmt)
aParams[ 4 ] <<= fv;
aParams[ 5 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "PPmt" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "PPmt" ), rPar.Get( 0 ) );
}
RTLFUNC(PV)
@@ -2745,7 +2855,7 @@ RTLFUNC(PV)
aParams[ 3 ] <<= fv;
aParams[ 4 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "PV" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "PV" ), rPar.Get( 0 ) );
}
RTLFUNC(NPV)
@@ -2773,7 +2883,7 @@ RTLFUNC(NPV)
aParams[ 1 ] <<= aValues;
- CallFunctionAccessFunction( aParams, rtl::OUString( "NPV" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "NPV" ), rPar.Get( 0 ) );
}
RTLFUNC(NPer)
@@ -2818,7 +2928,7 @@ RTLFUNC(NPer)
aParams[ 3 ] <<= fv;
aParams[ 4 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "NPer" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "NPer" ), rPar.Get( 0 ) );
}
RTLFUNC(MIRR)
@@ -2849,7 +2959,7 @@ RTLFUNC(MIRR)
aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() );
aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() );
- CallFunctionAccessFunction( aParams, rtl::OUString( "MIRR" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "MIRR" ), rPar.Get( 0 ) );
}
RTLFUNC(IRR)
@@ -2886,7 +2996,7 @@ RTLFUNC(IRR)
aParams[ 0 ] <<= aValues;
aParams[ 1 ] <<= guess;
- CallFunctionAccessFunction( aParams, rtl::OUString( "IRR" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "IRR" ), rPar.Get( 0 ) );
}
RTLFUNC(IPmt)
@@ -2933,7 +3043,7 @@ RTLFUNC(IPmt)
aParams[ 4 ] <<= fv;
aParams[ 5 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "IPmt" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "IPmt" ), rPar.Get( 0 ) );
}
RTLFUNC(FV)
@@ -2978,7 +3088,7 @@ RTLFUNC(FV)
aParams[ 3 ] <<= pv;
aParams[ 4 ] <<= type;
- CallFunctionAccessFunction( aParams, rtl::OUString( "FV" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "FV" ), rPar.Get( 0 ) );
}
RTLFUNC(DDB)
@@ -3017,7 +3127,7 @@ RTLFUNC(DDB)
aParams[ 3 ] <<= period;
aParams[ 4 ] <<= factor;
- CallFunctionAccessFunction( aParams, rtl::OUString( "DDB" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "DDB" ), rPar.Get( 0 ) );
}
RTLFUNC(Rate)
@@ -3076,7 +3186,7 @@ RTLFUNC(Rate)
aParams[ 4 ] <<= type;
aParams[ 5 ] <<= guess;
- CallFunctionAccessFunction( aParams, rtl::OUString( "Rate" ), rPar.Get( 0 ) );
+ CallFunctionAccessFunction( aParams, OUString( "Rate" ), rPar.Get( 0 ) );
}
RTLFUNC(StrReverse)
@@ -3115,8 +3225,9 @@ RTLFUNC(CompatibilityMode)
if( pInst )
{
if ( nCount == 2 )
+ {
pInst->EnableCompatibility( rPar.Get(1)->GetBool() );
-
+ }
bEnabled = pInst->IsCompatibility();
}
rPar.Get(0)->PutBool( bEnabled );
diff --git a/basic/source/runtime/sbdiagnose.cxx b/basic/source/runtime/sbdiagnose.cxx
index 95d2332e9900..2e5c1dcb3835 100644
--- a/basic/source/runtime/sbdiagnose.cxx
+++ b/basic/source/runtime/sbdiagnose.cxx
@@ -56,7 +56,9 @@ void DbgReportAssertion( const sal_Char* i_assertionMessage )
// prevent infinite recursion
if ( bReportingAssertion )
+ {
return;
+ }
::comphelper::FlagRestorationGuard aGuard( bReportingAssertion, true );
SbxArrayRef const xArguments( new SbxArray( SbxVARIANT ) );
@@ -66,7 +68,9 @@ void DbgReportAssertion( const sal_Char* i_assertionMessage )
ErrCode const nError = xAssertionChannelBasic->Call( sCaptureFunctionName, xArguments );
if ( ( nError & SbERR_METHOD_NOT_FOUND ) != 0 )
+ {
ResetCapturedAssertions();
+ }
}
#endif
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 8182afff7977..70384dbf3f04 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -801,9 +801,13 @@ SbxVariable* SbiStdObject::Find( const rtl::OUString& rName, SbxClassType t )
String aName_ = rtl::OUString::createFromAscii( p->pName );
SbxClassType eCT = SbxCLASS_OBJECT;
if( nType & _PROPERTY )
+ {
eCT = SbxCLASS_PROPERTY;
+ }
else if( nType & _METHOD )
+ {
eCT = SbxCLASS_METHOD;
+ }
pVar = Make( aName_, eCT, p->eType );
pVar->SetUserData( nIndex + 1 );
pVar->SetFlags( nAccess );
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx
index a436c100e573..9f938eeec268 100644
--- a/basic/source/runtime/step0.cxx
+++ b/basic/source/runtime/step0.cxx
@@ -35,8 +35,8 @@
#include <vcl/svapp.hxx>
#include <unotools/textsearch.hxx>
-Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
- const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
+Reference< XInterface > createComListener( const Any& aControlAny, const OUString& aVBAType,
+ const OUString& aPrefix, SbxObjectRef xScopeObj );
#include <algorithm>
#include <boost/unordered_map.hpp>
@@ -291,11 +291,13 @@ void SbiRuntime::StepLIKE()
int bTextMode(1);
bool bCompatibility = ( GetSbData()->pInst && GetSbData()->pInst->IsCompatibility() );
if( bCompatibility )
+ {
bTextMode = GetImageFlag( SBIMG_COMPARETEXT );
-
+ }
if( bTextMode )
+ {
aSearchOpt.transliterateFlags |= com::sun::star::i18n::TransliterationModules_IGNORE_CASE;
-
+ }
SbxVariable* pRes = new SbxVariable;
utl::TextSearch aSearch(aSearchOpt);
xub_StrLen nStart=0, nEnd=value.Len();
@@ -327,7 +329,9 @@ void SbiRuntime::StepIS()
sal_Bool bRes = sal_Bool( eType1 == SbxOBJECT && eType2 == SbxOBJECT );
if ( bVBAEnabled && !bRes )
+ {
Error( SbERR_INVALID_USAGE_OBJECT );
+ }
bRes = ( bRes && refVar1->GetObject() == refVar2->GetObject() );
SbxVariable* pRes = new SbxVariable;
pRes->PutBool( bRes );
@@ -455,8 +459,8 @@ void SbiRuntime::StepPUT()
// VBA Dim As New behavior handling, save init object information
struct DimAsNewRecoverItem
{
- OUString m_aObjClass;
- OUString m_aObjName;
+ OUString m_aObjClass;
+ OUString m_aObjName;
SbxObject* m_pObjParent;
SbModule* m_pClassModule;
@@ -492,7 +496,9 @@ void removeDimAsNewRecoverItem( SbxVariable* pVar )
DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( pVar );
if( it != rDimAsNewRecoverHash.end() )
+ {
rDimAsNewRecoverHash.erase( it );
+ }
}
@@ -532,9 +538,13 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
SbxVariableRef refObjVal = PTR_CAST(SbxObject,pObjVarObj);
if( refObjVal )
+ {
refVal = refObjVal;
+ }
else if( !(eValType & SbxARRAY) )
+ {
refVal = NULL;
+ }
}
}
@@ -557,8 +567,9 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
}
SbProcedureProperty* pProcProperty = PTR_CAST(SbProcedureProperty,(SbxVariable*)refVar);
if( pProcProperty )
+ {
pProcProperty->setSet( true );
-
+ }
if ( bHandleDefaultProp )
{
// get default properties for lhs & rhs where necessary
@@ -593,10 +604,14 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
}
SbxVariable* pDflt = NULL;
if ( pObj || bLHSHasDefaultProp )
+ {
// lhs is either a valid object || or has a defaultProp
pDflt = getDefaultProp( refVal );
+ }
if ( pDflt )
+ {
refVal = pDflt;
+ }
}
}
@@ -604,8 +619,9 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
bool bDimAsNew = bVBAEnabled && refVar->IsSet( SBX_DIM_AS_NEW );
SbxBaseRef xPrevVarObj;
if( bDimAsNew )
+ {
xPrevVarObj = refVar->GetObject();
-
+ }
// Handle withevents
sal_Bool bWithEvents = refVar->IsSet( SBX_WITH_EVENTS );
if ( bWithEvents )
@@ -618,8 +634,8 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
{
Any aControlAny = pUnoObj->getUnoAny();
String aDeclareClassName = refVar->GetDeclareClassName();
- ::rtl::OUString aVBAType = aDeclareClassName;
- ::rtl::OUString aPrefix = refVar->GetName();
+ OUString aVBAType = aDeclareClassName;
+ OUString aPrefix = refVar->GetName();
SbxObjectRef xScopeObj = refVar->GetParent();
xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj );
@@ -635,8 +651,9 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
// in this case we do not want to call checkUnoStructCopy 'cause that will
// cause an error also
if ( !checkUnoStructCopy( bHandleDefaultProp, refVal, refVar ) )
+ {
*refVar = *refVal;
-
+ }
if ( bDimAsNew )
{
if( !refVar->ISA(SbxObject) )
@@ -700,9 +717,10 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
}
}
-
if( bFlagsChanged )
+ {
refVar->SetFlags( n );
+ }
}
}
@@ -726,9 +744,11 @@ void SbiRuntime::StepLSET()
{
SbxVariableRef refVal = PopVar();
SbxVariableRef refVar = PopVar();
- if( refVar->GetType() != SbxSTRING
- || refVal->GetType() != SbxSTRING )
+ if( refVar->GetType() != SbxSTRING ||
+ refVal->GetType() != SbxSTRING )
+ {
Error( SbERR_INVALID_USAGE_OBJECT );
+ }
else
{
sal_uInt16 n = refVar->GetFlags();
@@ -759,9 +779,10 @@ void SbiRuntime::StepRSET()
{
SbxVariableRef refVal = PopVar();
SbxVariableRef refVar = PopVar();
- if( refVar->GetType() != SbxSTRING
- || refVal->GetType() != SbxSTRING )
+ if( refVar->GetType() != SbxSTRING || refVal->GetType() != SbxSTRING )
+ {
Error( SbERR_INVALID_USAGE_OBJECT );
+ }
else
{
sal_uInt16 n = refVar->GetFlags();
@@ -818,7 +839,9 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
if ( refRedim )
{
if ( !refRedimpArray ) // only erase the array not ReDim Preserve
+ {
lcl_eraseImpl( refVar, bVBAEnabled );
+ }
SbxDataType eType = refVar->GetType();
lcl_clearImpl( refVar, eType );
refRedim = NULL;
@@ -827,7 +850,9 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
// must have an even number of arguments
// have in mind that Arg[0] does not count!
if( pDims && !( pDims->Count() & 1 ) )
+ {
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
+ }
else
{
SbxDataType eType = refVar->IsFixed() ? refVar->GetType() : SbxVARIANT;
@@ -842,10 +867,14 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar )
sal_Int32 lb = pDims->Get( i++ )->GetLong();
sal_Int32 ub = pDims->Get( i++ )->GetLong();
if( ub < lb )
+ {
Error( SbERR_OUT_OF_RANGE ), ub = lb;
+ }
pArray->AddDim32( lb, ub );
if ( lb != ub )
+ {
pArray->setHasFixedSize( true );
+ }
}
}
else
@@ -891,7 +920,9 @@ void implCopyDimArray( SbxDimArray* pNewArray, SbxDimArray* pOldArray, short nMa
SbxVariable* pSource = pOldArray->Get32( pActualIndices );
SbxVariable* pDest = pNewArray->Get32( pActualIndices );
if( pSource && pDest )
+ {
*pDest = *pSource;
+ }
}
}
}
@@ -954,7 +985,7 @@ void SbiRuntime::StepREDIMP()
// (It would be faster to work on the flat internal data array of an
// SbyArray but this solution is clearer and easier)
implCopyDimArray( pNewArray, pOldArray, nDims - 1,
- 0, pActualIndices, pLowerBounds, pUpperBounds );
+ 0, pActualIndices, pLowerBounds, pUpperBounds );
}
delete[] pUpperBounds;
@@ -985,11 +1016,14 @@ void SbiRuntime::StepREDIMP_ERASE()
}
}
- else
- if( refVar->IsFixed() )
+ else if( refVar->IsFixed() )
+ {
refVar->Clear();
+ }
else
+ {
refVar->SetType( SbxEMPTY );
+ }
}
static void lcl_clearImpl( SbxVariableRef& refVar, SbxDataType& eType )
@@ -1020,28 +1054,37 @@ static void lcl_eraseImpl( SbxVariableRef& refVar, bool bVBAEnabled )
bClearValues = false;
}
else
+ {
pDimArray->Clear(); // clear Dims
+ }
}
if ( bClearValues )
{
SbxArray* pArray = PTR_CAST(SbxArray,pElemObj);
if ( pArray )
+ {
pArray->Clear();
+ }
}
}
else
- // Arrays have on an erase to VB quite a complex behaviour. Here are
- // only the type problems at REDIM (#26295) removed at first:
- // Set type hard onto the array-type, because a variable with array is
- // SbxOBJECT. At REDIM there's an SbxOBJECT-array generated then and
- // the original type is lost -> runtime error
+ {
+ // Arrays have on an erase to VB quite a complex behaviour. Here are
+ // only the type problems at REDIM (#26295) removed at first:
+ // Set type hard onto the array-type, because a variable with array is
+ // SbxOBJECT. At REDIM there's an SbxOBJECT-array generated then and
+ // the original type is lost -> runtime error
lcl_clearImpl( refVar, eType );
+ }
}
- else
- if( refVar->IsFixed() )
+ else if( refVar->IsFixed() )
+ {
refVar->Clear();
+ }
else
+ {
refVar->SetType( SbxEMPTY );
+ }
}
// delete variable
@@ -1061,7 +1104,9 @@ void SbiRuntime::StepERASE_CLEAR()
void SbiRuntime::StepARRAYACCESS()
{
if( !refArgv )
+ {
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
+ }
SbxVariableRef refVar = PopVar();
refVar->SetParameters( refArgv );
PopArgv();
@@ -1096,7 +1141,9 @@ void SbiRuntime::StepARGC()
void SbiRuntime::StepARGV()
{
if( !refArgv )
+ {
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
+ }
else
{
SbxVariableRef pVal = PopVar();
@@ -1125,20 +1172,27 @@ void SbiRuntime::StepINPUT()
{
ch = pIosys->Read();
if( ch != ' ' && ch != '\t' && ch != '\n' )
+ {
break;
+ }
}
if( !err )
{
// Scan until comma or whitespace
char sep = ( ch == '"' ) ? ch : 0;
- if( sep ) ch = pIosys->Read();
+ if( sep )
+ {
+ ch = pIosys->Read();
+ }
while( ( err = pIosys->GetError() ) == 0 )
{
if( ch == sep )
{
ch = pIosys->Read();
if( ch != sep )
+ {
break;
+ }
}
else if( !sep && (ch == ',' || ch == '\n') )
break;
@@ -1147,11 +1201,15 @@ void SbiRuntime::StepINPUT()
}
// skip whitespace
if( ch == ' ' || ch == '\t' )
- while( ( err = pIosys->GetError() ) == 0 )
{
- if( ch != ' ' && ch != '\t' && ch != '\n' )
- break;
- ch = pIosys->Read();
+ while( ( err = pIosys->GetError() ) == 0 )
+ {
+ if( ch != ' ' && ch != '\t' && ch != '\n' )
+ {
+ break;
+ }
+ ch = pIosys->Read();
+ }
}
}
if( !err )
@@ -1178,7 +1236,9 @@ void SbiRuntime::StepINPUT()
err = SbxBase::GetError();
SbxBase::ResetError();
if( !err )
+ {
err = SbERR_CONVERSION;
+ }
}
}
else
@@ -1189,13 +1249,19 @@ void SbiRuntime::StepINPUT()
}
}
if( err == SbERR_USER_ABORT )
+ {
Error( err );
+ }
else if( err )
{
if( pRestart && !pIosys->GetChannel() )
+ {
pCode = pRestart;
+ }
else
+ {
Error( err );
+ }
}
else
{
@@ -1208,7 +1274,7 @@ void SbiRuntime::StepINPUT()
void SbiRuntime::StepLINPUT()
{
- rtl::OString aInput;
+ OString aInput;
pIosys->Read( aInput );
Error( pIosys->GetError() );
SbxVariableRef p = PopVar();
@@ -1243,7 +1309,9 @@ void SbiRuntime::StepNEXT()
return;
}
if( pForStk->eForType == FOR_TO )
+ {
pForStk->refVar->Compute( SbxPLUS, *pForStk->refInc );
+ }
}
// beginning CASE: TOS in CASE-stack
@@ -1251,7 +1319,9 @@ void SbiRuntime::StepNEXT()
void SbiRuntime::StepCASE()
{
if( !refCaseStk.Is() )
+ {
refCaseStk = new SbxArray;
+ }
SbxVariableRef xVar = PopVar();
refCaseStk->Put( xVar, refCaseStk->Count() );
}
@@ -1261,9 +1331,13 @@ void SbiRuntime::StepCASE()
void SbiRuntime::StepENDCASE()
{
if( !refCaseStk || !refCaseStk->Count() )
+ {
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
+ }
else
+ {
refCaseStk->Remove( refCaseStk->Count() - 1 );
+ }
}
@@ -1294,7 +1368,9 @@ void SbiRuntime::StepLEAVE()
bRun = false;
// If VBA and we are leaving an ErrorHandler then clear the error ( it's been processed )
if ( bInError && pError )
+ {
SbxErrObject::getUnoErrObject()->Clear();
+ }
}
void SbiRuntime::StepCHANNEL() // TOS = channel number
@@ -1329,7 +1405,9 @@ void SbiRuntime::StepPRINTF() // print TOS in field
OUString s1 = p->GetString();
OUStringBuffer s;
if( p->GetType() >= SbxINTEGER && p->GetType() <= SbxDOUBLE )
+ {
s.append(' ');
+ }
s.append(s1);
comphelper::string::padToLength(s, 14, ' ');
OString aByteStr(OUStringToOString(s.makeStringAndClear(), osl_getThreadTextEncoding()));
@@ -1344,11 +1422,11 @@ void SbiRuntime::StepWRITE() // write TOS
char ch = 0;
switch (p->GetType() )
{
- case SbxSTRING: ch = '"'; break;
- case SbxCURRENCY:
- case SbxBOOL:
- case SbxDATE: ch = '#'; break;
- default: break;
+ case SbxSTRING: ch = '"'; break;
+ case SbxCURRENCY:
+ case SbxBOOL:
+ case SbxDATE: ch = '#'; break;
+ default: break;
}
String s;
if( ch )
@@ -1415,9 +1493,13 @@ void SbiRuntime::StepERROR()
sal_uInt16 n = refCode->GetUShort();
SbError error = StarBASIC::GetSfxFromVBError( n );
if ( bVBAEnabled )
+ {
pInst->Error( error );
+ }
else
+ {
Error( error );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index df132dd91f6a..841fbe25202f 100644
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -232,8 +232,9 @@ SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt
}
// #39108 Args can already be deleted!
if( !bFatalError )
+ {
SetupArgs( pElem, nOp1 );
-
+ }
// because a particular call-type is requested
if( pElem->IsA( TYPE(SbxMethod) ) )
{
@@ -575,7 +576,9 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
Any aAny2 = xIndexAccess->getByIndex( nIndex );
TypeClass eType = aAny2.getValueType().getTypeClass();
if( eType == TypeClass_INTERFACE )
+ {
xRet = *(Reference< XInterface >*)aAny2.getValue();
+ }
}
catch (const IndexOutOfBoundsException&)
{
@@ -825,7 +828,9 @@ void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 )
SbxVariableRef xComp = PopVar();
SbxVariableRef xCase = refCaseStk->Get( refCaseStk->Count() - 1 );
if( xCase->Compare( (SbxOperator) nOp2, *xComp ) )
+ {
StepJUMP( nOp1 );
+ }
}
}
@@ -1192,7 +1197,9 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3
bool bVarToDim = ((nOp2 & SBX_TYPE_VAR_TO_DIM_FLAG) != 0);
if( bVarToDim )
+ {
pVar->SetFlag( SBX_VAR_TO_DIM );
+ }
}
// establishing a local variable (+StringID+type)
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index e1725a893fd2..546727290348 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -260,7 +260,9 @@ const XubString& SbxArray::GetAlias( sal_uInt16 nIdx )
return String::EmptyString();
#ifdef DBG_UTIL
else
+ {
DBG_CHKOBJ( rRef, SbxBase, 0 );
+ }
#endif
return *rRef.pAlias;
@@ -269,14 +271,18 @@ const XubString& SbxArray::GetAlias( sal_uInt16 nIdx )
void SbxArray::PutAlias( const XubString& rAlias, sal_uInt16 nIdx )
{
if( !CanWrite() )
+ {
SetError( SbxERR_PROP_READONLY );
+ }
else
{
SbxVarEntry& rRef = (SbxVarEntry&) GetRef( nIdx );
if( !rRef.pAlias )
rRef.pAlias = new XubString( rAlias );
else
+ {
*rRef.pAlias = rAlias;
+ }
}
}
@@ -284,14 +290,20 @@ void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx )
{
DBG_ASSERT( pData->size() <= SBX_MAXINDEX32, "SBX: Array wird zu gross" );
if( pData->size() > SBX_MAXINDEX32 )
+ {
return;
+ }
SbxVarEntryPtr p = new SbxVarEntry;
*((SbxVariableRef*) p) = pVar;
SbxVarEntryPtrVector::size_type nSize = pData->size();
if( nIdx > nSize )
+ {
nIdx = nSize;
+ }
if( eType != SbxVARIANT && pVar )
+ {
(*p)->Convert( eType );
+ }
if( nIdx == nSize )
{
pData->push_back( p );
@@ -307,7 +319,9 @@ void SbxArray::Insert( SbxVariable* pVar, sal_uInt16 nIdx )
{
DBG_ASSERT( pData->size() <= 0x3FF0, "SBX: Array wird zu gross" );
if( pData->size() > 0x3FF0 )
- return;
+ {
+ return;
+ }
Insert32( pVar, nIdx );
}
@@ -441,7 +455,7 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData )
// Search of an element by his name and type. If an element is an object,
// it will also be scanned..
-SbxVariable* SbxArray::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t )
{
SbxVariable* p = NULL;
sal_uInt32 nCount = pData->size();
diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx
index 968c791f2926..69d159749a7d 100644
--- a/basic/source/sbx/sbxcoll.cxx
+++ b/basic/source/sbx/sbxcoll.cxx
@@ -96,7 +96,9 @@ SbxVariable* SbxCollection::FindUserData( sal_uInt32 nData )
return pObj ? pObj->FindUserData( nData ) : NULL;
}
else
+ {
return SbxObject::FindUserData( nData );
+ }
}
SbxVariable* SbxCollection::Find( const rtl::OUString& rName, SbxClassType t )
@@ -107,7 +109,9 @@ SbxVariable* SbxCollection::Find( const rtl::OUString& rName, SbxClassType t )
return pObj ? pObj->Find( rName, t ) : NULL;
}
else
+ {
return SbxObject::Find( rName, t );
+ }
}
void SbxCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1,
@@ -151,14 +155,20 @@ void SbxCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1,
void SbxCollection::CollAdd( SbxArray* pPar_ )
{
if( pPar_->Count() != 2 )
+ {
SetError( SbxERR_WRONG_ARGS );
+ }
else
{
SbxBase* pObj = pPar_->Get( 1 )->GetObject();
if( !pObj || !( pObj->ISA(SbxObject) ) )
+ {
SetError( SbxERR_NOTIMP );
+ }
else
+ {
Insert( (SbxObject*) pObj );
+ }
}
}
@@ -167,7 +177,9 @@ void SbxCollection::CollAdd( SbxArray* pPar_ )
void SbxCollection::CollItem( SbxArray* pPar_ )
{
if( pPar_->Count() != 2 )
+ {
SetError( SbxERR_WRONG_ARGS );
+ }
else
{
SbxVariable* pRes = NULL;
@@ -178,10 +190,14 @@ void SbxCollection::CollItem( SbxArray* pPar_ )
{
short n = p->GetInteger();
if( n >= 1 && n <= (short) pObjs->Count() )
+ {
pRes = pObjs->Get( (sal_uInt16) n - 1 );
+ }
}
if( !pRes )
+ {
SetError( SbxERR_BAD_INDEX );
+ }
pPar_->Get( 0 )->PutObject( pRes );
}
}
@@ -226,9 +242,13 @@ SbxStdCollection& SbxStdCollection::operator=( const SbxStdCollection& r )
if( &r != this )
{
if( !r.aElemClass.EqualsIgnoreCaseAscii( aElemClass ) )
+ {
SetError( SbxERR_CONVERSION );
+ }
else
+ {
SbxCollection::operator=( r );
+ }
}
return *this;
}
diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx
index 74cf3b2a21b6..3376d977c82f 100644
--- a/basic/source/sbx/sbxexec.cxx
+++ b/basic/source/sbx/sbxexec.cxx
@@ -138,16 +138,20 @@ static SbxVariable* Operand
SbxVariableRef refVar( new SbxVariable );
const sal_Unicode* p = SkipWhitespace( *ppBuf );
if( !bVar && ( aCharClass.isDigit( *p )
- || ( *p == '.' && aCharClass.isDigit( *( p+1 ) ) )
- || *p == '-'
- || *p == '&' ) )
+ || ( *p == '.' && aCharClass.isDigit( *( p+1 ) ) )
+ || *p == '-'
+ || *p == '&' ) )
{
// A number could be scanned in directly!
sal_uInt16 nLen;
- if( !refVar->Scan( rtl::OUString( p ), &nLen ) )
+ if( !refVar->Scan( OUString( p ), &nLen ) )
+ {
refVar.Clear();
+ }
else
+ {
p += nLen;
+ }
}
else if( !bVar && *p == '"' )
{
@@ -168,7 +172,9 @@ static SbxVariable* Operand
refVar->PutString( aString );
}
else
+ {
refVar = QualifiedName( pObj, pGbl, &p, SbxCLASS_DONTCARE );
+ }
*ppBuf = p;
if( refVar.Is() )
refVar->AddRef();
diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx
index 29cd1a9f8573..b267df7cfc3d 100644
--- a/basic/source/sbx/sbxform.cxx
+++ b/basic/source/sbx/sbxform.cxx
@@ -945,9 +945,13 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg )
if( b0FormatFound )
{
if( s0FormatStrg.Len() == 0 && bPosFormatFound )
+ {
sTempStrg = sPosFormatStrg;
+ }
else
+ {
sTempStrg = s0FormatStrg;
+ }
}
else if( bPosFormatFound )
{
@@ -967,10 +971,14 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg )
sTempStrg += sPosFormatStrg;
}
else
+ {
sTempStrg = sNegFormatStrg;
- }
+ }
+ }
else
+ {
sTempStrg = sFormatStrg;
+ }
// if NO format-string especially for negative
// values is given, output the leading sign
ScanFormatString( dNumber, sTempStrg, sReturnStrg,/*bCreateSign=*/bNegFormatFound/*sNegFormatStrg!=EMPTYFORMATSTRING*/ );
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index bdf2200c6722..4c7c966f5bb0 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -146,7 +146,9 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
&& aVarName.EqualsIgnoreCaseAscii( pNameProp ) )
{
if( bRead )
+ {
pVar->PutString( GetName() );
+ }
else
SetName( pVar->GetString() );
}
@@ -155,7 +157,9 @@ void SbxObject::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
{
SbxObject* p_ = GetParent();
if( !p_ )
+ {
p_ = this;
+ }
pVar->PutObject( p_ );
}
}
@@ -170,13 +174,18 @@ sal_Bool SbxObject::IsClass( const rtl::OUString& rName ) const
SbxVariable* SbxObject::FindUserData( sal_uInt32 nData )
{
if( !GetAll( SbxCLASS_DONTCARE ) )
+ {
return NULL;
-
+ }
SbxVariable* pRes = pMethods->FindUserData( nData );
if( !pRes )
+ {
pRes = pProps->FindUserData( nData );
+ }
if( !pRes )
+ {
pRes = pObjs->FindUserData( nData );
+ }
// Search in the parents?
if( !pRes && IsSet( SBX_GBLSEARCH ) )
{
@@ -198,46 +207,52 @@ SbxVariable* SbxObject::FindUserData( sal_uInt32 nData )
return pRes;
}
-SbxVariable* SbxObject::Find( const rtl::OUString& rName, SbxClassType t )
+SbxVariable* SbxObject::Find( const OUString& rName, SbxClassType t )
{
#ifdef DBG_UTIL
static sal_uInt16 nLvl = 0;
- static const char* pCls[] =
- { "DontCare","Array","Value","Variable","Method","Property","Object" };
+ static const char* pCls[] = { "DontCare","Array","Value","Variable","Method","Property","Object" };
rtl::OString aNameStr1(rtl::OUStringToOString(rName, RTL_TEXTENCODING_ASCII_US));
rtl::OString aNameStr2(rtl::OUStringToOString(SbxVariable::GetName(), RTL_TEXTENCODING_ASCII_US));
DbgOutf( "SBX: Search %.*s %s %s in %s",
- nLvl++, " ",
- ( t >= SbxCLASS_DONTCARE && t <= SbxCLASS_OBJECT )
- ? pCls[ t-1 ] : "Unknown class", aNameStr1.getStr(), aNameStr1.getStr() );
+ nLvl++, " ",
+ ( t >= SbxCLASS_DONTCARE && t <= SbxCLASS_OBJECT )
+ ? pCls[ t-1 ] : "Unknown class", aNameStr1.getStr(), aNameStr1.getStr() );
#endif
if( !GetAll( t ) )
+ {
return NULL;
+ }
SbxVariable* pRes = NULL;
pObjs->SetFlag( SBX_EXTSEARCH );
if( t == SbxCLASS_DONTCARE )
{
pRes = pMethods->Find( rName, SbxCLASS_METHOD );
if( !pRes )
+ {
pRes = pProps->Find( rName, SbxCLASS_PROPERTY );
+ }
if( !pRes )
+ {
pRes = pObjs->Find( rName, t );
+ }
}
else
{
SbxArray* pArray = NULL;
switch( t )
{
- case SbxCLASS_VARIABLE:
- case SbxCLASS_PROPERTY: pArray = pProps; break;
- case SbxCLASS_METHOD: pArray = pMethods; break;
- case SbxCLASS_OBJECT: pArray = pObjs; break;
- default:
- DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
+ case SbxCLASS_VARIABLE:
+ case SbxCLASS_PROPERTY: pArray = pProps; break;
+ case SbxCLASS_METHOD: pArray = pMethods; break;
+ case SbxCLASS_OBJECT: pArray = pObjs; break;
+ default: DBG_ASSERT( !this, "Ungueltige SBX-Klasse" ); break;
}
if( pArray )
+ {
pRes = pArray->Find( rName, t );
+ }
}
// ExtendedsSearch in the Object-Array?
// For objects and DontCare is the array of objects already
@@ -286,7 +301,9 @@ sal_Bool SbxObject::Call( const XubString& rName, SbxArray* pParam )
{
// FindQualified() might have been stroked!
if( pParam )
+ {
pMeth->SetParameters( pParam );
+ }
pMeth->Broadcast( SBX_HINT_DATAWANTED );
pMeth->SetParameters( NULL );
return sal_True;
@@ -301,14 +318,18 @@ SbxProperty* SbxObject::GetDfltProperty()
{
pDfltProp = (SbxProperty*) Find( aDfltPropName, SbxCLASS_PROPERTY );
if( !pDfltProp )
+ {
pDfltProp = (SbxProperty*) Make( aDfltPropName, SbxCLASS_PROPERTY, SbxVARIANT );
+ }
}
return pDfltProp;
}
void SbxObject::SetDfltProperty( const XubString& rName )
{
if ( rName != aDfltPropName )
+ {
pDfltProp = NULL;
+ }
aDfltPropName = rName;
SetModified( sal_True );
}
@@ -322,12 +343,11 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
SbxArray* pArray = NULL;
if( pVar ) switch( pVar->GetClass() )
{
- case SbxCLASS_VARIABLE:
- case SbxCLASS_PROPERTY: pArray = pProps; break;
- case SbxCLASS_METHOD: pArray = pMethods; break;
- case SbxCLASS_OBJECT: pArray = pObjs; break;
- default:
- DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
+ case SbxCLASS_VARIABLE:
+ case SbxCLASS_PROPERTY: pArray = pProps; break;
+ case SbxCLASS_METHOD: pArray = pMethods; break;
+ case SbxCLASS_OBJECT: pArray = pObjs; break;
+ default: DBG_ASSERT( !this, "Ungueltige SBX-Klasse" ); break;
}
if( pArray )
{
@@ -336,12 +356,14 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx )
pArray->ResetFlag( SBX_EXTSEARCH );
SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() );
if( pOld )
- for( sal_uInt16 i = 0; i < pArray->Count(); i++ )
{
- SbxVariableRef& rRef = pArray->GetRef( i );
- if( (SbxVariable*) rRef == pOld )
+ for( sal_uInt16 i = 0; i < pArray->Count(); i++ )
{
- nArrayIdx = i; break;
+ SbxVariableRef& rRef = pArray->GetRef( i );
+ if( (SbxVariable*) rRef == pOld )
+ {
+ nArrayIdx = i; break;
+ }
}
}
}
@@ -357,12 +379,11 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy
SbxArray* pArray = NULL;
switch( ct )
{
- case SbxCLASS_VARIABLE:
- case SbxCLASS_PROPERTY: pArray = pProps; break;
- case SbxCLASS_METHOD: pArray = pMethods; break;
- case SbxCLASS_OBJECT: pArray = pObjs; break;
- default:
- DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
+ case SbxCLASS_VARIABLE:
+ case SbxCLASS_PROPERTY: pArray = pProps; break;
+ case SbxCLASS_METHOD: pArray = pMethods; break;
+ case SbxCLASS_OBJECT: pArray = pObjs; break;
+ default: DBG_ASSERT( !this, "Ungueltige SBX-Klasse" ); break;
}
if( !pArray )
return NULL;
@@ -378,17 +399,18 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy
SbxVariable* pVar = NULL;
switch( ct )
{
- case SbxCLASS_VARIABLE:
- case SbxCLASS_PROPERTY:
- pVar = new SbxProperty( rName, dt );
- break;
- case SbxCLASS_METHOD:
- pVar = new SbxMethod( rName, dt );
- break;
- case SbxCLASS_OBJECT:
- pVar = CreateObject( rName );
- break;
- default: break;
+ case SbxCLASS_VARIABLE:
+ case SbxCLASS_PROPERTY:
+ pVar = new SbxProperty( rName, dt );
+ break;
+ case SbxCLASS_METHOD:
+ pVar = new SbxMethod( rName, dt );
+ break;
+ case SbxCLASS_OBJECT:
+ pVar = CreateObject( rName );
+ break;
+ default:
+ break;
}
pVar->SetParent( this );
pArray->Put( pVar, pArray->Count() );
@@ -483,12 +505,11 @@ void SbxObject::QuickInsert( SbxVariable* pVar )
{
switch( pVar->GetClass() )
{
- case SbxCLASS_VARIABLE:
- case SbxCLASS_PROPERTY: pArray = pProps; break;
- case SbxCLASS_METHOD: pArray = pMethods; break;
- case SbxCLASS_OBJECT: pArray = pObjs; break;
- default:
- DBG_ASSERT( !this, "Ungueltige SBX-Klasse" );
+ case SbxCLASS_VARIABLE:
+ case SbxCLASS_PROPERTY: pArray = pProps; break;
+ case SbxCLASS_METHOD: pArray = pMethods; break;
+ case SbxCLASS_OBJECT: pArray = pObjs; break;
+ default: DBG_ASSERT( !this, "Ungueltige SBX-Klasse" ); break;
}
}
if( pArray )
@@ -534,12 +555,18 @@ void SbxObject::Remove( SbxVariable* pVar )
#endif
SbxVariableRef pVar_ = pArray->Get( nIdx );
if( pVar_->IsBroadcaster() )
+ {
EndListening( pVar_->GetBroadcaster(), sal_True );
+ }
if( (SbxVariable*) pVar_ == pDfltProp )
+ {
pDfltProp = NULL;
+ }
pArray->Remove( nIdx );
if( pVar_->GetParent() == this )
+ {
pVar_->SetParent( NULL );
+ }
SetModified( sal_True );
Broadcast( SBX_HINT_OBJECTCHANGED );
}
@@ -549,7 +576,9 @@ static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray )
{
SbxArrayRef p = (SbxArray*) SbxBase::Load( rStrm );
if( !p.Is() )
+ {
return sal_False;
+ }
for( sal_uInt16 i = 0; i < p->Count(); i++ )
{
SbxVariableRef& r = p->GetRef( i );
@@ -571,14 +600,19 @@ sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer )
// Help for the read in of old objects: just TRUE back,
// LoadPrivateData() had to set the default status up
if( !nVer )
+ {
return sal_True;
-
+ }
pDfltProp = NULL;
if( !SbxVariable::LoadData( rStrm, nVer ) )
+ {
return sal_False;
+ }
// If it contains no alien object, insert ourselves
if( aData.eType == SbxOBJECT && !aData.pObj )
+ {
aData.pObj = this;
+ }
sal_uInt32 nSize;
XubString aDfltProp;
aClassName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStrm,
@@ -593,14 +627,20 @@ sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer )
nPos += nSize;
DBG_ASSERT( nPos >= nNewPos, "SBX: Zu viele Daten eingelesen" );
if( nPos != nNewPos )
+ {
rStrm.Seek( nPos );
- if( !LoadArray( rStrm, this, pMethods )
- || !LoadArray( rStrm, this, pProps )
- || !LoadArray( rStrm, this, pObjs ) )
+ }
+ if( !LoadArray( rStrm, this, pMethods ) ||
+ !LoadArray( rStrm, this, pProps ) ||
+ !LoadArray( rStrm, this, pObjs ) )
+ {
return sal_False;
+ }
// Set properties
if( aDfltProp.Len() )
+ {
pDfltProp = (SbxProperty*) pProps->Find( aDfltProp, SbxCLASS_PROPERTY );
+ }
SetModified( sal_False );
return sal_True;
}
@@ -611,23 +651,33 @@ sal_Bool SbxObject::StoreData( SvStream& rStrm ) const
return sal_False;
XubString aDfltProp;
if( pDfltProp )
+ {
aDfltProp = pDfltProp->GetName();
+ }
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aClassName, RTL_TEXTENCODING_ASCII_US);
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aDfltProp, RTL_TEXTENCODING_ASCII_US);
sal_uIntPtr nPos = rStrm.Tell();
rStrm << (sal_uInt32) 0L;
if( !StorePrivateData( rStrm ) )
+ {
return sal_False;
+ }
sal_uIntPtr nNew = rStrm.Tell();
rStrm.Seek( nPos );
rStrm << (sal_uInt32) ( nNew - nPos );
rStrm.Seek( nNew );
if( !pMethods->Store( rStrm ) )
+ {
return sal_False;
+ }
if( !pProps->Store( rStrm ) )
+ {
return sal_False;
+ }
if( !pObjs->Store( rStrm ) )
+ {
return sal_False;
+ }
((SbxObject*) this)->SetModified( sal_False );
return sal_True;
}
@@ -740,8 +790,9 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
// if necessary complete the object
if ( bFill )
+ {
GetAll( SbxCLASS_DONTCARE );
-
+ }
// Output the data of the object itself
rtl::OString aNameStr(rtl::OUStringToOString(GetName(), RTL_TEXTENCODING_ASCII_US));
rtl::OString aClassNameStr(rtl::OUStringToOString(aClassName, RTL_TEXTENCODING_ASCII_US));
@@ -760,7 +811,9 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
<< "=='" << ( aParentNameStr.isEmpty() ? "<unnamed>" : aParentNameStr.getStr() ) << "'";
}
else
+ {
rStrm << "no parent ";
+ }
rStrm << " )" << endl;
rtl::OString aIndentNameStr(rtl::OUStringToOString(aIndent, RTL_TEXTENCODING_ASCII_US));
rStrm << aIndentNameStr.getStr() << "{" << endl;
@@ -801,7 +854,9 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
((SbxObject*) pVar->GetValues_Impl().pObj)->Dump( rStrm, bFill );
}
else
+ {
rStrm << endl;
+ }
}
}
@@ -819,7 +874,9 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
aLine += pVar->GetName( SbxNAME_SHORT_TYPES );
XubString aAttrs3;
if( CollectAttrs( pVar, aAttrs3 ) )
+ {
aLine += aAttrs3;
+ }
if( !pVar->IsA( TYPE(SbxProperty) ) )
aLine.AppendAscii( " !! Not a Property !!" );
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, aLine, RTL_TEXTENCODING_ASCII_US);
@@ -834,7 +891,9 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
((SbxObject*) pVar->GetValues_Impl().pObj)->Dump( rStrm, bFill );
}
else
+ {
rStrm << endl;
+ }
}
}
}
@@ -850,9 +909,13 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill )
{
rStrm << aIndentNameStr.getStr() << " - Sub";
if ( pVar->ISA(SbxObject) )
+ {
((SbxObject*) pVar)->Dump( rStrm, bFill );
+ }
else if ( pVar->ISA(SbxVariable) )
+ {
((SbxVariable*) pVar)->Dump( rStrm, bFill );
+ }
}
}
}
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index c6f4d32f7dae..58c9be87a8f6 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -590,7 +590,9 @@ sal_Bool SbxValue::Scan( const XubString& rSrc, sal_uInt16* pLen )
{
SbxError eRes = SbxERR_OK;
if( !CanWrite() )
+ {
eRes = SbxERR_PROP_READONLY;
+ }
else
{
double n;
@@ -599,7 +601,9 @@ sal_Bool SbxValue::Scan( const XubString& rSrc, sal_uInt16* pLen )
if( eRes == SbxERR_OK )
{
if( !IsFixed() )
+ {
SetType( t );
+ }
PutDouble( n );
}
}
@@ -608,7 +612,9 @@ sal_Bool SbxValue::Scan( const XubString& rSrc, sal_uInt16* pLen )
SetError( eRes ); return sal_False;
}
else
+ {
return sal_True;
+ }
}
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 50ff641af158..a30780de5c33 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -127,7 +127,7 @@ SbxValue& SbxValue::operator=( const SbxValue& r )
&& aData.pObj && ( aData.pObj->GetType() == (SbxARRAY | SbxBYTE) )
&& (r.aData.eType == SbxSTRING) )
{
- ::rtl::OUString aStr = r.GetString();
+ OUString aStr = r.GetOUString();
SbxArray* pArr = StringToByteArray(aStr);
PutObject(pArr);
return *this;
@@ -429,14 +429,15 @@ const XubString& SbxValue::GetCoreString() const
return aToolString;
}
-::rtl::OUString SbxValue::GetOUString() const
+OUString SbxValue::GetOUString() const
{
- ::rtl::OUString aResult;
+ OUString aResult;
SbxValues aRes;
aRes.eType = SbxSTRING;
if( Get( aRes ) )
+ {
aResult = *aRes.pOUString;
-
+ }
return aResult;
}
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 9c8d13f10cce..8999122c49e6 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -84,7 +84,9 @@ SbxVariable::SbxVariable( const SbxVariable& r )
mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
#ifndef DISABLE_SCRIPTING
if( mpSbxVariableImpl->m_xComListener.is() )
+ {
registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+ }
#endif
}
pCst = NULL;
@@ -134,7 +136,9 @@ SbxVariable::~SbxVariable()
#endif
#ifndef DISABLE_SCRIPTING
if( IsSet( SBX_DIM_AS_NEW ))
+ {
removeDimAsNewRecoverItem( this );
+ }
#endif
delete mpSbxVariableImpl;
delete pCst;
@@ -145,7 +149,9 @@ SbxVariable::~SbxVariable()
SfxBroadcaster& SbxVariable::GetBroadcaster()
{
if( !pCst )
+ {
pCst = new SfxBroadcaster;
+ }
return *pCst;
}
@@ -169,19 +175,29 @@ void SbxVariable::Broadcast( sal_uIntPtr nHintId )
// Because the method could be called from outside, check the
// rights here again
if( nHintId & SBX_HINT_DATAWANTED )
+ {
if( !CanRead() )
+ {
return;
+ }
+ }
if( nHintId & SBX_HINT_DATACHANGED )
+ {
if( !CanWrite() )
+ {
return;
+ }
+ }
// Avoid further broadcasting
SfxBroadcaster* pSave = pCst;
pCst = NULL;
sal_uInt16 nSaveFlags = GetFlags();
SetFlag( SBX_READWRITE );
if( mpPar.Is() )
+ {
// Register this as element 0, but don't change over the parent!
mpPar->GetRef( 0 ) = this;
+ }
pSave->Broadcast( SbxHint( nHintId, this ) );
delete pCst; // who knows already, onto which thoughts someone comes?
pCst = pSave;
@@ -195,7 +211,9 @@ SbxInfo* SbxVariable::GetInfo()
{
Broadcast( SBX_HINT_INFOWANTED );
if( pInfo.Is() )
+ {
SetModified( sal_True );
+ }
}
return pInfo;
}
@@ -237,7 +255,9 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const
if( t == SbxNAME_SHORT_TYPES )
{
if( et <= SbxSTRING )
+ {
cType = cSuffixes[ et ];
+ }
if( cType != ' ' )
aTmp += cType;
}
@@ -328,11 +348,15 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r )
mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
#ifndef DISABLE_SCRIPTING
if( mpSbxVariableImpl->m_xComListener.is() )
+ {
registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+ }
#endif
}
else
+ {
mpSbxVariableImpl = NULL;
+ }
return *this;
}
@@ -341,11 +365,17 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r )
SbxDataType SbxVariable::GetType() const
{
if( aData.eType == SbxOBJECT )
+ {
return aData.pObj ? aData.pObj->GetType() : SbxOBJECT;
+ }
else if( aData.eType == SbxVARIANT )
+ {
return aData.pObj ? aData.pObj->GetType() : SbxVARIANT;
+ }
else
+ {
return aData.eType;
+ }
}
SbxClassType SbxVariable::GetClass() const
@@ -356,10 +386,14 @@ SbxClassType SbxVariable::GetClass() const
void SbxVariable::SetModified( sal_Bool b )
{
if( IsSet( SBX_NO_MODIFY ) )
+ {
return;
+ }
SbxBase::SetModified( b );
if( pParent && pParent != this ) //??? HotFix: Recursion out here MM
+ {
pParent->SetModified( b );
+ }
}
void SbxVariable::SetParent( SbxObject* p )
@@ -374,7 +408,9 @@ void SbxVariable::SetParent( SbxObject* p )
if ( pChildren )
{
for ( sal_uInt16 nIdx = 0; !bFound && nIdx < pChildren->Count(); ++nIdx )
+ {
bFound = ( this == pChildren->Get(nIdx) );
+ }
}
if ( !bFound )
{
@@ -395,7 +431,9 @@ void SbxVariable::SetParent( SbxObject* p )
SbxVariableImpl* SbxVariable::getImpl( void )
{
if( mpSbxVariableImpl == NULL )
+ {
mpSbxVariableImpl = new SbxVariableImpl();
+ }
return mpSbxVariableImpl;
}
@@ -439,9 +477,11 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
if( cMark == 0xFF )
{
if( !SbxValue::LoadData( rStrm, nVer ) )
+ {
return sal_False;
+ }
maName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStrm,
- RTL_TEXTENCODING_ASCII_US);
+ RTL_TEXTENCODING_ASCII_US);
sal_uInt32 nTemp;
rStrm >> nTemp;
nUserData = nTemp;
@@ -451,7 +491,7 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
rStrm.SeekRel( -1L );
rStrm >> nType;
maName = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rStrm,
- RTL_TEXTENCODING_ASCII_US);
+ RTL_TEXTENCODING_ASCII_US);
sal_uInt32 nTemp;
rStrm >> nTemp;
nUserData = nTemp;
@@ -514,7 +554,9 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
}
// putt value
if( nType != SbxNULL && nType != SbxEMPTY && !Put( aTmp ) )
+ {
return sal_False;
+ }
}
rStrm >> cMark;
// cMark is also a version number!
@@ -523,13 +565,17 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer )
if( cMark )
{
if( cMark > 2 )
+ {
return sal_False;
+ }
pInfo = new SbxInfo;
pInfo->LoadData( rStrm, (sal_uInt16) cMark );
}
// Load private data only, if it is a SbxVariable
if( GetClass() == SbxCLASS_VARIABLE && !LoadPrivateData( rStrm, nVer ) )
+ {
return sal_False;
+ }
((SbxVariable*) this)->Broadcast( SBX_HINT_DATACHANGED );
nHash = MakeHashCode( maName );
SetModified( sal_True );
@@ -557,11 +603,15 @@ sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const
pThis->ResetFlag( SBX_NO_BROADCAST );
}
else
+ {
bValStore = SbxValue::StoreData( rStrm );
+ }
if( !bValStore )
+ {
return sal_False;
+ }
write_lenPrefixed_uInt8s_FromOUString<sal_uInt16>(rStrm, maName,
- RTL_TEXTENCODING_ASCII_US);
+ RTL_TEXTENCODING_ASCII_US);
rStrm << (sal_uInt32)nUserData;
if( pInfo.Is() )
{
@@ -569,12 +619,18 @@ sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const
pInfo->StoreData( rStrm );
}
else
+ {
rStrm << (sal_uInt8) 0;
+ }
// Save private data only, if it is a SbxVariable
if( GetClass() == SbxCLASS_VARIABLE )
+ {
return StorePrivateData( rStrm );
+ }
else
+ {
return sal_True;
+ }
}
////////////////////////////// SbxInfo ///////////////////////////////////
@@ -602,7 +658,9 @@ SbxAlias& SbxAlias::operator=( const SbxAlias& r )
SbxAlias::~SbxAlias()
{
if( xAlias.Is() )
+ {
EndListening( xAlias->GetBroadcaster() );
+ }
}
void SbxAlias::Broadcast( sal_uIntPtr nHt )
@@ -611,9 +669,13 @@ void SbxAlias::Broadcast( sal_uIntPtr nHt )
{
xAlias->SetParameters( GetParameters() );
if( nHt == SBX_HINT_DATAWANTED )
+ {
SbxVariable::operator=( *xAlias );
+ }
else if( nHt == SBX_HINT_DATACHANGED || nHt == SBX_HINT_CONVERTED )
+ {
*xAlias = *this;
+ }
else if( nHt == SBX_HINT_INFOWANTED )
{
xAlias->Broadcast( nHt );
@@ -631,7 +693,9 @@ void SbxAlias::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
xAlias.Clear();
// delete the alias?
if( pParent )
+ {
pParent->Remove( this );
+ }
}
}
@@ -643,9 +707,13 @@ void SbxVariable::Dump( SvStream& rStrm, sal_Bool bFill )
<< aBNameStr.getStr();
rtl::OString aBParentNameStr(rtl::OUStringToOString(GetParent()->GetName(), RTL_TEXTENCODING_ASCII_US));
if ( GetParent() )
+ {
rStrm << " in parent '" << aBParentNameStr.getStr() << "'";
+ }
else
+ {
rStrm << " no parent";
+ }
rStrm << " ) ";
// output also the object at object-vars
@@ -658,7 +726,9 @@ void SbxVariable::Dump( SvStream& rStrm, sal_Bool bFill )
((SbxObject*) GetValues_Impl().pObj)->Dump( rStrm, bFill );
}
else
+ {
rStrm << endl;
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index fe76bf7f462f..c6252c75fe2a 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -84,7 +84,6 @@ using namespace osl;
using com::sun::star::uno::Reference;
-using ::rtl::OUString;
using ::rtl::OStringBuffer;
using ::rtl::OUStringToOString;
using ::rtl::Uri;
@@ -292,7 +291,10 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi
throw (RuntimeException)
{
if( !xListener.is() )
- throw RuntimeException("addContainerListener called with null xListener", static_cast< cppu::OWeakObject * >(this));
+ {
+ throw RuntimeException("addContainerListener called with null xListener",
+ static_cast< cppu::OWeakObject * >(this));
+ }
Reference< XInterface > xIface( xListener, UNO_QUERY );
maContainerListeners.addInterface( xIface );
}
@@ -301,7 +303,9 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine
throw (RuntimeException)
{
if( !xListener.is() )
+ {
throw RuntimeException();
+ }
Reference< XInterface > xIface( xListener, UNO_QUERY );
maContainerListeners.removeInterface( xIface );
}
@@ -311,7 +315,9 @@ void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListen
throw (RuntimeException)
{
if( !xListener.is() )
+ {
throw RuntimeException();
+ }
Reference< XInterface > xIface( xListener, UNO_QUERY );
maChangesListeners.addInterface( xIface );
}
@@ -320,7 +326,9 @@ void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesLis
throw (RuntimeException)
{
if( !xListener.is() )
+ {
throw RuntimeException();
+ }
Reference< XInterface > xIface( xListener, UNO_QUERY );
maChangesListeners.removeInterface( xIface );
}
@@ -331,12 +339,15 @@ void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesLis
void ModifiableHelper::setModified( sal_Bool _bModified )
{
if ( _bModified == mbModified )
+ {
return;
+ }
mbModified = _bModified;
if ( m_aModifyListeners.getLength() == 0 )
+ {
return;
-
+ }
EventObject aModifyEvent( m_rEventSource );
m_aModifyListeners.notifyEach( &XModifyListener::modified, aModifyEvent );
}
@@ -348,7 +359,8 @@ VBAScriptListenerContainer::VBAScriptListenerContainer( ::osl::Mutex& rMutex ) :
{
}
-bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent ) throw (Exception)
+bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent )
+ throw (Exception)
{
rxListener->notifyVBAScriptEvent( rEvent );
return true; // notify all other listeners too
@@ -386,14 +398,19 @@ SfxLibraryContainer::SfxLibraryContainer( void )
SfxLibraryContainer::~SfxLibraryContainer()
{
if( mbOwnBasMgr )
+ {
BasicManager::LegacyDeleteBasicManager( mpBasMgr );
+ }
DBG_DTOR( SfxLibraryContainer, NULL );
}
void SfxLibraryContainer::checkDisposed() const
{
if ( isDisposed() )
- throw DisposedException( ::rtl::OUString(), *const_cast< SfxLibraryContainer* >( this ) );
+ {
+ throw DisposedException( OUString(),
+ *const_cast< SfxLibraryContainer* >( this ) );
+ }
}
void SfxLibraryContainer::enterMethod()
@@ -410,16 +427,18 @@ void SfxLibraryContainer::leaveMethod()
BasicManager* SfxLibraryContainer::getBasicManager( void )
{
if ( mpBasMgr )
+ {
return mpBasMgr;
-
+ }
Reference< XModel > xDocument( mxOwnerDocument.get(), UNO_QUERY );
SAL_WARN_IF(
!xDocument.is(), "basic",
("SfxLibraryContainer::getBasicManager: cannot obtain a BasicManager"
" without document!"));
if ( xDocument.is() )
+ {
mpBasMgr = BasicManagerRepository::getDocumentBasicManager( xDocument );
-
+ }
return mpBasMgr;
}
@@ -430,40 +449,47 @@ Reference< XStorage > SAL_CALL SfxLibraryContainer::getRootStorage() throw (Runt
return mxStorage;
}
-void SAL_CALL SfxLibraryContainer::setRootStorage( const Reference< XStorage >& _rxRootStorage ) throw (IllegalArgumentException, RuntimeException)
+void SAL_CALL SfxLibraryContainer::setRootStorage( const Reference< XStorage >& _rxRootStorage )
+ throw (IllegalArgumentException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
if ( !_rxRootStorage.is() )
+ {
throw IllegalArgumentException();
-
+ }
mxStorage = _rxRootStorage;
onNewRootStorage();
}
-void SAL_CALL SfxLibraryContainer::storeLibrariesToStorage( const Reference< XStorage >& _rxRootStorage ) throw (IllegalArgumentException, WrappedTargetException, RuntimeException)
+void SAL_CALL SfxLibraryContainer::storeLibrariesToStorage( const Reference< XStorage >& _rxRootStorage )
+ throw (IllegalArgumentException, WrappedTargetException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
if ( !_rxRootStorage.is() )
+ {
throw IllegalArgumentException();
-
+ }
try
{
storeLibraries_Impl( _rxRootStorage, true );
}
catch( const Exception& )
{
- throw WrappedTargetException( ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+ throw WrappedTargetException( OUString(),
+ *this, ::cppu::getCaughtException() );
}
}
// Methods XModifiable
-sal_Bool SfxLibraryContainer::isModified() throw (RuntimeException)
+sal_Bool SfxLibraryContainer::isModified()
+ throw (RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
if ( maModifiable.isModified() )
+ {
return sal_True;
-
+ }
// the library container is not modified, go through the libraries and check whether they are modified
Sequence< OUString > aNames = maNameContainer.getElementNames();
const OUString* pNames = aNames.getConstArray();
@@ -484,26 +510,31 @@ sal_Bool SfxLibraryContainer::isModified() throw (RuntimeException)
return sal_True;
}
else
+ {
return sal_True;
+ }
}
}
return sal_False;
}
-void SAL_CALL SfxLibraryContainer::setModified( sal_Bool _bModified ) throw (PropertyVetoException, RuntimeException)
+void SAL_CALL SfxLibraryContainer::setModified( sal_Bool _bModified )
+ throw (PropertyVetoException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
maModifiable.setModified( _bModified );
}
-void SAL_CALL SfxLibraryContainer::addModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
+void SAL_CALL SfxLibraryContainer::addModifyListener( const Reference< XModifyListener >& _rxListener )
+ throw (RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
maModifiable.addModifyListener( _rxListener );
}
-void SAL_CALL SfxLibraryContainer::removeModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
+void SAL_CALL SfxLibraryContainer::removeModifyListener( const Reference< XModifyListener >& _rxListener )
+ throw (RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
maModifiable.removeModifyListener( _rxListener );
@@ -516,13 +547,14 @@ Any SAL_CALL SfxLibraryContainer::getRootLocation() throw (RuntimeException)
return makeAny( getRootStorage() );
}
-::rtl::OUString SAL_CALL SfxLibraryContainer::getContainerLocationName() throw (RuntimeException)
+OUString SAL_CALL SfxLibraryContainer::getContainerLocationName() throw (RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
return maLibrariesDir;
}
-void SAL_CALL SfxLibraryContainer::storeLibraries( ) throw (WrappedTargetException, RuntimeException)
+void SAL_CALL SfxLibraryContainer::storeLibraries( )
+ throw (WrappedTargetException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
try
@@ -534,7 +566,7 @@ void SAL_CALL SfxLibraryContainer::storeLibraries( ) throw (WrappedTargetExcept
}
catch( const Exception& )
{
- throw WrappedTargetException( ::rtl::OUString(), *this, ::cppu::getCaughtException() );
+ throw WrappedTargetException( OUString(), *this, ::cppu::getCaughtException() );
}
}
@@ -564,14 +596,17 @@ static void createVariableURL( OUString& rStr, const OUString& rLibName,
const OUString& rInfoFileName, bool bUser )
{
if( bUser )
- rStr = OUString(RTL_CONSTASCII_USTRINGPARAM("$(USER)/basic/"));
+ {
+ rStr = OUString("$(USER)/basic/");
+ }
else
- rStr = OUString(RTL_CONSTASCII_USTRINGPARAM("$(INST)/share/basic/"));
-
+ {
+ rStr = OUString("$(INST)/share/basic/");
+ }
rStr += rLibName;
- rStr += OUString(sal_Unicode('/'));
+ rStr += "/";
rStr += rInfoFileName;
- rStr += OUString(RTL_CONSTASCII_USTRINGPARAM(".xlb/"));
+ rStr += ".xlb/";
}
void SfxLibraryContainer::init( const OUString& rInitialDocumentURL, const uno::Reference< embed::XStorage >& rxInitialStorage )
@@ -740,7 +775,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
else
pLibInfoInetObj = new INetURLObject( String(maLibraryPath).GetToken(1) );
pLibInfoInetObj->insertName( maInfoFileName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
- pLibInfoInetObj->setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("xlc") ) );
+ pLibInfoInetObj->setExtension( OUString("xlc") );
aFileName = pLibInfoInetObj->GetMainURL( INetURLObject::NO_DECODE );
}
@@ -759,7 +794,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
{
INetURLObject aLibInfoInetObj( String(maLibraryPath).GetToken(1) );
aLibInfoInetObj.insertName( maOldInfoFileName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
- aLibInfoInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("xli") ) );
+ aLibInfoInetObj.setExtension( OUString( "xli") );
aFileName = aLibInfoInetObj.GetMainURL( INetURLObject::NO_DECODE );
try
@@ -818,7 +853,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
INetURLObject aInetObj( aLibraryPath );
aInetObj.insertName( rLib.aName, sal_True, INetURLObject::LAST_SEGMENT,
- sal_True, INetURLObject::ENCODE_ALL );
+ sal_True, INetURLObject::ENCODE_ALL );
OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( mxSFI->isFolder( aLibDirPath ) )
{
@@ -830,7 +865,7 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
// Check "share" path
INetURLObject aShareInetObj( String(maLibraryPath).GetToken(0) );
aShareInetObj.insertName( rLib.aName, sal_True, INetURLObject::LAST_SEGMENT,
- sal_True, INetURLObject::ENCODE_ALL );
+ sal_True, INetURLObject::ENCODE_ALL );
OUString aShareLibDirPath = aShareInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( mxSFI->isFolder( aShareLibDirPath ) )
{
@@ -866,8 +901,10 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
pImplLib->mbLoaded = sal_False;
pImplLib->mbReadOnly = rLib.bReadOnly;
if( !bStorage )
+ {
checkStorageURL( rLib.aStorageURL, pImplLib->maLibInfoFileURL,
- pImplLib->maStorageURL, pImplLib->maUnexpandedStorageURL );
+ pImplLib->maStorageURL, pImplLib->maUnexpandedStorageURL );
+ }
}
maModifiable.setModified( sal_False );
@@ -875,22 +912,23 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
if( !mbOldInfoFormat )
{
uno::Reference< embed::XStorage > xLibraryStor;
- if( !pImplLib->mbInitialised && bStorage )
+ if( !pImplLib->mbInitialised && bStorage )
{
- try {
+ try
+ {
xLibraryStor = xLibrariesStor->openStorageElement( rLib.aName,
embed::ElementModes::READ );
}
catch(const uno::Exception& )
{
- #if OSL_DEBUG_LEVEL > 0
+ #if OSL_DEBUG_LEVEL > 0
Any aError( ::cppu::getCaughtException() );
SAL_WARN(
"basic",
"couldn't open sub storage for library \""
<< rLib.aName << "\". Exception: "
<< comphelper::anyToString(aError));
- #endif
+ #endif
}
}
@@ -904,7 +942,9 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
("Different library names in library container and"
" library info files!"));
if( GbMigrationSuppressErrors && !bLoaded )
+ {
removeLibrary( aLibName );
+ }
}
}
else if( !bStorage )
@@ -927,8 +967,9 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
// Keep flag for documents to force writing the new index files
if( !bStorage )
+ {
mbOldInfoFormat = false;
-
+ }
delete pLibArray;
}
}
@@ -959,7 +1000,9 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
OUString aName = pNames[ i ];
SfxLibrary* pImplLib = getImplLib( aName );
if( pImplLib->mbPreload )
+ {
loadLibrary( aName );
+ }
}
}
@@ -1075,10 +1118,10 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
mxSFI->move( aFolderUserBasic, aPrevFolder );
mxSFI->move( aFolderTmp, aFolderUserBasic );
- OUString aUserSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"));
- OUString aSharedSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"));
- OUString aBundledSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"));
- OUString aInstSearchStr(RTL_CONSTASCII_USTRINGPARAM("$(INST)"));
+ OUString aUserSearchStr("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
+ OUString aSharedSearchStr("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE");
+ OUString aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
+ OUString aInstSearchStr("$(INST)");
Sequence< OUString > aNames = pPrevCont->getElementNames();
const OUString* pNames = aNames.getConstArray();
@@ -1115,7 +1158,9 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
bCreateLink = false;
}
if( bCreateLink )
+ {
createLibraryLink( aLibName, pImplLib->maStorageURL, pImplLib->mbReadOnly );
+ }
}
else
{
@@ -1129,10 +1174,14 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
String aPrevLibFolder = aPrevUserBasicLibFolderInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( mxSFI->isFolder( aPrevLibFolder ) && !mxSFI->isFolder( aLibFolder ) )
+ {
mxSFI->move( aPrevLibFolder, aLibFolder );
+ }
if( aLibName == aStandardStr )
- maNameContainer.removeByName( aLibName );
+ {
+ maNameContainer.removeByName( aLibName );
+ }
// Create library
Reference< XNameContainer > xLib = createLibrary( aLibName );
@@ -1140,12 +1189,11 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
pNewLib->mbLoaded = false;
pNewLib->implSetModified( sal_False );
checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
- pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
+ pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
uno::Reference< embed::XStorage > xDummyStor;
::xmlscript::LibDescriptor aLibDesc;
- implLoadLibraryIndexFile
- ( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
+ implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
implImportLibDescriptor( pNewLib, aLibDesc );
}
}
@@ -1196,14 +1244,15 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
void SfxLibraryContainer::implScanExtensions( void )
{
ScriptExtensionIterator aScriptIt;
- rtl::OUString aLibURL;
+ OUString aLibURL;
bool bPureDialogLib = false;
while ( !(aLibURL = aScriptIt.nextBasicOrDialogLibrary( bPureDialogLib )).isEmpty())
{
if( bPureDialogLib && maInfoFileName == "script" )
+ {
continue;
-
+ }
// Extract lib name
sal_Int32 nLen = aLibURL.getLength();
sal_Int32 indexLastSlash = aLibURL.lastIndexOf( '/' );
@@ -1218,8 +1267,9 @@ void SfxLibraryContainer::implScanExtensions( void )
// If a library of the same exists the existing library wins
if( hasByName( aLibName ) )
+ {
continue;
-
+ }
// Add index file to URL
OUString aIndexFileURL = aLibURL;
if( nReduceCopy == 0 )
@@ -1236,12 +1286,14 @@ void SfxLibraryContainer::implScanExtensions( void )
// Handle maLibInfoFileURL and maStorageURL correctly
void SfxLibraryContainer::checkStorageURL( const OUString& aSourceURL,
- OUString& aLibInfoFileURL, OUString& aStorageURL, OUString& aUnexpandedStorageURL )
+ OUString& aLibInfoFileURL, OUString& aStorageURL,
+ OUString& aUnexpandedStorageURL )
{
OUString aExpandedSourceURL = expand_url( aSourceURL );
if( aExpandedSourceURL != aSourceURL )
+ {
aUnexpandedStorageURL = aSourceURL;
-
+ }
INetURLObject aInetObj( aExpandedSourceURL );
OUString aExtension = aInetObj.getExtension();
if( aExtension.compareToAscii( "xlb" ) == COMPARE_EQUAL )
@@ -1256,7 +1308,7 @@ void SfxLibraryContainer::checkStorageURL( const OUString& aSourceURL,
// URL to library folder
aStorageURL = aExpandedSourceURL;
aInetObj.insertName( maInfoFileName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
- aInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("xlb") ) );
+ aInetObj.setExtension( OUString("xlb") );
aLibInfoFileURL = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
}
}
@@ -1274,19 +1326,19 @@ SfxLibrary* SfxLibraryContainer::getImplLib( const String& rLibraryName )
// Storing with password encryption
// Empty implementation, avoids unneccesary implementation in dlgcont.cxx
-sal_Bool SfxLibraryContainer::implStorePasswordLibrary(
- SfxLibrary*,
- const OUString&,
- const uno::Reference< embed::XStorage >&, const uno::Reference< task::XInteractionHandler >& )
+sal_Bool SfxLibraryContainer::implStorePasswordLibrary( SfxLibrary*,
+ const OUString&,
+ const uno::Reference< embed::XStorage >&,
+ const uno::Reference< task::XInteractionHandler >& )
{
return sal_False;
}
sal_Bool SfxLibraryContainer::implStorePasswordLibrary(
SfxLibrary* /*pLib*/,
- const ::rtl::OUString& /*aName*/,
+ const OUString& /*aName*/,
const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& /*xStorage*/,
- const ::rtl::OUString& /*aTargetURL*/,
+ const OUString& /*aTargetURL*/,
const Reference< XSimpleFileAccess2 > /*xToUseSFI*/,
const uno::Reference< task::XInteractionHandler >& )
{
@@ -1307,8 +1359,7 @@ throw(WrappedTargetException, RuntimeException)
#define EXPAND_PROTOCOL "vnd.sun.star.expand"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-OUString SfxLibraryContainer::createAppLibraryFolder
- ( SfxLibrary* pLib, const OUString& aName )
+OUString SfxLibraryContainer::createAppLibraryFolder( SfxLibrary* pLib, const OUString& aName )
{
OUString aLibDirPath = pLib->maStorageURL;
if( aLibDirPath.isEmpty() )
@@ -1335,7 +1386,8 @@ OUString SfxLibraryContainer::createAppLibraryFolder
// Storing
void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
- const OUString& aName, const uno::Reference< embed::XStorage >& xStorage )
+ const OUString& aName,
+ const uno::Reference< embed::XStorage >& xStorage )
{
OUString aDummyLocation;
Reference< XSimpleFileAccess2 > xDummySFA;
@@ -1345,9 +1397,11 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
// New variant for library export
void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
- const OUString& aName, const uno::Reference< embed::XStorage >& xStorage,
- const ::rtl::OUString& aTargetURL, Reference< XSimpleFileAccess2 > xToUseSFI,
- const Reference< XInteractionHandler >& xHandler )
+ const OUString& aName,
+ const uno::Reference< embed::XStorage >& xStorage,
+ const OUString& aTargetURL,
+ Reference< XSimpleFileAccess2 > xToUseSFI,
+ const Reference< XInteractionHandler >& xHandler )
{
sal_Bool bLink = pLib->mbLink;
bool bStorage = xStorage.is() && !bLink;
@@ -1361,9 +1415,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
{
OUString aElementName = pNames[ i ];
-
OUString aStreamName = aElementName;
- aStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") );
+ aStreamName += ".xml";
if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
@@ -1372,13 +1425,14 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
"invalid library element \"" << aElementName << '"');
continue;
}
- try {
+ try
+ {
uno::Reference< io::XStream > xElementStream = xStorage->openStreamElement(
aStreamName,
embed::ElementModes::READWRITE );
// throw uno::RuntimeException(); // TODO: method must either return the stream or throw an exception
- OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
+ OUString aMime( "text/xml" );
uno::Reference< beans::XPropertySet > xProps( xElementStream, uno::UNO_QUERY );
SAL_WARN_IF(
@@ -1388,10 +1442,10 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
if ( xProps.is() )
{
- xProps->setPropertyValue( rtl::OUString("MediaType"), uno::makeAny( aMime ) );
+ xProps->setPropertyValue( OUString("MediaType"), uno::makeAny( aMime ) );
// #87671 Allow encryption
- xProps->setPropertyValue( rtl::OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
Reference< XOutputStream > xOutput = xElementStream->getOutputStream();
Reference< XNameContainer > xLib( pLib );
@@ -1404,7 +1458,6 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
// TODO: error handling?
}
}
-
pLib->storeResourcesToStorage( xStorage );
}
else
@@ -1415,8 +1468,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
{
Reference< XSimpleFileAccess2 > xSFI = mxSFI;
if( xToUseSFI.is() )
+ {
xSFI = xToUseSFI;
-
+ }
OUString aLibDirPath;
if( bExport )
{
@@ -1425,8 +1479,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
aLibDirPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( !xSFI->isFolder( aLibDirPath ) )
+ {
xSFI->createFolder( aLibDirPath );
-
+ }
pLib->storeResourcesToURL( aLibDirPath, xHandler );
}
else
@@ -1441,7 +1496,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
INetURLObject aElementInetObj( aLibDirPath );
aElementInetObj.insertName( aElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aElementInetObj.setExtension( maLibElementFileExtension );
String aElementPath( aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ) );
@@ -1457,7 +1513,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
try
{
if( xSFI->exists( aElementPath ) )
+ {
xSFI->kill( aElementPath );
+ }
Reference< XOutputStream > xOutput = xSFI->openFileWrite( aElementPath );
Reference< XNameContainer > xLib( pLib );
writeLibraryElement( xLib, aElementName, xOutput );
@@ -1466,8 +1524,9 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
catch(const Exception& )
{
if( bExport )
+ {
throw;
-
+ }
SfxErrorContext aEc( ERRCTX_SFX_SAVEDOC, aElementPath );
sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
ErrorHandler::HandleError( nErrorCode );
@@ -1477,13 +1536,16 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
catch(const Exception& )
{
if( bExport )
+ {
throw;
+ }
}
}
}
void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
- const ::xmlscript::LibDescriptor& rLib, const uno::Reference< embed::XStorage >& xStorage )
+ const ::xmlscript::LibDescriptor& rLib,
+ const uno::Reference< embed::XStorage >& xStorage )
{
OUString aDummyLocation;
Reference< XSimpleFileAccess2 > xDummySFA;
@@ -1492,8 +1554,10 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
// New variant for library export
void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
- const ::xmlscript::LibDescriptor& rLib, const uno::Reference< embed::XStorage >& xStorage,
- const ::rtl::OUString& aTargetURL, Reference< XSimpleFileAccess2 > xToUseSFI )
+ const ::xmlscript::LibDescriptor& rLib,
+ const uno::Reference< embed::XStorage >& xStorage,
+ const OUString& aTargetURL,
+ Reference< XSimpleFileAccess2 > xToUseSFI )
{
// Create sax writer
Reference< XWriter > xWriter = xml::sax::Writer::create(comphelper::getComponentContext(mxMSF));
@@ -1507,9 +1571,10 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
if( bStorage )
{
OUString aStreamName( maInfoFileName );
- aStreamName += String( RTL_CONSTASCII_USTRINGPARAM("-lb.xml") );
+ aStreamName += "-lb.xml";
- try {
+ try
+ {
xInfoStream = xStorage->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
SAL_WARN_IF(!xInfoStream.is(), "basic", "No stream!");
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
@@ -1517,11 +1582,11 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
if ( xProps.is() )
{
- OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
- xProps->setPropertyValue( rtl::OUString("MediaType"), uno::makeAny( aMime ) );
+ OUString aMime("text/xml");
+ xProps->setPropertyValue( OUString("MediaType"), uno::makeAny( aMime ) );
// #87671 Allow encryption
- xProps->setPropertyValue( rtl::OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
xOut = xInfoStream->getOutputStream();
}
@@ -1538,8 +1603,9 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
bool bExport = !aTargetURL.isEmpty();
Reference< XSimpleFileAccess2 > xSFI = mxSFI;
if( xToUseSFI.is() )
+ {
xSFI = xToUseSFI;
-
+ }
OUString aLibInfoPath;
if( bExport )
{
@@ -1547,8 +1613,9 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
aInetObj.insertName( rLib.aName, sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( !xSFI->isFolder( aLibDirPath ) )
+ {
xSFI->createFolder( aLibDirPath );
-
+ }
aInetObj.insertName( maInfoFileName, sal_False, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
aInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("xlb") ) );
aLibInfoPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
@@ -1562,14 +1629,17 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
try
{
if( xSFI->exists( aLibInfoPath ) )
+ {
xSFI->kill( aLibInfoPath );
+ }
xOut = xSFI->openFileWrite( aLibInfoPath );
}
catch(const Exception& )
{
if( bExport )
+ {
throw;
-
+ }
SfxErrorContext aEc( ERRCTX_SFX_SAVEDOC, aLibInfoPath );
sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL;
ErrorHandler::HandleError( nErrorCode );
@@ -1580,15 +1650,15 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib,
SAL_WARN("basic", "couldn't open output stream");
return;
}
-
xWriter->setOutputStream( xOut );
-
xmlscript::exportLibrary( xWriter, rLib );
}
bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
- ::xmlscript::LibDescriptor& rLib, const uno::Reference< embed::XStorage >& xStorage, const OUString& aIndexFileName )
+ ::xmlscript::LibDescriptor& rLib,
+ const uno::Reference< embed::XStorage >& xStorage,
+ const OUString& aIndexFileName )
{
Reference< XParser > xParser = xml::sax::Parser::create(comphelper::getComponentContext(mxMSF));
@@ -1608,9 +1678,10 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
aLibInfoPath = maInfoFileName;
aLibInfoPath += String( RTL_CONSTASCII_USTRINGPARAM("-lb.xml") );
- try {
+ try
+ {
uno::Reference< io::XStream > xInfoStream =
- xStorage->openStreamElement( aLibInfoPath, embed::ElementModes::READ );
+ xStorage->openStreamElement( aLibInfoPath, embed::ElementModes::READ );
xInput = xInfoStream->getInputStream();
}
catch(const uno::Exception& )
@@ -1627,8 +1698,9 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
aLibInfoPath = pLib->maLibInfoFileURL;
}
else
+ {
aLibInfoPath = aIndexFileName;
-
+ }
try
{
xInput = mxSFI->openFileRead( aLibInfoPath );
@@ -1654,7 +1726,8 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
source.sSystemId = aLibInfoPath;
// start parsing
- try {
+ try
+ {
xParser->setDocumentHandler( ::xmlscript::importLibrary( rLib ) );
xParser->parseStream( source );
}
@@ -1674,7 +1747,7 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
pLib->mbLoaded = sal_False;
rLib.aStorageURL = aIndexFileName;
checkStorageURL( rLib.aStorageURL, pLib->maLibInfoFileURL, pLib->maStorageURL,
- pLib->maUnexpandedStorageURL );
+ pLib->maUnexpandedStorageURL );
implImportLibDescriptor( pLib, rLib );
}
@@ -1682,8 +1755,8 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
return true;
}
-void SfxLibraryContainer::implImportLibDescriptor
- ( SfxLibrary* pLib, ::xmlscript::LibDescriptor& rLib )
+void SfxLibraryContainer::implImportLibDescriptor( SfxLibrary* pLib,
+ ::xmlscript::LibDescriptor& rLib )
{
if( !pLib->mbInitialised )
{
@@ -1698,14 +1771,14 @@ void SfxLibraryContainer::implImportLibDescriptor
pLib->mbReadOnly = rLib.bReadOnly;
pLib->mbPreload = rLib.bPreload;
pLib->implSetModified( sal_False );
-
pLib->mbInitialised = true;
}
}
// Methods of new XLibraryStorage interface?
-void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& i_rStorage, bool bComplete )
+void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XStorage >& i_rStorage,
+ bool bComplete )
{
const Sequence< OUString > aNames = maNameContainer.getElementNames();
sal_Int32 nNameCount = aNames.getLength();
@@ -1718,18 +1791,21 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
{
SfxLibrary* pImplLib = getImplLib( *pName );
if( pImplLib->mbSharedIndexFile || pImplLib->mbExtension )
+ {
nLibsToSave--;
+ }
}
if( !nLibsToSave )
+ {
return;
-
+ }
boost::scoped_ptr< ::xmlscript::LibDescriptorArray > pLibArray(new ::xmlscript::LibDescriptorArray(nLibsToSave));
// Write to storage?
bool bStorage = i_rStorage.is();
uno::Reference< embed::XStorage > xSourceLibrariesStor;
uno::Reference< embed::XStorage > xTargetLibrariesStor;
- ::rtl::OUString sTempTargetStorName;
+ OUString sTempTargetStorName;
const bool bInplaceStorage = bStorage && ( i_rStorage == mxStorage );
if ( bStorage )
{
@@ -1740,13 +1816,15 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
Reference< XNameAccess > xNameAccess;
aLibAny >>= xNameAccess;
if ( ! ( xNameAccess->hasElements() || ( bInplaceStorage && isModified() ) ) )
+ {
return;
+ }
}
// create the empty target storage
try
{
- ::rtl::OUString sTargetLibrariesStoreName;
+ OUString sTargetLibrariesStoreName;
if ( bInplaceStorage )
{
// create a temporary target storage
@@ -1759,7 +1837,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
sTargetLibrariesStoreName = aTempTargetName.makeStringAndClear();
if ( !i_rStorage->hasByName( sTargetLibrariesStoreName ) )
+ {
break;
+ }
}
while ( true );
sTempTargetStorName = sTargetLibrariesStoreName;
@@ -1768,7 +1848,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
{
sTargetLibrariesStoreName = maLibrariesDir;
if ( i_rStorage->hasByName( sTargetLibrariesStoreName ) )
+ {
i_rStorage->removeElement( sTargetLibrariesStoreName );
+ }
}
xTargetLibrariesStor.set( i_rStorage->openStorageElement( sTargetLibrariesStoreName, embed::ElementModes::READWRITE ), UNO_QUERY_THROW );
@@ -1783,7 +1865,10 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
try
{
if ( mxStorage->hasByName( maLibrariesDir ) || bInplaceStorage )
- xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ );
+ {
+ xSourceLibrariesStor = mxStorage->openStorageElement( maLibrariesDir,
+ bInplaceStorage ? embed::ElementModes::READWRITE : embed::ElementModes::READ );
+ }
}
catch( const uno::Exception& )
{
@@ -1799,12 +1884,16 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
{
SfxLibrary* pImplLib = getImplLib( *pName );
if( pImplLib->mbSharedIndexFile )
+ {
continue;
+ }
const bool bExtensionLib = pImplLib->mbExtension;
::xmlscript::LibDescriptor& rLib = bExtensionLib ?
- aLibDescriptorForExtensionLibs : pLibArray->mpLibs[iArray];
+ aLibDescriptorForExtensionLibs : pLibArray->mpLibs[iArray];
if( !bExtensionLib )
+ {
iArray++;
+ }
rLib.aName = *pName;
rLib.bLink = pImplLib->mbLink;
@@ -1846,28 +1935,32 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
}
catch(const uno::Exception& )
{
- #if OSL_DEBUG_LEVEL > 0
+ #if OSL_DEBUG_LEVEL > 0
Any aError( ::cppu::getCaughtException() );
SAL_WARN(
"basic",
"couldn't create sub storage for library \""
<< rLib.aName << "\". Exception: "
<< comphelper::anyToString(aError));
- #endif
+ #endif
return;
}
}
// Maybe lib is not loaded?!
if( bComplete )
+ {
loadLibrary( rLib.aName );
-
+ }
if( pImplLib->mbPasswordProtected )
+ {
implStorePasswordLibrary( pImplLib, rLib.aName, xLibraryStor, uno::Reference< task::XInteractionHandler >() );
// TODO: Check return value
+ }
else
+ {
implStoreLibrary( pImplLib, rLib.aName, xLibraryStor );
-
+ }
implStoreLibraryIndexFile( pImplLib, rLib, xLibraryStor );
if( bStorage )
{
@@ -1912,20 +2005,20 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
if ( xSourceLibrariesStor.is() )
{
// remove
- const Sequence< ::rtl::OUString > aRemoveNames( xSourceLibrariesStor->getElementNames() );
- for ( const ::rtl::OUString* pRemoveName = aRemoveNames.getConstArray();
- pRemoveName != aRemoveNames.getConstArray() + aRemoveNames.getLength();
- ++pRemoveName
+ const Sequence< OUString > aRemoveNames( xSourceLibrariesStor->getElementNames() );
+ for ( const OUString* pRemoveName = aRemoveNames.getConstArray();
+ pRemoveName != aRemoveNames.getConstArray() + aRemoveNames.getLength();
+ ++pRemoveName
)
{
xSourceLibrariesStor->removeElement( *pRemoveName );
}
// copy
- const Sequence< ::rtl::OUString > aCopyNames( xTargetLibrariesStor->getElementNames() );
- for ( const ::rtl::OUString* pCopyName = aCopyNames.getConstArray();
- pCopyName != aCopyNames.getConstArray() + aCopyNames.getLength();
- ++pCopyName
+ const Sequence< OUString > aCopyNames( xTargetLibrariesStor->getElementNames() );
+ for ( const OUString* pCopyName = aCopyNames.getConstArray();
+ pCopyName != aCopyNames.getConstArray() + aCopyNames.getLength();
+ ++pCopyName
)
{
xTargetLibrariesStor->copyElementTo( *pCopyName, xSourceLibrariesStor, *pCopyName );
@@ -1936,7 +2029,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
xTargetLibrariesStor->dispose();
i_rStorage->removeElement( sTempTargetStorName );
xTargetLibrariesStor.clear();
- sTempTargetStorName = ::rtl::OUString();
+ sTempTargetStorName = OUString();
// adjust target
xTargetLibrariesStor = xSourceLibrariesStor;
@@ -1963,22 +2056,24 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
if( bStorage )
{
OUString aStreamName( maInfoFileName );
- aStreamName += String( RTL_CONSTASCII_USTRINGPARAM("-lc.xml") );
+ aStreamName += "-lc.xml";
- try {
+ try
+ {
xInfoStream = xTargetLibrariesStor->openStreamElement( aStreamName, embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY );
SAL_WARN_IF(
!xProps.is(), "basic",
"The stream must implement XPropertySet!");
if ( !xProps.is() )
+ {
throw uno::RuntimeException();
-
- OUString aMime( RTL_CONSTASCII_USTRINGPARAM("text/xml") );
- xProps->setPropertyValue( rtl::OUString("MediaType"), uno::makeAny( aMime ) );
+ }
+ OUString aMime( "text/xml" );
+ xProps->setPropertyValue( OUString("MediaType"), uno::makeAny( aMime ) );
// #87671 Allow encryption
- xProps->setPropertyValue( rtl::OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( OUString("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
xOut = xInfoStream->getOutputStream();
}
@@ -1999,7 +2094,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
try
{
if( mxSFI->exists( aLibInfoPath ) )
+ {
mxSFI->kill( aLibInfoPath );
+ }
xOut = mxSFI->openFileWrite( aLibInfoPath );
}
catch(const Exception& )
@@ -2029,8 +2126,9 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto
!xTransact.is(), "basic",
"The storage must implement XTransactedObject!");
if ( !xTransact.is() )
+ {
throw uno::RuntimeException();
-
+ }
xTransact->commit();
}
}
@@ -2084,7 +2182,7 @@ sal_Bool SfxLibraryContainer::hasByName( const OUString& aName )
// Methods XLibraryContainer
Reference< XNameContainer > SAL_CALL SfxLibraryContainer::createLibrary( const OUString& Name )
- throw(IllegalArgumentException, ElementExistException, RuntimeException)
+ throw(IllegalArgumentException, ElementExistException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
SfxLibrary* pNewLib = implCreateLibrary( Name );
@@ -2103,7 +2201,7 @@ Reference< XNameContainer > SAL_CALL SfxLibraryContainer::createLibrary( const O
Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
( const OUString& Name, const OUString& StorageURL, sal_Bool ReadOnly )
- throw(IllegalArgumentException, ElementExistException, RuntimeException)
+ throw(IllegalArgumentException, ElementExistException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
// TODO: Check other reasons to force ReadOnly status
@@ -2134,9 +2232,9 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
maNameContainer.insertByName( Name, aElement );
maModifiable.setModified( sal_True );
- OUString aUserSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"));
- OUString aSharedSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"));
- OUString aBundledSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$BUNDLED_EXTENSIONS"));
+ OUString aUserSearchStr("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE");
+ OUString aSharedSearchStr("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE");
+ OUString aBundledSearchStr("vnd.sun.star.expand:$BUNDLED_EXTENSIONS");
if( StorageURL.indexOf( aUserSearchStr ) != -1 )
{
pNewLib->mbExtension = true;
@@ -2160,8 +2258,9 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
aLibAny >>= xNameAccess;
SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
if( pImplLib->mbReadOnly && !pImplLib->mbLink )
+ {
throw IllegalArgumentException();
-
+ }
// Remove from container
maNameContainer.removeByName( Name );
maModifiable.setModified( sal_True );
@@ -2170,7 +2269,9 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
if( !pImplLib->mbLink )
{
if( mxStorage.is() )
+ {
return;
+ }
if( xNameAccess->hasElements() )
{
Sequence< OUString > aNames = pImplLib->getElementNames();
@@ -2188,14 +2289,16 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
try
{
if( mxSFI->exists( aLibInfoPath ) )
+ {
mxSFI->kill( aLibInfoPath );
+ }
}
catch(const Exception& ) {}
// Delete folder if empty
INetURLObject aInetObj( String(maLibraryPath).GetToken(1) );
aInetObj.insertName( Name, sal_True, INetURLObject::LAST_SEGMENT,
- sal_True, INetURLObject::ENCODE_ALL );
+ sal_True, INetURLObject::ENCODE_ALL );
OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
try
@@ -2205,7 +2308,9 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
Sequence< OUString > aContentSeq = mxSFI->getFolderContents( aLibDirPath, true );
sal_Int32 nCount = aContentSeq.getLength();
if( !nCount )
+ {
mxSFI->kill( aLibDirPath );
+ }
}
}
catch(const Exception& )
@@ -2250,14 +2355,17 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
uno::Reference< embed::XStorage > xLibraryStor;
if( bStorage )
{
- try {
+ try
+ {
xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
SAL_WARN_IF(
!xLibrariesStor.is(), "basic",
("The method must either throw exception or return a"
" storage!"));
if ( !xLibrariesStor.is() )
+ {
throw uno::RuntimeException();
+ }
xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
SAL_WARN_IF(
@@ -2265,7 +2373,9 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
("The method must either throw exception or return a"
" storage!"));
if ( !xLibrariesStor.is() )
+ {
throw uno::RuntimeException();
+ }
}
catch(const uno::Exception& )
{
@@ -2298,9 +2408,11 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
aFile = aElementName;
aFile += String( RTL_CONSTASCII_USTRINGPARAM(".xml") );
- try {
+ try
+ {
xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
- } catch(const uno::Exception& )
+ }
+ catch(const uno::Exception& )
{}
if( !xElementStream.is() )
@@ -2309,15 +2421,18 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
aFile = aElementName;
aFile += String( RTL_CONSTASCII_USTRINGPARAM(".") );
aFile += maLibElementFileExtension;
- try {
+ try
+ {
xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
- } catch(const uno::Exception& )
+ }
+ catch(const uno::Exception& )
{}
}
if ( xElementStream.is() )
+ {
xInStream = xElementStream->getInputStream();
-
+ }
if ( !xInStream.is() )
{
SAL_WARN(
@@ -2332,25 +2447,27 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
String aLibDirPath = pImplLib->maStorageURL;
INetURLObject aElementInetObj( aLibDirPath );
aElementInetObj.insertName( aElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aElementInetObj.setExtension( maLibElementFileExtension );
aFile = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
}
Reference< XNameContainer > xLib( pImplLib );
Any aAny = importLibraryElement( xLib, aElementName,
- aFile, xInStream );
+ aFile, xInStream );
if( pImplLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
+ {
pImplLib->maNameContainer.replaceByName( aElementName, aAny );
+ }
}
else
{
pImplLib->maNameContainer.insertByName( aElementName, aAny );
}
}
-
pImplLib->implSetModified( sal_False );
}
}
@@ -2372,7 +2489,9 @@ OUString SAL_CALL SfxLibraryContainer::getLibraryLinkURL( const OUString& Name )
SfxLibrary* pImplLib = getImplLib( Name );
sal_Bool bLink = pImplLib->mbLink;
if( !bLink )
+ {
throw IllegalArgumentException();
+ }
OUString aRetStr = pImplLib->maLibInfoFileURL;
return aRetStr;
}
@@ -2415,8 +2534,9 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
{
LibraryContainerMethodGuard aGuard( *this );
if( maNameContainer.hasByName( NewName ) )
+ {
throw ElementExistException();
-
+ }
// Get and hold library before removing
Any aLibAny = maNameContainer.getByName( Name ) ;
@@ -2425,7 +2545,9 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
aLibAny >>= xNameAccess;
SfxLibrary* pImplLib = static_cast< SfxLibrary* >( xNameAccess.get() );
if( pImplLib->mbPasswordProtected && !pImplLib->mbPasswordVerified )
+ {
return; // Lib with unverified password cannot be renamed
+ }
loadLibrary( Name );
// Remove from container
@@ -2445,26 +2567,29 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
INetURLObject aDestInetObj( String(maLibraryPath).GetToken(1) );
aDestInetObj.insertName( NewName, sal_True, INetURLObject::LAST_SEGMENT,
- sal_True, INetURLObject::ENCODE_ALL );
+ sal_True, INetURLObject::ENCODE_ALL );
OUString aDestDirPath = aDestInetObj.GetMainURL( INetURLObject::NO_DECODE );
// Store new URL
OUString aLibInfoFileURL = pImplLib->maLibInfoFileURL;
checkStorageURL( aDestDirPath, pImplLib->maLibInfoFileURL, pImplLib->maStorageURL,
- pImplLib->maUnexpandedStorageURL );
+ pImplLib->maUnexpandedStorageURL );
try
{
if( mxSFI->isFolder( aLibDirPath ) )
{
if( !mxSFI->isFolder( aDestDirPath ) )
+ {
mxSFI->createFolder( aDestDirPath );
-
+ }
// Move index file
try
{
if( mxSFI->exists( pImplLib->maLibInfoFileURL ) )
+ {
mxSFI->kill( pImplLib->maLibInfoFileURL );
+ }
mxSFI->move( aLibInfoFileURL, pImplLib->maLibInfoFileURL );
}
catch(const Exception& )
@@ -2486,7 +2611,8 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
INetURLObject aElementDestInetObj( aDestDirPath );
aElementDestInetObj.insertName( aElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aElementDestInetObj.setExtension( maLibElementFileExtension );
String aDestElementPath( aElementDestInetObj.GetMainURL( INetURLObject::NO_DECODE ) );
@@ -2507,7 +2633,7 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
sal_Int32 nCount = aContentSeq.getLength();
if( !nCount )
{
- mxSFI->kill( aLibDirPath );
+ mxSFI->kill( aLibDirPath );
}
bMovedSuccessful = true;
@@ -2522,11 +2648,13 @@ void SAL_CALL SfxLibraryContainer::renameLibrary( const OUString& Name, const OU
}
if( bStorage && !pImplLib->mbLink )
+ {
pImplLib->implSetModified( sal_True );
-
+ }
if( bMovedSuccessful )
+ {
maNameContainer.insertByName( NewName, aLibAny ) ;
-
+ }
}
@@ -2556,7 +2684,7 @@ void SAL_CALL SfxLibraryContainer::initialize( const Sequence< Any >& _rArgument
throw IllegalArgumentException();
}
-void SAL_CALL SfxLibraryContainer::initializeFromDocumentURL( const ::rtl::OUString& _rInitialDocumentURL )
+void SAL_CALL SfxLibraryContainer::initializeFromDocumentURL( const OUString& _rInitialDocumentURL )
{
init( _rInitialDocumentURL, NULL );
}
@@ -2568,9 +2696,10 @@ void SAL_CALL SfxLibraryContainer::initializeFromDocument( const Reference< XSto
try
{
Reference< XServiceInfo > xSI( _rxDocument, UNO_QUERY_THROW );
- if ( xSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.OfficeDocument" ) ) ) )
+ if ( xSI->supportsService( OUString("com.sun.star.document.OfficeDocument")))
+ {
xDocStorage.set( _rxDocument->getDocumentStorage(), UNO_QUERY_THROW );
-
+ }
Reference< XModel > xDocument( _rxDocument, UNO_QUERY_THROW );
Reference< XComponent > xDocComponent( _rxDocument, UNO_QUERY_THROW );
@@ -2580,8 +2709,9 @@ void SAL_CALL SfxLibraryContainer::initializeFromDocument( const Reference< XSto
catch( const Exception& ) { }
if ( !xDocStorage.is() )
+ {
throw IllegalArgumentException();
-
+ }
init( OUString(), xDocStorage );
}
@@ -2624,17 +2754,15 @@ sal_Bool SAL_CALL SfxLibraryContainer::isLibraryPasswordVerified( const OUString
throw IllegalArgumentException();
}
-sal_Bool SAL_CALL SfxLibraryContainer::verifyLibraryPassword
- ( const OUString&, const OUString& )
- throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+sal_Bool SAL_CALL SfxLibraryContainer::verifyLibraryPassword( const OUString&, const OUString& )
+ throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
throw IllegalArgumentException();
}
-void SAL_CALL SfxLibraryContainer::changeLibraryPassword(
- const OUString&, const OUString&, const OUString& )
- throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+void SAL_CALL SfxLibraryContainer::changeLibraryPassword(const OUString&, const OUString&, const OUString& )
+ throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
throw IllegalArgumentException();
@@ -2659,7 +2787,7 @@ void SAL_CALL SfxLibraryContainer::removeContainerListener( const Reference< XCo
// Methods XLibraryContainerExport
void SAL_CALL SfxLibraryContainer::exportLibrary( const OUString& Name, const OUString& URL,
const Reference< XInteractionHandler >& Handler )
- throw ( uno::Exception, NoSuchElementException, RuntimeException)
+ throw ( uno::Exception, NoSuchElementException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
SfxLibrary* pImplLib = getImplLib( Name );
@@ -2676,10 +2804,13 @@ void SAL_CALL SfxLibraryContainer::exportLibrary( const OUString& Name, const OU
uno::Reference< ::com::sun::star::embed::XStorage > xDummyStor;
if( pImplLib->mbPasswordProtected )
+ {
implStorePasswordLibrary( pImplLib, Name, xDummyStor, URL, xToUseSFI, Handler );
+ }
else
+ {
implStoreLibrary( pImplLib, Name, xDummyStor, URL, xToUseSFI, Handler );
-
+ }
::xmlscript::LibDescriptor aLibDesc;
aLibDesc.aName = Name;
aLibDesc.bLink = false; // Link status gets lost?
@@ -2698,15 +2829,14 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
{
if( !mxMacroExpander.is() )
{
- Reference< XComponentContext > xContext(
- comphelper::getComponentContext( mxMSF ) );
+ Reference< XComponentContext > xContext(comphelper::getComponentContext( mxMSF ) );
Reference< util::XMacroExpander > xExpander;
- xContext->getValueByName(
- OUSTR("/singletons/com.sun.star.util.theMacroExpander") ) >>= xExpander;
+ xContext->getValueByName( OUString("/singletons/com.sun.star.util.theMacroExpander") ) >>= xExpander;
if(! xExpander.is())
{
throw uno::DeploymentException(
- OUSTR("no macro expander singleton available!"), Reference< XInterface >() );
+ OUString("no macro expander singleton available!"),
+ Reference< XInterface >() );
}
MutexGuard guard( Mutex::getGlobalMutex() );
if( !mxMacroExpander.is() )
@@ -2716,8 +2846,9 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
}
if( !mxMacroExpander.is() )
+ {
return url;
-
+ }
// cut protocol
OUString macro( url.copy( sizeof (EXPAND_PROTOCOL ":") -1 ) );
// decode uric class chars
@@ -2745,14 +2876,16 @@ OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString
SfxLibrary* pImplLib = getImplLib( Name );
sal_Bool bLink = pImplLib->mbLink;
if( !bLink )
+ {
throw IllegalArgumentException();
+ }
OUString aRetStr = pImplLib->maOriginalStorageURL;
return aRetStr;
}
// XVBACompatibility
-::sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatibilityMode() throw (RuntimeException)
+sal_Bool SAL_CALL SfxLibraryContainer::getVBACompatibilityMode() throw (RuntimeException)
{
return mbVBACompat;
}
@@ -2771,8 +2904,9 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa
aLibName = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
+ {
pBasic->SetVBAEnabled( _vbacompatmodeon );
-
+ }
/* If in VBA compatibility mode, force creation of the VBA Globals
object. Each application will create an instance of its own
implementation and store it in its Basic manager. Implementations
@@ -2784,7 +2918,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa
{
Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
- xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
+ xFactory->createInstance( OUString( "ooo.vba.VBAGlobals"));
}
catch(const Exception& )
{
@@ -2792,7 +2926,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa
}
}
-void SAL_CALL SfxLibraryContainer::setProjectName( const ::rtl::OUString& _projectname ) throw (RuntimeException)
+void SAL_CALL SfxLibraryContainer::setProjectName( const OUString& _projectname ) throw (RuntimeException)
{
msProjectName = _projectname;
BasicManager* pBasMgr = getBasicManager();
@@ -2801,7 +2935,9 @@ void SAL_CALL SfxLibraryContainer::setProjectName( const ::rtl::OUString& _proje
// code expect the name of the VBA project to be set as the name of
// the basic manager. Provide fail back here.
if( pBasMgr )
+ {
pBasMgr->SetName( msProjectName );
+ }
}
sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException)
@@ -2820,17 +2956,17 @@ void SAL_CALL SfxLibraryContainer::removeVBAScriptListener( const Reference< vba
maVBAScriptListeners.removeTypedListener( rxListener );
}
-void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) throw (RuntimeException)
+void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const OUString& rModuleName ) throw (RuntimeException)
{
// own lock for accessing the number of running scripts
enterMethod();
switch( nIdentifier )
{
- case vba::VBAScriptEventId::SCRIPT_STARTED:
- ++mnRunningVBAScripts;
+ case vba::VBAScriptEventId::SCRIPT_STARTED:
+ ++mnRunningVBAScripts;
break;
- case vba::VBAScriptEventId::SCRIPT_STOPPED:
- --mnRunningVBAScripts;
+ case vba::VBAScriptEventId::SCRIPT_STOPPED:
+ --mnRunningVBAScripts;
break;
}
leaveMethod();
@@ -2842,15 +2978,19 @@ void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifie
}
// Methods XServiceInfo
-::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName )
+sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const OUString& _rServiceName )
throw (RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
const OUString* pSupportedServices = aSupportedServices.getConstArray();
for ( sal_Int32 i=0; i<aSupportedServices.getLength(); ++i, ++pSupportedServices )
+ {
if ( *pSupportedServices == _rServiceName )
+ {
return sal_True;
+ }
+ }
return sal_False;
}
@@ -2909,10 +3049,14 @@ SfxLibrary::SfxLibrary( ModifiableHelper& _rModifiable, const Type& aType,
void SfxLibrary::implSetModified( sal_Bool _bIsModified )
{
if ( mbIsModified == _bIsModified )
+ {
return;
+ }
mbIsModified = _bIsModified;
if ( mbIsModified )
+ {
mrModifiable.setModified( sal_True );
+ }
}
// Methods XInterface
@@ -2930,7 +3074,9 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType )
static_cast< XElementAccess * >( this ),
static_cast< XChangesNotifier * >( this ) ) );
if( !aRet.hasValue() )
+ {
aRet = OComponentHelper::queryInterface( rType );
+ }
return aRet;
}
@@ -2974,24 +3120,28 @@ sal_Bool SfxLibrary::hasByName( const OUString& aName )
void SfxLibrary::impl_checkReadOnly()
{
if( mbReadOnly || (mbLink && mbReadOnlyLink) )
+ {
throw IllegalArgumentException(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Library is readonly." ) ),
+ OUString("Library is readonly."),
// TODO: resource
*this, 0
);
+ }
}
void SfxLibrary::impl_checkLoaded()
{
if ( !mbLoaded )
+ {
throw WrappedTargetException(
- ::rtl::OUString(),
+ OUString(),
*this,
makeAny( LibraryNotLoadedException(
- ::rtl::OUString(),
+ OUString(),
*this
) )
);
+ }
}
// Methods XNameReplace
@@ -3025,7 +3175,7 @@ void SfxLibrary::insertByName( const OUString& aName, const Any& aElement )
implSetModified( sal_True );
}
-void SfxLibrary::impl_removeWithoutChecks( const ::rtl::OUString& _rElementName )
+void SfxLibrary::impl_removeWithoutChecks( const OUString& _rElementName )
{
maNameContainer.removeByName( _rElementName );
implSetModified( sal_True );
@@ -3035,14 +3185,17 @@ void SfxLibrary::impl_removeWithoutChecks( const ::rtl::OUString& _rElementName
{
INetURLObject aElementInetObj( maStorageURL );
aElementInetObj.insertName( _rElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aElementInetObj.setExtension( maLibElementFileExtension );
OUString aFile = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
try
{
if( mxSFI->exists( aFile ) )
+ {
mxSFI->kill( aFile );
+ }
}
catch(const Exception& )
{
@@ -3147,9 +3300,9 @@ ScriptExtensionIterator::ScriptExtensionIterator( void )
, m_pScriptSubPackageIterator( NULL )
{}
-rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDialogLib )
+OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDialogLib )
{
- rtl::OUString aRetLib;
+ OUString aRetLib;
while( aRetLib.isEmpty() && m_eState != END_REACHED )
{
@@ -3160,8 +3313,9 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia
Reference< deployment::XPackage > xScriptPackage =
implGetNextUserScriptPackage( rbPureDialogLib );
if( !xScriptPackage.is() )
+ {
break;
-
+ }
aRetLib = xScriptPackage->getURL();
break;
}
@@ -3171,8 +3325,9 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia
Reference< deployment::XPackage > xScriptPackage =
implGetNextSharedScriptPackage( rbPureDialogLib );
if( !xScriptPackage.is() )
+ {
break;
-
+ }
aRetLib = xScriptPackage->getURL();
break;
}
@@ -3181,8 +3336,9 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia
Reference< deployment::XPackage > xScriptPackage =
implGetNextBundledScriptPackage( rbPureDialogLib );
if( !xScriptPackage.is() )
+ {
break;
-
+ }
aRetLib = xScriptPackage->getURL();
break;
}
@@ -3207,8 +3363,9 @@ ScriptSubPackageIterator::ScriptSubPackageIterator( Reference< deployment::XPack
{
Reference< deployment::XPackage > xScriptPackage;
if( !m_xMainPackage.is() )
+ {
return;
-
+ }
// Check if parent package is registered
beans::Optional< beans::Ambiguous<sal_Bool> > option( m_xMainPackage->isRegistered
( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() ) );
@@ -3217,7 +3374,9 @@ ScriptSubPackageIterator::ScriptSubPackageIterator( Reference< deployment::XPack
{
beans::Ambiguous<sal_Bool> const & reg = option.Value;
if( !reg.IsAmbiguous && reg.Value )
+ {
bRegistered = true;
+ }
}
if( bRegistered )
{
@@ -3225,22 +3384,22 @@ ScriptSubPackageIterator::ScriptSubPackageIterator( Reference< deployment::XPack
if( m_xMainPackage->isBundle() )
{
m_bIsBundle = true;
- m_aSubPkgSeq = m_xMainPackage->getBundle
- ( Reference<task::XAbortChannel>(), Reference<ucb::XCommandEnvironment>() );
+ m_aSubPkgSeq = m_xMainPackage->getBundle( Reference<task::XAbortChannel>(),
+ Reference<ucb::XCommandEnvironment>() );
m_nSubPkgCount = m_aSubPkgSeq.getLength();
}
}
}
-Reference< deployment::XPackage > ScriptSubPackageIterator::getNextScriptSubPackage
- ( bool& rbPureDialogLib )
+Reference< deployment::XPackage > ScriptSubPackageIterator::getNextScriptSubPackage( bool& rbPureDialogLib )
{
rbPureDialogLib = false;
Reference< deployment::XPackage > xScriptPackage;
if( !m_bIsValid )
+ {
return xScriptPackage;
-
+ }
if( m_bIsBundle )
{
const Reference< deployment::XPackage >* pSeq = m_aSubPkgSeq.getConstArray();
@@ -3250,7 +3409,9 @@ Reference< deployment::XPackage > ScriptSubPackageIterator::getNextScriptSubPack
const Reference< deployment::XPackage > xSubPkg = pSeq[ iPkg ];
xScriptPackage = implDetectScriptPackage( xSubPkg, rbPureDialogLib );
if( xScriptPackage.is() )
+ {
break;
+ }
}
m_iNextSubPkg = iPkg + 1;
}
@@ -3263,15 +3424,15 @@ Reference< deployment::XPackage > ScriptSubPackageIterator::getNextScriptSubPack
return xScriptPackage;
}
-Reference< deployment::XPackage > ScriptSubPackageIterator::implDetectScriptPackage
- ( const Reference< deployment::XPackage > xPackage, bool& rbPureDialogLib )
+Reference< deployment::XPackage > ScriptSubPackageIterator::implDetectScriptPackage ( const Reference< deployment::XPackage > xPackage,
+ bool& rbPureDialogLib )
{
Reference< deployment::XPackage > xScriptPackage;
if( xPackage.is() )
{
const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xPackage->getPackageType();
- rtl::OUString aMediaType = xPackageTypeInfo->getMediaType();
+ OUString aMediaType = xPackageTypeInfo->getMediaType();
if ( aMediaType == sBasicLibMediaType )
{
xScriptPackage = xPackage;
@@ -3286,8 +3447,7 @@ Reference< deployment::XPackage > ScriptSubPackageIterator::implDetectScriptPack
return xScriptPackage;
}
-Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScriptPackage
- ( bool& rbPureDialogLib )
+Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScriptPackage( bool& rbPureDialogLib )
{
Reference< deployment::XPackage > xScriptPackage;
@@ -3295,11 +3455,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript
{
try
{
- Reference< XExtensionManager > xManager =
- ExtensionManager::get( m_xContext );
- m_aUserPackagesSeq = xManager->getDeployedExtensions
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")),
- Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() );
+ Reference< XExtensionManager > xManager = ExtensionManager::get( m_xContext );
+ m_aUserPackagesSeq = xManager->getDeployedExtensions(OUString("user"),
+ Reference< task::XAbortChannel >(),
+ Reference< ucb::XCommandEnvironment >() );
}
catch(const com::sun::star::uno::DeploymentException& )
{
@@ -3343,8 +3502,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript
return xScriptPackage;
}
-Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScriptPackage
- ( bool& rbPureDialogLib )
+Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScriptPackage( bool& rbPureDialogLib )
{
Reference< deployment::XPackage > xScriptPackage;
@@ -3352,11 +3510,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri
{
try
{
- Reference< XExtensionManager > xSharedManager =
- ExtensionManager::get( m_xContext );
- m_aSharedPackagesSeq = xSharedManager->getDeployedExtensions
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shared")),
- Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() );
+ Reference< XExtensionManager > xSharedManager = ExtensionManager::get( m_xContext );
+ m_aSharedPackagesSeq = xSharedManager->getDeployedExtensions(OUString("shared"),
+ Reference< task::XAbortChannel >(),
+ Reference< ucb::XCommandEnvironment >() );
}
catch(const com::sun::star::uno::DeploymentException& )
{
@@ -3399,8 +3556,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri
return xScriptPackage;
}
-Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScriptPackage
- ( bool& rbPureDialogLib )
+Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScriptPackage( bool& rbPureDialogLib )
{
Reference< deployment::XPackage > xScriptPackage;
@@ -3408,11 +3564,10 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScr
{
try
{
- Reference< XExtensionManager > xManager =
- ExtensionManager::get( m_xContext );
- m_aBundledPackagesSeq = xManager->getDeployedExtensions
- (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")),
- Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() );
+ Reference< XExtensionManager > xManager = ExtensionManager::get( m_xContext );
+ m_aBundledPackagesSeq = xManager->getDeployedExtensions(OUString("bundled"),
+ Reference< task::XAbortChannel >(),
+ Reference< ucb::XCommandEnvironment >() );
}
catch(const com::sun::star::uno::DeploymentException& )
{
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 0dfa8b40602a..6607aa85b8a2 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -73,8 +73,6 @@ using namespace com::sun::star;
using namespace cppu;
using namespace osl;
-using ::rtl::OUString;
-
//============================================================================
// Implementation class SfxScriptLibraryContainer
@@ -84,8 +82,7 @@ const sal_Char* SAL_CALL SfxScriptLibraryContainer::getLibElementFileExtension()
const sal_Char* SAL_CALL SfxScriptLibraryContainer::getLibrariesDir() const { return "Basic"; }
// OldBasicPassword interface
-void SfxScriptLibraryContainer::setLibraryPassword
- ( const OUString& rLibraryName, const OUString& rPassword )
+void SfxScriptLibraryContainer::setLibraryPassword( const OUString& rLibraryName, const OUString& rPassword )
{
try
{
@@ -105,7 +102,9 @@ OUString SfxScriptLibraryContainer::getLibraryPassword( const OUString& rLibrary
SfxLibrary* pImplLib = getImplLib( rLibraryName );
OUString aPassword;
if( pImplLib->mbPasswordVerified )
+ {
aPassword = pImplLib->maPassword;
+ }
return aPassword;
}
@@ -149,14 +148,14 @@ SfxLibrary* SfxScriptLibraryContainer::implCreateLibrary( const OUString& aName
return pRet;
}
-SfxLibrary* SfxScriptLibraryContainer::implCreateLibraryLink
- ( const OUString& aName, const OUString& aLibInfoFileURL,
- const OUString& StorageURL, sal_Bool ReadOnly )
+SfxLibrary* SfxScriptLibraryContainer::implCreateLibraryLink( const OUString& aName,
+ const OUString& aLibInfoFileURL,
+ const OUString& StorageURL,
+ sal_Bool ReadOnly )
{
(void)aName; // Only needed for SfxDialogLibrary
- SfxLibrary* pRet =
- new SfxScriptLibrary
- ( maModifiable, mxMSF, mxSFI, aLibInfoFileURL, StorageURL, ReadOnly );
+ SfxLibrary* pRet = new SfxScriptLibrary( maModifiable, mxMSF, mxSFI,
+ aLibInfoFileURL, StorageURL, ReadOnly );
return pRet;
}
@@ -173,12 +172,9 @@ bool SAL_CALL SfxScriptLibraryContainer::isLibraryElementValid( Any aElement ) c
return SfxScriptLibrary::containsValidModule( aElement );
}
-void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
-(
- const Reference < XNameContainer >& xLib,
- const OUString& aElementName,
- const Reference< XOutputStream >& xOutput
-)
+void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement( const Reference < XNameContainer >& xLib,
+ const OUString& aElementName,
+ const Reference< XOutputStream >& xOutput)
throw(Exception)
{
// Create sax writer
@@ -187,8 +183,9 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
Reference< XTruncate > xTruncate( xOutput, UNO_QUERY );
OSL_ENSURE( xTruncate.is(), "Currently only the streams that can be truncated are expected!" );
if ( xTruncate.is() )
+ {
xTruncate->truncate();
-
+ }
xWriter->setOutputStream( xOutput );
xmlscript::ModuleDescriptor aMod;
@@ -296,7 +293,7 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
{
Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
- xFactory->createInstance( ::rtl::OUString( "ooo.vba.VBAGlobals" ) );
+ xFactory->createInstance( OUString( "ooo.vba.VBAGlobals" ) );
}
catch(const Exception& )
{
@@ -347,7 +344,9 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
if( xVBAModuleInfo.is() )
{
if( xVBAModuleInfo->hasModuleInfo( aElementName ) )
+ {
xVBAModuleInfo->removeModuleInfo( aElementName );
+ }
xVBAModuleInfo->insertModuleInfo( aElementName, aModInfo );
}
}
@@ -396,7 +395,9 @@ sal_Bool SAL_CALL SfxScriptLibraryContainer::isLibraryPasswordVerified( const OU
LibraryContainerMethodGuard aGuard( *this );
SfxLibrary* pImplLib = getImplLib( Name );
if( !pImplLib->mbPasswordProtected )
+ {
throw IllegalArgumentException();
+ }
sal_Bool bRet = pImplLib->mbPasswordVerified;
return bRet;
}
@@ -408,15 +409,18 @@ sal_Bool SAL_CALL SfxScriptLibraryContainer::verifyLibraryPassword
LibraryContainerMethodGuard aGuard( *this );
SfxLibrary* pImplLib = getImplLib( Name );
if( !pImplLib->mbPasswordProtected || pImplLib->mbPasswordVerified )
+ {
throw IllegalArgumentException();
-
+ }
// Test password
sal_Bool bSuccess = sal_False;
if( pImplLib->mbDoc50Password )
{
bSuccess = ( Password == pImplLib->maPassword );
if( bSuccess )
+ {
pImplLib->mbPasswordVerified = sal_True;
+ }
}
else
{
@@ -432,28 +436,33 @@ sal_Bool SAL_CALL SfxScriptLibraryContainer::verifyLibraryPassword
// Reload library to get source
if( pImplLib->mbLoaded )
+ {
implLoadPasswordLibrary( pImplLib, Name );
+ }
}
}
return bSuccess;
}
void SAL_CALL SfxScriptLibraryContainer::changeLibraryPassword( const OUString& Name,
- const OUString& OldPassword, const OUString& NewPassword )
+ const OUString& OldPassword,
+ const OUString& NewPassword )
throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
{
LibraryContainerMethodGuard aGuard( *this );
SfxLibrary* pImplLib = getImplLib( Name );
if( OldPassword == NewPassword )
+ {
return;
-
+ }
sal_Bool bOldPassword = !OldPassword.isEmpty();
sal_Bool bNewPassword = !NewPassword.isEmpty();
sal_Bool bStorage = mxStorage.is() && !pImplLib->mbLink;
if( pImplLib->mbReadOnly || (bOldPassword && !pImplLib->mbPasswordProtected) )
+ {
throw IllegalArgumentException();
-
+ }
// Library must be loaded
loadLibrary( Name );
@@ -466,13 +475,16 @@ void SAL_CALL SfxScriptLibraryContainer::changeLibraryPassword( const OUString&
if( isLibraryPasswordVerified( Name ) )
{
if( pImplLib->maPassword != OldPassword )
+ {
throw IllegalArgumentException();
+ }
}
else
{
if( !verifyLibraryPassword( Name, OldPassword ) )
+ {
throw IllegalArgumentException();
-
+ }
// Reload library to get source
// Should be done in verifyLibraryPassword loadLibrary( Name );
}
@@ -529,7 +541,8 @@ void SAL_CALL SfxScriptLibraryContainer::changeLibraryPassword( const OUString&
INetURLObject aElementInetObj( aLibDirPath );
aElementInetObj.insertName( aElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
if( bKillUncryptedFiles )
aElementInetObj.setExtension( maLibElementFileExtension );
else
@@ -549,13 +562,17 @@ void setStreamKey( uno::Reference< io::XStream > xStream, const ::rtl::OUString&
{
uno::Reference< embed::XEncryptionProtectedSource > xEncrStream( xStream, uno::UNO_QUERY );
if ( xEncrStream.is() )
+ {
xEncrStream->setEncryptionPassword( aPass );
+ }
}
// Impl methods
sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
- const ::rtl::OUString& aName, const uno::Reference< embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler )
+ const ::rtl::OUString& aName,
+ const uno::Reference< embed::XStorage >& xStorage,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler )
{
OUString aDummyLocation;
Reference< XSimpleFileAccess2 > xDummySFA;
@@ -563,16 +580,19 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
}
sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, const ::rtl::OUString& aName,
- const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
- const ::rtl::OUString& aTargetURL, const Reference< XSimpleFileAccess2 > xToUseSFI, const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage,
+ const ::rtl::OUString& aTargetURL,
+ const Reference< XSimpleFileAccess2 > xToUseSFI,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& xHandler )
{
bool bExport = !aTargetURL.isEmpty();
BasicManager* pBasicMgr = getBasicManager();
OSL_ENSURE( pBasicMgr, "SfxScriptLibraryContainer::implStorePasswordLibrary: cannot do this without a BasicManager!" );
if ( !pBasicMgr )
+ {
return sal_False;
-
+ }
// Only need to handle the export case here,
// save/saveas etc are handled in sfxbasemodel::storeSelf &
// sfxbasemodel::impl_store
@@ -585,14 +605,17 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
uno::Reference< task::XInteractionRequest > xReq( pReq );
xHandler->handle( xReq );
if ( pReq->isAbort() )
+ {
throw util::VetoException();
+ }
}
}
StarBASIC* pBasicLib = pBasicMgr->GetLib( aName );
if( !pBasicLib )
+ {
return sal_False;
-
+ }
Sequence< OUString > aElementNames = pLib->getElementNames();
sal_Int32 nNameCount = aElementNames.getLength();
const OUString* pNames = aElementNames.getConstArray();
@@ -612,14 +635,16 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
OUString aCodeStreamName = aElementName;
aCodeStreamName += ".bin";
- try {
+ try
+ {
uno::Reference< io::XStream > xCodeStream = xStorage->openStreamElement(
- aCodeStreamName,
- embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
+ aCodeStreamName,
+ embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
if ( !xCodeStream.is() )
+ {
throw uno::RuntimeException();
-
+ }
SvMemoryStream aMemStream;
/*sal_Bool bStore = */pMod->StoreBinaryData( aMemStream );
@@ -630,9 +655,10 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
Reference< XOutputStream > xOut = xCodeStream->getOutputStream();
if ( !xOut.is() )
+ {
throw io::IOException(); // access denied because the stream is readonly
-
- xOut->writeBytes( aBinSeq );
+ }
+ xOut->writeBytes( aBinSeq );
xOut->closeOutput();
}
catch(const uno::Exception& )
@@ -645,27 +671,29 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
{
if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
- #if OSL_DEBUG_LEVEL > 0
+ #if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
aMessage.append( "invalid library element '" );
aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) );
aMessage.append( "'." );
OSL_FAIL( aMessage.makeStringAndClear().getStr() );
- #endif
+ #endif
continue;
}
OUString aSourceStreamName = aElementName;
aSourceStreamName += ".xml";
- try {
+ try
+ {
uno::Reference< io::XStream > xSourceStream = xStorage->openStreamElement(
- aSourceStreamName,
- embed::ElementModes::READWRITE );
+ aSourceStreamName,
+ embed::ElementModes::READWRITE );
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY );
if ( !xProps.is() )
+ {
throw uno::RuntimeException();
-
+ }
OUString aMime( "text/xml" );
xProps->setPropertyValue( rtl::OUString("MediaType"), uno::makeAny( aMime ) );
@@ -698,17 +726,21 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
{
Reference< XSimpleFileAccess2 > xSFI = mxSFI;
if( xToUseSFI.is() )
+ {
xSFI = xToUseSFI;
-
+ }
OUString aLibDirPath;
if( bExport )
{
INetURLObject aInetObj( aTargetURL );
- aInetObj.insertName( aName, sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ aInetObj.insertName( aName, sal_True, INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aLibDirPath = aInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( !xSFI->isFolder( aLibDirPath ) )
+ {
xSFI->createFolder( aLibDirPath );
+ }
}
else
{
@@ -721,31 +753,33 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
INetURLObject aElementInetObj( aLibDirPath );
aElementInetObj.insertName( aElementName, sal_False,
- INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL );
+ INetURLObject::LAST_SEGMENT, sal_True,
+ INetURLObject::ENCODE_ALL );
aElementInetObj.setExtension( OUString( "pba" ) );
OUString aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
- #if OSL_DEBUG_LEVEL > 0
+ #if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
aMessage.append( "invalid library element '" );
aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) );
aMessage.append( "'." );
OSL_FAIL( aMessage.makeStringAndClear().getStr() );
- #endif
+ #endif
continue;
}
try
{
uno::Reference< embed::XStorage > xElementRootStorage =
- ::comphelper::OStorageHelper::GetStorageFromURL(
- aElementPath,
- embed::ElementModes::READWRITE );
+ ::comphelper::OStorageHelper::GetStorageFromURL(
+ aElementPath,
+ embed::ElementModes::READWRITE );
if ( !xElementRootStorage.is() )
+ {
throw uno::RuntimeException();
-
+ }
// Write binary image stream
SbModule* pMod = pBasicLib->FindModule( aElementName );
if( pMod )
@@ -787,20 +821,24 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
OSL_ENSURE( xEncr.is(),
"StorageStream opened for writing must implement XEncryptionProtectedSource!\n" );
if ( !xEncr.is() )
+ {
throw uno::RuntimeException();
+ }
xEncr->setEncryptionPassword( pLib->maPassword );
}
catch(const ::com::sun::star::packages::WrongPasswordException& )
{
xSourceStream = xElementRootStorage->openEncryptedStreamElement(
- aSourceStreamName,
- embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,
- pLib->maPassword );
+ aSourceStreamName,
+ embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,
+ pLib->maPassword );
}
uno::Reference< beans::XPropertySet > xProps( xSourceStream, uno::UNO_QUERY );
if ( !xProps.is() )
+ {
throw uno::RuntimeException();
+ }
OUString aMime( "text/xml" );
xProps->setPropertyValue( rtl::OUString("MediaType"), uno::makeAny( aMime ) );
@@ -813,7 +851,9 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
uno::Reference< embed::XTransactedObject > xTransact( xElementRootStorage, uno::UNO_QUERY );
OSL_ENSURE( xTransact.is(), "The storage must implement XTransactedObject!\n" );
if ( !xTransact.is() )
+ {
throw uno::RuntimeException();
+ }
xTransact->commit();
}
@@ -846,7 +886,9 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
{
if( pScriptLib->mbLoadedBinary && !bVerifyPasswordOnly &&
(pScriptLib->mbLoadedSource || !pLib->mbPasswordVerified) )
- return sal_False;
+ {
+ return sal_False;
+ }
}
StarBASIC* pBasicLib = NULL;
@@ -860,8 +902,9 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
pBasicLib = pBasicMgr ? pBasicMgr->GetLib( Name ) : NULL;
pScriptLib->mbLoaded = bLoaded; // Restore flag
if( !pBasicLib )
+ {
return sal_False;
-
+ }
bLoadBinary = sal_True;
pScriptLib->mbLoadedBinary = true;
}
@@ -886,11 +929,14 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
try {
xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
if ( !xLibrariesStor.is() )
+ {
throw uno::RuntimeException();
-
+ }
xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
if ( !xLibraryStor.is() )
+ {
throw uno::RuntimeException();
+ }
}
catch(const uno::Exception& )
{
@@ -916,13 +962,15 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
OUString aCodeStreamName= aElementName;
aCodeStreamName += ".bin";
- try {
+ try
+ {
uno::Reference< io::XStream > xCodeStream = xLibraryStor->openStreamElement(
aCodeStreamName,
embed::ElementModes::READ );
if ( !xCodeStream.is() )
+ {
throw uno::RuntimeException();
-
+ }
SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xCodeStream );
if ( !pStream || pStream->GetError() )
{
@@ -949,29 +997,34 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
OUString aSourceStreamName = aElementName;
aSourceStreamName += ".xml";
- try {
+ try
+ {
uno::Reference< io::XStream > xSourceStream = xLibraryStor->openEncryptedStreamElement(
aSourceStreamName,
embed::ElementModes::READ,
pLib->maPassword );
if ( !xSourceStream.is() )
+ {
throw uno::RuntimeException();
-
+ }
// if this point is reached then the password is correct
if ( !bVerifyPasswordOnly )
{
uno::Reference< io::XInputStream > xInStream = xSourceStream->getInputStream();
if ( !xInStream.is() )
+ {
throw io::IOException(); // read access denied, seems to be impossible
-
+ }
Reference< XNameContainer > xLib( pLib );
Any aAny = importLibraryElement( xLib,
- aElementName, aSourceStreamName,
- xInStream );
+ aElementName, aSourceStreamName,
+ xInStream );
if( pLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
+ {
pLib->maNameContainer.replaceByName( aElementName, aAny );
+ }
}
else
{
@@ -1003,10 +1056,11 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
OUString aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
uno::Reference< embed::XStorage > xElementRootStorage;
- try {
+ try
+ {
xElementRootStorage = ::comphelper::OStorageHelper::GetStorageFromURL(
- aElementPath,
- embed::ElementModes::READ );
+ aElementPath,
+ embed::ElementModes::READ );
} catch(const uno::Exception& )
{
// TODO: error handling
@@ -1024,7 +1078,8 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
pBasicLib->SetModified( sal_False );
}
- try {
+ try
+ {
OUString aCodeStreamName( "code.bin" );
uno::Reference< io::XStream > xCodeStream = xElementRootStorage->openStreamElement(
aCodeStreamName,
@@ -1056,29 +1111,34 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
{
// Access encrypted source stream
OUString aSourceStreamName( "source.xml" );
- try {
+ try
+ {
uno::Reference< io::XStream > xSourceStream = xElementRootStorage->openEncryptedStreamElement(
aSourceStreamName,
embed::ElementModes::READ,
pLib->maPassword );
if ( !xSourceStream.is() )
+ {
throw uno::RuntimeException();
-
+ }
if ( !bVerifyPasswordOnly )
{
uno::Reference< io::XInputStream > xInStream = xSourceStream->getInputStream();
if ( !xInStream.is() )
+ {
throw io::IOException(); // read access denied, seems to be impossible
-
+ }
Reference< XNameContainer > xLib( pLib );
Any aAny = importLibraryElement( xLib,
- aElementName,
- aSourceStreamName,
- xInStream );
+ aElementName,
+ aSourceStreamName,
+ xInStream );
if( pLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
+ {
pLib->maNameContainer.replaceByName( aElementName, aAny );
+ }
}
else
{
@@ -1093,7 +1153,6 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
}
}
}
-
}
catch(const Exception& )
{
@@ -1110,13 +1169,15 @@ void SfxScriptLibraryContainer::onNewRootStorage()
{
}
-sal_Bool SAL_CALL
-SfxScriptLibraryContainer:: HasExecutableCode( const ::rtl::OUString& Library ) throw (uno::RuntimeException)
+sal_Bool SAL_CALL SfxScriptLibraryContainer:: HasExecutableCode( const ::rtl::OUString& Library )
+ throw (uno::RuntimeException)
{
BasicManager* pBasicMgr = getBasicManager();
OSL_ENSURE( pBasicMgr, "we need a basicmanager, really we do" );
if ( pBasicMgr )
+ {
return pBasicMgr->HasExeCode( Library ); // need to change this to take name
+ }
// default to it has code if we can't decide
return sal_True;
}
@@ -1128,12 +1189,14 @@ void createRegistryInfo_SfxScriptLibraryContainer()
static OAutoRegistration< SfxScriptLibraryContainer > aAutoRegistration;
}
-::rtl::OUString SAL_CALL SfxScriptLibraryContainer::getImplementationName( ) throw (RuntimeException)
+OUString SAL_CALL SfxScriptLibraryContainer::getImplementationName( )
+ throw (RuntimeException)
{
return getImplementationName_static();
}
-Sequence< ::rtl::OUString > SAL_CALL SfxScriptLibraryContainer::getSupportedServiceNames( ) throw (RuntimeException)
+Sequence< OUString > SAL_CALL SfxScriptLibraryContainer::getSupportedServiceNames( )
+ throw (RuntimeException)
{
return getSupportedServiceNames_static();
}
@@ -1152,12 +1215,10 @@ OUString SfxScriptLibraryContainer::getImplementationName_static()
return OUString("com.sun.star.comp.sfx2.ScriptLibraryContainer" );
}
-Reference< XInterface > SAL_CALL SfxScriptLibraryContainer::Create
- ( const Reference< XComponentContext >& )
- throw( Exception )
+Reference< XInterface > SAL_CALL SfxScriptLibraryContainer::Create( const Reference< XComponentContext >& )
+ throw( Exception )
{
- Reference< XInterface > xRet =
- static_cast< XInterface* >( static_cast< OWeakObject* >(new SfxScriptLibraryContainer()) );
+ Reference< XInterface > xRet = static_cast< XInterface* >( static_cast< OWeakObject* >(new SfxScriptLibraryContainer()) );
return xRet;
}
@@ -1234,38 +1295,47 @@ bool SAL_CALL SfxScriptLibrary::isLibraryElementValid( ::com::sun::star::uno::An
IMPLEMENT_FORWARD_XINTERFACE2( SfxScriptLibrary, SfxLibrary, SfxScriptLibrary_BASE );
IMPLEMENT_FORWARD_XTYPEPROVIDER2( SfxScriptLibrary, SfxLibrary, SfxScriptLibrary_BASE );
-script::ModuleInfo SAL_CALL
-SfxScriptLibrary::getModuleInfo( const ::rtl::OUString& ModuleName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+script::ModuleInfo SAL_CALL SfxScriptLibrary::getModuleInfo( const OUString& ModuleName )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
{
if ( !hasModuleInfo( ModuleName ) )
+ {
throw NoSuchElementException();
+ }
return mModuleInfos[ ModuleName ];
}
-sal_Bool SAL_CALL
-SfxScriptLibrary::hasModuleInfo( const ::rtl::OUString& ModuleName ) throw (RuntimeException)
+sal_Bool SAL_CALL SfxScriptLibrary::hasModuleInfo( const OUString& ModuleName )
+ throw (RuntimeException)
{
sal_Bool bRes = sal_False;
ModuleInfoMap::iterator it = mModuleInfos.find( ModuleName );
if ( it != mModuleInfos.end() )
+ {
bRes = sal_True;
-
+ }
return bRes;
}
-void SAL_CALL SfxScriptLibrary::insertModuleInfo( const ::rtl::OUString& ModuleName, const script::ModuleInfo& ModuleInfo ) throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+void SAL_CALL SfxScriptLibrary::insertModuleInfo( const OUString& ModuleName, const script::ModuleInfo& ModuleInfo )
+ throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
{
if ( hasModuleInfo( ModuleName ) )
+ {
throw ElementExistException();
+ }
mModuleInfos[ ModuleName ] = ModuleInfo;
}
-void SAL_CALL SfxScriptLibrary::removeModuleInfo( const ::rtl::OUString& ModuleName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+void SAL_CALL SfxScriptLibrary::removeModuleInfo( const OUString& ModuleName )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
{
// #FIXME add NoSuchElementException to the spec
if ( !hasModuleInfo( ModuleName ) )
+ {
throw NoSuchElementException();
+ }
mModuleInfos.erase( mModuleInfos.find( ModuleName ) );
}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 85856993ba7d..3dd661bc6848 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2998,9 +2998,13 @@ void ScInterpreter::ScExternal()
uno::Reference<table::XCellRange> xObj =
ScCellRangeObj::CreateRangeFromDoc( pDok, aRange );
if (xObj.is())
+ {
aParam <<= xObj;
+ }
else
+ {
SetError(errIllegalParameter);
+ }
}
break;
default:
@@ -3017,8 +3021,9 @@ void ScInterpreter::ScExternal()
}
while (nPar-- > 0)
+ {
Pop(); // in case of error, remove remaining args
-
+ }
if ( !GetError() )
{
aCall.ExecuteCall();
@@ -3026,8 +3031,9 @@ void ScInterpreter::ScExternal()
if ( aCall.HasVarRes() ) // handle async functions
{
if ( pMyFormulaCell->GetCode()->IsRecalcModeNormal() )
+ {
pMyFormulaCell->GetCode()->SetRecalcModeOnLoad();
-
+ }
uno::Reference<sheet::XVolatileResult> xRes = aCall.GetVarRes();
ScAddInListener* pLis = ScAddInListener::Get( xRes );
if ( !pLis )
@@ -3039,23 +3045,31 @@ void ScInterpreter::ScExternal()
{
pMyFormulaCell->StartListening( *pLis );
if ( !pLis->HasDocument( pDok ) )
+ {
pLis->AddDocument( pDok );
+ }
}
aCall.SetResult( pLis->GetResult() ); // use result from async
}
if ( aCall.GetErrCode() )
+ {
PushError( aCall.GetErrCode() );
+ }
else if ( aCall.HasMatrix() )
{
ScMatrixRef xMat = aCall.GetMatrix();
PushMatrix( xMat );
}
else if ( aCall.HasString() )
+ {
PushString( aCall.GetString() );
+ }
else
+ {
PushDouble( aCall.GetValue() );
+ }
}
else // error...
PushError( GetError());
@@ -3063,7 +3077,9 @@ void ScInterpreter::ScExternal()
else
{
while( nParamCount-- > 0)
+ {
Pop();
+ }
PushError( errNoAddin );
}
}
@@ -3189,10 +3205,13 @@ void ScInterpreter::ScMacro()
aMacroStr += pMethod->GetName();
String aBasicStr;
if (pObject->GetParent())
+ {
aBasicStr = pObject->GetParent()->GetName(); // Dokumentenbasic
+ }
else
+ {
aBasicStr = SFX_APP()->GetName(); // Applikationsbasic
-
+ }
// Parameter-Array zusammenbauen
SbxArrayRef refPar = new SbxArray;
@@ -3219,7 +3238,9 @@ void ScInterpreter::ScMacro()
bOk = lcl_setVBARange( aRange, pDok, pPar );
}
else
+ {
bOk = SetSbxVariable( pPar, aAdr );
+ }
}
break;
case svDoubleRef:
@@ -3286,15 +3307,21 @@ void ScInterpreter::ScMacro()
nIdx[ 1 ] = static_cast<sal_Int32>(nMatCol+1);
SbxVariable* p = refArray->Get32( nIdx );
if (pMat->IsString(nMatCol, nMatRow))
+ {
p->PutString( pMat->GetString(nMatCol, nMatRow) );
+ }
else
+ {
p->PutDouble( pMat->GetDouble(nMatCol, nMatRow));
+ }
}
}
pPar->PutObject( refArray );
}
else
+ {
SetError( errIllegalParameter );
+ }
}
break;
default:
@@ -3320,11 +3347,17 @@ void ScInterpreter::ScMacro()
SbxDataType eResType = refRes->GetType();
if( pVar->GetError() )
+ {
SetError( errNoValue);
+ }
if ( eRet != ERRCODE_NONE )
+ {
PushNoValue();
+ }
else if( eResType >= SbxINTEGER && eResType <= SbxDOUBLE )
+ {
PushDouble( refRes->GetDouble() );
+ }
else if ( eResType & SbxARRAY )
{
SbxBase* pElemObj = refRes->GetObject();
@@ -3371,7 +3404,9 @@ void ScInterpreter::ScMacro()
pV = pDimArray->Get32( nIdx );
eType = pV->GetType();
if ( eType >= SbxINTEGER && eType <= SbxDOUBLE )
+ {
pMat->PutDouble( pV->GetDouble(), i, j );
+ }
else
pMat->PutString( pV->GetString(), i, j );
}
@@ -3379,10 +3414,14 @@ void ScInterpreter::ScMacro()
PushMatrix( pMat );
}
else
+ {
PushIllegalArgument();
+ }
}
else
+ {
PushNoValue();
+ }
}
else
PushString( refRes->GetString() );