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 "storagetextstream.hxx"
21 :
22 : #include <com/sun/star/io/TextOutputStream.hpp>
23 :
24 : #include <tools/diagnose_ex.h>
25 :
26 : namespace dbaccess
27 : {
28 :
29 : using ::com::sun::star::uno::Reference;
30 : using ::com::sun::star::uno::XInterface;
31 : using ::com::sun::star::uno::UNO_QUERY;
32 : using ::com::sun::star::uno::UNO_QUERY_THROW;
33 : using ::com::sun::star::uno::UNO_SET_THROW;
34 : using ::com::sun::star::uno::Exception;
35 : using ::com::sun::star::uno::RuntimeException;
36 : using ::com::sun::star::uno::Any;
37 : using ::com::sun::star::uno::makeAny;
38 : using ::com::sun::star::uno::Sequence;
39 : using ::com::sun::star::uno::Type;
40 : using ::com::sun::star::uno::XComponentContext;
41 : using ::com::sun::star::embed::XStorage;
42 : using ::com::sun::star::io::TextOutputStream;
43 : using ::com::sun::star::io::XTextOutputStream2;
44 : using ::com::sun::star::io::XActiveDataSource;
45 :
46 : // StorageTextOutputStream_Data
47 0 : struct StorageTextOutputStream_Data
48 : {
49 : Reference< XTextOutputStream2 > xTextOutput;
50 : };
51 :
52 : static const char sLineFeed[] = "\n";
53 :
54 : // StorageTextOutputStream
55 0 : StorageTextOutputStream::StorageTextOutputStream( const Reference<XComponentContext>& i_rContext,
56 : const Reference< XStorage >& i_rParentStorage,
57 : const OUString& i_rStreamName
58 : )
59 : :StorageOutputStream( i_rContext, i_rParentStorage, i_rStreamName )
60 0 : ,m_pData( new StorageTextOutputStream_Data )
61 : {
62 0 : m_pData->xTextOutput = TextOutputStream::create( i_rContext );
63 0 : m_pData->xTextOutput->setEncoding( "UTF-8" );
64 0 : m_pData->xTextOutput->setOutputStream( getOutputStream() );
65 0 : }
66 :
67 0 : StorageTextOutputStream::~StorageTextOutputStream()
68 : {
69 0 : }
70 :
71 0 : void StorageTextOutputStream::writeLine( const OUString& i_rLine )
72 : {
73 0 : m_pData->xTextOutput->writeString( i_rLine );
74 0 : m_pData->xTextOutput->writeString( sLineFeed );
75 0 : }
76 :
77 0 : void StorageTextOutputStream::writeLine()
78 : {
79 0 : m_pData->xTextOutput->writeString( sLineFeed );
80 0 : }
81 :
82 : } // namespace dbaccess
83 :
84 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|