From 1abe2bdee6fbcaf876a19f75a765c72d833efa29 Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Mon, 29 Jan 2007 15:44:37 +0000 Subject: INTEGRATION: CWS ab32 (1.37.6); FILE MERGED 2007/01/18 13:55:46 ab 1.37.6.1: #i73077# Rename Resource IDs according to renamed dialog/control --- basctl/source/basicide/basobj3.cxx | 82 +++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 37 deletions(-) (limited to 'basctl/source/basicide') diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx index 2c4f52eebcb5..5e27b877c3fa 100644 --- a/basctl/source/basicide/basobj3.cxx +++ b/basctl/source/basicide/basobj3.cxx @@ -4,9 +4,9 @@ * * $RCSfile: basobj3.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: vg $ $Date: 2007-01-16 16:30:16 $ + * last change: $Author: rt $ $Date: 2007-01-29 16:44:37 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -477,6 +477,9 @@ void BasicIDE::RenameDialog( SfxObjectShell* pShell, const String& rLibName, con Reference< container::XNameContainer > xLib = GetDialogLibrary( pShell, rLibName, TRUE ); // rename dialog + BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); + IDEBaseWindow* pWin = NULL; + Reference< container::XNameContainer > xEditorDialogModel; if( xLib.is() && xLib->hasByName( aOUOldName ) ) { if ( xLib->hasByName( aOUNewName ) ) @@ -486,28 +489,46 @@ void BasicIDE::RenameDialog( SfxObjectShell* pShell, const String& rLibName, con Reference() ); } + if ( pIDEShell ) + { + pWin = pIDEShell->FindWindow( pShell, rLibName, rOldName, BASICIDE_TYPE_DIALOG, FALSE ); + if ( pWin ) + xEditorDialogModel = ((DialogWindow*)pWin)->GetEditor()->GetDialog(); + } + // get dialog Any aElement = xLib->getByName( aOUOldName ); // remove dialog from dialog container xLib->removeByName( aOUOldName ); - // create dialog model + // create or take existing dialog model Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); - Reference< container::XNameContainer > xDialogModel( xMSF->createInstance - ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); + Reference< container::XNameContainer > xDialogModel; + if( xEditorDialogModel.is() ) + { + xDialogModel = xEditorDialogModel; + } + else + { + xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); + } Reference< io::XInputStreamProvider > xISP; aElement >>= xISP; if( xISP.is() ) { - // import dialog model Reference< XComponentContext > xContext; Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); - Reference< io::XInputStream > xInput( xISP->createInputStream() ); - ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); + if( !xEditorDialogModel.is() ) + { + // import dialog model + Reference< io::XInputStream > xInput( xISP->createInputStream() ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext ); + } // set new name as property Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY ); @@ -515,6 +536,8 @@ void BasicIDE::RenameDialog( SfxObjectShell* pShell, const String& rLibName, con aName <<= aOUNewName; xDlgPSet->setPropertyValue( DLGED_PROP_NAME, aName ); + LocalizationMgr::renameStringResourceIDs( pShell, rLibName, aOUNewName, xDialogModel ); + // export dialog model xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); aElement <<= xISP; @@ -530,38 +553,23 @@ void BasicIDE::RenameDialog( SfxObjectShell* pShell, const String& rLibName, con Reference() ); } - BasicIDEShell* pIDEShell = IDE_DLL()->GetShell(); - if ( pIDEShell ) + if ( pWin ) { - IDEBaseWindow* pWin = pIDEShell->FindWindow( pShell, rLibName, rOldName, BASICIDE_TYPE_DIALOG, FALSE ); - if ( pWin ) - { - // set new name in window - pWin->SetName( rNewName ); + // set new name in window + pWin->SetName( rNewName ); - // get dialog model from dialog editor and set new name as property - Reference< container::XNameContainer > xDlgModel = ((DialogWindow*)pWin)->GetEditor()->GetDialog(); - if( xDlgModel.is() ) - { - Reference< beans::XPropertySet > xPSet( xDlgModel, UNO_QUERY ); - Any aName; - aName <<= aOUNewName; - xPSet->setPropertyValue( DLGED_PROP_NAME, aName ); - } - - // update property browser - ((DialogWindow*)pWin)->UpdateBrowser(); + // update property browser + ((DialogWindow*)pWin)->UpdateBrowser(); - // update tabwriter - USHORT nId = (USHORT)(pIDEShell->GetIDEWindowTable()).GetKey( pWin ); - DBG_ASSERT( nId, "No entry in Tabbar!" ); - if ( nId ) - { - BasicIDETabBar* pTabBar = (BasicIDETabBar*)pIDEShell->GetTabBar(); - pTabBar->SetPageText( nId, rNewName ); - pTabBar->Sort(); - pTabBar->MakeVisible( pTabBar->GetCurPageId() ); - } + // update tabwriter + USHORT nId = (USHORT)(pIDEShell->GetIDEWindowTable()).GetKey( pWin ); + DBG_ASSERT( nId, "No entry in Tabbar!" ); + if ( nId ) + { + BasicIDETabBar* pTabBar = (BasicIDETabBar*)pIDEShell->GetTabBar(); + pTabBar->SetPageText( nId, rNewName ); + pTabBar->Sort(); + pTabBar->MakeVisible( pTabBar->GetCurPageId() ); } } } -- cgit