summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-03-15 14:35:20 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-03-15 15:24:53 +0000
commit188042ad5230e912f3149cc7ea1bb836e084069a (patch)
treec7e627a84aabb501f2d921f7110e9928e769599c
parentRelated: #i119125# change XFillBitmapItem to work with GraphicObject (diff)
downloadcore-188042ad5230e912f3149cc7ea1bb836e084069a.tar.gz
core-188042ad5230e912f3149cc7ea1bb836e084069a.zip
restore enough of XOBitmap to do fore/back color setting on escher patterns
i.e. restore the logic of setting the colors of imported escher patterns like we always did in the past. Stripping that out seems risky in the absence of definite test-cases. Change-Id: I16bbb451b053fd04a5154602f8f38ed799e21286
-rw-r--r--filter/source/msfilter/msdffimp.cxx34
-rw-r--r--lotuswordpro/source/filter/lwpbackgroundstuff.cxx33
-rw-r--r--sc/source/filter/excel/xiescher.cxx12
-rw-r--r--svx/Package_inc.mk1
-rw-r--r--svx/inc/svx/xbitmap.hxx66
-rw-r--r--svx/inc/svx/xenum.hxx1
-rw-r--r--svx/source/xoutdev/xattrbmp.cxx222
7 files changed, 356 insertions, 13 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 71b69149d2d7..86fabbd01b9c 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -131,6 +131,7 @@
#include <com/sun/star/beans/PropertyValues.hpp>
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include "svx/EnhancedCustomShape2d.hxx"
+#include <svx/xbitmap.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustring.hxx>
#include <boost/scoped_array.hpp>
@@ -1371,13 +1372,36 @@ void DffPropertyReader::ApplyFillAttributes( SvStream& rIn, SfxItemSet& rSet, co
{
if ( eMSO_FillType == mso_fillPattern )
{
- Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
+ Bitmap aBmp( aGraf.GetBitmap() );
+ if( aBmp.GetSizePixel().Width() == 8 && aBmp.GetSizePixel().Height() == 8 && aBmp.GetColorCount() == 2)
+ {
+ Color aCol1( COL_WHITE ), aCol2( COL_WHITE );
+
+ if ( IsProperty( DFF_Prop_fillColor ) )
+ aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
+
+ if ( IsProperty( DFF_Prop_fillBackColor ) )
+ aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
- if ( IsProperty( DFF_Prop_fillColor ) )
- aCol1 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillColor ), DFF_Prop_fillColor );
+ XOBitmap aXOBitmap( aBmp );
+ aXOBitmap.Bitmap2Array();
+ aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+ aXOBitmap.SetPixelSize( aBmp.GetSizePixel() );
+
+ if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
+ {
+ aXOBitmap.SetPixelColor( aCol1 );
+ aXOBitmap.SetBackgroundColor( aCol2 );
+ }
+ else
+ {
+ aXOBitmap.SetPixelColor( aCol2 );
+ aXOBitmap.SetBackgroundColor( aCol1 );
+ }
- if ( IsProperty( DFF_Prop_fillBackColor ) )
- aCol2 = rManager.MSO_CLR_ToColor( GetPropertyValue( DFF_Prop_fillBackColor ), DFF_Prop_fillBackColor );
+ aXOBitmap.Array2Bitmap();
+ aGraf = Graphic( aXOBitmap.GetBitmap() );
+ }
rSet.Put(XFillBitmapItem(OUString(), aGraf));
}
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
index 0c8deba1ac7f..46bd2ed88d01 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -65,6 +65,7 @@
#include "tools/stream.hxx"
#include "vcl/bmpacc.hxx"
+#include "svx/xbitmap.hxx"
void LwpBackgroundStuff::Read(LwpObjectStream* pStrm)
@@ -128,9 +129,37 @@ XFBGImage* LwpBackgroundStuff::GetFillPattern()
pPttnArray = NULL;
}
- // transfer image data from Bitmap->SvStream->BYTE-Array
+ // create XOBitmap object from bitmap object
+ XOBitmap aXOBitmap( aBmp );
+ aXOBitmap.Bitmap2Array();
+ aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+
+ // set back/fore-ground colors
+ if (m_aFillColor.IsValidColor() && m_aPatternColor.IsValidColor())
+ {
+ Color aBackColor(static_cast<sal_uInt8>(m_aFillColor.GetRed()),
+ static_cast<sal_uInt8>(m_aFillColor.GetGreen()),
+ static_cast<sal_uInt8>(m_aFillColor.GetBlue()));
+ Color aForeColor(static_cast<sal_uInt8>(m_aPatternColor.GetRed()),
+ static_cast<sal_uInt8>(m_aPatternColor.GetGreen()),
+ static_cast<sal_uInt8>(m_aPatternColor.GetBlue()));
+
+ if( aXOBitmap.GetBackgroundColor() == COL_BLACK )
+ {
+ aXOBitmap.SetPixelColor( aBackColor );
+ aXOBitmap.SetBackgroundColor( aForeColor );
+ }
+ else
+ {
+ aXOBitmap.SetPixelColor( aForeColor );
+ aXOBitmap.SetBackgroundColor( aBackColor );
+ }
+ }
+
+ // transfer image data from XOBitmap->SvStream->BYTE-Array
SvMemoryStream aPicMemStream;
- aBmp.Write(aPicMemStream);
+ aXOBitmap.Array2Bitmap();
+ aXOBitmap.GetBitmap().Write(aPicMemStream);
sal_uInt32 nSize = aPicMemStream.GetEndOfData();
sal_uInt8* pImageBuff = new sal_uInt8 [nSize];
memcpy(pImageBuff, aPicMemStream.GetData(), nSize);
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index b51f7b203c4c..256287305959 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -78,6 +78,7 @@
#include <svx/xlinjoit.hxx>
#include <svx/xlntrit.hxx>
#include <svx/xbtmpit.hxx>
+#include <svx/xbitmap.hxx>
#include "document.hxx"
#include "drwlayer.hxx"
@@ -671,6 +672,17 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
Bitmap aBitmap;
aBitmap.Read( aMemStrm, sal_False );
+
+ XOBitmap aXOBitmap( aBitmap );
+ aXOBitmap.Bitmap2Array();
+ aXOBitmap.SetBitmapType( XBITMAP_8X8 );
+ if( aXOBitmap.GetBackgroundColor().GetColor() == COL_BLACK )
+ ::std::swap( aPattColor, aBackColor );
+ aXOBitmap.SetPixelColor( aPattColor );
+ aXOBitmap.SetBackgroundColor( aBackColor );
+ aXOBitmap.Array2Bitmap();
+ aBitmap = aXOBitmap.GetBitmap();
+
rSdrObj.SetMergedItem(XFillStyleItem(XFILL_BITMAP));
rSdrObj.SetMergedItem(XFillBitmapItem(EMPTY_STRING, Graphic(aBitmap)));
}
diff --git a/svx/Package_inc.mk b/svx/Package_inc.mk
index 048c5d1a30fc..e1deeab9ecd4 100644
--- a/svx/Package_inc.mk
+++ b/svx/Package_inc.mk
@@ -471,6 +471,7 @@ $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxmsitm.hxx,svx/sxmsitm.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdtaditm.hxx,svx/sdtaditm.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/svdotext.hxx,svx/svdotext.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/chrtitem.hxx,svx/chrtitem.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/xbitmap.hxx,svx/xbitmap.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sxallitm.hxx,svx/sxallitm.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/dlgutil.hxx,svx/dlgutil.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/unopage.hxx,svx/unopage.hxx))
diff --git a/svx/inc/svx/xbitmap.hxx b/svx/inc/svx/xbitmap.hxx
new file mode 100644
index 000000000000..959ceafdbd72
--- /dev/null
+++ b/svx/inc/svx/xbitmap.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef _SVX_XBITMAP_HXX
+#define _SVX_XBITMAP_HXX
+
+#include <tools/color.hxx>
+#include <vcl/bitmap.hxx>
+#include <svtools/grfmgr.hxx>
+#include <svx/xenum.hxx>
+#include "svx/svxdllapi.h"
+
+class SVX_DLLPUBLIC XOBitmap
+{
+private:
+ XBitmapType eType;
+ GraphicObject aGraphicObject;
+ sal_uInt16* pPixelArray;
+ Size aArraySize;
+ Color aPixelColor;
+ Color aBckgrColor;
+ sal_Bool bGraphicDirty;
+
+ const GraphicObject& GetGraphicObject() const;
+
+public:
+ XOBitmap( const Bitmap& rBitmap );
+ XOBitmap( const XOBitmap& rXBmp );
+ ~XOBitmap();
+
+ XOBitmap& operator=( const XOBitmap& rXOBitmap );
+ int operator==( const XOBitmap& rXOBitmap ) const;
+
+ void Bitmap2Array();
+ void Array2Bitmap();
+
+ void SetBitmapType( XBitmapType eNewType ) { eType = eNewType; }
+ void SetPixelColor( const Color& rColor ) { aPixelColor = rColor; bGraphicDirty = sal_True; }
+ void SetPixelSize( const Size& rSize ) { aArraySize = rSize; bGraphicDirty = sal_True; }
+ void SetBackgroundColor( const Color& rColor ) { aBckgrColor = rColor; bGraphicDirty = sal_True; }
+
+ XBitmapType GetBitmapType() const { return eType; }
+ Bitmap GetBitmap() const;
+ Color GetPixelColor() const { return aPixelColor; }
+ Color GetBackgroundColor() const { return aBckgrColor; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/inc/svx/xenum.hxx b/svx/inc/svx/xenum.hxx
index 1f483273894d..df0b629d5980 100644
--- a/svx/inc/svx/xenum.hxx
+++ b/svx/inc/svx/xenum.hxx
@@ -45,6 +45,7 @@ enum XFormTextStdForm { XFTFORM_NONE = 0, XFTFORM_TOPCIRC, XFTFORM_BOTCIRC,
XFTFORM_BOTARC, XFTFORM_LFTARC, XFTFORM_RGTARC,
XFTFORM_BUTTON1, XFTFORM_BUTTON2,
XFTFORM_BUTTON3, XFTFORM_BUTTON4};
+enum XBitmapType { XBITMAP_IMPORT, XBITMAP_8X8 };
#endif // _XENUM_HXX
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 27a3dd238365..1256f43caa3e 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -34,12 +34,228 @@
#include <editeng/unoprnms.hxx>
#include <svx/unoapi.hxx>
#include <svx/svdmodel.hxx>
+#include <svx/xbitmap.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <vcl/salbtype.hxx>
#include <vcl/bmpacc.hxx>
using namespace ::com::sun::star;
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( Bitmap aBitmap )
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const Bitmap& rBmp ) :
+ eType ( XBITMAP_IMPORT ),
+ aGraphicObject ( rBmp ),
+ pPixelArray ( NULL ),
+ bGraphicDirty ( sal_False )
+{
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( const XOBitmap& rXBmp )
+|*
+*************************************************************************/
+
+XOBitmap::XOBitmap( const XOBitmap& rXBmp ) :
+ pPixelArray ( NULL )
+{
+ eType = rXBmp.eType;
+ aGraphicObject = rXBmp.aGraphicObject;
+ aArraySize = rXBmp.aArraySize;
+ aPixelColor = rXBmp.aPixelColor;
+ aBckgrColor = rXBmp.aBckgrColor;
+ bGraphicDirty = rXBmp.bGraphicDirty;
+
+ if( rXBmp.pPixelArray )
+ {
+ if( eType == XBITMAP_8X8 )
+ {
+ pPixelArray = new sal_uInt16[ 64 ];
+
+ for( sal_uInt16 i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* XOBitmap::XOBitmap( Bitmap aBitmap )
+|*
+*************************************************************************/
+
+XOBitmap::~XOBitmap()
+{
+ delete [] pPixelArray;
+}
+
+/*************************************************************************
+|*
+|* XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+|*
+*************************************************************************/
+
+XOBitmap& XOBitmap::operator=( const XOBitmap& rXBmp )
+{
+ eType = rXBmp.eType;
+ aGraphicObject = rXBmp.aGraphicObject;
+ aArraySize = rXBmp.aArraySize;
+ aPixelColor = rXBmp.aPixelColor;
+ aBckgrColor = rXBmp.aBckgrColor;
+ bGraphicDirty = rXBmp.bGraphicDirty;
+
+ if( rXBmp.pPixelArray )
+ {
+ if( eType == XBITMAP_8X8 )
+ {
+ pPixelArray = new sal_uInt16[ 64 ];
+
+ for( sal_uInt16 i = 0; i < 64; i++ )
+ *( pPixelArray + i ) = *( rXBmp.pPixelArray + i );
+ }
+ }
+ return( *this );
+}
+
+/*************************************************************************
+|*
+|* int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+|*
+*************************************************************************/
+
+int XOBitmap::operator==( const XOBitmap& rXOBitmap ) const
+{
+ if( eType != rXOBitmap.eType ||
+ aGraphicObject != rXOBitmap.aGraphicObject ||
+ aArraySize != rXOBitmap.aArraySize ||
+ aPixelColor != rXOBitmap.aPixelColor ||
+ aBckgrColor != rXOBitmap.aBckgrColor ||
+ bGraphicDirty != rXOBitmap.bGraphicDirty )
+ {
+ return( sal_False );
+ }
+
+ if( pPixelArray && rXOBitmap.pPixelArray )
+ {
+ sal_uInt16 nCount = (sal_uInt16) ( aArraySize.Width() * aArraySize.Height() );
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ if( *( pPixelArray + i ) != *( rXOBitmap.pPixelArray + i ) )
+ return( sal_False );
+ }
+ }
+ return( sal_True );
+}
+
+/*************************************************************************
+|*
+|* Bitmap XOBitmap::GetBitmap()
+|*
+*************************************************************************/
+
+Bitmap XOBitmap::GetBitmap() const
+{
+ return GetGraphicObject().GetGraphic().GetBitmap();
+}
+
+/*************************************************************************
+|*
+|* Bitmap XOBitmap::GetGraphicObject()
+|*
+*************************************************************************/
+
+const GraphicObject& XOBitmap::GetGraphicObject() const
+{
+ if( bGraphicDirty )
+ ( (XOBitmap*) this )->Array2Bitmap();
+
+ return aGraphicObject;
+}
+
+/*************************************************************************
+|*
+|* void XOBitmap::Bitmap2Array()
+|*
+|* Beschreibung Umwandlung der Bitmap in Array, Hinter- u.
+|* Vordergrundfarbe
+|*
+*************************************************************************/
+
+void XOBitmap::Bitmap2Array()
+{
+ VirtualDevice aVD;
+ sal_Bool bPixelColor = sal_False;
+ const Bitmap aBitmap( GetBitmap() );
+ const sal_uInt16 nLines = 8; // von Type abhaengig
+
+ if( !pPixelArray )
+ pPixelArray = new sal_uInt16[ nLines * nLines ];
+
+ aVD.SetOutputSizePixel( aBitmap.GetSizePixel() );
+ aVD.DrawBitmap( Point(), aBitmap );
+ aPixelColor = aBckgrColor = aVD.GetPixel( Point() );
+
+ // Aufbau des Arrays und Ermittlung der Vorder-, bzw.
+ // Hintergrundfarbe
+ for( sal_uInt16 i = 0; i < nLines; i++ )
+ {
+ for( sal_uInt16 j = 0; j < nLines; j++ )
+ {
+ if ( aVD.GetPixel( Point( j, i ) ) == aBckgrColor )
+ *( pPixelArray + j + i * nLines ) = 0;
+ else
+ {
+ *( pPixelArray + j + i * nLines ) = 1;
+ if( !bPixelColor )
+ {
+ aPixelColor = aVD.GetPixel( Point( j, i ) );
+ bPixelColor = sal_True;
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* void XOBitmap::Array2Bitmap()
+|*
+|* Beschreibung Umwandlung des Arrays, Hinter- u.
+|* Vordergrundfarbe in eine Bitmap
+|*
+*************************************************************************/
+
+void XOBitmap::Array2Bitmap()
+{
+ VirtualDevice aVD;
+ sal_uInt16 nLines = 8; // von Type abhaengig
+
+ if( !pPixelArray )
+ return;
+
+ aVD.SetOutputSizePixel( Size( nLines, nLines ) );
+
+ // Aufbau der Bitmap
+ for( sal_uInt16 i = 0; i < nLines; i++ )
+ {
+ for( sal_uInt16 j = 0; j < nLines; j++ )
+ {
+ if( *( pPixelArray + j + i * nLines ) == 0 )
+ aVD.DrawPixel( Point( j, i ), aBckgrColor );
+ else
+ aVD.DrawPixel( Point( j, i ), aPixelColor );
+ }
+ }
+
+ aGraphicObject = GraphicObject( aVD.GetBitmap( Point(), Size( nLines, nLines ) ) );
+ bGraphicDirty = sal_False;
+}
+
// -----------------------
// class XFillBitmapItem
// -----------------------
@@ -146,12 +362,6 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
}
else if(1 == nVer)
{
- enum XBitmapType
- {
- XBITMAP_IMPORT,
- XBITMAP_8X8
- };
-
sal_Int16 iTmp;
rIn >> iTmp; // former XBitmapStyle