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 "oox/drawingml/textparagraph.hxx"
24 :
25 : using namespace ::com::sun::star::uno;
26 : using namespace ::com::sun::star::text;
27 : using namespace ::com::sun::star::frame;
28 :
29 : namespace oox { namespace drawingml {
30 :
31 :
32 10 : TextBody::TextBody()
33 : {
34 10 : }
35 :
36 43 : TextBody::TextBody( TextBodyPtr pBody )
37 : {
38 43 : if( pBody.get() ) {
39 17 : maTextProperties = pBody->maTextProperties;
40 17 : maTextListStyle = pBody->maTextListStyle;
41 : }
42 43 : }
43 :
44 71 : TextBody::~TextBody()
45 : {
46 71 : }
47 :
48 93 : TextParagraph& TextBody::addParagraph()
49 : {
50 93 : TextParagraphPtr xPara( new TextParagraph );
51 93 : maParagraphs.push_back( xPara );
52 93 : return *xPara;
53 : }
54 :
55 18 : 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 18 : TextListStyle aCombinedTextStyle;
63 18 : aCombinedTextStyle.apply( *pMasterTextListStylePtr );
64 18 : aCombinedTextStyle.apply( maTextListStyle );
65 :
66 54 : for( TextParagraphVector::const_iterator aBeg = maParagraphs.begin(), aIt = aBeg, aEnd = maParagraphs.end(); aIt != aEnd; ++aIt )
67 54 : (*aIt)->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, aCombinedTextStyle, aIt == aBeg );
68 18 : }
69 :
70 16 : bool TextBody::isEmpty()
71 : {
72 16 : if ( maParagraphs.size() <= 0 )
73 0 : return true;
74 16 : if ( maParagraphs.size() > 1 )
75 3 : return false;
76 :
77 13 : const TextRunVector aRuns = maParagraphs[0]->getRuns();
78 13 : if ( aRuns.size() <= 0 )
79 4 : return true;
80 9 : if ( aRuns.size() > 1 )
81 1 : return false;
82 :
83 8 : return aRuns[0]->getText().getLength() <= 0;
84 : }
85 :
86 51 : } }
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|