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 : // helper
53 : namespace
54 : {
55 0 : static const OUString& lcl_getTextStreamEncodingName()
56 : {
57 0 : static const OUString s_sMapStreamEncodingName( "UTF-8" );
58 0 : return s_sMapStreamEncodingName;
59 : }
60 :
61 0 : static const OUString& lcl_getLineFeed()
62 : {
63 0 : static const OUString s_sLineFeed( '\n' );
64 0 : return s_sLineFeed;
65 : }
66 : }
67 :
68 : // StorageTextOutputStream
69 0 : StorageTextOutputStream::StorageTextOutputStream( const Reference<XComponentContext>& i_rContext,
70 : const Reference< XStorage >& i_rParentStorage,
71 : const OUString& i_rStreamName
72 : )
73 : :StorageOutputStream( i_rContext, i_rParentStorage, i_rStreamName )
74 0 : ,m_pData( new StorageTextOutputStream_Data )
75 : {
76 0 : m_pData->xTextOutput = TextOutputStream::create( i_rContext );
77 0 : m_pData->xTextOutput->setEncoding( lcl_getTextStreamEncodingName() );
78 0 : m_pData->xTextOutput->setOutputStream( getOutputStream() );
79 0 : }
80 :
81 0 : StorageTextOutputStream::~StorageTextOutputStream()
82 : {
83 0 : }
84 :
85 0 : void StorageTextOutputStream::writeLine( const OUString& i_rLine )
86 : {
87 0 : m_pData->xTextOutput->writeString( i_rLine );
88 0 : m_pData->xTextOutput->writeString( lcl_getLineFeed() );
89 0 : }
90 :
91 0 : void StorageTextOutputStream::writeLine()
92 : {
93 0 : m_pData->xTextOutput->writeString( lcl_getLineFeed() );
94 0 : }
95 :
96 : } // namespace dbaccess
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|