1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "storagetextstream.hxx"
23 #include <com/sun/star/io/TextOutputStream.hpp>
25 #include <tools/diagnose_ex.h>
27 //......................................................................................................................
30 //......................................................................................................................
32 using ::com::sun::star::uno::Reference
;
33 using ::com::sun::star::uno::XInterface
;
34 using ::com::sun::star::uno::UNO_QUERY
;
35 using ::com::sun::star::uno::UNO_QUERY_THROW
;
36 using ::com::sun::star::uno::UNO_SET_THROW
;
37 using ::com::sun::star::uno::Exception
;
38 using ::com::sun::star::uno::RuntimeException
;
39 using ::com::sun::star::uno::Any
;
40 using ::com::sun::star::uno::makeAny
;
41 using ::com::sun::star::uno::Sequence
;
42 using ::com::sun::star::uno::Type
;
43 using ::com::sun::star::uno::XComponentContext
;
44 using ::com::sun::star::embed::XStorage
;
45 using ::com::sun::star::io::TextOutputStream
;
46 using ::com::sun::star::io::XTextOutputStream2
;
47 using ::com::sun::star::io::XActiveDataSource
;
49 //==================================================================================================================
50 //= StorageTextOutputStream_Data
51 //==================================================================================================================
52 struct StorageTextOutputStream_Data
54 Reference
< XTextOutputStream2
> xTextOutput
;
57 //==================================================================================================================
59 //==================================================================================================================
62 //--------------------------------------------------------------------------------------------------------------
63 static const OUString
& lcl_getTextStreamEncodingName()
65 static const OUString
s_sMapStreamEncodingName( "UTF-8" );
66 return s_sMapStreamEncodingName
;
69 //--------------------------------------------------------------------------------------------------------------
70 static const OUString
& lcl_getLineFeed()
72 static const OUString
s_sLineFeed( sal_Unicode( '\n' ) );
77 //==================================================================================================================
78 //= StorageTextOutputStream
79 //==================================================================================================================
80 //------------------------------------------------------------------------------------------------------------------
81 StorageTextOutputStream::StorageTextOutputStream( const Reference
<XComponentContext
>& i_rContext
,
82 const Reference
< XStorage
>& i_rParentStorage
,
83 const OUString
& i_rStreamName
85 :StorageOutputStream( i_rContext
, i_rParentStorage
, i_rStreamName
)
86 ,m_pData( new StorageTextOutputStream_Data
)
88 m_pData
->xTextOutput
= TextOutputStream::create( i_rContext
);
89 m_pData
->xTextOutput
->setEncoding( lcl_getTextStreamEncodingName() );
90 m_pData
->xTextOutput
->setOutputStream( getOutputStream() );
93 //------------------------------------------------------------------------------------------------------------------
94 StorageTextOutputStream::~StorageTextOutputStream()
98 //------------------------------------------------------------------------------------------------------------------
99 void StorageTextOutputStream::writeLine( const OUString
& i_rLine
)
101 m_pData
->xTextOutput
->writeString( i_rLine
);
102 m_pData
->xTextOutput
->writeString( lcl_getLineFeed() );
105 //------------------------------------------------------------------------------------------------------------------
106 void StorageTextOutputStream::writeLine()
108 m_pData
->xTextOutput
->writeString( lcl_getLineFeed() );
111 //......................................................................................................................
112 } // namespace dbaccess
113 //......................................................................................................................
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */