summaryrefslogtreecommitdiff
path: root/embeddedobj
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-14 12:58:00 +0200
committerNoel Grandin <noel@peralex.com>2012-12-21 10:57:09 +0200
commitbb121c864cc3c101ef733a4088c7ba3e36eced14 (patch)
tree2d528ca830aace6e563b7cdc93eb8f8d6c4f70cf /embeddedobj
parent6d818ed651aaafcfb12ebc21449d35947d2e85a9 (diff)
fdo#46808, Convert frame::Desktop to new style service.
I had to drop XEventBroadcaster from the merged interface because it introduced method name conflicts (addEventListener). Shouldn't be an issue since it was scheduled to be dropped anyhow, and the service implementation still implements it, so existing clients will be fine. I dropped the interface XPropertySet from the combined IDL because nobody seems to be using it, and it's primary purpose appears to be to set weird flags. I dropped the optional interfaces XStatusIndicatorFactory XDispatchInformationProvider from the combined IDL because the service does not implement them, and nobody seems to be using them. I suspect they were mistakenly copied from XFrame. I also did not convert the Title, UserDefinedAttributes and LayoutManager properties to attributes, again because no-one is using them. Change-Id: I678a00006ed2cca2d6c37c4e39465811442c33af
Diffstat (limited to 'embeddedobj')
-rw-r--r--embeddedobj/source/general/docholder.cxx46
-rw-r--r--embeddedobj/source/msole/ownview.cxx85
2 files changed, 58 insertions, 73 deletions
diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index f30eb5e1a6b0..47367f7cfa74 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -31,7 +31,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <com/sun/star/frame/XDispatchHelper.hpp>
#include <com/sun/star/frame/FrameSearchFlag.hpp>
@@ -173,26 +173,20 @@ DocumentHolder::DocumentHolder( const uno::Reference< lang::XMultiServiceFactory
aArg.Value <<= sal_False;
m_aOutplaceFrameProps[1] <<= aArg;
- const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
- uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
- if ( xDesktop.is() )
+ uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( comphelper::getComponentContext(m_xFactory) );
+ m_refCount++;
+ try
{
- m_refCount++;
- try
- {
- xDesktop->addTerminateListener( this );
- }
- catch ( const uno::Exception& )
- {
- }
- m_refCount--;
-
- aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame"));
- aArg.Value <<= xDesktop; //TODO/LATER: should use parent document frame
- m_aOutplaceFrameProps[2] <<= aArg;
+ xDesktop->addTerminateListener( this );
}
- else
- m_aOutplaceFrameProps.realloc( 2 );
+ catch ( const uno::Exception& )
+ {
+ }
+ m_refCount--;
+
+ aArg.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentFrame"));
+ aArg.Value <<= xDesktop; //TODO/LATER: should use parent document frame
+ m_aOutplaceFrameProps[2] <<= aArg;
}
//---------------------------------------------------------------------------
@@ -253,15 +247,12 @@ void DocumentHolder::CloseFrame()
//---------------------------------------------------------------------------
void DocumentHolder::FreeOffice()
{
- const ::rtl::OUString aServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.frame.Desktop" ) );
- uno::Reference< frame::XDesktop > xDesktop( m_xFactory->createInstance( aServiceName ), uno::UNO_QUERY );
- if ( xDesktop.is() )
- {
- xDesktop->removeTerminateListener( this );
+ uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( comphelper::getComponentContext(m_xFactory) );
+ xDesktop->removeTerminateListener( this );
- // the following code is commented out since for now there is still no completely correct way to detect
- // whether the office can be terminated, so it is better to have unnecessary process running than
- // to loose any data
+ // the following code is commented out since for now there is still no completely correct way to detect
+ // whether the office can be terminated, so it is better to have unnecessary process running than
+ // to loose any data
// uno::Reference< frame::XFramesSupplier > xFramesSupplier( xDesktop, uno::UNO_QUERY );
// if ( xFramesSupplier.is() )
@@ -277,7 +268,6 @@ void DocumentHolder::FreeOffice()
// {}
// }
// }
- }
}
//---------------------------------------------------------------------------
diff --git a/embeddedobj/source/msole/ownview.cxx b/embeddedobj/source/msole/ownview.cxx
index 01475efcc85a..7447b9c68315 100644
--- a/embeddedobj/source/msole/ownview.cxx
+++ b/embeddedobj/source/msole/ownview.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
@@ -115,64 +116,58 @@ sal_Bool OwnView_Impl::CreateModelFromURL( const ::rtl::OUString& aFileURL )
if ( !aFileURL.isEmpty() )
{
try {
- uno::Reference < frame::XComponentLoader > xDocumentLoader(
- m_xFactory->createInstance (
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) )),
- uno::UNO_QUERY );
+ uno::Reference < frame::XDesktop2 > xDocumentLoader = frame::Desktop::create(comphelper::getComponentContext(m_xFactory));
- if ( xDocumentLoader.is() )
- {
- uno::Sequence< beans::PropertyValue > aArgs( m_aFilterName.isEmpty() ? 4 : 5 );
+ uno::Sequence< beans::PropertyValue > aArgs( m_aFilterName.isEmpty() ? 4 : 5 );
- aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "URL" ));
- aArgs[0].Value <<= aFileURL;
+ aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "URL" ));
+ aArgs[0].Value <<= aFileURL;
- aArgs[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ));
- aArgs[1].Value <<= sal_True;
+ aArgs[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ReadOnly" ));
+ aArgs[1].Value <<= sal_True;
- aArgs[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ));
- aArgs[2].Value <<= uno::Reference< task::XInteractionHandler >(
- static_cast< ::cppu::OWeakObject* >( new DummyHandler_Impl() ), uno::UNO_QUERY );
+ aArgs[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ));
+ aArgs[2].Value <<= uno::Reference< task::XInteractionHandler >(
+ static_cast< ::cppu::OWeakObject* >( new DummyHandler_Impl() ), uno::UNO_QUERY );
- aArgs[3].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DontEdit" ));
- aArgs[3].Value <<= sal_True;
+ aArgs[3].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "DontEdit" ));
+ aArgs[3].Value <<= sal_True;
- if ( !m_aFilterName.isEmpty() )
- {
- aArgs[4].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
- aArgs[4].Value <<= m_aFilterName;
- }
+ if ( !m_aFilterName.isEmpty() )
+ {
+ aArgs[4].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
+ aArgs[4].Value <<= m_aFilterName;
+ }
- uno::Reference< frame::XModel > xModel( xDocumentLoader->loadComponentFromURL(
- aFileURL,
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "_blank" )),
- 0,
- aArgs ),
- uno::UNO_QUERY );
+ uno::Reference< frame::XModel > xModel( xDocumentLoader->loadComponentFromURL(
+ aFileURL,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "_blank" )),
+ 0,
+ aArgs ),
+ uno::UNO_QUERY );
- if ( xModel.is() )
+ if ( xModel.is() )
+ {
+ uno::Reference< document::XEventBroadcaster > xBroadCaster( xModel, uno::UNO_QUERY );
+ if ( xBroadCaster.is() )
+ xBroadCaster->addEventListener( uno::Reference< document::XEventListener >(
+ static_cast< ::cppu::OWeakObject* >( this ),
+ uno::UNO_QUERY ) );
+
+ uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY );
+ if ( xCloseable.is() )
{
- uno::Reference< document::XEventBroadcaster > xBroadCaster( xModel, uno::UNO_QUERY );
- if ( xBroadCaster.is() )
- xBroadCaster->addEventListener( uno::Reference< document::XEventListener >(
- static_cast< ::cppu::OWeakObject* >( this ),
- uno::UNO_QUERY ) );
-
- uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY );
- if ( xCloseable.is() )
- {
- xCloseable->addCloseListener( uno::Reference< util::XCloseListener >(
- static_cast< ::cppu::OWeakObject* >( this ),
- uno::UNO_QUERY ) );
+ xCloseable->addCloseListener( uno::Reference< util::XCloseListener >(
+ static_cast< ::cppu::OWeakObject* >( this ),
+ uno::UNO_QUERY ) );
- ::osl::MutexGuard aGuard( m_aMutex );
- m_xModel = xModel;
- bResult = sal_True;
- }
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_xModel = xModel;
+ bResult = sal_True;
}
}
}
- catch( uno::Exception& )
+ catch( const uno::Exception& )
{
}
}