summaryrefslogtreecommitdiff
path: root/sw/source/ui/vba
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/vba')
-rw-r--r--sw/source/ui/vba/vbacell.cxx120
-rw-r--r--sw/source/ui/vba/vbacell.hxx67
-rw-r--r--sw/source/ui/vba/vbacells.cxx223
-rw-r--r--sw/source/ui/vba/vbacells.hxx75
-rw-r--r--sw/source/ui/vba/vbacheckbox.cxx98
-rw-r--r--sw/source/ui/vba/vbacheckbox.hxx58
-rw-r--r--sw/source/ui/vba/vbacolumn.cxx201
-rw-r--r--sw/source/ui/vba/vbacolumn.hxx68
-rw-r--r--sw/source/ui/vba/vbacolumns.cxx160
-rw-r--r--sw/source/ui/vba/vbacolumns.hxx75
-rw-r--r--sw/source/ui/vba/vbaformfield.cxx139
-rw-r--r--sw/source/ui/vba/vbaformfield.hxx61
-rw-r--r--sw/source/ui/vba/vbaformfields.cxx205
-rw-r--r--sw/source/ui/vba/vbaformfields.hxx60
-rw-r--r--sw/source/ui/vba/vbaframe.cxx75
-rw-r--r--sw/source/ui/vba/vbaframe.hxx57
-rw-r--r--sw/source/ui/vba/vbaframes.cxx109
-rw-r--r--sw/source/ui/vba/vbaframes.hxx61
-rw-r--r--sw/source/ui/vba/vbaheadersfooters.cxx150
-rw-r--r--sw/source/ui/vba/vbaheadersfooters.hxx62
-rw-r--r--sw/source/ui/vba/vbalistformat.cxx121
-rw-r--r--sw/source/ui/vba/vbalistformat.hxx60
-rw-r--r--sw/source/ui/vba/vbalistgalleries.cxx115
-rw-r--r--sw/source/ui/vba/vbalistgalleries.hxx61
-rw-r--r--sw/source/ui/vba/vbalistgallery.cxx73
-rw-r--r--sw/source/ui/vba/vbalistgallery.hxx58
-rw-r--r--sw/source/ui/vba/vbalisthelper.cxx707
-rw-r--r--sw/source/ui/vba/vbalisthelper.hxx82
-rw-r--r--sw/source/ui/vba/vbalistlevel.cxx401
-rw-r--r--sw/source/ui/vba/vbalistlevel.hxx81
-rw-r--r--sw/source/ui/vba/vbalistlevels.cxx118
-rw-r--r--sw/source/ui/vba/vbalistlevels.hxx62
-rw-r--r--sw/source/ui/vba/vbalisttemplate.cxx80
-rw-r--r--sw/source/ui/vba/vbalisttemplate.hxx60
-rw-r--r--sw/source/ui/vba/vbalisttemplates.cxx112
-rw-r--r--sw/source/ui/vba/vbalisttemplates.hxx62
-rw-r--r--sw/source/ui/vba/vbarevision.cxx105
-rw-r--r--sw/source/ui/vba/vbarevision.hxx60
-rw-r--r--sw/source/ui/vba/vbarevisions.cxx188
-rw-r--r--sw/source/ui/vba/vbarevisions.hxx66
-rw-r--r--sw/source/ui/vba/vbarow.cxx136
-rw-r--r--sw/source/ui/vba/vbarow.hxx69
-rw-r--r--sw/source/ui/vba/vbarows.cxx368
-rw-r--r--sw/source/ui/vba/vbarows.hxx87
-rw-r--r--sw/source/ui/vba/vbatablehelper.cxx306
-rw-r--r--sw/source/ui/vba/vbatablehelper.hxx70
-rw-r--r--sw/source/ui/vba/vbatableofcontents.cxx125
-rw-r--r--sw/source/ui/vba/vbatableofcontents.hxx70
-rw-r--r--sw/source/ui/vba/vbatablesofcontents.cxx197
-rw-r--r--sw/source/ui/vba/vbatablesofcontents.hxx64
-rw-r--r--sw/source/ui/vba/vbatabstop.cxx63
-rw-r--r--sw/source/ui/vba/vbatabstop.hxx54
-rw-r--r--sw/source/ui/vba/vbatabstops.cxx280
-rw-r--r--sw/source/ui/vba/vbatabstops.hxx65
54 files changed, 6750 insertions, 0 deletions
diff --git a/sw/source/ui/vba/vbacell.cxx b/sw/source/ui/vba/vbacell.cxx
new file mode 100644
index 000000000000..043e2aa04358
--- /dev/null
+++ b/sw/source/ui/vba/vbacell.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacell.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include "vbatable.hxx"
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <rtl/ustrbuf.hxx>
+#include "wordvbahelper.hxx"
+#include "vbatablehelper.hxx"
+#include "vbarow.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaCell::SwVbaCell( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nColumn, sal_Int32 nRow ) throw ( uno::RuntimeException ) :
+ SwVbaCell_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnColumn( nColumn ), mnRow( nRow )
+{
+}
+
+SwVbaCell::~SwVbaCell()
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaCell::getWidth() throw (css::uno::RuntimeException)
+{
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ return aTableHelper.GetColWidth( mnColumn, mnRow, sal_True );
+}
+
+void SAL_CALL SwVbaCell::setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException)
+{
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ aTableHelper.SetColWidth( _width, mnColumn, mnRow, sal_True );
+}
+
+uno::Any SAL_CALL SwVbaCell::getHeight() throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) );
+ return xRow->getHeight();
+}
+
+void SAL_CALL SwVbaCell::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) );
+ xRow->setHeight( _height );
+}
+
+::sal_Int32 SAL_CALL SwVbaCell::getHeightRule() throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) );
+ return xRow->getHeightRule();
+}
+
+void SAL_CALL SwVbaCell::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) );
+ xRow->setHeightRule( _heightrule );
+}
+
+void SAL_CALL SwVbaCell::SetWidth( float width, sal_Int32 /*rulestyle*/ ) throw (css::uno::RuntimeException)
+{
+ // FIXME: handle the argument: rulestyle
+ setWidth( width );
+}
+
+void SAL_CALL SwVbaCell::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException)
+{
+ // FIXME: handle the argument: heightrule
+ setHeightRule( heightrule );
+ setHeight( uno::makeAny( height ) );
+}
+
+rtl::OUString&
+SwVbaCell::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCell") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaCell::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Cell" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbacell.hxx b/sw/source/ui/vba/vbacell.hxx
new file mode 100644
index 000000000000..4ce550793b11
--- /dev/null
+++ b/sw/source/ui/vba/vbacell.hxx
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_CELL_HXX
+#define SW_VBA_CELL_HXX
+
+#include <ooo/vba/word/XCell.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextTable.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XCell > SwVbaCell_BASE;
+
+class SwVbaCell : public SwVbaCell_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ sal_Int32 mnColumn;
+ sal_Int32 mnRow;
+
+public:
+ SwVbaCell( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nColumn, sal_Int32 nRow ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaCell();
+
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_CELL_HXX */
diff --git a/sw/source/ui/vba/vbacells.cxx b/sw/source/ui/vba/vbacells.cxx
new file mode 100644
index 000000000000..d8d6b04ab3d7
--- /dev/null
+++ b/sw/source/ui/vba/vbacells.cxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacells.hxx"
+#include "vbacell.hxx"
+#include "wordvbahelper.hxx"
+#include "vbatablehelper.hxx"
+#include "vbarow.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > CellCollectionHelper_Base;
+
+class CellsEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference< container::XIndexAccess > mxIndexAccess;
+ sal_Int32 nIndex;
+
+public:
+ CellsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 )
+ {
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( nIndex < mxIndexAccess->getCount() )
+ {
+ return mxIndexAccess->getByIndex( nIndex++ );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+class CellCollectionHelper : public CellCollectionHelper_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< css::text::XTextTable > mxTextTable;
+ sal_Int32 mnLeft;
+ sal_Int32 mnTop;
+ sal_Int32 mnRight;
+ sal_Int32 mnBottom;
+
+public:
+ CellCollectionHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw ( css::uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), mnLeft( nLeft ), mnTop( nTop ), mnRight( nRight ), mnBottom( nBottom )
+ {
+ }
+ virtual ~CellCollectionHelper() {}
+
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return ( mnRight - mnLeft + 1 ) * ( mnBottom - mnTop + 1 );
+ }
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw css::lang::IndexOutOfBoundsException();
+
+ for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
+ {
+ for( sal_Int32 col = mnLeft; col <= mnRight; col++ )
+ {
+ if( Index == ( ( row - mnTop ) * ( mnRight - mnLeft + 1 ) + ( col - mnLeft ) ) )
+ return uno::makeAny( uno::Reference< word::XCell >( new SwVbaCell( mxParent, mxContext, mxTextTable, col, row ) ) );
+ }
+ }
+ throw css::lang::IndexOutOfBoundsException();
+
+ }
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return word::XCell::static_type(0);
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new CellsEnumWrapper( this );
+ }
+};
+
+SwVbaCells::SwVbaCells( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (uno::RuntimeException) : SwVbaCells_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new CellCollectionHelper( xParent, xContext, xTextTable, nLeft, nTop, nRight, nBottom ) ) ), mxTextTable( xTextTable ), mnLeft( nLeft ), mnTop( nTop ), mnRight( nRight ), mnBottom( nBottom )
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaCells::getWidth() throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ return xCell->getWidth();
+}
+
+void SAL_CALL SwVbaCells::setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ while( nIndex < m_xIndexAccess->getCount() )
+ {
+ uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
+ xCell->setWidth( _width );
+ }
+}
+
+uno::Any SAL_CALL SwVbaCells::getHeight() throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) );
+ return xRow->getHeight();
+}
+
+void SAL_CALL SwVbaCells::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException)
+{
+ for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
+ {
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
+ xRow->setHeight( _height );
+ }
+}
+
+::sal_Int32 SAL_CALL SwVbaCells::getHeightRule() throw (css::uno::RuntimeException)
+{
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) );
+ return xRow->getHeightRule();
+}
+
+void SAL_CALL SwVbaCells::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException)
+{
+ for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
+ {
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
+ xRow->setHeightRule( _heightrule );
+ }
+}
+
+void SAL_CALL SwVbaCells::SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ while( nIndex < m_xIndexAccess->getCount() )
+ {
+ uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
+ xCell->SetWidth( width, rulestyle );
+ }
+}
+
+void SAL_CALL SwVbaCells::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException)
+{
+ for( sal_Int32 row = mnTop; row <= mnBottom; row++ )
+ {
+ uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) );
+ xRow->SetHeight( height, heightrule );
+ }
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaCells::getElementType() throw (uno::RuntimeException)
+{
+ return word::XCell::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+SwVbaCells::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return xEnumAccess->createEnumeration();
+}
+
+uno::Any
+SwVbaCells::createCollectionObject( const uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaCells::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCells") );
+ return sImplName;
+}
+
+uno::Sequence<rtl::OUString>
+SwVbaCells::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Cells") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbacells.hxx b/sw/source/ui/vba/vbacells.hxx
new file mode 100644
index 000000000000..5d4fa8ad440d
--- /dev/null
+++ b/sw/source/ui/vba/vbacells.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_CELLS_HXX
+#define SW_VBA_CELLS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XCells.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextTable.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XCells > SwVbaCells_BASE;
+
+class SwVbaCells : public SwVbaCells_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ sal_Int32 mnLeft;
+ sal_Int32 mnTop;
+ sal_Int32 mnRight;
+ sal_Int32 mnBottom;
+
+public:
+ SwVbaCells( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaCells() {}
+
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaCells_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_CELLS_HXX */
diff --git a/sw/source/ui/vba/vbacheckbox.cxx b/sw/source/ui/vba/vbacheckbox.cxx
new file mode 100644
index 000000000000..39747d552f5c
--- /dev/null
+++ b/sw/source/ui/vba/vbacheckbox.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacheckbox.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <ecmaflds.hxx>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaCheckBox::SwVbaCheckBox( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& rModel, const uno::Reference< text::XFormField >& xFormField ) throw ( uno::RuntimeException ) : SwVbaCheckBox_BASE( rParent, rContext ), mxModel( rModel ), mxFormField( xFormField )
+{
+ rtl::OUString sType = mxFormField->getFieldType();
+ if( !sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) )
+ {
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("It is not a CheckBox")), uno::Reference< uno::XInterface >() );
+ }
+}
+
+SwVbaCheckBox::~SwVbaCheckBox()
+{
+}
+
+sal_Bool SAL_CALL SwVbaCheckBox::getValue() throw ( uno::RuntimeException )
+{
+ sal_Bool bValue = sal_False;
+ sal_Int32 nCount = mxFormField->getParamCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ if( mxFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX_CHECKED ) )
+ {
+ if( mxFormField->getParamValue(i).equalsIgnoreAsciiCaseAscii("on") )
+ bValue = sal_True;
+ else
+ bValue = sal_False;
+ break;
+ }
+ }
+ return bValue;
+}
+
+void SAL_CALL SwVbaCheckBox::setValue( sal_Bool value ) throw ( uno::RuntimeException )
+{
+ rtl::OUString sValue = rtl::OUString::createFromAscii( value ? "on" : "off" );
+ mxFormField->addParam( rtl::OUString::createFromAscii( ECMA_FORMCHECKBOX_CHECKED ), sValue, sal_True );
+}
+
+rtl::OUString&
+SwVbaCheckBox::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCheckBox") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaCheckBox::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.CheckBox" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbacheckbox.hxx b/sw/source/ui/vba/vbacheckbox.hxx
new file mode 100644
index 000000000000..91367c319590
--- /dev/null
+++ b/sw/source/ui/vba/vbacheckbox.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_CHECKBOX_HXX
+#define SW_VBA_CHECKBOX_HXX
+
+#include <ooo/vba/word/XCheckBox.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XFormField.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XCheckBox > SwVbaCheckBox_BASE;
+
+class SwVbaCheckBox : public SwVbaCheckBox_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::text::XFormField > mxFormField;
+
+public:
+ SwVbaCheckBox( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XFormField >& xFormField ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaCheckBox();
+
+ // Methods
+ sal_Bool SAL_CALL getValue() throw ( css::uno::RuntimeException );
+ void SAL_CALL setValue( sal_Bool value ) throw ( css::uno::RuntimeException );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_CHECKBOX_HXX */
diff --git a/sw/source/ui/vba/vbacolumn.cxx b/sw/source/ui/vba/vbacolumn.cxx
new file mode 100644
index 000000000000..7cf50c50e03b
--- /dev/null
+++ b/sw/source/ui/vba/vbacolumn.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacolumn.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include "vbatable.hxx"
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <rtl/ustrbuf.hxx>
+#include "wordvbahelper.hxx"
+#include "vbatablehelper.hxx"
+
+#define RELATIVE_TABLE_WIDTH 10000
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( uno::RuntimeException ) :
+ SwVbaColumn_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex )
+{
+ mxTableColumns = mxTextTable->getColumns();
+}
+
+SwVbaColumn::~SwVbaColumn()
+{
+}
+
+void SwVbaColumn::calculateAbsoluteColumnWidth( sal_Int32 nTableWidth, const css::uno::Sequence< css::text::TableColumnSeparator >& aSeparators, double* pAbsWidth )
+{
+ const text::TableColumnSeparator* pArray = aSeparators.getConstArray();
+ sal_Int32 nSepCount = aSeparators.getLength();
+ for( sal_Int32 i = 0; i <= nSepCount; i++ )
+ {
+ sal_Int32 nRelColWidth = 0;
+ if( i == 0 )
+ {
+ if( nSepCount != 0 )
+ {
+ nRelColWidth = pArray[0].Position;
+ }
+ else
+ {
+ nRelColWidth = RELATIVE_TABLE_WIDTH;
+ }
+ }
+ else
+ {
+ if( i == nSepCount )
+ {
+ nRelColWidth = RELATIVE_TABLE_WIDTH - pArray[i-1].Position;
+ }
+ else
+ {
+ nRelColWidth = pArray[i].Position - pArray[i-1].Position;
+ }
+ }
+ pAbsWidth[i] = ( (double)nRelColWidth / RELATIVE_TABLE_WIDTH ) * (double) nTableWidth;
+ }
+}
+
+void SwVbaColumn::calculateRelativeColumnWidth( const double* pAbsWidth, double* pRelWidth, sal_Int32 nCount )
+{
+ double tableWidth = 0.0;
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ tableWidth += pAbsWidth[i];
+ }
+
+ pRelWidth[ nCount - 1 ] = tableWidth;
+ for( sal_Int32 i = 0; i < nCount - 1; i++ )
+ {
+ if( i == 0 )
+ {
+ pRelWidth[i] = ( pAbsWidth[i] * RELATIVE_TABLE_WIDTH ) / tableWidth;
+ }
+ else
+ {
+ pRelWidth[i] = pRelWidth[i-1] + ( pAbsWidth[i] * RELATIVE_TABLE_WIDTH ) / tableWidth;
+ }
+ }
+}
+
+sal_Int32 SAL_CALL
+SwVbaColumn::getWidth( ) throw ( css::uno::RuntimeException )
+{
+ /* uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ uno::Sequence< text::TableColumnSeparator > aSeparators;
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TableColumnSeparators") ) ) >>= aSeparators;
+ sal_Int32 nTableWidth = SwVbaTable::getTableWidth( xTableProps );
+ sal_Int32 nColCont = aSeparators.getLength() + 1;
+ double dAbsColWidth[ nColCont ];
+ calculateAbsoluteColumnWidth( nTableWidth, aSeparators, dAbsColWidth );
+ return Millimeter::getInPoints( (sal_Int32)( dAbsColWidth[ mnIndex ] ) );
+ */
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ return aTableHelper.GetColWidth( mnIndex );
+}
+
+void SAL_CALL
+SwVbaColumn::setWidth( sal_Int32 _width ) throw ( css::uno::RuntimeException )
+{
+/* uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ uno::Sequence< text::TableColumnSeparator > aSeparators;
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TableColumnSeparators") ) ) >>= aSeparators;
+ sal_Int32 nTableWidth = SwVbaTable::getTableWidth( xTableProps );
+ sal_Int32 nColCont = aSeparators.getLength() + 1;
+ double dAbsColWidth[ nColCont ];
+ calculateAbsoluteColumnWidth( nTableWidth, aSeparators, dAbsColWidth );
+ dAbsColWidth[ mnIndex ] = Millimeter::getInHundredthsOfOneMillimeter( _width );
+ double tableWidth = 0.0;
+ for( sal_Int32 i = 0; i < nColCont; i++ )
+ {
+ tableWidth += dAbsColWidth[i];
+ }
+
+ double dRelColWidth[ nColCont ];
+ calculateRelativeColumnWidth( dAbsColWidth, dRelColWidth, nColCont);
+
+ text::TableColumnSeparator* pArray = aSeparators.getArray();
+ for( sal_Int32 i = 0; i < nColCont - 1; i++ )
+ {
+ pArray[i].Position = (sal_Int16)(dRelColWidth[i]);
+ }
+
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TableColumnSeparators") ), uno::makeAny( aSeparators ) );
+ SwVbaTable::setTableWidth( xTableProps, (sal_Int32)( tableWidth ) );
+ */
+
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ aTableHelper.SetColWidth( _width, mnIndex );
+}
+
+void SAL_CALL
+SwVbaColumn::Select( ) throw ( uno::RuntimeException )
+{
+ SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex );
+}
+
+void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) throw ( uno::RuntimeException )
+{
+ rtl::OUStringBuffer aRangeName;
+ rtl::OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn );
+ aRangeName.append(sStartCol).append(sal_Int32( 1 ) );
+ rtl::OUString sEndCol = SwVbaTableHelper::getColumnStr( nEndColumn );
+ sal_Int32 nRowCount = xTextTable->getRows()->getCount();
+ aRangeName.appendAscii(":").append( sEndCol ).append( sal_Int32( nRowCount ) );
+
+ uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW );
+ rtl::OUString sSelRange = aRangeName.makeStringAndClear();
+ uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( sSelRange );
+
+ uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelection->select( uno::makeAny( xSelRange ) );
+}
+
+rtl::OUString&
+SwVbaColumn::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaColumn") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaColumn::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Column" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbacolumn.hxx b/sw/source/ui/vba/vbacolumn.hxx
new file mode 100644
index 000000000000..fe4a81fc21b1
--- /dev/null
+++ b/sw/source/ui/vba/vbacolumn.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_COLUMN_HXX
+#define SW_VBA_COLUMN_HXX
+
+#include <ooo/vba/word/XColumn.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/table/XTableColumns.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/TableColumnSeparator.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XColumn > SwVbaColumn_BASE;
+
+class SwVbaColumn : public SwVbaColumn_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ css::uno::Reference< css::table::XTableColumns > mxTableColumns;
+ sal_Int32 mnIndex;
+
+private:
+ void calculateAbsoluteColumnWidth( sal_Int32 nTableWidth, const css::uno::Sequence< css::text::TableColumnSeparator >& aSeparators, double* pAbsWidth );
+ void calculateRelativeColumnWidth( const double* pAbsWidth, double* pRelWidth, sal_Int32 nCount );
+
+public:
+ SwVbaColumn( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaColumn();
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getWidth() throw ( css::uno::RuntimeException );
+ virtual void SAL_CALL setWidth( sal_Int32 _width ) throw ( css::uno::RuntimeException );
+ virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException);
+
+ static void SelectColumn( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_COLUMN_HXX */
diff --git a/sw/source/ui/vba/vbacolumns.cxx b/sw/source/ui/vba/vbacolumns.cxx
new file mode 100644
index 000000000000..0abd73d99793
--- /dev/null
+++ b/sw/source/ui/vba/vbacolumns.cxx
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacolumns.hxx"
+#include "vbacolumn.hxx"
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <ooo/vba/word/WdConstants.hpp>
+#include <ooo/vba/word/WdRulerStyle.hpp>
+#include "wordvbahelper.hxx"
+#include "vbatablehelper.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class ColumnsEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::WeakReference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< text::XTextTable > mxTextTable;
+ uno::Reference< container::XIndexAccess > mxIndexAccess;
+ sal_Int32 nIndex;
+
+public:
+ ColumnsEnumWrapper( 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 )
+ {
+ mxIndexAccess.set( mxTextTable->getColumns(), uno::UNO_QUERY );
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( nIndex < mxIndexAccess->getCount() )
+ {
+ return uno::makeAny( uno::Reference< word::XColumn > ( new SwVbaColumn( mxParent, mxContext, mxTextTable, nIndex++ ) ) );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns )
+{
+ mnStartColumnIndex = 0;
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ mnEndColumnIndex = aTableHelper.getTabColumnsMaxCount( ) - 1;
+}
+
+SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns ), mnStartColumnIndex( nStartCol ), mnEndColumnIndex( nEndCol )
+{
+ if( mnEndColumnIndex < mnStartColumnIndex )
+ throw uno::RuntimeException();
+}
+
+uno::Reference< word::XColumn > SwVbaColumns::getColumnAtIndex( sal_Int32 index ) throw (uno::RuntimeException)
+{
+ return uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, index ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaColumns::getWidth() throw (uno::RuntimeException)
+{
+ return getColumnAtIndex( mnStartColumnIndex )->getWidth();
+}
+
+void SAL_CALL SwVbaColumns::setWidth( ::sal_Int32 _width ) throw (uno::RuntimeException)
+{
+ for( sal_Int32 index = mnStartColumnIndex; index <= mnEndColumnIndex; index++ )
+ {
+ getColumnAtIndex( index )->setWidth( _width );
+ }
+}
+
+void SAL_CALL SwVbaColumns::Select( ) throw (uno::RuntimeException)
+{
+ SwVbaColumn::SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnStartColumnIndex, mnEndColumnIndex );
+}
+
+::sal_Int32 SAL_CALL SwVbaColumns::getCount() throw (uno::RuntimeException)
+{
+ return ( mnEndColumnIndex - mnStartColumnIndex + 1 );
+}
+
+uno::Any SAL_CALL SwVbaColumns::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ if( ( Index1 >>= nIndex ) == sal_True )
+ {
+ if( nIndex <= 0 || nIndex > getCount() )
+ {
+ throw lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+ }
+ return uno::makeAny( uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, nIndex - 1 ) ) );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaColumns::getElementType() throw (uno::RuntimeException)
+{
+ return word::XColumn::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaColumns::createEnumeration() throw (uno::RuntimeException)
+{
+ return new ColumnsEnumWrapper( this, mxContext, mxTextTable );
+}
+
+uno::Any
+SwVbaColumns::createCollectionObject( const uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaColumns::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaColumns") );
+ return sImplName;
+}
+
+uno::Sequence<rtl::OUString>
+SwVbaColumns::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Columns") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbacolumns.hxx b/sw/source/ui/vba/vbacolumns.hxx
new file mode 100644
index 000000000000..a8f4dc2a3c89
--- /dev/null
+++ b/sw/source/ui/vba/vbacolumns.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_COLUMNS_HXX
+#define SW_VBA_COLUMNS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XColumns.hpp>
+#include <ooo/vba/word/XColumn.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/table/XTableColumns.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XColumns > SwVbaColumns_BASE;
+
+class SwVbaColumns : public SwVbaColumns_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ css::uno::Reference< css::table::XTableColumns > mxTableColumns;
+ sal_Int32 mnStartColumnIndex;
+ sal_Int32 mnEndColumnIndex;
+
+private:
+ css::uno::Reference< ooo::vba::word::XColumn > getColumnAtIndex( sal_Int32 index ) throw (css::uno::RuntimeException);
+
+public:
+ SwVbaColumns( 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::XTableColumns >& xTableColumns ) throw ( css::uno::RuntimeException );
+ SwVbaColumns( 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::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaColumns() {}
+
+ virtual sal_Int32 SAL_CALL getWidth( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException);
+
+ //XCollection
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaColumns_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_COLUMNS_HXX */
diff --git a/sw/source/ui/vba/vbaformfield.cxx b/sw/source/ui/vba/vbaformfield.cxx
new file mode 100644
index 000000000000..1f340667bb40
--- /dev/null
+++ b/sw/source/ui/vba/vbaformfield.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaformfield.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <ecmaflds.hxx>
+#include "vbacheckbox.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaFormField::SwVbaFormField( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& rModel, const uno::Reference< text::XFormField >& xFormField ) throw ( uno::RuntimeException ) : SwVbaFormField_BASE( rParent, rContext ), mxModel( rModel ), mxFormField( xFormField )
+{
+}
+
+SwVbaFormField::~SwVbaFormField()
+{
+}
+
+rtl::OUString SAL_CALL SwVbaFormField::getResult() throw ( uno::RuntimeException )
+{
+ rtl::OUString sResult;
+ rtl::OUString sType = mxFormField->getFieldType();
+ if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMTEXT ) )
+ {
+ uno::Reference< text::XTextContent > xTextContent( mxFormField, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTextRange = xTextContent->getAnchor();
+ sResult = xTextRange->getString();
+ }
+ else if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) )
+ {
+ sal_Int32 nValue = 0;
+ sal_Int32 nCount = mxFormField->getParamCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ if( mxFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX_CHECKED ) )
+ {
+ if( mxFormField->getParamValue(i).equalsIgnoreAsciiCaseAscii("on") )
+ nValue = 1;
+ else
+ nValue = 0;
+ break;
+ }
+
+ }
+ sResult = rtl::OUString::valueOf( nValue );
+ }
+ else
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ return sResult;
+}
+
+void SAL_CALL SwVbaFormField::setResult( const rtl::OUString& result ) throw ( uno::RuntimeException )
+{
+ rtl::OUString sType = mxFormField->getFieldType();
+ if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMTEXT ) )
+ {
+ uno::Reference< text::XTextContent > xTextContent( mxFormField, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTextRange = xTextContent->getAnchor();
+ xTextRange->setString( result );
+ }
+ else if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) )
+ {
+ // do nothing
+ }
+ else
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+}
+
+sal_Bool SAL_CALL SwVbaFormField::getEnabled() throw ( uno::RuntimeException )
+{
+ //allways return true
+ return sal_True;
+}
+
+void SAL_CALL SwVbaFormField::setEnabled( sal_Bool/* enabled */ ) throw ( uno::RuntimeException )
+{
+ // not support in Writer
+}
+
+uno::Any SAL_CALL SwVbaFormField::CheckBox() throw ( uno::RuntimeException )
+{
+ return uno::makeAny( uno::Reference< word::XCheckBox >( new SwVbaCheckBox( this, mxContext, mxModel, mxFormField ) ) );
+}
+
+rtl::OUString&
+SwVbaFormField::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFormField") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaFormField::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.FormField" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbaformfield.hxx b/sw/source/ui/vba/vbaformfield.hxx
new file mode 100644
index 000000000000..6a90269d4703
--- /dev/null
+++ b/sw/source/ui/vba/vbaformfield.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_FORMFIELD_HXX
+#define SW_VBA_FORMFIELD_HXX
+
+#include <ooo/vba/word/XFormField.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XFormField.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XFormField > SwVbaFormField_BASE;
+
+class SwVbaFormField : public SwVbaFormField_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::text::XFormField > mxFormField;
+
+public:
+ SwVbaFormField( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XFormField >& xFormField ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaFormField();
+
+ // Methods
+ rtl::OUString SAL_CALL getResult() throw ( css::uno::RuntimeException );
+ void SAL_CALL setResult( const rtl::OUString& result ) throw ( css::uno::RuntimeException );
+ sal_Bool SAL_CALL getEnabled() throw ( css::uno::RuntimeException );
+ void SAL_CALL setEnabled( sal_Bool enabled ) throw ( css::uno::RuntimeException );
+ css::uno::Any SAL_CALL CheckBox() throw ( css::uno::RuntimeException );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_FORMFIELD_HXX */
diff --git a/sw/source/ui/vba/vbaformfields.cxx b/sw/source/ui/vba/vbaformfields.cxx
new file mode 100644
index 000000000000..293f2f90ae5c
--- /dev/null
+++ b/sw/source/ui/vba/vbaformfields.cxx
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaformfields.hxx"
+#include "vbaformfield.hxx"
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include "wordvbahelper.hxx"
+#include <cppuhelper/implbase3.hxx>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef std::vector< uno::Reference< text::XFormField > > XFormFieldVec;
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > FormFiledEnumeration_BASE;
+typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > FormFieldCollectionHelper_BASE;
+
+rtl::OUString lcl_getFormFieldName( const uno::Reference< text::XFormField >& xFormField )
+{
+ rtl::OUString sName;
+ sal_Int32 nCount = xFormField->getParamCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ if( xFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( "Name" ) )
+ {
+ sName = xFormField->getParamValue(i);
+ OSL_TRACE("lcl_getFormFieldName: %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ break;
+ }
+ }
+ return sName;
+}
+
+class FormFieldsEnumeration : public FormFiledEnumeration_BASE
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< frame::XModel > mxModel;
+ XFormFieldVec mxFormFields;
+ XFormFieldVec::iterator cachePos;
+public:
+ FormFieldsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const XFormFieldVec& xFormFiels ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxFormFields( xFormFiels ), cachePos( mxFormFields.begin() )
+ {
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( cachePos != mxFormFields.end() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ uno::Reference< text::XFormField > xFormField( *cachePos++ );
+ return uno::makeAny( uno::Reference< word::XFormField > ( new SwVbaFormField( mxParent, mxContext, mxModel, xFormField ) ) );
+ }
+
+};
+
+class FormFieldCollectionHelper : public FormFieldCollectionHelper_BASE
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< frame::XModel > mxModel;
+ XFormFieldVec mxFormFields;
+ XFormFieldVec::iterator cachePos;
+public:
+ FormFieldCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel )
+ {
+ uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( xModel,uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW );
+ sal_Int32 nCount = xIndexAccess->getCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ uno::Reference< text::XFormField > xFormField( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
+ if( xFormField.is() )
+ mxFormFields.push_back( xFormField );
+ }
+ cachePos = mxFormFields.begin();
+ }
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return word::XFormField::static_type(0); }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return getCount() > 0 ; }
+ // XNameAcess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasByName(aName) )
+ throw container::NoSuchElementException();
+ uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XFormField >( new SwVbaFormField( mxParent, mxContext, mxModel, xFormField ) ) );
+ }
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< rtl::OUString > sNames( mxFormFields.size() );
+ rtl::OUString* pString = sNames.getArray();
+ XFormFieldVec::iterator it = mxFormFields.begin();
+ XFormFieldVec::iterator it_end = mxFormFields.end();
+ for ( ; it != it_end; ++it, ++pString )
+ {
+ uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW );
+ *pString = lcl_getFormFieldName( xFormField );
+ }
+ return sNames;
+ }
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ cachePos = mxFormFields.begin();
+ XFormFieldVec::iterator it_end = mxFormFields.end();
+ for ( ; cachePos != it_end; ++cachePos )
+ {
+ //uno::Reference< container::XNamed > xName( *cachePos, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW );
+ if ( aName.equalsIgnoreAsciiCase( lcl_getFormFieldName( xFormField )) )
+ break;
+ }
+ return ( cachePos != it_end );
+ }
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return mxFormFields.size();
+ }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+ return uno::makeAny( uno::Reference< word::XFormField >( new SwVbaFormField( mxParent, mxContext, mxModel, mxFormFields[ Index ] ) ) );
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new FormFieldsEnumeration( mxParent, mxContext, mxModel, mxFormFields );
+ }
+};
+
+SwVbaFormFields::SwVbaFormFields( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaFormFields_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new FormFieldCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel )
+{
+}
+// XEnumerationAccess
+uno::Type
+SwVbaFormFields::getElementType() throw (uno::RuntimeException)
+{
+ return word::XFormField::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaFormFields::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return xEnumAccess->createEnumeration();
+}
+
+uno::Any
+SwVbaFormFields::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaFormFields::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFormFields") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaFormFields::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.FormFields") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbaformfields.hxx b/sw/source/ui/vba/vbaformfields.hxx
new file mode 100644
index 000000000000..338b01cb84df
--- /dev/null
+++ b/sw/source/ui/vba/vbaformfields.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_FORMFIELDS_HXX
+#define SW_VBA_FORMFIELDS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XFormFields.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XFormFields > SwVbaFormFields_BASE;
+
+class SwVbaFormFields : public SwVbaFormFields_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+
+public:
+ SwVbaFormFields( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ virtual ~SwVbaFormFields() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaFormFields_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_FORMFIELDS_HXX */
diff --git a/sw/source/ui/vba/vbaframe.cxx b/sw/source/ui/vba/vbaframe.cxx
new file mode 100644
index 000000000000..0ea4af8e4a44
--- /dev/null
+++ b/sw/source/ui/vba/vbaframe.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaframe.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaFrame::SwVbaFrame( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< frame::XModel >& rModel, const css::uno::Reference< text::XTextFrame >& xTextFrame ) throw ( css::uno::RuntimeException ) :
+ SwVbaFrame_BASE( rParent, rContext ), mxModel( rModel ), mxTextFrame( xTextFrame )
+{
+}
+
+SwVbaFrame::~SwVbaFrame()
+{
+}
+
+void SAL_CALL SwVbaFrame::Select() throw ( uno::RuntimeException )
+{
+ uno::Reference< view::XSelectionSupplier > xSelectSupp( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelectSupp->select( uno::makeAny( mxTextFrame ) );
+}
+
+rtl::OUString&
+SwVbaFrame::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFrame") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaFrame::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frame" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbaframe.hxx b/sw/source/ui/vba/vbaframe.hxx
new file mode 100644
index 000000000000..6584bcf94fde
--- /dev/null
+++ b/sw/source/ui/vba/vbaframe.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_FRAME_HXX
+#define SW_VBA_FRAME_HXX
+
+#include <ooo/vba/word/XFrame.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextFrame.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XFrame > SwVbaFrame_BASE;
+
+class SwVbaFrame : public SwVbaFrame_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::text::XTextFrame > mxTextFrame;
+
+public:
+ SwVbaFrame( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XTextFrame >& xTextFrame ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaFrame();
+
+ // Methods
+ virtual void SAL_CALL Select() throw ( css::uno::RuntimeException );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_FRAME_HXX */
diff --git a/sw/source/ui/vba/vbaframes.cxx b/sw/source/ui/vba/vbaframes.cxx
new file mode 100644
index 000000000000..0c2a4f36f1e1
--- /dev/null
+++ b/sw/source/ui/vba/vbaframes.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaframes.hxx"
+#include "vbaframe.hxx"
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include "wordvbahelper.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > FramesEnumeration_Base;
+class FramesEnumeration : public FramesEnumeration_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< container::XIndexAccess> mxIndexAccess;
+ uno::Reference< frame::XModel > mxModel;
+ sal_Int32 nCurrentPos;
+public:
+ FramesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : mxParent( xParent ), mxContext( xContext), mxIndexAccess( xIndexAccess ), mxModel( xModel ), nCurrentPos(0)
+ {
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nCurrentPos < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ uno::Reference< text::XTextFrame > xTextFrame( mxIndexAccess->getByIndex( nCurrentPos++ ), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( mxParent, mxContext, mxModel, xTextFrame ) ) );
+ }
+
+};
+
+SwVbaFrames::SwVbaFrames( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xFrames, const uno::Reference< frame::XModel >& xModel ): SwVbaFrames_BASE( xParent, xContext, xFrames ), mxModel( xModel )
+{
+ mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW );
+}
+// XEnumerationAccess
+uno::Type
+SwVbaFrames::getElementType() throw (uno::RuntimeException)
+{
+ return word::XFrame::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+SwVbaFrames::createEnumeration() throw (uno::RuntimeException)
+{
+ return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel );
+}
+
+uno::Any
+SwVbaFrames::createCollectionObject( const css::uno::Any& aSource )
+{
+ uno::Reference< text::XTextFrame > xTextFrame( aSource, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( this, mxContext, mxModel, xTextFrame ) ) );
+}
+
+rtl::OUString&
+SwVbaFrames::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFrames") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaFrames::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frames") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbaframes.hxx b/sw/source/ui/vba/vbaframes.hxx
new file mode 100644
index 000000000000..7a7a1c3d15d2
--- /dev/null
+++ b/sw/source/ui/vba/vbaframes.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_FRAMES_HXX
+#define SW_VBA_FRAMES_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XFrames.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextFramesSupplier.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XFrames > SwVbaFrames_BASE;
+
+class SwVbaFrames : public SwVbaFrames_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::text::XTextFramesSupplier > mxFramesSupplier;
+
+public:
+ SwVbaFrames( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xFrames, const css::uno::Reference< css::frame::XModel >& xModel );
+ virtual ~SwVbaFrames() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaFrames_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+#endif /* SW_VBA_FRAMES_HXX */
diff --git a/sw/source/ui/vba/vbaheadersfooters.cxx b/sw/source/ui/vba/vbaheadersfooters.cxx
new file mode 100644
index 000000000000..197e64e692d1
--- /dev/null
+++ b/sw/source/ui/vba/vbaheadersfooters.cxx
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaheadersfooters.hxx"
+#include "vbaheaderfooter.hxx"
+#include <ooo/vba/word/WdHeaderFooterIndex.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+// I assume there is only one headersfooters in Writer
+typedef ::cppu::WeakImplHelper1<container::XIndexAccess > HeadersFootersIndexAccess_Base;
+class HeadersFootersIndexAccess : public HeadersFootersIndexAccess_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< frame::XModel > mxModel;
+ uno::Reference< beans::XPropertySet > mxPageStyleProps;
+ sal_Bool mbHeader;
+
+public:
+ HeadersFootersIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, sal_Bool bHeader ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( bHeader ) {}
+ ~HeadersFootersIndexAccess(){}
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ // first page, evenpages and primary page
+ return 3;
+ }
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( Index < 1 || Index > 3 )
+ throw container::NoSuchElementException();
+ return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( mxParent, mxContext, mxModel, mxPageStyleProps, mbHeader, Index ) ) );
+ }
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return word::XHeaderFooter::static_type(0);
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+};
+
+class HeadersFootersEnumWrapper : public EnumerationHelper_BASE
+{
+ SwVbaHeadersFooters* pHeadersFooters;
+ sal_Int32 nIndex;
+public:
+ HeadersFootersEnumWrapper( SwVbaHeadersFooters* _pHeadersFooters ) : pHeadersFooters( _pHeadersFooters ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < pHeadersFooters->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < pHeadersFooters->getCount() )
+ return pHeadersFooters->Item( uno::makeAny( ++nIndex ), uno::Any() );
+ throw container::NoSuchElementException();
+ }
+};
+
+SwVbaHeadersFooters::SwVbaHeadersFooters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, sal_Bool isHeader ): SwVbaHeadersFooters_BASE( xParent, xContext, new HeadersFootersIndexAccess( xParent, xContext, xModel, xPageStyleProps, isHeader ) ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( isHeader )
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaHeadersFooters::getCount() throw (uno::RuntimeException)
+{
+ // wdHeaderFooterFirstPage, wdHeaderFooterPrimary and wdHeaderFooterEvenPages
+ return 3;
+}
+
+uno::Any SAL_CALL SwVbaHeadersFooters::Item( const uno::Any& Index1, const uno::Any& ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ Index1 >>= nIndex;
+ if( ( nIndex < 1 ) || ( nIndex > 3 ) )
+ {
+ throw container::NoSuchElementException();
+ }
+ return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( this, mxContext, mxModel, mxPageStyleProps, mbHeader, nIndex ) ) );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaHeadersFooters::getElementType() throw (uno::RuntimeException)
+{
+ return word::XHeaderFooter::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+
+SwVbaHeadersFooters::createEnumeration() throw (uno::RuntimeException)
+{
+ return new HeadersFootersEnumWrapper( this );
+}
+
+uno::Any
+SwVbaHeadersFooters::createCollectionObject( const uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaHeadersFooters::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaHeadersFooters") );
+ return sImplName;
+}
+
+uno::Sequence<rtl::OUString>
+SwVbaHeadersFooters::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.HeadersFooters") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbaheadersfooters.hxx b/sw/source/ui/vba/vbaheadersfooters.hxx
new file mode 100644
index 000000000000..f7d2ce451761
--- /dev/null
+++ b/sw/source/ui/vba/vbaheadersfooters.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_HEADERSFOOTERS_HXX
+#define SW_VBA_HEADERSFOOTERS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XHeadersFooters.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef CollTestImplHelper< ooo::vba::word::XHeadersFooters > SwVbaHeadersFooters_BASE;
+
+class SwVbaHeadersFooters : public SwVbaHeadersFooters_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps;
+ sal_Bool mbHeader;
+
+public:
+ SwVbaHeadersFooters( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps, sal_Bool isHeader );
+ virtual ~SwVbaHeadersFooters() {}
+
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& )throw (css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaHeadersFooters_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_HEADERSFOOTERS_HXX */
diff --git a/sw/source/ui/vba/vbalistformat.cxx b/sw/source/ui/vba/vbalistformat.cxx
new file mode 100644
index 000000000000..f36d7f4ac26b
--- /dev/null
+++ b/sw/source/ui/vba/vbalistformat.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalistformat.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <ooo/vba/word/WdListApplyTo.hpp>
+#include <ooo/vba/word/WdDefaultListBehavior.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "vbalisttemplate.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaListFormat::SwVbaListFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : SwVbaListFormat_BASE( rParent, rContext ), mxTextRange( xTextRange )
+{
+}
+
+SwVbaListFormat::~SwVbaListFormat()
+{
+}
+
+void SAL_CALL SwVbaListFormat::ApplyListTemplate( const css::uno::Reference< word::XListTemplate >& ListTemplate, const css::uno::Any& ContinuePreviousList, const css::uno::Any& ApplyTo, const css::uno::Any& DefaultListBehavior ) throw (css::uno::RuntimeException)
+{
+ sal_Bool bContinuePreviousList = sal_True;
+ if( ContinuePreviousList.hasValue() )
+ ContinuePreviousList >>= bContinuePreviousList;
+
+ // "applyto" must be current selection
+ sal_Int32 bApplyTo = word::WdListApplyTo::wdListApplyToSelection;
+ if( ApplyTo.hasValue() )
+ ApplyTo >>= bApplyTo;
+ if( bApplyTo != word::WdListApplyTo::wdListApplyToSelection )
+ throw uno::RuntimeException();
+
+ // default behaviour must be wdWord8ListBehavior
+ sal_Int32 nDefaultListBehavior = word::WdDefaultListBehavior::wdWord8ListBehavior;
+ if( DefaultListBehavior.hasValue() )
+ DefaultListBehavior >>= nDefaultListBehavior;
+ if( nDefaultListBehavior != word::WdDefaultListBehavior::wdWord8ListBehavior )
+ throw uno::RuntimeException();
+
+ SwVbaListTemplate* pListTemplate = dynamic_cast< SwVbaListTemplate* >( ListTemplate.get() );
+
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( mxTextRange, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
+ sal_Bool isFirstElement = sal_True;
+ while( xEnum->hasMoreElements() )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xEnum->nextElement(), uno::UNO_QUERY_THROW );
+ if( isFirstElement )
+ {
+ sal_Bool isNumberingRestart = !bContinuePreviousList;
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart") ), uno::makeAny( isNumberingRestart ) );
+ if( isNumberingRestart )
+ {
+ sal_Int16 nStartValue = 1;
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue") ), uno::makeAny( nStartValue ) );
+ }
+ isFirstElement = sal_False;
+ }
+ else
+ {
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart") ), uno::makeAny( sal_False ) );
+ }
+ pListTemplate->applyListTemplate( xProps );
+ }
+}
+
+void SAL_CALL SwVbaListFormat::ConvertNumbersToText( ) throw (css::uno::RuntimeException)
+{
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+}
+
+rtl::OUString&
+SwVbaListFormat::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListFormat") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaListFormat::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListFormat" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbalistformat.hxx b/sw/source/ui/vba/vbalistformat.hxx
new file mode 100644
index 000000000000..966870c63f80
--- /dev/null
+++ b/sw/source/ui/vba/vbalistformat.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTFORMAT_HXX
+#define SW_VBA_LISTFORMAT_HXX
+
+#include <ooo/vba/word/XListFormat.hpp>
+#include <ooo/vba/word/XListTemplate.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextRange.hpp>
+#include "vbalisthelper.hxx"
+
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListFormat > SwVbaListFormat_BASE;
+
+class SwVbaListFormat : public SwVbaListFormat_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextRange > mxTextRange;
+
+public:
+ SwVbaListFormat( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaListFormat();
+
+ // Methods
+ virtual void SAL_CALL ApplyListTemplate( const css::uno::Reference< ::ooo::vba::word::XListTemplate >& ListTemplate, const css::uno::Any& ContinuePreviousList, const css::uno::Any& ApplyTo, const css::uno::Any& DefaultListBehavior ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ConvertNumbersToText( ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_LISTFORMAT_HXX */
diff --git a/sw/source/ui/vba/vbalistgalleries.cxx b/sw/source/ui/vba/vbalistgalleries.cxx
new file mode 100644
index 000000000000..e46b531ff8be
--- /dev/null
+++ b/sw/source/ui/vba/vbalistgalleries.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalistgalleries.hxx"
+#include "vbalistgallery.hxx"
+#include <ooo/vba/word/WdListGalleryType.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class ListGalleriesEnumWrapper : public EnumerationHelper_BASE
+{
+ SwVbaListGalleries* pListGalleries;
+ sal_Int32 nIndex;
+public:
+ ListGalleriesEnumWrapper( SwVbaListGalleries* pGalleries ) : pListGalleries( pGalleries ), nIndex( 1 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex <= pListGalleries->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex <= pListGalleries->getCount() )
+ return pListGalleries->Item( uno::makeAny( nIndex++ ), uno::Any() );
+ throw container::NoSuchElementException();
+ }
+};
+
+SwVbaListGalleries::SwVbaListGalleries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc ) throw (uno::RuntimeException) : SwVbaListGalleries_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc )
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaListGalleries::getCount() throw (uno::RuntimeException)
+{
+ // 3 types of list( bullet, numbered and outline )
+ return 3;
+}
+
+uno::Any SAL_CALL SwVbaListGalleries::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ if( ( Index1 >>= nIndex ) == sal_True )
+ {
+ if( nIndex == word::WdListGalleryType::wdBulletGallery
+ || nIndex == word::WdListGalleryType::wdNumberGallery
+ || nIndex == word::WdListGalleryType::wdOutlineNumberGallery )
+ return uno::makeAny( uno::Reference< word::XListGallery >( new SwVbaListGallery( this, mxContext, mxTextDocument, nIndex ) ) );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaListGalleries::getElementType() throw (uno::RuntimeException)
+{
+ return word::XListGallery::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+SwVbaListGalleries::createEnumeration() throw (uno::RuntimeException)
+{
+ return new ListGalleriesEnumWrapper( this );
+}
+
+uno::Any
+SwVbaListGalleries::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaListGalleries::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListGalleries") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaListGalleries::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListGalleries") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbalistgalleries.hxx b/sw/source/ui/vba/vbalistgalleries.hxx
new file mode 100644
index 000000000000..c1a1566bd1e8
--- /dev/null
+++ b/sw/source/ui/vba/vbalistgalleries.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTGALLERIES_HXX
+#define SW_VBA_LISTGALLERIES_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XListGalleries.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XListGalleries > SwVbaListGalleries_BASE;
+
+class SwVbaListGalleries : public SwVbaListGalleries_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+
+public:
+ SwVbaListGalleries( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc ) throw (css::uno::RuntimeException);
+ virtual ~SwVbaListGalleries() {}
+
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaListGalleries_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_LISTGALLERIES_HXX */
diff --git a/sw/source/ui/vba/vbalistgallery.cxx b/sw/source/ui/vba/vbalistgallery.cxx
new file mode 100644
index 000000000000..62b820f43dec
--- /dev/null
+++ b/sw/source/ui/vba/vbalistgallery.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalistgallery.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include "vbalisttemplates.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaListGallery::SwVbaListGallery( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw ( uno::RuntimeException ) : SwVbaListGallery_BASE( rParent, rContext ), mxTextDocument( xTextDoc ), mnType( nType )
+{
+}
+
+SwVbaListGallery::~SwVbaListGallery()
+{
+}
+
+uno::Any SAL_CALL
+SwVbaListGallery::ListTemplates( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xCol( new SwVbaListTemplates( mxParent, mxContext, mxTextDocument, mnType ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+rtl::OUString&
+SwVbaListGallery::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListGallery") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaListGallery::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListGallery" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbalistgallery.hxx b/sw/source/ui/vba/vbalistgallery.hxx
new file mode 100644
index 000000000000..dfb6fcd9ae94
--- /dev/null
+++ b/sw/source/ui/vba/vbalistgallery.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTGALLERY_HXX
+#define SW_VBA_LISTGALLERY_HXX
+
+#include <ooo/vba/word/XListGallery.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListGallery > SwVbaListGallery_BASE;
+
+class SwVbaListGallery : public SwVbaListGallery_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ sal_Int32 mnType;
+
+public:
+ SwVbaListGallery( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaListGallery();
+
+ // Methods
+ virtual css::uno::Any SAL_CALL ListTemplates( const css::uno::Any& index ) throw ( css::uno::RuntimeException );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_LISTGALLERY_HXX */
diff --git a/sw/source/ui/vba/vbalisthelper.cxx b/sw/source/ui/vba/vbalisthelper.cxx
new file mode 100644
index 000000000000..c3a1b2b12d83
--- /dev/null
+++ b/sw/source/ui/vba/vbalisthelper.cxx
@@ -0,0 +1,707 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalisthelper.hxx"
+#include <tools/diagnose_ex.h>
+#include <ooo/vba/word/WdListGalleryType.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/NumberingType.hpp>
+#include <com/sun/star/container/XIndexReplace.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+static const sal_Int32 LIST_LEVEL_COUNT = 9;
+
+static const char WORD_BULLET_GALLERY[] = "WdBullet";
+static const char WORD_NUMBER_GALLERY[] = "WdNumber";
+static const char WORD_OUTLINE_NUMBER_GALLERY[] = "WdOutlineNumber";
+
+static const char UNO_NAME_ADJUST[] = "Adjust";
+static const char UNO_NAME_PARENT_NUMBERING[] = "ParentNumbering";
+static const char UNO_NAME_PREFIX[] = "Prefix";
+static const char UNO_NAME_SUFFIX[] = "Suffix";
+static const char UNO_NAME_CHAR_STYLE_NAME[] = "CharStyleName";
+static const char UNO_NAME_START_WITH[] = "StartWith";
+static const char UNO_NAME_POSITION_AND_SPACE_MODE[] = "PositionAndSpaceMode";
+static const char UNO_NAME_LABEL_FOLLOWED_BY[] = "LabelFollowedBy";
+static const char UNO_NAME_LIST_TAB_STOP_POSITION[] = "ListtabStopPosition";
+static const char UNO_NAME_FIRST_LINE_INDENT[] = "FirstLineIndent";
+static const char UNO_NAME_INDENT_AT[] = "IndentAt";
+static const char UNO_NAME_NUMBERING_TYPE[] = "NumberingType";
+static const char UNO_NAME_BULLET_ID[] = "BulletId";
+static const char UNO_NAME_BULLET_CHAR[] = "BulletChar";
+static const char UNO_NAME_BULLET_FONT_NAME[] = "BulletFontName";
+static const char UNO_NAME_BULLET_FONT[] = "BulletFont";
+
+static const sal_Int16 CHAR_CLOSED_DOT = 8226;
+static const sal_Int16 CHAR_EMPTY_DOT = 111;
+static const sal_Int16 CHAR_SQUARE = 9632;
+static const sal_Int16 CHAR_STAR_SYMBOL = 10026;
+static const sal_Int16 CHAR_FOUR_DIAMONDS = 10070;
+static const sal_Int16 CHAR_DIAMOND = 10022;
+static const sal_Int16 CHAR_ARROW = 10146;
+static const sal_Int16 CHAR_CHECK_MARK = 10003;
+
+SwVbaListHelper::SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw( css::uno::RuntimeException ) : mxTextDocument( xTextDoc ), mnGalleryType( nGalleryType ), mnTemplateType( nTemplateType )
+{
+ Init();
+}
+
+void SwVbaListHelper::Init() throw( css::uno::RuntimeException )
+{
+ // set the numbering style name
+ switch( mnGalleryType )
+ {
+ case word::WdListGalleryType::wdBulletGallery:
+ {
+ msStyleName = rtl::OUString::createFromAscii( WORD_BULLET_GALLERY );
+ break;
+ }
+ case word::WdListGalleryType::wdNumberGallery:
+ {
+ msStyleName = rtl::OUString::createFromAscii( WORD_NUMBER_GALLERY );
+ break;
+ }
+ case word::WdListGalleryType::wdOutlineNumberGallery:
+ {
+ msStyleName = rtl::OUString::createFromAscii( WORD_OUTLINE_NUMBER_GALLERY );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ msStyleName += rtl::OUString::valueOf( mnTemplateType );
+
+ // get the numbering style
+ uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW );
+ mxStyleFamily.set( xStyleSupplier->getStyleFamilies()->getByName(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyles") ) ), uno::UNO_QUERY_THROW );
+ OSL_TRACE("SwVbaListHelper::Init: numbering style name: %s", rtl::OUStringToOString( msStyleName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( mxStyleFamily->hasByName( msStyleName ) )
+ {
+ mxStyleProps.set( mxStyleFamily->getByName( msStyleName ), uno::UNO_QUERY_THROW );
+ mxNumberingRules.set( mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) ), uno::UNO_QUERY_THROW );
+ }
+ else
+ {
+ // create new numbering style
+ uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW );
+ mxStyleProps.set( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.NumberingStyle") ) ), uno::UNO_QUERY_THROW );
+ // insert this style into style family, or the property NumberingRules doesn't exist.
+ mxStyleFamily->insertByName( msStyleName, uno::makeAny( mxStyleProps ) );
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) ) >>= mxNumberingRules;
+ //mxNumberingRules.set( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules") ) ), uno::UNO_QUERY_THROW );
+
+ CreateListTemplate();
+
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( mxNumberingRules ) );
+ }
+}
+
+void SwVbaListHelper::CreateListTemplate() throw( css::uno::RuntimeException )
+{
+ switch( mnGalleryType )
+ {
+ case word::WdListGalleryType::wdBulletGallery:
+ {
+ CreateBulletListTemplate();
+ break;
+ }
+ case word::WdListGalleryType::wdNumberGallery:
+ {
+ CreateNumberListTemplate();
+ break;
+ }
+ case word::WdListGalleryType::wdOutlineNumberGallery:
+ {
+ CreateOutlineNumberListTemplate();
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+}
+
+void SwVbaListHelper::CreateBulletListTemplate() throw( css::uno::RuntimeException )
+{
+ // there is only 1 level for each bullet list in MSWord
+ sal_Int32 nLevel = 0;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ rtl::OUString sCharStyleName( RTL_CONSTASCII_USTRINGPARAM("Bullet Symbols") );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
+ sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+
+ rtl::OUString aBulletChar;
+ switch( mnTemplateType )
+ {
+ case 1:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
+ break;
+ }
+ case 2:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_EMPTY_DOT ) );
+ break;
+ }
+ case 3:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) );
+ break;
+ }
+ case 4:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_STAR_SYMBOL ) );
+ break;
+ }
+ case 5:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
+ break;
+ }
+ case 6:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) );
+ break;
+ }
+ case 7:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_CHECK_MARK ) );
+ break;
+ }
+ default:
+ {
+ // we only support 7 types template now
+ throw css::uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_BULLET_CHAR ), uno::makeAny( aBulletChar ) );
+
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+}
+
+void SwVbaListHelper::CreateNumberListTemplate() throw( css::uno::RuntimeException )
+{
+ // there is only 1 level for each bullet list in MSWord
+ sal_Int32 nLevel = 0;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+
+ sal_Int16 nNumberingType = 0;
+ rtl::OUString sSuffix;
+ switch( mnTemplateType )
+ {
+ case 1:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 2:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 3:
+ {
+ nNumberingType = style::NumberingType::ROMAN_UPPER;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 4:
+ {
+ nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 5:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 6:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 7:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ default:
+ {
+ // we only support 7 types template now
+ throw css::uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
+
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+}
+
+void SwVbaListHelper::CreateOutlineNumberListTemplate() throw( css::uno::RuntimeException )
+{
+ switch( mnTemplateType )
+ {
+ case 1:
+ {
+ CreateOutlineNumberForType1();
+ break;
+ }
+ case 2:
+ {
+ CreateOutlineNumberForType2();
+ break;
+ }
+ case 3:
+ {
+ CreateOutlineNumberForType3();
+ break;
+ }
+ case 4:
+ {
+ CreateOutlineNumberForType4();
+ break;
+ }
+ case 5:
+ {
+ CreateOutlineNumberForType5();
+ break;
+ }
+ case 6:
+ {
+ CreateOutlineNumberForType6();
+ break;
+ }
+ case 7:
+ {
+ CreateOutlineNumberForType7();
+ break;
+ }
+ default:
+ {
+ // we only support 7 types template now
+ throw css::uno::RuntimeException();
+ }
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType1() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = 0;
+ rtl::OUString sPrefix;
+ rtl::OUString sSuffix;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ switch( nLevel )
+ {
+ case 0:
+ case 1:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 2:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 3:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 4:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 5:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 6:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 7:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 8:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType2() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = style::NumberingType::ARABIC;
+ sal_Int16 nParentNumbering = 0;
+ rtl::OUString sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
+ if( nLevel != 0 )
+ {
+ nParentNumbering = sal_Int16( nLevel - 1 );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
+ }
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType3() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL;
+ rtl::OUString sCharStyleName( RTL_CONSTASCII_USTRINGPARAM("Bullet Symbols") );
+ rtl::OUString aBulletChar;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_CHAR_STYLE_NAME ), uno::makeAny( sCharStyleName ) );
+ switch( nLevel )
+ {
+ case 0:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) );
+ break;
+ }
+ case 1:
+ case 5:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) );
+ break;
+ }
+ case 2:
+ case 6:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) );
+ break;
+ }
+ case 3:
+ case 7:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) );
+ break;
+ }
+ case 4:
+ case 8:
+ {
+ aBulletChar = rtl::OUString( sal_Unicode( CHAR_DIAMOND ) );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_BULLET_CHAR ), uno::makeAny( aBulletChar ) );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType4() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = 0;
+ rtl::OUString sPrefix;
+ rtl::OUString sSuffix;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ switch( nLevel )
+ {
+ case 0:
+ {
+ nNumberingType = style::NumberingType::ROMAN_UPPER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 1:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ sal_Int16 nParentNumbering = 0;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
+ break;
+ }
+ case 2:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 3:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 4:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 5:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 6:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 7:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 8:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType5() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = style::NumberingType::ARABIC;
+ sal_Int16 nParentNumbering = 0;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ if( nLevel != 0 )
+ {
+ nParentNumbering = sal_Int16( nLevel - 1 );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PARENT_NUMBERING ), uno::makeAny( nParentNumbering ) );
+ }
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType6() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = 0;
+ rtl::OUString sPrefix;
+ rtl::OUString sSuffix;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ switch( nLevel )
+ {
+ case 0:
+ {
+ nNumberingType = style::NumberingType::ROMAN_UPPER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 1:
+ {
+ nNumberingType = style::NumberingType::CHARS_UPPER_LETTER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 2:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 3:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString();
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 4:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 5:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 6:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode(')') );
+ break;
+ }
+ case 7:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ case 8:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ sPrefix = rtl::OUString::valueOf( sal_Unicode('(') );
+ sSuffix = rtl::OUString::valueOf( sal_Unicode('.') );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_SUFFIX ), uno::makeAny( sSuffix ) );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+void SwVbaListHelper::CreateOutlineNumberForType7() throw( css::uno::RuntimeException )
+{
+ sal_Int16 nNumberingType = style::NumberingType::ARABIC;
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+ rtl::OUString sPrefix = rtl::OUString::createFromAscii("Chapter ");
+
+ for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ )
+ {
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_NUMBERING_TYPE ), uno::makeAny( nNumberingType ) );
+ setOrAppendPropertyValue( aPropertyValues, rtl::OUString::createFromAscii( UNO_NAME_PREFIX ), uno::makeAny( sPrefix ) );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ }
+}
+
+uno::Any SwVbaListHelper::getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName ) throw( css::uno::RuntimeException )
+{
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ return getPropertyValue( aPropertyValues, sName );
+}
+
+void SwVbaListHelper::setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException )
+{
+ uno::Sequence< beans::PropertyValue > aPropertyValues;
+ mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues;
+ setOrAppendPropertyValue( aPropertyValues, sName, aValue );
+ mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) );
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( mxNumberingRules ) );
+}
+
diff --git a/sw/source/ui/vba/vbalisthelper.hxx b/sw/source/ui/vba/vbalisthelper.hxx
new file mode 100644
index 000000000000..0f5fa2681ba2
--- /dev/null
+++ b/sw/source/ui/vba/vbalisthelper.hxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile$
+ *
+ * $Revision$
+ *
+ * last change: $Author$ $Date$
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTHELPER_HXX
+#define SW_VBA_LISTHELPER_HXX
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/container/XIndexReplace.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <boost/shared_ptr.hpp>
+
+
+class SwVbaListHelper;
+typedef ::boost::shared_ptr< SwVbaListHelper > SwVbaListHelperRef;
+
+class SwVbaListHelper
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ css::uno::Reference< css::container::XIndexReplace > mxNumberingRules;
+ css::uno::Reference< css::container::XNameContainer > mxStyleFamily;
+ css::uno::Reference< css::beans::XPropertySet > mxStyleProps;
+ sal_Int32 mnGalleryType;
+ sal_Int32 mnTemplateType;
+ rtl::OUString msStyleName;
+
+ void Init() throw( css::uno::RuntimeException );
+ void CreateListTemplate() throw( css::uno::RuntimeException );
+ void CreateBulletListTemplate() throw( css::uno::RuntimeException );
+ void CreateNumberListTemplate() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberListTemplate() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType1() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType2() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType3() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType4() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType5() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType6() throw( css::uno::RuntimeException );
+ void CreateOutlineNumberForType7() throw( css::uno::RuntimeException );
+
+public:
+ SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw( css::uno::RuntimeException );
+
+ sal_Int32 getGalleryType() { return mnGalleryType; }
+ css::uno::Reference< css::container::XIndexReplace > getNumberingRules() { return mxNumberingRules; }
+ css::uno::Any getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName ) throw( css::uno::RuntimeException );
+ void setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException );
+
+};
+
+#endif//SW_VBA_LISTHELPER_HXX
diff --git a/sw/source/ui/vba/vbalistlevel.cxx b/sw/source/ui/vba/vbalistlevel.cxx
new file mode 100644
index 000000000000..6362b3ac2457
--- /dev/null
+++ b/sw/source/ui/vba/vbalistlevel.cxx
@@ -0,0 +1,401 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalistlevel.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/style/NumberingType.hpp>
+#include <ooo/vba/word/WdListNumberStyle.hpp>
+#include <ooo/vba/word/WdTrailingCharacter.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <ooo/vba/word/WdListLevelAlignment.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaListLevel::SwVbaListLevel( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) throw ( uno::RuntimeException ) : SwVbaListLevel_BASE( rParent, rContext ), pListHelper( pHelper ), mnLevel( nLevel )
+{
+}
+
+SwVbaListLevel::~SwVbaListLevel()
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getAlignment() throw (uno::RuntimeException)
+{
+ sal_Int16 nAlignment = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ) ) >>= nAlignment;
+ switch( nAlignment )
+ {
+ case text::HoriOrientation::LEFT:
+ {
+ nAlignment = word::WdListLevelAlignment::wdListLevelAlignLeft;
+ break;
+ }
+ case text::HoriOrientation::RIGHT:
+ {
+ nAlignment = word::WdListLevelAlignment::wdListLevelAlignRight;
+ break;
+ }
+ case text::HoriOrientation::CENTER:
+ {
+ nAlignment = word::WdListLevelAlignment::wdListLevelAlignCenter;
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ return nAlignment;
+}
+
+void SAL_CALL SwVbaListLevel::setAlignment( ::sal_Int32 _alignment ) throw (uno::RuntimeException)
+{
+ sal_Int16 nAlignment = text::HoriOrientation::LEFT;
+ switch( _alignment )
+ {
+ case word::WdListLevelAlignment::wdListLevelAlignLeft:
+ {
+ nAlignment = text::HoriOrientation::LEFT;
+ break;
+ }
+ case word::WdListLevelAlignment::wdListLevelAlignRight:
+ {
+ nAlignment = text::HoriOrientation::RIGHT;
+ break;
+ }
+ case word::WdListLevelAlignment::wdListLevelAlignCenter:
+ {
+ nAlignment = text::HoriOrientation::CENTER;
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ), uno::makeAny( nAlignment ) );
+}
+
+uno::Reference< ::ooo::vba::word::XFont > SAL_CALL SwVbaListLevel::getFont() throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ return uno::Reference< word::XFont >();
+}
+
+void SAL_CALL SwVbaListLevel::setFont( const uno::Reference< ::ooo::vba::word::XFont >& /*_font*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getIndex() throw (uno::RuntimeException)
+{
+ return mnLevel + 1;
+}
+
+::rtl::OUString SAL_CALL SwVbaListLevel::getLinkedStyle() throw (uno::RuntimeException)
+{
+ // TODO:
+ return rtl::OUString();
+}
+
+void SAL_CALL SwVbaListLevel::setLinkedStyle( const ::rtl::OUString& /*_linkedstyle*/ ) throw (uno::RuntimeException)
+{
+ // TODO:
+}
+
+::rtl::OUString SAL_CALL SwVbaListLevel::getNumberFormat() throw (uno::RuntimeException)
+{
+ // TODO::
+ return rtl::OUString();
+}
+
+void SAL_CALL SwVbaListLevel::setNumberFormat( const ::rtl::OUString& /*_numberformat*/ ) throw (uno::RuntimeException)
+{
+ // TODO::
+}
+
+float SAL_CALL SwVbaListLevel::getNumberPosition() throw (uno::RuntimeException)
+{
+ // indentAt + firstlineindent
+ sal_Int32 nIndentAt = 0;
+ sal_Int32 nFirstLineIndent = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent;
+
+ sal_Int32 nResult = nIndentAt + nFirstLineIndent;
+
+ return static_cast< float >( Millimeter::getInPoints( nResult ) );
+}
+
+void SAL_CALL SwVbaListLevel::setNumberPosition( float _numberposition ) throw (uno::RuntimeException)
+{
+ sal_Int32 nNumberPosition = Millimeter::getInHundredthsOfOneMillimeter( _numberposition );
+
+ sal_Int32 nIndentAt = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
+
+ sal_Int32 nFirstLineIndent = nNumberPosition - nIndentAt;
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getNumberStyle() throw (uno::RuntimeException)
+{
+ sal_Int16 nNumberingType = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ) ) >>= nNumberingType;
+ switch( nNumberingType )
+ {
+ case style::NumberingType::CHAR_SPECIAL:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleBullet;
+ break;
+ }
+ case style::NumberingType::CHARS_UPPER_LETTER:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseLetter;
+ break;
+ }
+ case style::NumberingType::CHARS_LOWER_LETTER:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseLetter;
+ break;
+ }
+ case style::NumberingType::ROMAN_UPPER:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseRoman;
+ break;
+ }
+ case style::NumberingType::ROMAN_LOWER:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseRoman;
+ break;
+ }
+ case style::NumberingType::ARABIC:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabic;
+ break;
+ }
+ case style::NumberingType::NUMBER_NONE:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleNone;
+ break;
+ }
+ case style::NumberingType::FULLWIDTH_ARABIC:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabicFullWidth;
+ break;
+ }
+ case style::NumberingType::CIRCLE_NUMBER:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleNumberInCircle;
+ break;
+ }
+ case style::NumberingType::CHARS_ARABIC:
+ {
+ nNumberingType = word::WdListNumberStyle::wdListNumberStyleCardinalText;
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ }
+ return nNumberingType;
+}
+
+void SAL_CALL SwVbaListLevel::setNumberStyle( ::sal_Int32 _numberstyle ) throw (uno::RuntimeException)
+{
+ sal_Int16 nNumberingType = 0;
+ switch( _numberstyle )
+ {
+ case word::WdListNumberStyle::wdListNumberStyleBullet:
+ {
+ nNumberingType = style::NumberingType::CHAR_SPECIAL;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleUppercaseLetter:
+ {
+ nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleLowercaseLetter:
+ {
+ nNumberingType = style::NumberingType::CHARS_LOWER_LETTER_N;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleUppercaseRoman:
+ {
+ nNumberingType = style::NumberingType::ROMAN_UPPER;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleLowercaseRoman:
+ {
+ nNumberingType = style::NumberingType::ROMAN_LOWER;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleArabic:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleNone:
+ {
+ nNumberingType = style::NumberingType::NUMBER_NONE;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleArabicFullWidth:
+ {
+ nNumberingType = style::NumberingType::FULLWIDTH_ARABIC;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleNumberInCircle:
+ {
+ nNumberingType = style::NumberingType::CIRCLE_NUMBER;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleCardinalText:
+ {
+ nNumberingType = style::NumberingType::CHARS_ARABIC;
+ break;
+ }
+ case word::WdListNumberStyle::wdListNumberStyleOrdinal:
+ case word::WdListNumberStyle::wdListNumberStyleOrdinalText:
+ case word::WdListNumberStyle::wdListNumberStyleKanji:
+ case word::WdListNumberStyle::wdListNumberStyleKanjiDigit:
+ case word::WdListNumberStyle::wdListNumberStyleAiueoHalfWidth:
+ case word::WdListNumberStyle::wdListNumberStyleIrohaHalfWidth:
+ {
+ nNumberingType = style::NumberingType::ARABIC;
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ }
+
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ), uno::makeAny( nNumberingType ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getResetOnHigher() throw (uno::RuntimeException)
+{
+ //seems not support?
+ return 0;
+}
+
+void SAL_CALL SwVbaListLevel::setResetOnHigher( ::sal_Int32 /*_resetonhigher*/ ) throw (uno::RuntimeException)
+{
+ //seems not support?
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getStartAt() throw (uno::RuntimeException)
+{
+ sal_Int16 nStartWith = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ) ) >>= nStartWith;
+ return nStartWith;
+}
+
+void SAL_CALL SwVbaListLevel::setStartAt( ::sal_Int32 _startat ) throw (uno::RuntimeException)
+{
+ sal_Int16 nStartWith = (sal_Int16)_startat;
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ), uno::makeAny( nStartWith ) );
+}
+
+float SAL_CALL SwVbaListLevel::getTabPosition() throw (uno::RuntimeException)
+{
+ sal_Int32 nTabPosition = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ) ) >>= nTabPosition;
+
+ return static_cast< float >( Millimeter::getInPoints( nTabPosition ) );
+}
+
+void SAL_CALL SwVbaListLevel::setTabPosition( float _tabposition ) throw (uno::RuntimeException)
+{
+ sal_Int32 nTabPosition = Millimeter::getInHundredthsOfOneMillimeter( _tabposition );
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ), uno::makeAny( nTabPosition ) );
+}
+
+float SAL_CALL SwVbaListLevel::getTextPosition() throw (uno::RuntimeException)
+{
+ // indentAt
+ sal_Int32 nIndentAt = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
+
+ return static_cast< float >( Millimeter::getInPoints( nIndentAt ) );
+}
+
+void SAL_CALL SwVbaListLevel::setTextPosition( float _textposition ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndentAt = 0;
+ sal_Int32 nFirstLineIndent = 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent;
+
+ sal_Int32 nAlignedAt = nIndentAt + nFirstLineIndent;
+
+ nIndentAt = Millimeter::getInHundredthsOfOneMillimeter( _textposition );
+ nFirstLineIndent = nAlignedAt - nIndentAt;
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ), uno::makeAny( nIndentAt ) );
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevel::getTrailingCharacter() throw (uno::RuntimeException)
+{
+ sal_Int16 nLabelFollowedBy= 0;
+ pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ) ) >>= nLabelFollowedBy;
+
+ return nLabelFollowedBy;
+}
+
+void SAL_CALL SwVbaListLevel::setTrailingCharacter( ::sal_Int32 _trailingcharacter ) throw (uno::RuntimeException)
+{
+ sal_Int16 nLabelFollowedBy = (sal_Int16)_trailingcharacter;
+ pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ), uno::makeAny( nLabelFollowedBy ) );
+}
+
+rtl::OUString&
+SwVbaListLevel::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevel") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaListLevel::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevel" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbalistlevel.hxx b/sw/source/ui/vba/vbalistlevel.hxx
new file mode 100644
index 000000000000..9f9d1b10558c
--- /dev/null
+++ b/sw/source/ui/vba/vbalistlevel.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTLEVEL_HXX
+#define SW_VBA_LISTLEVEL_HXX
+
+#include <ooo/vba/word/XListLevel.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include "vbalisthelper.hxx"
+
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListLevel > SwVbaListLevel_BASE;
+
+class SwVbaListLevel : public SwVbaListLevel_BASE
+{
+private:
+ SwVbaListHelperRef pListHelper;
+ sal_Int32 mnLevel;
+
+public:
+ SwVbaListLevel( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaListLevel();
+
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getAlignment() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAlignment( ::sal_Int32 _alignment ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::word::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFont( const css::uno::Reference< ::ooo::vba::word::XFont >& _font ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getIndex() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLinkedStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLinkedStyle( const ::rtl::OUString& _linkedstyle ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumberFormat() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNumberFormat( const ::rtl::OUString& _numberformat ) throw (css::uno::RuntimeException);
+ virtual float SAL_CALL getNumberPosition() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNumberPosition( float _numberposition ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getNumberStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNumberStyle( ::sal_Int32 _numberstyle ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getResetOnHigher() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setResetOnHigher( ::sal_Int32 _resetonhigher ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getStartAt() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStartAt( ::sal_Int32 _startat ) throw (css::uno::RuntimeException);
+ virtual float SAL_CALL getTabPosition() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTabPosition( float _tabposition ) throw (css::uno::RuntimeException);
+ virtual float SAL_CALL getTextPosition() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTextPosition( float _textposition ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getTrailingCharacter() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTrailingCharacter( ::sal_Int32 _trailingcharacter ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_LISTLEVEL_HXX */
diff --git a/sw/source/ui/vba/vbalistlevels.cxx b/sw/source/ui/vba/vbalistlevels.cxx
new file mode 100644
index 000000000000..0d3604a06bdf
--- /dev/null
+++ b/sw/source/ui/vba/vbalistlevels.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalistlevels.hxx"
+#include "vbalistlevel.hxx"
+#include <ooo/vba/word/WdListGalleryType.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class ListLevelsEnumWrapper : public EnumerationHelper_BASE
+{
+ SwVbaListLevels* pListLevels;
+ sal_Int32 nIndex;
+public:
+ ListLevelsEnumWrapper( SwVbaListLevels* pLevels ) : pListLevels( pLevels ), nIndex( 1 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex <= pListLevels->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex <= pListLevels->getCount() )
+ return pListLevels->Item( uno::makeAny( nIndex++ ), uno::Any() );
+ throw container::NoSuchElementException();
+ }
+};
+
+SwVbaListLevels::SwVbaListLevels( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, SwVbaListHelperRef pHelper ) throw (uno::RuntimeException) : SwVbaListLevels_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), pListHelper( pHelper )
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaListLevels::getCount() throw (uno::RuntimeException)
+{
+ sal_Int32 nGalleryType = pListHelper->getGalleryType();
+ if( nGalleryType == word::WdListGalleryType::wdBulletGallery
+ || nGalleryType == word::WdListGalleryType::wdNumberGallery )
+ return 1;
+ else if( nGalleryType == word::WdListGalleryType::wdOutlineNumberGallery )
+ return 9;
+ return 0;
+}
+
+uno::Any SAL_CALL SwVbaListLevels::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ if( ( Index1 >>= nIndex ) == sal_False )
+ throw uno::RuntimeException();
+ if( nIndex <=0 || nIndex > getCount() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+
+ return uno::makeAny( uno::Reference< word::XListLevel >( new SwVbaListLevel( this, mxContext, pListHelper, nIndex - 1 ) ) );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaListLevels::getElementType() throw (uno::RuntimeException)
+{
+ return word::XListLevel::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+SwVbaListLevels::createEnumeration() throw (uno::RuntimeException)
+{
+ return new ListLevelsEnumWrapper( this );
+}
+
+uno::Any
+SwVbaListLevels::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaListLevels::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevels") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaListLevels::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevels") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbalistlevels.hxx b/sw/source/ui/vba/vbalistlevels.hxx
new file mode 100644
index 000000000000..70774bdb6b30
--- /dev/null
+++ b/sw/source/ui/vba/vbalistlevels.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTLEVELS_HXX
+#define SW_VBA_LISTLEVELS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XListLevels.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include "vbalisthelper.hxx"
+
+
+typedef CollTestImplHelper< ooo::vba::word::XListLevels > SwVbaListLevels_BASE;
+
+class SwVbaListLevels : public SwVbaListLevels_BASE
+{
+private:
+ SwVbaListHelperRef pListHelper;
+
+public:
+ SwVbaListLevels( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaListLevels() {}
+
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaListLevels_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_LISTLEVELS_HXX */
diff --git a/sw/source/ui/vba/vbalisttemplate.cxx b/sw/source/ui/vba/vbalisttemplate.cxx
new file mode 100644
index 000000000000..f17c8fdd52df
--- /dev/null
+++ b/sw/source/ui/vba/vbalisttemplate.cxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalisttemplate.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include "vbalistlevels.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaListTemplate::SwVbaListTemplate( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw ( uno::RuntimeException ) : SwVbaListTemplate_BASE( rParent, rContext )
+{
+ pListHelper.reset( new SwVbaListHelper( xTextDoc, nGalleryType, nTemplateType ) );
+}
+
+SwVbaListTemplate::~SwVbaListTemplate()
+{
+}
+
+uno::Any SAL_CALL
+SwVbaListTemplate::ListLevels( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xCol( new SwVbaListLevels( mxParent, mxContext, pListHelper ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+void SwVbaListTemplate::applyListTemplate( uno::Reference< beans::XPropertySet >& xProps ) throw (uno::RuntimeException)
+{
+ uno::Reference< container::XIndexReplace > xNumberingRules = pListHelper->getNumberingRules();
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( xNumberingRules ) );
+}
+
+rtl::OUString&
+SwVbaListTemplate::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListTemplate") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaListTemplate::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListTemplate" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbalisttemplate.hxx b/sw/source/ui/vba/vbalisttemplate.hxx
new file mode 100644
index 000000000000..408f6b8fa6be
--- /dev/null
+++ b/sw/source/ui/vba/vbalisttemplate.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTTEMPLATE_HXX
+#define SW_VBA_LISTTEMPLATE_HXX
+
+#include <ooo/vba/word/XListTemplate.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include "vbalisthelper.hxx"
+
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListTemplate > SwVbaListTemplate_BASE;
+
+class SwVbaListTemplate : public SwVbaListTemplate_BASE
+{
+private:
+ SwVbaListHelperRef pListHelper;
+
+public:
+ SwVbaListTemplate( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaListTemplate();
+
+ void applyListTemplate( css::uno::Reference< css::beans::XPropertySet >& xProps ) throw ( css::uno::RuntimeException );
+
+ // Methods
+ virtual css::uno::Any SAL_CALL ListLevels( const css::uno::Any& index ) throw ( css::uno::RuntimeException );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_LISTTEMPLATE_HXX */
diff --git a/sw/source/ui/vba/vbalisttemplates.cxx b/sw/source/ui/vba/vbalisttemplates.cxx
new file mode 100644
index 000000000000..6fd3c4811e9b
--- /dev/null
+++ b/sw/source/ui/vba/vbalisttemplates.cxx
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbalisttemplates.hxx"
+#include "vbalisttemplate.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class ListTemplatesEnumWrapper : public EnumerationHelper_BASE
+{
+ SwVbaListTemplates* pListTemplates;
+ sal_Int32 nIndex;
+public:
+ ListTemplatesEnumWrapper( SwVbaListTemplates* pTemplates ) : pListTemplates( pTemplates ), nIndex( 1 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex <= pListTemplates->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex <= pListTemplates->getCount() )
+ return pListTemplates->Item( uno::makeAny( nIndex++ ), uno::Any() );
+ throw container::NoSuchElementException();
+ }
+};
+
+SwVbaListTemplates::SwVbaListTemplates( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw (uno::RuntimeException) : SwVbaListTemplates_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc ), mnGalleryType( nType )
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaListTemplates::getCount() throw (uno::RuntimeException)
+{
+ // 3 types of list( bullet, numbered and outline )
+ return 7;
+}
+
+uno::Any SAL_CALL SwVbaListTemplates::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ if( ( Index1 >>= nIndex ) == sal_False )
+ throw uno::RuntimeException();
+ if( nIndex <=0 || nIndex > getCount() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+
+ return uno::makeAny( uno::Reference< word::XListTemplate >( new SwVbaListTemplate( this, mxContext, mxTextDocument, mnGalleryType, nIndex ) ) );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaListTemplates::getElementType() throw (uno::RuntimeException)
+{
+ return word::XListTemplate::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+SwVbaListTemplates::createEnumeration() throw (uno::RuntimeException)
+{
+ return new ListTemplatesEnumWrapper( this );
+}
+
+uno::Any
+SwVbaListTemplates::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaListTemplates::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListTemplates") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaListTemplates::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListTemplates") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbalisttemplates.hxx b/sw/source/ui/vba/vbalisttemplates.hxx
new file mode 100644
index 000000000000..431f89183972
--- /dev/null
+++ b/sw/source/ui/vba/vbalisttemplates.hxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_LISTTEMPLATES_HXX
+#define SW_VBA_LISTTEMPLATES_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XListTemplates.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XListTemplates > SwVbaListTemplates_BASE;
+
+class SwVbaListTemplates : public SwVbaListTemplates_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ sal_Int32 mnGalleryType;
+
+public:
+ SwVbaListTemplates( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw (css::uno::RuntimeException);
+ virtual ~SwVbaListTemplates() {}
+
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaListTemplates_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_LISTTEMPLATES_HXX */
diff --git a/sw/source/ui/vba/vbarevision.cxx b/sw/source/ui/vba/vbarevision.cxx
new file mode 100644
index 000000000000..cc2ffa8fbb6d
--- /dev/null
+++ b/sw/source/ui/vba/vbarevision.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbarevision.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/document/XRedlinesSupplier.hpp>
+#include "wordvbahelper.hxx"
+#include <docsh.hxx>
+#include <doc.hxx>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xRedlineProps ) throw ( uno::RuntimeException ) : SwVbaRevision_BASE( rParent, rContext ), mxModel( xModel ), mxRedlineProps( xRedlineProps )
+{
+}
+
+SwVbaRevision::~SwVbaRevision()
+{
+}
+
+sal_Int32 SwVbaRevision::GetPosition() throw (css::uno::RuntimeException)
+{
+ sal_Int32 nPos = -1;
+ uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
+ sal_Int32 nCount = xRedlines->getCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW );
+ if( xProps == mxRedlineProps )
+ {
+ nPos = i;
+ OSL_TRACE(" SwVbaRevision::SwVbaRevision, the redline position is %d, ", nPos );
+ break;
+ }
+ }
+ if( nPos == -1 )
+ throw uno::RuntimeException();
+
+ return nPos;
+}
+
+void SAL_CALL
+SwVbaRevision::Accept() throw ( css::uno::RuntimeException )
+{
+ SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
+ if( pDoc )
+ pDoc->AcceptRedline( GetPosition(), sal_True );
+}
+
+void SAL_CALL
+SwVbaRevision::Reject( ) throw ( css::uno::RuntimeException )
+{
+ SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc();
+ if( pDoc )
+ pDoc->RejectRedline( GetPosition(), sal_True );
+}
+
+rtl::OUString&
+SwVbaRevision::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRevision") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaRevision::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Revision" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbarevision.hxx b/sw/source/ui/vba/vbarevision.hxx
new file mode 100644
index 000000000000..7f8adbe1b4be
--- /dev/null
+++ b/sw/source/ui/vba/vbarevision.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_REVISION_HXX
+#define SW_VBA_REVISION_HXX
+
+#include <ooo/vba/word/XRevision.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRevision > SwVbaRevision_BASE;
+
+class SwVbaRevision : public SwVbaRevision_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::beans::XPropertySet > mxRedlineProps;
+
+private:
+ sal_Int32 GetPosition() throw (css::uno::RuntimeException);
+
+public:
+ SwVbaRevision( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xRedlineProps ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaRevision();
+
+ // Methods
+ virtual void SAL_CALL Accept( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Reject( ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_REVISION_HXX */
diff --git a/sw/source/ui/vba/vbarevisions.cxx b/sw/source/ui/vba/vbarevisions.cxx
new file mode 100644
index 000000000000..be7120063d7e
--- /dev/null
+++ b/sw/source/ui/vba/vbarevisions.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbarevisions.hxx"
+#include "vbarevision.hxx"
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/document/XRedlinesSupplier.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > RevisionEnumeration_BASE;
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > RevisionCollectionHelper_BASE;
+typedef std::vector< uno::Reference< beans::XPropertySet > > RevisionMap;
+
+class RedlinesEnumeration : public RevisionEnumeration_BASE
+{
+ RevisionMap mRevisionMap;
+ RevisionMap::iterator mIt;
+public:
+ RedlinesEnumeration( const RevisionMap& sMap ) : mRevisionMap( sMap ), mIt( mRevisionMap.begin() ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( mIt != mRevisionMap.end() );
+ }
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ uno::Reference< beans::XPropertySet > xRevision( *mIt++ );
+ return uno::makeAny( xRevision ) ;
+ }
+};
+
+class RevisionCollectionHelper : public RevisionCollectionHelper_BASE
+{
+ RevisionMap mRevisionMap;
+public:
+RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw (uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return beans::XPropertySet::static_type(0); }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return ( mRevisionMap.size() > 0 ); }
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) { return mRevisionMap.size(); }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ return uno::makeAny( mRevisionMap[ Index ] );
+
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new RedlinesEnumeration( mRevisionMap );
+ }
+};
+
+RevisionCollectionHelper::RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw (uno::RuntimeException)
+ {
+ uno::Reference< text::XTextRangeCompare > xTRC( xTextRange->getText(), uno::UNO_QUERY_THROW );
+ uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
+ sal_Int32 nCount = xRedlines->getCount();
+ for( sal_Int32 index = 0; index < nCount; index++ )
+ {
+ uno::Reference< text::XTextRange > xRedlineRange( xRedlines->getByIndex( index ), uno::UNO_QUERY_THROW );
+ if( xTRC->compareRegionStarts( xTextRange, xRedlineRange ) >= 0 && xTRC->compareRegionEnds( xTextRange, xRedlineRange ) <= 0 )
+ {
+ uno::Reference< beans::XPropertySet > xRedlineProps( xRedlineRange, uno::UNO_QUERY_THROW );
+ mRevisionMap.push_back( xRedlineProps );
+ }
+ }
+ }
+class RevisionsEnumeration : public EnumerationHelperImpl
+{
+ uno::Reference< frame::XModel > m_xModel;
+public:
+ RevisionsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ) {}
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Reference< beans::XPropertySet > xRevision( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XRevision > ( new SwVbaRevision( m_xParent, m_xContext, m_xModel, xRevision ) ) );
+ }
+
+};
+
+SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ): SwVbaRevisions_BASE( xParent, xContext, new RevisionCollectionHelper( xModel, xTextRange ) ), mxModel( xModel )
+{
+}
+
+SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< container::XIndexAccess >& xIndexAccess ): SwVbaRevisions_BASE( xParent, xContext, xIndexAccess ), mxModel( xModel )
+{
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaRevisions::getElementType() throw (uno::RuntimeException)
+{
+ return word::XRevision::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaRevisions::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return new RevisionsEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel );
+}
+
+uno::Any
+SwVbaRevisions::createCollectionObject( const css::uno::Any& aSource )
+{
+ uno::Reference< beans::XPropertySet > xRevision( aSource, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XRevision > ( new SwVbaRevision( this, mxContext, mxModel, xRevision ) ) );
+}
+
+void SAL_CALL SwVbaRevisions::AcceptAll( ) throw (css::uno::RuntimeException)
+{
+ // First we need to put all the redline into a vector, because if the redline is accepted,
+ // it will auto delete in the document.
+ std::vector< uno::Reference< word::XRevision > > aRevisions;
+ uno::Reference< container::XEnumeration > xEnumeration = createEnumeration();
+ while( xEnumeration->hasMoreElements() )
+ {
+ uno::Reference< word::XRevision > xRevision( xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ aRevisions.push_back( xRevision );
+ }
+
+ std::vector< uno::Reference< word::XRevision > >::iterator it = aRevisions.begin();
+ for( ; it != aRevisions.end(); it++ )
+ {
+ uno::Reference< word::XRevision > xRevision( *it );
+ xRevision->Accept();
+ }
+}
+
+void SAL_CALL SwVbaRevisions::RejectAll( ) throw (css::uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+rtl::OUString&
+SwVbaRevisions::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRevisions") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaRevisions::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Revisions") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbarevisions.hxx b/sw/source/ui/vba/vbarevisions.hxx
new file mode 100644
index 000000000000..b299e713ea14
--- /dev/null
+++ b/sw/source/ui/vba/vbarevisions.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_PANES_HXX
+#define SW_VBA_PANES_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XRevisions.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextRange.hpp>
+
+
+typedef CollTestImplHelper< ooo::vba::word::XRevisions > SwVbaRevisions_BASE;
+
+class SwVbaRevisions : public SwVbaRevisions_BASE
+{
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+
+public:
+ SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange );
+
+ SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ virtual ~SwVbaRevisions() {}
+
+ // Methods
+ virtual void SAL_CALL AcceptAll( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL RejectAll( ) throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaRevisions_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_PANES_HXX */
diff --git a/sw/source/ui/vba/vbarow.cxx b/sw/source/ui/vba/vbarow.cxx
new file mode 100644
index 000000000000..3ffe9d024389
--- /dev/null
+++ b/sw/source/ui/vba/vbarow.cxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbarow.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <ooo/vba/word/WdRowHeightRule.hpp>
+#include <ooo/vba/word/WdConstants.hpp>
+#include <rtl/ustrbuf.hxx>
+#include "wordvbahelper.hxx"
+#include "vbatablehelper.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaRow::SwVbaRow( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( uno::RuntimeException ) :
+ SwVbaRow_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex )
+{
+ mxTableRows = mxTextTable->getRows();
+ mxRowProps.set( mxTableRows->getByIndex( mnIndex ), uno::UNO_QUERY_THROW );
+}
+
+SwVbaRow::~SwVbaRow()
+{
+}
+
+uno::Any SAL_CALL SwVbaRow::getHeight() throw (css::uno::RuntimeException)
+{
+ if( getHeightRule() == word::WdRowHeightRule::wdRowHeightAuto )
+ return uno::makeAny( sal_Int32( word::WdConstants::wdUndefined ) );
+
+ sal_Int32 nHeight = 0;
+ mxRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) ) >>= nHeight;
+ return uno::makeAny( (float)Millimeter::getInPoints( nHeight ) );
+}
+
+void SAL_CALL SwVbaRow::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException)
+{
+ float height = 0;
+ _height >>= height;
+
+ sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( height );
+ mxRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), uno::makeAny( nHeight ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaRow::getHeightRule() throw (css::uno::RuntimeException)
+{
+ sal_Bool isAutoHeight = sal_False;
+ mxRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoHeight") ) ) >>= isAutoHeight;
+ return isAutoHeight ? word::WdRowHeightRule::wdRowHeightAuto : word::WdRowHeightRule::wdRowHeightExactly;
+}
+
+void SAL_CALL SwVbaRow::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException)
+{
+ sal_Bool isAutoHeight = ( _heightrule == word::WdRowHeightRule::wdRowHeightAuto );
+ mxRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoHeight") ), uno::makeAny( isAutoHeight ) );
+}
+
+void SAL_CALL
+SwVbaRow::Select( ) throw ( uno::RuntimeException )
+{
+ SelectRow( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex );
+}
+
+void SwVbaRow::SelectRow( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow ) throw ( uno::RuntimeException )
+{
+ rtl::OUStringBuffer aRangeName;
+ aRangeName.appendAscii("A").append(sal_Int32( nStartRow + 1 ) );
+ SwVbaTableHelper aTableHelper( xTextTable );
+ sal_Int32 nColCount = aTableHelper.getTabColumnsCount( nEndRow );
+ // FIXME: the column count > 26
+ //sal_Char cCol = 'A' + nColCount - 1;
+ rtl::OUString sCol = aTableHelper.getColumnStr( nColCount - 1);
+ aRangeName.appendAscii(":").append( sCol ).append( sal_Int32( nEndRow + 1 ) );
+
+ uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW );
+ rtl::OUString sSelRange = aRangeName.makeStringAndClear();
+ uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( sSelRange );
+
+ uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelection->select( uno::makeAny( xSelRange ) );
+}
+
+void SAL_CALL SwVbaRow::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException)
+{
+ setHeightRule( heightrule );
+ setHeight( uno::makeAny( height ) );
+}
+
+rtl::OUString&
+SwVbaRow::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRow") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaRow::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Row" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbarow.hxx b/sw/source/ui/vba/vbarow.hxx
new file mode 100644
index 000000000000..218ea996a60f
--- /dev/null
+++ b/sw/source/ui/vba/vbarow.hxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_ROW_HXX
+#define SW_VBA_ROW_HXX
+
+#include <ooo/vba/word/XRow.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRow > SwVbaRow_BASE;
+
+class SwVbaRow : public SwVbaRow_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ css::uno::Reference< css::table::XTableRows > mxTableRows;
+ css::uno::Reference< css::beans::XPropertySet > mxRowProps;
+ sal_Int32 mnIndex;
+
+public:
+ SwVbaRow( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaRow();
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException);
+
+ 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 ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_ROW_HXX */
diff --git a/sw/source/ui/vba/vbarows.cxx b/sw/source/ui/vba/vbarows.cxx
new file mode 100644
index 000000000000..c5a04fb29ae6
--- /dev/null
+++ b/sw/source/ui/vba/vbarows.cxx
@@ -0,0 +1,368 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbarows.hxx"
+#include "vbarow.hxx"
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <ooo/vba/word/WdRowAlignment.hpp>
+#include <ooo/vba/word/WdConstants.hpp>
+#include <ooo/vba/word/WdRulerStyle.hpp>
+#include "wordvbahelper.hxx"
+#include "vbacolumns.hxx"
+#include "vbatablehelper.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class RowsEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::WeakReference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< text::XTextTable > mxTextTable;
+ uno::Reference< container::XIndexAccess > mxIndexAccess;
+ sal_Int32 nIndex;
+
+public:
+ 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 )
+ {
+ mxIndexAccess.set( mxTextTable->getRows(), uno::UNO_QUERY );
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( nIndex < mxIndexAccess->getCount() )
+ {
+ return uno::makeAny( uno::Reference< word::XRow > ( new SwVbaRow( mxParent, mxContext, mxTextTable, nIndex++ ) ) );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+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 ) throw (uno::RuntimeException) : SwVbaRows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableRows, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableRows( xTableRows )
+{
+ mnStartRowIndex = 0;
+ mnEndRowIndex = m_xIndexAccess->getCount() - 1;
+}
+
+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 ) throw (uno::RuntimeException) : SwVbaRows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableRows, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableRows( xTableRows ), mnStartRowIndex( nStarIndex ), mnEndRowIndex( nEndIndex )
+{
+ if( mnEndRowIndex < mnStartRowIndex )
+ throw uno::RuntimeException();
+}
+
+/**
+ * get the alignment of the rows: SO format com.sun.star.text.HoriOrientation
+ * is mapped to WdRowAlignment in Word
+ * @return the alignment
+ */
+::sal_Int32 SAL_CALL SwVbaRows::getAlignment() throw (uno::RuntimeException)
+{
+ sal_Int16 nAlignment = text::HoriOrientation::LEFT;
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") ) ) >>= nAlignment;
+ sal_Int32 nRet = 0;
+ switch( nAlignment )
+ {
+ case text::HoriOrientation::CENTER:
+ {
+ nRet = word::WdRowAlignment::wdAlignRowCenter;
+ break;
+ }
+ case text::HoriOrientation::RIGHT:
+ {
+ nRet = word::WdRowAlignment::wdAlignRowRight;
+ break;
+ }
+ default:
+ {
+ nRet = word::WdRowAlignment::wdAlignRowLeft;
+ }
+ }
+ return nRet;
+}
+
+void SAL_CALL SwVbaRows::setAlignment( ::sal_Int32 _alignment ) throw (uno::RuntimeException)
+{
+ sal_Int16 nAlignment = text::HoriOrientation::LEFT;
+ switch( _alignment )
+ {
+ case word::WdRowAlignment::wdAlignRowCenter:
+ {
+ nAlignment = text::HoriOrientation::CENTER;
+ break;
+ }
+ case word::WdRowAlignment::wdAlignRowRight:
+ {
+ nAlignment = text::HoriOrientation::RIGHT;
+ break;
+ }
+ default:
+ {
+ nAlignment = text::HoriOrientation::LEFT;
+ }
+ }
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") ), uno::makeAny( nAlignment ) );
+}
+
+uno::Any SAL_CALL SwVbaRows::getAllowBreakAcrossPages() throw (uno::RuntimeException)
+{
+ sal_Bool bAllowBreak = sal_False;
+ uno::Reference< container::XIndexAccess > xRowsAccess( mxTableRows, uno::UNO_QUERY_THROW );
+ for( sal_Int32 index = mnStartRowIndex; index <= mnEndRowIndex; ++index )
+ {
+ uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ sal_Bool bSplit = sal_False;
+ xRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsSplitAllowed") ) ) >>= bSplit;
+ if( index == 0 )
+ {
+ bAllowBreak = bSplit;
+ }
+ if( bSplit != bAllowBreak )
+ {
+ sal_Int32 nRet = word::WdConstants::wdUndefined;
+ return uno::makeAny( nRet );
+ }
+ }
+ return uno::makeAny( bAllowBreak );
+}
+
+void SAL_CALL SwVbaRows::setAllowBreakAcrossPages( const uno::Any& _allowbreakacrosspages ) throw (uno::RuntimeException)
+{
+ sal_Bool bAllowBreak = sal_False;
+ _allowbreakacrosspages >>= bAllowBreak;
+ uno::Reference< container::XIndexAccess > xRowsAccess( mxTableRows, uno::UNO_QUERY_THROW );
+ for( sal_Int32 index = mnStartRowIndex; index <= mnEndRowIndex; ++index )
+ {
+ uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ xRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsSplitAllowed") ), uno::makeAny( bAllowBreak ) );
+ }
+}
+
+float SAL_CALL SwVbaRows::getSpaceBetweenColumns() throw (uno::RuntimeException)
+{
+ // just get the first spacing of the first cell
+ uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( 0, mnStartRowIndex ), uno::UNO_QUERY_THROW );
+ sal_Int32 nLeftBorderDistance = 0;
+ sal_Int32 nRightBorderDistance = 0;
+ xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftBorderDistance") ) ) >>= nLeftBorderDistance;
+ xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightBorderDistance") ) ) >>= nRightBorderDistance;
+ return static_cast< float >( Millimeter::getInPoints( nLeftBorderDistance + nRightBorderDistance ) );
+}
+
+void SAL_CALL SwVbaRows::setSpaceBetweenColumns( float _spacebetweencolumns ) throw (uno::RuntimeException)
+{
+ sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _spacebetweencolumns ) / 2;
+ uno::Reference< container::XIndexAccess > xColumnAccess( mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW );
+ SwVbaTableHelper aTableHelper( mxTextTable );
+ for( sal_Int32 row = mnStartRowIndex; row <= mnEndRowIndex; ++row )
+ {
+ sal_Int32 nColumns = aTableHelper.getTabColumnsCount( row );
+ for( sal_Int32 column = 0; column < nColumns; ++column )
+ {
+ uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( column, row ), uno::UNO_QUERY_THROW );
+ xCellProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftBorderDistance") ), uno::makeAny( nSpace ) );
+ xCellProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightBorderDistance") ), uno::makeAny( nSpace ) );
+ }
+ }
+}
+
+void SAL_CALL SwVbaRows::Delete( ) throw (uno::RuntimeException)
+{
+ mxTableRows->removeByIndex( mnStartRowIndex, getCount() );
+}
+
+void SAL_CALL SwVbaRows::SetLeftIndent( float LeftIndent, ::sal_Int32 RulerStyle ) throw (uno::RuntimeException)
+{
+ uno::Reference< word::XColumns > xColumns( new SwVbaColumns( getParent(), mxContext, mxTextTable, mxTextTable->getColumns() ) );
+ sal_Int32 nIndent = (sal_Int32)( LeftIndent );
+ switch( RulerStyle )
+ {
+ case word::WdRulerStyle::wdAdjustFirstColumn:
+ {
+ setIndentWithAdjustFirstColumn( xColumns, nIndent );
+ break;
+ }
+ case word::WdRulerStyle::wdAdjustNone:
+ {
+ setIndentWithAdjustNone( nIndent );
+ break;
+ }
+ case word::WdRulerStyle::wdAdjustProportional:
+ {
+ setIndentWithAdjustProportional( xColumns, nIndent );
+ break;
+ }
+ case word::WdRulerStyle::wdAdjustSameWidth:
+ {
+ setIndentWithAdjustSameWidth( xColumns, nIndent );
+ break;
+ }
+ default:
+ {
+ DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
+ }
+ }
+}
+
+void SwVbaRows::setIndentWithAdjustNone( sal_Int32 indent ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ sal_Int32 nMargin = 0;
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ) ) >>= nMargin;
+ nMargin += indent;
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ), uno::makeAny( nMargin ) );
+}
+
+ void SwVbaRows::setIndentWithAdjustFirstColumn( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException)
+ {
+ sal_Int32 nIndex = 1;
+ uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
+ uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( nIndex ), uno::Any() ), uno::UNO_QUERY_THROW );
+ sal_Int32 nWidth = xColumn->getWidth();
+ nWidth -= indent;
+ xColumn->setWidth( nWidth );
+ setIndentWithAdjustNone( indent );
+ }
+
+ void SwVbaRows::setIndentWithAdjustProportional( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException)
+ {
+ // calculate the new width and get the proportion between old and new
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ sal_Int32 nWidth = 0;
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth;
+ sal_Int32 nNewWidth = nWidth - indent;
+ double propFactor = (double)nNewWidth/(double)nWidth;
+
+ // get all columns, calculate and set the new width of the columns
+ uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
+ sal_Int32 nColCount = xCol->getCount();
+ for( sal_Int32 i = 0; i < nColCount; i++ )
+ {
+ uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( i ), uno::Any() ), uno::UNO_QUERY_THROW );
+ sal_Int32 nColWidth = xColumn->getWidth();
+ sal_Int32 nNewColWidth = ( sal_Int32 )( propFactor * nColWidth );
+ xColumn->setWidth( nNewColWidth );
+ }
+
+ // set the width and position of the table
+ setIndentWithAdjustNone( indent );
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( nNewWidth ) );
+ }
+
+ void SwVbaRows::setIndentWithAdjustSameWidth( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException)
+ {
+ // calculate the new width and get the width of all columns
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ sal_Int32 nWidth = 0;
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth;
+ sal_Int32 nNewWidth = nWidth - indent;
+
+ // get all columns, calculate and set the new width of the columns
+ uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW );
+ sal_Int32 nColCount = xCol->getCount();
+ sal_Int32 nNewColWidth = (sal_Int32)( double( nNewWidth )/nColCount );
+ for( sal_Int32 i = 0; i < nColCount; i++ )
+ {
+ uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( i ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xColumn->setWidth( nNewColWidth );
+ }
+
+ // set the width and position of the table
+ setIndentWithAdjustNone( indent );
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( nNewWidth ) );
+ }
+
+void SAL_CALL SwVbaRows::Select( ) throw (uno::RuntimeException)
+{
+ SwVbaRow::SelectRow( getCurrentWordDoc(mxContext), mxTextTable, mnStartRowIndex, mnEndRowIndex );
+}
+
+::sal_Int32 SAL_CALL SwVbaRows::getCount() throw (uno::RuntimeException)
+{
+ return ( mnEndRowIndex - mnStartRowIndex + 1 );
+}
+
+uno::Any SAL_CALL SwVbaRows::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ if( ( Index1 >>= nIndex ) == sal_True )
+ {
+ if( nIndex <= 0 || nIndex > getCount() )
+ {
+ throw lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+ }
+ return uno::makeAny( uno::Reference< word::XRow >( new SwVbaRow( this, mxContext, mxTextTable, nIndex - 1 ) ) );
+ }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaRows::getElementType() throw (uno::RuntimeException)
+{
+ return word::XRow::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaRows::createEnumeration() throw (uno::RuntimeException)
+{
+ return new RowsEnumWrapper( this, mxContext, mxTextTable );
+}
+
+uno::Any
+SwVbaRows::createCollectionObject( const uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaRows::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRows") );
+ return sImplName;
+}
+
+uno::Sequence<rtl::OUString>
+SwVbaRows::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Rows") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbarows.hxx b/sw/source/ui/vba/vbarows.hxx
new file mode 100644
index 000000000000..0c2380d9fea5
--- /dev/null
+++ b/sw/source/ui/vba/vbarows.hxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_ROWS_HXX
+#define SW_VBA_ROWS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XRows.hpp>
+#include <ooo/vba/word/XColumns.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XRows > SwVbaRows_BASE;
+
+class SwVbaRows : public SwVbaRows_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ css::uno::Reference< css::table::XTableRows > mxTableRows;
+ sal_Int32 mnStartRowIndex;
+ sal_Int32 mnEndRowIndex;
+
+private:
+ void setIndentWithAdjustNone( sal_Int32 indent ) throw (css::uno::RuntimeException);
+ void setIndentWithAdjustFirstColumn( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException);
+ void setIndentWithAdjustProportional( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException);
+ void setIndentWithAdjustSameWidth( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException);
+
+public:
+ 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 ) throw ( css::uno::RuntimeException );
+ 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, sal_Int32 nStarIndex, sal_Int32 nEndIndex ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaRows() {}
+
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getAlignment() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAlignment( ::sal_Int32 _alignment ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getAllowBreakAcrossPages() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAllowBreakAcrossPages( const css::uno::Any& _allowbreakacrosspages ) throw (css::uno::RuntimeException);
+ virtual float SAL_CALL getSpaceBetweenColumns() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSpaceBetweenColumns( float _spacebetweencolumns ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SetLeftIndent( float LeftIndent, ::sal_Int32 RulerStyle ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException);
+
+ //XCollection
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaRows_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_ROWS_HXX */
diff --git a/sw/source/ui/vba/vbatablehelper.cxx b/sw/source/ui/vba/vbatablehelper.cxx
new file mode 100644
index 000000000000..60626dc78719
--- /dev/null
+++ b/sw/source/ui/vba/vbatablehelper.cxx
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbatablehelper.hxx"
+#include <swtable.hxx>
+#include <unotbl.hxx>
+#include <docsh.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+#define UNO_TABLE_COLUMN_SUM 10000
+
+SwVbaTableHelper::SwVbaTableHelper( const uno::Reference< text::XTextTable >& xTextTable ) throw (uno::RuntimeException) : mxTextTable( xTextTable ), pDoc( NULL )
+{
+ pTable = GetSwTable( mxTextTable );
+}
+
+SwTable* SwVbaTableHelper::GetSwTable( const uno::Reference< text::XTextTable >& xTextTable ) throw (uno::RuntimeException)
+{
+ uno::Reference< lang::XUnoTunnel > xTunnel( xTextTable, uno::UNO_QUERY_THROW );
+ SwXTextTable* pXTextTable = reinterpret_cast< SwXTextTable * >( sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextTable::getUnoTunnelId())));
+ if( !pXTextTable )
+ throw uno::RuntimeException();
+
+ SwFrmFmt* pFrmFmt = pXTextTable->GetFrmFmt();
+ if( !pFrmFmt )
+ throw uno::RuntimeException();
+
+ SwTable* pTable = SwTable::FindTable( pFrmFmt );
+ return pTable;
+}
+
+sal_Int32 SwVbaTableHelper::getTabColumnsCount( sal_Int32 nRowIndex ) throw (uno::RuntimeException)
+{
+ sal_Int32 nRet = 0;
+ if(!pTable->IsTblComplex())
+ {
+ SwTableLines& rLines = pTable->GetTabLines();
+ SwTableLine* pLine = rLines.GetObject( nRowIndex );
+ nRet = pLine->GetTabBoxes().Count();
+ }
+ return nRet;
+}
+
+sal_Int32 SwVbaTableHelper::getTabColumnsMaxCount( ) throw (uno::RuntimeException)
+{
+ sal_Int32 nRet = 0;
+ //sal_Int32 nRowCount = mxTextTable->getRows()->getCount();
+ sal_Int32 nRowCount = pTable->GetTabLines().Count();
+ for( sal_Int32 index = 0; index < nRowCount; index++ )
+ {
+ sal_Int32 nColCount = getTabColumnsCount( index );
+ if( nRet < nColCount )
+ nRet = nColCount;
+ }
+ return nRet;
+}
+
+sal_Int32 SwVbaTableHelper::getTabRowIndex( const rtl::OUString& CellName ) throw (uno::RuntimeException)
+{
+ sal_Int32 nRet = 0;
+ String sCellName(CellName);
+ SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
+ if( !pBox )
+ throw uno::RuntimeException();
+
+ const SwTableLine* pLine = pBox->GetUpper();
+ const SwTableLines* pLines = pLine->GetUpper()
+ ? &pLine->GetUpper()->GetTabLines() : &pTable->GetTabLines();
+ nRet = pLines->GetPos( pLine );
+ return nRet;
+}
+
+sal_Int32 SwVbaTableHelper::getTabColIndex( const rtl::OUString& CellName ) throw (uno::RuntimeException)
+{
+ sal_Int32 nRet = 0;
+ String sCellName(CellName);
+ const SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName );
+ if( !pBox )
+ throw uno::RuntimeException();
+ const SwTableBoxes* pBoxes = &pBox->GetUpper()->GetTabBoxes();
+ nRet = pBoxes->GetPos( pBox );
+ return nRet;
+}
+
+rtl::OUString SwVbaTableHelper::getColumnStr( sal_Int32 nCol )
+{
+ const sal_Int32 coDiff = 52; // 'A'-'Z' 'a' - 'z'
+ sal_Int32 nCalc = 0;
+
+ String sRet;
+ do{
+ nCalc = nCol % coDiff;
+ if( nCalc >= 26 )
+ sRet.Insert( sal_Unicode('a' - 26 + nCalc ), 0 );
+ else
+ sRet.Insert( sal_Unicode('A' + nCalc ), 0 );
+
+ if( 0 == ( nCol = nCol - nCalc ) )
+ break;
+ nCol /= coDiff;
+ --nCol;
+ }while(1);
+ return sRet;
+}
+
+sal_Int32 SwVbaTableHelper::getTableWidth( ) throw (uno::RuntimeException)
+{
+ sal_Int32 nWidth = 0;
+ sal_Bool isWidthRelatvie = sal_False;
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsWidthRelative") ) ) >>= isWidthRelatvie;
+ if( isWidthRelatvie )
+ {
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RelativeWidth") ) ) >>= nWidth;
+ }
+ else
+ {
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth;
+ }
+ return nWidth;
+}
+
+void SwVbaTableHelper::setTableWidth( sal_Int32 _width ) throw (uno::RuntimeException)
+{
+ sal_Bool isWidthRelatvie = sal_False;
+ uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW );
+ xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsWidthRelative") ) ) >>= isWidthRelatvie;
+ if( isWidthRelatvie )
+ {
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RelativeWidth") ), uno::makeAny( _width ));
+ }
+ else
+ {
+ xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( _width ) );
+ }
+}
+
+SwTableBox* SwVbaTableHelper::GetTabBox( sal_Int32 nCol, sal_Int32 nRow ) throw (css::uno::RuntimeException)
+{
+ SwTableLines& rLines = pTable->GetTabLines();
+ sal_Int32 nRowCount = rLines.Count();
+ if( nRowCount < nRow )
+ throw uno::RuntimeException();
+
+ SwTableBox* pStart = NULL;
+ SwTableLine* pLine = rLines.GetObject( nRow );
+ if( pLine->GetTabBoxes().Count() < nCol )
+ throw uno::RuntimeException();
+
+ pStart = pLine->GetTabBoxes()[ nCol ];
+
+ if( !pStart )
+ throw uno::RuntimeException();
+
+ return pStart;
+}
+
+void SwVbaTableHelper::InitTabCols( SwTabCols& rCols, const SwTableBox *pStart, BOOL /*bCurRowOnly*/ )
+{
+ rCols.SetLeftMin ( 0 );
+ rCols.SetLeft ( 0 );
+ rCols.SetRight ( UNO_TABLE_COLUMN_SUM );
+ rCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
+
+ //if( !pDoc )
+ // {
+ // pDoc = word::getDocShell( getCurrentDocument() )->GetDoc();
+ // }
+ pTable->GetTabCols( rCols, pStart, sal_False, sal_False );
+}
+
+sal_Int32 SwVbaTableHelper::GetColCount( SwTabCols& rCols ) const
+{
+ sal_Int32 nCount = 0;
+ for(sal_Int32 i = 0; i < rCols.Count(); i++ )
+ if(rCols.IsHidden(i))
+ nCount ++;
+ return rCols.Count() - nCount;
+}
+
+sal_Int32 SwVbaTableHelper::GetRightSeparator( SwTabCols& rCols, sal_Int32 nNum) const
+{
+ DBG_ASSERT( nNum < (sal_Int32)GetColCount( rCols ) ,"Index out of range");
+ sal_Int32 i = 0;
+ while( nNum >= 0 )
+ {
+ if( !rCols.IsHidden( static_cast< USHORT >(i)) )
+ nNum--;
+ i++;
+ }
+ return i - 1;
+}
+
+sal_Int32 SwVbaTableHelper::GetColWidth( sal_Int32 nCol, sal_Int32 nRow, sal_Bool bCurRowOnly ) throw (uno::RuntimeException)
+{
+ SwTableBox* pStart = GetTabBox( nCol, nRow );
+ SwTabCols aCols;
+ InitTabCols( aCols, pStart, bCurRowOnly );
+ sal_Int32 nWidth = GetColWidth( aCols, nCol );
+
+ sal_Int32 nTableWidth = getTableWidth( );
+ double dAbsWidth = ( (double)nWidth / UNO_TABLE_COLUMN_SUM ) * (double) nTableWidth;
+ return ( sal_Int32 )Millimeter::getInPoints( dAbsWidth );
+}
+
+sal_Int32 SwVbaTableHelper::GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) throw (uno::RuntimeException)
+{
+ SwTwips nWidth = 0;
+
+ if( rCols.Count() > 0 )
+ {
+ if(rCols.Count() == GetColCount( rCols ))
+ {
+ nWidth = (SwTwips)((nNum == rCols.Count()) ?
+ rCols.GetRight() - rCols[nNum-1] :
+ nNum == 0 ? rCols[nNum] - rCols.GetLeft() :
+ rCols[nNum] - rCols[nNum-1]);
+ }
+ else
+ {
+ SwTwips nRValid = nNum < GetColCount( rCols ) ?
+ rCols[(USHORT)GetRightSeparator( rCols, nNum)]:
+ rCols.GetRight();
+ SwTwips nLValid = nNum ?
+ rCols[(USHORT)GetRightSeparator( rCols, nNum - 1)]:
+ rCols.GetLeft();
+ nWidth = nRValid - nLValid;
+ }
+ }
+ else
+ nWidth = rCols.GetRight();
+
+ return nWidth;
+}
+
+void SwVbaTableHelper::SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow, sal_Bool bCurRowOnly ) throw (css::uno::RuntimeException)
+{
+ double dAbsWidth = Millimeter::getInHundredthsOfOneMillimeter( _width );
+ sal_Int32 nTableWidth = getTableWidth( );
+ sal_Int32 nNewWidth = (sal_Int32)( dAbsWidth/nTableWidth * UNO_TABLE_COLUMN_SUM );
+
+ SwTableBox* pStart = GetTabBox( nCol, nRow );
+ SwTabCols aOldCols;
+ InitTabCols( aOldCols, pStart, bCurRowOnly );
+
+ //BOOL bCurRowOnly = FALSE;
+ SwTwips nWidth = 0;
+
+ SwTabCols aCols( aOldCols );
+ if ( aCols.Count() > 0 )
+ {
+ // if(aCols.Count() != GetColCount( aCols ))
+ // bCurRowOnly = TRUE;
+ nWidth = GetColWidth( aCols, nCol);
+
+ int nDiff = (int)(nNewWidth - nWidth);
+ if( !nCol )
+ aCols[ static_cast< USHORT >(GetRightSeparator(aCols, 0)) ] += nDiff;
+ else if( nCol < GetColCount( aCols ) )
+ {
+ if(nDiff < GetColWidth( aCols, nCol + 1) - MINLAY)
+ aCols[ static_cast< USHORT >(GetRightSeparator( aCols, nCol)) ] += nDiff;
+ else
+ {
+ int nDiffLeft = nDiff - (int)GetColWidth( aCols, nCol + 1) + (int)MINLAY;
+ aCols[ static_cast< USHORT >(GetRightSeparator( aCols, nCol)) ] += (nDiff - nDiffLeft);
+ aCols[ static_cast< USHORT >(GetRightSeparator( aCols, nCol - 1)) ] -= nDiffLeft;
+ }
+ }
+ else
+ aCols[ static_cast< USHORT >(GetRightSeparator( aCols, nCol-1)) ] -= nDiff;
+ }
+ else
+ aCols.SetRight( Min( (long)nNewWidth, aCols.GetRightMax()) );
+
+ //pDoc->SetTabCols(*pTable, aCols, aOldCols, pStartBox, bCurRowOnly );
+ pTable->SetTabCols(aCols, aOldCols, pStart, bCurRowOnly );
+}
diff --git a/sw/source/ui/vba/vbatablehelper.hxx b/sw/source/ui/vba/vbatablehelper.hxx
new file mode 100644
index 000000000000..62677cc6e946
--- /dev/null
+++ b/sw/source/ui/vba/vbatablehelper.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vbahelper.hxx,v $
+ * $Revision: 1.5.32.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_WORD_VBA_TABLEHELPER_HXX
+#define SW_WORD_VBA_TABLEHELPER_HXX
+
+#include <com/sun/star/text/XTextTable.hpp>
+#include "wordvbahelper.hxx"
+#include <swtable.hxx>
+#include <tabcol.hxx>
+#include <doc.hxx>
+
+class SwVbaTableHelper
+{
+private:
+ css::uno::Reference< css::text::XTextTable > mxTextTable;
+ SwTable* pTable;
+ SwDoc* pDoc;
+
+private:
+ SwTableBox* GetTabBox( sal_Int32 nCol, sal_Int32 nRow ) throw (css::uno::RuntimeException);
+ void InitTabCols( SwTabCols& rCols, const SwTableBox *pStart, sal_Bool bCurRowOnly = FALSE );
+ sal_Int32 GetRightSeparator( SwTabCols& rCols, sal_Int32 nNum) const;
+ sal_Int32 GetColCount( SwTabCols& rCols ) const;
+ sal_Int32 GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) throw (css::uno::RuntimeException);
+
+public:
+ SwVbaTableHelper( const css::uno::Reference< css::text::XTextTable >& xTextTable ) throw (css::uno::RuntimeException);
+ ~SwVbaTableHelper() {}
+ sal_Int32 getTabColumnsCount( sal_Int32 nRowIndex ) throw (css::uno::RuntimeException);
+ sal_Int32 getTabColumnsMaxCount( ) throw (css::uno::RuntimeException);
+ sal_Int32 getTabRowIndex( const rtl::OUString& sCellName ) throw (css::uno::RuntimeException);
+ sal_Int32 getTabColIndex( const rtl::OUString& sCellName ) throw (css::uno::RuntimeException);
+ sal_Int32 getTableWidth( ) throw (css::uno::RuntimeException);
+ void setTableWidth( sal_Int32 _width ) throw (css::uno::RuntimeException);
+
+ sal_Int32 GetColWidth( sal_Int32 nCol, sal_Int32 nRow = 0, sal_Bool bCurRowOnly = FALSE ) throw (css::uno::RuntimeException);
+ void SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow = 0, sal_Bool bCurRowOnly = FALSE ) throw (css::uno::RuntimeException);
+
+ static SwTable* GetSwTable( const css::uno::Reference< css::text::XTextTable >& xTextTable ) throw (css::uno::RuntimeException);
+ static rtl::OUString getColumnStr( sal_Int32 nCol );
+};
+
+#endif
diff --git a/sw/source/ui/vba/vbatableofcontents.cxx b/sw/source/ui/vba/vbatableofcontents.cxx
new file mode 100644
index 000000000000..a30d1657f7a0
--- /dev/null
+++ b/sw/source/ui/vba/vbatableofcontents.cxx
@@ -0,0 +1,125 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbatableofcontents.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <ooo/vba/word/WdTabLeader.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaTableOfContents::SwVbaTableOfContents( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xDoc, const uno::Reference< text::XDocumentIndex >& xDocumentIndex ) throw ( uno::RuntimeException ) :
+ SwVbaTableOfContents_BASE( rParent, rContext ), mxTextDocument( xDoc ), mxDocumentIndex( xDocumentIndex )
+{
+ mxTocProps.set( mxDocumentIndex, uno::UNO_QUERY_THROW );
+}
+
+
+SwVbaTableOfContents::~SwVbaTableOfContents()
+{
+}
+
+::sal_Int32 SAL_CALL SwVbaTableOfContents::getLowerHeadingLevel() throw (uno::RuntimeException)
+{
+ sal_Int16 nLevel = 0;
+ mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ) ) >>= nLevel;
+ return nLevel;
+}
+
+void SAL_CALL SwVbaTableOfContents::setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (uno::RuntimeException)
+{
+ mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ), uno::makeAny( sal_Int8( _lowerheadinglevel ) ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaTableOfContents::getTabLeader() throw (uno::RuntimeException)
+{
+ // not support in Writer
+ return word::WdTabLeader::wdTabLeaderDots;
+}
+
+void SAL_CALL SwVbaTableOfContents::setTabLeader( ::sal_Int32 /*_tableader*/ ) throw (uno::RuntimeException)
+{
+ // not support in Writer
+}
+
+::sal_Bool SAL_CALL SwVbaTableOfContents::getUseFields() throw (css::uno::RuntimeException)
+{
+ sal_Bool bUseFields = sal_False;
+ mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ) ) >>= bUseFields;
+ return bUseFields;
+}
+
+void SAL_CALL SwVbaTableOfContents::setUseFields( ::sal_Bool _useFields ) throw (css::uno::RuntimeException)
+{
+ mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ), uno::makeAny( _useFields ) );
+}
+
+::sal_Bool SAL_CALL SwVbaTableOfContents::getUseOutlineLevels() throw (css::uno::RuntimeException)
+{
+ sal_Bool bUseOutlineLevels = sal_False;
+ mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ) ) >>= bUseOutlineLevels;
+ return bUseOutlineLevels;
+}
+
+void SAL_CALL SwVbaTableOfContents::setUseOutlineLevels( ::sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException)
+{
+ mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ), uno::makeAny( _useOutlineLevels ) );
+}
+
+void SAL_CALL SwVbaTableOfContents::Delete( ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextContent > xTextContent( mxDocumentIndex, uno::UNO_QUERY_THROW );
+ mxTextDocument->getText()->removeTextContent( xTextContent );
+}
+
+void SAL_CALL SwVbaTableOfContents::Update( ) throw (uno::RuntimeException)
+{
+ mxDocumentIndex->update();
+}
+
+rtl::OUString&
+SwVbaTableOfContents::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTableOfContents") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaTableOfContents::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TableOfContents" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbatableofcontents.hxx b/sw/source/ui/vba/vbatableofcontents.hxx
new file mode 100644
index 000000000000..73abc8f4a792
--- /dev/null
+++ b/sw/source/ui/vba/vbatableofcontents.hxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_TABLEOFCONTENTS_HXX
+#define SW_VBA_TABLEOFCONTENTS_HXX
+
+#include <ooo/vba/word/XTableOfContents.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/text/XDocumentIndex.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTableOfContents > SwVbaTableOfContents_BASE;
+
+class SwVbaTableOfContents : public SwVbaTableOfContents_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+ css::uno::Reference< css::text::XDocumentIndex > mxDocumentIndex;
+ css::uno::Reference< css::beans::XPropertySet > mxTocProps;
+
+public:
+ SwVbaTableOfContents( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xDoc, const css::uno::Reference< css::text::XDocumentIndex >& xDocumentIndex ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaTableOfContents();
+
+ // Attributes
+ virtual ::sal_Int32 SAL_CALL getLowerHeadingLevel() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getTabLeader() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTabLeader( ::sal_Int32 _tableader ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getUseFields() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUseFields( ::sal_Bool _useFields ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getUseOutlineLevels() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUseOutlineLevels( ::sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Update( ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_TABLEOFCONTENTS_HXX */
diff --git a/sw/source/ui/vba/vbatablesofcontents.cxx b/sw/source/ui/vba/vbatablesofcontents.cxx
new file mode 100644
index 000000000000..f7a84a9c6547
--- /dev/null
+++ b/sw/source/ui/vba/vbatablesofcontents.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbatablesofcontents.hxx"
+#include "vbatableofcontents.hxx"
+#include "vbarange.hxx"
+#include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > TableOfContentsCollectionHelper_Base;
+typedef std::vector< uno::Reference< text::XDocumentIndex > > XTocVec;
+
+class TablesOfContentsEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference< container::XIndexAccess > mxIndexAccess;
+ sal_Int32 nIndex;
+
+public:
+ TablesOfContentsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 )
+ {
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( nIndex < mxIndexAccess->getCount() )
+ {
+ return mxIndexAccess->getByIndex( nIndex++ );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+class TableOfContentsCollectionHelper : public TableOfContentsCollectionHelper_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< text::XTextDocument > mxTextDocument;
+ XTocVec maToc;
+
+public:
+ TableOfContentsCollectionHelper( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDoc ) throw ( uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxTextDocument( xDoc )
+ {
+ uno::Reference< text::XDocumentIndexesSupplier > xDocIndexSupp( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xDocIndexes = xDocIndexSupp->getDocumentIndexes();
+ sal_Int32 nCount = xDocIndexes->getCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ uno::Reference< text::XDocumentIndex > xToc( xDocIndexes->getByIndex(i), uno::UNO_QUERY_THROW );
+ if( xToc->getServiceName().equalsAscii("com.sun.star.text.ContentIndex") )
+ {
+ maToc.push_back( xToc );
+ }
+ }
+ }
+
+ virtual ~TableOfContentsCollectionHelper() {}
+
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return maToc.size();
+ }
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Reference< text::XDocumentIndex > xToc( maToc[Index], uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XTableOfContents >( new SwVbaTableOfContents( mxParent, mxContext, mxTextDocument, xToc ) ) );
+ }
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return word::XTableOfContents::static_type(0);
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new TablesOfContentsEnumWrapper( this );
+ }
+};
+
+SwVbaTablesOfContents::SwVbaTablesOfContents( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDoc ) throw (uno::RuntimeException) : SwVbaTablesOfContents_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TableOfContentsCollectionHelper( xParent, xContext, xDoc ) ) ), mxTextDocument( xDoc )
+{
+}
+
+uno::Reference< word::XTableOfContents > SAL_CALL
+SwVbaTablesOfContents::Add( const uno::Reference< word::XRange >& Range, const uno::Any& /*UseHeadingStyles*/, const uno::Any& /*UpperHeadingLevel*/, const uno::Any& LowerHeadingLevel, const uno::Any& UseFields, const uno::Any& /*TableID*/, const uno::Any& /*RightAlignPageNumbers*/, const uno::Any& /*IncludePageNumbers*/, const uno::Any& /*AddedStyles*/, const uno::Any& /*UseHyperlinks*/, const uno::Any& /*HidePageNumbersInWeb*/, const uno::Any& /*UseOutlineLevels*/ ) throw (uno::RuntimeException)
+{
+ uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XDocumentIndex > xDocumentIndex( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ContentIndex")) ), uno::UNO_QUERY_THROW );
+
+ uno::Reference< beans::XPropertySet > xTocProps( xDocumentIndex, uno::UNO_QUERY_THROW );
+ sal_Bool isProtected = sal_False;
+ xTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsProtected") ), uno::makeAny( isProtected ) );
+
+ uno::Reference< word::XTableOfContents > xToc( new SwVbaTableOfContents( this, mxContext, mxTextDocument, xDocumentIndex ) );
+
+ sal_Int32 nLowerHeadingLevel = 9;
+ if( LowerHeadingLevel.hasValue() )
+ LowerHeadingLevel >>= nLowerHeadingLevel;
+ xToc->setLowerHeadingLevel( nLowerHeadingLevel );
+
+ sal_Bool bUseFields = sal_False;
+ if( UseFields.hasValue() )
+ UseFields >>= bUseFields;
+ xToc->setUseFields( bUseFields );
+
+ sal_Bool bUseOutlineLevels = sal_True;
+ //if( UseOutlineLevels.hasValue() )
+ // UseOutlineLevels >>= bUseOutlineLevels;
+ xToc->setUseOutlineLevels( bUseOutlineLevels );
+
+ SwVbaRange* pVbaRange = dynamic_cast<SwVbaRange*>( Range.get() );
+ if( !pVbaRange )
+ throw uno::RuntimeException();
+
+ uno::Reference< text::XTextRange > xTextRange = pVbaRange->getXTextRange();
+ uno::Reference< text::XText > xText = pVbaRange->getXText();
+ uno::Reference< text::XTextContent > xTextContent( xDocumentIndex, uno::UNO_QUERY_THROW );
+ xText->insertTextContent( xTextRange, xTextContent, sal_False );
+ xToc->Update();
+
+ return xToc;
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaTablesOfContents::getElementType() throw (uno::RuntimeException)
+{
+ return word::XTableOfContents::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaTablesOfContents::createEnumeration() throw (uno::RuntimeException)
+{
+ return new TablesOfContentsEnumWrapper( m_xIndexAccess );
+}
+
+uno::Any
+SwVbaTablesOfContents::createCollectionObject( const uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaTablesOfContents::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTablesOfContents") );
+ return sImplName;
+}
+
+uno::Sequence<rtl::OUString>
+SwVbaTablesOfContents::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TablesOfContents") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbatablesofcontents.hxx b/sw/source/ui/vba/vbatablesofcontents.hxx
new file mode 100644
index 000000000000..5a6f0a0c766c
--- /dev/null
+++ b/sw/source/ui/vba/vbatablesofcontents.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_TABLESOFCONTENTS_HXX
+#define SW_VBA_TABLESOFCONTENTS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XTablesOfContents.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <ooo/vba/word/XTableOfContents.hpp>
+#include <ooo/vba/word/XRange.hpp>
+
+typedef CollTestImplHelper< ooo::vba::word::XTablesOfContents > SwVbaTablesOfContents_BASE;
+
+class SwVbaTablesOfContents : public SwVbaTablesOfContents_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextDocument > mxTextDocument;
+
+public:
+ SwVbaTablesOfContents( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xDoc ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaTablesOfContents() {}
+
+ // Methods
+ virtual css::uno::Reference< ::ooo::vba::word::XTableOfContents > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& UseHeadingStyles, const css::uno::Any& UpperHeadingLevel, const css::uno::Any& LowerHeadingLevel, const css::uno::Any& UseFields, const css::uno::Any& TableID, const css::uno::Any& RightAlignPageNumbers, const css::uno::Any& IncludePageNumbers, const css::uno::Any& AddedStyles, const css::uno::Any& UseHyperlinks, const css::uno::Any& HidePageNumbersInWeb, const css::uno::Any& UseOutlineLevels ) throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaTablesOfContents_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_TABLESOFCONTENTS_HXX */
diff --git a/sw/source/ui/vba/vbatabstop.cxx b/sw/source/ui/vba/vbatabstop.cxx
new file mode 100644
index 000000000000..8e47e9dbd4d6
--- /dev/null
+++ b/sw/source/ui/vba/vbatabstop.cxx
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbatabstop.hxx"
+#include <vbahelper/vbahelper.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+SwVbaTabStop::SwVbaTabStop( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< beans::XPropertySet >& xParaProps, const style::TabStop& aTabStop ) throw ( uno::RuntimeException ) : SwVbaTabStop_BASE( rParent, rContext ), mxParaProps( xParaProps ), maTabStop( aTabStop )
+{
+}
+
+SwVbaTabStop::~SwVbaTabStop()
+{
+}
+
+rtl::OUString&
+SwVbaTabStop::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTabStop") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+SwVbaTabStop::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TabStop" ) );
+ }
+ return aServiceNames;
+}
+
diff --git a/sw/source/ui/vba/vbatabstop.hxx b/sw/source/ui/vba/vbatabstop.hxx
new file mode 100644
index 000000000000..d5fd9c412f0f
--- /dev/null
+++ b/sw/source/ui/vba/vbatabstop.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_TABSTOP_HXX
+#define SW_VBA_TABSTOP_HXX
+
+#include <ooo/vba/word/XTabStop.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/style/TabStop.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTabStop > SwVbaTabStop_BASE;
+
+class SwVbaTabStop : public SwVbaTabStop_BASE
+{
+private:
+ css::uno::Reference< css::beans::XPropertySet > mxParaProps;
+ css::style::TabStop maTabStop;
+
+public:
+ SwVbaTabStop( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps, const css::style::TabStop& aTabStop ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaTabStop();
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SW_VBA_TABSTOP_HXX */
diff --git a/sw/source/ui/vba/vbatabstops.cxx b/sw/source/ui/vba/vbatabstops.cxx
new file mode 100644
index 000000000000..d2b066304609
--- /dev/null
+++ b/sw/source/ui/vba/vbatabstops.cxx
@@ -0,0 +1,280 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbatabstops.hxx"
+#include "vbatabstop.hxx"
+#include <com/sun/star/style/TabAlign.hpp>
+#include <ooo/vba/word/WdTabLeader.hpp>
+#include <ooo/vba/word/WdTabAlignment.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+uno::Sequence< style::TabStop > lcl_getTabStops( const uno::Reference< beans::XPropertySet >& xParaProps ) throw (uno::RuntimeException)
+{
+ uno::Sequence< style::TabStop > aSeq;
+ xParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTabStops") ) ) >>= aSeq;
+ return aSeq;
+}
+
+void lcl_setTabStops( const uno::Reference< beans::XPropertySet >& xParaProps, const uno::Sequence< style::TabStop >& aSeq ) throw (uno::RuntimeException)
+{
+ xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTabStops") ), uno::makeAny( aSeq ) );
+}
+
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > TabStopCollectionHelper_Base;
+
+class TabStopsEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference< container::XIndexAccess > mxIndexAccess;
+ sal_Int32 nIndex;
+
+public:
+ TabStopsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 )
+ {
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < mxIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( nIndex < mxIndexAccess->getCount() )
+ {
+ return mxIndexAccess->getByIndex( nIndex++ );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+class TabStopCollectionHelper : public TabStopCollectionHelper_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< beans::XPropertySet > mxParaProps;
+ uno::Sequence< style::TabStop > maTabStops;
+
+public:
+ TabStopCollectionHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps ) throw ( css::uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxParaProps( xParaProps )
+ {
+ maTabStops = lcl_getTabStops( xParaProps );
+ }
+
+ virtual ~TabStopCollectionHelper() {}
+
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return maTabStops.getLength();
+ }
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw css::lang::IndexOutOfBoundsException();
+
+ const style::TabStop* pTabs = maTabStops.getConstArray();
+ return uno::makeAny( uno::Reference< word::XTabStop >( new SwVbaTabStop( mxParent, mxContext, mxParaProps, pTabs[ Index ] ) ) );
+ }
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return word::XTabStop::static_type(0);
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new TabStopsEnumWrapper( this );
+ }
+};
+
+SwVbaTabStops::SwVbaTabStops( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& xParaProps ) throw (uno::RuntimeException) : SwVbaTabStops_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TabStopCollectionHelper( xParent, xContext, xParaProps ) ) ), mxParaProps( xParaProps )
+{
+}
+
+uno::Reference< word::XTabStop > SAL_CALL SwVbaTabStops::Add( float Position, const uno::Any& Alignment, const uno::Any& Leader ) throw (uno::RuntimeException)
+{
+ sal_Int32 nPosition = Millimeter::getInHundredthsOfOneMillimeter( Position );
+
+ style::TabAlign nAlign = style::TabAlign_LEFT;
+ if( Alignment.hasValue() )
+ {
+ sal_Int32 wdAlign = word::WdTabAlignment::wdAlignTabLeft;
+ Alignment >>= wdAlign;
+ switch( wdAlign )
+ {
+ case word::WdTabAlignment::wdAlignTabLeft:
+ {
+ nAlign = style::TabAlign_LEFT;
+ break;
+ }
+ case word::WdTabAlignment::wdAlignTabRight:
+ {
+ nAlign = style::TabAlign_RIGHT;
+ break;
+ }
+ case word::WdTabAlignment::wdAlignTabCenter:
+ {
+ nAlign = style::TabAlign_CENTER;
+ break;
+ }
+ case word::WdTabAlignment::wdAlignTabDecimal:
+ {
+ nAlign = style::TabAlign_DECIMAL;
+ break;
+ }
+ case word::WdTabAlignment::wdAlignTabBar:
+ case word::WdTabAlignment::wdAlignTabList:
+ {
+ DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() );
+ break;
+ }
+ default:
+ {
+ //left
+ }
+ }
+ }
+
+ sal_Char cLeader = ' '; // default is space
+ if( Leader.hasValue() )
+ {
+ sal_Int32 wdLeader = word::WdTabLeader::wdTabLeaderSpaces;
+ Leader >>= wdLeader;
+ switch( wdLeader )
+ {
+ case word::WdTabLeader::wdTabLeaderSpaces:
+ {
+ cLeader = ' ';
+ break;
+ }
+ case word::WdTabLeader::wdTabLeaderMiddleDot:
+ {
+ cLeader = 183;
+ break;
+ }
+ case word::WdTabLeader::wdTabLeaderDots:
+ {
+ cLeader = '.';
+ break;
+ }
+ case word::WdTabLeader::wdTabLeaderDashes:
+ case word::WdTabLeader::wdTabLeaderHeavy:
+ case word::WdTabLeader::wdTabLeaderLines:
+ {
+ cLeader = '_';
+ break;
+ }
+ default:
+ {
+ //left
+ }
+ }
+ }
+
+ sal_Char cDecimal = '.'; // default value
+
+ style::TabStop aTab;
+ aTab.Position = nPosition;
+ aTab.Alignment = nAlign;
+ aTab.DecimalChar = cDecimal;
+ aTab.FillChar = cLeader;
+
+ uno::Sequence< style::TabStop > aOldTabs = lcl_getTabStops( mxParaProps );
+ sal_Bool bOverWriter = sal_False;
+
+ sal_Int32 nTabs = aOldTabs.getLength();
+ uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 );
+
+ style::TabStop* pOldTab = aOldTabs.getArray();
+ style::TabStop* pNewTab = aNewTabs.getArray();
+ pNewTab[0] = aTab;
+ for( sal_Int32 nIndex = 0; nIndex < nTabs && !bOverWriter; nIndex++ )
+ {
+ if( pOldTab[nIndex].Position == nPosition )
+ {
+ bOverWriter = sal_True;
+ pOldTab[nIndex] = aTab;
+ break;
+ }
+ pNewTab[ nIndex+1 ] = pOldTab[ nIndex ];
+ }
+ if( bOverWriter )
+ lcl_setTabStops( mxParaProps, aOldTabs );
+ else
+ lcl_setTabStops( mxParaProps, aNewTabs );
+
+ return uno::Reference< word::XTabStop >( new SwVbaTabStop( this, mxContext, mxParaProps, aTab ) );
+}
+
+void SAL_CALL SwVbaTabStops::ClearAll() throw (uno::RuntimeException)
+{
+ uno::Sequence< style::TabStop > aSeq;
+ lcl_setTabStops( mxParaProps, aSeq );
+}
+
+// XEnumerationAccess
+uno::Type
+SwVbaTabStops::getElementType() throw (uno::RuntimeException)
+{
+ return word::XTabStop::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+SwVbaTabStops::createEnumeration() throw (uno::RuntimeException)
+{
+ return new TabStopsEnumWrapper( m_xIndexAccess );
+}
+
+uno::Any
+SwVbaTabStops::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+rtl::OUString&
+SwVbaTabStops::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTabStops") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+SwVbaTabStops::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TabStops") );
+ }
+ return sNames;
+}
diff --git a/sw/source/ui/vba/vbatabstops.hxx b/sw/source/ui/vba/vbatabstops.hxx
new file mode 100644
index 000000000000..1c6ae34476c2
--- /dev/null
+++ b/sw/source/ui/vba/vbatabstops.hxx
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:
+ * $Revision:
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SW_VBA_TABSTOPS_HXX
+#define SW_VBA_TABSTOPS_HXX
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/word/XTabStops.hpp>
+#include <ooo/vba/word/XTabStop.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef CollTestImplHelper< ooo::vba::word::XTabStops > SwVbaTabStops_BASE;
+
+class SwVbaTabStops : public SwVbaTabStops_BASE
+{
+private:
+ css::uno::Reference< css::beans::XPropertySet > mxParaProps;
+
+public:
+ SwVbaTabStops( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps ) throw ( css::uno::RuntimeException );
+ virtual ~SwVbaTabStops() {}
+
+ // Methods
+ virtual css::uno::Reference< ::ooo::vba::word::XTabStop > SAL_CALL Add( float Position, const css::uno::Any& Alignment, const css::uno::Any& Leader ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearAll( ) throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SwVbaTabStops_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SW_VBA_TABSTOPS_HXX */