1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MeasureHandler.cxx,v $
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 <MeasureHandler.hxx>
31 #include <PropertyMap.hxx>
32 #include <doctok/resourceids.hxx>
33 #include <ConversionHelper.hxx>
34 #include <ooxml/resourceids.hxx>
35 #include <com/sun/star/text/SizeType.hpp>
37 namespace writerfilter
{
40 using namespace ::com::sun::star
;
42 /*-- 24.04.2007 09:06:35---------------------------------------------------
44 -----------------------------------------------------------------------*/
45 MeasureHandler::MeasureHandler() :
48 m_nRowHeightSizeType( text::SizeType::MIN
)
51 /*-- 24.04.2007 09:06:35---------------------------------------------------
53 -----------------------------------------------------------------------*/
54 MeasureHandler::~MeasureHandler()
57 /*-- 24.04.2007 09:06:35---------------------------------------------------
59 -----------------------------------------------------------------------*/
60 void MeasureHandler::attribute(Id rName
, Value
& rVal
)
62 sal_Int32 nIntValue
= rVal
.getInt();
64 /* WRITERFILTERSTATUS: table: MeasureHandler_attributedata */
67 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
69 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
70 case NS_ooxml::LN_CT_TblWidth_type
:// = 90668;
71 //can be: NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
72 // NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
75 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
76 case NS_ooxml::LN_CT_Height_hRule
: // 90666;
78 ::rtl::OUString sHeightType
= rVal
.getString();
79 if( sHeightType
.equalsAscii( "exact" ) )
80 m_nRowHeightSizeType
= text::SizeType::FIX
;
83 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
84 case NS_rtf::LN_trleft
:
85 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
86 case NS_rtf::LN_preferredWidth
:
87 case NS_ooxml::LN_CT_TblWidth_w
:// = 90667;
88 m_nMeasureValue
= nIntValue
;
90 /* WRITERFILTERSTATUS: done: 1, planned: 0, spent: 0 */
91 case NS_ooxml::LN_CT_Height_val
: // 90665 -- a string value
93 m_nUnit
= NS_ooxml::LN_Value_ST_TblWidth_dxa
;
94 ::rtl::OUString sHeight
= rVal
.getString();
95 m_nMeasureValue
= sHeight
.toInt32();
99 OSL_ENSURE( false, "unknown attribute");
102 /*-- 24.04.2007 09:06:35---------------------------------------------------
104 -----------------------------------------------------------------------*/
105 void MeasureHandler::sprm(Sprm
& rSprm
)
109 /*-- 24.04.2007 09:09:01---------------------------------------------------
111 -----------------------------------------------------------------------*/
112 sal_Int32
MeasureHandler::getMeasureValue() const
115 if( m_nMeasureValue
!= 0 && m_nUnit
>= 0 )
117 // TODO m_nUnit 3 - twip, other values unknown :-(
118 if( m_nUnit
== 3 || sal::static_int_cast
<Id
>(m_nUnit
) == NS_ooxml::LN_Value_ST_TblWidth_dxa
)
119 nRet
= ConversionHelper::convertTwipToMM100( m_nMeasureValue
);
120 //todo: handle additional width types:
121 //NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
122 //NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
126 /*-- 18.06.2007 10:24:26---------------------------------------------------
128 -----------------------------------------------------------------------*/
129 bool MeasureHandler::isAutoWidth() const
131 return sal::static_int_cast
<Id
>(m_nUnit
) == NS_ooxml::LN_Value_ST_TblWidth_auto
;
134 } //namespace dmapper
135 } //namespace writerfilter