xref: /trunk/main/sc/source/ui/vba/vbatextboxshape.cxx (revision b3f79822)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "vbatextboxshape.hxx"
25 #include "vbacharacters.hxx"
26 #include <com/sun/star/text/XSimpleText.hpp>
27 #include <vector>
28 
29 using namespace com::sun::star;
30 using namespace ooo::vba;
31 
ScVbaTextBoxShape(const uno::Reference<uno::XComponentContext> & xContext,const uno::Reference<drawing::XShape> & xShape,const uno::Reference<drawing::XShapes> & xShapes,const uno::Reference<frame::XModel> & xModel)32 ScVbaTextBoxShape::ScVbaTextBoxShape( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel ) : TextBoxShapeImpl_BASE( uno::Reference< XHelperInterface >(), xContext, xShape, xShapes, xModel, ScVbaShape::getType( xShape )  )
33 {
34     m_xTextRange.set( xShape , uno::UNO_QUERY_THROW );
35     m_xModel.set( xModel );
36 }
37 
38 rtl::OUString SAL_CALL
getText()39 ScVbaTextBoxShape::getText() throw (css::uno::RuntimeException)
40 {
41     return m_xTextRange->getString();
42 }
43 
44 void SAL_CALL
setText(const rtl::OUString & _text)45 ScVbaTextBoxShape::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
46 {
47     m_xTextRange->setString( _text );
48 }
49 
50 uno::Reference< excel::XCharacters > SAL_CALL
characters(const uno::Any & Start,const uno::Any & Length)51 ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException)
52 {
53     ScDocShell* pDocShell = excel::getDocShell( m_xModel );
54     ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
55 
56     if ( !pDoc )
57         throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
58     uno::Reference< text::XSimpleText > xSimple( m_xTextRange, uno::UNO_QUERY_THROW );
59 
60     ScVbaPalette aPalette( pDoc->GetDocumentShell() );
61     return  new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length, sal_True );
62 }
63