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