cell borders correctly applied
This commit is contained in:
parent
174b6a7b3f
commit
7114e0f23a
3 changed files with 136 additions and 32 deletions
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: DomainMapperTableHandler.cxx,v $
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Revision: 1.10 $
|
||||
*
|
||||
* last change: $Author: os $ $Date: 2007-05-21 14:21:17 $
|
||||
* last change: $Author: os $ $Date: 2007-05-24 11:34:16 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -123,6 +123,9 @@ void DomainMapperTableHandler::endTable()
|
|||
PropertyMapVector1::const_iterator aCellIterator = aRowOfCellsIterator->begin();
|
||||
PropertyMapVector1::const_iterator aCellIteratorEnd = aRowOfCellsIterator->end();
|
||||
|
||||
//contains the default border of the line
|
||||
PropertyMapPtr aCellBorders( new PropertyMap );
|
||||
|
||||
sal_Int32 nCell = 0;
|
||||
pCellProperties[nRow].realloc( aRowOfCellsIterator->size() );
|
||||
beans::PropertyValues* pSingleCellProperties = pCellProperties[nRow].getArray();
|
||||
|
@ -134,6 +137,13 @@ void DomainMapperTableHandler::endTable()
|
|||
//aCellIterator points to a PropertyMapPtr;
|
||||
if( aCellIterator->get() )
|
||||
{
|
||||
if( nCell && aCellBorders->size() )
|
||||
{
|
||||
//now apply the default border
|
||||
//TODO: This overwrites the existing values!
|
||||
aCellIterator->get()->insert( aCellBorders, false );
|
||||
}
|
||||
|
||||
|
||||
const PropertyMap::iterator aVerticalIter =
|
||||
aCellIterator->get()->find( rPropSupplier.GetName(META_PROP_VERTICAL_BORDER) );
|
||||
|
@ -143,10 +153,36 @@ void DomainMapperTableHandler::endTable()
|
|||
aCellIterator->get()->find( rPropSupplier.GetName(PROP_RIGHT_BORDER) );
|
||||
const PropertyMap::const_iterator aBottomIter =
|
||||
aCellIterator->get()->find( rPropSupplier.GetName(PROP_BOTTOM_BORDER) );
|
||||
|
||||
if( aVerticalIter != aCellIterator->get()->end())
|
||||
{
|
||||
if( !nCell )
|
||||
aCellBorders->insert(*aVerticalIter);
|
||||
aCellIterator->get()->erase( aVerticalIter );
|
||||
}
|
||||
if( aHorizontalIter != aCellIterator->get()->end())
|
||||
{
|
||||
if( !nCell )
|
||||
aCellBorders->insert(*aHorizontalIter);
|
||||
aCellIterator->get()->erase( aHorizontalIter );
|
||||
}
|
||||
//fill the additional borders into the line default border
|
||||
if( !nCell )
|
||||
{
|
||||
const PropertyMap::const_iterator aLeftIter =
|
||||
aCellIterator->get()->find( rPropSupplier.GetName(PROP_RIGHT_BORDER) );
|
||||
if(aLeftIter != aCellIterator->get()->end())
|
||||
aCellBorders->insert(*aLeftIter);
|
||||
if(aRightIter != aCellIterator->get()->end())
|
||||
aCellBorders->insert(*aRightIter);
|
||||
const PropertyMap::const_iterator aTopIter =
|
||||
aCellIterator->get()->find( rPropSupplier.GetName(PROP_TOP_BORDER) );
|
||||
if(aTopIter != aCellIterator->get()->end())
|
||||
aCellBorders->insert(*aTopIter);
|
||||
if(aBottomIter != aCellIterator->get()->end())
|
||||
aCellBorders->insert(*aBottomIter);
|
||||
}
|
||||
|
||||
//now set the default left+right border distance TODO: there's an sprm containing the default distance!
|
||||
const PropertyMap::const_iterator aLeftDistanceIter =
|
||||
aCellIterator->get()->find( rPropSupplier.GetName(PROP_LEFT_BORDER_DISTANCE) );
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: TDefTableHandler.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: os $ $Date: 2007-05-21 14:23:22 $
|
||||
* last change: $Author: os $ $Date: 2007-05-24 11:32:50 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -47,6 +47,9 @@
|
|||
#ifndef INCLUDED_RESOURCESIDS
|
||||
#include <doctok/resourceids.hxx>
|
||||
#endif
|
||||
#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
|
||||
#include <com/sun/star/table/BorderLine.hpp>
|
||||
#endif
|
||||
#ifndef _COM_SUN_STAR_TEXT_TABLECOLUMNSEPARATOR_HPP_
|
||||
#include <com/sun/star/text/TableColumnSeparator.hpp>
|
||||
#endif
|
||||
|
@ -62,7 +65,11 @@ using namespace ::writerfilter;
|
|||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
TDefTableHandler::TDefTableHandler()
|
||||
TDefTableHandler::TDefTableHandler() :
|
||||
m_nLineWidth(0),
|
||||
m_nLineType(0),
|
||||
m_nLineColor(0),
|
||||
m_nLineDistance(0)
|
||||
{
|
||||
}
|
||||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
@ -86,14 +93,9 @@ void TDefTableHandler::attribute(doctok::Id rName, doctok::Value & rVal)
|
|||
//TODO: nIntValue is wrong for negative values!
|
||||
if( nIntValue > 0x7fff )
|
||||
nIntValue -= 0xffff;
|
||||
m_aCellBorders.push_back( ConversionHelper::convertToMM100( nIntValue ) );
|
||||
m_aCellBorderPositions.push_back( ConversionHelper::convertToMM100( nIntValue ) );
|
||||
break;
|
||||
case NS_rtf::LN_tc:
|
||||
//from LN_tc
|
||||
case NS_rtf::LN_BRCTOP:
|
||||
case NS_rtf::LN_BRCLEFT:
|
||||
case NS_rtf::LN_BRCBOTTOM:
|
||||
case NS_rtf::LN_BRCRIGHT:
|
||||
{
|
||||
doctok::Reference<doctok::Properties>::Pointer_t pProperties = rVal.getProperties();
|
||||
if( pProperties.get())
|
||||
|
@ -118,14 +120,58 @@ void TDefTableHandler::attribute(doctok::Id rName, doctok::Value & rVal)
|
|||
case NS_rtf::LN_FUNUSED:
|
||||
case NS_rtf::LN_CellPrefferedSize:
|
||||
break;
|
||||
//from LN_BRCXXXX
|
||||
case NS_rtf::LN_DPTLINEWIDTH:
|
||||
case NS_rtf::LN_BRCTYPE:
|
||||
case NS_rtf::LN_ICO:
|
||||
case NS_rtf::LN_DPTSPACE:
|
||||
case NS_rtf::LN_FSHADOW:
|
||||
case NS_rtf::LN_FFRAME:
|
||||
case NS_rtf::LN_UNUSED2_15:
|
||||
case NS_rtf::LN_BRCTOP:
|
||||
case NS_rtf::LN_BRCLEFT:
|
||||
case NS_rtf::LN_BRCBOTTOM:
|
||||
case NS_rtf::LN_BRCRIGHT:
|
||||
{
|
||||
doctok::Reference<doctok::Properties>::Pointer_t pProperties = rVal.getProperties();
|
||||
if( pProperties.get())
|
||||
{
|
||||
m_nLineWidth = m_nLineType = m_nLineColor = m_nLineDistance = 0;
|
||||
pProperties->resolve( *this );
|
||||
table::BorderLine aBorderLine;
|
||||
ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor,
|
||||
aBorderLine );
|
||||
|
||||
switch( rName )
|
||||
{
|
||||
case NS_rtf::LN_BRCTOP:
|
||||
m_aTopBorderLines.push_back(aBorderLine);
|
||||
break;
|
||||
case NS_rtf::LN_BRCLEFT:
|
||||
m_aLeftBorderLines.push_back(aBorderLine);
|
||||
break;
|
||||
case NS_rtf::LN_BRCBOTTOM:
|
||||
m_aBottomBorderLines.push_back(aBorderLine);
|
||||
break;
|
||||
case NS_rtf::LN_BRCRIGHT:
|
||||
m_aRightBorderLines.push_back(aBorderLine);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
//from LN_BRCXXXX - handled within the BorderHandler
|
||||
case NS_rtf::LN_DPTLINEWIDTH: // 0x2871
|
||||
// width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2.
|
||||
m_nLineWidth = ConversionHelper::convertToMM100( nIntValue * 5 / 2 );
|
||||
break;
|
||||
case NS_rtf::LN_BRCTYPE: // 0x2872
|
||||
m_nLineType = nIntValue;
|
||||
break;
|
||||
case NS_rtf::LN_ICO: // 0x2873
|
||||
m_nLineColor = nIntValue;
|
||||
break;
|
||||
case NS_rtf::LN_DPTSPACE: // 0x2874
|
||||
m_nLineDistance = nIntValue;
|
||||
break;
|
||||
case NS_rtf::LN_FSHADOW: // 0x2875
|
||||
//if 1 then line has shadow - unsupported
|
||||
case NS_rtf::LN_FFRAME: // 0x2876
|
||||
case NS_rtf::LN_UNUSED2_15: // 0x2877
|
||||
// ignored
|
||||
break;
|
||||
default:
|
||||
OSL_ASSERT("unknown attribute");
|
||||
|
@ -146,18 +192,18 @@ PropertyMapPtr TDefTableHandler::getRowProperties() const
|
|||
PropertyMapPtr pPropertyMap(new PropertyMap);
|
||||
|
||||
// Writer only wants the separators, Word provides also the outer border positions
|
||||
if( m_aCellBorders.size() > 2 )
|
||||
if( m_aCellBorderPositions.size() > 2 )
|
||||
{
|
||||
//determine table width
|
||||
double nFullWidth = m_aCellBorders[m_aCellBorders.size() - 1] - m_aCellBorders[0];
|
||||
double nFullWidth = m_aCellBorderPositions[m_aCellBorderPositions.size() - 1] - m_aCellBorderPositions[0];
|
||||
//the positions have to be distibuted in a range of 10000
|
||||
const double nFullWidthRelative = 10000.;
|
||||
uno::Sequence< text::TableColumnSeparator > aSeparators( m_aCellBorders.size() - 2 );
|
||||
uno::Sequence< text::TableColumnSeparator > aSeparators( m_aCellBorderPositions.size() - 2 );
|
||||
text::TableColumnSeparator* pSeparators = aSeparators.getArray();
|
||||
for( sal_uInt32 nBorder = 1; nBorder < m_aCellBorders.size() - 1; ++nBorder )
|
||||
for( sal_uInt32 nBorder = 1; nBorder < m_aCellBorderPositions.size() - 1; ++nBorder )
|
||||
{
|
||||
sal_Int16 nRelPos =
|
||||
sal::static_int_cast< sal_Int16 >(double(m_aCellBorders[nBorder]) * nFullWidthRelative / nFullWidth );
|
||||
sal::static_int_cast< sal_Int16 >(double(m_aCellBorderPositions[nBorder]) * nFullWidthRelative / nFullWidth );
|
||||
|
||||
pSeparators[nBorder - 1].Position = nRelPos;
|
||||
pSeparators[nBorder - 1].IsVisible = sal_True;
|
||||
|
@ -173,7 +219,7 @@ PropertyMapPtr TDefTableHandler::getRowProperties() const
|
|||
::boost::shared_ptr<PropertyMap> TDefTableHandler::getCellProperties( size_t nCell ) const
|
||||
{
|
||||
PropertyMapPtr pPropertyMap(new PropertyMap);
|
||||
if( m_aCellBorders.size() > nCell )
|
||||
if( m_aCellBorderPositions.size() > nCell )
|
||||
{
|
||||
sal_Int16 nVertOrient = text::VertOrientation::NONE;
|
||||
switch( m_aCellVertAlign[nCell] ) //0 - top 1 - center 2 - bottom
|
||||
|
@ -184,6 +230,14 @@ PropertyMapPtr TDefTableHandler::getRowProperties() const
|
|||
}
|
||||
pPropertyMap->Insert( PROP_VERT_ORIENT, uno::makeAny( nVertOrient ) );
|
||||
}
|
||||
if( m_aTopBorderLines.size() > nCell )
|
||||
pPropertyMap->Insert( PROP_TOP_BORDER, uno::makeAny( m_aTopBorderLines[nCell] ) );
|
||||
if( m_aLeftBorderLines.size() > nCell )
|
||||
pPropertyMap->Insert( PROP_LEFT_BORDER, uno::makeAny( m_aLeftBorderLines[nCell] ) );
|
||||
if( m_aBottomBorderLines.size() > nCell )
|
||||
pPropertyMap->Insert( PROP_BOTTOM_BORDER, uno::makeAny( m_aBottomBorderLines[nCell] ) );
|
||||
if( m_aRightBorderLines.size() > nCell )
|
||||
pPropertyMap->Insert( PROP_RIGHT_BORDER, uno::makeAny( m_aRightBorderLines[nCell] ) );
|
||||
return pPropertyMap;
|
||||
}
|
||||
/*-- 09.05.2007 13:14:17---------------------------------------------------
|
||||
|
@ -192,10 +246,10 @@ PropertyMapPtr TDefTableHandler::getRowProperties() const
|
|||
sal_Int32 TDefTableHandler::getTableWidth() const
|
||||
{
|
||||
sal_Int32 nWidth = 0;
|
||||
if( m_aCellBorders.size() > 1 )
|
||||
if( m_aCellBorderPositions.size() > 1 )
|
||||
{
|
||||
//determine table width
|
||||
nWidth = m_aCellBorders[m_aCellBorders.size() - 1] - m_aCellBorders[0];
|
||||
nWidth = m_aCellBorderPositions[m_aCellBorderPositions.size() - 1] - m_aCellBorderPositions[0];
|
||||
}
|
||||
return nWidth;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
*
|
||||
* $RCSfile: TDefTableHandler.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: os $ $Date: 2007-05-21 14:23:22 $
|
||||
* last change: $Author: os $ $Date: 2007-05-24 11:32:50 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU Lesser General Public License Version 2.1.
|
||||
|
@ -40,11 +40,13 @@
|
|||
#endif
|
||||
#include <doctok/WW8ResourceModel.hxx>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
//#include <com/sun/star/table/TableBorder.hpp>
|
||||
#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
|
||||
#include <com/sun/star/table/BorderLine.hpp>
|
||||
#endif
|
||||
#include <vector>
|
||||
namespace com{ namespace sun{ namespace star{namespace table {
|
||||
struct BorderLine;
|
||||
}}}}
|
||||
namespace dmapper
|
||||
{
|
||||
class PropertyMap;
|
||||
|
@ -53,8 +55,20 @@ class WRITERFILTER_DLLPRIVATE TDefTableHandler : public doctok::Properties
|
|||
public:
|
||||
|
||||
private:
|
||||
::std::vector<sal_Int32> m_aCellBorders;
|
||||
::std::vector<sal_Int32> m_aCellVertAlign;
|
||||
::std::vector<sal_Int32> m_aCellBorderPositions;
|
||||
::std::vector<sal_Int32> m_aCellVertAlign;
|
||||
|
||||
::std::vector< ::com::sun::star::table::BorderLine > m_aLeftBorderLines;
|
||||
::std::vector< ::com::sun::star::table::BorderLine > m_aRightBorderLines;
|
||||
::std::vector< ::com::sun::star::table::BorderLine > m_aTopBorderLines;
|
||||
::std::vector< ::com::sun::star::table::BorderLine > m_aBottomBorderLines;
|
||||
|
||||
//values of the current border
|
||||
sal_Int32 m_nLineWidth;
|
||||
sal_Int32 m_nLineType;
|
||||
sal_Int32 m_nLineColor;
|
||||
sal_Int32 m_nLineDistance;
|
||||
|
||||
public:
|
||||
TDefTableHandler( );
|
||||
virtual ~TDefTableHandler();
|
||||
|
|
Loading…
Reference in a new issue