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