diff --git a/xmloff/inc/xmlerror.hxx b/xmloff/inc/xmlerror.hxx index 56bbd2309443..9071be59f5ec 100644 --- a/xmloff/inc/xmlerror.hxx +++ b/xmloff/inc/xmlerror.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlerror.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: hr $ $Date: 2001-10-10 16:06:14 $ + * last change: $Author: dvo $ $Date: 2002-01-11 19:08:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,6 +102,7 @@ #define XMLERROR_SAX ( XMLERROR_CLASS_FORMAT | 0x00000001 ) #define XMLERROR_STYLE_ATTR_VALUE ( XMLERROR_CLASS_FORMAT | 0x00000002 ) #define XMLERROR_NO_INDEX_ALLOWED_HERE ( XMLERROR_CLASS_FORMAT | 0x00000003 ) +#define XMLERROR_PARENT_STYLE_NOT_ALLOWED ( XMLERROR_CLASS_FORMAT | 0x00000004 ) // API errors: #define XMLERROR_STYLE_PROP_VALUE ( XMLERROR_CLASS_API | 0x00000001 ) diff --git a/xmloff/source/style/prstylei.cxx b/xmloff/source/style/prstylei.cxx index 86b7e9cbdab0..375c4f6255cb 100644 --- a/xmloff/source/style/prstylei.cxx +++ b/xmloff/source/style/prstylei.cxx @@ -2,9 +2,9 @@ * * $RCSfile: prstylei.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mib $ $Date: 2001-09-05 08:30:32 $ + * last change: $Author: dvo $ $Date: 2002-01-11 19:08:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,6 +103,9 @@ #ifndef _XMLOFF_ATTRLIST_HXX #include "attrlist.hxx" #endif +#ifndef _XMLOFF_XMLERROR_HXX +#include "xmlerror.hxx" +#endif using namespace ::rtl; using namespace ::com::sun::star; @@ -328,7 +331,35 @@ void XMLPropStyleContext::Finish( sal_Bool bOverwrite ) sParent = OUString(); if( sParent != xStyle->getParentStyle() ) - xStyle->setParentStyle( sParent ); + { + // this may except if setting the parent style forms a + // circle in the style depencies; especially if the parent + // style is the same as the current style + try + { + xStyle->setParentStyle( sParent ); + } + catch( uno::Exception e ) + { + // according to the API definition, I would expect a + // container::NoSuchElementException. But it throws an + // uno::RuntimeException instead. I catch + // uno::Exception in order to process both of them. + + // We can't set the parent style. For a proper + // Error-Message, we should pass in the name of the + // style, as well as the desired parent style. + Sequence aSequence(2); + + // getName() throws no non-Runtime exception: + aSequence[0] = xStyle->getName(); + aSequence[1] = sParent; + + GetImport().SetError( + XMLERROR_FLAG_ERROR | XMLERROR_PARENT_STYLE_NOT_ALLOWED, + aSequence, e.Message, NULL ); + } + } // connect follow OUString sFollow( GetFollow() );