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