fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / vba / vbacharacters.cxx
blob0a0ad615135e2fc9b03aa3b663f257ed5e2f5790
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"
24 using namespace ::ooo::vba;
25 using namespace ::com::sun::star;
27 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, bool Replace ) throw ( css::lang::IllegalArgumentException, css::uno::RuntimeException ) : ScVbaCharacters_BASE( xParent, xContext ), m_xSimpleText(xRange), m_aPalette( dPalette), nLength(-1), nStart(1), bReplace( Replace )
29 Start >>= nStart;
30 if ( nStart < 1 )
31 nStart = 1; // silently correct user error ( as ms )
32 nStart--; // OOo is 0 based
33 Length >>=nLength;
34 uno::Reference< text::XTextCursor > xTextCursor( m_xSimpleText->createTextCursor(), uno::UNO_QUERY_THROW );
35 xTextCursor->collapseToStart();
36 if ( nStart )
38 if ( ( nStart + 1 ) > m_xSimpleText->getString().getLength() )
39 //nStart = m_xSimpleText->getString().getLength();
40 xTextCursor->gotoEnd( false );
41 xTextCursor->goRight( nStart, false );
43 if ( nLength < 0 ) // expand to end
44 xTextCursor->gotoEnd( sal_True );
45 else
46 xTextCursor->goRight( nLength, sal_True );
47 m_xTextRange.set( xTextCursor, uno::UNO_QUERY_THROW );
51 OUString SAL_CALL
52 ScVbaCharacters::getCaption() throw (css::uno::RuntimeException, std::exception)
54 return m_xTextRange->getString();
56 void SAL_CALL
57 ScVbaCharacters::setCaption( const OUString& _caption ) throw (css::uno::RuntimeException, std::exception)
59 m_xTextRange->setString( _caption );
63 ::sal_Int32 SAL_CALL
64 ScVbaCharacters::getCount() throw (css::uno::RuntimeException, std::exception)
66 return getCaption().getLength();
69 OUString SAL_CALL
70 ScVbaCharacters::getText() throw (css::uno::RuntimeException, std::exception)
72 return getCaption();
74 void SAL_CALL
75 ScVbaCharacters::setText( const OUString& _text ) throw (css::uno::RuntimeException, std::exception)
77 setCaption( _text );
79 uno::Reference< excel::XFont > SAL_CALL
80 ScVbaCharacters::getFont() throw (css::uno::RuntimeException, std::exception)
82 uno::Reference< beans::XPropertySet > xProps( m_xTextRange, uno::UNO_QUERY_THROW );
83 return uno::Reference< excel::XFont >( new ScVbaFont( this, mxContext, m_aPalette, xProps ) );
85 void SAL_CALL
86 ScVbaCharacters::setFont( const uno::Reference< excel::XFont >& /*_font*/ ) throw (css::uno::RuntimeException, std::exception)
88 // #TODO #FIXME needs implementation, or can't be done?
89 throw uno::RuntimeException("Not Implemented" );
92 // Methods
93 void SAL_CALL
94 ScVbaCharacters::Insert( const OUString& rString ) throw (css::uno::RuntimeException, std::exception)
96 m_xSimpleText->insertString( m_xTextRange, rString, bReplace );
99 void SAL_CALL
100 ScVbaCharacters::Delete( ) throw (css::uno::RuntimeException, std::exception)
102 // #FIXME #TODO is this a bit suspect?, I wonder should the contents
103 // of the cell be deleted from the parent ( range )
104 m_xSimpleText->setString(OUString());
107 OUString
108 ScVbaCharacters::getServiceImplName()
110 return OUString("ScVbaCharacters");
113 uno::Sequence< OUString >
114 ScVbaCharacters::getServiceNames()
116 static uno::Sequence< OUString > aServiceNames;
117 if ( aServiceNames.getLength() == 0 )
119 aServiceNames.realloc( 1 );
120 aServiceNames[ 0 ] = "ooo.vba.excel.Characters";
122 return aServiceNames;
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */