LCOV - code coverage report
Current view: top level - basic/source/runtime - iosys.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 144 438 32.9 %
Date: 2012-08-25 Functions: 21 52 40.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 112 704 15.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include <vcl/dialog.hxx>
      21                 :            : #include <vcl/edit.hxx>
      22                 :            : #include <vcl/button.hxx>
      23                 :            : #include <vcl/msgbox.hxx>
      24                 :            : #include <vcl/svapp.hxx>
      25                 :            : #include <osl/security.h>
      26                 :            : #include <osl/file.hxx>
      27                 :            : #include <tools/urlobj.hxx>
      28                 :            : #include <osl/mutex.hxx>
      29                 :            : 
      30                 :            : #include "runtime.hxx"
      31                 :            : 
      32                 :            : #include <sal/alloca.h>
      33                 :            : 
      34                 :            : #include <ctype.h>
      35                 :            : #include <rtl/byteseq.hxx>
      36                 :            : #include <rtl/textenc.h>
      37                 :            : #include <rtl/strbuf.hxx>
      38                 :            : #include <rtl/ustrbuf.hxx>
      39                 :            : 
      40                 :            : #include <comphelper/componentcontext.hxx>
      41                 :            : #include <comphelper/processfactory.hxx>
      42                 :            : #include <comphelper/string.hxx>
      43                 :            : 
      44                 :            : #include <com/sun/star/uno/Sequence.hxx>
      45                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      46                 :            : #include <com/sun/star/ucb/SimpleFileAccess.hpp>
      47                 :            : #include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
      48                 :            : #include <com/sun/star/ucb/XContentProvider.hpp>
      49                 :            : #include <com/sun/star/ucb/XContentProviderManager.hpp>
      50                 :            : #include <com/sun/star/io/XInputStream.hpp>
      51                 :            : #include <com/sun/star/io/XOutputStream.hpp>
      52                 :            : #include <com/sun/star/io/XStream.hpp>
      53                 :            : #include <com/sun/star/io/XSeekable.hpp>
      54                 :            : #include <com/sun/star/bridge/XBridge.hpp>
      55                 :            : #include <com/sun/star/bridge/XBridgeFactory.hpp>
      56                 :            : 
      57                 :            : using namespace comphelper;
      58                 :            : using namespace com::sun::star::uno;
      59                 :            : using namespace com::sun::star::lang;
      60                 :            : using namespace com::sun::star::ucb;
      61                 :            : using namespace com::sun::star::io;
      62                 :            : using namespace com::sun::star::bridge;
      63                 :            : 
      64                 :            : #include "iosys.hxx"
      65                 :            : #include "sbintern.hxx"
      66                 :            : 
      67                 :            : 
      68                 :            : 
      69 [ #  # ][ #  # ]:          0 : class SbiInputDialog : public ModalDialog {
         [ #  # ][ #  # ]
                 [ #  # ]
      70                 :            :     Edit aInput;
      71                 :            :     OKButton aOk;
      72                 :            :     CancelButton aCancel;
      73                 :            :     String aText;
      74                 :            :     DECL_LINK( Ok, Window * );
      75                 :            :     DECL_LINK( Cancel, Window * );
      76                 :            : public:
      77                 :            :     SbiInputDialog( Window*, const String& );
      78                 :          0 :     const String& GetInput() { return aText; }
      79                 :            : };
      80                 :            : 
      81                 :          0 : SbiInputDialog::SbiInputDialog( Window* pParent, const String& rPrompt )
      82                 :            :             :ModalDialog( pParent, WB_3DLOOK | WB_MOVEABLE | WB_CLOSEABLE ),
      83                 :            :              aInput( this, WB_3DLOOK | WB_LEFT | WB_BORDER ),
      84 [ #  # ][ #  # ]:          0 :              aOk( this ), aCancel( this )
         [ #  # ][ #  # ]
      85                 :            : {
      86         [ #  # ]:          0 :     SetText( rPrompt );
      87         [ #  # ]:          0 :     aOk.SetClickHdl( LINK( this, SbiInputDialog, Ok ) );
      88         [ #  # ]:          0 :     aCancel.SetClickHdl( LINK( this, SbiInputDialog, Cancel ) );
      89 [ #  # ][ #  # ]:          0 :     SetMapMode( MapMode( MAP_APPFONT ) );
                 [ #  # ]
      90                 :            : 
      91         [ #  # ]:          0 :     Point aPt = LogicToPixel( Point( 50, 50 ) );
      92         [ #  # ]:          0 :     Size  aSz = LogicToPixel( Size( 145, 65 ) );
      93         [ #  # ]:          0 :     SetPosSizePixel( aPt, aSz );
      94         [ #  # ]:          0 :     aPt = LogicToPixel( Point( 10, 10 ) );
      95         [ #  # ]:          0 :     aSz = LogicToPixel( Size( 120, 12 ) );
      96         [ #  # ]:          0 :     aInput.SetPosSizePixel( aPt, aSz );
      97         [ #  # ]:          0 :     aPt = LogicToPixel( Point( 15, 30 ) );
      98         [ #  # ]:          0 :     aSz = LogicToPixel( Size( 45, 15) );
      99         [ #  # ]:          0 :     aOk.SetPosSizePixel( aPt, aSz );
     100         [ #  # ]:          0 :     aPt = LogicToPixel( Point( 80, 30 ) );
     101         [ #  # ]:          0 :     aSz = LogicToPixel( Size( 45, 15) );
     102         [ #  # ]:          0 :     aCancel.SetPosSizePixel( aPt, aSz );
     103                 :            : 
     104         [ #  # ]:          0 :     aInput.Show();
     105         [ #  # ]:          0 :     aOk.Show();
     106         [ #  # ]:          0 :     aCancel.Show();
     107                 :          0 : }
     108                 :            : 
     109                 :          0 : IMPL_LINK_INLINE_START( SbiInputDialog, Ok, Window *, pWindow )
     110                 :            : {
     111                 :            :     (void)pWindow;
     112                 :            : 
     113         [ #  # ]:          0 :     aText = aInput.GetText();
     114                 :          0 :     EndDialog( 1 );
     115                 :          0 :     return 0;
     116                 :            : }
     117                 :          0 : IMPL_LINK_INLINE_END( SbiInputDialog, Ok, Window *, pWindow )
     118                 :            : 
     119                 :          0 : IMPL_LINK_INLINE_START( SbiInputDialog, Cancel, Window *, pWindow )
     120                 :            : {
     121                 :            :     (void)pWindow;
     122                 :            : 
     123                 :          0 :     EndDialog( 0 );
     124                 :          0 :     return 0;
     125                 :            : }
     126                 :          0 : IMPL_LINK_INLINE_END( SbiInputDialog, Cancel, Window *, pWindow )
     127                 :            : 
     128                 :            : 
     129                 :         24 : SbiStream::SbiStream()
     130                 :         24 :     : pStrm( 0 )
     131                 :            : {
     132                 :         24 : }
     133                 :            : 
     134                 :         24 : SbiStream::~SbiStream()
     135                 :            : {
     136 [ -  + ][ #  # ]:         24 :     delete pStrm;
     137                 :         24 : }
     138                 :            : 
     139                 :            : // map an SvStream-error to StarBASIC-code
     140                 :            : 
     141                 :         48 : void SbiStream::MapError()
     142                 :            : {
     143         [ +  - ]:         48 :     if( pStrm )
     144   [ +  -  -  -  :         48 :      switch( pStrm->GetError() )
             -  -  -  - ]
     145                 :            :      {
     146                 :            :         case SVSTREAM_OK:
     147                 :         48 :             nError = 0; break;
     148                 :            :         case SVSTREAM_FILE_NOT_FOUND:
     149                 :          0 :             nError = SbERR_FILE_NOT_FOUND; break;
     150                 :            :         case SVSTREAM_PATH_NOT_FOUND:
     151                 :          0 :             nError = SbERR_PATH_NOT_FOUND; break;
     152                 :            :         case SVSTREAM_TOO_MANY_OPEN_FILES:
     153                 :          0 :             nError = SbERR_TOO_MANY_FILES; break;
     154                 :            :         case SVSTREAM_ACCESS_DENIED:
     155                 :          0 :             nError = SbERR_ACCESS_DENIED; break;
     156                 :            :         case SVSTREAM_INVALID_PARAMETER:
     157                 :          0 :             nError = SbERR_BAD_ARGUMENT; break;
     158                 :            :         case SVSTREAM_OUTOFMEMORY:
     159                 :          0 :             nError = SbERR_NO_MEMORY; break;
     160                 :            :         default:
     161                 :         48 :             nError = SbERR_IO_ERROR; break;
     162                 :            :     }
     163                 :         48 : }
     164                 :            : 
     165                 :            : // TODO: Code is copied from daemons2/source/uno/asciiEncoder.cxx
     166                 :            : 
     167                 :          0 : ::rtl::OUString findUserInDescription( const ::rtl::OUString& aDescription )
     168                 :            : {
     169                 :          0 :     ::rtl::OUString user;
     170                 :            : 
     171                 :            :     sal_Int32 index;
     172                 :          0 :     sal_Int32 lastIndex = 0;
     173                 :            : 
     174         [ #  # ]:          0 :     do
     175                 :            :     {
     176                 :          0 :         index = aDescription.indexOf((sal_Unicode) ',', lastIndex);
     177         [ #  # ]:          0 :         ::rtl::OUString token = (index == -1) ? aDescription.copy(lastIndex) : aDescription.copy(lastIndex, index - lastIndex);
     178                 :            : 
     179                 :          0 :         lastIndex = index + 1;
     180                 :            : 
     181                 :          0 :         sal_Int32 eindex = token.indexOf((sal_Unicode)'=');
     182                 :          0 :         ::rtl::OUString left = token.copy(0, eindex).toAsciiLowerCase().trim();
     183                 :            :         ::rtl::OUString right = INetURLObject::decode( token.copy(eindex + 1).trim(), '%',
     184         [ #  # ]:          0 :                             INetURLObject::DECODE_WITH_CHARSET );
     185                 :            : 
     186         [ #  # ]:          0 :         if( left == "user" )
     187                 :            :         {
     188                 :          0 :             user = right;
     189                 :            :             break;
     190 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     191                 :            :     }
     192                 :            :     while(index != -1);
     193                 :            : 
     194                 :          0 :     return user;
     195                 :            : }
     196                 :            : 
     197                 :          0 : bool needSecurityRestrictions( void )
     198                 :            : {
     199                 :            :     static bool bNeedInit = true;
     200                 :            :     static bool bRetVal = true;
     201                 :            : 
     202         [ #  # ]:          0 :     if( bNeedInit )
     203                 :            :     {
     204                 :          0 :         bNeedInit = false;
     205                 :            : 
     206                 :            :         // Get system user to compare to portal user
     207         [ #  # ]:          0 :         oslSecurity aSecurity = osl_getCurrentSecurity();
     208                 :          0 :         ::rtl::OUString aSystemUser;
     209         [ #  # ]:          0 :         sal_Bool bRet = osl_getUserName( aSecurity, &aSystemUser.pData );
     210         [ #  # ]:          0 :         if( !bRet )
     211                 :            :         {
     212                 :            :             // No valid security! -> Secure mode!
     213                 :          0 :             return true;
     214                 :            :         }
     215                 :            : 
     216         [ #  # ]:          0 :         Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
     217         [ #  # ]:          0 :         if( !xSMgr.is() )
     218                 :          0 :             return true;
     219         [ #  # ]:          0 :         Reference< XBridgeFactory > xBridgeFac( xSMgr->createInstance
     220 [ #  # ][ #  # ]:          0 :             ( ::rtl::OUString("com.sun.star.bridge.BridgeFactory" ) ), UNO_QUERY );
     221                 :            : 
     222         [ #  # ]:          0 :         Sequence< Reference< XBridge > > aBridgeSeq;
     223                 :          0 :         sal_Int32 nBridgeCount = 0;
     224         [ #  # ]:          0 :         if( xBridgeFac.is() )
     225                 :            :         {
     226 [ #  # ][ #  # ]:          0 :             aBridgeSeq = xBridgeFac->getExistingBridges();
         [ #  # ][ #  # ]
     227                 :          0 :             nBridgeCount = aBridgeSeq.getLength();
     228                 :            :         }
     229                 :            : 
     230         [ #  # ]:          0 :         if( nBridgeCount == 0 )
     231                 :            :         {
     232                 :            :             // No bridges -> local
     233                 :          0 :             bRetVal = false;
     234                 :          0 :             return bRetVal;
     235                 :            :         }
     236                 :            : 
     237                 :            :         // Iterate through all bridges to find (portal) user property
     238                 :          0 :         const Reference< XBridge >* pBridges = aBridgeSeq.getConstArray();
     239                 :          0 :         bRetVal = false;    // Now only sal_True if user different from portal user is found
     240                 :            :         sal_Int32 i;
     241         [ #  # ]:          0 :         for( i = 0 ; i < nBridgeCount ; i++ )
     242                 :            :         {
     243                 :          0 :             const Reference< XBridge >& rxBridge = pBridges[ i ];
     244 [ #  # ][ #  # ]:          0 :             ::rtl::OUString aDescription = rxBridge->getDescription();
     245         [ #  # ]:          0 :             ::rtl::OUString aPortalUser = findUserInDescription( aDescription );
     246         [ #  # ]:          0 :             if( !aPortalUser.isEmpty() )
     247                 :            :             {
     248                 :            :                 // User Found, compare to system user
     249         [ #  # ]:          0 :                 if( aPortalUser == aSystemUser )
     250                 :            :                 {
     251                 :            :                     // Same user -> system security is ok, bRetVal stays FALSE
     252                 :            :                     break;
     253                 :            :                 }
     254                 :            :                 else
     255                 :            :                 {
     256                 :            :                     // Different user -> Secure mode!
     257                 :          0 :                     bRetVal = true;
     258                 :            :                     break;
     259                 :            :                 }
     260                 :            :             }
     261 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     262                 :            :         // No user found or PortalUser != SystemUser -> Secure mode! (Keep default value)
     263                 :            :     }
     264                 :            : 
     265                 :          0 :     return bRetVal;
     266                 :            : }
     267                 :            : 
     268                 :            : // Returns sal_True if UNO is available, otherwise the old file
     269                 :            : // system implementation has to be used
     270                 :            : // #89378 New semantic: Don't just ask for UNO but for UCB
     271                 :         98 : bool hasUno( void )
     272                 :            : {
     273                 :            :     static bool bNeedInit = true;
     274                 :            :     static bool bRetVal = true;
     275                 :            : 
     276         [ +  + ]:         98 :     if( bNeedInit )
     277                 :            :     {
     278                 :          2 :         bNeedInit = false;
     279         [ +  - ]:          2 :         Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
     280         [ -  + ]:          2 :         if( !xSMgr.is() )
     281                 :            :         {
     282                 :            :             // No service manager at all
     283                 :          0 :             bRetVal = false;
     284                 :            :         }
     285                 :            :         else
     286                 :            :         {
     287         [ +  - ]:          2 :             Reference< XContentProviderManager > xManager( xSMgr->createInstance(
     288 [ +  - ][ +  - ]:          2 :                                                                ::rtl::OUString( "com.sun.star.ucb.UniversalContentBroker" ) ), UNO_QUERY );
     289                 :            : 
     290 [ +  - ][ +  - ]:          2 :             if ( !( xManager.is() && xManager->queryContentProvider( ::rtl::OUString("file:///" ) ).is() ) )
         [ -  + ][ +  - ]
         [ +  - ][ +  - ]
           [ -  +  #  #  
             #  #  #  # ]
                 [ +  - ]
     291                 :            :             {
     292                 :            :                 // No UCB
     293                 :          0 :                 bRetVal = false;
     294                 :          2 :             }
     295                 :          2 :         }
     296                 :            :     }
     297                 :         98 :     return bRetVal;
     298                 :            : }
     299                 :            : 
     300                 :            : 
     301                 :            : 
     302                 :            : class OslStream : public SvStream
     303                 :            : {
     304                 :            :     osl::File maFile;
     305                 :            : 
     306                 :            : public:
     307                 :            :                     OslStream( const String& rName, short nStrmMode );
     308                 :            :                     ~OslStream();
     309                 :            :     virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize );
     310                 :            :     virtual sal_uIntPtr PutData( const void* pData, sal_uIntPtr nSize );
     311                 :            :     virtual sal_uIntPtr SeekPos( sal_uIntPtr nPos );
     312                 :            :     virtual void    FlushData();
     313                 :            :     virtual void    SetSize( sal_uIntPtr nSize );
     314                 :            : };
     315                 :            : 
     316                 :          0 : OslStream::OslStream( const String& rName, short nStrmMode )
     317         [ #  # ]:          0 :     : maFile( rName )
     318                 :            : {
     319                 :            :     sal_uInt32 nFlags;
     320                 :            : 
     321         [ #  # ]:          0 :     if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) )
     322                 :            :     {
     323                 :          0 :         nFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write;
     324                 :            :     }
     325         [ #  # ]:          0 :     else if( nStrmMode & STREAM_WRITE )
     326                 :            :     {
     327                 :          0 :         nFlags = osl_File_OpenFlag_Write;
     328                 :            :     }
     329                 :            :     else //if( nStrmMode & STREAM_READ )
     330                 :            :     {
     331                 :          0 :         nFlags = osl_File_OpenFlag_Read;
     332                 :            :     }
     333                 :            : 
     334         [ #  # ]:          0 :     osl::FileBase::RC nRet = maFile.open( nFlags );
     335 [ #  # ][ #  # ]:          0 :     if( nRet == osl::FileBase::E_NOENT && nFlags != osl_File_OpenFlag_Read )
     336                 :            :     {
     337                 :          0 :         nFlags |= osl_File_OpenFlag_Create;
     338         [ #  # ]:          0 :         nRet = maFile.open( nFlags );
     339                 :            :     }
     340                 :            : 
     341         [ #  # ]:          0 :     if( nRet != osl::FileBase::E_None )
     342                 :            :     {
     343         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     344                 :            :     }
     345                 :          0 : }
     346                 :            : 
     347                 :            : 
     348         [ #  # ]:          0 : OslStream::~OslStream()
     349                 :            : {
     350         [ #  # ]:          0 :     maFile.close();
     351         [ #  # ]:          0 : }
     352                 :            : 
     353                 :          0 : sal_uIntPtr OslStream::GetData( void* pData, sal_uIntPtr nSize )
     354                 :            : {
     355                 :          0 :     sal_uInt64 nBytesRead = nSize;
     356         [ #  # ]:          0 :     maFile.read( pData, nBytesRead, nBytesRead );
     357                 :          0 :     return (sal_uIntPtr)nBytesRead;
     358                 :            : }
     359                 :            : 
     360                 :          0 : sal_uIntPtr OslStream::PutData( const void* pData, sal_uIntPtr nSize )
     361                 :            : {
     362                 :            :     sal_uInt64 nBytesWritten;
     363         [ #  # ]:          0 :     maFile.write( pData, (sal_uInt64)nSize, nBytesWritten );
     364                 :          0 :     return (sal_uIntPtr)nBytesWritten;
     365                 :            : }
     366                 :            : 
     367                 :          0 : sal_uIntPtr OslStream::SeekPos( sal_uIntPtr nPos )
     368                 :            : {
     369                 :          0 :     ::osl::FileBase::RC rc = ::osl::FileBase::E_None;
     370         [ #  # ]:          0 :     if( nPos == STREAM_SEEK_TO_END )
     371         [ #  # ]:          0 :         rc = maFile.setPos( osl_Pos_End, 0 );
     372                 :            :     else
     373         [ #  # ]:          0 :         rc = maFile.setPos( osl_Pos_Absolut, (sal_uInt64)nPos );
     374                 :            :     OSL_VERIFY(rc == ::osl::FileBase::E_None);
     375                 :          0 :     sal_uInt64 nRealPos(0);
     376         [ #  # ]:          0 :     maFile.getPos( nRealPos );
     377                 :          0 :     return sal::static_int_cast<sal_uIntPtr>(nRealPos);
     378                 :            : }
     379                 :            : 
     380                 :          0 : void OslStream::FlushData()
     381                 :            : {
     382                 :          0 : }
     383                 :            : 
     384                 :          0 : void OslStream::SetSize( sal_uIntPtr nSize )
     385                 :            : {
     386                 :          0 :     maFile.setSize( (sal_uInt64)nSize );
     387                 :          0 : }
     388                 :            : 
     389                 :            : 
     390                 :            : class UCBStream : public SvStream
     391                 :            : {
     392                 :            :     Reference< XInputStream >   xIS;
     393                 :            :     Reference< XStream >        xS;
     394                 :            :     Reference< XSeekable >      xSeek;
     395                 :            : public:
     396                 :            :                     UCBStream( Reference< XInputStream > & xIS );
     397                 :            :                     UCBStream( Reference< XStream > & xS );
     398                 :            :                     ~UCBStream();
     399                 :            :     virtual sal_uIntPtr GetData( void* pData, sal_uIntPtr nSize );
     400                 :            :     virtual sal_uIntPtr PutData( const void* pData, sal_uIntPtr nSize );
     401                 :            :     virtual sal_uIntPtr SeekPos( sal_uIntPtr nPos );
     402                 :            :     virtual void    FlushData();
     403                 :            :     virtual void    SetSize( sal_uIntPtr nSize );
     404                 :            : };
     405                 :            : 
     406                 :          0 : UCBStream::UCBStream( Reference< XInputStream > & rStm )
     407                 :            :     : xIS( rStm )
     408         [ #  # ]:          0 :     , xSeek( rStm, UNO_QUERY )
     409                 :            : {
     410                 :          0 : }
     411                 :            : 
     412                 :         24 : UCBStream::UCBStream( Reference< XStream > & rStm )
     413                 :            :     : xS( rStm )
     414         [ +  - ]:         24 :     , xSeek( rStm, UNO_QUERY )
     415                 :            : {
     416                 :         24 : }
     417                 :            : 
     418                 :            : 
     419                 :         24 : UCBStream::~UCBStream()
     420                 :            : {
     421                 :            :     try
     422                 :            :     {
     423         [ -  + ]:         24 :         if( xIS.is() )
     424 [ #  # ][ #  # ]:          0 :             xIS->closeInput();
     425         [ +  - ]:         24 :         else if( xS.is() )
     426                 :            :         {
     427 [ +  - ][ +  - ]:         24 :             Reference< XInputStream > xIS_ = xS->getInputStream();
     428         [ +  - ]:         24 :             if( xIS_.is() )
     429 [ +  - ][ +  - ]:         24 :                 xIS_->closeInput();
     430                 :            :         }
     431                 :            :     }
     432   [ #  #  #  # ]:          0 :     catch(const Exception & )
     433                 :            :     {
     434         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     435                 :            :     }
     436         [ -  + ]:         48 : }
     437                 :            : 
     438                 :          0 : sal_uIntPtr UCBStream::GetData( void* pData, sal_uIntPtr nSize )
     439                 :            : {
     440                 :            :     try
     441                 :            :     {
     442                 :          0 :         Reference< XInputStream > xISFromS;
     443         [ #  # ]:          0 :         if( xIS.is() )
     444                 :            :         {
     445         [ #  # ]:          0 :             Sequence<sal_Int8> aData;
     446 [ #  # ][ #  # ]:          0 :             nSize = xIS->readBytes( aData, nSize );
     447         [ #  # ]:          0 :             rtl_copyMemory( pData, aData.getConstArray(), nSize );
     448         [ #  # ]:          0 :             return nSize;
     449                 :            :         }
     450 [ #  # ][ #  # ]:          0 :         else if( xS.is() && (xISFromS = xS->getInputStream()).is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     451                 :            :         {
     452         [ #  # ]:          0 :             Sequence<sal_Int8> aData;
     453 [ #  # ][ #  # ]:          0 :             nSize = xISFromS->readBytes( aData, nSize );
     454         [ #  # ]:          0 :             rtl_copyMemory( pData, aData.getConstArray(), nSize );
     455         [ #  # ]:          0 :             return nSize;
     456                 :            :         }
     457                 :            :         else
     458 [ #  # ][ #  # ]:          0 :             SetError( ERRCODE_IO_GENERAL );
     459                 :            :     }
     460         [ #  # ]:          0 :     catch(const Exception & )
     461                 :            :     {
     462         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     463                 :            :     }
     464                 :          0 :     return 0;
     465                 :            : }
     466                 :            : 
     467                 :        366 : sal_uIntPtr UCBStream::PutData( const void* pData, sal_uIntPtr nSize )
     468                 :            : {
     469                 :            :     try
     470                 :            :     {
     471                 :        366 :         Reference< XOutputStream > xOSFromS;
     472 [ +  - ][ +  - ]:        366 :         if( xS.is() && (xOSFromS = xS->getOutputStream()).is() )
         [ +  - ][ +  - ]
                 [ +  - ]
           [ +  -  #  # ]
                 [ +  - ]
     473                 :            :         {
     474         [ +  - ]:        366 :             Sequence<sal_Int8> aData( (const sal_Int8 *)pData, nSize );
     475 [ +  - ][ +  - ]:        366 :             xOSFromS->writeBytes( aData );
     476         [ +  - ]:        366 :             return nSize;
     477                 :            :         }
     478                 :            :         else
     479 [ #  # ][ -  + ]:        366 :             SetError( ERRCODE_IO_GENERAL );
     480                 :            :     }
     481         [ #  # ]:          0 :     catch(const Exception & )
     482                 :            :     {
     483         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     484                 :            :     }
     485                 :        366 :     return 0;
     486                 :            : }
     487                 :            : 
     488                 :          0 : sal_uIntPtr UCBStream::SeekPos( sal_uIntPtr nPos )
     489                 :            : {
     490                 :            :     try
     491                 :            :     {
     492         [ #  # ]:          0 :         if( xSeek.is() )
     493                 :            :         {
     494 [ #  # ][ #  # ]:          0 :             sal_uIntPtr nLen = sal::static_int_cast<sal_uIntPtr>( xSeek->getLength() );
     495         [ #  # ]:          0 :             if( nPos > nLen )
     496                 :          0 :                 nPos = nLen;
     497 [ #  # ][ #  # ]:          0 :             xSeek->seek( nPos );
     498                 :          0 :             return nPos;
     499                 :            :         }
     500                 :            :         else
     501         [ #  # ]:          0 :             SetError( ERRCODE_IO_GENERAL );
     502                 :            :     }
     503         [ #  # ]:          0 :     catch(const Exception & )
     504                 :            :     {
     505         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     506                 :            :     }
     507                 :          0 :     return 0;
     508                 :            : }
     509                 :            : 
     510                 :          0 : void    UCBStream::FlushData()
     511                 :            : {
     512                 :            :     try
     513                 :            :     {
     514                 :          0 :         Reference< XOutputStream > xOSFromS;
     515 [ #  # ][ #  # ]:          0 :         if( xS.is() && (xOSFromS = xS->getOutputStream()).is() )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     516 [ #  # ][ #  # ]:          0 :             xOSFromS->flush();
     517                 :            :         else
     518         [ #  # ]:          0 :             SetError( ERRCODE_IO_GENERAL );
     519                 :            :     }
     520         [ #  # ]:          0 :     catch(const Exception & )
     521                 :            :     {
     522         [ #  # ]:          0 :         SetError( ERRCODE_IO_GENERAL );
     523                 :            :     }
     524                 :          0 : }
     525                 :            : 
     526                 :          0 : void    UCBStream::SetSize( sal_uIntPtr nSize )
     527                 :            : {
     528                 :            :     (void)nSize;
     529                 :            : 
     530                 :            :     OSL_FAIL( "not allowed to call from basic" );
     531                 :          0 :     SetError( ERRCODE_IO_GENERAL );
     532                 :          0 : }
     533                 :            : 
     534                 :            : 
     535                 :         24 : SbError SbiStream::Open
     536                 :            : ( short nCh, const rtl::OString& rName, short nStrmMode, short nFlags, short nL )
     537                 :            : {
     538                 :         24 :     nMode   = nFlags;
     539                 :         24 :     nLen    = nL;
     540                 :         24 :     nChan   = nCh;
     541                 :         24 :     nLine   = 0;
     542                 :         24 :     nExpandOnWriteTo = 0;
     543         [ -  + ]:         24 :     if( ( nStrmMode & ( STREAM_READ|STREAM_WRITE ) ) == STREAM_READ )
     544                 :          0 :         nStrmMode |= STREAM_NOCREATE;
     545 [ +  - ][ +  - ]:         24 :     String aStr(rtl::OStringToOUString(rName, osl_getThreadTextEncoding()));
                 [ +  - ]
     546         [ +  - ]:         24 :     String aNameStr = getFullPath( aStr );
     547                 :            : 
     548 [ +  - ][ +  - ]:         24 :     if( hasUno() )
     549                 :            :     {
     550         [ +  - ]:         24 :         Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
     551         [ +  - ]:         24 :         if( xSMgr.is() )
     552                 :            :         {
     553                 :            :             Reference< XSimpleFileAccess2 >
     554 [ +  - ][ +  - ]:         24 :                 xSFI( SimpleFileAccess::create( comphelper::ComponentContext(xSMgr).getUNOContext() ) );
         [ +  - ][ +  - ]
     555                 :            :             try
     556                 :            :             {
     557                 :            : 
     558                 :            :             // #??? For write access delete file if it already exists (not for appending)
     559 [ +  - ][ +  - ]:         72 :             if( (nStrmMode & STREAM_WRITE) != 0 && !IsAppend() && !IsBinary() &&
         [ +  - ][ -  + ]
         [ #  # ][ -  + ]
     560 [ +  - ][ +  - ]:         48 :                 xSFI->exists( aNameStr ) && !xSFI->isFolder( aNameStr ) )
         [ +  - ][ #  # ]
         [ #  # ][ #  # ]
         [ -  + ][ +  - ]
           [ #  #  #  # ]
     561                 :            :             {
     562 [ #  # ][ #  # ]:          0 :                 xSFI->kill( aNameStr );
                 [ #  # ]
     563                 :            :             }
     564                 :            : 
     565         [ -  + ]:         24 :             if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) )
     566                 :            :             {
     567 [ #  # ][ #  # ]:          0 :                 Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
                 [ #  # ]
     568 [ #  # ][ #  # ]:          0 :                 pStrm = new UCBStream( xIS );
     569                 :            :             }
     570         [ +  - ]:         24 :             else if( nStrmMode & STREAM_WRITE )
     571                 :            :             {
     572 [ +  - ][ +  - ]:         24 :                 Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr );
                 [ +  - ]
     573 [ +  - ][ +  - ]:         24 :                 pStrm = new UCBStream( xIS );
     574                 :            :             }
     575                 :            :             else //if( nStrmMode & STREAM_READ )
     576                 :            :             {
     577 [ #  # ][ #  # ]:          0 :                 Reference< XInputStream > xIS = xSFI->openFileRead( aNameStr );
                 [ #  # ]
     578 [ #  # ][ #  # ]:          0 :                 pStrm = new UCBStream( xIS );
                 [ #  # ]
     579                 :            :             }
     580                 :            : 
     581                 :            :             }
     582         [ #  # ]:          0 :             catch(const Exception & )
     583                 :            :             {
     584                 :          0 :                 nError = ERRCODE_IO_GENERAL;
     585                 :         24 :             }
     586                 :         24 :         }
     587                 :            :     }
     588                 :            : 
     589         [ -  + ]:         24 :     if( !pStrm )
     590                 :            :     {
     591 [ #  # ][ #  # ]:          0 :         pStrm = new OslStream( aNameStr, nStrmMode );
     592                 :            :     }
     593         [ -  + ]:         24 :     if( IsAppend() )
     594         [ #  # ]:          0 :         pStrm->Seek( STREAM_SEEK_TO_END );
     595                 :         24 :     MapError();
     596         [ -  + ]:         24 :     if( nError )
     597 [ #  # ][ #  # ]:          0 :         delete pStrm, pStrm = NULL;
     598 [ +  - ][ +  - ]:         24 :     return nError;
     599                 :            : }
     600                 :            : 
     601                 :         24 : SbError SbiStream::Close()
     602                 :            : {
     603         [ +  - ]:         24 :     if( pStrm )
     604                 :            :     {
     605                 :         24 :         MapError();
     606         [ +  - ]:         24 :         delete pStrm;
     607                 :         24 :         pStrm = NULL;
     608                 :            :     }
     609                 :         24 :     nChan = 0;
     610                 :         24 :     return nError;
     611                 :            : }
     612                 :            : 
     613                 :          0 : SbError SbiStream::Read(rtl::OString& rBuf, sal_uInt16 n, bool bForceReadingPerByte)
     614                 :            : {
     615                 :          0 :     nExpandOnWriteTo = 0;
     616 [ #  # ][ #  # ]:          0 :     if( !bForceReadingPerByte && IsText() )
                 [ #  # ]
     617                 :            :     {
     618                 :          0 :         pStrm->ReadLine(rBuf);
     619                 :          0 :         nLine++;
     620                 :            :     }
     621                 :            :     else
     622                 :            :     {
     623         [ #  # ]:          0 :         if( !n )
     624                 :          0 :             n = nLen;
     625         [ #  # ]:          0 :         if( !n )
     626                 :          0 :             return nError = SbERR_BAD_RECORD_LENGTH;
     627 [ #  # ][ #  # ]:          0 :         rtl::OStringBuffer aBuffer(read_uInt8s_ToOString(*pStrm, n));
     628                 :            :         //Pad it out with ' ' to the requested length on short read
     629                 :          0 :         sal_Int32 nRequested = sal::static_int_cast<sal_Int32>(n);
     630         [ #  # ]:          0 :         comphelper::string::padToLength(aBuffer, nRequested, ' ');
     631                 :          0 :         rBuf = aBuffer.makeStringAndClear();
     632                 :            :     }
     633                 :          0 :     MapError();
     634 [ #  # ][ #  # ]:          0 :     if( !nError && pStrm->IsEof() )
                 [ #  # ]
     635                 :          0 :         nError = SbERR_READ_PAST_EOF;
     636                 :          0 :     return nError;
     637                 :            : }
     638                 :            : 
     639                 :          0 : SbError SbiStream::Read( char& ch )
     640                 :            : {
     641                 :          0 :     nExpandOnWriteTo = 0;
     642         [ #  # ]:          0 :     if (aLine.isEmpty())
     643                 :            :     {
     644                 :          0 :         Read( aLine, 0 );
     645                 :          0 :         aLine = aLine + rtl::OString('\n');
     646                 :            :     }
     647                 :          0 :     ch = aLine[0];
     648                 :          0 :     aLine = aLine.copy(1);
     649                 :          0 :     return nError;
     650                 :            : }
     651                 :            : 
     652                 :        366 : void SbiStream::ExpandFile()
     653                 :            : {
     654         [ -  + ]:        366 :     if ( nExpandOnWriteTo )
     655                 :            :     {
     656                 :          0 :         sal_uIntPtr nCur = pStrm->Seek(STREAM_SEEK_TO_END);
     657         [ #  # ]:          0 :         if( nCur < nExpandOnWriteTo )
     658                 :            :         {
     659                 :          0 :             sal_uIntPtr nDiff = nExpandOnWriteTo - nCur;
     660                 :          0 :             char c = 0;
     661         [ #  # ]:          0 :             while( nDiff-- )
     662                 :          0 :                 *pStrm << c;
     663                 :            :         }
     664                 :            :         else
     665                 :            :         {
     666                 :          0 :             pStrm->Seek( nExpandOnWriteTo );
     667                 :            :         }
     668                 :          0 :         nExpandOnWriteTo = 0;
     669                 :            :     }
     670                 :        366 : }
     671                 :            : 
     672                 :            : namespace
     673                 :            : {
     674                 :        184 :     void WriteLines(SvStream &rStream, const rtl::OString& rStr)
     675                 :            :     {
     676         [ +  - ]:        184 :         rtl::OString aStr(convertLineEnd(rStr, rStream.GetLineDelimiter()) );
     677         [ +  - ]:        184 :         write_uInt8s_FromOString(rStream, rStr);
     678         [ +  - ]:        184 :         endl( rStream );
     679                 :        184 :     }
     680                 :            : }
     681                 :            : 
     682                 :        366 : SbError SbiStream::Write( const rtl::OString& rBuf, sal_uInt16 n )
     683                 :            : {
     684                 :        366 :     ExpandFile();
     685         [ -  + ]:        366 :     if( IsAppend() )
     686                 :          0 :         pStrm->Seek( STREAM_SEEK_TO_END );
     687                 :            : 
     688         [ +  - ]:        366 :     if( IsText() )
     689                 :            :     {
     690                 :        366 :         aLine = aLine + rBuf;
     691                 :            :         // Get it out, if the end is an LF, but strip CRLF before,
     692                 :            :         // because the SvStrm adds a CRLF!
     693                 :        366 :         sal_Int32 nLineLen = aLine.getLength();
     694 [ +  + ][ +  + ]:        366 :         if (nLineLen && aLine[--nLineLen] == 0x0A)
                 [ +  - ]
     695                 :            :         {
     696                 :        184 :             aLine = aLine.copy(0, nLineLen);
     697 [ -  + ][ -  + ]:        184 :             if (nLineLen && aLine[--nLineLen] == 0x0D)
                 [ +  + ]
     698                 :          0 :                 aLine = aLine.copy(0, nLineLen);
     699                 :        184 :             WriteLines(*pStrm, aLine);
     700                 :        184 :             aLine = rtl::OString();
     701                 :            :         }
     702                 :            :     }
     703                 :            :     else
     704                 :            :     {
     705         [ #  # ]:          0 :         if( !n )
     706                 :          0 :             n = nLen;
     707         [ #  # ]:          0 :         if( !n )
     708                 :          0 :             return nError = SbERR_BAD_RECORD_LENGTH;
     709                 :          0 :         pStrm->Write(rBuf.getStr(), n);
     710                 :          0 :         MapError();
     711                 :            :     }
     712                 :        366 :     return nError;
     713                 :            : }
     714                 :            : 
     715                 :            : 
     716                 :            : 
     717                 :          0 : SbiIoSystem* SbGetIoSystem()
     718                 :            : {
     719                 :          0 :     SbiInstance* pInst = GetSbData()->pInst;
     720         [ #  # ]:          0 :     return pInst ? pInst->GetIoSystem() : NULL;
     721                 :            : }
     722                 :            : 
     723                 :            : 
     724                 :         31 : SbiIoSystem::SbiIoSystem()
     725                 :            : {
     726         [ +  + ]:       7967 :     for( short i = 0; i < CHANNELS; i++ )
     727                 :       7936 :         pChan[ i ] = NULL;
     728                 :         31 :     nChan  = 0;
     729                 :         31 :     nError = 0;
     730                 :         31 : }
     731                 :            : 
     732                 :         31 : SbiIoSystem::~SbiIoSystem()
     733                 :            : {
     734         [ +  - ]:         31 :     Shutdown();
     735                 :         31 : }
     736                 :            : 
     737                 :        640 : SbError SbiIoSystem::GetError()
     738                 :            : {
     739                 :        640 :     SbError n = nError; nError = 0;
     740                 :        640 :     return n;
     741                 :            : }
     742                 :            : 
     743                 :         24 : void SbiIoSystem::Open(short nCh, const rtl::OString& rName, short nMode, short nFlags, short nLen)
     744                 :            : {
     745                 :         24 :     nError = 0;
     746 [ +  - ][ -  + ]:         24 :     if( nCh >= CHANNELS || !nCh )
     747                 :          0 :         nError = SbERR_BAD_CHANNEL;
     748         [ -  + ]:         24 :     else if( pChan[ nCh ] )
     749                 :          0 :         nError = SbERR_FILE_ALREADY_OPEN;
     750                 :            :     else
     751                 :            :     {
     752                 :         24 :         pChan[ nCh ] = new SbiStream;
     753                 :         24 :         nError = pChan[ nCh ]->Open( nCh, rName, nMode, nFlags, nLen );
     754         [ -  + ]:         24 :         if( nError )
     755         [ #  # ]:          0 :             delete pChan[ nCh ], pChan[ nCh ] = NULL;
     756                 :            :     }
     757                 :         24 :     nChan = 0;
     758                 :         24 : }
     759                 :            : 
     760                 :            : 
     761                 :         22 : void SbiIoSystem::Close()
     762                 :            : {
     763         [ -  + ]:         22 :     if( !nChan )
     764                 :          0 :         nError = SbERR_BAD_CHANNEL;
     765         [ -  + ]:         22 :     else if( !pChan[ nChan ] )
     766                 :          0 :         nError = SbERR_BAD_CHANNEL;
     767                 :            :     else
     768                 :            :     {
     769                 :         22 :         nError = pChan[ nChan ]->Close();
     770         [ +  - ]:         22 :         delete pChan[ nChan ];
     771                 :         22 :         pChan[ nChan ] = NULL;
     772                 :            :     }
     773                 :         22 :     nChan = 0;
     774                 :         22 : }
     775                 :            : 
     776                 :            : 
     777                 :         31 : void SbiIoSystem::Shutdown()
     778                 :            : {
     779         [ +  + ]:       7936 :     for( short i = 1; i < CHANNELS; i++ )
     780                 :            :     {
     781         [ +  + ]:       7905 :         if( pChan[ i ] )
     782                 :            :         {
     783                 :          2 :             SbError n = pChan[ i ]->Close();
     784         [ +  - ]:          2 :             delete pChan[ i ];
     785                 :          2 :             pChan[ i ] = NULL;
     786 [ -  + ][ #  # ]:          2 :             if( n && !nError )
     787                 :          0 :                 nError = n;
     788                 :            :         }
     789                 :            :     }
     790                 :         31 :     nChan = 0;
     791                 :            :     // anything left to PRINT?
     792         [ -  + ]:         31 :     if( !aOut.isEmpty() )
     793                 :            :     {
     794 [ #  # ][ #  # ]:          0 :         rtl::OUString aOutStr(rtl::OStringToOUString(aOut, osl_getThreadTextEncoding()));
     795                 :            : #if defined GCC
     796         [ #  # ]:          0 :         Window* pParent = Application::GetDefDialogParent();
     797 [ #  # ][ #  # ]:          0 :         MessBox( pParent, WinBits( WB_OK ), String(), aOutStr ).Execute();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     798                 :            : #else
     799                 :            :         MessBox( GetpApp()->GetDefDialogParent(), WinBits( WB_OK ), String(), aOutStr ).Execute();
     800                 :            : #endif
     801                 :            :     }
     802                 :         31 :     aOut = rtl::OString();
     803                 :         31 : }
     804                 :            : 
     805                 :            : 
     806                 :          0 : void SbiIoSystem::Read(rtl::OString& rBuf, short n)
     807                 :            : {
     808         [ #  # ]:          0 :     if( !nChan )
     809                 :          0 :         ReadCon( rBuf );
     810         [ #  # ]:          0 :     else if( !pChan[ nChan ] )
     811                 :          0 :         nError = SbERR_BAD_CHANNEL;
     812                 :            :     else
     813                 :          0 :         nError = pChan[ nChan ]->Read( rBuf, n );
     814                 :          0 : }
     815                 :            : 
     816                 :          0 : char SbiIoSystem::Read()
     817                 :            : {
     818                 :          0 :     char ch = ' ';
     819         [ #  # ]:          0 :     if( !nChan )
     820                 :            :     {
     821         [ #  # ]:          0 :         if( aIn.isEmpty() )
     822                 :            :         {
     823         [ #  # ]:          0 :             ReadCon( aIn );
     824                 :          0 :             aIn = aIn + rtl::OString('\n');
     825                 :            :         }
     826                 :          0 :         ch = aIn[0];
     827                 :          0 :         aIn = aIn.copy(1);
     828                 :            :     }
     829         [ #  # ]:          0 :     else if( !pChan[ nChan ] )
     830                 :          0 :         nError = SbERR_BAD_CHANNEL;
     831                 :            :     else
     832         [ #  # ]:          0 :         nError = pChan[ nChan ]->Read( ch );
     833                 :          0 :     return ch;
     834                 :            : }
     835                 :            : 
     836                 :        366 : void SbiIoSystem::Write(const rtl::OString& rBuf, short n)
     837                 :            : {
     838         [ -  + ]:        366 :     if( !nChan )
     839                 :          0 :         WriteCon( rBuf );
     840         [ -  + ]:        366 :     else if( !pChan[ nChan ] )
     841                 :          0 :         nError = SbERR_BAD_CHANNEL;
     842                 :            :     else
     843                 :        366 :         nError = pChan[ nChan ]->Write( rBuf, n );
     844                 :        366 : }
     845                 :            : 
     846                 :            : // nChannel == 0..CHANNELS-1
     847                 :            : 
     848                 :         66 : SbiStream* SbiIoSystem::GetStream( short nChannel ) const
     849                 :            : {
     850                 :         66 :     SbiStream* pRet = 0;
     851 [ +  - ][ +  - ]:         66 :     if( nChannel >= 0 && nChannel < CHANNELS )
     852                 :         66 :         pRet = pChan[ nChannel ];
     853                 :         66 :     return pRet;
     854                 :            : }
     855                 :            : 
     856                 :          0 : void SbiIoSystem::CloseAll(void)
     857                 :            : {
     858         [ #  # ]:          0 :     for( short i = 1; i < CHANNELS; i++ )
     859                 :            :     {
     860         [ #  # ]:          0 :         if( pChan[ i ] )
     861                 :            :         {
     862                 :          0 :             SbError n = pChan[ i ]->Close();
     863         [ #  # ]:          0 :             delete pChan[ i ];
     864                 :          0 :             pChan[ i ] = NULL;
     865 [ #  # ][ #  # ]:          0 :             if( n && !nError )
     866                 :          0 :                 nError = n;
     867                 :            :         }
     868                 :            :     }
     869                 :          0 : }
     870                 :            : 
     871                 :            : /***************************************************************************
     872                 :            : *
     873                 :            : *   Console Support
     874                 :            : *
     875                 :            : ***************************************************************************/
     876                 :            : 
     877                 :            : 
     878                 :          0 : void SbiIoSystem::ReadCon(rtl::OString& rIn)
     879                 :            : {
     880 [ #  # ][ #  # ]:          0 :     rtl::OUString aPromptStr(rtl::OStringToOUString(aPrompt, osl_getThreadTextEncoding()));
     881 [ #  # ][ #  # ]:          0 :     SbiInputDialog aDlg( NULL, aPromptStr );
                 [ #  # ]
     882 [ #  # ][ #  # ]:          0 :     if( aDlg.Execute() )
     883 [ #  # ][ #  # ]:          0 :         rIn = rtl::OUStringToOString(aDlg.GetInput(), osl_getThreadTextEncoding());
                 [ #  # ]
     884                 :            :     else
     885                 :          0 :         nError = SbERR_USER_ABORT;
     886         [ #  # ]:          0 :     aPrompt = rtl::OString();
     887                 :          0 : }
     888                 :            : 
     889                 :            : // output of a MessageBox, if theres a CR in the console-buffer
     890                 :            : 
     891                 :          0 : void SbiIoSystem::WriteCon(const rtl::OString& rText)
     892                 :            : {
     893                 :          0 :     aOut += rText;
     894                 :          0 :     sal_Int32 n1 = aOut.indexOf('\n');
     895                 :          0 :     sal_Int32 n2 = aOut.indexOf('\r');
     896 [ #  # ][ #  # ]:          0 :     if( n1 != -1 || n2 != -1 )
     897                 :            :     {
     898         [ #  # ]:          0 :         if( n1 == -1 )
     899                 :          0 :             n1 = n2;
     900         [ #  # ]:          0 :         else if( n2 == -1 )
     901                 :          0 :             n2 = n1;
     902         [ #  # ]:          0 :         if( n1 > n2 )
     903                 :          0 :             n1 = n2;
     904                 :          0 :         rtl::OString s(aOut.copy(0, n1));
     905                 :          0 :         aOut = aOut.copy(n1);
     906 [ #  # ][ #  # ]:          0 :         while (aOut[0] == '\n' || aOut[0] == '\r')
                 [ #  # ]
     907                 :          0 :             aOut = aOut.copy(1);
     908 [ #  # ][ #  # ]:          0 :         String aStr(rtl::OStringToOUString(s, osl_getThreadTextEncoding()));
                 [ #  # ]
     909                 :            :         {
     910         [ #  # ]:          0 :             SolarMutexGuard aSolarGuard;
     911 [ #  # ][ #  # ]:          0 :             if( !MessBox( GetpApp()->GetDefDialogParent(),
                 [ #  # ]
     912                 :            :                         WinBits( WB_OK_CANCEL | WB_DEF_OK ),
     913 [ #  # ][ #  # ]:          0 :                         String(), aStr ).Execute() )
         [ #  # ][ #  # ]
                 [ #  # ]
     914         [ #  # ]:          0 :                 nError = SbERR_USER_ABORT;
     915         [ #  # ]:          0 :         }
     916                 :            :     }
     917                 :          0 : }
     918                 :            : 
     919                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10