diff --git a/writerfilter/source/dmapper/ModelEventListener.cxx b/writerfilter/source/dmapper/ModelEventListener.cxx new file mode 100644 index 000000000000..ed5861d43460 --- /dev/null +++ b/writerfilter/source/dmapper/ModelEventListener.cxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ModelEventListener.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: obo $ $Date: 2008-01-10 11:40:32 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#include +#include +#include +#include + +namespace writerfilter { +namespace dmapper { + +using namespace ::com::sun::star; + + +/*-- 22.11.2007 08:40:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +ModelEventListener::ModelEventListener() +{ +} +/*-- 22.11.2007 08:40:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +ModelEventListener::~ModelEventListener() +{ +} +/*-- 22.11.2007 08:40:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void ModelEventListener::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException) +{ + if( rEvent.EventName.equalsAscii("OnFocus")) + { + try + { + uno::Reference< text::XDocumentIndexesSupplier> xIndexesSupplier( rEvent.Source, uno::UNO_QUERY ); + uno::Reference< container::XIndexAccess > xIndexes = xIndexesSupplier->getDocumentIndexes(); + + sal_Int32 nIndexes = xIndexes->getCount(); + for( sal_Int32 nIndex = 0; nIndex < nIndexes; ++nIndex) + { + uno::Reference< text::XDocumentIndex> xIndex( xIndexes->getByIndex( nIndex ), uno::UNO_QUERY ); + xIndex->update(); + } + //update is done - remove listener + uno::Reference(rEvent.Source, uno::UNO_QUERY )->removeEventListener( + uno::Reference(this)); + } + catch( const uno::Exception& rEx ) + { + (void)rEx; + OSL_ASSERT("exception while updating indexes" ); + } + } +} +/*-- 22.11.2007 08:40:22--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void ModelEventListener::disposing( const lang::EventObject& rEvent ) throw (uno::RuntimeException) +{ + try + { + uno::Reference(rEvent.Source, uno::UNO_QUERY )->removeEventListener( + uno::Reference(this)); + } + catch( const uno::Exception& ) + { + } +} + +} //namespace dmapper +} //namespace writerfilter