/************************************************************** * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. * *************************************************************/ #include "precompiled_sd.hxx" #include "framework/ViewShellWrapper.hxx" #include "framework/Pane.hxx" #include "ViewShell.hxx" #include "Window.hxx" #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing::framework; using ::com::sun::star::awt::XWindow; using ::com::sun::star::rendering::XCanvas; using ::com::sun::star::lang::DisposedException; using ::rtl::OUString; namespace sd { namespace framework { ViewShellWrapper::ViewShellWrapper ( ::boost::shared_ptr pViewShell, const Reference& rxViewId, const Reference& rxWindow) : ViewShellWrapperInterfaceBase(MutexOwner::maMutex), mpViewShell(pViewShell), mxViewId(rxViewId), mxWindow(rxWindow) { if (rxWindow.is()) { rxWindow->addWindowListener(this); if( bool(pViewShell) ) { pViewShell->Resize(); } } } ViewShellWrapper::~ViewShellWrapper (void) { } void SAL_CALL ViewShellWrapper::disposing (void) { ::osl::MutexGuard aGuard( maMutex ); OSL_TRACE("disposing ViewShellWrapper %x", this); Reference xWindow (mxWindow); if (xWindow.is()) { OSL_TRACE("removing ViewShellWrapper %x from window listener at %x", this, mxWindow.get()); xWindow->removeWindowListener(this); } mpViewShell.reset(); } ::boost::shared_ptr ViewShellWrapper::GetViewShell (void) { return mpViewShell; } //----- XResource ------------------------------------------------------------- Reference SAL_CALL ViewShellWrapper::getResourceId (void) throw (RuntimeException) { return mxViewId; } sal_Bool SAL_CALL ViewShellWrapper::isAnchorOnly (void) throw (RuntimeException) { return false; } //----- XRelocatableResource -------------------------------------------------- sal_Bool SAL_CALL ViewShellWrapper::relocateToAnchor ( const Reference& xResource) throw (RuntimeException) { sal_Bool bResult (false); Reference xPane (xResource, UNO_QUERY); if (xPane.is()) { // Detach from the window of the old pane. Reference xWindow (mxWindow); if (xWindow.is()) xWindow->removeWindowListener(this); mxWindow = NULL; if (mpViewShell.get() != NULL) { ::Window* pWindow = VCLUnoHelper::GetWindow(xPane->getWindow()); if (pWindow != NULL && mpViewShell->RelocateToParentWindow(pWindow)) { bResult = sal_True; // Attach to the window of the new pane. xWindow = Reference(xPane->getWindow(), UNO_QUERY); if (xWindow.is()) { xWindow->addWindowListener(this); mpViewShell->Resize(); } } } } return bResult; } //----- XUnoTunnel ------------------------------------------------------------ const Sequence& ViewShellWrapper::getUnoTunnelId (void) { static Sequence* pSequence = NULL; if (pSequence == NULL) { const ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); if (pSequence == NULL) { static ::com::sun::star::uno::Sequence aSequence (16); rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True); pSequence = &aSequence; } } return *pSequence; } sal_Int64 SAL_CALL ViewShellWrapper::getSomething (const Sequence& rId) throw (RuntimeException) { sal_Int64 nResult = 0; if (rId.getLength() == 16 && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0) { nResult = reinterpret_cast(this); } return nResult; } //===== awt::XWindowListener ================================================== void SAL_CALL ViewShellWrapper::windowResized (const awt::WindowEvent& rEvent) throw (RuntimeException) { (void)rEvent; ViewShell* pViewShell (mpViewShell.get()); if (pViewShell != NULL) pViewShell->Resize(); } void SAL_CALL ViewShellWrapper::windowMoved (const awt::WindowEvent& rEvent) throw (RuntimeException) { (void)rEvent; } void SAL_CALL ViewShellWrapper::windowShown (const lang::EventObject& rEvent) throw (RuntimeException) { (void)rEvent; ViewShell* pViewShell (mpViewShell.get()); if (pViewShell != NULL) pViewShell->Resize(); } void SAL_CALL ViewShellWrapper::windowHidden (const lang::EventObject& rEvent) throw (RuntimeException) { (void)rEvent; } //===== XEventListener ======================================================== void SAL_CALL ViewShellWrapper::disposing (const lang::EventObject& rEvent) throw (RuntimeException) { if (rEvent.Source == mxWindow) mxWindow = NULL; } } } // end of namespace sd::framework