2009-08-26 13:11:27 +00:00
|
|
|
/*************************************************************************
|
2010-02-12 15:01:35 +01:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2009-08-26 13:11:27 +00:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
2011-01-04 10:26:14 +01:00
|
|
|
#include "cellvalueconversion.hxx"
|
2009-08-26 13:11:27 +00:00
|
|
|
#include "svtools/table/gridtablerenderer.hxx"
|
|
|
|
|
2011-01-04 10:26:14 +01:00
|
|
|
#include <com/sun/star/graphic/XGraphic.hpp>
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <vcl/window.hxx>
|
2010-02-12 17:08:15 +01:00
|
|
|
#include <vcl/image.hxx>
|
2009-08-26 13:11:27 +00:00
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
namespace svt { namespace table
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
2011-01-04 10:26:14 +01:00
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
|
|
using ::com::sun::star::graphic::XGraphic;
|
|
|
|
using ::com::sun::star::style::HorizontalAlignment;
|
|
|
|
using ::com::sun::star::style::HorizontalAlignment_LEFT;
|
|
|
|
using ::com::sun::star::style::HorizontalAlignment_CENTER;
|
|
|
|
using ::com::sun::star::style::HorizontalAlignment_RIGHT;
|
|
|
|
using ::com::sun::star::style::VerticalAlignment;
|
|
|
|
using ::com::sun::star::style::VerticalAlignment_TOP;
|
|
|
|
using ::com::sun::star::style::VerticalAlignment_MIDDLE;
|
|
|
|
using ::com::sun::star::style::VerticalAlignment_BOTTOM;
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
struct GridTableRenderer_Impl
|
|
|
|
{
|
|
|
|
ITableModel& rModel;
|
|
|
|
RowPos nCurrentRow;
|
|
|
|
|
|
|
|
GridTableRenderer_Impl( ITableModel& _rModel )
|
|
|
|
:rModel( _rModel )
|
|
|
|
,nCurrentRow( ROW_INVALID )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
//= GridTableRenderer
|
|
|
|
//====================================================================
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
GridTableRenderer::GridTableRenderer( ITableModel& _rModel )
|
|
|
|
:m_pImpl( new GridTableRenderer_Impl( _rModel ) )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
GridTableRenderer::~GridTableRenderer()
|
|
|
|
{
|
|
|
|
DELETEZ( m_pImpl );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RowPos GridTableRenderer::getCurrentRow()
|
|
|
|
{
|
|
|
|
return m_pImpl->nCurrentRow;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::PaintHeaderArea(
|
|
|
|
OutputDevice& _rDevice, const Rectangle& _rArea, bool _bIsColHeaderArea, bool _bIsRowHeaderArea,
|
|
|
|
const StyleSettings& _rStyle )
|
|
|
|
{
|
|
|
|
OSL_PRECOND( _bIsColHeaderArea || _bIsRowHeaderArea,
|
|
|
|
"GridTableRenderer::PaintHeaderArea: invalid area flags!" );
|
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
_rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
|
2010-04-16 16:55:27 +02:00
|
|
|
Color background = m_pImpl->rModel.getHeaderBackgroundColor();
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( background != COL_TRANSPARENT )
|
|
|
|
_rDevice.SetFillColor( background );
|
2010-04-16 16:55:27 +02:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetFillColor( _rStyle.GetDialogColor() );
|
|
|
|
_rDevice.SetLineColor( _rStyle.GetSeparatorColor() );
|
2009-08-26 13:11:27 +00:00
|
|
|
_rDevice.DrawRect( _rArea );
|
|
|
|
// delimiter lines at bottom/right
|
|
|
|
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
|
|
|
|
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
|
|
|
|
|
|
|
|
_rDevice.Pop();
|
2010-04-16 16:55:27 +02:00
|
|
|
(void)_bIsColHeaderArea;
|
|
|
|
(void)_bIsRowHeaderArea;
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::PaintColumnHeader( ColPos _nCol, bool _bActive, bool _bSelected,
|
|
|
|
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
|
|
|
|
{
|
2010-02-12 17:08:15 +01:00
|
|
|
_rDevice.Push( PUSH_LINECOLOR);
|
2010-04-16 16:55:27 +02:00
|
|
|
_rDevice.SetLineColor(_rStyle.GetSeparatorColor());
|
2010-02-12 17:08:15 +01:00
|
|
|
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight());
|
2009-08-26 13:11:27 +00:00
|
|
|
|
|
|
|
String sHeaderText;
|
|
|
|
PColumnModel pColumn = m_pImpl->rModel.getColumnModel( _nCol );
|
|
|
|
DBG_ASSERT( !!pColumn, "GridTableRenderer::PaintColumnHeader: invalid column model object!" );
|
|
|
|
if ( !!pColumn )
|
|
|
|
sHeaderText = pColumn->getName();
|
2010-06-09 14:39:18 +02:00
|
|
|
if(m_pImpl->rModel.getTextColor() != 0x000000)
|
|
|
|
_rDevice.SetTextColor(m_pImpl->rModel.getTextColor());
|
|
|
|
else
|
|
|
|
_rDevice.SetTextColor(_rStyle.GetFieldTextColor());
|
2010-04-16 16:55:27 +02:00
|
|
|
ULONG nHorFlag = TEXT_DRAW_LEFT;
|
|
|
|
ULONG nVerFlag = TEXT_DRAW_TOP;
|
|
|
|
if(m_pImpl->rModel.getVerticalAlign() == 1)
|
|
|
|
nVerFlag = TEXT_DRAW_VCENTER;
|
|
|
|
else if(m_pImpl->rModel.getVerticalAlign() == 2)
|
|
|
|
nVerFlag = TEXT_DRAW_BOTTOM;
|
|
|
|
if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 1)
|
|
|
|
nHorFlag = TEXT_DRAW_CENTER;
|
|
|
|
else if(m_pImpl->rModel.getColumnModel(_nCol)->getHorizontalAlign() == 2)
|
|
|
|
nHorFlag = TEXT_DRAW_RIGHT;
|
|
|
|
Rectangle aRect(_rArea);
|
|
|
|
aRect.Left()+=4; aRect.Right()-=4;
|
2010-04-23 17:41:32 +02:00
|
|
|
aRect.Bottom()-=2;
|
2010-04-16 16:55:27 +02:00
|
|
|
_rDevice.DrawText( aRect, sHeaderText, nHorFlag | nVerFlag | TEXT_DRAW_CLIP);
|
|
|
|
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
|
2009-08-26 13:11:27 +00:00
|
|
|
_rDevice.Pop();
|
|
|
|
|
|
|
|
(void)_bActive;
|
|
|
|
// no special painting for the active column at the moment
|
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
(void)_bSelected;
|
|
|
|
//selection for column header not yet implemented
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::PrepareRow( RowPos _nRow, bool _bActive, bool _bSelected,
|
|
|
|
OutputDevice& _rDevice, const Rectangle& _rRowArea, const StyleSettings& _rStyle )
|
|
|
|
{
|
|
|
|
// remember the row for subsequent calls to the other ->ITableRenderer methods
|
|
|
|
m_pImpl->nCurrentRow = _nRow;
|
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
_rDevice.Push( PUSH_FILLCOLOR | PUSH_LINECOLOR);
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
Color aRowBackground = m_pImpl->rModel.getOddRowBackgroundColor();
|
2011-01-04 10:26:14 +01:00
|
|
|
const Color lineColor = m_pImpl->rModel.getLineColor();
|
2010-04-16 16:55:27 +02:00
|
|
|
Color aRowBackground2 = m_pImpl->rModel.getEvenRowBackgroundColor();
|
2011-01-04 10:26:14 +01:00
|
|
|
const Color fieldColor = _rStyle.GetFieldColor();
|
|
|
|
if ( aRowBackground == COL_TRANSPARENT )
|
2010-06-09 14:39:18 +02:00
|
|
|
aRowBackground = fieldColor;
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( aRowBackground2 == COL_TRANSPARENT )
|
2010-06-09 14:39:18 +02:00
|
|
|
aRowBackground2 = fieldColor;
|
2010-04-16 16:55:27 +02:00
|
|
|
//if row is selected background color becomes blue, and lines should be also blue
|
|
|
|
//if they aren't user defined
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( _bSelected )
|
2010-02-12 17:08:15 +01:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
const Color aSelected( _rStyle.GetHighlightColor() );
|
2010-04-16 16:55:27 +02:00
|
|
|
aRowBackground = aSelected;
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( lineColor == COL_TRANSPARENT )
|
|
|
|
_rDevice.SetLineColor( aRowBackground );
|
2010-02-12 17:08:15 +01:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
2011-01-04 10:26:14 +01:00
|
|
|
// if row not selected, check the cases whether user defined backgrounds are set
|
|
|
|
// and set line color to be the same
|
2010-02-12 17:08:15 +01:00
|
|
|
else
|
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( ( aRowBackground2 != fieldColor ) && ( _nRow % 2 ) )
|
2010-04-16 16:55:27 +02:00
|
|
|
{
|
|
|
|
aRowBackground = aRowBackground2;
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( lineColor == COL_TRANSPARENT )
|
|
|
|
_rDevice.SetLineColor( aRowBackground );
|
2010-04-16 16:55:27 +02:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-04-16 16:55:27 +02:00
|
|
|
}
|
|
|
|
//fill the rows with alternating background colors if second background color is specified
|
2011-01-04 10:26:14 +01:00
|
|
|
else if ( aRowBackground != fieldColor && lineColor == COL_TRANSPARENT )
|
|
|
|
_rDevice.SetLineColor( aRowBackground );
|
2010-04-16 16:55:27 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
//if Line color is set, then it was user defined and should be visible
|
|
|
|
//if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-04-16 16:55:27 +02:00
|
|
|
}
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
_rDevice.SetFillColor( aRowBackground );
|
2010-04-16 16:55:27 +02:00
|
|
|
_rDevice.DrawRect( _rRowArea );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
// TODO: active?
|
2009-08-26 13:11:27 +00:00
|
|
|
|
|
|
|
_rDevice.Pop();
|
2010-04-16 16:55:27 +02:00
|
|
|
(void)_bActive;
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2011-01-03 16:01:14 +01:00
|
|
|
void GridTableRenderer::PaintRowHeader( RowPos const i_rowPos, bool _bActive, bool _bSelected, OutputDevice& _rDevice, const Rectangle& _rArea,
|
|
|
|
const StyleSettings& _rStyle )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.Push( PUSH_LINECOLOR | PUSH_TEXTCOLOR );
|
|
|
|
|
|
|
|
_rDevice.SetLineColor( _rStyle.GetSeparatorColor() );
|
2009-08-26 13:11:27 +00:00
|
|
|
_rDevice.DrawLine( _rArea.BottomLeft(), _rArea.BottomRight() );
|
2011-01-04 10:26:14 +01:00
|
|
|
|
|
|
|
if ( m_pImpl->rModel.getTextColor() != 0x000000 )
|
|
|
|
_rDevice.SetTextColor( m_pImpl->rModel.getTextColor() );
|
2010-06-09 14:39:18 +02:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetTextColor( _rStyle.GetFieldTextColor() );
|
|
|
|
|
2010-04-16 16:55:27 +02:00
|
|
|
ULONG nHorFlag = TEXT_DRAW_LEFT;
|
|
|
|
ULONG nVerFlag = TEXT_DRAW_TOP;
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( m_pImpl->rModel.getVerticalAlign() == 1 )
|
2010-04-16 16:55:27 +02:00
|
|
|
nVerFlag = TEXT_DRAW_VCENTER;
|
2011-01-04 10:26:14 +01:00
|
|
|
else if ( m_pImpl->rModel.getVerticalAlign() == 2 )
|
2010-04-16 16:55:27 +02:00
|
|
|
nVerFlag = TEXT_DRAW_BOTTOM;
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 1 )
|
2010-04-16 16:55:27 +02:00
|
|
|
nHorFlag = TEXT_DRAW_CENTER;
|
2011-01-04 10:26:14 +01:00
|
|
|
else if ( m_pImpl->rModel.getColumnModel(0)->getHorizontalAlign() == 2 )
|
2010-04-16 16:55:27 +02:00
|
|
|
nHorFlag = TEXT_DRAW_RIGHT;
|
2011-01-04 10:26:14 +01:00
|
|
|
|
|
|
|
Rectangle aRect( _rArea );
|
2010-04-16 16:55:27 +02:00
|
|
|
aRect.Left()+=4; aRect.Right()-=4;
|
2010-04-23 17:41:32 +02:00
|
|
|
aRect.Bottom()-=2;
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.DrawText( aRect, m_pImpl->rModel.getRowHeader( i_rowPos ), nHorFlag | nVerFlag | TEXT_DRAW_CLIP );
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
// TODO: active? selected?
|
|
|
|
(void)_bActive;
|
|
|
|
(void)_bSelected;
|
|
|
|
_rDevice.Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2011-01-04 10:26:14 +01:00
|
|
|
struct GridTableRenderer::CellRenderContext
|
|
|
|
{
|
|
|
|
OutputDevice& rDevice;
|
|
|
|
Rectangle const aContentArea;
|
|
|
|
StyleSettings const & rStyle;
|
|
|
|
ColPos const nColumn;
|
|
|
|
bool const bSelected;
|
|
|
|
|
|
|
|
CellRenderContext( OutputDevice& i_device, Rectangle const & i_contentArea,
|
|
|
|
StyleSettings const & i_style, ColPos const i_column, bool const i_selected )
|
|
|
|
:rDevice( i_device )
|
|
|
|
,aContentArea( i_contentArea )
|
|
|
|
,rStyle( i_style )
|
|
|
|
,nColumn( i_column )
|
|
|
|
,bSelected( i_selected )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::PaintCell( ColPos const i_column, bool _bSelected, bool _bActive,
|
|
|
|
OutputDevice& _rDevice, const Rectangle& _rArea, const StyleSettings& _rStyle )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
|
2010-06-04 15:02:11 +02:00
|
|
|
Color background1 = m_pImpl->rModel.getOddRowBackgroundColor();
|
|
|
|
Color background2 = m_pImpl->rModel.getEvenRowBackgroundColor();
|
2011-01-04 10:26:14 +01:00
|
|
|
Color lineColor = m_pImpl->rModel.getLineColor();
|
|
|
|
|
|
|
|
// if row is selected and line color isn't user specified, use the settings' color
|
|
|
|
if ( _bSelected )
|
2010-02-12 17:08:15 +01:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( lineColor == COL_TRANSPARENT )
|
|
|
|
_rDevice.SetLineColor( _rStyle.GetHighlightColor() );
|
2010-02-12 17:08:15 +01:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
2011-01-04 10:26:14 +01:00
|
|
|
// else set line color to the color of row background
|
2010-02-12 17:08:15 +01:00
|
|
|
else
|
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( ( background2 != COL_TRANSPARENT ) && ( m_pImpl->nCurrentRow % 2 ) )
|
2010-06-04 15:02:11 +02:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
if ( lineColor == COL_TRANSPARENT )
|
|
|
|
_rDevice.SetLineColor( background2 );
|
2010-06-04 15:02:11 +02:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-06-04 15:02:11 +02:00
|
|
|
}
|
2011-01-04 10:26:14 +01:00
|
|
|
else if ( ( background1 != COL_TRANSPARENT ) && ( lineColor == COL_TRANSPARENT ) )
|
|
|
|
_rDevice.SetLineColor( background1 );
|
2010-06-04 15:02:11 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
//if line color is set, then it was user defined and should be visible
|
|
|
|
//if it wasn't set, it'll be the same as the default background color, so lines still won't be visible
|
2011-01-04 10:26:14 +01:00
|
|
|
_rDevice.SetLineColor( lineColor );
|
2010-06-04 15:02:11 +02:00
|
|
|
}
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
2010-06-04 15:02:11 +02:00
|
|
|
_rDevice.DrawLine( _rArea.BottomRight(), _rArea.TopRight() );
|
|
|
|
|
|
|
|
Rectangle aRect( _rArea );
|
|
|
|
++aRect.Left(); --aRect.Right();
|
2011-01-04 10:26:14 +01:00
|
|
|
|
|
|
|
const CellRenderContext aRenderContext( _rDevice, aRect, _rStyle, i_column, _bSelected );
|
|
|
|
impl_paintCellContent( aRenderContext );
|
|
|
|
|
2010-06-04 15:02:11 +02:00
|
|
|
_rDevice.Pop();
|
2010-02-12 17:08:15 +01:00
|
|
|
|
|
|
|
(void)_bActive;
|
2010-03-23 15:28:55 +01:00
|
|
|
// no special painting for the active cell at the moment
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2011-01-04 10:26:14 +01:00
|
|
|
void GridTableRenderer::impl_paintCellImage( CellRenderContext const & i_context, Image const & i_image )
|
|
|
|
{
|
|
|
|
Point imagePos( Point( i_context.aContentArea.Left(), i_context.aContentArea.Top() ) );
|
|
|
|
Size imageSize = i_image.GetSizePixel();
|
|
|
|
if ( i_context.aContentArea.GetWidth() > imageSize.Width() )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign();
|
|
|
|
switch ( eHorzAlign )
|
|
|
|
{
|
|
|
|
case HorizontalAlignment_CENTER:
|
|
|
|
imagePos.X() += ( i_context.aContentArea.GetWidth() - imageSize.Width() ) / 2;
|
|
|
|
break;
|
|
|
|
case HorizontalAlignment_RIGHT:
|
|
|
|
imagePos.X() = i_context.aContentArea.Right() - imageSize.Width();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-12 17:08:15 +01:00
|
|
|
}
|
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
imageSize.Width() = i_context.aContentArea.GetWidth();
|
|
|
|
|
|
|
|
if ( i_context.aContentArea.GetHeight() > imageSize.Height() )
|
2010-02-12 17:08:15 +01:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign();
|
|
|
|
switch ( eVertAlign )
|
2010-06-04 15:02:11 +02:00
|
|
|
{
|
2011-01-04 10:26:14 +01:00
|
|
|
case VerticalAlignment_MIDDLE:
|
|
|
|
imagePos.Y() += ( i_context.aContentArea.GetHeight() - imageSize.Height() ) / 2;
|
|
|
|
break;
|
|
|
|
case VerticalAlignment_BOTTOM:
|
|
|
|
imagePos.Y() = i_context.aContentArea.Bottom() - imageSize.Height();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2010-06-04 15:02:11 +02:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
2011-01-04 10:26:14 +01:00
|
|
|
else
|
|
|
|
imageSize.Height() = i_context.aContentArea.GetHeight() - 1;
|
2010-06-04 15:02:11 +02:00
|
|
|
|
2011-01-04 10:26:14 +01:00
|
|
|
i_context.rDevice.DrawImage( imagePos, imageSize, i_image, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::impl_paintCellContent( CellRenderContext const & i_context )
|
|
|
|
{
|
|
|
|
Any aCellContent;
|
2011-01-04 10:37:54 +01:00
|
|
|
m_pImpl->rModel.getCellContent( i_context.nColumn, m_pImpl->nCurrentRow, aCellContent );
|
2011-01-04 10:26:14 +01:00
|
|
|
|
|
|
|
const Reference< XGraphic > xGraphic( aCellContent, UNO_QUERY );
|
|
|
|
if ( xGraphic.is() )
|
|
|
|
{
|
|
|
|
const Image aImage( xGraphic );
|
|
|
|
impl_paintCellImage( i_context, aImage );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ::rtl::OUString sText( CellValueConversion::convertToString( aCellContent ) );
|
|
|
|
impl_paintCellText( i_context, sText );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::impl_paintCellText( CellRenderContext const & i_context, ::rtl::OUString const & i_text )
|
|
|
|
{
|
|
|
|
if ( i_context.bSelected )
|
|
|
|
i_context.rDevice.SetTextColor( i_context.rStyle.GetHighlightTextColor() );
|
|
|
|
else if ( m_pImpl->rModel.getTextColor() != 0x000000 )
|
|
|
|
i_context.rDevice.SetTextColor( m_pImpl->rModel.getTextColor() );
|
2010-06-09 14:39:18 +02:00
|
|
|
else
|
2011-01-04 10:26:14 +01:00
|
|
|
i_context.rDevice.SetTextColor( i_context.rStyle.GetFieldTextColor() );
|
|
|
|
|
|
|
|
|
2010-03-23 15:28:55 +01:00
|
|
|
ULONG nVerFlag = TEXT_DRAW_TOP;
|
2011-01-04 10:26:14 +01:00
|
|
|
const VerticalAlignment eVertAlign = m_pImpl->rModel.getVerticalAlign();
|
|
|
|
switch ( eVertAlign )
|
|
|
|
{
|
|
|
|
case VerticalAlignment_MIDDLE: nVerFlag = TEXT_DRAW_VCENTER; break;
|
|
|
|
case VerticalAlignment_BOTTOM: nVerFlag = TEXT_DRAW_BOTTOM; break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-06-04 15:02:11 +02:00
|
|
|
|
2011-01-04 10:26:14 +01:00
|
|
|
ULONG nHorFlag = TEXT_DRAW_LEFT;
|
|
|
|
const HorizontalAlignment eHorzAlign = m_pImpl->rModel.getColumnModel( i_context.nColumn )->getHorizontalAlign();
|
|
|
|
switch ( eHorzAlign )
|
|
|
|
{
|
|
|
|
case HorizontalAlignment_CENTER: nHorFlag = TEXT_DRAW_CENTER; break;
|
|
|
|
case HorizontalAlignment_RIGHT: nHorFlag = TEXT_DRAW_RIGHT; break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle textRect( i_context.aContentArea );
|
|
|
|
textRect.Left() += 2; textRect.Right() -= 2;
|
|
|
|
++textRect.Top(); --textRect.Bottom();
|
|
|
|
|
|
|
|
i_context.rDevice.DrawText( textRect, i_text, nHorFlag | nVerFlag | TEXT_DRAW_CLIP );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::ShowCellCursor( Window& _rView, const Rectangle& _rCursorRect)
|
|
|
|
{
|
|
|
|
_rView.ShowFocus( _rCursorRect );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void GridTableRenderer::HideCellCursor( Window& _rView, const Rectangle& _rCursorRect)
|
|
|
|
{
|
2010-03-23 15:28:55 +01:00
|
|
|
(void)_rCursorRect;
|
2009-08-26 13:11:27 +00:00
|
|
|
_rView.HideFocus();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
} } // namespace svt::table
|
|
|
|
//........................................................................
|
|
|
|
|