summaryrefslogtreecommitdiff
path: root/sw/source/ui/vba
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-06 10:16:50 +0100
committerNoel Power <noel.power@novell.com>2010-10-06 10:16:50 +0100
commit9a3f243c89bd53b0dc06c19bdccaa402c9e32c14 (patch)
tree136e33fe6d405ea1175c45246c8e13385fc28a4b /sw/source/ui/vba
parentc1369970be1d2c0cb19edcac4e1d010635c89730 (diff)
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'sw/source/ui/vba')
-rw-r--r--sw/source/ui/vba/makefile.mk24
-rw-r--r--sw/source/ui/vba/service.cxx5
-rw-r--r--sw/source/ui/vba/vbaapplication.cxx11
-rw-r--r--sw/source/ui/vba/vbaapplication.hxx1
-rw-r--r--sw/source/ui/vba/vbaautotextentry.cxx31
-rw-r--r--sw/source/ui/vba/vbabookmark.cxx7
-rw-r--r--sw/source/ui/vba/vbabookmarks.cxx13
-rw-r--r--sw/source/ui/vba/vbabookmarks.hxx2
-rw-r--r--sw/source/ui/vba/vbaborders.cxx7
-rw-r--r--sw/source/ui/vba/vbadocument.cxx170
-rw-r--r--sw/source/ui/vba/vbadocument.hxx19
-rw-r--r--sw/source/ui/vba/vbadocumentproperties.cxx12
-rw-r--r--sw/source/ui/vba/vbafield.cxx115
-rw-r--r--sw/source/ui/vba/vbafield.hxx2
-rw-r--r--sw/source/ui/vba/vbaglobals.cxx6
-rw-r--r--sw/source/ui/vba/vbaglobals.hxx1
-rw-r--r--sw/source/ui/vba/vbaheaderfooter.cxx1
-rw-r--r--sw/source/ui/vba/vbaheaderfooterhelper.cxx121
-rw-r--r--sw/source/ui/vba/vbaheaderfooterhelper.hxx16
-rw-r--r--sw/source/ui/vba/vbaparagraph.cxx14
-rw-r--r--sw/source/ui/vba/vbaparagraph.hxx2
-rw-r--r--sw/source/ui/vba/vbaparagraphformat.cxx10
-rw-r--r--sw/source/ui/vba/vbarange.cxx173
-rw-r--r--sw/source/ui/vba/vbarange.hxx13
-rw-r--r--sw/source/ui/vba/vbarangehelper.cxx31
-rw-r--r--sw/source/ui/vba/vbarangehelper.hxx3
-rw-r--r--sw/source/ui/vba/vbareplacement.cxx6
-rw-r--r--sw/source/ui/vba/vbareplacement.hxx3
-rw-r--r--sw/source/ui/vba/vbasection.cxx15
-rw-r--r--sw/source/ui/vba/vbasection.hxx4
-rw-r--r--sw/source/ui/vba/vbasections.cxx13
-rw-r--r--sw/source/ui/vba/vbasections.hxx2
-rw-r--r--sw/source/ui/vba/vbaselection.cxx798
-rw-r--r--sw/source/ui/vba/vbaselection.hxx35
-rw-r--r--sw/source/ui/vba/vbastyle.cxx143
-rw-r--r--sw/source/ui/vba/vbastyle.hxx20
-rw-r--r--sw/source/ui/vba/vbastyles.cxx157
-rw-r--r--sw/source/ui/vba/vbasystem.cxx139
-rw-r--r--sw/source/ui/vba/vbatable.cxx24
-rw-r--r--sw/source/ui/vba/vbatable.hxx3
-rw-r--r--sw/source/ui/vba/vbatables.cxx93
-rw-r--r--sw/source/ui/vba/vbatemplate.cxx60
-rw-r--r--sw/source/ui/vba/vbatemplate.hxx3
-rw-r--r--sw/source/ui/vba/vbaview.cxx36
-rw-r--r--sw/source/ui/vba/vbawindow.cxx47
-rw-r--r--sw/source/ui/vba/vbawindow.hxx2
-rw-r--r--sw/source/ui/vba/wordvbahelper.cxx98
-rw-r--r--sw/source/ui/vba/wordvbahelper.hxx15
48 files changed, 2144 insertions, 382 deletions
diff --git a/sw/source/ui/vba/makefile.mk b/sw/source/ui/vba/makefile.mk
index b6d0d7994295..b0fb0f406fce 100644
--- a/sw/source/ui/vba/makefile.mk
+++ b/sw/source/ui/vba/makefile.mk
@@ -82,6 +82,7 @@ SLOFILES= \
$(SLO)$/vbaborders.obj \
$(SLO)$/vbadocuments.obj \
$(SLO)$/vbaheaderfooter.obj \
+ $(SLO)$/vbaheadersfooters.obj \
$(SLO)$/vbaheaderfooterhelper.obj \
$(SLO)$/vbaaddin.obj \
$(SLO)$/vbaaddins.obj \
@@ -91,6 +92,29 @@ SLOFILES= \
$(SLO)$/vbapagesetup.obj \
$(SLO)$/vbasection.obj \
$(SLO)$/vbasections.obj \
+ $(SLO)$/vbarow.obj \
+ $(SLO)$/vbarows.obj \
+ $(SLO)$/vbacolumn.obj \
+ $(SLO)$/vbacolumns.obj \
+ $(SLO)$/vbatablehelper.obj \
+ $(SLO)$/vbacell.obj \
+ $(SLO)$/vbacells.obj \
+ $(SLO)$/vbatabstop.obj \
+ $(SLO)$/vbatabstops.obj \
+ $(SLO)$/vbatableofcontents.obj \
+ $(SLO)$/vbatablesofcontents.obj \
+ $(SLO)$/vbalistgallery.obj \
+ $(SLO)$/vbalistgalleries.obj \
+ $(SLO)$/vbalisthelper.obj \
+ $(SLO)$/vbalisttemplate.obj \
+ $(SLO)$/vbalisttemplates.obj \
+ $(SLO)$/vbalistlevel.obj \
+ $(SLO)$/vbalistlevels.obj \
+ $(SLO)$/vbalistformat.obj \
+ $(SLO)$/vbarevision.obj \
+ $(SLO)$/vbarevisions.obj \
+ $(SLO)$/vbaframe.obj \
+ $(SLO)$/vbaframes.obj \
$(SLO)$/vbaeventshelper.obj \
# --- Targets ------------------------------------------------------
diff --git a/sw/source/ui/vba/service.cxx b/sw/source/ui/vba/service.cxx
index 9f9cbff204dd..7f1271ae16b9 100644
--- a/sw/source/ui/vba/service.cxx
+++ b/sw/source/ui/vba/service.cxx
@@ -57,6 +57,11 @@ namespace vbaeventshelper
extern sdecl::ServiceDecl const serviceDecl;
}
+namespace vbaeventshelper
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+
extern "C"
{
void SAL_CALL component_getImplementationEnvironment(
diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx
index 8056f9ae3deb..ad16899c934a 100644
--- a/sw/source/ui/vba/vbaapplication.cxx
+++ b/sw/source/ui/vba/vbaapplication.cxx
@@ -40,6 +40,7 @@
#include <editeng/acorrcfg.hxx>
#include "wordvbahelper.hxx"
#include <docsh.hxx>
+#include "vbalistgalleries.hxx"
using namespace ::ooo;
using namespace ::ooo::vba;
@@ -151,6 +152,16 @@ SwVbaApplication::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
return uno::makeAny( xCol );
}
+uno::Any SAL_CALL
+SwVbaApplication::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextDocument > xTextDoc( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaListGalleries( this, mxContext, xTextDoc ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
sal_Bool SAL_CALL SwVbaApplication::getDisplayAutoCompleteTips() throw (css::uno::RuntimeException)
{
return SvxAutoCorrCfg::Get()->IsAutoTextTip();
diff --git a/sw/source/ui/vba/vbaapplication.hxx b/sw/source/ui/vba/vbaapplication.hxx
index 1261590d7c56..65be18774330 100644
--- a/sw/source/ui/vba/vbaapplication.hxx
+++ b/sw/source/ui/vba/vbaapplication.hxx
@@ -60,6 +60,7 @@ public:
virtual css::uno::Any SAL_CALL Documents( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Addins( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Dialogs( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL ListGalleries( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual sal_Bool SAL_CALL getDisplayAutoCompleteTips() throw (css::uno::RuntimeException);
virtual void SAL_CALL setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips ) throw (css::uno::RuntimeException);
virtual sal_Int32 SAL_CALL getEnableCancelKey() throw (css::uno::RuntimeException);
diff --git a/sw/source/ui/vba/vbaautotextentry.cxx b/sw/source/ui/vba/vbaautotextentry.cxx
index d4c153913553..0a8c0925a446 100644
--- a/sw/source/ui/vba/vbaautotextentry.cxx
+++ b/sw/source/ui/vba/vbaautotextentry.cxx
@@ -26,7 +26,9 @@
************************************************************************/
#include "vbaautotextentry.hxx"
#include <vbahelper/vbahelper.hxx>
+#include <com/sun/star/text/XParagraphCursor.hpp>
#include <tools/diagnose_ex.h>
+#include "wordvbahelper.hxx"
#include "vbarange.hxx"
using namespace ::ooo::vba;
@@ -41,7 +43,7 @@ SwVbaAutoTextEntry::~SwVbaAutoTextEntry()
{
}
-uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::Reference< word::XRange >& _where, const uno::Any& /*_richtext*/ ) throw ( uno::RuntimeException )
+uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::Reference< word::XRange >& _where, const uno::Any& _richtext ) throw ( uno::RuntimeException )
{
SwVbaRange* pWhere = dynamic_cast<SwVbaRange*>( _where.get() );
if( pWhere )
@@ -55,8 +57,28 @@ uno::Reference< word::XRange > SAL_CALL SwVbaAutoTextEntry::Insert( const uno::R
uno::Reference< text::XTextCursor > xTC = xText->createTextCursorByRange( xTextRange->getStart() );
xTC->goRight( 1, sal_True );
xTC->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
+ // remove the blank paragraph if it is a rich text
+ sal_Bool bRich = sal_False;
+ _richtext >>= bRich;
+ if( bRich )
+ {
+ // check if it is a blank paragraph
+ uno::Reference< text::XParagraphCursor > xParaCursor( xTC, uno::UNO_QUERY_THROW );
+ if( xParaCursor->isStartOfParagraph() && xParaCursor->isEndOfParagraph() )
+ {
+ //remove the blank paragraph
+ uno::Reference< frame::XModel > xModel( getCurrentWordDoc( mxContext ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextViewCursor > xTVCursor = word::getXTextViewCursor( xModel );
+ uno::Reference< text::XTextRange > xCurrentRange( xTC->getEnd(), uno::UNO_QUERY_THROW );
+ xTVCursor->gotoRange( xCurrentRange, sal_False );
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Delete"));
+ dispatchRequests( xModel,url );
+ xTVCursor->gotoRange( xEndMarker->getEnd(), sal_False );
+ }
+ }
xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); // remove marker
- xTC->gotoRange( xEndMarker, sal_True );
+ //xTC->gotoRange( xEndMarker, sal_True );
+ xTC = xText->createTextCursorByRange( xEndMarker->getEnd() );
pWhere->setXTextCursor( xTC );
}
return uno::Reference< word::XRange >( pWhere );
@@ -95,8 +117,9 @@ SwVbaAutoTextEntries::getElementType() throw (uno::RuntimeException)
uno::Reference< container::XEnumeration >
SwVbaAutoTextEntries::createEnumeration() throw (uno::RuntimeException)
{
- uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
- return xEnumerationAccess->createEnumeration();
+ //uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ //return xEnumerationAccess->createEnumeration();
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
}
uno::Any
diff --git a/sw/source/ui/vba/vbabookmark.cxx b/sw/source/ui/vba/vbabookmark.cxx
index a710682c5194..360a59e2b255 100644
--- a/sw/source/ui/vba/vbabookmark.cxx
+++ b/sw/source/ui/vba/vbabookmark.cxx
@@ -29,9 +29,12 @@
#include <tools/diagnose_ex.h>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextContent.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include "vbarange.hxx"
+#include "wordvbahelper.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -65,8 +68,8 @@ void SAL_CALL SwVbaBookmark::Delete() throw ( uno::RuntimeException )
void SAL_CALL SwVbaBookmark::Select() throw ( uno::RuntimeException )
{
checkVality();
- uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
- xViewCursorSupplier->getViewCursor()->gotoRange( mxBookmark->getAnchor(),sal_False );
+ uno::Reference< view::XSelectionSupplier > xSelectSupp( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelectSupp->select( uno::makeAny( mxBookmark ) );
}
rtl::OUString SAL_CALL SwVbaBookmark::getName() throw ( uno::RuntimeException )
diff --git a/sw/source/ui/vba/vbabookmarks.cxx b/sw/source/ui/vba/vbabookmarks.cxx
index 609b8f9df767..40943c094f6e 100644
--- a/sw/source/ui/vba/vbabookmarks.cxx
+++ b/sw/source/ui/vba/vbabookmarks.cxx
@@ -118,8 +118,7 @@ SwVbaBookmarks::SwVbaBookmarks( const uno::Reference< XHelperInterface >& xParen
mxBookmarksSupplier.set( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW );
// use view cursor to insert bookmark, or it will fail if insert bookmark in table
- // mxText = xDocument->getText();
- mxText = word::getXTextViewCursor( mxModel )->getText();
+ //mxText = word::getXTextViewCursor( mxModel )->getText();
}
// XEnumerationAccess
uno::Type
@@ -145,16 +144,16 @@ SwVbaBookmarks::createCollectionObject( const css::uno::Any& aSource )
void SwVbaBookmarks::removeBookmarkByName( const rtl::OUString& rName ) throw (uno::RuntimeException)
{
uno::Reference< text::XTextContent > xBookmark( m_xNameAccess->getByName( rName ), uno::UNO_QUERY_THROW );
- mxText->removeTextContent( xBookmark );
+ word::getXTextViewCursor( mxModel )->getText()->removeTextContent( xBookmark );
}
-void SwVbaBookmarks::addBookmarkByName( const rtl::OUString& rName, const uno::Reference< text::XTextRange >& rTextRange ) throw (uno::RuntimeException)
+void SwVbaBookmarks::addBookmarkByName( const uno::Reference< frame::XModel >& xModel, const rtl::OUString& rName, const uno::Reference< text::XTextRange >& rTextRange ) throw (uno::RuntimeException)
{
- uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< lang::XMultiServiceFactory > xDocMSF( xModel, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextContent > xBookmark( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Bookmark")) ), uno::UNO_QUERY_THROW );
uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
xNamed->setName( rName );
- mxText->insertTextContent( rTextRange, xBookmark, sal_False );
+ rTextRange->getText()->insertTextContent( rTextRange, xBookmark, sal_False );
}
uno::Any SAL_CALL
@@ -180,7 +179,7 @@ SwVbaBookmarks::Add( const rtl::OUString& rName, const uno::Any& rRange ) throw
if( m_xNameAccess->hasByName( aName ) )
removeBookmarkByName( aName );
- addBookmarkByName( aName, xTextRange );
+ addBookmarkByName( mxModel, aName, xTextRange );
return uno::makeAny( uno::Reference< word::XBookmark >( new SwVbaBookmark( getParent(), mxContext, mxModel, aName ) ) );
}
diff --git a/sw/source/ui/vba/vbabookmarks.hxx b/sw/source/ui/vba/vbabookmarks.hxx
index d9047b33d49c..511ee8639415 100644
--- a/sw/source/ui/vba/vbabookmarks.hxx
+++ b/sw/source/ui/vba/vbabookmarks.hxx
@@ -47,12 +47,12 @@ private:
private:
void removeBookmarkByName( const rtl::OUString& rName ) throw (css::uno::RuntimeException);
- void addBookmarkByName( const rtl::OUString& rName, const css::uno::Reference< css::text::XTextRange >& rTextRange ) throw (css::uno::RuntimeException);
public:
SwVbaBookmarks( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xBookmarks, const css::uno::Reference< css::frame::XModel >& xModel );
virtual ~SwVbaBookmarks() {}
+ static void addBookmarkByName( const css::uno::Reference< css::frame::XModel >& xModel, const rtl::OUString& rName, const css::uno::Reference< css::text::XTextRange >& rTextRange ) 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);
diff --git a/sw/source/ui/vba/vbaborders.cxx b/sw/source/ui/vba/vbaborders.cxx
index 184f406c49ac..73da177ad18a 100644
--- a/sw/source/ui/vba/vbaborders.cxx
+++ b/sw/source/ui/vba/vbaborders.cxx
@@ -348,14 +348,19 @@ SwVbaBorders::getItemByIntIndex( const sal_Int32 nIndex ) throw (uno::RuntimeEx
sal_Bool SAL_CALL SwVbaBorders::getShadow() throw (uno::RuntimeException)
{
+ /*
table::ShadowFormat aShadowFormat;
m_xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShadowFormat") ) ) >>= aShadowFormat;
return ( aShadowFormat.Location != table::ShadowLocation_NONE );
+ */
+ // always return False for table border in MS Word
+ return sal_False;
}
void SAL_CALL SwVbaBorders::setShadow( sal_Bool /*_shadow*/ ) throw (uno::RuntimeException)
{
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ // not support in Table border in Word
+ // TODO:
}
rtl::OUString&
diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx
index cef47c7e32dc..48d77006e986 100644
--- a/sw/source/ui/vba/vbadocument.cxx
+++ b/sw/source/ui/vba/vbadocument.cxx
@@ -38,7 +38,9 @@
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/document/XRedlinesSupplier.hpp>
#include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/word/WdProtectionType.hpp>
#include <vbahelper/helperdecl.hxx>
#include <wordvbahelper.hxx>
@@ -50,7 +52,14 @@
#include "vbafield.hxx"
#include "vbapagesetup.hxx"
#include "vbasections.hxx"
+#include "vbatablesofcontents.hxx"
#include <vbahelper/vbashapes.hxx>
+#include <vbahelper/vbahelper.hxx>
+#include "vbarevisions.hxx"
+#include "vbaframes.hxx"
+#include "vbaformfields.hxx"
+#include <osl/file.hxx>
+#include <tools/urlobj.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -220,6 +229,31 @@ SwVbaDocument::Sections( const uno::Any& index ) throw (uno::RuntimeException)
}
uno::Any SAL_CALL
+SwVbaDocument::TablesOfContents( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xCol( new SwVbaTablesOfContents( this, mxContext, mxTextDocument ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+#ifdef FIELDPATCH
+uno::Any SAL_CALL
+SwVbaDocument::FormFields( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xCol( new SwVbaFormFields( this, mxContext, getModel() ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+#else
+uno::Any SAL_CALL
+SwVbaDocument::FormFields( const uno::Any& /*index*/ ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xCol;
+#endif
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL
SwVbaDocument::PageSetup( ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xPageProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
@@ -239,16 +273,34 @@ SwVbaDocument::getAttachedTemplate() throw (uno::RuntimeException)
uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( getModel(), uno::UNO_QUERY_THROW );
uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW );
uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );
- rtl::OUString sTemplateName = xDocProps->getTemplateName();
+ rtl::OUString sTemplateUrl = xDocProps->getTemplateURL();
- xTemplate = new SwVbaTemplate( this, mxContext, getModel(), sTemplateName );
+ xTemplate = new SwVbaTemplate( this, mxContext, getModel(), sTemplateUrl );
return uno::makeAny( xTemplate );
}
void SAL_CALL
-SwVbaDocument::setAttachedTemplate( const css::uno::Any& /*_attachedtemplate*/ ) throw (uno::RuntimeException)
+SwVbaDocument::setAttachedTemplate( const css::uno::Any& _attachedtemplate ) throw (uno::RuntimeException)
{
- throw uno::RuntimeException();
+ rtl::OUString sTemplate;
+ if( !( _attachedtemplate >>= sTemplate ) )
+ {
+ throw uno::RuntimeException();
+ }
+ rtl::OUString aURL;
+ INetURLObject aObj;
+ aObj.SetURL( sTemplate );
+ bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
+ if ( bIsURL )
+ aURL = sTemplate;
+ else
+ osl::FileBase::getFileURLFromSystemPath( sTemplate, aURL );
+
+ uno::Reference< word::XTemplate > xTemplate;
+ uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( getModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW );
+ uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );
+ xDocProps->setTemplateURL( aURL );
}
uno::Any SAL_CALL
@@ -267,6 +319,116 @@ void SAL_CALL SwVbaDocument::Activate() throw (uno::RuntimeException)
VbaDocumentBase::Activate();
}
+::sal_Int32 SAL_CALL SwVbaDocument::getProtectionType() throw (css::uno::RuntimeException)
+{
+ //TODO
+ return word::WdProtectionType::wdNoProtection;
+}
+
+void SAL_CALL SwVbaDocument::setProtectionType( ::sal_Int32 /*_protectiontype*/ ) throw (css::uno::RuntimeException)
+{
+ //TODO
+}
+
+::sal_Bool SAL_CALL SwVbaDocument::getUpdateStylesOnOpen() throw (css::uno::RuntimeException)
+{
+ //TODO
+ return sal_False;
+}
+
+void SAL_CALL SwVbaDocument::setUpdateStylesOnOpen( ::sal_Bool /*_updatestylesonopen*/ ) throw (uno::RuntimeException)
+{
+ //TODO
+}
+
+::sal_Bool SAL_CALL SwVbaDocument::getAutoHyphenation() throw (uno::RuntimeException)
+{
+ // check this property only in default paragraph style
+ sal_Bool IsAutoHyphenation = sal_False;
+ uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ xParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation")) ) >>= IsAutoHyphenation;
+ return IsAutoHyphenation;
+}
+
+void SAL_CALL SwVbaDocument::setAutoHyphenation( ::sal_Bool _autohyphenation ) throw (uno::RuntimeException)
+{
+ //TODO
+ uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation")), uno::makeAny( _autohyphenation ) );
+}
+
+::sal_Int32 SAL_CALL SwVbaDocument::getHyphenationZone() throw (uno::RuntimeException)
+{
+ //TODO
+ return 0;
+}
+
+void SAL_CALL SwVbaDocument::setHyphenationZone( ::sal_Int32 /*_hyphenationzone*/ ) throw (uno::RuntimeException)
+{
+ //TODO
+}
+
+::sal_Int32 SAL_CALL SwVbaDocument::getConsecutiveHyphensLimit() throw (uno::RuntimeException)
+{
+ //TODO
+ sal_Int16 nHyphensLimit = 0;
+ uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ xParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaHyphenationMaxHyphens")) ) >>= nHyphensLimit;
+ return nHyphensLimit;
+}
+
+void SAL_CALL SwVbaDocument::setConsecutiveHyphensLimit( ::sal_Int32 _consecutivehyphenslimit ) throw (uno::RuntimeException)
+{
+ sal_Int16 nHyphensLimit = static_cast< sal_Int16 >( _consecutivehyphenslimit );
+ uno::Reference< beans::XPropertySet > xParaProps( word::getDefaultParagraphStyle( getModel() ), uno::UNO_QUERY_THROW );
+ xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaHyphenationMaxHyphens")), uno::makeAny( nHyphensLimit ) );
+}
+
+void SAL_CALL SwVbaDocument::Protect( ::sal_Int32 /*Type*/, const uno::Any& /*NOReset*/, const uno::Any& /*Password*/, const uno::Any& /*UseIRM*/, const uno::Any& /*EnforceStyleLock*/ ) throw (uno::RuntimeException)
+{
+ // Seems not support in Writer
+ // VbaDocumentBase::Protect( Password );
+}
+
+void SAL_CALL SwVbaDocument::PrintOut( const uno::Any& /*Background*/, const uno::Any& /*Append*/, const uno::Any& /*Range*/, const uno::Any& /*OutputFileName*/, const uno::Any& /*From*/, const uno::Any& /*To*/, const uno::Any& /*Item*/, const uno::Any& /*Copies*/, const uno::Any& /*Pages*/, const uno::Any& /*PageType*/, const uno::Any& /*PrintToFile*/, const uno::Any& /*Collate*/, const uno::Any& /*FileName*/, const uno::Any& /*ActivePrinterMacGX*/, const uno::Any& /*ManualDuplexPrint*/, const uno::Any& /*PrintZoomColumn*/, const uno::Any& /*PrintZoomRow*/, const uno::Any& /*PrintZoomPaperWidth*/, const uno::Any& /*PrintZoomPaperHeight*/ ) throw (uno::RuntimeException)
+{
+ //TODO
+}
+
+void SAL_CALL SwVbaDocument::PrintPreview( ) throw (uno::RuntimeException)
+{
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrintPreview"));
+ dispatchRequests( mxModel,url );
+}
+
+void SAL_CALL SwVbaDocument::ClosePrintPreview( ) throw (uno::RuntimeException)
+{
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ClosePreview"));
+ dispatchRequests( mxModel,url );
+}
+
+uno::Any SAL_CALL
+SwVbaDocument::Revisions( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaRevisions( this, mxContext, getModel(), xRedlines ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL
+SwVbaDocument::Frames( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextFramesSupplier > xTextFramesSupp( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xFrames( xTextFramesSupp->getTextFrames(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaFrames( this, mxContext, xFrames, getModel() ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
uno::Any
SwVbaDocument::getControlShape( const ::rtl::OUString& sName )
{
diff --git a/sw/source/ui/vba/vbadocument.hxx b/sw/source/ui/vba/vbadocument.hxx
index ab87798a8ded..1ffe20e46aba 100644
--- a/sw/source/ui/vba/vbadocument.hxx
+++ b/sw/source/ui/vba/vbadocument.hxx
@@ -65,6 +65,25 @@ public:
virtual css::uno::Any SAL_CALL Sections( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL PageSetup() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL TablesOfContents( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL FormFields( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getProtectionType() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setProtectionType( ::sal_Int32 _protectiontype ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getUpdateStylesOnOpen() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUpdateStylesOnOpen( ::sal_Bool _updatestylesonopen ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getAutoHyphenation() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoHyphenation( ::sal_Bool _autohyphenation ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getHyphenationZone() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHyphenationZone( ::sal_Int32 _hyphenationzone ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getConsecutiveHyphensLimit() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setConsecutiveHyphensLimit( ::sal_Int32 _consecutivehyphenslimit ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Protect( ::sal_Int32 Type, const css::uno::Any& NOReset, const css::uno::Any& Password, const css::uno::Any& UseIRM, const css::uno::Any& EnforceStyleLock ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PrintOut( const css::uno::Any& Background, const css::uno::Any& Append, const css::uno::Any& Range, const css::uno::Any& OutputFileName, const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Item, const css::uno::Any& Copies, const css::uno::Any& Pages, const css::uno::Any& PageType, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& FileName, const css::uno::Any& ActivePrinterMacGX, const css::uno::Any& ManualDuplexPrint, const css::uno::Any& PrintZoomColumn, const css::uno::Any& PrintZoomRow, const css::uno::Any& PrintZoomPaperWidth, const css::uno::Any& PrintZoomPaperHeight ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PrintPreview( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClosePrintPreview( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Revisions( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Frames( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
// XInvocation
virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx
index 50ab62dd904f..4c914a96ca6f 100644
--- a/sw/source/ui/vba/vbadocumentproperties.cxx
+++ b/sw/source/ui/vba/vbadocumentproperties.cxx
@@ -203,16 +203,16 @@ public:
static DocPropInfo createDocPropInfo( const rtl::OUString& sDesc, const rtl::OUString& sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
{
- return createDocPropInfo( rtl::OUStringToOString( sDesc, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( sPropName, RTL_TEXTENCODING_UTF8 ).getStr(), rHelper );
+ DocPropInfo aItem;
+ aItem.msMSODesc = sDesc;
+ aItem.msOOOPropName = sPropName;
+ aItem.mpPropGetSetHelper = rHelper;
+ return aItem;
}
static DocPropInfo createDocPropInfo( const sal_Char* sDesc, const sal_Char* sPropName, boost::shared_ptr< PropertGetSetHelper >& rHelper )
{
- DocPropInfo aItem;
- aItem.msMSODesc = rtl::OUString::createFromAscii( sDesc );
- aItem.msOOOPropName = rtl::OUString::createFromAscii( sPropName );
- aItem.mpPropGetSetHelper = rHelper;
- return aItem;
+ return createDocPropInfo( rtl::OUString::createFromAscii( sDesc ), rtl::OUString::createFromAscii( sPropName ), rHelper );
}
uno::Any getValue()
{
diff --git a/sw/source/ui/vba/vbafield.cxx b/sw/source/ui/vba/vbafield.cxx
index a33b3c208c8f..e5b4d87a751d 100644
--- a/sw/source/ui/vba/vbafield.cxx
+++ b/sw/source/ui/vba/vbafield.cxx
@@ -33,6 +33,7 @@
#include <ooo/vba/word/WdFieldType.hpp>
#include <com/sun/star/text/FilenameDisplayFormat.hpp>
#include <com/sun/star/util/XRefreshable.hpp>
+#include <com/sun/star/util/XUpdatable.hpp>
#include <swtypes.hxx>
using namespace ::ooo::vba;
@@ -45,6 +46,17 @@ SwVbaField::SwVbaField( const uno::Reference< ooo::vba::XHelperInterface >& rPa
mxTextField.set( xTextField, uno::UNO_QUERY_THROW );
}
+sal_Bool SAL_CALL SwVbaField::Update() throw (uno::RuntimeException)
+{
+ uno::Reference< util::XUpdatable > xUpdatable( mxTextField, uno::UNO_QUERY );
+ if( xUpdatable.is() )
+ {
+ xUpdatable->update();
+ return sal_True;
+ }
+ return sal_False;
+}
+
// XHelperInterface
rtl::OUString&
SwVbaField::getServiceImplName()
@@ -368,6 +380,7 @@ SwVbaFields::Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range,
{
_ReadFieldParams aReadParam(sText);
sFieldName = aReadParam.GetFieldName();
+ OSL_TRACE("SwVbaFields::Add, the field name is %s ",rtl::OUStringToOString( sFieldName, RTL_TEXTENCODING_UTF8 ).getStr() );
}
uno::Reference< text::XTextContent > xTextField;
@@ -375,6 +388,10 @@ SwVbaFields::Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range,
{
xTextField.set( Create_Field_FileName( sText ), uno::UNO_QUERY_THROW );
}
+ else if( nType == word::WdFieldType::wdFieldDocProperty || sFieldName.EqualsIgnoreCaseAscii("DOCPROPERTY") )
+ {
+ xTextField.set( Create_Field_DocProperty( sText ), uno::UNO_QUERY_THROW );
+ }
else
{
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
@@ -419,6 +436,104 @@ uno::Reference< text::XTextField > SwVbaFields::Create_Field_FileName( const rtl
return xTextField;
}
+struct DocPropertyTable
+{
+ const char* sDocPropertyName;
+ const char* sFieldService;
+};
+
+static const DocPropertyTable aDocPropertyTables[] =
+{
+ { "Author", "com.sun.star.text.textfield.docinfo.CreateAuthor" },
+ { "Bytes", NULL },
+ { "Category", NULL },
+ { "Characters",NULL },
+ { "CharactersWithSpaces", NULL },
+ { "Comments", "com.sun.star.text.textfield.docinfo.Description" },
+ { "Company", NULL },
+ { "CreateTime", "com.sun.star.text.textfield.docinfo.CreateDateTime" },
+ { "HyperlinkBase", NULL },
+ { "Keywords", "com.sun.star.text.textfield.docinfo.Keywords" },
+ { "LastPrinted", "com.sun.star.text.textfield.docinfo.PrintDateTime" },
+ { "LastSavedBy", "com.sun.star.text.textfield.docinfo.ChangeAuthor" },
+ { "LastSavedTime", "com.sun.star.text.textfield.docinfo.ChangeDateTime" },
+ { "Lines", NULL },
+ { "Manager", NULL },
+ { "NameofApplication", NULL },
+ { "ODMADocID", NULL },
+ { "Pages", "com.sun.star.text.textfield.PageCount" },
+ { "Paragraphs", "com.sun.star.text.textfield.ParagraphCount" },
+ { "RevisionNumber", "com.sun.star.text.textfield.docinfo.Revision" },
+ { "Security", NULL },
+ { "Subject", "com.sun.star.text.textfield.docinfo.Subject" },
+ { "Template", "com.sun.star.text.textfield.TemplateName" },
+ { "Title", "com.sun.star.text.textfield.docinfo.Title" },
+ { "TotalEditingTime", "com.sun.star.text.textfield.docinfo.EditTime" },
+ { "Words", "com.sun.star.text.textfield.WordCount" },
+ { NULL, NULL }
+};
+
+uno::Reference< text::XTextField > SwVbaFields::Create_Field_DocProperty( const rtl::OUString _text ) throw (uno::RuntimeException)
+{
+ String aDocProperty;
+ _ReadFieldParams aReadParam( _text );
+ long nRet;
+ while( -1 != ( nRet = aReadParam.SkipToNextToken() ))
+ {
+ switch( nRet )
+ {
+ case -2:
+ if( !aDocProperty.Len() )
+ aDocProperty = aReadParam.GetResult();
+ break;
+ case '*':
+ //Skip over MERGEFORMAT
+ aReadParam.SkipToNextToken();
+ break;
+ }
+ }
+ aDocProperty.EraseAllChars('"');
+ OSL_TRACE("SwVbaFields::Create_Field_DocProperty, the document property name is %s ",rtl::OUStringToOString( aDocProperty, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if( aDocProperty.Len() == 0 )
+ {
+ throw uno::RuntimeException();
+ }
+
+ sal_Bool bCustom = sal_True;
+ rtl::OUString sFieldService;
+ // find the build in document properties
+ for( const DocPropertyTable* pTable = aDocPropertyTables; pTable->sDocPropertyName != NULL; pTable++ )
+ {
+ if( aDocProperty.EqualsIgnoreCaseAscii( pTable->sDocPropertyName ) )
+ {
+ if( pTable->sFieldService != NULL )
+ sFieldService = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( pTable->sFieldService ) );
+ bCustom = sal_False;
+ break;
+ }
+ }
+
+ if( bCustom )
+ {
+ sFieldService = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.textfield.docinfo.Custom" ) );
+ }
+ else if( sFieldService.getLength() == 0 )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+
+ uno::Reference< text::XTextField > xTextField( mxMSF->createInstance( sFieldService ), uno::UNO_QUERY_THROW );
+
+ if( bCustom )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xTextField, uno::UNO_QUERY_THROW );
+ rtl::OUString sDocPropertyName( aDocProperty );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Name") ), uno::makeAny( sDocPropertyName ) );
+ }
+
+ return xTextField;
+}
+
uno::Reference< container::XEnumeration > SAL_CALL
SwVbaFields::createEnumeration() throw (uno::RuntimeException)
{
diff --git a/sw/source/ui/vba/vbafield.hxx b/sw/source/ui/vba/vbafield.hxx
index 3c55acf73e9d..4f2ca4645be4 100644
--- a/sw/source/ui/vba/vbafield.hxx
+++ b/sw/source/ui/vba/vbafield.hxx
@@ -42,6 +42,7 @@ class SwVbaField : public SwVbaField_BASE
public:
SwVbaField( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& rDocument, const css::uno::Reference< css::text::XTextField >& xTextField) throw ( css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL Update() throw ( css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
@@ -57,6 +58,7 @@ class SwVbaFields : public SwVbaFields_BASE
css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
private:
css::uno::Reference< css::text::XTextField > Create_Field_FileName( const rtl::OUString _text ) throw (css::uno::RuntimeException);
+ css::uno::Reference< css::text::XTextField > Create_Field_DocProperty( const rtl::OUString _text ) throw (css::uno::RuntimeException);
public:
SwVbaFields( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
diff --git a/sw/source/ui/vba/vbaglobals.cxx b/sw/source/ui/vba/vbaglobals.cxx
index b95c5e5c9e3d..cd67e3019b37 100644
--- a/sw/source/ui/vba/vbaglobals.cxx
+++ b/sw/source/ui/vba/vbaglobals.cxx
@@ -129,6 +129,12 @@ SwVbaGlobals::Dialogs( const uno::Any& index ) throw (uno::RuntimeException)
return getApplication()->Dialogs( index );
}
+uno::Any SAL_CALL
+SwVbaGlobals::ListGalleries( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ return getApplication()->ListGalleries( index );
+}
+
uno::Reference<word::XSelection > SAL_CALL
SwVbaGlobals::getSelection() throw (uno::RuntimeException)
{
diff --git a/sw/source/ui/vba/vbaglobals.hxx b/sw/source/ui/vba/vbaglobals.hxx
index 9bb2e8fa606d..4bf3e7be033c 100644
--- a/sw/source/ui/vba/vbaglobals.hxx
+++ b/sw/source/ui/vba/vbaglobals.hxx
@@ -69,6 +69,7 @@ public:
virtual css::uno::Any SAL_CALL Documents( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Addins( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Dialogs( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL ListGalleries( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException);
// XMultiServiceFactory
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (css::uno::RuntimeException);
diff --git a/sw/source/ui/vba/vbaheaderfooter.cxx b/sw/source/ui/vba/vbaheaderfooter.cxx
index 6fb7061c573f..6b7c131492d6 100644
--- a/sw/source/ui/vba/vbaheaderfooter.cxx
+++ b/sw/source/ui/vba/vbaheaderfooter.cxx
@@ -81,6 +81,7 @@ uno::Reference< word::XRange > SAL_CALL SwVbaHeaderFooter::getRange() throw (uno
uno::Any SAL_CALL
SwVbaHeaderFooter::Shapes( const uno::Any& index ) throw (uno::RuntimeException)
{
+ // #FIXME: only get the shapes in the current header/footer
uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
//uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.cxx b/sw/source/ui/vba/vbaheaderfooterhelper.cxx
index 604cc1e11d8c..e299c51953ae 100644
--- a/sw/source/ui/vba/vbaheaderfooterhelper.cxx
+++ b/sw/source/ui/vba/vbaheaderfooterhelper.cxx
@@ -29,8 +29,12 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -38,41 +42,61 @@ using namespace ::ooo::vba;
#define FIRST_PAGE 1;
// Class HeaderFooterHelper
+sal_Bool HeaderFooterHelper::isHeaderFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ return isHeaderFooter( word::getCurrentXText( xModel ) );
+}
-sal_Bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isHeaderFooter( const uno::Reference< text::XText >& xText ) throw (uno::RuntimeException)
{
- uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xText, uno::UNO_QUERY_THROW );
+ rtl::OUString aImplName = xServiceInfo->getImplementationName();
+ if( aImplName.equalsAscii("SwXHeadFootText") )
+ return sal_True;
+ return sal_False;
+}
- sal_Bool isOn = sal_False;
- xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))) >>= isOn;
- if( !isOn )
+sal_Bool HeaderFooterHelper::isHeader( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ const uno::Reference< text::XText > xCurrentText = word::getCurrentXText( xModel );
+ if( !isHeaderFooter( xCurrentText ) )
return sal_False;
- sal_Bool isShared = sal_False;
- xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared"))) >>= isShared;
-
+ rtl::OUString aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared") );
rtl::OUString aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") );
+ uno::Reference< style::XStyle > xPageStyle = word::getCurrentPageStyle( xModel );
+ uno::Reference< beans::XPropertySet > xPageProps( xPageStyle, uno::UNO_QUERY_THROW );
+ sal_Bool isShared = sal_True;
+ xPageProps->getPropertyValue( aPropIsShared ) >>= isShared;
if( !isShared )
{
+ uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
if( 0 == xPageCursor->getPage() % 2 )
- {
aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderTextLeft") );
- }
else
- {
aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderTextRight") );
- }
}
- uno::Reference< text::XText > xText( xStyleProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
- //FIXME: can not compare in this way?
- return ( xText == xCurrentText );
+ uno::Reference< text::XText > xHeaderText( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRangeCompare > xTRC( xHeaderText, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTR1( xCurrentText, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTR2( xHeaderText, uno::UNO_QUERY_THROW );
+ try
+ {
+ if( xTRC->compareRegionStarts( xTR1, xTR2 ) == 0 )
+ return sal_True;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ return sal_False;
+ }
+
+ return sal_False;
}
-sal_Bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- if( isHeader( xModel, xCurrentText ) )
+ if( isHeader( xModel ) )
{
uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
// FIXME: getPage allways returns 1
@@ -82,9 +106,9 @@ sal_Bool HeaderFooterHelper::isFirstPageHeader( const uno::Reference< frame::XMo
return sal_False;
}
-sal_Bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- if( isHeader( xModel, xCurrentText ) )
+ if( isHeader( xModel ) )
{
uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
sal_Bool isShared = sal_False;
@@ -98,40 +122,47 @@ sal_Bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XMo
return sal_False;
}
-sal_Bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
-
- sal_Bool isOn = sal_False;
- xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))) >>= isOn;
- if( !isOn )
+ const uno::Reference< text::XText > xCurrentText = word::getCurrentXText( xModel );
+ if( !isHeaderFooter( xCurrentText ) )
return sal_False;
- sal_Bool isShared = sal_False;
- xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared"))) >>= isShared;
-
+ rtl::OUString aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared") );
rtl::OUString aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") );
+ uno::Reference< style::XStyle > xPageStyle = word::getCurrentPageStyle( xModel );
+ uno::Reference< beans::XPropertySet > xPageProps( xPageStyle, uno::UNO_QUERY_THROW );
+ sal_Bool isShared = sal_True;
+ xPageProps->getPropertyValue( aPropIsShared ) >>= isShared;
if( !isShared )
{
+ uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
if( 0 == xPageCursor->getPage() % 2 )
- {
aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterTextLeft") );
- }
else
- {
aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterTextRight") );
- }
}
- uno::Reference< text::XText > xText( xStyleProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XText > xFooterText( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRangeCompare > xTRC( xFooterText, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTR1( xCurrentText, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xTR2( xFooterText, uno::UNO_QUERY_THROW );
+ try
+ {
+ if( xTRC->compareRegionStarts( xTR1, xTR2 ) == 0 )
+ return sal_True;
+ }
+ catch( lang::IllegalArgumentException& )
+ {
+ return sal_False;
+ }
- return ( xText == xCurrentText );
+ return sal_False;
}
-sal_Bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- if( isFooter( xModel, xCurrentText ) )
+ if( isFooter( xModel ) )
{
uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
sal_Int32 nPage = xPageCursor->getPage();
@@ -140,9 +171,9 @@ sal_Bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XMo
return sal_False;
}
-sal_Bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- if( isFooter( xModel, xCurrentText ) )
+ if( isFooter( xModel ) )
{
uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW );
sal_Bool isShared = sal_False;
@@ -158,18 +189,18 @@ sal_Bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XMo
#ifdef TOMORROW
sal_Bool HeaderFooterHelper::isPrimaryHeader( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
{
- if( isHeader( xModel, xCurrentText ) )
+ if( isHeader( xModel ) )
{
- return( !( isFirstPageHeader( xModel, xCurrentText ) && isEvenPagesHeader( xModel, xCurrentText ) ) );
+ return( !( isFirstPageHeader( xModel ) && isEvenPagesHeader( xModel ) ) );
}
return sal_False;
}
-sal_Bool HeaderFooterHelper::isPrimaryFooter( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XText >& xCurrentText ) throw (uno::RuntimeException)
+sal_Bool HeaderFooterHelper::isPrimaryFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
- if( isHeader( xModel, xCurrentText ) )
+ if( isHeader( xModel ) )
{
- return( !( isFirstPageFooter( xModel, xCurrentText ) && isEvenPagesFooter( xModel, xCurrentText ) ) );
+ return( !( isFirstPageFooter( xModel ) && isEvenPagesFooter( xModel ) ) );
}
return sal_False;
}
diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.hxx b/sw/source/ui/vba/vbaheaderfooterhelper.hxx
index fd29a16015ab..4b620901da67 100644
--- a/sw/source/ui/vba/vbaheaderfooterhelper.hxx
+++ b/sw/source/ui/vba/vbaheaderfooterhelper.hxx
@@ -36,12 +36,16 @@
class HeaderFooterHelper
{
public:
- static sal_Bool isHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
- static sal_Bool isFirstPageHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
- static sal_Bool isEvenPagesHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
- static sal_Bool isFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
- static sal_Bool isFirstPageFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
- static sal_Bool isEvenPagesFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
+ static sal_Bool isHeaderFooter( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isHeaderFooter( const css::uno::Reference< css::text::XText >& xText ) throw (css::uno::RuntimeException);
+ static sal_Bool isHeader( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isFirstPageHeader( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isEvenPagesHeader( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isFooter( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isFirstPageFooter( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isEvenPagesFooter( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isPrimaryHeader( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ static sal_Bool isPrimaryFooter( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
#ifdef TOMORROW
static sal_Bool isPrimaryHeader( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
static sal_Bool isPrimaryFooter( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XText >& xCurrentText ) throw (css::uno::RuntimeException);
diff --git a/sw/source/ui/vba/vbaparagraph.cxx b/sw/source/ui/vba/vbaparagraph.cxx
index 333fd4ca9a98..61b78f1a330f 100644
--- a/sw/source/ui/vba/vbaparagraph.cxx
+++ b/sw/source/ui/vba/vbaparagraph.cxx
@@ -48,6 +48,20 @@ SwVbaParagraph::getRange( ) throw ( uno::RuntimeException )
return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, mxTextRange->getStart(), mxTextRange->getEnd(), mxTextRange->getText(), sal_True ) );
}
+uno::Any SAL_CALL
+SwVbaParagraph::getStyle( ) throw ( uno::RuntimeException )
+{
+ uno::Reference< word::XRange > xRange = getRange();
+ return xRange->getStyle();
+}
+
+void SAL_CALL
+SwVbaParagraph::setStyle( const uno::Any& style ) throw ( uno::RuntimeException )
+{
+ uno::Reference< word::XRange > xRange = getRange();
+ xRange->setStyle( style );
+}
+
rtl::OUString&
SwVbaParagraph::getServiceImplName()
{
diff --git a/sw/source/ui/vba/vbaparagraph.hxx b/sw/source/ui/vba/vbaparagraph.hxx
index 894ac61cc7e6..6e299c7d6f9f 100644
--- a/sw/source/ui/vba/vbaparagraph.hxx
+++ b/sw/source/ui/vba/vbaparagraph.hxx
@@ -50,6 +50,8 @@ public:
// XParagraph
virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL getRange() throw ( css::uno::RuntimeException );
+ virtual css::uno::Any SAL_CALL getStyle() throw ( css::uno::RuntimeException );
+ virtual void SAL_CALL setStyle( const css::uno::Any& style ) throw ( css::uno::RuntimeException );
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sw/source/ui/vba/vbaparagraphformat.cxx b/sw/source/ui/vba/vbaparagraphformat.cxx
index 07a822ad5752..5f28bfe21938 100644
--- a/sw/source/ui/vba/vbaparagraphformat.cxx
+++ b/sw/source/ui/vba/vbaparagraphformat.cxx
@@ -34,6 +34,7 @@
#include <ooo/vba/word/WdOutlineLevel.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/style/BreakType.hpp>
+#include "vbatabstops.hxx"
using namespace ::ooo::vba;
@@ -200,9 +201,12 @@ sal_Int32 SAL_CALL SwVbaParagraphFormat::getOutlineLevel() throw (uno::RuntimeEx
return nLevel;
}
-void SAL_CALL SwVbaParagraphFormat::setOutlineLevel( sal_Int32 /*_outlinelevel*/ ) throw (uno::RuntimeException)
+void SAL_CALL SwVbaParagraphFormat::setOutlineLevel( sal_Int32 _outlinelevel ) throw (uno::RuntimeException)
{
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ if( _outlinelevel != getOutlineLevel() )
+ {
+ // TODO: in my test in msword, there is no effect for this function.
+ }
}
uno::Any SAL_CALL SwVbaParagraphFormat::getPageBreakBefore() throw (uno::RuntimeException)
@@ -296,7 +300,7 @@ void SAL_CALL SwVbaParagraphFormat::setRightIndent( float _rightindent ) throw (
uno::Any SAL_CALL SwVbaParagraphFormat::getTabStops() throw (uno::RuntimeException)
{
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ return uno::makeAny( uno::Reference< word::XTabStops >( new SwVbaTabStops( this, mxContext, mxParaProps ) ) );
}
void SAL_CALL SwVbaParagraphFormat::setTabStops( const uno::Any& /*_tabstops*/ ) throw (uno::RuntimeException)
diff --git a/sw/source/ui/vba/vbarange.cxx b/sw/source/ui/vba/vbarange.cxx
index 647aedb34791..9c70f6f8cf95 100644
--- a/sw/source/ui/vba/vbarange.cxx
+++ b/sw/source/ui/vba/vbarange.cxx
@@ -32,12 +32,21 @@
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
-#include "wordvbahelper.hxx"
+#include <com/sun/star/text/XTextRangeCompare.hpp>
+#include <com/sun/star/text/XWordCursor.hpp>
+#include <com/sun/star/text/XParagraphCursor.hpp>
+#include <ooo/vba/word/WdUnits.hpp>
+#include <ooo/vba/word/WdMovementType.hpp>
#include "vbaparagraphformat.hxx"
#include "vbastyle.hxx"
#include "vbafont.hxx"
#include "vbapalette.hxx"
#include "vbapagesetup.hxx"
+#include "vbalistformat.hxx"
+#include "vbarevisions.hxx"
+#include "vbabookmarks.hxx"
+#include "vbasections.hxx"
+#include "vbafield.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -70,6 +79,8 @@ void SwVbaRange::initialize( const uno::Reference< text::XTextRange >& rStart, c
}
mxTextCursor = SwVbaRangeHelper::initCursor( rStart, mxText );
+ if( !mxTextCursor.is() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Fails to create text cursor") ), uno::Reference< uno::XInterface >() );
mxTextCursor->collapseToStart();
if( rEnd.is() )
@@ -90,6 +101,67 @@ void SwVbaRange::setXTextRange( const uno::Reference< text::XTextRange >& xRange
mxTextCursor->gotoRange( xRange->getStart(), sal_False );
mxTextCursor->gotoRange( xRange->getEnd(), sal_True );
}
+
+void
+SwVbaRange::Move( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend, word::E_DIRECTION eDirection ) throw ( uno::RuntimeException )
+{
+ sal_Int32 nUnit = word::WdUnits::wdCharacter;
+ sal_Int32 nCount = 1;
+ sal_Int32 nExtend = word::WdMovementType::wdMove;
+
+ if( _unit.hasValue() )
+ _unit >>= nUnit;
+ if( _count.hasValue() )
+ _count >>= nCount;
+ if( _extend.hasValue() )
+ _extend >>= nExtend;
+
+ if( nCount == 0 )
+ return;
+
+ sal_Bool bExpand = ( nExtend == word::WdMovementType::wdMove ) ? sal_False : sal_True;
+
+ switch( nUnit )
+ {
+ case word::WdUnits::wdParagraph:
+ {
+ if( eDirection == word::MOVE_LEFT || eDirection == word::MOVE_RIGHT )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< text::XParagraphCursor > xParagraphCursor( mxTextCursor, uno::UNO_QUERY_THROW );
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ if( ( eDirection == word::MOVE_UP ) && ( xParagraphCursor->gotoPreviousParagraph( bExpand ) == sal_False ) )
+ break;
+ else if( ( eDirection == word::MOVE_DOWN ) && ( xParagraphCursor->gotoNextParagraph( bExpand ) == sal_False ) )
+ break;
+ }
+ break;
+ }
+ case word::WdUnits::wdWord:
+ {
+ if( eDirection == word::MOVE_UP || eDirection == word::MOVE_DOWN )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< text::XWordCursor > xWordCursor( mxTextCursor, uno::UNO_QUERY_THROW );
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ if( (eDirection == word::MOVE_LEFT ) && ( xWordCursor->gotoPreviousWord( bExpand ) == sal_False ) )
+ break;
+ else if( ( eDirection == word::MOVE_RIGHT ) && ( xWordCursor->gotoNextWord( bExpand ) == sal_False ) )
+ break;
+ }
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ break;
+ }
+ }
+}
#endif
/**
* The complexity in this method is because we need to workaround
@@ -128,17 +200,46 @@ SwVbaRange::getText() throw ( uno::RuntimeException )
void SAL_CALL
SwVbaRange::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException )
{
+ // Emulate the MSWord behavior, Don't delete the bookmark
+ // which contains no text string in current inserting position,
+ rtl::OUString sName;
+ uno::Reference< text::XTextRange > xRange( mxTextCursor, uno::UNO_QUERY_THROW );
+ try
+ {
+ uno::Reference< text::XTextContent > xBookmark = SwVbaRangeHelper::findBookmarkByPosition( mxTextDocument, xRange->getStart() );
+ if( xBookmark.is() )
+ {
+ uno::Reference< container::XNamed > xNamed( xBookmark, uno::UNO_QUERY_THROW );
+ sName = xNamed->getName();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ // do nothing
+ }
+
if( rText.indexOf( '\n' ) != -1 )
{
mxTextCursor->setString( rtl::OUString() );
// process CR in strings
- uno::Reference< text::XTextRange > xRange( mxTextCursor, uno::UNO_QUERY_THROW );
SwVbaRangeHelper::insertString( xRange, mxText, rText, sal_True );
}
else
{
mxTextCursor->setString( rText );
}
+
+ // insert the bookmark if the bookmark is deleted during setting text string
+ if( sName.getLength() )
+ {
+ uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW );
+ if( !xNameAccess->hasByName( sName ) )
+ {
+ uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
+ SwVbaBookmarks::addBookmarkByName( xModel, sName, xRange->getStart() );
+ }
+ }
}
// FIXME: test is not pass
@@ -229,11 +330,8 @@ SwVbaRange::setParagraphFormat( const uno::Reference< word::XParagraphFormat >&
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
}
-uno::Reference< word::XStyle > SAL_CALL
-SwVbaRange::getStyle() throw ( uno::RuntimeException )
+void SwVbaRange::GetStyleInfo(rtl::OUString& aStyleName, rtl::OUString& aStyleType ) throw ( uno::RuntimeException )
{
- rtl::OUString aStyleName;
- rtl::OUString aStyleType;
uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW );
if( ( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharStyleName") ) ) >>= aStyleName ) && aStyleName.getLength() )
{
@@ -247,14 +345,23 @@ SwVbaRange::getStyle() throw ( uno::RuntimeException )
{
DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() );
}
+}
+
+uno::Any SAL_CALL
+SwVbaRange::getStyle() throw ( uno::RuntimeException )
+{
+ rtl::OUString aStyleName;
+ rtl::OUString aStyleType;
+ GetStyleInfo( aStyleName, aStyleType );
uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
- return uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xStyleProps ) );
+ uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xModel, xStyleProps ) ) );
}
void SAL_CALL
-SwVbaRange::setStyle( const uno::Reference< word::XStyle >& rStyle ) throw ( uno::RuntimeException )
+SwVbaRange::setStyle( const uno::Any& rStyle ) throw ( uno::RuntimeException )
{
uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW );
SwVbaStyle::setStyle( xParaProps, rStyle );
@@ -267,6 +374,12 @@ SwVbaRange::getFont() throw ( uno::RuntimeException )
return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), uno::Reference< beans::XPropertySet >( getXTextRange(), uno::UNO_QUERY_THROW ) );
}
+uno::Reference< word::XListFormat > SAL_CALL
+SwVbaRange::getListFormat() throw ( uno::RuntimeException )
+{
+ return uno::Reference< word::XListFormat >( new SwVbaListFormat( this, mxContext, getXTextRange() ) );
+}
+
::sal_Int32 SAL_CALL SwVbaRange::getLanguageID() throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW );
@@ -324,6 +437,50 @@ void SAL_CALL SwVbaRange::setEnd( ::sal_Int32 _end ) throw (uno::RuntimeExceptio
mxTextCursor->gotoRange( xEnd, sal_True );
}
+::sal_Bool SAL_CALL SwVbaRange::InRange( const uno::Reference< ::ooo::vba::word::XRange >& Range ) throw (uno::RuntimeException)
+{
+ SwVbaRange* pRange = dynamic_cast< SwVbaRange* >( Range.get() );
+ if( !pRange )
+ throw uno::RuntimeException();
+ uno::Reference< text::XTextRange > xTextRange = pRange->getXTextRange();
+ uno::Reference< text::XTextRangeCompare > xTRC( mxTextCursor->getText(), uno::UNO_QUERY_THROW );
+ if( xTRC->compareRegionStarts( xTextRange, getXTextRange() ) >= 0 && xTRC->compareRegionEnds( xTextRange, getXTextRange() ) <= 0 )
+ return sal_True;
+ return sal_False;
+}
+
+uno::Any SAL_CALL
+SwVbaRange::Revisions( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextRange > xTextRange = getXTextRange();
+ uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaRevisions( mxParent, mxContext, xModel, xTextRange ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL
+SwVbaRange::Sections( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextRange > xTextRange = getXTextRange();
+ uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, xModel, xTextRange ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL
+SwVbaRange::Fields( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ //FIXME: should be get the field in current range
+ uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, xModel ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
rtl::OUString&
SwVbaRange::getServiceImplName()
{
diff --git a/sw/source/ui/vba/vbarange.hxx b/sw/source/ui/vba/vbarange.hxx
index 1f1b3a3bbc8b..c74ef3487f5a 100644
--- a/sw/source/ui/vba/vbarange.hxx
+++ b/sw/source/ui/vba/vbarange.hxx
@@ -35,6 +35,8 @@
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <ooo/vba/word/XStyle.hpp>
+#include <ooo/vba/word/XListFormat.hpp>
+#include "wordvbahelper.hxx"
typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRange > SwVbaRange_BASE;
@@ -48,6 +50,7 @@ private:
private:
void initialize( const css::uno::Reference< css::text::XTextRange >& rStart, const css::uno::Reference< css::text::XTextRange >& rEnd ) throw (css::uno::RuntimeException);
+ void GetStyleInfo(rtl::OUString& aStyleName, rtl::OUString& aStyleType ) throw ( css::uno::RuntimeException );
public:
SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& rTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart, sal_Bool _bMaySpanEndOfDocument = sal_False ) throw (css::uno::RuntimeException);
SwVbaRange( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& rTextDocument, const css::uno::Reference< css::text::XTextRange >& rStart, const css::uno::Reference< css::text::XTextRange >& rEnd, sal_Bool _bMaySpanEndOfDocument = sal_False ) throw (css::uno::RuntimeException);
@@ -61,16 +64,18 @@ public:
#endif
css::uno::Reference< css::text::XText > getXText() { return mxText; }
void setXTextCursor( const css::uno::Reference< css::text::XTextCursor >& xTextCursor ) { mxTextCursor = xTextCursor; }
+ void Move( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend, ooo::vba::word::E_DIRECTION eDirection ) throw (css::uno::RuntimeException);
// Attribute
virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
virtual void SAL_CALL setText( const rtl::OUString& rText ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XParagraphFormat > SAL_CALL getParagraphFormat() throw (css::uno::RuntimeException);
virtual void SAL_CALL setParagraphFormat( const css::uno::Reference< ooo::vba::word::XParagraphFormat >& rParagraphFormat ) throw (css::uno::RuntimeException);
- virtual css::uno::Reference< ooo::vba::word::XStyle > SAL_CALL getStyle() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setStyle( const css::uno::Reference< ooo::vba::word::XStyle >& _xStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( const css::uno::Any& _xStyle ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ooo::vba::word::XListFormat > SAL_CALL getListFormat() throw (css::uno::RuntimeException);
// Methods
virtual void SAL_CALL InsertBreak( const css::uno::Any& _breakType ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Select() throw (css::uno::RuntimeException);
@@ -84,6 +89,10 @@ public:
virtual void SAL_CALL setStart( ::sal_Int32 _start ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getEnd() throw (css::uno::RuntimeException);
virtual void SAL_CALL setEnd( ::sal_Int32 _end ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL InRange( const css::uno::Reference< ::ooo::vba::word::XRange >& Range ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Revisions( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Sections( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Fields( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sw/source/ui/vba/vbarangehelper.cxx b/sw/source/ui/vba/vbarangehelper.cxx
index 4fd9e5f143f1..d121cb483825 100644
--- a/sw/source/ui/vba/vbarangehelper.cxx
+++ b/sw/source/ui/vba/vbarangehelper.cxx
@@ -27,6 +27,7 @@
#include "vbarangehelper.hxx"
#include <com/sun/star/text/ControlCharacter.hpp>
#include <com/sun/star/text/XTextRangeCompare.hpp>
+#include <com/sun/star/text/XBookmarksSupplier.hpp>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -111,7 +112,7 @@ uno::Reference< text::XTextCursor > SwVbaRangeHelper::initCursor( const uno::Ref
DebugHelper::exception(e);
}
- if( !bGotTextCursor )
+ if( !bGotTextCursor || !xTextCursor.is() )
{
try
{
@@ -125,7 +126,7 @@ uno::Reference< text::XTextCursor > SwVbaRangeHelper::initCursor( const uno::Ref
}
}
- if( !bGotTextCursor )
+ if( !bGotTextCursor || !xTextCursor.is() )
{
try
{
@@ -169,3 +170,29 @@ sal_Int32 SwVbaRangeHelper::getPosition( const uno::Reference< text::XText >& rT
return nPosition;
}
+
+uno::Reference< text::XTextContent > SwVbaRangeHelper::findBookmarkByPosition( const uno::Reference< text::XTextDocument >& xTextDoc, const uno::Reference< text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException )
+{
+ uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( xTextDoc, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW );
+ for( sal_Int32 index = 0; index < xIndexAccess->getCount(); index++ )
+ {
+ uno::Reference< text::XTextContent > xBookmark( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xBkAnchor = xBookmark->getAnchor();
+ uno::Reference< text::XTextRangeCompare > xCompare( xBkAnchor->getText(), uno::UNO_QUERY_THROW );
+ if( xCompare->compareRegionStarts( xBkAnchor->getStart(), xBkAnchor->getEnd() ) == 0 )
+ {
+ try
+ {
+ if( xCompare->compareRegionStarts( xTextRange, xBkAnchor->getStart() ) == 0 )
+ return xBookmark;
+ }
+ catch( uno::Exception& )
+ {
+ continue;
+ }
+ }
+ }
+ return uno::Reference< text::XTextContent >();
+}
+
diff --git a/sw/source/ui/vba/vbarangehelper.hxx b/sw/source/ui/vba/vbarangehelper.hxx
index 71bdf20f94a2..89eeb0c152fb 100644
--- a/sw/source/ui/vba/vbarangehelper.hxx
+++ b/sw/source/ui/vba/vbarangehelper.hxx
@@ -30,6 +30,8 @@
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
class SwVbaRangeHelper
{
@@ -38,6 +40,7 @@ public:
static void insertString( css::uno::Reference< css::text::XTextRange >& rTextRange, css::uno::Reference< css::text::XText >& rText, const rtl::OUString& rStr, sal_Bool _bAbsorb ) throw ( css::uno::RuntimeException );
static css::uno::Reference< css::text::XTextCursor > initCursor( const css::uno::Reference< css::text::XTextRange >& rTextRange, const css::uno::Reference< css::text::XText >& rText ) throw ( css::uno::RuntimeException );
static sal_Int32 getPosition( const css::uno::Reference< css::text::XText >& rText, const css::uno::Reference< css::text::XTextRange >& rTextRange ) throw ( css::uno::RuntimeException );
+ static css::uno::Reference< css::text::XTextContent > findBookmarkByPosition( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, const css::uno::Reference< css::text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException );
};
#endif /* SW_VBA_RANGEHELPER_HXX */
diff --git a/sw/source/ui/vba/vbareplacement.cxx b/sw/source/ui/vba/vbareplacement.cxx
index 81f2bb193412..226cc53c6246 100644
--- a/sw/source/ui/vba/vbareplacement.cxx
+++ b/sw/source/ui/vba/vbareplacement.cxx
@@ -50,6 +50,12 @@ void SAL_CALL SwVbaReplacement::setText( const ::rtl::OUString& _text ) throw (u
mxPropertyReplace->setReplaceString( _text );
}
+void SAL_CALL SwVbaReplacement::ClearFormatting( ) throw (uno::RuntimeException)
+{
+ uno::Sequence< beans::PropertyValue > aPropValues;
+ mxPropertyReplace->setReplaceAttributes( aPropValues );
+}
+
rtl::OUString&
SwVbaReplacement::getServiceImplName()
{
diff --git a/sw/source/ui/vba/vbareplacement.hxx b/sw/source/ui/vba/vbareplacement.hxx
index b257fb7a3abc..e67896f69d1f 100644
--- a/sw/source/ui/vba/vbareplacement.hxx
+++ b/sw/source/ui/vba/vbareplacement.hxx
@@ -47,6 +47,9 @@ public:
virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+ //Methods
+ virtual void SAL_CALL ClearFormatting() throw (css::uno::RuntimeException);
+
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/sw/source/ui/vba/vbasection.cxx b/sw/source/ui/vba/vbasection.cxx
index 2e685fbb1676..62715f2886a0 100644
--- a/sw/source/ui/vba/vbasection.cxx
+++ b/sw/source/ui/vba/vbasection.cxx
@@ -28,6 +28,7 @@
#include <vbahelper/vbahelper.hxx>
#include <tools/diagnose_ex.h>
#include "vbapagesetup.hxx"
+#include "vbaheadersfooters.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -50,14 +51,20 @@ void SAL_CALL SwVbaSection::setProtectedForForms( ::sal_Bool /*_protectedforform
{
}
-uno::Any SAL_CALL SwVbaSection::Headers( ) throw (uno::RuntimeException)
+uno::Any SAL_CALL SwVbaSection::Headers( const uno::Any& index ) throw (uno::RuntimeException)
{
- return uno::Any();
+ uno::Reference< XCollection > xCol( new SwVbaHeadersFooters( this, mxContext, mxModel, mxPageProps, sal_True ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
}
-uno::Any SAL_CALL SwVbaSection::Footers( ) throw (uno::RuntimeException)
+uno::Any SAL_CALL SwVbaSection::Footers( const uno::Any& index ) throw (uno::RuntimeException)
{
- return uno::Any();
+ uno::Reference< XCollection > xCol( new SwVbaHeadersFooters( this, mxContext, mxModel, mxPageProps, sal_False ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
}
uno::Any SAL_CALL
diff --git a/sw/source/ui/vba/vbasection.hxx b/sw/source/ui/vba/vbasection.hxx
index 90a2972c2f52..e13af7fa0ee3 100644
--- a/sw/source/ui/vba/vbasection.hxx
+++ b/sw/source/ui/vba/vbasection.hxx
@@ -48,8 +48,8 @@ public:
virtual void SAL_CALL setProtectedForForms( ::sal_Bool _protectedforforms ) throw (css::uno::RuntimeException);
// Methods
- virtual css::uno::Any SAL_CALL Headers( ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL Footers( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Headers( const css::uno::Any& index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Footers( const css::uno::Any& index ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL PageSetup( ) throw (css::uno::RuntimeException);
// XHelperInterface
diff --git a/sw/source/ui/vba/vbasections.cxx b/sw/source/ui/vba/vbasections.cxx
index c0f887f0f249..983fac9a98b9 100644
--- a/sw/source/ui/vba/vbasections.cxx
+++ b/sw/source/ui/vba/vbasections.cxx
@@ -87,6 +87,15 @@ public:
}
}
+ SectionCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel )
+ {
+ // Hacky implementation of Range.Sections, only support 1 secction
+ uno::Reference< beans::XPropertySet > xRangeProps( xTextRange, uno::UNO_QUERY_THROW );
+ uno::Reference< style::XStyle > xStyle = word::getCurrentPageStyle( mxModel, xRangeProps );
+ uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW );
+ mxSections.push_back( xPageProps );
+ }
+
~SectionCollectionHelper(){}
// XIndexAccess
@@ -134,6 +143,10 @@ SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent,
{
}
+SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ): SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel, xTextRange ) ) ), mxModel( xModel )
+{
+}
+
uno::Any SAL_CALL
SwVbaSections::PageSetup( ) throw (uno::RuntimeException)
{
diff --git a/sw/source/ui/vba/vbasections.hxx b/sw/source/ui/vba/vbasections.hxx
index 3204689af5d8..8304de445c1a 100644
--- a/sw/source/ui/vba/vbasections.hxx
+++ b/sw/source/ui/vba/vbasections.hxx
@@ -31,6 +31,7 @@
#include <ooo/vba/word/XSections.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
#include <vbahelper/vbahelperinterface.hxx>
typedef CollTestImplHelper< ooo::vba::word::XSections > SwVbaSections_BASE;
@@ -42,6 +43,7 @@ private:
public:
SwVbaSections( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ SwVbaSections( 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 );
virtual ~SwVbaSections() {}
// XEnumerationAccess
diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx
index 620e44fa413b..f393519c894a 100644
--- a/sw/source/ui/vba/vbaselection.cxx
+++ b/sw/source/ui/vba/vbaselection.cxx
@@ -29,7 +29,6 @@
#include <tools/diagnose_ex.h>
#include "vbarange.hxx"
#include "vbafind.hxx"
-#include "wordvbahelper.hxx"
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTableCursor.hpp>
@@ -41,14 +40,19 @@
#include <ooo/vba/word/WdGoToDirection.hpp>
#include <ooo/vba/word/XBookmark.hpp>
#include <ooo/vba/word/XApplication.hpp>
+#include <ooo/vba/word/WdCollapseDirection.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include "unotbl.hxx"
#include "unocoll.hxx"
#include "vbatable.hxx"
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/view/XViewCursor.hpp>
+#include <com/sun/star/view/XLineCursor.hpp>
+#include <com/sun/star/text/XWordCursor.hpp>
+#include <com/sun/star/text/XParagraphCursor.hpp>
#include <ooo/vba/word/WdInformation.hpp>
#include <ooo/vba/word/WdHeaderFooterIndex.hpp>
+#include <ooo/vba/word/WdSeekView.hpp>
#include "vbainformationhelper.hxx"
#include "vbafield.hxx"
#include "vbaheaderfooter.hxx"
@@ -56,6 +60,17 @@
#include <vbahelper/vbashaperange.hxx>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/text/ControlCharacter.hpp>
+#include "vbarows.hxx"
+#include "vbacolumns.hxx"
+#include "vbatablehelper.hxx"
+#include "vbacells.hxx"
+#include "vbaview.hxx"
+#include "vbaparagraph.hxx"
+#include "vbastyle.hxx"
+#include <docsh.hxx>
+#include <tblenum.hxx>
+#include <fesh.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -123,23 +138,25 @@ SwVbaSelection::HomeKey( const uno::Any& _unit, const uno::Any& _extend ) throw
sal_Int32 nExtend = word::WdMovementType::wdMove;
_unit >>= nUnit;
_extend >>= nExtend;
+ sal_Bool bExtend = ( nExtend == word::WdMovementType::wdExtend ) ? sal_True : sal_False;
switch( nUnit )
{
case word::WdUnits::wdStory:
{
+ // go to the valid text first so that the current view cursor is valid to call gotoRange.
+ word::gotoSelectedObjectAnchor(mxModel);
// go to the begin of the document
- rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfDoc"));
- dispatchRequests( mxModel,url );
- // If something is selected, it needs to go twice
- dispatchRequests( mxModel,url );
+ uno::Reference< text::XText > xCurrentText = word::getCurrentXText( mxModel );
+ uno::Reference< text::XTextRange > xFirstRange = word::getFirstObjectPosition( xCurrentText );
+ mxTextViewCursor->gotoRange( xFirstRange, bExtend );
break;
}
case word::WdUnits::wdLine:
{
// go to the begin of the Line
- rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToStartOfLine"));
- dispatchRequests( mxModel,url );
+ uno::Reference< view::XLineCursor > xLineCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ xLineCursor->gotoStartOfLine( bExtend );
break;
}
default:
@@ -157,23 +174,25 @@ SwVbaSelection::EndKey( const uno::Any& _unit, const uno::Any& _extend ) throw (
sal_Int32 nExtend = word::WdMovementType::wdMove;
_unit >>= nUnit;
_extend >>= nExtend;
+ sal_Bool bExtend = ( nExtend == word::WdMovementType::wdExtend ) ? sal_True : sal_False;
switch( nUnit )
{
case word::WdUnits::wdStory:
{
+ // go to the valid text first so that the current view cursor is valid to call gotoRange.
+ word::gotoSelectedObjectAnchor(mxModel);
// go to the end of the document
- rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfDoc"));
- dispatchRequests( mxModel,url );
- // If something is selected, it needs to go twice
- dispatchRequests( mxModel,url );
+ uno::Reference< text::XText > xCurrentText = word::getCurrentXText( mxModel );
+ uno::Reference< text::XTextRange > xEnd = xCurrentText->getEnd();
+ mxTextViewCursor->gotoRange( xEnd, bExtend );
break;
}
case word::WdUnits::wdLine:
{
// go to the end of the Line
- rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:GoToEndOfLine"));
- dispatchRequests( mxModel,url );
+ uno::Reference< view::XLineCursor > xLineCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ xLineCursor->gotoEndOfLine( bExtend );
break;
}
default:
@@ -185,14 +204,161 @@ SwVbaSelection::EndKey( const uno::Any& _unit, const uno::Any& _extend ) throw (
}
void SAL_CALL
-SwVbaSelection::Delete( const uno::Any& /*_unit*/, const uno::Any& /*_count*/ ) throw ( uno::RuntimeException )
+SwVbaSelection::Delete( const uno::Any& _unit, const uno::Any& _count ) throw ( uno::RuntimeException )
{
- // FIXME: handle the arguments: _unit and _count
+ sal_Int32 nUnit = word::WdUnits::wdLine;
+ sal_Int32 nCount = 0;
+ if( _count.hasValue() )
+ _count >>= nCount;
+ if( _unit.hasValue() && ( nCount > 0 ) )
+ {
+ _unit >>= nUnit;
+ switch( nUnit )
+ {
+ case word::WdUnits::wdCharacter:
+ {
+ if( HasSelection() )
+ nCount--;
+ mxTextViewCursor->goRight( nCount, sal_True );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ }
+ }
rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Delete"));
dispatchRequests( mxModel,url );
}
-void SwVbaSelection::NextCell( sal_Int32 nCount, E_DIRECTION eDirection ) throw ( uno::RuntimeException )
+void
+SwVbaSelection::Move( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend, word::E_DIRECTION eDirection ) throw ( uno::RuntimeException )
+{
+ sal_Int32 nUnit = word::WdUnits::wdCharacter;
+ sal_Int32 nCount = 1;
+ sal_Int32 nExtend = word::WdMovementType::wdMove;
+
+ if( _unit.hasValue() )
+ _unit >>= nUnit;
+ if( _count.hasValue() )
+ _count >>= nCount;
+ if( _extend.hasValue() )
+ _extend >>= nExtend;
+
+ if( nCount == 0 )
+ return;
+
+ sal_Bool bExpand = ( nExtend == word::WdMovementType::wdMove ) ? sal_False : sal_True;
+
+ switch( nUnit )
+ {
+ case word::WdUnits::wdCell:
+ {
+ if( nExtend == word::WdMovementType::wdExtend )
+ {
+ DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
+ return;
+ }
+ NextCell( nCount, eDirection );
+ break;
+ }
+ case word::WdUnits::wdLine:
+ {
+ if( eDirection == word::MOVE_LEFT || eDirection == word::MOVE_RIGHT )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< view::XViewCursor > xViewCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ if( eDirection == word::MOVE_UP )
+ xViewCursor->goUp( nCount, bExpand );
+ else if( eDirection == word::MOVE_DOWN )
+ xViewCursor->goDown( nCount, bExpand );
+ break;
+ }
+ case word::WdUnits::wdCharacter:
+ {
+ if( eDirection == word::MOVE_UP || eDirection == word::MOVE_DOWN )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ if( word::gotoSelectedObjectAnchor( mxModel ) )
+ {
+ nCount--;
+ }
+ uno::Reference< view::XViewCursor > xViewCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ if( eDirection == word::MOVE_LEFT )
+ {
+ // if current select is a cellrange or table,
+ // the first count of move should move to the first selected cell.
+ uno::Reference< text::XTextTableCursor > xTextTableCursor( mxModel->getCurrentSelection(), uno::UNO_QUERY );
+ if ( xTextTableCursor.is() )
+ {
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextTable > xTextTable;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable;
+ if( xTextTable.is() )
+ {
+ uno::Reference< text::XTextRange > xRange( xTextTable->getCellByName( xTextTableCursor->getRangeName()), uno::UNO_QUERY_THROW );
+ mxTextViewCursor->gotoRange( xRange->getStart(), bExpand );
+ nCount--;
+ }
+ }
+ xViewCursor->goLeft( nCount, bExpand );
+ }
+ else if( eDirection == word::MOVE_RIGHT )
+ xViewCursor->goRight( nCount, bExpand );
+ break;
+ }
+ case word::WdUnits::wdWord:
+ case word::WdUnits::wdParagraph:
+ {
+ uno::Reference< text::XTextRange > xRange = GetSelectedRange();
+ uno::Reference< text::XText > xText = xRange->getText();
+ uno::Reference< text::XTextCursor > xTextCursor = xText->createTextCursorByRange( xRange );
+ if( nUnit == word::WdUnits::wdParagraph )
+ {
+ if( eDirection == word::MOVE_LEFT || eDirection == word::MOVE_RIGHT )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< text::XParagraphCursor > xParagraphCursor( xTextCursor, uno::UNO_QUERY_THROW );
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ if( ( eDirection == word::MOVE_UP ) && ( xParagraphCursor->gotoPreviousParagraph( bExpand ) == sal_False ) )
+ break;
+ else if( ( eDirection == word::MOVE_DOWN ) && ( xParagraphCursor->gotoNextParagraph( bExpand ) == sal_False ) )
+ break;
+ }
+ }
+ else if( nUnit == word::WdUnits::wdWord )
+ {
+ if( eDirection == word::MOVE_UP || eDirection == word::MOVE_DOWN )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< text::XWordCursor > xWordCursor( xTextCursor, uno::UNO_QUERY_THROW );
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ if( (eDirection == word::MOVE_LEFT ) && ( xWordCursor->gotoPreviousWord( bExpand ) == sal_False ) )
+ break;
+ else if( ( eDirection == word::MOVE_RIGHT ) && ( xWordCursor->gotoNextWord( bExpand ) == sal_False ) )
+ break;
+ }
+ }
+ mxTextViewCursor->gotoRange( xTextCursor->getStart(), sal_False );
+ mxTextViewCursor->gotoRange( xTextCursor->getEnd(), sal_True );
+ break;
+ }
+ default:
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ break;
+ }
+ }
+}
+
+void SwVbaSelection::NextCell( sal_Int32 nCount, word::E_DIRECTION eDirection ) throw ( uno::RuntimeException )
{
uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
uno::Reference< text::XTextTable > xTextTable;
@@ -211,22 +377,22 @@ void SwVbaSelection::NextCell( sal_Int32 nCount, E_DIRECTION eDirection ) throw
// move the table cursor
switch( eDirection )
{
- case MOVE_LEFT:
+ case word::MOVE_LEFT:
{
xTextTableCursor->goLeft( nCount, sal_False );
break;
}
- case MOVE_RIGHT:
+ case word::MOVE_RIGHT:
{
xTextTableCursor->goRight( nCount, sal_False );
break;
}
- case MOVE_UP:
+ case word::MOVE_UP:
{
xTextTableCursor->goUp( nCount, sal_False );
break;
}
- case MOVE_DOWN:
+ case word::MOVE_DOWN:
{
xTextTableCursor->goDown( nCount, sal_False );
break;
@@ -245,61 +411,29 @@ void SwVbaSelection::NextCell( sal_Int32 nCount, E_DIRECTION eDirection ) throw
void SAL_CALL
SwVbaSelection::MoveRight( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend ) throw ( uno::RuntimeException )
{
- sal_Int32 nUnit = word::WdUnits::wdCharacter;
sal_Int32 nCount = 1;
- sal_Int32 nExtend = word::WdMovementType::wdMove;
- if( _unit.hasValue() )
- _unit >>= nUnit;
if( _count.hasValue() )
_count >>= nCount;
- if( _extend.hasValue() )
- _extend >>= nExtend;
if( nCount == 0 )
return;
if( nCount < 0 )
{
- // TODO: call MoveLeft;
MoveLeft( _unit, uno::makeAny( -nCount ), _extend );
return;
}
- switch( nUnit )
- {
- case word::WdUnits::wdCell:
- {
- if( nExtend == word::WdMovementType::wdExtend )
- {
- DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
- return;
- }
- NextCell( nCount, MOVE_RIGHT );
- break;
- }
- default:
- {
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
- break;
- }
- }
-
+ Move( _unit, _count, _extend, word::MOVE_RIGHT );
}
void SAL_CALL
SwVbaSelection::MoveLeft( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend ) throw ( uno::RuntimeException )
{
- sal_Int32 nUnit = word::WdUnits::wdCharacter;
sal_Int32 nCount = 1;
- sal_Int32 nExtend = word::WdMovementType::wdMove;
-
- if( _unit.hasValue() )
- _unit >>= nUnit;
if( _count.hasValue() )
_count >>= nCount;
- if( _extend.hasValue() )
- _extend >>= nExtend;
if( nCount == 0 )
return;
@@ -310,67 +444,47 @@ SwVbaSelection::MoveLeft( const uno::Any& _unit, const uno::Any& _count, const u
return;
}
- switch( nUnit )
- {
- case word::WdUnits::wdCell:
- {
- if( nExtend == word::WdMovementType::wdExtend )
- {
- DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
- return;
- }
- NextCell( nCount, MOVE_LEFT );
- break;
- }
- default:
- {
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
- break;
- }
- }
-
+ Move( _unit, _count, _extend, word::MOVE_LEFT );
}
void SAL_CALL
SwVbaSelection::MoveDown( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend ) throw ( uno::RuntimeException )
{
- sal_Int32 nUnit = word::WdUnits::wdCharacter;
sal_Int32 nCount = 1;
- sal_Int32 nExtend = word::WdMovementType::wdMove;
- if( _unit.hasValue() )
- _unit >>= nUnit;
if( _count.hasValue() )
_count >>= nCount;
- if( _extend.hasValue() )
- _extend >>= nExtend;
if( nCount == 0 )
return;
if( nCount < 0 )
{
- // TODO: call MoveLeft;
- //MoveUp( _unit, uno::makeAny( -nCount ), _extend );
+ MoveUp( _unit, uno::makeAny( -nCount ), _extend );
return;
}
- switch( nUnit )
+ Move( _unit, _count, _extend, word::MOVE_DOWN );
+}
+
+void SAL_CALL
+SwVbaSelection::MoveUp( const uno::Any& _unit, const uno::Any& _count, const uno::Any& _extend ) throw ( uno::RuntimeException )
+{
+ sal_Int32 nCount = 1;
+
+ if( _count.hasValue() )
+ _count >>= nCount;
+
+ if( nCount == 0 )
+ return;
+
+ if( nCount < 0 )
{
- case word::WdUnits::wdLine:
- {
- uno::Reference< view::XViewCursor > xViewCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
- sal_Bool bExpand = ( nExtend == word::WdMovementType::wdMove ) ? sal_False : sal_True;
- xViewCursor->goDown( nCount, bExpand );
- break;
- }
- default:
- {
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
- break;
- }
+ MoveDown( _unit, uno::makeAny( -nCount ), _extend );
+ return;
}
+ Move( _unit, _count, _extend, word::MOVE_UP );
}
void SAL_CALL
@@ -422,16 +536,17 @@ SwVbaSelection::getFind() throw ( uno::RuntimeException )
return uno::Reference< word::XFind >( new SwVbaFind( this, mxContext, mxModel, xTextRange ) );
}
-uno::Reference< word::XStyle > SAL_CALL
+uno::Any SAL_CALL
SwVbaSelection::getStyle() throw ( uno::RuntimeException )
{
return getRange()->getStyle();
}
void SAL_CALL
-SwVbaSelection::setStyle( const uno::Reference< word::XStyle >& rStyle ) throw ( uno::RuntimeException )
+SwVbaSelection::setStyle( const uno::Any& rStyle ) throw ( uno::RuntimeException )
{
- return getRange()->setStyle( rStyle );
+ uno::Reference< beans::XPropertySet > xParaProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ return SwVbaStyle::setStyle( xParaProps, rStyle );
}
uno::Reference< word::XFont > SAL_CALL
@@ -474,39 +589,79 @@ uno::Reference< word::XRange > SAL_CALL SwVbaSelection::GoTo( const uno::Any& _w
sal_Int32 nWhich = 0;
if( _which.hasValue() )
_which >>= nWhich;
- sal_Int32 nPage = 0;
- switch( nWhich )
- {
- case word::WdGoToDirection::wdGoToLast:
- {
- nPage = nLastPage;
- break;
- }
- case word::WdGoToDirection::wdGoToNext:
- {
- nPage = nCurrPage + 1;
- break;
- }
- case word::WdGoToDirection::wdGoToPrevious:
- {
- nPage = nCurrPage - 1;
- break;
- }
- default:
- {
- nPage = nCount;
- }
- }
- if( nPage <= 0 )
- nPage = 1;
- if( nPage > nLastPage )
- nPage = nLastPage;
- xPageCursor->jumpToPage( ( sal_Int16 )( nPage ) );
- break;
+ sal_Int32 nPage = 0;
+ switch( nWhich )
+ {
+ case word::WdGoToDirection::wdGoToLast:
+ {
+ nPage = nLastPage;
+ break;
+ }
+ case word::WdGoToDirection::wdGoToNext:
+ {
+ if( nCount !=0 )
+ nPage = nCurrPage + nCount;
+ else
+ nPage = nCurrPage + 1;
+ break;
+ }
+ case word::WdGoToDirection::wdGoToPrevious:
+ {
+ if( nCount !=0 )
+ nPage = nCurrPage - nCount;
+ else
+ nPage = nCurrPage - 1;
+ break;
+ }
+ default:
+ {
+ nPage = nCount;
+ }
+ }
+ if( _name.hasValue() )
+ {
+ rtl::OUString sName;
+ _name >>= sName;
+ sal_Int32 nName = sName.toInt32();
+ if( nName !=0 )
+ nPage = nName;
+ }
+ if( nPage <= 0 )
+ nPage = 1;
+ if( nPage > nLastPage )
+ nPage = nLastPage;
+ xPageCursor->jumpToPage( ( sal_Int16 )( nPage ) );
+ break;
}
case word::WdGoToItem::wdGoToSection:
{
- // TODO: implement Section object
+ uno::Reference< text::XPageCursor > xPageCursor( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ sal_Int32 nCount = 0;
+ if( _count.hasValue() )
+ _count >>= nCount;
+ sal_Int32 nWhich = 0;
+ if( _which.hasValue() )
+ _which >>= nWhich;
+ sal_Int32 nPage = 0;
+ switch( nWhich )
+ {
+ case word::WdGoToDirection::wdGoToAbsolute:
+ {
+ // currently only support this type
+ if( nCount == 1 )
+ nPage = 1;
+ break;
+ }
+ default:
+ {
+ nPage = 0;
+ }
+ }
+ if( nPage != 0 )
+ xPageCursor->jumpToPage( ( sal_Int16 )( nPage ) );
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ break;
}
default:
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
@@ -546,6 +701,82 @@ uno::Any SAL_CALL SwVbaSelection::Information( sal_Int32 _type ) throw (uno::Run
result = uno::makeAny( SwVbaInformationHelper::handleWdVerticalPositionRelativeToPage( mxModel, mxTextViewCursor ) );
break;
}
+ case word::WdInformation::wdWithInTable:
+ {
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextTable > xTextTable;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable;
+ if( xTextTable.is() )
+ result = uno::makeAny( sal_True );
+ else
+ result = uno::makeAny( sal_False );
+ break;
+ }
+ case word::WdInformation::wdHeaderFooterType:
+ {
+ uno::Reference< word::XView > xView( new SwVbaView( this, mxContext, mxModel ) );
+ sal_Int32 nView = xView->getSeekView();
+ sal_Int32 nHeaderFooterType = 0;
+ switch( nView )
+ {
+ case word::WdSeekView::wdSeekMainDocument:
+ {
+ nHeaderFooterType = -1; // not in a header or footer
+ break;
+ }
+ case word::WdSeekView::wdSeekEvenPagesHeader:
+ {
+ nHeaderFooterType = 0; // even page header
+ break;
+ }
+ case word::WdSeekView::wdSeekPrimaryHeader:
+ {
+ nHeaderFooterType = 1; // odd page header
+ break;
+ }
+ case word::WdSeekView::wdSeekEvenPagesFooter:
+ {
+ nHeaderFooterType = 2; // even page footer
+ break;
+ }
+ case word::WdSeekView::wdSeekPrimaryFooter:
+ {
+ nHeaderFooterType = 3; // odd page footer
+ break;
+ }
+ case word::WdSeekView::wdSeekFirstPageHeader:
+ case word::WdSeekView::wdSeekFirstPageFooter:
+ {
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ rtl::OUString aPageStyleName;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName;
+ sal_Bool bFirstPage = sal_False;
+ if( aPageStyleName.equalsAscii( "First Page" ) )
+ bFirstPage = sal_True;
+ if( nView == word::WdSeekView::wdSeekFirstPageHeader )
+ {
+ if( bFirstPage )
+ nHeaderFooterType = 4;
+ else
+ nHeaderFooterType = 1;
+ }
+ else
+ {
+ if( bFirstPage )
+ nHeaderFooterType = 5;
+ else
+ nHeaderFooterType = 3;
+ }
+ break;
+ }
+ default:
+ {
+ nHeaderFooterType = -1;
+ }
+ }
+ result = uno::makeAny( nHeaderFooterType );
+ break;
+ }
default:
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
}
@@ -566,11 +797,6 @@ SwVbaSelection::Tables( const uno::Any& aIndex ) throw (uno::RuntimeException)
// we can only support a selection that is a single table
if ( !aIndex.hasValue() ) // currently we can't support multiple tables in a selection
throw uno::RuntimeException();
- // if the current selection is a XTextTableCursor and the index is 1 then we can service this request, otherwise we just have to throw
- uno::Reference< text::XTextTableCursor > xTextTableCursor( mxModel->getCurrentSelection(), uno::UNO_QUERY );
-
- if ( !xTextTableCursor.is() )
- throw uno::RuntimeException();
sal_Int32 nIndex = 0;
aIndex >>= nIndex;
@@ -579,6 +805,24 @@ SwVbaSelection::Tables( const uno::Any& aIndex ) throw (uno::RuntimeException)
if ( nIndex != 1 )
throw uno::RuntimeException();
+
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextTable > xTextTable;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable;
+ if( xTextTable.is() )
+ {
+ uno::Reference< css::text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< word::XTable > xVBATbl = new SwVbaTable( mxParent, mxContext, xTextDoc, xTextTable );
+ aRet <<= xVBATbl;
+ return aRet;
+ }
+
+ // if the current selection is a XTextTableCursor and the index is 1 then we can service this request, otherwise we just have to throw
+ uno::Reference< text::XTextTableCursor > xTextTableCursor( mxModel->getCurrentSelection(), uno::UNO_QUERY );
+
+ if ( !xTextTableCursor.is() )
+ throw uno::RuntimeException();
+
SwXTextTableCursor* pTTCursor = dynamic_cast< SwXTextTableCursor* >( xTextTableCursor.get() );
if ( pTTCursor )
{
@@ -608,15 +852,14 @@ SwVbaSelection::Fields( const uno::Any& index ) throw (uno::RuntimeException)
uno::Reference< word::XHeaderFooter > SAL_CALL
SwVbaSelection::getHeaderFooter() throw ( uno::RuntimeException )
{
- uno::Reference< text::XText > xCurrentText = word::getXTextViewCursor( mxModel )->getText();
- if( HeaderFooterHelper::isHeader( mxModel, xCurrentText ) || HeaderFooterHelper::isFooter( mxModel, xCurrentText ) )
+ if( HeaderFooterHelper::isHeaderFooter( mxModel ) )
{
uno::Reference< beans::XPropertySet > xPageStyleProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW );
sal_Int32 nIndex = word::WdHeaderFooterIndex::wdHeaderFooterPrimary;
- sal_Bool isHeader = HeaderFooterHelper::isHeader( mxModel, xCurrentText );
- if( HeaderFooterHelper::isEvenPagesHeader( mxModel, xCurrentText ) || HeaderFooterHelper::isEvenPagesFooter( mxModel, xCurrentText ) )
+ sal_Bool isHeader = HeaderFooterHelper::isHeader( mxModel );
+ if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) || HeaderFooterHelper::isEvenPagesFooter( mxModel ) )
nIndex = word::WdHeaderFooterIndex::wdHeaderFooterEvenPages;
- else if( HeaderFooterHelper::isFirstPageHeader( mxModel, xCurrentText ) || HeaderFooterHelper::isFirstPageFooter( mxModel, xCurrentText ) )
+ else if( HeaderFooterHelper::isFirstPageHeader( mxModel ) || HeaderFooterHelper::isFirstPageFooter( mxModel ) )
nIndex = word::WdHeaderFooterIndex::wdHeaderFooterFirstPage;
return uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( this, mxContext, mxModel, xPageStyleProps, isHeader, nIndex ) );
@@ -629,9 +872,13 @@ uno::Any SAL_CALL
SwVbaSelection::ShapeRange( ) throw (uno::RuntimeException)
{
uno::Reference< drawing::XShapes > xShapes( mxModel->getCurrentSelection(), uno::UNO_QUERY );
-
if ( !xShapes.is() )
- throw uno::RuntimeException();
+ {
+ uno::Reference< drawing::XShape > xShape( mxModel->getCurrentSelection(), uno::UNO_QUERY_THROW );
+ uno::Reference< lang::XMultiServiceFactory > xMSF( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xShapes.set( xMSF->createInstance( rtl::OUString::createFromAscii( "com.sun.star.drawing.ShapeCollection" ) ), uno::UNO_QUERY_THROW );
+ xShapes->add( xShape );
+ }
uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< drawing::XDrawPage > xDrawPage = xDrawPageSupplier->getDrawPage();
@@ -658,6 +905,281 @@ void SAL_CALL SwVbaSelection::setEnd( ::sal_Int32 _end ) throw (uno::RuntimeExce
getRange()->setEnd( _end );
}
+void SAL_CALL SwVbaSelection::SelectRow() throw (uno::RuntimeException)
+{
+ uno::Reference< word::XRows > xRows( Rows( uno::Any() ), uno::UNO_QUERY_THROW );
+ xRows->Select();
+}
+
+void SAL_CALL SwVbaSelection::SelectColumn() throw (uno::RuntimeException)
+{
+ uno::Reference< word::XColumns > xColumns( Columns( uno::Any() ), uno::UNO_QUERY_THROW );
+ xColumns->Select();
+}
+
+uno::Any SAL_CALL SwVbaSelection::Rows( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ rtl::OUString sTLName;
+ rtl::OUString sBRName;
+ GetSelectedCellRange( sTLName, sBRName );
+
+ sal_Int32 nStartRow = 0;
+ sal_Int32 nEndRow = 0;
+ uno::Reference< text::XTextTable > xTextTable = GetXTextTable();
+ SwVbaTableHelper aTableHelper( xTextTable );
+ nStartRow = aTableHelper.getTabRowIndex( sTLName );
+ if( sBRName.getLength() > 0 )
+ {
+ nEndRow = aTableHelper.getTabRowIndex( sBRName );
+ }
+ else
+ {
+ nEndRow = nStartRow;
+ }
+
+ uno::Reference< XCollection > xCol( new SwVbaRows( this, mxContext, xTextTable, xTextTable->getRows(), nStartRow, nEndRow ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL SwVbaSelection::Columns( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ rtl::OUString sTLName;
+ rtl::OUString sBRName;
+ GetSelectedCellRange( sTLName, sBRName );
+ sal_Int32 nStartColumn = 0;
+ sal_Int32 nEndColumn = 0;
+
+ uno::Reference< text::XTextTable > xTextTable = GetXTextTable();
+ SwVbaTableHelper aTableHelper( xTextTable );
+ nStartColumn = aTableHelper.getTabColIndex( sTLName );
+ if( sBRName.getLength() > 0 )
+ {
+ nEndColumn = aTableHelper.getTabColIndex( sBRName );
+ }
+ else
+ {
+ nEndColumn = nStartColumn;
+ }
+
+ uno::Reference< XCollection > xCol( new SwVbaColumns( this, mxContext, xTextTable, xTextTable->getColumns(), nStartColumn, nEndColumn ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Reference< text::XTextTable > SwVbaSelection::GetXTextTable() throw( uno::RuntimeException )
+{
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextTable > xTextTable;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable;
+ return xTextTable;
+}
+
+sal_Bool SwVbaSelection::IsInTable() throw( uno::RuntimeException )
+{
+ uno::Reference< text::XTextTable > xTextTable = GetXTextTable();
+ if( xTextTable.is() )
+ return sal_True;
+ return sal_False;
+}
+
+sal_Bool SwVbaSelection::HasSelection() throw( uno::RuntimeException )
+{
+ uno::Reference< text::XTextRange > xStart = mxTextViewCursor->getStart();
+ uno::Reference< text::XTextRange > xEnd = mxTextViewCursor->getEnd();
+ uno::Reference< text::XTextRangeCompare > xTRC( mxTextViewCursor->getText(), uno::UNO_QUERY_THROW );
+ if( xTRC->compareRegionStarts( xStart, xEnd ) == 0 && xTRC->compareRegionEnds( xStart, xEnd ) == 0 )
+ return sal_False;
+ return sal_True;
+}
+
+void SwVbaSelection::GetSelectedCellRange( rtl::OUString& sTLName, rtl::OUString& sBRName ) throw( uno::RuntimeException )
+{
+ uno::Reference< beans::XPropertySet > xCursorProps( mxTextViewCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextTable > xTextTable;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable;
+ if( !xTextTable.is() )
+ throw uno::RuntimeException( );
+
+ uno::Reference< text::XTextTableCursor > xTextTableCursor( mxModel->getCurrentSelection(), uno::UNO_QUERY );
+ if( xTextTableCursor.is() )
+ {
+ String sRange( xTextTableCursor->getRangeName() );
+ if( sRange.GetTokenCount(':') > 0 )
+ {
+ sTLName = sRange.GetToken(0, ':');
+ sBRName = sRange.GetToken(1, ':');
+ }
+ }
+ if( !sTLName.getLength() )
+ {
+ uno::Reference< table::XCell > xCell;
+ xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cell") ) ) >>= xCell;
+ if( !xCell.is() )
+ {
+ throw uno::RuntimeException( );
+ }
+ uno::Reference< beans::XPropertySet > xCellProps( xCell, uno::UNO_QUERY_THROW );
+ xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellName") ) ) >>= sTLName;
+ }
+}
+
+uno::Any SAL_CALL SwVbaSelection::Cells( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ rtl::OUString sTLName;
+ rtl::OUString sBRName;
+ GetSelectedCellRange( sTLName, sBRName );
+ sal_Int32 nLeft = 0;
+ sal_Int32 nTop = 0;
+ sal_Int32 nRight = 0;
+ sal_Int32 nBottom = 0;
+
+ uno::Reference< text::XTextTable > xTextTable = GetXTextTable();
+ SwVbaTableHelper aTableHelper( xTextTable );
+ nLeft = aTableHelper.getTabColIndex( sTLName );
+ nTop = aTableHelper.getTabRowIndex( sTLName );
+ if( sBRName.getLength() > 0 )
+ {
+ nRight = aTableHelper.getTabColIndex( sBRName );
+ nBottom = aTableHelper.getTabRowIndex( sBRName );
+ }
+ else
+ {
+ nRight = nLeft;
+ nBottom = nTop;
+ }
+
+ uno::Reference< XCollection > xCol( new SwVbaCells( this, mxContext, xTextTable, nLeft, nTop, nRight, nBottom ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+void SAL_CALL SwVbaSelection::Copy( ) throw (uno::RuntimeException)
+{
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Copy"));
+ dispatchRequests( mxModel,url );
+}
+
+void SAL_CALL SwVbaSelection::CopyAsPicture( ) throw (uno::RuntimeException)
+{
+ // seems not support in Writer
+ Copy();
+}
+
+void SAL_CALL SwVbaSelection::Paste( ) throw (uno::RuntimeException)
+{
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Paste"));
+ dispatchRequests( mxModel,url );
+}
+
+void SAL_CALL SwVbaSelection::Collapse( const uno::Any& Direction ) throw (uno::RuntimeException)
+{
+ if( word::gotoSelectedObjectAnchor( mxModel ) )
+ return;
+
+ sal_Int32 nDirection = word::WdCollapseDirection::wdCollapseStart;
+ if( Direction.hasValue() )
+ Direction >>= nDirection;
+
+ uno::Reference< text::XTextViewCursor > xTextViewCursor = word::getXTextViewCursor( mxModel );
+ if( nDirection == word::WdCollapseDirection::wdCollapseStart )
+ {
+ // it is inaccurate if current seleciton is multipul cells, so it needs to go to start
+ uno::Reference< text::XTextRange > xTextRange = mxTextViewCursor->getStart();
+ xTextViewCursor->gotoRange( xTextRange, sal_False );
+ xTextViewCursor->collapseToStart();
+ }
+ else if( nDirection == word::WdCollapseDirection::wdCollapseEnd )
+ {
+ uno::Reference< text::XTextRange > xTextRange = mxTextViewCursor->getEnd();
+ xTextViewCursor->gotoRange( xTextRange, sal_False );
+ xTextViewCursor->collapseToEnd();
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+}
+
+void SAL_CALL SwVbaSelection::WholeStory( ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XText > xText = word::getCurrentXText( mxModel );
+ // FIXME: for i#7747,if the first line is a table, it fails to select all the contents in the story.
+ // Temporary solution, insert an empty line before the table so that it could select all the contents.
+ uno::Reference< container::XEnumerationAccess > xParaAccess( xText, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration> xParaEnum = xParaAccess->createEnumeration();
+ if( xParaEnum->hasMoreElements() )
+ {
+ uno::Reference< text::XTextTable > xTextTable( xParaEnum->nextElement(), uno::UNO_QUERY );
+ if( xTextTable.is() )
+ {
+ // insert an empty line
+ uno::Reference< text::XTextRange > xFirstCellRange = word::getFirstObjectPosition( xText );
+ mxTextViewCursor->gotoRange( xFirstCellRange, sal_False );
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertPara"));
+ dispatchRequests( mxModel,url );
+ }
+ }
+ uno::Reference< text::XTextRange > xStart = xText->getStart();
+ uno::Reference< text::XTextRange > xEnd = xText->getEnd();
+ mxTextViewCursor->gotoRange( xStart, sal_False );
+ mxTextViewCursor->gotoRange( xEnd, sal_True );
+}
+
+::sal_Bool SAL_CALL SwVbaSelection::InRange( const uno::Reference< ::ooo::vba::word::XRange >& Range ) throw (uno::RuntimeException)
+{
+ return getRange()->InRange( Range );
+}
+
+void SAL_CALL SwVbaSelection::SplitTable( ) throw (uno::RuntimeException)
+{
+ if( !IsInTable() )
+ throw uno::RuntimeException();
+
+ SwDocShell* pDocShell = word::getDocShell( mxModel );
+ if( pDocShell )
+ {
+ SwFEShell* pFEShell = pDocShell->GetFEShell();
+ if( pFEShell )
+ {
+ pFEShell->SplitTable( HEADLINE_CNTNTCOPY );
+ }
+ }
+}
+
+uno::Any SAL_CALL
+SwVbaSelection::Paragraphs( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ // Hacky implementation due to missing api ( and lack of knowledge )
+ // we can only support a selection that is a single paragraph
+ if ( !aIndex.hasValue() ) // currently we can't support multiple paragraphs in a selection
+ throw uno::RuntimeException();
+
+ sal_Int32 nIndex = 0;
+ aIndex >>= nIndex;
+
+ uno::Any aRet;
+
+ if ( nIndex != 1 )
+ throw uno::RuntimeException();
+
+ uno::Reference< text::XTextRange > xTextRange = mxTextViewCursor->getStart();
+ uno::Reference< text::XText > xText = xTextRange->getText();
+ uno::Reference< text::XParagraphCursor > xParaCursor( xText->createTextCursor(), uno::UNO_QUERY_THROW );
+ xParaCursor->gotoStartOfParagraph( sal_False );
+ xParaCursor->gotoStartOfParagraph( sal_True );
+
+ uno::Reference< text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextRange > xParaRange( xParaCursor, uno::UNO_QUERY_THROW );
+ uno::Reference< word::XParagraph > xParagraph = new SwVbaParagraph( mxParent, mxContext, xTextDoc, xParaRange );
+
+ aRet <<= xParagraph;
+ return aRet;
+}
+
rtl::OUString&
SwVbaSelection::getServiceImplName()
{
diff --git a/sw/source/ui/vba/vbaselection.hxx b/sw/source/ui/vba/vbaselection.hxx
index a5079340ee19..10ed8a084728 100644
--- a/sw/source/ui/vba/vbaselection.hxx
+++ b/sw/source/ui/vba/vbaselection.hxx
@@ -31,11 +31,13 @@
#include <ooo/vba/word/XRange.hpp>
#include <vbahelper/vbahelperinterface.hxx>
#include <com/sun/star/text/XTextViewCursor.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
#include <ooo/vba/word/XParagraphFormat.hpp>
#include <ooo/vba/word/XFind.hpp>
#include <ooo/vba/word/XStyle.hpp>
#include <ooo/vba/word/XFont.hpp>
#include <ooo/vba/word/XHeaderFooter.hpp>
+#include "wordvbahelper.hxx"
typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XSelection > SwVbaSelection_BASE;
@@ -46,17 +48,14 @@ private:
css::uno::Reference< css::text::XTextViewCursor > mxTextViewCursor;
css::uno::Reference< ooo::vba::word::XRange > mxRange;
- enum E_DIRECTION
- {
- MOVE_LEFT = 1,
- MOVE_RIGHT,
- MOVE_UP,
- MOVE_DOWN
- };
-
private:
- void NextCell( sal_Int32 nCount, E_DIRECTION eDirection ) throw ( css::uno::RuntimeException );
+ void Move( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend, ooo::vba::word::E_DIRECTION eDirection ) throw (css::uno::RuntimeException);
+ void NextCell( sal_Int32 nCount, ooo::vba::word::E_DIRECTION eDirection ) throw ( css::uno::RuntimeException );
css::uno::Reference< css::text::XTextRange > GetSelectedRange() throw ( css::uno::RuntimeException );
+ void GetSelectedCellRange( rtl::OUString& sTLName, rtl::OUString& sBRName ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< css::text::XTextTable > GetXTextTable() throw ( css::uno::RuntimeException );
+ sal_Bool IsInTable() throw ( css::uno::RuntimeException );
+ sal_Bool HasSelection() throw ( css::uno::RuntimeException );
public:
SwVbaSelection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel ) throw ( css::uno::RuntimeException );
@@ -73,6 +72,7 @@ public:
virtual void SAL_CALL MoveRight( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend ) throw (css::uno::RuntimeException);
virtual void SAL_CALL MoveLeft( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend ) throw (css::uno::RuntimeException);
virtual void SAL_CALL MoveDown( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL MoveUp( const css::uno::Any& _unit, const css::uno::Any& _count, const css::uno::Any& _extend ) throw (css::uno::RuntimeException);
virtual void SAL_CALL TypeParagraph() throw (css::uno::RuntimeException);
virtual void SAL_CALL InsertParagraph() throw (css::uno::RuntimeException);
virtual void SAL_CALL InsertParagraphBefore() throw (css::uno::RuntimeException);
@@ -80,8 +80,8 @@ public:
virtual css::uno::Reference< ooo::vba::word::XParagraphFormat > SAL_CALL getParagraphFormat() throw (css::uno::RuntimeException);
virtual void SAL_CALL setParagraphFormat( const css::uno::Reference< ooo::vba::word::XParagraphFormat >& rParagraphFormat ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XFind > SAL_CALL getFind() throw (css::uno::RuntimeException);
- virtual css::uno::Reference< ooo::vba::word::XStyle > SAL_CALL getStyle() throw (css::uno::RuntimeException);
- virtual void SAL_CALL setStyle( const css::uno::Reference< ooo::vba::word::XStyle >& _xStyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( const css::uno::Any& _xStyle ) throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
virtual void SAL_CALL TypeBackspace() throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL GoTo( const css::uno::Any& _what, const css::uno::Any& _which, const css::uno::Any& _count, const css::uno::Any& _name ) throw (css::uno::RuntimeException);
@@ -97,6 +97,19 @@ public:
virtual void SAL_CALL setStart( ::sal_Int32 _start ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getEnd() throw (css::uno::RuntimeException);
virtual void SAL_CALL setEnd( ::sal_Int32 _end ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SelectRow() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SelectColumn() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Rows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Columns( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Cells( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Copy( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL CopyAsPicture( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Paste( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Collapse( const css::uno::Any& Direction ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL WholeStory( ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL InRange( const css::uno::Reference< ::ooo::vba::word::XRange >& Range ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SplitTable( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Paragraphs( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sw/source/ui/vba/vbastyle.cxx b/sw/source/ui/vba/vbastyle.cxx
index cf49da020284..247c6df8b9fb 100644
--- a/sw/source/ui/vba/vbastyle.cxx
+++ b/sw/source/ui/vba/vbastyle.cxx
@@ -28,15 +28,18 @@
#include "vbastyle.hxx"
#include <ooo/vba/word/WdStyleType.hpp>
#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
#include <i18npool/mslangid.hxx>
#include "vbafont.hxx"
#include "vbapalette.hxx"
+#include "vbaparagraphformat.hxx"
+#include "vbastyles.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaStyle::SwVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet ) throw ( script::BasicErrorException, uno::RuntimeException ) : SwVbaStyle_BASE( xParent, xContext ) , mxStyleProps( _xPropertySet )
+SwVbaStyle::SwVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel>& xModel, const uno::Reference< beans::XPropertySet >& _xPropertySet ) throw ( script::BasicErrorException, uno::RuntimeException ) : SwVbaStyle_BASE( xParent, xContext ) , mxModel( xModel ), mxStyleProps( _xPropertySet )
{
mxStyle.set( _xPropertySet, uno::UNO_QUERY_THROW );
}
@@ -84,7 +87,7 @@ void SAL_CALL SwVbaStyle::setLanguageID( ::sal_Int32 _languageid ) throw (uno::R
nType = word::WdStyleType::wdStyleTypeParagraph;
else if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.CharacterStyle") ) ) )
nType = word::WdStyleType::wdStyleTypeCharacter;
- else // if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingStyle") ) ) )
+ else
nType = word::WdStyleType::wdStyleTypeList;
return nType;
}
@@ -96,10 +99,31 @@ SwVbaStyle::getFont() throw ( uno::RuntimeException )
return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), mxStyleProps );
}
-void SwVbaStyle::setStyle( const uno::Reference< beans::XPropertySet >& xTCProps, const uno::Reference< ooo::vba::word::XStyle >& xStyle )throw (uno::RuntimeException)
+
+void SAL_CALL SwVbaStyle::LinkToListTemplate( const uno::Reference< word::XListTemplate >& /*ListTemplate*/, const uno::Any& /*ListLevelNumber*/ ) throw (uno::RuntimeException)
+{
+}
+
+void SwVbaStyle::setStyle( const uno::Reference< beans::XPropertySet >& xParaProps, const uno::Any& rStyle )throw (uno::RuntimeException)
{
- rtl::OUString aStyleType = getOOoStyleTypeFromMSWord( xStyle->getType() );
- xTCProps->setPropertyValue( aStyleType, uno::makeAny( xStyle->getName() ) );
+ rtl::OUString sStyle;
+ uno::Reference< word::XStyle > xStyle;
+ if( rStyle >>= xStyle )
+ {
+ sStyle = xStyle->getName();
+ }
+ else
+ {
+ rStyle >>= sStyle;
+ }
+
+ if( sStyle.getLength() )
+ {
+ xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ), uno::makeAny( sStyle ) );
+ return;
+ }
+
+ throw uno::RuntimeException();
}
rtl::OUString SwVbaStyle::getOOoStyleTypeFromMSWord( sal_Int32 _wdStyleType )
@@ -129,6 +153,115 @@ rtl::OUString SwVbaStyle::getOOoStyleTypeFromMSWord( sal_Int32 _wdStyleType )
return aStyleType;
}
+::rtl::OUString SAL_CALL SwVbaStyle::getNameLocal() throw (uno::RuntimeException)
+{
+ rtl::OUString sNameLocal;
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DisplayName") ) ) >>= sNameLocal;
+ return sNameLocal;
+}
+
+void SAL_CALL SwVbaStyle::setNameLocal( const ::rtl::OUString& _namelocal ) throw (uno::RuntimeException)
+{
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DisplayName") ), uno::makeAny( _namelocal ) );
+}
+
+uno::Reference< word::XParagraphFormat > SAL_CALL SwVbaStyle::getParagraphFormat() throw (uno::RuntimeException)
+{
+ if( word::WdStyleType::wdStyleTypeParagraph == getType() )
+ {
+ uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
+ return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, xTextDocument, mxStyleProps ) );
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+ return uno::Reference< word::XParagraphFormat >();
+}
+
+::sal_Bool SAL_CALL SwVbaStyle::getAutomaticallyUpdate() throw (uno::RuntimeException)
+{
+ sal_Bool isAutoUpdate = sal_False;
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoUpdate") ) ) >>= isAutoUpdate;
+ return isAutoUpdate;
+}
+
+void SAL_CALL SwVbaStyle::setAutomaticallyUpdate( ::sal_Bool _automaticallyupdate ) throw (uno::RuntimeException)
+{
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoUpdate") ), uno::makeAny( _automaticallyupdate ) );
+}
+
+uno::Any SAL_CALL SwVbaStyle::getBaseStyle() throw (uno::RuntimeException)
+{
+ // ParentStyle
+ rtl::OUString sBaseStyle;
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParentStyle") ) ) >>= sBaseStyle;
+ if( sBaseStyle.getLength() > 0 )
+ {
+ uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
+ return xCol->Item( uno::makeAny( sBaseStyle ), uno::Any() );
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+ return uno::Any();
+}
+
+void SAL_CALL SwVbaStyle::setBaseStyle( const uno::Any& _basestyle ) throw (uno::RuntimeException)
+{
+ uno::Reference< word::XStyle > xStyle;
+ _basestyle >>= xStyle;
+ if( xStyle.is() )
+ {
+ rtl::OUString sBaseStyle = xStyle->getName();
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParentStyle") ), uno::makeAny( sBaseStyle ) );
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+}
+
+uno::Any SAL_CALL SwVbaStyle::getNextParagraphStyle() throw (uno::RuntimeException)
+{
+ //FollowStyle
+ rtl::OUString sFollowStyle;
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FollowStyle") ) ) >>= sFollowStyle;
+ if( sFollowStyle.getLength() > 0 )
+ {
+ uno::Reference< XCollection > xCol( new SwVbaStyles( this, mxContext, mxModel ) );
+ return xCol->Item( uno::makeAny( sFollowStyle ), uno::Any() );
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+ return uno::Any();
+}
+
+void SAL_CALL SwVbaStyle::setNextParagraphStyle( const uno::Any& _nextparagraphstyle ) throw (uno::RuntimeException)
+{
+ uno::Reference< word::XStyle > xStyle;
+ _nextparagraphstyle >>= xStyle;
+ if( xStyle.is() )
+ {
+ rtl::OUString sFollowStyle = xStyle->getName();
+ mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FollowStyle") ), uno::makeAny( sFollowStyle ) );
+ }
+ else
+ {
+ throw uno::RuntimeException();
+ }
+}
+
+::sal_Int32 SAL_CALL SwVbaStyle::getListLevelNumber() throw (uno::RuntimeException)
+{
+ sal_Int16 nNumberingLevel = 0;
+ mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingLevel") ) ) >>= nNumberingLevel;
+ return nNumberingLevel;
+}
+
rtl::OUString&
SwVbaStyle::getServiceImplName()
{
diff --git a/sw/source/ui/vba/vbastyle.hxx b/sw/source/ui/vba/vbastyle.hxx
index 401baa5337a1..3a31c6eca073 100644
--- a/sw/source/ui/vba/vbastyle.hxx
+++ b/sw/source/ui/vba/vbastyle.hxx
@@ -33,6 +33,7 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/style/XStyle.hpp>
#include <ooo/vba/word/XFont.hpp>
+#include <ooo/vba/word/XListTemplate.hpp>
typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XStyle > SwVbaStyle_BASE;
@@ -40,13 +41,14 @@ typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XStyle > SwVbaStyle_BASE;
class SwVbaStyle : public SwVbaStyle_BASE
{
private:
+ css::uno::Reference< css::frame::XModel > mxModel;
css::uno::Reference< css::beans::XPropertySet > mxStyleProps;
css::uno::Reference< css::style::XStyle > mxStyle;
public:
- SwVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ SwVbaStyle( 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::beans::XPropertySet >& _xPropertySet ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
virtual ~SwVbaStyle(){}
- static void setStyle( const css::uno::Reference< css::beans::XPropertySet >& xTCProps, const css::uno::Reference< ooo::vba::word::XStyle >& xStyle ) throw (css::uno::RuntimeException);
+ static void setStyle( const css::uno::Reference< css::beans::XPropertySet >& xParaProps, const css::uno::Any& xStyle ) throw (css::uno::RuntimeException);
static rtl::OUString getOOoStyleTypeFromMSWord( sal_Int32 _wdStyleType );
static sal_Int32 getLanguageID( const css::uno::Reference< css::beans::XPropertySet >& xTCProps ) throw (css::uno::RuntimeException);
static void setLanguageID( const css::uno::Reference< css::beans::XPropertySet >& xTCProps, sal_Int32 _languageid ) throw (css::uno::RuntimeException);
@@ -58,6 +60,20 @@ public:
virtual void SAL_CALL setLanguageID( ::sal_Int32 _languageid ) throw (css::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException);
virtual css::uno::Reference< ooo::vba::word::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL LinkToListTemplate( const css::uno::Reference< ooo::vba::word::XListTemplate >& ListTemplate, const css::uno::Any& ListLevelNumber ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameLocal() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNameLocal( const ::rtl::OUString& _namelocal ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::word::XParagraphFormat > SAL_CALL getParagraphFormat() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getAutomaticallyUpdate() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutomaticallyUpdate( ::sal_Bool _automaticallyupdate ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getBaseStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setBaseStyle( const css::uno::Any& _basestyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getNextParagraphStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNextParagraphStyle( const css::uno::Any& _nextparagraphstyle ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getListLevelNumber() throw (css::uno::RuntimeException);
+
+ //XDefaultProperty
+ virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return rtl::OUString::createFromAscii("Name"); }
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sw/source/ui/vba/vbastyles.cxx b/sw/source/ui/vba/vbastyles.cxx
index 371c1225cafa..68850cabf64b 100644
--- a/sw/source/ui/vba/vbastyles.cxx
+++ b/sw/source/ui/vba/vbastyles.cxx
@@ -44,7 +44,7 @@ struct BuiltinStyleTable
sal_Int32 wdStyleType;
};
-const BuiltinStyleTable aBuiltinStyleTable[] =
+static const BuiltinStyleTable aBuiltinStyleTable[] =
{
{ word::WdBuiltinStyle::wdStyleBlockQuotation, "", word::WdStyleType::wdStyleTypeParagraph },
{ word::WdBuiltinStyle::wdStyleBodyText, "Text body", word::WdStyleType::wdStyleTypeParagraph },
@@ -152,7 +152,20 @@ const BuiltinStyleTable aBuiltinStyleTable[] =
{ 0, 0, 0 }
};
+struct MSOStyleNameTable
+{
+ const sal_Char* pMSOStyleName;
+ const sal_Char* pOOoStyleName;
+ const sal_Char* pOOoStyleType;
+};
+
+static const MSOStyleNameTable aMSOStyleNameTable[] =
+{
+ { "Normal", "Default", "ParagraphStyles" },
+ { 0, 0, 0 }
+};
+#ifdef FUTURE // seems this isn't used
static uno::Sequence< rtl::OUString > getStyleTypes()
{
uno::Sequence< rtl::OUString > aRet(3);
@@ -162,41 +175,25 @@ static uno::Sequence< rtl::OUString > getStyleTypes()
pArray[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyles") );
return aRet;
}
+#endif
typedef ::cppu::WeakImplHelper1< container::XEnumeration > StyleEnumeration_BASE;
typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > StyleCollectionHelper_BASE;
-/*
-class StylesEnumeration : public StyleEnumeration_BASE
-{
-public:
- StylesEnumeration( const SheetMap& sMap ) : mSheetMap( sMap ), mIt( mSheetMap.begin() ) {}
- virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
- {
- return ( mIt != mSheetMap.end() );
- }
- virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
- {
- if ( !hasMoreElements() )
- throw container::NoSuchElementException();
- uno::Reference< sheet::XSpreadsheet > xSheet( *mIt++ );
- return uno::makeAny( xSheet ) ;
- }
-};
-*/
+
class StyleCollectionHelper : public StyleCollectionHelper_BASE
{
private:
uno::Reference< frame::XModel > mxModel;
- uno::Reference< container::XNameAccess > mxStyleFamilies;
- uno::Reference< container::XNameContainer > mxCurrentStyleFamily;
+ uno::Reference< container::XNameAccess > mxParaStyles;
uno::Any cachePos;
public:
StyleCollectionHelper( const uno::Reference< frame::XModel >& _xModel ) : mxModel( _xModel )
{
+ // we only concern about the Paragraph styles
uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( _xModel, uno::UNO_QUERY_THROW);
- mxStyleFamilies = xStyleSupplier->getStyleFamilies();
+ uno::Reference< container::XNameAccess > xStyleFamilies = xStyleSupplier->getStyleFamilies();
+ mxParaStyles.set( xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ) ), uno::UNO_QUERY_THROW );
}
- uno::Reference< container::XNameContainer > getCurrentStyleFamily(){ return mxCurrentStyleFamily; }
// XElementAccess
virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return style::XStyle::static_type(0); }
virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return getCount() > 0; }
@@ -209,32 +206,42 @@ public:
}
virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
{
- uno::Sequence< rtl::OUString > sNames( getCount() );
- rtl::OUString* pString = sNames.getArray();
- uno::Sequence< rtl::OUString > aStyleTypes = getStyleTypes();
- sal_Int32 nCount = 0;
- for( sal_Int32 i = 0; i < aStyleTypes.getLength(); i++ )
+ return mxParaStyles->getElementNames();
+ }
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ // search in the MSOStyleName table first
+ for( const MSOStyleNameTable* pTable = aMSOStyleNameTable; pTable->pMSOStyleName != NULL; pTable++ )
{
- uno::Reference< container::XNameAccess > xNameAccess( mxStyleFamilies->getByName( aStyleTypes[i] ), uno::UNO_QUERY_THROW );
- uno::Sequence< rtl::OUString > sElementNames = xNameAccess->getElementNames();
- for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ )
+ if( aName.equalsIgnoreAsciiCaseAscii( pTable->pMSOStyleName ) )
{
- pString[nCount++] = sElementNames[j];
+ //Found it
+ rtl::OUString sStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
+ if( mxParaStyles->hasByName( sStyleName ) )
+ {
+ cachePos = mxParaStyles->getByName( sStyleName );
+ return sal_True;
+ }
+ return sal_False;
}
}
- return sNames;
- }
- virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
- {
- uno::Sequence< rtl::OUString > aStyleTypes = getStyleTypes();
- for( sal_Int32 i = 0; i < aStyleTypes.getLength(); i++ )
+
+ if( mxParaStyles->hasByName( aName ) )
+ {
+ cachePos = mxParaStyles->getByName( aName );
+ return sal_True;
+ }
+ else
{
- uno::Reference< container::XNameAccess > xNameAccess( mxStyleFamilies->getByName( aStyleTypes[i] ), uno::UNO_QUERY_THROW );
- if( xNameAccess->hasByName( aName ) )
+ uno::Sequence< rtl::OUString > sElementNames = mxParaStyles->getElementNames();
+ for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ )
{
- cachePos = xNameAccess->getByName( aName );
- mxCurrentStyleFamily.set( xNameAccess, uno::UNO_QUERY_THROW );
- return sal_True;
+ rtl::OUString aStyleName = sElementNames[j];
+ if( aStyleName.equalsIgnoreAsciiCase( aName ) )
+ {
+ cachePos = mxParaStyles->getByName( aStyleName );
+ return sal_True;
+ }
}
}
return sal_False;
@@ -243,44 +250,43 @@ public:
// XIndexAccess
virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
{
- uno::Sequence< rtl::OUString > aStyleTypes = getStyleTypes();
- sal_Int32 nCount = 0;
- for( sal_Int32 i = 0; i < aStyleTypes.getLength(); i++ )
- {
- uno::Reference< container::XIndexAccess > xIndexAccess( mxStyleFamilies->getByName( aStyleTypes[i] ), uno::UNO_QUERY_THROW );
- nCount += xIndexAccess->getCount();
- }
- return nCount;
+ uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
+ return xIndexAccess->getCount();
}
virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
{
if ( Index < 0 || Index >= getCount() )
throw lang::IndexOutOfBoundsException();
- // FIXME: need to make a alphabetically sorted list of style names
- uno::Sequence< rtl::OUString > aStyleTypes = getStyleTypes();
- for( sal_Int32 i = 0; i < aStyleTypes.getLength(); i++ )
- {
- uno::Reference< container::XIndexAccess > xIndexAccess( mxStyleFamilies->getByName( aStyleTypes[i] ), uno::UNO_QUERY_THROW );
- sal_Int32 nCount = xIndexAccess->getCount();
- if( Index >= nCount )
- Index -= nCount;
- else
- {
- mxCurrentStyleFamily.set( xIndexAccess, uno::UNO_QUERY_THROW );
- return xIndexAccess->getByIndex( Index );
- }
- }
- throw lang::IndexOutOfBoundsException();
+ uno::Reference< container::XIndexAccess > xIndexAccess( mxParaStyles, uno::UNO_QUERY_THROW );
+ return xIndexAccess->getByIndex( Index );
}
// XEnumerationAccess
virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
{
- // FIXME:
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
}
};
+class StylesEnumWrapper : public EnumerationHelper_BASE
+{
+ SwVbaStyles* pStyles;
+ sal_Int32 nIndex;
+public:
+ StylesEnumWrapper( SwVbaStyles* _pStyles ) : pStyles( _pStyles ), nIndex( 1 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex <= pStyles->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex <= pStyles->getCount() )
+ return pStyles->Item( uno::makeAny( nIndex++ ), uno::Any() );
+ throw container::NoSuchElementException();
+ }
+};
+
SwVbaStyles::SwVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException ) : SwVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new StyleCollectionHelper( xModel ) ) ), mxModel( xModel )
{
mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
@@ -290,7 +296,7 @@ uno::Any
SwVbaStyles::createCollectionObject(const uno::Any& aObject)
{
uno::Reference< beans::XPropertySet > xStyleProp( aObject, uno::UNO_QUERY_THROW );
- return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xStyleProp ) ) );
+ return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProp ) ) );
}
uno::Type SAL_CALL
@@ -302,7 +308,7 @@ SwVbaStyles::getElementType() throw (uno::RuntimeException)
uno::Reference< container::XEnumeration > SAL_CALL
SwVbaStyles::createEnumeration() throw (uno::RuntimeException)
{
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+ return new StylesEnumWrapper( this );
}
uno::Any SAL_CALL
@@ -319,7 +325,8 @@ SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::
rtl::OUString aStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName );
if( aStyleName.getLength() > 0 )
{
- rtl::OUString aStyleType = SwVbaStyle::getOOoStyleTypeFromMSWord( pTable->wdStyleType );
+ //rtl::OUString aStyleType = SwVbaStyle::getOOoStyleTypeFromMSWord( pTable->wdStyleType );
+ rtl::OUString aStyleType;
switch( pTable->wdStyleType )
{
case word::WdStyleType::wdStyleTypeParagraph:
@@ -335,7 +342,8 @@ SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::
}
case word::WdStyleType::wdStyleTypeList:
{
- aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyles") );
+ // should use Paragraph style and set the property "NumberingStyleName"
+ aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") );
break;
}
default:
@@ -344,7 +352,12 @@ SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::
uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW);
uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( aStyleType ), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xStyleProps( xStylesAccess->getByName( aStyleName ), uno::UNO_QUERY_THROW );
- return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, xStyleProps ) ) );
+ // set the property "NumberingStyleName" if it is a listbullet
+ if( pTable->wdStyleType == word::WdStyleType::wdStyleTypeList )
+ {
+ xStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName") ), uno::makeAny( aStyleName ) );
+ }
+ return uno::makeAny( uno::Reference< word::XStyle >( new SwVbaStyle( this, mxContext, mxModel, xStyleProps ) ) );
}
else
{
diff --git a/sw/source/ui/vba/vbasystem.cxx b/sw/source/ui/vba/vbasystem.cxx
index 42d1c09ccbac..4d2d229da833 100644
--- a/sw/source/ui/vba/vbasystem.cxx
+++ b/sw/source/ui/vba/vbasystem.cxx
@@ -34,6 +34,13 @@
#include <tools/urlobj.hxx>
#include <tools/string.hxx>
+#ifdef WNT
+#include <tools/prewin.h>
+#include <windows.h>
+#include <tools/postwin.h>
+#include <tchar.h>
+#endif
+
using namespace ::ooo::vba;
using namespace ::com::sun::star;
@@ -47,13 +54,79 @@ void PrivateProfileStringListener::Initialize( const rtl::OUString& rFileName, c
maGroupName = rGroupName;
maKey = rKey;
}
+#ifdef WNT
+void lcl_getRegKeyInfo( const ByteString& sKeyInfo, HKEY& hBaseKey, ByteString& sSubKey )
+{
+ sal_Int32 nBaseKeyIndex = sKeyInfo.Search('\\');
+ if( nBaseKeyIndex > 0 )
+ {
+ ByteString sBaseKey = sKeyInfo.Copy( 0, nBaseKeyIndex );
+ sSubKey = sKeyInfo.Copy( nBaseKeyIndex + 1 );
+ if( sBaseKey.Equals("HKEY_CURRENT_USER") )
+ {
+ hBaseKey = HKEY_CURRENT_USER;
+ }
+ else if( sBaseKey.Equals("HKEY_LOCAL_MACHINE") )
+ {
+ hBaseKey = HKEY_LOCAL_MACHINE;
+ }
+ else if( sBaseKey.Equals("HKEY_CLASSES_ROOT") )
+ {
+ hBaseKey = HKEY_CLASSES_ROOT;
+ }
+ else if( sBaseKey.Equals("HKEY_USERS") )
+ {
+ hBaseKey = HKEY_USERS;
+ }
+ else if( sBaseKey.Equals("HKEY_CURRENT_CONFIG") )
+ {
+ hBaseKey = HKEY_CURRENT_CONFIG;
+ }
+ }
+}
+#endif
uno::Any PrivateProfileStringListener::getValueEvent()
{
// get the private profile string
- Config aCfg( maFileName );
- aCfg.SetGroup( maGroupName );
- rtl::OUString sValue = String( aCfg.ReadKey( maKey ), RTL_TEXTENCODING_DONTKNOW );
+ rtl::OUString sValue;
+ if(maFileName.getLength())
+ {
+ // get key/value from a file
+ Config aCfg( maFileName );
+ aCfg.SetGroup( maGroupName );
+ sValue = String( aCfg.ReadKey( maKey ), RTL_TEXTENCODING_DONTKNOW );
+ }
+ else
+ {
+ // get key/value from windows register
+#ifdef WNT
+ HKEY hBaseKey = NULL;
+ ByteString sSubKey;
+ sal_Int32 nBaseKeyIndex = maGroupName.Search('\\');
+ lcl_getRegKeyInfo( maGroupName, hBaseKey, sSubKey );
+ if( hBaseKey != NULL )
+ {
+ HKEY hKey = NULL;
+ LONG lResult;
+ LPCTSTR lpSubKey = TEXT( sSubKey.GetBuffer());
+ TCHAR szBuffer[1024];
+ DWORD cbData = sizeof( szBuffer );
+ lResult = RegOpenKeyEx( hBaseKey, lpSubKey, 0, KEY_QUERY_VALUE, &hKey );
+ if( ERROR_SUCCESS == lResult )
+ {
+ LPCTSTR lpValueName = TEXT(maKey.GetBuffer());
+ lResult = RegQueryValueEx( hKey, lpValueName, NULL, NULL, (LPBYTE)szBuffer, &cbData );
+ RegCloseKey( hKey );
+ sValue = rtl::OUString::createFromAscii(szBuffer);
+ }
+ }
+
+ return uno::makeAny( sValue );
+#endif
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Only support on Windows")), uno::Reference< uno::XInterface >() );
+ }
return uno::makeAny( sValue );
}
@@ -61,12 +134,44 @@ uno::Any PrivateProfileStringListener::getValueEvent()
void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value )
{
// set the private profile string
- Config aCfg( maFileName );
- aCfg.SetGroup( maGroupName );
-
rtl::OUString aValue;
value >>= aValue;
- aCfg.WriteKey( maKey, ByteString( aValue.getStr(), RTL_TEXTENCODING_DONTKNOW ) );
+ if(maFileName.getLength())
+ {
+ // set value into a file
+ Config aCfg( maFileName );
+ aCfg.SetGroup( maGroupName );
+ aCfg.WriteKey( maKey, ByteString( aValue.getStr(), RTL_TEXTENCODING_DONTKNOW ) );
+ }
+ else
+ {
+ //set value into windows register
+#ifdef WNT
+ HKEY hBaseKey = NULL;
+ ByteString sSubKey;
+ sal_Int32 nBaseKeyIndex = maGroupName.Search('\\');
+ lcl_getRegKeyInfo( maGroupName, hBaseKey, sSubKey );
+ if( hBaseKey != NULL )
+ {
+ HKEY hKey = NULL;
+ LONG lResult;
+ LPCTSTR lpSubKey = TEXT( sSubKey.GetBuffer());
+ lResult = RegCreateKeyEx( hBaseKey, lpSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL );
+ if( ERROR_SUCCESS == lResult )
+ {
+ LPCTSTR szValue = TEXT( rtl::OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 ).getStr() );
+ DWORD cbData = sizeof(TCHAR) * (_tcslen(szValue) + 1);
+ LPCTSTR lpValueName = TEXT(maKey.GetBuffer());
+ lResult = RegSetValueEx( hKey, lpValueName, NULL, REG_SZ, (LPBYTE)szValue, cbData );
+ RegCloseKey( hKey );
+ }
+ }
+ return;
+#endif
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Not implemented")), uno::Reference< uno::XInterface >() );
+ }
+
}
SwVbaSystem::SwVbaSystem( uno::Reference<uno::XComponentContext >& xContext ): SwVbaSystem_BASE( uno::Reference< XHelperInterface >(), xContext )
@@ -146,19 +251,19 @@ SwVbaSystem::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
uno::Any SAL_CALL
SwVbaSystem::PrivateProfileString( const rtl::OUString& rFilename, const rtl::OUString& rSection, const rtl::OUString& rKey ) throw ( uno::RuntimeException )
{
- if( rFilename.getLength() == 0 )
- throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
-
// FIXME: need to detect whether it is a relative file path
// we need to detect if this is a URL, if not then assume its a file path
rtl::OUString sFileUrl;
- INetURLObject aObj;
- aObj.SetURL( rFilename );
- bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
- if ( bIsURL )
- sFileUrl = rFilename;
- else
- osl::FileBase::getFileURLFromSystemPath( rFilename, sFileUrl);
+ if( rFilename.getLength() )
+ {
+ INetURLObject aObj;
+ aObj.SetURL( rFilename );
+ bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
+ if ( bIsURL )
+ sFileUrl = rFilename;
+ else
+ osl::FileBase::getFileURLFromSystemPath( rFilename, sFileUrl);
+ }
ByteString aGroupName = ByteString( rSection.getStr(), RTL_TEXTENCODING_DONTKNOW);
ByteString aKey = ByteString( rKey.getStr(), RTL_TEXTENCODING_DONTKNOW);
diff --git a/sw/source/ui/vba/vbatable.cxx b/sw/source/ui/vba/vbatable.cxx
index 11969d6717a0..73d91ad492c8 100644
--- a/sw/source/ui/vba/vbatable.cxx
+++ b/sw/source/ui/vba/vbatable.cxx
@@ -9,11 +9,13 @@
#include <com/sun/star/container/XNamed.hpp>
#include "vbaborders.hxx"
#include "vbapalette.hxx"
+#include "vbarows.hxx"
+#include "vbacolumns.hxx"
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaTable::SwVbaTable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& rDocument, const uno::Reference< css::text::XTextTable >& xTextTable) throw ( uno::RuntimeException ) : SwVbaTable_BASE( rParent, rContext ), mxTextDocument( rDocument )
+SwVbaTable::SwVbaTable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rDocument, const uno::Reference< text::XTextTable >& xTextTable) throw ( uno::RuntimeException ) : SwVbaTable_BASE( rParent, rContext ), mxTextDocument( rDocument )
{
mxTextTable.set( xTextTable, uno::UNO_QUERY_THROW );
}
@@ -75,6 +77,26 @@ SwVbaTable::Borders( const uno::Any& index ) throw (uno::RuntimeException)
return uno::makeAny( xCol );
}
+uno::Any SAL_CALL
+SwVbaTable::Rows( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< table::XTableRows > xTableRows( mxTextTable->getRows(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaRows( this, mxContext, mxTextTable, xTableRows ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
+uno::Any SAL_CALL
+SwVbaTable::Columns( const uno::Any& index ) throw (uno::RuntimeException)
+{
+ uno::Reference< table::XTableColumns > xTableColumns( mxTextTable->getColumns(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( new SwVbaColumns( this, mxContext, mxTextTable, xTableColumns ) );
+ if ( index.hasValue() )
+ return xCol->Item( index, uno::Any() );
+ return uno::makeAny( xCol );
+}
+
// XHelperInterface
rtl::OUString&
SwVbaTable::getServiceImplName()
diff --git a/sw/source/ui/vba/vbatable.hxx b/sw/source/ui/vba/vbatable.hxx
index 7d913d718895..d6da8c9afec4 100644
--- a/sw/source/ui/vba/vbatable.hxx
+++ b/sw/source/ui/vba/vbatable.hxx
@@ -21,6 +21,9 @@ public:
virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL ConvertToText( const css::uno::Any& Separator, const css::uno::Any& NestedTables ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getName( ) throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Rows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Columns( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
virtual css::uno::Sequence<rtl::OUString> getServiceNames();
diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx
index 9a10622400d3..9ca798a6ce6a 100644
--- a/sw/source/ui/vba/vbatables.cxx
+++ b/sw/source/ui/vba/vbatables.cxx
@@ -4,6 +4,9 @@
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/text/XTextTablesSupplier.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
#include <comphelper/componentcontext.hxx>
using namespace ::ooo::vba;
@@ -26,7 +29,89 @@ uno::Any lcl_createTable( const uno::Reference< XHelperInterface >& xParent, con
return uno::makeAny( xTable );
}
+sal_Bool lcl_isInHeaderFooter( const uno::Reference< text::XTextTable >& xTable )
+{
+ uno::Reference< text::XTextContent > xTextContent( xTable, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XText > xText = xTextContent->getAnchor()->getText();
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xText, uno::UNO_QUERY_THROW );
+ rtl::OUString aImplName = xServiceInfo->getImplementationName();
+ if( aImplName.equalsAscii("SwXHeadFootText") )
+ return sal_True;
+ return sal_False;
+}
+
typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > EnumBase;
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XNameAccess > TableCollectionHelper_Base;
+typedef std::vector< uno::Reference< text::XTextTable > > XTextTableVec;
+
+class TableCollectionHelper : public TableCollectionHelper_Base
+{
+ XTextTableVec mxTables;
+ XTextTableVec::iterator cachePos;
+
+public:
+ TableCollectionHelper( const uno::Reference< frame::XModel >& xDocument )
+ {
+ // only count the tables in the body text, not in the header/footer
+ uno::Reference< container::XIndexAccess > xTables = lcl_getTables( xDocument );
+ sal_Int32 nCount = xTables->getCount();
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ uno::Reference< text::XTextTable > xTable( xTables->getByIndex( i ) , uno::UNO_QUERY_THROW );
+ if( !lcl_isInHeaderFooter( xTable ) )
+ mxTables.push_back( xTable );
+ }
+ cachePos = mxTables.begin();
+ }
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return mxTables.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::XTextTable > xTable( mxTables[ Index ], uno::UNO_QUERY_THROW );
+ return uno::makeAny( xTable );
+ }
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return text::XTextTable::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::XTextTable > xTable( *cachePos, uno::UNO_QUERY_THROW );
+ return uno::makeAny( xTable );
+ }
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< rtl::OUString > sNames( mxTables.size() );
+ rtl::OUString* pString = sNames.getArray();
+ XTextTableVec::iterator it = mxTables.begin();
+ XTextTableVec::iterator it_end = mxTables.end();
+ for ( ; it != it_end; ++it, ++pString )
+ {
+ uno::Reference< container::XNamed > xName( *it, uno::UNO_QUERY_THROW );
+ *pString = xName->getName();
+ }
+ return sNames;
+ }
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ cachePos = mxTables.begin();
+ XTextTableVec::iterator it_end = mxTables.end();
+ for ( ; cachePos != it_end; ++cachePos )
+ {
+ uno::Reference< container::XNamed > xName( *cachePos, uno::UNO_QUERY_THROW );
+ if ( aName.equalsIgnoreAsciiCase( xName->getName() ) )
+ break;
+ }
+ return ( cachePos != it_end );
+ }
+};
class TableEnumerationImpl : public EnumBase
{
@@ -52,7 +137,7 @@ public:
};
-SwVbaTables::SwVbaTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xDocument ) : SwVbaTables_BASE( xParent, xContext , lcl_getTables( xDocument ) ), mxDocument( xDocument )
+SwVbaTables::SwVbaTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xDocument ) : SwVbaTables_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new TableCollectionHelper( xDocument ) ) ), mxDocument( xDocument )
{
}
@@ -85,6 +170,12 @@ SwVbaTables::Add( const uno::Reference< word::XRange >& Range, const uno::Any& N
uno::Reference< text::XTextContent > xContext( xTable, uno::UNO_QUERY_THROW );
xText->insertTextContent( xTextRange, xContext, true );
+
+ // move the current cursor to the first table cell
+ uno::Reference< table::XCellRange > xCellRange( xTable, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XText> xFirstCellText( xCellRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ word::getXTextViewCursor( mxDocument )->gotoRange( xFirstCellText->getStart(), sal_False );
+
uno::Reference< word::XTable > xVBATable( new SwVbaTable( mxParent, mxContext, pVbaRange->getDocument(), xTable ) );
return xVBATable;
}
diff --git a/sw/source/ui/vba/vbatemplate.cxx b/sw/source/ui/vba/vbatemplate.cxx
index 68476b301a17..ae7a1fda2184 100644
--- a/sw/source/ui/vba/vbatemplate.cxx
+++ b/sw/source/ui/vba/vbatemplate.cxx
@@ -30,12 +30,35 @@
#include "vbaautotextentry.hxx"
#include <comphelper/processfactory.hxx>
#include <com/sun/star/text/XAutoTextContainer.hpp>
+#include <tools/urlobj.hxx>
+#include <osl/file.hxx>
using namespace ::ooo::vba;
using namespace ::com::sun::star;
-SwVbaTemplate::SwVbaTemplate( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const rtl::OUString& rName )
- : SwVbaTemplate_BASE( rParent, rContext ), mxModel( rModel ), msName( rName )
+String lcl_CheckGroupName( const String& rGroupName )
+{
+ String sRet;
+ //group name should contain only A-Z and a-z and spaces
+ for( xub_StrLen i = 0; i < rGroupName.Len(); i++ )
+ {
+ sal_Unicode cChar = rGroupName.GetChar(i);
+ if( (cChar >= 'A' && cChar <= 'Z') ||
+ (cChar >= 'a' && cChar <= 'z') ||
+ (cChar >= '0' && cChar <= '9') ||
+ cChar == '_' || cChar == 0x20 )
+ {
+ sRet += cChar;
+ }
+ }
+ sRet.EraseLeadingChars();
+ sRet.EraseTrailingChars();
+ return sRet;
+}
+
+
+SwVbaTemplate::SwVbaTemplate( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const rtl::OUString& rFullUrl )
+ : SwVbaTemplate_BASE( rParent, rContext ), mxModel( rModel ), msFullUrl( rFullUrl )
{
}
@@ -47,7 +70,27 @@ SwVbaTemplate::~SwVbaTemplate()
rtl::OUString
SwVbaTemplate::getName() throw ( css::uno::RuntimeException )
{
- return msName;
+ rtl::OUString sName;
+ if( msFullUrl.getLength() )
+ {
+ INetURLObject aURL( msFullUrl );
+ ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName );
+ }
+ return sName;
+}
+
+rtl::OUString
+SwVbaTemplate::getPath() throw ( css::uno::RuntimeException )
+{
+ rtl::OUString sPath;
+ if( msFullUrl.getLength() )
+ {
+ INetURLObject aURL( msFullUrl );
+ rtl::OUString sURL( aURL.GetMainURL( INetURLObject::DECODE_TO_IURI ) );
+ sURL = sURL.copy( 0, sURL.getLength() - aURL.GetLastName().getLength() - 1 );
+ ::osl::File::getSystemPathFromFileURL( sURL, sPath );
+ }
+ return sPath;
}
uno::Any SAL_CALL
@@ -58,17 +101,18 @@ SwVbaTemplate::AutoTextEntries( const uno::Any& index ) throw (uno::RuntimeExcep
// the default template is "Normal.dot" in Word.
rtl::OUString sGroup( RTL_CONSTASCII_USTRINGPARAM("Normal") );
- sal_Int32 nIndex = msName.lastIndexOf( sal_Unicode('.') );
+ rtl::OUString sName = getName();
+ sal_Int32 nIndex = sName.lastIndexOf( sal_Unicode('.') );
if( nIndex > 0 )
{
- sGroup = msName.copy( 0, msName.lastIndexOf( sal_Unicode('.') ) );
- // OSL_TRACE("SwVbaTemplate::AutoTextEntries: %s", rtl::OUStringToOString( sGroup, RTL_TEXTENCODING_UTF8 ).getStr() );
+ sGroup = sName.copy( 0, sName.lastIndexOf( sal_Unicode('.') ) );
}
+ String sNewGroup = lcl_CheckGroupName( sGroup );
uno::Reference< container::XIndexAccess > xGroup;
- if( xAutoTextContainer->hasByName( sGroup ) )
+ if( xAutoTextContainer->hasByName( sNewGroup ) )
{
- xGroup.set( xAutoTextContainer->getByName( sGroup ), uno::UNO_QUERY_THROW );
+ xGroup.set( xAutoTextContainer->getByName( sNewGroup ), uno::UNO_QUERY_THROW );
}
else
{
diff --git a/sw/source/ui/vba/vbatemplate.hxx b/sw/source/ui/vba/vbatemplate.hxx
index 073e5cc5db1e..9d959b221bda 100644
--- a/sw/source/ui/vba/vbatemplate.hxx
+++ b/sw/source/ui/vba/vbatemplate.hxx
@@ -36,7 +36,7 @@ class SwVbaTemplate : public SwVbaTemplate_BASE
{
private:
css::uno::Reference< css::frame::XModel > mxModel;
- rtl::OUString msName;
+ rtl::OUString msFullUrl;
public:
SwVbaTemplate( 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 rtl::OUString& );
@@ -44,6 +44,7 @@ public:
// XTemplate
virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getPath() throw (css::uno::RuntimeException);
virtual css::uno::Any SAL_CALL AutoTextEntries( const css::uno::Any& index ) throw (css::uno::RuntimeException);
// XHelperInterface
virtual rtl::OUString& getServiceImplName();
diff --git a/sw/source/ui/vba/vbaview.cxx b/sw/source/ui/vba/vbaview.cxx
index 9cb8bf1490ce..c1d8319de24f 100644
--- a/sw/source/ui/vba/vbaview.cxx
+++ b/sw/source/ui/vba/vbaview.cxx
@@ -92,20 +92,20 @@ SwVbaView::getSeekView() throw (css::uno::RuntimeException)
}
else if( aImplName.equalsAscii("SwXHeadFootText") )
{
- if( HeaderFooterHelper::isHeader( mxModel, xCurrentText ) )
+ if( HeaderFooterHelper::isHeader( mxModel ) )
{
- if( HeaderFooterHelper::isFirstPageHeader( mxModel, xCurrentText ) )
+ if( HeaderFooterHelper::isFirstPageHeader( mxModel ) )
return word::WdSeekView::wdSeekFirstPageHeader;
- else if( HeaderFooterHelper::isEvenPagesHeader( mxModel, xCurrentText ) )
+ else if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) )
return word::WdSeekView::wdSeekEvenPagesHeader;
else
return word::WdSeekView::wdSeekPrimaryHeader;
}
else
{
- if( HeaderFooterHelper::isFirstPageFooter( mxModel, xCurrentText ) )
+ if( HeaderFooterHelper::isFirstPageFooter( mxModel ) )
return word::WdSeekView::wdSeekFirstPageFooter;
- else if( HeaderFooterHelper::isEvenPagesFooter( mxModel, xCurrentText ) )
+ else if( HeaderFooterHelper::isEvenPagesFooter( mxModel ) )
return word::WdSeekView::wdSeekEvenPagesFooter;
else
return word::WdSeekView::wdSeekPrimaryFooter;
@@ -132,6 +132,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeExceptio
// if( _seekview == getSeekView() )
// return;
+ word::gotoSelectedObjectAnchor( mxModel );
switch( _seekview )
{
case word::WdSeekView::wdSeekFirstPageFooter:
@@ -181,7 +182,7 @@ SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeExceptio
{
uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW );
uno::Reference< text::XText > xText = xTextDocument->getText();
- mxViewCursor->gotoRange( getFirstObjectPosition( xText ), sal_False );
+ mxViewCursor->gotoRange( word::getFirstObjectPosition( xText ), sal_False );
break;
}
}
@@ -376,28 +377,7 @@ uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType )
{
DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() );
}
- uno::Reference< text::XTextRange > xTextRange = getFirstObjectPosition( xText );
- return xTextRange;
-}
-
-uno::Reference< text::XTextRange > SwVbaView::getFirstObjectPosition( const uno::Reference< text::XText >& xText ) throw (uno::RuntimeException)
-{
- // if the first object is table, get the position of first cell
- uno::Reference< text::XTextRange > xTextRange;
- uno::Reference< container::XEnumerationAccess > xParaAccess( xText, uno::UNO_QUERY_THROW );
- uno::Reference< container::XEnumeration> xParaEnum = xParaAccess->createEnumeration();
- if( xParaEnum->hasMoreElements() )
- {
- uno::Reference< lang::XServiceInfo > xServiceInfo( xParaEnum->nextElement(), uno::UNO_QUERY_THROW );
- if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable") ) ) )
- {
- uno::Reference< table::XCellRange > xCellRange( xServiceInfo, uno::UNO_QUERY_THROW );
- uno::Reference< text::XText> xFirstCellText( xCellRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
- xTextRange = xFirstCellText->getStart();
- }
- }
- if( !xTextRange.is() )
- xTextRange = xText->getStart();
+ uno::Reference< text::XTextRange > xTextRange = word::getFirstObjectPosition( xText );
return xTextRange;
}
diff --git a/sw/source/ui/vba/vbawindow.cxx b/sw/source/ui/vba/vbawindow.cxx
index e3d9bddbc7aa..a4306382372e 100644
--- a/sw/source/ui/vba/vbawindow.cxx
+++ b/sw/source/ui/vba/vbawindow.cxx
@@ -25,12 +25,21 @@
*
************************************************************************/
#include <vbahelper/helperdecl.hxx>
+#include <ooo/vba/word/WdWindowState.hpp>
+#include <vcl/wrkwin.hxx>
+
#include "vbawindow.hxx"
#include "vbaglobals.hxx"
#include "vbadocument.hxx"
#include "vbaview.hxx"
#include "vbapanes.hxx"
#include "vbapane.hxx"
+#include "wordvbahelper.hxx"
+#include <view.hxx>
+// #FIXME where has SfxTopViewFrame gone
+#if 0
+#include <sfx2/topfrm.hxx>
+#endif
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -73,6 +82,44 @@ void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeE
}
uno::Any SAL_CALL
+SwVbaWindow::getWindowState() throw (uno::RuntimeException)
+{
+ sal_Int32 nwindowState = word::WdWindowState::wdWindowStateNormal;
+ SwView* pView = word::getView( m_xModel );
+ SfxViewFrame* pViewFrame = pView -> GetViewFrame();
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
+ {
+ if ( pWork -> IsMaximized())
+ nwindowState = word::WdWindowState::wdWindowStateMaximize;
+ else if (pWork -> IsMinimized())
+ nwindowState = word::WdWindowState::wdWindowStateMinimize;
+ }
+ return uno::makeAny( nwindowState );
+}
+
+void SAL_CALL
+SwVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeException)
+{
+ sal_Int32 nwindowState = word::WdWindowState::wdWindowStateMaximize;
+ _windowstate >>= nwindowState;
+ SwView* pView = word::getView( m_xModel );
+ SfxViewFrame* pViewFrame = pView -> GetViewFrame();
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
+ {
+ if ( nwindowState == word::WdWindowState::wdWindowStateMaximize )
+ pWork -> Maximize();
+ else if (nwindowState == word::WdWindowState::wdWindowStateMinimize)
+ pWork -> Minimize();
+ else if (nwindowState == word::WdWindowState::wdWindowStateNormal)
+ pWork -> Restore();
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
+ }
+}
+
+uno::Any SAL_CALL
SwVbaWindow::Panes( const uno::Any& aIndex ) throw (uno::RuntimeException)
{
uno::Reference< XCollection > xPanes( new SwVbaPanes( this, mxContext, m_xModel ) );
diff --git a/sw/source/ui/vba/vbawindow.hxx b/sw/source/ui/vba/vbawindow.hxx
index 0809d2b73685..c93e95fd7e55 100644
--- a/sw/source/ui/vba/vbawindow.hxx
+++ b/sw/source/ui/vba/vbawindow.hxx
@@ -44,6 +44,8 @@ public:
// Attributes
virtual css::uno::Any SAL_CALL getView() throw (css::uno::RuntimeException);
virtual void SAL_CALL setView( const css::uno::Any& _view ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWindowState() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWindowState( const css::uno::Any& _windowstate ) throw (css::uno::RuntimeException);
// Methods
virtual void SAL_CALL Activate( ) throw (css::uno::RuntimeException);
virtual void SAL_CALL Close( const css::uno::Any& SaveChanges, const css::uno::Any& RouteDocument ) throw (css::uno::RuntimeException);
diff --git a/sw/source/ui/vba/wordvbahelper.cxx b/sw/source/ui/vba/wordvbahelper.cxx
index 82dfacf4f18d..c4639a0e329f 100644
--- a/sw/source/ui/vba/wordvbahelper.cxx
+++ b/sw/source/ui/vba/wordvbahelper.cxx
@@ -29,11 +29,16 @@
#include <comphelper/processfactory.hxx>
#include <com/sun/star/frame/XController.hpp>
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <unotxdoc.hxx>
#include <doc.hxx>
+#include <view.hxx>
using namespace ::com::sun::star;
using namespace ::ooo::vba;
@@ -71,8 +76,13 @@ uno::Reference< text::XTextViewCursor > getXTextViewCursor( const uno::Reference
uno::Reference< style::XStyle > getCurrentPageStyle( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
{
uno::Reference< beans::XPropertySet > xCursorProps( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
+ return getCurrentPageStyle( xModel, xCursorProps );
+}
+
+uno::Reference< style::XStyle > getCurrentPageStyle( const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xProps ) throw (uno::RuntimeException)
+{
rtl::OUString aPageStyleName;
- xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName;
uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_QUERY_THROW );
uno::Reference< container::XNameAccess > xPageStyles( xSytleFamNames->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles") ) ), uno::UNO_QUERY_THROW );
@@ -87,6 +97,92 @@ sal_Int32 getPageCount( const uno::Reference< frame::XModel>& xModel ) throw (un
return pDocShell ? pDocShell->GetDoc()->GetPageCount() : 0;
}
+uno::Reference< style::XStyle > getDefaultParagraphStyle( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xParaStyles( xSytleFamNames->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< style::XStyle > xStyle( xParaStyles->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ) ), uno::UNO_QUERY_THROW );
+
+ return xStyle;
+}
+
+uno::Reference< text::XTextRange > getFirstObjectPosition( const uno::Reference< text::XText >& xText ) throw (uno::RuntimeException)
+{
+ // if the first object is table, get the position of first cell
+ uno::Reference< text::XTextRange > xTextRange;
+ uno::Reference< container::XEnumerationAccess > xParaAccess( xText, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration> xParaEnum = xParaAccess->createEnumeration();
+ if( xParaEnum->hasMoreElements() )
+ {
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xParaEnum->nextElement(), uno::UNO_QUERY_THROW );
+ if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable") ) ) )
+ {
+ uno::Reference< table::XCellRange > xCellRange( xServiceInfo, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XText> xFirstCellText( xCellRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ xTextRange = xFirstCellText->getStart();
+ }
+ }
+ if( !xTextRange.is() )
+ xTextRange = xText->getStart();
+ return xTextRange;
+}
+
+uno::Reference< text::XText > getCurrentXText( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ uno::Reference< text::XTextRange > xTextRange;
+ uno::Reference< text::XTextContent > xTextContent( xModel->getCurrentSelection(), uno::UNO_QUERY );
+ if( !xTextContent.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndexAccess( xModel->getCurrentSelection(), uno::UNO_QUERY );
+ if( xIndexAccess.is() )
+ {
+ xTextContent.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY );
+ }
+ }
+
+ if( xTextContent.is() )
+ xTextRange.set( xTextContent->getAnchor(), uno::UNO_QUERY );
+
+ if( !xTextRange.is() )
+ xTextRange.set( getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW );
+
+ uno::Reference< text::XText > xText;
+ try
+ {
+ xText.set( xTextRange->getText(), uno::UNO_QUERY );
+ }
+ catch( uno::RuntimeException& )
+ {
+ //catch exception "no text selection"
+ }
+ uno::Reference< beans::XPropertySet > xVCProps( xTextRange, uno::UNO_QUERY_THROW );
+ while( xVCProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextContent )
+ {
+ xText = xTextContent->getAnchor()->getText();
+ xVCProps.set( xText->createTextCursor(), uno::UNO_QUERY_THROW );
+ }
+
+ if( !xText.is() )
+ throw uno::RuntimeException( rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), uno::Reference< uno::XInterface >() );
+
+ return xText;
+}
+
+sal_Bool gotoSelectedObjectAnchor( const uno::Reference< frame::XModel>& xModel ) throw (uno::RuntimeException)
+{
+ sal_Bool isObjectSelected = sal_False;
+ uno::Reference< text::XTextContent > xTextContent( xModel->getCurrentSelection(), uno::UNO_QUERY );
+ if( xTextContent.is() )
+ {
+ uno::Reference< text::XTextRange > xTextRange( xTextContent->getAnchor(), uno::UNO_QUERY_THROW );
+ uno::Reference< view::XSelectionSupplier > xSelectSupp( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelectSupp->select( uno::makeAny( xTextRange ) );
+ isObjectSelected = sal_True;
+ }
+ return isObjectSelected;
+}
+
} // word
} //
} //
diff --git a/sw/source/ui/vba/wordvbahelper.hxx b/sw/source/ui/vba/wordvbahelper.hxx
index 0629d613a724..faf7db26d5ca 100644
--- a/sw/source/ui/vba/wordvbahelper.hxx
+++ b/sw/source/ui/vba/wordvbahelper.hxx
@@ -32,6 +32,8 @@
#include <com/sun/star/text/XTextViewCursor.hpp>
#include <com/sun/star/text/XPageCursor.hpp>
#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
class SwDocShell;
class SwView;
@@ -46,7 +48,20 @@ namespace ooo
SwView* getView( const css::uno::Reference< css::frame::XModel>& xModel );
css::uno::Reference< css::text::XTextViewCursor > getXTextViewCursor( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
css::uno::Reference< css::style::XStyle > getCurrentPageStyle( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ css::uno::Reference< css::style::XStyle > getCurrentPageStyle( const css::uno::Reference< css::frame::XModel>& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps ) throw (css::uno::RuntimeException);
sal_Int32 getPageCount( const css::uno::Reference< css::frame::XModel>& xModel ) throw (css::uno::RuntimeException);
+ css::uno::Reference< css::style::XStyle > getDefaultParagraphStyle( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+ css::uno::Reference< css::text::XTextRange > getFirstObjectPosition( const css::uno::Reference< css::text::XText >& xText ) throw (css::uno::RuntimeException);
+ css::uno::Reference< css::text::XText > getCurrentXText( const css::uno::Reference< css::frame::XModel>& xModel ) throw (css::uno::RuntimeException);
+ sal_Bool gotoSelectedObjectAnchor( const css::uno::Reference< css::frame::XModel>& xModel ) throw (css::uno::RuntimeException);
+
+ enum E_DIRECTION
+ {
+ MOVE_LEFT = 1,
+ MOVE_RIGHT,
+ MOVE_UP,
+ MOVE_DOWN
+ };
} // word
} // vba