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