2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2006-09-17 05:23:16 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <com/sun/star/awt/XBitmap.hpp>
|
2008-01-10 11:49:45 +00:00
|
|
|
#include <com/sun/star/graphic/XGraphic.hpp>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/stream.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
#include <vcl/bitmapex.hxx>
|
2013-06-28 04:38:06 +02:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/style.hxx>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <editeng/memberids.hrc>
|
2007-06-27 18:33:53 +00:00
|
|
|
#include <svx/dialogs.hrc>
|
2010-04-20 15:55:51 +02:00
|
|
|
#include "svx/xattr.hxx"
|
2007-06-27 18:33:53 +00:00
|
|
|
#include <svx/xtable.hxx>
|
|
|
|
#include <svx/xdef.hxx>
|
|
|
|
#include <svx/unomid.hxx>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <editeng/unoprnms.hxx>
|
2012-05-10 09:29:55 +00:00
|
|
|
#include <svx/unoapi.hxx>
|
2007-06-27 18:33:53 +00:00
|
|
|
#include <svx/svdmodel.hxx>
|
2013-03-15 14:35:20 +00:00
|
|
|
#include <svx/xbitmap.hxx>
|
2004-12-23 10:09:13 +00:00
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2012-05-10 09:29:55 +00:00
|
|
|
#include <vcl/salbtype.hxx>
|
2016-02-06 21:03:41 +11:00
|
|
|
#include <vcl/bitmapaccess.hxx>
|
2013-01-10 16:28:40 +00:00
|
|
|
#include <vcl/dibtools.hxx>
|
2004-12-23 10:09:13 +00:00
|
|
|
|
2015-01-07 09:45:03 +01:00
|
|
|
#include <libxml/xmlwriter.h>
|
|
|
|
|
2004-12-23 10:09:13 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2013-03-15 14:35:20 +00:00
|
|
|
XOBitmap::XOBitmap( const Bitmap& rBmp ) :
|
2017-01-11 08:57:51 +00:00
|
|
|
xGraphicObject (new GraphicObject(rBmp)),
|
2014-03-11 15:23:07 +02:00
|
|
|
bGraphicDirty ( false )
|
2013-03-15 14:35:20 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XOBitmap::~XOBitmap()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Bitmap XOBitmap::GetBitmap() const
|
|
|
|
{
|
|
|
|
return GetGraphicObject().GetGraphic().GetBitmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
const GraphicObject& XOBitmap::GetGraphicObject() const
|
|
|
|
{
|
|
|
|
if( bGraphicDirty )
|
2015-03-26 15:31:47 +01:00
|
|
|
const_cast<XOBitmap*>(this)->Array2Bitmap();
|
2013-03-15 14:35:20 +00:00
|
|
|
|
2017-01-11 08:57:51 +00:00
|
|
|
return *xGraphicObject;
|
2013-03-15 14:35:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XOBitmap::Bitmap2Array()
|
|
|
|
{
|
2015-03-31 23:04:14 +01:00
|
|
|
ScopedVclPtrInstance< VirtualDevice > pVDev;
|
2013-04-22 09:10:41 +09:00
|
|
|
bool bPixelColor = false;
|
2013-03-15 14:35:20 +00:00
|
|
|
const Bitmap aBitmap( GetBitmap() );
|
2017-01-17 09:14:06 +00:00
|
|
|
const sal_Int32 nLines = 8; // type dependent
|
2013-03-15 14:35:20 +00:00
|
|
|
|
|
|
|
if( !pPixelArray )
|
2017-01-11 13:04:35 +02:00
|
|
|
pPixelArray.reset( new sal_uInt16[ nLines * nLines ] );
|
2013-03-15 14:35:20 +00:00
|
|
|
|
2015-03-19 14:38:23 +00:00
|
|
|
pVDev->SetOutputSizePixel( aBitmap.GetSizePixel() );
|
|
|
|
pVDev->DrawBitmap( Point(), aBitmap );
|
|
|
|
aPixelColor = aBckgrColor = pVDev->GetPixel( Point() );
|
2013-03-15 14:35:20 +00:00
|
|
|
|
2013-08-21 15:15:47 +02:00
|
|
|
// create array and determine foreground and background color
|
2017-01-17 09:14:06 +00:00
|
|
|
for (sal_Int32 i = 0; i < nLines; ++i)
|
2013-03-15 14:35:20 +00:00
|
|
|
{
|
2017-01-17 09:14:06 +00:00
|
|
|
for (sal_Int32 j = 0; j < nLines; ++j)
|
2013-03-15 14:35:20 +00:00
|
|
|
{
|
2015-03-19 14:38:23 +00:00
|
|
|
if ( pVDev->GetPixel( Point( j, i ) ) == aBckgrColor )
|
2017-01-11 13:04:35 +02:00
|
|
|
pPixelArray[ j + i * nLines ] = 0;
|
2013-03-15 14:35:20 +00:00
|
|
|
else
|
|
|
|
{
|
2017-01-11 13:04:35 +02:00
|
|
|
pPixelArray[ j + i * nLines ] = 1;
|
2013-03-15 14:35:20 +00:00
|
|
|
if( !bPixelColor )
|
|
|
|
{
|
2015-03-19 14:38:23 +00:00
|
|
|
aPixelColor = pVDev->GetPixel( Point( j, i ) );
|
2013-04-22 09:10:41 +09:00
|
|
|
bPixelColor = true;
|
2013-03-15 14:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-21 15:15:47 +02:00
|
|
|
/// convert array, fore- and background color into a bitmap
|
2013-03-15 14:35:20 +00:00
|
|
|
void XOBitmap::Array2Bitmap()
|
|
|
|
{
|
2017-01-17 09:14:06 +00:00
|
|
|
if (!pPixelArray)
|
2013-03-15 14:35:20 +00:00
|
|
|
return;
|
|
|
|
|
2017-01-17 09:14:06 +00:00
|
|
|
ScopedVclPtrInstance< VirtualDevice > pVDev;
|
|
|
|
const sal_Int32 nLines = 8; // type dependent
|
|
|
|
|
2015-03-19 14:38:23 +00:00
|
|
|
pVDev->SetOutputSizePixel( Size( nLines, nLines ) );
|
2013-03-15 14:35:20 +00:00
|
|
|
|
2013-08-21 15:15:47 +02:00
|
|
|
// create bitmap
|
2017-01-17 09:14:06 +00:00
|
|
|
for (sal_Int32 i = 0; i < nLines; ++i)
|
2013-03-15 14:35:20 +00:00
|
|
|
{
|
2017-01-17 09:14:06 +00:00
|
|
|
for (sal_Int32 j = 0; j < nLines; ++j)
|
2013-03-15 14:35:20 +00:00
|
|
|
{
|
2017-01-11 13:04:35 +02:00
|
|
|
if( pPixelArray[ j + i * nLines ] == 0 )
|
2015-03-19 14:38:23 +00:00
|
|
|
pVDev->DrawPixel( Point( j, i ), aBckgrColor );
|
2013-03-15 14:35:20 +00:00
|
|
|
else
|
2015-03-19 14:38:23 +00:00
|
|
|
pVDev->DrawPixel( Point( j, i ), aPixelColor );
|
2013-03-15 14:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-11 08:57:51 +00:00
|
|
|
xGraphicObject.reset(new GraphicObject(pVDev->GetBitmap(Point(), Size(nLines, nLines))));
|
2014-03-11 15:23:07 +02:00
|
|
|
bGraphicDirty = false;
|
2013-03-15 14:35:20 +00:00
|
|
|
}
|
|
|
|
|
2015-11-07 14:43:19 +01:00
|
|
|
|
|
|
|
SfxPoolItem* XFillBitmapItem::CreateDefault() { return new XFillBitmapItem; }
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2013-08-30 09:22:30 +02:00
|
|
|
XFillBitmapItem::XFillBitmapItem(const OUString& rName, const GraphicObject& rGraphicObject)
|
2012-05-10 09:29:55 +00:00
|
|
|
: NameOrIndex(XATTR_FILLBITMAP, rName),
|
|
|
|
maGraphicObject(rGraphicObject)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
|
|
|
|
: NameOrIndex(rItem),
|
|
|
|
maGraphicObject(rItem.maGraphicObject)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
Bitmap createHistorical8x8FromArray(const sal_uInt16* pArray, Color aColorPix, Color aColorBack)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
BitmapPalette aPalette(2);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
aPalette[0] = BitmapColor(aColorBack);
|
|
|
|
aPalette[1] = BitmapColor(aColorPix);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
Bitmap aBitmap(Size(8, 8), 1, &aPalette);
|
2016-12-05 14:03:12 +00:00
|
|
|
Bitmap::ScopedWriteAccess pContent(aBitmap);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
if(pContent)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
for(sal_uInt16 a(0); a < 8; a++)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
for(sal_uInt16 b(0); b < 8; b++)
|
|
|
|
{
|
|
|
|
if(pArray[(a * 8) + b])
|
|
|
|
{
|
2013-05-02 13:22:17 +00:00
|
|
|
pContent->SetPixelIndex(a, b, 1);
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-02 13:22:17 +00:00
|
|
|
pContent->SetPixelIndex(a, b, 0);
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 14:03:12 +00:00
|
|
|
pContent.reset();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
return aBitmap;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 13:05:50 +01:00
|
|
|
bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-09-29 09:10:40 +01:00
|
|
|
bool bRet(false);
|
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
if(!rBitmapEx.IsTransparent())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
Bitmap aBitmap(rBitmapEx.GetBitmap());
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
if(2 == aBitmap.GetColorCount())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
if(pRead)
|
|
|
|
{
|
|
|
|
if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
|
|
|
|
{
|
|
|
|
const BitmapPalette& rPalette = pRead->GetPalette();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-06-16 18:21:52 +02:00
|
|
|
// #i123564# background and foreground were exchanged; of course
|
2013-10-29 17:40:43 +00:00
|
|
|
// rPalette[0] is the background color
|
|
|
|
o_rFront = rPalette[1];
|
|
|
|
o_rBack = rPalette[0];
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-09-29 09:10:40 +01:00
|
|
|
bRet = true;
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
2015-09-29 09:10:40 +01:00
|
|
|
|
|
|
|
Bitmap::ReleaseAccess(pRead);
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 09:10:40 +01:00
|
|
|
return bRet;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 10:55:09 +01:00
|
|
|
GraphicObject XFillBitmapItem::makeGraphicObject(SvStream& rIn, sal_uInt16 nVer) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
if (!IsIndex())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
if(0 == nVer)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-08-21 15:15:47 +02:00
|
|
|
// work with the old bitmap
|
2000-09-18 16:07:07 +00:00
|
|
|
Bitmap aBmp;
|
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
ReadDIB(aBmp, rIn, true);
|
2017-06-15 10:55:09 +01:00
|
|
|
return Graphic(aBmp);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2012-05-10 09:29:55 +00:00
|
|
|
else if(1 == nVer)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-01-10 16:11:35 +01:00
|
|
|
sal_Int16 iTmp;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-05 10:41:04 +02:00
|
|
|
rIn.ReadInt16( iTmp ); // former XBitmapStyle
|
2016-08-17 11:45:33 +02:00
|
|
|
rIn.ReadInt16( iTmp ); // XBitmapType
|
2012-05-10 09:29:55 +00:00
|
|
|
|
2016-08-17 11:45:33 +02:00
|
|
|
if(XBitmapType::Import == (XBitmapType)iTmp)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Bitmap aBmp;
|
2012-05-10 09:29:55 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
ReadDIB(aBmp, rIn, true);
|
2017-06-15 10:55:09 +01:00
|
|
|
return Graphic(aBmp);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2016-08-17 11:45:33 +02:00
|
|
|
else if(XBitmapType::N8x8 == (XBitmapType)iTmp)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
sal_uInt16 aArray[64];
|
|
|
|
|
2016-05-11 09:53:05 +02:00
|
|
|
for(sal_uInt16 & i : aArray)
|
2012-05-10 09:29:55 +00:00
|
|
|
{
|
2016-05-11 09:53:05 +02:00
|
|
|
rIn.ReadUInt16( i );
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Color aColorPix;
|
|
|
|
Color aColorBack;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-01-30 13:46:42 +02:00
|
|
|
ReadColor( rIn, aColorPix );
|
|
|
|
ReadColor( rIn, aColorBack );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
const Bitmap aBitmap(createHistorical8x8FromArray(aArray, aColorPix, aColorBack));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2017-06-15 10:55:09 +01:00
|
|
|
return Graphic(aBitmap);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-10 09:29:55 +00:00
|
|
|
else if(2 == nVer)
|
|
|
|
{
|
|
|
|
BitmapEx aBmpEx;
|
2000-12-14 15:18:59 +00:00
|
|
|
|
2013-01-10 16:28:40 +00:00
|
|
|
ReadDIBBitmapEx(aBmpEx, rIn);
|
2017-06-15 10:55:09 +01:00
|
|
|
return Graphic(aBmpEx);
|
2012-05-10 09:29:55 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-15 10:55:09 +01:00
|
|
|
return GraphicObject();
|
|
|
|
}
|
|
|
|
|
|
|
|
XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
|
|
|
|
: NameOrIndex(XATTR_FILLBITMAP, rIn)
|
|
|
|
, maGraphicObject(makeGraphicObject(rIn, nVer))
|
|
|
|
{
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 16:10:13 +02:00
|
|
|
XFillBitmapItem::XFillBitmapItem(const GraphicObject& rGraphicObject)
|
2017-06-15 10:55:09 +01:00
|
|
|
: NameOrIndex(XATTR_FILLBITMAP, -1)
|
|
|
|
, maGraphicObject(rGraphicObject)
|
2000-10-12 10:54:52 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-06-19 16:06:25 +00:00
|
|
|
SfxPoolItem* XFillBitmapItem::Clone(SfxItemPool* /*pPool*/) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return new XFillBitmapItem(*this);
|
|
|
|
}
|
|
|
|
|
2014-01-10 17:01:52 +01:00
|
|
|
bool XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
return (NameOrIndex::operator==(rItem)
|
2014-10-17 15:43:45 +02:00
|
|
|
&& maGraphicObject == static_cast<const XFillBitmapItem&>(rItem).maGraphicObject);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SfxPoolItem* XFillBitmapItem::Create(SvStream& rIn, sal_uInt16 nVer) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
return new XFillBitmapItem( rIn, nVer );
|
|
|
|
}
|
|
|
|
|
2011-01-10 16:11:35 +01:00
|
|
|
SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
NameOrIndex::Store(rOut, nItemVersion);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
if(!IsIndex())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-01-10 16:28:40 +00:00
|
|
|
WriteDIBBitmapEx(maGraphicObject.GetGraphic().GetBitmapEx(), rOut);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rOut;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-16 15:54:53 +05:30
|
|
|
bool XFillBitmapItem::isPattern() const
|
|
|
|
{
|
|
|
|
BitmapColor aBack, aFront;
|
|
|
|
return isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmap(), aBack, aFront);
|
|
|
|
}
|
|
|
|
|
2012-05-10 09:29:55 +00:00
|
|
|
sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-02-11 13:20:49 +02:00
|
|
|
return 2;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-07-24 11:31:39 +02:00
|
|
|
bool XFillBitmapItem::GetPresentation(
|
2014-07-24 15:43:00 +02:00
|
|
|
SfxItemPresentation /*ePres*/,
|
2016-08-19 09:31:35 +01:00
|
|
|
MapUnit /*eCoreUnit*/,
|
|
|
|
MapUnit /*ePresUnit*/,
|
2012-05-10 09:29:55 +00:00
|
|
|
OUString& rText,
|
|
|
|
const IntlWrapper*) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-07-24 15:43:00 +02:00
|
|
|
rText += GetName();
|
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 14:59:47 +02:00
|
|
|
bool XFillBitmapItem::QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-22 11:05:15 +00:00
|
|
|
nMemberId &= ~CONVERT_TWIPS;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
// needed for MID_NAME
|
2013-01-23 12:41:52 +01:00
|
|
|
OUString aApiName;
|
2004-12-23 10:09:13 +00:00
|
|
|
// needed for complete item (MID 0)
|
2013-01-23 12:41:52 +01:00
|
|
|
OUString aInternalName;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
2013-01-23 12:41:52 +01:00
|
|
|
OUString aURL;
|
2015-10-30 14:59:47 +02:00
|
|
|
css::uno::Reference< css::awt::XBitmap > xBmp;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if( nMemberId == MID_NAME )
|
|
|
|
{
|
2012-12-06 15:30:20 +00:00
|
|
|
aApiName = SvxUnogetApiNameForItem(Which(), GetName());
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
else if( nMemberId == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-12-23 10:09:13 +00:00
|
|
|
aInternalName = GetName();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
if( nMemberId == MID_GRAFURL ||
|
|
|
|
nMemberId == 0 )
|
|
|
|
{
|
2013-11-15 11:05:19 +02:00
|
|
|
aURL = UNO_NAME_GRAPHOBJ_URLPREFIX;
|
2013-04-07 12:06:47 +02:00
|
|
|
aURL += OStringToOUString(
|
2012-05-10 09:29:55 +00:00
|
|
|
GetGraphicObject().GetUniqueID(),
|
2011-09-22 09:02:16 +01:00
|
|
|
RTL_TEXTENCODING_ASCII_US);
|
2004-12-23 10:09:13 +00:00
|
|
|
}
|
|
|
|
if( nMemberId == MID_BITMAP ||
|
|
|
|
nMemberId == 0 )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
xBmp.set(VCLUnoHelper::CreateBitmap(GetGraphicObject().GetGraphic().GetBitmapEx()));
|
2004-12-23 10:09:13 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-12-23 10:09:13 +00:00
|
|
|
if( nMemberId == MID_NAME )
|
|
|
|
rVal <<= aApiName;
|
|
|
|
else if( nMemberId == MID_GRAFURL )
|
|
|
|
rVal <<= aURL;
|
|
|
|
else if( nMemberId == MID_BITMAP )
|
2000-09-18 16:07:07 +00:00
|
|
|
rVal <<= xBmp;
|
2004-12-23 10:09:13 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// member-id 0 => complete item (e.g. for toolbars)
|
|
|
|
DBG_ASSERT( nMemberId == 0, "invalid member-id" );
|
|
|
|
uno::Sequence< beans::PropertyValue > aPropSeq( 3 );
|
|
|
|
|
2013-11-15 11:05:19 +02:00
|
|
|
aPropSeq[0].Name = "Name";
|
2017-02-24 11:22:18 +02:00
|
|
|
aPropSeq[0].Value <<= aInternalName;
|
2013-11-15 11:05:19 +02:00
|
|
|
aPropSeq[1].Name = "FillBitmapURL";
|
2017-02-24 11:22:18 +02:00
|
|
|
aPropSeq[1].Value <<= aURL;
|
2013-11-15 11:05:19 +02:00
|
|
|
aPropSeq[2].Name = "Bitmap";
|
2017-02-24 11:22:18 +02:00
|
|
|
aPropSeq[2].Value <<= xBmp;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
rVal <<= aPropSeq;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2010-10-04 15:23:49 +01:00
|
|
|
return true;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 14:59:47 +02:00
|
|
|
bool XFillBitmapItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-05-22 11:05:15 +00:00
|
|
|
nMemberId &= ~CONVERT_TWIPS;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aName;
|
|
|
|
OUString aURL;
|
2015-10-30 14:59:47 +02:00
|
|
|
css::uno::Reference< css::awt::XBitmap > xBmp;
|
|
|
|
css::uno::Reference< css::graphic::XGraphic > xGraphic;
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
bool bSetName = false;
|
|
|
|
bool bSetURL = false;
|
|
|
|
bool bSetBitmap = false;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if( nMemberId == MID_NAME )
|
2004-12-23 10:09:13 +00:00
|
|
|
bSetName = (rVal >>= aName);
|
|
|
|
else if( nMemberId == MID_GRAFURL )
|
|
|
|
bSetURL = (rVal >>= aURL);
|
|
|
|
else if( nMemberId == MID_BITMAP )
|
2008-01-10 11:49:45 +00:00
|
|
|
{
|
2004-12-23 10:09:13 +00:00
|
|
|
bSetBitmap = (rVal >>= xBmp);
|
2008-01-10 11:49:45 +00:00
|
|
|
if ( !bSetBitmap )
|
|
|
|
bSetBitmap = (rVal >>= xGraphic );
|
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-12-23 10:09:13 +00:00
|
|
|
DBG_ASSERT( nMemberId == 0, "invalid member-id" );
|
|
|
|
uno::Sequence< beans::PropertyValue > aPropSeq;
|
|
|
|
if( rVal >>= aPropSeq )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-12-23 10:09:13 +00:00
|
|
|
for ( sal_Int32 n = 0; n < aPropSeq.getLength(); n++ )
|
|
|
|
{
|
2012-04-06 14:28:18 +02:00
|
|
|
if ( aPropSeq[n].Name == "Name" )
|
2004-12-23 10:09:13 +00:00
|
|
|
bSetName = (aPropSeq[n].Value >>= aName);
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropSeq[n].Name == "FillBitmapURL" )
|
2004-12-23 10:09:13 +00:00
|
|
|
bSetURL = (aPropSeq[n].Value >>= aURL);
|
2012-04-06 14:28:18 +02:00
|
|
|
else if ( aPropSeq[n].Name == "Bitmap" )
|
2004-12-23 10:09:13 +00:00
|
|
|
bSetBitmap = (aPropSeq[n].Value >>= xBmp);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
if( bSetName )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-12-23 10:09:13 +00:00
|
|
|
SetName( aName );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
if( bSetURL )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-03-06 15:53:07 +05:30
|
|
|
GraphicObject aGraphicObject = GraphicObject::CreateGraphicObjectFromURL(aURL);
|
2016-05-27 09:43:22 +02:00
|
|
|
if( aGraphicObject.GetType() != GraphicType::NONE )
|
2014-03-06 15:53:07 +05:30
|
|
|
maGraphicObject = aGraphicObject;
|
2012-10-16 08:44:02 +00:00
|
|
|
|
|
|
|
// #121194# Prefer GraphicObject over bitmap object if both are provided
|
2016-05-27 09:43:22 +02:00
|
|
|
if(bSetBitmap && GraphicType::NONE != maGraphicObject.GetType())
|
2012-10-16 08:44:02 +00:00
|
|
|
{
|
|
|
|
bSetBitmap = false;
|
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
}
|
|
|
|
if( bSetBitmap )
|
|
|
|
{
|
2012-05-10 09:29:55 +00:00
|
|
|
if(xBmp.is())
|
2008-01-10 11:49:45 +00:00
|
|
|
{
|
2017-06-15 11:05:13 +01:00
|
|
|
maGraphicObject.SetGraphic(VCLUnoHelper::GetBitmap(xBmp));
|
2008-01-10 11:49:45 +00:00
|
|
|
}
|
2012-05-10 09:29:55 +00:00
|
|
|
else if(xGraphic.is())
|
2004-12-23 10:09:13 +00:00
|
|
|
{
|
2017-06-15 11:05:13 +01:00
|
|
|
maGraphicObject.SetGraphic(xGraphic);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2004-12-23 10:09:13 +00:00
|
|
|
|
|
|
|
return (bSetName || bSetURL || bSetBitmap);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2014-03-11 15:23:07 +02:00
|
|
|
bool XFillBitmapItem::CompareValueFunc( const NameOrIndex* p1, const NameOrIndex* p2 )
|
2001-03-07 12:21:41 +00:00
|
|
|
{
|
2014-10-17 15:43:45 +02:00
|
|
|
const GraphicObject& aGraphicObjectA(static_cast<const XFillBitmapItem*>(p1)->GetGraphicObject());
|
|
|
|
const GraphicObject& aGraphicObjectB(static_cast<const XFillBitmapItem*>(p2)->GetGraphicObject());
|
2012-05-10 09:29:55 +00:00
|
|
|
|
|
|
|
return aGraphicObjectA == aGraphicObjectB;
|
2001-03-07 12:21:41 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-03-07 12:21:41 +00:00
|
|
|
XFillBitmapItem* XFillBitmapItem::checkForUniqueItem( SdrModel* pModel ) const
|
|
|
|
{
|
|
|
|
if( pModel )
|
|
|
|
{
|
2016-08-16 15:51:26 +02:00
|
|
|
XPropertyListType aListType = XPropertyListType::Bitmap;
|
2016-06-07 16:58:20 +05:30
|
|
|
if(isPattern())
|
2016-08-16 15:51:26 +02:00
|
|
|
aListType = XPropertyListType::Pattern;
|
2013-09-04 12:11:38 +02:00
|
|
|
const OUString aUniqueName = NameOrIndex::CheckNamedItem(
|
2011-09-23 14:05:07 +01:00
|
|
|
this, XATTR_FILLBITMAP, &pModel->GetItemPool(),
|
2015-11-10 10:25:28 +01:00
|
|
|
pModel->GetStyleSheetPool() ? &pModel->GetStyleSheetPool()->GetPool() : nullptr,
|
2011-09-23 14:05:07 +01:00
|
|
|
XFillBitmapItem::CompareValueFunc, RID_SVXSTR_BMP21,
|
2016-06-07 16:58:20 +05:30
|
|
|
pModel->GetPropertyList( aListType ) );
|
2001-03-07 12:21:41 +00:00
|
|
|
|
|
|
|
// if the given name is not valid, replace it!
|
|
|
|
if( aUniqueName != GetName() )
|
2012-05-10 09:29:55 +00:00
|
|
|
{
|
|
|
|
return new XFillBitmapItem(aUniqueName, maGraphicObject);
|
|
|
|
}
|
2001-03-07 12:21:41 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-11-10 10:25:28 +01:00
|
|
|
return nullptr;
|
2001-05-13 02:33:31 +00:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
2015-01-07 09:45:03 +01:00
|
|
|
void XFillBitmapItem::dumpAsXml(xmlTextWriterPtr pWriter) const
|
|
|
|
{
|
2016-11-16 08:59:00 +02:00
|
|
|
xmlTextWriterStartElement(pWriter, BAD_CAST("XFillBitmapItem"));
|
2015-01-07 09:45:03 +01:00
|
|
|
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
|
|
|
|
|
|
|
|
NameOrIndex::dumpAsXml(pWriter);
|
|
|
|
|
|
|
|
xmlTextWriterEndElement(pWriter);
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|