diff options
author | Noel Grandin <noel@peralex.com> | 2013-05-16 14:13:36 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-05-21 08:23:58 +0200 |
commit | 6c61b20a8d4a6dcac28801cde82a211fb7e30654 (patch) | |
tree | d82328eaa120b8bc822f028fa1e62bc7814c9e1b /basctl | |
parent | 6c53dff36ebdac7b6a6cf514ab469b2202d6aa48 (diff) |
fdo#46808, Convert awt::UnoControlDialogModel to new style
Change-Id: I4b912034ef3f4855b87d6d6f18ff13bd1ecc8f72
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside3.cxx | 50 | ||||
-rw-r--r-- | basctl/source/basicide/basides3.cxx | 10 | ||||
-rw-r--r-- | basctl/source/basicide/moduldlg.cxx | 35 | ||||
-rw-r--r-- | basctl/source/basicide/scriptdocument.cxx | 26 | ||||
-rw-r--r-- | basctl/source/dlged/dlged.cxx | 172 | ||||
-rw-r--r-- | basctl/source/dlged/dlgedfac.cxx | 12 |
6 files changed, 121 insertions, 184 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index 2643400dcc01..a6b87743f4f0 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -35,6 +35,7 @@ #include "objdlg.hxx" #include <basic/basmgr.hxx> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/resource/StringResourceWithLocation.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp> @@ -944,8 +945,7 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum { bool bDone = false; - Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); - Reference< XComponentContext > xContext( comphelper::getComponentContext( xMSF ) ); + Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); @@ -977,10 +977,9 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum try { // create dialog model - Reference< container::XNameContainer > xDialogModel( xMSF->createInstance - ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW ); + Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); - Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) ); + Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); Reference< XInputStream > xInput; if( xSFI->exists( aCurPath ) ) @@ -988,20 +987,7 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); - OUString aXmlDlgName; - Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY ); - if( xDialogModelPropSet.is() ) - { - try - { - Any aXmlDialogNameAny = xDialogModelPropSet->getPropertyValue( DLGED_PROP_NAME ); - OUString aOUXmlDialogName; - aXmlDialogNameAny >>= aOUXmlDialogName; - aXmlDlgName = aOUXmlDialogName; - } - catch(const beans::UnknownPropertyException& ) - {} - } + OUString aXmlDlgName = xDialogModel->getName(); bool bValidName = !aXmlDlgName.isEmpty(); OSL_ASSERT( bValidName ); if( !bValidName ) @@ -1186,30 +1172,8 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum if( eNameClashMode == CLASH_RENAME_DIALOG ) { - bool bRenamed = false; - if( xDialogModelPropSet.is() ) - { - try - { - Any aXmlDialogNameAny; - aXmlDialogNameAny <<= OUString( aNewDlgName ); - xDialogModelPropSet->setPropertyValue( DLGED_PROP_NAME, aXmlDialogNameAny ); - bRenamed = true; - } - catch(const beans::UnknownPropertyException& ) - {} - } - - - if( bRenamed ) - { - LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel ); - } - else - { - // TODO: Assertion? - return bDone; - } + xDialogModel->setName( aNewDlgName ); + LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel ); } Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx index 8d0b70dbb251..271282e5f445 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -26,8 +26,9 @@ #include <localizationmgr.hxx> #include <dlgedview.hxx> #include <comphelper/processfactory.hxx> -#include <com/sun/star/script/XLibraryContainer.hpp> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/script/XLibraryContainer.hpp> #include <xmlscript/xmldlg_imexp.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfac.hxx> @@ -75,12 +76,9 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri if ( xISP.is() ) { // create dialog model - Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); - Reference< container::XNameContainer > xDialogModel( xMSF->createInstance - ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY ); + Reference< uno::XComponentContext > xContext = getProcessComponentContext(); + Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); Reference< XInputStream > xInput( xISP->createInputStream() ); - Reference< XComponentContext > xContext( - comphelper::getComponentContext( xMSF ) ); ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel ); diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx index 49c58a31af09..84a25a9910b8 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -28,6 +28,7 @@ #include "iderdll.hxx" #include <basic/basmgr.hxx> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <comphelper/processfactory.hxx> #include <sfx2/app.hxx> @@ -284,31 +285,25 @@ void Shell::CopyDialogResources( return; // create dialog model - Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance - ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY ); + Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); Reference< io::XInputStream > xInput( io_xISP->createInputStream() ); - Reference< XComponentContext > xContext( - comphelper::getComponentContext( xMSF ) ); ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() ); - if( xDialogModel.is() ) + if( bSourceLocalized && bDestLocalized ) { - if( bSourceLocalized && bDestLocalized ) - { - Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY ); - LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver ); - } - else if( bSourceLocalized ) - { - LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr ); - } - else if( bDestLocalized ) - { - LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); - } - io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); + Reference< resource::XStringResourceResolver > xSourceStringResolver( xSourceMgr, UNO_QUERY ); + LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceStringResolver ); + } + else if( bSourceLocalized ) + { + LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr ); + } + else if( bDestLocalized ) + { + LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr ); } + io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() ); } diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx index 3224c7129a80..bccb4c4bcbb2 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -25,17 +25,18 @@ #include "doceventnotifier.hxx" #include "documentenumeration.hxx" -#include <com/sun/star/uri/UriReferenceFactory.hpp> -#include <com/sun/star/util/theMacroExpander.hpp> +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/document/MacroExecMode.hpp> -#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/document/XEmbeddedScripts.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/frame/XModel2.hpp> -#include <com/sun/star/awt/XWindow2.hpp> -#include <com/sun/star/document/XEmbeddedScripts.hpp> +#include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/util/theMacroExpander.hpp> #include <sfx2/objsh.hxx> #include <sfx2/app.hxx> @@ -629,12 +630,7 @@ namespace basctl if ( _rxExistingDialogModel.is() ) xDialogModel = _rxExistingDialogModel; else - xDialogModel.set( - ( aContext->getServiceManager()-> - createInstanceWithContext( - "com.sun.star.awt.UnoControlDialogModel", - aContext ) ), - UNO_QUERY_THROW ); + xDialogModel = css::awt::UnoControlDialogModel::create( aContext ); // import dialog model Reference< XInputStreamProvider > xISP( aElement, UNO_QUERY_THROW ); @@ -753,14 +749,10 @@ namespace basctl // create new dialog model Reference< XComponentContext > aContext( comphelper::getProcessComponentContext() ); - Reference< XNameContainer > xDialogModel( - aContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.UnoControlDialogModel", aContext ), - UNO_QUERY_THROW ); + Reference< css::awt::XUnoControlDialogModel > xDialogModel = css::awt::UnoControlDialogModel::create( aContext ); // set name property - Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW ); - xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _rDialogName ) ); + xDialogModel->setName( _rDialogName ); // export dialog model _out_rDialogProvider = ::xmlscript::exportDialogModel( xDialogModel, aContext, isDocument() ? getDocument() : Reference< XModel >() ); diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx index 935dcfd5b0b4..c4683f91d44f 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -33,6 +33,7 @@ #include "baside3.hxx" #include <com/sun/star/awt/XDialog.hpp> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/resource/StringResource.hpp> #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/util/NumberFormatsSupplier.hpp> @@ -872,9 +873,9 @@ void DlgEditor::Paste() if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) ) { // create clipboard dialog model from xml - Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); - Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance( - "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY ); + Reference< uno::XComponentContext > xContext = getProcessComponentContext(); + Reference< awt::XUnoControlDialogModel > xClipDialogModel = + awt::UnoControlDialogModel::create( xContext ); bool bSourceIsLocalized = false; Sequence< sal_Int8 > DialogModelBytes; @@ -914,102 +915,93 @@ void DlgEditor::Paste() aAny >>= DialogModelBytes; } - if ( xClipDialogModel.is() ) - { - Reference< XComponentContext > xContext( - comphelper::getComponentContext( xMSF ) ); - ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument ); - } + ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument ); // get control models from clipboard dialog model - Reference< ::com::sun::star::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY ); - if ( xNameAcc.is() ) - { - Sequence< OUString > aNames = xNameAcc->getElementNames(); - const OUString* pNames = aNames.getConstArray(); - sal_uInt32 nCtrls = aNames.getLength(); + Sequence< OUString > aNames = xClipDialogModel->getElementNames(); + const OUString* pNames = aNames.getConstArray(); + sal_uInt32 nCtrls = aNames.getLength(); - Reference< resource::XStringResourcePersistence > xStringResourcePersistence; - if( nCtrls > 0 && bSourceIsLocalized ) - { - xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() ); - xStringResourcePersistence->importBinary( aResData ); - } - for( sal_uInt32 n = 0; n < nCtrls; n++ ) + Reference< resource::XStringResourcePersistence > xStringResourcePersistence; + if( nCtrls > 0 && bSourceIsLocalized ) + { + xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() ); + xStringResourcePersistence->importBinary( aResData ); + } + for( sal_uInt32 n = 0; n < nCtrls; n++ ) + { + Any aA = xClipDialogModel->getByName( pNames[n] ); + Reference< ::com::sun::star::awt::XControlModel > xCM; + aA >>= xCM; + + // clone the control model + Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY ); + Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY ); + + DlgEdObj* pCtrlObj = new DlgEdObj(); + pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form + pDlgEdForm->AddChild(pCtrlObj); // add child to parent form + pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model + + // set new name + OUString aOUniqueName( pCtrlObj->GetUniqueName() ); + Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY ); + Any aUniqueName; + aUniqueName <<= aOUniqueName; + xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); + + // set tabindex + Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY ); + Sequence< OUString > aNames_ = xNA->getElementNames(); + Any aTabIndex; + aTabIndex <<= (sal_Int16) aNames_.getLength(); + xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex ); + + if( bLocalized ) { - Any aA = xNameAcc->getByName( pNames[n] ); - Reference< ::com::sun::star::awt::XControlModel > xCM; - aA >>= xCM; - - // clone the control model - Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY ); - Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY ); - - DlgEdObj* pCtrlObj = new DlgEdObj(); - pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form - pDlgEdForm->AddChild(pCtrlObj); // add child to parent form - pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model - - // set new name - OUString aOUniqueName( pCtrlObj->GetUniqueName() ); - Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY ); - Any aUniqueName; - aUniqueName <<= aOUniqueName; - xPSet->setPropertyValue( DLGED_PROP_NAME, aUniqueName ); - - // set tabindex - Reference< container::XNameAccess > xNA( m_xUnoControlDialogModel , UNO_QUERY ); - Sequence< OUString > aNames_ = xNA->getElementNames(); - Any aTabIndex; - aTabIndex <<= (sal_Int16) aNames_.getLength(); - xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex ); - - if( bLocalized ) + Any aControlAny; + aControlAny <<= xCtrlModel; + if( bSourceIsLocalized && xStringResourcePersistence.is() ) { - Any aControlAny; - aControlAny <<= xCtrlModel; - if( bSourceIsLocalized && xStringResourcePersistence.is() ) - { - Reference< resource::XStringResourceResolver > - xSourceStringResolver( xStringResourcePersistence, UNO_QUERY ); - LocalizationMgr::copyResourcesForPastedEditorObject( this, - aControlAny, aOUniqueName, xSourceStringResolver ); - } - else - { - LocalizationMgr::setControlResourceIDsForNewEditorObject - ( this, aControlAny, aOUniqueName ); - } + Reference< resource::XStringResourceResolver > + xSourceStringResolver( xStringResourcePersistence, UNO_QUERY ); + LocalizationMgr::copyResourcesForPastedEditorObject( this, + aControlAny, aOUniqueName, xSourceStringResolver ); + } + else + { + LocalizationMgr::setControlResourceIDsForNewEditorObject + ( this, aControlAny, aOUniqueName ); } - - // insert control model in editor dialog model - Any aCtrlModel; - aCtrlModel <<= xCtrlModel; - m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel ); - - // insert object into drawing page - pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj ); - pCtrlObj->SetRectFromProps(); - pCtrlObj->UpdateStep(); - pDlgEdForm->UpdateTabOrderAndGroups(); - pCtrlObj->StartListening(); // start listening - - // mark object - SdrPageView* pPgView = pDlgEdView->GetSdrPageView(); - pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true); } - // center marked objects in dialog editor form - Point aMarkCenter = (pDlgEdView->GetMarkedObjRect()).Center(); - Point aFormCenter = (pDlgEdForm->GetSnapRect()).Center(); - Point aPoint = aFormCenter - aMarkCenter; - Size aSize( aPoint.X() , aPoint.Y() ); - pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove - pDlgEdView->MarkListHasChanged(); - - // dialog model changed - SetDialogModelChanged(true); + // insert control model in editor dialog model + Any aCtrlModel; + aCtrlModel <<= xCtrlModel; + m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel ); + + // insert object into drawing page + pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj ); + pCtrlObj->SetRectFromProps(); + pCtrlObj->UpdateStep(); + pDlgEdForm->UpdateTabOrderAndGroups(); + pCtrlObj->StartListening(); // start listening + + // mark object + SdrPageView* pPgView = pDlgEdView->GetSdrPageView(); + pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true); } + + // center marked objects in dialog editor form + Point aMarkCenter = (pDlgEdView->GetMarkedObjRect()).Center(); + Point aFormCenter = (pDlgEdForm->GetSnapRect()).Center(); + Point aPoint = aFormCenter - aMarkCenter; + Size aSize( aPoint.X() , aPoint.Y() ); + pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove + pDlgEdView->MarkListHasChanged(); + + // dialog model changed + SetDialogModelChanged(true); } } } diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx index 1ffbff22968d..a092c8ffeea9 100644 --- a/basctl/source/dlged/dlgedfac.cxx +++ b/basctl/source/dlged/dlgedfac.cxx @@ -24,6 +24,8 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/ScrollBarOrientation.hpp> +#include <com/sun/star/awt/UnoControlDialogModel.hpp> + namespace basctl { @@ -46,17 +48,11 @@ DlgEdFactory::~DlgEdFactory() IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) { static bool bNeedsInit = true; - static uno::Reference< lang::XMultiServiceFactory > xDialogSFact; + static uno::Reference< awt::XUnoControlDialogModel > xDialogSFact; if( bNeedsInit ) { - uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); - uno::Reference< container::XNameContainer > xC( xMSF->createInstance( "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY ); - if( xC.is() ) - { - uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY ); - xDialogSFact = xModFact; - } + xDialogSFact = awt::UnoControlDialogModel::create( ::comphelper::getProcessComponentContext() ); bNeedsInit = false; } |