LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/writerfilter/source/dmapper - TablePositionHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 87 102 85.3 %
Date: 2013-07-09 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  */
       9             : #include <TablePositionHandler.hxx>
      10             : #include <PropertyMap.hxx>
      11             : #include <doctok/resourceids.hxx>
      12             : #include <ConversionHelper.hxx>
      13             : #include <ooxml/resourceids.hxx>
      14             : #include <com/sun/star/text/HoriOrientation.hpp>
      15             : #include <com/sun/star/text/VertOrientation.hpp>
      16             : #include <com/sun/star/text/RelOrientation.hpp>
      17             : #include "dmapperLoggers.hxx"
      18             : 
      19             : namespace writerfilter {
      20             : namespace dmapper {
      21             : 
      22             : using namespace ::com::sun::star;
      23             : 
      24           7 : TablePositionHandler::TablePositionHandler() :
      25             :     LoggedProperties(dmapper_logger, "TablePositionHandler"),
      26             :     m_aVertAnchor( "margin" ),
      27             :     m_aYSpec( ),
      28             :     m_aHorzAnchor( "text" ),
      29             :     m_aXSpec( ),
      30             :     m_nY( 0 ),
      31           7 :     m_nX( 0 )
      32             : {
      33           7 : }
      34             : 
      35          14 : TablePositionHandler::~TablePositionHandler()
      36             : {
      37          14 : }
      38             : 
      39             : 
      40          16 : void TablePositionHandler::lcl_attribute(Id rName, Value& rVal)
      41             : {
      42          16 :     switch (rName)
      43             :     {
      44             :         case NS_ooxml::LN_CT_TblPPr_vertAnchor:
      45           5 :             m_aVertAnchor = rVal.getString();
      46           5 :         break;
      47             :         case NS_ooxml::LN_CT_TblPPr_tblpYSpec:
      48           2 :             m_aYSpec = rVal.getString();
      49           2 :         break;
      50             :         case NS_ooxml::LN_CT_TblPPr_horzAnchor:
      51           4 :             m_aHorzAnchor = rVal.getString();
      52           4 :         break;
      53             :         case NS_ooxml::LN_CT_TblPPr_tblpXSpec:
      54           0 :             m_aXSpec = rVal.getString();
      55           0 :         break;
      56             :         case NS_ooxml::LN_CT_TblPPr_tblpY:
      57           5 :             m_nY = rVal.getInt();
      58           5 :         break;
      59             :         case NS_ooxml::LN_CT_TblPPr_tblpX:
      60           0 :             m_nX = rVal.getInt();
      61           0 :         break;
      62             :         default:
      63             : #ifdef DEBUG_DOMAINMAPPER
      64             :             dmapper_logger->element("unhandled");
      65             : #endif
      66           0 :             break;
      67             :     }
      68          16 : }
      69             : 
      70             : 
      71           0 : void TablePositionHandler::lcl_sprm(Sprm& /*rSprm*/)
      72             : {
      73           0 : }
      74             : 
      75             : 
      76           4 : uno::Sequence<beans::PropertyValue> TablePositionHandler::getTablePosition() const
      77             : {
      78           4 :     uno::Sequence< beans::PropertyValue > aFrameProperties(18);
      79           4 :     beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
      80             : 
      81           4 :     pFrameProperties[0].Name = "LeftBorderDistance";
      82           4 :     pFrameProperties[0].Value <<= sal_Int32(0);
      83           4 :     pFrameProperties[1].Name = "RightBorderDistance";
      84           4 :     pFrameProperties[1].Value <<= sal_Int32(0);
      85           4 :     pFrameProperties[2].Name = "TopBorderDistance";
      86           4 :     pFrameProperties[2].Value <<= sal_Int32(0);
      87           4 :     pFrameProperties[3].Name = "BottomBorderDistance";
      88           4 :     pFrameProperties[3].Value <<= sal_Int32(0);
      89             : 
      90           4 :     pFrameProperties[4].Name = "LeftMargin";
      91           4 :     pFrameProperties[4].Value <<= sal_Int32(0);
      92           4 :     pFrameProperties[5].Name = "RightMargin";
      93           4 :     pFrameProperties[5].Value <<= sal_Int32(0);
      94           4 :     pFrameProperties[6].Name = "TopMargin";
      95           4 :     pFrameProperties[6].Value <<= sal_Int32(0);
      96           4 :     pFrameProperties[7].Name = "BottomMargin";
      97           4 :     pFrameProperties[7].Value <<= sal_Int32(0);
      98             : 
      99           4 :     table::BorderLine2 aEmptyBorder;
     100           4 :     pFrameProperties[8].Name = "TopBorder";
     101           4 :     pFrameProperties[8].Value <<= aEmptyBorder;
     102           4 :     pFrameProperties[9].Name = "BottomBorder";
     103           4 :     pFrameProperties[9].Value <<= aEmptyBorder;
     104           4 :     pFrameProperties[10].Name = "LeftBorder";
     105           4 :     pFrameProperties[10].Value <<= aEmptyBorder;
     106           4 :     pFrameProperties[11].Name = "RightBorder";
     107           4 :     pFrameProperties[11].Value <<= aEmptyBorder;
     108             : 
     109             :     // Horizontal positioning
     110           4 :     sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
     111           4 :     if ( m_aXSpec == "center" )
     112           0 :         nHoriOrient = text::HoriOrientation::CENTER;
     113           4 :     else if ( m_aXSpec == "inside" )
     114           0 :         nHoriOrient = text::HoriOrientation::INSIDE;
     115           4 :     else if ( m_aXSpec == "left" )
     116           0 :         nHoriOrient = text::HoriOrientation::LEFT;
     117           4 :     else if ( m_aXSpec == "outside" )
     118           0 :         nHoriOrient = text::HoriOrientation::OUTSIDE;
     119           4 :     else if ( m_aXSpec == "right" )
     120           0 :         nHoriOrient = text::HoriOrientation::RIGHT;
     121             : 
     122             :     sal_Int16 nHoriOrientRelation;
     123           4 :     if ( m_aHorzAnchor == "margin" )
     124           2 :         nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
     125           2 :     else if ( m_aHorzAnchor == "page" )
     126           0 :         nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
     127           2 :     else if ( m_aHorzAnchor == "text" )
     128           2 :         nHoriOrientRelation = text::RelOrientation::FRAME;
     129             : 
     130           4 :     pFrameProperties[12].Name = "HoriOrient";
     131           4 :     pFrameProperties[12].Value <<= nHoriOrient;
     132           4 :     pFrameProperties[13].Name = "HoriOrientRelation";
     133           4 :     pFrameProperties[13].Value <<= nHoriOrientRelation;
     134           4 :     pFrameProperties[14].Name = "HoriOrientPosition";
     135           4 :     pFrameProperties[14].Value <<= m_nX;
     136             : 
     137             : 
     138             :     // Vertical positioning
     139           4 :     sal_Int16 nVertOrient = text::VertOrientation::NONE;
     140           4 :     if ( m_aYSpec == "bottom" )
     141           1 :         nVertOrient = text::VertOrientation::BOTTOM;
     142           3 :     else if ( m_aYSpec == "center" )
     143           0 :         nVertOrient = text::VertOrientation::CENTER;
     144           3 :     else if ( m_aYSpec == "top" )
     145           0 :         nVertOrient = text::VertOrientation::TOP;
     146             :     // TODO There are a few cases we can't map ATM.
     147             : 
     148             : 
     149             :     sal_Int16 nVertOrientRelation;
     150           4 :     if ( m_aVertAnchor == "margin" )
     151           1 :         nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
     152           3 :     else if ( m_aVertAnchor == "page" )
     153           2 :         nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
     154           1 :     else if ( m_aVertAnchor == "text" )
     155           1 :         nVertOrientRelation = text::RelOrientation::FRAME;
     156             : 
     157           4 :     pFrameProperties[15].Name = "VertOrient";
     158           4 :     pFrameProperties[15].Value <<= nVertOrient;
     159           4 :     pFrameProperties[16].Name = "VertOrientRelation";
     160           4 :     pFrameProperties[16].Value <<= nVertOrientRelation;
     161           4 :     pFrameProperties[17].Name = "VertOrientPosition";
     162           4 :     pFrameProperties[17].Value <<= m_nY;
     163             : 
     164           4 :     return aFrameProperties;
     165             : }
     166             : 
     167           3 : bool TablePositionHandler::operator== (const TablePositionHandler& rHandler) const
     168             : {
     169           6 :     return m_aVertAnchor == rHandler.m_aVertAnchor &&
     170           6 :            m_aYSpec == rHandler.m_aYSpec &&
     171           6 :            m_aHorzAnchor == rHandler.m_aHorzAnchor &&
     172           6 :            m_aXSpec == rHandler.m_aXSpec &&
     173           9 :            m_nY == rHandler.m_nY &&
     174           6 :            m_nX == rHandler.m_nX;
     175             : }
     176             : 
     177             : } // namespace dmapper
     178          24 : } // namespace writerfilter
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10