summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-01-30 14:46:50 +0200
committerNoel Grandin <noel@peralex.com>2013-02-11 08:02:15 +0200
commitff85e8319a263e428ce53f7758092475b953afba (patch)
tree61d407de6a6bd00b352da51c013e3351237b95ee /scripting
parenta7ecab870eb5567bceb3ef61d87d8db805bc6796 (diff)
fdo#46808, convert io::TextInputStream service to new style
Change-Id: Ida4abdd6587399aa8ade88af672bcb23ab7ea0f1
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/stringresource/stringresource.cxx201
1 files changed, 96 insertions, 105 deletions
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index 1b30c81bacd7..311df0013fce 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -19,7 +19,7 @@
#include "stringresource.hxx"
#include <com/sun/star/io/TempFile.hpp>
-#include <com/sun/star/io/XTextInputStream.hpp>
+#include <com/sun/star/io/TextInputStream.hpp>
#include <com/sun/star/io/XTextOutputStream.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
@@ -1969,7 +1969,7 @@ sal_Unicode getEscapeChar( const sal_Unicode* pBuf, sal_Int32 nLen, sal_Int32& r
return cRet;
}
-void CheckContinueInNextLine( Reference< io::XTextInputStream > xTextInputStream,
+void CheckContinueInNextLine( Reference< io::XTextInputStream2 > xTextInputStream,
::rtl::OUString& aLine, bool& bEscapePending, const sal_Unicode*& pBuf,
sal_Int32& nLen, sal_Int32& i )
{
@@ -1996,127 +1996,118 @@ bool StringResourcePersistenceImpl::implReadPropertiesFile
return false;
bool bSuccess = false;
- Reference< XMultiComponentFactory > xMCF = getMultiComponentFactory();
- Reference< io::XTextInputStream > xTextInputStream( xMCF->createInstanceWithContext
- ( ::rtl::OUString("com.sun.star.io.TextInputStream"), m_xContext ), UNO_QUERY );
+ Reference< io::XTextInputStream2 > xTextInputStream = io::TextInputStream::create( m_xContext );
+
+ bSuccess = true;
+
+ xTextInputStream->setInputStream( xInputStream );
+
+ ::rtl::OUString aEncodingStr = ::rtl::OUString::createFromAscii
+ ( rtl_getMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ xTextInputStream->setEncoding( aEncodingStr );
- if( xTextInputStream.is() )
+ ::rtl::OUString aLine;
+ while( !xTextInputStream->isEOF() )
{
- Reference< io::XActiveDataSink> xActiveDataSink( xTextInputStream, UNO_QUERY );
- if( xActiveDataSink.is() )
- {
- bSuccess = true;
+ aLine = xTextInputStream->readLine();
- xActiveDataSink->setInputStream( xInputStream );
+ sal_Int32 nLen = aLine.getLength();
+ if( 0 == nLen )
+ continue;
+ const sal_Unicode* pBuf = aLine.getStr();
+ ::rtl::OUStringBuffer aBuf;
+ sal_Unicode c = 0;
+ sal_Int32 i = 0;
- ::rtl::OUString aEncodingStr = ::rtl::OUString::createFromAscii
- ( rtl_getMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
- xTextInputStream->setEncoding( aEncodingStr );
+ skipWhites( pBuf, nLen, i );
+ if( i == nLen )
+ continue; // line contains only white spaces
+
+ // Comment?
+ c = pBuf[i];
+ if( c == '#' || c == '!' )
+ continue;
- ::rtl::OUString aLine;
- while( !xTextInputStream->isEOF() )
+ // Scan key
+ ::rtl::OUString aResourceID;
+ bool bEscapePending = false;
+ bool bStrComplete = false;
+ while( i < nLen && !bStrComplete )
+ {
+ c = pBuf[i];
+ if( bEscapePending )
+ {
+ aBuf.append( getEscapeChar( pBuf, nLen, i ) );
+ bEscapePending = false;
+ }
+ else
{
- aLine = xTextInputStream->readLine();
-
- sal_Int32 nLen = aLine.getLength();
- if( 0 == nLen )
- continue;
- const sal_Unicode* pBuf = aLine.getStr();
- ::rtl::OUStringBuffer aBuf;
- sal_Unicode c = 0;
- sal_Int32 i = 0;
-
- skipWhites( pBuf, nLen, i );
- if( i == nLen )
- continue; // line contains only white spaces
-
- // Comment?
- c = pBuf[i];
- if( c == '#' || c == '!' )
- continue;
-
- // Scan key
- ::rtl::OUString aResourceID;
- bool bEscapePending = false;
- bool bStrComplete = false;
- while( i < nLen && !bStrComplete )
+ if( c == '\\' )
{
- c = pBuf[i];
- if( bEscapePending )
- {
- aBuf.append( getEscapeChar( pBuf, nLen, i ) );
- bEscapePending = false;
- }
- else
- {
- if( c == '\\' )
- {
- bEscapePending = true;
- }
- else
- {
- if( c == ':' || c == '=' || isWhiteSpace( c ) )
- bStrComplete = true;
- else
- aBuf.append( c );
- }
- }
- i++;
-
- CheckContinueInNextLine( xTextInputStream, aLine, bEscapePending, pBuf, nLen, i );
- if( i == nLen )
+ bEscapePending = true;
+ }
+ else
+ {
+ if( c == ':' || c == '=' || isWhiteSpace( c ) )
bStrComplete = true;
-
- if( bStrComplete )
- aResourceID = aBuf.makeStringAndClear();
+ else
+ aBuf.append( c );
}
+ }
+ i++;
- // Ignore lines with empty keys
- if( aResourceID.isEmpty() )
- continue;
+ CheckContinueInNextLine( xTextInputStream, aLine, bEscapePending, pBuf, nLen, i );
+ if( i == nLen )
+ bStrComplete = true;
- // Scan value
- skipWhites( pBuf, nLen, i );
+ if( bStrComplete )
+ aResourceID = aBuf.makeStringAndClear();
+ }
- ::rtl::OUString aValueStr;
- bEscapePending = false;
- bStrComplete = false;
- while( i < nLen && !bStrComplete )
- {
- c = pBuf[i];
- if( c == 0x000a || c == 0x000d ) // line feed/carriage return, not always handled by TextInputStream
- {
- i++;
- }
- else
- {
- if( bEscapePending )
- {
- aBuf.append( getEscapeChar( pBuf, nLen, i ) );
- bEscapePending = false;
- }
- else if( c == '\\' )
- bEscapePending = true;
- else
- aBuf.append( c );
- i++;
+ // Ignore lines with empty keys
+ if( aResourceID.isEmpty() )
+ continue;
- CheckContinueInNextLine( xTextInputStream, aLine, bEscapePending, pBuf, nLen, i );
- }
- if( i == nLen )
- bStrComplete = true;
+ // Scan value
+ skipWhites( pBuf, nLen, i );
- if( bStrComplete )
- aValueStr = aBuf.makeStringAndClear();
+ ::rtl::OUString aValueStr;
+ bEscapePending = false;
+ bStrComplete = false;
+ while( i < nLen && !bStrComplete )
+ {
+ c = pBuf[i];
+ if( c == 0x000a || c == 0x000d ) // line feed/carriage return, not always handled by TextInputStream
+ {
+ i++;
+ }
+ else
+ {
+ if( bEscapePending )
+ {
+ aBuf.append( getEscapeChar( pBuf, nLen, i ) );
+ bEscapePending = false;
}
+ else if( c == '\\' )
+ bEscapePending = true;
+ else
+ aBuf.append( c );
+ i++;
- // Push into table
- pLocaleItem->m_aIdToStringMap[ aResourceID ] = aValueStr;
- implScanIdForNumber( aResourceID );
- IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap;
- rIndexMap[ aResourceID ] = pLocaleItem->m_nNextIndex++;
+ CheckContinueInNextLine( xTextInputStream, aLine, bEscapePending, pBuf, nLen, i );
}
+ if( i == nLen )
+ bStrComplete = true;
+
+ if( bStrComplete )
+ aValueStr = aBuf.makeStringAndClear();
}
+
+ // Push into table
+ pLocaleItem->m_aIdToStringMap[ aResourceID ] = aValueStr;
+ implScanIdForNumber( aResourceID );
+ IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap;
+ rIndexMap[ aResourceID ] = pLocaleItem->m_nNextIndex++;
}
return bSuccess;