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 "ToolBarManager.hxx"
31 : :
32 : : #include "DrawViewShell.hxx"
33 : : #include "EventMultiplexer.hxx"
34 : : #include "ViewShellBase.hxx"
35 : : #include "ViewShellManager.hxx"
36 : : #include <com/sun/star/beans/XPropertySet.hpp>
37 : : #include <com/sun/star/frame/XLayoutManager.hpp>
38 : : #include <com/sun/star/ui/UIElementType.hpp>
39 : :
40 : : #include <cppuhelper/implbase1.hxx>
41 : : #include <osl/mutex.hxx>
42 : : #include <rtl/ref.hxx>
43 : : #include <sfx2/app.hxx>
44 : : #include <sfx2/docfile.hxx>
45 : : #include <sfx2/objsh.hxx>
46 : : #include <sfx2/request.hxx>
47 : : #include <sfx2/viewfrm.hxx>
48 : : #include <svl/eitem.hxx>
49 : : #include <svx/dialogs.hrc>
50 : : #include <svx/extrusionbar.hxx>
51 : : #include <svx/fontworkbar.hxx>
52 : : #include <toolkit/unohlp.hxx>
53 : : #include <tools/link.hxx>
54 : :
55 : : #include <map>
56 : : #include <vector>
57 : :
58 : : using namespace ::com::sun::star;
59 : : using namespace ::com::sun::star::uno;
60 : :
61 : : namespace {
62 : :
63 : : using namespace sd;
64 : :
65 : : class ToolBarRules;
66 : :
67 : : /** Lock of the frame::XLayoutManager.
68 : : */
69 : : class LayouterLock
70 : : {
71 : : public:
72 : : LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter);
73 : : ~LayouterLock (void);
74 : : private:
75 : : Reference<frame::XLayoutManager> mxLayouter;
76 : : };
77 : :
78 : :
79 : : typedef ::std::vector<rtl::OUString> NameList;
80 : :
81 : : /** Store a list of tool bars for each of the tool bar groups. From
82 : : this the list of requested tool bars is built.
83 : : */
84 : 130 : class ToolBarList
85 : : {
86 : : public:
87 : : ToolBarList (void);
88 : :
89 : : void ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup);
90 : : void AddToolBar (sd::ToolBarManager::ToolBarGroup eGroup, const ::rtl::OUString& rsName);
91 : : bool RemoveToolBar (sd::ToolBarManager::ToolBarGroup eGroup, const ::rtl::OUString& rsName);
92 : :
93 : : void GetToolBarsToActivate (NameList& rToolBars) const;
94 : : void GetToolBarsToDeactivate (NameList& rToolBars) const;
95 : :
96 : : void MarkToolBarAsActive (const ::rtl::OUString& rsName);
97 : : void MarkToolBarAsNotActive (const ::rtl::OUString& rsName);
98 : : void MarkAllToolBarsAsNotActive (void);
99 : :
100 : : private:
101 : : typedef ::std::map<sd::ToolBarManager::ToolBarGroup,NameList> Groups;
102 : : Groups maGroups;
103 : : NameList maActiveToolBars;
104 : :
105 : : void MakeRequestedToolBarList (NameList& rToolBars) const;
106 : : };
107 : :
108 : :
109 : :
110 : :
111 : : /** Manage tool bars that are implemented as sub shells of a view shell.
112 : : The typical procedure of updating the sub shells of a view shell is to
113 : : rebuild a list of sub shells that the caller would like to have active.
114 : : The methods ClearGroup() and AddShellId() allow the caller to do that. A
115 : : final call to UpdateShells() activates the requested shells that are not
116 : : active and deactivates the active shells that are not requested .
117 : :
118 : : This is done by maintaining two lists. One (the current list)
119 : : reflects the current state. The other (the requested list) contains the
120 : : currently requested shells. UpdateShells() makes the requested
121 : : list the current list and clears the current list.
122 : :
123 : : Each shell belongs to one group. Different groups can be modified
124 : : seperately.
125 : : */
126 : 130 : class ToolBarShellList
127 : : {
128 : : public:
129 : : /** Create a new object with an empty current list and an empty
130 : : requested list.
131 : : */
132 : : ToolBarShellList (void);
133 : :
134 : : /** Remove all shells from a group. Calling this method should normally
135 : : not be necessary because after the construction or after a call to
136 : : UpdateShells() the requested list is empty.
137 : : @param eGroup
138 : : The group to clear. Shells in other groups are not modified.
139 : : */
140 : : void ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup);
141 : :
142 : : /** Add a shell. When the specified shell has alreadt been requested
143 : : for another group then it is moved to this group.
144 : : @param eGroup
145 : : The group to which to add the shell.
146 : : @param nId
147 : : The id of the shell to add.
148 : : */
149 : : void AddShellId (sd::ToolBarManager::ToolBarGroup eGroup, sd::ShellId nId);
150 : :
151 : : /** Releasing all shells means that the given ToolBarRules object is
152 : : informed that every shell mananged by the called ToolBarShellList is
153 : : about to be removed and that the associated framework tool bars can
154 : : be removed as well. The caller still has to call UpdateShells().
155 : : */
156 : : void ReleaseAllShells (ToolBarRules& rRules);
157 : :
158 : : /** The requested list is made the current list by activating all
159 : : shells in the requested list and by deactivating the shells in the
160 : : current list that are not in the requested list.
161 : : @param pMainViewShell
162 : : The shells that are activated or deactivated are sub shells of
163 : : this view shell.
164 : : @param rManager
165 : : This ViewShellManager is used to activate or deactivate shells.
166 : : */
167 : : void UpdateShells (
168 : : const ::boost::shared_ptr<ViewShell>& rpMainViewShell,
169 : : const ::boost::shared_ptr<ViewShellManager>& rpManager);
170 : :
171 : : private:
172 : : class ShellDescriptor
173 : : {public:
174 : : ShellDescriptor (ShellId nId,sd::ToolBarManager::ToolBarGroup eGroup);
175 : : ShellId mnId;
176 : : sd::ToolBarManager::ToolBarGroup meGroup;
177 : 0 : friend bool operator<(const ShellDescriptor& r1, const ShellDescriptor& r2)
178 : 0 : { return r1.mnId < r2.mnId; }
179 : : };
180 : :
181 : : /** The requested list of tool bar shells that will be active after the
182 : : next call to UpdateShells().
183 : : */
184 : : typedef ::std::set<ShellDescriptor> GroupedShellList;
185 : : GroupedShellList maNewList;
186 : :
187 : : /** The list of tool bar shells that are currently on the shell stack.
188 : : Using a GroupedShellList is not strictly necessary but it makes
189 : : things easier and does not waste too much memory.
190 : : */
191 : : GroupedShellList maCurrentList;
192 : : };
193 : :
194 : :
195 : :
196 : :
197 : : /** This class concentrates the knowledge about when to show what tool bars
198 : : in one place.
199 : : */
200 [ + - ]: 130 : class ToolBarRules
201 : : {
202 : : public:
203 : : ToolBarRules (
204 : : const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager,
205 : : const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager);
206 : :
207 : : /** This method calls MainViewShellChanged() and SelectionHasChanged()
208 : : for the current main view shell and its view.
209 : : */
210 : : void Update (ViewShellBase& rBase);
211 : :
212 : : /** Reset all tool bars in all groups and add tool bars and tool bar
213 : : shells to the TBG_PERMANENT group for the specified ViewShell type.
214 : : */
215 : : void MainViewShellChanged (ViewShell::ShellType nShellType);
216 : :
217 : : /** Reset all tool bars in all groups and add tool bars and tool bar
218 : : shells to the TBG_PERMANENT group for the specified ViewShell.
219 : : */
220 : : void MainViewShellChanged (const ViewShell& rMainViewShell);
221 : :
222 : : /** Reset all tool bars in the TBG_FUNCTION group and add tool bars and tool bar
223 : : shells to this group for the current selection.
224 : : */
225 : : void SelectionHasChanged (
226 : : const ::sd::ViewShell& rViewShell,
227 : : const SdrView& rView);
228 : :
229 : : /** Add a tool bar for the specified tool bar shell.
230 : : */
231 : : void SubShellAdded (
232 : : ::sd::ToolBarManager::ToolBarGroup eGroup,
233 : : sd::ShellId nShellId);
234 : :
235 : : /** Remove a tool bar for the specified tool bar shell.
236 : : */
237 : : void SubShellRemoved (
238 : : ::sd::ToolBarManager::ToolBarGroup eGroup,
239 : : sd::ShellId nShellId);
240 : :
241 : : private:
242 : : ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
243 : : ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
244 : : };
245 : :
246 : : } // end of anonymous namespace
247 : :
248 : :
249 : :
250 : :
251 : : namespace sd {
252 : :
253 : : //===== ToolBarManager::Implementation ========================================
254 : :
255 : : class ToolBarManager::Implementation
256 : : {
257 : : public:
258 : : /** This constructor takes three arguments even though the
259 : : ToolBarManager could be taken from the ViewShellBase. This is so to
260 : : state explicitly which information has to be present when this
261 : : constructor is called. The ViewShellBase may not have been fully
262 : : initialized at this point and must not be asked for this values.
263 : : */
264 : : Implementation (
265 : : ViewShellBase& rBase,
266 : : const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
267 : : const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
268 : : const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager);
269 : : ~Implementation (void);
270 : :
271 : : void SetValid (bool bValid);
272 : :
273 : : void ResetToolBars (ToolBarGroup eGroup);
274 : : void ResetAllToolBars (void);
275 : : void AddToolBar (ToolBarGroup eGroup, const ::rtl::OUString& rsToolBarName);
276 : : void AddToolBarShell (ToolBarGroup eGroup, ShellId nToolBarId);
277 : : void RemoveToolBar (ToolBarGroup eGroup, const ::rtl::OUString& rsToolBarName);
278 : :
279 : : /** Release all tool bar shells and the associated framework tool bars.
280 : : Typically called when the main view shell is being replaced by
281 : : another, all tool bar shells are released. In that process the
282 : : shells are destroyed anyway and whithout calling this method they
283 : : would still be referenced.
284 : : */
285 : : void ReleaseAllToolBarShells (void);
286 : :
287 : : void ToolBarsDestroyed(void);
288 : :
289 : : void RequestUpdate (void);
290 : :
291 : : void PreUpdate (void);
292 : : void PostUpdate (void);
293 : : /** Tell the XLayoutManager about the tool bars that we would like to be
294 : : shown.
295 : : @param rpLayouterLock
296 : : This typically is the mpSynchronousLayouterLock that is used in
297 : : this method and that is either released at its end or assigned
298 : : to mpAsynchronousLock in order to be unlocked later.
299 : : */
300 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
301 : : void Update (::std::auto_ptr<LayouterLock> pLayouterLock);
302 : : SAL_WNODEPRECATED_DECLARATIONS_POP
303 : :
304 : : class UpdateLockImplementation
305 : : {
306 : : public:
307 : 260 : UpdateLockImplementation (Implementation& rImplementation)
308 : 260 : : mrImplementation(rImplementation) { mrImplementation.LockUpdate(); }
309 : 260 : ~UpdateLockImplementation (void) { mrImplementation.UnlockUpdate(); }
310 : : private:
311 : : Implementation& mrImplementation;
312 : : };
313 : :
314 : : void LockViewShellManager (void);
315 : : void LockUpdate (void);
316 : : void UnlockUpdate (void);
317 : :
318 : : ToolBarRules& GetToolBarRules (void);
319 : :
320 : : private:
321 : : const static ::rtl::OUString msToolBarResourcePrefix;
322 : :
323 : : mutable ::osl::Mutex maMutex;
324 : : ViewShellBase& mrBase;
325 : : ::boost::shared_ptr<sd::tools::EventMultiplexer> mpEventMultiplexer;
326 : : bool mbIsValid;
327 : : ToolBarList maToolBarList;
328 : : ToolBarShellList maToolBarShellList;
329 : : Reference<frame::XLayoutManager> mxLayouter;
330 : : sal_Int32 mnLockCount;
331 : : bool mbPreUpdatePending;
332 : : bool mbPostUpdatePending;
333 : : /** The layouter locks manage the locking of the XLayoutManager. The
334 : : lock() and unlock() functions are not called directly because the
335 : : (final) unlocking is usually done asynchronously *after* the
336 : : list of requested toolbars is updated.
337 : : */
338 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
339 : : ::std::auto_ptr<LayouterLock> mpSynchronousLayouterLock;
340 : : ::std::auto_ptr<LayouterLock> mpAsynchronousLayouterLock;
341 : : ::std::auto_ptr<ViewShellManager::UpdateLock> mpViewShellManagerLock;
342 : : SAL_WNODEPRECATED_DECLARATIONS_POP
343 : : sal_uLong mnPendingUpdateCall;
344 : : sal_uLong mnPendingSetValidCall;
345 : : ToolBarRules maToolBarRules;
346 : :
347 : : ::rtl::OUString GetToolBarResourceName (const ::rtl::OUString& rsBaseName) const;
348 : : bool CheckPlugInMode (const ::rtl::OUString& rsName) const;
349 : :
350 : : DECL_LINK(UpdateCallback, void *);
351 : : DECL_LINK(EventMultiplexerCallback, sd::tools::EventMultiplexerEvent*);
352 : : DECL_LINK(SetValidCallback,void*);
353 : : };
354 : :
355 : :
356 : :
357 : : //===== ToolBarManager ========================================================
358 : :
359 : 25 : const ::rtl::OUString ToolBarManager::msToolBar("toolbar");
360 : 25 : const ::rtl::OUString ToolBarManager::msOptionsToolBar("optionsbar");
361 : 25 : const ::rtl::OUString ToolBarManager::msCommonTaskToolBar("commontaskbar");
362 : 25 : const ::rtl::OUString ToolBarManager::msViewerToolBar("viewerbar");
363 : 25 : const ::rtl::OUString ToolBarManager::msSlideSorterToolBar("slideviewtoolbar");
364 : 25 : const ::rtl::OUString ToolBarManager::msSlideSorterObjectBar("slideviewobjectbar");
365 : 25 : const ::rtl::OUString ToolBarManager::msOutlineToolBar("outlinetoolbar");
366 : 25 : const ::rtl::OUString ToolBarManager::msMasterViewToolBar("masterviewtoolbar");
367 : 25 : const ::rtl::OUString ToolBarManager::msDrawingObjectToolBar("drawingobjectbar");
368 : 25 : const ::rtl::OUString ToolBarManager::msGluePointsToolBar("gluepointsobjectbar");
369 : 25 : const ::rtl::OUString ToolBarManager::msTextObjectBar("textobjectbar");
370 : 25 : const ::rtl::OUString ToolBarManager::msBezierObjectBar("bezierobjectbar");
371 : 25 : const ::rtl::OUString ToolBarManager::msGraphicObjectBar("graphicobjectbar");
372 : 25 : const ::rtl::OUString ToolBarManager::msMediaObjectBar("mediaobjectbar");
373 : 25 : const ::rtl::OUString ToolBarManager::msTableObjectBar("tableobjectbar");
374 : :
375 : :
376 : 130 : ::boost::shared_ptr<ToolBarManager> ToolBarManager::Create (
377 : : ViewShellBase& rBase,
378 : : const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
379 : : const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager)
380 : : {
381 [ + - ][ + - ]: 130 : ::boost::shared_ptr<ToolBarManager> pManager (new ToolBarManager());
382 : 130 : pManager->mpImpl.reset(
383 [ + - ]: 260 : new Implementation(rBase,rpMultiplexer,rpViewShellManager,pManager));
[ + - + - ]
384 : 130 : return pManager;
385 : : }
386 : :
387 : :
388 : :
389 : :
390 : 130 : ToolBarManager::ToolBarManager (void)
391 : 130 : : mpImpl()
392 : : {
393 : 130 : }
394 : :
395 : :
396 : :
397 : :
398 [ + - ]: 130 : ToolBarManager::~ToolBarManager (void)
399 : : {
400 : 130 : }
401 : :
402 : :
403 : :
404 : :
405 : 130 : void ToolBarManager::Shutdown (void)
406 : : {
407 [ + - ]: 130 : if (mpImpl.get() != NULL)
408 : 130 : mpImpl.reset();
409 : 130 : }
410 : :
411 : :
412 : :
413 : :
414 : 678 : void ToolBarManager::ResetToolBars (ToolBarGroup eGroup)
415 : : {
416 [ + - ]: 678 : if (mpImpl.get() != NULL)
417 : : {
418 [ + - ][ + - ]: 678 : UpdateLock aLock (shared_from_this());
[ + - ]
419 [ + - ][ + - ]: 678 : mpImpl->ResetToolBars(eGroup);
420 : : }
421 : 678 : }
422 : :
423 : :
424 : :
425 : :
426 : 390 : void ToolBarManager::ResetAllToolBars (void)
427 : : {
428 [ + - ]: 390 : if (mpImpl.get() != NULL)
429 : : {
430 [ + - ][ + - ]: 390 : UpdateLock aLock (shared_from_this());
[ + - ]
431 [ + - ][ + - ]: 390 : mpImpl->ResetAllToolBars();
432 : : }
433 : 390 : }
434 : :
435 : :
436 : :
437 : :
438 : 832 : void ToolBarManager::AddToolBar (
439 : : ToolBarGroup eGroup,
440 : : const ::rtl::OUString& rsToolBarName)
441 : : {
442 [ + - ]: 832 : if (mpImpl.get() != NULL)
443 : : {
444 [ + - ][ + - ]: 832 : UpdateLock aLock (shared_from_this());
[ + - ]
445 [ + - ][ + - ]: 832 : mpImpl->AddToolBar(eGroup,rsToolBarName);
446 : : }
447 : 832 : }
448 : :
449 : :
450 : :
451 : :
452 : 0 : void ToolBarManager::AddToolBarShell (
453 : : ToolBarGroup eGroup,
454 : : ShellId nToolBarId)
455 : : {
456 [ # # ]: 0 : if (mpImpl.get() != NULL)
457 : : {
458 [ # # ][ # # ]: 0 : UpdateLock aLock (shared_from_this());
[ # # ]
459 [ # # ][ # # ]: 0 : mpImpl->AddToolBarShell(eGroup,nToolBarId);
460 : : }
461 : 0 : }
462 : :
463 : :
464 : :
465 : :
466 : 0 : void ToolBarManager::RemoveToolBar (
467 : : ToolBarGroup eGroup,
468 : : const ::rtl::OUString& rsToolBarName)
469 : : {
470 [ # # ]: 0 : if (mpImpl.get() != NULL)
471 : : {
472 [ # # ][ # # ]: 0 : UpdateLock aLock (shared_from_this());
[ # # ]
473 [ # # ][ # # ]: 0 : mpImpl->RemoveToolBar(eGroup,rsToolBarName);
474 : : }
475 : 0 : }
476 : :
477 : :
478 : :
479 : :
480 : 522 : void ToolBarManager::SetToolBar (
481 : : ToolBarGroup eGroup,
482 : : const ::rtl::OUString& rsToolBarName)
483 : : {
484 [ + - ]: 522 : if (mpImpl.get() != NULL)
485 : : {
486 [ + - ][ + - ]: 522 : UpdateLock aLock (shared_from_this());
[ + - ]
487 [ + - ]: 522 : mpImpl->ResetToolBars(eGroup);
488 [ + - ][ + - ]: 522 : mpImpl->AddToolBar(eGroup,rsToolBarName);
489 : : }
490 : 522 : }
491 : :
492 : :
493 : :
494 : :
495 : 0 : void ToolBarManager::SetToolBarShell (
496 : : ToolBarGroup eGroup,
497 : : ShellId nToolBarId)
498 : : {
499 [ # # ]: 0 : if (mpImpl.get() != NULL)
500 : : {
501 [ # # ][ # # ]: 0 : UpdateLock aLock (shared_from_this());
[ # # ]
502 [ # # ]: 0 : mpImpl->ResetToolBars(eGroup);
503 [ # # ][ # # ]: 0 : mpImpl->AddToolBarShell(eGroup,nToolBarId);
504 : : }
505 : 0 : }
506 : :
507 : :
508 : :
509 : :
510 : 260 : void ToolBarManager::PreUpdate (void)
511 : : {
512 [ + - ]: 260 : if (mpImpl.get()!=NULL)
513 : 260 : mpImpl->PreUpdate();
514 : 260 : }
515 : :
516 : :
517 : :
518 : :
519 : 130 : void ToolBarManager::RequestUpdate (void)
520 : : {
521 [ + - ]: 130 : if (mpImpl.get()!=NULL)
522 : 130 : mpImpl->RequestUpdate();
523 : 130 : }
524 : :
525 : :
526 : :
527 : :
528 : 934 : void ToolBarManager::LockViewShellManager (void)
529 : : {
530 [ + - ]: 934 : if (mpImpl.get() != NULL)
531 : 934 : mpImpl->LockViewShellManager();
532 : 934 : }
533 : :
534 : :
535 : :
536 : :
537 : 3876 : void ToolBarManager::LockUpdate (void)
538 : : {
539 [ + - ]: 3876 : if (mpImpl.get()!=NULL)
540 : 3876 : mpImpl->LockUpdate();
541 : 3876 : }
542 : :
543 : :
544 : :
545 : :
546 : 3876 : void ToolBarManager::UnlockUpdate (void)
547 : : {
548 [ + - ]: 3876 : if (mpImpl.get()!=NULL)
549 : 3876 : mpImpl->UnlockUpdate();
550 : 3876 : }
551 : :
552 : :
553 : :
554 : :
555 : 130 : void ToolBarManager::MainViewShellChanged (ViewShell::ShellType nShellType)
556 : : {
557 [ + - ]: 130 : if (mpImpl.get() != NULL)
558 : : {
559 : 130 : mpImpl->ReleaseAllToolBarShells();
560 : 130 : mpImpl->GetToolBarRules().MainViewShellChanged(nShellType);
561 : : }
562 : 130 : }
563 : :
564 : :
565 : :
566 : :
567 : 130 : void ToolBarManager::MainViewShellChanged (const ViewShell& rMainViewShell)
568 : : {
569 [ + - ]: 130 : if (mpImpl.get() != NULL)
570 : : {
571 : 130 : mpImpl->ReleaseAllToolBarShells();
572 : 130 : mpImpl->GetToolBarRules().MainViewShellChanged(rMainViewShell);
573 : : }
574 : 130 : }
575 : :
576 : :
577 : :
578 : :
579 : 392 : void ToolBarManager::SelectionHasChanged (
580 : : const ViewShell& rViewShell,
581 : : const SdrView& rView)
582 : : {
583 [ + - ]: 392 : if (mpImpl.get() != NULL)
584 : 392 : mpImpl->GetToolBarRules().SelectionHasChanged(rViewShell,rView);
585 : 392 : }
586 : :
587 : :
588 : 0 : void ToolBarManager::ToolBarsDestroyed(void)
589 : : {
590 [ # # ]: 0 : if (mpImpl.get() != NULL)
591 : 0 : mpImpl->ToolBarsDestroyed();
592 : 0 : }
593 : :
594 : :
595 : : //===== ToolBarManager::Implementation =======================================
596 : :
597 : 25 : const ::rtl::OUString ToolBarManager::Implementation::msToolBarResourcePrefix("private:resource/toolbar/");
598 : :
599 : 130 : ToolBarManager::Implementation::Implementation (
600 : : ViewShellBase& rBase,
601 : : const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
602 : : const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
603 : : const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager)
604 : : : maMutex(),
605 : : mrBase(rBase),
606 : : mpEventMultiplexer(rpMultiplexer),
607 : : mbIsValid(false),
608 : : maToolBarList(),
609 : : maToolBarShellList(),
610 : : mxLayouter(NULL),
611 : : mnLockCount(0),
612 : : mbPreUpdatePending(false),
613 : : mbPostUpdatePending(false),
614 : : mpSynchronousLayouterLock(),
615 : : mpAsynchronousLayouterLock(),
616 : : mpViewShellManagerLock(),
617 : : mnPendingUpdateCall(0),
618 : : mnPendingSetValidCall(0),
619 [ + - ][ + - ]: 130 : maToolBarRules(rpToolBarManager,rpViewShellManager)
[ + - ][ + - ]
[ + - ]
620 : : {
621 [ + - ]: 130 : Link aLink (LINK(this,ToolBarManager::Implementation,EventMultiplexerCallback));
622 : : mpEventMultiplexer->AddEventListener(
623 : : aLink,
624 : : tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED
625 : : | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED
626 [ + - ]: 130 : | tools::EventMultiplexerEvent::EID_PANE_MANAGER_DYING);
627 : 130 : }
628 : :
629 : :
630 : :
631 : : /** The order of statements is important.
632 : : First unregister listeners, which may post user events.
633 : : Then remove pending user events.
634 : : */
635 [ + - ][ + - ]: 130 : ToolBarManager::Implementation::~Implementation (void)
[ + - ][ + - ]
[ + - ]
636 : : {
637 : : // Unregister at broadcasters.
638 [ + - ]: 130 : Link aLink (LINK(this,ToolBarManager::Implementation,EventMultiplexerCallback));
639 [ + - ]: 130 : mpEventMultiplexer->RemoveEventListener(aLink);
640 : :
641 : : // Abort pending user calls.
642 [ + + ]: 130 : if (mnPendingUpdateCall != 0)
643 [ + - ]: 1 : Application::RemoveUserEvent(mnPendingUpdateCall);
644 [ - + ]: 130 : if (mnPendingSetValidCall != 0)
645 [ # # ]: 0 : Application::RemoveUserEvent(mnPendingSetValidCall);
646 : 130 : }
647 : :
648 : :
649 : 0 : void ToolBarManager::Implementation::ToolBarsDestroyed(void)
650 : : {
651 : 0 : maToolBarList.MarkAllToolBarsAsNotActive();
652 : 0 : }
653 : :
654 : :
655 : 260 : void ToolBarManager::Implementation::SetValid (bool bValid)
656 : : {
657 [ + - ]: 260 : ::osl::MutexGuard aGuard(maMutex);
658 : :
659 [ + - ]: 260 : if (mbIsValid != bValid)
660 : : {
661 [ + - ]: 260 : UpdateLockImplementation aUpdateLock (*this);
662 : :
663 : 260 : mbIsValid = bValid;
664 [ + + ]: 260 : if (mbIsValid)
665 : : {
666 : 130 : Reference<frame::XFrame> xFrame;
667 [ + - ]: 130 : if (mrBase.GetViewFrame() != NULL)
668 [ + - ][ + - ]: 130 : xFrame = mrBase.GetViewFrame()->GetFrame().GetFrameInterface();
[ + - ]
669 : : try
670 : : {
671 [ + - ]: 130 : Reference<beans::XPropertySet> xFrameProperties (xFrame, UNO_QUERY_THROW);
672 [ + - ][ + - ]: 130 : Any aValue (xFrameProperties->getPropertyValue("LayoutManager"));
673 [ # # ][ + - ]: 130 : aValue >>= mxLayouter;
674 : : }
675 [ # # ]: 0 : catch (const RuntimeException&)
676 : : {
677 : : }
678 : :
679 [ + - ]: 130 : GetToolBarRules().Update(mrBase);
680 : : }
681 : : else
682 : : {
683 [ + - ]: 130 : ResetAllToolBars();
684 [ + - ]: 130 : mxLayouter = NULL;
685 [ + - ]: 260 : }
686 [ + - ]: 260 : }
687 : 260 : }
688 : :
689 : :
690 : :
691 : :
692 : 2760 : void ToolBarManager::Implementation::ResetToolBars (ToolBarGroup eGroup)
693 : : {
694 [ + - ]: 2760 : ::osl::MutexGuard aGuard(maMutex);
695 : :
696 [ + - ]: 2760 : maToolBarList.ClearGroup(eGroup);
697 [ + - ]: 2760 : maToolBarShellList.ClearGroup(eGroup);
698 : :
699 [ + - ]: 2760 : mbPreUpdatePending = true;
700 : 2760 : }
701 : :
702 : :
703 : :
704 : :
705 : 520 : void ToolBarManager::Implementation::ResetAllToolBars (void)
706 : : {
707 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": resetting all tool bars");
708 [ + + ]: 2080 : for (int i=TBG__FIRST; i<=TBG__LAST; ++i)
709 : 1560 : ResetToolBars((ToolBarGroup)i);
710 : 520 : }
711 : :
712 : :
713 : :
714 : :
715 : 1354 : void ToolBarManager::Implementation::AddToolBar (
716 : : ToolBarGroup eGroup,
717 : : const ::rtl::OUString& rsToolBarName)
718 : : {
719 [ + - ]: 1354 : ::osl::MutexGuard aGuard(maMutex);
720 : :
721 [ + - ][ + + ]: 1354 : if (CheckPlugInMode(rsToolBarName))
722 : : {
723 [ + - ]: 1094 : maToolBarList.AddToolBar(eGroup,rsToolBarName);
724 : :
725 : 1094 : mbPostUpdatePending = true;
726 [ - + ]: 1094 : if (mnLockCount == 0)
727 [ # # ]: 0 : PostUpdate();
728 [ + - ]: 1354 : }
729 : 1354 : }
730 : :
731 : :
732 : :
733 : :
734 : 0 : void ToolBarManager::Implementation::RemoveToolBar (
735 : : ToolBarGroup eGroup,
736 : : const ::rtl::OUString& rsToolBarName)
737 : : {
738 [ # # ]: 0 : ::osl::MutexGuard aGuard(maMutex);
739 : :
740 [ # # ][ # # ]: 0 : if (maToolBarList.RemoveToolBar(eGroup,rsToolBarName))
741 : : {
742 : 0 : mbPreUpdatePending = true;
743 [ # # ]: 0 : if (mnLockCount == 0)
744 [ # # ]: 0 : PreUpdate();
745 [ # # ]: 0 : }
746 : 0 : }
747 : :
748 : :
749 : :
750 : :
751 : 0 : void ToolBarManager::Implementation::AddToolBarShell (
752 : : ToolBarGroup eGroup,
753 : : ShellId nToolBarId)
754 : : {
755 : 0 : ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
756 [ # # ]: 0 : if (pMainViewShell != NULL)
757 : : {
758 : 0 : maToolBarShellList.AddShellId(eGroup,nToolBarId);
759 : 0 : GetToolBarRules().SubShellAdded(eGroup, nToolBarId);
760 : : }
761 : 0 : }
762 : :
763 : :
764 : :
765 : :
766 : 260 : void ToolBarManager::Implementation::ReleaseAllToolBarShells (void)
767 : : {
768 : 260 : maToolBarShellList.ReleaseAllShells(GetToolBarRules());
769 [ + - ][ + - ]: 260 : maToolBarShellList.UpdateShells(mrBase.GetMainViewShell(), mrBase.GetViewShellManager());
[ + - ]
770 : 260 : }
771 : :
772 : :
773 : :
774 : :
775 : 130 : void ToolBarManager::Implementation::RequestUpdate (void)
776 : : {
777 [ + - ]: 130 : if (mnPendingUpdateCall == 0)
778 : : {
779 : : mnPendingUpdateCall = Application::PostUserEvent(
780 [ + - ]: 130 : LINK(this,ToolBarManager::Implementation,UpdateCallback));
781 : : }
782 : 130 : }
783 : :
784 : :
785 : :
786 : :
787 : 418 : void ToolBarManager::Implementation::PreUpdate (void)
788 : : {
789 [ + - ]: 418 : ::osl::MutexGuard aGuard(maMutex);
790 : :
791 [ + + ]: 576 : if (mbIsValid
[ + - + - ]
[ + + ]
792 : : && mbPreUpdatePending
793 : 158 : && mxLayouter.is())
794 : : {
795 : 158 : mbPreUpdatePending = false;
796 : :
797 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": ToolBarManager::PreUpdate [");
798 : :
799 : : // Get the list of tool bars that are not used anymore and are to be
800 : : // deactivated.
801 [ + - ]: 158 : NameList aToolBars;
802 [ + - ]: 158 : maToolBarList.GetToolBarsToDeactivate(aToolBars);
803 : :
804 : : // Turn off the tool bars.
805 : 158 : NameList::const_iterator iToolBar;
806 [ + - ][ + - ]: 158 : for (iToolBar=aToolBars.begin(); iToolBar!=aToolBars.end(); ++iToolBar)
[ - + ]
807 : : {
808 : 0 : ::rtl::OUString sFullName (GetToolBarResourceName(*iToolBar));
809 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": turning off tool bar " <<
810 : : ::rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_UTF8).getStr());
811 [ # # ][ # # ]: 0 : mxLayouter->destroyElement(sFullName);
812 [ # # ]: 0 : maToolBarList.MarkToolBarAsNotActive(*iToolBar);
813 : 0 : }
814 : :
815 : 158 : SAL_INFO("sd.view", OSL_THIS_FUNC << ": ToolBarManager::PreUpdate ]");
816 [ + - ]: 418 : }
817 : 418 : }
818 : :
819 : :
820 : :
821 : :
822 : 131 : void ToolBarManager::Implementation::PostUpdate (void)
823 : : {
824 [ + - ]: 131 : ::osl::MutexGuard aGuard(maMutex);
825 : :
826 [ + - ]: 262 : if (mbIsValid
[ + - + - ]
[ + - ]
827 : : && mbPostUpdatePending
828 : 131 : && mxLayouter.is())
829 : : {
830 : 131 : mbPostUpdatePending = false;
831 : :
832 : : // Create the list of requested tool bars.
833 [ + - ]: 131 : NameList aToolBars;
834 [ + - ]: 131 : maToolBarList.GetToolBarsToActivate(aToolBars);
835 : :
836 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": ToolBarManager::PostUpdate [");
837 : :
838 : : // Turn on the tool bars that are visible in the new context.
839 : 131 : NameList::const_iterator iToolBar;
840 [ + - ][ + - ]: 544 : for (iToolBar=aToolBars.begin(); iToolBar!=aToolBars.end(); ++iToolBar)
[ + + ]
841 : : {
842 : 413 : ::rtl::OUString sFullName (GetToolBarResourceName(*iToolBar));
843 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": turning on tool bar " <<
844 : : ::rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_UTF8).getStr());
845 [ + - ][ + - ]: 413 : mxLayouter->requestElement(sFullName);
846 [ + - ]: 413 : maToolBarList.MarkToolBarAsActive(*iToolBar);
847 : 413 : }
848 : :
849 : 131 : SAL_INFO("sd.view", OSL_THIS_FUNC << ": ToolBarManager::PostUpdate ]");
850 [ + - ]: 131 : }
851 : 131 : }
852 : :
853 : :
854 : :
855 : :
856 : 934 : void ToolBarManager::Implementation::LockViewShellManager (void)
857 : : {
858 [ + + ]: 934 : if (mpViewShellManagerLock.get() == NULL)
859 : : mpViewShellManagerLock.reset(
860 [ + - ][ + - ]: 544 : new ViewShellManager::UpdateLock(mrBase.GetViewShellManager()));
861 : 934 : }
862 : :
863 : :
864 : :
865 : :
866 : 4136 : void ToolBarManager::Implementation::LockUpdate (void)
867 : : {
868 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": LockUpdate " << mnLockCount);
869 [ + - ]: 4136 : ::osl::MutexGuard aGuard(maMutex);
870 : :
871 : : DBG_ASSERT(mnLockCount<100, "ToolBarManager lock count unusually high");
872 [ + + ]: 4136 : if (mnLockCount == 0)
873 : : {
874 : : OSL_ASSERT(mpSynchronousLayouterLock.get()==NULL);
875 : :
876 [ + - ][ + - ]: 830 : mpSynchronousLayouterLock.reset(new LayouterLock(mxLayouter));
877 : : }
878 [ + - ]: 4136 : ++mnLockCount;
879 : 4136 : }
880 : :
881 : :
882 : :
883 : :
884 : 4136 : void ToolBarManager::Implementation::UnlockUpdate (void)
885 : : {
886 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": UnlockUpdate " << mnLockCount);
887 [ + - ]: 4136 : ::osl::MutexGuard aGuard(maMutex);
888 : :
889 : : OSL_ASSERT(mnLockCount>0);
890 : 4136 : --mnLockCount;
891 [ + + ]: 4136 : if (mnLockCount == 0)
892 : : {
893 [ + - ][ + - ]: 830 : Update(mpSynchronousLayouterLock);
894 [ + - ]: 4136 : }
895 : 4136 : }
896 : :
897 : :
898 : :
899 : : SAL_WNODEPRECATED_DECLARATIONS_PUSH
900 : 830 : void ToolBarManager::Implementation::Update (
901 : : ::std::auto_ptr<LayouterLock> pLocalLayouterLock)
902 : : {
903 : : // When the lock is released and there are pending changes to the set of
904 : : // tool bars then update this set now.
905 [ + - ]: 830 : if (mnLockCount == 0)
906 : : {
907 : : // During ceation of ViewShellBase we may have the situation that
908 : : // the controller has already been created and attached to the frame
909 : : // but that the ToolBarManager has not yet completed its
910 : : // initialization (by initializing the mxLayouter member.) We do
911 : : // this here so that we do not have to wait for the next Update()
912 : : // call to show the tool bars.
913 [ + + ]: 830 : if (mnPendingSetValidCall != 0)
914 : : {
915 : 130 : Application::RemoveUserEvent(mnPendingSetValidCall);
916 : 130 : mnPendingSetValidCall = 0;
917 : 130 : SetValid(true);
918 : : }
919 : :
920 [ + + ][ + - ]: 830 : if (mbIsValid && mxLayouter.is() && (mbPreUpdatePending || mbPostUpdatePending))
[ + + ][ + + ]
[ + + ]
921 : : {
922 : : // 1) Release UNO tool bars that are not longer used. Do this
923 : : // now so that they are not updated when the SFX shell stack is
924 : : // modified.
925 [ + + ]: 418 : if (mbPreUpdatePending)
926 : 158 : PreUpdate();
927 : :
928 : : // 2) Update the requested shells that represent tool bar
929 : : // functionality. Those that are not used anymore are
930 : : // deactivated now. Those that are missing are activated in the
931 : : // next step together with the view shells.
932 [ + + ]: 418 : if (mpViewShellManagerLock.get() == NULL)
933 : : mpViewShellManagerLock.reset(
934 [ + - ][ + - ]: 156 : new ViewShellManager::UpdateLock(mrBase.GetViewShellManager()));
935 : : maToolBarShellList.UpdateShells(
936 : : mrBase.GetMainViewShell(),
937 [ + - ][ + - ]: 418 : mrBase.GetViewShellManager());
[ + - ]
938 : :
939 : : // 3) Unlock the ViewShellManager::UpdateLock. This updates the
940 : : // shell stack. We have to be carfull here. The deletion of
941 : : // the lock may end in a synchronous call to LockUpdate(). When
942 : : // at this time the lock has been deleted but the auto_ptr has
943 : : // not yet been reset then the lock is deleted a second time.
944 : 418 : ViewShellManager::UpdateLock* pLock = mpViewShellManagerLock.release();
945 [ + - ]: 418 : delete pLock;
946 : :
947 : : // 4) Make the UNO tool bars visible. The outstanding call to
948 : : // PostUpdate() is done via PostUserEvent() so that it is
949 : : // guaranteed to be executed when the SFX shell stack has been
950 : : // updated (under the assumption that our lock to the
951 : : // ViewShellManager was the only one open. If that is not the
952 : : // case then all should still be well but not as fast.)
953 : : //
954 : : // Note that the lock count may have been increased since
955 : : // entering this method. In that case one of the next
956 : : // UnlockUpdate() calls will post the UpdateCallback.
957 [ + + ][ + - ]: 418 : if (mnPendingUpdateCall==0 && mnLockCount==0)
958 : : {
959 : 2 : mpAsynchronousLayouterLock = pLocalLayouterLock;
960 : : mnPendingUpdateCall = Application::PostUserEvent(
961 [ + - ]: 2 : LINK(this,ToolBarManager::Implementation,UpdateCallback));
962 : : }
963 : : }
964 : : else
965 : : {
966 : 412 : mpViewShellManagerLock.reset();
967 : 412 : pLocalLayouterLock.reset();
968 : : }
969 : : }
970 : 830 : }
971 : : SAL_WNODEPRECATED_DECLARATIONS_POP
972 : :
973 : :
974 : :
975 : :
976 : 1042 : ToolBarRules& ToolBarManager::Implementation::GetToolBarRules (void)
977 : : {
978 : 1042 : return maToolBarRules;
979 : : }
980 : :
981 : :
982 : :
983 : :
984 : 131 : IMPL_LINK_NOARG(ToolBarManager::Implementation, UpdateCallback)
985 : : {
986 : 131 : mnPendingUpdateCall = 0;
987 [ + - ]: 131 : if (mnLockCount == 0)
988 : : {
989 [ - + ]: 131 : if (mbPreUpdatePending)
990 : 0 : PreUpdate();
991 [ + - ]: 131 : if (mbPostUpdatePending)
992 : 131 : PostUpdate();
993 [ + - ][ + - ]: 131 : if (mbIsValid && mxLayouter.is())
[ + - ]
994 : 131 : mpAsynchronousLayouterLock.reset();
995 : : }
996 : 131 : return 0;
997 : : }
998 : :
999 : :
1000 : :
1001 : :
1002 : 6905 : IMPL_LINK(ToolBarManager::Implementation,EventMultiplexerCallback,
1003 : : sd::tools::EventMultiplexerEvent*,pEvent)
1004 : : {
1005 [ + - ]: 6905 : if (pEvent != NULL)
1006 : : {
1007 [ + + - + ]: 6905 : switch (pEvent->meEventId)
1008 : : {
1009 : : case tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED:
1010 [ + - ]: 130 : if (mnPendingSetValidCall == 0)
1011 : : mnPendingSetValidCall
1012 [ + - ]: 130 : = Application::PostUserEvent(LINK(this,Implementation,SetValidCallback));
1013 : 130 : break;
1014 : :
1015 : : case tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED:
1016 : 130 : SetValid(false);
1017 : 130 : break;
1018 : :
1019 : : case tools::EventMultiplexerEvent::EID_PANE_MANAGER_DYING:
1020 : 0 : SetValid(false);
1021 : 6905 : break;
1022 : : }
1023 : : }
1024 : 6905 : return 0;
1025 : : }
1026 : :
1027 : :
1028 : :
1029 : :
1030 : 0 : IMPL_LINK_NOARG(ToolBarManager::Implementation, SetValidCallback)
1031 : : {
1032 : 0 : mnPendingSetValidCall = 0;
1033 : 0 : SetValid(true);
1034 : 0 : return 0;
1035 : : }
1036 : :
1037 : :
1038 : :
1039 : :
1040 : :
1041 : 413 : ::rtl::OUString ToolBarManager::Implementation::GetToolBarResourceName (
1042 : : const ::rtl::OUString& rsBaseName) const
1043 : : {
1044 : 413 : ::rtl::OUString sToolBarName (msToolBarResourcePrefix);
1045 : 413 : sToolBarName += rsBaseName;
1046 : 413 : return sToolBarName;
1047 : : }
1048 : :
1049 : :
1050 : :
1051 : :
1052 : 1354 : bool ToolBarManager::Implementation::CheckPlugInMode (const ::rtl::OUString& rsName) const
1053 : : {
1054 : 1354 : bool bValid (false);
1055 : :
1056 : : // Determine the plug in mode.
1057 : 1354 : bool bIsPlugInMode (false);
1058 : : do
1059 : : {
1060 : 1354 : SfxObjectShell* pObjectShell = mrBase.GetObjectShell();
1061 [ - + ]: 1354 : if (pObjectShell == NULL)
1062 : 0 : break;
1063 : :
1064 : 1354 : SfxMedium* pMedium = pObjectShell->GetMedium();
1065 [ - + ]: 1354 : if (pMedium == NULL)
1066 : 0 : break;
1067 : :
1068 : 1354 : SFX_ITEMSET_ARG(pMedium->GetItemSet(),pViewOnlyItem,SfxBoolItem,SID_VIEWONLY,sal_False);
1069 [ + - ]: 1354 : if (pViewOnlyItem == NULL)
1070 : 1354 : break;
1071 : :
1072 : 0 : bIsPlugInMode = pViewOnlyItem->GetValue();
1073 : : }
1074 : : while (false);
1075 : :
1076 [ + + ]: 1354 : if (rsName.equals(msViewerToolBar))
1077 : 260 : bValid = bIsPlugInMode;
1078 : : else
1079 : 1094 : bValid = ! bIsPlugInMode;
1080 : :
1081 : 1354 : return bValid;
1082 : : }
1083 : :
1084 : :
1085 : :
1086 : :
1087 : : } // end of namespace sd
1088 : :
1089 : :
1090 : :
1091 : :
1092 : : namespace {
1093 : :
1094 : : using namespace ::sd;
1095 : :
1096 : : //===== LayouterLock ==========================================================
1097 : :
1098 : 830 : LayouterLock::LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter)
1099 : 830 : : mxLayouter(rxLayouter)
1100 : : {
1101 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": LayouterLock " << (mxLayouter.is() ? 1 :0));
1102 [ + + ]: 830 : if (mxLayouter.is())
1103 [ + - ][ + - ]: 310 : mxLayouter->lock();
1104 : 830 : }
1105 : :
1106 : :
1107 : :
1108 : :
1109 : 830 : LayouterLock::~LayouterLock (void)
1110 : : {
1111 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": ~LayouterLock " << (mxLayouter.is() ? 1 :0));
1112 [ + + ]: 830 : if (mxLayouter.is())
1113 [ + - ][ + - ]: 310 : mxLayouter->unlock();
1114 : 830 : }
1115 : :
1116 : :
1117 : :
1118 : :
1119 : : //===== ToolBarRules ==========================================================
1120 : :
1121 : 130 : ToolBarRules::ToolBarRules (
1122 : : const ::boost::shared_ptr<sd::ToolBarManager>& rpToolBarManager,
1123 : : const ::boost::shared_ptr<sd::ViewShellManager>& rpViewShellManager)
1124 : : : mpToolBarManager(rpToolBarManager),
1125 [ + - ]: 130 : mpViewShellManager(rpViewShellManager)
1126 : : {
1127 : 130 : }
1128 : :
1129 : :
1130 : :
1131 : :
1132 : 130 : void ToolBarRules::Update (ViewShellBase& rBase)
1133 : : {
1134 : 130 : ViewShell* pMainViewShell = rBase.GetMainViewShell().get();
1135 [ + - ]: 130 : if (pMainViewShell != NULL)
1136 : : {
1137 : 130 : MainViewShellChanged(pMainViewShell->GetShellType());
1138 [ + - ]: 130 : if (pMainViewShell->GetView())
1139 : 130 : SelectionHasChanged (*pMainViewShell, *pMainViewShell->GetView());
1140 : : }
1141 : : else
1142 : 0 : MainViewShellChanged(ViewShell::ST_NONE);
1143 : 130 : }
1144 : :
1145 : :
1146 : :
1147 : :
1148 : 390 : void ToolBarRules::MainViewShellChanged (ViewShell::ShellType nShellType)
1149 : : {
1150 [ + - ]: 390 : ::sd::ToolBarManager::UpdateLock aToolBarManagerLock (mpToolBarManager);
1151 [ + - ]: 390 : ::sd::ViewShellManager::UpdateLock aViewShellManagerLock (mpViewShellManager);
1152 : :
1153 [ + - ]: 390 : mpToolBarManager->ResetAllToolBars();
1154 : :
1155 [ + + - - : 390 : switch(nShellType)
+ ]
1156 : : {
1157 : : case ::sd::ViewShell::ST_IMPRESS:
1158 : : case ::sd::ViewShell::ST_NOTES:
1159 : : case ::sd::ViewShell::ST_HANDOUT:
1160 : : mpToolBarManager->AddToolBar(
1161 : : ToolBarManager::TBG_PERMANENT,
1162 [ + - ]: 52 : ToolBarManager::msToolBar);
1163 : : mpToolBarManager->AddToolBar(
1164 : : ToolBarManager::TBG_PERMANENT,
1165 [ + - ]: 52 : ToolBarManager::msOptionsToolBar);
1166 : : mpToolBarManager->AddToolBar(
1167 : : ToolBarManager::TBG_PERMANENT,
1168 [ + - ]: 52 : ToolBarManager::msCommonTaskToolBar);
1169 : : mpToolBarManager->AddToolBar(
1170 : : ToolBarManager::TBG_PERMANENT,
1171 [ + - ]: 52 : ToolBarManager::msViewerToolBar);
1172 : 52 : break;
1173 : :
1174 : : case ::sd::ViewShell::ST_DRAW:
1175 : : mpToolBarManager->AddToolBar(
1176 : : ToolBarManager::TBG_PERMANENT,
1177 [ + - ]: 208 : ToolBarManager::msToolBar);
1178 : : mpToolBarManager->AddToolBar(
1179 : : ToolBarManager::TBG_PERMANENT,
1180 [ + - ]: 208 : ToolBarManager::msOptionsToolBar);
1181 : : mpToolBarManager->AddToolBar(
1182 : : ToolBarManager::TBG_PERMANENT,
1183 [ + - ]: 208 : ToolBarManager::msViewerToolBar);
1184 : 208 : break;
1185 : :
1186 : : case ViewShell::ST_OUTLINE:
1187 : : mpToolBarManager->AddToolBar(
1188 : : ToolBarManager::TBG_PERMANENT,
1189 [ # # ]: 0 : ToolBarManager::msOutlineToolBar);
1190 : : mpToolBarManager->AddToolBar(
1191 : : ToolBarManager::TBG_PERMANENT,
1192 [ # # ]: 0 : ToolBarManager::msViewerToolBar);
1193 : : mpToolBarManager->AddToolBarShell(
1194 [ # # ]: 0 : ToolBarManager::TBG_PERMANENT, RID_DRAW_TEXT_TOOLBOX);
1195 : 0 : break;
1196 : :
1197 : : case ViewShell::ST_SLIDE_SORTER:
1198 : : mpToolBarManager->AddToolBar(
1199 : : ToolBarManager::TBG_PERMANENT,
1200 [ # # ]: 0 : ToolBarManager::msViewerToolBar);
1201 : : mpToolBarManager->AddToolBar(
1202 : : ToolBarManager::TBG_PERMANENT,
1203 [ # # ]: 0 : ToolBarManager::msSlideSorterToolBar);
1204 : : mpToolBarManager->AddToolBar(
1205 : : ToolBarManager::TBG_PERMANENT,
1206 [ # # ]: 0 : ToolBarManager::msSlideSorterObjectBar);
1207 : 0 : break;
1208 : :
1209 : : case ViewShell::ST_NONE:
1210 : : case ViewShell::ST_PRESENTATION:
1211 : : case ViewShell::ST_TASK_PANE:
1212 : : default:
1213 : 130 : break;
1214 [ + - ][ + - ]: 390 : }
1215 : 390 : }
1216 : :
1217 : :
1218 : :
1219 : :
1220 : 130 : void ToolBarRules::MainViewShellChanged (const ViewShell& rMainViewShell)
1221 : : {
1222 [ + - ]: 130 : ::sd::ToolBarManager::UpdateLock aToolBarManagerLock (mpToolBarManager);
1223 [ + - ]: 130 : ::sd::ViewShellManager::UpdateLock aViewShellManagerLock (mpViewShellManager);
1224 : :
1225 [ + - ][ + - ]: 130 : MainViewShellChanged(rMainViewShell.GetShellType());
1226 [ + - ][ + - ]: 130 : switch(rMainViewShell.GetShellType())
1227 : : {
1228 : : case ::sd::ViewShell::ST_IMPRESS:
1229 : : case ::sd::ViewShell::ST_DRAW:
1230 : : case ::sd::ViewShell::ST_NOTES:
1231 : : {
1232 : : const DrawViewShell* pDrawViewShell
1233 [ - + ]: 130 : = dynamic_cast<const DrawViewShell*>(&rMainViewShell);
1234 [ + - ]: 130 : if (pDrawViewShell != NULL)
1235 [ - + ]: 130 : if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
1236 : : mpToolBarManager->AddToolBar(
1237 : : ToolBarManager::TBG_MASTER_MODE,
1238 [ # # ]: 0 : ToolBarManager::msMasterViewToolBar);
1239 : 130 : break;
1240 : : }
1241 : :
1242 : : default:
1243 : 0 : break;
1244 [ + - ][ + - ]: 130 : }
1245 : 130 : }
1246 : :
1247 : :
1248 : :
1249 : :
1250 : 522 : void ToolBarRules::SelectionHasChanged (
1251 : : const ::sd::ViewShell& rViewShell,
1252 : : const SdrView& rView)
1253 : : {
1254 [ + - ]: 522 : ::sd::ToolBarManager::UpdateLock aLock (mpToolBarManager);
1255 [ + - ]: 522 : mpToolBarManager->LockViewShellManager();
1256 [ + - ]: 522 : bool bTextEdit = rView.IsTextEdit();
1257 : :
1258 [ + - ]: 522 : mpToolBarManager->ResetToolBars(ToolBarManager::TBG_FUNCTION);
1259 : :
1260 [ + - ]: 522 : switch (rView.GetContext())
[ - - - + ]
1261 : : {
1262 : : case SDRCONTEXT_GRAPHIC:
1263 [ # # ]: 0 : if( !bTextEdit )
1264 [ # # ]: 0 : mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_GRAF_TOOLBOX);
1265 : 0 : break;
1266 : :
1267 : : case SDRCONTEXT_MEDIA:
1268 [ # # ]: 0 : if( !bTextEdit )
1269 [ # # ]: 0 : mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_MEDIA_TOOLBOX);
1270 : 0 : break;
1271 : :
1272 : : case SDRCONTEXT_TABLE:
1273 [ # # ]: 0 : mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX);
1274 : 0 : bTextEdit = true;
1275 : 0 : break;
1276 : :
1277 : : case SDRCONTEXT_STANDARD:
1278 : : default:
1279 [ + - ]: 522 : if( !bTextEdit )
1280 : : {
1281 [ + - ][ + - ]: 522 : switch(rViewShell.GetShellType())
1282 : : {
1283 : : case ::sd::ViewShell::ST_IMPRESS:
1284 : : case ::sd::ViewShell::ST_DRAW:
1285 : : case ::sd::ViewShell::ST_NOTES:
1286 : : case ::sd::ViewShell::ST_HANDOUT:
1287 : : mpToolBarManager->SetToolBar(
1288 : : ToolBarManager::TBG_FUNCTION,
1289 [ + - ]: 522 : ToolBarManager::msDrawingObjectToolBar);
1290 : 522 : break;
1291 : : default:
1292 : 0 : break;
1293 : : }
1294 : 522 : break;
1295 : : }
1296 : : }
1297 : :
1298 [ - + ]: 522 : if( bTextEdit )
1299 [ # # ]: 0 : mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_TEXT_TOOLBOX);
1300 : :
1301 : 522 : SdrView* pView = &const_cast<SdrView&>(rView);
1302 : : // Check if the extrusion tool bar and the fontwork tool bar have to
1303 : : // be activated.
1304 [ + - ][ - + ]: 522 : if (svx::checkForSelectedCustomShapes(pView, true /* bOnlyExtruded */ ))
1305 [ # # ]: 0 : mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_SVX_EXTRUSION_BAR);
1306 : 522 : sal_uInt32 nCheckStatus = 0;
1307 [ + - ][ - + ]: 522 : if (svx::checkForSelectedFontWork(pView, nCheckStatus))
1308 [ # # ]: 0 : mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_SVX_FONTWORK_BAR);
1309 : :
1310 : : // Switch on additional context-sensitive tool bars.
1311 [ + - ][ - + ]: 522 : if (rView.GetContext() == SDRCONTEXT_POINTEDIT)
1312 [ # # ][ + - ]: 522 : mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_BEZIER_TOOLBOX);
1313 : 522 : }
1314 : :
1315 : :
1316 : :
1317 : :
1318 : 0 : void ToolBarRules::SubShellAdded (
1319 : : ::sd::ToolBarManager::ToolBarGroup eGroup,
1320 : : sd::ShellId nShellId)
1321 : : {
1322 : : // For some tool bar shells (those defined in sd) we have to add the
1323 : : // actual tool bar here.
1324 [ # # # # : 0 : switch (nShellId)
# # ]
1325 : : {
1326 : : case RID_DRAW_GRAF_TOOLBOX:
1327 : 0 : mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msGraphicObjectBar);
1328 : 0 : break;
1329 : :
1330 : : case RID_DRAW_MEDIA_TOOLBOX:
1331 : 0 : mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msMediaObjectBar);
1332 : 0 : break;
1333 : :
1334 : : case RID_DRAW_TEXT_TOOLBOX:
1335 : 0 : mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msTextObjectBar);
1336 : 0 : break;
1337 : :
1338 : : case RID_BEZIER_TOOLBOX:
1339 : 0 : mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msBezierObjectBar);
1340 : 0 : break;
1341 : :
1342 : : case RID_DRAW_TABLE_TOOLBOX:
1343 : 0 : mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msTableObjectBar);
1344 : 0 : break;
1345 : : }
1346 : 0 : }
1347 : :
1348 : :
1349 : :
1350 : :
1351 : 0 : void ToolBarRules::SubShellRemoved (
1352 : : ::sd::ToolBarManager::ToolBarGroup eGroup,
1353 : : sd::ShellId nShellId)
1354 : : {
1355 : : // For some tool bar shells (those defined in sd) we have to add the
1356 : : // actual tool bar here.
1357 [ # # # # : 0 : switch (nShellId)
# # ]
1358 : : {
1359 : : case RID_DRAW_GRAF_TOOLBOX:
1360 : 0 : mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msGraphicObjectBar);
1361 : 0 : break;
1362 : :
1363 : : case RID_DRAW_MEDIA_TOOLBOX:
1364 : 0 : mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msMediaObjectBar);
1365 : 0 : break;
1366 : :
1367 : : case RID_DRAW_TEXT_TOOLBOX:
1368 : 0 : mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msTextObjectBar);
1369 : 0 : break;
1370 : :
1371 : : case RID_BEZIER_TOOLBOX:
1372 : 0 : mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msBezierObjectBar);
1373 : 0 : break;
1374 : :
1375 : : case RID_DRAW_TABLE_TOOLBOX:
1376 : 0 : mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msTableObjectBar);
1377 : 0 : break;
1378 : : }
1379 : 0 : }
1380 : :
1381 : :
1382 : :
1383 : :
1384 : : //===== ToolBarList ===========================================================
1385 : :
1386 : 130 : ToolBarList::ToolBarList (void)
1387 : : : maGroups(),
1388 [ + - ]: 130 : maActiveToolBars()
1389 : : {
1390 : 130 : }
1391 : :
1392 : :
1393 : :
1394 : :
1395 : 2760 : void ToolBarList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup)
1396 : : {
1397 [ + - ]: 2760 : Groups::iterator iGroup (maGroups.find(eGroup));
1398 [ + + ]: 2760 : if (iGroup != maGroups.end())
1399 : : {
1400 [ + + ]: 1694 : if ( ! iGroup->second.empty())
1401 : : {
1402 : 782 : iGroup->second.clear();
1403 : : }
1404 : : }
1405 : 2760 : }
1406 : :
1407 : :
1408 : :
1409 : :
1410 : 1094 : void ToolBarList::AddToolBar (
1411 : : sd::ToolBarManager::ToolBarGroup eGroup,
1412 : : const ::rtl::OUString& rsName)
1413 : : {
1414 [ + - ]: 1094 : Groups::iterator iGroup (maGroups.find(eGroup));
1415 [ + + ]: 1094 : if (iGroup == maGroups.end())
1416 [ + - ][ + - ]: 260 : iGroup = maGroups.insert(Groups::value_type(eGroup,NameList())).first;
1417 : :
1418 [ + - ]: 1094 : if (iGroup != maGroups.end())
1419 : : {
1420 : : NameList::const_iterator iBar (
1421 [ + - ][ + - ]: 1094 : ::std::find(iGroup->second.begin(),iGroup->second.end(),rsName));
1422 [ + - ][ + - ]: 1094 : if (iBar == iGroup->second.end())
1423 : : {
1424 [ + - ]: 1094 : iGroup->second.push_back(rsName);
1425 : : }
1426 : : }
1427 : 1094 : }
1428 : :
1429 : :
1430 : :
1431 : :
1432 : 0 : bool ToolBarList::RemoveToolBar (
1433 : : sd::ToolBarManager::ToolBarGroup eGroup,
1434 : : const ::rtl::OUString& rsName)
1435 : : {
1436 [ # # ]: 0 : Groups::iterator iGroup (maGroups.find(eGroup));
1437 [ # # ]: 0 : if (iGroup != maGroups.end())
1438 : : {
1439 : : NameList::iterator iBar (
1440 [ # # ]: 0 : ::std::find(iGroup->second.begin(),iGroup->second.end(),rsName));
1441 [ # # ][ # # ]: 0 : if (iBar != iGroup->second.end())
1442 : : {
1443 [ # # ]: 0 : iGroup->second.erase(iBar);
1444 : 0 : return true;
1445 : : }
1446 : : }
1447 : 0 : return false;
1448 : : }
1449 : :
1450 : :
1451 : :
1452 : :
1453 : 289 : void ToolBarList::MakeRequestedToolBarList (NameList& rRequestedToolBars) const
1454 : : {
1455 [ + + ]: 1156 : for (int i=sd::ToolBarManager::TBG__FIRST; i<=sd::ToolBarManager::TBG__LAST; ++i)
1456 : : {
1457 : 867 : ::sd::ToolBarManager::ToolBarGroup eGroup = (::sd::ToolBarManager::ToolBarGroup)i;
1458 [ + - ]: 867 : Groups::const_iterator iGroup (maGroups.find(eGroup));
1459 [ + + ]: 867 : if (iGroup != maGroups.end())
1460 : : ::std::copy(
1461 : 578 : iGroup->second.begin(),
1462 : 578 : iGroup->second.end(),
1463 [ + - + - ]: 1734 : ::std::inserter(rRequestedToolBars,rRequestedToolBars.end()));
1464 : : }
1465 : 289 : }
1466 : :
1467 : :
1468 : :
1469 : :
1470 : 131 : void ToolBarList::GetToolBarsToActivate (NameList& rToolBars) const
1471 : : {
1472 [ + - ]: 131 : NameList aRequestedToolBars;
1473 [ + - ]: 131 : MakeRequestedToolBarList(aRequestedToolBars);
1474 : :
1475 : 131 : NameList::const_iterator iToolBar;
1476 [ + - ][ + - ]: 550 : for (iToolBar=aRequestedToolBars.begin(); iToolBar!=aRequestedToolBars.end(); ++iToolBar)
[ + + ]
1477 : : {
1478 [ + - ][ + + ]: 838 : if (::std::find(maActiveToolBars.begin(),maActiveToolBars.end(),*iToolBar)
1479 [ + - ]: 838 : == maActiveToolBars.end())
1480 : : {
1481 [ + - ]: 413 : rToolBars.push_back(*iToolBar);
1482 : : }
1483 : 131 : }
1484 : 131 : }
1485 : :
1486 : :
1487 : :
1488 : :
1489 : 158 : void ToolBarList::GetToolBarsToDeactivate (NameList& rToolBars) const
1490 : : {
1491 [ + - ]: 158 : NameList aRequestedToolBars;
1492 [ + - ]: 158 : MakeRequestedToolBarList(aRequestedToolBars);
1493 : :
1494 : 158 : NameList::const_iterator iToolBar;
1495 [ + - ][ + + ]: 164 : for (iToolBar=maActiveToolBars.begin(); iToolBar!=maActiveToolBars.end(); ++iToolBar)
1496 : : {
1497 [ + - ][ - + ]: 12 : if (::std::find(aRequestedToolBars.begin(),aRequestedToolBars.end(),*iToolBar)
1498 [ + - ]: 12 : == aRequestedToolBars.end())
1499 : : {
1500 [ # # ]: 0 : rToolBars.push_back(*iToolBar);
1501 : : }
1502 : 158 : }
1503 : 158 : }
1504 : :
1505 : :
1506 : :
1507 : :
1508 : 413 : void ToolBarList::MarkToolBarAsActive (const ::rtl::OUString& rsName)
1509 : : {
1510 : 413 : maActiveToolBars.push_back(rsName);
1511 : 413 : }
1512 : :
1513 : :
1514 : :
1515 : :
1516 : 0 : void ToolBarList::MarkToolBarAsNotActive (const ::rtl::OUString& rsName)
1517 : : {
1518 : : maActiveToolBars.erase(
1519 : 0 : ::std::find(maActiveToolBars.begin(),maActiveToolBars.end(), rsName));
1520 : 0 : }
1521 : :
1522 : :
1523 : :
1524 : :
1525 : 0 : void ToolBarList::MarkAllToolBarsAsNotActive (void)
1526 : : {
1527 : 0 : maActiveToolBars.clear();
1528 : 0 : }
1529 : :
1530 : :
1531 : :
1532 : :
1533 : : //===== ToolBarShellList ======================================================
1534 : :
1535 : 0 : ToolBarShellList::ShellDescriptor::ShellDescriptor (
1536 : : ShellId nId,
1537 : : sd::ToolBarManager::ToolBarGroup eGroup)
1538 : : : mnId(nId),
1539 : 0 : meGroup(eGroup)
1540 : : {
1541 : 0 : }
1542 : :
1543 : :
1544 : :
1545 : :
1546 : 130 : ToolBarShellList::ToolBarShellList (void)
1547 : : : maNewList()
1548 [ + - ]: 130 : , maCurrentList()
1549 : : {
1550 : 130 : }
1551 : :
1552 : :
1553 : :
1554 : :
1555 : 2760 : void ToolBarShellList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup)
1556 : : {
1557 : : // In every loop we erase the first member of the specified group.
1558 : : // Because that invalidates the iterator another loop is started after
1559 : : // that. The loop is left only when no member of the group is found and
1560 : : // no element is erased
1561 : : bool bLoop;
1562 [ - + ]: 2760 : do
1563 : : {
1564 : 2760 : bLoop = false;
1565 : :
1566 : 2760 : GroupedShellList::iterator iDescriptor;
1567 [ - + ]: 2760 : for (iDescriptor=maNewList.begin(); iDescriptor!=maNewList.end(); ++iDescriptor)
1568 [ # # ]: 0 : if (iDescriptor->meGroup == eGroup)
1569 : : {
1570 [ # # ]: 0 : maNewList.erase(iDescriptor);
1571 : : // Erasing the descriptor invalidated the iterator so we
1572 : : // have to exit the for loop and start anew to search for
1573 : : // further elements of the group.
1574 : 0 : bLoop = true;
1575 : 0 : break;
1576 : : }
1577 : : }
1578 : : while (bLoop);
1579 : 2760 : }
1580 : :
1581 : :
1582 : :
1583 : :
1584 : 0 : void ToolBarShellList::AddShellId (sd::ToolBarManager::ToolBarGroup eGroup, sd::ShellId nId)
1585 : : {
1586 : : // Make sure that the shell is not added twice (and possibly in
1587 : : // different groups.)
1588 : 0 : ShellDescriptor aDescriptor (nId,eGroup);
1589 [ # # ]: 0 : GroupedShellList::iterator iDescriptor (maNewList.find(aDescriptor));
1590 [ # # ]: 0 : if (iDescriptor != maNewList.end())
1591 : : {
1592 : : // The shell is already requested.
1593 [ # # ]: 0 : if (iDescriptor->meGroup != eGroup)
1594 : : {
1595 : : // It is now being requested for another group.
1596 : : // (Is this an error?)
1597 : : // Move it to that group.
1598 [ # # ]: 0 : maNewList.erase(iDescriptor);
1599 [ # # ]: 0 : maNewList.insert(aDescriptor);
1600 : : }
1601 : : // else nothing to do.
1602 : : }
1603 : : else
1604 [ # # ]: 0 : maNewList.insert(aDescriptor);
1605 : 0 : }
1606 : :
1607 : :
1608 : :
1609 : :
1610 : 260 : void ToolBarShellList::ReleaseAllShells (ToolBarRules& rRules)
1611 : : {
1612 : : // Release the currently active tool bars.
1613 [ + - ]: 260 : GroupedShellList aList (maCurrentList);
1614 : 260 : GroupedShellList::iterator iDescriptor;
1615 [ - + ]: 260 : for (iDescriptor=aList.begin(); iDescriptor!=aList.end(); ++iDescriptor)
1616 : : {
1617 [ # # ]: 0 : rRules.SubShellRemoved(iDescriptor->meGroup, iDescriptor->mnId);
1618 : : }
1619 : :
1620 : : // Clear the list of requested tool bars.
1621 : 260 : maNewList.clear();
1622 : 260 : }
1623 : :
1624 : :
1625 : :
1626 : :
1627 : 678 : void ToolBarShellList::UpdateShells (
1628 : : const ::boost::shared_ptr<ViewShell>& rpMainViewShell,
1629 : : const ::boost::shared_ptr<ViewShellManager>& rpManager)
1630 : : {
1631 [ + + ]: 678 : if (rpMainViewShell.get() != NULL)
1632 : : {
1633 [ + - ]: 548 : GroupedShellList aList;
1634 : :
1635 : : // Deactivate shells that are in maCurrentList, but not in
1636 : : // maNewList.
1637 : : ::std::set_difference(maCurrentList.begin(), maCurrentList.end(),
1638 : : maNewList.begin(), maNewList.end(),
1639 [ + - ]: 548 : std::insert_iterator<GroupedShellList>(aList,aList.begin()));
1640 [ - + ]: 548 : for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell)
1641 : : {
1642 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": deactivating tool bar shell " << iShell->mnId);
1643 [ # # ]: 0 : rpManager->DeactivateSubShell(*rpMainViewShell, iShell->mnId);
1644 : : }
1645 : :
1646 : : // Activate shells that are in maNewList, but not in
1647 : : // maCurrentList.
1648 : 548 : aList.clear();
1649 : : ::std::set_difference(maNewList.begin(), maNewList.end(),
1650 : : maCurrentList.begin(), maCurrentList.end(),
1651 [ + - ]: 548 : std::insert_iterator<GroupedShellList>(aList,aList.begin()));
1652 [ - + ]: 548 : for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell)
1653 : : {
1654 : : SAL_INFO("sd.view", OSL_THIS_FUNC << ": activating tool bar shell " << iShell->mnId);
1655 [ # # ]: 0 : rpManager->ActivateSubShell(*rpMainViewShell, iShell->mnId);
1656 : : }
1657 : :
1658 : : // The maNewList now refelects the current state and thus is made
1659 : : // maCurrentList.
1660 [ + - ]: 548 : maCurrentList = maNewList;
1661 : : }
1662 : 678 : }
1663 : :
1664 : :
1665 : :
1666 : :
1667 [ + - ][ + - ]: 75 : } // end of anonymous namespace
1668 : :
1669 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|