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