Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On 03/08/11 11:08, Noel Power wrote:
( /me must remember to reply-all )
Hi Lubos
On 02/08/11 13:58, Lubos Lunak wrote:
  Hello,

last week .docx support was broken because of a mistake during the gbuild changes and I wasted quite some time finding out what was wrong. As something
similar had happened to me already
same for me ( too many times )
  before I'd like to apply the attached
patches. However I have some issues with it:

- the error dialog that pops up just says 'General error. General input/output error.', which is completely unhelpful, however I don't feel like digging more for how to pass the information as far as the place where the dialog is
shown,
hmm I think it would be nicer to handle at least the CannotActivateFactoryException problems from the filter instatiations and pop a dialog ( debug output to terminal especially on weirdy windows is not the best way to see this problem ), I vaguely recall the twisted mechanism for getting some dialogs to pop with the interaction handler stuff, I will have a look

maybe this patch is useful to you, it has the disadvantage of creating the needed error dialog but then it also pops up the "General Error" one after that. I contemplated throwing ( well I actually half implemented it but gave up ) the exception up to allow SfxBaseModel::load to handle it but it appears there is all sorts of stuff inbetween that runs ( not expecting an exception ). Not passing an exception but setting a new ( or reusing an existing ) ERROR_IO_xxx ( or something ) also has problems like you can't easily ( or at all ) pass the error message, also I suppose you could use such a new error type to suppress the second 'General Error' but in the end it all just seemed too much trouble for what probably is just something you want in debug ( I guess ) So.. anyway patch attached if you think it might be useful, feel free to use/disregard/change totally etc.

Noel

diff --git sfx2/source/doc/objstor.cxx sfx2/source/doc/objstor.cxx
index 31ee8f0..0716a48 100644
--- sfx2/source/doc/objstor.cxx
+++ sfx2/source/doc/objstor.cxx
@@ -75,6 +75,8 @@
 
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
+
 #include <comphelper/processfactory.hxx>
 #include <comphelper/configurationhelper.hxx>
 #include <comphelper/interaction.hxx>
@@ -102,6 +104,7 @@
 #include <comphelper/seqstream.hxx>
 #include <comphelper/documentconstants.hxx>
 #include <comphelper/string.hxx>
+#include <comphelper/interaction.hxx>
 #include <vcl/bitmapex.hxx>
 #include <svtools/embedhlp.hxx>
 #include <rtl/logfile.hxx>
@@ -153,6 +156,33 @@ using namespace ::cppu;
 namespace css = ::com::sun::star;
 
 //=========================================================================
+class FilterActivationHandlerHelper
+{
+    uno::Reference< XInteractionHandler > mxHandler;
+public:
+    FilterActivationHandlerHelper( SfxMedium& rMedium)
+    {
+        mxHandler = rMedium.GetInteractionHandler();
+    }
+    void handleException( const loader::CannotActivateFactoryException& e )
+    {
+// not sure if we want this in non debug builds
+//#if OSL_DEBUG_LEVEL > 0
+        if ( mxHandler.is() )
+        {
+            comphelper::OInteractionRequest* pReq = new comphelper::OInteractionRequest( 
uno::makeAny( e ) );
+            pReq->addContinuation( new comphelper::OInteractionApprove() );
+            uno::Reference< task::XInteractionRequest > xReq( pReq );
+            mxHandler->handle( xReq );
+        }
+        else
+        {
+            OSL_TRACE("Caught CannotActivateFactoryException: %s", rtl::OUStringToOString( 
e.Message, RTL_TEXTENCODING_UTF8 ).getStr());
+        }
+//#endif
+    }
+};
+
 void impl_addToModelCollection(const css::uno::Reference< css::frame::XModel >& xModel)
 {
     if (!xModel.is())
@@ -2186,7 +2216,13 @@ sal_Bool SfxObjectShell::ImportFrom( SfxMedium& rMedium, bool bInsert )
         try{
         xLoader = uno::Reference< document::XFilter >
             ( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any >() 
), uno::UNO_QUERY );
-        }catch(const uno::Exception&)
+        }
+        catch(const loader::CannotActivateFactoryException& e )
+        {
+            FilterActivationHandlerHelper helper( rMedium );
+            helper.handleException( e );
+        }
+        catch(const uno::Exception& e)
             { xLoader.clear(); }
     }
     if ( xLoader.is() )
@@ -2281,6 +2317,11 @@ sal_Bool SfxObjectShell::ExportTo( SfxMedium& rMedium )
             try{
             xExporter = uno::Reference< document::XExporter >
                 ( xFilterFact->createInstanceWithArguments( aFilterName, uno::Sequence < uno::Any 
() ), uno::UNO_QUERY );
+            }
+            catch(const loader::CannotActivateFactoryException& e )
+            {
+                FilterActivationHandlerHelper helper( rMedium );
+                helper.handleException( e );
             }catch(const uno::Exception&)
                 { xExporter.clear(); }
         }

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.