xref: /trunk/main/sd/source/ui/slideshow/PaneHider.cxx (revision 26490e24)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 #include "PaneHider.hxx"
27 
28 #include "ViewShell.hxx"
29 #include "ViewShellBase.hxx"
30 #include "slideshow.hxx"
31 #include "slideshowimpl.hxx"
32 #include "framework/FrameworkHelper.hxx"
33 #include "framework/ConfigurationController.hxx"
34 
35 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
36 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
37 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
38 #include <com/sun/star/lang/DisposedException.hpp>
39 
40 #include <tools/diagnose_ex.h>
41 
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::drawing::framework;
44 using ::sd::framework::FrameworkHelper;
45 using ::com::sun::star::lang::DisposedException;
46 
47 namespace sd {
48 
PaneHider(const ViewShell & rViewShell,SlideshowImpl * pSlideShow)49 PaneHider::PaneHider (const ViewShell& rViewShell, SlideshowImpl* pSlideShow)
50 	: mrViewShell(rViewShell),
51 	  mbWindowVisibilitySaved(false),
52 	  mbOriginalLeftPaneWindowVisibility(false),
53 	  mbOriginalRightPaneWindowVisibility(false)
54 {
55 	// Hide the left and right pane windows when a slideshow exists and is
56 	// not full screen.
57 	if (pSlideShow!=NULL && !pSlideShow->isFullScreen()) try
58 	{
59 		Reference<XControllerManager> xControllerManager (
60 			mrViewShell.GetViewShellBase().GetController(), UNO_QUERY_THROW);
61 		mxConfigurationController = xControllerManager->getConfigurationController();
62 		if (mxConfigurationController.is())
63 		{
64 			// Get and save the current configuration.
65 			mxConfiguration = mxConfigurationController->getRequestedConfiguration();
66 			if (mxConfiguration.is())
67 			{
68 				// Iterate over the resources and deactivate the panes.
69 				Sequence<Reference<XResourceId> > aResources (
70 					mxConfiguration->getResources(
71 						NULL,
72 						framework::FrameworkHelper::msPaneURLPrefix,
73 						AnchorBindingMode_DIRECT));
74 				for (sal_Int32 nIndex=0; nIndex<aResources.getLength(); ++nIndex)
75 				{
76 					Reference<XResourceId> xPaneId (aResources[nIndex]);
77 					if ( ! xPaneId->getResourceURL().equals(FrameworkHelper::msCenterPaneURL))
78 					{
79 						mxConfigurationController->requestResourceDeactivation(xPaneId);
80 					}
81 				}
82 			}
83 		}
84 		FrameworkHelper::Instance(mrViewShell.GetViewShellBase())->WaitForUpdate();
85 	}
86 	catch (RuntimeException&)
87 	{
88 		DBG_UNHANDLED_EXCEPTION();
89 	}
90 }
91 
92 
~PaneHider(void)93 PaneHider::~PaneHider (void)
94 {
95 	if (mxConfiguration.is() && mxConfigurationController.is())
96 	{
97 		try
98 		{
99 			mxConfigurationController->restoreConfiguration(mxConfiguration);
100 		}
101 		catch (DisposedException&)
102 		{
103 			// When the configuration controller is already disposed then
104 			// there is no point in restoring the configuration.
105 		}
106 	}
107 }
108 
109 
110 } // end of namespace sd
111 
112 /* vim: set noet sw=4 ts=4: */
113