GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sc / source / ui / vba / vbacharacters.cxx
blobb73818b9516bf28d62dad9b0fdc9bc759c4f02ac
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "vbacharacters.hxx"
21 #include "vbaglobals.hxx"
22 #include "vbafont.hxx"
25 using namespace ::ooo::vba;
26 using namespace ::com::sun::star;
28 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 )
30 Start >>= nStart;
31 if ( nStart < 1 )
32 nStart = 1; // silently correct user error ( as ms )
33 nStart--; // OOo is 0 based
34 Length >>=nLength;
35 uno::Reference< text::XTextCursor > xTextCursor( m_xSimpleText->createTextCursor(), uno::UNO_QUERY_THROW );
36 xTextCursor->collapseToStart();
37 if ( nStart )
39 if ( ( nStart + 1 ) > m_xSimpleText->getString().getLength() )
40 //nStart = m_xSimpleText->getString().getLength();
41 xTextCursor->gotoEnd( false );
42 xTextCursor->goRight( nStart, false );
44 if ( nLength < 0 ) // expand to end
45 xTextCursor->gotoEnd( sal_True );
46 else
47 xTextCursor->goRight( nLength, sal_True );
48 m_xTextRange.set( xTextCursor, uno::UNO_QUERY_THROW );
52 OUString SAL_CALL
53 ScVbaCharacters::getCaption() throw (css::uno::RuntimeException)
55 return m_xTextRange->getString();
57 void SAL_CALL
58 ScVbaCharacters::setCaption( const OUString& _caption ) throw (css::uno::RuntimeException)
60 m_xTextRange->setString( _caption );
64 ::sal_Int32 SAL_CALL
65 ScVbaCharacters::getCount() throw (css::uno::RuntimeException)
67 return getCaption().getLength();
70 OUString SAL_CALL
71 ScVbaCharacters::getText() throw (css::uno::RuntimeException)
73 return getCaption();
75 void SAL_CALL
76 ScVbaCharacters::setText( const OUString& _text ) throw (css::uno::RuntimeException)
78 setCaption( _text );
80 uno::Reference< excel::XFont > SAL_CALL
81 ScVbaCharacters::getFont() throw (css::uno::RuntimeException)
83 uno::Reference< beans::XPropertySet > xProps( m_xTextRange, uno::UNO_QUERY_THROW );
84 return uno::Reference< excel::XFont >( new ScVbaFont( this, mxContext, m_aPalette, xProps ) );
86 void SAL_CALL
87 ScVbaCharacters::setFont( const uno::Reference< excel::XFont >& /*_font*/ ) throw (css::uno::RuntimeException)
89 // #TODO #FIXME needs implementation, or can't be done?
90 throw uno::RuntimeException("Not Implemented", uno::Reference< XInterface >() );
94 // Methods
95 void SAL_CALL
96 ScVbaCharacters::Insert( const OUString& rString ) throw (css::uno::RuntimeException)
98 m_xSimpleText->insertString( m_xTextRange, rString, bReplace );
101 void SAL_CALL
102 ScVbaCharacters::Delete( ) throw (css::uno::RuntimeException)
104 // #FIXME #TODO is this a bit suspect?, I wonder should the contents
105 // of the cell be deleted from the parent ( range )
106 m_xSimpleText->setString(OUString());
110 OUString
111 ScVbaCharacters::getServiceImplName()
113 return OUString("ScVbaCharacters");
116 uno::Sequence< OUString >
117 ScVbaCharacters::getServiceNames()
119 static uno::Sequence< OUString > aServiceNames;
120 if ( aServiceNames.getLength() == 0 )
122 aServiceNames.realloc( 1 );
123 aServiceNames[ 0 ] = "ooo.vba.excel.Characters";
125 return aServiceNames;
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */