update dev300-m58
[ooovba.git] / writerfilter / source / dmapper / BorderHandler.cxx
blobc3ed4edf3605b58ea20b6f5d39ccdbc1f883ca98
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BorderHandler.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <BorderHandler.hxx>
31 #include <PropertyMap.hxx>
32 #include <doctok/resourceids.hxx>
33 #include <ConversionHelper.hxx>
34 #include <com/sun/star/table/BorderLine.hpp>
35 #include <ooxml/resourceids.hxx>
37 namespace writerfilter {
38 namespace dmapper {
40 using namespace ::com::sun::star;
41 //using namespace ::std;
43 /*-- 24.04.2007 09:06:35---------------------------------------------------
45 -----------------------------------------------------------------------*/
46 BorderHandler::BorderHandler( bool bOOXML ) :
47 m_nCurrentBorderPosition( BORDER_TOP ),
48 m_nLineWidth(0),
49 m_nLineType(0),
50 m_nLineColor(0),
51 m_nLineDistance(0),
52 m_bOOXML( bOOXML )
55 /*-- 24.04.2007 09:06:35---------------------------------------------------
57 -----------------------------------------------------------------------*/
58 BorderHandler::~BorderHandler()
61 /*-- 24.04.2007 09:06:35---------------------------------------------------
63 -----------------------------------------------------------------------*/
64 void BorderHandler::attribute(Id rName, Value & rVal)
66 sal_Int32 nIntValue = rVal.getInt();
67 /* WRITERFILTERSTATUS: table: BorderHandler_attributedata */
68 switch( rName )
70 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
71 case NS_rtf::LN_rgbrc:
73 writerfilter::Reference<Properties>::Pointer_t pProperties = rVal.getProperties();
74 if( pProperties.get())
76 pProperties->resolve(*this);
77 ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor,
78 m_aBorderLines[m_nCurrentBorderPosition], m_bOOXML );
79 OSL_ENSURE(m_nCurrentBorderPosition < BORDER_COUNT, "too many border values");
80 ++m_nCurrentBorderPosition;
83 break;
84 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
85 case NS_rtf::LN_DPTLINEWIDTH: // 0x2871
86 // width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2.
87 m_nLineWidth = ConversionHelper::convertTwipToMM100( nIntValue * 5 / 2 );
88 break;
89 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
90 case NS_rtf::LN_BRCTYPE: // 0x2872
91 m_nLineType = nIntValue;
92 break;
93 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
94 case NS_ooxml::LN_CT_Border_color:
95 case NS_rtf::LN_ICO: // 0x2873
96 m_nLineColor = nIntValue;
97 break;
98 /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */
99 case NS_rtf::LN_DPTSPACE: // border distance in points
100 m_nLineDistance = ConversionHelper::convertTwipToMM100( nIntValue * 20 );
101 break;
102 case NS_rtf::LN_FSHADOW: // 0x2875
103 //if 1 then line has shadow - unsupported
104 case NS_rtf::LN_FFRAME: // 0x2876
105 case NS_rtf::LN_UNUSED2_15: // 0x2877
106 // ignored
107 break;
108 case NS_ooxml::LN_CT_Border_themeTint: break;
109 case NS_ooxml::LN_CT_Border_themeColor: break;
110 default:
111 OSL_ENSURE( false, "unknown attribute");
114 /*-- 24.04.2007 09:06:35---------------------------------------------------
116 -----------------------------------------------------------------------*/
117 void BorderHandler::sprm(Sprm & rSprm)
119 /* WRITERFILTERSTATUS: table: BorderHandler_sprm */
120 switch( rSprm.getId())
122 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
123 case NS_ooxml::LN_CT_TblBorders_top:
124 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
125 case NS_ooxml::LN_CT_TblBorders_left:
126 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
127 case NS_ooxml::LN_CT_TblBorders_bottom:
128 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
129 case NS_ooxml::LN_CT_TblBorders_right:
130 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
131 case NS_ooxml::LN_CT_TblBorders_insideH:
132 /* WRITERFILTERSTATUS: done: 75, planned: 0, spent: 0 */
133 case NS_ooxml::LN_CT_TblBorders_insideV:
135 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
136 if( pProperties.get())
137 pProperties->resolve(*this);
138 ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor,
139 m_aBorderLines[rSprm.getId() - NS_ooxml::LN_CT_TblBorders_top], m_bOOXML );
141 break;
142 default:;
145 /*-- 24.04.2007 09:09:01---------------------------------------------------
147 -----------------------------------------------------------------------*/
148 PropertyMapPtr BorderHandler::getProperties()
150 static const PropertyIds aPropNames[BORDER_COUNT] =
152 PROP_TOP_BORDER,
153 PROP_LEFT_BORDER,
154 PROP_BOTTOM_BORDER,
155 PROP_RIGHT_BORDER,
156 META_PROP_HORIZONTAL_BORDER,
157 META_PROP_VERTICAL_BORDER
159 PropertyMapPtr pPropertyMap(new PropertyMap);
160 // don't fill in default properties
161 if( m_bOOXML || m_nCurrentBorderPosition )
163 for( sal_Int32 nProp = 0; nProp < BORDER_COUNT; ++nProp)
164 pPropertyMap->Insert( aPropNames[nProp], false, uno::makeAny( m_aBorderLines[nProp] ) );
166 return pPropertyMap;
168 /*-- 14.11.2007 12:42:52---------------------------------------------------
169 used only in OOXML import
170 -----------------------------------------------------------------------*/
171 table::BorderLine BorderHandler::getBorderLine()
173 table::BorderLine aBorderLine;
174 ConversionHelper::MakeBorderLine( m_nLineWidth, m_nLineType, m_nLineColor, aBorderLine, m_bOOXML );
175 return aBorderLine;
178 } //namespace dmapper
179 } //namespace writerfilter