tdf#144694 In direct SQL dialog, activate options 'Run SQL command
[LibreOffice.git] / oox / source / ppt / commonbehaviorcontext.cxx
blobca0a0c9ec7acfc57d822a02a11af58f50ebe5407
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 <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"
31 #include <string.h>
33 using namespace ::oox::core;
34 using namespace ::com::sun::star::uno;
35 using namespace ::com::sun::star::xml::sax;
37 namespace oox::ppt {
39 CommonBehaviorContext::CommonBehaviorContext( FragmentHandler2 const & rParent,
40 const TimeNodePtr & pNode)
41 : FragmentHandler2(rParent)
42 , mbInAttrList( false )
43 , mbIsInAttrName( false )
44 , mpNode(pNode)
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;
72 break;
74 case PPT_TOKEN( attrNameLst ):
75 mbInAttrList = false;
76 break;
77 case PPT_TOKEN( attrName ):
78 if( mbIsInAttrName )
80 const ImplAttributeNameConversion *attrConv = getAttributeConversionList();
81 while( attrConv->mpMSName != nullptr )
83 if(msCurrentAttribute.equalsAscii( attrConv->mpMSName ) )
85 Attribute attr;
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 );
92 break;
94 attrConv++;
96 mbIsInAttrName = false;
98 break;
99 default:
100 break;
104 void CommonBehaviorContext::onCharacters( const OUString& aChars )
106 if( mbIsInAttrName )
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 ):
121 mbInAttrList = true;
122 return this;
123 case PPT_TOKEN( attrName ):
125 if( mbInAttrList )
127 mbIsInAttrName = true;
128 msCurrentAttribute.clear();
130 else
132 SAL_INFO("oox.ppt", "OOX: Attribute Name outside an Attribute List" );
134 return this;
136 default:
137 break;
140 return this;
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */