xref: /aoo42x/main/sd/source/ui/slideshow/PaneHider.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 
29 // MARKER(update_precomp.py): autogen include statement, do not remove
30 #include "precompiled_sd.hxx"
31 #include "PaneHider.hxx"
32 
33 #include "ViewShell.hxx"
34 #include "ViewShellBase.hxx"
35 #include "slideshow.hxx"
36 #include "slideshowimpl.hxx"
37 #include "framework/FrameworkHelper.hxx"
38 #include "framework/ConfigurationController.hxx"
39 
40 #include <com/sun/star/drawing/framework/XControllerManager.hpp>
41 #include <com/sun/star/drawing/framework/XConfigurationController.hpp>
42 #include <com/sun/star/drawing/framework/XConfiguration.hpp>
43 #include <com/sun/star/lang/DisposedException.hpp>
44 
45 #include <tools/diagnose_ex.h>
46 
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::drawing::framework;
49 using ::sd::framework::FrameworkHelper;
50 using ::com::sun::star::lang::DisposedException;
51 
52 namespace sd {
53 
54 PaneHider::PaneHider (const ViewShell& rViewShell, SlideshowImpl* pSlideShow)
55     : mrViewShell(rViewShell),
56       mbWindowVisibilitySaved(false),
57       mbOriginalLeftPaneWindowVisibility(false),
58       mbOriginalRightPaneWindowVisibility(false)
59 {
60      // Hide the left and right pane windows when a slideshow exists and is
61     // not full screen.
62     if (pSlideShow!=NULL && !pSlideShow->isFullScreen()) try
63     {
64         Reference<XControllerManager> xControllerManager (
65             mrViewShell.GetViewShellBase().GetController(), UNO_QUERY_THROW);
66         mxConfigurationController = xControllerManager->getConfigurationController();
67         if (mxConfigurationController.is())
68         {
69             // Get and save the current configuration.
70             mxConfiguration = mxConfigurationController->getRequestedConfiguration();
71             if (mxConfiguration.is())
72             {
73                 // Iterate over the resources and deactivate the panes.
74                 Sequence<Reference<XResourceId> > aResources (
75                     mxConfiguration->getResources(
76                         NULL,
77                         framework::FrameworkHelper::msPaneURLPrefix,
78                         AnchorBindingMode_DIRECT));
79                 for (sal_Int32 nIndex=0; nIndex<aResources.getLength(); ++nIndex)
80                 {
81                     Reference<XResourceId> xPaneId (aResources[nIndex]);
82                     if ( ! xPaneId->getResourceURL().equals(FrameworkHelper::msCenterPaneURL))
83                     {
84                         mxConfigurationController->requestResourceDeactivation(xPaneId);
85                     }
86                 }
87             }
88         }
89         FrameworkHelper::Instance(mrViewShell.GetViewShellBase())->WaitForUpdate();
90     }
91     catch (RuntimeException&)
92     {
93         DBG_UNHANDLED_EXCEPTION();
94     }
95 }
96 
97 
98 
99 
100 PaneHider::~PaneHider (void)
101 {
102     if (mxConfiguration.is() && mxConfigurationController.is())
103     {
104         try
105         {
106             mxConfigurationController->restoreConfiguration(mxConfiguration);
107         }
108         catch (DisposedException&)
109         {
110             // When the configuration controller is already disposed then
111             // there is no point in restoring the configuration.
112         }
113     }
114 }
115 
116 
117 } // end of namespace sd
118