summaryrefslogtreecommitdiff
path: root/sc/source/ui/collab/sccollaboration.cxx
blob: e9c4ea0c2e889d56b379116422d8715c4d2eaf9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "sccollaboration.hxx"

#include "docsh.hxx"
#include "sendfunc.hxx"

ScCollaboration::ScCollaboration( ScDocShell* pScDocShell ) :
    mpScDocShell( pScDocShell )
{
}

ScCollaboration::~ScCollaboration()
{
}

void ScCollaboration::ContactLeft()
{
    SAL_INFO( "sc.tubes", "Contact has left the collaboration" );
    ScDocFuncSend* pSender = GetScDocFuncSend();
    if (pSender)
    {
        delete pSender;
        mpScDocShell->SetDocFunc( new ScDocFuncDirect( *mpScDocShell ) );
    }
}

TeleConference* ScCollaboration::GetConference()
{
    ScDocFuncSend* pSender = GetScDocFuncSend();
    if (pSender)
        return pSender->GetConference();

    return NULL;
}

sal_uInt64 ScCollaboration::GetId()
{
    return reinterpret_cast<sal_uInt64> (mpScDocShell);
}

void ScCollaboration::PacketReceived( const OString& rPacket )
{
    ScDocFuncSend* pSender = GetScDocFuncSend();
    if (pSender)
        return pSender->RecvMessage( rPacket );
}

void ScCollaboration::SetCollaboration( TeleConference* pConference )
{
    ScDocFunc* pDocFunc = &mpScDocShell->GetDocFunc();
    ScDocFuncSend* pSender = dynamic_cast<ScDocFuncSend*> (pDocFunc);
    if (!pSender)
    {
        // This means pDocFunc has to be ScDocFuncDirect* and we are not collaborating yet.
        pSender = new ScDocFuncSend( *mpScDocShell, dynamic_cast<ScDocFuncDirect*> (pDocFunc) );
        mpScDocShell->SetDocFunc( pSender );
    }
    pSender->SetCollaboration( pConference );
}

void ScCollaboration::SendFile( TpContact* pContact, const OUString& rURL )
{
    ScDocFuncSend* pSender = GetScDocFuncSend();
    if (pSender)
        pSender->SendFile( pContact, rURL );
}

ScDocFuncSend* ScCollaboration::GetScDocFuncSend()
{
    return dynamic_cast<ScDocFuncSend*> (&mpScDocShell->GetDocFunc());
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */