summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-01-30 16:05:28 +0200
committerNoel Grandin <noel@peralex.com>2013-02-11 08:02:15 +0200
commitfbd4588afd596b96f988350174ad55e66db6d830 (patch)
treedebbe093822d476efa99de1447aa5000aaeb9076 /scripting
parentff85e8319a263e428ce53f7758092475b953afba (diff)
fdo#46808, convert io::TextOutputStream service to new-style
Change-Id: I12af47afc21c2b646197893a77698f4e0818f94f
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/stringresource/stringresource.cxx122
1 files changed, 57 insertions, 65 deletions
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index 311df0013fce..8b0db02c5089 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -20,7 +20,7 @@
#include "stringresource.hxx"
#include <com/sun/star/io/TempFile.hpp>
#include <com/sun/star/io/TextInputStream.hpp>
-#include <com/sun/star/io/XTextOutputStream.hpp>
+#include <com/sun/star/io/TextOutputStream.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/io/XStream.hpp>
@@ -2175,7 +2175,7 @@ void implWriteCharToBuffer( ::rtl::OUStringBuffer& aBuf, sal_Unicode cu, bool bK
}
void implWriteStringWithEncoding( const ::rtl::OUString& aStr,
- Reference< io::XTextOutputStream > xTextOutputStream, bool bKey )
+ Reference< io::XTextOutputStream2 > xTextOutputStream, bool bKey )
{
static sal_Unicode cLineFeed = 0xa;
@@ -2208,79 +2208,71 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale
return false;
bool bSuccess = false;
- Reference< XMultiComponentFactory > xMCF = getMultiComponentFactory();
- Reference< io::XTextOutputStream > xTextOutputStream( xMCF->createInstanceWithContext
- ( ::rtl::OUString("com.sun.star.io.TextOutputStream"), m_xContext ), UNO_QUERY );
+ Reference< io::XTextOutputStream2 > xTextOutputStream = io::TextOutputStream::create(m_xContext);
- if( xTextOutputStream.is() )
- {
- Reference< io::XActiveDataSource> xActiveDataSource( xTextOutputStream, UNO_QUERY );
- if( xActiveDataSource.is() )
- {
- xActiveDataSource->setOutputStream( xOutputStream );
+ xTextOutputStream->setOutputStream( xOutputStream );
- ::rtl::OUString aEncodingStr = ::rtl::OUString::createFromAscii
- ( rtl_getMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
- xTextOutputStream->setEncoding( aEncodingStr );
+ ::rtl::OUString aEncodingStr = ::rtl::OUString::createFromAscii
+ ( rtl_getMimeCharsetFromTextEncoding( RTL_TEXTENCODING_ISO_8859_1 ) );
+ xTextOutputStream->setEncoding( aEncodingStr );
- xTextOutputStream->writeString( aComment );
- xTextOutputStream->writeString( aLineFeedStr );
+ xTextOutputStream->writeString( aComment );
+ xTextOutputStream->writeString( aLineFeedStr );
- const IdToStringMap& rHashMap = pLocaleItem->m_aIdToStringMap;
- if( rHashMap.size() > 0 )
- {
- // Sort ids according to read order
- const IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap;
- IdToIndexMap::const_iterator it_index;
-
- // Find max/min index
- sal_Int32 nMinIndex = -1;
- sal_Int32 nMaxIndex = -1;
- for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index )
- {
- sal_Int32 nIndex = (*it_index).second;
- if( nMinIndex > nIndex || nMinIndex == -1 )
- nMinIndex = nIndex;
- if( nMaxIndex < nIndex )
- nMaxIndex = nIndex;
- }
- sal_Int32 nTabSize = nMaxIndex - nMinIndex + 1;
-
- // Create sorted array of pointers to the id strings
- const ::rtl::OUString** pIdPtrs = new const ::rtl::OUString*[nTabSize];
- sal_Int32 i;
- for( i = 0 ; i < nTabSize ; i++ )
- pIdPtrs[i] = NULL;
- for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index )
- {
- sal_Int32 nIndex = (*it_index).second;
- pIdPtrs[nIndex - nMinIndex] = &((*it_index).first);
- }
+ const IdToStringMap& rHashMap = pLocaleItem->m_aIdToStringMap;
+ if( rHashMap.size() > 0 )
+ {
+ // Sort ids according to read order
+ const IdToIndexMap& rIndexMap = pLocaleItem->m_aIdToIndexMap;
+ IdToIndexMap::const_iterator it_index;
- // Write lines in correct order
- for( i = 0 ; i < nTabSize ; i++ )
+ // Find max/min index
+ sal_Int32 nMinIndex = -1;
+ sal_Int32 nMaxIndex = -1;
+ for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index )
+ {
+ sal_Int32 nIndex = (*it_index).second;
+ if( nMinIndex > nIndex || nMinIndex == -1 )
+ nMinIndex = nIndex;
+ if( nMaxIndex < nIndex )
+ nMaxIndex = nIndex;
+ }
+ sal_Int32 nTabSize = nMaxIndex - nMinIndex + 1;
+
+ // Create sorted array of pointers to the id strings
+ const ::rtl::OUString** pIdPtrs = new const ::rtl::OUString*[nTabSize];
+ sal_Int32 i;
+ for( i = 0 ; i < nTabSize ; i++ )
+ pIdPtrs[i] = NULL;
+ for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index )
+ {
+ sal_Int32 nIndex = (*it_index).second;
+ pIdPtrs[nIndex - nMinIndex] = &((*it_index).first);
+ }
+
+ // Write lines in correct order
+ for( i = 0 ; i < nTabSize ; i++ )
+ {
+ const ::rtl::OUString* pStr = pIdPtrs[i];
+ if( pStr != NULL )
+ {
+ ::rtl::OUString aResourceID = *pStr;
+ IdToStringMap::const_iterator it = rHashMap.find( aResourceID );
+ if( !( it == rHashMap.end() ) )
{
- const ::rtl::OUString* pStr = pIdPtrs[i];
- if( pStr != NULL )
- {
- ::rtl::OUString aResourceID = *pStr;
- IdToStringMap::const_iterator it = rHashMap.find( aResourceID );
- if( !( it == rHashMap.end() ) )
- {
- implWriteStringWithEncoding( aResourceID, xTextOutputStream, true );
- xTextOutputStream->writeString( aAssignmentStr );
- ::rtl::OUString aValStr = (*it).second;
- implWriteStringWithEncoding( aValStr, xTextOutputStream, false );
- }
- }
+ implWriteStringWithEncoding( aResourceID, xTextOutputStream, true );
+ xTextOutputStream->writeString( aAssignmentStr );
+ ::rtl::OUString aValStr = (*it).second;
+ implWriteStringWithEncoding( aValStr, xTextOutputStream, false );
}
-
- delete pIdPtrs;
}
-
- bSuccess = true;
}
+
+ delete pIdPtrs;
}
+
+ bSuccess = true;
+
return bSuccess;
}