1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp> 31*cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp> 32*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 33*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp> 34*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 35*cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 36*cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 37*cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 38*cdf0e10cSrcweir #include "PropType.hxx" 39*cdf0e10cSrcweir #include "DeepTContext.hxx" 40*cdf0e10cSrcweir #include "ProcAttrTContext.hxx" 41*cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFOERMERBASE_HXX 42*cdf0e10cSrcweir #include "TransformerBase.hxx" 43*cdf0e10cSrcweir #endif 44*cdf0e10cSrcweir #include "TransformerActions.hxx" 45*cdf0e10cSrcweir #include "ActionMapTypesOASIS.hxx" 46*cdf0e10cSrcweir #include "MutableAttrList.hxx" 47*cdf0e10cSrcweir #include "PropertyActionsOASIS.hxx" 48*cdf0e10cSrcweir #include "StyleOASISTContext.hxx" 49*cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 50*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using ::rtl::OUString; 53*cdf0e10cSrcweir using namespace ::xmloff::token; 54*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax; 56*cdf0e10cSrcweir //------------------------------------------------------------------------------ 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] = 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir PROP_OASIS_GRAPHIC_ATTR_ACTIONS, 61*cdf0e10cSrcweir PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE 62*cdf0e10cSrcweir PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS, 63*cdf0e10cSrcweir PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS, 64*cdf0e10cSrcweir PROP_OASIS_TEXT_ATTR_ACTIONS, 65*cdf0e10cSrcweir PROP_OASIS_PARAGRAPH_ATTR_ACTIONS, 66*cdf0e10cSrcweir MAX_OASIS_PROP_ACTIONS, // RUBY 67*cdf0e10cSrcweir PROP_OASIS_SECTION_ATTR_ACTIONS, 68*cdf0e10cSrcweir PROP_OASIS_TABLE_ATTR_ACTIONS, 69*cdf0e10cSrcweir PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS, 70*cdf0e10cSrcweir PROP_OASIS_TABLE_ROW_ATTR_ACTIONS, 71*cdf0e10cSrcweir PROP_OASIS_TABLE_CELL_ATTR_ACTIONS, 72*cdf0e10cSrcweir PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS, 73*cdf0e10cSrcweir PROP_OASIS_CHART_ATTR_ACTIONS 74*cdf0e10cSrcweir }; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir //------------------------------------------------------------------------------ 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir class XMLPropertiesTContext_Impl : public XMLPersElemContentTContext 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir ::com::sun::star::uno::Reference< 81*cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > m_xAttrList; 82*cdf0e10cSrcweir 83*cdf0e10cSrcweir XMLPropType m_ePropType; 84*cdf0e10cSrcweir sal_Bool m_bControlStyle; 85*cdf0e10cSrcweir ::rtl::OUString m_aStyleFamily; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir public: 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void SetQNameAndPropType( const ::rtl::OUString& rQName, 90*cdf0e10cSrcweir XMLPropType ePropType ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir m_ePropType = ePropType; 93*cdf0e10cSrcweir XMLTransformerContext::SetQName( rQName ); 94*cdf0e10cSrcweir }; 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir TYPEINFO(); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir XMLPropertiesTContext_Impl( XMLTransformerBase& rTransformer, 99*cdf0e10cSrcweir const ::rtl::OUString& rQName, 100*cdf0e10cSrcweir XMLPropType eP, 101*cdf0e10cSrcweir const ::rtl::OUString& rStyleFamily, 102*cdf0e10cSrcweir sal_Bool _bControlStyle = sal_False ); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir virtual ~XMLPropertiesTContext_Impl(); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ); 107*cdf0e10cSrcweir 108*cdf0e10cSrcweir virtual void Export(); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir static XMLPropType GetPropType( const OUString& rLocalName ); 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir static OUString MergeUnderline( XMLTokenEnum eUnderline, 113*cdf0e10cSrcweir sal_Bool bBold, sal_Bool bDouble ); 114*cdf0e10cSrcweir static OUString MergeLineThrough( XMLTokenEnum eLineThrough, 115*cdf0e10cSrcweir sal_Bool bBold, sal_Bool bDouble, 116*cdf0e10cSrcweir sal_Unicode c ); 117*cdf0e10cSrcweir }; 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir TYPEINIT1( XMLPropertiesTContext_Impl, XMLPersElemContentTContext ); 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir XMLPropertiesTContext_Impl::XMLPropertiesTContext_Impl( 122*cdf0e10cSrcweir XMLTransformerBase& rImp, const OUString& rQName, XMLPropType eP, 123*cdf0e10cSrcweir const ::rtl::OUString& rStyleFamily, sal_Bool _bControlStyle ) : 124*cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName, XML_NAMESPACE_STYLE, 125*cdf0e10cSrcweir XML_PROPERTIES), 126*cdf0e10cSrcweir m_ePropType( eP ), 127*cdf0e10cSrcweir m_bControlStyle( _bControlStyle ), 128*cdf0e10cSrcweir m_aStyleFamily( rStyleFamily ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir XMLPropertiesTContext_Impl::~XMLPropertiesTContext_Impl() 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void XMLPropertiesTContext_Impl::StartElement( 137*cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir XMLTransformerActions *pActions = 0; 140*cdf0e10cSrcweir sal_uInt16 nActionMap = aAttrActionMaps[m_ePropType]; 141*cdf0e10cSrcweir if( nActionMap < MAX_OASIS_PROP_ACTIONS ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir pActions = GetTransformer().GetUserDefinedActions( nActionMap ); 144*cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" ); 145*cdf0e10cSrcweir } 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir if( pActions ) 148*cdf0e10cSrcweir { 149*cdf0e10cSrcweir XMLMutableAttributeList *pAttrList = 0; 150*cdf0e10cSrcweir if( !m_xAttrList.is() ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir pAttrList = new XMLMutableAttributeList(); 153*cdf0e10cSrcweir m_xAttrList = pAttrList; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir else 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir pAttrList = 158*cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ); 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir XMLTokenEnum eUnderline = XML_TOKEN_END; 162*cdf0e10cSrcweir sal_Bool bBoldUnderline = sal_False, bDoubleUnderline = sal_False; 163*cdf0e10cSrcweir XMLTokenEnum eLineThrough = XML_TOKEN_END; 164*cdf0e10cSrcweir sal_Bool bBoldLineThrough = sal_False, bDoubleLineThrough = sal_False; 165*cdf0e10cSrcweir sal_Unicode cLineThroughChar = 0; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir bool bIntervalMinorFound = false; 168*cdf0e10cSrcweir double fIntervalMajor = 0.0; 169*cdf0e10cSrcweir sal_Int32 nIntervalMinorDivisor = 0; 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir // #i25616# 172*cdf0e10cSrcweir OUString aOpacityValueRemember; 173*cdf0e10cSrcweir OUString aImageOpacityValueRemember; 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0; 176*cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 177*cdf0e10cSrcweir { 178*cdf0e10cSrcweir const OUString& rAttrName = rAttrList->getNameByIndex( i ); 179*cdf0e10cSrcweir const OUString& rAttrValue = rAttrList->getValueByIndex( i ); 180*cdf0e10cSrcweir OUString aLocalName; 181*cdf0e10cSrcweir sal_uInt16 nPrefix = 182*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName, 183*cdf0e10cSrcweir &aLocalName ); 184*cdf0e10cSrcweir 185*cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); 186*cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter = 187*cdf0e10cSrcweir pActions->find( aKey ); 188*cdf0e10cSrcweir if( !(aIter == pActions->end() ) ) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir switch( (*aIter).second.m_nActionType ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir case XML_ATACTION_REMOVE: 193*cdf0e10cSrcweir break; 194*cdf0e10cSrcweir case XML_ATACTION_COPY: 195*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue ); 196*cdf0e10cSrcweir break; 197*cdf0e10cSrcweir case XML_ATACTION_RENAME: 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir OUString aNewAttrQName( 200*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 201*cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 202*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 203*cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) ); 204*cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue ); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir break; 207*cdf0e10cSrcweir case XML_ATACTION_IN2INCH: 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 210*cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInWithInch( 211*cdf0e10cSrcweir aAttrValue ); 212*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir break; 215*cdf0e10cSrcweir case XML_ATACTION_INS2INCHS: 216*cdf0e10cSrcweir { 217*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 218*cdf0e10cSrcweir XMLTransformerBase::ReplaceInWithInch( 219*cdf0e10cSrcweir aAttrValue ); 220*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir break; 223*cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME_REF: 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 226*cdf0e10cSrcweir GetTransformer().DecodeStyleName(aAttrValue); 227*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir break; 230*cdf0e10cSrcweir case XML_ATACTION_RENAME_DECODE_STYLE_NAME_REF: 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir OUString aNewAttrQName( 233*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 234*cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 235*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 236*cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) ); 237*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 238*cdf0e10cSrcweir GetTransformer().DecodeStyleName(aAttrValue); 239*cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, aAttrValue ); 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir break; 242*cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT: 243*cdf0e10cSrcweir { 244*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 245*cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue); 246*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 247*cdf0e10cSrcweir } 248*cdf0e10cSrcweir break; 249*cdf0e10cSrcweir case XML_ATACTION_RENAME_NEG_PERCENT: 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir OUString aNewAttrQName( 252*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 253*cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(), 254*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 255*cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) ); 256*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 257*cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue); 258*cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, aAttrValue ); 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir break; 261*cdf0e10cSrcweir case XML_OPTACTION_LINE_MODE: 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir sal_Bool bWordMode = 264*cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_SKIP_WHITE_SPACE ); 265*cdf0e10cSrcweir OUString aAttrQName( 266*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 267*cdf0e10cSrcweir XML_NAMESPACE_FO, 268*cdf0e10cSrcweir GetXMLToken( XML_SCORE_SPACES ) ) ); 269*cdf0e10cSrcweir sal_Int16 nIndex = 270*cdf0e10cSrcweir pAttrList->GetIndexByName( aAttrQName ); 271*cdf0e10cSrcweir if( -1 != nIndex ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir if( bWordMode ) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir const OUString& rOldValue = 276*cdf0e10cSrcweir pAttrList->getValueByIndex( nIndex ); 277*cdf0e10cSrcweir if( !IsXMLToken( rOldValue, XML_TRUE ) ) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir pAttrList->SetValueByIndex( nIndex, 280*cdf0e10cSrcweir GetXMLToken( XML_TRUE ) ); 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir else 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( bWordMode 287*cdf0e10cSrcweir ? XML_FALSE 288*cdf0e10cSrcweir : XML_TRUE ) ); 289*cdf0e10cSrcweir pAttrList->AddAttribute( aAttrQName, aAttrValue ); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir break; 293*cdf0e10cSrcweir case XML_OPTACTION_KEEP_WITH_NEXT: 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( 296*cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_ALWAYS ) 297*cdf0e10cSrcweir ? XML_TRUE 298*cdf0e10cSrcweir : XML_FALSE) ); 299*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir break; 302*cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_WIDTH: 303*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_BOLD ) ) 304*cdf0e10cSrcweir bBoldUnderline = sal_True; 305*cdf0e10cSrcweir break; 306*cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_TYPE: 307*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_DOUBLE ) ) 308*cdf0e10cSrcweir bDoubleUnderline = sal_True; 309*cdf0e10cSrcweir break; 310*cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_STYLE: 311*cdf0e10cSrcweir eUnderline = GetTransformer().GetToken( rAttrValue ); 312*cdf0e10cSrcweir break; 313*cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_WIDTH: 314*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_BOLD ) ) 315*cdf0e10cSrcweir bBoldLineThrough = sal_True; 316*cdf0e10cSrcweir break; 317*cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_TYPE: 318*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_DOUBLE ) ) 319*cdf0e10cSrcweir bDoubleLineThrough = sal_True; 320*cdf0e10cSrcweir break; 321*cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_STYLE: 322*cdf0e10cSrcweir eLineThrough = GetTransformer().GetToken( rAttrValue ); 323*cdf0e10cSrcweir break; 324*cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_TEXT: 325*cdf0e10cSrcweir if( rAttrValue.getLength() ) 326*cdf0e10cSrcweir cLineThroughChar = rAttrValue[0]; 327*cdf0e10cSrcweir break; 328*cdf0e10cSrcweir case XML_OPTACTION_INTERPOLATION: 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir // 0: none 331*cdf0e10cSrcweir sal_Int32 nSplineType = 0; 332*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_CUBIC_SPLINE )) 333*cdf0e10cSrcweir nSplineType = 1; 334*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_B_SPLINE )) 335*cdf0e10cSrcweir nSplineType = 2; 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir pAttrList->AddAttribute( 338*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 339*cdf0e10cSrcweir XML_NAMESPACE_CHART, 340*cdf0e10cSrcweir GetXMLToken( XML_SPLINES )), 341*cdf0e10cSrcweir OUString::valueOf( nSplineType )); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir break; 344*cdf0e10cSrcweir case XML_OPTACTION_INTERVAL_MAJOR: 345*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue ); 346*cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( fIntervalMajor, rAttrValue ); 347*cdf0e10cSrcweir break; 348*cdf0e10cSrcweir case XML_OPTACTION_INTERVAL_MINOR_DIVISOR: 349*cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( nIntervalMinorDivisor, rAttrValue ); 350*cdf0e10cSrcweir bIntervalMinorFound = true; 351*cdf0e10cSrcweir break; 352*cdf0e10cSrcweir case XML_OPTACTION_SYMBOL_TYPE: 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir // if symbol_type is "named-symbol" the "symbol" 355*cdf0e10cSrcweir // property is set in the action XML_OPTACTION_SYMBOL_NAME 356*cdf0e10cSrcweir sal_Int32 nSymbolType = 0; 357*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_NONE )) 358*cdf0e10cSrcweir nSymbolType = -3; 359*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_AUTOMATIC )) 360*cdf0e10cSrcweir nSymbolType = -2; 361*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_IMAGE )) 362*cdf0e10cSrcweir nSymbolType = -1; 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir if( nSymbolType < 0 ) 365*cdf0e10cSrcweir pAttrList->AddAttribute( 366*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 367*cdf0e10cSrcweir XML_NAMESPACE_CHART, 368*cdf0e10cSrcweir GetXMLToken( XML_SYMBOL )), 369*cdf0e10cSrcweir OUString::valueOf( nSymbolType )); 370*cdf0e10cSrcweir } 371*cdf0e10cSrcweir break; 372*cdf0e10cSrcweir case XML_OPTACTION_SYMBOL_NAME: 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir // assume "symbol-type" == "named-symbol" 375*cdf0e10cSrcweir sal_Int32 nSymbolType = -3; // NONE 376*cdf0e10cSrcweir // "square" just has an awkward token-name 377*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_GRADIENTSTYLE_SQUARE )) 378*cdf0e10cSrcweir nSymbolType = 0; 379*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_DIAMOND )) 380*cdf0e10cSrcweir nSymbolType = 1; 381*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_DOWN )) 382*cdf0e10cSrcweir nSymbolType = 2; 383*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_UP )) 384*cdf0e10cSrcweir nSymbolType = 3; 385*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_RIGHT )) 386*cdf0e10cSrcweir nSymbolType = 4; 387*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_LEFT )) 388*cdf0e10cSrcweir nSymbolType = 5; 389*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_BOW_TIE )) 390*cdf0e10cSrcweir nSymbolType = 6; 391*cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_HOURGLASS )) 392*cdf0e10cSrcweir nSymbolType = 7; 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if( nSymbolType >= 0 ) 395*cdf0e10cSrcweir pAttrList->AddAttribute( 396*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 397*cdf0e10cSrcweir XML_NAMESPACE_CHART, 398*cdf0e10cSrcweir GetXMLToken( XML_SYMBOL )), 399*cdf0e10cSrcweir OUString::valueOf( nSymbolType )); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir break; 402*cdf0e10cSrcweir // #i25616# 403*cdf0e10cSrcweir case XML_OPTACTION_OPACITY: 404*cdf0e10cSrcweir aOpacityValueRemember = rAttrValue; 405*cdf0e10cSrcweir GetTransformer().NegPercent(aOpacityValueRemember); 406*cdf0e10cSrcweir break; 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // #i25616# 409*cdf0e10cSrcweir case XML_OPTACTION_IMAGE_OPACITY: 410*cdf0e10cSrcweir aImageOpacityValueRemember = rAttrValue; 411*cdf0e10cSrcweir GetTransformer().NegPercent(aImageOpacityValueRemember); 412*cdf0e10cSrcweir break; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir case XML_OPTACTION_KEEP_TOGETHER: 415*cdf0e10cSrcweir pAttrList->AddAttribute( 416*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 417*cdf0e10cSrcweir XML_NAMESPACE_STYLE,GetXMLToken(XML_BREAK_INSIDE)), 418*cdf0e10cSrcweir GetXMLToken( 419*cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_ALWAYS ) 420*cdf0e10cSrcweir ? XML_COLUMNSPLIT_AVOID 421*cdf0e10cSrcweir : XML_COLUMNSPLIT_AUTO ) ); 422*cdf0e10cSrcweir break; 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir case XML_OPTACTION_CONTROL_TEXT_ALIGN: 425*cdf0e10cSrcweir if ( m_bControlStyle ) 426*cdf0e10cSrcweir { 427*cdf0e10cSrcweir OUString aNewAttrQName( 428*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 429*cdf0e10cSrcweir XML_NAMESPACE_STYLE, 430*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 431*cdf0e10cSrcweir XML_TEXT_ALIGN ) ) ); 432*cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue ); 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir else 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir OUString aNewAttrQName( 437*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 438*cdf0e10cSrcweir XML_NAMESPACE_FO, 439*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( 440*cdf0e10cSrcweir XML_TEXT_ALIGN ) ) ); 441*cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue ); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir break; 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir case XML_OPTACTION_DRAW_WRITING_MODE: 446*cdf0e10cSrcweir if( IsXMLToken( m_aStyleFamily, XML_GRAPHICS ) ) 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir pAttrList->AddAttribute( 449*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 450*cdf0e10cSrcweir XML_NAMESPACE_DRAW, 451*cdf0e10cSrcweir GetXMLToken( XML_WRITING_MODE ) ), rAttrValue ); 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue ); 454*cdf0e10cSrcweir break; 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir case XML_ATACTION_CAPTION_ESCAPE_OASIS: 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 459*cdf0e10cSrcweir if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir sal_Int32 nValue = 0; 462*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue ); 463*cdf0e10cSrcweir if( nValue ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir nValue *= 100; 466*cdf0e10cSrcweir rtl::OUStringBuffer aOut; 467*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue ); 468*cdf0e10cSrcweir aAttrValue = aOut.makeStringAndClear(); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir } 471*cdf0e10cSrcweir else 472*cdf0e10cSrcweir { 473*cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInWithInch( aAttrValue ); 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue ); 477*cdf0e10cSrcweir } 478*cdf0e10cSrcweir break; 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir case XML_ATACTION_DECODE_PROTECT: 481*cdf0e10cSrcweir { 482*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue ); 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir if( rAttrValue.indexOf( GetXMLToken( XML_SIZE ) ) != -1 ) 485*cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( 486*cdf0e10cSrcweir XML_NAMESPACE_DRAW, 487*cdf0e10cSrcweir GetXMLToken( XML_SIZE_PROTECT )), GetXMLToken( XML_TRUE ) ); 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir if( rAttrValue.indexOf( GetXMLToken( XML_POSITION ) ) != -1 ) 490*cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( 491*cdf0e10cSrcweir XML_NAMESPACE_DRAW, 492*cdf0e10cSrcweir GetXMLToken( XML_MOVE_PROTECT )), GetXMLToken( XML_TRUE ) ); 493*cdf0e10cSrcweir } 494*cdf0e10cSrcweir break; 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir case XML_ATACTION_DRAW_MIRROR_OASIS: // renames style:mirror to draw:mirror and adapts values 497*cdf0e10cSrcweir { 498*cdf0e10cSrcweir // keep original for writer graphic objects 499*cdf0e10cSrcweir // --> OD 2005-05-12 #i49139# - adapts attribute values, 500*cdf0e10cSrcweir OUString aNewAttrValue; 501*cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rAttrValue ); 502*cdf0e10cSrcweir OUString aToken; 503*cdf0e10cSrcweir while( aTokenEnum.getNextToken( aToken ) ) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir if ( aNewAttrValue.getLength() > 0 ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir aNewAttrValue += rtl::OUString::createFromAscii( " " ); 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_EVEN ) ) 511*cdf0e10cSrcweir { 512*cdf0e10cSrcweir aNewAttrValue += GetXMLToken( XML_HORIZONTAL_ON_LEFT_PAGES ); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_ODD ) ) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir aNewAttrValue += GetXMLToken( XML_HORIZONTAL_ON_RIGHT_PAGES ); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir else 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir aNewAttrValue += aToken; 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir } 523*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aNewAttrValue ); 524*cdf0e10cSrcweir // <-- 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir // create old draw:mirror for drawing graphic objects 527*cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( IsXMLToken( rAttrValue, XML_HORIZONTAL ) ? XML_TRUE : XML_FALSE ) ); 528*cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey( 529*cdf0e10cSrcweir XML_NAMESPACE_DRAW, 530*cdf0e10cSrcweir GetXMLToken( XML_MIRROR )), aAttrValue ); 531*cdf0e10cSrcweir } 532*cdf0e10cSrcweir break; 533*cdf0e10cSrcweir case XML_ATACTION_GAMMA_OASIS: // converts percentage value to double 534*cdf0e10cSrcweir { 535*cdf0e10cSrcweir sal_Int32 nValue; 536*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue ); 537*cdf0e10cSrcweir const double fValue = ((double)nValue) / 100.0; 538*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, OUString::valueOf( fValue ) ); 539*cdf0e10cSrcweir } 540*cdf0e10cSrcweir break; 541*cdf0e10cSrcweir case XML_ATACTION_OPACITY_FIX: 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir sal_Int32 nValue; 544*cdf0e10cSrcweir if( rAttrValue.indexOf( sal_Unicode('%') ) != -1 ) 545*cdf0e10cSrcweir { 546*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue ); 547*cdf0e10cSrcweir } 548*cdf0e10cSrcweir else 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir nValue = sal_Int32( rAttrValue.toDouble() * 100.0 ); 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir nValue = 100 - nValue; 553*cdf0e10cSrcweir 554*cdf0e10cSrcweir rtl::OUStringBuffer aOut; 555*cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue ); 556*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aOut.makeStringAndClear() ); 557*cdf0e10cSrcweir } 558*cdf0e10cSrcweir break; 559*cdf0e10cSrcweir default: 560*cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" ); 561*cdf0e10cSrcweir break; 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir else 565*cdf0e10cSrcweir { 566*cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue ); 567*cdf0e10cSrcweir } 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir if( XML_TOKEN_END != eUnderline ) 570*cdf0e10cSrcweir pAttrList->AddAttribute( 571*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 572*cdf0e10cSrcweir XML_NAMESPACE_STYLE, 573*cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE ) ), 574*cdf0e10cSrcweir MergeUnderline( eUnderline, bBoldUnderline, 575*cdf0e10cSrcweir bDoubleUnderline ) ); 576*cdf0e10cSrcweir if( XML_TOKEN_END != eLineThrough ) 577*cdf0e10cSrcweir pAttrList->AddAttribute( 578*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 579*cdf0e10cSrcweir XML_NAMESPACE_STYLE, 580*cdf0e10cSrcweir GetXMLToken( XML_TEXT_CROSSING_OUT ) ), 581*cdf0e10cSrcweir MergeLineThrough( eLineThrough, bBoldLineThrough, 582*cdf0e10cSrcweir bDoubleLineThrough, cLineThroughChar ) ); 583*cdf0e10cSrcweir if( bIntervalMinorFound ) 584*cdf0e10cSrcweir { 585*cdf0e10cSrcweir double fIntervalMinor = 0.0; 586*cdf0e10cSrcweir if( nIntervalMinorDivisor != 0) 587*cdf0e10cSrcweir fIntervalMinor = fIntervalMajor / static_cast< double >( nIntervalMinorDivisor ); 588*cdf0e10cSrcweir 589*cdf0e10cSrcweir ::rtl::OUStringBuffer aBuf; 590*cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( aBuf, fIntervalMinor ); 591*cdf0e10cSrcweir pAttrList->AddAttribute( 592*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 593*cdf0e10cSrcweir XML_NAMESPACE_CHART, 594*cdf0e10cSrcweir GetXMLToken( XML_INTERVAL_MINOR )), 595*cdf0e10cSrcweir aBuf.makeStringAndClear()); 596*cdf0e10cSrcweir } 597*cdf0e10cSrcweir 598*cdf0e10cSrcweir // #i25616# 599*cdf0e10cSrcweir if(aOpacityValueRemember.getLength() || aImageOpacityValueRemember.getLength()) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir pAttrList->AddAttribute( 602*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey( 603*cdf0e10cSrcweir XML_NAMESPACE_DRAW, 604*cdf0e10cSrcweir GetXMLToken( XML_TRANSPARENCY ) ), 605*cdf0e10cSrcweir aImageOpacityValueRemember.getLength() 606*cdf0e10cSrcweir ? aImageOpacityValueRemember : aOpacityValueRemember ); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir else 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir if( !m_xAttrList.is() ) 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir m_xAttrList = new XMLMutableAttributeList( rAttrList, sal_True ); 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir else 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() ) 618*cdf0e10cSrcweir ->AppendAttributeList( rAttrList ); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir } 621*cdf0e10cSrcweir } 622*cdf0e10cSrcweir 623*cdf0e10cSrcweir void XMLPropertiesTContext_Impl::Export() 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir OUString aNewQName( GetTransformer().GetNamespaceMap().GetQNameByKey( 626*cdf0e10cSrcweir XML_NAMESPACE_STYLE, 627*cdf0e10cSrcweir ::xmloff::token::GetXMLToken( XML_PROPERTIES ) ) ); 628*cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetExportQName(), 629*cdf0e10cSrcweir m_xAttrList ); 630*cdf0e10cSrcweir ExportContent(); 631*cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetExportQName() ); 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir 634*cdf0e10cSrcweir XMLPropType XMLPropertiesTContext_Impl::GetPropType( const OUString& rLocalName ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir XMLPropType eProp = XML_PROP_TYPE_END; 637*cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) ) 638*cdf0e10cSrcweir eProp = XML_PROP_TYPE_GRAPHIC; 639*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_DRAWING_PAGE_PROPERTIES ) ) 640*cdf0e10cSrcweir eProp = XML_PROP_TYPE_DRAWING_PAGE; 641*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PAGE_LAYOUT_PROPERTIES ) ) 642*cdf0e10cSrcweir eProp = XML_PROP_TYPE_PAGE_LAYOUT; 643*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_HEADER_FOOTER_PROPERTIES ) ) 644*cdf0e10cSrcweir eProp = XML_PROP_TYPE_HEADER_FOOTER; 645*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) ) 646*cdf0e10cSrcweir eProp = XML_PROP_TYPE_TEXT; 647*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) ) 648*cdf0e10cSrcweir eProp = XML_PROP_TYPE_PARAGRAPH; 649*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_RUBY_PROPERTIES ) ) 650*cdf0e10cSrcweir eProp = XML_PROP_TYPE_RUBY; 651*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) ) 652*cdf0e10cSrcweir eProp = XML_PROP_TYPE_SECTION; 653*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) ) 654*cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE; 655*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) ) 656*cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_COLUMN; 657*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) ) 658*cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_ROW; 659*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) ) 660*cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_CELL; 661*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_LIST_LEVEL_PROPERTIES ) ) 662*cdf0e10cSrcweir eProp = XML_PROP_TYPE_LIST_LEVEL; 663*cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) ) 664*cdf0e10cSrcweir eProp = XML_PROP_TYPE_CHART; 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir return eProp; 667*cdf0e10cSrcweir } 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir OUString XMLPropertiesTContext_Impl::MergeUnderline( 670*cdf0e10cSrcweir XMLTokenEnum eUnderline, sal_Bool bBold, sal_Bool bDouble ) 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir if( bDouble ) 673*cdf0e10cSrcweir { 674*cdf0e10cSrcweir switch( eUnderline ) 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir case XML_WAVE: 677*cdf0e10cSrcweir eUnderline = XML_DOUBLE_WAVE; 678*cdf0e10cSrcweir break; 679*cdf0e10cSrcweir default: 680*cdf0e10cSrcweir eUnderline = XML_DOUBLE; 681*cdf0e10cSrcweir break; 682*cdf0e10cSrcweir } 683*cdf0e10cSrcweir } 684*cdf0e10cSrcweir else if( bBold ) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir switch( eUnderline ) 687*cdf0e10cSrcweir { 688*cdf0e10cSrcweir case XML_NONE: 689*cdf0e10cSrcweir case XML_SOLID: 690*cdf0e10cSrcweir eUnderline = XML_BOLD; 691*cdf0e10cSrcweir break; 692*cdf0e10cSrcweir case XML_DOTTED: 693*cdf0e10cSrcweir eUnderline = XML_BOLD_DOTTED; 694*cdf0e10cSrcweir break; 695*cdf0e10cSrcweir case XML_DASH: 696*cdf0e10cSrcweir eUnderline = XML_BOLD_DASH; 697*cdf0e10cSrcweir break; 698*cdf0e10cSrcweir case XML_LONG_DASH: 699*cdf0e10cSrcweir eUnderline = XML_BOLD_LONG_DASH; 700*cdf0e10cSrcweir break; 701*cdf0e10cSrcweir case XML_DOT_DASH: 702*cdf0e10cSrcweir eUnderline = XML_BOLD_DOT_DASH; 703*cdf0e10cSrcweir break; 704*cdf0e10cSrcweir case XML_DOT_DOT_DASH: 705*cdf0e10cSrcweir eUnderline = XML_BOLD_DOT_DOT_DASH; 706*cdf0e10cSrcweir break; 707*cdf0e10cSrcweir case XML_WAVE: 708*cdf0e10cSrcweir eUnderline = XML_BOLD_WAVE; 709*cdf0e10cSrcweir break; 710*cdf0e10cSrcweir default: 711*cdf0e10cSrcweir OSL_ENSURE( false, "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" ); 712*cdf0e10cSrcweir break; 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir } 715*cdf0e10cSrcweir else 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir switch( eUnderline ) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir case XML_SOLID: 720*cdf0e10cSrcweir eUnderline = XML_SINGLE; 721*cdf0e10cSrcweir break; 722*cdf0e10cSrcweir case XML_NONE: 723*cdf0e10cSrcweir eUnderline = XML_NONE; 724*cdf0e10cSrcweir break; 725*cdf0e10cSrcweir default: 726*cdf0e10cSrcweir OSL_ENSURE( false, "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" ); 727*cdf0e10cSrcweir break; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir } 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir return GetXMLToken( eUnderline ); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir OUString XMLPropertiesTContext_Impl::MergeLineThrough( 735*cdf0e10cSrcweir XMLTokenEnum eLineThrough, sal_Bool bBold, sal_Bool bDouble, 736*cdf0e10cSrcweir sal_Unicode c ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir if( c ) 739*cdf0e10cSrcweir eLineThrough = c=='/' ? XML_SLASH : XML_uX; 740*cdf0e10cSrcweir else if( bDouble ) 741*cdf0e10cSrcweir eLineThrough = XML_DOUBLE_LINE; 742*cdf0e10cSrcweir else if( bBold ) 743*cdf0e10cSrcweir eLineThrough = XML_THICK_LINE; 744*cdf0e10cSrcweir else if( XML_NONE != eLineThrough ) 745*cdf0e10cSrcweir eLineThrough = XML_SINGLE_LINE; 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir return GetXMLToken( eLineThrough ); 748*cdf0e10cSrcweir } 749*cdf0e10cSrcweir 750*cdf0e10cSrcweir //------------------------------------------------------------------------------ 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir TYPEINIT1( XMLStyleOASISTContext, XMLPersElemContentTContext ); 753*cdf0e10cSrcweir 754*cdf0e10cSrcweir XMLStyleOASISTContext::XMLStyleOASISTContext( XMLTransformerBase& rImp, 755*cdf0e10cSrcweir const OUString& rQName, 756*cdf0e10cSrcweir sal_Bool bPersistent ) : 757*cdf0e10cSrcweir XMLPersElemContentTContext ( rImp, rQName ), 758*cdf0e10cSrcweir m_bPersistent( bPersistent ), 759*cdf0e10cSrcweir m_bControlStyle( false ) 760*cdf0e10cSrcweir { 761*cdf0e10cSrcweir } 762*cdf0e10cSrcweir 763*cdf0e10cSrcweir XMLStyleOASISTContext::XMLStyleOASISTContext( 764*cdf0e10cSrcweir XMLTransformerBase& rImp, 765*cdf0e10cSrcweir const OUString& rQName, 766*cdf0e10cSrcweir sal_uInt16 nPrefix, 767*cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum eToken, 768*cdf0e10cSrcweir sal_Bool bPersistent ) : 769*cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ), 770*cdf0e10cSrcweir m_bPersistent( bPersistent ) 771*cdf0e10cSrcweir { 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir 774*cdf0e10cSrcweir XMLStyleOASISTContext::~XMLStyleOASISTContext() 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir } 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir XMLTransformerContext *XMLStyleOASISTContext::CreateChildContext( 779*cdf0e10cSrcweir sal_uInt16 nPrefix, 780*cdf0e10cSrcweir const OUString& rLocalName, 781*cdf0e10cSrcweir const OUString& rQName, 782*cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 783*cdf0e10cSrcweir { 784*cdf0e10cSrcweir XMLTransformerContext *pContext = 0; 785*cdf0e10cSrcweir 786*cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefix ) 787*cdf0e10cSrcweir { 788*cdf0e10cSrcweir XMLPropType ePropType = 789*cdf0e10cSrcweir XMLPropertiesTContext_Impl::GetPropType( rLocalName ); 790*cdf0e10cSrcweir if( XML_PROP_TYPE_END != ePropType ) 791*cdf0e10cSrcweir { 792*cdf0e10cSrcweir // if no properties context exist start a new one. 793*cdf0e10cSrcweir if( !m_xPropContext.is() ) 794*cdf0e10cSrcweir m_xPropContext = new XMLPropertiesTContext_Impl( 795*cdf0e10cSrcweir GetTransformer(), rQName, ePropType, m_aStyleFamily, m_bControlStyle ); 796*cdf0e10cSrcweir else 797*cdf0e10cSrcweir m_xPropContext->SetQNameAndPropType( rQName, ePropType ); 798*cdf0e10cSrcweir pContext = m_xPropContext.get(); 799*cdf0e10cSrcweir } 800*cdf0e10cSrcweir } 801*cdf0e10cSrcweir if( !pContext ) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir // if a properties context exist close it 804*cdf0e10cSrcweir if( m_xPropContext.is() && !m_bPersistent ) 805*cdf0e10cSrcweir { 806*cdf0e10cSrcweir m_xPropContext->Export(); 807*cdf0e10cSrcweir m_xPropContext = 0; 808*cdf0e10cSrcweir } 809*cdf0e10cSrcweir 810*cdf0e10cSrcweir pContext = m_bPersistent 811*cdf0e10cSrcweir ? XMLPersElemContentTContext::CreateChildContext( 812*cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ) 813*cdf0e10cSrcweir : XMLTransformerContext::CreateChildContext( 814*cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList ); 815*cdf0e10cSrcweir } 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir return pContext; 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir 820*cdf0e10cSrcweir void XMLStyleOASISTContext::StartElement( 821*cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList ) 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir XMLTransformerActions *pActions = 824*cdf0e10cSrcweir GetTransformer().GetUserDefinedActions( OASIS_STYLE_ACTIONS ); 825*cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" ); 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir Reference< XAttributeList > xAttrList( rAttrList ); 828*cdf0e10cSrcweir XMLMutableAttributeList *pMutableAttrList = 0; 829*cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; 830*cdf0e10cSrcweir sal_Int16 nFamilyAttr = -1; 831*cdf0e10cSrcweir m_bControlStyle = sal_False; 832*cdf0e10cSrcweir 833*cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ ) 834*cdf0e10cSrcweir { 835*cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i ); 836*cdf0e10cSrcweir OUString aLocalName; 837*cdf0e10cSrcweir sal_uInt16 nPrefix = 838*cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName, 839*cdf0e10cSrcweir &aLocalName ); 840*cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); 841*cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter = 842*cdf0e10cSrcweir pActions->find( aKey ); 843*cdf0e10cSrcweir if( !(aIter == pActions->end() ) ) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir if( !pMutableAttrList ) 846*cdf0e10cSrcweir { 847*cdf0e10cSrcweir pMutableAttrList = 848*cdf0e10cSrcweir new XMLMutableAttributeList( xAttrList ); 849*cdf0e10cSrcweir xAttrList = pMutableAttrList; 850*cdf0e10cSrcweir } 851*cdf0e10cSrcweir const OUString& rAttrValue = xAttrList->getValueByIndex( i ); 852*cdf0e10cSrcweir switch( (*aIter).second.m_nActionType ) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir case XML_ATACTION_STYLE_FAMILY: 855*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_GRAPHIC ) ) 856*cdf0e10cSrcweir { 857*cdf0e10cSrcweir m_aStyleFamily = GetXMLToken( XML_GRAPHICS ) ; 858*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, m_aStyleFamily ); 859*cdf0e10cSrcweir } 860*cdf0e10cSrcweir else 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir m_aStyleFamily = rAttrValue; 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_PARAGRAPH ) ) 865*cdf0e10cSrcweir nFamilyAttr = i; 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir break; 869*cdf0e10cSrcweir case XML_ATACTION_STYLE_DISPLAY_NAME: 870*cdf0e10cSrcweir case XML_ATACTION_REMOVE: 871*cdf0e10cSrcweir pMutableAttrList->RemoveAttributeByIndex( i ); 872*cdf0e10cSrcweir --i; 873*cdf0e10cSrcweir --nAttrCount; 874*cdf0e10cSrcweir break; 875*cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME: 876*cdf0e10cSrcweir m_bControlStyle = 0 == rAttrValue.compareToAscii( "ctrl", 4 ); 877*cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME_REF: 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 880*cdf0e10cSrcweir if( GetTransformer().DecodeStyleName(aAttrValue) ) 881*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 882*cdf0e10cSrcweir } 883*cdf0e10cSrcweir break; 884*cdf0e10cSrcweir case XML_ATACTION_IN2INCH: 885*cdf0e10cSrcweir { 886*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 887*cdf0e10cSrcweir if( XMLTransformerBase::ReplaceSingleInWithInch( 888*cdf0e10cSrcweir aAttrValue ) ) 889*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 890*cdf0e10cSrcweir } 891*cdf0e10cSrcweir break; 892*cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT: 893*cdf0e10cSrcweir { 894*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 895*cdf0e10cSrcweir if( GetTransformer().NegPercent(aAttrValue) ) 896*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 897*cdf0e10cSrcweir } 898*cdf0e10cSrcweir break; 899*cdf0e10cSrcweir case XML_ATACTION_URI_OASIS: 900*cdf0e10cSrcweir { 901*cdf0e10cSrcweir OUString aAttrValue( rAttrValue ); 902*cdf0e10cSrcweir if( GetTransformer().ConvertURIToOOo( aAttrValue, 903*cdf0e10cSrcweir static_cast< sal_Bool >((*aIter).second.m_nParam1))) 904*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue ); 905*cdf0e10cSrcweir } 906*cdf0e10cSrcweir break; 907*cdf0e10cSrcweir default: 908*cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" ); 909*cdf0e10cSrcweir break; 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir if( m_bControlStyle && nFamilyAttr != -1 ) 915*cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( nFamilyAttr, GetXMLToken( XML_CONTROL ) ); 916*cdf0e10cSrcweir 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir if( m_bPersistent ) 919*cdf0e10cSrcweir XMLPersElemContentTContext::StartElement( xAttrList ); 920*cdf0e10cSrcweir else 921*cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetExportQName(), 922*cdf0e10cSrcweir xAttrList ); 923*cdf0e10cSrcweir } 924*cdf0e10cSrcweir 925*cdf0e10cSrcweir void XMLStyleOASISTContext::EndElement() 926*cdf0e10cSrcweir { 927*cdf0e10cSrcweir if( m_bPersistent ) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir XMLPersElemContentTContext::EndElement(); 930*cdf0e10cSrcweir } 931*cdf0e10cSrcweir else 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir // if a properties context exist close it 934*cdf0e10cSrcweir if( m_xPropContext.is() ) 935*cdf0e10cSrcweir { 936*cdf0e10cSrcweir m_xPropContext->Export(); 937*cdf0e10cSrcweir m_xPropContext = 0; 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetExportQName() ); 940*cdf0e10cSrcweir } 941*cdf0e10cSrcweir } 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir void XMLStyleOASISTContext::Characters( const OUString& ) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir // element content only: 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir 948*cdf0e10cSrcweir void XMLStyleOASISTContext::ExportContent() 949*cdf0e10cSrcweir { 950*cdf0e10cSrcweir if( m_xPropContext.is() ) 951*cdf0e10cSrcweir m_xPropContext->Export(); 952*cdf0e10cSrcweir XMLPersElemContentTContext::ExportContent(); 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir sal_Bool XMLStyleOASISTContext::IsPersistent() const 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir return m_bPersistent; 958*cdf0e10cSrcweir } 959*cdf0e10cSrcweir 960*cdf0e10cSrcweir XMLTransformerActions *XMLStyleOASISTContext::CreateTransformerActions( 961*cdf0e10cSrcweir sal_uInt16 nType ) 962*cdf0e10cSrcweir { 963*cdf0e10cSrcweir XMLTransformerActionInit *pInit = 0; 964*cdf0e10cSrcweir 965*cdf0e10cSrcweir switch( nType ) 966*cdf0e10cSrcweir { 967*cdf0e10cSrcweir case PROP_OASIS_GRAPHIC_ATTR_ACTIONS: 968*cdf0e10cSrcweir pInit = aGraphicPropertyOASISAttrActionTable; 969*cdf0e10cSrcweir break; 970*cdf0e10cSrcweir case PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS: 971*cdf0e10cSrcweir pInit = aDrawingPagePropertyOASISAttrActionTable; 972*cdf0e10cSrcweir break; 973*cdf0e10cSrcweir case PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS: 974*cdf0e10cSrcweir pInit = aPageLayoutPropertyOASISAttrActionTable; 975*cdf0e10cSrcweir break; 976*cdf0e10cSrcweir case PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS: 977*cdf0e10cSrcweir pInit = aHeaderFooterPropertyOASISAttrActionTable; 978*cdf0e10cSrcweir break; 979*cdf0e10cSrcweir case PROP_OASIS_TEXT_ATTR_ACTIONS: 980*cdf0e10cSrcweir pInit = aTextPropertyOASISAttrActionTable; 981*cdf0e10cSrcweir break; 982*cdf0e10cSrcweir case PROP_OASIS_PARAGRAPH_ATTR_ACTIONS: 983*cdf0e10cSrcweir pInit = aParagraphPropertyOASISAttrActionTable; 984*cdf0e10cSrcweir break; 985*cdf0e10cSrcweir case PROP_OASIS_SECTION_ATTR_ACTIONS: 986*cdf0e10cSrcweir pInit = aSectionPropertyOASISAttrActionTable; 987*cdf0e10cSrcweir break; 988*cdf0e10cSrcweir case PROP_OASIS_TABLE_ATTR_ACTIONS: 989*cdf0e10cSrcweir pInit = aTablePropertyOASISAttrActionTable; 990*cdf0e10cSrcweir break; 991*cdf0e10cSrcweir case PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS: 992*cdf0e10cSrcweir pInit = aTableColumnPropertyOASISAttrActionTable; 993*cdf0e10cSrcweir break; 994*cdf0e10cSrcweir case PROP_OASIS_TABLE_ROW_ATTR_ACTIONS: 995*cdf0e10cSrcweir pInit = aTableRowPropertyOASISAttrActionTable; 996*cdf0e10cSrcweir break; 997*cdf0e10cSrcweir case PROP_OASIS_TABLE_CELL_ATTR_ACTIONS: 998*cdf0e10cSrcweir pInit = aTableCellPropertyOASISAttrActionTable; 999*cdf0e10cSrcweir break; 1000*cdf0e10cSrcweir case PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS: 1001*cdf0e10cSrcweir pInit = aListLevelPropertyOASISAttrActionTable; 1002*cdf0e10cSrcweir break; 1003*cdf0e10cSrcweir case PROP_OASIS_CHART_ATTR_ACTIONS: 1004*cdf0e10cSrcweir pInit = aChartPropertyOASISAttrActionTable; 1005*cdf0e10cSrcweir break; 1006*cdf0e10cSrcweir } 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir XMLTransformerActions *pActions = 0; 1009*cdf0e10cSrcweir if( pInit ) 1010*cdf0e10cSrcweir pActions = new XMLTransformerActions( pInit ); 1011*cdf0e10cSrcweir 1012*cdf0e10cSrcweir return pActions; 1013*cdf0e10cSrcweir } 1014