Show TOC Start of Content Area

Procedure documentation Implementing IWDIOSFactory  Locate the document in its SAP Library structure

Use

The IWDIOSFactory allows you to handle documents in expertMode.

Prerequisites

You have implemented a OfficeControl as described in: Using OfficeControl

Procedure

       1.      Set the expertMode property of the OfficeControl to true.

       2.      Create an attribute called errors of type String. If an error occurs, for example while opening the document, this context attribute will take the error message.

       3.      The following variables need to be declared (in others):

public IWDIOSFactory factoryInstance;

public IWDIOSDocument documentInstance;

       4.      To get an instance of the IWDIOSFactory you have to retrieve the IWDAttributeInfo of the context attribute dataSrc:

IWDAttributeInfo info =
  
wdContext.nodeSrc().getNodeInfo().getAttribute("dataSrc");

factoryInstance =
   WDOfficeControlMethods.getMethodHandlerInstance(info);

       5.      To open an existing file, enter the following code into the relevant method:

IWDMessageManager mmger = wdComponentAPI.getMessageManager();

IWDNodeElement element = wdContext.currentSrcElement();

try{

   if (factoryInstance == null){

      IWDAttributeInfo info =
        
wdContext.nodeSrc().getNodeInfo().getAttribute("dataSrc");

      factoryInstance =
         WDOfficeControlMethods.
getMethodHandlerInstance(info);

   }

   IWDAttributePointer errorpointer =

      element.getAttributePointer("errors");

   documentInstance = factoryInstance.getDocumentProxy();

   documentInstance.openDocument(errorpointer);

}

catch (WDIOSDocumentException documentException){

      mmger.reportException("could not create file: " +

      documentException.getMessage(), false);

}

catch (WDIOSEnvironmentException envException){

      mmger.reportException("could not create file: " +

      envException.getMessage(), false);

}

catch (WDIOSFactoryException facException){

      mmger.reportException("could not create file: " +

      facException.getMessage(), false);

}

You can use this source text in the same way for other methods of the IWDIOSDocument, but need to take account of the differences in the exceptions.

End of Content Area