MCPcopy Create free account
hub / github.com/LibreOffice/core / CreateTempFile

Method CreateTempFile

odk/examples/java/Storage/TestHelper.java:697–751  ·  view source on GitHub ↗
( XMultiServiceFactory xMSF )

Source from the content-addressed store, hash-verified

695 }
696
697 public String CreateTempFile( XMultiServiceFactory xMSF )
698 {
699 String sResult = null;
700
701 // try to get temporary file representation
702 XPropertySet xTempFileProps = null;
703 try
704 {
705 Object oTempFile = xMSF.createInstance( "com.sun.star.io.TempFile" );
706 xTempFileProps = UnoRuntime.queryInterface( XPropertySet.class, oTempFile );
707 }
708 catch( Exception e )
709 {}
710
711 if ( xTempFileProps != null )
712 {
713 try
714 {
715 xTempFileProps.setPropertyValue( "RemoveFile", Boolean.FALSE );
716 sResult = AnyConverter.toString( xTempFileProps.getPropertyValue( "Uri" ) );
717 }
718 catch( Exception e )
719 {
720 Error( "Can't control TempFile properties, exception: " + e );
721 }
722 }
723 else
724 {
725 Error( "Can't create temporary file representation!" );
726 }
727
728 // close temporary file explicitly
729 try
730 {
731 XStream xStream = UnoRuntime.queryInterface( XStream.class, xTempFileProps );
732 if ( xStream != null )
733 {
734 XOutputStream xOut = xStream.getOutputStream();
735 if ( xOut != null )
736 xOut.closeOutput();
737
738 XInputStream xIn = xStream.getInputStream();
739 if ( xIn != null )
740 xIn.closeInput();
741 }
742 else
743 Error( "Can't close TempFile!" );
744 }
745 catch( Exception e )
746 {
747 Error( "Can't close TempFile, exception: " + e );
748 }
749
750 return sResult;
751 }
752
753 public boolean copyElementTo( XStorage xSource, String sName, XStorage xDest )
754 {

Callers 6

testMethod · 0.45
testMethod · 0.45
testMethod · 0.45
testMethod · 0.45
testMethod · 0.45
testMethod · 0.45

Calls 10

queryInterfaceMethod · 0.95
toStringMethod · 0.95
ErrorMethod · 0.95
createInstanceMethod · 0.65
setPropertyValueMethod · 0.45
getPropertyValueMethod · 0.45
getOutputStreamMethod · 0.45
closeOutputMethod · 0.45
getInputStreamMethod · 0.45
closeInputMethod · 0.45

Tested by

no test coverage detected