summaryrefslogtreecommitdiff
path: root/oox/source/helper
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2009-07-15 14:57:49 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2009-07-15 14:57:49 +0000
commit0851da4d8a0a557f1e9a31af652a530c615c2989 (patch)
tree4c630979f4764c52e84314e9bb16d22416a447b2 /oox/source/helper
parente49ca2777ba38f75b24a49d30f59c2f0d2be79e6 (diff)
CWS-TOOLING: integrate CWS dr68
2009-06-19 17:43:48 +0200 oc r273175 : #i102946# some lines for new dialog added 2009-06-19 14:17:45 +0200 oc r273158 : #i102946# three lines added 2009-05-19 11:56:14 +0200 dr r272065 : #i99677# wrong attribute name 2009-05-18 18:37:05 +0200 dr r272045 : #i10000# suncc warning 2009-05-05 16:46:13 +0200 dr r271536 : #i10000# adoptions after rebase to master containing dr67 2009-05-05 16:01:19 +0200 dr r271530 : #i10000# adoptions after rebase to master containing dr67 2009-05-04 14:20:39 +0200 dr r271453 : CWS-TOOLING: rebase CWS dr68 to trunk@271427 (milestone: DEV300:m47) 2009-04-28 17:01:14 +0200 dr r271332 : CWS-TOOLING: rebase CWS dr68 to trunk@270723 (milestone: DEV300:m46) 2009-04-23 12:21:40 +0200 dr r271149 : #i100688# missing checkins 2009-04-23 12:18:16 +0200 dr r271147 : #i100978# relations path handling 2009-04-22 19:25:45 +0200 nn r271136 : #i49491# show navigator for double click on document position status bar control 2009-04-22 11:28:36 +0200 nn r271085 : #i60401# small text change 2009-04-21 16:53:23 +0200 dr r271044 : #i10000# missing dtor 2009-04-20 13:39:25 +0200 nn r270977 : #i60401# add dialog to extend sort range (patch from maoyg) 2009-04-08 12:11:08 +0200 dr r270630 : #i100943# prevent assertion when loading chart with empty category ranges 2009-04-07 19:03:00 +0200 dr r270609 : #i100688# missing bits for OLE 2009-04-07 17:14:06 +0200 dr r270605 : ported fix for #i100710# 2009-04-07 17:12:50 +0200 dr r270604 : #i10000# wae 2009-04-07 15:31:55 +0200 dr r270598 : import system colors moved to FilterBase class, more rework on fill and color contexts 2009-04-06 15:00:03 +0200 dr r270552 : #i99677# prevent recursive loading of the current document 2009-04-03 18:28:42 +0200 dr r270515 : added import of brightness/contrast and mono/grayscale color effects for image shapes 2009-04-03 17:36:03 +0200 dr r270509 : cache already imported embedded graphics 2009-04-03 16:46:34 +0200 dr r270500 : more rework on bitmap fill and graphic object handling 2009-03-31 12:28:10 +0200 dr r270271 : #i10000# unxlngi6 wae 2009-03-31 09:04:10 +0200 dr r270261 : CWS-TOOLING: rebase CWS dr68 to trunk@270033 (milestone: DEV300:m45) 2009-03-30 17:42:05 +0200 dr r270249 : #i91122# add missing doc 2009-03-30 17:37:08 +0200 dr r270248 : #i91122# add missing doc 2009-03-30 16:59:15 +0200 dr r270241 : #i99677# add import of ActiveX scrollbar controls 2009-03-30 14:30:36 +0200 dr r270230 : #i91122# missing/wrong documentation 2009-03-30 13:03:38 +0200 dr r270220 : #i99677# add import of ActiveX combobox and spinbutton controls 2009-03-27 11:46:59 +0100 dr r270144 : #i99677# import ActiveX listbox controls (Forms.ListBox.1) 2009-03-26 19:58:00 +0100 dr r270104 : #i99677# move more OLE import code into ole submodule 2009-03-26 15:15:02 +0100 dr r270082 : #i100546# add import of chart bitmap fills, add import of X/Y offset in tiled bitmap fills of all shapes 2009-03-25 12:54:59 +0100 dr r270018 : #i99677# import ActiveX edit text control (Forms.TextBox.1) 2009-03-24 10:59:29 +0100 dr r269921 : #i99677# moved import of OLE StdHlink to 'ole' submodule, added string import helpers to BinaryStreamBase class, removed implementation of ST_XString import from docprop in favour of the implementation in class AttributeList 2009-03-24 10:40:18 +0100 dr r269919 : #i100502# implicit precedence of '&&' was intended 2009-03-24 10:18:29 +0100 dr r269917 : #i100502# missing parentheses 2009-03-23 15:17:48 +0100 dr r269876 : #i99677# more code reorg, added graphic helper and OLE helper object per filter, added OLE/control import to PPTX/XLSX filter, moved helpers from XmlFilterBase to FilterBase 2009-03-19 12:45:20 +0100 dr r269740 : #i99677# interface changes in oox 2009-03-18 15:51:50 +0100 dr r269683 : #i99677# improved relation handling (internal/external), added preprocessor for VML streams to eat MS specific instructions, added OCX ToggleButton/OptionButton import, added DIB import for BIFF (page background picture, lots of other minor improvements 2009-03-16 15:25:30 +0100 dr r269551 : #i99677# import excel form control client data (printable, cell link) 2009-03-13 18:37:17 +0100 dr r269494 : #i99677# import image controls and check boxes 2009-03-12 15:08:18 +0100 dr r269420 : #i10000# rebase problems 2009-03-12 14:43:09 +0100 dr r269418 : #i10000# rebase problems 2009-03-12 14:42:41 +0100 dr r269417 : #i10000# missing delivered header 2009-03-12 13:57:06 +0100 dr r269405 : #i10000# typos 2009-03-12 12:58:52 +0100 dr r269391 : CWS-TOOLING: rebase CWS dr68 to trunk@269297 (milestone: DEV300:m43) 2009-03-12 11:11:46 +0100 dr r269374 : #i99677# first step to import BIFF8 page background 2009-03-12 10:21:53 +0100 dr r269364 : #i99677# rework of graphic import in entire filter, added import of AX Label controls 2009-03-09 16:44:50 +0100 dr r269202 : #i99677# import some formatting attributes of command buttons 2009-03-05 15:31:46 +0100 dr r268911 : #i99677# use VML shape client data to import excel VML shape positions 2009-03-05 11:39:48 +0100 dr r268888 : #i99677# create UNO control shapes from VML control shapes 2009-03-05 11:38:59 +0100 dr r268886 : #i99677# change attribute Shapes to DrawPage for import of embedded form controls 2009-03-05 11:30:40 +0100 dr r268885 : #i99677# change attribute Shapes to DrawPage for import of embedded form controls 2009-03-04 18:46:05 +0100 dr r268860 : adapt namespace ids according to oox 2009-03-04 18:43:49 +0100 dr r268859 : #i99677# more VML import rework 2009-03-03 13:38:36 +0100 dr r268721 : #i99677# more cleanup for VML filter 2009-03-03 13:13:15 +0100 dr r268719 : #i99807# do not iterate beyond end of std::list 2009-03-02 11:55:49 +0100 dr r268644 : add ST_XString support (encoded characters in attribute values) 2009-02-26 17:07:18 +0100 dr r268542 : #i99677# first steps of ax control import: dummy AX base classes, reimplement VML import (hopefully without breaking anything), register embedded AX controls at VML drawing 2009-02-23 17:43:50 +0100 dr r268365 : #i99426# remaining work on scenario import 2009-02-19 16:56:25 +0100 dr r268295 : #i99426# base implementations for scenarios import
Diffstat (limited to 'oox/source/helper')
-rw-r--r--oox/source/helper/attributelist.cxx153
-rw-r--r--oox/source/helper/binaryinputstream.cxx67
-rw-r--r--oox/source/helper/binaryoutputstream.cxx4
-rw-r--r--oox/source/helper/graphichelper.cxx123
-rw-r--r--oox/source/helper/makefile.mk2
-rw-r--r--oox/source/helper/modelobjecthelper.cxx94
-rw-r--r--oox/source/helper/recordinputstream.cxx2
-rw-r--r--oox/source/helper/storagebase.cxx8
8 files changed, 427 insertions, 26 deletions
diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx
index 708ecd82c533..61fb47aab9ca 100644
--- a/oox/source/helper/attributelist.cxx
+++ b/oox/source/helper/attributelist.cxx
@@ -30,8 +30,10 @@
#include "oox/helper/attributelist.hxx"
#include <osl/diagnose.h>
+#include <rtl/ustrbuf.hxx>
using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::util::DateTime;
@@ -41,6 +43,40 @@ namespace oox {
// ============================================================================
+namespace {
+
+const sal_Int32 XSTRING_ENCCHAR_LEN = 7;
+
+bool lclAddHexDigit( sal_Unicode& orcChar, sal_Unicode cDigit, int nBitShift )
+{
+ if( ('0' <= cDigit) && (cDigit <= '9') ) { orcChar |= ((cDigit - '0') << nBitShift); return true; }
+ if( ('a' <= cDigit) && (cDigit <= 'f') ) { orcChar |= ((cDigit - 'a' + 10) << nBitShift); return true; }
+ if( ('A' <= cDigit) && (cDigit <= 'F') ) { orcChar |= ((cDigit - 'A' + 10) << nBitShift); return true; }
+ return false;
+}
+
+sal_Unicode lclGetXChar( const sal_Unicode*& rpcStr, const sal_Unicode* pcEnd )
+{
+ sal_Unicode cChar = 0;
+ if( (pcEnd - rpcStr >= XSTRING_ENCCHAR_LEN) &&
+ (rpcStr[ 0 ] == '_') &&
+ (rpcStr[ 1 ] == 'x') &&
+ (rpcStr[ 6 ] == '_') &&
+ lclAddHexDigit( cChar, rpcStr[ 2 ], 12 ) &&
+ lclAddHexDigit( cChar, rpcStr[ 3 ], 8 ) &&
+ lclAddHexDigit( cChar, rpcStr[ 4 ], 4 ) &&
+ lclAddHexDigit( cChar, rpcStr[ 5 ], 0 ) )
+ {
+ rpcStr += XSTRING_ENCCHAR_LEN;
+ return cChar;
+ }
+ return *rpcStr++;
+}
+
+} // namespace
+
+// ============================================================================
+
AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) :
mxAttribs( rxAttribs )
{
@@ -52,6 +88,56 @@ bool AttributeList::hasAttribute( sal_Int32 nElement ) const
return mxAttribs->hasAttribute( nElement );
}
+// static string conversion -----------------------------------------------
+
+OUString AttributeList::decodeXString( const OUString& rValue )
+{
+ // string shorter than one encoded character - no need to decode
+ if( rValue.getLength() < XSTRING_ENCCHAR_LEN )
+ return rValue;
+ OUStringBuffer aBuffer;
+ const sal_Unicode* pcStr = rValue.getStr();
+ const sal_Unicode* pcEnd = pcStr + rValue.getLength();
+ while( pcStr < pcEnd )
+ aBuffer.append( lclGetXChar( pcStr, pcEnd ) );
+ return aBuffer.makeStringAndClear();
+}
+
+double AttributeList::decodeDouble( const OUString& rValue )
+{
+ return rValue.toDouble();
+}
+
+sal_Int32 AttributeList::decodeInteger( const OUString& rValue )
+{
+ return rValue.toInt32();
+}
+
+sal_uInt32 AttributeList::decodeUnsigned( const OUString& rValue )
+{
+ return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64(), 0, SAL_MAX_UINT32 );
+}
+
+sal_Int64 AttributeList::decodeHyper( const OUString& rValue )
+{
+ return rValue.toInt64();
+}
+
+sal_Int32 AttributeList::decodeIntegerHex( const OUString& rValue )
+{
+ return rValue.toInt32( 16 );
+}
+
+sal_uInt32 AttributeList::decodeUnsignedHex( const OUString& rValue )
+{
+ return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64( 16 ), 0, SAL_MAX_UINT32 );
+}
+
+sal_Int64 AttributeList::decodeHyperHex( const OUString& rValue )
+{
+ return rValue.toInt64( 16 );
+}
+
// optional return values -----------------------------------------------------
OptValue< sal_Int32 > AttributeList::getToken( sal_Int32 nElement ) const
@@ -65,49 +151,69 @@ OptValue< OUString > AttributeList::getString( sal_Int32 nElement ) const
return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), mxAttribs->getOptionalValue( nElement ) );
}
+OptValue< OUString > AttributeList::getXString( sal_Int32 nElement ) const
+{
+ return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), decodeXString( mxAttribs->getOptionalValue( nElement ) ) );
+}
+
OptValue< double > AttributeList::getDouble( sal_Int32 nElement ) const
{
OUString aValue = mxAttribs->getOptionalValue( nElement );
bool bValid = aValue.getLength() > 0;
- return OptValue< double >( bValid, bValid ? aValue.toDouble() : 0.0 );
+ return OptValue< double >( bValid, bValid ? decodeDouble( aValue ) : 0.0 );
}
OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nElement ) const
{
OUString aValue = mxAttribs->getOptionalValue( nElement );
bool bValid = aValue.getLength() > 0;
- return OptValue< sal_Int32 >( bValid, bValid ? aValue.toInt32() : 0 );
+ return OptValue< sal_Int32 >( bValid, bValid ? decodeInteger( aValue ) : 0 );
+}
+
+OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nElement ) const
+{
+ OUString aValue = mxAttribs->getOptionalValue( nElement );
+ bool bValid = aValue.getLength() > 0;
+ return OptValue< sal_uInt32 >( bValid, decodeUnsigned( aValue ) );
+}
+
+OptValue< sal_Int64 > AttributeList::getHyper( sal_Int32 nElement ) const
+{
+ OUString aValue = mxAttribs->getOptionalValue( nElement );
+ bool bValid = aValue.getLength() > 0;
+ return OptValue< sal_Int64 >( bValid, bValid ? decodeHyper( aValue ) : 0 );
}
-OptValue< sal_uInt32 > AttributeList::getUnsignedInteger( sal_Int32 nElement ) const
+OptValue< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nElement ) const
{
OUString aValue = mxAttribs->getOptionalValue( nElement );
bool bValid = aValue.getLength() > 0;
- sal_Int64 nValue = bValid ? aValue.toInt64() : 0;
- return OptValue< sal_uInt32 >( bValid, static_cast< sal_uInt32 >( ((nValue < 0) || (nValue > SAL_MAX_UINT32)) ? 0 : nValue ) );
+ return OptValue< sal_Int32 >( bValid, bValid ? decodeIntegerHex( aValue ) : 0 );
}
-OptValue< sal_Int64 > AttributeList::getInteger64( sal_Int32 nElement ) const
+OptValue< sal_uInt32 > AttributeList::getUnsignedHex( sal_Int32 nElement ) const
{
OUString aValue = mxAttribs->getOptionalValue( nElement );
bool bValid = aValue.getLength() > 0;
- return OptValue< sal_Int64 >( bValid, bValid ? aValue.toInt64() : 0 );
+ return OptValue< sal_uInt32 >( bValid, bValid ? decodeUnsignedHex( aValue ) : 0 );
}
-OptValue< sal_Int32 > AttributeList::getHex( sal_Int32 nElement ) const
+OptValue< sal_Int64 > AttributeList::getHyperHex( sal_Int32 nElement ) const
{
OUString aValue = mxAttribs->getOptionalValue( nElement );
bool bValid = aValue.getLength() > 0;
- return OptValue< sal_Int32 >( bValid, bValid ? aValue.toInt32( 16 ) : 0 );
+ return OptValue< sal_Int64 >( bValid, bValid ? decodeHyperHex( aValue ) : 0 );
}
OptValue< bool > AttributeList::getBool( sal_Int32 nElement ) const
{
- // boolean attributes may be "true", "false", "on", "off", "1", or "0"
+ // boolean attributes may be "t", "f", "true", "false", "on", "off", "1", or "0"
switch( getToken( nElement, -1 ) )
{
+ case XML_t: return OptValue< bool >( true, true ); // used in VML
case XML_true: return OptValue< bool >( true, true );
case XML_on: return OptValue< bool >( true, true );
+ case XML_f: return OptValue< bool >( true, false ); // used in VML
case XML_false: return OptValue< bool >( true, false );
case XML_off: return OptValue< bool >( true, false );
}
@@ -152,6 +258,11 @@ OUString AttributeList::getString( sal_Int32 nElement, const OUString& rDefault
return rDefault;
}
+OUString AttributeList::getXString( sal_Int32 nElement, const OUString& rDefault ) const
+{
+ return getXString( nElement ).get( rDefault );
+}
+
double AttributeList::getDouble( sal_Int32 nElement, double fDefault ) const
{
return getDouble( nElement ).get( fDefault );
@@ -162,19 +273,29 @@ sal_Int32 AttributeList::getInteger( sal_Int32 nElement, sal_Int32 nDefault ) co
return getInteger( nElement ).get( nDefault );
}
-sal_uInt32 AttributeList::getUnsignedInteger( sal_Int32 nElement, sal_uInt32 nDefault ) const
+sal_uInt32 AttributeList::getUnsigned( sal_Int32 nElement, sal_uInt32 nDefault ) const
+{
+ return getUnsigned( nElement ).get( nDefault );
+}
+
+sal_Int64 AttributeList::getHyper( sal_Int32 nElement, sal_Int64 nDefault ) const
+{
+ return getHyper( nElement ).get( nDefault );
+}
+
+sal_Int32 AttributeList::getIntegerHex( sal_Int32 nElement, sal_Int32 nDefault ) const
{
- return getUnsignedInteger( nElement ).get( nDefault );
+ return getIntegerHex( nElement ).get( nDefault );
}
-sal_Int64 AttributeList::getInteger64( sal_Int32 nElement, sal_Int64 nDefault ) const
+sal_uInt32 AttributeList::getUnsignedHex( sal_Int32 nElement, sal_uInt32 nDefault ) const
{
- return getInteger64( nElement ).get( nDefault );
+ return getUnsignedHex( nElement ).get( nDefault );
}
-sal_Int32 AttributeList::getHex( sal_Int32 nElement, sal_Int32 nDefault ) const
+sal_Int64 AttributeList::getHyperHex( sal_Int32 nElement, sal_Int64 nDefault ) const
{
- return getHex( nElement ).get( nDefault );
+ return getHyperHex( nElement ).get( nDefault );
}
bool AttributeList::getBool( sal_Int32 nElement, bool bDefault ) const
diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx
index 4675372b497b..5f7f0c29591e 100644
--- a/oox/source/helper/binaryinputstream.cxx
+++ b/oox/source/helper/binaryinputstream.cxx
@@ -29,9 +29,16 @@
************************************************************************/
#include "oox/helper/binaryinputstream.hxx"
-#include <osl/diagnose.h>
#include <string.h>
-
+#include <vector>
+#include <rtl/strbuf.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using ::rtl::OString;
+using ::rtl::OStringBuffer;
+using ::rtl::OStringToOUString;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Exception;
@@ -44,6 +51,60 @@ const sal_Int32 INPUTSTREAM_BUFFERSIZE = 0x8000;
// ============================================================================
+OString BinaryInputStream::readNulCharArray()
+{
+ OStringBuffer aBuffer;
+ for( sal_uInt8 nChar = readuInt8(); !mbEof && (nChar > 0); readValue( nChar ) )
+ aBuffer.append( static_cast< sal_Char >( nChar ) );
+ return aBuffer.makeStringAndClear();
+}
+
+OUString BinaryInputStream::readNulCharArrayUC( rtl_TextEncoding eTextEnc )
+{
+ return OStringToOUString( readNulCharArray(), eTextEnc );
+}
+
+OUString BinaryInputStream::readNulUnicodeArray()
+{
+ OUStringBuffer aBuffer;
+ for( sal_uInt16 nChar = readuInt16(); !mbEof && (nChar > 0); readValue( nChar ) )
+ aBuffer.append( static_cast< sal_Unicode >( nChar ) );
+ return aBuffer.makeStringAndClear();
+}
+
+OString BinaryInputStream::readCharArray( sal_Int32 nChars, bool bAllowNulChars )
+{
+ if( nChars <= 0 )
+ return OString();
+
+ ::std::vector< sal_Char > aBuffer( static_cast< size_t >( nChars ) );
+ size_t nCharsRead = static_cast< size_t >( readMemory( &aBuffer.front(), nChars ) );
+ if( !bAllowNulChars )
+ ::std::replace( aBuffer.begin(), aBuffer.begin() + nCharsRead, '\0', '?' );
+ return OString( &aBuffer.front(), nCharsRead );
+}
+
+OUString BinaryInputStream::readCharArrayUC( sal_Int32 nChars, rtl_TextEncoding eTextEnc, bool bAllowNulChars )
+{
+ return OStringToOUString( readCharArray( nChars, bAllowNulChars ), eTextEnc );
+}
+
+OUString BinaryInputStream::readUnicodeArray( sal_Int32 nChars, bool bAllowNulChars )
+{
+ OUStringBuffer aBuffer;
+ if( nChars > 0 )
+ {
+ aBuffer.ensureCapacity( nChars );
+ sal_uInt16 nChar;
+ for( sal_uInt16 nCharIdx = 0; !mbEof && (nCharIdx < nChars); ++nCharIdx )
+ {
+ readValue( nChar );
+ aBuffer.append( static_cast< sal_Unicode >( (!bAllowNulChars && (nChar == 0)) ? '?' : nChar ) );
+ }
+ }
+ return aBuffer.makeStringAndClear();
+}
+
void BinaryInputStream::readAtom( void* opMem, sal_uInt8 nSize )
{
readMemory( opMem, nSize );
@@ -131,7 +192,7 @@ void BinaryXInputStream::close()
// ============================================================================
-SequenceInputStream::SequenceInputStream( StreamDataSequence& rData ) :
+SequenceInputStream::SequenceInputStream( const StreamDataSequence& rData ) :
SequenceSeekableStream( rData )
{
}
diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx
index c61b005029ba..474b33965fb5 100644
--- a/oox/source/helper/binaryoutputstream.cxx
+++ b/oox/source/helper/binaryoutputstream.cxx
@@ -148,8 +148,8 @@ void SequenceOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes )
if( nBytes > 0 )
{
if( mrData.getLength() - mnPos < nBytes )
- mrData.realloc( mnPos + nBytes );
- memcpy( mrData.getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) );
+ const_cast< StreamDataSequence& >( mrData ).realloc( mnPos + nBytes );
+ memcpy( const_cast< StreamDataSequence& >( mrData ).getArray() + mnPos, pMem, static_cast< size_t >( nBytes ) );
mnPos += nBytes;
}
}
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
new file mode 100644
index 000000000000..6d8d5a678a18
--- /dev/null
+++ b/oox/source/helper/graphichelper.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: graphichelper.cxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "oox/helper/graphichelper.hxx"
+#include <com/sun/star/graphic/GraphicObject.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/seqstream.hxx>
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_SET_THROW;
+using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::io::XInputStream;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::graphic::GraphicObject;
+using ::com::sun::star::graphic::XGraphic;
+using ::com::sun::star::graphic::XGraphicObject;
+using ::com::sun::star::graphic::XGraphicProvider;
+
+namespace oox {
+
+// ============================================================================
+
+GraphicHelper::GraphicHelper( const Reference< XMultiServiceFactory >& rxFactory ) :
+ mxGraphicProvider( rxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.graphic.GraphicProvider" ) ), UNO_QUERY ),
+ maGraphicObjScheme( CREATE_OUSTRING( "vnd.sun.star.GraphicObject:" ) )
+{
+ ::comphelper::ComponentContext aContext( rxFactory );
+ mxCompContext = aContext.getUNOContext();
+}
+
+GraphicHelper::~GraphicHelper()
+{
+}
+
+Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStream >& rxInStrm )
+{
+ Reference< XGraphic > xGraphic;
+ if( rxInStrm.is() && mxGraphicProvider.is() ) try
+ {
+ Sequence< PropertyValue > aArgs( 1 );
+ aArgs[ 0 ].Name = CREATE_OUSTRING( "InputStream" );
+ aArgs[ 0 ].Value <<= rxInStrm;
+ xGraphic = mxGraphicProvider->queryGraphic( aArgs );
+ }
+ catch( Exception& )
+ {
+ }
+ return xGraphic;
+}
+
+Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData )
+{
+ Reference< XGraphic > xGraphic;
+ if( rGraphicData.hasElements() )
+ {
+ Reference< XInputStream > xInStrm( new ::comphelper::SequenceInputStream( rGraphicData ) );
+ xGraphic = importGraphic( xInStrm );
+ }
+ return xGraphic;
+}
+
+OUString GraphicHelper::createGraphicObject( const Reference< XGraphic >& rxGraphic )
+{
+ OUString aGraphicObjUrl;
+ if( mxCompContext.is() && rxGraphic.is() ) try
+ {
+ Reference< XGraphicObject > xGraphicObj( GraphicObject::create( mxCompContext ), UNO_SET_THROW );
+ xGraphicObj->setGraphic( rxGraphic );
+ maGraphicObjects.push_back( xGraphicObj );
+ aGraphicObjUrl = maGraphicObjScheme + xGraphicObj->getUniqueID();
+ }
+ catch( Exception& )
+ {
+ }
+ return aGraphicObjUrl;
+}
+
+OUString GraphicHelper::importGraphicObject( const Reference< XInputStream >& rxInStrm )
+{
+ return createGraphicObject( importGraphic( rxInStrm ) );
+}
+
+OUString GraphicHelper::importGraphicObject( const StreamDataSequence& rGraphicData )
+{
+ return createGraphicObject( importGraphic( rGraphicData ) );
+}
+
+// ============================================================================
+
+} // namespace oox
+
diff --git a/oox/source/helper/makefile.mk b/oox/source/helper/makefile.mk
index 7677a1fa3329..b172cad3d9d4 100644
--- a/oox/source/helper/makefile.mk
+++ b/oox/source/helper/makefile.mk
@@ -50,6 +50,8 @@ SLOFILES = \
$(SLO)$/binaryoutputstream.obj \
$(SLO)$/binarystreambase.obj \
$(SLO)$/containerhelper.obj \
+ $(SLO)$/graphichelper.obj \
+ $(SLO)$/modelobjecthelper.obj \
$(SLO)$/olestorage.obj \
$(SLO)$/progressbar.obj \
$(SLO)$/propertymap.obj \
diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx
new file mode 100644
index 000000000000..e6e45492eb60
--- /dev/null
+++ b/oox/source/helper/modelobjecthelper.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: modelobjecthelper.cxx,v $
+ * $Revision: 1.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "oox/helper/modelobjecthelper.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/awt/Gradient.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/PolyPolygonBezierCoords.hpp>
+#include "oox/helper/helper.hxx"
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::awt::Gradient;
+using ::com::sun::star::drawing::LineDash;
+using ::com::sun::star::drawing::PolyPolygonBezierCoords;
+
+namespace oox {
+
+// ============================================================================
+
+ModelObjectHelper::ModelObjectHelper( const Reference< XMultiServiceFactory >& rxFactory ) :
+ maMarkerContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.MarkerTable" ) ),
+ maDashContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.DashTable" ) ),
+ maGradientContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.GradientTable" ) ),
+ maBitmapContainer( rxFactory, CREATE_OUSTRING( "com.sun.star.drawing.BitmapTable" ) ),
+ maDashNameBase( CREATE_OUSTRING( "msLineDash " ) ),
+ maGradientNameBase( CREATE_OUSTRING( "msFillGradient " ) ),
+ maBitmapNameBase( CREATE_OUSTRING( "msFillBitmap " ) )
+{
+}
+
+bool ModelObjectHelper::hasLineMarker( const OUString& rMarkerName ) const
+{
+ return maMarkerContainer.hasObject( rMarkerName );
+}
+
+bool ModelObjectHelper::insertLineMarker( const OUString& rMarkerName, const PolyPolygonBezierCoords& rMarker )
+{
+ OSL_ENSURE( rMarker.Coordinates.hasElements(), "ModelObjectHelper::insertLineMarker - line marker without coordinates" );
+ if( rMarker.Coordinates.hasElements() )
+ return maMarkerContainer.insertObject( rMarkerName, Any( rMarker ), false ).getLength() > 0;
+ return false;
+}
+
+OUString ModelObjectHelper::insertLineDash( const LineDash& rDash )
+{
+ return maDashContainer.insertObject( maDashNameBase, Any( rDash ), true );
+}
+
+OUString ModelObjectHelper::insertFillGradient( const Gradient& rGradient )
+{
+ return maGradientContainer.insertObject( maGradientNameBase, Any( rGradient ), true );
+}
+
+OUString ModelObjectHelper::insertFillBitmap( const OUString& rGraphicUrl )
+{
+ if( rGraphicUrl.getLength() > 0 )
+ return maBitmapContainer.insertObject( maBitmapNameBase, Any( rGraphicUrl ), true );
+ return OUString();
+}
+
+// ============================================================================
+
+} // namespace oox
+
diff --git a/oox/source/helper/recordinputstream.cxx b/oox/source/helper/recordinputstream.cxx
index 4b2ad21fc5c2..ee1138d3c751 100644
--- a/oox/source/helper/recordinputstream.cxx
+++ b/oox/source/helper/recordinputstream.cxx
@@ -38,7 +38,7 @@ namespace oox {
// ============================================================================
-RecordInputStream::RecordInputStream( StreamDataSequence& rData ) :
+RecordInputStream::RecordInputStream( const StreamDataSequence& rData ) :
SequenceInputStream( rData )
{
}
diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx
index bb130f962f98..028daeb027fb 100644
--- a/oox/source/helper/storagebase.cxx
+++ b/oox/source/helper/storagebase.cxx
@@ -75,12 +75,12 @@ StorageBase::StorageBase( const Reference< XInputStream >& rxInStream, bool bBas
OSL_ENSURE( mxInStream.is(), "StorageBase::StorageBase - missing base input stream" );
}
-StorageBase::StorageBase( const Reference< XStream >& rxStream, bool bBaseStreamAccess ) :
- mxStream( rxStream ),
+StorageBase::StorageBase( const Reference< XStream >& rxOutStream, bool bBaseStreamAccess ) :
+ mxOutStream( rxOutStream ),
mpParentStorage( 0 ),
mbBaseStreamAccess( bBaseStreamAccess )
{
- OSL_ENSURE( mxStream.is(), "StorageBase::StorageBase - missing base output stream" );
+ OSL_ENSURE( mxOutStream.is(), "StorageBase::StorageBase - missing base output stream" );
}
StorageBase::StorageBase( const StorageBase& rParentStorage, const OUString& rStorageName ) :
@@ -183,7 +183,7 @@ Reference< XOutputStream > StorageBase::openOutputStream( const OUString& rStrea
}
else if( mbBaseStreamAccess )
{
- xOutStream = mxStream->getOutputStream();
+ xOutStream = mxOutStream->getOutputStream();
}
return xOutStream;
}