diff options
author | Michael Meeks <michael.meeks@suse.com> | 2012-03-21 19:06:35 +0000 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-17 16:39:28 +0200 |
commit | c0f49f43d1c07980625a4eb4e1bb344013c74316 (patch) | |
tree | e0aff231d84884997ff3a51226ea1cc0b130698b /sc/source | |
parent | 5e23c25b4efc0a4bbc0611bc0981731a2c8f8194 (diff) |
split ScDocFunc interceptor to new collab/ module and start on it
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 134 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 80 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 2 |
3 files changed, 138 insertions, 78 deletions
diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx new file mode 100644 index 000000000000..ccc785d725b0 --- /dev/null +++ b/sc/source/ui/collab/sendfunc.cxx @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * Copyright (C) 2012 Michael Meeks <michael.meeks@suse.com> (initial developer) + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include "sal/config.h" +#include "cell.hxx" +#include "docsh.hxx" +#include "docfunc.hxx" + +namespace { + +// Ye noddy protocol ! +// method name ',' then arguments comma separated +class ScChangeOp +{ + rtl::OUStringBuffer aMessage; +public: + ScChangeOp( const char *pName ) + { + aMessage.appendAscii( pName ); + aMessage.append( sal_Unicode( ',' ) ); + } + + void appendString( const ScAddress &rPos ) + { + rtl::OUString aStr; + rPos.Format( aStr ); + aMessage.append( aStr ); + } + + void appendAddress( const ScAddress &rPos ) + { + (void)rPos; + } +}; + +class ScDocFuncIntercept : public ScDocFunc +{ +public: + ScDocFuncIntercept( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) + { + fprintf( stderr, "Interceptor created !\n" ); + } + virtual ~ScDocFuncIntercept() {} + virtual void EnterListAction( sal_uInt16 nNameResId ) + { + // Want to group these operations for the other side ... + String aUndo( ScGlobal::GetRscString( nNameResId ) ); + } + virtual void EndListAction() + { + } + virtual ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, + const String& rFormulaNmsp, + const formula::FormulaGrammar::Grammar eGrammar, + short* pRetFormatType ) + { + fprintf( stderr, "interp. english string '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::InterpretEnglishString( rPos, rText, rFormulaNmsp, + eGrammar, pRetFormatType ); + } + virtual sal_Bool SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi ) + { + fprintf( stderr, "set normal string '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::SetNormalString( rPos, rText, bApi ); + } + + virtual sal_Bool PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi ) + { + fprintf( stderr, "put cell '%p' type %d %d\n", pNewCell, pNewCell->GetCellType(), bApi ); + return ScDocFunc::PutCell( rPos, pNewCell, bApi ); + } + + virtual sal_Bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, + sal_Bool bInterpret, sal_Bool bApi ) + { + fprintf( stderr, "put data\n" ); + return ScDocFunc::PutData( rPos, rEngine, bInterpret, bApi ); + } + + virtual sal_Bool SetCellText( const ScAddress& rPos, const String& rText, + sal_Bool bInterpret, sal_Bool bEnglish, sal_Bool bApi, + const String& rFormulaNmsp, + const formula::FormulaGrammar::Grammar eGrammar ) + { + fprintf( stderr, "set cell text '%s'\n", + rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); + return ScDocFunc::SetCellText( rPos, rText, bInterpret, bEnglish, bApi, rFormulaNmsp, eGrammar ); + } + + virtual bool ShowNote( const ScAddress& rPos, bool bShow = true ) + { + fprintf( stderr, "%s note\n", bShow ? "show" : "hide" ); + return ScDocFunc::ShowNote( rPos, bShow ); + } +}; + +} // anonymous namespace + +SC_DLLPRIVATE ScDocFunc *ScDocShell::CreateDocFunc() +{ + if (getenv ("INTERCEPT")) + return new ScDocFuncIntercept( *this ); + else + return new ScDocFuncDirect( *this ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index ecc3d24af4e9..475f3b77115d 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2500,82 +2500,6 @@ sal_Bool ScDocShell::HasAutomaticTableName( const String& rFilter ) || rFilter.EqualsAscii( pFilterRtf ); } -namespace { - -class ScDocFuncIntercept : public ScDocFunc -{ -public: - ScDocFuncIntercept( ScDocShell& rDocSh ) : ScDocFunc( rDocSh ) - { - fprintf( stderr, "Interceptor created !\n" ); - } - virtual ~ScDocFuncIntercept() {} - virtual void EnterListAction( sal_uInt16 nNameResId ) - { - // Want to group these operations for the other side ... - String aUndo( ScGlobal::GetRscString( nNameResId ) ); - } - virtual void EndListAction() - { - } - virtual ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText, - const String& rFormulaNmsp, - const formula::FormulaGrammar::Grammar eGrammar, - short* pRetFormatType ) - { - fprintf( stderr, "interp. english string '%s'\n", - rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); - return ScDocFunc::InterpretEnglishString( rPos, rText, rFormulaNmsp, - eGrammar, pRetFormatType ); - } - virtual sal_Bool SetNormalString( const ScAddress& rPos, const String& rText, sal_Bool bApi ) - { - fprintf( stderr, "set normal string '%s'\n", - rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); - return ScDocFunc::SetNormalString( rPos, rText, bApi ); - } - - virtual sal_Bool PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, sal_Bool bApi ) - { - fprintf( stderr, "put cell '%p' type %d %d\n", pNewCell, pNewCell->GetCellType(), bApi ); - return ScDocFunc::PutCell( rPos, pNewCell, bApi ); - } - - virtual sal_Bool PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, - sal_Bool bInterpret, sal_Bool bApi ) - { - fprintf( stderr, "put data\n" ); - return ScDocFunc::PutData( rPos, rEngine, bInterpret, bApi ); - } - - virtual sal_Bool SetCellText( const ScAddress& rPos, const String& rText, - sal_Bool bInterpret, sal_Bool bEnglish, sal_Bool bApi, - const String& rFormulaNmsp, - const formula::FormulaGrammar::Grammar eGrammar ) - { - fprintf( stderr, "set cell text '%s'\n", - rtl::OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ).getStr() ); - return ScDocFunc::SetCellText( rPos, rText, bInterpret, bEnglish, bApi, rFormulaNmsp, eGrammar ); - } - - virtual bool ShowNote( const ScAddress& rPos, bool bShow = true ) - { - fprintf( stderr, "%s note\n", bShow ? "show" : "hide" ); - return ScDocFunc::ShowNote( rPos, bShow ); - } -}; - -static ScDocFunc * -createDocFunc( ScDocShell *pThis ) -{ - if (getenv ("INTERCEPT")) - return new ScDocFuncIntercept( *pThis ); - else - return new ScDocFuncDirect( *pThis ); -} - -} // anonymous namespace - ScDocShell::ScDocShell( const ScDocShell& rShell ) : SvRefBase(), SotObject(), @@ -2607,7 +2531,7 @@ ScDocShell::ScDocShell( const ScDocShell& rShell ) : bIsInplace = rShell.bIsInplace; - pDocFunc = createDocFunc( this ); + pDocFunc = CreateDocFunc(); // SetBaseModel needs exception handling ScModelObj::CreateAndSet( this ); @@ -2654,7 +2578,7 @@ ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags ) : bIsInplace = (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED); // wird zurueckgesetzt, wenn nicht inplace - pDocFunc = createDocFunc( this ); + pDocFunc = CreateDocFunc(); // SetBaseModel needs exception handling ScModelObj::CreateAndSet( this ); diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index eeb0124299b3..3971e5edc19e 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -165,6 +165,8 @@ class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener SC_DLLPRIVATE void UseSheetSaveEntries(); + SC_DLLPRIVATE ScDocFunc *CreateDocFunc(); + protected: virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); |