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 #include "oox/drawingml/textparagraph.hxx" 29*cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <rtl/ustring.hxx> 32*cdf0e10cSrcweir #include "oox/helper/propertyset.hxx" 33*cdf0e10cSrcweir #include <com/sun/star/text/XText.hpp> 34*cdf0e10cSrcweir #include <com/sun/star/text/XTextCursor.hpp> 35*cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using ::rtl::OUString; 38*cdf0e10cSrcweir using namespace ::com::sun::star::text; 39*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 40*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 41*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir namespace oox { namespace drawingml { 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir TextParagraph::TextParagraph() 46*cdf0e10cSrcweir { 47*cdf0e10cSrcweir } 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir TextParagraph::~TextParagraph() 50*cdf0e10cSrcweir { 51*cdf0e10cSrcweir } 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir void TextParagraph::insertAt( 54*cdf0e10cSrcweir const ::oox::core::XmlFilterBase& rFilterBase, 55*cdf0e10cSrcweir const Reference < XText > &xText, 56*cdf0e10cSrcweir const Reference < XTextCursor > &xAt, 57*cdf0e10cSrcweir const TextCharacterProperties& rTextStyleProperties, 58*cdf0e10cSrcweir const TextListStyle& rTextListStyle, bool bFirst) const 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir try { 61*cdf0e10cSrcweir sal_Int32 nParagraphSize = 0; 62*cdf0e10cSrcweir Reference< XTextRange > xStart( xAt, UNO_QUERY ); 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir sal_Int16 nLevel = maProperties.getLevel(); 65*cdf0e10cSrcweir const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle(); 66*cdf0e10cSrcweir if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) ) 67*cdf0e10cSrcweir nLevel = 0; 68*cdf0e10cSrcweir TextParagraphPropertiesPtr pTextParagraphStyle; 69*cdf0e10cSrcweir if ( rListStyle.size() ) 70*cdf0e10cSrcweir pTextParagraphStyle = rListStyle[ nLevel ]; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir TextCharacterProperties aTextCharacterStyle( rTextStyleProperties ); 73*cdf0e10cSrcweir if ( pTextParagraphStyle.get() ) 74*cdf0e10cSrcweir aTextCharacterStyle.assignUsed( pTextParagraphStyle->getTextCharacterProperties() ); 75*cdf0e10cSrcweir aTextCharacterStyle.assignUsed( maProperties.getTextCharacterProperties() ); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir if( !bFirst ) 78*cdf0e10cSrcweir { 79*cdf0e10cSrcweir xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False ); 80*cdf0e10cSrcweir xAt->gotoEnd( sal_True ); 81*cdf0e10cSrcweir } 82*cdf0e10cSrcweir if ( maRuns.begin() == maRuns.end() ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir PropertySet aPropSet( xStart ); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir TextCharacterProperties aTextCharacterProps( aTextCharacterStyle ); 87*cdf0e10cSrcweir aTextCharacterProps.assignUsed( maEndProperties ); 88*cdf0e10cSrcweir aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir else 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ); 95*cdf0e10cSrcweir nParagraphSize += (*aIt)->getText().getLength(); 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir xAt->gotoEnd( sal_True ); 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir PropertyMap aioBulletList; 101*cdf0e10cSrcweir Reference< XPropertySet > xProps( xStart, UNO_QUERY); 102*cdf0e10cSrcweir float fCharacterSize = 18; 103*cdf0e10cSrcweir if ( pTextParagraphStyle.get() ) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir pTextParagraphStyle->pushToPropSet( rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize ); 106*cdf0e10cSrcweir fCharacterSize = pTextParagraphStyle->getCharHeightPoints( 18 ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir maProperties.pushToPropSet( rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize ); 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir // empty paragraphs do not have bullets in ppt 111*cdf0e10cSrcweir if ( !nParagraphSize ) 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) ); 114*cdf0e10cSrcweir xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( -1 ) ) ); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir // FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub 118*cdf0e10cSrcweir // Reference< XTextRange > xEnd( xAt, UNO_QUERY ); 119*cdf0e10cSrcweir // Reference< XPropertySet > xProps2( xEnd, UNO_QUERY ); 120*cdf0e10cSrcweir // mpEndProperties->pushToPropSet( xProps2 ); 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir catch( Exception & ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir OSL_TRACE("OOX: exception in TextParagraph::insertAt"); 125*cdf0e10cSrcweir } 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir } } 130*cdf0e10cSrcweir 131