diff options
author | Oliver Bolte <obo@openoffice.org> | 2008-01-10 10:40:32 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2008-01-10 10:40:32 +0000 |
commit | b92e9bc9016742cd4cfc7a79e8a94c46fffd10ab (patch) | |
tree | 1156d1e87cfd4ed9380b9ab7dfff1bb6154c9722 /writerfilter/source/dmapper/ModelEventListener.cxx | |
parent | 71c186e2dd811161ecbbb02d55d546d9756533a6 (diff) |
INTEGRATION: CWS xmlfilter02 (1.1.2); FILE ADDED
2007/11/22 08:23:42 os 1.1.2.1: deferred TOC update
Diffstat (limited to 'writerfilter/source/dmapper/ModelEventListener.cxx')
-rw-r--r-- | writerfilter/source/dmapper/ModelEventListener.cxx | 103 |
1 files changed, 103 insertions, 0 deletions
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 <ModelEventListener.hxx> +#include <com/sun/star/document/XEventBroadcaster.hpp> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> + +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<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener( + uno::Reference<document::XEventListener>(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<document::XEventBroadcaster>(rEvent.Source, uno::UNO_QUERY )->removeEventListener( + uno::Reference<document::XEventListener>(this)); + } + catch( const uno::Exception& ) + { + } +} + +} //namespace dmapper +} //namespace writerfilter |