1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: CanvasUpdateRequester.cxx,v $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_sd.hxx"
34 #include "CanvasUpdateRequester.hxx"
35 #include <vcl/svapp.hxx>
36 #include <com/sun/star/lang/XComponent.hpp>
38 using namespace ::com::sun::star
;
39 using namespace ::com::sun::star::uno
;
40 using ::rtl::OUString
;
42 namespace sd
{ namespace presenter
{
44 //===== CanvasUpdateRequester::Deleter ========================================
46 class CanvasUpdateRequester::Deleter
49 void operator() (CanvasUpdateRequester
* pObject
) { delete pObject
; }
55 //===== CanvasUpdateRequester =================================================
57 CanvasUpdateRequester::RequesterMap
CanvasUpdateRequester::maRequesterMap
;
59 ::boost::shared_ptr
<CanvasUpdateRequester
> CanvasUpdateRequester::Instance (
60 const Reference
<rendering::XSpriteCanvas
>& rxSharedCanvas
)
62 RequesterMap::const_iterator iRequester
;
63 for (iRequester
=maRequesterMap
.begin(); iRequester
!=maRequesterMap
.end(); ++iRequester
)
65 if (iRequester
->first
== rxSharedCanvas
)
66 return iRequester
->second
;
69 // No requester for the given canvas found. Create a new one.
70 ::boost::shared_ptr
<CanvasUpdateRequester
> pRequester (
71 new CanvasUpdateRequester(rxSharedCanvas
), Deleter());
72 maRequesterMap
.push_back(RequesterMap::value_type(rxSharedCanvas
,pRequester
));
79 CanvasUpdateRequester::CanvasUpdateRequester (
80 const Reference
<rendering::XSpriteCanvas
>& rxCanvas
)
83 mbUpdateFlag(sal_False
)
85 Reference
<lang::XComponent
> xComponent (mxCanvas
, UNO_QUERY
);
88 //xComponent->addEventListener(this);
95 CanvasUpdateRequester::~CanvasUpdateRequester (void)
97 if (mnUserEventId
!= 0)
98 Application::RemoveUserEvent(mnUserEventId
);
104 void CanvasUpdateRequester::RequestUpdate (const sal_Bool bUpdateAll
)
106 if (mnUserEventId
== 0)
108 mbUpdateFlag
= bUpdateAll
;
109 mnUserEventId
= Application::PostUserEvent(LINK(this, CanvasUpdateRequester
, Callback
));
113 mbUpdateFlag
|= bUpdateAll
;
119 IMPL_LINK(CanvasUpdateRequester
, Callback
, void*, EMPTYARG
)
124 mxCanvas
->updateScreen(mbUpdateFlag
);
125 mbUpdateFlag
= sal_False
;
131 } } // end of namespace ::sd::presenter