fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / presenter / CanvasUpdateRequester.cxx
blob16e1fd488c37888c17ea43a45811df141aa63849
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "CanvasUpdateRequester.hxx"
22 #include <vcl/svapp.hxx>
23 #include <com/sun/star/lang/XComponent.hpp>
25 using namespace ::com::sun::star;
26 using namespace ::com::sun::star::uno;
28 namespace sd { namespace presenter {
30 //===== CanvasUpdateRequester::Deleter ========================================
32 class CanvasUpdateRequester::Deleter
34 public:
35 void operator() (CanvasUpdateRequester* pObject) { delete pObject; }
41 //===== CanvasUpdateRequester =================================================
43 CanvasUpdateRequester::RequesterMap CanvasUpdateRequester::maRequesterMap;
45 ::boost::shared_ptr<CanvasUpdateRequester> CanvasUpdateRequester::Instance (
46 const Reference<rendering::XSpriteCanvas>& rxSharedCanvas)
48 RequesterMap::const_iterator iRequester;
49 for (iRequester=maRequesterMap.begin(); iRequester!=maRequesterMap.end(); ++iRequester)
51 if (iRequester->first == rxSharedCanvas)
52 return iRequester->second;
55 // No requester for the given canvas found. Create a new one.
56 ::boost::shared_ptr<CanvasUpdateRequester> pRequester (
57 new CanvasUpdateRequester(rxSharedCanvas), Deleter());
58 maRequesterMap.push_back(RequesterMap::value_type(rxSharedCanvas,pRequester));
59 return pRequester;
65 CanvasUpdateRequester::CanvasUpdateRequester (
66 const Reference<rendering::XSpriteCanvas>& rxCanvas)
67 : mxCanvas(rxCanvas),
68 mnUserEventId(0),
69 mbUpdateFlag(sal_False)
71 Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
72 if (xComponent.is())
74 //xComponent->addEventListener(this);
81 CanvasUpdateRequester::~CanvasUpdateRequester (void)
83 if (mnUserEventId != 0)
84 Application::RemoveUserEvent(mnUserEventId);
90 void CanvasUpdateRequester::RequestUpdate (const sal_Bool bUpdateAll)
92 if (mnUserEventId == 0)
94 mbUpdateFlag = bUpdateAll;
95 mnUserEventId = Application::PostUserEvent(LINK(this, CanvasUpdateRequester, Callback));
97 else
99 mbUpdateFlag |= bUpdateAll;
105 IMPL_LINK_NOARG(CanvasUpdateRequester, Callback)
107 mnUserEventId = 0;
108 if (mxCanvas.is())
110 mxCanvas->updateScreen(mbUpdateFlag);
111 mbUpdateFlag = sal_False;
113 return 0;
117 } } // end of namespace ::sd::presenter
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */