28#include <osl/diagnose.h>
33#include <com/sun/star/uri/UriReferenceFactory.hpp>
34#include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
37#include <unordered_map>
44 public std::unordered_map< NameKey_Impl, OUString,
45 NameHash_Impl, NameHash_Impl >
56 XMLTransformerOASISEventMap_Impl::key_type aKey;
57 XMLTransformerOASISEventMap_Impl::mapped_type
aData;
61 aKey.m_aLocalName = OUString::createFromAscii(pInit->
m_pOASISName);
63 OSL_ENSURE(
find( aKey ) ==
end(),
"duplicate event map entry" );
67 XMLTransformerOASISEventMap_Impl::value_type aVal( aKey,
aData );
76 const OUString& rQName ) :
78 rImp.GetNamespaceMap().GetKeyByAttrName( rQName ),
XML_EVENT )
106 const OUString& rName,
110 XMLTransformerOASISEventMap_Impl::key_type aKey( nPrefix, rName );
113 XMLTransformerOASISEventMap_Impl::const_iterator aIter =
115 if( aIter != pMap2->end() )
116 return (*aIter).second;
119 XMLTransformerOASISEventMap_Impl::const_iterator aIter = rMap.find( aKey );
120 if( aIter == rMap.end() )
123 return (*aIter).second;
127 const OUString& rAttrValue,
128 OUString* pName, OUString* pLocation )
130 Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
132 Reference< css::uri::XUriReferenceFactory >
xFactory = css::uri::UriReferenceFactory::create(xContext);
134 Reference< css::uri::XVndSunStarScriptUrl > xUrl (
xFactory->parse( rAttrValue ), UNO_QUERY );
139 if ( xUrl.is() && xUrl->hasParameter( aLanguageKey ) )
141 OUString aLanguage = xUrl->getParameter( aLanguageKey );
143 if ( aLanguage.equalsIgnoreAsciiCase(
"basic") )
145 *
pName = xUrl->getName();
152 if ( tmp.equalsIgnoreAsciiCase( doc ) )
168 const Reference< XAttributeList >& rAttrList )
170 SAL_INFO(
"xmloff.transform",
"XMLEventOASISTransformerContext::StartElement");
174 SAL_WARN_IF( pActions ==
nullptr,
"xmloff.transform",
"got no actions" );
176 Reference< XAttributeList > xAttrList( rAttrList );
178 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
179 for( sal_Int16
i=0;
i < nAttrCount;
i++ )
181 const OUString& rAttrName = xAttrList->getNameByIndex(
i );
186 XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
187 XMLTransformerActions::const_iterator aIter =
188 pActions->find( aKey );
189 if( aIter != pActions->end() )
191 if( !pMutableAttrList )
195 xAttrList = pMutableAttrList;
197 const OUString& rAttrValue = xAttrList->getValueByIndex(
i );
198 switch( (*aIter).second.m_nActionType )
202 OUString
aName, aLocation;
204 bool bNeedsTransform =
207 if ( bNeedsTransform )
209 pMutableAttrList->RemoveAttributeByIndex(
i );
216 pMutableAttrList->AddAttribute( aAttrQName,
aName );
218 sal_Int16
idx = pMutableAttrList->GetIndexByName(
224 pMutableAttrList->SetValueByIndex(
idx,
"StarBasic");
231 pMutableAttrList->AddAttribute( aLocQName, aLocation );
242 bool bForm = pObjContext &&
245 pMutableAttrList->SetValueByIndex(
i,
252 OUString aAttrValue( rAttrValue );
253 sal_uInt16 nValPrefix =
254 static_cast<sal_uInt16
>((*aIter).second.m_nParam1);
256 aAttrValue, nValPrefix ) )
257 pMutableAttrList->SetValueByIndex(
i, aAttrValue );
262 OUString
aName, aLocation;
263 bool bNeedsTransform =
266 if ( bNeedsTransform )
268 pMutableAttrList->SetValueByIndex(
i,
aName );
270 sal_Int16
idx = pMutableAttrList->GetIndexByName(
276 pMutableAttrList->SetValueByIndex(
idx,
"StarBasic");
283 pMutableAttrList->AddAttribute( aLocQName, aLocation );
290 if( rAttrValue.getLength() > rApp.getLength()+1 &&
292 ':' == rAttrValue[rApp.getLength()] )
295 aAttrValue = rAttrValue.copy( rApp.getLength()+1 );
297 else if( rAttrValue.getLength() > rDoc.getLength()+1 &&
299 ':' == rAttrValue[rDoc.getLength()] )
302 aAttrValue = rAttrValue.copy( rDoc.getLength()+1 );
304 if( !aAttrValue.isEmpty() )
305 pMutableAttrList->SetValueByIndex(
i,
307 if( !aLocation.isEmpty() )
312 pMutableAttrList->AddAttribute( aAttrQName, aLocation );
317 pMutableAttrList->AddAttribute( aAttrQName, aLocation );
325 SAL_WARN(
"xmloff.transform",
"unknown action" );
XMLTransformerEventMapEntry const aFormTransformerEventMap[]
XMLTransformerEventMapEntry const aTransformerEventMap[]
static bool ParseURL(const OUString &rAttrValue, OUString *pName, OUString *pLocation)
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
static OUString GetEventName(sal_uInt16 nPrefix, const OUString &rName, XMLTransformerOASISEventMap_Impl &rMap, XMLTransformerOASISEventMap_Impl *pMap2)
static XMLTransformerOASISEventMap_Impl * CreateEventMap()
virtual ~XMLEventOASISTransformerContext() override
static XMLTransformerOASISEventMap_Impl * CreateFormEventMap()
static void FlushEventMap(XMLTransformerOASISEventMap_Impl *p)
XMLEventOASISTransformerContext(XMLTransformerBase &rTransformer, const OUString &rQName)
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
virtual void StartElement(const css::uno::Reference< css::xml::sax::XAttributeList > &xAttrList) override
bool HasNamespace(sal_uInt16 nPrefix) const
XMLTransformerBase & GetTransformer()
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
constexpr OUStringLiteral aData
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
const char * m_pOASISName
sal_uInt16 const m_nOASISPrefix
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT