Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "SlideSorterModule.hxx"
21 :
22 : #include "framework/FrameworkHelper.hxx"
23 : #include <com/sun/star/drawing/framework/XTabBar.hpp>
24 : #include <com/sun/star/drawing/framework/TabBarButton.hpp>
25 :
26 : #include "strings.hrc"
27 : #include "sdresid.hxx"
28 : #include "svtools/slidesorterbaropt.hxx"
29 :
30 : using namespace ::com::sun::star;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::drawing::framework;
33 :
34 : using ::sd::framework::FrameworkHelper;
35 :
36 : namespace sd { namespace framework {
37 :
38 : //===== SlideSorterModule ==================================================
39 :
40 127 : SlideSorterModule::SlideSorterModule (
41 : const Reference<frame::XController>& rxController,
42 : const OUString& rsLeftPaneURL)
43 : : ResourceManager(rxController,
44 : FrameworkHelper::CreateResourceId(FrameworkHelper::msSlideSorterURL, rsLeftPaneURL)),
45 : mxViewTabBarId(FrameworkHelper::CreateResourceId(
46 : FrameworkHelper::msViewTabBarURL,
47 : FrameworkHelper::msCenterPaneURL)),
48 127 : mxControllerManager(rxController,UNO_QUERY)
49 : {
50 127 : if (mxConfigurationController.is())
51 : {
52 127 : UpdateViewTabBar(NULL);
53 :
54 127 : if (SvtSlideSorterBarOptions().GetVisibleImpressView())
55 126 : AddActiveMainView(FrameworkHelper::msImpressViewURL);
56 127 : if (SvtSlideSorterBarOptions().GetVisibleOutlineView())
57 127 : AddActiveMainView(FrameworkHelper::msOutlineViewURL);
58 127 : if (SvtSlideSorterBarOptions().GetVisibleNotesView())
59 127 : AddActiveMainView(FrameworkHelper::msNotesViewURL);
60 127 : if (SvtSlideSorterBarOptions().GetVisibleHandoutView())
61 0 : AddActiveMainView(FrameworkHelper::msHandoutViewURL);
62 127 : if (SvtSlideSorterBarOptions().GetVisibleSlideSorterView())
63 0 : AddActiveMainView(FrameworkHelper::msSlideSorterURL);
64 127 : if (SvtSlideSorterBarOptions().GetVisibleDrawView())
65 127 : AddActiveMainView(FrameworkHelper::msDrawViewURL);
66 :
67 127 : mxConfigurationController->addConfigurationChangeListener(
68 : this,
69 : FrameworkHelper::msResourceActivationEvent,
70 127 : Any());
71 : }
72 127 : }
73 :
74 254 : SlideSorterModule::~SlideSorterModule()
75 : {
76 254 : }
77 :
78 127 : void SlideSorterModule::SaveResourceState()
79 : {
80 127 : SvtSlideSorterBarOptions().SetVisibleImpressView(IsResourceActive(FrameworkHelper::msImpressViewURL));
81 127 : SvtSlideSorterBarOptions().SetVisibleOutlineView(IsResourceActive(FrameworkHelper::msOutlineViewURL));
82 127 : SvtSlideSorterBarOptions().SetVisibleNotesView(IsResourceActive(FrameworkHelper::msNotesViewURL));
83 127 : SvtSlideSorterBarOptions().SetVisibleHandoutView(IsResourceActive(FrameworkHelper::msHandoutViewURL));
84 127 : SvtSlideSorterBarOptions().SetVisibleSlideSorterView(IsResourceActive(FrameworkHelper::msSlideSorterURL));
85 127 : SvtSlideSorterBarOptions().SetVisibleDrawView(IsResourceActive(FrameworkHelper::msDrawViewURL));
86 127 : }
87 :
88 1837 : void SAL_CALL SlideSorterModule::notifyConfigurationChange (
89 : const ConfigurationChangeEvent& rEvent)
90 : throw (RuntimeException, std::exception)
91 : {
92 1837 : if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
93 : {
94 559 : if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
95 : {
96 : // Update the view tab bar because the view tab bar has just
97 : // become active.
98 41 : UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
99 : }
100 1554 : else if (rEvent.ResourceId->getResourceTypePrefix().equals(
101 2072 : FrameworkHelper::msViewURLPrefix)
102 1952 : && rEvent.ResourceId->isBoundTo(
103 : FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
104 916 : AnchorBindingMode_DIRECT))
105 : {
106 : // Update the view tab bar because the view in the center pane
107 : // has changed.
108 133 : UpdateViewTabBar(NULL);
109 : }
110 : }
111 : else
112 : {
113 1278 : ResourceManager::notifyConfigurationChange(rEvent);
114 : }
115 1837 : }
116 :
117 301 : void SlideSorterModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
118 : {
119 301 : if ( ! mxControllerManager.is())
120 301 : return;
121 :
122 301 : Reference<XTabBar> xBar (rxTabBar);
123 301 : if ( ! xBar.is())
124 : {
125 : Reference<XConfigurationController> xCC (
126 260 : mxControllerManager->getConfigurationController());
127 260 : if (xCC.is())
128 260 : xBar = Reference<XTabBar>(xCC->getResource(mxViewTabBarId), UNO_QUERY);
129 : }
130 :
131 301 : if (xBar.is())
132 : {
133 47 : TabBarButton aButtonA;
134 94 : aButtonA.ResourceId = FrameworkHelper::CreateResourceId(
135 : FrameworkHelper::msSlideSorterURL,
136 47 : FrameworkHelper::msCenterPaneURL);
137 47 : aButtonA.ButtonLabel = SD_RESSTR(STR_SLIDE_MODE);
138 :
139 94 : TabBarButton aButtonB;
140 94 : aButtonB.ResourceId = FrameworkHelper::CreateResourceId(
141 : FrameworkHelper::msHandoutViewURL,
142 47 : FrameworkHelper::msCenterPaneURL);
143 :
144 47 : if ( ! xBar->hasTabBarButton(aButtonA))
145 88 : xBar->addTabBarButtonAfter(aButtonA, aButtonB);
146 301 : }
147 : }
148 :
149 66 : } } // end of namespace sd::framework
150 :
151 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|