1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "drawingml/textbody.hxx"
21 #include <com/sun/star/text/XText.hpp>
22 #include <com/sun/star/text/XTextCursor.hpp>
23 #include <com/sun/star/beans/XPropertySet.hpp>
24 #include "drawingml/textparagraph.hxx"
26 using namespace ::com::sun::star::uno
;
27 using namespace ::com::sun::star::text
;
28 using namespace ::com::sun::star::frame
;
30 namespace oox
{ namespace drawingml
{
36 TextBody::TextBody( TextBodyPtr pBody
)
39 maTextProperties
= pBody
->maTextProperties
;
40 maTextListStyle
= pBody
->maTextListStyle
;
48 TextParagraph
& TextBody::addParagraph()
50 TextParagraphPtr
xPara( new TextParagraph
);
51 maParagraphs
.push_back( xPara
);
55 void TextBody::insertAt(
56 const ::oox::core::XmlFilterBase
& rFilterBase
,
57 const Reference
< XText
> & xText
,
58 const Reference
< XTextCursor
> & xAt
,
59 const TextCharacterProperties
& rTextStyleProperties
,
60 const TextListStylePtr
& pMasterTextListStylePtr
) const
62 TextListStyle aCombinedTextStyle
;
63 aCombinedTextStyle
.apply( *pMasterTextListStylePtr
);
64 aCombinedTextStyle
.apply( maTextListStyle
);
66 Reference
<css::beans::XPropertySet
> xPropertySet(xAt
, UNO_QUERY
);
67 float nCharHeight
= xPropertySet
->getPropertyValue("CharHeight").get
<float>();
68 for( TextParagraphVector::const_iterator aBeg
= maParagraphs
.begin(), aIt
= aBeg
, aEnd
= maParagraphs
.end(); aIt
!= aEnd
; ++aIt
)
69 (*aIt
)->insertAt( rFilterBase
, xText
, xAt
, rTextStyleProperties
, aCombinedTextStyle
, aIt
== aBeg
, nCharHeight
);
72 bool TextBody::isEmpty()
74 if ( maParagraphs
.size() <= 0 )
76 if ( maParagraphs
.size() > 1 )
79 const TextRunVector aRuns
= maParagraphs
[0]->getRuns();
80 if ( aRuns
.size() <= 0 )
82 if ( aRuns
.size() > 1 )
85 return aRuns
[0]->getText().getLength() <= 0;
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */