21#include <com/sun/star/beans/XPropertySet.hpp>
22#include <com/sun/star/text/HoriOrientation.hpp>
23#include <com/sun/star/table/XCellRange.hpp>
24#include <ooo/vba/word/WdRowAlignment.hpp>
25#include <ooo/vba/word/WdConstants.hpp>
26#include <ooo/vba/word/WdRulerStyle.hpp>
39 uno::WeakReference< XHelperInterface >
mxParent;
40 uno::Reference< uno::XComponentContext >
mxContext;
41 uno::Reference< text::XTextTable > mxTextTable;
42 uno::Reference< container::XIndexAccess > mxIndexAccess;
46 RowsEnumWrapper(
const uno::Reference< XHelperInterface >& xParent, uno::Reference< uno::XComponentContext > xContext, uno::Reference< text::XTextTable > xTextTable ) :
mxParent( xParent ),
mxContext(
std::move( xContext )), mxTextTable(
std::move( xTextTable )), m_nIndex( 0 )
48 mxIndexAccess = mxTextTable->getRows();
50 virtual sal_Bool SAL_CALL hasMoreElements( )
override
52 return ( m_nIndex < mxIndexAccess->getCount() );
55 virtual uno::Any SAL_CALL nextElement( )
override
57 if( m_nIndex < mxIndexAccess->getCount() )
59 return uno::Any( uno::Reference< word::XRow > (
new SwVbaRow( mxParent, mxContext, mxTextTable, m_nIndex++ ) ) );
61 throw container::NoSuchElementException();
67SwVbaRows::SwVbaRows(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext, uno::Reference< text::XTextTable > xTextTable,
const uno::Reference< table::XTableRows >& xTableRows ) :
SwVbaRows_BASE( xParent, xContext,
uno::
Reference< container::XIndexAccess >( xTableRows,
uno::UNO_QUERY_THROW ) ), mxTextTable(
std::move( xTextTable )), mxTableRows( xTableRows )
70 mnEndRowIndex = m_xIndexAccess->
getCount() - 1;
73SwVbaRows::SwVbaRows(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext, uno::Reference< text::XTextTable > xTextTable,
const uno::Reference< table::XTableRows >& xTableRows, sal_Int32 nStarIndex, sal_Int32 nEndIndex ) :
SwVbaRows_BASE( xParent, xContext,
uno::
Reference< container::XIndexAccess >( xTableRows,
uno::UNO_QUERY_THROW ) ), mxTextTable(
std::move( xTextTable )), mxTableRows( xTableRows ), mnStartRowIndex( nStarIndex ), mnEndRowIndex( nEndIndex )
75 if( mnEndRowIndex < mnStartRowIndex )
76 throw uno::RuntimeException();
86 sal_Int16 nAlignment = text::HoriOrientation::LEFT;
87 uno::Reference< beans::XPropertySet > xTableProps(
mxTextTable, uno::UNO_QUERY_THROW );
88 xTableProps->getPropertyValue(
"HoriOrient") >>= nAlignment;
92 case text::HoriOrientation::CENTER:
94 nRet = word::WdRowAlignment::wdAlignRowCenter;
97 case text::HoriOrientation::RIGHT:
99 nRet = word::WdRowAlignment::wdAlignRowRight;
104 nRet = word::WdRowAlignment::wdAlignRowLeft;
112 sal_Int16 nAlignment = text::HoriOrientation::LEFT;
115 case word::WdRowAlignment::wdAlignRowCenter:
117 nAlignment = text::HoriOrientation::CENTER;
120 case word::WdRowAlignment::wdAlignRowRight:
122 nAlignment = text::HoriOrientation::RIGHT;
127 nAlignment = text::HoriOrientation::LEFT;
130 uno::Reference< beans::XPropertySet > xTableProps(
mxTextTable, uno::UNO_QUERY_THROW );
131 xTableProps->setPropertyValue(
"HoriOrient",
uno::Any( nAlignment ) );
136 bool bAllowBreak =
false;
137 uno::Reference< container::XIndexAccess > xRowsAccess(
mxTableRows, uno::UNO_QUERY_THROW );
140 uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex(
index ), uno::UNO_QUERY_THROW );
142 xRowProps->getPropertyValue(
"IsSplitAllowed") >>= bSplit;
145 bAllowBreak = bSplit;
147 if( bSplit != bAllowBreak )
149 return uno::Any( sal_Int32(word::WdConstants::wdUndefined) );
157 bool bAllowBreak =
false;
158 _allowbreakacrosspages >>= bAllowBreak;
159 uno::Reference< container::XIndexAccess > xRowsAccess(
mxTableRows, uno::UNO_QUERY_THROW );
162 uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex(
index ), uno::UNO_QUERY_THROW );
163 xRowProps->setPropertyValue(
"IsSplitAllowed",
uno::Any( bAllowBreak ) );
170 uno::Reference< table::XCellRange > xCellRange(
mxTextTable, uno::UNO_QUERY_THROW );
171 uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( 0,
mnStartRowIndex ), uno::UNO_QUERY_THROW );
172 sal_Int32 nLeftBorderDistance = 0;
173 sal_Int32 nRightBorderDistance = 0;
174 xCellProps->getPropertyValue(
"LeftBorderDistance") >>= nLeftBorderDistance;
175 xCellProps->getPropertyValue(
"RightBorderDistance") >>= nRightBorderDistance;
176 return static_cast< float >( Millimeter::getInPoints( nLeftBorderDistance + nRightBorderDistance ) );
181 sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _spacebetweencolumns ) / 2;
182 uno::Reference< container::XIndexAccess > xColumnAccess(
mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
183 uno::Reference< table::XCellRange > xCellRange(
mxTextTable, uno::UNO_QUERY_THROW );
188 for( sal_Int32 column = 0; column < nColumns; ++column )
190 uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( column, row ), uno::UNO_QUERY_THROW );
191 xCellProps->setPropertyValue(
"LeftBorderDistance",
uno::Any( nSpace ) );
192 xCellProps->setPropertyValue(
"RightBorderDistance",
uno::Any( nSpace ) );
205 sal_Int32 nIndent =
static_cast<sal_Int32
>(LeftIndent);
208 case word::WdRulerStyle::wdAdjustFirstColumn:
213 case word::WdRulerStyle::wdAdjustNone:
218 case word::WdRulerStyle::wdAdjustProportional:
223 case word::WdRulerStyle::wdAdjustSameWidth:
237 uno::Reference< beans::XPropertySet > xTableProps(
mxTextTable, uno::UNO_QUERY_THROW );
238 sal_Int32 nMargin = 0;
239 xTableProps->getPropertyValue(
"LeftMargin") >>= nMargin;
241 xTableProps->setPropertyValue(
"LeftMargin",
uno::Any( nMargin ) );
246 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
247 uno::Reference< word::XColumn >
xColumn( xCol->Item(
uno::Any( sal_Int32(1) ),
uno::Any() ), uno::UNO_QUERY_THROW );
248 sal_Int32 nWidth =
xColumn->getWidth();
255 const uno::Reference< word::XColumns >& xColumns,
260 uno::Reference< beans::XPropertySet > xTableProps(
mxTextTable, uno::UNO_QUERY_THROW );
261 sal_Int32 nWidth = 0;
262 xTableProps->getPropertyValue(
"Width") >>= nWidth;
263 sal_Int32 nNewWidth = nWidth - indent;
264 if ((nNewWidth <= 0) || (nWidth <= 0))
266 throw uno::RuntimeException(
267 "Pb with width, in SwVbaRows::setIndentWithAdjustProportional "
268 "(nNewWidth <= 0) || (nWidth <= 0)"
271 double propFactor =
static_cast<double>(nNewWidth)/
static_cast<double>(nWidth);
274 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
275 sal_Int32 nColCount = xCol->getCount();
276 for( sal_Int32
i = 0;
i < nColCount;
i++ )
279 sal_Int32 nColWidth =
xColumn->getWidth();
280 sal_Int32 nNewColWidth =
static_cast<sal_Int32
>( propFactor * nColWidth );
281 xColumn->setWidth( nNewColWidth );
286 xTableProps->setPropertyValue(
"Width",
uno::Any( nNewWidth ) );
292 uno::Reference< beans::XPropertySet > xTableProps(
mxTextTable, uno::UNO_QUERY_THROW );
293 sal_Int32 nWidth = 0;
294 xTableProps->getPropertyValue(
"Width") >>= nWidth;
295 sal_Int32 nNewWidth = nWidth - indent;
298 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
299 sal_Int32 nColCount = xCol->getCount();
300 sal_Int32 nNewColWidth =
static_cast<sal_Int32
>( double( nNewWidth )/nColCount );
301 for( sal_Int32
i = 0;
i < nColCount;
i++ )
304 xColumn->setWidth( nNewColWidth );
309 xTableProps->setPropertyValue(
"Width",
uno::Any( nNewWidth ) );
327 if( nIndex <= 0 || nIndex >
getCount() )
329 throw lang::IndexOutOfBoundsException(
"Index out of bounds" );
333 throw uno::RuntimeException(
"Index out of bounds" );
342uno::Reference< container::XEnumeration >
360uno::Sequence<OUString>
363 static uno::Sequence< OUString >
const sNames
unotools::WeakReference< AnimationNode > mxParent
css::uno::Reference< css::uno::XComponentContext > mxContext
virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent() override
virtual ::sal_Int32 SAL_CALL getCount() override
static void SelectRow(const css::uno::Reference< css::frame::XModel > &xModel, const css::uno::Reference< css::text::XTextTable > &xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow)
virtual void SAL_CALL Select() override
virtual void SAL_CALL SetLeftIndent(float LeftIndent, ::sal_Int32 RulerStyle) override
virtual css::uno::Sequence< OUString > getServiceNames() override
void setIndentWithAdjustFirstColumn(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
SwVbaRows(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, css::uno::Reference< css::text::XTextTable > xTextTable, const css::uno::Reference< css::table::XTableRows > &xTableRows)
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
void setIndentWithAdjustSameWidth(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
virtual void SAL_CALL Delete() override
css::uno::Reference< css::text::XTextTable > mxTextTable
virtual void SAL_CALL setAlignment(::sal_Int32 _alignment) override
virtual float SAL_CALL getSpaceBetweenColumns() override
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) override
virtual css::uno::Any SAL_CALL getAllowBreakAcrossPages() override
virtual ::sal_Int32 SAL_CALL getAlignment() override
get the alignment of the rows: SO format com.sun.star.text.HoriOrientation is mapped to WdRowAlignmen...
virtual css::uno::Any SAL_CALL Item(const css::uno::Any &Index1, const css::uno::Any &) override
virtual void SAL_CALL setSpaceBetweenColumns(float _spacebetweencolumns) override
virtual OUString getServiceImplName() override
virtual void SAL_CALL setAllowBreakAcrossPages(const css::uno::Any &_allowbreakacrosspages) override
virtual css::uno::Type SAL_CALL getElementType() override
css::uno::Reference< css::table::XTableRows > mxTableRows
void setIndentWithAdjustProportional(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
sal_Int32 mnStartRowIndex
void setIndentWithAdjustNone(sal_Int32 indent)
virtual ::sal_Int32 SAL_CALL getCount() override
sal_Int32 getTabColumnsCount(sal_Int32 nRowIndex)
css::uno::Type const & get()
VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc(const css::uno::Reference< css::uno::XComponentContext > &xContext)
#define ERRCODE_BASIC_BAD_ARGUMENT
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE