1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #include "precompiled_sd.hxx"
25
26 #include "SlideSorterModule.hxx"
27
28 #include "framework/FrameworkHelper.hxx"
29 #include <com/sun/star/drawing/framework/XTabBar.hpp>
30 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
31
32 #include "strings.hrc"
33 #include "sdresid.hxx"
34
35 using namespace ::com::sun::star;
36 using namespace ::com::sun::star::uno;
37 using namespace ::com::sun::star::drawing::framework;
38
39 using ::rtl::OUString;
40 using ::sd::framework::FrameworkHelper;
41
42
43 namespace sd { namespace framework {
44
45
46 //===== SlideSorterModule ==================================================
47
SlideSorterModule(const Reference<frame::XController> & rxController,const OUString & rsLeftPaneURL)48 SlideSorterModule::SlideSorterModule (
49 const Reference<frame::XController>& rxController,
50 const OUString& rsLeftPaneURL)
51 : ResourceManager(rxController,
52 FrameworkHelper::CreateResourceId(FrameworkHelper::msSlideSorterURL, rsLeftPaneURL)),
53 mxViewTabBarId(FrameworkHelper::CreateResourceId(
54 FrameworkHelper::msViewTabBarURL,
55 FrameworkHelper::msCenterPaneURL)),
56 mxControllerManager(rxController,UNO_QUERY)
57 {
58 if (mxConfigurationController.is())
59 {
60 UpdateViewTabBar(NULL);
61
62 AddActiveMainView(FrameworkHelper::msImpressViewURL);
63 AddActiveMainView(FrameworkHelper::msOutlineViewURL);
64 AddActiveMainView(FrameworkHelper::msNotesViewURL);
65
66 AddActiveMainView(FrameworkHelper::msDrawViewURL);
67
68 mxConfigurationController->addConfigurationChangeListener(
69 this,
70 FrameworkHelper::msResourceActivationEvent,
71 Any());
72 }
73 }
74
75
76
77
~SlideSorterModule(void)78 SlideSorterModule::~SlideSorterModule (void)
79 {
80 }
81
82
83
84
notifyConfigurationChange(const ConfigurationChangeEvent & rEvent)85 void SAL_CALL SlideSorterModule::notifyConfigurationChange (
86 const ConfigurationChangeEvent& rEvent)
87 throw (RuntimeException)
88 {
89 if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
90 {
91 if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
92 {
93 // Update the view tab bar because the view tab bar has just
94 // become active.
95 UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
96 }
97 else if (rEvent.ResourceId->getResourceTypePrefix().equals(
98 FrameworkHelper::msViewURLPrefix)
99 && rEvent.ResourceId->isBoundTo(
100 FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
101 AnchorBindingMode_DIRECT))
102 {
103 // Update the view tab bar because the view in the center pane
104 // has changed.
105 UpdateViewTabBar(NULL);
106 }
107 }
108 else
109 {
110 ResourceManager::notifyConfigurationChange(rEvent);
111 }
112 }
113
114
115
116
UpdateViewTabBar(const Reference<XTabBar> & rxTabBar)117 void SlideSorterModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
118 {
119 if ( ! mxControllerManager.is())
120 return;
121
122 Reference<XTabBar> xBar (rxTabBar);
123 if ( ! xBar.is())
124 {
125 Reference<XConfigurationController> xCC (
126 mxControllerManager->getConfigurationController());
127 if (xCC.is())
128 xBar = Reference<XTabBar>(xCC->getResource(mxViewTabBarId), UNO_QUERY);
129 }
130
131 if (xBar.is())
132 {
133 TabBarButton aButtonA;
134 aButtonA.ResourceId = FrameworkHelper::CreateResourceId(
135 FrameworkHelper::msSlideSorterURL,
136 FrameworkHelper::msCenterPaneURL);
137 aButtonA.ButtonLabel = String(SdResId(STR_SLIDE_MODE));
138
139 TabBarButton aButtonB;
140 aButtonB.ResourceId = FrameworkHelper::CreateResourceId(
141 FrameworkHelper::msHandoutViewURL,
142 FrameworkHelper::msCenterPaneURL);
143
144 if ( ! xBar->hasTabBarButton(aButtonA))
145 xBar->addTabBarButtonAfter(aButtonA, aButtonB);
146 }
147 }
148
149
150
151 } } // end of namespace sd::framework
152