bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / presenter / CanvasUpdateRequester.cxx
blob0f73676fff4bec66da3d7a9ec94c721fed483ad3
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 .
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
33 public:
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));
55 return pRequester;
58 CanvasUpdateRequester::CanvasUpdateRequester (
59 const Reference<rendering::XSpriteCanvas>& rxCanvas)
60 : mxCanvas(rxCanvas),
61 mnUserEventId(0),
62 mbUpdateFlag(false)
64 Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
65 if (xComponent.is())
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));
84 else
86 mbUpdateFlag |= bUpdateAll;
90 IMPL_LINK_NOARG(CanvasUpdateRequester, Callback)
92 mnUserEventId = 0;
93 if (mxCanvas.is())
95 mxCanvas->updateScreen(mbUpdateFlag);
96 mbUpdateFlag = false;
98 return 0;
101 } } // end of namespace ::sd::presenter
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */