1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _XMLOFF_XMLERROR_HXX 25 #define _XMLOFF_XMLERROR_HXX 26 27 #include <com/sun/star/xml/sax/SAXParseException.hpp> 28 #include <sal/types.h> 29 30 // STL includes 31 #include <vector> 32 33 34 35 // masks for the error ID fields 36 #define XMLERROR_MASK_FLAG 0xF0000000 37 #define XMLERROR_MASK_CLASS 0x00FF0000 38 #define XMLERROR_MASK_NUMBER 0x0000FFFF 39 40 // error flags: 41 #define XMLERROR_FLAG_WARNING 0x10000000 42 #define XMLERROR_FLAG_ERROR 0x20000000 43 #define XMLERROR_FLAG_SEVERE 0x40000000 44 45 // error classes: Error ID 46 #define XMLERROR_CLASS_IO 0x00010000 47 #define XMLERROR_CLASS_FORMAT 0x00020000 48 #define XMLERROR_CLASS_API 0x00040000 49 #define XMLERROR_CLASS_OTHER 0x00080000 50 51 52 // error numbers, listed by error class 53 // Within each class, errors should be numbered consecutively. Please 54 // allways add to error code below the appropriate comment. 55 56 // I/O errors: 57 58 // format errors: 59 #define XMLERROR_SAX ( XMLERROR_CLASS_FORMAT | 0x00000001 ) 60 #define XMLERROR_STYLE_ATTR_VALUE ( XMLERROR_CLASS_FORMAT | 0x00000002 ) 61 #define XMLERROR_NO_INDEX_ALLOWED_HERE ( XMLERROR_CLASS_FORMAT | 0x00000003 ) 62 #define XMLERROR_PARENT_STYLE_NOT_ALLOWED ( XMLERROR_CLASS_FORMAT | 0x00000004 ) 63 #define XMLERROR_ILLEGAL_EVENT (XMLERROR_CLASS_FORMAT | 0x00000005 ) 64 #define XMLERROR_NAMESPACE_TROUBLE (XMLERROR_CLASS_FORMAT | 0x00000006 ) 65 66 #define XMLERROR_XFORMS_NO_SCHEMA_SUPPORT ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x00000007 ) 67 #define XMLERROR_XFORMS_UNKNOWN ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x00000008 ) 68 #define XMLERROR_XFORMS_ONLY_ONE_INSTANCE_ELEMENT ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x00000009 ) 69 #define XMLERROR_UNKNOWN_ATTRIBUTE ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x0000000a ) 70 #define XMLERROR_UNKNOWN_ELEMENT ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x0000000b ) 71 #define XMLERROR_UNKNOWN_CHARACTERS ( XMLERROR_CLASS_FORMAT | XMLERROR_FLAG_WARNING | 0x0000000c ) 72 #define XMLERROR_UNKNOWN_ROOT (XMLERROR_CLASS_FORMAT | 0x0000000d ) 73 74 // API errors: 75 #define XMLERROR_STYLE_PROP_VALUE ( XMLERROR_CLASS_API | 0x00000001 ) 76 #define XMLERROR_STYLE_PROP_UNKNOWN ( XMLERROR_CLASS_API | 0x00000002 ) 77 #define XMLERROR_STYLE_PROP_OTHER ( XMLERROR_CLASS_API | 0x00000003 ) 78 #define XMLERROR_API ( XMLERROR_CLASS_API | 0x00000004 ) 79 80 // other errors: 81 #define XMLERROR_CANCEL ( XMLERROR_CLASS_OTHER | 0x00000001 ) 82 83 84 85 // 16bit error flag constants for use in the 86 // SvXMLExport/SvXMLImport error flags 87 #define ERROR_NO 0x0000 88 #define ERROR_DO_NOTHING 0x0001 89 #define ERROR_ERROR_OCCURED 0x0002 90 #define ERROR_WARNING_OCCURED 0x0004 91 92 93 94 95 // forward declarations 96 namespace rtl { class OUString; } 97 namespace com { namespace sun { namespace star { 98 namespace uno { template<class X> class Sequence; } 99 namespace uno { template<class X> class Reference; } 100 namespace xml { namespace sax { class XLocator; } } 101 } } } 102 class ErrorRecord; 103 104 105 106 /** 107 * The XMLErrors is used to collect all errors and warnings that occur 108 * for appropriate processing. 109 */ 110 class XMLErrors 111 { 112 /// definition of type for error list 113 typedef ::std::vector<ErrorRecord> ErrorList; 114 115 ErrorList aErrors; /// list of error records 116 117 public: 118 119 XMLErrors(); 120 ~XMLErrors(); 121 122 /// add a new entry to the list of error messages 123 void AddRecord( 124 sal_Int32 nId, /// error ID == error flags + error class + error number 125 const ::com::sun::star::uno::Sequence< 126 ::rtl::OUString> & rParams, /// parameters for error message 127 const ::rtl::OUString& rExceptionMessage, /// original exception string 128 sal_Int32 nRow, /// XLocator: file row number 129 sal_Int32 nColumn, /// XLocator: file column number 130 const ::rtl::OUString& rPublicId, /// XLocator: file public ID 131 const ::rtl::OUString& rSystemId ); /// XLocator: file system ID 132 133 void AddRecord( 134 sal_Int32 nId, /// error ID == error flags + error class + error number 135 const ::com::sun::star::uno::Sequence< 136 ::rtl::OUString> & rParams, /// parameters for error message 137 const ::rtl::OUString& rExceptionMessage, /// original exception string 138 const ::com::sun::star::uno::Reference< 139 ::com::sun::star::xml::sax::XLocator> & rLocator); /// location 140 141 void AddRecord( 142 sal_Int32 nId, /// error ID == error flags + error class + error number 143 const ::com::sun::star::uno::Sequence< 144 ::rtl::OUString> & rParams, /// parameters for error message 145 const ::rtl::OUString& rExceptionMessage); /// original exception string 146 147 void AddRecord( 148 sal_Int32 nId, /// error ID == error flags + error class + error number 149 const ::com::sun::star::uno::Sequence< 150 ::rtl::OUString> & rParams); /// parameters for error message 151 152 153 /** 154 * throw a SAXParseException that describes the first error that matches 155 * the given mask 156 */ 157 void ThrowErrorAsSAXException( sal_Int32 nIdMask ) 158 throw( ::com::sun::star::xml::sax::SAXParseException ); 159 }; 160 161 162 #endif 163