summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2010-07-07 19:27:51 +0200
committerDaniel Rentz <dr@openoffice.org>2010-07-07 19:27:51 +0200
commit4232a54805f36dcfcb05b980ac9b6df2ed381fef (patch)
treef524e0a6342a18c08d848fe311fdd8b09d0c6132 /oox
parent19d399fdda8f8e2b124e00bff54ecea476a3592e (diff)
mib17: remove unused code
Diffstat (limited to 'oox')
-rwxr-xr-xoox/inc/oox/ole/vbahelper.hxx123
-rwxr-xr-xoox/inc/oox/ole/vbaproject.hxx151
-rw-r--r--[-rwxr-xr-x]oox/source/core/filterbase.cxx32
-rwxr-xr-xoox/source/ole/vbacontrol.cxx28
-rwxr-xr-xoox/source/ole/vbahelper.cxx171
-rwxr-xr-xoox/source/ole/vbaproject.cxx64
-rw-r--r--oox/source/xls/excelfilter.cxx45
7 files changed, 70 insertions, 544 deletions
diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx
index 76dc1c736025..c1e7297d0c5b 100755
--- a/oox/inc/oox/ole/vbahelper.hxx
+++ b/oox/inc/oox/ole/vbahelper.hxx
@@ -30,11 +30,6 @@
#include "oox/helper/binarystreambase.hxx"
-namespace com { namespace sun { namespace star {
- namespace container { class XNameContainer; }
- namespace document { class XEventsSupplier; }
-} } }
-
namespace oox { class BinaryInputStream; }
namespace oox {
@@ -102,124 +97,6 @@ public:
::rtl::OUString& rValue,
const ::rtl::OUString& rKeyValue );
- /** Removes whitespace characters from the beginning of the passed string.
-
- @param rCodeLine (in/out parameter) The string to be modified.
-
- @return True = at least one whitespace character found and removed
- from rCodeLine. False = rCodeLine is empty or does not start with
- a whitespace character.
- */
- static bool eatWhitespace( ::rtl::OUString& rCodeLine );
-
- /** Removes the passed keyword from the beginning of the passed string.
-
- @param rCodeLine (in/out parameter) The string to be modified.
-
- @param rKeyword The keyword to be removed from the beginning of the
- rCodeLine string.
-
- @return True = rCodeLine starts with the passed keyword (case
- insensitive), and is followed by whitespace characters, or it ends
- right after the keyword. The keyword and the following whitespace
- characters have been removed from rCodeLine. False = rCodeLine is
- empty or does not start with the specified keyword, or the keyword
- is not followed by whitespace characters.
- */
- static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword );
-
- /** Returns the VBA source code of the specified module, or an empty
- string, if the module does not exist.
-
- @param rxBasicLib The container for all VBA code modules.
- @param rModuleName The name of the VBA code module.
- */
- static ::rtl::OUString getSourceCode(
- const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
- const ::rtl::OUString& rModuleName );
-
- /** Checks, if a macro with the specified name exists in the passed VBA
- source code.
-
- @param rSourceCode The VBA source code.
- @param rMacroName The name of the macro.
- */
- static bool hasMacro(
- const ::rtl::OUString& rSourceCode,
- const ::rtl::OUString& rMacroName );
-
- /** Checks, if a macro with the specified name exists in the specified
- module.
-
- @param rxBasicLib The container for all VBA code modules.
- @param rModuleName The name of the VBA module to check for the macro.
- @param rMacroName The name of the macro.
- */
- static bool hasMacro(
- const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName );
-
- /** Tries to insert a VBA macro into the specified code module.
-
- @descr If the specified macro does not exist, it will be generated as
- following, using the passed parameters. If the parameter rMacroType
- is left empty, a sub procedure macro will be generated:
-
- Private Sub <rMacroName> ( <rMacroArgs> )
- <rMacroCode>
- End Sub
-
- If the parameter rMacroType is not empty, a function macro
- will be generated. Note that the parameter rMacroCode has to
- provide the code that returns the function value.
-
- Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType>
- <rMacroCode>
- End Function
-
- The source code in rMacroCode may contain a special placeholder
- $MACRO that will be replaced by the macro name passed in rMacroName
- before the macro will be inserted into the module.
-
- @param rModuleName The name of the VBA module to be used.
- @param rMacroName The name of the VBA macro to be inserted.
- @param rMacroArgs The argument list of the VBA macro.
- @param rMacroType Macro return type (empty for sub procedure).
- @param rMacroCode The VBA source code for the macro.
-
- @return True, if the specified VBA macro has been inserted. False, if
- there already exists a macro with the specified name, or if any
- error has occurred, for example, Office configuration forbids to
- generate executable VBA code or the specified module does not
- exist.
- */
- static bool insertMacro(
- const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName,
- const ::rtl::OUString& rMacroArgs,
- const ::rtl::OUString& rMacroType,
- const ::rtl::OUString& rMacroCode );
-
- /** Tries to attach a VBA macro to an event of the passed events supplier.
-
- @descr The function checks if the specified macro exists and attaches
- it to the event of the passed events supplier.
-
- @param rxEventsSupp The events supplier for the event to be attached.
- @param rEventName The event name used in the office API.
- @param rLibraryName The name of the Basic library containing the macro.
- @param rModuleName The name of the VBA module containing the macro.
- @param rMacroName The name of the VBA macro to attach to the event.
- */
- static bool attachMacroToEvent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp,
- const ::rtl::OUString& rEventName,
- const ::rtl::OUString& rLibraryName,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName );
-
private:
VbaHelper();
~VbaHelper();
diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx
index 0422ccbd0cf8..1d2fca29dbab 100755
--- a/oox/inc/oox/ole/vbaproject.hxx
+++ b/oox/inc/oox/ole/vbaproject.hxx
@@ -97,157 +97,6 @@ public:
/** Returns true, if the document contains the specified dialog. */
bool hasDialog( const ::rtl::OUString& rDialogName ) const;
- // Insert VBA code modules and VBA macros into modules --------------------
-
- /** Tries to insert a VBA macro into the specified code module.
-
- @descr If the specified macro does not exist, it will be generated as
- following, using the passed parameters. If the parameter rMacroType
- is left empty, a sub procedure macro will be generated:
-
- Private Sub <rMacroName> ( <rMacroArgs> )
- <rMacroCode>
- End Sub
-
- If the parameter rMacroType is not empty, a function macro
- will be generated. Note that the parameter rMacroCode has to
- provide the code that returns the function value.
-
- Private Function <rMacroName> ( <rMacroArgs> ) As <rMacroType>
- <rMacroCode>
- End Function
-
- The source code in rMacroCode may contain a special placeholder
- $MACRO that will be replaced by the macro name passed in rMacroName
- before the macro will be inserted into the module.
-
- @param rModuleName The name of the VBA module to be used.
- @param rMacroName The name of the VBA macro to be inserted.
- @param rMacroArgs The argument list of the VBA macro.
- @param rMacroType Macro return type (empty for sub procedure).
- @param rMacroCode The VBA source code for the macro.
-
- @return True, if the specified VBA macro has been inserted. False, if
- there already exists a macro with the specified name, or if any
- error has occurred, for example, Office configuration forbids to
- generate executable VBA code or the specified module does not
- exist.
- */
- bool insertMacro(
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName,
- const ::rtl::OUString& rMacroArgs,
- const ::rtl::OUString& rMacroType,
- const ::rtl::OUString& rMacroCode );
-
- // Attach VBA macros to generic or document events ------------------------
-
- /** Tries to attach the specified VBA macro to an event directly.
-
- @descr The function checks if the specified macro exists and attaches
- it to the event of the passed events supplier.
-
- @param rxEventsSupp The events supplier for the event to be attached.
- @param rEventName The event name used in the office API.
- @param rModuleName The name of the VBA module containing the macro.
- @param rMacroName The name of the VBA macro to attach to the event.
-
- @return True, if the specified VBA macro exists and could be attached
- to the specified event.
- */
- bool attachMacroToEvent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp,
- const ::rtl::OUString& rEventName,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName );
-
- /** Tries to attach the specified VBA macro to a document event directly.
-
- @descr The function checks if the specified macro exists and attaches
- it to the document event.
-
- @param rEventName The document event name used in the office API.
- @param rModuleName The name of the VBA module containing the macro.
- @param rMacroName The name of the VBA macro to attach to the event.
-
- @return True, if the specified VBA macro exists and could be attached
- to the specified document event.
- */
- bool attachMacroToDocumentEvent(
- const ::rtl::OUString& rEventName,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName );
-
- /** Tries to attach the specified VBA macro to an event via a generated
- proxy macro that implements necessary conversion between VBA and UNO.
-
- @descr The function checks if the specified VBA macro exists, then it
- tries to generate a proxy macro using the parameters passed to this
- function, appends it to the code module, and attaches it to the
- event.
-
- The proxy macro will execute the code specified in the rProxyCode
- parameter. This code may contain special placeholders that will be
- replaced before the proxy macro will be inserted into the module:
- - $MACRO will be replaced by the original VBA macro name passed
- in the rMacroName parameter.
- - $PROXY will be replaced by the name of the proxy macro
- generated by this function.
-
- @param rxEventsSupp The events supplier for the event to be attached.
- @param rEventName The event name used in the office API.
- @param rModuleName The name of the VBA module containing the macro.
- @param rMacroName The name of the VBA macro to attach to the event.
- @param rProxyArgs The argument list of the generated proxy macro.
- @param rProxyType Proxy macro return type (empty for procedure).
- @param rProxyCode Proxy macro source code.
-
- @return True, if the specified VBA macro exists and could be attached
- to the specified event.
- */
- bool attachMacroToEvent(
- const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp,
- const ::rtl::OUString& rEventName,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName,
- const ::rtl::OUString& rProxyArgs,
- const ::rtl::OUString& rProxyType,
- const ::rtl::OUString& rProxyCode );
-
- /** Tries to attach the specified VBA macro to a document event via a
- proxy macro that implements necessary conversion between VBA and UNO.
-
- @descr The function checks if the specified VBA macro exists, then it
- tries to generate a proxy macro using the parameters passed to this
- function, appends it to the code module, and attaches it to the
- document event.
-
- The proxy macro will execute the code specified in the rProxyCode
- parameter. This code may contain special placeholders that will be
- replaced before the proxy macro will be inserted into the module:
- - $MACRO will be replaced by the original VBA macro name passed
- in the rMacroName parameter.
- - $PROXY will be replaced by the name of the proxy macro
- generated by this function.
-
- @param rEventName The document event name used in the office API.
- @param rModuleName The name of the VBA module containing the macro.
- @param rMacroName The name of the VBA macro to attach to the event.
- @param rProxyArgs The argument list of the generated proxy macro.
- @param rProxyType Proxy macro return type (empty for procedure).
- @param rProxyCode Proxy macro source code.
-
- @return True, if the specified VBA macro exists and could be attached
- to the specified event.
- */
- bool attachMacroToDocumentEvent(
- const ::rtl::OUString& rEventName,
- const ::rtl::OUString& rModuleName,
- const ::rtl::OUString& rMacroName,
- const ::rtl::OUString& rProxyArgs,
- const ::rtl::OUString& rProxyType,
- const ::rtl::OUString& rProxyCode );
-
private:
VbaProject( const VbaProject& );
VbaProject& operator=( const VbaProject& );
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 902784cafe80..dfa898026dd8 100755..100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -74,8 +74,18 @@ namespace core {
namespace {
+struct UrlPool
+{
+ ::osl::Mutex maMutex;
+ ::std::set< OUString > maUrls;
+};
+
+struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {};
+
+// ----------------------------------------------------------------------------
+
/** This guard prevents recursive loading/saving of the same document. */
-class DocumentOpenedGuard : public ::osl::Mutex
+class DocumentOpenedGuard
{
public:
explicit DocumentOpenedGuard( const OUString& rUrl );
@@ -87,31 +97,28 @@ private:
DocumentOpenedGuard( const DocumentOpenedGuard& );
DocumentOpenedGuard& operator=( const DocumentOpenedGuard& );
- typedef ::std::set< OUString > UrlSet;
- struct UrlPool : public ::rtl::Static< UrlSet, UrlPool > {};
-
- UrlSet& mrUrls;
OUString maUrl;
bool mbValid;
};
-DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl ) :
- mrUrls( UrlPool::get() )
+DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl )
{
- ::osl::MutexGuard aGuard( *this );
- mbValid = (rUrl.getLength() == 0) || (mrUrls.count( rUrl ) == 0);
+ UrlPool& rUrlPool = StaticUrlPool::get();
+ ::osl::MutexGuard aGuard( rUrlPool.maMutex );
+ mbValid = (rUrl.getLength() == 0) || (rUrlPool.maUrls.count( rUrl ) == 0);
if( mbValid && (rUrl.getLength() > 0) )
{
- mrUrls.insert( rUrl );
+ rUrlPool.maUrls.insert( rUrl );
maUrl = rUrl;
}
}
DocumentOpenedGuard::~DocumentOpenedGuard()
{
- ::osl::MutexGuard aGuard( *this );
+ UrlPool& rUrlPool = StaticUrlPool::get();
+ ::osl::MutexGuard aGuard( rUrlPool.maMutex );
if( maUrl.getLength() > 0 )
- mrUrls.erase( maUrl );
+ rUrlPool.maUrls.erase( maUrl );
}
} // namespace
@@ -594,4 +601,3 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const
} // namespace core
} // namespace oox
-
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 4952b956bae4..e9ea87d98a58 100755
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -722,6 +722,30 @@ OUString lclGetQuotedString( const OUString& rCodeLine )
return aBuffer.makeStringAndClear();
}
+bool lclEatWhitespace( OUString& rCodeLine )
+{
+ sal_Int32 nIndex = 0;
+ while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) )
+ ++nIndex;
+ if( nIndex > 0 )
+ {
+ rCodeLine = rCodeLine.copy( nIndex );
+ return true;
+ }
+ return false;
+}
+
+bool lclEatKeyword( OUString& rCodeLine, const OUString& rKeyword )
+{
+ if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) )
+ {
+ rCodeLine = rCodeLine.copy( rKeyword.getLength() );
+ // success, if code line ends after keyword, or if whitespace follows
+ return (rCodeLine.getLength() == 0) || lclEatWhitespace( rCodeLine );
+ }
+ return false;
+}
+
} // namespace
// ----------------------------------------------------------------------------
@@ -755,10 +779,10 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib,
while( !bBeginFound && !aFrameTextStrm.isEof() )
{
aLine = aFrameTextStrm.readLine().trim();
- bBeginFound = VbaHelper::eatKeyword( aLine, aBegin );
+ bBeginFound = lclEatKeyword( aLine, aBegin );
}
// check for the specific GUID that represents VBA forms
- if( !bBeginFound || !VbaHelper::eatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) )
+ if( !bBeginFound || !lclEatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) )
return;
// remaining line is the form name
diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx
index 7293e357e746..3bf72d30bfa5 100755
--- a/oox/source/ole/vbahelper.cxx
+++ b/oox/source/ole/vbahelper.cxx
@@ -27,27 +27,15 @@
#include "oox/ole/vbahelper.hxx"
#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/container/XNameContainer.hpp>
-#include <com/sun/star/document/XEventsSupplier.hpp>
-#include <comphelper/string.hxx>
#include "oox/helper/binaryinputstream.hxx"
-using ::rtl::OUString;
-using ::rtl::OUStringBuffer;
-using ::com::sun::star::beans::PropertyValue;
-using ::com::sun::star::container::XNameContainer;
-using ::com::sun::star::container::XNameReplace;
-using ::com::sun::star::document::XEventsSupplier;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::UNO_SET_THROW;
-
namespace oox {
namespace ole {
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using namespace ::com::sun::star::uno;
+
// ============================================================================
/*static*/ OUString VbaHelper::getBasicScriptUrl(
@@ -91,157 +79,6 @@ namespace ole {
return false;
}
-/*static*/ bool VbaHelper::eatWhitespace( OUString& rCodeLine )
-{
- sal_Int32 nIndex = 0;
- while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) )
- ++nIndex;
- if( nIndex > 0 )
- {
- rCodeLine = rCodeLine.copy( nIndex );
- return true;
- }
- return false;
-}
-
-/*static*/ bool VbaHelper::eatKeyword( OUString& rCodeLine, const OUString& rKeyword )
-{
- if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) )
- {
- rCodeLine = rCodeLine.copy( rKeyword.getLength() );
- // success, if code line ends after keyword, or if whitespace follows
- return (rCodeLine.getLength() == 0) || eatWhitespace( rCodeLine );
- }
- return false;
-}
-
-/*static*/ OUString VbaHelper::getSourceCode( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName )
-{
- OUString aSourceCode;
- if( rxBasicLib.is() ) try
- {
- rxBasicLib->getByName( rModuleName ) >>= aSourceCode;
- }
- catch( Exception& )
- {
- }
- return aSourceCode;
-}
-
-namespace {
-
-bool lclGetLine( OUString& rCodeLine, sal_Int32& rnIndex, const OUString& rSourceCode )
-{
- if( rnIndex < rSourceCode.getLength() )
- {
- sal_Int32 nPosLF = rSourceCode.indexOf( '\n', rnIndex );
- if( nPosLF >= rnIndex )
- {
- rCodeLine = rSourceCode.copy( rnIndex, nPosLF - rnIndex ).trim();
- rnIndex = nPosLF + 1;
- return true;
- }
- }
- return false;
-}
-
-} // namespace
-
-/*static*/ bool VbaHelper::hasMacro( const OUString& rSourceCode, const OUString& rMacroName )
-{
- // scan all text lines for '[Public|Private] [Static] Sub <macroname> (...)'
- const OUString aPublic = CREATE_OUSTRING( "Public" );
- const OUString aPrivate = CREATE_OUSTRING( "Private" );
- const OUString aStatic = CREATE_OUSTRING( "Static" );
- const OUString aSub = CREATE_OUSTRING( "Sub" );
-
- OUString aCodeLine;
- sal_Int32 nIndex = 0;
- while( lclGetLine( aCodeLine, nIndex, rSourceCode ) )
- {
- // eat optional 'Private' or 'Public', but do not accept both keywords in a row (therefore the ||)
- eatKeyword( aCodeLine, aPublic ) || eatKeyword( aCodeLine, aPrivate );
- // eat optional 'Static'
- eatKeyword( aCodeLine, aStatic );
- // eat 'Sub' keyword, check if macro name follows
- if( eatKeyword( aCodeLine, aSub ) && aCodeLine.matchIgnoreAsciiCase( rMacroName ) )
- {
- // eat macro name and following whitespace
- aCodeLine = aCodeLine.copy( rMacroName.getLength() );
- eatWhitespace( aCodeLine );
- // opening bracket must follow the macro name
- if( (aCodeLine.getLength() >= 2) && (aCodeLine[ 0 ] == '(') )
- return true;
- }
- }
- return false;
-}
-
-/*static*/ bool VbaHelper::hasMacro( const Reference< XNameContainer >& rxBasicLib,
- const OUString& rModuleName, const OUString& rMacroName )
-{
- return hasMacro( getSourceCode( rxBasicLib, rModuleName ), rMacroName );
-}
-
-/*static*/ bool VbaHelper::insertMacro( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName,
- const OUString& rMacroName, const OUString& rMacroArgs, const OUString& rMacroType, const OUString& rMacroCode )
-{
- if( rxBasicLib.is() ) try
- {
- // receive module source code and check that the specified macro does not exist
- OUString aSourceCode = getSourceCode( rxBasicLib, rModuleName );
- if( !hasMacro( aSourceCode, rMacroName ) )
- {
- bool bFunction = rMacroType.getLength() > 0;
- const sal_Char* pcSubFunc = bFunction ? "Function" : "Sub";
- OUStringBuffer aBuffer( aSourceCode );
- // generate the source code for the new macro
- aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\nPrivate " ) ).
- appendAscii( pcSubFunc ).append( sal_Unicode( ' ' ) ).
- append( rMacroName ).append( sal_Unicode( '(' ) );
- if( rMacroArgs.getLength() > 0 )
- aBuffer.append( sal_Unicode( ' ' ) ).append( rMacroArgs ).append( sal_Unicode( ' ' ) );
- aBuffer.append( sal_Unicode( ')' ) );
- if( bFunction )
- aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " As " ) ).append( rMacroType );
- aBuffer.append( sal_Unicode( '\n' ) );
- // replace all $MACRO placeholders with macro name
- if( rMacroCode.getLength() > 0 )
- {
- OUString aMacroCode = ::comphelper::string::searchAndReplaceAsciiL( rMacroCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName );
- aBuffer.append( aMacroCode ).append( sal_Unicode( '\n' ) );
- }
- aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End " ) ).appendAscii( pcSubFunc ).append( sal_Unicode( '\n' ) );
- rxBasicLib->replaceByName( rModuleName, Any( aBuffer.makeStringAndClear() ) );
- return true;
- }
- }
- catch( Exception& )
- {
- }
- return false;
-}
-
-/*static*/ bool VbaHelper::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp,
- const OUString& rEventName, const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName )
-{
- if( rxEventsSupp.is() ) try
- {
- Reference< XNameReplace > xEvents( rxEventsSupp->getEvents(), UNO_SET_THROW );
- Sequence< PropertyValue > aEvent( 2 );
- aEvent[ 0 ].Name = CREATE_OUSTRING( "EventType" );
- aEvent[ 0 ].Value <<= CREATE_OUSTRING( "Script" );
- aEvent[ 1 ].Name = CREATE_OUSTRING( "Script" );
- aEvent[ 1 ].Value <<= getBasicScriptUrl( rLibraryName, rModuleName, rMacroName );
- xEvents->replaceByName( rEventName, Any( aEvent ) );
- return true;
- }
- catch( Exception& )
- {
- }
- return false;
-}
-
// ============================================================================
} // namespace ole
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index a370fb3d168e..04f3eb49d35d 100755
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -184,70 +184,6 @@ bool VbaProject::hasDialog( const OUString& rDialogName ) const
return mxDialogLib.is() && mxDialogLib->hasByName( rDialogName );
}
-// Insert VBA code modules and VBA macros into modules ------------------------
-
-bool VbaProject::insertMacro( const OUString& rModuleName,
- const OUString& rMacroName, const OUString& rMacroArgs,
- const OUString& rMacroType, const OUString& rMacroCode )
-{
- return
- // do nothing if macros are imported as comments
- isImportVbaExecutable() &&
- // try to insert the macro (will check that the macro does not exist yet)
- VbaHelper::insertMacro( mxBasicLib, rModuleName, rMacroName, rMacroArgs, rMacroType, rMacroCode );
-}
-
-// Attach VBA macros to generic or document events ----------------------------
-
-bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp,
- const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName )
-{
- return
- // do not attach if macros are imported as comments
- isImportVbaExecutable() &&
- // check that the specified macro exists in the module
- VbaHelper::hasMacro( mxBasicLib, rModuleName, rMacroName ) &&
- // attach the macro to the events supplier
- VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, rMacroName );
-}
-
-bool VbaProject::attachMacroToDocumentEvent( const OUString& rEventName,
- const OUString& rModuleName, const OUString& rMacroName )
-{
- Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY );
- return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName );
-}
-
-bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp,
- const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName,
- const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode )
-{
- // receive module source code, and check that the specified macro exists in the module
- OUString aSourceCode = VbaHelper::getSourceCode( mxBasicLib, rModuleName );
- if( isImportVbaExecutable() && VbaHelper::hasMacro( aSourceCode, rMacroName ) )
- {
- // create the name of the proxy macro, and the macro source code
- OUString aProxyName = OUStringBuffer( rMacroName ).append( sal_Unicode( '_' ) ).
- append( rEventName ).appendAscii( "_Proxy" ).makeStringAndClear();
- // replace $MACRO and $PROXY placeholders in proxy source code
- OUString aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( rProxyCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName );
- aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( aProxyCode, RTL_CONSTASCII_STRINGPARAM( "$PROXY" ), aProxyName );
- // insert the new macro into the code module and attach it to the event
- return
- VbaHelper::insertMacro( mxBasicLib, rModuleName, aProxyName, rProxyArgs, rProxyType, aProxyCode ) &&
- VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, aProxyName );
- }
- return false;
-}
-
-bool VbaProject::attachMacroToDocumentEvent(
- const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName,
- const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode )
-{
- Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY );
- return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName, rProxyArgs, rProxyType, rProxyCode );
-}
-
// private --------------------------------------------------------------------
Reference< XLibraryContainer > VbaProject::getLibraryContainer( sal_Int32 nPropId )
diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx
index 71475790851f..5affbfff44a7 100644
--- a/oox/source/xls/excelfilter.cxx
+++ b/oox/source/xls/excelfilter.cxx
@@ -115,19 +115,18 @@ ExcelFilter::~ExcelFilter()
bool ExcelFilter::importDocument() throw()
{
- /* to activate the XLSX/XLSB dumper, define the environment variable
- OOO_XLSBDUMPER and insert the full path to the file
- file:///<path-to-oox-module>/source/dump/xlsbdumper.ini. */
+ /* To activate the XLSX/XLSB dumper, insert the full path to the file
+ file:///<path-to-oox-module>/source/dump/xlsbdumper.ini
+ into the environment variable OOO_XLSBDUMPER and start the office with
+ this variable (nonpro only). */
OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper );
- bool bRet = false;
OUString aWorkbookPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATIONSTYPE( "officeDocument" ) );
- if( aWorkbookPath.getLength() > 0 )
- {
- WorkbookHelperRoot aHelper( *this );
- bRet = aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) );
- }
- return bRet;
+ if( aWorkbookPath.getLength() == 0 )
+ return false;
+
+ WorkbookHelperRoot aHelper( *this );
+ return aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) );
}
bool ExcelFilter::exportDocument() throw()
@@ -198,31 +197,30 @@ ExcelBiffFilter::~ExcelBiffFilter()
bool ExcelBiffFilter::importDocument() throw()
{
- /* to activate the BIFF dumper, define the environment variable
- OOO_BIFFDUMPER and insert the full path to the file
- file:///<path-to-oox-module>/source/dump/biffdumper.ini. */
+ /* To activate the BIFF dumper, insert the full path to the file
+ file:///<path-to-oox-module>/source/dump/biffdumper.ini
+ into the environment variable OOO_BIFFDUMPER and start the office with
+ this variable (nonpro only). */
OOX_DUMP_FILE( ::oox::dump::biff::Dumper );
/* The boolean argument "UseBiffFilter" passed through XInitialisation
- decides whether to use the BIFF file dumper implemented in this filter
- only (false or missing), or to import/export the document (true). */
+ decides whether to import/export the document with this filter (true),
+ or to only use the BIFF file dumper implemented in this filter (false
+ or missing) */
Any aUseBiffFilter = getArgument( CREATE_OUSTRING( "UseBiffFilter" ) );
bool bUseBiffFilter = false;
if( !(aUseBiffFilter >>= bUseBiffFilter) || !bUseBiffFilter )
return true;
- bool bRet = false;
-
// detect BIFF version and workbook stream name
OUString aWorkbookName;
BiffType eBiff = BiffDetector::detectStorageBiffVersion( aWorkbookName, getStorage() );
OSL_ENSURE( eBiff != BIFF_UNKNOWN, "ExcelBiffFilter::ExcelBiffFilter - invalid file format" );
- if( eBiff != BIFF_UNKNOWN )
- {
- WorkbookHelperRoot aHelper( *this, eBiff );
- bRet = aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment();
- }
- return bRet;
+ if( eBiff == BIFF_UNKNOWN )
+ return false;
+
+ WorkbookHelperRoot aHelper( *this, eBiff );
+ return aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment();
}
bool ExcelBiffFilter::exportDocument() throw()
@@ -244,4 +242,3 @@ OUString ExcelBiffFilter::implGetImplementationName() const
} // namespace xls
} // namespace oox
-