LibreOffice Module writerfilter (master) 1
TablePositionHandler.cxx
Go to the documentation of this file.
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 */
10#include "ConversionHelper.hxx"
11#include "TagLogger.hxx"
12#include <ooxml/resourceids.hxx>
13#include <com/sun/star/beans/PropertyValue.hpp>
14#include <com/sun/star/text/HoriOrientation.hpp>
15#include <com/sun/star/text/VertOrientation.hpp>
16#include <com/sun/star/text/RelOrientation.hpp>
18
20{
21using namespace ::com::sun::star;
22
24 : LoggedProperties("TablePositionHandler")
25{
26}
27
29
31{
32 switch (nId)
33 {
34 case NS_ooxml::LN_CT_TblPPr_vertAnchor:
35 m_aVertAnchor = rVal.getString();
36 break;
37 case NS_ooxml::LN_CT_TblPPr_tblpYSpec:
38 m_aYSpec = rVal.getString();
39 break;
40 case NS_ooxml::LN_CT_TblPPr_horzAnchor:
41 m_aHorzAnchor = rVal.getString();
42 break;
43 case NS_ooxml::LN_CT_TblPPr_tblpXSpec:
44 m_aXSpec = rVal.getString();
45 break;
46 case NS_ooxml::LN_CT_TblPPr_tblpY:
47 m_nY = rVal.getInt();
48 break;
49 case NS_ooxml::LN_CT_TblPPr_tblpX:
50 m_nX = rVal.getInt();
51 break;
52 case NS_ooxml::LN_CT_TblPPr_leftFromText:
53 m_nLeftFromText = rVal.getInt();
54 break;
55 case NS_ooxml::LN_CT_TblPPr_rightFromText:
56 m_nRightFromText = rVal.getInt();
57 break;
58 case NS_ooxml::LN_CT_TblPPr_topFromText:
59 m_nTopFromText = rVal.getInt();
60 break;
61 case NS_ooxml::LN_CT_TblPPr_bottomFromText:
63 break;
64 default:
65#ifdef DBG_UTIL
66 TagLogger::getInstance().element("unhandled");
67#endif
68 break;
69 }
70}
71
73
75{
76 comphelper::SequenceAsHashMap aFrameProperties;
77
78 aFrameProperties["LeftBorderDistance"] <<= sal_Int32(0);
79 aFrameProperties["RightBorderDistance"] <<= sal_Int32(0);
80 aFrameProperties["TopBorderDistance"] <<= sal_Int32(0);
81 aFrameProperties["BottomBorderDistance"] <<= sal_Int32(0);
82
83 aFrameProperties["LeftMargin"] <<= ConversionHelper::convertTwipToMM100(m_nLeftFromText);
84 aFrameProperties["RightMargin"] <<= ConversionHelper::convertTwipToMM100(m_nRightFromText);
85 aFrameProperties["TopMargin"] <<= ConversionHelper::convertTwipToMM100(m_nTopFromText);
86 aFrameProperties["BottomMargin"] <<= ConversionHelper::convertTwipToMM100(m_nBottomFromText);
87
88 table::BorderLine2 aEmptyBorder;
89 aFrameProperties["TopBorder"] <<= aEmptyBorder;
90 aFrameProperties["BottomBorder"] <<= aEmptyBorder;
91 aFrameProperties["LeftBorder"] <<= aEmptyBorder;
92 aFrameProperties["RightBorder"] <<= aEmptyBorder;
93
94 // Horizontal positioning
95 sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
96 if (m_aXSpec == "center")
97 nHoriOrient = text::HoriOrientation::CENTER;
98 else if (m_aXSpec == "inside")
99 nHoriOrient = text::HoriOrientation::INSIDE;
100 else if (m_aXSpec == "left")
101 nHoriOrient = text::HoriOrientation::LEFT;
102 else if (m_aXSpec == "outside")
103 nHoriOrient = text::HoriOrientation::OUTSIDE;
104 else if (m_aXSpec == "right")
105 nHoriOrient = text::HoriOrientation::RIGHT;
106
107 sal_Int16 nHoriOrientRelation;
108 if (m_aHorzAnchor == "margin")
109 nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
110 else if (m_aHorzAnchor == "page")
111 nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
112 else if (m_aHorzAnchor == "text")
113 nHoriOrientRelation = text::RelOrientation::FRAME;
114
115 aFrameProperties["HoriOrient"] <<= nHoriOrient;
116 aFrameProperties["HoriOrientRelation"] <<= nHoriOrientRelation;
117 aFrameProperties["HoriOrientPosition"] <<= ConversionHelper::convertTwipToMM100(m_nX);
118
119 // Vertical positioning
120 sal_Int16 nVertOrient = text::VertOrientation::NONE;
121 if (m_aYSpec == "bottom")
122 nVertOrient = text::VertOrientation::BOTTOM;
123 else if (m_aYSpec == "center")
124 nVertOrient = text::VertOrientation::CENTER;
125 else if (m_aYSpec == "top")
126 nVertOrient = text::VertOrientation::TOP;
127 // TODO There are a few cases we can't map ATM.
128
129 sal_Int16 nVertOrientRelation;
130 if (m_aVertAnchor == "margin")
131 nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
132 else if (m_aVertAnchor == "page")
133 nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
134 else if (m_aVertAnchor == "text")
135 nVertOrientRelation = text::RelOrientation::FRAME;
136
137 aFrameProperties["VertOrient"] <<= nVertOrient;
138 aFrameProperties["VertOrientRelation"] <<= nVertOrientRelation;
139 aFrameProperties["VertOrientPosition"] <<= ConversionHelper::convertTwipToMM100(m_nY);
140 aFrameProperties["FillTransparence"] <<= sal_Int32(100);
141
142 return aFrameProperties.getAsConstPropertyValueList();
143}
144
146{
147 return m_aVertAnchor == rHandler.m_aVertAnchor && m_aYSpec == rHandler.m_aYSpec
148 && m_aHorzAnchor == rHandler.m_aHorzAnchor && m_aXSpec == rHandler.m_aXSpec
149 && m_nY == rHandler.m_nY && m_nX == rHandler.m_nX;
150}
151
152} // namespace writerfilter::dmapper
153
154/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
An SPRM: Section, Paragraph and Run Modifier.
static TagLogger & getInstance()
Definition: TagLogger.cxx:95
void element(const std::string &name)
Definition: TagLogger.cxx:102
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
Handler for floating table positioning.
bool operator==(const TablePositionHandler &rHandler) const
css::uno::Sequence< css::beans::PropertyValue > getTablePosition() const
Compute the UNO properties for the frame containing the table based on the received tokens.
void lcl_attribute(Id nId, Value &rVal) override
sal_Int16 nId
sal_uInt32 Id