xref: /aoo41x/main/sc/source/ui/vba/vbatextboxshape.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "vbatextboxshape.hxx"
29 #include "vbacharacters.hxx"
30 #include <com/sun/star/text/XSimpleText.hpp>
31 #include <vector>
32 
33 using namespace com::sun::star;
34 using namespace ooo::vba;
35 
36 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 )  )
37 {
38     m_xTextRange.set( xShape , uno::UNO_QUERY_THROW );
39     m_xModel.set( xModel );
40 }
41 
42 rtl::OUString SAL_CALL
43 ScVbaTextBoxShape::getText() throw (css::uno::RuntimeException)
44 {
45     return m_xTextRange->getString();
46 }
47 
48 void SAL_CALL
49 ScVbaTextBoxShape::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
50 {
51     m_xTextRange->setString( _text );
52 }
53 
54 uno::Reference< excel::XCharacters > SAL_CALL
55 ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException)
56 {
57     ScDocShell* pDocShell = excel::getDocShell( m_xModel );
58     ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
59 
60     if ( !pDoc )
61         throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
62     uno::Reference< text::XSimpleText > xSimple( m_xTextRange, uno::UNO_QUERY_THROW );
63 
64     ScVbaPalette aPalette( pDoc->GetDocumentShell() );
65     return  new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length, sal_True );
66 }
67