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 :
21 : #include "storagetextstream.hxx"
22 :
23 : #include <com/sun/star/io/TextOutputStream.hpp>
24 :
25 : #include <tools/diagnose_ex.h>
26 :
27 : //......................................................................................................................
28 : namespace dbaccess
29 : {
30 : //......................................................................................................................
31 :
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;
48 :
49 : //==================================================================================================================
50 : //= StorageTextOutputStream_Data
51 : //==================================================================================================================
52 0 : struct StorageTextOutputStream_Data
53 : {
54 : Reference< XTextOutputStream2 > xTextOutput;
55 : };
56 :
57 : //==================================================================================================================
58 : //= helper
59 : //==================================================================================================================
60 : namespace
61 : {
62 : //--------------------------------------------------------------------------------------------------------------
63 0 : static const OUString& lcl_getTextStreamEncodingName()
64 : {
65 0 : static const OUString s_sMapStreamEncodingName( "UTF-8" );
66 0 : return s_sMapStreamEncodingName;
67 : }
68 :
69 : //--------------------------------------------------------------------------------------------------------------
70 0 : static const OUString& lcl_getLineFeed()
71 : {
72 0 : static const OUString s_sLineFeed( sal_Unicode( '\n' ) );
73 0 : return s_sLineFeed;
74 : }
75 : }
76 :
77 : //==================================================================================================================
78 : //= StorageTextOutputStream
79 : //==================================================================================================================
80 : //------------------------------------------------------------------------------------------------------------------
81 0 : StorageTextOutputStream::StorageTextOutputStream( const Reference<XComponentContext>& i_rContext,
82 : const Reference< XStorage >& i_rParentStorage,
83 : const OUString& i_rStreamName
84 : )
85 : :StorageOutputStream( i_rContext, i_rParentStorage, i_rStreamName )
86 0 : ,m_pData( new StorageTextOutputStream_Data )
87 : {
88 0 : m_pData->xTextOutput = TextOutputStream::create( i_rContext );
89 0 : m_pData->xTextOutput->setEncoding( lcl_getTextStreamEncodingName() );
90 0 : m_pData->xTextOutput->setOutputStream( getOutputStream() );
91 0 : }
92 :
93 : //------------------------------------------------------------------------------------------------------------------
94 0 : StorageTextOutputStream::~StorageTextOutputStream()
95 : {
96 0 : }
97 :
98 : //------------------------------------------------------------------------------------------------------------------
99 0 : void StorageTextOutputStream::writeLine( const OUString& i_rLine )
100 : {
101 0 : m_pData->xTextOutput->writeString( i_rLine );
102 0 : m_pData->xTextOutput->writeString( lcl_getLineFeed() );
103 0 : }
104 :
105 : //------------------------------------------------------------------------------------------------------------------
106 0 : void StorageTextOutputStream::writeLine()
107 : {
108 0 : m_pData->xTextOutput->writeString( lcl_getLineFeed() );
109 0 : }
110 :
111 : //......................................................................................................................
112 : } // namespace dbaccess
113 : //......................................................................................................................
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|