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 "oox/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 "oox/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 :
33 0 : TextBody::TextBody()
34 : {
35 0 : }
36 :
37 0 : TextBody::TextBody( TextBodyPtr pBody )
38 : {
39 0 : if( pBody.get() ) {
40 0 : maTextProperties = pBody->maTextProperties;
41 0 : maTextListStyle = pBody->maTextListStyle;
42 : }
43 0 : }
44 :
45 0 : TextBody::~TextBody()
46 : {
47 0 : }
48 :
49 0 : TextParagraph& TextBody::addParagraph()
50 : {
51 0 : TextParagraphPtr xPara( new TextParagraph );
52 0 : maParagraphs.push_back( xPara );
53 0 : return *xPara;
54 : }
55 :
56 0 : void TextBody::insertAt(
57 : const ::oox::core::XmlFilterBase& rFilterBase,
58 : const Reference < XText > & xText,
59 : const Reference < XTextCursor > & xAt,
60 : const TextCharacterProperties& rTextStyleProperties,
61 : const TextListStylePtr& pMasterTextListStylePtr ) const
62 : {
63 0 : TextListStyle aCombinedTextStyle;
64 0 : aCombinedTextStyle.apply( *pMasterTextListStylePtr );
65 0 : aCombinedTextStyle.apply( maTextListStyle );
66 :
67 0 : Reference<css::beans::XPropertySet> xPropertySet(xAt, UNO_QUERY);
68 0 : float nCharHeight = xPropertySet->getPropertyValue("CharHeight").get<float>();
69 0 : for( TextParagraphVector::const_iterator aBeg = maParagraphs.begin(), aIt = aBeg, aEnd = maParagraphs.end(); aIt != aEnd; ++aIt )
70 0 : (*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg, nCharHeight );
71 0 : }
72 :
73 0 : bool TextBody::isEmpty()
74 : {
75 0 : if ( maParagraphs.size() <= 0 )
76 0 : return true;
77 0 : if ( maParagraphs.size() > 1 )
78 0 : return false;
79 :
80 0 : const TextRunVector aRuns = maParagraphs[0]->getRuns();
81 0 : if ( aRuns.size() <= 0 )
82 0 : return true;
83 0 : if ( aRuns.size() > 1 )
84 0 : return false;
85 :
86 0 : return aRuns[0]->getText().getLength() <= 0;
87 : }
88 :
89 0 : } }
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|