diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-08-20 17:58:20 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-08-20 17:58:44 +0200 |
commit | 2d2337eb74161f9aab9bc3cf50fa63975d9c1731 (patch) | |
tree | 2321e843c678aa340b7eaf9860e247a6d5d20b38 /framework | |
parent | 5be1f5234b46a89a7660a9cfe3deaa00e2aa124b (diff) |
Improve some debug output
Change-Id: I1008822ba8592ea43f87805bf00adbfdaf4f02fc
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/services.h | 1 | ||||
-rw-r--r-- | framework/source/dispatch/loaddispatcher.cxx | 16 | ||||
-rw-r--r-- | framework/source/inc/loadenv/loadenvexception.hxx | 78 | ||||
-rw-r--r-- | framework/source/loadenv/loadenv.cxx | 50 | ||||
-rw-r--r-- | framework/source/services/autorecovery.cxx | 2 |
5 files changed, 49 insertions, 98 deletions
diff --git a/framework/inc/services.h b/framework/inc/services.h index 2f759c5b8095..b10888984c08 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -29,7 +29,6 @@ namespace framework{ //_________________________________________________________________________________________________________________ #define SERVICENAME_FILTERFACTORY DECLARE_ASCII("com.sun.star.document.FilterFactory" ) -#define SERVICENAME_TYPEDETECTION DECLARE_ASCII("com.sun.star.document.TypeDetection" ) #define SERVICENAME_CFGUPDATEACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationUpdateAccess") // provides read/write access to the configuration #define SERVICENAME_CFGREADACCESS DECLARE_ASCII("com.sun.star.configuration.ConfigurationAccess" ) // provides readonly access to the configuration #define SERVICENAME_CONTENTHANDLER DECLARE_ASCII("com.sun.star.frame.ContentHandler" ) diff --git a/framework/source/dispatch/loaddispatcher.cxx b/framework/source/dispatch/loaddispatcher.cxx index 6c5230160d63..6eb2284a0878 100644 --- a/framework/source/dispatch/loaddispatcher.cxx +++ b/framework/source/dispatch/loaddispatcher.cxx @@ -122,8 +122,20 @@ css::uno::Any LoadDispatcher::impl_dispatch( const css::util::URL& rURL, // TODO thinking about asynchronous operations and listener support } - catch(const LoadEnvException&) - { xComponent.clear(); } + catch(const LoadEnvException& e) + { + SAL_WARN( + "fwk.dispatch", + "caught LoadEnvException " << +e.m_nID << " \"" << e.m_sMessage + << "\"" + << (e.m_exOriginal.has<css::uno::Exception>() + ? (", " + e.m_exOriginal.getValueTypeName() + " \"" + + e.m_exOriginal.get<css::uno::Exception>().Message + + "\"") + : OUString()) + << " while dispatching <" << rURL.Complete << ">"); + xComponent.clear(); + } if (xListener.is()) { diff --git a/framework/source/inc/loadenv/loadenvexception.hxx b/framework/source/inc/loadenv/loadenvexception.hxx index 868944587147..aedb6b3beae3 100644 --- a/framework/source/inc/loadenv/loadenvexception.hxx +++ b/framework/source/inc/loadenv/loadenvexception.hxx @@ -32,15 +32,10 @@ namespace framework{ @descr Of course outside code must wrapp it, to transport the occurred information to its caller. - - @author as96863 */ class LoadEnvException { - - public: - /** @short Can be used as an ID for an instance of a LoadEnvException. @descr To prevent errors on adding/removing/changing such IDs here, an enum field is used. Its int values are self organized ... @@ -93,76 +88,17 @@ class LoadEnvException ID_GENERAL_ERROR }; - //___________________________________________ - // member - - public: - - /** @short contains a suitable message, which describes the reason for this - exception. */ - OString m_sMessage; - - /** @short An ID, which make this exception unique among others. */ sal_Int32 m_nID; - - /** @short Contains the original exception, if any occurred. */ + OUString m_sMessage; css::uno::Any m_exOriginal; - /** TODO - Experimental use! Maybe it can be useful to know if an exception was already - catched and handled by an interaction and might be rethrown! */ - sal_Bool m_bHandled; - - //___________________________________________ - // interface - - public: - - /** @short initialize a new instance with an ID. - @descr Some other items of this exception - (e.g. a suitable message) will be generated - automaticly. + LoadEnvException( + sal_Int32 id, OUString const & message = OUString(), + css::uno::Any const & original = css::uno::Any()): + m_nID(id), m_sMessage(message), m_exOriginal(original) + {} - @param nID - One of the defined const IDs of this class. - */ - LoadEnvException(sal_Int32 nID) - { - m_nID = nID; - } - - //_______________________________________ - - /** @short initialize a new instance with an ID - an wrap a detected exception into this one. - @descr Some other items of this exception - (e.g. a suitable message) will be generated - automaticly. - - @param nID - One of the defined const IDs of this class. - - @param exUno - the original catched uno exception. - */ - LoadEnvException( sal_Int32 nID , - const css::uno::Any& exUno) - { - m_nID = nID ; - m_exOriginal = exUno; - } - - //_______________________________________ - - /** @short destruct an instance of this exception. - */ - ~LoadEnvException() - { - m_sMessage = OString(); - m_nID = 0; - m_bHandled = false; - m_exOriginal.clear(); - } + ~LoadEnvException() {} }; } // namespace framework diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 4320edf29158..fc60f1c04a53 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -182,23 +182,23 @@ css::uno::Reference< css::lang::XComponent > LoadEnv::loadComponentFromURL(const "Optional list of arguments seem to be corrupted.", xLoader, 4); case LoadEnvException::ID_UNSUPPORTED_CONTENT: - { - OUStringBuffer aMsg; - aMsg.appendAscii("Unsupported URL <").append(sURL).append('>'); - - if (!ex.m_sMessage.isEmpty()) - { - aMsg.appendAscii(": \""). - append(OStringToOUString( - ex.m_sMessage, RTL_TEXTENCODING_UTF8)). - appendAscii("\""); - } - - throw css::lang::IllegalArgumentException(aMsg.makeStringAndClear(), + throw css::lang::IllegalArgumentException( + ("Unsupported URL <" + sURL + ">" + ": \"" + ex.m_sMessage + + "\""), xLoader, 1); - } default: + SAL_WARN( + "fwk.loadenv", + "caught LoadEnvException " << +ex.m_nID << " \"" + << ex.m_sMessage << "\"" + << (ex.m_exOriginal.has<css::uno::Exception>() + ? (", " + ex.m_exOriginal.getValueTypeName() + " \"" + + (ex.m_exOriginal.get<css::uno::Exception>(). + Message) + + "\"") + : OUString()) + << " while loading <" << sURL << ">"); xComponent.clear(); break; } @@ -261,7 +261,7 @@ void LoadEnv::initializeLoading(const OUString& { m_eContentType = LoadEnv::classifyContent(sURL, lMediaDescriptor); if (m_eContentType == E_UNSUPPORTED_CONTENT) - throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT); + throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, "from LoadEnv::initializeLoading"); } // make URL part of the MediaDescriptor @@ -369,7 +369,7 @@ void LoadEnv::startLoading() // content can not be loaded or handled // check "classifyContent()" failed before ... if (m_eContentType == E_UNSUPPORTED_CONTENT) - throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT); + throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT, "from LoadEnv::startLoading"); // <- SAFE aReadLock.unlock(); @@ -640,8 +640,9 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString& // following operations can work on an internal type name only :-( css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext(); css::uno::Reference< css::document::XTypeDetection > xDetect( - xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext), - css::uno::UNO_QUERY); + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.document.TypeDetection", xContext), + css::uno::UNO_QUERY_THROW); OUString sType = xDetect->queryTypeByURL(sURL); @@ -807,13 +808,16 @@ void LoadEnv::impl_detectTypeAndFilter() return; } - css::uno::Reference< css::document::XTypeDetection > xDetect( xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext), css::uno::UNO_QUERY); - if (xDetect.is()) - sType = xDetect->queryTypeByDescriptor(lDescriptor, sal_True); /*TODO should deep detection be able for enable/disable it from outside? */ + css::uno::Reference< css::document::XTypeDetection > xDetect( + xContext->getServiceManager()->createInstanceWithContext( + "com.sun.star.document.TypeDetection", xContext), + css::uno::UNO_QUERY_THROW); + sType = xDetect->queryTypeByDescriptor(lDescriptor, sal_True); /*TODO should deep detection be able for enable/disable it from outside? */ // no valid content -> loading not possible if (sType.isEmpty()) - throw LoadEnvException(LoadEnvException::ID_UNSUPPORTED_CONTENT); + throw LoadEnvException( + LoadEnvException::ID_UNSUPPORTED_CONTENT, "type detection failed"); // SAFE -> WriteGuard aWriteLock(m_aLock); @@ -1681,7 +1685,7 @@ void LoadEnv::impl_reactForLoadingState() if (bThrow) { if ( aRequest.isExtractableTo( ::cppu::UnoType< css::uno::Exception >::get() ) ) - throw LoadEnvException( LoadEnvException::ID_GENERAL_ERROR, aRequest ); + throw LoadEnvException( LoadEnvException::ID_GENERAL_ERROR, "", aRequest ); } // <- SAFE ---------------------------------- diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index be50d2ba2421..653567dd6d94 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -1151,7 +1151,7 @@ void AutoRecovery::implts_specifyDefaultFilterAndExtension(AutoRecovery::TDocume xModuleProps->getByName(OUString(CFG_ENTRY_REALDEFAULTFILTER)) >>= rInfo.DefaultFilter; css::uno::Reference< css::container::XNameAccess > xFilterCFG(xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_FILTERFACTORY, xContext), css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::container::XNameAccess > xTypeCFG (xContext->getServiceManager()->createInstanceWithContext(SERVICENAME_TYPEDETECTION, xContext), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::container::XNameAccess > xTypeCFG (xContext->getServiceManager()->createInstanceWithContext("com.sun.star.document.TypeDetection", xContext), css::uno::UNO_QUERY_THROW); ::comphelper::SequenceAsHashMap lFilterProps (xFilterCFG->getByName(rInfo.DefaultFilter)); OUString sTypeRegistration = lFilterProps.getUnpackedValueOrDefault(OUString(FILTER_PROP_TYPE), OUString()); |