1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <rtl/ustrbuf.hxx>
21 #include <sal/log.hxx>
23 #include <oox/helper/attributelist.hxx>
24 #include <oox/token/namespaces.hxx>
25 #include <oox/ppt/pptfilterhelpers.hxx>
27 #include "commonbehaviorcontext.hxx"
28 #include "commontimenodecontext.hxx"
29 #include "timetargetelementcontext.hxx"
33 using namespace ::oox::core
;
34 using namespace ::com::sun::star::uno
;
35 using namespace ::com::sun::star::xml::sax
;
39 CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2
const & rParent
,
40 const TimeNodePtr
& pNode
)
41 : FragmentHandler2(rParent
)
42 , mbInAttrList( false )
43 , mbIsInAttrName( false )
48 CommonBehaviorContext::~CommonBehaviorContext( ) noexcept
52 void CommonBehaviorContext::onEndElement()
54 switch( getCurrentElement() )
56 case PPT_TOKEN( cBhvr
):
58 if( !maAttributes
.empty() )
60 OUStringBuffer sAttributes
;
61 for (auto const& attribute
: maAttributes
)
63 if( !sAttributes
.isEmpty() )
65 sAttributes
.append( ";" );
67 sAttributes
.append( attribute
.name
);
69 OUString
sTmp( sAttributes
.makeStringAndClear() );
70 mpNode
->getNodeProperties()[ NP_ATTRIBUTENAME
] <<= sTmp
;
74 case PPT_TOKEN( attrNameLst
):
77 case PPT_TOKEN( attrName
):
80 const ImplAttributeNameConversion
*attrConv
= getAttributeConversionList();
81 while( attrConv
->mpMSName
!= nullptr )
83 if(msCurrentAttribute
.equalsAscii( attrConv
->mpMSName
) )
86 attr
.name
= OUString( 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
);
96 mbIsInAttrName
= false;
104 void CommonBehaviorContext::onCharacters( const OUString
& aChars
)
108 msCurrentAttribute
+= aChars
;
112 ::oox::core::ContextHandlerRef
CommonBehaviorContext::onCreateContext( sal_Int32 aElementToken
, const AttributeList
& rAttribs
)
114 switch ( aElementToken
)
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
):
123 case PPT_TOKEN( attrName
):
127 mbIsInAttrName
= true;
128 msCurrentAttribute
.clear();
132 SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" );
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */