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