View | Details | Raw Unified | Return to issue 113048
Collapse All | Expand All

(-)a/oox/inc/oox/helper/containerhelper.hxx (+14 lines)
Lines 124-129 Link Here
124
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
124
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
125
                        }
125
                        }
126
126
127
    /** Calls the passed member function of ObjType on every contained object,
128
        automatically skips all elements that are empty references. */
129
    template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3, typename ParamType4 >
130
    inline void         forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3, ParamType4 aParam4 ) const
131
                        {
132
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3, aParam4 ) );
133
                        }
127
    /** Calls the passed functor for every contained object. Passes the index as
134
    /** Calls the passed functor for every contained object. Passes the index as
128
        first argument and the object reference as second argument to rFunctor. */
135
        first argument and the object reference as second argument to rFunctor. */
129
    template< typename FunctorType >
136
    template< typename FunctorType >
Lines 280-285 Link Here
280
    inline void         forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
287
    inline void         forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3 ) const
281
                        {
288
                        {
282
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
289
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3 ) );
290
                        }
291
    /** Calls the passed member function of ObjType on every contained object,
292
        automatically skips all elements that are empty references. */
293
    template< typename FuncType, typename ParamType1, typename ParamType2, typename ParamType3, typename ParamType4 >
294
    inline void         forEachMem( FuncType pFunc, ParamType1 aParam1, ParamType2 aParam2, ParamType3 aParam3, ParamType4 aParam4 ) const
295
                        {
296
                            forEach( ::boost::bind( pFunc, _1, aParam1, aParam2, aParam3, aParam4 ) );
283
                        }
297
                        }
284
    /** Calls the passed functor for every contained object. Passes the key as
298
    /** Calls the passed functor for every contained object. Passes the key as
285
        first argument and the object reference as second argument to rFunctor. */
299
        first argument and the object reference as second argument to rFunctor. */
(-)a/oox/inc/oox/ole/vbamodule.hxx (-1 / +3 lines)
Lines 72-84 Link Here
72
    void                importSourceCode(
72
    void                importSourceCode(
73
                            StorageBase& rVbaStrg,
73
                            StorageBase& rVbaStrg,
74
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
74
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
75
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
75
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleNameOverrides ) const;
76
76
77
    /** Creates empty document module for the passed Basic library/project. */
77
    /** Creates empty document module for the passed Basic library/project. */
78
    void                createEmptyDocModule(
78
    void                createEmptyDocModule(
79
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
79
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
80
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
80
                            const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& rxDocObjectNA ) const;
81
private:
81
private:
82
    void extractOleOverrideFromAttr( const rtl::OUString& rAttribute, 
83
                                     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxOleNameOverrides ) const;
82
    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
84
    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
83
                        mxDocModel;         /// Document model used to import/export the VBA project.
85
                        mxDocModel;         /// Document model used to import/export the VBA project.
84
    ::rtl::OUString     maName;
86
    ::rtl::OUString     maName;
(-)a/oox/inc/oox/ole/vbaproject.hxx (-1 / +3 lines)
Lines 248-254 Link Here
248
                            const ::rtl::OUString& rProxyArgs,
248
                            const ::rtl::OUString& rProxyArgs,
249
                            const ::rtl::OUString& rProxyType,
249
                            const ::rtl::OUString& rProxyType,
250
                            const ::rtl::OUString& rProxyCode );
250
                            const ::rtl::OUString& rProxyCode );
251
251
    void                setOleOverridesSink( ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >&  rxOleOverridesSink ){ mxOleOverridesSink = rxOleOverridesSink; }
252
private:
252
private:
253
                        VbaProject( const VbaProject& );
253
                        VbaProject( const VbaProject& );
254
    VbaProject&         operator=( const VbaProject& );
254
    VbaProject&         operator=( const VbaProject& );
Lines 279-284 Link Here
279
                        mxBasicLib;         /// The Basic library of the document used for import.
279
                        mxBasicLib;         /// The Basic library of the document used for import.
280
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
280
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
281
                        mxDialogLib;        /// The dialog library of the document used for import.
281
                        mxDialogLib;        /// The dialog library of the document used for import.
282
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
283
                        mxOleOverridesSink;
282
    ::rtl::OUString     maPrjName;        /// Name of VBA project being imported
284
    ::rtl::OUString     maPrjName;        /// Name of VBA project being imported
283
};
285
};
284
286
(-)a/oox/source/ole/vbamodule.cxx (-1 / +105 lines)
Lines 27-32 Link Here
27
27
28
#include "oox/ole/vbamodule.hxx"
28
#include "oox/ole/vbamodule.hxx"
29
#include <com/sun/star/container/XNameContainer.hpp>
29
#include <com/sun/star/container/XNameContainer.hpp>
30
#include <com/sun/star/container/XIndexContainer.hpp>
30
#include <com/sun/star/script/ModuleInfo.hpp>
31
#include <com/sun/star/script/ModuleInfo.hpp>
31
#include <com/sun/star/script/ModuleType.hpp>
32
#include <com/sun/star/script/ModuleType.hpp>
32
#include <com/sun/star/script/XVBAModuleInfo.hpp>
33
#include <com/sun/star/script/XVBAModuleInfo.hpp>
Lines 35-51 Link Here
35
#include "oox/helper/textinputstream.hxx"
36
#include "oox/helper/textinputstream.hxx"
36
#include "oox/ole/vbahelper.hxx"
37
#include "oox/ole/vbahelper.hxx"
37
#include "oox/ole/vbainputstream.hxx"
38
#include "oox/ole/vbainputstream.hxx"
39
#include <hash_map>
40
#include <cppuhelper/implbase1.hxx>
38
41
39
using ::rtl::OUString;
42
using ::rtl::OUString;
40
using ::rtl::OUStringBuffer;
43
using ::rtl::OUStringBuffer;
41
using ::com::sun::star::container::XNameAccess;
44
using ::com::sun::star::container::XNameAccess;
42
using ::com::sun::star::container::XNameContainer;
45
using ::com::sun::star::container::XNameContainer;
46
using ::com::sun::star::container::XIndexContainer;
47
using ::com::sun::star::container::ElementExistException;
48
using ::com::sun::star::container::NoSuchElementException;
49
using ::com::sun::star::lang::IndexOutOfBoundsException;
50
using ::com::sun::star::lang::WrappedTargetException;
51
using ::com::sun::star::lang::IllegalArgumentException;
43
using ::com::sun::star::frame::XModel;
52
using ::com::sun::star::frame::XModel;
44
using ::com::sun::star::script::ModuleInfo;
53
using ::com::sun::star::script::ModuleInfo;
45
using ::com::sun::star::script::XVBAModuleInfo;
54
using ::com::sun::star::script::XVBAModuleInfo;
46
using ::com::sun::star::uno::Any;
55
using ::com::sun::star::uno::Any;
56
using ::com::sun::star::uno::Type;
57
using ::com::sun::star::uno::makeAny;
47
using ::com::sun::star::uno::Exception;
58
using ::com::sun::star::uno::Exception;
48
using ::com::sun::star::uno::Reference;
59
using ::com::sun::star::uno::Reference;
60
using ::com::sun::star::uno::RuntimeException;
49
using ::com::sun::star::uno::UNO_QUERY;
61
using ::com::sun::star::uno::UNO_QUERY;
50
using ::com::sun::star::uno::UNO_QUERY_THROW;
62
using ::com::sun::star::uno::UNO_QUERY_THROW;
51
63
Lines 55-60 Link Here
55
namespace ole {
67
namespace ole {
56
68
57
// ============================================================================
69
// ============================================================================
70
typedef ::cppu::WeakImplHelper1< XIndexContainer > OleIdToNameContainer_BASE;
71
typedef std::hash_map< sal_Int32, rtl::OUString >  ObjIdToName;
72
class OleIdToNameContainer : public OleIdToNameContainer_BASE
73
{
74
    ObjIdToName ObjIdToNameHash;
75
    ::osl::Mutex m_aMutex;
76
    bool hasByIndex( ::sal_Int32 Index )
77
    {
78
        ::osl::MutexGuard aGuard( m_aMutex );
79
        return ( ObjIdToNameHash.find( Index ) != ObjIdToNameHash.end() );
80
    }
81
public:
82
    OleIdToNameContainer() {}
83
    // XIndexContainer Methods
84
    virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
85
    {
86
        ::osl::MutexGuard aGuard( m_aMutex );
87
        rtl::OUString sOleName;
88
        if ( !( Element >>= sOleName ) )
89
            throw IllegalArgumentException();
90
        ObjIdToNameHash[ Index ] = sOleName;
91
    }
92
    virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
93
    {
94
        ::osl::MutexGuard aGuard( m_aMutex );
95
        if ( !hasByIndex( Index ) )
96
            throw IndexOutOfBoundsException();
97
        ObjIdToNameHash.erase( ObjIdToNameHash.find( Index ) );
98
    }
99
    // XIndexReplace Methods
100
    virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
101
    {
102
        ::osl::MutexGuard aGuard( m_aMutex );
103
        if ( !hasByIndex( Index ) )
104
            throw IndexOutOfBoundsException();
105
        rtl::OUString sOleName;
106
        if ( !( Element >>= sOleName ) )
107
            throw IllegalArgumentException();
108
        ObjIdToNameHash[ Index ] = sOleName;
109
    }
110
    // XIndexAccess Methods
111
    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (RuntimeException)
112
    {
113
        ::osl::MutexGuard aGuard( m_aMutex );
114
        return ObjIdToNameHash.size();
115
    }
116
    virtual Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
117
    {
118
        ::osl::MutexGuard aGuard( m_aMutex );
119
        if ( !hasByIndex( Index ) )
120
            throw IndexOutOfBoundsException();
121
        return makeAny( ObjIdToNameHash[ Index ] );
122
    }
123
    // XElementAccess Methods
124
    virtual Type SAL_CALL getElementType(  ) throw (RuntimeException)
125
    {
126
        return ::getCppuType((const ::rtl::OUString*)(NULL) );
127
    }
128
    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (RuntimeException)
129
    {
130
        ::osl::MutexGuard aGuard( m_aMutex );
131
        return ( getCount() > 0 );
132
    }
133
};
58
134
59
VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rName, rtl_TextEncoding eTextEnc, bool bExecutable ) :
135
VbaModule::VbaModule( const Reference< XModel >& rxDocModel, const OUString& rName, rtl_TextEncoding eTextEnc, bool bExecutable ) :
60
    mxDocModel( rxDocModel ),
136
    mxDocModel( rxDocModel ),
Lines 134-141 Link Here
134
    OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" );
210
    OSL_ENSURE( mnOffset < SAL_MAX_UINT32, "VbaModule::importDirRecords - missing module stream offset" );
135
}
211
}
136
212
213
void VbaModule::extractOleOverrideFromAttr( const rtl::OUString& rAttribute,
214
                                            const Reference< XNameContainer >& rxOleNameOverrides ) const
215
{
216
    // format of the attribute we are interested in is
217
    // Attribute VB_Control = "ControlName", intString, MSForms, ControlTypeAsString
218
    // e.g.
219
    // Attribute VB_Control = "CommandButton1, 201, 19, MSForms, CommandButton"
220
    rtl::OUString sControlAttribute( RTL_CONSTASCII_USTRINGPARAM("Attribute VB_Control = \"") );
221
    if ( rxOleNameOverrides.is() && rAttribute.indexOf( sControlAttribute ) !=  -1 )
222
    {
223
        rtl::OUString sRest = rAttribute.copy( sControlAttribute.getLength() );
224
        sal_Int32 nPos = sRest.indexOf( ',' );
225
        rtl::OUString sCntrlName = sRest.copy( 0, nPos );
226
        
227
        sal_Int32 nCntrlId = sRest.copy( nPos + 1 ).copy( 0, sRest.indexOf( ',', nPos + 1) ).toInt32();
228
        OSL_TRACE("In module %s, assiging %d controlname %s", 
229
            rtl::OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ).getStr(), nCntrlId,
230
            rtl::OUStringToOString( sCntrlName, RTL_TEXTENCODING_UTF8 ).getStr() );
231
        if ( !rxOleNameOverrides->hasByName( maName ) )
232
            rxOleNameOverrides->insertByName( maName, makeAny( Reference< XIndexContainer> ( new OleIdToNameContainer() ) ) );
233
        Reference< XIndexContainer > xIdToOleName;
234
        if ( rxOleNameOverrides->getByName( maName ) >>= xIdToOleName )
235
            xIdToOleName->insertByIndex( nCntrlId, makeAny( sCntrlName ) );
236
    }
237
}
238
137
void VbaModule::importSourceCode( StorageBase& rVbaStrg,
239
void VbaModule::importSourceCode( StorageBase& rVbaStrg,
138
        const Reference< XNameContainer >& rxBasicLib, const Reference< XNameAccess >& rxDocObjectNA ) const
240
        const Reference< XNameContainer >& rxBasicLib, const Reference< XNameAccess >& rxDocObjectNA,  const Reference< XNameContainer >& rxOleNameOverrides ) const
139
{
241
{
140
    if( (maName.getLength() == 0) || (maStreamName.getLength() == 0) || (mnOffset == SAL_MAX_UINT32) )
242
    if( (maName.getLength() == 0) || (maStreamName.getLength() == 0) || (mnOffset == SAL_MAX_UINT32) )
141
        return;
243
        return;
Lines 208-213 Link Here
208
                aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) );
310
                aSourceCode.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Rem " ) );
209
            aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) );
311
            aSourceCode.append( aCodeLine ).append( sal_Unicode( '\n' ) );
210
        }
312
        }
313
        else
314
            extractOleOverrideFromAttr( aCodeLine, rxOleNameOverrides );
211
    }
315
    }
212
316
213
    // close the subroutine named after the module
317
    // close the subroutine named after the module
(-)a/oox/source/ole/vbaproject.cxx (-1 / +1 lines)
Lines 473-479 Link Here
473
            aGeneratedModules.forEachMem( &VbaModule::createEmptyDocModule,
473
            aGeneratedModules.forEachMem( &VbaModule::createEmptyDocModule,
474
                ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ) );
474
                ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ) );
475
            aModules.forEachMem( &VbaModule::importSourceCode,
475
            aModules.forEachMem( &VbaModule::importSourceCode,
476
                ::boost::ref( *xVbaStrg ), ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ) );
476
                ::boost::ref( *xVbaStrg ), ::boost::cref( xBasicLib ), ::boost::cref( xDocObjectNA ), ::boost::cref( mxOleOverridesSink ) );
477
        }
477
        }
478
    }
478
    }
479
    catch( Exception& )
479
    catch( Exception& )
(-)a/oox/source/xls/excelfilter.cxx (+5 lines)
Lines 35-40 Link Here
35
#include "oox/xls/workbookfragment.hxx"
35
#include "oox/xls/workbookfragment.hxx"
36
#include "oox/dump/biffdumper.hxx"
36
#include "oox/dump/biffdumper.hxx"
37
#include "oox/dump/xlsbdumper.hxx"
37
#include "oox/dump/xlsbdumper.hxx"
38
#include <com/sun/star/container/XNameContainer.hpp>
38
39
39
using ::rtl::OUString;
40
using ::rtl::OUString;
40
using ::com::sun::star::uno::Any;
41
using ::com::sun::star::uno::Any;
Lines 42-47 Link Here
42
using ::com::sun::star::uno::Sequence;
43
using ::com::sun::star::uno::Sequence;
43
using ::com::sun::star::uno::Exception;
44
using ::com::sun::star::uno::Exception;
44
using ::com::sun::star::uno::XInterface;
45
using ::com::sun::star::uno::XInterface;
46
using ::com::sun::star::container::XNameContainer;
45
using ::com::sun::star::lang::XMultiServiceFactory;
47
using ::com::sun::star::lang::XMultiServiceFactory;
46
using ::com::sun::star::xml::sax::XFastDocumentHandler;
48
using ::com::sun::star::xml::sax::XFastDocumentHandler;
47
using ::oox::core::BinaryFilterBase;
49
using ::oox::core::BinaryFilterBase;
Lines 278-288 Link Here
278
    {
280
    {
279
        Sequence< rtl::OUString > sGeneratedCNames;
281
        Sequence< rtl::OUString > sGeneratedCNames;
280
        getArgument( CREATE_OUSTRING( "GeneratedCodeNames" ) ) >>= sGeneratedCNames;
282
        getArgument( CREATE_OUSTRING( "GeneratedCodeNames" ) ) >>= sGeneratedCNames;
283
        Reference< XNameContainer > xOleNameOverrideSink;
284
        getArgument( CREATE_OUSTRING( "OleNameOverrideInfo" ) ) >>= xOleNameOverrideSink;
281
        WorkbookHelperRoot aHelper( *this, eBiff );
285
        WorkbookHelperRoot aHelper( *this, eBiff );
282
        StorageRef xVbaPrjStrg = openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false )    ;
286
        StorageRef xVbaPrjStrg = openSubStorage( CREATE_OUSTRING( "_VBA_PROJECT_CUR" ), false )    ;
283
        if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
287
        if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() )
284
        {
288
        {
285
            VbaProject aVbaProject( getGlobalFactory(), aHelper.getDocument() );
289
            VbaProject aVbaProject( getGlobalFactory(), aHelper.getDocument() );
290
            aVbaProject.setOleOverridesSink( xOleNameOverrideSink );
286
            aVbaProject.importVbaProject( *xVbaPrjStrg, getGraphicHelper(), sGeneratedCNames );
291
            aVbaProject.importVbaProject( *xVbaPrjStrg, getGraphicHelper(), sGeneratedCNames );
287
            bRet = true;
292
            bRet = true;
288
        }
293
        }
(-)a/sc/source/filter/excel/excimp8.cxx (-1 / +86 lines)
Lines 102-107 Link Here
102
#include <basic/basmgr.hxx>
102
#include <basic/basmgr.hxx>
103
#include <cppuhelper/component_context.hxx>
103
#include <cppuhelper/component_context.hxx>
104
#include <com/sun/star/container/XNameContainer.hpp>
104
#include <com/sun/star/container/XNameContainer.hpp>
105
#include <com/sun/star/container/XIndexContainer.hpp>
105
#include <sfx2/app.hxx>
106
#include <sfx2/app.hxx>
106
#include <com/sun/star/document/XFilter.hpp>
107
#include <com/sun/star/document/XFilter.hpp>
107
#include <com/sun/star/document/XImporter.hpp>
108
#include <com/sun/star/document/XImporter.hpp>
Lines 115-120 Link Here
115
116
116
117
117
118
119
//OleNameOverrideContainer
120
121
typedef ::cppu::WeakImplHelper1< container::XNameContainer > OleNameOverrideContainer_BASE;
122
123
class OleNameOverrideContainer : public OleNameOverrideContainer_BASE
124
{
125
private:
126
    typedef std::hash_map< rtl::OUString, uno::Reference< container::XIndexContainer >, ::rtl::OUStringHash,
127
       ::std::equal_to< ::rtl::OUString > > NamedIndexToOleName;
128
    NamedIndexToOleName  IdToOleNameHash;
129
    ::osl::Mutex m_aMutex;
130
public:
131
    // XElementAccess
132
    virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException) { return  container::XIndexContainer::static_type(0); }
133
    virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException) 
134
    { 
135
        ::osl::MutexGuard aGuard( m_aMutex );
136
        return ( IdToOleNameHash.size() > 0 ); 
137
    }
138
    // XNameAcess 
139
    virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
140
    {
141
        ::osl::MutexGuard aGuard( m_aMutex );
142
        if ( !hasByName(aName) )
143
            throw container::NoSuchElementException();
144
        return uno::makeAny( IdToOleNameHash[ aName ] );
145
    }
146
    virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
147
    {
148
        ::osl::MutexGuard aGuard( m_aMutex );
149
        uno::Sequence< ::rtl::OUString > aResult( IdToOleNameHash.size() );
150
        NamedIndexToOleName::iterator it = IdToOleNameHash.begin();
151
        NamedIndexToOleName::iterator it_end = IdToOleNameHash.end();
152
        rtl::OUString* pName = aResult.getArray();
153
        for (; it != it_end; ++it, ++pName )
154
            *pName = it->first; 
155
        return aResult;
156
    }
157
    virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
158
    {
159
        ::osl::MutexGuard aGuard( m_aMutex );
160
        return ( IdToOleNameHash.find( aName ) != IdToOleNameHash.end() );        
161
    }
162
163
    // XElementAccess
164
    virtual ::sal_Int32 SAL_CALL getCount(  ) throw (uno::RuntimeException) 
165
    { 
166
        ::osl::MutexGuard aGuard( m_aMutex );
167
        return IdToOleNameHash.size(); 
168
    }	
169
    // XNameContainer
170
    virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException)
171
    {
172
        ::osl::MutexGuard aGuard( m_aMutex );
173
        if ( hasByName( aName ) )
174
            throw container::ElementExistException();
175
        uno::Reference< container::XIndexContainer > xElement;
176
        if ( ! ( aElement >>= xElement ) )
177
            throw lang::IllegalArgumentException(); 
178
       IdToOleNameHash[ aName ] = xElement;
179
    }
180
    virtual void SAL_CALL removeByName( const ::rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
181
    {
182
        ::osl::MutexGuard aGuard( m_aMutex );
183
        if ( !hasByName( aName ) )
184
            throw container::NoSuchElementException(); 
185
        IdToOleNameHash.erase( IdToOleNameHash.find( aName ) );
186
    }
187
    virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
188
    {
189
        ::osl::MutexGuard aGuard( m_aMutex );
190
        if ( !hasByName( aName ) )
191
            throw container::NoSuchElementException(); 
192
        uno::Reference< container::XIndexContainer > xElement;
193
        if ( ! ( aElement >>= xElement ) )
194
            throw lang::IllegalArgumentException(); 
195
        IdToOleNameHash[ aName ] = xElement;
196
    }    
197
};
118
198
119
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
199
ImportExcel8::ImportExcel8( XclImpRootData& rImpData, SvStream& rStrm ) :
120
    ImportExcel( rImpData, rStrm )
200
    ImportExcel( rImpData, rStrm )
Lines 288-294 Link Here
288
        try
368
        try
289
        {
369
        {
290
            uno::Reference< lang::XComponent > xComponent( pShell->GetModel(), uno::UNO_QUERY_THROW );
370
            uno::Reference< lang::XComponent > xComponent( pShell->GetModel(), uno::UNO_QUERY_THROW );
291
                uno::Sequence< beans::NamedValue > aArgSeq(1);
371
                uno::Sequence< beans::NamedValue > aArgSeq(2);
292
                // I guess we could actually handle the GeneratedCodeNames here
372
                // I guess we could actually handle the GeneratedCodeNames here
293
                // ( e.g. after import create the required modules ) but...
373
                // ( e.g. after import create the required modules ) but...
294
                // better to reuse the code in the filter right?
374
                // better to reuse the code in the filter right?
Lines 304-309 Link Here
304
                }
384
                }
305
                aArgSeq[ 0 ].Value <<= sGeneratedCNames;
385
                aArgSeq[ 0 ].Value <<= sGeneratedCNames;
306
386
387
                aArgSeq[ 1 ].Name = CREATE_OUSTRING( "OleNameOverrideInfo");
388
                uno::Reference< container::XNameContainer > xOleNameOverrideSink( new OleNameOverrideContainer() );
389
                aArgSeq[ 1 ].Value <<=  xOleNameOverrideSink;
390
          
307
                uno::Sequence< uno::Any > aArgs( 2 );
391
                uno::Sequence< uno::Any > aArgs( 2 );
308
                aArgs[ 0 ] <<= getProcessServiceFactory();
392
                aArgs[ 0 ] <<= getProcessServiceFactory();
309
                aArgs[ 1 ] <<= aArgSeq;
393
                aArgs[ 1 ] <<= aArgSeq;
Lines 328-333 Link Here
328
            // call the filter
412
            // call the filter
329
            uno::Reference< document::XFilter > xFilter( xImporter, uno::UNO_QUERY_THROW );
413
            uno::Reference< document::XFilter > xFilter( xImporter, uno::UNO_QUERY_THROW );
330
            xFilter->filter( aMediaDesc.getAsConstPropertyValueList() );
414
            xFilter->filter( aMediaDesc.getAsConstPropertyValueList() );
415
            GetObjectManager().SetOleNameOverrideInfo( xOleNameOverrideSink );
331
        }
416
        }
332
        catch( uno::Exception& )
417
        catch( uno::Exception& )
333
        {
418
        {
(-)a/sc/source/filter/excel/read.cxx (-1 lines)
Lines 1237-1243 Link Here
1237
        std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
1237
        std::vector < SCTAB >::iterator it_end = nTabsWithNoCodeName.end();
1238
        for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
1238
        for ( std::vector < SCTAB >::iterator it = nTabsWithNoCodeName.begin(); it != it_end; ++it )
1239
        {
1239
        {
1240
            bool bGotCodeName = false;
1241
            SCTAB nTab = 1;
1240
            SCTAB nTab = 1;
1242
            OSL_TRACE("Trying to find suitable codename for %d", *it );
1241
            OSL_TRACE("Trying to find suitable codename for %d", *it );
1243
            while ( true )
1242
            while ( true )
(-)a/sc/source/filter/excel/xiescher.cxx (-1 / +35 lines)
Lines 114-119 Link Here
114
#include "xipage.hxx"
114
#include "xipage.hxx"
115
#include "xichart.hxx"
115
#include "xichart.hxx"
116
#include "xicontent.hxx"
116
#include "xicontent.hxx"
117
#include "scextopt.hxx"
118
117
#include "namebuff.hxx"
119
#include "namebuff.hxx"
118
120
119
using ::rtl::OUString;
121
using ::rtl::OUString;
Lines 240-246 Link Here
240
                xDrawObj.reset( new XclImpPhObj( rRoot ) );
242
                xDrawObj.reset( new XclImpPhObj( rRoot ) );
241
        }
243
        }
242
    }
244
    }
243
245
    xDrawObj->mnTab = rRoot.GetCurrScTab();
244
    xDrawObj->ImplReadObj3( rStrm );
246
    xDrawObj->ImplReadObj3( rStrm );
245
    return xDrawObj;
247
    return xDrawObj;
246
}
248
}
Lines 273-278 Link Here
273
        }
275
        }
274
    }
276
    }
275
277
278
    xDrawObj->mnTab = rRoot.GetCurrScTab();
276
    xDrawObj->ImplReadObj4( rStrm );
279
    xDrawObj->ImplReadObj4( rStrm );
277
    return xDrawObj;
280
    return xDrawObj;
278
}
281
}
Lines 315-320 Link Here
315
        }
318
        }
316
    }
319
    }
317
320
321
    xDrawObj->mnTab = rRoot.GetCurrScTab();
318
    xDrawObj->ImplReadObj5( rStrm );
322
    xDrawObj->ImplReadObj5( rStrm );
319
    return xDrawObj;
323
    return xDrawObj;
320
}
324
}
Lines 373-378 Link Here
373
        }
377
        }
374
    }
378
    }
375
379
380
    xDrawObj->mnTab = rRoot.GetCurrScTab();
376
    xDrawObj->ImplReadObj8( rStrm );
381
    xDrawObj->ImplReadObj8( rStrm );
377
    return xDrawObj;
382
    return xDrawObj;
378
}
383
}
Lines 2820-2825 Link Here
2820
    return xSdrObj.release();
2825
    return xSdrObj.release();
2821
}
2826
}
2822
2827
2828
String XclImpPictureObj::GetObjName() const
2829
{
2830
    if( IsOcxControl() )
2831
    {
2832
        String sName( GetObjectManager().GetOleNameOverride( GetTab(), GetObjId() ) );
2833
        if ( sName.Len() > 0 )
2834
            return sName;
2835
    }
2836
    return XclImpDrawObjBase::GetObjName();
2837
}
2838
2823
void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
2839
void XclImpPictureObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const
2824
{
2840
{
2825
    if( IsOcxControl() )
2841
    if( IsOcxControl() )
Lines 3134-3139 Link Here
3134
{
3150
{
3135
}
3151
}
3136
3152
3153
String XclImpObjectManager::GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId )
3154
{
3155
    rtl::OUString sOleName; 
3156
    String sCodeName = GetExtDocOptions().GetCodeName( nTab );
3157
    
3158
    if (  mxOleCtrlNameOverride->hasByName( sCodeName ) )
3159
    {
3160
        Reference< XIndexContainer > xIdToOleName;
3161
        mxOleCtrlNameOverride->getByName( sCodeName ) >>= xIdToOleName;
3162
        xIdToOleName->getByIndex( nObjId ) >>= sOleName;
3163
    }
3164
    OSL_TRACE("XclImpObjectManager::GetOleNameOverride tab %d, ( module %s ) object id ( %d ) is %s", nTab,
3165
        rtl::OUStringToOString( sCodeName, RTL_TEXTENCODING_UTF8 ).getStr(), nObjId,
3166
        rtl::OUStringToOString( sOleName, RTL_TEXTENCODING_UTF8 ).getStr() );
3167
        
3168
    return sOleName;
3169
}
3170
3137
void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize )
3171
void XclImpDffConverter::StartProgressBar( sal_Size nProgressSize )
3138
{
3172
{
3139
    mxProgress.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING ) );
3173
    mxProgress.reset( new ScfProgressBar( GetDocShell(), STR_PROGRESS_CALCULATING ) );
(-)a/sc/source/filter/inc/xiescher.hxx (-4 / +12 lines)
Lines 92-98 Link Here
92
    /** Returns the Excel object type from OBJ record. */
92
    /** Returns the Excel object type from OBJ record. */
93
    inline sal_uInt16   GetObjType() const { return mnObjType; }
93
    inline sal_uInt16   GetObjType() const { return mnObjType; }
94
    /** Returns the name of this object, may generate a default name. */
94
    /** Returns the name of this object, may generate a default name. */
95
    String              GetObjName() const;
95
    virtual String              GetObjName() const;
96
    /** Returns associated macro name, if set, otherwise zero length string. */
96
    /** Returns associated macro name, if set, otherwise zero length string. */
97
    inline const String& GetMacroName() const { return maMacroName; }
97
    inline const String& GetMacroName() const { return maMacroName; }
98
98
Lines 114-120 Link Here
114
    bool                IsValidSize( const Rectangle& rAnchorRect ) const;
114
    bool                IsValidSize( const Rectangle& rAnchorRect ) const;
115
    /** Returns the range in the sheet covered by this object. */
115
    /** Returns the range in the sheet covered by this object. */
116
    ScRange             GetUsedArea( SCTAB nScTab ) const;
116
    ScRange             GetUsedArea( SCTAB nScTab ) const;
117
118
    /** Returns true, if the object is valid and will be processed. */
117
    /** Returns true, if the object is valid and will be processed. */
119
    inline bool         IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
118
    inline bool         IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
120
    /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
119
    /** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
Lines 172-178 Link Here
172
    virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
171
    virtual void        DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
173
    /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
172
    /** Derived classes may perform additional processing for the passed SdrObject after insertion. */
174
    virtual void        DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
173
    virtual void        DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
175
174
    SCTAB               GetTab() const { return mnTab; }
176
private:
175
private:
177
    /** Reads the contents of a BIFF3 OBJ record. */
176
    /** Reads the contents of a BIFF3 OBJ record. */
178
    void                ImplReadObj3( XclImpStream& rStrm );
177
    void                ImplReadObj3( XclImpStream& rStrm );
Lines 186-191 Link Here
186
private:
185
private:
187
    XclObjAnchor        maAnchor;       /// The position of the object in its parent.
186
    XclObjAnchor        maAnchor;       /// The position of the object in its parent.
188
    sal_uInt16          mnObjId;        /// The object identifier (unique per drawing).
187
    sal_uInt16          mnObjId;        /// The object identifier (unique per drawing).
188
    SCTAB               mnTab;          /// Location of object
189
    sal_uInt16          mnObjType;      /// The Excel object type from OBJ record.
189
    sal_uInt16          mnObjType;      /// The Excel object type from OBJ record.
190
    sal_uInt32          mnDffShapeId;   /// Shape ID from DFF stream.
190
    sal_uInt32          mnDffShapeId;   /// Shape ID from DFF stream.
191
    sal_uInt32          mnDffFlags;     /// Shape flags from DFF stream.
191
    sal_uInt32          mnDffFlags;     /// Shape flags from DFF stream.
Lines 862-868 Link Here
862
{
862
{
863
public:
863
public:
864
    explicit            XclImpPictureObj( const XclImpRoot& rRoot );
864
    explicit            XclImpPictureObj( const XclImpRoot& rRoot );
865
865
    /** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
866
    virtual String              GetObjName() const;
866
    /** Returns the graphic imported from the IMGDATA record. */
867
    /** Returns the graphic imported from the IMGDATA record. */
867
    inline const Graphic& GetGraphic() const { return maGraphic; }
868
    inline const Graphic& GetGraphic() const { return maGraphic; }
868
    /** Returns the visible area of the imported graphic. */
869
    /** Returns the visible area of the imported graphic. */
Lines 1225-1233 Link Here
1225
    String              GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
1226
    String              GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
1226
    /** Returns the used area in the sheet with the passed index. */
1227
    /** Returns the used area in the sheet with the passed index. */
1227
    ScRange             GetUsedArea( SCTAB nScTab ) const;
1228
    ScRange             GetUsedArea( SCTAB nScTab ) const;
1229
    /** Sets the container to recieve overriden shape/ctrls names from
1230
        the filter. */
1231
    void SetOleNameOverrideInfo( const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& rxOverrideInfo ) {  mxOleCtrlNameOverride = rxOverrideInfo; }
1232
    /** Returns the name of overridden name ( or zero length string ) for 
1233
        associated object id. */
1234
    String GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId );
1228
1235
1229
    // ------------------------------------------------------------------------
1236
    // ------------------------------------------------------------------------
1230
private:
1237
private:
1238
    com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >  mxOleCtrlNameOverride;
1231
    typedef ::std::map< sal_uInt16, String >            DefObjNameMap;
1239
    typedef ::std::map< sal_uInt16, String >            DefObjNameMap;
1232
    typedef ScfRef< XclImpSheetDrawing >                XclImpSheetDrawingRef;
1240
    typedef ScfRef< XclImpSheetDrawing >                XclImpSheetDrawingRef;
1233
    typedef ::std::map< SCTAB, XclImpSheetDrawingRef >  XclImpSheetDrawingMap;
1241
    typedef ::std::map< SCTAB, XclImpSheetDrawingRef >  XclImpSheetDrawingMap;

Return to issue 113048