1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #include "CanvasUpdateRequester.hxx"
21 #include <vcl/svapp.hxx>
22 #include <com/sun/star/lang/XComponent.hpp>
24 using namespace ::com::sun::star
;
25 using namespace ::com::sun::star::uno
;
27 namespace sd
{ namespace presenter
{
29 //===== CanvasUpdateRequester::Deleter ========================================
31 class CanvasUpdateRequester::Deleter
34 void operator() (CanvasUpdateRequester
* pObject
) { delete pObject
; }
37 //===== CanvasUpdateRequester =================================================
39 CanvasUpdateRequester::RequesterMap
CanvasUpdateRequester::maRequesterMap
;
41 ::boost::shared_ptr
<CanvasUpdateRequester
> CanvasUpdateRequester::Instance (
42 const Reference
<rendering::XSpriteCanvas
>& rxSharedCanvas
)
44 RequesterMap::const_iterator iRequester
;
45 for (iRequester
=maRequesterMap
.begin(); iRequester
!=maRequesterMap
.end(); ++iRequester
)
47 if (iRequester
->first
== rxSharedCanvas
)
48 return iRequester
->second
;
51 // No requester for the given canvas found. Create a new one.
52 ::boost::shared_ptr
<CanvasUpdateRequester
> pRequester (
53 new CanvasUpdateRequester(rxSharedCanvas
), Deleter());
54 maRequesterMap
.push_back(RequesterMap::value_type(rxSharedCanvas
,pRequester
));
58 CanvasUpdateRequester::CanvasUpdateRequester (
59 const Reference
<rendering::XSpriteCanvas
>& rxCanvas
)
64 Reference
<lang::XComponent
> xComponent (mxCanvas
, UNO_QUERY
);
67 //xComponent->addEventListener(this);
71 CanvasUpdateRequester::~CanvasUpdateRequester()
73 if (mnUserEventId
!= 0)
74 Application::RemoveUserEvent(mnUserEventId
);
77 void CanvasUpdateRequester::RequestUpdate (const bool bUpdateAll
)
79 if (mnUserEventId
== 0)
81 mbUpdateFlag
= bUpdateAll
;
82 mnUserEventId
= Application::PostUserEvent(LINK(this, CanvasUpdateRequester
, Callback
));
86 mbUpdateFlag
|= bUpdateAll
;
90 IMPL_LINK_NOARG(CanvasUpdateRequester
, Callback
)
95 mxCanvas
->updateScreen(mbUpdateFlag
);
101 } } // end of namespace ::sd::presenter
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */