1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10*63bba73cSAndrew Rist * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*63bba73cSAndrew Rist * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19*63bba73cSAndrew Rist * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp> 27cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp> 28cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 29cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 30cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 31cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 32cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 33cdf0e10cSrcweir #include "PropType.hxx" 34cdf0e10cSrcweir #include "DeepTContext.hxx" 35cdf0e10cSrcweir #include "RenameElemTContext.hxx" 36cdf0e10cSrcweir #include "ProcAttrTContext.hxx" 37cdf0e10cSrcweir #include "ActionMapTypesOOo.hxx" 38cdf0e10cSrcweir #include "MutableAttrList.hxx" 39cdf0e10cSrcweir #include "TransformerActions.hxx" 40cdf0e10cSrcweir #include "PropertyActionsOOo.hxx" 41cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFORMERBASE_HXX 42cdf0e10cSrcweir #include "TransformerBase.hxx" 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir 45cdf0e10cSrcweir #ifndef _XMLOFF_STYLEOASISTCONTEXT_HXX 46cdf0e10cSrcweir #include "StyleOOoTContext.hxx" 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 49cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 50cdf0e10cSrcweir #include <rtl/math.hxx> 51cdf0e10cSrcweir 52cdf0e10cSrcweir using ::rtl::OUString; 53cdf0e10cSrcweir using namespace ::xmloff::token; 54cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 56cdf0e10cSrcweir 57cdf0e10cSrcweir const sal_uInt16 MAX_PROP_TYPES = 4; 58cdf0e10cSrcweir #define ENTRY4(a,b,c,d) \ 59cdf0e10cSrcweir { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 60cdf0e10cSrcweir XML_PROP_TYPE_##c, XML_PROP_TYPE_##d } 61cdf0e10cSrcweir #define ENTRY3(a,b,c) \ 62cdf0e10cSrcweir { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 63cdf0e10cSrcweir XML_PROP_TYPE_##c, XML_PROP_TYPE_END } 64cdf0e10cSrcweir #define ENTRY2(a,b) \ 65cdf0e10cSrcweir { XML_PROP_TYPE_##a, XML_PROP_TYPE_##b, \ 66cdf0e10cSrcweir XML_PROP_TYPE_END, XML_PROP_TYPE_END } 67cdf0e10cSrcweir #define ENTRY1(a) \ 68cdf0e10cSrcweir { XML_PROP_TYPE_##a, XML_PROP_TYPE_##END, \ 69cdf0e10cSrcweir XML_PROP_TYPE_END, XML_PROP_TYPE_END } 70cdf0e10cSrcweir 71cdf0e10cSrcweir static XMLPropType aPropTypes[XML_FAMILY_TYPE_END][MAX_PROP_TYPES] = 72cdf0e10cSrcweir { 73cdf0e10cSrcweir ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_GRAPHIC, 74cdf0e10cSrcweir ENTRY3( GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PRESENTATION, 75cdf0e10cSrcweir ENTRY1( DRAWING_PAGE ), // XML_FAMILY_TYPE_DRAWING_PAGE, 76cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_MASTER_PAGE 77cdf0e10cSrcweir ENTRY1( PAGE_LAYOUT ), // XML_FAMILY_TYPE_PAGE_LAYOUT, 78cdf0e10cSrcweir ENTRY1( HEADER_FOOTER ), // XML_FAMILY_TYPE_HEADER_FOOTER 79cdf0e10cSrcweir ENTRY1( TEXT ), // XML_FAMILY_TYPE_TEXT, 80cdf0e10cSrcweir ENTRY2( PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_PARAGRAPH, 81cdf0e10cSrcweir ENTRY1( RUBY ), //XML_FAMILY_TYPE_RUBY, 82cdf0e10cSrcweir ENTRY1( SECTION ), // XML_FAMILY_TYPE_SECTION, 83cdf0e10cSrcweir ENTRY1( TABLE ), // XML_FAMILY_TYPE_TABLE, 84cdf0e10cSrcweir ENTRY1( TABLE_COLUMN ), // XML_FAMILY_TYPE_TABLE_COLUMN, 85cdf0e10cSrcweir ENTRY1( TABLE_ROW ), // XML_FAMILY_TYPE_TABLE_ROW, 86cdf0e10cSrcweir ENTRY3( TABLE_CELL, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_TABLE_CELL, 87cdf0e10cSrcweir ENTRY1( LIST_LEVEL ), // XML_FAMILY_TYPE_LIST, 88cdf0e10cSrcweir ENTRY4( CHART, GRAPHIC, PARAGRAPH, TEXT ), // XML_FAMILY_TYPE_CHART, 89cdf0e10cSrcweir ENTRY1( TEXT ), // XML_FAMILY_TYPE_DATA, 90cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_GRADIENT, 91cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_HATCH, 92cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_FILL_IMAGE, 93cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_STROKE_DASH, 94cdf0e10cSrcweir ENTRY1( END ), // XML_FAMILY_TYPE_MARKER, 95cdf0e10cSrcweir ENTRY1( END ) // XML_FAMILY_TYPE_PRESENTATION_PAGE_LAYOUT, 96cdf0e10cSrcweir }; 97cdf0e10cSrcweir 98cdf0e10cSrcweir static XMLTokenEnum aPropTokens[XML_PROP_TYPE_END] = 99cdf0e10cSrcweir { 100cdf0e10cSrcweir XML_GRAPHIC_PROPERTIES, 101cdf0e10cSrcweir XML_DRAWING_PAGE_PROPERTIES, 102cdf0e10cSrcweir XML_PAGE_LAYOUT_PROPERTIES, 103cdf0e10cSrcweir XML_HEADER_FOOTER_PROPERTIES, 104cdf0e10cSrcweir XML_TEXT_PROPERTIES, 105cdf0e10cSrcweir XML_PARAGRAPH_PROPERTIES, 106cdf0e10cSrcweir XML_RUBY_PROPERTIES, 107cdf0e10cSrcweir XML_SECTION_PROPERTIES, 108cdf0e10cSrcweir XML_TABLE_PROPERTIES, 109cdf0e10cSrcweir XML_TABLE_COLUMN_PROPERTIES, 110cdf0e10cSrcweir XML_TABLE_ROW_PROPERTIES, 111cdf0e10cSrcweir XML_TABLE_CELL_PROPERTIES, 112cdf0e10cSrcweir XML_LIST_LEVEL_PROPERTIES, 113cdf0e10cSrcweir XML_CHART_PROPERTIES 114cdf0e10cSrcweir }; 115cdf0e10cSrcweir 116cdf0e10cSrcweir static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] = 117cdf0e10cSrcweir { 118cdf0e10cSrcweir PROP_OOO_GRAPHIC_ATTR_ACTIONS, 119cdf0e10cSrcweir PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE 120cdf0e10cSrcweir PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS, 121cdf0e10cSrcweir PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS, 122cdf0e10cSrcweir PROP_OOO_TEXT_ATTR_ACTIONS, 123cdf0e10cSrcweir PROP_OOO_PARAGRAPH_ATTR_ACTIONS, 124cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, // RUBY 125cdf0e10cSrcweir PROP_OOO_SECTION_ATTR_ACTIONS, 126cdf0e10cSrcweir PROP_OOO_TABLE_ATTR_ACTIONS, 127cdf0e10cSrcweir PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS, 128cdf0e10cSrcweir PROP_OOO_TABLE_ROW_ATTR_ACTIONS, 129cdf0e10cSrcweir PROP_OOO_TABLE_CELL_ATTR_ACTIONS, 130cdf0e10cSrcweir PROP_OOO_LIST_LEVEL_ATTR_ACTIONS, 131cdf0e10cSrcweir PROP_OOO_CHART_ATTR_ACTIONS 132cdf0e10cSrcweir }; 133cdf0e10cSrcweir 134cdf0e10cSrcweir static sal_uInt16 aElemActionMaps[XML_PROP_TYPE_END] = 135cdf0e10cSrcweir { 136cdf0e10cSrcweir PROP_OOO_GRAPHIC_ELEM_ACTIONS, 137cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 138cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 139cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 140cdf0e10cSrcweir PROP_OOO_TEXT_ELEM_ACTIONS, 141cdf0e10cSrcweir PROP_OOO_PARAGRAPH_ELEM_ACTIONS, 142cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 143cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 144cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 145cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 146cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 147cdf0e10cSrcweir PROP_OOO_TABLE_CELL_ELEM_ACTIONS, 148cdf0e10cSrcweir MAX_OOO_PROP_ACTIONS, 149cdf0e10cSrcweir PROP_OOO_CHART_ELEM_ACTIONS 150cdf0e10cSrcweir }; 151cdf0e10cSrcweir 152cdf0e10cSrcweir 153cdf0e10cSrcweir //------------------------------------------------------------------------------ 154cdf0e10cSrcweir 155cdf0e10cSrcweir class XMLTypedPropertiesOOoTContext_Impl : public XMLPersElemContentTContext 156cdf0e10cSrcweir { 157cdf0e10cSrcweir ::com::sun::star::uno::Reference< 158cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > m_xAttrList; 159cdf0e10cSrcweir 160cdf0e10cSrcweir public: 161cdf0e10cSrcweir 162cdf0e10cSrcweir TYPEINFO(); 163cdf0e10cSrcweir 164cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer, 165cdf0e10cSrcweir const ::rtl::OUString& rQName ); 166cdf0e10cSrcweir 167cdf0e10cSrcweir virtual ~XMLTypedPropertiesOOoTContext_Impl(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir using XMLPersAttrListTContext::AddAttribute; 170cdf0e10cSrcweir void AddAttribute( const ::rtl::OUString &sName , 171cdf0e10cSrcweir const ::rtl::OUString &sValue ); 172cdf0e10cSrcweir void AddAttribute( sal_uInt16 nPrefix, XMLTokenEnum eToken, 173cdf0e10cSrcweir const ::rtl::OUString &sValue ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList ); 176cdf0e10cSrcweir 177cdf0e10cSrcweir virtual void Export(); 178cdf0e10cSrcweir }; 179cdf0e10cSrcweir 180cdf0e10cSrcweir TYPEINIT1( XMLTypedPropertiesOOoTContext_Impl, XMLPersElemContentTContext ); 181cdf0e10cSrcweir 182cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl::XMLTypedPropertiesOOoTContext_Impl( 183cdf0e10cSrcweir XMLTransformerBase& rImp, 184cdf0e10cSrcweir const OUString& rQName ) : 185cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName ), 186cdf0e10cSrcweir m_xAttrList( new XMLMutableAttributeList() ) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir } 189cdf0e10cSrcweir 190cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl::~XMLTypedPropertiesOOoTContext_Impl() 191cdf0e10cSrcweir { 192cdf0e10cSrcweir } 193cdf0e10cSrcweir 194cdf0e10cSrcweir void XMLTypedPropertiesOOoTContext_Impl::AddAttribute( 195cdf0e10cSrcweir const ::rtl::OUString &sName , 196cdf0e10cSrcweir const ::rtl::OUString &sValue ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ) 199cdf0e10cSrcweir ->AddAttribute( sName, sValue ); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir void XMLTypedPropertiesOOoTContext_Impl::AddAttribute( 203cdf0e10cSrcweir sal_uInt16 nPrefix, XMLTokenEnum eToken, 204cdf0e10cSrcweir const ::rtl::OUString &sValue ) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir OUString sName( 207cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 208cdf0e10cSrcweir nPrefix, ::xmloff::token::GetXMLToken( eToken ) ) ); 209cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ) 210cdf0e10cSrcweir ->AddAttribute( sName, sValue ); 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir void XMLTypedPropertiesOOoTContext_Impl::StartElement( 214cdf0e10cSrcweir const Reference< XAttributeList >& ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir // empty, ignore even the attribute list 217cdf0e10cSrcweir } 218cdf0e10cSrcweir 219cdf0e10cSrcweir void XMLTypedPropertiesOOoTContext_Impl::Export() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir if( m_xAttrList->getLength() || HasElementContent() ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetQName(), m_xAttrList ); 224cdf0e10cSrcweir ExportContent(); 225cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetQName() ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir } 228cdf0e10cSrcweir 229cdf0e10cSrcweir //------------------------------------------------------------------------------ 230cdf0e10cSrcweir 231cdf0e10cSrcweir class XMLPropertiesOOoTContext_Impl : public XMLTransformerContext 232cdf0e10cSrcweir { 233cdf0e10cSrcweir ::rtl::Reference < XMLTypedPropertiesOOoTContext_Impl > 234cdf0e10cSrcweir m_aPropContexts[MAX_PROP_TYPES]; 235cdf0e10cSrcweir 236cdf0e10cSrcweir typedef XMLPropType XMLPropTypes[MAX_PROP_TYPES]; 237cdf0e10cSrcweir 238cdf0e10cSrcweir XMLPropTypes m_aPropTypes; 239cdf0e10cSrcweir 240cdf0e10cSrcweir sal_Bool m_bPersistent; 241cdf0e10cSrcweir 242cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl *GetPropContextAndAction( 243cdf0e10cSrcweir TransformerAction_Impl& rAction, 244cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName, 245cdf0e10cSrcweir sal_Bool bElem ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl *GetPropContext( 248cdf0e10cSrcweir XMLPropType eType ); 249cdf0e10cSrcweir 250cdf0e10cSrcweir 251cdf0e10cSrcweir public: 252cdf0e10cSrcweir 253cdf0e10cSrcweir TYPEINFO(); 254cdf0e10cSrcweir 255cdf0e10cSrcweir XMLPropertiesOOoTContext_Impl( XMLTransformerBase& rTransformer, 256cdf0e10cSrcweir const ::rtl::OUString& rQName, 257cdf0e10cSrcweir XMLPropTypes& rTypes, 258cdf0e10cSrcweir sal_Bool bPersistent ); 259cdf0e10cSrcweir 260cdf0e10cSrcweir virtual ~XMLPropertiesOOoTContext_Impl(); 261cdf0e10cSrcweir 262cdf0e10cSrcweir XMLTransformerContext *CreateChildContext( 263cdf0e10cSrcweir sal_uInt16 nPrefix, 264cdf0e10cSrcweir const OUString& rLocalName, 265cdf0e10cSrcweir const OUString& rQName, 266cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& rAttrList ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir virtual void EndElement(); 271cdf0e10cSrcweir 272cdf0e10cSrcweir virtual void Characters( const ::rtl::OUString& rChars ); 273cdf0e10cSrcweir 274cdf0e10cSrcweir virtual void Export(); 275cdf0e10cSrcweir 276cdf0e10cSrcweir virtual sal_Bool IsPersistent() const; 277cdf0e10cSrcweir }; 278cdf0e10cSrcweir 279cdf0e10cSrcweir TYPEINIT1( XMLPropertiesOOoTContext_Impl, XMLTransformerContext ); 280cdf0e10cSrcweir 281cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl 282cdf0e10cSrcweir *XMLPropertiesOOoTContext_Impl::GetPropContext( 283cdf0e10cSrcweir XMLPropType eType ) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir sal_uInt16 nIndex = MAX_PROP_TYPES; 286cdf0e10cSrcweir for( sal_uInt16 i=0; i< MAX_PROP_TYPES; i++ ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir if( m_aPropTypes[i] == eType ) 289cdf0e10cSrcweir { 290cdf0e10cSrcweir nIndex = i; 291cdf0e10cSrcweir break; 292cdf0e10cSrcweir } 293cdf0e10cSrcweir } 294cdf0e10cSrcweir if( MAX_PROP_TYPES == nIndex ) 295cdf0e10cSrcweir return 0; 296cdf0e10cSrcweir 297cdf0e10cSrcweir if( !m_aPropContexts[nIndex].is() ) 298cdf0e10cSrcweir { 299cdf0e10cSrcweir m_aPropContexts[nIndex] = 300cdf0e10cSrcweir new XMLTypedPropertiesOOoTContext_Impl( 301cdf0e10cSrcweir GetTransformer(), 302cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 303cdf0e10cSrcweir XML_NAMESPACE_STYLE, 304cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 305cdf0e10cSrcweir aPropTokens[m_aPropTypes[nIndex]] ) )); 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir return m_aPropContexts[nIndex].get(); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir 312cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl 313cdf0e10cSrcweir *XMLPropertiesOOoTContext_Impl::GetPropContextAndAction( 314cdf0e10cSrcweir TransformerAction_Impl& rAction, 315cdf0e10cSrcweir sal_uInt16 nPrefix, const OUString& rLocalName, 316cdf0e10cSrcweir sal_Bool bElem ) 317cdf0e10cSrcweir { 318cdf0e10cSrcweir rAction.m_nActionType = XML_ATACTION_COPY; 319cdf0e10cSrcweir sal_uInt16 nIndex = 0; 320cdf0e10cSrcweir 321cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, rLocalName ); 322cdf0e10cSrcweir sal_uInt16 i=0; 323cdf0e10cSrcweir while( i < MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir sal_uInt16 nActionMap = 326cdf0e10cSrcweir (bElem ? aElemActionMaps : aAttrActionMaps)[m_aPropTypes[i]]; 327cdf0e10cSrcweir if( nActionMap < MAX_OOO_PROP_ACTIONS ) 328cdf0e10cSrcweir { 329cdf0e10cSrcweir XMLTransformerActions *pActions = 330cdf0e10cSrcweir GetTransformer().GetUserDefinedActions( nActionMap ); 331cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" ); 332cdf0e10cSrcweir if( pActions ) 333cdf0e10cSrcweir { 334cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter = 335cdf0e10cSrcweir pActions->find( aKey ); 336cdf0e10cSrcweir 337cdf0e10cSrcweir if( !(aIter == pActions->end()) ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir rAction = (*aIter).second; 340cdf0e10cSrcweir nIndex = i; 341cdf0e10cSrcweir break; 342cdf0e10cSrcweir } 343cdf0e10cSrcweir } 344cdf0e10cSrcweir } 345cdf0e10cSrcweir ++i; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir #ifdef DBG_UTIL 349cdf0e10cSrcweir if( !( XML_NAMESPACE_NONE == nPrefix || 350cdf0e10cSrcweir (XML_NAMESPACE_UNKNOWN_FLAG & nPrefix) || 351cdf0e10cSrcweir XML_PROP_TYPE_END==m_aPropTypes[1] || 352cdf0e10cSrcweir (i<MAX_PROP_TYPES && XML_PROP_TYPE_END!=m_aPropTypes[i]) ) ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir ::rtl::OString aTmp("Didnt't find property: "); 355cdf0e10cSrcweir const ::rtl::OUString& rPrefix = 356cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetPrefixByKey( nPrefix ); 357cdf0e10cSrcweir aTmp += ::rtl::OString( rPrefix.getStr(), rPrefix.getLength(), 358cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 359cdf0e10cSrcweir aTmp += ::rtl::OString::valueOf( ':' ); 360cdf0e10cSrcweir aTmp += ::rtl::OString( rLocalName.getStr(), rLocalName.getLength(), 361cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 362cdf0e10cSrcweir aTmp += ::rtl::OString(", assuming <style:"); 363cdf0e10cSrcweir const ::rtl::OUString& rName = 364cdf0e10cSrcweir ::xmloff::token::GetXMLToken( aPropTokens[m_aPropTypes[0]] ); 365cdf0e10cSrcweir aTmp += ::rtl::OString( rName.getStr(), rName.getLength(), 366cdf0e10cSrcweir RTL_TEXTENCODING_ASCII_US ); 367cdf0e10cSrcweir aTmp += ::rtl::OString::valueOf( '>' ); 368cdf0e10cSrcweir 369cdf0e10cSrcweir OSL_ENSURE( !this, aTmp ); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir #endif 372cdf0e10cSrcweir 373cdf0e10cSrcweir if( !m_aPropContexts[nIndex].is() ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir m_aPropContexts[nIndex] = 376cdf0e10cSrcweir new XMLTypedPropertiesOOoTContext_Impl( 377cdf0e10cSrcweir GetTransformer(), 378cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 379cdf0e10cSrcweir XML_NAMESPACE_STYLE, 380cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 381cdf0e10cSrcweir aPropTokens[m_aPropTypes[nIndex]] ) )); 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir return m_aPropContexts[nIndex].get(); 385cdf0e10cSrcweir } 386cdf0e10cSrcweir 387cdf0e10cSrcweir XMLPropertiesOOoTContext_Impl::XMLPropertiesOOoTContext_Impl( 388cdf0e10cSrcweir XMLTransformerBase& rImp, 389cdf0e10cSrcweir const OUString& rQName, 390cdf0e10cSrcweir XMLPropTypes& rTypes, 391cdf0e10cSrcweir sal_Bool bPersistent ) : 392cdf0e10cSrcweir XMLTransformerContext( rImp, rQName ), 393cdf0e10cSrcweir m_bPersistent( bPersistent ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir for( sal_uInt16 i=0; i < MAX_PROP_TYPES; ++i ) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir // remember the types that belong to the attribute and element lists 398cdf0e10cSrcweir m_aPropTypes[i] = rTypes[i]; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir } 401cdf0e10cSrcweir 402cdf0e10cSrcweir XMLPropertiesOOoTContext_Impl::~XMLPropertiesOOoTContext_Impl() 403cdf0e10cSrcweir { 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir XMLTransformerContext *XMLPropertiesOOoTContext_Impl::CreateChildContext( 407cdf0e10cSrcweir sal_uInt16 nPrefix, 408cdf0e10cSrcweir const OUString& rLocalName, 409cdf0e10cSrcweir const OUString& rQName, 410cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir TransformerAction_Impl aAction; 413cdf0e10cSrcweir return GetPropContextAndAction( aAction, nPrefix, rLocalName, sal_True ) 414cdf0e10cSrcweir ->CreateChildContext( nPrefix, rLocalName, rQName, rAttrList ); 415cdf0e10cSrcweir } 416cdf0e10cSrcweir 417cdf0e10cSrcweir 418cdf0e10cSrcweir void XMLPropertiesOOoTContext_Impl::StartElement( 419cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 420cdf0e10cSrcweir { 421cdf0e10cSrcweir Reference< XAttributeList > xAttrList( rAttrList ); 422cdf0e10cSrcweir 423cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl * pIntervalMinorDivisorContext = 0; 424cdf0e10cSrcweir double fIntervalMajor = 0.0; 425cdf0e10cSrcweir double fIntervalMinor = 0.0; 426cdf0e10cSrcweir sal_Bool bMoveProtect = sal_False; 427cdf0e10cSrcweir sal_Bool bSizeProtect = sal_False; 428cdf0e10cSrcweir OUString aProtectAttrValue; 429cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl * pProtectContext = 0; 430cdf0e10cSrcweir 431cdf0e10cSrcweir // --> OD 2005-05-13 #i49139# - attribute <style:mirror> has to be priority 432cdf0e10cSrcweir // over attribute <style:draw>. The filter from OpenDocument file format 433cdf0e10cSrcweir // to OpenOffice.org file format produces styles with both attributes. 434cdf0e10cSrcweir sal_Bool bExistStyleMirror( sal_False ); 435cdf0e10cSrcweir OUString aStyleMirrorAttrValue; 436cdf0e10cSrcweir sal_Bool bExistDrawMirror( sal_False ); 437cdf0e10cSrcweir OUString aDrawMirrorAttrValue; 438cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl* pMirrorContext( 0L ); 439cdf0e10cSrcweir // <-- 440cdf0e10cSrcweir 441cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 442cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir const OUString sAttrName = xAttrList->getNameByIndex( i ); 445cdf0e10cSrcweir const OUString sAttrValue = xAttrList->getValueByIndex( i ); 446cdf0e10cSrcweir OUString aLocalName; 447cdf0e10cSrcweir sal_uInt16 nPrefix = 448cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName, 449cdf0e10cSrcweir &aLocalName ); 450cdf0e10cSrcweir TransformerAction_Impl aAction; 451cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl *pContext = 452cdf0e10cSrcweir GetPropContextAndAction( aAction, nPrefix, aLocalName, sal_False ); 453cdf0e10cSrcweir switch( aAction.m_nActionType ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir case XML_ATACTION_REMOVE: 456cdf0e10cSrcweir break; 457cdf0e10cSrcweir case XML_ATACTION_COPY: 458cdf0e10cSrcweir pContext->AddAttribute( sAttrName, sAttrValue ); 459cdf0e10cSrcweir break; 460cdf0e10cSrcweir case XML_ATACTION_COPY_DUPLICATE: 461cdf0e10cSrcweir { 462cdf0e10cSrcweir pContext->AddAttribute( sAttrName, sAttrValue ); 463cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl *pContext2 = 464cdf0e10cSrcweir GetPropContext( (XMLPropType)aAction.m_nParam1 ); 465cdf0e10cSrcweir if( pContext2 ) 466cdf0e10cSrcweir pContext2->AddAttribute( sAttrName, sAttrValue ); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir break; 469cdf0e10cSrcweir case XML_ATACTION_RENAME: 470cdf0e10cSrcweir { 471cdf0e10cSrcweir pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 472cdf0e10cSrcweir aAction.GetQNameTokenFromParam1(), 473cdf0e10cSrcweir sAttrValue ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir break; 476cdf0e10cSrcweir case XML_ATACTION_ENCODE_STYLE_NAME_REF: 477cdf0e10cSrcweir { 478cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 479cdf0e10cSrcweir GetTransformer().EncodeStyleName(aAttrValue); 480cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir break; 483cdf0e10cSrcweir case XML_ATACTION_RENAME_ENCODE_STYLE_NAME_REF: 484cdf0e10cSrcweir { 485cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 486cdf0e10cSrcweir GetTransformer().EncodeStyleName(aAttrValue); 487cdf0e10cSrcweir pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 488cdf0e10cSrcweir aAction.GetQNameTokenFromParam1(), 489cdf0e10cSrcweir aAttrValue ); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir break; 492cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT: 493cdf0e10cSrcweir { 494cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 495cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue); 496cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 497cdf0e10cSrcweir } 498cdf0e10cSrcweir break; 499cdf0e10cSrcweir case XML_ATACTION_RENAME_NEG_PERCENT: 500cdf0e10cSrcweir { 501cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 502cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue); 503cdf0e10cSrcweir pContext->AddAttribute( aAction.GetQNamePrefixFromParam1(), 504cdf0e10cSrcweir aAction.GetQNameTokenFromParam1(), 505cdf0e10cSrcweir aAttrValue ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir break; 508cdf0e10cSrcweir case XML_ATACTION_INCH2IN: 509cdf0e10cSrcweir { 510cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 511cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 512cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 513cdf0e10cSrcweir } 514cdf0e10cSrcweir break; 515cdf0e10cSrcweir case XML_ATACTION_INCH2IN_DUPLICATE: 516cdf0e10cSrcweir { 517cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 518cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 519cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 520cdf0e10cSrcweir XMLTypedPropertiesOOoTContext_Impl *pContext2 = 521cdf0e10cSrcweir GetPropContext( (XMLPropType)aAction.m_nParam1 ); 522cdf0e10cSrcweir if( pContext2 ) 523cdf0e10cSrcweir pContext2->AddAttribute( sAttrName, aAttrValue ); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir break; 526cdf0e10cSrcweir case XML_ATACTION_INCHS2INS: 527cdf0e10cSrcweir { 528cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 529cdf0e10cSrcweir XMLTransformerBase::ReplaceInchWithIn( aAttrValue ); 530cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 531cdf0e10cSrcweir } 532cdf0e10cSrcweir break; 533cdf0e10cSrcweir case XML_PTACTION_LINE_MODE: 534cdf0e10cSrcweir { 535cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( 536cdf0e10cSrcweir IsXMLToken( sAttrValue, XML_TRUE ) 537cdf0e10cSrcweir ? XML_CONTINUOUS 538cdf0e10cSrcweir : XML_SKIP_WHITE_SPACE) ); 539cdf0e10cSrcweir OUString aAttrQName( 540cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 541cdf0e10cSrcweir XML_NAMESPACE_STYLE, 542cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE_MODE ) ) ); 543cdf0e10cSrcweir pContext->AddAttribute( aAttrQName, aAttrValue ); 544cdf0e10cSrcweir 545cdf0e10cSrcweir aAttrQName = 546cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 547cdf0e10cSrcweir XML_NAMESPACE_STYLE, 548cdf0e10cSrcweir GetXMLToken( XML_TEXT_LINE_THROUGH_MODE ) ); 549cdf0e10cSrcweir pContext->AddAttribute( aAttrQName, aAttrValue ); 550cdf0e10cSrcweir } 551cdf0e10cSrcweir break; 552cdf0e10cSrcweir case XML_PTACTION_KEEP_WITH_NEXT: 553cdf0e10cSrcweir { 554cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( 555cdf0e10cSrcweir IsXMLToken( sAttrValue, XML_TRUE ) 556cdf0e10cSrcweir ? XML_ALWAYS 557cdf0e10cSrcweir : XML_AUTO) ); 558cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 559cdf0e10cSrcweir } 560cdf0e10cSrcweir break; 561cdf0e10cSrcweir case XML_PTACTION_UNDERLINE: 562cdf0e10cSrcweir { 563cdf0e10cSrcweir XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue ); 564cdf0e10cSrcweir sal_Bool bBold = sal_False, bDouble = sal_False; 565cdf0e10cSrcweir switch( eToken ) 566cdf0e10cSrcweir { 567cdf0e10cSrcweir case XML_SINGLE: 568cdf0e10cSrcweir eToken = XML_SOLID; 569cdf0e10cSrcweir break; 570cdf0e10cSrcweir case XML_DOUBLE: 571cdf0e10cSrcweir eToken = XML_SOLID; 572cdf0e10cSrcweir bDouble = sal_True; 573cdf0e10cSrcweir break; 574cdf0e10cSrcweir case XML_BOLD: 575cdf0e10cSrcweir eToken = XML_SOLID; 576cdf0e10cSrcweir bBold = sal_True; 577cdf0e10cSrcweir break; 578cdf0e10cSrcweir case XML_BOLD_DOTTED: 579cdf0e10cSrcweir eToken = XML_DOTTED; 580cdf0e10cSrcweir bBold = sal_True; 581cdf0e10cSrcweir break; 582cdf0e10cSrcweir case XML_BOLD_DASH: 583cdf0e10cSrcweir eToken = XML_DASH; 584cdf0e10cSrcweir bBold = sal_True; 585cdf0e10cSrcweir break; 586cdf0e10cSrcweir case XML_BOLD_LONG_DASH: 587cdf0e10cSrcweir eToken = XML_LONG_DASH; 588cdf0e10cSrcweir bBold = sal_True; 589cdf0e10cSrcweir break; 590cdf0e10cSrcweir case XML_BOLD_DOT_DASH: 591cdf0e10cSrcweir eToken = XML_DOT_DASH; 592cdf0e10cSrcweir bBold = sal_True; 593cdf0e10cSrcweir break; 594cdf0e10cSrcweir case XML_BOLD_DOT_DOT_DASH: 595cdf0e10cSrcweir eToken = XML_DOT_DOT_DASH; 596cdf0e10cSrcweir bBold = sal_True; 597cdf0e10cSrcweir break; 598cdf0e10cSrcweir case XML_BOLD_WAVE: 599cdf0e10cSrcweir eToken = XML_WAVE; 600cdf0e10cSrcweir bBold = sal_True; 601cdf0e10cSrcweir break; 602cdf0e10cSrcweir case XML_DOUBLE_WAVE: 603cdf0e10cSrcweir eToken = XML_WAVE; 604cdf0e10cSrcweir bDouble = sal_True; 605cdf0e10cSrcweir break; 606cdf0e10cSrcweir case XML_NONE: 607cdf0e10cSrcweir eToken = XML_NONE; 608cdf0e10cSrcweir bDouble = sal_False; 609cdf0e10cSrcweir break; 610cdf0e10cSrcweir default: 611cdf0e10cSrcweir OSL_ENSURE( false, "xmloff::XMLPropertiesOOoTContext_Impl::StartElement(), unknown underline token!" ); 612cdf0e10cSrcweir break; 613cdf0e10cSrcweir } 614cdf0e10cSrcweir pContext->AddAttribute( 615cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 616cdf0e10cSrcweir XML_NAMESPACE_STYLE, 617cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE_STYLE ) ), 618cdf0e10cSrcweir eToken != XML_TOKEN_END ? GetXMLToken( eToken ) 619cdf0e10cSrcweir : sAttrValue ); 620cdf0e10cSrcweir if( bDouble ) 621cdf0e10cSrcweir pContext->AddAttribute( 622cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 623cdf0e10cSrcweir XML_NAMESPACE_STYLE, 624cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE_TYPE ) ), 625cdf0e10cSrcweir GetXMLToken( XML_DOUBLE ) ); 626cdf0e10cSrcweir if( bBold ) 627cdf0e10cSrcweir pContext->AddAttribute( 628cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 629cdf0e10cSrcweir XML_NAMESPACE_STYLE, 630cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE_WIDTH ) ), 631cdf0e10cSrcweir GetXMLToken( XML_BOLD ) ); 632cdf0e10cSrcweir } 633cdf0e10cSrcweir break; 634cdf0e10cSrcweir case XML_PTACTION_LINETHROUGH: 635cdf0e10cSrcweir { 636cdf0e10cSrcweir XMLTokenEnum eToken = GetTransformer().GetToken( sAttrValue ); 637cdf0e10cSrcweir sal_Bool bBold = sal_False, bDouble = sal_False; 638cdf0e10cSrcweir sal_Unicode c = 0; 639cdf0e10cSrcweir switch( eToken ) 640cdf0e10cSrcweir { 641cdf0e10cSrcweir case XML_SINGLE_LINE: 642cdf0e10cSrcweir eToken = XML_SOLID; 643cdf0e10cSrcweir break; 644cdf0e10cSrcweir case XML_DOUBLE_LINE: 645cdf0e10cSrcweir eToken = XML_SOLID; 646cdf0e10cSrcweir bDouble = sal_True; 647cdf0e10cSrcweir break; 648cdf0e10cSrcweir case XML_THICK_LINE: 649cdf0e10cSrcweir eToken = XML_SOLID; 650cdf0e10cSrcweir bBold = sal_True; 651cdf0e10cSrcweir break; 652cdf0e10cSrcweir case XML_SLASH: 653cdf0e10cSrcweir eToken = XML_SOLID; 654cdf0e10cSrcweir c = '/'; 655cdf0e10cSrcweir break; 656cdf0e10cSrcweir case XML_uX: 657cdf0e10cSrcweir eToken = XML_SOLID; 658cdf0e10cSrcweir c = 'X'; 659cdf0e10cSrcweir break; 660cdf0e10cSrcweir default: 661cdf0e10cSrcweir break; 662cdf0e10cSrcweir } 663cdf0e10cSrcweir pContext->AddAttribute( 664cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 665cdf0e10cSrcweir XML_NAMESPACE_STYLE, 666cdf0e10cSrcweir GetXMLToken( XML_TEXT_LINE_THROUGH_STYLE ) ), 667cdf0e10cSrcweir eToken != XML_TOKEN_END ? GetXMLToken( eToken ) 668cdf0e10cSrcweir : sAttrValue ); 669cdf0e10cSrcweir if( bDouble ) 670cdf0e10cSrcweir pContext->AddAttribute( 671cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 672cdf0e10cSrcweir XML_NAMESPACE_STYLE, 673cdf0e10cSrcweir GetXMLToken( XML_TEXT_LINE_THROUGH_TYPE ) ), 674cdf0e10cSrcweir GetXMLToken( XML_DOUBLE ) ); 675cdf0e10cSrcweir if( bBold ) 676cdf0e10cSrcweir pContext->AddAttribute( 677cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 678cdf0e10cSrcweir XML_NAMESPACE_STYLE, 679cdf0e10cSrcweir GetXMLToken( XML_TEXT_LINE_THROUGH_WIDTH ) ), 680cdf0e10cSrcweir GetXMLToken( XML_BOLD ) ); 681cdf0e10cSrcweir if( c ) 682cdf0e10cSrcweir pContext->AddAttribute( 683cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 684cdf0e10cSrcweir XML_NAMESPACE_STYLE, 685cdf0e10cSrcweir GetXMLToken( XML_TEXT_LINE_THROUGH_TEXT ) ), 686cdf0e10cSrcweir OUString::valueOf( c ) ); 687cdf0e10cSrcweir } 688cdf0e10cSrcweir break; 689cdf0e10cSrcweir case XML_PTACTION_SPLINES: 690cdf0e10cSrcweir { 691cdf0e10cSrcweir sal_Int32 nSplineType = sAttrValue.toInt32(); 692cdf0e10cSrcweir OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey( 693cdf0e10cSrcweir XML_NAMESPACE_CHART, GetXMLToken( XML_INTERPOLATION ) ); 694cdf0e10cSrcweir 695cdf0e10cSrcweir switch( nSplineType ) 696cdf0e10cSrcweir { 697cdf0e10cSrcweir // straight lines 698cdf0e10cSrcweir case 0: 699cdf0e10cSrcweir pContext->AddAttribute( 700cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_NONE )); 701cdf0e10cSrcweir break; 702cdf0e10cSrcweir // cubic spline 703cdf0e10cSrcweir case 1: 704cdf0e10cSrcweir pContext->AddAttribute( 705cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_CUBIC_SPLINE )); 706cdf0e10cSrcweir break; 707cdf0e10cSrcweir // B-spline 708cdf0e10cSrcweir case 2: 709cdf0e10cSrcweir pContext->AddAttribute( 710cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_B_SPLINE )); 711cdf0e10cSrcweir break; 712cdf0e10cSrcweir 713cdf0e10cSrcweir default: 714cdf0e10cSrcweir OSL_ENSURE( false, "invalid spline type" ); 715cdf0e10cSrcweir pContext->AddAttribute( 716cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_NONE )); 717cdf0e10cSrcweir break; 718cdf0e10cSrcweir } 719cdf0e10cSrcweir } 720cdf0e10cSrcweir break; 721cdf0e10cSrcweir case XML_PTACTION_INTERVAL_MAJOR: 722cdf0e10cSrcweir pContext->AddAttribute( sAttrName, sAttrValue ); 723cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( fIntervalMajor, sAttrValue ); 724cdf0e10cSrcweir break; 725cdf0e10cSrcweir case XML_PTACTION_INTERVAL_MINOR: 726cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( fIntervalMinor, sAttrValue ); 727cdf0e10cSrcweir pIntervalMinorDivisorContext = pContext; 728cdf0e10cSrcweir break; 729cdf0e10cSrcweir case XML_PTACTION_SYMBOL: 730cdf0e10cSrcweir { 731cdf0e10cSrcweir sal_Int32 nSymbolType = sAttrValue.toInt32(); 732cdf0e10cSrcweir OUString aNewAttrName = GetTransformer().GetNamespaceMap().GetQNameByKey( 733cdf0e10cSrcweir XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_TYPE ) ); 734cdf0e10cSrcweir 735cdf0e10cSrcweir if( nSymbolType >= 0 ) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir pContext->AddAttribute( aNewAttrName, GetXMLToken( XML_NAMED_SYMBOL )); 738cdf0e10cSrcweir enum XMLTokenEnum eToken = XML_TOKEN_INVALID; 739cdf0e10cSrcweir switch( nSymbolType ) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir // SYMBOL0 742cdf0e10cSrcweir case 0: 743cdf0e10cSrcweir // "square" has an awkward token name 744cdf0e10cSrcweir eToken = XML_GRADIENTSTYLE_SQUARE; 745cdf0e10cSrcweir break; 746cdf0e10cSrcweir // SYMBOL1 747cdf0e10cSrcweir case 1: 748cdf0e10cSrcweir eToken = XML_DIAMOND; 749cdf0e10cSrcweir break; 750cdf0e10cSrcweir // SYMBOL2 751cdf0e10cSrcweir case 2: 752cdf0e10cSrcweir eToken = XML_ARROW_DOWN; 753cdf0e10cSrcweir break; 754cdf0e10cSrcweir // SYMBOL3 755cdf0e10cSrcweir case 3: 756cdf0e10cSrcweir eToken = XML_ARROW_UP; 757cdf0e10cSrcweir break; 758cdf0e10cSrcweir // SYMBOL4 759cdf0e10cSrcweir case 4: 760cdf0e10cSrcweir eToken = XML_ARROW_RIGHT; 761cdf0e10cSrcweir break; 762cdf0e10cSrcweir // SYMBOL5 763cdf0e10cSrcweir case 5: 764cdf0e10cSrcweir eToken = XML_ARROW_LEFT; 765cdf0e10cSrcweir break; 766cdf0e10cSrcweir // SYMBOL6 767cdf0e10cSrcweir case 6: 768cdf0e10cSrcweir eToken = XML_BOW_TIE; 769cdf0e10cSrcweir break; 770cdf0e10cSrcweir // SYMBOL7 771cdf0e10cSrcweir case 7: 772cdf0e10cSrcweir eToken = XML_HOURGLASS; 773cdf0e10cSrcweir break; 774cdf0e10cSrcweir default: 775cdf0e10cSrcweir OSL_ENSURE( false, "invalid named symbol" ); 776cdf0e10cSrcweir break; 777cdf0e10cSrcweir } 778cdf0e10cSrcweir 779cdf0e10cSrcweir if( eToken != XML_TOKEN_INVALID ) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir pContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( 782cdf0e10cSrcweir XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_NAME )), 783cdf0e10cSrcweir GetXMLToken( eToken )); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir } 786cdf0e10cSrcweir else 787cdf0e10cSrcweir { 788cdf0e10cSrcweir switch( nSymbolType ) 789cdf0e10cSrcweir { 790cdf0e10cSrcweir // NONE 791cdf0e10cSrcweir case -3: 792cdf0e10cSrcweir pContext->AddAttribute( 793cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_NONE )); 794cdf0e10cSrcweir break; 795cdf0e10cSrcweir // AUTO 796cdf0e10cSrcweir case -2: 797cdf0e10cSrcweir pContext->AddAttribute( 798cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_AUTOMATIC )); 799cdf0e10cSrcweir break; 800cdf0e10cSrcweir // BITMAPURL 801cdf0e10cSrcweir case -1: 802cdf0e10cSrcweir pContext->AddAttribute( 803cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_IMAGE )); 804cdf0e10cSrcweir break; 805cdf0e10cSrcweir default: 806cdf0e10cSrcweir OSL_ENSURE( false, "invalid symbol type" ); 807cdf0e10cSrcweir pContext->AddAttribute( 808cdf0e10cSrcweir aNewAttrName, GetXMLToken( XML_NONE )); 809cdf0e10cSrcweir break; 810cdf0e10cSrcweir } 811cdf0e10cSrcweir } 812cdf0e10cSrcweir } 813cdf0e10cSrcweir break; 814cdf0e10cSrcweir case XML_PTACTION_SYMBOL_IMAGE_NAME: 815cdf0e10cSrcweir { 816cdf0e10cSrcweir // create an xlink:href element for URI attribute 817cdf0e10cSrcweir XMLPersAttrListTContext *pSymbolImageContext = new XMLPersAttrListTContext( 818cdf0e10cSrcweir GetTransformer(), GetTransformer().GetNamespaceMap().GetQNameByKey( 819cdf0e10cSrcweir XML_NAMESPACE_CHART, GetXMLToken( XML_SYMBOL_IMAGE ))); 820cdf0e10cSrcweir 821cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 822cdf0e10cSrcweir if( GetTransformer().ConvertURIToOASIS( aAttrValue, sal_True )) 823cdf0e10cSrcweir { 824cdf0e10cSrcweir pSymbolImageContext->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, aAttrValue ); 825cdf0e10cSrcweir pContext->AddContent( pSymbolImageContext ); 826cdf0e10cSrcweir } 827cdf0e10cSrcweir } 828cdf0e10cSrcweir break; 829cdf0e10cSrcweir 830cdf0e10cSrcweir // #i25616# 831cdf0e10cSrcweir case XML_PTACTION_TRANSPARENCY : 832cdf0e10cSrcweir { 833cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 834cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue); 835cdf0e10cSrcweir pContext->AddAttribute( XML_NAMESPACE_DRAW, 836cdf0e10cSrcweir XML_OPACITY, 837cdf0e10cSrcweir aAttrValue ); 838cdf0e10cSrcweir pContext->AddAttribute( XML_NAMESPACE_DRAW, 839cdf0e10cSrcweir XML_IMAGE_OPACITY, 840cdf0e10cSrcweir aAttrValue ); 841cdf0e10cSrcweir } 842cdf0e10cSrcweir break; 843cdf0e10cSrcweir 844cdf0e10cSrcweir case XML_PTACTION_BREAK_INSIDE: 845cdf0e10cSrcweir { 846cdf0e10cSrcweir pContext->AddAttribute( 847cdf0e10cSrcweir XML_NAMESPACE_FO, XML_KEEP_TOGETHER, 848cdf0e10cSrcweir GetXMLToken( 849cdf0e10cSrcweir IsXMLToken( sAttrValue, XML_COLUMNSPLIT_AVOID ) 850cdf0e10cSrcweir ? XML_ALWAYS 851cdf0e10cSrcweir : XML_AUTO ) ); 852cdf0e10cSrcweir } 853cdf0e10cSrcweir break; 854cdf0e10cSrcweir case XML_ATACTION_CAPTION_ESCAPE_OOO: 855cdf0e10cSrcweir { 856cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 857cdf0e10cSrcweir if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 858cdf0e10cSrcweir { 859cdf0e10cSrcweir sal_Int32 nValue = 0; 860cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, sAttrValue ); 861cdf0e10cSrcweir if( nValue ) 862cdf0e10cSrcweir { 863cdf0e10cSrcweir nValue /= 100; 864cdf0e10cSrcweir rtl::OUStringBuffer aOut; 865cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue ); 866cdf0e10cSrcweir aAttrValue = aOut.makeStringAndClear(); 867cdf0e10cSrcweir } 868cdf0e10cSrcweir } 869cdf0e10cSrcweir else 870cdf0e10cSrcweir { 871cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInchWithIn( aAttrValue ); 872cdf0e10cSrcweir } 873cdf0e10cSrcweir 874cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 875cdf0e10cSrcweir } 876cdf0e10cSrcweir break; 877cdf0e10cSrcweir case XML_ATACTION_MOVE_PROTECT: 878cdf0e10cSrcweir bMoveProtect = IsXMLToken( sAttrValue, XML_TRUE ); 879cdf0e10cSrcweir pProtectContext = pContext; 880cdf0e10cSrcweir break; 881cdf0e10cSrcweir case XML_ATACTION_SIZE_PROTECT: 882cdf0e10cSrcweir bSizeProtect = IsXMLToken( sAttrValue, XML_TRUE ); 883cdf0e10cSrcweir pProtectContext = pContext; 884cdf0e10cSrcweir break; 885cdf0e10cSrcweir case XML_ATACTION_PROTECT: 886cdf0e10cSrcweir aProtectAttrValue = sAttrValue; 887cdf0e10cSrcweir pProtectContext = pContext; 888cdf0e10cSrcweir break; 889cdf0e10cSrcweir case XML_ATACTION_DRAW_MIRROR_OOO: // renames draw:mirror to style:mirror and adapts values 890cdf0e10cSrcweir { 891cdf0e10cSrcweir // --> OD 2005-05-13 #i49139# 892cdf0e10cSrcweir aDrawMirrorAttrValue = 893cdf0e10cSrcweir GetXMLToken( IsXMLToken( sAttrValue, XML_TRUE ) 894cdf0e10cSrcweir ? XML_HORIZONTAL : XML_NONE ); 895cdf0e10cSrcweir bExistDrawMirror = sal_True; 896cdf0e10cSrcweir pMirrorContext = pContext; 897cdf0e10cSrcweir // <-- 898cdf0e10cSrcweir } 899cdf0e10cSrcweir break; 900cdf0e10cSrcweir // --> OD 2005-05-12 #i49139# 901cdf0e10cSrcweir case XML_ATACTION_STYLE_MIRROR_OOO: // adapts style:mirror values 902cdf0e10cSrcweir { 903cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( sAttrValue ); 904cdf0e10cSrcweir OUString aToken; 905cdf0e10cSrcweir while( aTokenEnum.getNextToken( aToken ) ) 906cdf0e10cSrcweir { 907cdf0e10cSrcweir if ( aStyleMirrorAttrValue.getLength() > 0 ) 908cdf0e10cSrcweir { 909cdf0e10cSrcweir aStyleMirrorAttrValue += rtl::OUString::createFromAscii( " " ); 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_LEFT_PAGES ) ) 913cdf0e10cSrcweir { 914cdf0e10cSrcweir aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_EVEN ); 915cdf0e10cSrcweir } 916cdf0e10cSrcweir else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_RIGHT_PAGES ) ) 917cdf0e10cSrcweir { 918cdf0e10cSrcweir aStyleMirrorAttrValue += GetXMLToken( XML_HORIZONTAL_ON_ODD ); 919cdf0e10cSrcweir } 920cdf0e10cSrcweir else 921cdf0e10cSrcweir { 922cdf0e10cSrcweir aStyleMirrorAttrValue += aToken; 923cdf0e10cSrcweir } 924cdf0e10cSrcweir } 925cdf0e10cSrcweir bExistStyleMirror = sal_True; 926cdf0e10cSrcweir pMirrorContext = pContext; 927cdf0e10cSrcweir } 928cdf0e10cSrcweir break; 929cdf0e10cSrcweir // <-- 930cdf0e10cSrcweir case XML_ATACTION_GAMMA_OOO: // converts double value to percentage 931cdf0e10cSrcweir { 932cdf0e10cSrcweir double fValue = sAttrValue.toDouble(); 933cdf0e10cSrcweir sal_Int32 nValue = (sal_Int32)((fValue * 100.0) + ( fValue > 0 ? 0.5 : - 0.5 ) ); 934cdf0e10cSrcweir 935cdf0e10cSrcweir rtl::OUStringBuffer aOut; 936cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue ); 937cdf0e10cSrcweir OUString aAttrValue( aOut.makeStringAndClear() ); 938cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aAttrValue ); 939cdf0e10cSrcweir } 940cdf0e10cSrcweir break; 941cdf0e10cSrcweir case XML_ATACTION_OPACITY_FIX: 942cdf0e10cSrcweir { 943cdf0e10cSrcweir sal_Int32 nValue; 944cdf0e10cSrcweir if( sAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 945cdf0e10cSrcweir { 946cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, sAttrValue ); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir else 949cdf0e10cSrcweir { 950cdf0e10cSrcweir nValue = sal_Int32( sAttrValue.toDouble() * 100.0 ); 951cdf0e10cSrcweir } 952cdf0e10cSrcweir nValue = 100 - nValue; 953cdf0e10cSrcweir 954cdf0e10cSrcweir rtl::OUStringBuffer aOut; 955cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue ); 956cdf0e10cSrcweir pContext->AddAttribute( sAttrName, aOut.makeStringAndClear() ); 957cdf0e10cSrcweir } 958cdf0e10cSrcweir break; 959cdf0e10cSrcweir default: 960cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" ); 961cdf0e10cSrcweir break; 962cdf0e10cSrcweir } 963cdf0e10cSrcweir } 964cdf0e10cSrcweir 965cdf0e10cSrcweir // --> OD 2005-05-13 #i49139# 966cdf0e10cSrcweir if ( bExistStyleMirror ) 967cdf0e10cSrcweir { 968cdf0e10cSrcweir pMirrorContext->AddAttribute( 969cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 970cdf0e10cSrcweir XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ), 971cdf0e10cSrcweir aStyleMirrorAttrValue); 972cdf0e10cSrcweir } 973cdf0e10cSrcweir else if ( bExistDrawMirror ) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir pMirrorContext->AddAttribute( 976cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 977cdf0e10cSrcweir XML_NAMESPACE_STYLE, GetXMLToken( XML_MIRROR ) ), 978cdf0e10cSrcweir aDrawMirrorAttrValue); 979cdf0e10cSrcweir } 980cdf0e10cSrcweir // <-- 981cdf0e10cSrcweir 982cdf0e10cSrcweir if( bMoveProtect || bSizeProtect || aProtectAttrValue.getLength() ) 983cdf0e10cSrcweir { 984cdf0e10cSrcweir if( (bMoveProtect ||bSizeProtect) && IsXMLToken( aProtectAttrValue, XML_NONE ) ) 985cdf0e10cSrcweir aProtectAttrValue = OUString(); 986cdf0e10cSrcweir 987cdf0e10cSrcweir const OUString& rPosition = GetXMLToken( XML_POSITION ); 988cdf0e10cSrcweir if( bMoveProtect && -1 == aProtectAttrValue.indexOf( rPosition ) ) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir if( aProtectAttrValue.getLength() ) 991cdf0e10cSrcweir aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) ); 992cdf0e10cSrcweir aProtectAttrValue += rPosition; 993cdf0e10cSrcweir } 994cdf0e10cSrcweir 995cdf0e10cSrcweir const OUString& rSize = GetXMLToken( XML_SIZE ); 996cdf0e10cSrcweir if( bSizeProtect && -1 == aProtectAttrValue.indexOf( rSize ) ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir if( aProtectAttrValue.getLength() ) 999cdf0e10cSrcweir aProtectAttrValue += OUString::valueOf( sal_Unicode( ' ' ) ); 1000cdf0e10cSrcweir aProtectAttrValue += rSize; 1001cdf0e10cSrcweir } 1002cdf0e10cSrcweir 1003cdf0e10cSrcweir pProtectContext->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_STYLE, GetXMLToken( XML_PROTECT ) ), aProtectAttrValue ); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir if( pIntervalMinorDivisorContext ) 1007cdf0e10cSrcweir { 1008cdf0e10cSrcweir if( fIntervalMinor != 0.0 ) 1009cdf0e10cSrcweir { 1010cdf0e10cSrcweir sal_Int32 nIntervalMinorDivisor = static_cast< sal_Int32 >( 1011cdf0e10cSrcweir ::rtl::math::round( fIntervalMajor / fIntervalMinor )); 1012cdf0e10cSrcweir 1013cdf0e10cSrcweir ::rtl::OUStringBuffer aBuf; 1014cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( aBuf, nIntervalMinorDivisor ); 1015cdf0e10cSrcweir pIntervalMinorDivisorContext->AddAttribute( 1016cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 1017cdf0e10cSrcweir XML_NAMESPACE_CHART, 1018cdf0e10cSrcweir GetXMLToken( XML_INTERVAL_MINOR_DIVISOR )), 1019cdf0e10cSrcweir aBuf.makeStringAndClear()); 1020cdf0e10cSrcweir } 1021cdf0e10cSrcweir } 1022cdf0e10cSrcweir } 1023cdf0e10cSrcweir 1024cdf0e10cSrcweir void XMLPropertiesOOoTContext_Impl::EndElement() 1025cdf0e10cSrcweir { 1026cdf0e10cSrcweir if( !m_bPersistent ) 1027cdf0e10cSrcweir Export(); 1028cdf0e10cSrcweir } 1029cdf0e10cSrcweir 1030cdf0e10cSrcweir void XMLPropertiesOOoTContext_Impl::Characters( const OUString& ) 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir // ignore them 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir 1035cdf0e10cSrcweir void XMLPropertiesOOoTContext_Impl::Export() 1036cdf0e10cSrcweir { 1037cdf0e10cSrcweir 1038cdf0e10cSrcweir for( sal_uInt16 i=0; i < MAX_PROP_TYPES; i++ ) 1039cdf0e10cSrcweir { 1040cdf0e10cSrcweir if( m_aPropContexts[i].is() ) 1041cdf0e10cSrcweir m_aPropContexts[i]->Export(); 1042cdf0e10cSrcweir } 1043cdf0e10cSrcweir } 1044cdf0e10cSrcweir 1045cdf0e10cSrcweir sal_Bool XMLPropertiesOOoTContext_Impl::IsPersistent() const 1046cdf0e10cSrcweir { 1047cdf0e10cSrcweir return m_bPersistent; 1048cdf0e10cSrcweir } 1049cdf0e10cSrcweir 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir //------------------------------------------------------------------------------ 1052cdf0e10cSrcweir 1053cdf0e10cSrcweir TYPEINIT1( XMLStyleOOoTContext, XMLPersElemContentTContext ); 1054cdf0e10cSrcweir 1055cdf0e10cSrcweir XMLStyleOOoTContext::XMLStyleOOoTContext( XMLTransformerBase& rImp, 1056cdf0e10cSrcweir const OUString& rQName, 1057cdf0e10cSrcweir XMLFamilyType eT, 1058cdf0e10cSrcweir sal_Bool bPersistent ) : 1059cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName ), 1060cdf0e10cSrcweir m_eFamily( eT ), 1061cdf0e10cSrcweir m_bPersistent( bPersistent ) 1062cdf0e10cSrcweir { 1063cdf0e10cSrcweir } 1064cdf0e10cSrcweir 1065cdf0e10cSrcweir XMLStyleOOoTContext::XMLStyleOOoTContext( 1066cdf0e10cSrcweir XMLTransformerBase& rImp, 1067cdf0e10cSrcweir const OUString& rQName, 1068cdf0e10cSrcweir XMLFamilyType eT, 1069cdf0e10cSrcweir sal_uInt16 nPrefix, 1070cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum eToken, 1071cdf0e10cSrcweir sal_Bool bPersistent ) : 1072cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ), 1073cdf0e10cSrcweir m_eFamily( eT ), 1074cdf0e10cSrcweir m_bPersistent( bPersistent ) 1075cdf0e10cSrcweir { 1076cdf0e10cSrcweir } 1077cdf0e10cSrcweir 1078cdf0e10cSrcweir XMLStyleOOoTContext::~XMLStyleOOoTContext() 1079cdf0e10cSrcweir { 1080cdf0e10cSrcweir } 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir XMLTransformerContext *XMLStyleOOoTContext::CreateChildContext( 1083cdf0e10cSrcweir sal_uInt16 nPrefix, 1084cdf0e10cSrcweir const OUString& rLocalName, 1085cdf0e10cSrcweir const OUString& rQName, 1086cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 1087cdf0e10cSrcweir { 1088cdf0e10cSrcweir XMLTransformerContext *pContext = 0; 1089cdf0e10cSrcweir 1090cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefix && 1091cdf0e10cSrcweir IsXMLToken( rLocalName, XML_PROPERTIES ) ) 1092cdf0e10cSrcweir { 1093cdf0e10cSrcweir if( aPropTypes[m_eFamily][0] == XML_PROP_TYPE_END ) 1094cdf0e10cSrcweir { 1095cdf0e10cSrcweir OSL_ENSURE( !this, "unexpected properties element" ); 1096cdf0e10cSrcweir pContext = m_bPersistent 1097cdf0e10cSrcweir ? XMLPersElemContentTContext::CreateChildContext( 1098cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ) 1099cdf0e10cSrcweir : XMLTransformerContext::CreateChildContext( 1100cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ); 1101cdf0e10cSrcweir } 1102cdf0e10cSrcweir else if( aPropTypes[m_eFamily][1] == XML_PROP_TYPE_END ) 1103cdf0e10cSrcweir { 1104cdf0e10cSrcweir sal_uInt16 nActionMap = 1105cdf0e10cSrcweir aAttrActionMaps[aPropTypes[m_eFamily][0]]; 1106cdf0e10cSrcweir if( nActionMap < MAX_OOO_PROP_ACTIONS ) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir pContext = new XMLPropertiesOOoTContext_Impl( 1109cdf0e10cSrcweir GetTransformer(), rQName, 1110cdf0e10cSrcweir aPropTypes[m_eFamily], m_bPersistent ); 1111cdf0e10cSrcweir } 1112cdf0e10cSrcweir else 1113cdf0e10cSrcweir { 1114cdf0e10cSrcweir if( m_bPersistent ) 1115cdf0e10cSrcweir pContext = new XMLPersElemContentTContext( 1116cdf0e10cSrcweir GetTransformer(), rQName, 1117cdf0e10cSrcweir XML_NAMESPACE_STYLE, 1118cdf0e10cSrcweir aPropTokens[aPropTypes[m_eFamily][0]] ); 1119cdf0e10cSrcweir else 1120cdf0e10cSrcweir pContext = new XMLRenameElemTransformerContext( 1121cdf0e10cSrcweir GetTransformer(), rQName, 1122cdf0e10cSrcweir XML_NAMESPACE_STYLE, 1123cdf0e10cSrcweir aPropTokens[aPropTypes[m_eFamily][0]] ); 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir } 1126cdf0e10cSrcweir else 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir pContext = new XMLPropertiesOOoTContext_Impl( 1129cdf0e10cSrcweir GetTransformer(), rQName, 1130cdf0e10cSrcweir aPropTypes[m_eFamily], m_bPersistent); 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir if( m_bPersistent ) 1134cdf0e10cSrcweir AddContent( pContext ); 1135cdf0e10cSrcweir } 1136cdf0e10cSrcweir else 1137cdf0e10cSrcweir { 1138cdf0e10cSrcweir pContext = m_bPersistent 1139cdf0e10cSrcweir ? XMLPersElemContentTContext::CreateChildContext( 1140cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ) 1141cdf0e10cSrcweir : XMLTransformerContext::CreateChildContext( 1142cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ); 1143cdf0e10cSrcweir } 1144cdf0e10cSrcweir 1145cdf0e10cSrcweir return pContext; 1146cdf0e10cSrcweir } 1147cdf0e10cSrcweir 1148cdf0e10cSrcweir void XMLStyleOOoTContext::StartElement( 1149cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 1150cdf0e10cSrcweir { 1151cdf0e10cSrcweir XMLTransformerActions *pActions = 1152cdf0e10cSrcweir GetTransformer().GetUserDefinedActions( OOO_STYLE_ACTIONS ); 1153cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" ); 1154cdf0e10cSrcweir 1155cdf0e10cSrcweir Reference< XAttributeList > xAttrList( rAttrList ); 1156cdf0e10cSrcweir XMLMutableAttributeList *pMutableAttrList = 0; 1157cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 1158cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 1159cdf0e10cSrcweir { 1160cdf0e10cSrcweir const OUString sAttrName = xAttrList->getNameByIndex( i ); 1161cdf0e10cSrcweir OUString aLocalName; 1162cdf0e10cSrcweir sal_uInt16 nPrefix = 1163cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( sAttrName, 1164cdf0e10cSrcweir &aLocalName ); 1165cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); 1166cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter = 1167cdf0e10cSrcweir pActions->find( aKey ); 1168cdf0e10cSrcweir if( !(aIter == pActions->end() ) ) 1169cdf0e10cSrcweir { 1170cdf0e10cSrcweir if( !pMutableAttrList ) 1171cdf0e10cSrcweir { 1172cdf0e10cSrcweir pMutableAttrList = 1173cdf0e10cSrcweir new XMLMutableAttributeList( xAttrList ); 1174cdf0e10cSrcweir xAttrList = pMutableAttrList; 1175cdf0e10cSrcweir } 1176cdf0e10cSrcweir const OUString sAttrValue = xAttrList->getValueByIndex( i ); 1177cdf0e10cSrcweir switch( (*aIter).second.m_nActionType ) 1178cdf0e10cSrcweir { 1179cdf0e10cSrcweir case XML_ATACTION_STYLE_FAMILY: 1180cdf0e10cSrcweir { 1181cdf0e10cSrcweir sal_Bool bControl = sal_False; 1182cdf0e10cSrcweir if( XML_FAMILY_TYPE_END == m_eFamily ) 1183cdf0e10cSrcweir { 1184cdf0e10cSrcweir if( IsXMLToken( sAttrValue, XML_GRAPHICS ) ) 1185cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_GRAPHIC; 1186cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_PRESENTATION ) ) 1187cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_PRESENTATION; 1188cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_DRAWING_PAGE ) ) 1189cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_DRAWING_PAGE; 1190cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_TEXT) ) 1191cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TEXT; 1192cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_PARAGRAPH) ) 1193cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_PARAGRAPH; 1194cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_RUBY) ) 1195cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_RUBY; 1196cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_SECTION) ) 1197cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_SECTION; 1198cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_TABLE) ) 1199cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TABLE; 1200cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_TABLE_COLUMN) ) 1201cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TABLE_COLUMN; 1202cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_TABLE_ROW) ) 1203cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TABLE_ROW; 1204cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_TABLE_CELL) ) 1205cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TABLE_CELL; 1206cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_CHART) ) 1207cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_CHART; 1208cdf0e10cSrcweir else if( IsXMLToken( sAttrValue, XML_CONTROL) ) 1209cdf0e10cSrcweir { 1210cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_PARAGRAPH; 1211cdf0e10cSrcweir bControl = sal_True; 1212cdf0e10cSrcweir } 1213cdf0e10cSrcweir } 1214cdf0e10cSrcweir if( XML_FAMILY_TYPE_GRAPHIC == m_eFamily ) 1215cdf0e10cSrcweir { 1216cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, 1217cdf0e10cSrcweir GetXMLToken( XML_GRAPHIC ) ); 1218cdf0e10cSrcweir } 1219cdf0e10cSrcweir else if( bControl ) 1220cdf0e10cSrcweir { 1221cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, 1222cdf0e10cSrcweir GetXMLToken( XML_PARAGRAPH ) ); 1223cdf0e10cSrcweir } 1224cdf0e10cSrcweir } 1225cdf0e10cSrcweir break; 1226cdf0e10cSrcweir case XML_ATACTION_INCH2IN: 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 1229cdf0e10cSrcweir if( XMLTransformerBase::ReplaceSingleInchWithIn( 1230cdf0e10cSrcweir aAttrValue ) ) 1231cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1232cdf0e10cSrcweir } 1233cdf0e10cSrcweir break; 1234cdf0e10cSrcweir case XML_ATACTION_ENCODE_STYLE_NAME: 1235cdf0e10cSrcweir { 1236cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 1237cdf0e10cSrcweir if( GetTransformer().EncodeStyleName(aAttrValue) ) 1238cdf0e10cSrcweir { 1239cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1240cdf0e10cSrcweir OUString aNewAttrQName( 1241cdf0e10cSrcweir GetTransformer().GetNamespaceMap(). 1242cdf0e10cSrcweir GetQNameByKey( 1243cdf0e10cSrcweir nPrefix, ::xmloff::token::GetXMLToken( 1244cdf0e10cSrcweir XML_DISPLAY_NAME ) ) ); 1245cdf0e10cSrcweir pMutableAttrList->AddAttribute( aNewAttrQName, 1246cdf0e10cSrcweir sAttrValue ); 1247cdf0e10cSrcweir } 1248cdf0e10cSrcweir } 1249cdf0e10cSrcweir break; 1250cdf0e10cSrcweir case XML_ATACTION_ENCODE_STYLE_NAME_REF: 1251cdf0e10cSrcweir { 1252cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 1253cdf0e10cSrcweir if( GetTransformer().EncodeStyleName(aAttrValue) ) 1254cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1255cdf0e10cSrcweir } 1256cdf0e10cSrcweir break; 1257cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT: 1258cdf0e10cSrcweir { 1259cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 1260cdf0e10cSrcweir if( GetTransformer().NegPercent(aAttrValue) ) 1261cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir break; 1264cdf0e10cSrcweir case XML_ATACTION_URI_OOO: 1265cdf0e10cSrcweir { 1266cdf0e10cSrcweir OUString aAttrValue( sAttrValue ); 1267cdf0e10cSrcweir if( GetTransformer().ConvertURIToOASIS( aAttrValue, 1268cdf0e10cSrcweir static_cast< sal_Bool >((*aIter).second.m_nParam1))) 1269cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 1270cdf0e10cSrcweir } 1271cdf0e10cSrcweir break; 1272cdf0e10cSrcweir default: 1273cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" ); 1274cdf0e10cSrcweir break; 1275cdf0e10cSrcweir } 1276cdf0e10cSrcweir } 1277cdf0e10cSrcweir } 1278cdf0e10cSrcweir if( XML_FAMILY_TYPE_END == m_eFamily ) 1279cdf0e10cSrcweir m_eFamily = XML_FAMILY_TYPE_TEXT; 1280cdf0e10cSrcweir if( m_bPersistent ) 1281cdf0e10cSrcweir XMLPersElemContentTContext::StartElement( xAttrList ); 1282cdf0e10cSrcweir else 1283cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetExportQName(), 1284cdf0e10cSrcweir xAttrList ); 1285cdf0e10cSrcweir } 1286cdf0e10cSrcweir 1287cdf0e10cSrcweir void XMLStyleOOoTContext::EndElement() 1288cdf0e10cSrcweir { 1289cdf0e10cSrcweir if( m_bPersistent ) 1290cdf0e10cSrcweir XMLPersElemContentTContext::EndElement(); 1291cdf0e10cSrcweir else 1292cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetExportQName() ); 1293cdf0e10cSrcweir } 1294cdf0e10cSrcweir 1295cdf0e10cSrcweir void XMLStyleOOoTContext::Characters( const OUString& ) 1296cdf0e10cSrcweir { 1297cdf0e10cSrcweir // element content only: 1298cdf0e10cSrcweir } 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir sal_Bool XMLStyleOOoTContext::IsPersistent() const 1301cdf0e10cSrcweir { 1302cdf0e10cSrcweir return m_bPersistent; 1303cdf0e10cSrcweir } 1304cdf0e10cSrcweir 1305cdf0e10cSrcweir XMLTransformerActions *XMLStyleOOoTContext::CreateTransformerActions( 1306cdf0e10cSrcweir sal_uInt16 nType ) 1307cdf0e10cSrcweir { 1308cdf0e10cSrcweir XMLTransformerActionInit *pInit = 0; 1309cdf0e10cSrcweir 1310cdf0e10cSrcweir switch( nType ) 1311cdf0e10cSrcweir { 1312cdf0e10cSrcweir case PROP_OOO_GRAPHIC_ATTR_ACTIONS: 1313cdf0e10cSrcweir pInit = aGraphicPropertyOOoAttrActionTable; 1314cdf0e10cSrcweir break; 1315cdf0e10cSrcweir case PROP_OOO_GRAPHIC_ELEM_ACTIONS: 1316cdf0e10cSrcweir pInit = aGraphicPropertyOOoElemActionTable; 1317cdf0e10cSrcweir break; 1318cdf0e10cSrcweir case PROP_OOO_DRAWING_PAGE_ATTR_ACTIONS: 1319cdf0e10cSrcweir pInit = aDrawingPagePropertyOOoAttrActionTable; 1320cdf0e10cSrcweir break; 1321cdf0e10cSrcweir case PROP_OOO_PAGE_LAYOUT_ATTR_ACTIONS: 1322cdf0e10cSrcweir pInit = aPageLayoutPropertyOOoAttrActionTable; 1323cdf0e10cSrcweir break; 1324cdf0e10cSrcweir case PROP_OOO_HEADER_FOOTER_ATTR_ACTIONS: 1325cdf0e10cSrcweir pInit = aHeaderFooterPropertyOOoAttrActionTable; 1326cdf0e10cSrcweir break; 1327cdf0e10cSrcweir case PROP_OOO_TEXT_ATTR_ACTIONS: 1328cdf0e10cSrcweir pInit = aTextPropertyOOoAttrActionTable; 1329cdf0e10cSrcweir break; 1330cdf0e10cSrcweir case PROP_OOO_TEXT_ELEM_ACTIONS: 1331cdf0e10cSrcweir pInit = aTextPropertyOOoElemActionTable; 1332cdf0e10cSrcweir break; 1333cdf0e10cSrcweir case PROP_OOO_PARAGRAPH_ATTR_ACTIONS: 1334cdf0e10cSrcweir pInit = aParagraphPropertyOOoAttrActionTable; 1335cdf0e10cSrcweir break; 1336cdf0e10cSrcweir case PROP_OOO_PARAGRAPH_ELEM_ACTIONS: 1337cdf0e10cSrcweir pInit = aParagraphPropertyOOoElemActionTable; 1338cdf0e10cSrcweir break; 1339cdf0e10cSrcweir case PROP_OOO_SECTION_ATTR_ACTIONS: 1340cdf0e10cSrcweir pInit = aSectionPropertyOOoAttrActionTable; 1341cdf0e10cSrcweir break; 1342cdf0e10cSrcweir case PROP_OOO_TABLE_ATTR_ACTIONS: 1343cdf0e10cSrcweir pInit = aTablePropertyOOoAttrActionTable; 1344cdf0e10cSrcweir break; 1345cdf0e10cSrcweir case PROP_OOO_TABLE_COLUMN_ATTR_ACTIONS: 1346cdf0e10cSrcweir pInit = aTableColumnPropertyOOoAttrActionTable; 1347cdf0e10cSrcweir break; 1348cdf0e10cSrcweir case PROP_OOO_TABLE_ROW_ATTR_ACTIONS: 1349cdf0e10cSrcweir pInit = aTableRowPropertyOOoAttrActionTable; 1350cdf0e10cSrcweir break; 1351cdf0e10cSrcweir case PROP_OOO_TABLE_CELL_ATTR_ACTIONS: 1352cdf0e10cSrcweir pInit = aTableCellPropertyOOoAttrActionTable; 1353cdf0e10cSrcweir break; 1354cdf0e10cSrcweir case PROP_OOO_TABLE_CELL_ELEM_ACTIONS: 1355cdf0e10cSrcweir pInit = aTableCellPropertyOOoElemActionTable; 1356cdf0e10cSrcweir break; 1357cdf0e10cSrcweir case PROP_OOO_LIST_LEVEL_ATTR_ACTIONS: 1358cdf0e10cSrcweir pInit = aListLevelPropertyOOoAttrActionTable; 1359cdf0e10cSrcweir break; 1360cdf0e10cSrcweir case PROP_OOO_CHART_ATTR_ACTIONS: 1361cdf0e10cSrcweir pInit = aChartPropertyOOoAttrActionTable; 1362cdf0e10cSrcweir break; 1363cdf0e10cSrcweir case PROP_OOO_CHART_ELEM_ACTIONS: 1364cdf0e10cSrcweir pInit = aChartPropertyOOoElemActionTable; 1365cdf0e10cSrcweir break; 1366cdf0e10cSrcweir } 1367cdf0e10cSrcweir 1368cdf0e10cSrcweir XMLTransformerActions *pActions = 0; 1369cdf0e10cSrcweir if( pInit ) 1370cdf0e10cSrcweir pActions = new XMLTransformerActions( pInit ); 1371cdf0e10cSrcweir 1372cdf0e10cSrcweir return pActions; 1373cdf0e10cSrcweir } 1374