summaryrefslogtreecommitdiffstats
path: root/writerfilter/source/dmapper/BorderHandler.cxx
diff options
context:
space:
mode:
authorOliver Specht <os@openoffice.org>2007-04-25 10:28:59 +0000
committerOliver Specht <os@openoffice.org>2007-04-25 10:28:59 +0000
commitc690115805f8d5cb76e6992265746fa9d6f6d397 (patch)
tree4e4b84c3e86f9bd851431f5a55827ab988fbd4d9 /writerfilter/source/dmapper/BorderHandler.cxx
parentderived TableManager (diff)
downloadcore-c690115805f8d5cb76e6992265746fa9d6f6d397.tar.gz
core-c690115805f8d5cb76e6992265746fa9d6f6d397.zip
handler of border attributes
Diffstat (limited to 'writerfilter/source/dmapper/BorderHandler.cxx')
-rw-r--r--writerfilter/source/dmapper/BorderHandler.cxx168
1 files changed, 168 insertions, 0 deletions
diff --git a/writerfilter/source/dmapper/BorderHandler.cxx b/writerfilter/source/dmapper/BorderHandler.cxx
new file mode 100644
index 000000000000..382b9a50578a
--- /dev/null
+++ b/writerfilter/source/dmapper/BorderHandler.cxx
@@ -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