1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: textparagraph.cxx,v $
10 * $Revision: 1.7.6.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/textparagraph.hxx"
32 #include "oox/drawingml/drawingmltypes.hxx"
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/text/XText.hpp>
36 #include <com/sun/star/text/XTextCursor.hpp>
37 #include <com/sun/star/text/ControlCharacter.hpp>
39 using ::rtl::OUString
;
40 using namespace ::com::sun::star::text
;
41 using namespace ::com::sun::star::uno
;
42 using namespace ::com::sun::star::beans
;
43 using namespace ::com::sun::star::frame
;
45 namespace oox
{ namespace drawingml
{
47 TextParagraph::TextParagraph()
51 TextParagraph::~TextParagraph()
55 void TextParagraph::insertAt(
56 const ::oox::core::XmlFilterBase
& rFilterBase
,
57 const Reference
< XText
> &xText
,
58 const Reference
< XTextCursor
> &xAt
,
59 const TextCharacterProperties
& rTextStyleProperties
,
60 const TextListStyle
& rTextListStyle
, bool bFirst
) const
63 sal_Int32 nParagraphSize
= 0;
64 Reference
< XTextRange
> xStart( xAt
, UNO_QUERY
);
66 sal_Int16 nLevel
= maProperties
.getLevel();
67 const TextParagraphPropertiesVector
& rListStyle
= rTextListStyle
.getListStyle();
68 if ( nLevel
>= static_cast< sal_Int16
>( rListStyle
.size() ) )
70 TextParagraphPropertiesPtr pTextParagraphStyle
;
71 if ( rListStyle
.size() )
72 pTextParagraphStyle
= rListStyle
[ nLevel
];
74 TextCharacterProperties
aTextCharacterStyle( rTextStyleProperties
);
75 if ( pTextParagraphStyle
.get() )
76 aTextCharacterStyle
.assignUsed( pTextParagraphStyle
->getTextCharacterProperties() );
77 aTextCharacterStyle
.assignUsed( maProperties
.getTextCharacterProperties() );
81 xText
->insertControlCharacter( xStart
, ControlCharacter::APPEND_PARAGRAPH
, sal_False
);
82 xAt
->gotoEnd( sal_True
);
85 for( TextRunVector::const_iterator aIt
= maRuns
.begin(), aEnd
= maRuns
.end(); aIt
!= aEnd
; ++aIt
)
87 (*aIt
)->insertAt( rFilterBase
, xText
, xAt
, aTextCharacterStyle
);
88 nParagraphSize
+= (*aIt
)->getText().getLength();
90 xAt
->gotoEnd( sal_True
);
92 PropertyMap aioBulletList
;
93 Reference
< XPropertySet
> xProps( xStart
, UNO_QUERY
);
94 float fCharacterSize
= 18;
95 if ( pTextParagraphStyle
.get() )
97 pTextParagraphStyle
->pushToPropSet( rFilterBase
, xProps
, aioBulletList
, NULL
, sal_False
, fCharacterSize
);
98 fCharacterSize
= pTextParagraphStyle
->getCharHeightPoints( 18 );
101 maProperties
.pushToPropSet( rFilterBase
, xProps
, aioBulletList
, &pTextParagraphStyle
->getBulletList(), sal_True
, fCharacterSize
);
103 // empty paragraphs do not have bullets in ppt
104 if ( !nParagraphSize
)
106 const OUString
sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
107 xProps
->setPropertyValue( sNumberingLevel
, Any( static_cast< sal_Int16
>( -1 ) ) );
110 // FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub
111 // Reference< XTextRange > xEnd( xAt, UNO_QUERY );
112 // Reference< XPropertySet > xProps2( xEnd, UNO_QUERY );
113 // mpEndProperties->pushToPropSet( xProps2 );
117 OSL_TRACE("OOX: exception in TextParagraph::insertAt");