summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-11-03 17:45:47 +0100
committerStephan Bergmann <sbergman@redhat.com>2011-11-04 08:21:26 +0100
commite66e54fb00bf74d13b7059bd32b6207a029afa5e (patch)
tree05a1a0e9c5cf4c889537cd3e616598effa0a85c1 /desktop
parente04249337551653f63ba9b2a2302578961e38562 (diff)
Further clean up of areas touched by previous commit.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/inc/app.hxx1
-rw-r--r--desktop/source/app/app.cxx248
-rw-r--r--desktop/source/app/cmdlineargs.cxx2
-rw-r--r--desktop/source/app/officeipcthread.cxx20
4 files changed, 135 insertions, 136 deletions
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 87a774c5661b..f30ac4645e89 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -190,7 +190,6 @@ class Desktop : public Application
void DoFirstRunInitializations();
static sal_Bool SaveTasks();
- static sal_Bool _bTasksSaved;
static void retrieveCrashReporterState();
static sal_Bool isUIOnSessionShutdownAllowed();
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 00850aae039c..1555510efab7 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1346,8 +1346,6 @@ sal_Bool impl_callRecoveryUI(sal_Bool bEmergencySave ,
*
*/
-sal_Bool Desktop::_bTasksSaved = sal_False;
-
sal_Bool Desktop::SaveTasks()
{
return impl_callRecoveryUI(
@@ -2990,138 +2988,139 @@ String GetURL_Impl(
void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
{
- if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("APPEAR")) && !GetCommandLineArgs().IsInvisible() )
+ switch ( rAppEvent.GetEvent() )
{
- css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
-
- // find active task - the active task is always a visible task
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >
- xDesktop( xSMGR->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
- ::com::sun::star::uno::UNO_QUERY );
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xTask = xDesktop->getActiveFrame();
- if ( !xTask.is() )
+ case ApplicationEvent::TYPE_ACCEPT:
+ // every time an accept parameter is used we create an acceptor
+ // with the corresponding accept-string
+ createAcceptor(rAppEvent.GetData());
+ break;
+ case ApplicationEvent::TYPE_APPEAR:
+ if ( !GetCommandLineArgs().IsInvisible() )
{
- // get any task if there is no active one
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xList( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY );
- if ( xList->getCount()>0 )
- xList->getByIndex(0) >>= xTask;
- }
+ css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory();
- if ( xTask.is() )
- {
- Reference< com::sun::star::awt::XTopWindow > xTop( xTask->getContainerWindow(), UNO_QUERY );
- xTop->toFront();
- }
- else
- {
- // no visible task that could be activated found
- Reference< XFrame > xBackingFrame;
- Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xDesktopFrame( xDesktop, UNO_QUERY );
+ // find active task - the active task is always a visible task
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >
+ xDesktop( xSMGR->createInstance( OUSTRING(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
+ ::com::sun::star::uno::UNO_QUERY );
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xTask = xDesktop->getActiveFrame();
+ if ( !xTask.is() )
+ {
+ // get any task if there is no active one
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > xList( xDesktop->getFrames(), ::com::sun::star::uno::UNO_QUERY );
+ if ( xList->getCount()>0 )
+ xList->getByIndex(0) >>= xTask;
+ }
- xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0);
- if (xBackingFrame.is())
- xContainerWindow = xBackingFrame->getContainerWindow();
- if (xContainerWindow.is())
+ if ( xTask.is() )
+ {
+ Reference< com::sun::star::awt::XTopWindow > xTop( xTask->getContainerWindow(), UNO_QUERY );
+ xTop->toFront();
+ }
+ else
{
- Sequence< Any > lArgs(1);
- lArgs[0] <<= xContainerWindow;
- Reference< XController > xBackingComp(
- xSMGR->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs),
- UNO_QUERY);
- if (xBackingComp.is())
+ // no visible task that could be activated found
+ Reference< XFrame > xBackingFrame;
+ Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xDesktopFrame( xDesktop, UNO_QUERY );
+
+ xBackingFrame = xDesktopFrame->findFrame(OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" )), 0);
+ if (xBackingFrame.is())
+ xContainerWindow = xBackingFrame->getContainerWindow();
+ if (xContainerWindow.is())
{
- Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
- // Attention: You MUST(!) call setComponent() before you call attachFrame().
- // Because the backing component set the property "IsBackingMode" of the frame
- // to true inside attachFrame(). But setComponent() reset this state everytimes ...
- xBackingFrame->setComponent(xBackingWin, xBackingComp);
- xBackingComp->attachFrame(xBackingFrame);
- xContainerWindow->setVisible(sal_True);
-
- Window* pCompWindow = VCLUnoHelper::GetWindow(xBackingFrame->getComponentWindow());
- if (pCompWindow)
- pCompWindow->Update();
+ Sequence< Any > lArgs(1);
+ lArgs[0] <<= xContainerWindow;
+ Reference< XController > xBackingComp(
+ xSMGR->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs),
+ UNO_QUERY);
+ if (xBackingComp.is())
+ {
+ Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
+ // Attention: You MUST(!) call setComponent() before you call attachFrame().
+ // Because the backing component set the property "IsBackingMode" of the frame
+ // to true inside attachFrame(). But setComponent() reset this state everytimes ...
+ xBackingFrame->setComponent(xBackingWin, xBackingComp);
+ xBackingComp->attachFrame(xBackingFrame);
+ xContainerWindow->setVisible(sal_True);
+
+ Window* pCompWindow = VCLUnoHelper::GetWindow(xBackingFrame->getComponentWindow());
+ if (pCompWindow)
+ pCompWindow->Update();
+ }
}
}
}
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QUICKSTART")) && !GetCommandLineArgs().IsInvisible() )
- {
- // If the office has been started the second time its command line arguments are sent through a pipe
- // connection to the first office. We want to reuse the quickstart option for the first office.
- // NOTICE: The quickstart service must be initialized inside the "main thread", so we use the
- // application events to do this (they are executed inside main thread)!!!
- // Don't start quickstart service if the user specified "-invisible" on the command line!
- sal_Bool bQuickstart( sal_True );
- Sequence< Any > aSeq( 1 );
- aSeq[0] <<= bQuickstart;
+ break;
+ case ApplicationEvent::TYPE_HELP:
+#ifndef UNX
+ // in non unix version allow showing of cmdline help window
+ displayCmdlineHelp();
+#endif
+ break;
+ case ApplicationEvent::TYPE_OPEN:
+ {
+ const CommandLineArgs& rCmdLine = GetCommandLineArgs();
+ if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
+ {
+ ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
+ rCmdLine.getCwdUrl());
+ pDocsRequest->aOpenList = rAppEvent.GetData();
+ pDocsRequest->pcProcessed = NULL;
- Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
- DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" )),
- UNO_QUERY );
- if ( xQuickstart.is() )
- xQuickstart->initialize( aSeq );
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ACCEPT")) )
- {
- // every time an accept parameter is used we create an acceptor
- // with the corresponding accept-string
- createAcceptor(rAppEvent.GetData());
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNACCEPT")) )
- {
- // try to remove corresponding acceptor
- destroyAcceptor(rAppEvent.GetData());
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SaveDocuments")) )
- {
- Desktop::_bTasksSaved = sal_False;
- Desktop::_bTasksSaved = SaveTasks();
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OPENHELPURL")) )
- {
+ OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
+ delete pDocsRequest;
+ }
+ }
+ break;
+ case ApplicationEvent::TYPE_OPENHELPURL:
// start help for a specific URL
- Help *pHelp = Application::GetHelp();
- pHelp->Start(rAppEvent.GetData(), NULL);
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(APPEVENT_OPEN_STRING)) )
- {
- const CommandLineArgs& rCmdLine = GetCommandLineArgs();
- if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
+ Application::GetHelp()->Start(rAppEvent.GetData(), NULL);
+ break;
+ case ApplicationEvent::TYPE_PRINT:
{
- ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
- rCmdLine.getCwdUrl());
- pDocsRequest->aOpenList = rAppEvent.GetData();
- pDocsRequest->pcProcessed = NULL;
+ const CommandLineArgs& rCmdLine = GetCommandLineArgs();
+ if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
+ {
+ ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
+ rCmdLine.getCwdUrl());
+ pDocsRequest->aPrintList = rAppEvent.GetData();
+ pDocsRequest->pcProcessed = NULL;
- OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
- delete pDocsRequest;
+ OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
+ delete pDocsRequest;
+ }
}
- }
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(APPEVENT_PRINT_STRING)) )
- {
- const CommandLineArgs& rCmdLine = GetCommandLineArgs();
- if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
+ break;
+ case ApplicationEvent::TYPE_PRIVATE_DOSHUTDOWN:
{
- ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
- rCmdLine.getCwdUrl());
- pDocsRequest->aPrintList = rAppEvent.GetData();
- pDocsRequest->pcProcessed = NULL;
+ Desktop* pD = dynamic_cast<Desktop*>(GetpApp());
+ OSL_ENSURE( pD, "no desktop ?!?" );
+ if( pD )
+ pD->doShutdown();
+ }
+ break;
+ case ApplicationEvent::TYPE_QUICKSTART:
+ if ( !GetCommandLineArgs().IsInvisible() )
+ {
+ // If the office has been started the second time its command line arguments are sent through a pipe
+ // connection to the first office. We want to reuse the quickstart option for the first office.
+ // NOTICE: The quickstart service must be initialized inside the "main thread", so we use the
+ // application events to do this (they are executed inside main thread)!!!
+ // Don't start quickstart service if the user specified "-invisible" on the command line!
+ sal_Bool bQuickstart( sal_True );
+ Sequence< Any > aSeq( 1 );
+ aSeq[0] <<= bQuickstart;
- OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
- delete pDocsRequest;
+ Reference < XInitialization > xQuickstart( ::comphelper::getProcessServiceFactory()->createInstance(
+ DEFINE_CONST_UNICODE( "com.sun.star.office.Quickstart" )),
+ UNO_QUERY );
+ if ( xQuickstart.is() )
+ xQuickstart->initialize( aSeq );
}
- }
-#ifndef UNX
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HELP")) )
- {
- // in non unix version allow showing of cmdline help window
- displayCmdlineHelp();
- }
-#endif
- else if ( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHOWDIALOG")) )
- {
+ break;
+ case ApplicationEvent::TYPE_SHOWDIALOG:
// ignore all errors here. It's clicking a menu entry only ...
// The user will try it again, in case nothing happens .-)
try
@@ -3153,13 +3152,14 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
}
catch(const css::uno::Exception&)
{}
- }
- else if( rAppEvent.GetEvent() == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PRIVATE:DOSHUTDOWN")) )
- {
- Desktop* pD = dynamic_cast<Desktop*>(GetpApp());
- OSL_ENSURE( pD, "no desktop ?!?" );
- if( pD )
- pD->doShutdown();
+ break;
+ case ApplicationEvent::TYPE_UNACCEPT:
+ // try to remove corresponding acceptor
+ destroyAcceptor(rAppEvent.GetData());
+ break;
+ default:
+ OSL_FAIL("this cannot happen");
+ break;
}
}
diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx
index 78c6e719e8d7..4db23d92e93a 100644
--- a/desktop/source/app/cmdlineargs.cxx
+++ b/desktop/source/app/cmdlineargs.cxx
@@ -399,8 +399,8 @@ void CommandLineArgs::ParseCommandLine_Impl( Supplier& supplier )
void CommandLineArgs::AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam )
{
- ::rtl::OUStringBuffer aParamBuf(m_aStrParams[eParam]);
OSL_ASSERT( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT );
+ ::rtl::OUStringBuffer aParamBuf(m_aStrParams[eParam]);
if ( aParamBuf.getLength() )
aParamBuf.append('\n');
aParamBuf.append(aParam);
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index af30005d42d9..d9273c029eb3 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -695,7 +695,6 @@ void SAL_CALL OfficeIPCThread::run()
// is this a termination message ? if so, terminate
if(( aArguments.CompareTo( sc_aTerminationSequence, sc_nTSeqLength ) == COMPARE_EQUAL ) ||
mbDowning ) return;
- String aEmpty;
std::auto_ptr< CommandLineArgs > aCmdLineArgs;
try
{
@@ -715,22 +714,22 @@ void SAL_CALL OfficeIPCThread::run()
{
// we have to use application event, because we have to start quickstart service in main thread!!
ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QUICKSTART")));
+ new ApplicationEvent(ApplicationEvent::TYPE_QUICKSTART);
ImplPostForeignAppEvent( pAppEvent );
}
// handle request for acceptor
OUString aAcceptString;
if ( aCmdLineArgs->GetAcceptString(aAcceptString) ) {
- ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ACCEPT")), aAcceptString);
+ ApplicationEvent* pAppEvent = new ApplicationEvent(
+ ApplicationEvent::TYPE_ACCEPT, aAcceptString);
ImplPostForeignAppEvent( pAppEvent );
}
// handle acceptor removal
OUString aUnAcceptString;
if ( aCmdLineArgs->GetUnAcceptString(aUnAcceptString) ) {
- ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNACCEPT")), aUnAcceptString);
+ ApplicationEvent* pAppEvent = new ApplicationEvent(
+ ApplicationEvent::TYPE_UNACCEPT, aUnAcceptString);
ImplPostForeignAppEvent( pAppEvent );
}
@@ -739,7 +738,7 @@ void SAL_CALL OfficeIPCThread::run()
// in a running instance in order to display the command line help
if ( aCmdLineArgs->IsHelp() ) {
ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HELP")));
+ new ApplicationEvent(ApplicationEvent::TYPE_HELP);
ImplPostForeignAppEvent( pAppEvent );
}
#endif
@@ -837,8 +836,9 @@ void SAL_CALL OfficeIPCThread::run()
#elif defined WNT
aHelpURLBuffer.appendAscii("&System=WIN");
#endif
- ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OPENHELPURL")), aHelpURLBuffer.makeStringAndClear());
+ ApplicationEvent* pAppEvent = new ApplicationEvent(
+ ApplicationEvent::TYPE_OPENHELPURL,
+ aHelpURLBuffer.makeStringAndClear());
ImplPostForeignAppEvent( pAppEvent );
}
}
@@ -876,7 +876,7 @@ void SAL_CALL OfficeIPCThread::run()
{
// no document was sent, just bring Office to front
ApplicationEvent* pAppEvent =
- new ApplicationEvent(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("APPEAR")));
+ new ApplicationEvent(ApplicationEvent::TYPE_APPEAR);
ImplPostForeignAppEvent( pAppEvent );
}