update emoji autocorrect entries from po-files
[LibreOffice.git] / writerfilter / source / dmapper / TblStylePrHandler.cxx
blobd1c28ba7fc62ceead547e160718862dcf1091181
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 .
20 #include <TblStylePrHandler.hxx>
21 #include <PropertyMap.hxx>
22 #include <ooxml/resourceids.hxx>
23 #include <comphelper/sequence.hxx>
26 using namespace css;
28 namespace writerfilter {
29 namespace dmapper {
31 TblStylePrHandler::TblStylePrHandler( DomainMapper & rDMapper ) :
32 LoggedProperties("TblStylePrHandler"),
33 m_rDMapper( rDMapper ),
34 m_pTablePropsHandler(new TablePropertiesHandler()),
35 m_nType( TBL_STYLE_UNKNOWN ),
36 m_pProperties( new PropertyMap )
40 TblStylePrHandler::~TblStylePrHandler( )
42 delete m_pTablePropsHandler, m_pTablePropsHandler = nullptr;
45 OUString TblStylePrHandler::getTypeString()
47 switch (m_nType)
49 case TBL_STYLE_WHOLETABLE: return OUString("wholeTable");
50 case TBL_STYLE_FIRSTROW: return OUString("firstRow");
51 case TBL_STYLE_LASTROW: return OUString("lastRow");
52 case TBL_STYLE_FIRSTCOL: return OUString("firstCol");
53 case TBL_STYLE_LASTCOL: return OUString("lastCol");
54 case TBL_STYLE_BAND1VERT: return OUString("band1Vert");
55 case TBL_STYLE_BAND2VERT: return OUString("band2Vert");
56 case TBL_STYLE_BAND1HORZ: return OUString("band1Horz");
57 case TBL_STYLE_BAND2HORZ: return OUString("band2Horz");
58 case TBL_STYLE_NECELL: return OUString("neCell");
59 case TBL_STYLE_NWCELL: return OUString("nwCell");
60 case TBL_STYLE_SECELL: return OUString("seCell");
61 case TBL_STYLE_SWCELL: return OUString("swCell");
62 default: break;
64 return OUString();
67 void TblStylePrHandler::lcl_attribute(Id rName, Value & rVal)
70 switch ( rName )
72 case NS_ooxml::LN_CT_TblStyleOverrideType:
74 switch (rVal.getInt())
76 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_wholeTable:
77 m_nType = TBL_STYLE_WHOLETABLE;
78 break;
79 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_firstRow:
80 m_nType = TBL_STYLE_FIRSTROW;
81 break;
82 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_lastRow:
83 m_nType = TBL_STYLE_LASTROW;
84 break;
85 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_firstCol:
86 m_nType = TBL_STYLE_FIRSTCOL;
87 break;
88 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_lastCol:
89 m_nType = TBL_STYLE_LASTCOL;
90 break;
91 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band1Vert:
92 m_nType = TBL_STYLE_BAND1VERT;
93 break;
94 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band2Vert:
95 m_nType = TBL_STYLE_BAND2VERT;
96 break;
97 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band1Horz:
98 m_nType = TBL_STYLE_BAND1HORZ;
99 break;
100 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_band2Horz:
101 m_nType = TBL_STYLE_BAND2HORZ;
102 break;
103 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_neCell:
104 m_nType = TBL_STYLE_NECELL;
105 break;
106 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_nwCell:
107 m_nType = TBL_STYLE_NWCELL;
108 break;
109 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_seCell:
110 m_nType = TBL_STYLE_SECELL;
111 break;
112 case NS_ooxml::LN_Value_ST_TblStyleOverrideType_swCell:
113 m_nType = TBL_STYLE_SWCELL;
114 break;
117 break;
121 void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
123 #ifdef DEBUG_WRITERFILTER
124 TagLogger::getInstance().startElement("TblStylePrHandler.sprm");
125 TagLogger::getInstance().attribute("sprm", rSprm.toString());
126 #endif
128 Value::Pointer_t pValue = rSprm.getValue();
129 switch ( rSprm.getId( ) )
131 case NS_ooxml::LN_CT_PPrBase:
132 case NS_ooxml::LN_EG_RPrBase:
133 case NS_ooxml::LN_CT_TblPrBase:
134 case NS_ooxml::LN_CT_TrPrBase:
135 case NS_ooxml::LN_CT_TcPrBase:
137 std::vector<beans::PropertyValue> aSavedGrabBag;
138 bool bGrabBag = rSprm.getId() == NS_ooxml::LN_CT_PPrBase ||
139 rSprm.getId() == NS_ooxml::LN_EG_RPrBase ||
140 rSprm.getId() == NS_ooxml::LN_CT_TblPrBase ||
141 rSprm.getId() == NS_ooxml::LN_CT_TcPrBase;
142 if (bGrabBag)
144 aSavedGrabBag = m_aInteropGrabBag;
145 m_aInteropGrabBag.clear();
147 resolveSprmProps( rSprm );
148 if (bGrabBag)
150 if (rSprm.getId() == NS_ooxml::LN_CT_PPrBase)
151 aSavedGrabBag.push_back(getInteropGrabBag("pPr"));
152 else if (rSprm.getId() == NS_ooxml::LN_EG_RPrBase)
153 aSavedGrabBag.push_back(getInteropGrabBag("rPr"));
154 else if (rSprm.getId() == NS_ooxml::LN_CT_TblPrBase)
155 aSavedGrabBag.push_back(getInteropGrabBag("tblPr"));
156 else if (rSprm.getId() == NS_ooxml::LN_CT_TcPrBase)
157 aSavedGrabBag.push_back(getInteropGrabBag("tcPr"));
158 m_aInteropGrabBag = aSavedGrabBag;
161 break;
162 default:
163 // Tables specific properties have to handled here
164 m_pTablePropsHandler->SetProperties( m_pProperties );
165 m_pTablePropsHandler->SetInteropGrabBag(m_aInteropGrabBag);
166 bool bRet = m_pTablePropsHandler->sprm( rSprm );
168 if ( !bRet )
170 // The DomainMapper can handle some of the properties
171 m_rDMapper.PushStyleSheetProperties( m_pProperties, true );
172 // Just pass a non-empty string, the array will have a single element anyway.
173 m_rDMapper.enableInteropGrabBag("TblStylePrHandler");
174 m_rDMapper.sprm( rSprm );
175 uno::Sequence<beans::PropertyValue> aGrabBag = m_rDMapper.getInteropGrabBag().Value.get< uno::Sequence<beans::PropertyValue> >();
176 if (aGrabBag.hasElements())
177 m_aInteropGrabBag.push_back(aGrabBag[0]);
178 m_rDMapper.PopStyleSheetProperties( true );
182 #ifdef DEBUG_WRITERFILTER
183 TagLogger::getInstance().endElement();
184 #endif
187 void TblStylePrHandler::resolveSprmProps(Sprm & rSprm)
189 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
190 if( pProperties.get())
191 pProperties->resolve(*this);
194 void TblStylePrHandler::appendInteropGrabBag(const OUString& aKey, const OUString& aValue)
196 beans::PropertyValue aProperty;
197 aProperty.Name = aKey;
198 aProperty.Value = uno::makeAny(aValue);
199 m_aInteropGrabBag.push_back(aProperty);
202 beans::PropertyValue TblStylePrHandler::getInteropGrabBag(const OUString& aName)
204 beans::PropertyValue aRet;
205 aRet.Name = aName;
207 aRet.Value = uno::makeAny(comphelper::containerToSequence(m_aInteropGrabBag));
208 return aRet;
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */