1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 #include <TblStylePrHandler.hxx>
23 #include <PropertyMap.hxx>
24 #include <ooxml/resourceids.hxx>
25 #include <dmapperLoggers.hxx>
26 #include <resourcemodel/QNameToString.hxx>
27
28 #include "dmapperLoggers.hxx"
29
30 namespace writerfilter {
31 namespace dmapper {
32
TblStylePrHandler(DomainMapper & rDMapper)33 TblStylePrHandler::TblStylePrHandler( DomainMapper & rDMapper ) :
34 LoggedProperties(dmapper_logger, "TblStylePrHandler"),
35 m_rDMapper( rDMapper ),
36 m_pTablePropsHandler( new TablePropertiesHandler( true ) ),
37 m_nType( TBL_STYLE_UNKNOWN ),
38 m_pProperties( new PropertyMap )
39 {
40 }
41
~TblStylePrHandler()42 TblStylePrHandler::~TblStylePrHandler( )
43 {
44 delete m_pTablePropsHandler, m_pTablePropsHandler = NULL;
45 }
46
lcl_attribute(Id rName,Value & rVal)47 void TblStylePrHandler::lcl_attribute(Id rName, Value & rVal)
48 {
49 #ifdef DEBUG_DOMAINMAPPER
50 dmapper_logger->startElement("TblStylePrHandler.attribute");
51 dmapper_logger->attribute("name", (*QNameToString::Instance())(rName));
52 dmapper_logger->chars(rVal.toString());
53 dmapper_logger->endElement("TblStylePrHandler.attribute");
54 #endif
55
56 switch ( rName )
57 {
58 case NS_ooxml::LN_CT_TblStyleOverrideType:
59 {
60 // The tokenid should be the same in the model.xml than
61 // in the TblStyleType enum
62 m_nType = TblStyleType( rVal.getInt( ) );
63 }
64 break;
65 }
66 }
67
lcl_sprm(Sprm & rSprm)68 void TblStylePrHandler::lcl_sprm(Sprm & rSprm)
69 {
70 #ifdef DEBUG_DOMAINMAPPER
71 dmapper_logger->startElement("TblStylePrHandler.sprm");
72 dmapper_logger->attribute("sprm", rSprm.toString());
73 #endif
74
75 Value::Pointer_t pValue = rSprm.getValue();
76 switch ( rSprm.getId( ) )
77 {
78 case NS_ooxml::LN_CT_PPrBase:
79 case NS_ooxml::LN_EG_RPrBase:
80 case NS_ooxml::LN_CT_TblPrBase:
81 case NS_ooxml::LN_CT_TrPrBase:
82 case NS_ooxml::LN_CT_TcPrBase:
83 resolveSprmProps( rSprm );
84 break;
85 default:
86 // Tables specific properties have to handled here
87 m_pTablePropsHandler->SetProperties( m_pProperties );
88 bool bRet = m_pTablePropsHandler->sprm( rSprm );
89
90 if ( !bRet )
91 {
92 // The DomainMapper can handle some of the properties
93 m_rDMapper.PushStyleSheetProperties( m_pProperties, true );
94 m_rDMapper.sprm( rSprm );
95 m_rDMapper.PopStyleSheetProperties( true );
96 }
97 }
98
99 #ifdef DEBUG_DOMAINMAPPER
100 dmapper_logger->endElement("TblStylePrHandler.sprm");
101 #endif
102 }
103
resolveSprmProps(Sprm & rSprm)104 void TblStylePrHandler::resolveSprmProps(Sprm & rSprm)
105 {
106 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
107 if( pProperties.get())
108 pProperties->resolve(*this);
109 }
110
111 }}
112