From e24fccf9f533e18f8990157d4f43a9e973d1b5b8 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Wed, 9 May 2007 12:49:23 +0000 Subject: [PATCH] hander of measures, value + measurement type --- .../source/dmapper/MeasureHandler.cxx | 111 ++++++++++++++++++ .../source/dmapper/MeasureHandler.hxx | 69 +++++++++++ 2 files changed, 180 insertions(+) create mode 100644 writerfilter/source/dmapper/MeasureHandler.cxx create mode 100644 writerfilter/source/dmapper/MeasureHandler.hxx diff --git a/writerfilter/source/dmapper/MeasureHandler.cxx b/writerfilter/source/dmapper/MeasureHandler.cxx new file mode 100644 index 000000000000..481240834d4f --- /dev/null +++ b/writerfilter/source/dmapper/MeasureHandler.cxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MeasureHandler.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: os $ $Date: 2007-05-09 13:49:12 $ + * + * 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_MEASUREHANDLER_HXX +#include +#endif +#ifndef INCLUDED_DMAPPER_PROPERTYMAP_HXX +#include +#endif +#ifndef INCLUDED_RESOURCESIDS +#include +#endif +#ifndef INCLUDED_DMAPPER_CONVERSIONHELPER_HXX +#include +#endif +#ifndef INCLUDED_QNAME_HXX +#include +#endif + +using namespace ::writerfilter; +namespace dmapper { + +using namespace ::com::sun::star; + +/*-- 24.04.2007 09:06:35--------------------------------------------------- + + -----------------------------------------------------------------------*/ +MeasureHandler::MeasureHandler() : + m_nMeasureValue( 0 ), + m_nUnit( -1 ) +{ +} +/*-- 24.04.2007 09:06:35--------------------------------------------------- + + -----------------------------------------------------------------------*/ +MeasureHandler::~MeasureHandler() +{ +} +/*-- 24.04.2007 09:06:35--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void MeasureHandler::attribute(doctok::Id rName, doctok::Value & rVal) +{ + sal_Int32 nIntValue = rVal.getInt(); + (void)rName; + switch( rName ) + { + case NS_rtf::LN_unit: + m_nUnit = nIntValue; + break; + case NS_rtf::LN_trleft: + case NS_rtf::LN_preferredWidth: + m_nMeasureValue = nIntValue; + break; + default: + OSL_ASSERT("unknown attribute"); + } +} +/*-- 24.04.2007 09:06:35--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void MeasureHandler::sprm(doctok::Sprm & rSprm) +{ + (void)rSprm; +} +/*-- 24.04.2007 09:09:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Int32 MeasureHandler::getTwipValue() const +{ + sal_Int32 nRet = 0; + if( m_nMeasureValue != 0 && m_nUnit >= 0 ) + { + // TODO m_nUnit 3 - twip, other values unknown :-( + if( m_nUnit == 3 ) + nRet = ConversionHelper::convertToMM100( m_nMeasureValue ); + } + return nRet; +} +} //namespace dmapper diff --git a/writerfilter/source/dmapper/MeasureHandler.hxx b/writerfilter/source/dmapper/MeasureHandler.hxx new file mode 100644 index 000000000000..a68576d2745a --- /dev/null +++ b/writerfilter/source/dmapper/MeasureHandler.hxx @@ -0,0 +1,69 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MeasureHandler.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: os $ $Date: 2007-05-09 13:49:23 $ + * + * 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_MEASUREHANDLER_HXX +#define INCLUDED_MEASUREHANDLER_HXX + +#ifndef INCLUDED_WRITERFILTERDLLAPI_H +#include +#endif +#include +#include + +namespace dmapper +{ +class PropertyMap; +/** Handler for sprms that contain a measure and a unit + - Left indent of tables + - Preferred width of tables + */ +class WRITERFILTER_DLLPRIVATE MeasureHandler : public doctok::Properties +{ + sal_Int32 m_nMeasureValue; + sal_Int32 m_nUnit; + +public: + MeasureHandler(); + virtual ~MeasureHandler(); + + // Properties + virtual void attribute(doctok::Id Name, doctok::Value & val); + virtual void sprm(doctok::Sprm & sprm); + + sal_Int32 getTwipValue() const; +}; +typedef boost::shared_ptr< MeasureHandler > MeasureHandlerPtr; +} + +#endif //