1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include <CellMarginHandler.hxx>
24 #include <PropertyMap.hxx>
25 #include <doctok/resourceids.hxx>
26 #include <ConversionHelper.hxx>
27 #include <ooxml/resourceids.hxx>
28 #include "dmapperLoggers.hxx"
29 
30 namespace writerfilter {
31 namespace dmapper {
32 
33 using namespace ::com::sun::star;
34 using namespace ::writerfilter;
35 //using namespace ::std;
36 
37 /*-- 18.02.2008 12:36:51---------------------------------------------------
38 
39   -----------------------------------------------------------------------*/
CellMarginHandler()40 CellMarginHandler::CellMarginHandler() :
41 LoggedProperties(dmapper_logger, "CellMarginHandler"),
42 m_nValue( 0 ),
43 m_nLeftMargin( 0 ),
44 m_bLeftMarginValid( false ),
45 m_nRightMargin( 0 ),
46 m_bRightMarginValid( false ),
47 m_nTopMargin( 0 ),
48 m_bTopMarginValid( false ),
49 m_nBottomMargin( 0 ),
50 m_bBottomMarginValid( false )
51 {
52 }
53 /*-- 18.02.2008 12:36:51---------------------------------------------------
54 
55   -----------------------------------------------------------------------*/
~CellMarginHandler()56 CellMarginHandler::~CellMarginHandler()
57 {
58 }
59 /*-- 18.02.2008 12:36:51---------------------------------------------------
60 
61   -----------------------------------------------------------------------*/
lcl_attribute(Id rName,Value & rVal)62 void CellMarginHandler::lcl_attribute(Id rName, Value & rVal)
63 {
64     sal_Int32 nIntValue = rVal.getInt();
65     (void)nIntValue;
66     (void)rName;
67     /* WRITERFILTERSTATUS: table: CellColor_attributedata */
68     switch( rName )
69     {
70         case NS_ooxml::LN_CT_TblWidth_w:
71             m_nValue = ConversionHelper::convertTwipToMM100( nIntValue );
72         break;
73         case NS_ooxml::LN_CT_TblWidth_type:
74             OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only");
75         break;
76         default:
77             OSL_ENSURE( false, "unknown attribute");
78     }
79 }
80 /*-- 18.02.2008 12:36:51---------------------------------------------------
81 
82   -----------------------------------------------------------------------*/
lcl_sprm(Sprm & rSprm)83 void CellMarginHandler::lcl_sprm(Sprm & rSprm)
84 {
85     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
86     if( pProperties.get())
87     {
88         pProperties.get()->resolve( *this );
89         switch( rSprm.getId() )
90         {
91             /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */
92             case NS_ooxml::LN_CT_TblCellMar_top:
93                 m_nTopMargin = m_nValue;
94                 m_bTopMarginValid = true;
95             break;
96             /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */
97             case NS_ooxml::LN_CT_TblCellMar_left:
98                 m_nLeftMargin = m_nValue;
99                 m_bLeftMarginValid = true;
100             break;
101             /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */
102             case NS_ooxml::LN_CT_TblCellMar_bottom:
103                 m_nBottomMargin = m_nValue;
104                 m_bBottomMarginValid = true;
105             break;
106             /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */
107             case NS_ooxml::LN_CT_TblCellMar_right:
108                 m_nRightMargin = m_nValue;
109                 m_bRightMarginValid = true;
110             break;
111             default:
112                 OSL_ENSURE( false, "unknown attribute");
113         }
114     }
115     m_nValue = 0;
116 }
117 } //namespace dmapper
118 } //namespace writerfilter
119