diff options
Diffstat (limited to 'basctl/source')
-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 | 175 | ||||
-rw-r--r-- | basctl/source/dlged/dlgedfac.cxx | 12 |
6 files changed, 185 insertions, 123 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx index a6b87743f4f0..2643400dcc01 100644 --- a/basctl/source/basicide/baside3.cxx +++ b/basctl/source/basicide/baside3.cxx @@ -35,7 +35,6 @@ #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> @@ -945,7 +944,8 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum { bool bDone = false; - Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() ); + Reference< XComponentContext > xContext( comphelper::getComponentContext( xMSF ) ); Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE); Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY); @@ -977,9 +977,10 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum try { // create dialog model - Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); + Reference< container::XNameContainer > xDialogModel( xMSF->createInstance + ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW ); - Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) ); + Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) ); Reference< XInputStream > xInput; if( xSFI->exists( aCurPath ) ) @@ -987,7 +988,20 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() ); - OUString aXmlDlgName = xDialogModel->getName(); + 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& ) + {} + } bool bValidName = !aXmlDlgName.isEmpty(); OSL_ASSERT( bValidName ); if( !bValidName ) @@ -1172,8 +1186,30 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum if( eNameClashMode == CLASH_RENAME_DIALOG ) { - xDialogModel->setName( aNewDlgName ); - LocalizationMgr::renameStringResourceIDs( rDocument, aLibName, aNewDlgName, xDialogModel ); + 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; + } } 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 271282e5f445..8d0b70dbb251 100644 --- a/basctl/source/basicide/basides3.cxx +++ b/basctl/source/basicide/basides3.cxx @@ -26,9 +26,8 @@ #include <localizationmgr.hxx> #include <dlgedview.hxx> #include <comphelper/processfactory.hxx> -#include <com/sun/star/awt/UnoControlDialogModel.hpp> -#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/script/XLibraryContainer.hpp> +#include <com/sun/star/container/XNameContainer.hpp> #include <xmlscript/xmldlg_imexp.hxx> #include <sfx2/dispatch.hxx> #include <sfx2/docfac.hxx> @@ -76,9 +75,12 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri if ( xISP.is() ) { // create dialog model - Reference< uno::XComponentContext > xContext = getProcessComponentContext(); - Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); + Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); + Reference< container::XNameContainer > xDialogModel( xMSF->createInstance + ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY ); 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 84a25a9910b8..49c58a31af09 100644 --- a/basctl/source/basicide/moduldlg.cxx +++ b/basctl/source/basicide/moduldlg.cxx @@ -28,7 +28,6 @@ #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> @@ -285,25 +284,31 @@ void Shell::CopyDialogResources( return; // create dialog model - Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); - Reference< awt::XUnoControlDialogModel > xDialogModel = awt::UnoControlDialogModel::create( xContext ); + Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); + Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance + ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY ); 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( bSourceLocalized && bDestLocalized ) + if( xDialogModel.is() ) { - 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 ); + 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 >() ); } - 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 bccb4c4bcbb2..3224c7129a80 100644 --- a/basctl/source/basicide/scriptdocument.cxx +++ b/basctl/source/basicide/scriptdocument.cxx @@ -25,18 +25,17 @@ #include "doceventnotifier.hxx" #include "documentenumeration.hxx" -#include <com/sun/star/awt/XWindow2.hpp> -#include <com/sun/star/awt/UnoControlDialogModel.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/util/theMacroExpander.hpp> #include <com/sun/star/document/MacroExecMode.hpp> -#include <com/sun/star/document/XEmbeddedScripts.hpp> +#include <com/sun/star/frame/XStorable.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/frame/XStorable.hpp> +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/document/XEmbeddedScripts.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> @@ -630,7 +629,12 @@ namespace basctl if ( _rxExistingDialogModel.is() ) xDialogModel = _rxExistingDialogModel; else - xDialogModel = css::awt::UnoControlDialogModel::create( aContext ); + xDialogModel.set( + ( aContext->getServiceManager()-> + createInstanceWithContext( + "com.sun.star.awt.UnoControlDialogModel", + aContext ) ), + UNO_QUERY_THROW ); // import dialog model Reference< XInputStreamProvider > xISP( aElement, UNO_QUERY_THROW ); @@ -749,10 +753,14 @@ namespace basctl // create new dialog model Reference< XComponentContext > aContext( comphelper::getProcessComponentContext() ); - Reference< css::awt::XUnoControlDialogModel > xDialogModel = css::awt::UnoControlDialogModel::create( aContext ); + Reference< XNameContainer > xDialogModel( + aContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.awt.UnoControlDialogModel", aContext ), + UNO_QUERY_THROW ); // set name property - xDialogModel->setName( _rDialogName ); + Reference< XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY_THROW ); + xDlgPSet->setPropertyValue( DLGED_PROP_NAME, makeAny( _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 8e55c02387c2..54aef41b16ba 100644 --- a/basctl/source/dlged/dlged.cxx +++ b/basctl/source/dlged/dlged.cxx @@ -33,8 +33,6 @@ #include "baside3.hxx" #include <com/sun/star/awt/Toolkit.hpp> -#include <com/sun/star/awt/UnoControlDialog.hpp> -#include <com/sun/star/awt/UnoControlDialogModel.hpp> #include <com/sun/star/awt/XDialog.hpp> #include <com/sun/star/resource/StringResource.hpp> #include <com/sun/star/util/XCloneable.hpp> @@ -93,7 +91,7 @@ void DlgEditor::ShowDialog() uno::Reference< uno::XComponentContext > xContext = getProcessComponentContext(); // create a dialog - uno::Reference< awt::XUnoControlDialog > xDlg = awt::UnoControlDialog::create( xContext ); + uno::Reference< awt::XControl > xDlg( getProcessServiceFactory()->createInstance( "com.sun.star.awt.UnoControlDialog" ), uno::UNO_QUERY ); // clone the dialog model uno::Reference< util::XCloneable > xC( m_xUnoControlDialogModel, uno::UNO_QUERY ); @@ -875,9 +873,9 @@ void DlgEditor::Paste() if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) ) { // create clipboard dialog model from xml - Reference< uno::XComponentContext > xContext = getProcessComponentContext(); - Reference< awt::XUnoControlDialogModel > xClipDialogModel = - awt::UnoControlDialogModel::create( xContext ); + Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory(); + Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance( + "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY ); bool bSourceIsLocalized = false; Sequence< sal_Int8 > DialogModelBytes; @@ -917,93 +915,102 @@ void DlgEditor::Paste() aAny >>= DialogModelBytes; } - ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument ); - - // get control models from clipboard dialog model - Sequence< OUString > aNames = xClipDialogModel->getElementNames(); - const OUString* pNames = aNames.getConstArray(); - sal_uInt32 nCtrls = aNames.getLength(); - - Reference< resource::XStringResourcePersistence > xStringResourcePersistence; - if( nCtrls > 0 && bSourceIsLocalized ) + if ( xClipDialogModel.is() ) { - xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() ); - xStringResourcePersistence->importBinary( aResData ); + Reference< XComponentContext > xContext( + comphelper::getComponentContext( xMSF ) ); + ::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument ); } - for( sal_uInt32 n = 0; n < nCtrls; n++ ) + + // get control models from clipboard dialog model + Reference< ::com::sun::star::container::XNameAccess > xNameAcc( xClipDialogModel, UNO_QUERY ); + if ( xNameAcc.is() ) { - 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 ) + Sequence< OUString > aNames = xNameAcc->getElementNames(); + const OUString* pNames = aNames.getConstArray(); + sal_uInt32 nCtrls = aNames.getLength(); + + Reference< resource::XStringResourcePersistence > xStringResourcePersistence; + if( nCtrls > 0 && bSourceIsLocalized ) { - Any aControlAny; - aControlAny <<= xCtrlModel; - if( bSourceIsLocalized && xStringResourcePersistence.is() ) - { - Reference< resource::XStringResourceResolver > - xSourceStringResolver( xStringResourcePersistence, UNO_QUERY ); - LocalizationMgr::copyResourcesForPastedEditorObject( this, - aControlAny, aOUniqueName, xSourceStringResolver ); - } - else + xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() ); + xStringResourcePersistence->importBinary( aResData ); + } + for( sal_uInt32 n = 0; n < nCtrls; n++ ) + { + 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 ) { - LocalizationMgr::setControlResourceIDsForNewEditorObject - ( this, aControlAny, aOUniqueName ); + 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 ); + } } - } - // 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); - } + // 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(); + // 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); + // dialog model changed + SetDialogModelChanged(true); + } } } } diff --git a/basctl/source/dlged/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx index a092c8ffeea9..1ffbff22968d 100644 --- a/basctl/source/dlged/dlgedfac.cxx +++ b/basctl/source/dlged/dlgedfac.cxx @@ -24,8 +24,6 @@ #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 { @@ -48,11 +46,17 @@ DlgEdFactory::~DlgEdFactory() IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory ) { static bool bNeedsInit = true; - static uno::Reference< awt::XUnoControlDialogModel > xDialogSFact; + static uno::Reference< lang::XMultiServiceFactory > xDialogSFact; if( bNeedsInit ) { - xDialogSFact = awt::UnoControlDialogModel::create( ::comphelper::getProcessComponentContext() ); + 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; + } bNeedsInit = false; } |