Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include "vbacharacters.hxx"
29 : :
30 : : #include "vbaglobals.hxx"
31 : : #include "vbafont.hxx"
32 : :
33 : :
34 : : using namespace ::ooo::vba;
35 : : using namespace ::com::sun::star;
36 : :
37 : 0 : ScVbaCharacters::ScVbaCharacters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, const uno::Reference< text::XSimpleText>& xRange,const css::uno::Any& Start, const css::uno::Any& Length, sal_Bool Replace ) throw ( css::lang::IllegalArgumentException ) : ScVbaCharacters_BASE( xParent, xContext ), m_xSimpleText(xRange), m_aPalette( dPalette), nLength(-1), nStart(1), bReplace( Replace )
38 : : {
39 : 0 : Start >>= nStart;
40 [ # # ]: 0 : if ( nStart < 1 )
41 : 0 : nStart = 1; // silently correct user error ( as ms )
42 : 0 : nStart--; // OOo is 0 based
43 : 0 : Length >>=nLength;
44 [ # # ][ # # ]: 0 : uno::Reference< text::XTextCursor > xTextCursor( m_xSimpleText->createTextCursor(), uno::UNO_QUERY_THROW );
[ # # ]
45 [ # # ][ # # ]: 0 : xTextCursor->collapseToStart();
46 [ # # ]: 0 : if ( nStart )
47 : : {
48 [ # # ][ # # ]: 0 : if ( ( nStart + 1 ) > m_xSimpleText->getString().getLength() )
[ # # ]
49 : : //nStart = m_xSimpleText->getString().getLength();
50 [ # # ][ # # ]: 0 : xTextCursor->gotoEnd( false );
51 [ # # ][ # # ]: 0 : xTextCursor->goRight( nStart, false );
52 : : }
53 [ # # ]: 0 : if ( nLength < 0 ) // expand to end
54 [ # # ][ # # ]: 0 : xTextCursor->gotoEnd( sal_True );
55 : : else
56 [ # # ][ # # ]: 0 : xTextCursor->goRight( nLength, sal_True );
57 [ # # ]: 0 : m_xTextRange.set( xTextCursor, uno::UNO_QUERY_THROW );
58 : :
59 : 0 : }
60 : :
61 : : ::rtl::OUString SAL_CALL
62 : 0 : ScVbaCharacters::getCaption() throw (css::uno::RuntimeException)
63 : : {
64 : 0 : return m_xTextRange->getString();
65 : : }
66 : : void SAL_CALL
67 : 0 : ScVbaCharacters::setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException)
68 : : {
69 : 0 : m_xTextRange->setString( _caption );
70 : :
71 : 0 : }
72 : :
73 : : ::sal_Int32 SAL_CALL
74 : 0 : ScVbaCharacters::getCount() throw (css::uno::RuntimeException)
75 : : {
76 : 0 : return getCaption().getLength();
77 : : }
78 : :
79 : : ::rtl::OUString SAL_CALL
80 : 0 : ScVbaCharacters::getText() throw (css::uno::RuntimeException)
81 : : {
82 : 0 : return getCaption();
83 : : }
84 : : void SAL_CALL
85 : 0 : ScVbaCharacters::setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException)
86 : : {
87 : 0 : setCaption( _text );
88 : 0 : }
89 : : uno::Reference< excel::XFont > SAL_CALL
90 : 0 : ScVbaCharacters::getFont() throw (css::uno::RuntimeException)
91 : : {
92 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( m_xTextRange, uno::UNO_QUERY_THROW );
93 [ # # ][ # # ]: 0 : return uno::Reference< excel::XFont >( new ScVbaFont( this, mxContext, m_aPalette, xProps ) );
[ # # ][ # # ]
94 : : }
95 : : void SAL_CALL
96 : 0 : ScVbaCharacters::setFont( const uno::Reference< excel::XFont >& /*_font*/ ) throw (css::uno::RuntimeException)
97 : : {
98 : : // #TODO #FIXME needs implementation, or can't be done?
99 [ # # ][ # # ]: 0 : throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Not Implemented") ), uno::Reference< XInterface >() );
100 : : }
101 : :
102 : :
103 : : // Methods
104 : : void SAL_CALL
105 : 0 : ScVbaCharacters::Insert( const ::rtl::OUString& String ) throw (css::uno::RuntimeException)
106 : : {
107 : 0 : m_xSimpleText->insertString( m_xTextRange, String, bReplace );
108 : 0 : }
109 : :
110 : : void SAL_CALL
111 : 0 : ScVbaCharacters::Delete( ) throw (css::uno::RuntimeException)
112 : : {
113 : : // #FIXME #TODO is this a bit suspect?, I wonder should the contents
114 : : // of the cell be deleted from the parent ( range )
115 [ # # ]: 0 : m_xSimpleText->setString(rtl::OUString());
116 : 0 : }
117 : :
118 : :
119 : : rtl::OUString
120 : 0 : ScVbaCharacters::getServiceImplName()
121 : : {
122 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaCharacters"));
123 : : }
124 : :
125 : : uno::Sequence< rtl::OUString >
126 : 0 : ScVbaCharacters::getServiceNames()
127 : : {
128 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
129 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
130 : : {
131 : 0 : aServiceNames.realloc( 1 );
132 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Characters" ) );
133 : : }
134 : 0 : return aServiceNames;
135 : : }
136 : :
137 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|