LibreOffice Module writerfilter (master) 1
MeasureHandler.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 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#include "MeasureHandler.hxx"
20#include "ConversionHelper.hxx"
21#include <ooxml/resourceids.hxx>
22#include <osl/diagnose.h>
23#include <com/sun/star/text/SizeType.hpp>
25
26namespace writerfilter::dmapper {
27
28using namespace ::com::sun::star;
29
30
32LoggedProperties("MeasureHandler"),
33m_nMeasureValue( 0 ),
34m_nUnit( -1 ),
35m_nRowHeightSizeType( text::SizeType::MIN )
36{
37}
38
39
41{
42}
43
44
46{
47 sal_Int32 nIntValue = rVal.getInt();
48 switch( rName )
49 {
50 case NS_ooxml::LN_CT_TblWidth_type:
51 {
52 //can be: NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
53 // NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
54 m_nUnit = nIntValue;
55
56 if (!m_aInteropGrabBagName.isEmpty())
57 {
58 beans::PropertyValue aValue;
59 aValue.Name = "type";
60 switch (nIntValue)
61 {
62 case NS_ooxml::LN_Value_ST_TblWidth_nil: aValue.Value <<= OUString("nil"); break;
63 case NS_ooxml::LN_Value_ST_TblWidth_pct: aValue.Value <<= OUString("pct"); break;
64 case NS_ooxml::LN_Value_ST_TblWidth_dxa: aValue.Value <<= OUString("dxa"); break;
65 case NS_ooxml::LN_Value_ST_TblWidth_auto: aValue.Value <<= OUString("auto"); break;
66 }
67 m_aInteropGrabBag.push_back(aValue);
68 }
69 }
70 break;
71 case NS_ooxml::LN_CT_Height_hRule:
72 {
73 OUString sHeightType = rVal.getString();
74 if ( sHeightType == "exact" )
75 m_nRowHeightSizeType = text::SizeType::FIX;
76 }
77 break;
78 case NS_ooxml::LN_CT_TblWidth_w:
79 m_nMeasureValue = nIntValue;
80 if (!m_aInteropGrabBagName.isEmpty())
81 {
82 beans::PropertyValue aValue;
83 aValue.Name = "w";
84 aValue.Value <<= nIntValue;
85 m_aInteropGrabBag.push_back(aValue);
86 }
87 break;
88 case NS_ooxml::LN_CT_Height_val: // a string value
89 {
90 m_nUnit = NS_ooxml::LN_Value_ST_TblWidth_dxa;
91 OUString sHeight = rVal.getString();
92 m_nMeasureValue = sHeight.toInt32();
93 }
94 break;
95 default:
96 OSL_FAIL( "unknown attribute");
97 }
98}
99
100
102
103
105{
106 sal_Int32 nRet = 0;
107 if( m_nMeasureValue != 0 && m_nUnit >= 0 )
108 {
109 // TODO m_nUnit 3 - twip, other values unknown :-(
110 if( m_nUnit == 3 || sal::static_int_cast<Id>(m_nUnit) == NS_ooxml::LN_Value_ST_TblWidth_dxa)
111 {
113 }
114 //todo: handle additional width types:
115 //NS_ooxml::LN_Value_ST_TblWidth_nil, NS_ooxml::LN_Value_ST_TblWidth_pct,
116 //NS_ooxml::LN_Value_ST_TblWidth_dxa, NS_ooxml::LN_Value_ST_TblWidth_auto;
117 }
118 return nRet;
119}
120
121void MeasureHandler::enableInteropGrabBag(const OUString& aName)
122{
124}
125
127{
128 beans::PropertyValue aRet;
129 aRet.Name = m_aInteropGrabBagName;
131 return aRet;
132}
133
134} //namespace writerfilter::dmapper
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define MIN(x, y)
An SPRM: Section, Paragraph and Run Modifier.
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
std::vector< css::beans::PropertyValue > m_aInteropGrabBag
css::beans::PropertyValue getInteropGrabBag()
virtual void lcl_sprm(Sprm &sprm) override
void enableInteropGrabBag(const OUString &aName)
virtual void lcl_attribute(Id Name, Value &val) override
OUString aName
def text(shape, orig_st)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
sal_uInt32 Id