1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 
25 #ifndef INCLUDED_PDFIMPORT_OUTPUTWRAP_HXX
26 #define INCLUDED_PDFIMPORT_OUTPUTWRAP_HXX
27 
28 #include <cppuhelper/basemutex.hxx>
29 #include <cppuhelper/compbase1.hxx>
30 #include <com/sun/star/io/XOutputStream.hpp>
31 #include <osl/file.hxx>
32 
33 namespace pdfi
34 {
35 
36 typedef ::cppu::WeakComponentImplHelper1<
37         com::sun::star::io::XOutputStream > OutputWrapBase;
38 
39     class OutputWrap : private cppu::BaseMutex, public OutputWrapBase
40     {
41         osl::File maFile;
42 
43     public:
44 
OutputWrap(const rtl::OUString & rURL)45         explicit OutputWrap( const rtl::OUString& rURL ) : OutputWrapBase(m_aMutex), maFile(rURL)
46         {
47             maFile.open(osl_File_OpenFlag_Create|OpenFlag_Write);
48         }
49 
writeBytes(const com::sun::star::uno::Sequence<::sal_Int8> & aData)50 		virtual void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (com::sun::star::io::NotConnectedException,com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
51 
52         {
53             sal_uInt64 nBytesWritten(0);
54             maFile.write(aData.getConstArray(),aData.getLength(),nBytesWritten);
55         }
56 
flush()57         virtual void SAL_CALL flush() throw (com::sun::star::io::NotConnectedException, com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
58         {
59         }
60 
closeOutput()61         virtual void SAL_CALL closeOutput() throw (com::sun::star::io::NotConnectedException, com::sun::star::io::BufferSizeExceededException, com::sun::star::io::IOException, com::sun::star::uno::RuntimeException)
62         {
63             maFile.close();
64         }
65     };
66 }
67 #endif
68 
69