bump product version to 5.0.4.1
[LibreOffice.git] / sd / source / ui / framework / module / SlideSorterModule.cxx
blob32dc1e79dba52d320caad5ab58e5085831d59305
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "SlideSorterModule.hxx"
22 #include "framework/FrameworkHelper.hxx"
23 #include <com/sun/star/drawing/framework/XTabBar.hpp>
24 #include <com/sun/star/drawing/framework/TabBarButton.hpp>
26 #include "strings.hrc"
27 #include "sdresid.hxx"
28 #include "svtools/slidesorterbaropt.hxx"
30 using namespace ::com::sun::star;
31 using namespace ::com::sun::star::uno;
32 using namespace ::com::sun::star::drawing::framework;
34 using ::sd::framework::FrameworkHelper;
36 namespace sd { namespace framework {
38 //===== SlideSorterModule ==================================================
40 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 mxControllerManager(rxController,UNO_QUERY)
50 if (mxConfigurationController.is())
52 UpdateViewTabBar(NULL);
54 if (SvtSlideSorterBarOptions().GetVisibleImpressView())
55 AddActiveMainView(FrameworkHelper::msImpressViewURL);
56 if (SvtSlideSorterBarOptions().GetVisibleOutlineView())
57 AddActiveMainView(FrameworkHelper::msOutlineViewURL);
58 if (SvtSlideSorterBarOptions().GetVisibleNotesView())
59 AddActiveMainView(FrameworkHelper::msNotesViewURL);
60 if (SvtSlideSorterBarOptions().GetVisibleHandoutView())
61 AddActiveMainView(FrameworkHelper::msHandoutViewURL);
62 if (SvtSlideSorterBarOptions().GetVisibleSlideSorterView())
63 AddActiveMainView(FrameworkHelper::msSlideSorterURL);
64 if (SvtSlideSorterBarOptions().GetVisibleDrawView())
65 AddActiveMainView(FrameworkHelper::msDrawViewURL);
67 mxConfigurationController->addConfigurationChangeListener(
68 this,
69 FrameworkHelper::msResourceActivationEvent,
70 Any());
74 SlideSorterModule::~SlideSorterModule()
78 void SlideSorterModule::SaveResourceState()
80 SvtSlideSorterBarOptions().SetVisibleImpressView(IsResourceActive(FrameworkHelper::msImpressViewURL));
81 SvtSlideSorterBarOptions().SetVisibleOutlineView(IsResourceActive(FrameworkHelper::msOutlineViewURL));
82 SvtSlideSorterBarOptions().SetVisibleNotesView(IsResourceActive(FrameworkHelper::msNotesViewURL));
83 SvtSlideSorterBarOptions().SetVisibleHandoutView(IsResourceActive(FrameworkHelper::msHandoutViewURL));
84 SvtSlideSorterBarOptions().SetVisibleSlideSorterView(IsResourceActive(FrameworkHelper::msSlideSorterURL));
85 SvtSlideSorterBarOptions().SetVisibleDrawView(IsResourceActive(FrameworkHelper::msDrawViewURL));
88 void SAL_CALL SlideSorterModule::notifyConfigurationChange (
89 const ConfigurationChangeEvent& rEvent)
90 throw (RuntimeException, std::exception)
92 if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent))
94 if (rEvent.ResourceId->compareTo(mxViewTabBarId) == 0)
96 // Update the view tab bar because the view tab bar has just
97 // become active.
98 UpdateViewTabBar(Reference<XTabBar>(rEvent.ResourceObject,UNO_QUERY));
100 else if (rEvent.ResourceId->getResourceTypePrefix().equals(
101 FrameworkHelper::msViewURLPrefix)
102 && rEvent.ResourceId->isBoundTo(
103 FrameworkHelper::CreateResourceId(FrameworkHelper::msCenterPaneURL),
104 AnchorBindingMode_DIRECT))
106 // Update the view tab bar because the view in the center pane
107 // has changed.
108 UpdateViewTabBar(NULL);
111 else
113 ResourceManager::notifyConfigurationChange(rEvent);
117 void SlideSorterModule::UpdateViewTabBar (const Reference<XTabBar>& rxTabBar)
119 if ( ! mxControllerManager.is())
120 return;
122 Reference<XTabBar> xBar (rxTabBar);
123 if ( ! xBar.is())
125 Reference<XConfigurationController> xCC (
126 mxControllerManager->getConfigurationController());
127 if (xCC.is())
128 xBar = Reference<XTabBar>(xCC->getResource(mxViewTabBarId), UNO_QUERY);
131 if (xBar.is())
133 TabBarButton aButtonA;
134 aButtonA.ResourceId = FrameworkHelper::CreateResourceId(
135 FrameworkHelper::msSlideSorterURL,
136 FrameworkHelper::msCenterPaneURL);
137 aButtonA.ButtonLabel = SD_RESSTR(STR_SLIDE_MODE);
139 TabBarButton aButtonB;
140 aButtonB.ResourceId = FrameworkHelper::CreateResourceId(
141 FrameworkHelper::msHandoutViewURL,
142 FrameworkHelper::msCenterPaneURL);
144 if ( ! xBar->hasTabBarButton(aButtonA))
145 xBar->addTabBarButtonAfter(aButtonA, aButtonB);
149 } } // end of namespace sd::framework
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */