diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-07-27 19:47:01 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-07-27 19:47:01 +0200 |
commit | 787940e0ac285aa1101ca8964d252faaab3ea8c1 (patch) | |
tree | 1f9dc8a0ae0693e31aa79d4e2d47586b5e603fde /sfx2 | |
parent | a1c081a7c213a56321b0b60651a1dbd63bcaec80 (diff) |
fdo#54264: Fix multi-argument ApplicationEvent::TYPE_OPEN/PRINT
...that had been broken when 5c22a03320f20ae9ac2c3c16025e7c5e3a7915d5> "Cleaned
up CommandLineArgs" changed the representation of those multi-arguments from a
single string with \n delimiters to vector<string> in
desktop/soruce/app/cmdlineargs.hxx, but missed updating other producers of
such ApplicationEvents.
Change-Id: I527d620c60a87f3a01d970927c521163fb6df192
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appdde.cxx | 71 |
1 files changed, 44 insertions, 27 deletions
diff --git a/sfx2/source/appl/appdde.cxx b/sfx2/source/appl/appdde.cxx index dd680810c3ac..5f2ab9cf0f36 100644 --- a/sfx2/source/appl/appdde.cxx +++ b/sfx2/source/appl/appdde.cxx @@ -230,10 +230,14 @@ public: class SfxDdeDocTopics_Impl : public std::vector<SfxDdeDocTopic_Impl*> {}; +#if defined( WNT ) + +namespace { + /* [Description] Checks if 'rCmd' of the event 'rEvent' is (without '(') and then assemble - this data into a <ApplicationEvent>, which can be excecuted through + this data into a <ApplicationEvent>, which is then excecuted through <Application::AppEvent()>. If 'rCmd' is the given event 'rEvent', then TRUE is returned, otherwise FALSE. @@ -242,41 +246,55 @@ class SfxDdeDocTopics_Impl : public std::vector<SfxDdeDocTopic_Impl*> {}; rCmd = "Open(\"d:\doc\doc.sdw\")" rEvent = "Open" */ -sal_Bool SfxAppEvent_Impl( ApplicationEvent &rAppEvent, - const OUString& rCmd, const OUString& rEvent, +sal_Bool SfxAppEvent_Impl( const OUString& rCmd, const OUString& rEvent, ApplicationEvent::Type eType ) { - OUString sEvent(rEvent); - sEvent += "("; + OUString sEvent(rEvent + "("); if (rCmd.startsWithIgnoreAsciiCase(sEvent)) { - OUStringBuffer aData( rCmd ); - aData.remove(0, sEvent.getLength()); - if ( aData.getLength() > 2 ) + sal_Int32 start = sEvent.getLength(); + if ( rCmd.getLength() - start >= 2 ) { // Transform into the ApplicationEvent Format - aData.remove( aData.getLength() - 1, 1 ); - for ( sal_Int32 n = 0; n < aData.getLength(); ) + std::vector<OUString> aData; + for ( sal_Int32 n = start; n < rCmd.getLength() - 1; ) { - switch ( aData[n] ) + // Resiliently read arguments either starting with " and + // spanning to the next " (if any; TODO: do we need to undo any + // escaping within the string?) or with neither " nor SPC and + // spanning to the next SPC (if any; TODO: is this from not + // wrapped in "..." relevant? it would have been parsed by the + // original code even if that was only by accident, so I left it + // in), with runs of SPCs treated like single ones: + switch ( rCmd[n] ) { case '"': - aData.remove( n, 1 ); - while ( n < aData.getLength() && aData[n] != '"' ) - ++n; - if ( n < aData.getLength() ) - aData.remove( n, 1 ); - break; + { + sal_Int32 i = rCmd.indexOf('"', ++n); + if (i < 0 || i > rCmd.getLength() - 1) { + i = rCmd.getLength() - 1; + } + aData.push_back(rCmd.copy(n, i - n)); + n = i + 1; + break; + } case ' ': - aData[n++] = '\n'; - break; - default: ++n; break; + default: + { + sal_Int32 i = rCmd.indexOf(' ', n); + if (i < 0 || i > rCmd.getLength() - 1) { + i = rCmd.getLength() - 1; + } + aData.push_back(rCmd.copy(n, i - n)); + n = i + 1; + break; + } } } - rAppEvent = ApplicationEvent(eType, aData.makeStringAndClear()); + GetpApp()->AppEvent( ApplicationEvent(eType, aData) ); return sal_True; } } @@ -284,7 +302,8 @@ sal_Bool SfxAppEvent_Impl( ApplicationEvent &rAppEvent, return sal_False; } -#if defined( WNT ) +} + /* Description] This method can be overloaded by application developers, to receive @@ -297,11 +316,8 @@ sal_Bool SfxAppEvent_Impl( ApplicationEvent &rAppEvent, long SfxApplication::DdeExecute( const OUString& rCmd ) // Expressed in our BASIC-Syntax { // Print or Open-Event? - ApplicationEvent aAppEvent; - if ( SfxAppEvent_Impl( aAppEvent, rCmd, "Print", ApplicationEvent::TYPE_PRINT ) || - SfxAppEvent_Impl( aAppEvent, rCmd, "Open", ApplicationEvent::TYPE_OPEN ) ) - GetpApp()->AppEvent( aAppEvent ); - else + if ( !( SfxAppEvent_Impl( rCmd, "Print", ApplicationEvent::TYPE_PRINT ) || + SfxAppEvent_Impl( rCmd, "Open", ApplicationEvent::TYPE_OPEN ) ) ) { // all others are BASIC StarBASIC* pBasic = GetBasic(); @@ -315,6 +331,7 @@ long SfxApplication::DdeExecute( const OUString& rCmd ) // Expressed in our B } return 1; } + #endif /* [Description] |