Branch data 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 : : #include <vbahelper/helperdecl.hxx>
20 : : #include <com/sun/star/drawing/TextFitToSizeType.hpp>
21 : : #include <com/sun/star/text/XText.hpp>
22 : : #include <vbahelper/vbatextframe.hxx>
23 : :
24 : : using namespace ::ooo::vba;
25 : : using namespace ::com::sun::star;
26 : :
27 : 0 : VbaTextFrame::VbaTextFrame( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< drawing::XShape > xShape ) : VbaTextFrame_BASE( xParent, xContext ), m_xShape( xShape )
28 : : {
29 [ # # ]: 0 : m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW );
30 : 0 : }
31 : :
32 : : void
33 : 0 : VbaTextFrame::setAsMSObehavior()
34 : : {
35 : : //set property TextWordWrap default as False.
36 : : // TextFitToSize control the text content. it seems we should set the default as False.
37 : : // com.sun.star.drawing.TextFitToSizeType.NONE
38 [ # # ][ # # ]: 0 : m_xPropertySet->setPropertyValue( rtl::OUString("TextWordWrap"), uno::makeAny( sal_False ) );
39 [ # # ][ # # ]: 0 : m_xPropertySet->setPropertyValue( rtl::OUString("TextFitToSize"), uno::makeAny( drawing::TextFitToSizeType_NONE ) );
40 : 0 : }
41 : :
42 : 0 : sal_Int32 VbaTextFrame::getMargin( rtl::OUString sMarginType )
43 : : {
44 : 0 : sal_Int32 nMargin = 0;
45 [ # # ][ # # ]: 0 : uno::Any aMargin = m_xPropertySet->getPropertyValue( sMarginType );
46 : 0 : aMargin >>= nMargin;
47 : 0 : return nMargin;
48 : : }
49 : :
50 : 0 : void VbaTextFrame::setMargin( rtl::OUString sMarginType, float fMargin )
51 : : {
52 [ # # ]: 0 : sal_Int32 nMargin = Millimeter::getInHundredthsOfOneMillimeter( fMargin );
53 [ # # ][ # # ]: 0 : m_xPropertySet->setPropertyValue( sMarginType, uno::makeAny( nMargin ) );
[ # # ]
54 : 0 : }
55 : :
56 : : // Attributes
57 : : sal_Bool SAL_CALL
58 : 0 : VbaTextFrame::getAutoSize() throw (uno::RuntimeException)
59 : : {
60 : : // I don't know why, but in OOo, TextAutoGrowHeight is the property control autosize. not TextFitToSize.
61 : : // TextFitToSize control the text content.
62 : : // and in mso, there isnot option TextWordWrap which means auto wrap. the default is False.
63 : 0 : sal_Bool bAutosize = sal_False;
64 [ # # ][ # # ]: 0 : uno::Any aTextAutoGrowHeight = m_xPropertySet->getPropertyValue( rtl::OUString("TextAutoGrowHeight") );
65 : 0 : aTextAutoGrowHeight >>= bAutosize;
66 : 0 : return bAutosize;
67 : : }
68 : :
69 : : void SAL_CALL
70 : 0 : VbaTextFrame::setAutoSize( sal_Bool _autosize ) throw (uno::RuntimeException)
71 : : {
72 : 0 : setAsMSObehavior();
73 [ # # ]: 0 : m_xPropertySet->setPropertyValue( rtl::OUString("TextAutoGrowHeight"), uno::makeAny( _autosize ) );
74 : 0 : }
75 : :
76 : : float SAL_CALL
77 : 0 : VbaTextFrame::getMarginBottom() throw (uno::RuntimeException)
78 : : {
79 [ # # ]: 0 : sal_Int32 nMargin = getMargin( rtl::OUString("TextLowerDistance") );
80 : 0 : float fMargin = (float)Millimeter::getInPoints( nMargin );
81 : 0 : return fMargin;
82 : : }
83 : :
84 : : void SAL_CALL
85 : 0 : VbaTextFrame::setMarginBottom( float _marginbottom ) throw (uno::RuntimeException)
86 : : {
87 [ # # ]: 0 : setMargin( rtl::OUString("TextLowerDistance"), _marginbottom );
88 : 0 : }
89 : :
90 : : float SAL_CALL
91 : 0 : VbaTextFrame::getMarginTop() throw (uno::RuntimeException)
92 : : {
93 [ # # ]: 0 : sal_Int32 nMargin = getMargin( rtl::OUString("TextUpperDistance") );
94 : 0 : float fMargin = (float)Millimeter::getInPoints( nMargin );
95 : 0 : return fMargin;
96 : : }
97 : :
98 : : void SAL_CALL
99 : 0 : VbaTextFrame::setMarginTop( float _margintop ) throw (uno::RuntimeException)
100 : : {
101 [ # # ]: 0 : setMargin( rtl::OUString("TextUpperDistance"), _margintop );
102 : 0 : }
103 : :
104 : : float SAL_CALL
105 : 0 : VbaTextFrame::getMarginLeft() throw (uno::RuntimeException)
106 : : {
107 [ # # ]: 0 : sal_Int32 nMargin = getMargin( rtl::OUString("TextLeftDistance") );
108 : 0 : float fMargin = (float)Millimeter::getInPoints( nMargin );
109 : 0 : return fMargin;
110 : : }
111 : :
112 : : void SAL_CALL
113 : 0 : VbaTextFrame::setMarginLeft( float _marginleft ) throw (uno::RuntimeException)
114 : : {
115 [ # # ]: 0 : setMargin( rtl::OUString("TextLeftDistance"), _marginleft );
116 : 0 : }
117 : :
118 : : float SAL_CALL
119 : 0 : VbaTextFrame::getMarginRight() throw (uno::RuntimeException)
120 : : {
121 [ # # ]: 0 : sal_Int32 nMargin = getMargin( rtl::OUString("TextRightDistance") );
122 : 0 : float fMargin = (float)Millimeter::getInPoints( nMargin );
123 : 0 : return fMargin;
124 : : }
125 : :
126 : : void SAL_CALL
127 : 0 : VbaTextFrame::setMarginRight( float _marginright ) throw (uno::RuntimeException)
128 : : {
129 [ # # ]: 0 : setMargin( rtl::OUString("TextRightDistance"), _marginright );
130 : 0 : }
131 : :
132 : :
133 : : // Methods
134 : : uno::Any SAL_CALL
135 : 0 : VbaTextFrame::Characters() throw (uno::RuntimeException)
136 : : {
137 [ # # ]: 0 : throw uno::RuntimeException( rtl::OUString( "Not implemented" ), uno::Reference< uno::XInterface >() );
138 : : }
139 : :
140 : : rtl::OUString
141 : 0 : VbaTextFrame::getServiceImplName()
142 : : {
143 : 0 : return rtl::OUString("VbaTextFrame");
144 : : }
145 : :
146 : : uno::Sequence< rtl::OUString >
147 : 0 : VbaTextFrame::getServiceNames()
148 : : {
149 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
150 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
151 : : {
152 : 0 : aServiceNames.realloc( 1 );
153 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( "ooo.vba.msforms.TextFrame" );
154 : : }
155 : 0 : return aServiceNames;
156 : : }
157 : :
158 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|