summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorKurt Zenker <kz@openoffice.org>2008-03-06 10:43:43 +0000
committerKurt Zenker <kz@openoffice.org>2008-03-06 10:43:43 +0000
commit3160bc4514539846192afb36041d5c274234ea31 (patch)
treef26f76aa7b84782c3ab8e1ff5dd6bc420b619c62 /toolkit
parentc2e7390bf647d181cc8006bd81d5e800056a3ca4 (diff)
INTEGRATION: CWS layout_DEV300 (1.1.2); FILE ADDED
2008/02/15 09:56:40 jcn 1.1.2.2: Remove byteseq.cxx c&p from xml_byteseq.cxx. 2008/02/08 18:44:43 jcn 1.1.2.1: Initial toolkit import from ee9a2fcc29d7e2f01cc80ef7c13bf7bc7d55ae7e. layout/source/awt -> toolkit/source/awt layout/source/core -> toolkit/source/layout layout/source/wrapper -> toolkit/source/vclcompat layout/inc/layout -> toolkit/inc/layout layout/source/inc -> toolkit/inc/layout layout/workben -> toolkit/workben/layout That's ooo-build trunk r11539 @ ooh680-m5/src680-m245.
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/layout/byteseq.cxx75
1 files changed, 75 insertions, 0 deletions
diff --git a/toolkit/source/layout/byteseq.cxx b/toolkit/source/layout/byteseq.cxx
new file mode 100644
index 000000000000..faa9859c636d
--- /dev/null
+++ b/toolkit/source/layout/byteseq.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: byteseq.cxx,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * last change: $Author: kz $ $Date: 2008-03-06 11:43:43 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+/* We do not link to xmlscript, because that would introduce an extra
+ toolkit dependency. */
+#include <xml_helper/xml_byteseq.cxx>
+
+#include <stdio.h>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+namespace layoutimpl
+{
+
+uno::Reference< io::XInputStream >
+getFileAsStream( const uno::Reference< lang::XMultiServiceFactory > &xFactory,
+ const rtl::OUString &rName );
+
+uno::Reference< io::XInputStream >
+getFileAsStream( const uno::Reference< lang::XMultiServiceFactory > & /* xFactory */,
+ const rtl::OUString &rName )
+{
+ rtl::OString fname = rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 );
+ // create the input stream
+ FILE *f = ::fopen( fname, "rb" );
+ if (f)
+ {
+ ::fseek( f, 0 ,SEEK_END );
+ int nLength = ::ftell( f );
+ ::fseek( f, 0, SEEK_SET );
+
+ ByteSequence bytes( nLength );
+ ::fread( bytes.getArray(), nLength, 1, f );
+ ::fclose( f );
+
+ return new xmlscript::BSeqInputStream( bytes );
+ }
+
+ throw Exception( OUString( RTL_CONSTASCII_USTRINGPARAM("### Cannot read file!") ),
+ Reference< XInterface >() );
+}
+
+} // namespace layoutimpl