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>
38 uno::WeakReference< XHelperInterface >
mxParent;
39 uno::Reference< uno::XComponentContext >
mxContext;
40 uno::Reference< text::XTextTable > mxTextTable;
41 uno::Reference< container::XIndexAccess > mxIndexAccess;
45 RowsEnumWrapper(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext >& xContext,
const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 )
47 mxIndexAccess = mxTextTable->getRows();
49 virtual sal_Bool SAL_CALL hasMoreElements( )
override
51 return ( nIndex < mxIndexAccess->getCount() );
54 virtual uno::Any SAL_CALL nextElement( )
override
56 if( nIndex < mxIndexAccess->getCount() )
58 return uno::Any( uno::Reference< word::XRow > (
new SwVbaRow( mxParent, mxContext, mxTextTable, nIndex++ ) ) );
60 throw container::NoSuchElementException();
66 SwVbaRows::SwVbaRows(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const 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( xTextTable ), mxTableRows( xTableRows )
69 mnEndRowIndex = m_xIndexAccess->
getCount() - 1;
72 SwVbaRows::SwVbaRows(
const uno::Reference< XHelperInterface >& xParent,
const uno::Reference< uno::XComponentContext > & xContext,
const 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( xTextTable ), mxTableRows( xTableRows ), mnStartRowIndex( nStarIndex ), mnEndRowIndex( nEndIndex )
74 if( mnEndRowIndex < mnStartRowIndex )
75 throw uno::RuntimeException();
85 sal_Int16 nAlignment = text::HoriOrientation::LEFT;
86 uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
87 xTableProps->getPropertyValue(
"HoriOrient") >>= nAlignment;
91 case text::HoriOrientation::CENTER:
93 nRet = word::WdRowAlignment::wdAlignRowCenter;
96 case text::HoriOrientation::RIGHT:
98 nRet = word::WdRowAlignment::wdAlignRowRight;
103 nRet = word::WdRowAlignment::wdAlignRowLeft;
111 sal_Int16 nAlignment = text::HoriOrientation::LEFT;
114 case word::WdRowAlignment::wdAlignRowCenter:
116 nAlignment = text::HoriOrientation::CENTER;
119 case word::WdRowAlignment::wdAlignRowRight:
121 nAlignment = text::HoriOrientation::RIGHT;
126 nAlignment = text::HoriOrientation::LEFT;
129 uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
130 xTableProps->setPropertyValue(
"HoriOrient",
uno::Any( nAlignment ) );
135 bool bAllowBreak =
false;
136 uno::Reference< container::XIndexAccess > xRowsAccess(
mxTableRows, uno::UNO_QUERY_THROW );
139 uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex(
index ), uno::UNO_QUERY_THROW );
141 xRowProps->getPropertyValue(
"IsSplitAllowed") >>= bSplit;
144 bAllowBreak = bSplit;
146 if( bSplit != bAllowBreak )
148 return uno::Any( sal_Int32(word::WdConstants::wdUndefined) );
156 bool bAllowBreak =
false;
157 _allowbreakacrosspages >>= bAllowBreak;
158 uno::Reference< container::XIndexAccess > xRowsAccess(
mxTableRows, uno::UNO_QUERY_THROW );
161 uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex(
index ), uno::UNO_QUERY_THROW );
162 xRowProps->setPropertyValue(
"IsSplitAllowed",
uno::Any( bAllowBreak ) );
169 uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW );
170 uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( 0,
mnStartRowIndex ), uno::UNO_QUERY_THROW );
171 sal_Int32 nLeftBorderDistance = 0;
172 sal_Int32 nRightBorderDistance = 0;
173 xCellProps->getPropertyValue(
"LeftBorderDistance") >>= nLeftBorderDistance;
174 xCellProps->getPropertyValue(
"RightBorderDistance") >>= nRightBorderDistance;
175 return static_cast< float >( Millimeter::getInPoints( nLeftBorderDistance + nRightBorderDistance ) );
180 sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _spacebetweencolumns ) / 2;
181 uno::Reference< container::XIndexAccess > xColumnAccess( mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
182 uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW );
187 for( sal_Int32 column = 0; column < nColumns; ++column )
189 uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( column, row ), uno::UNO_QUERY_THROW );
190 xCellProps->setPropertyValue(
"LeftBorderDistance",
uno::Any( nSpace ) );
191 xCellProps->setPropertyValue(
"RightBorderDistance",
uno::Any( nSpace ) );
203 uno::Reference< word::XColumns > xColumns(
new SwVbaColumns(
getParent(), mxContext, mxTextTable, mxTextTable->getColumns() ) );
204 sal_Int32 nIndent =
static_cast<sal_Int32
>(LeftIndent);
207 case word::WdRulerStyle::wdAdjustFirstColumn:
212 case word::WdRulerStyle::wdAdjustNone:
217 case word::WdRulerStyle::wdAdjustProportional:
222 case word::WdRulerStyle::wdAdjustSameWidth:
236 uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
237 sal_Int32 nMargin = 0;
238 xTableProps->getPropertyValue(
"LeftMargin") >>= nMargin;
240 xTableProps->setPropertyValue(
"LeftMargin",
uno::Any( nMargin ) );
245 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
246 uno::Reference< word::XColumn >
xColumn( xCol->Item(
uno::Any( sal_Int32(1) ),
uno::Any() ), uno::UNO_QUERY_THROW );
247 sal_Int32 nWidth =
xColumn->getWidth();
254 const uno::Reference< word::XColumns >& xColumns,
259 uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
260 sal_Int32 nWidth = 0;
261 xTableProps->getPropertyValue(
"Width") >>= nWidth;
262 sal_Int32 nNewWidth = nWidth - indent;
263 if ((nNewWidth <= 0) || (nWidth <= 0))
265 throw uno::RuntimeException(
266 "Pb with width, in SwVbaRows::setIndentWithAdjustProportional "
267 "(nNewWidth <= 0) || (nWidth <= 0)"
270 double propFactor =
static_cast<double>(nNewWidth)/static_cast<double>(nWidth);
273 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
274 sal_Int32 nColCount = xCol->getCount();
275 for( sal_Int32
i = 0;
i < nColCount;
i++ )
278 sal_Int32 nColWidth =
xColumn->getWidth();
279 sal_Int32 nNewColWidth =
static_cast<sal_Int32
>( propFactor * nColWidth );
280 xColumn->setWidth( nNewColWidth );
285 xTableProps->setPropertyValue(
"Width",
uno::Any( nNewWidth ) );
291 uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
292 sal_Int32 nWidth = 0;
293 xTableProps->getPropertyValue(
"Width") >>= nWidth;
294 sal_Int32 nNewWidth = nWidth - indent;
297 uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
298 sal_Int32 nColCount = xCol->getCount();
299 sal_Int32 nNewColWidth =
static_cast<sal_Int32
>( double( nNewWidth )/nColCount );
300 for( sal_Int32
i = 0;
i < nColCount;
i++ )
303 xColumn->setWidth( nNewColWidth );
308 xTableProps->setPropertyValue(
"Width",
uno::Any( nNewWidth ) );
323 sal_Int32 nIndex = 0;
324 if( Index1 >>= nIndex )
326 if( nIndex <= 0 || nIndex >
getCount() )
328 throw lang::IndexOutOfBoundsException(
"Index out of bounds" );
330 return uno::Any( uno::Reference< word::XRow >(
new SwVbaRow(
this, mxContext, mxTextTable, nIndex - 1 ) ) );
332 throw uno::RuntimeException(
"Index out of bounds" );
341 uno::Reference< container::XEnumeration >
344 return new RowsEnumWrapper(
this, mxContext, mxTextTable );
359 uno::Sequence<OUString>
362 static uno::Sequence< OUString >
const sNames
virtual void SAL_CALL Delete() override
#define ERRCODE_BASIC_BAD_ARGUMENT
void setIndentWithAdjustSameWidth(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
WeakReference< XInterface > mxParent
virtual css::uno::Any createCollectionObject(const css::uno::Any &aSource) 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...
::cppu::WeakImplHelper< css::container::XEnumeration > EnumerationHelper_BASE
exports com.sun.star. container
virtual void SAL_CALL Select() override
virtual void SAL_CALL setSpaceBetweenColumns(float _spacebetweencolumns) override
virtual float SAL_CALL getSpaceBetweenColumns() override
virtual css::uno::Any SAL_CALL Item(const css::uno::Any &Index1, const css::uno::Any &) override
sal_Int32 getTabColumnsCount(sal_Int32 nRowIndex)
void setIndentWithAdjustNone(sal_Int32 indent)
void setIndentWithAdjustFirstColumn(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
virtual void SAL_CALL SetLeftIndent(float LeftIndent,::sal_Int32 RulerStyle) override
void setIndentWithAdjustProportional(const css::uno::Reference< ooo::vba::word::XColumns > &xColumns, sal_Int32 indent)
sal_Int32 mnStartRowIndex
css::uno::Reference< css::table::XTableRows > mxTableRows
virtual ::sal_Int32 SAL_CALL getCount() override
uno::Reference< frame::XModel > getCurrentWordDoc(const uno::Reference< uno::XComponentContext > &xContext)
css::uno::Type const & get()
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual void SAL_CALL setAlignment(::sal_Int32 _alignment) override
virtual OUString getServiceImplName() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
virtual css::uno::Type SAL_CALL getElementType() override
virtual css::uno::Reference< ov::XHelperInterface > SAL_CALL getParent() override
virtual css::uno::Any SAL_CALL getAllowBreakAcrossPages() override
SwVbaRows(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::text::XTextTable > &xTextTable, const css::uno::Reference< css::table::XTableRows > &xTableRows)
virtual void SAL_CALL setAllowBreakAcrossPages(const css::uno::Any &_allowbreakacrosspages) 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 ::sal_Int32 SAL_CALL getCount() override