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 #ifndef SD_FRAMEWORK_SHELL_STACK_GUARD_HXX 23 #define SD_FRAMEWORK_SHELL_STACK_GUARD_HXX 24 25 #include <cppuhelper/basemutex.hxx> 26 27 #include "framework/ConfigurationController.hxx" 28 29 #include <com/sun/star/drawing/framework/XConfigurationChangeListener.hpp> 30 #include <com/sun/star/drawing/framework/XConfigurationController.hpp> 31 #include <com/sun/star/frame/XController.hpp> 32 33 #include <vcl/timer.hxx> 34 #include <cppuhelper/compbase1.hxx> 35 #include <boost/scoped_ptr.hpp> 36 37 namespace css = ::com::sun::star; 38 39 namespace { 40 41 typedef ::cppu::WeakComponentImplHelper1 < 42 css::drawing::framework::XConfigurationChangeListener 43 > ShellStackGuardInterfaceBase; 44 45 } // end of anonymous namespace. 46 47 namespace sd { 48 49 class ViewShellBase; 50 51 } 52 53 namespace sd { namespace framework { 54 55 /** This module locks updates of the current configuration in situations 56 when the shell stack must not be modified. 57 58 On every start of a configuration update the ShellStackGuard checks the 59 printer. If it is printing the configuration update is locked. It then 60 polls the printer and unlocks updates when printing finishes. 61 62 When in the future there are no resources left that use shells then this 63 module can be removed. 64 */ 65 class ShellStackGuard 66 : private ::cppu::BaseMutex, 67 public ShellStackGuardInterfaceBase 68 { 69 public: 70 ShellStackGuard (css::uno::Reference<css::frame::XController>& rxController); 71 virtual ~ShellStackGuard (void); 72 73 virtual void SAL_CALL disposing (void); 74 75 76 // XConfigurationChangeListener 77 78 virtual void SAL_CALL notifyConfigurationChange ( 79 const css::drawing::framework::ConfigurationChangeEvent& rEvent) 80 throw (css::uno::RuntimeException); 81 82 // XEventListener 83 84 virtual void SAL_CALL disposing (const css::lang::EventObject& rEvent) 85 throw (css::uno::RuntimeException); 86 87 private: 88 css::uno::Reference<css::drawing::framework::XConfigurationController> 89 mxConfigurationController; 90 ViewShellBase* mpBase; 91 ::boost::scoped_ptr<ConfigurationController::Lock> mpUpdateLock; 92 Timer maPrinterPollingTimer; 93 94 DECL_LINK(TimeoutHandler, Timer*); 95 96 /** Return <TRUE/> when the printer is printing. Return <FALSE/> when 97 the printer is not printing, or there is no printer, or something 98 else went wrong. 99 */ 100 bool IsPrinting (void) const; 101 }; 102 103 } } // end of namespace sd::framework 104 105 #endif 106 107 /* vim: set noet sw=4 ts=4: */ 108