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