1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #include "oox/drawingml/textparagraph.hxx" 25 #include "oox/drawingml/drawingmltypes.hxx" 26 27 #include <rtl/ustring.hxx> 28 #include "oox/helper/propertyset.hxx" 29 #include <com/sun/star/text/XText.hpp> 30 #include <com/sun/star/text/XTextCursor.hpp> 31 #include <com/sun/star/text/ControlCharacter.hpp> 32 33 using ::rtl::OUString; 34 using namespace ::com::sun::star::text; 35 using namespace ::com::sun::star::uno; 36 using namespace ::com::sun::star::beans; 37 using namespace ::com::sun::star::frame; 38 39 namespace oox { namespace drawingml { 40 41 TextParagraph::TextParagraph() 42 { 43 } 44 45 TextParagraph::~TextParagraph() 46 { 47 } 48 49 void TextParagraph::insertAt( 50 const ::oox::core::XmlFilterBase& rFilterBase, 51 const Reference < XText > &xText, 52 const Reference < XTextCursor > &xAt, 53 const TextCharacterProperties& rTextStyleProperties, 54 const TextListStyle& rTextListStyle, bool bFirst) const 55 { 56 try { 57 sal_Int32 nParagraphSize = 0; 58 Reference< XTextRange > xStart( xAt, UNO_QUERY ); 59 60 sal_Int16 nLevel = maProperties.getLevel(); 61 const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle(); 62 if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) ) 63 nLevel = 0; 64 TextParagraphPropertiesPtr pTextParagraphStyle; 65 if ( rListStyle.size() ) 66 pTextParagraphStyle = rListStyle[ nLevel ]; 67 68 TextCharacterProperties aTextCharacterStyle( rTextStyleProperties ); 69 if ( pTextParagraphStyle.get() ) 70 aTextCharacterStyle.assignUsed( pTextParagraphStyle->getTextCharacterProperties() ); 71 aTextCharacterStyle.assignUsed( maProperties.getTextCharacterProperties() ); 72 73 if( !bFirst ) 74 { 75 xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False ); 76 xAt->gotoEnd( sal_True ); 77 } 78 if ( maRuns.begin() == maRuns.end() ) 79 { 80 PropertySet aPropSet( xStart ); 81 82 TextCharacterProperties aTextCharacterProps( aTextCharacterStyle ); 83 aTextCharacterProps.assignUsed( maEndProperties ); 84 aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); 85 } 86 else 87 { 88 for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt ) 89 { 90 (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ); 91 nParagraphSize += (*aIt)->getText().getLength(); 92 } 93 } 94 xAt->gotoEnd( sal_True ); 95 96 PropertyMap aioBulletList; 97 Reference< XPropertySet > xProps( xStart, UNO_QUERY); 98 float fCharacterSize = 18; 99 if ( pTextParagraphStyle.get() ) 100 { 101 pTextParagraphStyle->pushToPropSet( rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize ); 102 fCharacterSize = pTextParagraphStyle->getCharHeightPoints( 18 ); 103 } 104 maProperties.pushToPropSet( rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize ); 105 106 // empty paragraphs do not have bullets in ppt 107 if ( !nParagraphSize ) 108 { 109 const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) ); 110 xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( -1 ) ) ); 111 } 112 113 // FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub 114 // Reference< XTextRange > xEnd( xAt, UNO_QUERY ); 115 // Reference< XPropertySet > xProps2( xEnd, UNO_QUERY ); 116 // mpEndProperties->pushToPropSet( xProps2 ); 117 } 118 catch( Exception & ) 119 { 120 OSL_TRACE("OOX: exception in TextParagraph::insertAt"); 121 } 122 } 123 124 125 } } 126 127