1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <CellMarginHandler.hxx>
20 #include <PropertyMap.hxx>
21 #include <doctok/resourceids.hxx>
22 #include <ConversionHelper.hxx>
23 #include <ooxml/resourceids.hxx>
24 #include "dmapperLoggers.hxx"
26 namespace writerfilter
{
29 using namespace ::com::sun::star
;
30 using namespace ::writerfilter
;
32 CellMarginHandler::CellMarginHandler() :
33 LoggedProperties(dmapper_logger
, "CellMarginHandler"),
36 m_bLeftMarginValid( false ),
38 m_bRightMarginValid( false ),
40 m_bTopMarginValid( false ),
42 m_bBottomMarginValid( false )
46 CellMarginHandler::~CellMarginHandler()
50 void CellMarginHandler::lcl_attribute(Id rName
, Value
& rVal
)
52 sal_Int32 nIntValue
= rVal
.getInt();
57 case NS_ooxml::LN_CT_TblWidth_w
:
58 m_nValue
= ConversionHelper::convertTwipToMM100( nIntValue
);
60 case NS_ooxml::LN_CT_TblWidth_type
:
61 OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa
== sal::static_int_cast
<Id
>(nIntValue
), "cell margins work for absolute values, only");
64 OSL_FAIL( "unknown attribute");
68 void CellMarginHandler::lcl_sprm(Sprm
& rSprm
)
70 writerfilter::Reference
<Properties
>::Pointer_t pProperties
= rSprm
.getProps();
71 if( pProperties
.get())
73 pProperties
.get()->resolve( *this );
74 bool rtl
= false; // TODO
75 switch( rSprm
.getId() )
77 case NS_ooxml::LN_CT_TblCellMar_top
:
78 case NS_ooxml::LN_CT_TcMar_top
:
79 m_nTopMargin
= m_nValue
;
80 m_bTopMarginValid
= true;
82 case NS_ooxml::LN_CT_TblCellMar_start
:
85 m_nRightMargin
= m_nValue
;
86 m_bRightMarginValid
= true;
90 m_nLeftMargin
= m_nValue
;
91 m_bLeftMarginValid
= true;
94 case NS_ooxml::LN_CT_TblCellMar_left
:
95 case NS_ooxml::LN_CT_TcMar_left
:
96 m_nLeftMargin
= m_nValue
;
97 m_bLeftMarginValid
= true;
99 case NS_ooxml::LN_CT_TblCellMar_bottom
:
100 case NS_ooxml::LN_CT_TcMar_bottom
:
101 m_nBottomMargin
= m_nValue
;
102 m_bBottomMarginValid
= true;
104 case NS_ooxml::LN_CT_TblCellMar_end
:
107 m_nLeftMargin
= m_nValue
;
108 m_bLeftMarginValid
= true;
112 m_nRightMargin
= m_nValue
;
113 m_bRightMarginValid
= true;
116 case NS_ooxml::LN_CT_TblCellMar_right
:
117 case NS_ooxml::LN_CT_TcMar_right
:
118 m_nRightMargin
= m_nValue
;
119 m_bRightMarginValid
= true;
122 OSL_FAIL( "unknown sprm");
127 } //namespace dmapper
128 } //namespace writerfilter
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */