Files
libreoffice/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx
Vladimir Glazounov cc56e555cb INTEGRATION: CWS chart2mst3 (1.6.4); FILE MERGED
2007/05/15 11:49:00 bm 1.6.4.20: #i73604# RESYNC: additional changes for ItemId cleanup
2006/10/20 20:40:25 iha 1.6.4.19: implement gradient step count
2006/10/18 17:06:12 bm 1.6.4.18: RESYNC: (1.7-1.8); FILE MERGED
2006/06/14 18:42:49 bm 1.6.4.17: #i66438# also transparency gradient
2006/06/14 18:28:38 bm 1.6.4.16: #i66438# for named properties: set also the content, otherwise the preview is wrong and no list-entry is selected
2006/05/17 14:13:01 bm 1.6.4.15: support bitmap properties like tile, stretch, offsets etc. also for data points/series
2006/05/17 13:26:11 bm 1.6.4.14: bitmap properties (tile, stretch, etc.)
2005/11/24 18:32:42 bm 1.6.4.13: transparency gradients enabled
2005/11/24 15:08:27 bm 1.6.4.12: symbol graphics support
2005/10/07 11:31:37 bm 1.6.4.11: RESYNC: (1.6-1.7); FILE MERGED
2005/09/02 11:58:02 bm 1.6.4.10: hack for transparence item: QueryValue/PutValue use sal_Int32 for UNO, but sal_Int16 is needed
2005/07/22 12:54:42 bm 1.6.4.9: #124485# property FillBackground added
2005/07/12 15:28:18 bm 1.6.4.8: support fill bitmaps (GraphicObjectResolver still missing)
2005/07/12 14:41:17 bm 1.6.4.7: add hatch and dash names to tables
2005/07/12 12:57:02 bm 1.6.4.6: use named properties for gradients etc. in chart model
2005/06/16 07:55:46 iha 1.6.4.5: correct name for Property FillTransparenceGradient
2005/06/15 18:19:12 iha 1.6.4.4: correct name for Property FillTransparenceGradient
2005/05/13 12:14:31 bm 1.6.4.3: member ids for gradient and hatch corrected
2004/05/07 11:23:39 bm 1.6.4.2: enabling member-ids for all items
2004/05/07 09:14:20 bm 1.6.4.1: enabling member-ids for all items
2007-05-22 17:00:42 +00:00

1034 lines
38 KiB
C++

/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: GraphicPropertyItemConverter.cxx,v $
*
* $Revision: 1.9 $
*
* last change: $Author: vg $ $Date: 2007-05-22 18:00:42 $
*
* 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
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_chart2.hxx"
#include "GraphicPropertyItemConverter.hxx"
#include "SchWhichPairs.hxx"
#include "macros.hxx"
#include "ItemPropertyMap.hxx"
#include "PropertyHelper.hxx"
#include "CommonConverters.hxx"
// #ifndef _SFXINTITEM_HXX
// #include <svtools/intitem.hxx>
// #endif
#ifndef _SVX_XFLCLIT_HXX
#include <svx/xflclit.hxx>
#endif
#ifndef _SVX_XLNCLIT_HXX
#include <svx/xlnclit.hxx>
#endif
#ifndef _SVX_XFLBMTIT_HXX
#include <svx/xflbmtit.hxx>
#endif
#ifndef _SVX_XFLBSTIT_HXX
#include <svx/xflbstit.hxx>
#endif
#ifndef _SVX_XBTMPIT_HXX
#include <svx/xbtmpit.hxx>
#endif
#ifndef _SVX_XFLFTRIT_HXX
#include <svx/xflftrit.hxx>
#endif
#ifndef _SVX_XLNDSIT_HXX
#include <svx/xlndsit.hxx>
#endif
#ifndef _SVX_XFLHTIT_HXX
#include <svx/xflhtit.hxx>
#endif
#ifndef _SVX_XFLGRIT_HXX
#include <svx/xflgrit.hxx>
#endif
#ifndef _SVX_XFLTRIT_HXX
#include <svx/xfltrit.hxx>
#endif
#ifndef _SVX_XLNTRIT_HXX
#include <svx/xlntrit.hxx>
#endif
#ifndef _EEITEM_HXX
#include <svx/eeitem.hxx>
#endif
// for SfxBoolItem
#ifndef _SFXENUMITEM_HXX
#include <svtools/eitem.hxx>
#endif
// for XFillGradientStepCountItem
#ifndef _SVX_XGRSCIT_HXX
#include <svx/xgrscit.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#ifndef _COM_SUN_STAR_CHART2_FILLBITMAP_HPP_
#include <com/sun/star/chart2/FillBitmap.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_GRADIENT_HPP_
#include <com/sun/star/awt/Gradient.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
using namespace ::com::sun::star;
namespace
{
::comphelper::ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap()
{
static ::comphelper::ItemPropertyMapType aDataPointPropertyFilledMap(
::comphelper::MakeItemPropertyMap
IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
IPM_MAP_ENTRY( XATTR_FILLCOLOR, "Color", 0 )
// IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "Transparency", 0 )
// IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "Gradient", 0 )
// IPM_MAP_ENTRY( XATTR_FILLHATCH, "Hatch", 0 )
IPM_MAP_ENTRY( XATTR_LINECOLOR, "BorderColor", 0 )
IPM_MAP_ENTRY( XATTR_LINESTYLE, "BorderStyle", 0 )
IPM_MAP_ENTRY( XATTR_LINEWIDTH, "BorderWidth", 0 )
// IPM_MAP_ENTRY( XATTR_LINEDASH, "BorderDash", 0 )
// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "BorderTransparency", 0 )
IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
);
return aDataPointPropertyFilledMap;
}
::comphelper::ItemPropertyMapType & lcl_GetDataPointLinePropertyMap()
{
static ::comphelper::ItemPropertyMapType aDataPointPropertyLineMap(
::comphelper::MakeItemPropertyMap
IPM_MAP_ENTRY( XATTR_LINECOLOR, "Color", 0 )
// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "Transparency", 0 )
IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
// IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
);
return aDataPointPropertyLineMap;
}
::comphelper::ItemPropertyMapType & lcl_GetLinePropertyMap()
{
static ::comphelper::ItemPropertyMapType aLinePropertyMap(
::comphelper::MakeItemPropertyMap
IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 )
IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 )
// IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 )
IPM_MAP_ENTRY( XATTR_LINECOLOR, "LineColor", 0 )
// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "LineTransparence", 0 )
IPM_MAP_ENTRY( XATTR_LINEJOINT, "LineJoint", 0 )
);
return aLinePropertyMap;
}
::comphelper::ItemPropertyMapType & lcl_GetFillPropertyMap()
{
static ::comphelper::ItemPropertyMapType aFillPropertyMap(
::comphelper::MakeItemPropertyMap
IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 )
IPM_MAP_ENTRY( XATTR_FILLCOLOR, "FillColor", 0 )
// IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "FillTransparence", 0 )
// IPM_MAP_ENTRY( XATTR_FILLBITMAP, "FillBitmapName", MID_NAME )
// IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "FillGradient", 0 )
// IPM_MAP_ENTRY( XATTR_FILLHATCH, "FillHatch", 0 )
IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 )
IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 )
);
return aFillPropertyMap;
}
bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
{
return ( eType == ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ||
eType == ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES ||
eType == ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES );
}
bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType )
{
return ( eType != ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES );
}
bool lcl_SetContentForNamedProperty(
const uno::Reference< lang::XMultiServiceFactory > & xFactory,
const ::rtl::OUString & rTableName,
NameOrIndex & rItem, BYTE nMemberId )
{
bool bResult = false;
if( xFactory.is())
{
::rtl::OUString aPropertyValue( rItem.GetName());
uno::Reference< container::XNameAccess > xNameAcc(
xFactory->createInstance( rTableName ),
uno::UNO_QUERY );
if( xNameAcc.is() &&
xNameAcc->hasByName( aPropertyValue ))
{
rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId );
bResult = true;
}
}
return bResult;
}
} // anonymous namespace
// ========================================
namespace chart
{
namespace wrapper
{
GraphicPropertyItemConverter::GraphicPropertyItemConverter(
const uno::Reference<
beans::XPropertySet > & rPropertySet,
SfxItemPool& rItemPool,
SdrModel& rDrawModel,
const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory,
eGraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) :
ItemConverter( rPropertySet, rItemPool ),
m_eGraphicObjectType( eObjectType ),
m_rDrawModel( rDrawModel ),
m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory )
{}
GraphicPropertyItemConverter::~GraphicPropertyItemConverter()
{}
const USHORT * GraphicPropertyItemConverter::GetWhichPairs() const
{
const USHORT * pResult = NULL;
switch( m_eGraphicObjectType )
{
case LINE_DATA_POINT:
case FILLED_DATA_POINT:
pResult = nRowWhichPairs; break;
case LINE_PROPERTIES:
pResult = nLinePropertyWhichPairs; break;
case FILL_PROPERTIES:
pResult = nFillPropertyWhichPairs; break;
case LINE_AND_FILL_PROPERTIES:
pResult = nLineAndFillPropertyWhichPairs; break;
}
return pResult;
}
bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const
{
::comphelper::ItemPropertyMapType::const_iterator aEndIt;
::comphelper::ItemPropertyMapType::const_iterator aIt;
switch( m_eGraphicObjectType )
{
case LINE_DATA_POINT:
aEndIt = lcl_GetDataPointLinePropertyMap().end();
aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId );
break;
case FILLED_DATA_POINT:
aEndIt = lcl_GetDataPointFilledPropertyMap().end();
aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId );
break;
case LINE_PROPERTIES:
aEndIt = lcl_GetLinePropertyMap().end();
aIt = lcl_GetLinePropertyMap().find( nWhichId );
break;
case FILL_PROPERTIES:
aEndIt = lcl_GetFillPropertyMap().end();
aIt = lcl_GetFillPropertyMap().find( nWhichId );
break;
case LINE_AND_FILL_PROPERTIES:
// line
aEndIt = lcl_GetLinePropertyMap().end();
aIt = lcl_GetLinePropertyMap().find( nWhichId );
// not found => try fill
if( aIt == aEndIt )
{
aEndIt = lcl_GetFillPropertyMap().end();
aIt = lcl_GetFillPropertyMap().find( nWhichId );
}
break;
}
if( aIt == aEndIt )
return false;
rOutProperty =(*aIt).second;
return true;
}
void GraphicPropertyItemConverter::FillSpecialItem(
USHORT nWhichId, SfxItemSet & rOutItemSet ) const
throw( uno::Exception )
{
// if( m_eGraphicObjectType == LINE_DATA_POINT ||
// m_eGraphicObjectType == LINE_PROPERTIES )
// return;
switch( nWhichId )
{
// bitmap property
case XATTR_FILLBMP_TILE:
case XATTR_FILLBMP_STRETCH:
{
drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT;
if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode )
{
rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT ));
rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH ));
}
}
break;
// case XATTR_FILLBMP_POS:
// case XATTR_FILLBMP_SIZEX:
// case XATTR_FILLBMP_SIZEY:
// case XATTR_FILLBMP_SIZELOG:
// case XATTR_FILLBMP_TILEOFFSETX:
// case XATTR_FILLBMP_TILEOFFSETY:
// case XATTR_FILLBMP_STRETCH:
// case XATTR_FILLBMP_POSOFFSETX:
// case XATTR_FILLBMP_POSOFFSETY:
// if( lcl_supportsFillProperties( m_eGraphicObjectType ))
// {
// avoid assertions while bitmap stuff is not working
// try
// {
// FillBitmapItem( nWhichId, rOutItemSet );
// }
// catch( beans::UnknownPropertyException ex )
// {
// ASSERT_EXCEPTION( ex );
// }
// }
// break;
case XATTR_FILLFLOATTRANSPARENCE:
try
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "TransparencyGradientName" )
: C2U( "FillTransparenceGradientName" );
uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ));
if( aValue.hasValue())
{
XFillFloatTransparenceItem aItem;
aItem.PutValue( aValue, MID_NAME );
lcl_SetContentForNamedProperty(
m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"),
aItem, MID_FILLGRADIENT );
// this is important to enable the item
::rtl::OUString aName;
if( (aValue >>= aName) &&
aName.getLength())
{
aItem.SetEnabled( TRUE );
rOutItemSet.Put( aItem );
}
}
}
}
catch( beans::UnknownPropertyException ex )
{
ASSERT_EXCEPTION( ex );
}
break;
case XATTR_GRADIENTSTEPCOUNT:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "GradientStepCount" )
: C2U( "FillGradientStepCount" );
sal_Int16 nStepCount = 0;
uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) );
if( hasLongOrShortValue(aValue) )
{
nStepCount = getShortForLongAlso(aValue);
rOutItemSet.Put( XGradientStepCountItem( nStepCount ));
}
}
break;
case XATTR_LINEDASH:
if( lcl_supportsLineProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "BorderDashName" )
: C2U( "LineDashName" );
XLineDashItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
lcl_SetContentForNamedProperty(
m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"),
aItem, MID_LINEDASH );
// translate model name to UI-name for predefined entries, so
// that the correct entry is chosen in the list of UI-names
XLineDashItem * pItemToPut = & aItem;
pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
rOutItemSet.Put( * pItemToPut );
}
break;
case XATTR_FILLGRADIENT:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "GradientName" )
: C2U( "FillGradientName" );
XFillGradientItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
lcl_SetContentForNamedProperty(
m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"),
aItem, MID_FILLGRADIENT );
// translate model name to UI-name for predefined entries, so
// that the correct entry is chosen in the list of UI-names
XFillGradientItem * pItemToPut = & aItem;
pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
rOutItemSet.Put( * pItemToPut );
}
break;
case XATTR_FILLHATCH:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "HatchName" )
: C2U( "FillHatchName" );
XFillHatchItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME );
lcl_SetContentForNamedProperty(
m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"),
aItem, MID_FILLHATCH );
// translate model name to UI-name for predefined entries, so
// that the correct entry is chosen in the list of UI-names
XFillHatchItem * pItemToPut = & aItem;
pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
rOutItemSet.Put( * pItemToPut );
}
break;
case XATTR_FILLBITMAP:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
XFillBitmapItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME );
lcl_SetContentForNamedProperty(
m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"),
aItem, MID_GRAFURL );
// translate model name to UI-name for predefined entries, so
// that the correct entry is chosen in the list of UI-names
XFillBitmapItem * pItemToPut = & aItem;
pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel );
rOutItemSet.Put( * pItemToPut );
}
break;
// hack, because QueryValue of XLineTransparenceItem returns sal_Int32
// instead of sal_Int16
case XATTR_LINETRANSPARENCE:
if( lcl_supportsLineProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "BorderTransparency" )
: (m_eGraphicObjectType == LINE_DATA_POINT)
? C2U( "Transparency" )
: C2U( "LineTransparence" );
XLineTransparenceItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
rOutItemSet.Put( aItem );
}
break;
// hack, because QueryValue of XFillTransparenceItem returns sal_Int32
// instead of sal_Int16
case XATTR_FILLTRANSPARENCE:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "Transparency" )
: C2U( "FillTransparence" );
XFillTransparenceItem aItem;
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) );
rOutItemSet.Put( aItem );
}
break;
}
}
bool GraphicPropertyItemConverter::ApplySpecialItem(
USHORT nWhichId, const SfxItemSet & rItemSet )
throw( uno::Exception )
{
bool bChanged = false;
uno::Any aValue;
switch( nWhichId )
{
// bitmap property
case XATTR_FILLBMP_STRETCH:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
bool bStretched = reinterpret_cast< const XFillBmpStretchItem & >(
rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue();
drawing::BitmapMode aMode =
(bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT);
aValue <<= aMode;
if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
{
GetPropertySet()->setPropertyValue( aModePropName, aValue );
bChanged = true;
}
}
break;
case XATTR_FILLBMP_TILE:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
const ::rtl::OUString aModePropName = C2U("FillBitmapMode");
bool bTiled = reinterpret_cast< const XFillBmpTileItem & >(
rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue();
drawing::BitmapMode aMode =
(bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT);
aValue <<= aMode;
if( aValue != GetPropertySet()->getPropertyValue( aModePropName ))
{
GetPropertySet()->setPropertyValue( aModePropName, aValue );
bChanged = true;
}
}
break;
// case XATTR_FILLBMP_POS:
// case XATTR_FILLBMP_SIZEX:
// case XATTR_FILLBMP_SIZEY:
// case XATTR_FILLBMP_SIZELOG:
// case XATTR_FILLBMP_TILEOFFSETX:
// case XATTR_FILLBMP_TILEOFFSETY:
// case XATTR_FILLBMP_STRETCH:
// case XATTR_FILLBMP_POSOFFSETX:
// case XATTR_FILLBMP_POSOFFSETY:
// if( lcl_supportsFillProperties( m_eGraphicObjectType ))
// {
// avoid assertions while bitmap stuff is not working
// try
// {
// ApplyBitmapItem( nWhichId, rItemSet );
// bChanged = true;
// }
// catch( beans::UnknownPropertyException ex )
// {
// ASSERT_EXCEPTION( ex );
// }
// }
// break;
case XATTR_FILLFLOATTRANSPARENCE:
try
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "TransparencyGradientName" )
: C2U( "FillTransparenceGradientName" );
const XFillFloatTransparenceItem & rItem =
reinterpret_cast< const XFillFloatTransparenceItem & >(
rItemSet.Get( nWhichId ));
if( rItem.IsEnabled() &&
rItem.QueryValue( aValue, MID_NAME ))
{
uno::Any aGradient;
rItem.QueryValue( aGradient, MID_FILLGRADIENT );
// add TransparencyGradient to list if it does not already exist
::rtl::OUString aPreferredName;
aValue >>= aPreferredName;
aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable(
aGradient, m_xNamedPropertyTableFactory, aPreferredName );
if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
{
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
}
else
{
::rtl::OUString aName;
if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName )
&& aName.getLength() > 0 )
{
uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY );
if( xState.is())
xState->setPropertyToDefault( aPropName );
bChanged = true;
}
}
}
}
catch( beans::UnknownPropertyException ex )
{
ASSERT_EXCEPTION( ex );
}
break;
case XATTR_GRADIENTSTEPCOUNT:
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "GradientStepCount" )
: C2U( "FillGradientStepCount" );
sal_Int16 nStepCount = ( reinterpret_cast< const XGradientStepCountItem & >(
rItemSet.Get( nWhichId ))).GetValue();
aValue <<= nStepCount;
if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
{
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
}
break;
}
break;
case XATTR_LINEDASH:
{
if( lcl_supportsLineProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "BorderDashName" )
: C2U( "LineDashName" );
const XLineDashItem & rItem =
reinterpret_cast< const XLineDashItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue, MID_NAME ))
{
if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
{
// add LineDash to list
uno::Any aLineDash;
rItem.QueryValue( aLineDash, MID_LINEDASH );
::rtl::OUString aPreferredName;
aValue >>= aPreferredName;
aValue <<= PropertyHelper::addLineDashUniqueNameToTable(
aLineDash, m_xNamedPropertyTableFactory, aPreferredName );
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
}
}
}
break;
case XATTR_FILLGRADIENT:
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "GradientName" )
: C2U( "FillGradientName" );
const XFillGradientItem & rItem =
reinterpret_cast< const XFillGradientItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue, MID_NAME ))
{
if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
{
// add Gradient to list
uno::Any aGradient;
rItem.QueryValue( aGradient, MID_FILLGRADIENT );
::rtl::OUString aPreferredName;
aValue >>= aPreferredName;
aValue <<= PropertyHelper::addGradientUniqueNameToTable(
aGradient, m_xNamedPropertyTableFactory, aPreferredName );
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
}
}
}
break;
case XATTR_FILLHATCH:
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "HatchName" )
: C2U( "FillHatchName" );
const XFillHatchItem & rItem =
reinterpret_cast< const XFillHatchItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue, MID_NAME ))
{
if( aValue != GetPropertySet()->getPropertyValue( aPropName ))
{
// add Hatch to list
uno::Any aHatch;
rItem.QueryValue( aHatch, MID_FILLHATCH );
::rtl::OUString aPreferredName;
aValue >>= aPreferredName;
aValue <<= PropertyHelper::addHatchUniqueNameToTable(
aHatch, m_xNamedPropertyTableFactory, aPreferredName );
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
}
}
}
break;
case XATTR_FILLBITMAP:
{
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
const XFillBitmapItem & rItem =
reinterpret_cast< const XFillBitmapItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue, MID_NAME ))
{
if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" )))
{
// add Bitmap to list
uno::Any aBitmap;
rItem.QueryValue( aBitmap, MID_GRAFURL );
::rtl::OUString aPreferredName;
aValue >>= aPreferredName;
aValue <<= PropertyHelper::addBitmapUniqueNameToTable(
aBitmap, m_xNamedPropertyTableFactory, aPreferredName );
GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue );
bChanged = true;
}
}
}
}
break;
// hack, because QueryValue of XLineTransparenceItem returns sal_Int32
// instead of sal_Int16
case XATTR_LINETRANSPARENCE:
if( lcl_supportsLineProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "BorderTransparency" )
: (m_eGraphicObjectType == LINE_DATA_POINT)
? C2U( "Transparency" )
: C2U( "LineTransparence" );
const XLineTransparenceItem & rItem =
reinterpret_cast< const XLineTransparenceItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue ))
{
OSL_ENSURE( ! aValue.isExtractableTo(
::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
"TransparenceItem QueryValue bug is fixed. Remove hack." );
sal_Int32 nValue;
if( aValue >>= nValue )
{
OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
aValue <<= nValueToSet;
GetPropertySet()->setPropertyValue( aPropName, aValue );
bChanged = true;
}
else
{
OSL_ENSURE( false, "Wrong type in Transparency Any" );
}
}
}
break;
// hack, because QueryValue of XFillTransparenceItem returns sal_Int32
// instead of sal_Int16
case XATTR_FILLTRANSPARENCE:
if( lcl_supportsFillProperties( m_eGraphicObjectType ))
{
::rtl::OUString aPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "Transparency" )
: C2U( "FillTransparence" );
const XFillTransparenceItem & rItem =
reinterpret_cast< const XFillTransparenceItem & >(
rItemSet.Get( nWhichId ));
if( rItem.QueryValue( aValue ))
{
OSL_ENSURE( ! aValue.isExtractableTo(
::getCppuType( reinterpret_cast< const sal_Int16 * >(0))),
"TransparenceItem QueryValue bug is fixed. Remove hack." );
sal_Int32 nValue;
if( aValue >>= nValue )
{
OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" );
sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue ));
aValue <<= nValueToSet;
GetPropertySet()->setPropertyValue( aPropName, aValue );
// if linear or no transparence is set, delete the gradient
::rtl::OUString aTransGradPropName =
(m_eGraphicObjectType == FILLED_DATA_POINT)
? C2U( "TransparencyGradientName" )
: C2U( "FillTransparenceGradientName" );
GetPropertySet()->setPropertyValue(
aTransGradPropName, uno::makeAny( ::rtl::OUString() ));
bChanged = true;
}
else
{
OSL_ENSURE( false, "Wrong type in Transparency Any" );
}
}
}
break;
}
return bChanged;
}
void GraphicPropertyItemConverter::FillBitmapItem(
USHORT nWhichId, SfxItemSet & rOutItemSet ) const
throw( beans::UnknownPropertyException )
{
uno::Reference< beans::XPropertySet > xProp( GetPropertySet() );
OSL_ASSERT( xProp.is());
chart2::FillBitmap aBitmap;
( xProp->getPropertyValue( C2U( "Bitmap" ))) >>= aBitmap;
switch( nWhichId )
{
// bitmap property
case XATTR_FILLBITMAP:
{
XFillBitmapItem aBmpIt;
aBmpIt.PutValue( uno::makeAny( aBitmap.aURL ), MID_GRAFURL );
rOutItemSet.Put( aBmpIt );
}
break;
case XATTR_FILLBMP_TILE:
rOutItemSet.Put( XFillBmpTileItem(
aBitmap.aBitmapMode == drawing::BitmapMode_REPEAT ));
rOutItemSet.Put( XFillBmpStretchItem( FALSE ));
break;
case XATTR_FILLBMP_STRETCH:
rOutItemSet.Put( XFillBmpStretchItem(
aBitmap.aBitmapMode == drawing::BitmapMode_STRETCH ));
rOutItemSet.Put( XFillBmpTileItem( FALSE ));
break;
case XATTR_FILLBMP_POS:
break;
case XATTR_FILLBMP_SIZEX:
break;
case XATTR_FILLBMP_SIZEY:
break;
case XATTR_FILLBMP_SIZELOG:
break;
case XATTR_FILLBMP_TILEOFFSETX:
break;
case XATTR_FILLBMP_TILEOFFSETY:
break;
case XATTR_FILLBMP_POSOFFSETX:
break;
case XATTR_FILLBMP_POSOFFSETY:
break;
}
}
void GraphicPropertyItemConverter::ApplyBitmapItem(
USHORT nWhichId, const SfxItemSet & rItemSet )
throw( beans::UnknownPropertyException )
{
static const ::rtl::OUString aBitmapPropName(
RTL_CONSTASCII_USTRINGPARAM( "Bitmap" ));
uno::Reference< beans::XPropertySet > xProp( GetPropertySet() );
OSL_ASSERT( xProp.is());
chart2::FillBitmap aBitmap;
uno::Any aValue;
try
{
( xProp->getPropertyValue( aBitmapPropName )) >>= aBitmap;
switch( nWhichId )
{
// bitmap property
case XATTR_FILLBITMAP:
{
const XFillBitmapItem & rBitmapItem =
reinterpret_cast< const XFillBitmapItem & >(
rItemSet.Get( nWhichId ));
rBitmapItem.QueryValue( aValue, MID_GRAFURL );
aValue >>= aBitmap.aURL;
// must remember bitmap, so that URL stays valid
//ToDo: Never deleted yet !!!
// GraphicObject * pTESTING_CACHE = new GraphicObject(
// rBitmapItem.GetValue().GetGraphicObject() );
}
break;
case XATTR_FILLBMP_TILE:
case XATTR_FILLBMP_STRETCH:
{
const XFillBmpStretchItem & rStretchItem =
reinterpret_cast< const XFillBmpStretchItem & >(
rItemSet.Get( XATTR_FILLBMP_STRETCH ));
const XFillBmpTileItem & rTileItem =
reinterpret_cast< const XFillBmpTileItem & >(
rItemSet.Get( XATTR_FILLBMP_TILE ));
if( rTileItem.GetValue() != FALSE )
aBitmap.aBitmapMode = drawing::BitmapMode_REPEAT;
else if( rStretchItem.GetValue() != FALSE )
aBitmap.aBitmapMode = drawing::BitmapMode_STRETCH;
else
aBitmap.aBitmapMode = drawing::BitmapMode_NO_REPEAT;
}
break;
case XATTR_FILLBMP_POS:
break;
case XATTR_FILLBMP_SIZEX:
break;
case XATTR_FILLBMP_SIZEY:
break;
case XATTR_FILLBMP_SIZELOG:
break;
case XATTR_FILLBMP_TILEOFFSETX:
break;
case XATTR_FILLBMP_TILEOFFSETY:
break;
case XATTR_FILLBMP_POSOFFSETX:
break;
case XATTR_FILLBMP_POSOFFSETY:
break;
}
xProp->setPropertyValue( aBitmapPropName, uno::makeAny( aBitmap ));
}
catch( beans::UnknownPropertyException ex )
{
ASSERT_EXCEPTION( ex );
}
}
} // namespace wrapper
} // namespace chart