Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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"
25 :
26 : using namespace ::com::sun::star::uno;
27 : using namespace ::com::sun::star::text;
28 : using namespace ::com::sun::star::frame;
29 :
30 : namespace oox { namespace drawingml {
31 :
32 4114 : TextBody::TextBody()
33 : {
34 4114 : }
35 :
36 1272 : TextBody::TextBody( TextBodyPtr pBody )
37 : {
38 1272 : if( pBody.get() ) {
39 422 : maTextProperties = pBody->maTextProperties;
40 422 : maTextListStyle = pBody->maTextListStyle;
41 : }
42 1272 : }
43 :
44 5814 : TextBody::~TextBody()
45 : {
46 5814 : }
47 :
48 6094 : TextParagraph& TextBody::addParagraph()
49 : {
50 6094 : TextParagraphPtr xPara( new TextParagraph );
51 6094 : maParagraphs.push_back( xPara );
52 6094 : return *xPara;
53 : }
54 :
55 1744 : 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
61 : {
62 1744 : TextListStyle aCombinedTextStyle;
63 1744 : aCombinedTextStyle.apply( *pMasterTextListStylePtr );
64 1744 : aCombinedTextStyle.apply( maTextListStyle );
65 :
66 3488 : Reference<css::beans::XPropertySet> xPropertySet(xAt, UNO_QUERY);
67 1744 : float nCharHeight = xPropertySet->getPropertyValue("CharHeight").get<float>();
68 3936 : for( TextParagraphVector::const_iterator aBeg = maParagraphs.begin(), aIt = aBeg, aEnd = maParagraphs.end(); aIt != aEnd; ++aIt )
69 3936 : (*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg, nCharHeight );
70 1744 : }
71 :
72 430 : bool TextBody::isEmpty()
73 : {
74 430 : if ( maParagraphs.size() <= 0 )
75 0 : return true;
76 430 : if ( maParagraphs.size() > 1 )
77 28 : return false;
78 :
79 402 : const TextRunVector aRuns = maParagraphs[0]->getRuns();
80 402 : if ( aRuns.size() <= 0 )
81 136 : return true;
82 266 : if ( aRuns.size() > 1 )
83 12 : return false;
84 :
85 254 : return aRuns[0]->getText().getLength() <= 0;
86 : }
87 :
88 408 : } }
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|