Kaydet (Commit) ed338bc2 authored tarafından José Guilherme Vanz's avatar José Guilherme Vanz Kaydeden (comit) Muthu Subramanian K

OUString cleanup in oox

Change-Id: Id3c121acddd515621325c93735bb3dd88592749e
Signed-off-by: 's avatarJosé Guilherme Vanz <guilherme.sft@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/1485Reviewed-by: 's avatarMuthu Subramanian K <muthusuba@gmail.com>
Tested-by: 's avatarMuthu Subramanian K <muthusuba@gmail.com>
üst ef48f2fd
...@@ -26,10 +26,6 @@ namespace ole { ...@@ -26,10 +26,6 @@ namespace ole {
// ============================================================================ // ============================================================================
using ::rtl::OUString;
// ============================================================================
namespace { namespace {
const sal_uInt32 AX_STRING_SIZEMASK = 0x7FFFFFFF; const sal_uInt32 AX_STRING_SIZEMASK = 0x7FFFFFFF;
...@@ -218,7 +214,7 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue ) ...@@ -218,7 +214,7 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue )
} }
} }
void AxBinaryPropertyReader::readGuidProperty( ::rtl::OUString& orGuid ) void AxBinaryPropertyReader::readGuidProperty( OUString& orGuid )
{ {
if( startNextProperty() ) if( startNextProperty() )
maLargeProps.push_back( ComplexPropVector::value_type( new GuidProperty( orGuid ) ) ); maLargeProps.push_back( ComplexPropVector::value_type( new GuidProperty( orGuid ) ) );
......
...@@ -34,10 +34,6 @@ namespace ole { ...@@ -34,10 +34,6 @@ namespace ole {
// ============================================================================ // ============================================================================
using ::rtl::OUString;
// ============================================================================
namespace { namespace {
const sal_uInt32 AX_STRING_SIZEMASK = 0x7FFFFFFF; const sal_uInt32 AX_STRING_SIZEMASK = 0x7FFFFFFF;
......
...@@ -558,11 +558,11 @@ void ControlConverter::convertToAxState( PropertySet& rPropSet, ...@@ -558,11 +558,11 @@ void ControlConverter::convertToAxState( PropertySet& rPropSet,
// control is awt or not ) // control is awt or not )
rPropSet.getProperty( nState, PROP_State ); rPropSet.getProperty( nState, PROP_State );
rValue = rtl::OUString(); // empty e.g. 'don't know' rValue = OUString(); // empty e.g. 'don't know'
if ( nState == API_STATE_UNCHECKED ) if ( nState == API_STATE_UNCHECKED )
rValue = rtl::OUString( '0' ); rValue = OUString('0');
else if ( nState == API_STATE_CHECKED ) else if ( nState == API_STATE_CHECKED )
rValue = rtl::OUString( '1' ); rValue = OUString('1');
// tristate // tristate
if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) ) if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) )
...@@ -2414,16 +2414,16 @@ HtmlSelectModel::HtmlSelectModel() ...@@ -2414,16 +2414,16 @@ HtmlSelectModel::HtmlSelectModel()
bool bool
HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{ {
static String sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") ); static OUString sMultiple( "<SELECT MULTIPLE" );
static String sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") ); static OUString sSelected( "OPTION SELECTED" );
OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() ); OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );
String data = sStringContents; OUString data = sStringContents;
// replace crlf with lf // replace crlf with lf
data.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) ); data = data.replaceAll( "\x0D\x0A" , "\x0A" );
std::vector< rtl::OUString > listValues; std::vector< OUString > listValues;
std::vector< sal_Int16 > selectedIndices; std::vector< sal_Int16 > selectedIndices;
// Ultra hacky parser for the info // Ultra hacky parser for the info
...@@ -2431,10 +2431,10 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) ...@@ -2431,10 +2431,10 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken ) for ( sal_Int32 nToken = 0; nToken < nTokenCount; ++nToken )
{ {
String sLine( data.GetToken( nToken, '\n' ) ); OUString sLine( data.getToken( nToken, '\n' ) );
if ( !nToken ) // first line will tell us if multiselect is enabled if ( !nToken ) // first line will tell us if multiselect is enabled
{ {
if ( sLine.CompareTo( sMultiple, sMultiple.Len() ) == COMPARE_EQUAL ) if ( sLine == sMultiple )
mnMultiSelect = true; mnMultiSelect = true;
} }
// skip first and last lines, no data there // skip first and last lines, no data there
...@@ -2442,17 +2442,17 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) ...@@ -2442,17 +2442,17 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{ {
if ( comphelper::string::getTokenCount(sLine, '>') ) if ( comphelper::string::getTokenCount(sLine, '>') )
{ {
String displayValue = sLine.GetToken( 1, '>' ); OUString displayValue = sLine.getToken( 1, '>' );
if ( displayValue.Len() ) if ( displayValue.getLength() )
{ {
// Really we should be using a proper html parser // Really we should be using a proper html parser
// escaping some common bits to be escaped // escaping some common bits to be escaped
displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&lt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) ); displayValue = displayValue.replaceAll( "&lt;", "<" );
displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&gt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) ); displayValue = displayValue.replaceAll( "&gt;", ">" );
displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&quot;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) ); displayValue = displayValue.replaceAll( "&quot;", "\"" );
displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&amp;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) ); displayValue = displayValue.replaceAll( "&amp;", "&" );
listValues.push_back( displayValue ); listValues.push_back( displayValue );
if( sLine.Search( sSelected ) != STRING_NOTFOUND ) if( sLine.indexOf( sSelected ) != STRING_NOTFOUND )
selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 ); selectedIndices.push_back( static_cast< sal_Int16 >( listValues.size() ) - 1 );
} }
} }
...@@ -2462,7 +2462,7 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm ) ...@@ -2462,7 +2462,7 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{ {
msListData.realloc( listValues.size() ); msListData.realloc( listValues.size() );
sal_Int32 index = 0; sal_Int32 index = 0;
for( std::vector< rtl::OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index ) for( std::vector< OUString >::iterator it = listValues.begin(); it != listValues.end(); ++it, ++index )
msListData[ index ] = *it; msListData[ index ] = *it;
} }
if ( !selectedIndices.empty() ) if ( !selectedIndices.empty() )
...@@ -2497,7 +2497,7 @@ HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm ) ...@@ -2497,7 +2497,7 @@ HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
// in msocximex ( where this is ported from, it appears *nothing* is read // in msocximex ( where this is ported from, it appears *nothing* is read
// from the control stream ), surely there is some useful info there ? // from the control stream ), surely there is some useful info there ?
OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :"); OSL_TRACE("HtmlTextBoxModel::importBinaryModel - string contents of stream :");
OSL_TRACE("%s", rtl::OUStringToOString( sStringContents, RTL_TEXTENCODING_UTF8 ).getStr() ); OSL_TRACE("%s", OUStringToOString( sStringContents, RTL_TEXTENCODING_UTF8 ).getStr() );
#else #else
(void) rInStrm; (void) rInStrm;
#endif #endif
......
...@@ -38,7 +38,6 @@ using ::oox::core::ContextHandler2; ...@@ -38,7 +38,6 @@ using ::oox::core::ContextHandler2;
using ::oox::core::ContextHandlerRef; using ::oox::core::ContextHandlerRef;
using ::oox::core::FragmentHandler2; using ::oox::core::FragmentHandler2;
using ::oox::core::XmlFilterBase; using ::oox::core::XmlFilterBase;
using ::rtl::OUString;
// ============================================================================ // ============================================================================
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
namespace oox { namespace oox {
namespace ole { namespace ole {
using ::rtl::OUString;
// ============================================================================ // ============================================================================
AxFontData::AxFontData() : AxFontData::AxFontData() :
......
...@@ -46,9 +46,6 @@ namespace ole { ...@@ -46,9 +46,6 @@ namespace ole {
// ============================================================================ // ============================================================================
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::com::sun::star::form::XFormComponent; using ::com::sun::star::form::XFormComponent;
using ::com::sun::star::form::XForm; using ::com::sun::star::form::XForm;
using ::com::sun::star::awt::XControlModel; using ::com::sun::star::awt::XControlModel;
...@@ -238,7 +235,7 @@ StdFontInfo::StdFontInfo() : ...@@ -238,7 +235,7 @@ StdFontInfo::StdFontInfo() :
{ {
} }
StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, StdFontInfo::StdFontInfo( const OUString& rName, sal_uInt32 nHeight,
sal_uInt16 nWeight, sal_uInt16 nCharSet, sal_uInt8 nFlags ) : sal_uInt16 nWeight, sal_uInt16 nCharSet, sal_uInt8 nFlags ) :
maName( rName ), maName( rName ),
mnHeight( nHeight ), mnHeight( nHeight ),
...@@ -361,22 +358,22 @@ class OleFormCtrlExportHelper ...@@ -361,22 +358,22 @@ class OleFormCtrlExportHelper
Reference< XModel > mxDocModel; Reference< XModel > mxDocModel;
Reference< XControlModel > mxControlModel; Reference< XControlModel > mxControlModel;
::rtl::OUString maName; OUString maName;
::rtl::OUString maTypeName; OUString maTypeName;
::rtl::OUString maFullName; OUString maFullName;
::rtl::OUString maGUID; OUString maGUID;
public: public:
OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& xDocModel, const Reference< XControlModel >& xModel ); OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& xDocModel, const Reference< XControlModel >& xModel );
virtual ~OleFormCtrlExportHelper() { } virtual ~OleFormCtrlExportHelper() { }
virtual ::rtl::OUString getGUID() virtual OUString getGUID()
{ {
rtl::OUString sResult; OUString sResult;
if ( maGUID.getLength() > 2 ) if ( maGUID.getLength() > 2 )
sResult = maGUID.copy(1, maGUID.getLength() - 2 ); sResult = maGUID.copy(1, maGUID.getLength() - 2 );
return sResult; return sResult;
} }
::rtl::OUString getFullName() { return maFullName; } OUString getFullName() { return maFullName; }
::rtl::OUString getTypeName() { return maTypeName; } OUString getTypeName() { return maTypeName; }
bool isValid() { return mpModel != NULL; } bool isValid() { return mpModel != NULL; }
void exportName( const Reference< XOutputStream >& rxOut ); void exportName( const Reference< XOutputStream >& rxOut );
void exportCompObj( const Reference< XOutputStream >& rxOut ); void exportCompObj( const Reference< XOutputStream >& rxOut );
...@@ -475,7 +472,7 @@ MSConvertOCXControls::~MSConvertOCXControls() ...@@ -475,7 +472,7 @@ MSConvertOCXControls::~MSConvertOCXControls()
} }
bool bool
MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const ::rtl::OUString& rGuidString ) MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rGuidString )
{ {
::oox::ole::EmbeddedControl aControl( CREATE_OUSTRING( "Unknown" ) ); ::oox::ole::EmbeddedControl aControl( CREATE_OUSTRING( "Unknown" ) );
if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) ) if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString ) )
...@@ -504,7 +501,7 @@ MSConvertOCXControls::ReadOCXCtlsStream( SotStorageStreamRef& rSrc1, Reference< ...@@ -504,7 +501,7 @@ MSConvertOCXControls::ReadOCXCtlsStream( SotStorageStreamRef& rSrc1, Reference<
return sal_False; return sal_False;
} }
bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const rtl::OUString& rStrmClassId, bool MSConvertOCXControls::importControlFromStream( ::oox::BinaryInputStream& rInStrm, Reference< XFormComponent >& rxFormComp, const OUString& rStrmClassId,
sal_Int32 nStreamSize) sal_Int32 nStreamSize)
{ {
if ( !rInStrm.isEof() ) if ( !rInStrm.isEof() )
...@@ -575,7 +572,7 @@ sal_Bool MSConvertOCXControls::ReadOCXStorage( SotStorageRef& xOleStg, ...@@ -575,7 +572,7 @@ sal_Bool MSConvertOCXControls::ReadOCXStorage( SotStorageRef& xOleStg,
sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, SotStorageRef &xOleStg, sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, SotStorageRef &xOleStg,
const Reference< XControlModel > &rxControlModel, const Reference< XControlModel > &rxControlModel,
const com::sun::star::awt::Size& rSize, rtl::OUString &rName) const com::sun::star::awt::Size& rSize, OUString &rName)
{ {
SvGlobalName aName; SvGlobalName aName;
...@@ -584,10 +581,10 @@ sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxMode ...@@ -584,10 +581,10 @@ sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxMode
if ( !exportHelper.isValid() ) if ( !exportHelper.isValid() )
return sal_False; return sal_False;
rtl::OUString sId = exportHelper.getGUID(); OUString sId = exportHelper.getGUID();
aName.MakeId(sId); aName.MakeId(sId);
rtl::OUString sFullName = exportHelper.getFullName(); OUString sFullName = exportHelper.getFullName();
rName = exportHelper.getTypeName(); rName = exportHelper.getTypeName();
xOleStg->SetClass( aName,0x5C,sFullName); xOleStg->SetClass( aName,0x5C,sFullName);
{ {
...@@ -632,14 +629,14 @@ const Reference< XIndexContainer >& ...@@ -632,14 +629,14 @@ const Reference< XIndexContainer >&
Reference< XNameContainer > xNameCont = Reference< XNameContainer > xNameCont =
xFormsSupplier->getForms(); xFormsSupplier->getForms();
rtl::OUString sStdName = CREATE_OUSTRING( "WW-Standard" ); OUString sStdName = CREATE_OUSTRING( "WW-Standard" );
rtl::OUString sName( sStdName ); OUString sName( sStdName );
sal_uInt16 n = 0; sal_uInt16 n = 0;
while( xNameCont->hasByName( sName ) ) while( xNameCont->hasByName( sName ) )
{ {
sName = sStdName; sName = sStdName;
sName += rtl::OUString::valueOf(static_cast<sal_Int32>(++n)); sName += OUString::valueOf(static_cast<sal_Int32>(++n));
} }
const Reference< XMultiServiceFactory > &rServiceFactory const Reference< XMultiServiceFactory > &rServiceFactory
......
...@@ -41,8 +41,6 @@ using namespace ::com::sun::star::io; ...@@ -41,8 +41,6 @@ using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using ::rtl::OUString;
// ============================================================================ // ============================================================================
OleObjectInfo::OleObjectInfo() : OleObjectInfo::OleObjectInfo() :
......
...@@ -47,8 +47,6 @@ using namespace ::com::sun::star::io; ...@@ -47,8 +47,6 @@ using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using ::rtl::OUString;
// ============================================================================ // ============================================================================
namespace { namespace {
......
...@@ -779,12 +779,12 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, ...@@ -779,12 +779,12 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib,
while( !bExitLoop && !aFrameTextStrm.isEof() ) while( !bExitLoop && !aFrameTextStrm.isEof() )
{ {
aLine = aFrameTextStrm.readLine().trim(); aLine = aFrameTextStrm.readLine().trim();
bExitLoop = aLine.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "End" ) ); bExitLoop = aLine.equalsIgnoreAsciiCaseAscii( "End" );
if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) )
{ {
if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Caption" ) ) ) if( aKey.equalsIgnoreAsciiCaseAscii( "Caption" ) )
mxCtrlModel->importProperty( XML_Caption, lclGetQuotedString( aValue ) ); mxCtrlModel->importProperty( XML_Caption, lclGetQuotedString( aValue ) );
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Tag" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAscii( "Tag" ) )
mxSiteModel->importProperty( XML_Tag, lclGetQuotedString( aValue ) ); mxSiteModel->importProperty( XML_Tag, lclGetQuotedString( aValue ) );
} }
} }
......
...@@ -28,9 +28,6 @@ namespace ole { ...@@ -28,9 +28,6 @@ namespace ole {
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
// ============================================================================ // ============================================================================
/*static*/ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData, BinaryInputStream& rInStrm ) /*static*/ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData, BinaryInputStream& rInStrm )
......
...@@ -43,12 +43,10 @@ using namespace ::com::sun::star::script::vba; ...@@ -43,12 +43,10 @@ using namespace ::com::sun::star::script::vba;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::com::sun::star::awt::KeyEvent; using ::com::sun::star::awt::KeyEvent;
// ============================================================================ // ============================================================================
typedef ::cppu::WeakImplHelper1< container::XIndexContainer > OleIdToNameContainer_BASE; typedef ::cppu::WeakImplHelper1< container::XIndexContainer > OleIdToNameContainer_BASE;
typedef boost::unordered_map< sal_Int32, rtl::OUString > ObjIdToName; typedef boost::unordered_map< sal_Int32, OUString > ObjIdToName;
class OleIdToNameContainer : public OleIdToNameContainer_BASE class OleIdToNameContainer : public OleIdToNameContainer_BASE
{ {
...@@ -65,7 +63,7 @@ public: ...@@ -65,7 +63,7 @@ public:
virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
rtl::OUString sOleName; OUString sOleName;
if ( !( Element >>= sOleName ) ) if ( !( Element >>= sOleName ) )
throw IllegalArgumentException(); throw IllegalArgumentException();
ObjIdToNameHash[ Index ] = sOleName; ObjIdToNameHash[ Index ] = sOleName;
...@@ -83,7 +81,7 @@ public: ...@@ -83,7 +81,7 @@ public:
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
if ( !hasByIndex( Index ) ) if ( !hasByIndex( Index ) )
throw IndexOutOfBoundsException(); throw IndexOutOfBoundsException();
rtl::OUString sOleName; OUString sOleName;
if ( !( Element >>= sOleName ) ) if ( !( Element >>= sOleName ) )
throw IllegalArgumentException(); throw IllegalArgumentException();
ObjIdToNameHash[ Index ] = sOleName; ObjIdToNameHash[ Index ] = sOleName;
...@@ -104,7 +102,7 @@ public: ...@@ -104,7 +102,7 @@ public:
// XElementAccess Methods // XElementAccess Methods
virtual Type SAL_CALL getElementType( ) throw (RuntimeException) virtual Type SAL_CALL getElementType( ) throw (RuntimeException)
{ {
return ::getCppuType( static_cast< const ::rtl::OUString* >( 0 ) ); return ::getCppuType( static_cast< const OUString* >( 0 ) );
} }
virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException) virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException)
{ {
...@@ -216,7 +214,7 @@ void VbaModule::createEmptyModule( const Reference< container::XNameContainer >& ...@@ -216,7 +214,7 @@ void VbaModule::createEmptyModule( const Reference< container::XNameContainer >&
OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
{ {
OUStringBuffer aSourceCode; OUStringBuffer aSourceCode;
const static rtl::OUString sUnmatchedRemovedTag( RTL_CONSTASCII_USTRINGPARAM( "Rem removed unmatched Sub/End: " ) ); const static OUString sUnmatchedRemovedTag( "Rem removed unmatched Sub/End: " );
if( !maStreamName.isEmpty() && (mnOffset != SAL_MAX_UINT32) ) if( !maStreamName.isEmpty() && (mnOffset != SAL_MAX_UINT32) )
{ {
BinaryXInputStream aInStrm( rVbaStrg.openInputStream( maStreamName ), true ); BinaryXInputStream aInStrm( rVbaStrg.openInputStream( maStreamName ), true );
...@@ -241,7 +239,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const ...@@ -241,7 +239,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
while( !aVbaTextStrm.isEof() ) while( !aVbaTextStrm.isEof() )
{ {
OUString aCodeLine = aVbaTextStrm.readLine(); OUString aCodeLine = aVbaTextStrm.readLine();
if( aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) ) if( aCodeLine.match( "Attribute " ) )
{ {
// attribute // attribute
int index = aCodeLine.indexOf( ".VB_ProcData.VB_Invoke_Func = " ); int index = aCodeLine.indexOf( ".VB_ProcData.VB_Invoke_Func = " );
...@@ -254,15 +252,15 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const ...@@ -254,15 +252,15 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
// word doesn't store the shortcut in the module // word doesn't store the shortcut in the module
// attributes // attributes
int nSpaceIndex = aCodeLine.indexOf(' '); int nSpaceIndex = aCodeLine.indexOf(' ');
rtl::OUString sProc = aCodeLine.copy( nSpaceIndex + 1, index - nSpaceIndex - 1); OUString sProc = aCodeLine.copy( nSpaceIndex + 1, index - nSpaceIndex - 1);
// for Excel short cut key seems limited to cntrl+'a-z, A-Z' // for Excel short cut key seems limited to cntrl+'a-z, A-Z'
rtl::OUString sKey = aCodeLine.copy( aCodeLine.lastIndexOf("= ") + 3, 1 ); OUString sKey = aCodeLine.copy( aCodeLine.lastIndexOf("= ") + 3, 1 );
// only alpha key valid for key shortcut, however the api will accept other keys // only alpha key valid for key shortcut, however the api will accept other keys
if ( !isalpha( (char)sKey[ 0 ] ) ) if ( !isalpha( (char)sKey[ 0 ] ) )
{ {
// cntrl modifier is explicit ( but could be cntrl+shift ), parseKeyEvent // cntrl modifier is explicit ( but could be cntrl+shift ), parseKeyEvent
// will handle and uppercase letter appropriately // will handle and uppercase letter appropriately
rtl::OUString sApiKey = "^"; OUString sApiKey = "^";
sApiKey += sKey; sApiKey += sKey;
try try
{ {
...@@ -281,12 +279,12 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const ...@@ -281,12 +279,12 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
// The behaviour of the vba ide practically guarantees the case and // The behaviour of the vba ide practically guarantees the case and
// spacing of Sub statement(s). However, indentation can be arbitrary hence // spacing of Sub statement(s). However, indentation can be arbitrary hence
// the trim. // the trim.
rtl::OUString trimLine( aCodeLine.trim() ); OUString trimLine( aCodeLine.trim() );
if ( mbExecutable && ( if ( mbExecutable && (
trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Sub ") ) || trimLine.match("Sub ") ||
trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Public Sub ") ) || trimLine.match("Public Sub ") ||
trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Private Sub ") ) || trimLine.match("Private Sub ") ||
trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Static Sub ") ) ) ) trimLine.match("Static Sub ") ) )
{ {
// this should never happen, basic doesn't support nested procedures // this should never happen, basic doesn't support nested procedures
// first Sub Foo must be bogus // first Sub Foo must be bogus
...@@ -303,7 +301,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const ...@@ -303,7 +301,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
procInfo.nPos = aSourceCode.getLength(); procInfo.nPos = aSourceCode.getLength();
} }
} }
else if ( mbExecutable && aCodeLine.trim().matchAsciiL( RTL_CONSTASCII_STRINGPARAM("End Sub")) ) else if ( mbExecutable && aCodeLine.trim().match("End Sub") )
{ {
// un-matched End Sub // un-matched End Sub
if ( !procInfo.bInProcedure ) if ( !procInfo.bInProcedure )
...@@ -318,7 +316,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const ...@@ -318,7 +316,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
} }
// normal source code line // normal source code line
if( !mbExecutable ) if( !mbExecutable )
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) ); aSourceCode.appendAscii( "Rem " );
aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) ); aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) );
} }
} }
...@@ -338,22 +336,22 @@ void VbaModule::createModule( const OUString& rVBASourceCode, ...@@ -338,22 +336,22 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
script::ModuleInfo aModuleInfo; script::ModuleInfo aModuleInfo;
aModuleInfo.ModuleType = mnType; aModuleInfo.ModuleType = mnType;
OUStringBuffer aSourceCode; OUStringBuffer aSourceCode;
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) ); aSourceCode.appendAscii( "Rem Attribute VBA_ModuleType=" );
switch( mnType ) switch( mnType )
{ {
case script::ModuleType::NORMAL: case script::ModuleType::NORMAL:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) ); aSourceCode.appendAscii( "VBAModule" );
break; break;
case script::ModuleType::CLASS: case script::ModuleType::CLASS:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) ); aSourceCode.appendAscii( "VBAClassModule" );
break; break;
case script::ModuleType::FORM: case script::ModuleType::FORM:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAFormModule" ) ); aSourceCode.appendAscii( "VBAFormModule" );
// hack from old filter, document Basic should know the XModel, but it doesn't // hack from old filter, document Basic should know the XModel, but it doesn't
aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY ); aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY );
break; break;
case script::ModuleType::DOCUMENT: case script::ModuleType::DOCUMENT:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) ); aSourceCode.appendAscii( "VBADocumentModule" );
// get the VBA implementation object associated to the document module // get the VBA implementation object associated to the document module
if( rxDocObjectNA.is() ) try if( rxDocObjectNA.is() ) try
{ {
...@@ -364,19 +362,19 @@ void VbaModule::createModule( const OUString& rVBASourceCode, ...@@ -364,19 +362,19 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
} }
break; break;
default: default:
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAUnknown" ) ); aSourceCode.appendAscii( "VBAUnknown" );
} }
aSourceCode.append( sal_Unicode( '\n' ) ); aSourceCode.append( sal_Unicode( '\n' ) );
if( mbExecutable ) if( mbExecutable )
{ {
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) ); aSourceCode.appendAscii( "Option VBASupport 1\n" );
if( mnType == script::ModuleType::CLASS ) if( mnType == script::ModuleType::CLASS )
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) ); aSourceCode.appendAscii( "Option ClassModule\n" );
} }
else else
{ {
// add a subroutine named after the module itself // add a subroutine named after the module itself
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Sub " ) ). aSourceCode.appendAscii( "Sub " ).
append( maName.replace( ' ', '_' ) ).append( sal_Unicode( '\n' ) ); append( maName.replace( ' ', '_' ) ).append( sal_Unicode( '\n' ) );
} }
...@@ -385,7 +383,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode, ...@@ -385,7 +383,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
// close the subroutine named after the module // close the subroutine named after the module
if( !mbExecutable ) if( !mbExecutable )
aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) ); aSourceCode.appendAscii( "End Sub\n" );
// insert extended module info // insert extended module info
try try
......
...@@ -60,8 +60,6 @@ using namespace ::com::sun::star::script::vba; ...@@ -60,8 +60,6 @@ using namespace ::com::sun::star::script::vba;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using ::comphelper::ConfigurationHelper; using ::comphelper::ConfigurationHelper;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
// ============================================================================ // ============================================================================
...@@ -382,7 +380,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap ...@@ -382,7 +380,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) ) if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) )
{ {
sal_Int32 nType = ModuleType::UNKNOWN; sal_Int32 nType = ModuleType::UNKNOWN;
if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) ) if( aKey.equalsIgnoreAsciiCaseAscii( "Document" ) )
{ {
nType = ModuleType::DOCUMENT; nType = ModuleType::DOCUMENT;
// strip automation server version from module names // strip automation server version from module names
...@@ -390,11 +388,11 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap ...@@ -390,11 +388,11 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
if( nSlashPos >= 0 ) if( nSlashPos >= 0 )
aValue = aValue.copy( 0, nSlashPos ); aValue = aValue.copy( 0, nSlashPos );
} }
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAscii( "Module" ) )
nType = ModuleType::NORMAL; nType = ModuleType::NORMAL;
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAscii( "Class" ) )
nType = ModuleType::CLASS; nType = ModuleType::CLASS;
else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) ) else if( aKey.equalsIgnoreAsciiCaseAscii( "BaseClass" ) )
nType = ModuleType::FORM; nType = ModuleType::FORM;
if( (nType != ModuleType::UNKNOWN) && !aValue.isEmpty() ) if( (nType != ModuleType::UNKNOWN) && !aValue.isEmpty() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment