LibreOffice Module oox (master)  1
commonbehaviorcontext.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 
20 #include <rtl/ustrbuf.hxx>
21 #include <sal/log.hxx>
22 
24 #include <oox/token/namespaces.hxx>
26 
30 
31 #include <string.h>
32 
33 using namespace ::oox::core;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
36 
37 namespace oox::ppt {
38 
39  CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2 const & rParent,
40  const TimeNodePtr & pNode)
41  : FragmentHandler2(rParent)
42  , mbInAttrList( false )
43  , mbIsInAttrName( false )
44  , mpNode(pNode)
45  {
46  }
47 
49  {
50  }
51 
53  {
54  switch( getCurrentElement() )
55  {
56  case PPT_TOKEN( cBhvr ):
57  {
58  if( !maAttributes.empty() )
59  {
60  OUStringBuffer sAttributes;
61  for (auto const& attribute : maAttributes)
62  {
63  if( !sAttributes.isEmpty() )
64  {
65  sAttributes.append( ";" );
66  }
67  sAttributes.append( attribute.name );
68  }
69  OUString sTmp( sAttributes.makeStringAndClear() );
70  mpNode->getNodeProperties()[ NP_ATTRIBUTENAME ] <<= sTmp;
71  }
72  break;
73  }
74  case PPT_TOKEN( attrNameLst ):
75  mbInAttrList = false;
76  break;
77  case PPT_TOKEN( attrName ):
78  if( mbIsInAttrName )
79  {
81  while( attrConv->mpMSName != nullptr )
82  {
83  if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
84  {
85  Attribute attr;
86  attr.name = OUString::intern( attrConv->mpAPIName,
87  strlen(attrConv->mpAPIName),
88  RTL_TEXTENCODING_ASCII_US );
89  attr.type = attrConv->meAttribute;
90  maAttributes.push_back( attr );
91  SAL_INFO("oox.ppt", "OOX: attrName is " << msCurrentAttribute << " -> " << attrConv->mpAPIName );
92  break;
93  }
94  attrConv++;
95  }
96  mbIsInAttrName = false;
97  }
98  break;
99  default:
100  break;
101  }
102  }
103 
104  void CommonBehaviorContext::onCharacters( const OUString& aChars )
105  {
106  if( mbIsInAttrName )
107  {
108  msCurrentAttribute += aChars;
109  }
110  }
111 
113  {
114  switch ( aElementToken )
115  {
116  case PPT_TOKEN( cTn ):
117  return new CommonTimeNodeContext( *this, aElementToken, rAttribs.getFastAttributeList(), mpNode );
118  case PPT_TOKEN( tgtEl ):
119  return new TimeTargetElementContext( *this, mpNode->getTarget() );
120  case PPT_TOKEN( attrNameLst ):
121  mbInAttrList = true;
122  return this;
123  case PPT_TOKEN( attrName ):
124  {
125  if( mbInAttrList )
126  {
127  mbIsInAttrName = true;
128  msCurrentAttribute.clear();
129  }
130  else
131  {
132  SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" );
133  }
134  return this;
135  }
136  default:
137  break;
138  }
139 
140  return this;
141  }
142 
143 }
144 
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::vector< Attribute > maAttributes
AlgAtomPtr mpNode
const ImplAttributeNameConversion * getAttributeConversionList()
AnimationAttributeEnum type
CommonBehaviorContext(::oox::core::FragmentHandler2 const &rParent, const TimeNodePtr &pNode)
virtual ~CommonBehaviorContext() noexcept override
sal_Int32 getCurrentElement() const
Returns the identifier of the currently processed element.
Provides access to attribute values of an element.
sal_Int32 attribute
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
#define SAL_INFO(area, stream)
const css::uno::Reference< css::xml::sax::XFastAttributeList > & getFastAttributeList() const
Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object.
std::shared_ptr< TimeNode > TimeNodePtr
Definition: timenode.hxx:44
virtual void onCharacters(const OUString &aChars) override
Will be called before a new child element starts, or if the current element is about to be left...
virtual void onEndElement() override
Will be called when the current element is about to be left.
bool m_bDetectedRangeSegmentation false