On 02/15/2013 10:35 AM, Noel Grandin wrote:
Then how about this?
Split the logic so we can differentiate the cases.

It would grow more code, but if you absolutely feel like it...  :)

(In which case the "of type XFilePicker3" should arguably be removed from the original two throw expressions.)

Also, we could reduce the compress the EXE size a little by moving all
of this boilerplate into a central utility method somewhere.

Yeah, might be possible to abstract out some common code into one or more functions.

static Reference< XFilePicker3 > createDefault(Reference<
XComponentContext > const & the_context) {
    assert(the_context.is());
    Reference< XInterface > the_instance1;
    try {
      the_instance1 =
the_context->getServiceManager()->createInstanceWithArgumentsAndContext(
                         "com.sun.star.ui.dialogs.FilePicker" ,
                         Sequence<Any>(),
                         the_context),
     } catch (RuntimeException &) {
       throw;
     } catch (Exception & the_exception) {
       throw DeploymentException( "component context fails to supply
service FilePicker of type XFilePicker3: "
                       + the_exception.Message, the_context);
     }
     if (!the_instance1.is()) {
          throw DeploymentException( "component context fails to supply
service FilePicker of type XFilePicker3" ), the_context);
     }
     Reference< XFilePicker3 > the_instance2( the_instance1, UNO_QUERY );
     if (!the_instance2.is()) {
         throw DeploymentException( "component context supplied a
service FilePicker, but the service does not implement interface
XFilePicker3" ), the_context);     }
     return the_instance;
}

Stephan
_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to