diff options
Diffstat (limited to 'sc/source/ui/collab/sendfunc.cxx')
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index 75233cfe218b..37f51c2099ca 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -32,8 +32,226 @@ #include "docsh.hxx" #include "docfunc.hxx" #include "sccollaboration.hxx" +#include <editeng/editobj.hxx> #include <tubes/manager.hxx> +namespace { + +OUString formulaCellToString( ScFormulaCell *pCell ) +{ + (void)pCell; // FIXME: implement me + return OUString(); +} + +OUString editToString( const EditTextObject& /*rEditText*/ ) +{ + // FIXME: implement me. + return OUString(); +} + +EditTextObject stringToEdit( const OUString& rStr ) +{ + // FIXME: implement me. + return EditTextObject(); +} + +ScFormulaCell* stringToFormulaCell( const OUString &rString ) +{ + (void)rString; // FIXME: implement me + return NULL; +} + +struct ProtocolError { + const char *message; +}; + +class ScChangeOpReader { + std::vector< rtl::OUString > maArgs; + +public: + ScChangeOpReader( const rtl::OUString &rString) + { + // will need to handle escaping etc. + // Surely someone else wrote this before ! [!?] + enum { + IN_TEXT, CHECK_QUOTE, FIND_LAST_QUOTE, SKIP_SEMI + } eState = CHECK_QUOTE; + + sal_Int32 nStart = 0; + for (sal_Int32 n = 0; n < rString.getLength(); n++) + { + if (rString[n] == '\\') + { + n++; // skip next char + continue; + } + switch (eState) { + case CHECK_QUOTE: + if (rString[n] == '"') + { + nStart = n + 1; + eState = FIND_LAST_QUOTE; + break; + } + // else drop through + case IN_TEXT: + if (rString[n] == ';') + { + maArgs.push_back( rString.copy( nStart, n - nStart ) ); + nStart = n + 1; + eState = CHECK_QUOTE; + } + break; + case FIND_LAST_QUOTE: + if (rString[n] == '"') + { + maArgs.push_back( rString.copy( nStart, n - nStart ) ); + eState = SKIP_SEMI; + break; + } + break; + case SKIP_SEMI: + if (rString[n] == ';') + { + nStart = n + 1; + eState = CHECK_QUOTE; + } + break; + } + } + if ( nStart < rString.getLength()) + maArgs.push_back( rString.copy( nStart, rString.getLength() - nStart ) ); + } + ~ScChangeOpReader() {} + + rtl::OUString getMethod() + { + return maArgs[0]; + } + + size_t getArgCount() { return maArgs.size(); } + + rtl::OUString getString( sal_Int32 n ) + { + if (n > 0 && (size_t)n < getArgCount() ) + { + rtl::OUString aUStr( maArgs[ n ] ); + ScGlobal::EraseQuotes( aUStr ); + return aUStr; + } else + return rtl::OUString(); + } + + ScAddress getAddress( sal_Int32 n ) + { + ScAddress aAddr; + rtl::OUString aToken( getString( n ) ); + aAddr.Parse( aToken ); + return aAddr; + } + + sal_Int32 getInt( sal_Int32 n ) + { + return getString( n ).toInt32(); + } + + bool getBool( sal_Int32 n ) + { + return getString( n ).equalsIgnoreAsciiCase( "true" ); + } + + ScFormulaCell* getFormulaCell( sal_Int32 n ) + { + return stringToFormulaCell( getString( n ) ); + } + + double getDouble( sal_Int32 n ) + { + return getString(n).toDouble(); + } + + EditTextObject getEdit( sal_Int32 n ) + { + return stringToEdit(getString(n)); + } + +}; + +} // anonymous namespace + +// Ye noddy mangling - needs improvement ... +// method name ';' then arguments ; separated +class ScChangeOpWriter +{ + rtl::OUStringBuffer aMessage; + void appendSeparator() + { + aMessage.append( sal_Unicode( ';' ) ); + } + +public: + ScChangeOpWriter( const char *pName ) + { + aMessage.appendAscii( pName ); + appendSeparator(); + } + + void appendString( const rtl::OUString &rStr ) + { + if ( rStr.indexOf( sal_Unicode( '"' ) ) >= 0 || + rStr.indexOf( sal_Unicode( ';' ) ) >= 0 ) + { + rtl::OUString aQuoted( rStr ); + ScGlobal::AddQuotes( aQuoted, sal_Unicode( '"' ) ); + aMessage.append( aQuoted ); + } + else + aMessage.append( rStr ); + appendSeparator(); + } + + void appendAddress( const ScAddress &rPos ) + { + rtl::OUString aStr; + rPos.Format( aStr, SCA_VALID ); + aMessage.append( aStr ); + appendSeparator(); + } + + void appendInt( sal_Int32 i ) + { + aMessage.append( i ); + appendSeparator(); + } + + void appendBool( sal_Bool b ) + { + aMessage.appendAscii( b ? "true" : "false" ); + appendSeparator(); + } + + void appendFormulaCell( ScFormulaCell *pCell ) + { + appendString( formulaCellToString( pCell ) ); + } + + void appendEditText( const EditTextObject& rStr ) + { + appendString( editToString(rStr) ); + } + + void appendDouble( double fVal ) + { + aMessage.append(fVal); + appendSeparator(); + } + + rtl::OString toString() + { + return rtl::OUStringToOString( aMessage.toString(), RTL_TEXTENCODING_UTF8 ); + } +}; + void ScDocFuncSend::RecvMessage( const rtl::OString &rString ) { try { |