OUString cleanup in oox

Change-Id: Id3c121acddd515621325c93735bb3dd88592749e
Signed-off-by: José Guilherme Vanz <guilherme.sft@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/1485
Reviewed-by: Muthu Subramanian K <muthusuba@gmail.com>
Tested-by: Muthu Subramanian K <muthusuba@gmail.com>
diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx
index 9b660c0..1e4c626 100644
--- a/oox/source/ole/axbinaryreader.cxx
+++ b/oox/source/ole/axbinaryreader.cxx
@@ -26,10 +26,6 @@ namespace ole {

// ============================================================================

using ::rtl::OUString;

// ============================================================================

namespace {

const sal_uInt32 AX_STRING_SIZEMASK         = 0x7FFFFFFF;
@@ -218,7 +214,7 @@ void AxBinaryPropertyReader::readStringProperty( OUString& orValue )
    }
}

void AxBinaryPropertyReader::readGuidProperty( ::rtl::OUString& orGuid )
void AxBinaryPropertyReader::readGuidProperty( OUString& orGuid )
{
    if( startNextProperty() )
        maLargeProps.push_back( ComplexPropVector::value_type( new GuidProperty( orGuid ) ) );
diff --git a/oox/source/ole/axbinarywriter.cxx b/oox/source/ole/axbinarywriter.cxx
index e5ed29a..f8cbc0c1 100644
--- a/oox/source/ole/axbinarywriter.cxx
+++ b/oox/source/ole/axbinarywriter.cxx
@@ -34,10 +34,6 @@ namespace ole {

// ============================================================================

using ::rtl::OUString;

// ============================================================================

namespace {

const sal_uInt32 AX_STRING_SIZEMASK         = 0x7FFFFFFF;
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index b39b77a..7145083 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -558,11 +558,11 @@ void ControlConverter::convertToAxState( PropertySet& rPropSet,
    // control is awt or not )
    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 )
        rValue = rtl::OUString( '0' );
        rValue = OUString('0');
    else if ( nState == API_STATE_CHECKED )
        rValue = rtl::OUString( '1' );
        rValue = OUString('1');

    // tristate
    if( bSupportsTriState && rPropSet.getProperty( bTmp, PROP_TriState ) )
@@ -2414,16 +2414,16 @@ HtmlSelectModel::HtmlSelectModel()
bool
HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
{
    static String sMultiple( RTL_CONSTASCII_USTRINGPARAM("<SELECT MULTIPLE") );
    static String sSelected( RTL_CONSTASCII_USTRINGPARAM("OPTION SELECTED") );
    static OUString sMultiple( "<SELECT MULTIPLE" );
    static OUString sSelected( "OPTION SELECTED" );

    OUString sStringContents = rInStrm.readUnicodeArray( rInStrm.size() );

    String data = sStringContents;
    OUString data = sStringContents;

    // replace crlf with lf
    data.SearchAndReplaceAll( String( RTL_CONSTASCII_USTRINGPARAM( "\x0D\x0A" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "\x0A" ) ) );
    std::vector< rtl::OUString > listValues;
    data = data.replaceAll( "\x0D\x0A" , "\x0A" );
    std::vector< OUString > listValues;
    std::vector< sal_Int16 > selectedIndices;

    // Ultra hacky parser for the info
@@ -2431,10 +2431,10 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )

    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 ( sLine.CompareTo( sMultiple, sMultiple.Len() ) == COMPARE_EQUAL )
            if ( sLine == sMultiple )
                mnMultiSelect = true;
        }
        // skip first and last lines, no data there
@@ -2442,17 +2442,17 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
        {
            if ( comphelper::string::getTokenCount(sLine, '>') )
            {
                String displayValue  = sLine.GetToken( 1, '>' );
                if ( displayValue.Len() )
                OUString displayValue  = sLine.getToken( 1, '>' );
                if ( displayValue.getLength() )
                {
                    // Really we should be using a proper html parser
                    // escaping some common bits to be escaped
                    displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&lt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("<") ) );
                    displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&gt;" ) ), String( RTL_CONSTASCII_USTRINGPARAM(">") ) );
                    displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&quot;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("\"") ) );
                    displayValue.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "&amp;" ) ), String( RTL_CONSTASCII_USTRINGPARAM("&") ) );
                    displayValue = displayValue.replaceAll( "&lt;", "<" );
                    displayValue = displayValue.replaceAll( "&gt;", ">" );
                    displayValue = displayValue.replaceAll( "&quot;", "\"" );
                    displayValue = displayValue.replaceAll( "&amp;", "&" );
                    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 );
                }
            }
@@ -2462,7 +2462,7 @@ HtmlSelectModel::importBinaryModel( BinaryInputStream& rInStrm )
    {
        msListData.realloc( listValues.size() );
        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;
    }
    if ( !selectedIndices.empty() )
@@ -2497,7 +2497,7 @@ HtmlTextBoxModel::importBinaryModel( BinaryInputStream& rInStrm )
    // in msocximex ( where this is ported from, it appears *nothing* is read
    // from the control stream ), surely there is some useful info there ?
    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
    (void) rInStrm;
#endif
diff --git a/oox/source/ole/axcontrolfragment.cxx b/oox/source/ole/axcontrolfragment.cxx
index 6126a16..af93537 100644
--- a/oox/source/ole/axcontrolfragment.cxx
+++ b/oox/source/ole/axcontrolfragment.cxx
@@ -38,7 +38,6 @@ using ::oox::core::ContextHandler2;
using ::oox::core::ContextHandlerRef;
using ::oox::core::FragmentHandler2;
using ::oox::core::XmlFilterBase;
using ::rtl::OUString;

// ============================================================================

diff --git a/oox/source/ole/axfontdata.cxx b/oox/source/ole/axfontdata.cxx
index c2eac7a..d2ccd39 100644
--- a/oox/source/ole/axfontdata.cxx
+++ b/oox/source/ole/axfontdata.cxx
@@ -25,8 +25,6 @@
namespace oox {
namespace ole {

using ::rtl::OUString;

// ============================================================================

AxFontData::AxFontData() :
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx
index 4307981..91dd7f3 100644
--- a/oox/source/ole/olehelper.cxx
+++ b/oox/source/ole/olehelper.cxx
@@ -46,9 +46,6 @@ namespace ole {

// ============================================================================

using ::rtl::OUString;
using ::rtl::OUStringBuffer;

using ::com::sun::star::form::XFormComponent;
using ::com::sun::star::form::XForm;
using ::com::sun::star::awt::XControlModel;
@@ -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 ) :
    maName( rName ),
    mnHeight( nHeight ),
@@ -361,22 +358,22 @@ class OleFormCtrlExportHelper
    Reference< XModel > mxDocModel;
    Reference< XControlModel > mxControlModel;

    ::rtl::OUString maName;
    ::rtl::OUString maTypeName;
    ::rtl::OUString maFullName;
    ::rtl::OUString maGUID;
    OUString maName;
    OUString maTypeName;
    OUString maFullName;
    OUString maGUID;
public:
    OleFormCtrlExportHelper( const Reference< XComponentContext >& rxCtx, const Reference< XModel >& xDocModel, const Reference< XControlModel >& xModel );
    virtual ~OleFormCtrlExportHelper() { }
    virtual ::rtl::OUString getGUID()
    virtual OUString getGUID()
    {
        rtl::OUString sResult;
        OUString sResult;
        if ( maGUID.getLength() > 2 )
            sResult = maGUID.copy(1, maGUID.getLength() - 2 );
        return sResult;
    }
    ::rtl::OUString getFullName() { return maFullName; }
    ::rtl::OUString getTypeName() { return maTypeName; }
    OUString getFullName() { return maFullName; }
    OUString getTypeName() { return maTypeName; }
    bool isValid() { return mpModel != NULL; }
    void exportName( const Reference< XOutputStream >& rxOut );
    void exportCompObj( const Reference< XOutputStream >& rxOut );
@@ -475,7 +472,7 @@ MSConvertOCXControls::~MSConvertOCXControls()
}

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" ) );
    if( ::oox::ole::ControlModelBase* pModel = aControl.createModelFromGuid( rGuidString  ) )
@@ -504,7 +501,7 @@ MSConvertOCXControls::ReadOCXCtlsStream( SotStorageStreamRef& rSrc1, Reference< 
    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)
{
    if ( !rInStrm.isEof() )
@@ -575,7 +572,7 @@ sal_Bool MSConvertOCXControls::ReadOCXStorage( SotStorageRef& xOleStg,

sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxModel, SotStorageRef &xOleStg,
    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;

@@ -584,10 +581,10 @@ sal_Bool MSConvertOCXControls::WriteOCXStream( const Reference< XModel >& rxMode
    if ( !exportHelper.isValid() )
        return sal_False;

    rtl::OUString sId = exportHelper.getGUID();
    OUString sId = exportHelper.getGUID();
    aName.MakeId(sId);

    rtl::OUString sFullName = exportHelper.getFullName();
    OUString sFullName = exportHelper.getFullName();
    rName = exportHelper.getTypeName();
    xOleStg->SetClass( aName,0x5C,sFullName);
    {
@@ -632,14 +629,14 @@ const Reference< XIndexContainer >&
            Reference< XNameContainer >  xNameCont =
                xFormsSupplier->getForms();

            rtl::OUString sStdName = CREATE_OUSTRING( "WW-Standard" );
            rtl::OUString sName( sStdName );
            OUString sStdName = CREATE_OUSTRING( "WW-Standard" );
            OUString sName( sStdName );
            sal_uInt16 n = 0;

            while( xNameCont->hasByName( sName ) )
            {
                sName = sStdName;
                sName += rtl::OUString::valueOf(static_cast<sal_Int32>(++n));
                sName += OUString::valueOf(static_cast<sal_Int32>(++n));
            }

            const Reference< XMultiServiceFactory > &rServiceFactory
diff --git a/oox/source/ole/oleobjecthelper.cxx b/oox/source/ole/oleobjecthelper.cxx
index cc529f0..382ceee 100644
--- a/oox/source/ole/oleobjecthelper.cxx
+++ b/oox/source/ole/oleobjecthelper.cxx
@@ -41,8 +41,6 @@ using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;

using ::rtl::OUString;

// ============================================================================

OleObjectInfo::OleObjectInfo() :
diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx
index 3b71dda..26b16a1 100644
--- a/oox/source/ole/olestorage.cxx
+++ b/oox/source/ole/olestorage.cxx
@@ -47,8 +47,6 @@ using namespace ::com::sun::star::io;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;

using ::rtl::OUString;

// ============================================================================

namespace {
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 607b8e6..56c8cbb 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -779,12 +779,12 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib,
    while( !bExitLoop && !aFrameTextStrm.isEof() )
    {
        aLine = aFrameTextStrm.readLine().trim();
        bExitLoop = aLine.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "End" ) );
        bExitLoop = aLine.equalsIgnoreAsciiCaseAscii( "End" );
        if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) )
        {
            if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Caption" ) ) )
            if( aKey.equalsIgnoreAsciiCaseAscii( "Caption" ) )
                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 ) );
        }
    }
diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx
index 1b13c2f..1681f2ba 100644
--- a/oox/source/ole/vbahelper.cxx
+++ b/oox/source/ole/vbahelper.cxx
@@ -28,9 +28,6 @@ namespace ole {

using namespace ::com::sun::star::uno;

using ::rtl::OUString;
using ::rtl::OUStringBuffer;

// ============================================================================

/*static*/ bool VbaHelper::readDirRecord( sal_uInt16& rnRecId, StreamDataSequence& rRecData, BinaryInputStream& rInStrm )
diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx
index 1a404de..b5e4e1c 100644
--- a/oox/source/ole/vbamodule.cxx
+++ b/oox/source/ole/vbamodule.cxx
@@ -43,12 +43,10 @@ using namespace ::com::sun::star::script::vba;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;

using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::com::sun::star::awt::KeyEvent;
// ============================================================================
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
{
@@ -65,7 +63,7 @@ public:
    virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
    {
        ::osl::MutexGuard aGuard( m_aMutex );
        rtl::OUString sOleName;
        OUString sOleName;
        if ( !( Element >>= sOleName ) )
            throw IllegalArgumentException();
        ObjIdToNameHash[ Index ] = sOleName;
@@ -83,7 +81,7 @@ public:
        ::osl::MutexGuard aGuard( m_aMutex );
        if ( !hasByIndex( Index ) )
            throw IndexOutOfBoundsException();
        rtl::OUString sOleName;
        OUString sOleName;
        if ( !( Element >>= sOleName ) )
            throw IllegalArgumentException();
        ObjIdToNameHash[ Index ] = sOleName;
@@ -104,7 +102,7 @@ public:
    // XElementAccess Methods
    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)
    {
@@ -216,7 +214,7 @@ void VbaModule::createEmptyModule( const Reference< container::XNameContainer >&
OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
{
    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) )
    {
        BinaryXInputStream aInStrm( rVbaStrg.openInputStream( maStreamName ), true );
@@ -241,7 +239,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
            while( !aVbaTextStrm.isEof() )
            {
                OUString aCodeLine = aVbaTextStrm.readLine();
                if( aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) )
                if( aCodeLine.match( "Attribute " ) )
                {
                    // attribute
                    int index = aCodeLine.indexOf( ".VB_ProcData.VB_Invoke_Func = " );
@@ -254,15 +252,15 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
                        // word doesn't store the shortcut in the module
                        // attributes
                        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'
                        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
                        if ( !isalpha( (char)sKey[ 0 ] ) )
                        {
                            // cntrl modifier is explicit ( but could be cntrl+shift ), parseKeyEvent
                            // will handle and uppercase letter appropriately
                            rtl::OUString sApiKey = "^";
                            OUString sApiKey = "^";
                            sApiKey += sKey;
                            try
                            {
@@ -281,12 +279,12 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
                    // The behaviour of the vba ide practically guarantees the case and
                    // spacing of Sub statement(s). However, indentation can be arbitrary hence
                    // the trim.
                    rtl::OUString trimLine( aCodeLine.trim() );
                    OUString trimLine( aCodeLine.trim() );
                    if ( mbExecutable && (
                      trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Sub ") )         ||
                      trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Public Sub ") )  ||
                      trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Private Sub ") ) ||
                      trimLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("Static Sub ") ) ) )
                      trimLine.match("Sub ")         ||
                      trimLine.match("Public Sub ")  ||
                      trimLine.match("Private Sub ") ||
                      trimLine.match("Static Sub ") ) )
                    {
                        // this should never happen, basic doesn't support nested procedures
                        // first Sub Foo must be bogus
@@ -303,7 +301,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
                            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
                        if ( !procInfo.bInProcedure )
@@ -318,7 +316,7 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const
                    }
                    // normal source code line
                    if( !mbExecutable )
                        aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) );
                        aSourceCode.appendAscii( "Rem " );
                    aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) );
                }
            }
@@ -338,22 +336,22 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
    script::ModuleInfo aModuleInfo;
    aModuleInfo.ModuleType = mnType;
    OUStringBuffer aSourceCode;
    aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem Attribute VBA_ModuleType=" ) );
    aSourceCode.appendAscii( "Rem Attribute VBA_ModuleType=" );
    switch( mnType )
    {
        case script::ModuleType::NORMAL:
            aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAModule" ) );
            aSourceCode.appendAscii( "VBAModule" );
        break;
        case script::ModuleType::CLASS:
            aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAClassModule" ) );
            aSourceCode.appendAscii( "VBAClassModule" );
        break;
        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
            aModuleInfo.ModuleObject.set( mxDocModel, UNO_QUERY );
        break;
        case script::ModuleType::DOCUMENT:
            aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBADocumentModule" ) );
            aSourceCode.appendAscii( "VBADocumentModule" );
            // get the VBA implementation object associated to the document module
            if( rxDocObjectNA.is() ) try
            {
@@ -364,19 +362,19 @@ void VbaModule::createModule( const OUString& rVBASourceCode,
            }
        break;
        default:
            aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "VBAUnknown" ) );
            aSourceCode.appendAscii( "VBAUnknown" );
    }
    aSourceCode.append( sal_Unicode( '\n' ) );
    if( mbExecutable )
    {
        aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option VBASupport 1\n" ) );
        aSourceCode.appendAscii( "Option VBASupport 1\n" );
        if( mnType == script::ModuleType::CLASS )
            aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Option ClassModule\n" ) );
            aSourceCode.appendAscii( "Option ClassModule\n" );
    }
    else
    {
        // add a subroutine named after the module itself
        aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Sub " ) ).
        aSourceCode.appendAscii( "Sub " ).
            append( maName.replace( ' ', '_' ) ).append( sal_Unicode( '\n' ) );
    }

@@ -385,7 +383,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode,

    // close the subroutine named after the module
    if( !mbExecutable )
        aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End Sub\n" ) );
        aSourceCode.appendAscii( "End Sub\n" );

    // insert extended module info
    try
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index 9498c9f..f6a42a2 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -60,8 +60,6 @@ using namespace ::com::sun::star::script::vba;
using namespace ::com::sun::star::uno;

using ::comphelper::ConfigurationHelper;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;

// ============================================================================

@@ -382,7 +380,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
            if( !bExitLoop && VbaHelper::extractKeyValue( aKey, aValue, aLine ) )
            {
                sal_Int32 nType = ModuleType::UNKNOWN;
                if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Document" ) ) )
                if( aKey.equalsIgnoreAsciiCaseAscii( "Document" ) )
                {
                    nType = ModuleType::DOCUMENT;
                    // strip automation server version from module names
@@ -390,11 +388,11 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap
                    if( nSlashPos >= 0 )
                        aValue = aValue.copy( 0, nSlashPos );
                }
                else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Module" ) ) )
                else if( aKey.equalsIgnoreAsciiCaseAscii( "Module" ) )
                    nType = ModuleType::NORMAL;
                else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Class" ) ) )
                else if( aKey.equalsIgnoreAsciiCaseAscii( "Class" ) )
                    nType = ModuleType::CLASS;
                else if( aKey.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "BaseClass" ) ) )
                else if( aKey.equalsIgnoreAsciiCaseAscii( "BaseClass" ) )
                    nType = ModuleType::FORM;

                if( (nType != ModuleType::UNKNOWN) && !aValue.isEmpty() )