diff options
Diffstat (limited to 'sw/source/ui/vba/vbaview.cxx')
-rw-r--r-- | sw/source/ui/vba/vbaview.cxx | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/sw/source/ui/vba/vbaview.cxx b/sw/source/ui/vba/vbaview.cxx index 9cb8bf1490ce..e17fd7a0d766 100644 --- a/sw/source/ui/vba/vbaview.cxx +++ b/sw/source/ui/vba/vbaview.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -86,32 +87,32 @@ SwVbaView::getSeekView() throw (css::uno::RuntimeException) } uno::Reference< lang::XServiceInfo > xServiceInfo( xCurrentText, uno::UNO_QUERY_THROW ); rtl::OUString aImplName = xServiceInfo->getImplementationName(); - if( aImplName.equalsAscii("SwXBodyText") ) + if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXBodyText")) ) { return word::WdSeekView::wdSeekMainDocument; } - else if( aImplName.equalsAscii("SwXHeadFootText") ) + else if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXHeadFootText")) ) { - if( HeaderFooterHelper::isHeader( mxModel, xCurrentText ) ) + if( HeaderFooterHelper::isHeader( mxModel ) ) { - if( HeaderFooterHelper::isFirstPageHeader( mxModel, xCurrentText ) ) + if( HeaderFooterHelper::isFirstPageHeader( mxModel ) ) return word::WdSeekView::wdSeekFirstPageHeader; - else if( HeaderFooterHelper::isEvenPagesHeader( mxModel, xCurrentText ) ) + else if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) ) return word::WdSeekView::wdSeekEvenPagesHeader; else return word::WdSeekView::wdSeekPrimaryHeader; } else { - if( HeaderFooterHelper::isFirstPageFooter( mxModel, xCurrentText ) ) + if( HeaderFooterHelper::isFirstPageFooter( mxModel ) ) return word::WdSeekView::wdSeekFirstPageFooter; - else if( HeaderFooterHelper::isEvenPagesFooter( mxModel, xCurrentText ) ) + else if( HeaderFooterHelper::isEvenPagesFooter( mxModel ) ) return word::WdSeekView::wdSeekEvenPagesFooter; else return word::WdSeekView::wdSeekPrimaryFooter; } } - else if( aImplName.equalsAscii("SwXFootnote") ) + else if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXFootnote")) ) { if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote") ) ) ) return word::WdSeekView::wdSeekEndnotes; @@ -129,9 +130,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeExceptio // document, so we can jump back to this position, if the macro sets // the ViewMode back to wdSeekMainDocument - // if( _seekview == getSeekView() ) - // return; - + word::gotoSelectedObjectAnchor( mxModel ); switch( _seekview ) { case word::WdSeekView::wdSeekFirstPageFooter: @@ -181,7 +180,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeExceptio { uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); uno::Reference< text::XText > xText = xTextDocument->getText(); - mxViewCursor->gotoRange( getFirstObjectPosition( xText ), sal_False ); + mxViewCursor->gotoRange( word::getFirstObjectPosition( xText ), sal_False ); break; } } @@ -314,7 +313,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType ) uno::Reference< beans::XPropertySet > xCursorProps( mxViewCursor, uno::UNO_QUERY_THROW ); rtl::OUString aPageStyleName; xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName; - if( aPageStyleName.equalsAscii("First Page") ) + if( aPageStyleName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("First Page")) ) { // go to the beginning of where the next style is used sal_Bool hasNextPage = sal_False; @@ -376,28 +375,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType ) { DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() ); } - uno::Reference< text::XTextRange > xTextRange = getFirstObjectPosition( xText ); - return xTextRange; -} - -uno::Reference< text::XTextRange > SwVbaView::getFirstObjectPosition( const uno::Reference< text::XText >& xText ) throw (uno::RuntimeException) -{ - // if the first object is table, get the position of first cell - uno::Reference< text::XTextRange > xTextRange; - uno::Reference< container::XEnumerationAccess > xParaAccess( xText, uno::UNO_QUERY_THROW ); - uno::Reference< container::XEnumeration> xParaEnum = xParaAccess->createEnumeration(); - if( xParaEnum->hasMoreElements() ) - { - uno::Reference< lang::XServiceInfo > xServiceInfo( xParaEnum->nextElement(), uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable") ) ) ) - { - uno::Reference< table::XCellRange > xCellRange( xServiceInfo, uno::UNO_QUERY_THROW ); - uno::Reference< text::XText> xFirstCellText( xCellRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW ); - xTextRange = xFirstCellText->getStart(); - } - } - if( !xTextRange.is() ) - xTextRange = xText->getStart(); + uno::Reference< text::XTextRange > xTextRange = word::getFirstObjectPosition( xText ); return xTextRange; } @@ -420,3 +398,4 @@ SwVbaView::getServiceNames() return aServiceNames; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |