handler of border attributes
This commit is contained in:
parent
09a7fefdc1
commit
c690115805
2 changed files with 253 additions and 0 deletions
168
writerfilter/source/dmapper/BorderHandler.cxx
Normal file
168
writerfilter/source/dmapper/BorderHandler.cxx
Normal file
|
@ -0,0 +1,168 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: BorderHandler.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: os $ $Date: 2007-04-25 11:28:48 $
|
||||
*
|
||||
* 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
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef INCLUDED_BORDERHANDLER_HXX
|
||||
#include <BorderHandler.hxx>
|
||||
#endif
|
||||
#ifndef INCLUDED_DMAPPER_PROPERTYMAP_HXX
|
||||
#include <PropertyMap.hxx>
|
||||
#endif
|
||||
#ifndef INCLUDED_RESOURCESIDS
|
||||
#include <doctok/resourceids.hxx>
|
||||
#endif
|
||||
#ifndef INCLUDED_DMAPPER_CONVERSIONHELPER_HXX
|
||||
#include <ConversionHelper.hxx>
|
||||
#endif
|
||||
#ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_
|
||||
#include <com/sun/star/table/BorderLine.hpp>
|
||||
#endif
|
||||
|
||||
namespace dmapper {
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
//using namespace ::std;
|
||||
|
||||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
BorderHandler::BorderHandler() :
|
||||
m_nCurrentBorderPosition( BORDER_TOP ),
|
||||
m_nLineWidth(0),
|
||||
m_nLineType(0),
|
||||
m_nLineColor(0),
|
||||
m_nLineDistance(0)
|
||||
{
|
||||
m_aTableBorder.IsTopLineValid = sal_False;;
|
||||
m_aTableBorder.IsBottomLineValid = sal_False;;
|
||||
m_aTableBorder.IsLeftLineValid = sal_False;;
|
||||
m_aTableBorder.IsRightLineValid = sal_False;;
|
||||
m_aTableBorder.IsHorizontalLineValid = sal_False;;
|
||||
m_aTableBorder.IsVerticalLineValid = sal_False;;
|
||||
m_aTableBorder.IsDistanceValid = sal_False;
|
||||
}
|
||||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
BorderHandler::~BorderHandler()
|
||||
{
|
||||
}
|
||||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
void BorderHandler::attribute(doctok::Id rName, doctok::Value & rVal)
|
||||
{
|
||||
sal_Int32 nIntValue = rVal.getInt();
|
||||
switch( rName )
|
||||
{
|
||||
case NS_rtf::LN_rgbrc:
|
||||
{
|
||||
doctok::Reference<Properties>::Pointer_t pProperties = rVal.getProperties();
|
||||
if( pProperties.get())
|
||||
{
|
||||
pProperties->resolve(*this);
|
||||
//
|
||||
table::BorderLine* pToFill = 0;
|
||||
switch(m_nCurrentBorderPosition)
|
||||
{
|
||||
case BORDER_TOP:
|
||||
pToFill = &m_aTableBorder.TopLine;
|
||||
m_aTableBorder.IsTopLineValid = sal_True;
|
||||
break;
|
||||
case BORDER_LEFT:
|
||||
pToFill = &m_aTableBorder.LeftLine;
|
||||
m_aTableBorder.IsLeftLineValid = sal_True;
|
||||
break;
|
||||
case BORDER_BOTTOM:
|
||||
pToFill = &m_aTableBorder.BottomLine;
|
||||
m_aTableBorder.IsBottomLineValid = sal_True;;
|
||||
break;
|
||||
case BORDER_RIGHT:
|
||||
pToFill = &m_aTableBorder.RightLine;
|
||||
m_aTableBorder.IsRightLineValid = sal_True;
|
||||
break;
|
||||
case BORDER_HORIZONTAL:
|
||||
pToFill = &m_aTableBorder.HorizontalLine;
|
||||
m_aTableBorder.IsHorizontalLineValid = sal_True;;
|
||||
break;
|
||||
case BORDER_VERTICAL:
|
||||
m_aTableBorder.IsVerticalLineValid = sal_True;;
|
||||
default:
|
||||
pToFill = &m_aTableBorder.VerticalLine; break;
|
||||
}
|
||||
ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor, *pToFill );
|
||||
OSL_ENSURE(m_nCurrentBorderPosition <= BORDER_VERTICAL, "too many border values");
|
||||
++m_nCurrentBorderPosition;
|
||||
}
|
||||
}
|
||||
break;
|
||||
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");
|
||||
}
|
||||
}
|
||||
/*-- 24.04.2007 09:06:35---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
void BorderHandler::sprm(doctok::Sprm & rSprm)
|
||||
{
|
||||
(void)rSprm;
|
||||
}
|
||||
/*-- 24.04.2007 09:09:01---------------------------------------------------
|
||||
|
||||
-----------------------------------------------------------------------*/
|
||||
PropertyMapPtr BorderHandler::getProperties()
|
||||
{
|
||||
PropertyMapPtr pPropertyMap(new PropertyMap);
|
||||
pPropertyMap->Insert( PROP_TABLE_BORDER, uno::makeAny( m_aTableBorder ) );
|
||||
return pPropertyMap;
|
||||
}
|
||||
} //namespace dmapper
|
85
writerfilter/source/dmapper/BorderHandler.hxx
Normal file
85
writerfilter/source/dmapper/BorderHandler.hxx
Normal file
|
@ -0,0 +1,85 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: BorderHandler.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: os $ $Date: 2007-04-25 11:28:59 $
|
||||
*
|
||||
* 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
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef INCLUDED_BORDERHANDLER_HXX
|
||||
#define INCLUDED_BORDERHANDLER_HXX
|
||||
|
||||
#ifndef INCLUDED_WRITERFILTERDLLAPI_H
|
||||
#include <WriterFilterDllApi.hxx>
|
||||
#endif
|
||||
#include <doctok/WW8ResourceModel.hxx>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <com/sun/star/table/TableBorder.hpp>
|
||||
|
||||
namespace dmapper
|
||||
{
|
||||
class PropertyMap;
|
||||
class WRITERFILTER_DLLPRIVATE BorderHandler : public doctok::Properties
|
||||
{
|
||||
public:
|
||||
//todo: order is a guess
|
||||
enum BorderPosition
|
||||
{
|
||||
BORDER_TOP,
|
||||
BORDER_LEFT,
|
||||
BORDER_BOTTOM,
|
||||
BORDER_RIGHT,
|
||||
BORDER_HORIZONTAL,
|
||||
BORDER_VERTICAL
|
||||
};
|
||||
|
||||
private:
|
||||
sal_Int8 m_nCurrentBorderPosition;
|
||||
//values of the current border
|
||||
sal_Int32 m_nLineWidth;
|
||||
sal_Int32 m_nLineType;
|
||||
sal_Int32 m_nLineColor;
|
||||
sal_Int32 m_nLineDistance;
|
||||
|
||||
::com::sun::star::table::TableBorder m_aTableBorder;
|
||||
|
||||
public:
|
||||
BorderHandler( );
|
||||
virtual ~BorderHandler();
|
||||
|
||||
// Properties
|
||||
virtual void attribute(doctok::Id Name, doctok::Value & val);
|
||||
virtual void sprm(doctok::Sprm & sprm);
|
||||
|
||||
::boost::shared_ptr<PropertyMap> getProperties();
|
||||
};
|
||||
typedef boost::shared_ptr< BorderHandler > BorderHandlerPtr;
|
||||
}
|
||||
|
||||
#endif //
|
Loading…
Reference in a new issue