Files
libreoffice/embeddedobj/source/general/intercept.cxx

408 lines
11 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2012-09-27 13:52:10 +01:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2003-10-27 12:05:38 +00:00
#include <com/sun/star/embed/EmbedStates.hpp>
#include <cppuhelper/weak.hxx>
#include "intercept.hxx"
#include "docholder.hxx"
#include "commonembobj.hxx"
using namespace ::com::sun::star;
#define IUL 6
2003-10-27 12:05:38 +00:00
uno::Sequence< OUString > Interceptor::m_aInterceptedURL(IUL);
2003-10-27 12:05:38 +00:00
struct equalOUString
{
bool operator()(
const OUString& rKey1,
const OUString& rKey2 ) const
2003-10-27 12:05:38 +00:00
{
return !!( rKey1 == rKey2 );
}
};
struct hashOUString
{
size_t operator()( const OUString& rName ) const
2003-10-27 12:05:38 +00:00
{
return rName.hashCode();
}
};
class StatusChangeListenerContainer
: public ::cppu::OMultiTypeInterfaceContainerHelperVar<
OUString,hashOUString,equalOUString>
2003-10-27 12:05:38 +00:00
{
public:
StatusChangeListenerContainer( ::osl::Mutex& aMutex )
: cppu::OMultiTypeInterfaceContainerHelperVar<
OUString,hashOUString,equalOUString>(aMutex)
2003-10-27 12:05:38 +00:00
{
}
};
void Interceptor::DisconnectDocHolder()
{
osl::MutexGuard aGuard( m_aMutex );
m_pDocHolder = NULL;
}
void SAL_CALL
Interceptor::addEventListener(
const uno::Reference<lang::XEventListener >& Listener )
throw( uno::RuntimeException )
{
osl::MutexGuard aGuard( m_aMutex );
if ( ! m_pDisposeEventListeners )
m_pDisposeEventListeners =
new cppu::OInterfaceContainerHelper( m_aMutex );
m_pDisposeEventListeners->addInterface( Listener );
}
void SAL_CALL
Interceptor::removeEventListener(
const uno::Reference< lang::XEventListener >& Listener )
throw( uno::RuntimeException )
{
osl::MutexGuard aGuard( m_aMutex );
if ( m_pDisposeEventListeners )
m_pDisposeEventListeners->removeInterface( Listener );
}
Interceptor::Interceptor( DocumentHolder* pDocHolder )
: m_pDocHolder( pDocHolder ),
m_pDisposeEventListeners(0),
m_pStatCL(0)
2003-10-27 12:05:38 +00:00
{
m_aInterceptedURL[0] = OUString(".uno:Save");
m_aInterceptedURL[1] = OUString(".uno:SaveAll");
m_aInterceptedURL[2] = OUString(".uno:CloseDoc");
m_aInterceptedURL[3] = OUString(".uno:CloseWin");
m_aInterceptedURL[4] = OUString(".uno:CloseFrame");
m_aInterceptedURL[5] = OUString(".uno:SaveAs");
2003-10-27 12:05:38 +00:00
}
Interceptor::~Interceptor()
{
if( m_pDisposeEventListeners )
delete m_pDisposeEventListeners;
if(m_pStatCL)
delete m_pStatCL;
}
//XDispatch
void SAL_CALL
Interceptor::dispatch(
const util::URL& URL,
const uno::Sequence<
beans::PropertyValue >& Arguments )
throw (uno::RuntimeException)
{
osl::MutexGuard aGuard(m_aMutex);
if( m_pDocHolder )
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
{
2003-10-27 12:05:38 +00:00
if(URL.Complete == m_aInterceptedURL[0])
m_pDocHolder->GetEmbedObject()->SaveObject_Impl();
else if(URL.Complete == m_aInterceptedURL[2] ||
URL.Complete == m_aInterceptedURL[3] ||
URL.Complete == m_aInterceptedURL[4])
{
try {
m_pDocHolder->GetEmbedObject()->changeState( embed::EmbedStates::RUNNING );
2003-10-27 12:05:38 +00:00
}
2011-12-09 02:56:30 +09:00
catch( const uno::Exception& )
2003-10-27 12:05:38 +00:00
{
}
}
else if ( URL.Complete == m_aInterceptedURL[5] )
{
uno::Sequence< beans::PropertyValue > aNewArgs = Arguments;
sal_Int32 nInd = 0;
while( nInd < aNewArgs.getLength() )
{
if ( aNewArgs[nInd].Name == "SaveTo" )
{
aNewArgs[nInd].Value <<= sal_True;
break;
}
nInd++;
}
if ( nInd == aNewArgs.getLength() )
{
aNewArgs.realloc( nInd + 1 );
aNewArgs[nInd].Name = OUString( "SaveTo" );
aNewArgs[nInd].Value <<= sal_True;
}
uno::Reference< frame::XDispatch > xDispatch = m_xSlaveDispatchProvider->queryDispatch(
URL, OUString( "_self" ), 0 );
if ( xDispatch.is() )
xDispatch->dispatch( URL, aNewArgs );
}
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
}
2003-10-27 12:05:38 +00:00
}
void SAL_CALL
Interceptor::addStatusListener(
const uno::Reference<
frame::XStatusListener >& Control,
const util::URL& URL )
throw (
uno::RuntimeException
)
{
if(!Control.is())
return;
if(URL.Complete == m_aInterceptedURL[0])
{ // Save
frame::FeatureStateEvent aStateEvent;
aStateEvent.FeatureURL.Complete = m_aInterceptedURL[0];
aStateEvent.FeatureDescriptor = OUString("Update");
2003-10-27 12:05:38 +00:00
aStateEvent.IsEnabled = sal_True;
aStateEvent.Requery = sal_False;
aStateEvent.State <<= (OUString( "($1) ") + m_pDocHolder->GetTitle() );
2003-10-27 12:05:38 +00:00
Control->statusChanged(aStateEvent);
{
osl::MutexGuard aGuard(m_aMutex);
if(!m_pStatCL)
m_pStatCL =
new StatusChangeListenerContainer(m_aMutex);
}
m_pStatCL->addInterface(URL.Complete,Control);
return;
}
sal_Int32 i = 2;
if(URL.Complete == m_aInterceptedURL[i] ||
URL.Complete == m_aInterceptedURL[++i] ||
URL.Complete == m_aInterceptedURL[++i] )
{ // Close and return
frame::FeatureStateEvent aStateEvent;
aStateEvent.FeatureURL.Complete = m_aInterceptedURL[i];
aStateEvent.FeatureDescriptor = OUString("Close and Return");
2003-10-27 12:05:38 +00:00
aStateEvent.IsEnabled = sal_True;
aStateEvent.Requery = sal_False;
aStateEvent.State <<= (OUString( "($2) ") + m_pDocHolder->GetTitle() );
2003-10-27 12:05:38 +00:00
Control->statusChanged(aStateEvent);
{
osl::MutexGuard aGuard(m_aMutex);
if(!m_pStatCL)
m_pStatCL =
new StatusChangeListenerContainer(m_aMutex);
}
m_pStatCL->addInterface(URL.Complete,Control);
return;
}
if(URL.Complete == m_aInterceptedURL[5])
{ // SaveAs
frame::FeatureStateEvent aStateEvent;
aStateEvent.FeatureURL.Complete = m_aInterceptedURL[5];
aStateEvent.FeatureDescriptor = OUString("SaveCopyTo");
aStateEvent.IsEnabled = sal_True;
aStateEvent.Requery = sal_False;
aStateEvent.State <<= (OUString( "($3)"));
Control->statusChanged(aStateEvent);
{
osl::MutexGuard aGuard(m_aMutex);
if(!m_pStatCL)
m_pStatCL =
new StatusChangeListenerContainer(m_aMutex);
}
m_pStatCL->addInterface(URL.Complete,Control);
return;
}
2003-10-27 12:05:38 +00:00
}
void SAL_CALL
Interceptor::removeStatusListener(
const uno::Reference<
frame::XStatusListener >& Control,
const util::URL& URL )
throw (
uno::RuntimeException
)
{
if(!(Control.is() && m_pStatCL))
return;
else {
m_pStatCL->removeInterface(URL.Complete,Control);
return;
}
}
//XInterceptorInfo
uno::Sequence< OUString >
2003-10-27 12:05:38 +00:00
SAL_CALL
Interceptor::getInterceptedURLs( )
throw (
uno::RuntimeException
)
{
// now implemented as update
return m_aInterceptedURL;
}
// XDispatchProvider
uno::Reference< frame::XDispatch > SAL_CALL
Interceptor::queryDispatch(
const util::URL& URL,
const OUString& TargetFrameName,
2003-10-27 12:05:38 +00:00
sal_Int32 SearchFlags )
throw (
uno::RuntimeException
)
{
osl::MutexGuard aGuard(m_aMutex);
if(URL.Complete == m_aInterceptedURL[0])
return (frame::XDispatch*)this;
else if(URL.Complete == m_aInterceptedURL[1])
return (frame::XDispatch*)0 ;
else if(URL.Complete == m_aInterceptedURL[2])
return (frame::XDispatch*)this;
else if(URL.Complete == m_aInterceptedURL[3])
return (frame::XDispatch*)this;
else if(URL.Complete == m_aInterceptedURL[4])
return (frame::XDispatch*)this;
else if(URL.Complete == m_aInterceptedURL[5])
return (frame::XDispatch*)this;
2003-10-27 12:05:38 +00:00
else {
if(m_xSlaveDispatchProvider.is())
return m_xSlaveDispatchProvider->queryDispatch(
URL,TargetFrameName,SearchFlags);
else
return uno::Reference<frame::XDispatch>(0);
}
}
uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL
Interceptor::queryDispatches(
const uno::Sequence<frame::DispatchDescriptor >& Requests )
throw (
uno::RuntimeException
)
{
uno::Sequence< uno::Reference< frame::XDispatch > > aRet;
osl::MutexGuard aGuard(m_aMutex);
if(m_xSlaveDispatchProvider.is())
aRet = m_xSlaveDispatchProvider->queryDispatches(Requests);
else
aRet.realloc(Requests.getLength());
for(sal_Int32 i = 0; i < Requests.getLength(); ++i)
if(m_aInterceptedURL[0] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) this;
else if(m_aInterceptedURL[1] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) 0;
else if(m_aInterceptedURL[2] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) this;
else if(m_aInterceptedURL[3] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) this;
else if(m_aInterceptedURL[4] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) this;
else if(m_aInterceptedURL[5] == Requests[i].FeatureURL.Complete)
aRet[i] = (frame::XDispatch*) this;
2003-10-27 12:05:38 +00:00
return aRet;
}
//XDispatchProviderInterceptor
uno::Reference< frame::XDispatchProvider > SAL_CALL
Interceptor::getSlaveDispatchProvider( )
throw (
uno::RuntimeException
)
{
osl::MutexGuard aGuard(m_aMutex);
return m_xSlaveDispatchProvider;
}
void SAL_CALL
Interceptor::setSlaveDispatchProvider(
const uno::Reference< frame::XDispatchProvider >& NewDispatchProvider )
throw (
uno::RuntimeException
)
{
osl::MutexGuard aGuard(m_aMutex);
m_xSlaveDispatchProvider = NewDispatchProvider;
}
uno::Reference< frame::XDispatchProvider > SAL_CALL
Interceptor::getMasterDispatchProvider( )
throw (
uno::RuntimeException
)
{
osl::MutexGuard aGuard(m_aMutex);
return m_xMasterDispatchProvider;
}
void SAL_CALL
Interceptor::setMasterDispatchProvider(
const uno::Reference< frame::XDispatchProvider >& NewSupplier )
throw (
uno::RuntimeException
)
{
osl::MutexGuard aGuard(m_aMutex);
m_xMasterDispatchProvider = NewSupplier;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */