Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "CanvasUpdateRequester.hxx"
31 : : #include <vcl/svapp.hxx>
32 : : #include <com/sun/star/lang/XComponent.hpp>
33 : :
34 : : using namespace ::com::sun::star;
35 : : using namespace ::com::sun::star::uno;
36 : : using ::rtl::OUString;
37 : :
38 : : namespace sd { namespace presenter {
39 : :
40 : : //===== CanvasUpdateRequester::Deleter ========================================
41 : :
42 : : class CanvasUpdateRequester::Deleter
43 : : {
44 : : public:
45 [ # # ]: 0 : void operator() (CanvasUpdateRequester* pObject) { delete pObject; }
46 : : };
47 : :
48 : :
49 : :
50 : :
51 : : //===== CanvasUpdateRequester =================================================
52 : :
53 : 25 : CanvasUpdateRequester::RequesterMap CanvasUpdateRequester::maRequesterMap;
54 : :
55 : 0 : ::boost::shared_ptr<CanvasUpdateRequester> CanvasUpdateRequester::Instance (
56 : : const Reference<rendering::XSpriteCanvas>& rxSharedCanvas)
57 : : {
58 : 0 : RequesterMap::const_iterator iRequester;
59 [ # # ][ # # ]: 0 : for (iRequester=maRequesterMap.begin(); iRequester!=maRequesterMap.end(); ++iRequester)
[ # # ]
60 : : {
61 [ # # ][ # # ]: 0 : if (iRequester->first == rxSharedCanvas)
62 [ # # ]: 0 : return iRequester->second;
63 : : }
64 : :
65 : : // No requester for the given canvas found. Create a new one.
66 : : ::boost::shared_ptr<CanvasUpdateRequester> pRequester (
67 [ # # ][ # # ]: 0 : new CanvasUpdateRequester(rxSharedCanvas), Deleter());
[ # # ]
68 [ # # ][ # # ]: 0 : maRequesterMap.push_back(RequesterMap::value_type(rxSharedCanvas,pRequester));
[ # # ]
69 [ # # ][ # # ]: 0 : return pRequester;
70 : : }
71 : :
72 : :
73 : :
74 : :
75 : 0 : CanvasUpdateRequester::CanvasUpdateRequester (
76 : : const Reference<rendering::XSpriteCanvas>& rxCanvas)
77 : : : mxCanvas(rxCanvas),
78 : : mnUserEventId(0),
79 : 0 : mbUpdateFlag(sal_False)
80 : : {
81 [ # # ]: 0 : Reference<lang::XComponent> xComponent (mxCanvas, UNO_QUERY);
82 : 0 : if (xComponent.is())
83 : : {
84 : : //xComponent->addEventListener(this);
85 : 0 : }
86 : 0 : }
87 : :
88 : :
89 : :
90 : :
91 : 0 : CanvasUpdateRequester::~CanvasUpdateRequester (void)
92 : : {
93 [ # # ]: 0 : if (mnUserEventId != 0)
94 [ # # ]: 0 : Application::RemoveUserEvent(mnUserEventId);
95 : 0 : }
96 : :
97 : :
98 : :
99 : :
100 : 0 : void CanvasUpdateRequester::RequestUpdate (const sal_Bool bUpdateAll)
101 : : {
102 [ # # ]: 0 : if (mnUserEventId == 0)
103 : : {
104 : 0 : mbUpdateFlag = bUpdateAll;
105 [ # # ]: 0 : mnUserEventId = Application::PostUserEvent(LINK(this, CanvasUpdateRequester, Callback));
106 : : }
107 : : else
108 : : {
109 : 0 : mbUpdateFlag |= bUpdateAll;
110 : : }
111 : 0 : }
112 : :
113 : :
114 : :
115 : 0 : IMPL_LINK_NOARG(CanvasUpdateRequester, Callback)
116 : : {
117 : 0 : mnUserEventId = 0;
118 [ # # ]: 0 : if (mxCanvas.is())
119 : : {
120 : 0 : mxCanvas->updateScreen(mbUpdateFlag);
121 : 0 : mbUpdateFlag = sal_False;
122 : : }
123 : 0 : return 0;
124 : : }
125 : :
126 : :
127 [ + - ][ + - ]: 75 : } } // end of namespace ::sd::presenter
128 : :
129 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|