Kaydet (Commit) 188042ad authored tarafından Caolán McNamara's avatar Caolán McNamara

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
üst c97aec0d
......@@ -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));
}
......
......@@ -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);
......
......@@ -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)));
}
......
......@@ -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))
......
/* -*- 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: */
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment