1*6d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6d739b60SAndrew Rist * distributed with this work for additional information 6*6d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6d739b60SAndrew Rist * "License"); you may not use this file except in compliance 9*6d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*6d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*6d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6d739b60SAndrew Rist * software distributed under the License is distributed on an 15*6d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6d739b60SAndrew Rist * KIND, either express or implied. See the License for the 17*6d739b60SAndrew Rist * specific language governing permissions and limitations 18*6d739b60SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*6d739b60SAndrew Rist *************************************************************/ 21*6d739b60SAndrew Rist 22*6d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir #include "services/taskcreatorsrv.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir //_______________________________________________ 29cdf0e10cSrcweir // own includes 30cdf0e10cSrcweir #include <helper/persistentwindowstate.hxx> 31cdf0e10cSrcweir #include <helper/tagwindowasmodified.hxx> 32cdf0e10cSrcweir #include <helper/titlebarupdate.hxx> 33cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 34cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 35cdf0e10cSrcweir #include <loadenv/targethelper.hxx> 36cdf0e10cSrcweir #include <services.h> 37cdf0e10cSrcweir 38cdf0e10cSrcweir //_______________________________________________ 39cdf0e10cSrcweir // interface includes 40cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 41cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 42cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 43cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 44cdf0e10cSrcweir #include <com/sun/star/awt/XTopWindow.hpp> 45cdf0e10cSrcweir #include <com/sun/star/awt/WindowDescriptor.hpp> 46cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 47cdf0e10cSrcweir #include <com/sun/star/awt/VclWindowPeerAttribute.hpp> 48cdf0e10cSrcweir 49cdf0e10cSrcweir //_______________________________________________ 50cdf0e10cSrcweir // other includes 51cdf0e10cSrcweir #include <svtools/colorcfg.hxx> 52cdf0e10cSrcweir #include <vcl/svapp.hxx> 53cdf0e10cSrcweir 54cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ 55cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #include <vcl/window.hxx> 58cdf0e10cSrcweir 59cdf0e10cSrcweir //_______________________________________________ 60cdf0e10cSrcweir // namespaces 61cdf0e10cSrcweir 62cdf0e10cSrcweir namespace framework 63cdf0e10cSrcweir { 64cdf0e10cSrcweir 65cdf0e10cSrcweir //----------------------------------------------- 66cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_PARENTFRAME = ::rtl::OUString::createFromAscii("ParentFrame" ); // XFrame 67cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_FRAMENAME = ::rtl::OUString::createFromAscii("FrameName" ); // OUString 68cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_MAKEVISIBLE = ::rtl::OUString::createFromAscii("MakeVisible" ); // sal_Bool 69cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_CREATETOPWINDOW = ::rtl::OUString::createFromAscii("CreateTopWindow" ); // sal_Bool 70cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_POSSIZE = ::rtl::OUString::createFromAscii("PosSize" ); // Rectangle 71cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_CONTAINERWINDOW = ::rtl::OUString::createFromAscii("ContainerWindow" ); // XWindow 72cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE = ::rtl::OUString::createFromAscii("SupportPersistentWindowState" ); // sal_Bool 73cdf0e10cSrcweir const ::rtl::OUString TaskCreatorService::ARGUMENT_ENABLE_TITLEBARUPDATE = ::rtl::OUString::createFromAscii("EnableTitleBarUpdate" ); // sal_Bool 74cdf0e10cSrcweir 75cdf0e10cSrcweir //----------------------------------------------- 76cdf0e10cSrcweir DEFINE_XINTERFACE_3(TaskCreatorService , 77cdf0e10cSrcweir OWeakObject , 78cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XTypeProvider ), 79cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XServiceInfo ), 80cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XSingleServiceFactory)) 81cdf0e10cSrcweir 82cdf0e10cSrcweir //----------------------------------------------- 83cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_3(TaskCreatorService , 84cdf0e10cSrcweir css::lang::XTypeProvider , 85cdf0e10cSrcweir css::lang::XServiceInfo , 86cdf0e10cSrcweir css::lang::XSingleServiceFactory) 87cdf0e10cSrcweir 88cdf0e10cSrcweir //----------------------------------------------- 89cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(TaskCreatorService , 90cdf0e10cSrcweir ::cppu::OWeakObject , 91cdf0e10cSrcweir SERVICENAME_TASKCREATOR , 92cdf0e10cSrcweir IMPLEMENTATIONNAME_FWK_TASKCREATOR) 93cdf0e10cSrcweir 94cdf0e10cSrcweir //----------------------------------------------- 95cdf0e10cSrcweir DEFINE_INIT_SERVICE( 96cdf0e10cSrcweir TaskCreatorService, 97cdf0e10cSrcweir { 98cdf0e10cSrcweir /*Attention 99cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() 100cdf0e10cSrcweir to create a new instance of this class by our own supported service factory. 101cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations! 102cdf0e10cSrcweir */ 103cdf0e10cSrcweir } 104cdf0e10cSrcweir ) 105cdf0e10cSrcweir 106cdf0e10cSrcweir //----------------------------------------------- 107cdf0e10cSrcweir TaskCreatorService::TaskCreatorService(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) 108cdf0e10cSrcweir : ThreadHelpBase (&Application::GetSolarMutex()) 109cdf0e10cSrcweir , ::cppu::OWeakObject( ) 110cdf0e10cSrcweir , m_xSMGR (xSMGR ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir //----------------------------------------------- 115cdf0e10cSrcweir TaskCreatorService::~TaskCreatorService() 116cdf0e10cSrcweir { 117cdf0e10cSrcweir } 118cdf0e10cSrcweir 119cdf0e10cSrcweir //----------------------------------------------- 120cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createInstance() 121cdf0e10cSrcweir throw(css::uno::Exception , 122cdf0e10cSrcweir css::uno::RuntimeException) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return createInstanceWithArguments(css::uno::Sequence< css::uno::Any >()); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir //----------------------------------------------- 128cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > SAL_CALL TaskCreatorService::createInstanceWithArguments(const css::uno::Sequence< css::uno::Any >& lArguments) 129cdf0e10cSrcweir throw(css::uno::Exception , 130cdf0e10cSrcweir css::uno::RuntimeException) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir static ::rtl::OUString DEFAULTVAL_FRAMENAME = ::rtl::OUString(); 133cdf0e10cSrcweir static sal_Bool DEFAULTVAL_MAKEVISIBLE = sal_False; 134cdf0e10cSrcweir static sal_Bool DEFAULTVAL_CREATETOPWINDOW = sal_True; 135cdf0e10cSrcweir static css::awt::Rectangle DEFAULTVAL_POSSIZE = css::awt::Rectangle(0, 0, 0, 0); // only possize=[0,0,0,0] triggers default handling of vcl ! 136cdf0e10cSrcweir static sal_Bool DEFAULTVAL_SUPPORTPERSSISTENTWINDOWSTATE = sal_False; 137cdf0e10cSrcweir static sal_Bool DEFAULTVAL_ENABLE_TITLEBARUPDATE = sal_True; 138cdf0e10cSrcweir 139cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lArgs(lArguments); 140cdf0e10cSrcweir 141cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xParentFrame = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_PARENTFRAME , css::uno::Reference< css::frame::XFrame >()); 142cdf0e10cSrcweir ::rtl::OUString sFrameName = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_FRAMENAME , DEFAULTVAL_FRAMENAME ); 143cdf0e10cSrcweir sal_Bool bVisible = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_MAKEVISIBLE , DEFAULTVAL_MAKEVISIBLE ); 144cdf0e10cSrcweir sal_Bool bCreateTopWindow = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_CREATETOPWINDOW , DEFAULTVAL_CREATETOPWINDOW ); 145cdf0e10cSrcweir css::awt::Rectangle aPosSize = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_POSSIZE , DEFAULTVAL_POSSIZE ); 146cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xContainerWindow = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_CONTAINERWINDOW , css::uno::Reference< css::awt::XWindow >() ); 147cdf0e10cSrcweir sal_Bool bSupportPersistentWindowState = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE , DEFAULTVAL_SUPPORTPERSSISTENTWINDOWSTATE ); 148cdf0e10cSrcweir sal_Bool bEnableTitleBarUpdate = lArgs.getUnpackedValueOrDefault(TaskCreatorService::ARGUMENT_ENABLE_TITLEBARUPDATE , DEFAULTVAL_ENABLE_TITLEBARUPDATE ); 149cdf0e10cSrcweir 150cdf0e10cSrcweir /* SAFE { */ 151cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 152cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 153cdf0e10cSrcweir aReadLock.unlock(); 154cdf0e10cSrcweir /* } SAFE */ 155cdf0e10cSrcweir 156cdf0e10cSrcweir // We use FrameName property to set it as API name of the new created frame later. 157cdf0e10cSrcweir // But those frame names must be different from the set of special target names as e.g. _blank, _self etcpp ! 158cdf0e10cSrcweir ::rtl::OUString sRightName = impl_filterNames(sFrameName); 159cdf0e10cSrcweir 160cdf0e10cSrcweir // if no external frame window was given ... create a new one. 161cdf0e10cSrcweir if ( ! xContainerWindow.is()) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xParentWindow; 164cdf0e10cSrcweir if (xParentFrame.is()) 165cdf0e10cSrcweir xParentWindow = xParentFrame->getContainerWindow(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir // Parent has no own window ... 168cdf0e10cSrcweir // So we have to create a top level window always ! 169cdf0e10cSrcweir if ( ! xParentWindow.is()) 170cdf0e10cSrcweir bCreateTopWindow = sal_True; 171cdf0e10cSrcweir 172cdf0e10cSrcweir xContainerWindow = implts_createContainerWindow(xParentWindow, aPosSize, bCreateTopWindow); 173cdf0e10cSrcweir } 174cdf0e10cSrcweir 175cdf0e10cSrcweir //-------------------> 176cdf0e10cSrcweir // HACK #125187# + #i53630# 177cdf0e10cSrcweir // Mark all document windows as "special ones", so VCL can bind 178cdf0e10cSrcweir // special features to it. Because VCL doesnt know anything about documents ... 179cdf0e10cSrcweir // Note: Doing so it's no longer supported, that e.g. our wizards can use findFrame(_blank) 180cdf0e10cSrcweir // to create it's previes frames. They must do it manually by using WindowDescriptor+Toolkit! 181cdf0e10cSrcweir css::uno::Reference< css::frame::XDesktop > xDesktop(xParentFrame, css::uno::UNO_QUERY); 182cdf0e10cSrcweir ::sal_Bool bTopLevelDocumentWindow = ( 183cdf0e10cSrcweir (sRightName.getLength () < 1) && 184cdf0e10cSrcweir ( 185cdf0e10cSrcweir (! xParentFrame.is() ) || 186cdf0e10cSrcweir ( xDesktop.is() ) 187cdf0e10cSrcweir ) 188cdf0e10cSrcweir ); 189cdf0e10cSrcweir if (bTopLevelDocumentWindow) 190cdf0e10cSrcweir implts_applyDocStyleToWindow(xContainerWindow); 191cdf0e10cSrcweir //-------------------> 192cdf0e10cSrcweir 193cdf0e10cSrcweir // create the new frame 194cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xFrame = implts_createFrame(xParentFrame, xContainerWindow, sRightName); 195cdf0e10cSrcweir 196cdf0e10cSrcweir // special freature: 197cdf0e10cSrcweir // A special listener will restore pos/size states in case 198cdf0e10cSrcweir // a component was loaded into the frame first time. 199cdf0e10cSrcweir if (bSupportPersistentWindowState) 200cdf0e10cSrcweir implts_establishWindowStateListener(xFrame); 201cdf0e10cSrcweir 202cdf0e10cSrcweir // special feature: On Mac we need tagging the window in case 203cdf0e10cSrcweir // the underlying model was modified. 204cdf0e10cSrcweir // VCL will ignore our calls in case different platform then Mac 205cdf0e10cSrcweir // is used ... 206cdf0e10cSrcweir if (bTopLevelDocumentWindow) 207cdf0e10cSrcweir implts_establishDocModifyListener (xFrame); 208cdf0e10cSrcweir 209cdf0e10cSrcweir // special freature: 210cdf0e10cSrcweir // A special listener will update title bar (text and icon) 211cdf0e10cSrcweir // if component of frame will be changed. 212cdf0e10cSrcweir if (bEnableTitleBarUpdate) 213cdf0e10cSrcweir implts_establishTitleBarUpdate(xFrame); 214cdf0e10cSrcweir 215cdf0e10cSrcweir // Make it visible directly here ... 216cdf0e10cSrcweir // if its required from outside. 217cdf0e10cSrcweir if (bVisible) 218cdf0e10cSrcweir xContainerWindow->setVisible(bVisible); 219cdf0e10cSrcweir 220cdf0e10cSrcweir return css::uno::Reference< css::uno::XInterface >(xFrame, css::uno::UNO_QUERY_THROW); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir 223cdf0e10cSrcweir //----------------------------------------------- 224cdf0e10cSrcweir void TaskCreatorService::implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) const 225cdf0e10cSrcweir { 226cdf0e10cSrcweir // SYNCHRONIZED -> 227cdf0e10cSrcweir ::vos::OClearableGuard aSolarGuard(Application::GetSolarMutex()); 228cdf0e10cSrcweir Window* pVCLWindow = VCLUnoHelper::GetWindow(xWindow); 229cdf0e10cSrcweir if (pVCLWindow) 230cdf0e10cSrcweir pVCLWindow->SetExtendedStyle(WB_EXT_DOCUMENT); 231cdf0e10cSrcweir aSolarGuard.clear(); 232cdf0e10cSrcweir // <- SYNCHRONIZED 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir //----------------------------------------------- 236cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > TaskCreatorService::implts_createContainerWindow( const css::uno::Reference< css::awt::XWindow >& xParentWindow , 237cdf0e10cSrcweir const css::awt::Rectangle& aPosSize , 238cdf0e10cSrcweir sal_Bool bTopWindow ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir // SAFE -> 241cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 242cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 243cdf0e10cSrcweir aReadLock.unlock(); 244cdf0e10cSrcweir // <- SAFE 245cdf0e10cSrcweir 246cdf0e10cSrcweir // get toolkit to create task container window 247cdf0e10cSrcweir css::uno::Reference< css::awt::XToolkit > xToolkit( xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), css::uno::UNO_QUERY_THROW); 248cdf0e10cSrcweir 249cdf0e10cSrcweir // Check if child frames can be created realy. We need at least a valid window at the parent frame ... 250cdf0e10cSrcweir css::uno::Reference< css::awt::XWindowPeer > xParentWindowPeer; 251cdf0e10cSrcweir if ( ! bTopWindow) 252cdf0e10cSrcweir { 253cdf0e10cSrcweir if ( ! xParentWindow.is()) 254cdf0e10cSrcweir bTopWindow = sal_False; 255cdf0e10cSrcweir else 256cdf0e10cSrcweir xParentWindowPeer = css::uno::Reference< css::awt::XWindowPeer >(xParentWindow, css::uno::UNO_QUERY_THROW); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir // describe window properties. 260cdf0e10cSrcweir css::awt::WindowDescriptor aDescriptor; 261cdf0e10cSrcweir if (bTopWindow) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir aDescriptor.Type = css::awt::WindowClass_TOP ; 264cdf0e10cSrcweir aDescriptor.WindowServiceName = DECLARE_ASCII("window") ; 265cdf0e10cSrcweir aDescriptor.ParentIndex = -1 ; 266cdf0e10cSrcweir aDescriptor.Parent = css::uno::Reference< css::awt::XWindowPeer >() ; 267cdf0e10cSrcweir aDescriptor.Bounds = aPosSize ; 268cdf0e10cSrcweir aDescriptor.WindowAttributes = css::awt::WindowAttribute::BORDER | 269cdf0e10cSrcweir css::awt::WindowAttribute::MOVEABLE | 270cdf0e10cSrcweir css::awt::WindowAttribute::SIZEABLE | 271cdf0e10cSrcweir css::awt::WindowAttribute::CLOSEABLE | 272cdf0e10cSrcweir css::awt::VclWindowPeerAttribute::CLIPCHILDREN ; 273cdf0e10cSrcweir } 274cdf0e10cSrcweir else 275cdf0e10cSrcweir { 276cdf0e10cSrcweir aDescriptor.Type = css::awt::WindowClass_TOP ; 277cdf0e10cSrcweir aDescriptor.WindowServiceName = DECLARE_ASCII("dockingwindow") ; 278cdf0e10cSrcweir aDescriptor.ParentIndex = 1 ; 279cdf0e10cSrcweir aDescriptor.Parent = xParentWindowPeer ; 280cdf0e10cSrcweir aDescriptor.Bounds = aPosSize ; 281cdf0e10cSrcweir aDescriptor.WindowAttributes = css::awt::VclWindowPeerAttribute::CLIPCHILDREN ; 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir // create a new blank container window and get access to parent container to append new created task. 285cdf0e10cSrcweir css::uno::Reference< css::awt::XWindowPeer > xPeer = xToolkit->createWindow( aDescriptor ); 286cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow ( xPeer, css::uno::UNO_QUERY ); 287cdf0e10cSrcweir if ( ! xWindow.is()) 288cdf0e10cSrcweir throw css::uno::Exception(::rtl::OUString::createFromAscii("TaskCreator service was not able to create suitable frame window."), 289cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 290cdf0e10cSrcweir if (bTopWindow) 291cdf0e10cSrcweir xPeer->setBackground(::svtools::ColorConfig().GetColorValue(::svtools::APPBACKGROUND).nColor); 292cdf0e10cSrcweir else 293cdf0e10cSrcweir xPeer->setBackground(0xffffffff); 294cdf0e10cSrcweir 295cdf0e10cSrcweir return xWindow; 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir //----------------------------------------------- 299cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > TaskCreatorService::implts_createFrame( const css::uno::Reference< css::frame::XFrame >& xParentFrame , 300cdf0e10cSrcweir const css::uno::Reference< css::awt::XWindow >& xContainerWindow, 301cdf0e10cSrcweir const ::rtl::OUString& sName ) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir // SAFE -> 304cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 305cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 306cdf0e10cSrcweir aReadLock.unlock(); 307cdf0e10cSrcweir // <- SAFE 308cdf0e10cSrcweir 309cdf0e10cSrcweir // create new frame. 310cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xNewFrame( xSMGR->createInstance( SERVICENAME_FRAME ), css::uno::UNO_QUERY_THROW ); 311cdf0e10cSrcweir 312cdf0e10cSrcweir // Set window on frame. 313cdf0e10cSrcweir // Do it before calling any other interface methods ... 314cdf0e10cSrcweir // The new created frame must be initialized before you can do anything else there. 315cdf0e10cSrcweir xNewFrame->initialize( xContainerWindow ); 316cdf0e10cSrcweir 317cdf0e10cSrcweir // Put frame to the frame tree. 318cdf0e10cSrcweir // Note: The property creator/parent will be set on the new putted frame automaticly ... by the parent container. 319cdf0e10cSrcweir if (xParentFrame.is()) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir css::uno::Reference< css::frame::XFramesSupplier > xSupplier (xParentFrame, css::uno::UNO_QUERY_THROW); 322cdf0e10cSrcweir css::uno::Reference< css::frame::XFrames > xContainer = xSupplier->getFrames(); 323cdf0e10cSrcweir xContainer->append( xNewFrame ); 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir // Set it's API name (if there is one from outside) 327cdf0e10cSrcweir if (sName.getLength()) 328cdf0e10cSrcweir xNewFrame->setName( sName ); 329cdf0e10cSrcweir 330cdf0e10cSrcweir return xNewFrame; 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir //----------------------------------------------- 334cdf0e10cSrcweir void TaskCreatorService::implts_establishWindowStateListener( const css::uno::Reference< css::frame::XFrame >& xFrame ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir // SAFE -> 337cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 338cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 339cdf0e10cSrcweir aReadLock.unlock(); 340cdf0e10cSrcweir // <- SAFE 341cdf0e10cSrcweir 342cdf0e10cSrcweir // Special feature: It's allowed for frames using a top level window only! 343cdf0e10cSrcweir // We must create a special listener service and couple it with the new created task frame. 344cdf0e10cSrcweir // He will restore or save the window state of it ... 345cdf0e10cSrcweir // See used classes for further informations too. 346cdf0e10cSrcweir PersistentWindowState* pPersistentStateHandler = new PersistentWindowState(xSMGR); 347cdf0e10cSrcweir css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pPersistentStateHandler), css::uno::UNO_QUERY_THROW); 348cdf0e10cSrcweir 349cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > lInitData(1); 350cdf0e10cSrcweir lInitData[0] <<= xFrame; 351cdf0e10cSrcweir xInit->initialize(lInitData); 352cdf0e10cSrcweir } 353cdf0e10cSrcweir 354cdf0e10cSrcweir //----------------------------------------------- 355cdf0e10cSrcweir void TaskCreatorService::implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame >& xFrame ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir // SAFE -> 358cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 359cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 360cdf0e10cSrcweir aReadLock.unlock(); 361cdf0e10cSrcweir // <- SAFE 362cdf0e10cSrcweir 363cdf0e10cSrcweir // Special feature: It's allowed for frames using a top level window only! 364cdf0e10cSrcweir // We must create a special listener service and couple it with the new created task frame. 365cdf0e10cSrcweir // It will tag the window as modified if the underlying model was modified ... 366cdf0e10cSrcweir TagWindowAsModified* pTag = new TagWindowAsModified(xSMGR); 367cdf0e10cSrcweir css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pTag), css::uno::UNO_QUERY_THROW); 368cdf0e10cSrcweir 369cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > lInitData(1); 370cdf0e10cSrcweir lInitData[0] <<= xFrame; 371cdf0e10cSrcweir xInit->initialize(lInitData); 372cdf0e10cSrcweir } 373cdf0e10cSrcweir 374cdf0e10cSrcweir //----------------------------------------------- 375cdf0e10cSrcweir void TaskCreatorService::implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame >& xFrame ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // SAFE -> 378cdf0e10cSrcweir ReadGuard aReadLock( m_aLock ); 379cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 380cdf0e10cSrcweir aReadLock.unlock(); 381cdf0e10cSrcweir // <- SAFE 382cdf0e10cSrcweir 383cdf0e10cSrcweir TitleBarUpdate* pHelper = new TitleBarUpdate (xSMGR); 384cdf0e10cSrcweir css::uno::Reference< css::lang::XInitialization > xInit(static_cast< ::cppu::OWeakObject* >(pHelper), css::uno::UNO_QUERY_THROW); 385cdf0e10cSrcweir 386cdf0e10cSrcweir css::uno::Sequence< css::uno::Any > lInitData(1); 387cdf0e10cSrcweir lInitData[0] <<= xFrame; 388cdf0e10cSrcweir xInit->initialize(lInitData); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir //----------------------------------------------- 392cdf0e10cSrcweir ::rtl::OUString TaskCreatorService::impl_filterNames( const ::rtl::OUString& sName ) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir ::rtl::OUString sFiltered; 395cdf0e10cSrcweir if (TargetHelper::isValidNameForFrame(sName)) 396cdf0e10cSrcweir sFiltered = sName; 397cdf0e10cSrcweir return sFiltered; 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir } // namespace framework 401