From f3234f4f14702da71528561418f07ee6670a8c2a Mon Sep 17 00:00:00 2001 From: Hannah Meeks Date: Sat, 30 Jul 2022 11:11:06 +0100 Subject: VBA Add Padding properties to XTable Change-Id: I021ad15b81ce55c4f9e9e9b515be1ddaaca8d07d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137630 Tested-by: Jenkins Reviewed-by: Michael Meeks --- oovbaapi/ooo/vba/word/XTable.idl | 5 +++ sw/qa/core/macros-test.cxx | 11 +++--- sw/source/ui/vba/vbatable.cxx | 85 +++++++++++++++++++++++++++++++++++++++- sw/source/ui/vba/vbatable.hxx | 10 ++++- sw/source/ui/vba/vbatables.cxx | 4 +- 5 files changed, 107 insertions(+), 8 deletions(-) diff --git a/oovbaapi/ooo/vba/word/XTable.idl b/oovbaapi/ooo/vba/word/XTable.idl index 0ce702c7e613..683e859e4040 100644 --- a/oovbaapi/ooo/vba/word/XTable.idl +++ b/oovbaapi/ooo/vba/word/XTable.idl @@ -54,6 +54,11 @@ interface XTable any Rows([in] any aIndex ); any Columns([in] any aIndex ); + + [attribute] double BottomPadding; + [attribute] double LeftPadding; + [attribute] double RightPadding; + [attribute] double TopPadding; }; }; }; }; diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx index 02d097a2a8bb..49d5b6ecf586 100644 --- a/sw/qa/core/macros-test.cxx +++ b/sw/qa/core/macros-test.cxx @@ -113,17 +113,18 @@ void SwMacrosTest::testVba() { OUString("testDocumentRange.docm"), OUString("vnd.sun.Star.script:Project.Module1.testAll?language=Basic&location=document") - }, + } /*{ OUString("testSelectionFind.docm"), OUString("vnd.sun.Star.script:Project.Module1.testAll?language=Basic&location=document") - },*/ + }, { //current working tests here! + OUString("testFontColor.docm"), OUString("vnd.sun.Star.script:Project.ThisDocument.testAll?language=Basic&location=document") } - /* TODO - make these pass in Writer + // TODO - make these pass in Writer { OUString("testSentences.docm"), OUString("vnd.sun.Star.script:Project.ThisDocument.TestAll?language=Basic&location=document") @@ -138,8 +139,8 @@ void SwMacrosTest::testVba() }, { OUString("testTables.docm"), - OUString("vnd.sun.Star.script:Project.ThisDocument.TestAll?language=Basic&location=document") - },*/ + OUString("vnd.sun.Star.script:Project.ThisDocument.RightPadding?language=Basic&location=document") + }*/ }; for ( size_t i=0; i #include #include +#include +#include #include "vbaborders.hxx" #include "vbapalette.hxx" #include "vbarows.hxx" #include "vbacolumns.hxx" +#include "vbaapplication.hxx" + +#include + +#include using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -70,7 +77,7 @@ SwVbaTable::Delete( ) } OUString SAL_CALL -SwVbaTable::getName() +SwVbaTable::getName( ) { uno::Reference< container::XNamed > xNamed( mxTextTable, uno::UNO_QUERY_THROW ); return xNamed->getName(); @@ -87,6 +94,82 @@ SwVbaTable::Borders( const uno::Any& index ) return uno::Any( xCol ); } +double SAL_CALL +SwVbaTable::getBottomPadding() +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + xPropertySet->getPropertyValue("TableBorderDistances") >>= aTableBorderDistances; + return convertMm100ToPoint(aTableBorderDistances.BottomDistance); +} + +void SAL_CALL +SwVbaTable::setBottomPadding( double fValue ) +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + aTableBorderDistances.IsBottomDistanceValid = true; + aTableBorderDistances.BottomDistance = convertPointToMm100(fValue); + xPropertySet->setPropertyValue( "TableBorderDistances", uno::Any( aTableBorderDistances ) ); +} + +double SAL_CALL +SwVbaTable::getLeftPadding() +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + xPropertySet->getPropertyValue("TableBorderDistances") >>= aTableBorderDistances; + return convertMm100ToPoint(aTableBorderDistances.LeftDistance); +} + +void SAL_CALL +SwVbaTable::setLeftPadding( double fValue ) +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + aTableBorderDistances.IsLeftDistanceValid = true; + aTableBorderDistances.LeftDistance = convertPointToMm100(fValue); + xPropertySet->setPropertyValue( "TableBorderDistances", uno::Any( aTableBorderDistances ) ); +} + +double SAL_CALL +SwVbaTable::getRightPadding() +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + xPropertySet->getPropertyValue("TableBorderDistances") >>= aTableBorderDistances; + return convertMm100ToPoint(aTableBorderDistances.RightDistance); +} + +void SAL_CALL +SwVbaTable::setRightPadding( double fValue ) +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + aTableBorderDistances.IsRightDistanceValid = true; + aTableBorderDistances.RightDistance = convertPointToMm100(fValue); + xPropertySet->setPropertyValue( "TableBorderDistances", uno::Any( aTableBorderDistances ) ); +} + +double SAL_CALL +SwVbaTable::getTopPadding() +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + xPropertySet->getPropertyValue("TableBorderDistances") >>= aTableBorderDistances; + return convertMm100ToPoint(aTableBorderDistances.TopDistance); +} + +void SAL_CALL +SwVbaTable::setTopPadding( double fValue ) +{ + uno::Reference< beans::XPropertySet > xPropertySet( mxTextTable, uno::UNO_QUERY_THROW); + table::TableBorderDistances aTableBorderDistances; + aTableBorderDistances.IsTopDistanceValid = true; + aTableBorderDistances.TopDistance = convertPointToMm100(fValue); + xPropertySet->setPropertyValue( "TableBorderDistances", uno::Any( aTableBorderDistances ) ); +} + uno::Any SAL_CALL SwVbaTable::Rows( const uno::Any& index ) { diff --git a/sw/source/ui/vba/vbatable.hxx b/sw/source/ui/vba/vbatable.hxx index 37bdd332f810..0d48cd2b3b50 100644 --- a/sw/source/ui/vba/vbatable.hxx +++ b/sw/source/ui/vba/vbatable.hxx @@ -37,8 +37,16 @@ public: virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL Range( ) override; virtual void SAL_CALL Select( ) override; virtual void SAL_CALL Delete( ) override; - virtual OUString SAL_CALL getName( ) override; + virtual OUString SAL_CALL getName( ) override; virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& aIndex ) override; + virtual double SAL_CALL getBottomPadding( ) override; + virtual void SAL_CALL setBottomPadding( double fValue ) override; + virtual double SAL_CALL getLeftPadding( ) override; + virtual void SAL_CALL setLeftPadding( double fValue ) override; + virtual double SAL_CALL getRightPadding( ) override; + virtual void SAL_CALL setRightPadding( double fValue ) override; + virtual double SAL_CALL getTopPadding( ) override; + virtual void SAL_CALL setTopPadding( double fValue ) override; virtual css::uno::Any SAL_CALL Rows( const css::uno::Any& aIndex ) override; virtual css::uno::Any SAL_CALL Columns( const css::uno::Any& aIndex ) override; diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx index 35b6f6173664..75e23a65dddf 100644 --- a/sw/source/ui/vba/vbatables.cxx +++ b/sw/source/ui/vba/vbatables.cxx @@ -54,7 +54,9 @@ static bool lcl_isInHeaderFooter( const uno::Reference< text::XTextTable >& xTab { uno::Reference< text::XTextContent > xTextContent( xTable, uno::UNO_QUERY_THROW ); uno::Reference< text::XText > xText = xTextContent->getAnchor()->getText(); - uno::Reference< lang::XServiceInfo > xServiceInfo( xText, uno::UNO_QUERY_THROW ); + uno::Reference< lang::XServiceInfo > xServiceInfo( xText, uno::UNO_QUERY ); + if ( !xServiceInfo ) + return false; OUString aImplName = xServiceInfo->getImplementationName(); return aImplName == "SwXHeadFootText"; } -- cgit v1.2.3