Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / source / dmapper / SectionColumnHandler.cxx
blob9fed9c34a68ed2299f292d8101ce93b7a857f4e9
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "SectionColumnHandler.hxx"
20 #include "ConversionHelper.hxx"
21 #include <ooxml/resourceids.hxx>
22 #include <osl/diagnose.h>
24 namespace writerfilter::dmapper
26 using namespace ::com::sun::star;
28 SectionColumnHandler::SectionColumnHandler()
29 : LoggedProperties("SectionColumnHandler")
30 , m_bEqualWidth(false)
31 , m_nSpace(1270) // 720 twips
32 , m_nNum(0)
33 , m_bSep(false)
35 m_aTempColumn.nWidth = m_aTempColumn.nSpace = 0;
38 SectionColumnHandler::~SectionColumnHandler() {}
40 void SectionColumnHandler::lcl_attribute(Id rName, Value& rVal)
42 sal_Int32 nIntValue = rVal.getInt();
43 switch (rName)
45 case NS_ooxml::LN_CT_Columns_equalWidth:
46 m_bEqualWidth = (nIntValue != 0);
47 break;
48 case NS_ooxml::LN_CT_Columns_space:
49 m_nSpace = ConversionHelper::convertTwipToMM100(nIntValue);
50 break;
51 case NS_ooxml::LN_CT_Columns_num:
52 m_nNum = nIntValue;
53 break;
54 case NS_ooxml::LN_CT_Columns_sep:
55 m_bSep = (nIntValue != 0);
56 break;
58 case NS_ooxml::LN_CT_Column_w:
59 m_aTempColumn.nWidth = ConversionHelper::convertTwipToMM100(nIntValue);
60 break;
61 case NS_ooxml::LN_CT_Column_space:
62 m_aTempColumn.nSpace = ConversionHelper::convertTwipToMM100(nIntValue);
63 break;
64 default:
65 OSL_FAIL("SectionColumnHandler: unknown attribute");
69 void SectionColumnHandler::lcl_sprm(Sprm& rSprm)
71 switch (rSprm.getId())
73 case NS_ooxml::LN_CT_Columns_col:
75 m_aTempColumn.nWidth = m_aTempColumn.nSpace = 0;
76 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
77 if (pProperties)
79 pProperties->resolve(*this);
80 m_aCols.push_back(m_aTempColumn);
83 break;
84 default:
85 OSL_FAIL("SectionColumnHandler: unknown sprm");
88 } //namespace writerfilter::dmapper
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */