diff options
author | Noel Grandin <noel@peralex.com> | 2013-03-08 12:57:31 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2013-03-20 07:32:50 +0200 |
commit | e655c756c48f3ba21e18eae6b705432e5dd37a08 (patch) | |
tree | 924423b626d28920c776720ce12d46243755d4a6 /sw/source/ui | |
parent | 4f26b7a6d1524e2feccd6d5fe8f70ea8c1bed80e (diff) |
fdo#46808, cleanup some usage of comphelper::getProcessServiceFactory()
Change-Id: Id343405c323a9efe86f7d9f41c3c866d817a0ccd
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/dbui/mailmergehelper.cxx | 124 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmconfigitem.cxx | 41 | ||||
-rw-r--r-- | sw/source/ui/envelp/labelexp.cxx | 6 |
3 files changed, 83 insertions, 88 deletions
diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx index 9aa0ecbb4a0f..37070ee914ec 100644 --- a/sw/source/ui/dbui/mailmergehelper.cxx +++ b/sw/source/ui/dbui/mailmergehelper.cxx @@ -97,77 +97,75 @@ uno::Reference< mail::XSmtpService > ConnectToSmtpServer( Window* pDialogParentWindow ) { uno::Reference< mail::XSmtpService > xSmtpServer; - uno::Reference< lang::XMultiServiceFactory> rMgr = ::comphelper::getProcessServiceFactory(); - if (rMgr.is()) - try - { - uno::Reference< mail::XMailServiceProvider > xMailServiceProvider( - mail::MailServiceProvider::create( - comphelper::getComponentContext(rMgr))); - xSmtpServer = uno::Reference< mail::XSmtpService > ( - xMailServiceProvider->create( - mail::MailServiceType_SMTP - ), uno::UNO_QUERY); - - uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener()); - - if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP()) - { - uno::Reference< mail::XMailService > xInMailService = + uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); + try + { + uno::Reference< mail::XMailServiceProvider > xMailServiceProvider( + mail::MailServiceProvider::create( xContext ) ); + xSmtpServer = uno::Reference< mail::XSmtpService > ( xMailServiceProvider->create( - rConfigItem.IsInServerPOP() ? - mail::MailServiceType_POP3 : mail::MailServiceType_IMAP); - //authenticate at the POP or IMAP server first - String sPasswd = rConfigItem.GetInServerPassword(); - if(rInMailServerPassword.Len()) - sPasswd = rInMailServerPassword; - uno::Reference<mail::XAuthenticator> xAuthenticator = - new SwAuthenticator( - rConfigItem.GetInServerUserName(), - sPasswd, - pDialogParentWindow); + mail::MailServiceType_SMTP + ), uno::UNO_QUERY); - xInMailService->addConnectionListener(xConnectionListener); - //check connection - uno::Reference< uno::XCurrentContext> xConnectionContext = - new SwConnectionContext( - rConfigItem.GetInServerName(), - rConfigItem.GetInServerPort(), - ::rtl::OUString("Insecure")); - xInMailService->connect(xConnectionContext, xAuthenticator); - rxInMailService = xInMailService; - } - uno::Reference< mail::XAuthenticator> xAuthenticator; - if(rConfigItem.IsAuthentication() && - !rConfigItem.IsSMTPAfterPOP() && - !rConfigItem.GetMailUserName().isEmpty()) - { - String sPasswd = rConfigItem.GetMailPassword(); - if(rOutMailServerPassword.Len()) - sPasswd = rOutMailServerPassword; - xAuthenticator = - new SwAuthenticator(rConfigItem.GetMailUserName(), - sPasswd, - pDialogParentWindow); - } - else - xAuthenticator = new SwAuthenticator(); - //just to check if the server exists - xSmtpServer->getSupportedConnectionTypes(); - //check connection + uno::Reference< mail::XConnectionListener> xConnectionListener(new SwConnectionListener()); + if(rConfigItem.IsAuthentication() && rConfigItem.IsSMTPAfterPOP()) + { + uno::Reference< mail::XMailService > xInMailService = + xMailServiceProvider->create( + rConfigItem.IsInServerPOP() ? + mail::MailServiceType_POP3 : mail::MailServiceType_IMAP); + //authenticate at the POP or IMAP server first + String sPasswd = rConfigItem.GetInServerPassword(); + if(rInMailServerPassword.Len()) + sPasswd = rInMailServerPassword; + uno::Reference<mail::XAuthenticator> xAuthenticator = + new SwAuthenticator( + rConfigItem.GetInServerUserName(), + sPasswd, + pDialogParentWindow); + + xInMailService->addConnectionListener(xConnectionListener); + //check connection uno::Reference< uno::XCurrentContext> xConnectionContext = new SwConnectionContext( - rConfigItem.GetMailServer(), - rConfigItem.GetMailPort(), - rConfigItem.IsSecureConnection() ? OUString("Ssl") : OUString("Insecure") ); - xSmtpServer->connect(xConnectionContext, xAuthenticator); - rxInMailService = uno::Reference< mail::XMailService >( xSmtpServer, uno::UNO_QUERY ); + rConfigItem.GetInServerName(), + rConfigItem.GetInServerPort(), + ::rtl::OUString("Insecure")); + xInMailService->connect(xConnectionContext, xAuthenticator); + rxInMailService = xInMailService; } - catch (const uno::Exception&) + uno::Reference< mail::XAuthenticator> xAuthenticator; + if(rConfigItem.IsAuthentication() && + !rConfigItem.IsSMTPAfterPOP() && + !rConfigItem.GetMailUserName().isEmpty()) { - OSL_FAIL("exception caught"); + String sPasswd = rConfigItem.GetMailPassword(); + if(rOutMailServerPassword.Len()) + sPasswd = rOutMailServerPassword; + xAuthenticator = + new SwAuthenticator(rConfigItem.GetMailUserName(), + sPasswd, + pDialogParentWindow); } + else + xAuthenticator = new SwAuthenticator(); + //just to check if the server exists + xSmtpServer->getSupportedConnectionTypes(); + //check connection + + uno::Reference< uno::XCurrentContext> xConnectionContext = + new SwConnectionContext( + rConfigItem.GetMailServer(), + rConfigItem.GetMailPort(), + rConfigItem.IsSecureConnection() ? OUString("Ssl") : OUString("Insecure") ); + xSmtpServer->connect(xConnectionContext, xAuthenticator); + rxInMailService = uno::Reference< mail::XMailService >( xSmtpServer, uno::UNO_QUERY ); + } + catch (const uno::Exception&) + { + OSL_FAIL("exception caught"); + } return xSmtpServer; } diff --git a/sw/source/ui/dbui/mmconfigitem.cxx b/sw/source/ui/dbui/mmconfigitem.cxx index 5e086fc777db..f47a0597113c 100644 --- a/sw/source/ui/dbui/mmconfigitem.cxx +++ b/sw/source/ui/dbui/mmconfigitem.cxx @@ -902,30 +902,27 @@ Reference< XResultSet> SwMailMergeConfigItem::GetResultSet() const try { Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() ); - if( xMgr.is() ) + + Reference<XRowSet> xRowSet( xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY ); + Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY); + xRowProperties->setPropertyValue("DataSourceName", makeAny(m_pImpl->aDBData.sDataSource)); + xRowProperties->setPropertyValue("Command", makeAny(m_pImpl->aDBData.sCommand)); + xRowProperties->setPropertyValue("CommandType", makeAny(m_pImpl->aDBData.nCommandType)); + xRowProperties->setPropertyValue("FetchSize", makeAny((sal_Int32)10)); + xRowProperties->setPropertyValue("ActiveConnection", makeAny(m_pImpl->xConnection.getTyped())); + try { - Reference<XRowSet> xRowSet( - xMgr->createInstance("com.sun.star.sdb.RowSet"), UNO_QUERY); - Reference<XPropertySet> xRowProperties(xRowSet, UNO_QUERY); - xRowProperties->setPropertyValue("DataSourceName", makeAny(m_pImpl->aDBData.sDataSource)); - xRowProperties->setPropertyValue("Command", makeAny(m_pImpl->aDBData.sCommand)); - xRowProperties->setPropertyValue("CommandType", makeAny(m_pImpl->aDBData.nCommandType)); - xRowProperties->setPropertyValue("FetchSize", makeAny((sal_Int32)10)); - xRowProperties->setPropertyValue("ActiveConnection", makeAny(m_pImpl->xConnection.getTyped())); - try - { - xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->sFilter.isEmpty())); - xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->sFilter)); - } - catch (const Exception&) - { - OSL_FAIL("exception caught in xResultSet->SetFilter()"); - } - xRowSet->execute(); - m_pImpl->xResultSet = xRowSet.get(); - m_pImpl->xResultSet->first(); - m_pImpl->nResultSetCursorPos = 1; + xRowProperties->setPropertyValue("ApplyFilter", makeAny(!m_pImpl->sFilter.isEmpty())); + xRowProperties->setPropertyValue("Filter", makeAny(m_pImpl->sFilter)); + } + catch (const Exception&) + { + OSL_FAIL("exception caught in xResultSet->SetFilter()"); } + xRowSet->execute(); + m_pImpl->xResultSet = xRowSet.get(); + m_pImpl->xResultSet->first(); + m_pImpl->nResultSetCursorPos = 1; } catch (const Exception&) { diff --git a/sw/source/ui/envelp/labelexp.cxx b/sw/source/ui/envelp/labelexp.cxx index a90eaef95e70..f3ae13ffa629 100644 --- a/sw/source/ui/envelp/labelexp.cxx +++ b/sw/source/ui/envelp/labelexp.cxx @@ -49,11 +49,11 @@ void SwVisitingCardPage::InitFrameControl() pExampleFrame = new SwOneExampleFrame( aExampleWIN, EX_SHOW_BUSINESS_CARDS, &aLink ); - uno::Reference< lang::XMultiServiceFactory > xMgr = - getProcessServiceFactory(); + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); + //now the AutoText ListBoxes have to be filled - m_xAutoText = text::AutoTextContainer::create( comphelper::getComponentContext(xMgr) ); + m_xAutoText = text::AutoTextContainer::create( xContext ); uno::Sequence<OUString> aNames = m_xAutoText->getElementNames(); const OUString* pGroups = aNames.getConstArray(); |