1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir #include "vbarange.hxx" 24cdf0e10cSrcweir #include <vbahelper/vbahelper.hxx> 25cdf0e10cSrcweir #include <tools/diagnose_ex.h> 26cdf0e10cSrcweir #include "vbarangehelper.hxx" 27cdf0e10cSrcweir #include <ooo/vba/word/WdBreakType.hpp> 28cdf0e10cSrcweir #include <com/sun/star/style/BreakType.hpp> 29cdf0e10cSrcweir #include <com/sun/star/text/ControlCharacter.hpp> 30cdf0e10cSrcweir #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 31cdf0e10cSrcweir #include "wordvbahelper.hxx" 32cdf0e10cSrcweir #include "vbaparagraphformat.hxx" 33cdf0e10cSrcweir #include "vbastyle.hxx" 34cdf0e10cSrcweir #include "vbafont.hxx" 35cdf0e10cSrcweir #include "vbapalette.hxx" 36cdf0e10cSrcweir #include "vbapagesetup.hxx" 37cdf0e10cSrcweir 38cdf0e10cSrcweir using namespace ::ooo::vba; 39cdf0e10cSrcweir using namespace ::com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) 42cdf0e10cSrcweir { 43cdf0e10cSrcweir uno::Reference< text::XTextRange > xEnd; 44cdf0e10cSrcweir initialize( rStart, xEnd ); 45cdf0e10cSrcweir } 46cdf0e10cSrcweir 47cdf0e10cSrcweir SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir initialize( rStart, rEnd ); 50cdf0e10cSrcweir } 51cdf0e10cSrcweir 52cdf0e10cSrcweir SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, const uno::Reference< text::XText >& rText, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ),mxTextDocument( rTextDocument ), mxText( rText ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir initialize( rStart, rEnd ); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir SwVbaRange::~SwVbaRange() 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir void SwVbaRange::initialize( const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd ) throw (uno::RuntimeException) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir if( !mxText.is() ) 64cdf0e10cSrcweir { 65cdf0e10cSrcweir mxText = mxTextDocument->getText(); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir mxTextCursor = SwVbaRangeHelper::initCursor( rStart, mxText ); 69cdf0e10cSrcweir mxTextCursor->collapseToStart(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir if( rEnd.is() ) 72cdf0e10cSrcweir mxTextCursor->gotoRange( rEnd, sal_True ); 73cdf0e10cSrcweir else 74cdf0e10cSrcweir mxTextCursor->gotoEnd( sal_True ); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir uno::Reference< text::XTextRange > SAL_CALL 78cdf0e10cSrcweir SwVbaRange::getXTextRange() throw (uno::RuntimeException) 79cdf0e10cSrcweir { 80cdf0e10cSrcweir uno::Reference< text::XTextRange > xTextRange( mxTextCursor, uno::UNO_QUERY_THROW ); 81cdf0e10cSrcweir return xTextRange; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir #ifdef TOMORROW 84cdf0e10cSrcweir void SwVbaRange::setXTextRange( const uno::Reference< text::XTextRange >& xRange ) throw (uno::RuntimeException) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir mxTextCursor->gotoRange( xRange->getStart(), sal_False ); 87cdf0e10cSrcweir mxTextCursor->gotoRange( xRange->getEnd(), sal_True ); 88cdf0e10cSrcweir } 89cdf0e10cSrcweir #endif 90cdf0e10cSrcweir /** 91cdf0e10cSrcweir * The complexity in this method is because we need to workaround 92cdf0e10cSrcweir * an issue that the last paragraph in a document does not have a trailing CRLF. 93cdf0e10cSrcweir * @return 94cdf0e10cSrcweir */ 95cdf0e10cSrcweir rtl::OUString SAL_CALL 96cdf0e10cSrcweir SwVbaRange::getText() throw ( uno::RuntimeException ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir rtl::OUString aText = mxTextCursor->getString(); 99cdf0e10cSrcweir sal_Int32 nLen = aText.getLength(); 100cdf0e10cSrcweir 101cdf0e10cSrcweir // FIXME: should add a line separator if the range includes the last paragraph 102cdf0e10cSrcweir if( nLen == 0 ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir if( mxTextCursor->isCollapsed() ) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir mxTextCursor->goRight( 1, sal_True ); 107cdf0e10cSrcweir aText = mxTextCursor->getString(); 108cdf0e10cSrcweir mxTextCursor->collapseToStart(); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir else 111cdf0e10cSrcweir { 112cdf0e10cSrcweir uno::Reference< text::XTextRange > xStart = mxTextCursor->getStart(); 113cdf0e10cSrcweir uno::Reference< text::XTextRange > xEnd = mxTextCursor->getEnd(); 114cdf0e10cSrcweir mxTextCursor->collapseToEnd(); 115cdf0e10cSrcweir mxTextCursor->goRight( 1, sal_True ); 116cdf0e10cSrcweir mxTextCursor->gotoRange( xStart, sal_False ); 117cdf0e10cSrcweir mxTextCursor->gotoRange( xEnd, sal_True ); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir } 120cdf0e10cSrcweir 121cdf0e10cSrcweir return aText; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir void SAL_CALL 125cdf0e10cSrcweir SwVbaRange::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException ) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir if( rText.indexOf( '\n' ) != -1 ) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir mxTextCursor->setString( rtl::OUString() ); 130cdf0e10cSrcweir // process CR in strings 131cdf0e10cSrcweir uno::Reference< text::XTextRange > xRange( mxTextCursor, uno::UNO_QUERY_THROW ); 132cdf0e10cSrcweir SwVbaRangeHelper::insertString( xRange, mxText, rText, sal_True ); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir else 135cdf0e10cSrcweir { 136cdf0e10cSrcweir mxTextCursor->setString( rText ); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir // FIXME: test is not pass 141cdf0e10cSrcweir void SAL_CALL SwVbaRange::InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // default type is wdPageBreak; 144cdf0e10cSrcweir sal_Int32 nBreakType = word::WdBreakType::wdPageBreak; 145cdf0e10cSrcweir if( _breakType.hasValue() ) 146cdf0e10cSrcweir _breakType >>= nBreakType; 147cdf0e10cSrcweir 148cdf0e10cSrcweir style::BreakType eBreakType = style::BreakType_NONE; 149cdf0e10cSrcweir switch( nBreakType ) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir case word::WdBreakType::wdPageBreak: 152cdf0e10cSrcweir eBreakType = style::BreakType_PAGE_BEFORE; 153cdf0e10cSrcweir break; 154cdf0e10cSrcweir case word::WdBreakType::wdColumnBreak: 155cdf0e10cSrcweir eBreakType = style::BreakType_COLUMN_AFTER; 156cdf0e10cSrcweir break; 157cdf0e10cSrcweir case word::WdBreakType::wdLineBreak: 158cdf0e10cSrcweir case word::WdBreakType::wdLineBreakClearLeft: 159cdf0e10cSrcweir case word::WdBreakType::wdLineBreakClearRight: 160cdf0e10cSrcweir case word::WdBreakType::wdSectionBreakContinuous: 161cdf0e10cSrcweir case word::WdBreakType::wdSectionBreakEvenPage: 162cdf0e10cSrcweir case word::WdBreakType::wdSectionBreakNextPage: 163cdf0e10cSrcweir case word::WdBreakType::wdSectionBreakOddPage: 164cdf0e10cSrcweir case word::WdBreakType::wdTextWrappingBreak: 165cdf0e10cSrcweir DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); 166cdf0e10cSrcweir break; 167cdf0e10cSrcweir default: 168cdf0e10cSrcweir DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir if( eBreakType != style::BreakType_NONE ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir if( !mxTextCursor->isCollapsed() ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir mxTextCursor->setString( rtl::OUString() ); 176cdf0e10cSrcweir mxTextCursor->collapseToStart(); 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW ); 180cdf0e10cSrcweir xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ), uno::makeAny( eBreakType ) ); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir void SAL_CALL 185cdf0e10cSrcweir SwVbaRange::Select() throw ( uno::RuntimeException ) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); 188cdf0e10cSrcweir uno::Reference< text::XTextViewCursor > xTextViewCursor = word::getXTextViewCursor( xModel ); 189cdf0e10cSrcweir xTextViewCursor->gotoRange( mxTextCursor->getStart(), sal_False ); 190cdf0e10cSrcweir xTextViewCursor->gotoRange( mxTextCursor->getEnd(), sal_True ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir void SAL_CALL 194cdf0e10cSrcweir SwVbaRange::InsertParagraph() throw ( uno::RuntimeException ) 195cdf0e10cSrcweir { 196cdf0e10cSrcweir mxTextCursor->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); 197cdf0e10cSrcweir InsertParagraphBefore(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir void SAL_CALL 201cdf0e10cSrcweir SwVbaRange::InsertParagraphBefore() throw ( uno::RuntimeException ) 202cdf0e10cSrcweir { 203cdf0e10cSrcweir uno::Reference< text::XTextRange > xTextRange = mxTextCursor->getStart(); 204cdf0e10cSrcweir mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_True ); 205cdf0e10cSrcweir mxTextCursor->gotoRange( xTextRange, sal_True ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir void SAL_CALL 209cdf0e10cSrcweir SwVbaRange::InsertParagraphAfter() throw ( uno::RuntimeException ) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir uno::Reference< text::XTextRange > xTextRange = mxTextCursor->getEnd(); 212cdf0e10cSrcweir mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_True ); 213cdf0e10cSrcweir } 214cdf0e10cSrcweir 215cdf0e10cSrcweir uno::Reference< word::XParagraphFormat > SAL_CALL 216cdf0e10cSrcweir SwVbaRange::getParagraphFormat() throw ( uno::RuntimeException ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); 219cdf0e10cSrcweir return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, mxTextDocument, xParaProps ) ); 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir void SAL_CALL 223cdf0e10cSrcweir SwVbaRange::setParagraphFormat( const uno::Reference< word::XParagraphFormat >& /*rParagraphFormat*/ ) throw ( uno::RuntimeException ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir uno::Reference< word::XStyle > SAL_CALL 229cdf0e10cSrcweir SwVbaRange::getStyle() throw ( uno::RuntimeException ) 230cdf0e10cSrcweir { 231cdf0e10cSrcweir rtl::OUString aStyleName; 232cdf0e10cSrcweir rtl::OUString aStyleType; 233cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW ); 234cdf0e10cSrcweir if( ( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharStyleName") ) ) >>= aStyleName ) && aStyleName.getLength() ) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharacterStyles") ); 237cdf0e10cSrcweir } 238cdf0e10cSrcweir else if( ( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ) ) >>= aStyleName ) && aStyleName.getLength() ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir if( aStyleType.getLength() == 0 ) 243cdf0e10cSrcweir { 244cdf0e10cSrcweir DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() ); 245cdf0e10cSrcweir } 246cdf0e10cSrcweir uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW); 247cdf0e10cSrcweir uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW ); 248cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW ); 249cdf0e10cSrcweir return uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xStyleProps ) ); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir void SAL_CALL 253cdf0e10cSrcweir SwVbaRange::setStyle( const uno::Reference< word::XStyle >& rStyle ) throw ( uno::RuntimeException ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); 256cdf0e10cSrcweir SwVbaStyle::setStyle( xParaProps, rStyle ); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir uno::Reference< word::XFont > SAL_CALL 260cdf0e10cSrcweir SwVbaRange::getFont() throw ( uno::RuntimeException ) 261cdf0e10cSrcweir { 262cdf0e10cSrcweir VbaPalette aColors; 263cdf0e10cSrcweir return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), uno::Reference< beans::XPropertySet >( getXTextRange(), uno::UNO_QUERY_THROW ) ); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir ::sal_Int32 SAL_CALL SwVbaRange::getLanguageID() throw (uno::RuntimeException) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); 269cdf0e10cSrcweir return SwVbaStyle::getLanguageID( xParaProps ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir void SAL_CALL SwVbaRange::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); 275cdf0e10cSrcweir SwVbaStyle::setLanguageID( xParaProps, _languageid ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir uno::Any SAL_CALL 279cdf0e10cSrcweir SwVbaRange::PageSetup( ) throw (uno::RuntimeException) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); 282cdf0e10cSrcweir uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); 283cdf0e10cSrcweir rtl::OUString aPageStyleName; 284cdf0e10cSrcweir xParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName; 285cdf0e10cSrcweir uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW ); 286cdf0e10cSrcweir uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_QUERY_THROW ); 287cdf0e10cSrcweir uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles") ) ), uno::UNO_QUERY_THROW ); 288cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPageProps( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW ); 289cdf0e10cSrcweir return uno::makeAny( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, xModel, xPageProps ) ) ); 290cdf0e10cSrcweir } 291cdf0e10cSrcweir 292cdf0e10cSrcweir ::sal_Int32 SAL_CALL SwVbaRange::getStart() throw (uno::RuntimeException) 293cdf0e10cSrcweir { 294cdf0e10cSrcweir uno::Reference< text::XText > xText = mxTextDocument->getText(); 295cdf0e10cSrcweir return SwVbaRangeHelper::getPosition( xText, mxTextCursor->getStart() ); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir 298cdf0e10cSrcweir void SAL_CALL SwVbaRange::setStart( ::sal_Int32 _start ) throw (uno::RuntimeException) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir uno::Reference< text::XText > xText = mxTextDocument->getText(); 301cdf0e10cSrcweir uno::Reference< text::XTextRange > xStart = SwVbaRangeHelper::getRangeByPosition( xText, _start ); 302cdf0e10cSrcweir uno::Reference< text::XTextRange > xEnd = mxTextCursor->getEnd(); 303cdf0e10cSrcweir 304cdf0e10cSrcweir mxTextCursor->gotoRange( xStart, sal_False ); 305cdf0e10cSrcweir mxTextCursor->gotoRange( xEnd, sal_True ); 306cdf0e10cSrcweir } 307cdf0e10cSrcweir 308cdf0e10cSrcweir ::sal_Int32 SAL_CALL SwVbaRange::getEnd() throw (uno::RuntimeException) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir uno::Reference< text::XText > xText = mxTextDocument->getText(); 311cdf0e10cSrcweir return SwVbaRangeHelper::getPosition( xText, mxTextCursor->getEnd() ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir void SAL_CALL SwVbaRange::setEnd( ::sal_Int32 _end ) throw (uno::RuntimeException) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir uno::Reference< text::XText > xText = mxTextDocument->getText(); 317cdf0e10cSrcweir uno::Reference< text::XTextRange > xEnd = SwVbaRangeHelper::getRangeByPosition( xText, _end ); 318cdf0e10cSrcweir 319cdf0e10cSrcweir mxTextCursor->collapseToStart(); 320cdf0e10cSrcweir mxTextCursor->gotoRange( xEnd, sal_True ); 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir rtl::OUString& 324cdf0e10cSrcweir SwVbaRange::getServiceImplName() 325cdf0e10cSrcweir { 326cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRange") ); 327cdf0e10cSrcweir return sImplName; 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir uno::Sequence< rtl::OUString > 331cdf0e10cSrcweir SwVbaRange::getServiceNames() 332cdf0e10cSrcweir { 333cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 334cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir aServiceNames.realloc( 1 ); 337cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Range" ) ); 338cdf0e10cSrcweir } 339cdf0e10cSrcweir return aServiceNames; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir 342