diff options
Diffstat (limited to 'sw/source/ui/vba')
145 files changed, 0 insertions, 21145 deletions
diff --git a/sw/source/ui/vba/service.cxx b/sw/source/ui/vba/service.cxx deleted file mode 100644 index 7bdc724169..0000000000 --- a/sw/source/ui/vba/service.cxx +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "cppuhelper/implementationentry.hxx" -#include "com/sun/star/lang/XMultiServiceFactory.hpp" -#include "com/sun/star/registry/XRegistryKey.hpp" -#include "comphelper/servicedecl.hxx" - -// ============================================================================= -// component exports -// ============================================================================= -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; - -namespace sdecl = comphelper::service_decl; - -namespace globals -{ -extern sdecl::ServiceDecl const serviceDecl; -} - -namespace document -{ -extern sdecl::ServiceDecl const serviceDecl; -} - -namespace wrapformat -{ -extern sdecl::ServiceDecl const serviceDecl; -} - -namespace vbaeventshelper -{ -extern sdecl::ServiceDecl const serviceDecl; -} - -namespace vbaeventshelper -{ -extern sdecl::ServiceDecl const serviceDecl; -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL vbaswobj_component_getFactory( - const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, - registry::XRegistryKey * pRegistryKey ) -{ - void* pRet = component_getFactoryHelper(pImplName, pServiceManager, - pRegistryKey, globals::serviceDecl, document::serviceDecl, - wrapformat::serviceDecl, vbaeventshelper::serviceDecl ); - OSL_TRACE("Ret is 0x%x", pRet); - return pRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaaddin.cxx b/sw/source/ui/vba/vbaaddin.cxx deleted file mode 100644 index 71a372ee12..0000000000 --- a/sw/source/ui/vba/vbaaddin.cxx +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaaddin.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <tools/urlobj.hxx> -#include <osl/file.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaAddin::SwVbaAddin( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const rtl::OUString& rFileURL, sal_Bool bAutoload ) throw ( uno::RuntimeException ) : - SwVbaAddin_BASE( rParent, rContext ), msFileURL( rFileURL ), mbAutoload( bAutoload ), mbInstalled( bAutoload ) -{ -} - -SwVbaAddin::~SwVbaAddin() -{ -} - -::rtl::OUString SAL_CALL SwVbaAddin::getName() throw (uno::RuntimeException) -{ - rtl::OUString sName; - INetURLObject aURL( msFileURL ); - ::osl::File::getSystemPathFromFileURL( aURL.GetLastName(), sName ); - return sName; -} - -void SAL_CALL -SwVbaAddin::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException ) -{ - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() ); -} - -::rtl::OUString SAL_CALL SwVbaAddin::getPath() throw (uno::RuntimeException) -{ - INetURLObject aURL( msFileURL ); - aURL.CutLastName(); - return aURL.GetURLPath(); -} - -::sal_Bool SAL_CALL SwVbaAddin::getAutoload() throw (uno::RuntimeException) -{ - return mbAutoload; -} - -::sal_Bool SAL_CALL SwVbaAddin::getInstalled() throw (uno::RuntimeException) -{ - return mbInstalled; -} - -void SAL_CALL SwVbaAddin::setInstalled( ::sal_Bool _installed ) throw (uno::RuntimeException) -{ - if( _installed != mbInstalled ) - { - mbInstalled = _installed; - // TODO: should call AutoExec and AutoExit etc. - } -} - -rtl::OUString& -SwVbaAddin::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAddin") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaAddin::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Addin" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaaddin.hxx b/sw/source/ui/vba/vbaaddin.hxx deleted file mode 100644 index ae92cddcb2..0000000000 --- a/sw/source/ui/vba/vbaaddin.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_ADDIN_HXX -#define SW_VBA_ADDIN_HXX - -#include <ooo/vba/word/XAddin.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XAddin > SwVbaAddin_BASE; - -class SwVbaAddin : public SwVbaAddin_BASE -{ -private: - rtl::OUString msFileURL; - sal_Bool mbAutoload; - sal_Bool mbInstalled; - -public: - SwVbaAddin( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const rtl::OUString& rFileURL, sal_Bool bAutoload ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaAddin(); - - // Attributes - virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); - virtual void SAL_CALL setName( const rtl::OUString& _name ) throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getPath() throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoload() throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getInstalled() throw (css::uno::RuntimeException); - virtual void SAL_CALL setInstalled( ::sal_Bool _installed ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_ADDIN_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaaddins.cxx b/sw/source/ui/vba/vbaaddins.cxx deleted file mode 100644 index e454ad1cb6..0000000000 --- a/sw/source/ui/vba/vbaaddins.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaaddins.hxx" -#include "vbaaddin.hxx" -#include <cppuhelper/implbase3.hxx> -#include <unotools/pathoptions.hxx> -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -uno::Reference< container::XIndexAccess > lcl_getAddinCollection( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) -{ - XNamedObjectCollectionHelper< word::XAddin >::XNamedVec maAddins; - - // first get the autoload addins in the directory STARTUP - uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< ucb::XSimpleFileAccess > xSFA( xMCF->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")), xContext), uno::UNO_QUERY_THROW ); - SvtPathOptions aPathOpt; - // FIXME: temporary the STARTUP path is located in $OO/basic3.1/program/addin - String aAddinPath = aPathOpt.GetAddinPath(); - OSL_TRACE("lcl_getAddinCollection: %s", rtl::OUStringToOString( aAddinPath, RTL_TEXTENCODING_UTF8 ).getStr() ); - if( xSFA->isFolder( aAddinPath ) ) - { - uno::Sequence< rtl::OUString > sEntries = xSFA->getFolderContents( aAddinPath, sal_False ); - sal_Int32 nEntry = sEntries.getLength(); - for( sal_Int32 index = 0; index < nEntry; ++index ) - { - rtl::OUString sUrl = sEntries[ index ]; - if( !xSFA->isFolder( sUrl ) && sUrl.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) ) - { - maAddins.push_back( uno::Reference< word::XAddin >( new SwVbaAddin( xParent, xContext, sUrl, sal_True ) ) ); - } - } - } - - // TODO: second get the customize addins in the org.openoffice.Office.Writer/GlobalTemplateList - - uno::Reference< container::XIndexAccess > xAddinsAccess( new XNamedObjectCollectionHelper< word::XAddin >( maAddins ) ); - return xAddinsAccess; -} - -SwVbaAddins::SwVbaAddins( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext ) throw (uno::RuntimeException): SwVbaAddins_BASE( xParent, xContext, lcl_getAddinCollection( xParent,xContext ) ) -{ -} -// XEnumerationAccess -uno::Type -SwVbaAddins::getElementType() throw (uno::RuntimeException) -{ - return word::XAddin::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaAddins::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumerationAccess->createEnumeration(); -} - -uno::Any -SwVbaAddins::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaAddins::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAddins") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaAddins::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Addins") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaaddins.hxx b/sw/source/ui/vba/vbaaddins.hxx deleted file mode 100644 index 65642aada2..0000000000 --- a/sw/source/ui/vba/vbaaddins.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_ADDINS_HXX -#define SW_VBA_ADDINS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XAddins.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef CollTestImplHelper< ooo::vba::word::XAddins > SwVbaAddins_BASE; - -class SwVbaAddins : public SwVbaAddins_BASE -{ -public: - SwVbaAddins( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext ) throw (css::uno::RuntimeException); - virtual ~SwVbaAddins() {} - - // 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); - - // SwVbaAddins_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_ADDINS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaapplication.cxx b/sw/source/ui/vba/vbaapplication.cxx deleted file mode 100644 index 9d8a055744..0000000000 --- a/sw/source/ui/vba/vbaapplication.cxx +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> -#include "vbaapplication.hxx" -#include "vbadocument.hxx" -#include <osl/file.hxx> -#include <vbahelper/vbahelper.hxx> -#include "vbawindow.hxx" -#include "vbasystem.hxx" -#include "vbaoptions.hxx" -#include "vbaselection.hxx" -#include "vbadocuments.hxx" -#include "vbaaddins.hxx" -#include "vbadialogs.hxx" -#include <ooo/vba/word/WdEnableCancelKey.hpp> -#include <editeng/acorrcfg.hxx> -#include "wordvbahelper.hxx" -#include <docsh.hxx> -#include "vbalistgalleries.hxx" - -using namespace ::ooo; -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_QUERY; -using ::rtl::OUString; - -// Enable our own join detection for Intersection and Union -// should be more efficient than using ScRangeList::Join ( because -// we already are testing the same things ) - -#define OWN_JOIN 1 - -// #TODO is this defined somewhere else? -#if ( defined UNX ) -#define FILE_PATH_SEPERATOR "/" -#else // windows -#define FILE_PATH_SEPERATOR "\\" -#endif - -#define EXCELVERSION "11.0" - -uno::Any sbxToUnoValue( SbxVariable* pVar ); - -SwVbaApplication::SwVbaApplication( uno::Reference<uno::XComponentContext >& xContext ): SwVbaApplication_BASE( xContext ) -{ -} - -SwVbaApplication::~SwVbaApplication() -{ -} - -SfxObjectShell* SwVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - return static_cast< SfxObjectShell* >( word::getDocShell( xModel ) ); -} - -rtl::OUString SAL_CALL -SwVbaApplication::getName() throw (uno::RuntimeException) -{ - static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Word" ) ); - return appName; -} - -uno::Reference< word::XDocument > SAL_CALL -SwVbaApplication::getActiveDocument() throw (uno::RuntimeException) -{ - return new SwVbaDocument( this, mxContext, getCurrentDocument() ); -} - -uno::Reference< word::XWindow > SAL_CALL -SwVbaApplication::getActiveWindow() throw (uno::RuntimeException) -{ - // #FIXME sofar can't determine Parent - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_SET_THROW ); - uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_SET_THROW ); - return new SwVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel, xController ); -} - -uno::Reference<word::XSystem > SAL_CALL -SwVbaApplication::getSystem() throw (uno::RuntimeException) -{ - return uno::Reference< word::XSystem >( new SwVbaSystem( mxContext ) ); -} - -uno::Reference<word::XOptions > SAL_CALL -SwVbaApplication::getOptions() throw (uno::RuntimeException) -{ - return uno::Reference< word::XOptions >( new SwVbaOptions( mxContext ) ); -} - -uno::Any SAL_CALL -SwVbaApplication::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - return VbaApplicationBase::CommandBars( aIndex ); -} - -uno::Reference< word::XSelection > SAL_CALL -SwVbaApplication::getSelection() throw (uno::RuntimeException) -{ - return new SwVbaSelection( this, mxContext, getCurrentDocument() ); -} - -uno::Any SAL_CALL -SwVbaApplication::Documents( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaDocuments( this, mxContext ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaApplication::Addins( const uno::Any& index ) throw (uno::RuntimeException) -{ - static uno::Reference< XCollection > xCol( new SwVbaAddins( this, mxContext ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaApplication::Dialogs( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< word::XDialogs > xCol( new SwVbaDialogs( this, mxContext, getCurrentDocument() )); - if ( index.hasValue() ) - return xCol->Item( index ); - 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(); -} - -void SAL_CALL SwVbaApplication::setDisplayAutoCompleteTips( sal_Bool _displayAutoCompleteTips ) throw (css::uno::RuntimeException) -{ - SvxAutoCorrCfg::Get().SetAutoTextTip( _displayAutoCompleteTips ); -} - -sal_Int32 SAL_CALL SwVbaApplication::getEnableCancelKey() throw (css::uno::RuntimeException) -{ - // the default value is wdCancelInterrupt in Word - return word::WdEnableCancelKey::wdCancelInterrupt; -} - -void SAL_CALL SwVbaApplication::setEnableCancelKey( sal_Int32/* _enableCancelKey */) throw (css::uno::RuntimeException) -{ - // seems not supported in Writer -} - -float SAL_CALL SwVbaApplication::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException) -{ - return VbaApplicationBase::CentimetersToPoints( _Centimeters ); -} - -uno::Reference< frame::XModel > -SwVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException) -{ - return getCurrentWordDoc( mxContext ); -} - -rtl::OUString& -SwVbaApplication::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaApplication") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaApplication::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Application" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaapplication.hxx b/sw/source/ui/vba/vbaapplication.hxx deleted file mode 100644 index 9d741013a7..0000000000 --- a/sw/source/ui/vba/vbaapplication.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_APPLICATION_HXX -#define SW_VBA_APPLICATION_HXX - -#include <ooo/vba/word/XApplication.hpp> -#include <ooo/vba/word/XDocument.hpp> -#include <ooo/vba/word/XWindow.hpp> -#include <ooo/vba/word/XSystem.hpp> -#include <ooo/vba/word/XOptions.hpp> -#include <ooo/vba/word/XSelection.hpp> -#include <ooo/vba/word/XAddins.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbaapplicationbase.hxx> -#include <cppuhelper/implbase1.hxx> - -//typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XApplication > SwVbaApplication_BASE; -typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ooo::vba::word::XApplication > SwVbaApplication_BASE; - -class SwVbaApplication : public SwVbaApplication_BASE -{ -public: - SwVbaApplication( css::uno::Reference< css::uno::XComponentContext >& m_xContext ); - virtual ~SwVbaApplication(); - - virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); - - // XApplication - virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - 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); - virtual void SAL_CALL setEnableCancelKey( sal_Int32 _enableCancelKey ) throw (css::uno::RuntimeException); - virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -protected: - virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException); -}; -#endif /* SW_VBA_APPLICATION_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaautotextentry.cxx b/sw/source/ui/vba/vbaautotextentry.cxx deleted file mode 100644 index 5c302da869..0000000000 --- a/sw/source/ui/vba/vbaautotextentry.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "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; -using namespace ::com::sun::star; - -SwVbaAutoTextEntry::SwVbaAutoTextEntry( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XAutoTextEntry >& xEntry ) throw ( uno::RuntimeException ) : - SwVbaAutoTextEntry_BASE( rParent, rContext ), mxEntry( xEntry ) -{ -} - -SwVbaAutoTextEntry::~SwVbaAutoTextEntry() -{ -} - -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 ) - { - uno::Reference< text::XTextRange > xTextRange = pWhere->getXTextRange(); - xTextRange->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker - uno::Reference< text::XTextRange > xEndMarker = xTextRange->getEnd(); - xEndMarker->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("x") ) ); // set marker - uno::Reference< text::XText > xText = pWhere->getXText(); - mxEntry->applyTo( xEndMarker->getStart() ); - 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 = xText->createTextCursorByRange( xEndMarker->getEnd() ); - pWhere->setXTextCursor( xTC ); - } - return uno::Reference< word::XRange >( pWhere ); -} - -rtl::OUString& -SwVbaAutoTextEntry::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntry") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaAutoTextEntry::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntry" ) ); - } - return aServiceNames; -} - - -SwVbaAutoTextEntries::SwVbaAutoTextEntries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ) throw (uno::RuntimeException) : SwVbaAutoTextEntries_BASE( xParent, xContext, xIndexAccess ), mxAutoTextEntryAccess( xIndexAccess ) -{ -} - -// XEnumerationAccess -uno::Type -SwVbaAutoTextEntries::getElementType() throw (uno::RuntimeException) -{ - return word::XAutoTextEntry::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaAutoTextEntries::createEnumeration() throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -uno::Any -SwVbaAutoTextEntries::createCollectionObject( const css::uno::Any& aSource ) -{ - uno::Reference< text::XAutoTextEntry > xEntry( aSource, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XAutoTextEntry >( new SwVbaAutoTextEntry( this, mxContext, xEntry ) ) ); -} - -rtl::OUString& -SwVbaAutoTextEntries::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaAutoTextEntries") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaAutoTextEntries::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.AutoTextEntries") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaautotextentry.hxx b/sw/source/ui/vba/vbaautotextentry.hxx deleted file mode 100644 index c37a62f8ca..0000000000 --- a/sw/source/ui/vba/vbaautotextentry.hxx +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_AUTOTEXTENTRY_HXX -#define SW_VBA_AUTOTEXTENTRY_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XAutoTextEntries.hpp> -#include <ooo/vba/word/XAutoTextEntry.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/word/XRange.hpp> -#include <com/sun/star/text/XAutoTextEntry.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XAutoTextEntry > SwVbaAutoTextEntry_BASE; - -class SwVbaAutoTextEntry : public SwVbaAutoTextEntry_BASE -{ -private: - css::uno::Reference< css::text::XAutoTextEntry > mxEntry; - -public: - SwVbaAutoTextEntry( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XAutoTextEntry >& xEntry ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaAutoTextEntry(); - - // XAutoTextEntry - virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL Insert( const css::uno::Reference< ooo::vba::word::XRange >& _where, const css::uno::Any& _richtext ) throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - - -/* class SwVbaAutoTextEntries */ -typedef CollTestImplHelper< ooo::vba::word::XAutoTextEntries > SwVbaAutoTextEntries_BASE; - -class SwVbaAutoTextEntries : public SwVbaAutoTextEntries_BASE -{ -private: - css::uno::Reference< css::container::XIndexAccess > mxAutoTextEntryAccess; - -public: - SwVbaAutoTextEntries( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ) throw (css::uno::RuntimeException); - virtual ~SwVbaAutoTextEntries() {} - - // 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); - - // SwVbaAutoTextEntries_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_AUTOTEXTENTRY_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbabookmark.cxx b/sw/source/ui/vba/vbabookmark.cxx deleted file mode 100644 index e580f946ef..0000000000 --- a/sw/source/ui/vba/vbabookmark.cxx +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbabookmark.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextContent.hpp> -#include <com/sun/star/text/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; - -SwVbaBookmark::SwVbaBookmark( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, - const css::uno::Reference< frame::XModel >& rModel, const rtl::OUString& rName ) throw ( css::uno::RuntimeException ) : - SwVbaBookmark_BASE( rParent, rContext ), mxModel( rModel ), maName( rName ), mbValid( sal_True ) -{ - uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( mxModel, uno::UNO_QUERY_THROW ); - mxBookmark.set( xBookmarksSupplier->getBookmarks()->getByName( maName ), uno::UNO_QUERY_THROW ); -} - -SwVbaBookmark::~SwVbaBookmark() -{ -} - -void SwVbaBookmark::checkVality() throw ( uno::RuntimeException ) -{ - if( !mbValid ) - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("The bookmark is not valid" ) ), uno::Reference< uno::XInterface >() ); -} - -void SAL_CALL SwVbaBookmark::Delete() throw ( uno::RuntimeException ) -{ - checkVality(); - uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); - xTextDocument->getText()->removeTextContent( mxBookmark ); - mbValid = sal_False; -} - -void SAL_CALL SwVbaBookmark::Select() throw ( uno::RuntimeException ) -{ - checkVality(); - 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 ) -{ - return maName; -} - -void SAL_CALL SwVbaBookmark::setName( const rtl::OUString& _name ) throw ( uno::RuntimeException ) -{ - uno::Reference< container::XNamed > xNamed( mxBookmark, uno::UNO_QUERY_THROW ); - xNamed->setName( _name ); -} - -uno::Any SAL_CALL SwVbaBookmark::Range() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextContent > xTextContent( mxBookmark, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextRange > xTextRange( xTextContent->getAnchor(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XRange>( new SwVbaRange( this, mxContext, xTextDocument, xTextRange->getStart(), xTextRange->getEnd(), xTextRange->getText() ) ) ); -} - -rtl::OUString& -SwVbaBookmark::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBookmark") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaBookmark::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Bookmark" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbabookmark.hxx b/sw/source/ui/vba/vbabookmark.hxx deleted file mode 100644 index 4c17749a5f..0000000000 --- a/sw/source/ui/vba/vbabookmark.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_BOOKMARK_HXX -#define SW_VBA_BOOKMARK_HXX - -#include <ooo/vba/word/XBookmark.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XBookmarksSupplier.hpp> -#include <com/sun/star/text/XTextContent.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XBookmark > SwVbaBookmark_BASE; - -class SwVbaBookmark : public SwVbaBookmark_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextContent > mxBookmark; - rtl::OUString maName; - sal_Bool mbValid; - -private: - void checkVality() throw ( css::uno::RuntimeException ); - -public: - SwVbaBookmark( 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& rName ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaBookmark(); - - // Methods - virtual rtl::OUString SAL_CALL getName() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL setName( const rtl::OUString& ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL Delete() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL Select() throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL Range() throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_BOOKMARK_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbabookmarks.cxx b/sw/source/ui/vba/vbabookmarks.cxx deleted file mode 100644 index 9c45b8f193..0000000000 --- a/sw/source/ui/vba/vbabookmarks.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbabookmarks.hxx" -#include "vbabookmark.hxx" -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <ooo/vba/word/WdBookmarkSortBy.hpp> -#include "vbarange.hxx" -#include "wordvbahelper.hxx" -#include <cppuhelper/implbase2.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class BookmarksEnumeration : public EnumerationHelperImpl -{ - uno::Reference< frame::XModel > mxModel; -public: - BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel ) {} - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - uno::Reference< container::XNamed > xNamed( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - rtl::OUString aName = xNamed->getName(); - return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( m_xParent, m_xContext, mxModel, aName ) ) ); - } - -}; - -// Bookmarks use case-insensitive name lookup in MS Word. -typedef ::cppu::WeakImplHelper2< container::XNameAccess, container::XIndexAccess > BookmarkCollectionHelper_BASE; -class BookmarkCollectionHelper : public BookmarkCollectionHelper_BASE -{ -private: - uno::Reference< container::XNameAccess > mxNameAccess; - uno::Reference< container::XIndexAccess > mxIndexAccess; - uno::Any cachePos; -public: - BookmarkCollectionHelper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) throw (uno::RuntimeException) : mxIndexAccess( xIndexAccess ) - { - mxNameAccess.set( mxIndexAccess, uno::UNO_QUERY_THROW ); - } - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return mxIndexAccess->getElementType(); } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return mxIndexAccess->hasElements(); } - // XNameAcess - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasByName(aName) ) - throw container::NoSuchElementException(); - return cachePos; - } - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - return mxNameAccess->getElementNames(); - } - virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) - { - if( mxNameAccess->hasByName( aName ) ) - { - cachePos = mxNameAccess->getByName( aName ); - return sal_True; - } - else - { - for( sal_Int32 nIndex = 0; nIndex < mxIndexAccess->getCount(); nIndex++ ) - { - uno::Reference< container::XNamed > xNamed( mxIndexAccess->getByIndex( nIndex ), uno::UNO_QUERY_THROW ); - rtl::OUString aBookmarkName = xNamed->getName(); - if( aName.equalsIgnoreAsciiCase( aBookmarkName ) ) - { - cachePos <<= xNamed; - return sal_True; - } - } - } - return sal_False; - } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return mxIndexAccess->getCount(); - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) - { - return mxIndexAccess->getByIndex( Index ); - } -}; - -SwVbaBookmarks::SwVbaBookmarks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xBookmarks, const uno::Reference< frame::XModel >& xModel ): SwVbaBookmarks_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BookmarkCollectionHelper( xBookmarks ) ) ), mxModel( xModel ) -{ - mxBookmarksSupplier.set( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW ); -} -// XEnumerationAccess -uno::Type -SwVbaBookmarks::getElementType() throw (uno::RuntimeException) -{ - return word::XBookmark::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaBookmarks::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new BookmarksEnumeration( getParent(), mxContext,xEnumAccess->createEnumeration(), mxModel ); -} - -uno::Any -SwVbaBookmarks::createCollectionObject( const css::uno::Any& aSource ) -{ - uno::Reference< container::XNamed > xNamed( aSource, uno::UNO_QUERY_THROW ); - rtl::OUString aName = xNamed->getName(); - return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( getParent(), mxContext, mxModel, aName ) ) ); -} - -void SwVbaBookmarks::removeBookmarkByName( const rtl::OUString& rName ) throw (uno::RuntimeException) -{ - uno::Reference< text::XTextContent > xBookmark( m_xNameAccess->getByName( rName ), uno::UNO_QUERY_THROW ); - word::getXTextViewCursor( mxModel )->getText()->removeTextContent( xBookmark ); -} - -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( 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 ); - rTextRange->getText()->insertTextContent( rTextRange, xBookmark, sal_False ); -} - -uno::Any SAL_CALL -SwVbaBookmarks::Add( const rtl::OUString& rName, const uno::Any& rRange ) throw (uno::RuntimeException) -{ - uno::Reference< text::XTextRange > xTextRange; - uno::Reference< word::XRange > xRange; - if( rRange >>= xRange ) - { - SwVbaRange* pRange = dynamic_cast< SwVbaRange* >( xRange.get() ); - if( pRange ) - xTextRange = pRange->getXTextRange(); - } - else - { - // FIXME: insert the bookmark into current view cursor - xTextRange.set( word::getXTextViewCursor( mxModel ), uno::UNO_QUERY_THROW ); - } - - // remove the exist bookmark - rtl::OUString aName = rName; - if( m_xNameAccess->hasByName( aName ) ) - removeBookmarkByName( aName ); - - addBookmarkByName( mxModel, aName, xTextRange ); - - return uno::makeAny( uno::Reference< word::XBookmark >( new SwVbaBookmark( getParent(), mxContext, mxModel, aName ) ) ); -} - -sal_Int32 SAL_CALL -SwVbaBookmarks::getDefaultSorting() throw (css::uno::RuntimeException) -{ - return word::WdBookmarkSortBy::wdSortByName; -} - -void SAL_CALL -SwVbaBookmarks::setDefaultSorting( sal_Int32/* _type*/ ) throw (css::uno::RuntimeException) -{ - // not support in Writer -} - -sal_Bool SAL_CALL -SwVbaBookmarks::getShowHidden() throw (css::uno::RuntimeException) -{ - return sal_True; -} - -void SAL_CALL -SwVbaBookmarks::setShowHidden( sal_Bool /*_hidden*/ ) throw (css::uno::RuntimeException) -{ - // not support in Writer -} - -sal_Bool SAL_CALL -SwVbaBookmarks::Exists( const rtl::OUString& rName ) throw (css::uno::RuntimeException) -{ - sal_Bool bExist = m_xNameAccess->hasByName( rName ); - return bExist; -} - -rtl::OUString& -SwVbaBookmarks::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBookmarks") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaBookmarks::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Bookmarks") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbabookmarks.hxx b/sw/source/ui/vba/vbabookmarks.hxx deleted file mode 100644 index 606f57b043..0000000000 --- a/sw/source/ui/vba/vbabookmarks.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_BOOKMARKS_HXX -#define SW_VBA_BOOKMARKS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XBookmarks.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XBookmarksSupplier.hpp> -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XText.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XBookmarks > SwVbaBookmarks_BASE; - -class SwVbaBookmarks : public SwVbaBookmarks_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XBookmarksSupplier > mxBookmarksSupplier; - css::uno::Reference< css::text::XText > mxText; - -private: - void removeBookmarkByName( const rtl::OUString& rName ) 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); - - // SwVbaBookmarks_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - - // XBookmarks - virtual sal_Int32 SAL_CALL getDefaultSorting() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDefaultSorting( sal_Int32 _type ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getShowHidden() throw (css::uno::RuntimeException); - virtual void SAL_CALL setShowHidden( sal_Bool _hidden ) throw (css::uno::RuntimeException); - - virtual css::uno::Any SAL_CALL Add( const rtl::OUString& rName, const css::uno::Any& rRange ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL Exists( const rtl::OUString& rName ) throw (css::uno::RuntimeException); -}; - -#endif /* SW_VBA_BOOKMARKS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaborders.cxx b/sw/source/ui/vba/vbaborders.cxx deleted file mode 100644 index 26d5a6bf18..0000000000 --- a/sw/source/ui/vba/vbaborders.cxx +++ /dev/null @@ -1,382 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaborders.hxx" -#include <ooo/vba/word/XBorder.hpp> -#include <ooo/vba/word/WdBorderType.hpp> -#include <ooo/vba/word/WdLineStyle.hpp> -#include <sal/macros.h> -#include <cppuhelper/implbase3.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/table/TableBorder.hpp> -#include <com/sun/star/table/ShadowFormat.hpp> -#include <com/sun/star/table/ShadowLocation.hpp> -#include "vbapalette.hxx" - -using namespace ::com::sun::star; -using namespace ::ooo::vba; - - -typedef ::cppu::WeakImplHelper1<container::XIndexAccess > RangeBorders_Base; -typedef InheritedHelperInterfaceImpl1<word::XBorder > SwVbaBorder_Base; - -// #TODO sort these indexes to match the order in which Word iterates over the -// borders, the enumeration will match the order in this list -static const sal_Int16 supportedIndexTable[] = { word::WdBorderType::wdBorderBottom, word::WdBorderType::wdBorderDiagonalDown, word::WdBorderType::wdBorderDiagonalUp, word::WdBorderType::wdBorderHorizontal, word::WdBorderType::wdBorderLeft, word::WdBorderType::wdBorderRight, word::WdBorderType::wdBorderTop, word::WdBorderType::wdBorderVertical }; - -const static rtl::OUString sTableBorder( RTL_CONSTASCII_USTRINGPARAM("TableBorder") ); - -// Equiv widths in in 1/100 mm -const static sal_Int32 OOLineThin = 35; -const static sal_Int32 OOLineMedium = 88; -const static sal_Int32 OOLineThick = 141; -const static sal_Int32 OOLineHairline = 2; - -class SwVbaBorder : public SwVbaBorder_Base -{ -private: - uno::Reference< beans::XPropertySet > m_xProps; - sal_Int32 m_LineType; - VbaPalette m_Palette; - bool setBorderLine( table::BorderLine& rBorderLine ) - { - table::TableBorder aTableBorder; - m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder; - - switch ( m_LineType ) - { - case word::WdBorderType::wdBorderLeft: - aTableBorder.IsLeftLineValid = sal_True; - aTableBorder.LeftLine= rBorderLine; - break; - case word::WdBorderType::wdBorderTop: - aTableBorder.IsTopLineValid = sal_True; - aTableBorder.TopLine = rBorderLine; - break; - - case word::WdBorderType::wdBorderBottom: - aTableBorder.IsBottomLineValid = sal_True; - aTableBorder.BottomLine = rBorderLine; - break; - case word::WdBorderType::wdBorderRight: - aTableBorder.IsRightLineValid = sal_True; - aTableBorder.RightLine = rBorderLine; - break; - case word::WdBorderType::wdBorderVertical: - aTableBorder.IsVerticalLineValid = sal_True; - aTableBorder.VerticalLine = rBorderLine; - break; - case word::WdBorderType::wdBorderHorizontal: - aTableBorder.IsHorizontalLineValid = sal_True; - aTableBorder.HorizontalLine = rBorderLine; - break; - case word::WdBorderType::wdBorderDiagonalDown: - case word::WdBorderType::wdBorderDiagonalUp: - // #TODO have to ignore at the momement, would be - // nice to investigate what we can do here - break; - default: - return false; - } - m_xProps->setPropertyValue( sTableBorder, uno::makeAny(aTableBorder) ); - return true; - } - - bool getBorderLine( table::BorderLine& rBorderLine ) - { - table::TableBorder aTableBorder; - m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder; - switch ( m_LineType ) - { - case word::WdBorderType::wdBorderLeft: - if ( aTableBorder.IsLeftLineValid ) - rBorderLine = aTableBorder.LeftLine; - break; - case word::WdBorderType::wdBorderTop: - if ( aTableBorder.IsTopLineValid ) - rBorderLine = aTableBorder.TopLine; - break; - case word::WdBorderType::wdBorderBottom: - if ( aTableBorder.IsBottomLineValid ) - rBorderLine = aTableBorder.BottomLine; - break; - case word::WdBorderType::wdBorderRight: - if ( aTableBorder.IsRightLineValid ) - rBorderLine = aTableBorder.RightLine; - break; - case word::WdBorderType::wdBorderVertical: - if ( aTableBorder.IsVerticalLineValid ) - rBorderLine = aTableBorder.VerticalLine; - break; - case word::WdBorderType::wdBorderHorizontal: - if ( aTableBorder.IsHorizontalLineValid ) - rBorderLine = aTableBorder.HorizontalLine; - break; - - case word::WdBorderType::wdBorderDiagonalDown: - case word::WdBorderType::wdBorderDiagonalUp: - // #TODO have to ignore at the momement, would be - // nice to investigate what we can do here - break; - default: - return false; - } - return true; - } - SwVbaBorder(); // no impl -protected: - virtual rtl::OUString& getServiceImplName() - { - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBorder") ); - return sImplName; - } - virtual css::uno::Sequence<rtl::OUString> getServiceNames() - { - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Border" ) ); - } - return aServiceNames; - } -public: - SwVbaBorder( const uno::Reference< beans::XPropertySet > & xProps, const uno::Reference< uno::XComponentContext >& xContext, sal_Int32 lineType, VbaPalette& rPalette) : SwVbaBorder_Base( uno::Reference< XHelperInterface >( xProps, uno::UNO_QUERY ), xContext ), m_xProps( xProps ), m_LineType( lineType ), m_Palette( rPalette ) {} - - uno::Any SAL_CALL getLineStyle() throw (uno::RuntimeException) - { - sal_Int32 nLineStyle = word::WdLineStyle::wdLineStyleNone; - table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) - { - if( aBorderLine.InnerLineWidth !=0 && aBorderLine.OuterLineWidth !=0 ) - { - nLineStyle = word::WdLineStyle::wdLineStyleDouble; - } - else if( aBorderLine.InnerLineWidth !=0 || aBorderLine.OuterLineWidth !=0 ) - { - nLineStyle = word::WdLineStyle::wdLineStyleSingle; - } - else - { - nLineStyle = word::WdLineStyle::wdLineStyleNone; - } - } - return uno::makeAny( nLineStyle ); - } - void SAL_CALL setLineStyle( const uno::Any& _linestyle ) throw (uno::RuntimeException) - { - // Urk no choice but to silently ignore we don't support this attribute - // #TODO would be nice to support the word line styles - sal_Int32 nLineStyle = 0; - _linestyle >>= nLineStyle; - table::BorderLine aBorderLine; - if ( getBorderLine( aBorderLine ) ) - { - switch ( nLineStyle ) - { - case word::WdLineStyle::wdLineStyleNone: - { - aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = 0; - break; - } - case word::WdLineStyle::wdLineStyleDashDot: - case word::WdLineStyle::wdLineStyleDashDotDot: - case word::WdLineStyle::wdLineStyleDashDotStroked: - case word::WdLineStyle::wdLineStyleDashLargeGap: - case word::WdLineStyle::wdLineStyleDashSmallGap: - case word::WdLineStyle::wdLineStyleDot: - case word::WdLineStyle::wdLineStyleDouble: - case word::WdLineStyle::wdLineStyleDoubleWavy: - case word::WdLineStyle::wdLineStyleEmboss3D: - case word::WdLineStyle::wdLineStyleEngrave3D: - case word::WdLineStyle::wdLineStyleInset: - case word::WdLineStyle::wdLineStyleOutset: - case word::WdLineStyle::wdLineStyleSingle: - case word::WdLineStyle::wdLineStyleSingleWavy: - case word::WdLineStyle::wdLineStyleThickThinLargeGap: - case word::WdLineStyle::wdLineStyleThickThinMedGap: - case word::WdLineStyle::wdLineStyleThickThinSmallGap: - case word::WdLineStyle::wdLineStyleThinThickLargeGap: - case word::WdLineStyle::wdLineStyleThinThickMedGap: - case word::WdLineStyle::wdLineStyleThinThickSmallGap: - case word::WdLineStyle::wdLineStyleThinThickThinLargeGap: - case word::WdLineStyle::wdLineStyleThinThickThinMedGap: - case word::WdLineStyle::wdLineStyleThinThickThinSmallGap: - case word::WdLineStyle::wdLineStyleTriple: - { - aBorderLine.InnerLineWidth = 0; - aBorderLine.OuterLineWidth = OOLineHairline; - break; - } - default: - throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Bad param" ) ), uno::Reference< uno::XInterface >() ); - } - setBorderLine( aBorderLine ); - } - else - throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Method failed" ) ), uno::Reference< uno::XInterface >() ); - } -}; - -class RangeBorders : public RangeBorders_Base -{ -private: - uno::Reference< table::XCellRange > m_xRange; - uno::Reference< uno::XComponentContext > m_xContext; - VbaPalette m_Palette; - sal_Int32 getTableIndex( sal_Int32 nConst ) - { - // hokay return position of the index in the table - sal_Int32 nIndexes = getCount(); - sal_Int32 realIndex = 0; - const sal_Int16* pTableEntry = supportedIndexTable; - for ( ; realIndex < nIndexes; ++realIndex, ++pTableEntry ) - { - if ( *pTableEntry == nConst ) - return realIndex; - } - return getCount(); // error condition - } -public: - RangeBorders( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< uno::XComponentContext > & xContext, VbaPalette& rPalette ) : m_xRange( xRange ), m_xContext( xContext ), m_Palette( rPalette ) - { - } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return SAL_N_ELEMENTS( supportedIndexTable ); - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - - sal_Int32 nIndex = getTableIndex( Index ); - if ( nIndex >= 0 && nIndex < getCount() ) - { - uno::Reference< beans::XPropertySet > xProps( m_xRange, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XBorder >( new SwVbaBorder( xProps, m_xContext, supportedIndexTable[ nIndex ], m_Palette )) ); - } - throw lang::IndexOutOfBoundsException(); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XBorder::static_type(0); - } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } -}; - -uno::Reference< container::XIndexAccess > -rangeToBorderIndexAccess( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< uno::XComponentContext > & xContext, VbaPalette& rPalette ) -{ - return new RangeBorders( xRange, xContext, rPalette ); -} - -class RangeBorderEnumWrapper : public EnumerationHelper_BASE -{ - uno::Reference<container::XIndexAccess > m_xIndexAccess; - sal_Int32 nIndex; -public: - RangeBorderEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < m_xIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex < m_xIndexAccess->getCount() ) - return m_xIndexAccess->getByIndex( nIndex++ ); - throw container::NoSuchElementException(); - } -}; - -// for Table borders -SwVbaBorders::SwVbaBorders( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< table::XCellRange >& xRange, VbaPalette& rPalette ): SwVbaBorders_BASE( xParent, xContext, rangeToBorderIndexAccess( xRange ,xContext, rPalette ) ) -{ - m_xProps.set( xRange, uno::UNO_QUERY_THROW ); -} - -uno::Reference< container::XEnumeration > -SwVbaBorders::createEnumeration() throw (uno::RuntimeException) -{ - return new RangeBorderEnumWrapper( m_xIndexAccess ); -} - -uno::Any -SwVbaBorders::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; // its already a Border object -} - -uno::Type -SwVbaBorders::getElementType() throw (uno::RuntimeException) -{ - return word::XBorders::static_type(0); -} - -uno::Any -SwVbaBorders::getItemByIntIndex( const sal_Int32 nIndex ) throw (uno::RuntimeException) -{ - return createCollectionObject( m_xIndexAccess->getByIndex( nIndex ) ); -} - -sal_Bool SAL_CALL SwVbaBorders::getShadow() throw (uno::RuntimeException) -{ - // always return False for table border in MS Word - return sal_False; -} - -void SAL_CALL SwVbaBorders::setShadow( sal_Bool /*_shadow*/ ) throw (uno::RuntimeException) -{ - // not support in Table border in Word - // TODO: -} - -rtl::OUString& -SwVbaBorders::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBorders") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaBorders::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Borders" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaborders.hxx b/sw/source/ui/vba/vbaborders.hxx deleted file mode 100644 index 17f4fe5f6d..0000000000 --- a/sw/source/ui/vba/vbaborders.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_BORDERS_HXX -#define SW_VBA_BORDERS_HXX - -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/word/XBorders.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/table/XCellRange.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <vbahelper/vbacollectionimpl.hxx> - -typedef CollTestImplHelper< ov::word::XBorders > SwVbaBorders_BASE; -class VbaPalette; -class SwVbaBorders : public SwVbaBorders_BASE -{ - // XEnumerationAccess - virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException); - css::uno::Reference< css::beans::XPropertySet > m_xProps; -public: - SwVbaBorders( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::table::XCellRange >& xRange, VbaPalette& rPalette ); - virtual ~SwVbaBorders() {} - - // 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); - - // SwVbaCollectionBaseImpl - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - - virtual sal_Bool SAL_CALL getShadow() throw (css::uno::RuntimeException); - virtual void SAL_CALL setShadow( sal_Bool _shadow ) throw (css::uno::RuntimeException); - - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif //SW_VBA_BORDERS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacell.cxx b/sw/source/ui/vba/vbacell.cxx deleted file mode 100644 index 2aada3408a..0000000000 --- a/sw/source/ui/vba/vbacell.cxx +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbacell.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbatable.hxx" -#include <com/sun/star/table/XCellRange.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <rtl/ustrbuf.hxx> -#include "wordvbahelper.hxx" -#include "vbatablehelper.hxx" -#include "vbarow.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaCell::SwVbaCell( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nColumn, sal_Int32 nRow ) throw ( uno::RuntimeException ) : - SwVbaCell_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnColumn( nColumn ), mnRow( nRow ) -{ -} - -SwVbaCell::~SwVbaCell() -{ -} - -::sal_Int32 SAL_CALL SwVbaCell::getWidth() throw (css::uno::RuntimeException) -{ - SwVbaTableHelper aTableHelper( mxTextTable ); - return aTableHelper.GetColWidth( mnColumn, mnRow, sal_True ); -} - -void SAL_CALL SwVbaCell::setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException) -{ - SwVbaTableHelper aTableHelper( mxTextTable ); - aTableHelper.SetColWidth( _width, mnColumn, mnRow, sal_True ); -} - -uno::Any SAL_CALL SwVbaCell::getHeight() throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) ); - return xRow->getHeight(); -} - -void SAL_CALL SwVbaCell::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) ); - xRow->setHeight( _height ); -} - -::sal_Int32 SAL_CALL SwVbaCell::getHeightRule() throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) ); - return xRow->getHeightRule(); -} - -void SAL_CALL SwVbaCell::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnRow ) ); - xRow->setHeightRule( _heightrule ); -} - -void SAL_CALL SwVbaCell::SetWidth( float width, sal_Int32 /*rulestyle*/ ) throw (css::uno::RuntimeException) -{ - // FIXME: handle the argument: rulestyle - setWidth( static_cast<sal_Int32>(width) ); -} - -void SAL_CALL SwVbaCell::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException) -{ - // FIXME: handle the argument: heightrule - setHeightRule( heightrule ); - setHeight( uno::makeAny( height ) ); -} - -rtl::OUString& -SwVbaCell::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCell") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaCell::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Cell" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacell.hxx b/sw/source/ui/vba/vbacell.hxx deleted file mode 100644 index 1e26b79440..0000000000 --- a/sw/source/ui/vba/vbacell.hxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_CELL_HXX -#define SW_VBA_CELL_HXX - -#include <ooo/vba/word/XCell.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextTable.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XCell > SwVbaCell_BASE; - -class SwVbaCell : public SwVbaCell_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - sal_Int32 mnColumn; - sal_Int32 mnRow; - -public: - SwVbaCell( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nColumn, sal_Int32 nRow ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaCell(); - - // Attributes - virtual ::sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException); - virtual void SAL_CALL setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException); - - // Methods - virtual void SAL_CALL SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException); - virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_CELL_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacells.cxx b/sw/source/ui/vba/vbacells.cxx deleted file mode 100644 index a104ea29c1..0000000000 --- a/sw/source/ui/vba/vbacells.cxx +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbacells.hxx" -#include "vbacell.hxx" -#include "wordvbahelper.hxx" -#include "vbatablehelper.hxx" -#include "vbarow.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > CellCollectionHelper_Base; - -class CellsEnumWrapper : public EnumerationHelper_BASE -{ - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 nIndex; - -public: - CellsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 ) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if( nIndex < mxIndexAccess->getCount() ) - { - return mxIndexAccess->getByIndex( nIndex++ ); - } - throw container::NoSuchElementException(); - } -}; - -class CellCollectionHelper : public CellCollectionHelper_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< css::text::XTextTable > mxTextTable; - sal_Int32 mnLeft; - sal_Int32 mnTop; - sal_Int32 mnRight; - sal_Int32 mnBottom; - -public: - CellCollectionHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw ( css::uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), mnLeft( nLeft ), mnTop( nTop ), mnRight( nRight ), mnBottom( nBottom ) - { - } - virtual ~CellCollectionHelper() {} - - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return ( mnRight - mnLeft + 1 ) * ( mnBottom - mnTop + 1 ); - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 || Index >= getCount() ) - throw css::lang::IndexOutOfBoundsException(); - - for( sal_Int32 row = mnTop; row <= mnBottom; row++ ) - { - for( sal_Int32 col = mnLeft; col <= mnRight; col++ ) - { - if( Index == ( ( row - mnTop ) * ( mnRight - mnLeft + 1 ) + ( col - mnLeft ) ) ) - return uno::makeAny( uno::Reference< word::XCell >( new SwVbaCell( mxParent, mxContext, mxTextTable, col, row ) ) ); - } - } - throw css::lang::IndexOutOfBoundsException(); - - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XCell::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new CellsEnumWrapper( this ); - } -}; - -SwVbaCells::SwVbaCells( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (uno::RuntimeException) : SwVbaCells_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new CellCollectionHelper( xParent, xContext, xTextTable, nLeft, nTop, nRight, nBottom ) ) ), mxTextTable( xTextTable ), mnLeft( nLeft ), mnTop( nTop ), mnRight( nRight ), mnBottom( nBottom ) -{ -} - -::sal_Int32 SAL_CALL SwVbaCells::getWidth() throw (css::uno::RuntimeException) -{ - uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( 0 ), uno::UNO_QUERY_THROW ); - return xCell->getWidth(); -} - -void SAL_CALL SwVbaCells::setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - while( nIndex < m_xIndexAccess->getCount() ) - { - uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW ); - xCell->setWidth( _width ); - } -} - -uno::Any SAL_CALL SwVbaCells::getHeight() throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) ); - return xRow->getHeight(); -} - -void SAL_CALL SwVbaCells::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException) -{ - for( sal_Int32 row = mnTop; row <= mnBottom; row++ ) - { - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) ); - xRow->setHeight( _height ); - } -} - -::sal_Int32 SAL_CALL SwVbaCells::getHeightRule() throw (css::uno::RuntimeException) -{ - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, mnTop ) ); - return xRow->getHeightRule(); -} - -void SAL_CALL SwVbaCells::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException) -{ - for( sal_Int32 row = mnTop; row <= mnBottom; row++ ) - { - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) ); - xRow->setHeightRule( _heightrule ); - } -} - -void SAL_CALL SwVbaCells::SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - while( nIndex < m_xIndexAccess->getCount() ) - { - uno::Reference< word::XCell > xCell( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW ); - xCell->SetWidth( width, rulestyle ); - } -} - -void SAL_CALL SwVbaCells::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException) -{ - for( sal_Int32 row = mnTop; row <= mnBottom; row++ ) - { - uno::Reference< word::XRow > xRow( new SwVbaRow( getParent(), mxContext, mxTextTable, row ) ); - xRow->SetHeight( height, heightrule ); - } -} - -// XEnumerationAccess -uno::Type -SwVbaCells::getElementType() throw (uno::RuntimeException) -{ - return word::XCell::static_type(0); -} - -uno::Reference< container::XEnumeration > -SwVbaCells::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumAccess->createEnumeration(); -} - -uno::Any -SwVbaCells::createCollectionObject( const uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaCells::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCells") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaCells::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Cells") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacells.hxx b/sw/source/ui/vba/vbacells.hxx deleted file mode 100644 index e3fe940aa2..0000000000 --- a/sw/source/ui/vba/vbacells.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_CELLS_HXX -#define SW_VBA_CELLS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XCells.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextTable.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XCells > SwVbaCells_BASE; - -class SwVbaCells : public SwVbaCells_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - sal_Int32 mnLeft; - sal_Int32 mnTop; - sal_Int32 mnRight; - sal_Int32 mnBottom; - -public: - SwVbaCells( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaCells() {} - - // Attributes - virtual ::sal_Int32 SAL_CALL getWidth() throw (css::uno::RuntimeException); - virtual void SAL_CALL setWidth( ::sal_Int32 _width ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException); - - // Methods - virtual void SAL_CALL SetWidth( float width, sal_Int32 rulestyle ) throw (css::uno::RuntimeException); - virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException); - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaCells_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_CELLS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacheckbox.cxx b/sw/source/ui/vba/vbacheckbox.cxx deleted file mode 100644 index 65b55a3142..0000000000 --- a/sw/source/ui/vba/vbacheckbox.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbacheckbox.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextContent.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <ecmaflds.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaCheckBox::SwVbaCheckBox( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& rModel, const uno::Reference< text::XFormField >& xFormField ) throw ( uno::RuntimeException ) : SwVbaCheckBox_BASE( rParent, rContext ), mxModel( rModel ), mxFormField( xFormField ) -{ - rtl::OUString sType = mxFormField->getFieldType(); - if( !sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) ) - { - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("It is not a CheckBox")), uno::Reference< uno::XInterface >() ); - } -} - -SwVbaCheckBox::~SwVbaCheckBox() -{ -} - -sal_Bool SAL_CALL SwVbaCheckBox::getValue() throw ( uno::RuntimeException ) -{ - sal_Bool bValue = sal_False; - sal_Int32 nCount = mxFormField->getParamCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - if( mxFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX_CHECKED ) ) - { - if( mxFormField->getParamValue(i).equalsIgnoreAsciiCaseAscii("on") ) - bValue = sal_True; - else - bValue = sal_False; - break; - } - } - return bValue; -} - -void SAL_CALL SwVbaCheckBox::setValue( sal_Bool value ) throw ( uno::RuntimeException ) -{ - rtl::OUString sValue = value ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("on")) : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("off")); - mxFormField->addParam( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ECMA_FORMCHECKBOX_CHECKED )), sValue, sal_True ); -} - -rtl::OUString& -SwVbaCheckBox::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCheckBox") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaCheckBox::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.CheckBox" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacheckbox.hxx b/sw/source/ui/vba/vbacheckbox.hxx deleted file mode 100644 index e8e4da8e2e..0000000000 --- a/sw/source/ui/vba/vbacheckbox.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_CHECKBOX_HXX -#define SW_VBA_CHECKBOX_HXX - -#include <ooo/vba/word/XCheckBox.hpp> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XFormField.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XCheckBox > SwVbaCheckBox_BASE; - -class SwVbaCheckBox : public SwVbaCheckBox_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XFormField > mxFormField; - -public: - SwVbaCheckBox( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XFormField >& xFormField ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaCheckBox(); - - // Methods - sal_Bool SAL_CALL getValue() throw ( css::uno::RuntimeException ); - void SAL_CALL setValue( sal_Bool value ) throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_CHECKBOX_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacolumn.cxx b/sw/source/ui/vba/vbacolumn.cxx deleted file mode 100644 index 86b2f27dae..0000000000 --- a/sw/source/ui/vba/vbacolumn.cxx +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbacolumn.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbatable.hxx" -#include <com/sun/star/table/XCellRange.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <rtl/ustrbuf.hxx> -#include "wordvbahelper.hxx" -#include "vbatablehelper.hxx" - -#define RELATIVE_TABLE_WIDTH 10000 - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaColumn::SwVbaColumn( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( uno::RuntimeException ) : - SwVbaColumn_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex ) -{ - mxTableColumns = mxTextTable->getColumns(); -} - -SwVbaColumn::~SwVbaColumn() -{ -} - -void SwVbaColumn::calculateAbsoluteColumnWidth( sal_Int32 nTableWidth, const css::uno::Sequence< css::text::TableColumnSeparator >& aSeparators, double* pAbsWidth ) -{ - const text::TableColumnSeparator* pArray = aSeparators.getConstArray(); - sal_Int32 nSepCount = aSeparators.getLength(); - for( sal_Int32 i = 0; i <= nSepCount; i++ ) - { - sal_Int32 nRelColWidth = 0; - if( i == 0 ) - { - if( nSepCount != 0 ) - { - nRelColWidth = pArray[0].Position; - } - else - { - nRelColWidth = RELATIVE_TABLE_WIDTH; - } - } - else - { - if( i == nSepCount ) - { - nRelColWidth = RELATIVE_TABLE_WIDTH - pArray[i-1].Position; - } - else - { - nRelColWidth = pArray[i].Position - pArray[i-1].Position; - } - } - pAbsWidth[i] = ( (double)nRelColWidth / RELATIVE_TABLE_WIDTH ) * (double) nTableWidth; - } -} - -void SwVbaColumn::calculateRelativeColumnWidth( const double* pAbsWidth, double* pRelWidth, sal_Int32 nCount ) -{ - double tableWidth = 0.0; - for( sal_Int32 i = 0; i < nCount; i++ ) - { - tableWidth += pAbsWidth[i]; - } - - pRelWidth[ nCount - 1 ] = tableWidth; - for( sal_Int32 i = 0; i < nCount - 1; i++ ) - { - if( i == 0 ) - { - pRelWidth[i] = ( pAbsWidth[i] * RELATIVE_TABLE_WIDTH ) / tableWidth; - } - else - { - pRelWidth[i] = pRelWidth[i-1] + ( pAbsWidth[i] * RELATIVE_TABLE_WIDTH ) / tableWidth; - } - } -} - -sal_Int32 SAL_CALL -SwVbaColumn::getWidth( ) throw ( css::uno::RuntimeException ) -{ - SwVbaTableHelper aTableHelper( mxTextTable ); - return aTableHelper.GetColWidth( mnIndex ); -} - -void SAL_CALL -SwVbaColumn::setWidth( sal_Int32 _width ) throw ( css::uno::RuntimeException ) -{ - - SwVbaTableHelper aTableHelper( mxTextTable ); - aTableHelper.SetColWidth( _width, mnIndex ); -} - -void SAL_CALL -SwVbaColumn::Select( ) throw ( uno::RuntimeException ) -{ - SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex ); -} - -void SwVbaColumn::SelectColumn( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) throw ( uno::RuntimeException ) -{ - rtl::OUStringBuffer aRangeName; - rtl::OUString sStartCol = SwVbaTableHelper::getColumnStr( nStartColumn ); - aRangeName.append(sStartCol).append(sal_Int32( 1 ) ); - rtl::OUString sEndCol = SwVbaTableHelper::getColumnStr( nEndColumn ); - sal_Int32 nRowCount = xTextTable->getRows()->getCount(); - aRangeName.appendAscii(":").append( sEndCol ).append( sal_Int32( nRowCount ) ); - - uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW ); - rtl::OUString sSelRange = aRangeName.makeStringAndClear(); - uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( sSelRange ); - - uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - xSelection->select( uno::makeAny( xSelRange ) ); -} - -rtl::OUString& -SwVbaColumn::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaColumn") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaColumn::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Column" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacolumn.hxx b/sw/source/ui/vba/vbacolumn.hxx deleted file mode 100644 index 3ab42d6491..0000000000 --- a/sw/source/ui/vba/vbacolumn.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_COLUMN_HXX -#define SW_VBA_COLUMN_HXX - -#include <ooo/vba/word/XColumn.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/table/XTableColumns.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <com/sun/star/text/TableColumnSeparator.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XColumn > SwVbaColumn_BASE; - -class SwVbaColumn : public SwVbaColumn_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - css::uno::Reference< css::table::XTableColumns > mxTableColumns; - sal_Int32 mnIndex; - -private: - void calculateAbsoluteColumnWidth( sal_Int32 nTableWidth, const css::uno::Sequence< css::text::TableColumnSeparator >& aSeparators, double* pAbsWidth ); - void calculateRelativeColumnWidth( const double* pAbsWidth, double* pRelWidth, sal_Int32 nCount ); - -public: - SwVbaColumn( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaColumn(); - - // Methods - virtual sal_Int32 SAL_CALL getWidth() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL setWidth( sal_Int32 _width ) throw ( css::uno::RuntimeException ); - virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException); - - static void SelectColumn( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartColumn, sal_Int32 nEndColumn ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_COLUMN_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacolumns.cxx b/sw/source/ui/vba/vbacolumns.cxx deleted file mode 100644 index 1d8cc55fc4..0000000000 --- a/sw/source/ui/vba/vbacolumns.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbacolumns.hxx" -#include "vbacolumn.hxx" -#include <com/sun/star/text/HoriOrientation.hpp> -#include <com/sun/star/table/XCellRange.hpp> -#include <ooo/vba/word/WdConstants.hpp> -#include <ooo/vba/word/WdRulerStyle.hpp> -#include "wordvbahelper.hxx" -#include "vbatablehelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class ColumnsEnumWrapper : public EnumerationHelper_BASE -{ - uno::WeakReference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< text::XTextTable > mxTextTable; - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 nIndex; - -public: - ColumnsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 ) - { - mxIndexAccess.set( mxTextTable->getColumns(), uno::UNO_QUERY ); - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if( nIndex < mxIndexAccess->getCount() ) - { - return uno::makeAny( uno::Reference< word::XColumn > ( new SwVbaColumn( mxParent, mxContext, mxTextTable, nIndex++ ) ) ); - } - throw container::NoSuchElementException(); - } -}; - -SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns ) -{ - mnStartColumnIndex = 0; - SwVbaTableHelper aTableHelper( mxTextTable ); - mnEndColumnIndex = aTableHelper.getTabColumnsMaxCount( ) - 1; -} - -SwVbaColumns::SwVbaColumns( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw (uno::RuntimeException) : SwVbaColumns_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableColumns, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableColumns( xTableColumns ), mnStartColumnIndex( nStartCol ), mnEndColumnIndex( nEndCol ) -{ - if( mnEndColumnIndex < mnStartColumnIndex ) - throw uno::RuntimeException(); -} - -uno::Reference< word::XColumn > SwVbaColumns::getColumnAtIndex( sal_Int32 index ) throw (uno::RuntimeException) -{ - return uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, index ) ); -} - -::sal_Int32 SAL_CALL SwVbaColumns::getWidth() throw (uno::RuntimeException) -{ - return getColumnAtIndex( mnStartColumnIndex )->getWidth(); -} - -void SAL_CALL SwVbaColumns::setWidth( ::sal_Int32 _width ) throw (uno::RuntimeException) -{ - for( sal_Int32 index = mnStartColumnIndex; index <= mnEndColumnIndex; index++ ) - { - getColumnAtIndex( index )->setWidth( _width ); - } -} - -void SAL_CALL SwVbaColumns::Select( ) throw (uno::RuntimeException) -{ - SwVbaColumn::SelectColumn( getCurrentWordDoc(mxContext), mxTextTable, mnStartColumnIndex, mnEndColumnIndex ); -} - -::sal_Int32 SAL_CALL SwVbaColumns::getCount() throw (uno::RuntimeException) -{ - return ( mnEndColumnIndex - mnStartColumnIndex + 1 ); -} - -uno::Any SAL_CALL SwVbaColumns::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) == sal_True ) - { - if( nIndex <= 0 || nIndex > getCount() ) - { - throw lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); - } - return uno::makeAny( uno::Reference< word::XColumn >( new SwVbaColumn( this, mxContext, mxTextTable, nIndex - 1 ) ) ); - } - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); -} - -// XEnumerationAccess -uno::Type -SwVbaColumns::getElementType() throw (uno::RuntimeException) -{ - return word::XColumn::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaColumns::createEnumeration() throw (uno::RuntimeException) -{ - return new ColumnsEnumWrapper( this, mxContext, mxTextTable ); -} - -uno::Any -SwVbaColumns::createCollectionObject( const uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaColumns::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaColumns") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaColumns::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Columns") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbacolumns.hxx b/sw/source/ui/vba/vbacolumns.hxx deleted file mode 100644 index f6f14ea098..0000000000 --- a/sw/source/ui/vba/vbacolumns.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_COLUMNS_HXX -#define SW_VBA_COLUMNS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XColumns.hpp> -#include <ooo/vba/word/XColumn.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/table/XTableColumns.hpp> -#include <com/sun/star/text/XTextTable.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XColumns > SwVbaColumns_BASE; - -class SwVbaColumns : public SwVbaColumns_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - css::uno::Reference< css::table::XTableColumns > mxTableColumns; - sal_Int32 mnStartColumnIndex; - sal_Int32 mnEndColumnIndex; - -private: - css::uno::Reference< ooo::vba::word::XColumn > getColumnAtIndex( sal_Int32 index ) throw (css::uno::RuntimeException); - -public: - SwVbaColumns( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, const css::uno::Reference< css::table::XTableColumns >& xTableColumns ) throw ( css::uno::RuntimeException ); - SwVbaColumns( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, const css::uno::Reference< css::table::XTableColumns >& xTableColumns, sal_Int32 nStartCol, sal_Int32 nEndCol ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaColumns() {} - - virtual sal_Int32 SAL_CALL getWidth( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL setWidth( sal_Int32 _width ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException); - - //XCollection - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException ); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaColumns_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_COLUMNS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadialog.cxx b/sw/source/ui/vba/vbadialog.cxx deleted file mode 100644 index adcc464e9e..0000000000 --- a/sw/source/ui/vba/vbadialog.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbadialog.hxx" -#include <ooo/vba/word/WdWordDialog.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -struct WordDialogTable -{ - sal_Int32 wdDialog; - const sal_Char* ooDialog; -}; - -static const WordDialogTable aWordDialogTable[] = -{ - { word::WdWordDialog::wdDialogFileNew, ".uno:NewDoc" }, - { word::WdWordDialog::wdDialogFileOpen, ".uno:Open" }, - { word::WdWordDialog::wdDialogFilePrint, ".uno:Print" }, - { word::WdWordDialog::wdDialogFileSaveAs, ".uno:SaveAs" }, - { 0, 0 } -}; - -rtl::OUString -SwVbaDialog::mapIndexToName( sal_Int32 nIndex ) -{ - for( const WordDialogTable* pTable = aWordDialogTable; pTable != NULL; pTable++ ) - { - if( nIndex == pTable->wdDialog ) - { - return rtl::OUString::createFromAscii( pTable->ooDialog ); - } - } - return rtl::OUString(); -} - -rtl::OUString& -SwVbaDialog::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaDialog") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaDialog::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Dialog" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadialog.hxx b/sw/source/ui/vba/vbadialog.hxx deleted file mode 100644 index f4f8d1b5bd..0000000000 --- a/sw/source/ui/vba/vbadialog.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_DIALOG_HXX -#define SW_VBA_DIALOG_HXX - -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/word/XDialog.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbadialogbase.hxx> - -typedef cppu::ImplInheritanceHelper1< VbaDialogBase, ov::word::XDialog > SwVbaDialog_BASE; - -class SwVbaDialog : public SwVbaDialog_BASE -{ -public: - SwVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):SwVbaDialog_BASE( xParent, xContext, xModel, nIndex ) {} - virtual ~SwVbaDialog() {} - - // Methods - virtual rtl::OUString mapIndexToName( sal_Int32 nIndex ); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_DIALOG_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadialogs.cxx b/sw/source/ui/vba/vbadialogs.cxx deleted file mode 100644 index 7db0dafdd5..0000000000 --- a/sw/source/ui/vba/vbadialogs.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <ooo/vba/word/XDialog.hpp> -#include "vbadialogs.hxx" -#include "vbadialog.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -uno::Any -SwVbaDialogs::Item( const uno::Any &aItem ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - aItem >>= nIndex; - uno::Reference< word::XDialog > aDialog( new SwVbaDialog( uno::Reference< XHelperInterface >( Application(),uno::UNO_QUERY_THROW ), mxContext, m_xModel, nIndex ) ); - return uno::Any( aDialog ); -} - -rtl::OUString& -SwVbaDialogs::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaDialogs") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaDialogs::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Dialogs" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadialogs.hxx b/sw/source/ui/vba/vbadialogs.hxx deleted file mode 100644 index ff6a0748de..0000000000 --- a/sw/source/ui/vba/vbadialogs.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_DIALOGS_HXX -#define SW_VBA_DIALOGS_HXX - -#include <com/sun/star/uno/XComponentContext.hpp> -#include <ooo/vba/word/XDialogs.hpp> -#include <ooo/vba/XCollection.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbadialogsbase.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ov::word::XDialogs > SwVbaDialogs_BASE; - -class SwVbaDialogs : public SwVbaDialogs_BASE -{ -public: - SwVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): SwVbaDialogs_BASE( xParent, xContext, xModel ) {} - virtual ~SwVbaDialogs() {} - - // XCollection - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_DIALOGS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx deleted file mode 100644 index 119becfee2..0000000000 --- a/sw/source/ui/vba/vbadocument.cxx +++ /dev/null @@ -1,534 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbadocument.hxx" -#include "vbarange.hxx" -#include "vbarangehelper.hxx" -#include "vbadocumentproperties.hxx" -#include "vbabookmarks.hxx" -#include "vbavariables.hxx" -#include <com/sun/star/text/XBookmarksSupplier.hpp> -#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/document/XDocumentInfoSupplier.hpp> -#include <com/sun/star/document/XDocumentProperties.hpp> -#include <com/sun/star/drawing/XDrawPageSupplier.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> -#include <docsh.hxx> -#include "vbatemplate.hxx" -#include "vbaparagraph.hxx" -#include "vbastyles.hxx" -#include "vbatables.hxx" -#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; - -SwVbaDocument::SwVbaDocument( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< frame::XModel > xModel ): SwVbaDocument_BASE( xParent, xContext, xModel ) -{ - Initialize(); -} -SwVbaDocument::SwVbaDocument( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) : SwVbaDocument_BASE( aArgs, xContext ) -{ - Initialize(); -} - -SwVbaDocument::~SwVbaDocument() -{ -} - -void SwVbaDocument::Initialize() -{ - mxTextDocument.set( getModel(), uno::UNO_QUERY_THROW ); -} - -uno::Reference< word::XRange > SAL_CALL -SwVbaDocument::getContent() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xStart = mxTextDocument->getText()->getStart(); - uno::Reference< text::XTextRange > xEnd; - return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, xStart, xEnd, sal_True ) ); -} - -uno::Reference< word::XRange > SAL_CALL -SwVbaDocument::Range( const uno::Any& rStart, const uno::Any& rEnd ) throw ( uno::RuntimeException ) -{ - if( !rStart.hasValue() && !rEnd.hasValue() ) - return getContent(); - - sal_Int32 nStart = 0; - sal_Int32 nEnd = 0; - rStart >>= nStart; - rEnd >>= nEnd; - nStart--; - nEnd--; - - uno::Reference< text::XTextRange > xStart; - uno::Reference< text::XTextRange > xEnd; - if( nStart != -1 || nEnd != -1 ) - { - if( nStart == -1 ) - xStart = mxTextDocument->getText()->getStart(); - else - xStart = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nStart ); - - if( nEnd == -1 ) - xEnd = mxTextDocument->getText()->getEnd(); - else - xEnd = SwVbaRangeHelper::getRangeByPosition( mxTextDocument->getText(), nEnd ); - } - - if( !xStart.is() && !xEnd.is() ) - { - try - { - // FIXME - xStart = mxTextDocument->getText()->getStart(); - xEnd = mxTextDocument->getText()->getEnd(); - } - catch(const uno::Exception&) - { - DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString()); - } - } - return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, mxTextDocument, xStart, xEnd ) ); -} - -uno::Any SAL_CALL -SwVbaDocument::BuiltInDocumentProperties( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaBuiltinDocumentProperties( mxParent, mxContext, getModel() ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::CustomDocumentProperties( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaCustomDocumentProperties( mxParent, mxContext, getModel() ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::Bookmarks( const uno::Any& rIndex ) throw ( uno::RuntimeException ) -{ - uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( getModel(),uno::UNO_QUERY_THROW ); - uno::Reference<container::XIndexAccess > xBookmarks( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xBookmarksVba( new SwVbaBookmarks( this, mxContext, xBookmarks, getModel() ) ); - if ( rIndex.getValueTypeClass() == uno::TypeClass_VOID ) - return uno::makeAny( xBookmarksVba ); - - return uno::Any( xBookmarksVba->Item( rIndex, uno::Any() ) ); -} - -uno::Any SAL_CALL -SwVbaDocument::Variables( const uno::Any& rIndex ) throw ( uno::RuntimeException ) -{ - uno::Reference< document::XDocumentPropertiesSupplier > xDocumentPropertiesSupplier( getModel(),uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); - uno::Reference< beans::XPropertyAccess > xUserDefined( xDocumentProperties->getUserDefinedProperties(), uno::UNO_QUERY_THROW ); - - uno::Reference< XCollection > xVariables( new SwVbaVariables( this, mxContext, xUserDefined ) ); - if ( rIndex.getValueTypeClass() == uno::TypeClass_VOID ) - return uno::makeAny( xVariables ); - - return uno::Any( xVariables->Item( rIndex, uno::Any() ) ); -} - -uno::Any SAL_CALL -SwVbaDocument::Paragraphs( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaParagraphs( mxParent, mxContext, mxTextDocument ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::Styles( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaStyles( mxParent, mxContext, getModel() ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::Fields( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, getModel() ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::Shapes( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); - uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, xModel ) ); - - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Any SAL_CALL -SwVbaDocument::Sections( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaSections( mxParent, mxContext, getModel() ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -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 ); -} - -uno::Any SAL_CALL -SwVbaDocument::FormFields( const uno::Any& /*index*/ ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol; - 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 ); - return uno::makeAny( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, mxModel, xPageProps ) ) ); -} - -rtl::OUString& -SwVbaDocument::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaDocument") ); - return sImplName; -} -uno::Any SAL_CALL -SwVbaDocument::getAttachedTemplate() throw (uno::RuntimeException) -{ - 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 ); - rtl::OUString sTemplateUrl = xDocProps->getTemplateURL(); - - xTemplate = new SwVbaTemplate( this, mxContext, getModel(), sTemplateUrl ); - return uno::makeAny( xTemplate ); -} - -void SAL_CALL -SwVbaDocument::setAttachedTemplate( const css::uno::Any& _attachedtemplate ) 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 -SwVbaDocument::Tables( const css::uno::Any& aIndex ) throw (uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< XCollection > xColl( new SwVbaTables( mxParent, mxContext, xModel ) ); - - if ( aIndex.hasValue() ) - return xColl->Item( aIndex, uno::Any() ); - return uno::makeAny( xColl ); -} - -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 ) -{ - uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); - - sal_Int32 nCount = xIndexAccess->getCount(); - for( int index = 0; index < nCount; index++ ) - { - uno::Any aUnoObj = xIndexAccess->getByIndex( index ); - // It seems there are some drawing objects that can not query into Control shapes? - uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY ); - if( xControlShape.is() ) - { - uno::Reference< container::XNamed > xNamed( xControlShape->getControl(), uno::UNO_QUERY_THROW ); - if( sName.equals( xNamed->getName() )) - { - return aUnoObj; - } - } - } - return uno::Any(); -} - -uno::Reference< beans::XIntrospectionAccess > SAL_CALL -SwVbaDocument::getIntrospection( ) throw (uno::RuntimeException) -{ - return uno::Reference< beans::XIntrospectionAccess >(); -} - -uno::Any SAL_CALL -SwVbaDocument::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException) -{ - OSL_TRACE("** SwVbaDocument::invoke( %s ), will barf", - rtl::OUStringToOString( aFunctionName, RTL_TEXTENCODING_UTF8 ).getStr() ); - - throw uno::RuntimeException(); // unsupported operation -} - -void SAL_CALL -SwVbaDocument::setValue( const ::rtl::OUString& /*aPropertyName*/, const uno::Any& /*aValue*/ ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException) -{ - throw uno::RuntimeException(); // unsupported operation -} -uno::Any SAL_CALL -SwVbaDocument::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException) -{ - uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW ); - - uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW ); - uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW ); - uno::Reference< msforms::XControl > xControl( xControlProvider->createControl( xControlShape, getModel() ) ); - return uno::makeAny( xControl ); -} - -::sal_Bool SAL_CALL -SwVbaDocument::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException) -{ - return sal_False; -} - -::sal_Bool SAL_CALL -SwVbaDocument::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException) -{ - uno::Reference< container::XNameAccess > xFormControls( getFormControls() ); - if ( xFormControls.is() ) - return xFormControls->hasByName( aName ); - return sal_False; -} - -uno::Reference< container::XNameAccess > -SwVbaDocument::getFormControls() -{ - uno::Reference< container::XNameAccess > xFormControls; - try - { - uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY_THROW ); - // get the www-standard container ( maybe we should access the - // 'www-standard' by name rather than index, this seems an - // implementation detail - xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW ); - } - catch(const uno::Exception&) - { - } - return xFormControls; -} - -uno::Sequence< rtl::OUString > -SwVbaDocument::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Document" ) ); - } - return aServiceNames; -} - -namespace document -{ -namespace sdecl = comphelper::service_decl; -sdecl::vba_service_class_<SwVbaDocument, sdecl::with_args<true> > serviceImpl; -extern sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "SwVbaDocument", - "ooo.vba.word.Document" ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocument.hxx b/sw/source/ui/vba/vbadocument.hxx deleted file mode 100644 index f2c2db6169..0000000000 --- a/sw/source/ui/vba/vbadocument.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_DOCUMENT_HXX -#define SW_VBA_DOCUMENT_HXX - -#include <ooo/vba/word/XDocument.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbadocumentbase.hxx> -#include <com/sun/star/text/XTextDocument.hpp> - -typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ooo::vba::word::XDocument > SwVbaDocument_BASE; - -class SwVbaDocument : public SwVbaDocument_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - - void Initialize(); - css::uno::Any getControlShape( const rtl::OUString& sName ); - css::uno::Reference< css::container::XNameAccess > getFormControls(); - -public: - SwVbaDocument( const css::uno::Reference< ooo::vba::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& m_xContext, css::uno::Reference< css::frame::XModel > xModel ); - SwVbaDocument( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ); - virtual ~SwVbaDocument(); - - // XDocument - virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL getContent() throw ( css::uno::RuntimeException ); - virtual css::uno::Reference< ooo::vba::word::XRange > SAL_CALL Range( const css::uno::Any& rStart, const css::uno::Any& rEnd ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL BuiltInDocumentProperties( const css::uno::Any& index ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL CustomDocumentProperties( const css::uno::Any& index ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Bookmarks( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL Variables( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL getAttachedTemplate() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAttachedTemplate( const css::uno::Any& _attachedtemplate ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Paragraphs( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL Styles( const css::uno::Any& rIndex ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL Tables( 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); - virtual css::uno::Any SAL_CALL Shapes( 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 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); - using VbaDocumentBase::Protect; - 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); - virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_DOCUMENT_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx deleted file mode 100644 index 69c6539634..0000000000 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ /dev/null @@ -1,766 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbadocumentproperties.hxx" -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase3.hxx> -#include <com/sun/star/document/XDocumentInfoSupplier.hpp> -#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/beans/NamedValue.hpp> -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <ooo/vba/word/WdBuiltInProperty.hpp> -#include <ooo/vba/office/MsoDocProperties.hpp> -#include <memory> -#include <boost/shared_ptr.hpp> -#include "wordvbahelper.hxx" -#include "fesh.hxx" -#include "docsh.hxx" -using namespace ::ooo::vba; -using namespace css; - -sal_Int8 lcl_toMSOPropType( const uno::Type& aType ) throw ( lang::IllegalArgumentException ) -{ - sal_Int16 msoType = office::MsoDocProperties::msoPropertyTypeString; - - switch ( aType.getTypeClass() ) - { - case uno::TypeClass_BOOLEAN: - msoType = office::MsoDocProperties::msoPropertyTypeBoolean; - break; - case uno::TypeClass_FLOAT: - msoType = office::MsoDocProperties::msoPropertyTypeFloat; - break; - case uno::TypeClass_STRUCT: // Assume date - msoType = office::MsoDocProperties::msoPropertyTypeDate; - break; - case uno::TypeClass_BYTE: - case uno::TypeClass_SHORT: - case uno::TypeClass_LONG: - case uno::TypeClass_HYPER: - msoType = office::MsoDocProperties::msoPropertyTypeNumber; - break; - default: - throw lang::IllegalArgumentException(); - } - return msoType; -} - -class PropertGetSetHelper -{ -protected: - uno::Reference< frame::XModel > m_xModel; - uno::Reference< beans::XPropertySet > mxProps; -public: - PropertGetSetHelper( const uno::Reference< frame::XModel >& xModel ):m_xModel( xModel ) - { - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW ); - mxProps.set( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - } - virtual ~PropertGetSetHelper() {} - virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) = 0; - virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) = 0; - virtual uno::Reference< beans::XPropertySet > getUnoProperties() { return mxProps; } - -}; - -class BuiltinPropertyGetSetHelper : public PropertGetSetHelper -{ -public: - BuiltinPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) - { - } - virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) - { - if ( rPropName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("EditingDuration" ) ) ) ) - { - sal_Int32 nSecs = 0; - mxProps->getPropertyValue( rPropName ) >>= nSecs; - return uno::makeAny( nSecs/60 ); // minutes - } - return mxProps->getPropertyValue( rPropName ); - } - virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) - { - mxProps->setPropertyValue( rPropName, aValue ); - } -}; - -class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper -{ -public: - CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel ) - { - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( mxProps, uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - mxProps.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW ); - } -}; -class StatisticPropertyGetSetHelper : public PropertGetSetHelper -{ - SwDocShell* mpDocShell; - uno::Reference< beans::XPropertySet > mxModelProps; -public: - StatisticPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :PropertGetSetHelper( xModel ) , mpDocShell( NULL ) - { - mxModelProps.set( m_xModel, uno::UNO_QUERY_THROW ); - mpDocShell = word::getDocShell( xModel ); - } - virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) - { - uno::Sequence< beans::NamedValue > stats; - try - { - // Characters, ParagraphCount & WordCount are available from - // the model ( and addtionally these also update the statics object ) - return mxModelProps->getPropertyValue( rPropName ); - } - catch( uno::Exception& ) - { - OSL_TRACE("Got exception"); - } - uno::Any aReturn; - if ( rPropName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineCount")) ) ) // special processing needed - { - if ( mpDocShell ) - { - SwFEShell* pFEShell = mpDocShell->GetFEShell(); - if(pFEShell) - { - aReturn <<= pFEShell->GetLineCount(sal_False); - } - } - } - else - { - mxModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphCount") ) ) >>= stats; - mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats; - - sal_Int32 nLen = stats.getLength(); - bool bFound = false; - for ( sal_Int32 index = 0; index < nLen && !bFound ; ++index ) - { - if ( rPropName.equals( stats[ index ].Name ) ) - { - aReturn = stats[ index ].Value; - bFound = true; - } - } - if ( !bFound ) - throw uno::RuntimeException(); // bad Property - } - return aReturn; - } - - virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) - { - - uno::Sequence< beans::NamedValue > stats; - mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats; - - sal_Int32 nLen = stats.getLength(); - for ( sal_Int32 index = 0; index < nLen; ++index ) - { - if ( rPropName.equals( stats[ index ].Name ) ) - { - stats[ index ].Value = aValue; - mxProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ), uno::makeAny( stats ) ); - break; - } - } - } -}; - -class DocPropInfo -{ -public: - rtl::OUString msMSODesc; - rtl::OUString msOOOPropName; - boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper; - - static DocPropInfo createDocPropInfo( const rtl::OUString& sDesc, const rtl::OUString& sPropName, boost::shared_ptr< PropertGetSetHelper >& 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 ) - { - return createDocPropInfo( rtl::OUString::createFromAscii( sDesc ), rtl::OUString::createFromAscii( sPropName ), rHelper ); - } - uno::Any getValue() - { - if ( mpPropGetSetHelper.get() ) - return mpPropGetSetHelper->getPropertyValue( msOOOPropName ); - return uno::Any(); - } - void setValue( const uno::Any& rValue ) - { - if ( mpPropGetSetHelper.get() ) - mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue ); - } - uno::Reference< beans::XPropertySet > getUnoProperties() - { - - uno::Reference< beans::XPropertySet > xProps; - if ( mpPropGetSetHelper.get() ) - return mpPropGetSetHelper->getUnoProperties(); - return xProps; - } -}; - - -typedef boost::unordered_map< sal_Int32, DocPropInfo > MSOIndexToOODocPropInfo; - -class BuiltInIndexHelper -{ - MSOIndexToOODocPropInfo m_docPropInfoMap; - BuiltInIndexHelper(); -public: - BuiltInIndexHelper( const uno::Reference< frame::XModel >& xModel ) - { - boost::shared_ptr< PropertGetSetHelper > aStandardHelper( new BuiltinPropertyGetSetHelper( xModel ) ); - boost::shared_ptr< PropertGetSetHelper > aUsingStatsHelper( new StatisticPropertyGetSetHelper( xModel ) ); - - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTitle ] = DocPropInfo::createDocPropInfo( "Title", "Title", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySubject ] = DocPropInfo::createDocPropInfo( "Subject", "Subject", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAuthor ] = DocPropInfo::createDocPropInfo( "Author", "Author", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyKeywords ] = DocPropInfo::createDocPropInfo( "Keywords", "Keywords", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyComments ] = DocPropInfo::createDocPropInfo( "Comments", "Description", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTemplate ] = DocPropInfo::createDocPropInfo( "Template", "Template", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLastAuthor ] = DocPropInfo::createDocPropInfo( "Last author", "ModifiedBy", aStandardHelper ); // doesn't seem to exist - throw or return nothing ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyRevision ] = DocPropInfo::createDocPropInfo( "Revision number", "EditingCycles", aStandardHelper ); // doesn't seem to exist - throw or return nothing ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyAppName ] = DocPropInfo::createDocPropInfo( "Application name", "Generator", aStandardHelper ); // doesn't seem to exist - throw or return nothing ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastPrinted ] = DocPropInfo::createDocPropInfo( "Last print date", "PrintDate", aStandardHelper ); // doesn't seem to exist - throw or return nothing ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeCreated ] = DocPropInfo::createDocPropInfo( "Creation date", "CreationDate", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyTimeLastSaved ] = DocPropInfo::createDocPropInfo( "Last save time", "ModifyDate", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyVBATotalEdit ] = DocPropInfo::createDocPropInfo( "Total editing time", "EditingDuration", aStandardHelper ); // Not sure if this is correct - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyPages ] = DocPropInfo::createDocPropInfo( "Number of pages", "PageCount", aUsingStatsHelper ); // special handling required ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyWords ] = DocPropInfo::createDocPropInfo( "Number of words", "WordCount", aUsingStatsHelper ); // special handling require ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharacters ] = DocPropInfo::createDocPropInfo( "Number of characters", "CharacterCount", aUsingStatsHelper ); // special handling required ? - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySecurity ] = DocPropInfo::createDocPropInfo( "Security", "", aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCategory ] = DocPropInfo::createDocPropInfo( "Category", "Category", aStandardHelper ); // hacked in - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyFormat ] = DocPropInfo::createDocPropInfo( "Format", "", aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyManager ] = DocPropInfo::createDocPropInfo( "Manager", "Manager", aStandardHelper ); // hacked in - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCompany ] = DocPropInfo::createDocPropInfo( "Company", "Company", aStandardHelper ); // hacked in - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyBytes ] = DocPropInfo::createDocPropInfo( "Number of bytes", "", aStandardHelper ); // doesn't seem to exist - size on disk exists ( for an already saved document ) perhaps it will do ( or we need something else ) - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyLines ] = DocPropInfo::createDocPropInfo( "Number of lines", "LineCount", aUsingStatsHelper ); // special handling - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyParas ] = DocPropInfo::createDocPropInfo( "Number of paragraphs", "ParagraphCount", aUsingStatsHelper ); // special handling - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertySlides ] = DocPropInfo::createDocPropInfo( "Number of slides", "" , aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyNotes ] = DocPropInfo::createDocPropInfo( "Number of notes", "", aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHiddenSlides ] = DocPropInfo::createDocPropInfo("Number of hidden Slides", "", aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyMMClips ] = DocPropInfo::createDocPropInfo( "Number of multimedia clips", "", aStandardHelper ); // doesn't seem to exist - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyHyperlinkBase ] = DocPropInfo::createDocPropInfo( "Hyperlink base", "AutoloadURL", aStandardHelper ); - m_docPropInfoMap[ word::WdBuiltInProperty::wdPropertyCharsWSpaces ] = DocPropInfo::createDocPropInfo( "Number of characters (with spaces)", "", aStandardHelper ); // doesn't seem to be supported - } - - MSOIndexToOODocPropInfo& getDocPropInfoMap() { return m_docPropInfoMap; } -}; - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::XDocumentProperty > SwVbaDocumentProperty_BASE; - -class SwVbaBuiltInDocumentProperty : public SwVbaDocumentProperty_BASE -{ -protected: - DocPropInfo mPropInfo; -public: - SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ); - // XDocumentProperty - virtual void SAL_CALL Delete( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getName( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException); - virtual ::sal_Int8 SAL_CALL getType( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setLinkToContent( ::sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException); - virtual uno::Any SAL_CALL getValue( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException); - virtual rtl::OUString SAL_CALL getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setLinkSource( const rtl::OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException); - //XDefaultProperty - virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (uno::RuntimeException) { return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value")); } - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual uno::Sequence<rtl::OUString> getServiceNames(); -}; - -class SwVbaCustomDocumentProperty : public SwVbaBuiltInDocumentProperty -{ -public: - - SwVbaCustomDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ); - - virtual ::sal_Bool SAL_CALL getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setLinkToContent( ::sal_Bool LinkToContent ) throw (script::BasicErrorException, uno::RuntimeException); - - virtual rtl::OUString SAL_CALL getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setLinkSource( const rtl::OUString& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL Delete( ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException); - virtual void SAL_CALL setType( ::sal_Int8 Type ) throw (script::BasicErrorException, uno::RuntimeException); - -}; - - -SwVbaCustomDocumentProperty::SwVbaCustomDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaBuiltInDocumentProperty( xParent, xContext, rInfo ) -{ -} - -sal_Bool -SwVbaCustomDocumentProperty::getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // #FIXME we need to store the link content somewhere - return sal_False; -} - -void -SwVbaCustomDocumentProperty::setLinkToContent( sal_Bool /*bLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ -} - -rtl::OUString -SwVbaCustomDocumentProperty::getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // #FIXME we need to store the link content somewhere - return rtl::OUString();; -} - -void -SwVbaCustomDocumentProperty::setLinkSource( const rtl::OUString& /*rsLinkContent*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // #FIXME we need to store the link source somewhere -} - -void SAL_CALL -SwVbaCustomDocumentProperty::setName( const ::rtl::OUString& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // setName on existing property ? - // #FIXME - // do we need to delete existing property and create a new one? -} - -void SAL_CALL -SwVbaCustomDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // setType, do we need to do a conversion? - // #FIXME the underlying value needs to be changed to the new type -} - -void SAL_CALL -SwVbaCustomDocumentProperty::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - uno::Reference< beans::XPropertyContainer > xContainer( mPropInfo.getUnoProperties(), uno::UNO_QUERY_THROW ); - xContainer->removeProperty( getName() ); -} - -SwVbaBuiltInDocumentProperty::SwVbaBuiltInDocumentProperty( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const DocPropInfo& rInfo ) : SwVbaDocumentProperty_BASE( xParent, xContext ), mPropInfo( rInfo ) -{ -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -::rtl::OUString SAL_CALL -SwVbaBuiltInDocumentProperty::getName( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return mPropInfo.msMSODesc; -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::setName( const rtl::OUString& ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -::sal_Int8 SAL_CALL -SwVbaBuiltInDocumentProperty::getType( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return lcl_toMSOPropType( getValue().getValueType() ); -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -::sal_Bool SAL_CALL -SwVbaBuiltInDocumentProperty::getLinkToContent( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return sal_False; // built-in always false -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::setLinkToContent( ::sal_Bool /*LinkToContent*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -uno::Any SAL_CALL -SwVbaBuiltInDocumentProperty::getValue( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - uno::Any aRet = mPropInfo.getValue(); - if ( !aRet.hasValue() ) - throw uno::RuntimeException(); - return aRet; -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::setValue( const uno::Any& Value ) throw (script::BasicErrorException, uno::RuntimeException) -{ - mPropInfo.setValue( Value ); -} - -rtl::OUString SAL_CALL -SwVbaBuiltInDocumentProperty::getLinkSource( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -void SAL_CALL -SwVbaBuiltInDocumentProperty::setLinkSource( const rtl::OUString& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // not valid for Builtin - throw uno::RuntimeException(); -} - -rtl::OUString& -SwVbaBuiltInDocumentProperty::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBuiltinDocumentProperty") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaBuiltInDocumentProperty::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.DocumentProperty" ) ); - } - return aServiceNames; -} -typedef ::cppu::WeakImplHelper3< com::sun::star::container::XIndexAccess - ,com::sun::star::container::XNameAccess - ,com::sun::star::container::XEnumerationAccess - > PropertiesImpl_BASE; - -typedef boost::unordered_map< sal_Int32, uno::Reference< XDocumentProperty > > DocProps; - -typedef ::cppu::WeakImplHelper1< com::sun::star::container::XEnumeration > DocPropEnumeration_BASE; -class DocPropEnumeration : public DocPropEnumeration_BASE -{ - DocProps mDocProps; - DocProps::iterator mIt; -public: - - DocPropEnumeration( const DocProps& rProps ) : mDocProps( rProps ), mIt( mDocProps.begin() ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return mIt != mDocProps.end(); - } - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - return uno::makeAny( mIt++->second ); - } -}; - -typedef boost::unordered_map< rtl::OUString, uno::Reference< XDocumentProperty >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > DocPropsByName; - -class BuiltInPropertiesImpl : public PropertiesImpl_BASE -{ -protected: - - uno::Reference< XHelperInterface > m_xParent; - uno::Reference< uno::XComponentContext > m_xContext; - uno::Reference< frame::XModel > m_xModel; - uno::Reference< document::XDocumentInfo > m_xOOOBuiltIns; - - DocProps mDocProps; - DocPropsByName mNamedDocProps; - - public: - BuiltInPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel ) - { - BuiltInIndexHelper builtIns( m_xModel ); - for ( sal_Int32 index = word::WdBuiltInProperty::wdPropertyTitle; index <= word::WdBuiltInProperty::wdPropertyCharsWSpaces; ++index ) - { - mDocProps[ index ] = new SwVbaBuiltInDocumentProperty( xParent, xContext, builtIns.getDocPropInfoMap()[ index ] ); - mNamedDocProps[ mDocProps[ index ]->getName() ] = mDocProps[ index ]; - } - } -// XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return mDocProps.size(); - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException ) - { - // correct the correct by the base class for 1 based indices - DocProps::iterator it = mDocProps.find( ++Index ); - if ( it == mDocProps.end() ) - throw lang::IndexOutOfBoundsException(); - return uno::makeAny( it->second ); - } - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasByName( aName ) ) - throw container::NoSuchElementException(); - DocPropsByName::iterator it = mNamedDocProps.find( aName ); - return uno::Any( it->second ); - - } - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - uno::Sequence< rtl::OUString > aNames( getCount() ); - rtl::OUString* pName = aNames.getArray(); - DocPropsByName::iterator it_end = mNamedDocProps.end(); - for( DocPropsByName::iterator it = mNamedDocProps.begin(); it != it_end; ++it, ++pName ) - *pName = it->first; - return aNames; - } - - virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) - { - DocPropsByName::iterator it = mNamedDocProps.find( aName ); - if ( it == mNamedDocProps.end() ) - return sal_False; - return sal_True; - } -// XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return XDocumentProperty::static_type(0); - } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return mDocProps.size() > 0; - } - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new DocPropEnumeration( mDocProps ); - } -}; - -SwVbaBuiltinDocumentProperties::SwVbaBuiltinDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaDocumentproperties_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new BuiltInPropertiesImpl( xParent, xContext, xModel ) ) ), m_xModel( xModel ) -{ -} - -uno::Reference< XDocumentProperty > SAL_CALL -SwVbaBuiltinDocumentProperties::Add( const ::rtl::OUString& /*Name*/, ::sal_Bool /*LinkToContent*/, ::sal_Int8 /*Type*/, const uno::Any& /*value*/, const uno::Any& /*LinkSource*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - throw uno::RuntimeException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("not supported for Builtin properties") ), uno::Reference< uno::XInterface >() ); -} - -// XEnumerationAccess -uno::Type SAL_CALL -SwVbaBuiltinDocumentProperties::getElementType() throw (uno::RuntimeException) -{ - return XDocumentProperty::static_type(0); -} - -uno::Reference< container::XEnumeration > SAL_CALL -SwVbaBuiltinDocumentProperties::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumAccess->createEnumeration(); -} - -// ScVbaCollectionBaseImpl -uno::Any -SwVbaBuiltinDocumentProperties::createCollectionObject( const uno::Any& aSource ) -{ - // pass through - return aSource; -} - -// XHelperInterface -rtl::OUString& -SwVbaBuiltinDocumentProperties::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaBuiltinDocumentProperties") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaBuiltinDocumentProperties::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.DocumentProperties" ) ); - } - return aServiceNames; -} - -class CustomPropertiesImpl : public PropertiesImpl_BASE -{ - uno::Reference< XHelperInterface > m_xParent; - uno::Reference< uno::XComponentContext > m_xContext; - uno::Reference< frame::XModel > m_xModel; - uno::Reference< beans::XPropertySet > mxUserDefinedProp; - boost::shared_ptr< PropertGetSetHelper > mpPropGetSetHelper; -public: - CustomPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel ) - { - // suck in the document( custom ) properties - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - mxUserDefinedProp.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW ); - mpPropGetSetHelper.reset( new CustomPropertyGetSetHelper( m_xModel ) ); - }; - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return mxUserDefinedProp->getPropertySetInfo()->getProperties().getLength(); - } - - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException ) - { - uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties(); - if ( Index >= aProps.getLength() ) - throw lang::IndexOutOfBoundsException(); - // How to determine type e.g Date? ( com.sun.star.util.DateTime ) - DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aProps[ Index ].Name, aProps[ Index ].Name, mpPropGetSetHelper ); - return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) ); - } - - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasByName( aName ) ) - throw container::NoSuchElementException(); - - DocPropInfo aPropInfo = DocPropInfo::createDocPropInfo( aName, aName, mpPropGetSetHelper ); - return uno::makeAny( uno::Reference< XDocumentProperty >( new SwVbaCustomDocumentProperty( m_xParent, m_xContext, aPropInfo ) ) ); - } - - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - uno::Sequence< beans::Property > aProps = mxUserDefinedProp->getPropertySetInfo()->getProperties(); - uno::Sequence< rtl::OUString > aNames( aProps.getLength() ); - rtl::OUString* pString = aNames.getArray(); - rtl::OUString* pEnd = ( pString + aNames.getLength() ); - beans::Property* pProp = aProps.getArray(); - for ( ; pString != pEnd; ++pString, ++pProp ) - *pString = pProp->Name; - return aNames; - } - - virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) - { - OSL_TRACE("hasByName(%s) returns %d", rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr(), mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ) ); - return mxUserDefinedProp->getPropertySetInfo()->hasPropertyByName( aName ); - } - - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return XDocumentProperty::static_type(0); - } - - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return getCount() > 0; - } - - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - // create a map of properties ( the key doesn't matter ) - OSL_TRACE("Creating an enumeration"); - sal_Int32 key = 0; - sal_Int32 nElem = getCount(); - DocProps simpleDocPropSnapShot; - for ( ; key < nElem; ++key ) - simpleDocPropSnapShot[ key ].set( getByIndex( key ), uno::UNO_QUERY_THROW ); - OSL_TRACE("After creating the enumeration"); - return new DocPropEnumeration( simpleDocPropSnapShot ); - } - - void addProp( const ::rtl::OUString& Name, ::sal_Int8 /*Type*/, const uno::Any& Value ) - { - sal_Int16 attributes = 128; - uno::Reference< beans::XPropertyContainer > xContainer( mxUserDefinedProp, uno::UNO_QUERY_THROW ); - // TODO fixme, perform the necessary Type Value conversions - xContainer->addProperty( Name, attributes, Value ); - } - -}; - - -SwVbaCustomDocumentProperties::SwVbaCustomDocumentProperties( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaBuiltinDocumentProperties( xParent, xContext, xModel ) -{ - // replace the m_xIndexAccess implementation ( we need a virtual init ) - m_xIndexAccess.set( new CustomPropertiesImpl( xParent, xContext, xModel ) ); - m_xNameAccess.set( m_xIndexAccess, uno::UNO_QUERY_THROW ); -} - -uno::Reference< XDocumentProperty > SAL_CALL -SwVbaCustomDocumentProperties::Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const uno::Any& Value, const uno::Any& LinkSource ) throw (script::BasicErrorException, uno::RuntimeException) -{ - CustomPropertiesImpl* pCustomProps = dynamic_cast< CustomPropertiesImpl* > ( m_xIndexAccess.get() ); - uno::Reference< XDocumentProperty > xDocProp; - if ( pCustomProps ) - { - rtl::OUString sLinkSource; - pCustomProps->addProp( Name, Type, Value ); - - xDocProp.set( m_xNameAccess->getByName( Name ), uno::UNO_QUERY_THROW ); - xDocProp->setLinkToContent( LinkToContent ); - - if ( LinkSource >>= sLinkSource ) - xDocProp->setLinkSource( sLinkSource ); - } - return xDocProp; -} - -// XHelperInterface -rtl::OUString& -SwVbaCustomDocumentProperties::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaCustomDocumentProperties") ); - return sImplName; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocumentproperties.hxx b/sw/source/ui/vba/vbadocumentproperties.hxx deleted file mode 100644 index 25cc54bd87..0000000000 --- a/sw/source/ui/vba/vbadocumentproperties.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_DOCUMENTPROPERTIES_HXX -#define SW_VBA_DOCUMENTPROPERTIES_HXX - -#include <ooo/vba/XDocumentProperties.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <vbahelper/vbacollectionimpl.hxx> -#include <boost/unordered_map.hpp> - -typedef CollTestImplHelper< ov::XDocumentProperties > SwVbaDocumentproperties_BASE; - -class SwVbaBuiltinDocumentProperties : public SwVbaDocumentproperties_BASE -{ -protected: - css::uno::Reference< css::frame::XModel > m_xModel; -public: - SwVbaBuiltinDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument ); - - // XDocumentProperties - virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) throw (css::script::BasicErrorException, 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); - // ScVbaCollectionBaseImpl - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -class SwVbaCustomDocumentProperties : public SwVbaBuiltinDocumentProperties -{ -public: - SwVbaCustomDocumentProperties( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument ); -// XDocumentProperties - virtual css::uno::Reference< ::ooo::vba::XDocumentProperty > SAL_CALL Add( const ::rtl::OUString& Name, ::sal_Bool LinkToContent, ::sal_Int8 Type, const css::uno::Any& Value, const css::uno::Any& LinkSource ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); -}; - -#endif /* SW_VBA_DOCUMENTPROPERTY_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocuments.cxx b/sw/source/ui/vba/vbadocuments.cxx deleted file mode 100644 index a354574c10..0000000000 --- a/sw/source/ui/vba/vbadocuments.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <comphelper/processfactory.hxx> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase3.hxx> - -#include <com/sun/star/frame/XDesktop.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/frame/XFrame.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/beans/PropertyVetoException.hpp> -#include <com/sun/star/util/XCloseable.hpp> -#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/document/XTypeDetection.hpp> -#include <com/sun/star/uri/XUriReference.hpp> -#include <com/sun/star/uri/XUriReferenceFactory.hpp> - -#include <sfx2/objsh.hxx> -#include <tools/urlobj.hxx> - -#include "vbaglobals.hxx" -#include "vbadocument.hxx" -#include "vbadocuments.hxx" -#include <vbahelper/vbahelper.hxx> - -#include <boost/unordered_map.hpp> -#include <osl/file.hxx> -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -static uno::Any -getDocument( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextDocument > &xDoc, const uno::Any& aApplication ) -{ - // FIXME: fine as long as SwVbaDocument is stateless ... - uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); - if( !xModel.is() ) - return uno::Any(); - - SwVbaDocument *pWb = new SwVbaDocument( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); - return uno::Any( uno::Reference< word::XDocument > (pWb) ); -} - -class DocumentEnumImpl : public EnumerationHelperImpl -{ - uno::Any m_aApplication; -public: - DocumentEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {} - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - uno::Reference< text::XTextDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return getDocument( m_xContext, xDoc, m_aApplication ); - } -}; - -SwVbaDocuments::SwVbaDocuments( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : SwVbaDocuments_BASE( xParent, xContext, VbaDocumentsBase::WORD_DOCUMENT ) -{ -} -// XEnumerationAccess -uno::Type -SwVbaDocuments::getElementType() throw (uno::RuntimeException) -{ - return word::XDocument::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaDocuments::createEnumeration() throw (uno::RuntimeException) -{ - // #FIXME its possible the DocumentEnumImpl here doens't reflect - // the state of this object ( although it should ) would be - // safer to create an enumeration based on this objects state - // rather than one effectively based of the desktop component - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new DocumentEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() ); -} - -uno::Any -SwVbaDocuments::createCollectionObject( const uno::Any& aSource ) -{ - uno::Reference< text::XTextDocument > xDoc( aSource, uno::UNO_QUERY_THROW ); - return getDocument( mxContext, xDoc, Application() ); -} - -uno::Any SAL_CALL -SwVbaDocuments::Add( const uno::Any& Template, const uno::Any& /*NewTemplate*/, const uno::Any& /*DocumentType*/, const uno::Any& /*Visible*/ ) throw (uno::RuntimeException) -{ - rtl::OUString sFileName; - if( Template.hasValue() && ( Template >>= sFileName ) ) - { - return Open( sFileName, uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any(), uno::Any()); - } - uno::Reference <text::XTextDocument> xTextDoc( createDocument() , uno::UNO_QUERY_THROW ); - - if( xTextDoc.is() ) - return getDocument( mxContext, xTextDoc, Application() ); - return uno::Any(); -} - -// #TODO# #FIXME# can any of the unused params below be used? -void SAL_CALL -SwVbaDocuments::Close( const uno::Any& /*SaveChanges*/, const uno::Any& /*OriginalFormat*/, const uno::Any& /*RouteDocument*/ ) throw (uno::RuntimeException) -{ - closeDocuments(); -} - -// #TODO# #FIXME# can any of the unused params below be used? -uno::Any SAL_CALL -SwVbaDocuments::Open( const ::rtl::OUString& Filename, const uno::Any& /*ConfirmConversions*/, const uno::Any& ReadOnly, const uno::Any& /*AddToRecentFiles*/, const uno::Any& /*PasswordDocument*/, const uno::Any& /*PasswordTemplate*/, const uno::Any& /*Revert*/, const uno::Any& /*WritePasswordDocument*/, const uno::Any& /*WritePasswordTemplate*/, const uno::Any& /*Format*/, const uno::Any& /*Encoding*/, const uno::Any& /*Visible*/, const uno::Any& /*OpenAndRepair*/, const uno::Any& /*DocumentDirection*/, const uno::Any& /*NoEncodingDialog*/, const uno::Any& /*XMLTransform*/ ) throw (uno::RuntimeException) -{ - // we need to detect if this is a URL, if not then assume its a file path - rtl::OUString aURL; - INetURLObject aObj; - aObj.SetURL( Filename ); - bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID; - if ( bIsURL ) - aURL = Filename; - else - osl::FileBase::getFileURLFromSystemPath( Filename, aURL ); - - uno::Sequence< beans::PropertyValue > sProps(0); - - uno::Reference <text::XTextDocument> xSpreadDoc( openDocument( Filename, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); - uno::Any aRet = getDocument( mxContext, xSpreadDoc, Application() ); - uno::Reference< word::XDocument > xDocument( aRet, uno::UNO_QUERY ); - if ( xDocument.is() ) - xDocument->Activate(); - return aRet; -} - -rtl::OUString& -SwVbaDocuments::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaDocuments") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaDocuments::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Documents") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbadocuments.hxx b/sw/source/ui/vba/vbadocuments.hxx deleted file mode 100644 index d8ad9ff306..0000000000 --- a/sw/source/ui/vba/vbadocuments.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_DOCUMENTS_HXX -#define SW_VBA_DOCUMENTS_HXX - - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XDocuments.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <vbahelper/vbadocumentsbase.hxx> -#include "wordvbahelper.hxx" - - -typedef cppu::ImplInheritanceHelper1< VbaDocumentsBase, ov::word::XDocuments > SwVbaDocuments_BASE; - -class SwVbaDocuments : public SwVbaDocuments_BASE -{ -public: - SwVbaDocuments( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ); - virtual ~SwVbaDocuments() {} - - // 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); - - // SwVbaDocuments_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - - // Methods - virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Template, const css::uno::Any& NewTemplate, const css::uno::Any& DocumentType, const css::uno::Any& Visible ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ConfirmConversions, const css::uno::Any& ReadOnly, const css::uno::Any& AddToRecentFiles, const css::uno::Any& PasswordDocument, const css::uno::Any& PasswordTemplate, const css::uno::Any& Revert, const css::uno::Any& WritePasswordDocument, const css::uno::Any& WritePasswordTemplate, const css::uno::Any& Format, const css::uno::Any& Encoding, const css::uno::Any& Visible, const css::uno::Any& OpenAndRepair, const css::uno::Any& DocumentDirection, const css::uno::Any& NoEncodingDialog, const css::uno::Any& XMLTransform ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Close( const css::uno::Any& SaveChanges, const css::uno::Any& OriginalFormat, const css::uno::Any& RouteDocument ) throw (css::uno::RuntimeException); -}; - -#endif /* SW_VBA_DOCUMENTS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaeventshelper.cxx b/sw/source/ui/vba/vbaeventshelper.cxx deleted file mode 100644 index e7f4ec2366..0000000000 --- a/sw/source/ui/vba/vbaeventshelper.cxx +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "vbaeventshelper.hxx" -#include <com/sun/star/script/ModuleType.hpp> -#include <com/sun/star/script/vba/VBAEventId.hpp> -#include <vbahelper/helperdecl.hxx> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::script::vba::VBAEventId; -using namespace ::ooo::vba; - -// ============================================================================ - -SwVbaEventsHelper::SwVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& xContext ) : - VbaEventsHelperBase( aArgs, xContext ) -{ - using namespace ::com::sun::star::script::ModuleType; - registerEventHandler( DOCUMENT_NEW, DOCUMENT, "Document_New" ); - registerEventHandler( AUTO_NEW, NORMAL, "AutoNew" ); - registerEventHandler( DOCUMENT_OPEN, DOCUMENT, "Document_Open" ); - registerEventHandler( AUTO_OPEN, NORMAL, "AutoOpen" ); - registerEventHandler( DOCUMENT_CLOSE, DOCUMENT, "Document_Close" ); - registerEventHandler( AUTO_CLOSE, NORMAL, "AutoClose" ); -} - -SwVbaEventsHelper::~SwVbaEventsHelper() -{ -} - -bool SwVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, - const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& /*rArgs*/ ) throw (uno::RuntimeException) -{ - switch( rInfo.mnEventId ) - { - case DOCUMENT_NEW: - rEventQueue.push_back( AUTO_NEW ); - break; - case DOCUMENT_OPEN: - rEventQueue.push_back( AUTO_OPEN ); - break; - case DOCUMENT_CLOSE: - rEventQueue.push_back( AUTO_CLOSE ); - break; - } - return true; -} - -uno::Sequence< uno::Any > SwVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& /*rInfo*/, - const uno::Sequence< uno::Any >& /*rArgs*/ ) throw (lang::IllegalArgumentException) -{ - // no event handler expects any arguments - return uno::Sequence< uno::Any >(); -} - -void SwVbaEventsHelper::implPostProcessEvent( EventQueue& /*rEventQueue*/, - const EventHandlerInfo& /*rInfo*/, bool /*bCancel*/ ) throw (uno::RuntimeException) -{ - // nothing to do after any event -} - -::rtl::OUString SwVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& /*rInfo*/, - const uno::Sequence< uno::Any >& /*rArgs*/ ) const throw (lang::IllegalArgumentException) -{ - // TODO: get actual codename from document - return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisDocument" ) ); -} - -// ============================================================================ - -namespace vbaeventshelper -{ -namespace sdecl = comphelper::service_decl; -sdecl::class_<SwVbaEventsHelper, sdecl::with_args<true> > serviceImpl; -extern sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "SwVbaEventsHelper", - "com.sun.star.document.vba.VBATextEventProcessor" ); -} - -// ============================================================================ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaeventshelper.hxx b/sw/source/ui/vba/vbaeventshelper.hxx deleted file mode 100644 index 3c291a78b4..0000000000 --- a/sw/source/ui/vba/vbaeventshelper.hxx +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SW_VBAEVENTS_HXX -#define SW_VBAEVENTS_HXX - -#include <vbahelper/vbaeventshelperbase.hxx> - -// ============================================================================ - -class SwVbaEventsHelper : public VbaEventsHelperBase -{ -public: - SwVbaEventsHelper( - const css::uno::Sequence< css::uno::Any >& rArgs, - const css::uno::Reference< css::uno::XComponentContext >& rxContext ); - virtual ~SwVbaEventsHelper(); - -protected: - virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); - virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); - virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bCancel ) throw (css::uno::RuntimeException); - virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); -}; - -// ============================================================================ - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafield.cxx b/sw/source/ui/vba/vbafield.cxx deleted file mode 100644 index 27a682ebe7..0000000000 --- a/sw/source/ui/vba/vbafield.cxx +++ /dev/null @@ -1,594 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbafield.hxx" -#include "vbarange.hxx" -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/text/XTextFieldsSupplier.hpp> -#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; -using namespace ::com::sun::star; - -// *** SwVbaField *********************************************** - -SwVbaField::SwVbaField( 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::XTextField >& xTextField) throw ( uno::RuntimeException ) : SwVbaField_BASE( rParent, rContext ), mxTextDocument( rDocument ) -{ - 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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaField") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaField::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Field" ) ); - } - return aServiceNames; -} - -// *** _ReadFieldParams *********************************************** -// the codes are copied from ww8par5.cxx -class _ReadFieldParams -{ -private: - String aData; - xub_StrLen nLen, nFnd, nNext, nSavPtr; - String aFieldName; -public: - _ReadFieldParams( const String& rData ); - ~_ReadFieldParams(); - - xub_StrLen GoToTokenParam(); - long SkipToNextToken(); - xub_StrLen GetTokenSttPtr() const { return nFnd; } - - xub_StrLen FindNextStringPiece( xub_StrLen _nStart = STRING_NOTFOUND ); - bool GetTokenSttFromTo(xub_StrLen* _pFrom, xub_StrLen* _pTo, - xub_StrLen _nMax); - - String GetResult() const; - String GetFieldName()const { return aFieldName; } -}; - - -_ReadFieldParams::_ReadFieldParams( const String& _rData ) - : aData( _rData ), nLen( _rData.Len() ), nNext( 0 ) -{ - /* - erstmal nach einer oeffnenden Klammer oder einer Leerstelle oder einem - Anfuehrungszeichen oder einem Backslash suchen, damit der Feldbefehl - (also INCLUDEPICTURE bzw EINFUeGENGRAFIK bzw ...) ueberlesen wird - */ - while( (nLen > nNext) && (aData.GetChar( nNext ) == ' ') ) - ++nNext; - - sal_Unicode c; - while( nLen > nNext - && (c = aData.GetChar( nNext )) != ' ' - && c != '"' - && c != '\\' - && c != 132 - && c != 0x201c ) - ++nNext; - - nFnd = nNext; - nSavPtr = nNext; - aFieldName = aData.Copy( 0, nFnd ); -} - - -_ReadFieldParams::~_ReadFieldParams() -{ -} - - -String _ReadFieldParams::GetResult() const -{ - return (STRING_NOTFOUND == nFnd) - ? aEmptyStr - : aData.Copy( nFnd, (nSavPtr - nFnd) ); -} - - -xub_StrLen _ReadFieldParams::GoToTokenParam() -{ - xub_StrLen nOld = nNext; - if( -2 == SkipToNextToken() ) - return GetTokenSttPtr(); - nNext = nOld; - return STRING_NOTFOUND; -} - -// ret: -2: NOT a '\' parameter but normal Text -long _ReadFieldParams::SkipToNextToken() -{ - long nRet = -1; // Ende - if ( - (STRING_NOTFOUND != nNext) && (nLen > nNext) && - STRING_NOTFOUND != (nFnd = FindNextStringPiece(nNext)) - ) - { - nSavPtr = nNext; - - if ('\\' == aData.GetChar(nFnd) && '\\' != aData.GetChar(nFnd + 1)) - { - nRet = aData.GetChar(++nFnd); - nNext = ++nFnd; // und dahinter setzen - } - else - { - nRet = -2; - if ( - (STRING_NOTFOUND != nSavPtr ) && - ( - ('"' == aData.GetChar(nSavPtr - 1)) || - (0x201d == aData.GetChar(nSavPtr - 1)) - ) - ) - { - --nSavPtr; - } - } - } - return nRet; -} - -// FindNextPara sucht naechsten Backslash-Parameter oder naechste Zeichenkette -// bis zum Blank oder naechsten "\" oder zum schliessenden Anfuehrungszeichen -// oder zum String-Ende von pStr. -// -// Ausgabe ppNext (falls ppNext != 0) Suchbeginn fuer naechsten Parameter bzw. 0 -// -// Returnwert: 0 falls String-Ende erreicht, -// ansonsten Anfang des Paramters bzw. der Zeichenkette -// -xub_StrLen _ReadFieldParams::FindNextStringPiece(const xub_StrLen nStart) -{ - xub_StrLen n = ( STRING_NOTFOUND == nStart ) ? nFnd : nStart; // Anfang - xub_StrLen n2; // Ende - - nNext = STRING_NOTFOUND; // Default fuer nicht gefunden - - while( (nLen > n) && (aData.GetChar( n ) == ' ') ) - ++n; - - if( nLen == n ) - return STRING_NOTFOUND; // String End reached! - - if( (aData.GetChar( n ) == '"') // Anfuehrungszeichen vor Para? - || (aData.GetChar( n ) == 0x201c) - || (aData.GetChar( n ) == 132) ) - { - n++; // Anfuehrungszeichen ueberlesen - n2 = n; // ab hier nach Ende suchen - while( (nLen > n2) - && (aData.GetChar( n2 ) != '"') - && (aData.GetChar( n2 ) != 0x201d) - && (aData.GetChar( n2 ) != 147) ) - n2++; // Ende d. Paras suchen - } - else // keine Anfuehrungszeichen - { - n2 = n; // ab hier nach Ende suchen - while( (nLen > n2) && (aData.GetChar( n2 ) != ' ') ) // Ende d. Paras suchen - { - if( aData.GetChar( n2 ) == '\\' ) - { - if( aData.GetChar( n2+1 ) == '\\' ) - n2 += 2; // Doppel-Backslash -> OK - else - { - if( n2 > n ) - n2--; - break; // einfach-Backslash -> Ende - } - } - else - n2++; // kein Backslash -> OK - } - } - if( nLen > n2 ) - { - if(aData.GetChar( n2 ) != ' ') n2++; - nNext = n2; - } - return n; -} - - - -// read parameters "1-3" or 1-3 with both values between 1 and nMax -bool _ReadFieldParams::GetTokenSttFromTo(sal_uInt16* pFrom, sal_uInt16* pTo, sal_uInt16 nMax) -{ - sal_uInt16 nStart = 0; - sal_uInt16 nEnd = 0; - xub_StrLen n = GoToTokenParam(); - if( STRING_NOTFOUND != n ) - { - - String sParams( GetResult() ); - - xub_StrLen nIndex = 0; - String sStart( sParams.GetToken(0, '-', nIndex) ); - if( STRING_NOTFOUND != nIndex ) - { - nStart = static_cast<sal_uInt16>(sStart.ToInt32()); - nEnd = static_cast<sal_uInt16>(sParams.Copy(nIndex).ToInt32()); - } - } - if( pFrom ) *pFrom = nStart; - if( pTo ) *pTo = nEnd; - - return nStart && nEnd && (nMax >= nStart) && (nMax >= nEnd); -} - -// *** SwVbaFields *********************************************** - -uno::Any lcl_createField( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Any& aSource ) -{ - uno::Reference< text::XTextField > xTextField( aSource, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextDocument > xTextDocument( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< word::XField > xField( new SwVbaField( xParent, xContext, xTextDocument, xTextField ) ); - return uno::makeAny( xField ); -} - -typedef ::cppu::WeakImplHelper1< css::container::XEnumeration > FieldEnumeration_BASE; -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > FieldCollectionHelper_BASE; - -class FieldEnumeration : public FieldEnumeration_BASE -{ - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - uno::Reference< container::XEnumeration > mxEnumeration; -public: - FieldEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< container::XEnumeration >& xEnumeration ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxEnumeration( xEnumeration ) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return mxEnumeration->hasMoreElements(); - } - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - return lcl_createField( mxParent, mxContext, mxModel, mxEnumeration->nextElement() ); - } -}; - -class FieldCollectionHelper : public FieldCollectionHelper_BASE -{ - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - uno::Reference< container::XEnumerationAccess > mxEnumerationAccess; -public: - FieldCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) throw (css::uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) - { - uno::Reference< text::XTextFieldsSupplier > xSupp( xModel, uno::UNO_QUERY_THROW ); - mxEnumerationAccess.set( xSupp->getTextFields(), uno::UNO_QUERY_THROW ); - } - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return mxEnumerationAccess->getElementType(); } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return mxEnumerationAccess->hasElements(); } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - uno::Reference< container::XEnumeration > xEnumeration = mxEnumerationAccess->createEnumeration(); - sal_Int32 nCount = 0; - while( xEnumeration->hasMoreElements() ) - { - ++nCount; - xEnumeration->nextElement(); - } - return nCount; - } - 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< container::XEnumeration > xEnumeration = mxEnumerationAccess->createEnumeration(); - sal_Int32 nCount = 0; - while( xEnumeration->hasMoreElements() ) - { - if( nCount == Index ) - { - return xEnumeration->nextElement(); - } - ++nCount; - } - throw lang::IndexOutOfBoundsException(); - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - uno::Reference< container::XEnumeration > xEnumeration = mxEnumerationAccess->createEnumeration(); - return uno::Reference< container::XEnumeration >( new FieldEnumeration( mxParent, mxContext, mxModel, xEnumeration ) ); - } -}; - -SwVbaFields::SwVbaFields( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) : SwVbaFields_BASE( xParent, xContext , uno::Reference< container::XIndexAccess >( new FieldCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel ) -{ - mxMSF.set( mxModel, uno::UNO_QUERY_THROW ); -} - -uno::Reference< word::XField > SAL_CALL -SwVbaFields::Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& Type, const css::uno::Any& Text, const css::uno::Any& /*PreserveFormatting*/ ) throw (css::uno::RuntimeException) -{ - sal_Int32 nType = word::WdFieldType::wdFieldEmpty; - Type >>= nType; - rtl::OUString sText; - Text >>= sText; - - String sFieldName; - if( ( nType == word::WdFieldType::wdFieldEmpty ) && ( sText.getLength() > 0 ) ) - { - _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; - if( nType == word::WdFieldType::wdFieldFileName || sFieldName.EqualsIgnoreCaseAscii("FILENAME") ) - { - 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 >() ); - } - - SwVbaRange* pVbaRange = dynamic_cast< SwVbaRange* >( Range.get() ); - uno::Reference< text::XTextRange > xTextRange = pVbaRange->getXTextRange(); - uno::Reference< text::XText > xText = xTextRange->getText(); - xText->insertTextContent( xTextRange, xTextField, true ); - return uno::Reference< word::XField >( new SwVbaField( mxParent, mxContext, uno::Reference< text::XTextDocument >( mxModel, uno::UNO_QUERY_THROW ), uno::Reference< text::XTextField >( xTextField, uno::UNO_QUERY_THROW ) ) ); -} - -uno::Reference< text::XTextField > SwVbaFields::Create_Field_FileName( const rtl::OUString _text ) throw (uno::RuntimeException) -{ - uno::Reference< text::XTextField > xTextField( mxMSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.FileName")) ), uno::UNO_QUERY_THROW ); - sal_Int16 nFileFormat = text::FilenameDisplayFormat::NAME_AND_EXT; - if( _text.getLength() > 0 ) - { - long nRet; - _ReadFieldParams aReadParam( _text ); - while (-1 != (nRet = aReadParam.SkipToNextToken())) - { - switch (nRet) - { - case 'p': - nFileFormat = text::FilenameDisplayFormat::FULL; - break; - case '*': - //Skip over MERGEFORMAT - aReadParam.SkipToNextToken(); - break; - default: - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - break; - } - } - } - - uno::Reference< beans::XPropertySet > xProps( xTextField, uno::UNO_QUERY_THROW ); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FileFormat") ), uno::makeAny( nFileFormat ) ); - - 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::createFromAscii(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) -{ - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumerationAccess->createEnumeration(); -} - -// ScVbaCollectionBaseImpl -uno::Any -SwVbaFields::createCollectionObject( const uno::Any& aSource ) -{ - return lcl_createField( mxParent, mxContext, mxModel, aSource ); -} - -sal_Int32 SAL_CALL SwVbaFields::Update() throw (uno::RuntimeException) -{ - sal_Int32 nUpdate = 1; - try - { - uno::Reference< text::XTextFieldsSupplier > xSupp( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< util::XRefreshable > xRef( xSupp->getTextFields(), uno::UNO_QUERY_THROW ); - xRef->refresh(); - nUpdate = 0; - } - catch(const uno::Exception&) - { - nUpdate = 1; - } - return nUpdate; -} - -// XHelperInterface -rtl::OUString& -SwVbaFields::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFields") ); - return sImplName; -} - -// XEnumerationAccess -uno::Type SAL_CALL -SwVbaFields::getElementType() throw (uno::RuntimeException) -{ - return word::XField::static_type(0); -} - -uno::Sequence<rtl::OUString> -SwVbaFields::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Fields" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafield.hxx b/sw/source/ui/vba/vbafield.hxx deleted file mode 100644 index 57bdf44bb2..0000000000 --- a/sw/source/ui/vba/vbafield.hxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FIELD_HXX -#define SW_VBA_FIELD_HXX -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextField.hpp> -#include <ooo/vba/word/XField.hpp> -#include <ooo/vba/word/XFields.hpp> -#include <vbahelper/vbacollectionimpl.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XField > SwVbaField_BASE; - -class SwVbaField : public SwVbaField_BASE -{ - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::text::XTextField > mxTextField; -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(); -}; - -// *** SwVbaFields *********************************************** - -typedef CollTestImplHelper< ov::word::XFields > SwVbaFields_BASE; - -class SwVbaFields : public SwVbaFields_BASE -{ - css::uno::Reference< css::frame::XModel > mxModel; - 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 ); - // XFields - virtual css::uno::Reference< ::ooo::vba::word::XField > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& Type, const css::uno::Any& Text, const css::uno::Any& PreserveFormatting ) throw (css::uno::RuntimeException); - virtual sal_Int32 SAL_CALL Update() 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); - // ScVbaCollectionBaseImpl - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafind.cxx b/sw/source/ui/vba/vbafind.cxx deleted file mode 100644 index 25f1bcdc78..0000000000 --- a/sw/source/ui/vba/vbafind.cxx +++ /dev/null @@ -1,423 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbafind.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbareplacement.hxx" -#include <ooo/vba/word/WdFindWrap.hpp> -#include <ooo/vba/word/WdReplace.hpp> -#include <com/sun/star/text/XTextRangeCompare.hpp> -#include "wordvbahelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaFind::SwVbaFind( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : - SwVbaFind_BASE( rParent, rContext ), mxModel( xModel ), mxTextRange( xTextRange ), mbReplace( sal_False ), mnReplaceType( word::WdReplace::wdReplaceOne ), mnWrap( word::WdFindWrap::wdFindStop ) -{ - mxReplaceable.set( mxModel, uno::UNO_QUERY_THROW ); - mxPropertyReplace.set( mxReplaceable->createReplaceDescriptor(), uno::UNO_QUERY_THROW ); - mxTVC = word::getXTextViewCursor( mxModel ); - mxSelSupp.set( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); -} - -SwVbaFind::~SwVbaFind() -{ -} - -sal_Bool SwVbaFind::InRange( const uno::Reference< text::XTextRange >& xCurrentRange ) throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRangeCompare > xTRC( mxTextRange->getText(), uno::UNO_QUERY_THROW ); - if( xTRC->compareRegionStarts( mxTextRange, xCurrentRange ) >= 0 && xTRC->compareRegionEnds( mxTextRange, xCurrentRange ) <= 0 ) - return sal_True; - return sal_False; -} - -sal_Bool SwVbaFind::InEqualRange( const uno::Reference< text::XTextRange >& xCurrentRange ) throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRangeCompare > xTRC( mxTextRange->getText(), uno::UNO_QUERY_THROW ); - if( xTRC->compareRegionStarts( mxTextRange, xCurrentRange ) == 0 && xTRC->compareRegionEnds( mxTextRange, xCurrentRange ) == 0 ) - return sal_True; - return sal_False; -} - -void SwVbaFind::SetReplaceWith( const rtl::OUString& rText ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setReplaceString( rText ); - mbReplace = sal_True; -} - -rtl::OUString SwVbaFind::GetReplaceWith() throw (uno::RuntimeException) -{ - return mxPropertyReplace->getReplaceString(); -} -void SwVbaFind::SetReplace( sal_Int32 type ) -{ - mnReplaceType = type; - mbReplace = sal_True; -} -uno::Reference< text::XTextRange > SwVbaFind::FindOneElement() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xFoundOne; - if( mxTVC->getString().getLength() > 0 ) - { - if( getForward() ) - { - xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - } - else - { - xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - } - - if( xFoundOne.is() && InEqualRange( xFoundOne ) ) - { - xFoundOne.set( mxReplaceable->findNext( xFoundOne, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - } - else if( xFoundOne.is() && !InRange( xFoundOne ) ) - { - xFoundOne = uno::Reference< text::XTextRange >(); - } - } - else - { - xFoundOne.set( mxReplaceable->findNext( mxTextRange, uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - } - - if( !xFoundOne.is() && ( getWrap() == word::WdFindWrap::wdFindContinue || getWrap() == word::WdFindWrap::wdFindAsk ) ) - { - if( getForward() ) - { - mxTVC->gotoStart(sal_False); - xFoundOne.set( mxReplaceable->findNext( mxTextRange->getStart(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - } - else - { - mxTVC->gotoEnd( sal_False ); - xFoundOne.set( mxReplaceable->findNext( mxTextRange->getEnd(), uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ), uno::UNO_QUERY ); - - } - } - return xFoundOne; -} - -sal_Bool SwVbaFind::SearchReplace() throw (uno::RuntimeException) -{ - sal_Bool result = sal_False; - - // TODO: map wildcards in area to OOo wildcards - - if( mbReplace ) - { - switch( mnReplaceType ) - { - case word::WdReplace::wdReplaceNone: - { - result = sal_True; - break; - } - case word::WdReplace::wdReplaceOne: - { - uno::Reference< text::XTextRange > xFindOne = FindOneElement(); - if( xFindOne.is() ) - { - xFindOne->setString( GetReplaceWith() ); - result = mxSelSupp->select( uno::makeAny( xFindOne ) ); - } - break; - } - case word::WdReplace::wdReplaceAll: - { - uno::Reference< container::XIndexAccess > xIndexAccess = mxReplaceable->findAll( uno::Reference< util::XSearchDescriptor >( mxPropertyReplace, uno::UNO_QUERY_THROW ) ); - if( xIndexAccess->getCount() > 0 ) - { - for( sal_Int32 i = 0; i < xIndexAccess->getCount(); i++ ) - { - uno::Reference< text::XTextRange > xTextRange( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW ); - if( mnWrap == word::WdFindWrap::wdFindContinue || mnWrap == word::WdFindWrap::wdFindAsk || InRange( xTextRange ) ) - { - xTextRange->setString( GetReplaceWith() ); - result = sal_True; - } - } - } - break; - } - default: - { - result = sal_False; - } - } - } - else - { - uno::Reference< text::XTextRange > xFindOne = FindOneElement(); - if( xFindOne.is() ) - result = mxSelSupp->select( uno::makeAny( xFindOne ) ); - } - - return result; -} - -::rtl::OUString SAL_CALL SwVbaFind::getText() throw (uno::RuntimeException) -{ - return mxPropertyReplace->getSearchString(); -} - -void SAL_CALL SwVbaFind::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setSearchString( _text ); -} - -uno::Any SAL_CALL SwVbaFind::getReplacement() throw (uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< word::XReplacement >( new SwVbaReplacement( this, mxContext, mxPropertyReplace ) ) ); -} - -void SAL_CALL SwVbaFind::setReplacement( const uno::Any& /*_replacement */ ) throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -::sal_Bool SAL_CALL SwVbaFind::getForward() throw (uno::RuntimeException) -{ - sal_Bool bBackward = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ) ) >>= bBackward; - return !bBackward; -} - -void SAL_CALL SwVbaFind::setForward( ::sal_Bool _forward ) throw (uno::RuntimeException) -{ - sal_Bool bBackward = !_forward; - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchBackwards") ), uno::makeAny( bBackward ) ); -} - -::sal_Int32 SAL_CALL SwVbaFind::getWrap() throw (uno::RuntimeException) -{ - // seems not supported in Writer - return mnWrap; -} - -void SAL_CALL SwVbaFind::setWrap( ::sal_Int32 _wrap ) throw (uno::RuntimeException) -{ - // seems not supported in Writer - mnWrap = _wrap; -} - -::sal_Bool SAL_CALL SwVbaFind::getFormat() throw (uno::RuntimeException) -{ - return mxPropertyReplace->getValueSearch(); -} - -void SAL_CALL SwVbaFind::setFormat( ::sal_Bool _format ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setValueSearch( _format ); -} - -::sal_Bool SAL_CALL SwVbaFind::getMatchCase() throw (uno::RuntimeException) -{ - sal_Bool value = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ) ) >>= value; - return value; -} - -void SAL_CALL SwVbaFind::setMatchCase( ::sal_Bool _matchcase ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchCaseSensitive") ), uno::makeAny( _matchcase ) ); -} - -::sal_Bool SAL_CALL SwVbaFind::getMatchWholeWord() throw (uno::RuntimeException) -{ - sal_Bool value = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ) ) >>= value; - return value; -} - -void SAL_CALL SwVbaFind::setMatchWholeWord( ::sal_Bool _matchwholeword ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchWords") ), uno::makeAny( _matchwholeword ) ); -} - -::sal_Bool SAL_CALL SwVbaFind::getMatchWildcards() throw (uno::RuntimeException) -{ - sal_Bool value = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ) ) >>= value; - return value; -} - -void SAL_CALL SwVbaFind::setMatchWildcards( ::sal_Bool _matchwildcards ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchRegularExpression") ), uno::makeAny( _matchwildcards ) ); -} - -::sal_Bool SAL_CALL SwVbaFind::getMatchSoundsLike() throw (uno::RuntimeException) -{ - sal_Bool value = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ) ) >>= value; - return value; -} - -void SAL_CALL SwVbaFind::setMatchSoundsLike( ::sal_Bool _matchsoundslike ) throw (uno::RuntimeException) -{ - // seems not accurate - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ), uno::makeAny( _matchsoundslike ) ); -} - -::sal_Bool SAL_CALL SwVbaFind::getMatchAllWordForms() throw (uno::RuntimeException) -{ - sal_Bool value = sal_False; - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ) ) >>= value; - if( value ) - mxPropertyReplace->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ) ) >>= value; - return value; -} - -void SAL_CALL SwVbaFind::setMatchAllWordForms( ::sal_Bool _matchallwordforms ) throw (uno::RuntimeException) -{ - // seems not accurate - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarity") ), uno::makeAny( _matchallwordforms ) ); - mxPropertyReplace->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SearchSimilarityRelax") ), uno::makeAny( _matchallwordforms ) ); -} - -uno::Any SAL_CALL SwVbaFind::getStyle() throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -void SAL_CALL SwVbaFind::setStyle( const uno::Any& /*_style */ ) throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -sal_Bool SAL_CALL -SwVbaFind::Execute( const uno::Any& FindText, const uno::Any& MatchCase, const uno::Any& MatchWholeWord, const uno::Any& MatchWildcards, const uno::Any& MatchSoundsLike, const uno::Any& MatchAllWordForms, const uno::Any& Forward, const uno::Any& Wrap, const uno::Any& Format, const uno::Any& ReplaceWith, const uno::Any& Replace, const uno::Any& /*MatchKashida*/, const uno::Any& /*MatchDiacritics*/, const uno::Any& /*MatchAlefHamza*/, const uno::Any& /*MatchControl*/, const uno::Any& /*MatchPrefix*/, const uno::Any& /*MatchSuffix*/, const uno::Any& /*MatchPhrase*/, const uno::Any& /*IgnoreSpace*/, const uno::Any& /*IgnorePunct*/ ) throw (uno::RuntimeException) -{ - sal_Bool result = sal_False; - if( FindText.hasValue() ) - { - rtl::OUString sText; - FindText >>= sText; - setText( sText ); - } - - sal_Bool bValue = sal_False; - if( MatchCase.hasValue() ) - { - MatchCase >>= bValue; - setMatchCase( bValue ); - } - - if( MatchWholeWord.hasValue() ) - { - MatchWholeWord >>= bValue; - setMatchWholeWord( bValue ); - } - - if( MatchWildcards.hasValue() ) - { - MatchWildcards >>= bValue; - setMatchWildcards( bValue ); - } - - if( MatchSoundsLike.hasValue() ) - { - MatchSoundsLike >>= bValue; - setMatchSoundsLike( bValue ); - } - - if( MatchAllWordForms.hasValue() ) - { - MatchAllWordForms >>= bValue; - setMatchAllWordForms( bValue ); - } - - if( Forward.hasValue() ) - { - Forward >>= bValue; - setForward( bValue ); - } - - if( Wrap.hasValue() ) - { - sal_Int32 nWrapType = 0; - Wrap >>= nWrapType; - setWrap( nWrapType ); - } - - if( Format.hasValue() ) - { - Format >>= bValue; - setFormat( bValue ); - } - - if( ReplaceWith.hasValue() ) - { - rtl::OUString sValue; - ReplaceWith >>= sValue; - SetReplaceWith( sValue ); - } - - if( Replace.hasValue() ) - { - sal_Int32 nValue(0); - Replace >>= nValue; - SetReplace( nValue ); - } - - result = SearchReplace(); - - return result; -} - -void SAL_CALL -SwVbaFind::ClearFormatting( ) throw (uno::RuntimeException) -{ - uno::Sequence< beans::PropertyValue > aSearchAttribs; - mxPropertyReplace->setSearchAttributes( aSearchAttribs ); -} - -rtl::OUString& -SwVbaFind::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFind") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaFind::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Find" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafind.hxx b/sw/source/ui/vba/vbafind.hxx deleted file mode 100644 index da07d2fd5a..0000000000 --- a/sw/source/ui/vba/vbafind.hxx +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FIND_HXX -#define SW_VBA_FIND_HXX - -#include <ooo/vba/word/XFind.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/util/XReplaceable.hpp> -#include <com/sun/star/util/XPropertyReplace.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextCursor.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XFind > SwVbaFind_BASE; - -class SwVbaFind : public SwVbaFind_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextRange > mxTextRange; - css::uno::Reference< css::util::XReplaceable > mxReplaceable; - css::uno::Reference< css::util::XPropertyReplace> mxPropertyReplace; - css::uno::Reference< css::text::XTextViewCursor> mxTVC; - css::uno::Reference< css::view::XSelectionSupplier> mxSelSupp; - sal_Bool mbReplace; - sal_Int32 mnReplaceType; - sal_Int32 mnWrap; - -private: - sal_Bool InRange( const css::uno::Reference< css::text::XTextRange >& xCurrentRange ) throw ( css::uno::RuntimeException ); - sal_Bool InEqualRange( const css::uno::Reference< css::text::XTextRange >& xCurrentRange ) throw ( css::uno::RuntimeException ); - void SetReplace( sal_Int32 type ); - void SetReplaceWith( const rtl::OUString& rText ) throw ( css::uno::RuntimeException ); - rtl::OUString GetReplaceWith() throw ( css::uno::RuntimeException ); - css::uno::Reference< css::text::XTextRange > FindOneElement() throw ( css::uno::RuntimeException ); - sal_Bool SearchReplace() throw ( css::uno::RuntimeException ); - -public: - SwVbaFind( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaFind(); - - // Attributes - virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException); - virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getReplacement() throw (css::uno::RuntimeException); - virtual void SAL_CALL setReplacement( const css::uno::Any& _replacement ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getForward() throw (css::uno::RuntimeException); - virtual void SAL_CALL setForward( ::sal_Bool _forward ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getWrap() throw (css::uno::RuntimeException); - virtual void SAL_CALL setWrap( ::sal_Int32 _wrap ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getFormat() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFormat( ::sal_Bool _format ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMatchCase() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMatchCase( ::sal_Bool _matchcase ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMatchWholeWord() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMatchWholeWord( ::sal_Bool _matchwholeword ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMatchWildcards() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMatchWildcards( ::sal_Bool _matchwildcards ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMatchSoundsLike() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMatchSoundsLike( ::sal_Bool _matchsoundslike ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMatchAllWordForms() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMatchAllWordForms( ::sal_Bool _matchallwordforms ) 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); - - // Methods - virtual ::sal_Bool SAL_CALL Execute( const css::uno::Any& FindText, const css::uno::Any& MatchCase, const css::uno::Any& MatchWholeWord, const css::uno::Any& MatchWildcards, const css::uno::Any& MatchSoundsLike, const css::uno::Any& MatchAllWordForms, const css::uno::Any& Forward, const css::uno::Any& Wrap, const css::uno::Any& Format, const css::uno::Any& ReplaceWith, const css::uno::Any& Replace, const css::uno::Any& MatchKashida, const css::uno::Any& MatchDiacritics, const css::uno::Any& MatchAlefHamza, const css::uno::Any& MatchControl, const css::uno::Any& MatchPrefix, const css::uno::Any& MatchSuffix, const css::uno::Any& MatchPhrase, const css::uno::Any& IgnoreSpace, const css::uno::Any& IgnorePunct ) throw (css::uno::RuntimeException); - virtual void SAL_CALL ClearFormatting( ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_FIND_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafont.cxx b/sw/source/ui/vba/vbafont.cxx deleted file mode 100644 index 4553c4705a..0000000000 --- a/sw/source/ui/vba/vbafont.cxx +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "vbafont.hxx" -#include <com/sun/star/awt/FontUnderline.hpp> -#include <ooo/vba/word/WdUnderline.hpp> -#include <boost/unordered_map.hpp> -#include <sal/macros.h> -#include <ooo/vba/word/WdColorIndex.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -const uno::Any aLongAnyTrue( sal_Int16(-1) ); -const uno::Any aLongAnyFalse( sal_Int16( 0 ) ); - -struct MapPair -{ - sal_Int32 nMSOConst; - sal_Int32 nOOOConst; -}; - -static MapPair UnderLineTable[] = { - { word::WdUnderline::wdUnderlineNone, com::sun::star::awt::FontUnderline::NONE }, - { word::WdUnderline::wdUnderlineSingle, com::sun::star::awt::FontUnderline::SINGLE }, - { word::WdUnderline::wdUnderlineWords, com::sun::star::awt::FontUnderline::SINGLE }, - { word::WdUnderline::wdUnderlineDouble, com::sun::star::awt::FontUnderline::DOUBLE }, - { word::WdUnderline::wdUnderlineDotted, com::sun::star::awt::FontUnderline::DOTTED }, - { word::WdUnderline::wdUnderlineThick, com::sun::star::awt::FontUnderline::BOLDDASH }, - { word::WdUnderline::wdUnderlineDash, com::sun::star::awt::FontUnderline::DASH }, - { word::WdUnderline::wdUnderlineDotDash, com::sun::star::awt::FontUnderline::DASHDOT }, - { word::WdUnderline::wdUnderlineDotDotDash, com::sun::star::awt::FontUnderline::DASHDOTDOT }, - { word::WdUnderline::wdUnderlineWavy, com::sun::star::awt::FontUnderline::WAVE }, - { word::WdUnderline::wdUnderlineDottedHeavy, com::sun::star::awt::FontUnderline::BOLDDOTTED }, - { word::WdUnderline::wdUnderlineDashHeavy, com::sun::star::awt::FontUnderline::BOLDDASH }, - { word::WdUnderline::wdUnderlineDotDashHeavy, com::sun::star::awt::FontUnderline::BOLDDASHDOT }, - { word::WdUnderline::wdUnderlineDotDotDashHeavy, com::sun::star::awt::FontUnderline::BOLDDASHDOTDOT }, - { word::WdUnderline::wdUnderlineWavyHeavy, com::sun::star::awt::FontUnderline::BOLDWAVE }, - { word::WdUnderline::wdUnderlineDashLong, com::sun::star::awt::FontUnderline::LONGDASH }, - { word::WdUnderline::wdUnderlineWavyDouble, com::sun::star::awt::FontUnderline::DOUBLEWAVE }, - { word::WdUnderline::wdUnderlineDashLongHeavy, com::sun::star::awt::FontUnderline::BOLDLONGDASH }, -}; - -typedef boost::unordered_map< sal_Int32, sal_Int32 > ConstToConst; -class UnderLineMapper -{ - ConstToConst MSO2OOO; - ConstToConst OOO2MSO; -private: - UnderLineMapper() - { - sal_Int32 nLen = SAL_N_ELEMENTS( UnderLineTable ); - - for ( sal_Int32 index=0; index<nLen; ++index ) - { - MSO2OOO[ UnderLineTable[ index ].nMSOConst ] = UnderLineTable[ index ].nOOOConst; - OOO2MSO[ UnderLineTable[ index ].nOOOConst ] = UnderLineTable[ index ].nMSOConst; - } - } -public: - static rtl::OUString propName() - { - static rtl::OUString sPropName( RTL_CONSTASCII_USTRINGPARAM("CharUnderline") ); - return sPropName; - } - - static UnderLineMapper& instance() - { - static UnderLineMapper theMapper; - return theMapper; - } - - sal_Int32 getOOOFromMSO( sal_Int32 nMSOConst ) throw( lang::IllegalArgumentException ) - { - ConstToConst::iterator it = MSO2OOO.find( nMSOConst ); - if ( it == MSO2OOO.end() ) - throw lang::IllegalArgumentException(); - return it->second; - } - sal_Int32 getMSOFromOOO( sal_Int32 nOOOConst ) throw( lang::IllegalArgumentException ) - { - ConstToConst::iterator it = OOO2MSO.find( nOOOConst ); - if ( it == OOO2MSO.end() ) - throw lang::IllegalArgumentException(); - return it->second; - } -}; - -SwVbaFont::SwVbaFont( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xPalette, uno::Reference< css::beans::XPropertySet > xPropertySet ) throw ( css::uno::RuntimeException ) : SwVbaFont_BASE( xParent, xContext, xPalette, xPropertySet ) -{ -} - -uno::Any SAL_CALL -SwVbaFont::getUnderline() throw (uno::RuntimeException) -{ - sal_Int32 nOOVal = 0; - mxFont->getPropertyValue( UnderLineMapper::propName() ) >>= nOOVal; - return uno::makeAny( UnderLineMapper::instance().getMSOFromOOO( nOOVal ) ); -} - -void SAL_CALL -SwVbaFont::setUnderline( const uno::Any& _underline ) throw (uno::RuntimeException) -{ - sal_Int32 nMSOVal = 0; - - if ( _underline >>= nMSOVal ) - { - sal_Int32 nOOVal = UnderLineMapper::instance().getOOOFromMSO( nMSOVal ); - mxFont->setPropertyValue( UnderLineMapper::propName(), uno::makeAny( nOOVal ) ); - } -} - -rtl::OUString& -SwVbaFont::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFont") ); - return sImplName; -} - -void SAL_CALL -SwVbaFont::setColorIndex( const uno::Any& _colorindex ) throw( uno::RuntimeException ) -{ - sal_Int32 nIndex = 0; - _colorindex >>= nIndex; - return setColor( OORGBToXLRGB(mxPalette->getByIndex( nIndex )) ); -} - -uno::Any SAL_CALL -SwVbaFont::getColorIndex() throw ( uno::RuntimeException ) -{ - sal_Int32 nColor = 0; - - XLRGBToOORGB( getColor() ) >>= nColor; - sal_Int32 nElems = mxPalette->getCount(); - sal_Int32 nIndex = 0; - for ( sal_Int32 count=0; count<nElems; ++count ) - { - sal_Int32 nPaletteColor = 0; - mxPalette->getByIndex( count ) >>= nPaletteColor; - if ( nPaletteColor == nColor ) - { - nIndex = count; - break; - } - } - return uno::makeAny( nIndex ); -} -uno::Any SAL_CALL -SwVbaFont::getSubscript() throw ( uno::RuntimeException ) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getSubscript() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Any SAL_CALL -SwVbaFont::getSuperscript() throw ( uno::RuntimeException ) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getSuperscript() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Any SAL_CALL -SwVbaFont::getBold() throw (uno::RuntimeException) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getBold() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Any SAL_CALL -SwVbaFont::getItalic() throw (uno::RuntimeException) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getItalic() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Any SAL_CALL -SwVbaFont::getStrikethrough() throw (css::uno::RuntimeException) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getStrikethrough() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Any SAL_CALL -SwVbaFont::getShadow() throw (uno::RuntimeException) -{ - sal_Bool bRes = sal_False; - SwVbaFont_BASE::getShadow() >>= bRes; - if ( bRes ) - return aLongAnyTrue; - return aLongAnyFalse; -} - -uno::Sequence< rtl::OUString > -SwVbaFont::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Font" ) ); - } - return aServiceNames; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbafont.hxx b/sw/source/ui/vba/vbafont.hxx deleted file mode 100644 index fead5bf58b..0000000000 --- a/sw/source/ui/vba/vbafont.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef VBA_FONT_HXX -#define VBA_FONT_HXX - -#include <vbahelper/vbafontbase.hxx> -#include <ooo/vba/word/XFont.hpp> - -typedef cppu::ImplInheritanceHelper1< VbaFontBase, ov::word::XFont > SwVbaFont_BASE; - -class SwVbaFont : public SwVbaFont_BASE -{ -public: - SwVbaFont( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XIndexAccess >& xPalette, css::uno::Reference< css::beans::XPropertySet > xPropertySet ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaFont(){} - - // Attributes - virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getColorIndex() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getUnderline() throw (css::uno::RuntimeException); - virtual void SAL_CALL setUnderline( const css::uno::Any& _underline ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getSubscript() throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL getSuperscript() throw ( css::uno::RuntimeException ); - - virtual css::uno::Any SAL_CALL getBold() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getItalic() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getStrikethrough() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getShadow() throw (css::uno::RuntimeException); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaformfield.cxx b/sw/source/ui/vba/vbaformfield.cxx deleted file mode 100644 index ed6bf39a60..0000000000 --- a/sw/source/ui/vba/vbaformfield.cxx +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaformfield.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextContent.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <ecmaflds.hxx> -#include "vbacheckbox.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaFormField::SwVbaFormField( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& rModel, const uno::Reference< text::XFormField >& xFormField ) throw ( uno::RuntimeException ) : SwVbaFormField_BASE( rParent, rContext ), mxModel( rModel ), mxFormField( xFormField ) -{ -} - -SwVbaFormField::~SwVbaFormField() -{ -} - -rtl::OUString SAL_CALL SwVbaFormField::getResult() throw ( uno::RuntimeException ) -{ - rtl::OUString sResult; - rtl::OUString sType = mxFormField->getFieldType(); - if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMTEXT ) ) - { - uno::Reference< text::XTextContent > xTextContent( mxFormField, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextRange > xTextRange = xTextContent->getAnchor(); - sResult = xTextRange->getString(); - } - else if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) ) - { - sal_Int32 nValue = 0; - sal_Int32 nCount = mxFormField->getParamCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - if( mxFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX_CHECKED ) ) - { - if( mxFormField->getParamValue(i).equalsIgnoreAsciiCaseAscii("on") ) - nValue = 1; - else - nValue = 0; - break; - } - - } - sResult = rtl::OUString::valueOf( nValue ); - } - else - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } - return sResult; -} - -void SAL_CALL SwVbaFormField::setResult( const rtl::OUString& result ) throw ( uno::RuntimeException ) -{ - rtl::OUString sType = mxFormField->getFieldType(); - if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMTEXT ) ) - { - uno::Reference< text::XTextContent > xTextContent( mxFormField, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextRange > xTextRange = xTextContent->getAnchor(); - xTextRange->setString( result ); - } - else if( sType.equalsIgnoreAsciiCaseAscii( ECMA_FORMCHECKBOX ) ) - { - // do nothing - } - else - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } -} - -sal_Bool SAL_CALL SwVbaFormField::getEnabled() throw ( uno::RuntimeException ) -{ - //allways return true - return sal_True; -} - -void SAL_CALL SwVbaFormField::setEnabled( sal_Bool/* enabled */ ) throw ( uno::RuntimeException ) -{ - // not support in Writer -} - -uno::Any SAL_CALL SwVbaFormField::CheckBox() throw ( uno::RuntimeException ) -{ - return uno::makeAny( uno::Reference< word::XCheckBox >( new SwVbaCheckBox( this, mxContext, mxModel, mxFormField ) ) ); -} - -rtl::OUString& -SwVbaFormField::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFormField") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaFormField::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.FormField" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaformfield.hxx b/sw/source/ui/vba/vbaformfield.hxx deleted file mode 100644 index 00ba837443..0000000000 --- a/sw/source/ui/vba/vbaformfield.hxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FORMFIELD_HXX -#define SW_VBA_FORMFIELD_HXX - -#include <ooo/vba/word/XFormField.hpp> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XFormField.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XFormField > SwVbaFormField_BASE; - -class SwVbaFormField : public SwVbaFormField_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XFormField > mxFormField; - -public: - SwVbaFormField( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XFormField >& xFormField ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaFormField(); - - // Methods - rtl::OUString SAL_CALL getResult() throw ( css::uno::RuntimeException ); - void SAL_CALL setResult( const rtl::OUString& result ) throw ( css::uno::RuntimeException ); - sal_Bool SAL_CALL getEnabled() throw ( css::uno::RuntimeException ); - void SAL_CALL setEnabled( sal_Bool enabled ) throw ( css::uno::RuntimeException ); - css::uno::Any SAL_CALL CheckBox() throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_FORMFIELD_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaformfields.cxx b/sw/source/ui/vba/vbaformfields.cxx deleted file mode 100644 index 43c8e3cd5e..0000000000 --- a/sw/source/ui/vba/vbaformfields.cxx +++ /dev/null @@ -1,205 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaformfields.hxx" -#include "vbaformfield.hxx" -#include <com/sun/star/container/XNamed.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include "wordvbahelper.hxx" -#include <cppuhelper/implbase3.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef std::vector< uno::Reference< text::XFormField > > XFormFieldVec; -typedef ::cppu::WeakImplHelper1< container::XEnumeration > FormFiledEnumeration_BASE; -typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > FormFieldCollectionHelper_BASE; - -rtl::OUString lcl_getFormFieldName( const uno::Reference< text::XFormField >& xFormField ) -{ - rtl::OUString sName; - sal_Int32 nCount = xFormField->getParamCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - if( xFormField->getParamName(i).equalsIgnoreAsciiCaseAscii( "Name" ) ) - { - sName = xFormField->getParamValue(i); - OSL_TRACE("lcl_getFormFieldName: %s", rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() ); - break; - } - } - return sName; -} - -class FormFieldsEnumeration : public FormFiledEnumeration_BASE -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - XFormFieldVec mxFormFields; - XFormFieldVec::iterator cachePos; -public: - FormFieldsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const XFormFieldVec& xFormFiels ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxFormFields( xFormFiels ), cachePos( mxFormFields.begin() ) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( cachePos != mxFormFields.end() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - uno::Reference< text::XFormField > xFormField( *cachePos++ ); - return uno::makeAny( uno::Reference< word::XFormField > ( new SwVbaFormField( mxParent, mxContext, mxModel, xFormField ) ) ); - } - -}; - -class FormFieldCollectionHelper : public FormFieldCollectionHelper_BASE -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - XFormFieldVec mxFormFields; - XFormFieldVec::iterator cachePos; -public: - FormFieldCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) - { - uno::Reference< text::XBookmarksSupplier > xBookmarksSupplier( xModel,uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xIndexAccess( xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xIndexAccess->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - uno::Reference< text::XFormField > xFormField( xIndexAccess->getByIndex( i ), uno::UNO_QUERY ); - if( xFormField.is() ) - mxFormFields.push_back( xFormField ); - } - cachePos = mxFormFields.begin(); - } - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return word::XFormField::static_type(0); } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return getCount() > 0 ; } - // XNameAcess - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasByName(aName) ) - throw container::NoSuchElementException(); - uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XFormField >( new SwVbaFormField( mxParent, mxContext, mxModel, xFormField ) ) ); - } - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - uno::Sequence< rtl::OUString > sNames( mxFormFields.size() ); - rtl::OUString* pString = sNames.getArray(); - XFormFieldVec::iterator it = mxFormFields.begin(); - XFormFieldVec::iterator it_end = mxFormFields.end(); - for ( ; it != it_end; ++it, ++pString ) - { - uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW ); - *pString = lcl_getFormFieldName( xFormField ); - } - return sNames; - } - virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException) - { - cachePos = mxFormFields.begin(); - XFormFieldVec::iterator it_end = mxFormFields.end(); - for ( ; cachePos != it_end; ++cachePos ) - { - //uno::Reference< container::XNamed > xName( *cachePos, uno::UNO_QUERY_THROW ); - uno::Reference< text::XFormField > xFormField( *cachePos, uno::UNO_QUERY_THROW ); - if ( aName.equalsIgnoreAsciiCase( lcl_getFormFieldName( xFormField )) ) - break; - } - return ( cachePos != it_end ); - } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return mxFormFields.size(); - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) - { - if ( Index < 0 || Index >= getCount() ) - throw lang::IndexOutOfBoundsException(); - return uno::makeAny( uno::Reference< word::XFormField >( new SwVbaFormField( mxParent, mxContext, mxModel, mxFormFields[ Index ] ) ) ); - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new FormFieldsEnumeration( mxParent, mxContext, mxModel, mxFormFields ); - } -}; - -SwVbaFormFields::SwVbaFormFields( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaFormFields_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new FormFieldCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel ) -{ -} -// XEnumerationAccess -uno::Type -SwVbaFormFields::getElementType() throw (uno::RuntimeException) -{ - return word::XFormField::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaFormFields::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumAccess->createEnumeration(); -} - -uno::Any -SwVbaFormFields::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaFormFields::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFormFields") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaFormFields::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.FormFields") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaformfields.hxx b/sw/source/ui/vba/vbaformfields.hxx deleted file mode 100644 index 335fceb743..0000000000 --- a/sw/source/ui/vba/vbaformfields.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FORMFIELDS_HXX -#define SW_VBA_FORMFIELDS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XFormFields.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XBookmarksSupplier.hpp> -#include <com/sun/star/text/XTextRange.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XFormFields > SwVbaFormFields_BASE; - -class SwVbaFormFields : public SwVbaFormFields_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - -public: - SwVbaFormFields( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel ); - virtual ~SwVbaFormFields() {} - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaFormFields_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_FORMFIELDS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaframe.cxx b/sw/source/ui/vba/vbaframe.cxx deleted file mode 100644 index 04d13a0967..0000000000 --- a/sw/source/ui/vba/vbaframe.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaframe.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextContent.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaFrame::SwVbaFrame( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const css::uno::Reference< frame::XModel >& rModel, const css::uno::Reference< text::XTextFrame >& xTextFrame ) throw ( css::uno::RuntimeException ) : - SwVbaFrame_BASE( rParent, rContext ), mxModel( rModel ), mxTextFrame( xTextFrame ) -{ -} - -SwVbaFrame::~SwVbaFrame() -{ -} - -void SAL_CALL SwVbaFrame::Select() throw ( uno::RuntimeException ) -{ - uno::Reference< view::XSelectionSupplier > xSelectSupp( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); - xSelectSupp->select( uno::makeAny( mxTextFrame ) ); -} - -rtl::OUString& -SwVbaFrame::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFrame") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaFrame::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frame" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaframe.hxx b/sw/source/ui/vba/vbaframe.hxx deleted file mode 100644 index 745d5f2096..0000000000 --- a/sw/source/ui/vba/vbaframe.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FRAME_HXX -#define SW_VBA_FRAME_HXX - -#include <ooo/vba/word/XFrame.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextFrame.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XFrame > SwVbaFrame_BASE; - -class SwVbaFrame : public SwVbaFrame_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextFrame > mxTextFrame; - -public: - SwVbaFrame( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& rModel, const css::uno::Reference< css::text::XTextFrame >& xTextFrame ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaFrame(); - - // Methods - virtual void SAL_CALL Select() throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_FRAME_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaframes.cxx b/sw/source/ui/vba/vbaframes.cxx deleted file mode 100644 index e3aba63cfb..0000000000 --- a/sw/source/ui/vba/vbaframes.cxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaframes.hxx" -#include "vbaframe.hxx" -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include "wordvbahelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef ::cppu::WeakImplHelper1< container::XEnumeration > FramesEnumeration_Base; -class FramesEnumeration : public FramesEnumeration_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< container::XIndexAccess> mxIndexAccess; - uno::Reference< frame::XModel > mxModel; - sal_Int32 nCurrentPos; -public: - FramesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : mxParent( xParent ), mxContext( xContext), mxIndexAccess( xIndexAccess ), mxModel( xModel ), nCurrentPos(0) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nCurrentPos < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - uno::Reference< text::XTextFrame > xTextFrame( mxIndexAccess->getByIndex( nCurrentPos++ ), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( mxParent, mxContext, mxModel, xTextFrame ) ) ); - } - -}; - -SwVbaFrames::SwVbaFrames( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xFrames, const uno::Reference< frame::XModel >& xModel ): SwVbaFrames_BASE( xParent, xContext, xFrames ), mxModel( xModel ) -{ - mxFramesSupplier.set( mxModel, uno::UNO_QUERY_THROW ); -} -// XEnumerationAccess -uno::Type -SwVbaFrames::getElementType() throw (uno::RuntimeException) -{ - return word::XFrame::static_type(0); -} - -uno::Reference< container::XEnumeration > -SwVbaFrames::createEnumeration() throw (uno::RuntimeException) -{ - return new FramesEnumeration( this, mxContext,m_xIndexAccess, mxModel ); -} - -uno::Any -SwVbaFrames::createCollectionObject( const css::uno::Any& aSource ) -{ - uno::Reference< text::XTextFrame > xTextFrame( aSource, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XFrame > ( new SwVbaFrame( this, mxContext, mxModel, xTextFrame ) ) ); -} - -rtl::OUString& -SwVbaFrames::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaFrames") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaFrames::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Frames") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaframes.hxx b/sw/source/ui/vba/vbaframes.hxx deleted file mode 100644 index 38015fd47c..0000000000 --- a/sw/source/ui/vba/vbaframes.hxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_FRAMES_HXX -#define SW_VBA_FRAMES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XFrames.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextFramesSupplier.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XFrames > SwVbaFrames_BASE; - -class SwVbaFrames : public SwVbaFrames_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextFramesSupplier > mxFramesSupplier; - -public: - SwVbaFrames( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xFrames, const css::uno::Reference< css::frame::XModel >& xModel ); - virtual ~SwVbaFrames() {} - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaFrames_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - -}; - -#endif /* SW_VBA_FRAMES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaglobals.cxx b/sw/source/ui/vba/vbaglobals.cxx deleted file mode 100644 index d7d975549e..0000000000 --- a/sw/source/ui/vba/vbaglobals.cxx +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <vbahelper/helperdecl.hxx> -#include "vbaglobals.hxx" -#include <sal/macros.h> -#include <comphelper/unwrapargs.hxx> - -#include <com/sun/star/lang/XMultiComponentFactory.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <cppuhelper/bootstrap.hxx> -#include "vbaapplication.hxx" -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::ooo::vba; - - -rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("WordDocumentContext") ); - -// ============================================================================= -// SwVbaGlobals -// ============================================================================= - -SwVbaGlobals::SwVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : SwVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName ) -{ - OSL_TRACE("SwVbaGlobals::SwVbaGlobals()"); - uno::Sequence< beans::PropertyValue > aInitArgs( 2 ); - aInitArgs[ 0 ].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Application")); - aInitArgs[ 0 ].Value = uno::makeAny( getApplication() ); - aInitArgs[ 1 ].Name = sDocCtxName; - aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) ); - - init( aInitArgs ); -} - -SwVbaGlobals::~SwVbaGlobals() -{ - OSL_TRACE("SwVbaGlobals::~SwVbaGlobals"); -} - -// ============================================================================= -// XGlobals -// ============================================================================= -uno::Reference<word::XApplication > -SwVbaGlobals::getApplication() throw (uno::RuntimeException) -{ - OSL_TRACE("In SwVbaGlobals::getApplication"); - if ( !mxApplication.is() ) - mxApplication.set( new SwVbaApplication( mxContext) ); - - return mxApplication; -} - -uno::Reference<word::XSystem > SAL_CALL -SwVbaGlobals::getSystem() throw (uno::RuntimeException) -{ - return getApplication()->getSystem(); -} - -uno::Reference< word::XDocument > SAL_CALL -SwVbaGlobals::getActiveDocument() throw (uno::RuntimeException) -{ - return getApplication()->getActiveDocument(); -} - -uno::Reference< word::XWindow > SAL_CALL -SwVbaGlobals::getActiveWindow() throw (uno::RuntimeException) -{ - return getApplication()->getActiveWindow(); -} - -rtl::OUString SAL_CALL -SwVbaGlobals::getName() throw (uno::RuntimeException) -{ - return getApplication()->getName(); -} - -uno::Reference<word::XOptions > SAL_CALL -SwVbaGlobals::getOptions() throw (uno::RuntimeException) -{ - return getApplication()->getOptions(); -} - -uno::Any SAL_CALL -SwVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException) -{ - return getApplication()->CommandBars( aIndex ); -} - -uno::Any SAL_CALL -SwVbaGlobals::Documents( const uno::Any& index ) throw (uno::RuntimeException) -{ - return getApplication()->Documents( index ); -} - -uno::Any SAL_CALL -SwVbaGlobals::Addins( const uno::Any& index ) throw (uno::RuntimeException) -{ - return getApplication()->Addins( index ); -} - -uno::Any SAL_CALL -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) -{ - return getApplication()->getSelection(); -} - -float SAL_CALL SwVbaGlobals::CentimetersToPoints( float _Centimeters ) throw (uno::RuntimeException) -{ - return getApplication()->CentimetersToPoints( _Centimeters ); -} - -rtl::OUString& -SwVbaGlobals::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaGlobals") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaGlobals::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Globals" ) ); - } - return aServiceNames; -} - -uno::Sequence< rtl::OUString > -SwVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) -{ - static bool bInit = false; - static uno::Sequence< rtl::OUString > serviceNames( SwVbaGlobals_BASE::getAvailableServiceNames() ); - if ( !bInit ) - { - rtl::OUString names[] = { - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Document" ) ), -// #FIXME #TODO make Application a proper service -// ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.word.Application" ) ), - }; - sal_Int32 nWordServices = SAL_N_ELEMENTS( names ); - sal_Int32 startIndex = serviceNames.getLength(); - serviceNames.realloc( serviceNames.getLength() + nWordServices ); - for ( sal_Int32 index = 0; index < nWordServices; ++index ) - serviceNames[ startIndex + index ] = names[ index ]; - bInit = true; - } - return serviceNames; -} - -namespace globals -{ -namespace sdecl = comphelper::service_decl; -sdecl::vba_service_class_<SwVbaGlobals, sdecl::with_args<true> > serviceImpl; -extern sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "SwVbaGlobals", - "ooo.vba.word.Globals" ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaglobals.hxx b/sw/source/ui/vba/vbaglobals.hxx deleted file mode 100644 index 3ad5cf4195..0000000000 --- a/sw/source/ui/vba/vbaglobals.hxx +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_GLOBALS_HXX -#define SW_VBA_GLOBALS_HXX - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <ooo/vba/word/XGlobals.hpp> -#include <ooo/vba/word/XApplication.hpp> -#include <ooo/vba/word/XSystem.hpp> -#include <ooo/vba/word/XOptions.hpp> -#include <ooo/vba/word/XSelection.hpp> -#include <cppuhelper/implbase1.hxx> -#include <vbahelper/vbahelper.hxx> -#include <vbahelper/vbaglobalbase.hxx> - -// ============================================================================= -// class SwVbaGlobals -// ============================================================================= - - -typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::word::XGlobals > SwVbaGlobals_BASE; - -class SwVbaGlobals : public SwVbaGlobals_BASE -{ -private: - css::uno::Reference< ooo::vba::word::XApplication > mxApplication; - - virtual css::uno::Reference< ooo::vba::word::XApplication > getApplication() throw (css::uno::RuntimeException); - -public: - - SwVbaGlobals( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& rxContext ); - virtual ~SwVbaGlobals(); - - // XGlobals - virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XSystem > SAL_CALL getSystem() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ov::word::XDocument > SAL_CALL getActiveDocument() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ov::word::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XOptions > SAL_CALL getOptions() throw (css::uno::RuntimeException); - virtual css::uno::Reference< ooo::vba::word::XSelection > SAL_CALL getSelection() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - 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); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_GLOBALS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheaderfooter.cxx b/sw/source/ui/vba/vbaheaderfooter.cxx deleted file mode 100644 index 0a7bd993d6..0000000000 --- a/sw/source/ui/vba/vbaheaderfooter.cxx +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaheaderfooter.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <ooo/vba/word/WdHeaderFooterIndex.hpp> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/drawing/XDrawPageSupplier.hpp> -#include "vbarange.hxx" -#include <vbahelper/vbashapes.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaHeaderFooter::SwVbaHeaderFooter( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& rProps, sal_Bool isHeader, sal_Int32 index ) throw ( uno::RuntimeException ) : SwVbaHeaderFooter_BASE( rParent, rContext ), mxModel( xModel ), mxPageStyleProps( rProps ), mbHeader( isHeader ), mnIndex( index ) -{ -} - -sal_Bool SAL_CALL SwVbaHeaderFooter::getIsHeader() throw (uno::RuntimeException) -{ - return mbHeader; -} - -sal_Bool SAL_CALL SwVbaHeaderFooter::getLinkToPrevious() throw (uno::RuntimeException) -{ - // seems always false - return sal_False; -} - -void SAL_CALL SwVbaHeaderFooter::setLinkToPrevious( ::sal_Bool /*_linktoprevious*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -uno::Reference< word::XRange > SAL_CALL SwVbaHeaderFooter::getRange() throw (uno::RuntimeException) -{ - rtl::OUString sPropsNameText; - if( mbHeader ) - { - sPropsNameText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") ); - } - else - { - sPropsNameText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") ); - } - if( mnIndex == word::WdHeaderFooterIndex::wdHeaderFooterEvenPages ) - { - sPropsNameText.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Left") ) ); - } - - uno::Reference< text::XText > xText( mxPageStyleProps->getPropertyValue( sPropsNameText ), uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW ); - return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xText->getStart(), xText->getEnd(), xText ) ); -} - -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 ); - uno::Reference< XCollection > xCol( new ScVbaShapes( this, mxContext, xIndexAccess, mxModel ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -rtl::OUString& -SwVbaHeaderFooter::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaHeaderFooter") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaHeaderFooter::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Pane" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheaderfooter.hxx b/sw/source/ui/vba/vbaheaderfooter.hxx deleted file mode 100644 index 5d93f3cd8b..0000000000 --- a/sw/source/ui/vba/vbaheaderfooter.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_HEADERFOOTER_HXX -#define SW_VBA_HEADERFOOTER_HXX - -#include <ooo/vba/word/XHeaderFooter.hpp> -#include <ooo/vba/word/XRange.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XHeaderFooter > SwVbaHeaderFooter_BASE; - -class SwVbaHeaderFooter : public SwVbaHeaderFooter_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps; - sal_Bool mbHeader; - sal_Int32 mnIndex; - -public: - SwVbaHeaderFooter( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps, sal_Bool isHeader, sal_Int32 index ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaHeaderFooter(){} - - // Attributes - virtual ::sal_Bool SAL_CALL getIsHeader() throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getLinkToPrevious() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLinkToPrevious( ::sal_Bool _linktoprevious ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL getRange() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Shapes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_HEADERFOOTER_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.cxx b/sw/source/ui/vba/vbaheaderfooterhelper.cxx deleted file mode 100644 index c1d04f6369..0000000000 --- a/sw/source/ui/vba/vbaheaderfooterhelper.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaheaderfooterhelper.hxx" -#include "wordvbahelper.hxx" -#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; - -#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::isHeaderFooter( const uno::Reference< text::XText >& xText ) throw (uno::RuntimeException) -{ - uno::Reference< lang::XServiceInfo > xServiceInfo( xText, uno::UNO_QUERY_THROW ); - rtl::OUString aImplName = xServiceInfo->getImplementationName(); - if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXHeadFootText")) ) - return sal_True; - return sal_False; -} - -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; - - 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 > 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 ) throw (uno::RuntimeException) -{ - if( isHeader( xModel ) ) - { - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW ); - // FIXME: getPage allways returns 1 - sal_Int32 nPage = xPageCursor->getPage(); - return nPage == FIRST_PAGE; - } - return sal_False; -} - -sal_Bool HeaderFooterHelper::isEvenPagesHeader( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - if( isHeader( xModel ) ) - { - uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW ); - sal_Bool isShared = sal_False; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared"))) >>= isShared; - if( !isShared ) - { - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW ); - return ( 0 == xPageCursor->getPage() % 2 ); - } - } - return sal_False; -} - -sal_Bool HeaderFooterHelper::isFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - const uno::Reference< text::XText > xCurrentText = word::getCurrentXText( xModel ); - if( !isHeaderFooter( xCurrentText ) ) - return sal_False; - - 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 > 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 sal_False; -} - -sal_Bool HeaderFooterHelper::isFirstPageFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - if( isFooter( xModel ) ) - { - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW ); - sal_Int32 nPage = xPageCursor->getPage(); - return nPage == FIRST_PAGE; - } - return sal_False; -} - -sal_Bool HeaderFooterHelper::isEvenPagesFooter( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - if( isFooter( xModel ) ) - { - uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW ); - sal_Bool isShared = sal_False; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared"))) >>= isShared; - if( !isShared ) - { - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( xModel ), uno::UNO_QUERY_THROW ); - return ( 0 == xPageCursor->getPage() % 2 ); - } - } - return sal_False; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheaderfooterhelper.hxx b/sw/source/ui/vba/vbaheaderfooterhelper.hxx deleted file mode 100644 index 551db0a94f..0000000000 --- a/sw/source/ui/vba/vbaheaderfooterhelper.hxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_WORD_VBA_HEADERFOOTERHELPER_HXX -#define SW_WORD_VBA_HEADERFOOTERHELPER_HXX - -#include <vbahelper/vbahelper.hxx> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XPageCursor.hpp> -#include <com/sun/star/style/XStyle.hpp> - -class HeaderFooterHelper -{ -public: - 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); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheadersfooters.cxx b/sw/source/ui/vba/vbaheadersfooters.cxx deleted file mode 100644 index 27b2756998..0000000000 --- a/sw/source/ui/vba/vbaheadersfooters.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaheadersfooters.hxx" -#include "vbaheaderfooter.hxx" -#include <ooo/vba/word/WdHeaderFooterIndex.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -// I assume there is only one headersfooters in Writer -typedef ::cppu::WeakImplHelper1<container::XIndexAccess > HeadersFootersIndexAccess_Base; -class HeadersFootersIndexAccess : public HeadersFootersIndexAccess_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - uno::Reference< beans::XPropertySet > mxPageStyleProps; - sal_Bool mbHeader; - -public: - HeadersFootersIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, sal_Bool bHeader ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( bHeader ) {} - ~HeadersFootersIndexAccess(){} - - // XIndexAccess - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - // first page, evenpages and primary page - return 3; - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if( Index < 1 || Index > 3 ) - throw container::NoSuchElementException(); - return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( mxParent, mxContext, mxModel, mxPageStyleProps, mbHeader, Index ) ) ); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XHeaderFooter::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } -}; - -class HeadersFootersEnumWrapper : public EnumerationHelper_BASE -{ - SwVbaHeadersFooters* pHeadersFooters; - sal_Int32 nIndex; -public: - HeadersFootersEnumWrapper( SwVbaHeadersFooters* _pHeadersFooters ) : pHeadersFooters( _pHeadersFooters ), nIndex( 0 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < pHeadersFooters->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex < pHeadersFooters->getCount() ) - return pHeadersFooters->Item( uno::makeAny( ++nIndex ), uno::Any() ); - throw container::NoSuchElementException(); - } -}; - -SwVbaHeadersFooters::SwVbaHeadersFooters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xPageStyleProps, sal_Bool isHeader ): SwVbaHeadersFooters_BASE( xParent, xContext, new HeadersFootersIndexAccess( xParent, xContext, xModel, xPageStyleProps, isHeader ) ), mxModel( xModel ), mxPageStyleProps( xPageStyleProps ), mbHeader( isHeader ) -{ -} - -::sal_Int32 SAL_CALL SwVbaHeadersFooters::getCount() throw (uno::RuntimeException) -{ - // wdHeaderFooterFirstPage, wdHeaderFooterPrimary and wdHeaderFooterEvenPages - return 3; -} - -uno::Any SAL_CALL SwVbaHeadersFooters::Item( const uno::Any& Index1, const uno::Any& ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - Index1 >>= nIndex; - if( ( nIndex < 1 ) || ( nIndex > 3 ) ) - { - throw container::NoSuchElementException(); - } - return uno::makeAny( uno::Reference< word::XHeaderFooter >( new SwVbaHeaderFooter( this, mxContext, mxModel, mxPageStyleProps, mbHeader, nIndex ) ) ); -} - -// XEnumerationAccess -uno::Type -SwVbaHeadersFooters::getElementType() throw (uno::RuntimeException) -{ - return word::XHeaderFooter::static_type(0); -} -uno::Reference< container::XEnumeration > - -SwVbaHeadersFooters::createEnumeration() throw (uno::RuntimeException) -{ - return new HeadersFootersEnumWrapper( this ); -} - -uno::Any -SwVbaHeadersFooters::createCollectionObject( const uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaHeadersFooters::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaHeadersFooters") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaHeadersFooters::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.HeadersFooters") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaheadersfooters.hxx b/sw/source/ui/vba/vbaheadersfooters.hxx deleted file mode 100644 index 253942b0b1..0000000000 --- a/sw/source/ui/vba/vbaheadersfooters.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_HEADERSFOOTERS_HXX -#define SW_VBA_HEADERSFOOTERS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XHeadersFooters.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef CollTestImplHelper< ooo::vba::word::XHeadersFooters > SwVbaHeadersFooters_BASE; - -class SwVbaHeadersFooters : public SwVbaHeadersFooters_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::beans::XPropertySet > mxPageStyleProps; - sal_Bool mbHeader; - -public: - SwVbaHeadersFooters( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps, sal_Bool isHeader ); - virtual ~SwVbaHeadersFooters() {} - - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& )throw (css::uno::RuntimeException); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaHeadersFooters_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_HEADERSFOOTERS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbainformationhelper.cxx b/sw/source/ui/vba/vbainformationhelper.cxx deleted file mode 100644 index 45cc8bde26..0000000000 --- a/sw/source/ui/vba/vbainformationhelper.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbainformationhelper.hxx" -#include <com/sun/star/text/XPageCursor.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include "wordvbahelper.hxx" -#include <docsh.hxx> -#include <doc.hxx> -#include <vbahelper/vbahelper.hxx> -#include <swtypes.hxx> -#include <viewsh.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -static const sal_Int32 DEFAULT_PAGE_DISTANCE = 500; - -sal_Int32 SwVbaInformationHelper::handleWdActiveEndPageNumber( const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor ) throw( css::uno::RuntimeException ) -{ - uno::Reference< text::XPageCursor > xPageCursor( xTVCursor, uno::UNO_QUERY_THROW ); - return xPageCursor->getPage(); -} - -sal_Int32 SwVbaInformationHelper::handleWdNumberOfPagesInDocument( const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException ) -{ - return word::getPageCount( xModel ); -} - -double SwVbaInformationHelper::handleWdVerticalPositionRelativeToPage( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor ) throw( css::uno::RuntimeException ) -{ - xTVCursor->collapseToStart(); - uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( xModel ), uno::UNO_QUERY_THROW ); - sal_Int32 nTopMargin = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin") ) ) >>= nTopMargin; - sal_Int32 nCurrentPos = xTVCursor->getPosition().Y; - - sal_Int32 nCurrentPage = handleWdActiveEndPageNumber( xTVCursor ); - SwDoc* pDoc = word::getDocShell( xModel )->GetDoc(); - ViewShell* pViewSh = pDoc->GetCurrentViewShell(); - sal_Int32 nPageHeight = pViewSh ? pViewSh->GetPageSize( nCurrentPage, sal_False ).Height() : 0; - // FIXME: handle multipul page style - // it is very strange that the curros position is incorrect when open Word file. - // e.g. if current cursor in the top left of the text body of the first page without header, - // the top value of current position should be 0, but is 201 when open a Word file. - nCurrentPos = nCurrentPos + nTopMargin - ( DEFAULT_PAGE_DISTANCE + TWIP_TO_MM100( nPageHeight ) ) * ( nCurrentPage - 1 ); - return Millimeter::getInPoints( nCurrentPos ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbainformationhelper.hxx b/sw/source/ui/vba/vbainformationhelper.hxx deleted file mode 100644 index 581bb95fdd..0000000000 --- a/sw/source/ui/vba/vbainformationhelper.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_INFORMATIONHELPER_HXX -#define SW_VBA_INFORMATIONHELPER_HXX - -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> - -class SwVbaInformationHelper -{ -public: - static sal_Int32 handleWdActiveEndPageNumber( const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor ) throw( css::uno::RuntimeException ); - static sal_Int32 handleWdNumberOfPagesInDocument( const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException ); - static double handleWdVerticalPositionRelativeToPage( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor ) throw( css::uno::RuntimeException ); - //static double verticalPositionRelativeToPageBoundary( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextViewCursor >& xTVCursor, const css::uno::Reference< css::beans::XPropertySet >& xStyleProps ) throw( css::uno::RuntimeException ); - -}; -#endif /* SW_VBA_INFORMATIONHELPER_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistformat.cxx b/sw/source/ui/vba/vbalistformat.cxx deleted file mode 100644 index 15eed9a8b4..0000000000 --- a/sw/source/ui/vba/vbalistformat.cxx +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalistformat.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <ooo/vba/word/WdListApplyTo.hpp> -#include <ooo/vba/word/WdDefaultListBehavior.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include "vbalisttemplate.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaListFormat::SwVbaListFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : SwVbaListFormat_BASE( rParent, rContext ), mxTextRange( xTextRange ) -{ -} - -SwVbaListFormat::~SwVbaListFormat() -{ -} - -void SAL_CALL SwVbaListFormat::ApplyListTemplate( const css::uno::Reference< word::XListTemplate >& ListTemplate, const css::uno::Any& ContinuePreviousList, const css::uno::Any& ApplyTo, const css::uno::Any& DefaultListBehavior ) throw (css::uno::RuntimeException) -{ - sal_Bool bContinuePreviousList = sal_True; - if( ContinuePreviousList.hasValue() ) - ContinuePreviousList >>= bContinuePreviousList; - - // "applyto" must be current selection - sal_Int32 bApplyTo = word::WdListApplyTo::wdListApplyToSelection; - if( ApplyTo.hasValue() ) - ApplyTo >>= bApplyTo; - if( bApplyTo != word::WdListApplyTo::wdListApplyToSelection ) - throw uno::RuntimeException(); - - // default behaviour must be wdWord8ListBehavior - sal_Int32 nDefaultListBehavior = word::WdDefaultListBehavior::wdWord8ListBehavior; - if( DefaultListBehavior.hasValue() ) - DefaultListBehavior >>= nDefaultListBehavior; - if( nDefaultListBehavior != word::WdDefaultListBehavior::wdWord8ListBehavior ) - throw uno::RuntimeException(); - - SwVbaListTemplate* pListTemplate = dynamic_cast< SwVbaListTemplate* >( ListTemplate.get() ); - - uno::Reference< container::XEnumerationAccess > xEnumAccess( mxTextRange, uno::UNO_QUERY_THROW ); - uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); - sal_Bool isFirstElement = sal_True; - while( xEnum->hasMoreElements() ) - { - uno::Reference< beans::XPropertySet > xProps( xEnum->nextElement(), uno::UNO_QUERY_THROW ); - if( isFirstElement ) - { - sal_Bool isNumberingRestart = !bContinuePreviousList; - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart") ), uno::makeAny( isNumberingRestart ) ); - if( isNumberingRestart ) - { - sal_Int16 nStartValue = 1; - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStartValue") ), uno::makeAny( nStartValue ) ); - } - isFirstElement = sal_False; - } - else - { - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsNumberingRestart") ), uno::makeAny( sal_False ) ); - } - pListTemplate->applyListTemplate( xProps ); - } -} - -void SAL_CALL SwVbaListFormat::ConvertNumbersToText( ) throw (css::uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -rtl::OUString& -SwVbaListFormat::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListFormat") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaListFormat::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListFormat" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistformat.hxx b/sw/source/ui/vba/vbalistformat.hxx deleted file mode 100644 index 0483df54e0..0000000000 --- a/sw/source/ui/vba/vbalistformat.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTFORMAT_HXX -#define SW_VBA_LISTFORMAT_HXX - -#include <ooo/vba/word/XListFormat.hpp> -#include <ooo/vba/word/XListTemplate.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextRange.hpp> -#include "vbalisthelper.hxx" - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListFormat > SwVbaListFormat_BASE; - -class SwVbaListFormat : public SwVbaListFormat_BASE -{ -private: - css::uno::Reference< css::text::XTextRange > mxTextRange; - -public: - SwVbaListFormat( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaListFormat(); - - // Methods - virtual void SAL_CALL ApplyListTemplate( const css::uno::Reference< ::ooo::vba::word::XListTemplate >& ListTemplate, const css::uno::Any& ContinuePreviousList, const css::uno::Any& ApplyTo, const css::uno::Any& DefaultListBehavior ) throw (css::uno::RuntimeException); - virtual void SAL_CALL ConvertNumbersToText( ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_LISTFORMAT_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistgalleries.cxx b/sw/source/ui/vba/vbalistgalleries.cxx deleted file mode 100644 index 7ddd7145a6..0000000000 --- a/sw/source/ui/vba/vbalistgalleries.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalistgalleries.hxx" -#include "vbalistgallery.hxx" -#include <ooo/vba/word/WdListGalleryType.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class ListGalleriesEnumWrapper : public EnumerationHelper_BASE -{ - SwVbaListGalleries* pListGalleries; - sal_Int32 nIndex; -public: - ListGalleriesEnumWrapper( SwVbaListGalleries* pGalleries ) : pListGalleries( pGalleries ), nIndex( 1 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex <= pListGalleries->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex <= pListGalleries->getCount() ) - return pListGalleries->Item( uno::makeAny( nIndex++ ), uno::Any() ); - throw container::NoSuchElementException(); - } -}; - -SwVbaListGalleries::SwVbaListGalleries( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc ) throw (uno::RuntimeException) : SwVbaListGalleries_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc ) -{ -} - -::sal_Int32 SAL_CALL SwVbaListGalleries::getCount() throw (uno::RuntimeException) -{ - // 3 types of list( bullet, numbered and outline ) - return 3; -} - -uno::Any SAL_CALL SwVbaListGalleries::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) == sal_True ) - { - if( nIndex == word::WdListGalleryType::wdBulletGallery - || nIndex == word::WdListGalleryType::wdNumberGallery - || nIndex == word::WdListGalleryType::wdOutlineNumberGallery ) - return uno::makeAny( uno::Reference< word::XListGallery >( new SwVbaListGallery( this, mxContext, mxTextDocument, nIndex ) ) ); - } - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); -} - -// XEnumerationAccess -uno::Type -SwVbaListGalleries::getElementType() throw (uno::RuntimeException) -{ - return word::XListGallery::static_type(0); -} - -uno::Reference< container::XEnumeration > -SwVbaListGalleries::createEnumeration() throw (uno::RuntimeException) -{ - return new ListGalleriesEnumWrapper( this ); -} - -uno::Any -SwVbaListGalleries::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaListGalleries::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListGalleries") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaListGalleries::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListGalleries") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistgalleries.hxx b/sw/source/ui/vba/vbalistgalleries.hxx deleted file mode 100644 index a6e829783a..0000000000 --- a/sw/source/ui/vba/vbalistgalleries.hxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTGALLERIES_HXX -#define SW_VBA_LISTGALLERIES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XListGalleries.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextDocument.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XListGalleries > SwVbaListGalleries_BASE; - -class SwVbaListGalleries : public SwVbaListGalleries_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - -public: - SwVbaListGalleries( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc ) throw (css::uno::RuntimeException); - virtual ~SwVbaListGalleries() {} - - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException ); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaListGalleries_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_LISTGALLERIES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistgallery.cxx b/sw/source/ui/vba/vbalistgallery.cxx deleted file mode 100644 index 016de8c7ba..0000000000 --- a/sw/source/ui/vba/vbalistgallery.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalistgallery.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbalisttemplates.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaListGallery::SwVbaListGallery( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw ( uno::RuntimeException ) : SwVbaListGallery_BASE( rParent, rContext ), mxTextDocument( xTextDoc ), mnType( nType ) -{ -} - -SwVbaListGallery::~SwVbaListGallery() -{ -} - -uno::Any SAL_CALL -SwVbaListGallery::ListTemplates( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaListTemplates( mxParent, mxContext, mxTextDocument, mnType ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -rtl::OUString& -SwVbaListGallery::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListGallery") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaListGallery::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListGallery" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistgallery.hxx b/sw/source/ui/vba/vbalistgallery.hxx deleted file mode 100644 index 6371e8613f..0000000000 --- a/sw/source/ui/vba/vbalistgallery.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTGALLERY_HXX -#define SW_VBA_LISTGALLERY_HXX - -#include <ooo/vba/word/XListGallery.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextDocument.hpp> - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListGallery > SwVbaListGallery_BASE; - -class SwVbaListGallery : public SwVbaListGallery_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - sal_Int32 mnType; - -public: - SwVbaListGallery( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaListGallery(); - - // Methods - virtual css::uno::Any SAL_CALL ListTemplates( const css::uno::Any& index ) throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_LISTGALLERY_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisthelper.cxx b/sw/source/ui/vba/vbalisthelper.cxx deleted file mode 100644 index 65949d6502..0000000000 --- a/sw/source/ui/vba/vbalisthelper.cxx +++ /dev/null @@ -1,705 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalisthelper.hxx" -#include <tools/diagnose_ex.h> -#include <ooo/vba/word/WdListGalleryType.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/style/NumberingType.hpp> -#include <com/sun/star/container/XIndexReplace.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -static const sal_Int32 LIST_LEVEL_COUNT = 9; - -static const char WORD_BULLET_GALLERY[] = "WdBullet"; -static const char WORD_NUMBER_GALLERY[] = "WdNumber"; -static const char WORD_OUTLINE_NUMBER_GALLERY[] = "WdOutlineNumber"; - -static const char UNO_NAME_ADJUST[] = "Adjust"; -static const char UNO_NAME_PARENT_NUMBERING[] = "ParentNumbering"; -static const char UNO_NAME_PREFIX[] = "Prefix"; -static const char UNO_NAME_SUFFIX[] = "Suffix"; -static const char UNO_NAME_CHAR_STYLE_NAME[] = "CharStyleName"; -static const char UNO_NAME_START_WITH[] = "StartWith"; -static const char UNO_NAME_POSITION_AND_SPACE_MODE[] = "PositionAndSpaceMode"; -static const char UNO_NAME_LABEL_FOLLOWED_BY[] = "LabelFollowedBy"; -static const char UNO_NAME_LIST_TAB_STOP_POSITION[] = "ListtabStopPosition"; -static const char UNO_NAME_FIRST_LINE_INDENT[] = "FirstLineIndent"; -static const char UNO_NAME_INDENT_AT[] = "IndentAt"; -static const char UNO_NAME_NUMBERING_TYPE[] = "NumberingType"; -static const char UNO_NAME_BULLET_ID[] = "BulletId"; -static const char UNO_NAME_BULLET_CHAR[] = "BulletChar"; -static const char UNO_NAME_BULLET_FONT_NAME[] = "BulletFontName"; -static const char UNO_NAME_BULLET_FONT[] = "BulletFont"; - -static const sal_Int16 CHAR_CLOSED_DOT = 8226; -static const sal_Int16 CHAR_EMPTY_DOT = 111; -static const sal_Int16 CHAR_SQUARE = 9632; -static const sal_Int16 CHAR_STAR_SYMBOL = 10026; -static const sal_Int16 CHAR_FOUR_DIAMONDS = 10070; -static const sal_Int16 CHAR_DIAMOND = 10022; -static const sal_Int16 CHAR_ARROW = 10146; -static const sal_Int16 CHAR_CHECK_MARK = 10003; - -SwVbaListHelper::SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw( css::uno::RuntimeException ) : mxTextDocument( xTextDoc ), mnGalleryType( nGalleryType ), mnTemplateType( nTemplateType ) -{ - Init(); -} - -void SwVbaListHelper::Init() throw( css::uno::RuntimeException ) -{ - // set the numbering style name - switch( mnGalleryType ) - { - case word::WdListGalleryType::wdBulletGallery: - { - msStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( WORD_BULLET_GALLERY )); - break; - } - case word::WdListGalleryType::wdNumberGallery: - { - msStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( WORD_NUMBER_GALLERY )); - break; - } - case word::WdListGalleryType::wdOutlineNumberGallery: - { - msStyleName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( WORD_OUTLINE_NUMBER_GALLERY )); - break; - } - default: - { - throw uno::RuntimeException(); - } - } - msStyleName += rtl::OUString::valueOf( mnTemplateType ); - - // get the numbering style - uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxTextDocument, uno::UNO_QUERY_THROW ); - mxStyleFamily.set( xStyleSupplier->getStyleFamilies()->getByName(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyles") ) ), uno::UNO_QUERY_THROW ); - OSL_TRACE("SwVbaListHelper::Init: numbering style name: %s", rtl::OUStringToOString( msStyleName, RTL_TEXTENCODING_UTF8 ).getStr() ); - if( mxStyleFamily->hasByName( msStyleName ) ) - { - mxStyleProps.set( mxStyleFamily->getByName( msStyleName ), uno::UNO_QUERY_THROW ); - mxNumberingRules.set( mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) ), uno::UNO_QUERY_THROW ); - } - else - { - // create new numbering style - uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW ); - mxStyleProps.set( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.NumberingStyle") ) ), uno::UNO_QUERY_THROW ); - // insert this style into style family, or the property NumberingRules doesn't exist. - mxStyleFamily->insertByName( msStyleName, uno::makeAny( mxStyleProps ) ); - mxStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) ) >>= mxNumberingRules; - - CreateListTemplate(); - - mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( mxNumberingRules ) ); - } -} - -void SwVbaListHelper::CreateListTemplate() throw( css::uno::RuntimeException ) -{ - switch( mnGalleryType ) - { - case word::WdListGalleryType::wdBulletGallery: - { - CreateBulletListTemplate(); - break; - } - case word::WdListGalleryType::wdNumberGallery: - { - CreateNumberListTemplate(); - break; - } - case word::WdListGalleryType::wdOutlineNumberGallery: - { - CreateOutlineNumberListTemplate(); - break; - } - default: - { - throw uno::RuntimeException(); - } - } -} - -void SwVbaListHelper::CreateBulletListTemplate() throw( css::uno::RuntimeException ) -{ - // there is only 1 level for each bullet list in MSWord - sal_Int32 nLevel = 0; - uno::Sequence< beans::PropertyValue > aPropertyValues; - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - rtl::OUString sCharStyleName( RTL_CONSTASCII_USTRINGPARAM("Bullet Symbols") ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_CHAR_STYLE_NAME )), uno::makeAny( sCharStyleName ) ); - sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - - rtl::OUString aBulletChar; - switch( mnTemplateType ) - { - case 1: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) ); - break; - } - case 2: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_EMPTY_DOT ) ); - break; - } - case 3: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) ); - break; - } - case 4: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_STAR_SYMBOL ) ); - break; - } - case 5: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) ); - break; - } - case 6: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) ); - break; - } - case 7: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_CHECK_MARK ) ); - break; - } - default: - { - // we only support 7 types template now - throw css::uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_BULLET_CHAR )), uno::makeAny( aBulletChar ) ); - - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); -} - -void SwVbaListHelper::CreateNumberListTemplate() throw( css::uno::RuntimeException ) -{ - // there is only 1 level for each bullet list in MSWord - sal_Int32 nLevel = 0; - uno::Sequence< beans::PropertyValue > aPropertyValues; - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - - sal_Int16 nNumberingType = 0; - rtl::OUString sSuffix; - switch( mnTemplateType ) - { - case 1: - { - nNumberingType = style::NumberingType::ARABIC; - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 2: - { - nNumberingType = style::NumberingType::ARABIC; - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 3: - { - nNumberingType = style::NumberingType::ROMAN_UPPER; - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 4: - { - nNumberingType = style::NumberingType::CHARS_UPPER_LETTER; - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 5: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 6: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 7: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - default: - { - // we only support 7 types template now - throw css::uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_SUFFIX )), uno::makeAny( sSuffix ) ); - - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); -} - -void SwVbaListHelper::CreateOutlineNumberListTemplate() throw( css::uno::RuntimeException ) -{ - switch( mnTemplateType ) - { - case 1: - { - CreateOutlineNumberForType1(); - break; - } - case 2: - { - CreateOutlineNumberForType2(); - break; - } - case 3: - { - CreateOutlineNumberForType3(); - break; - } - case 4: - { - CreateOutlineNumberForType4(); - break; - } - case 5: - { - CreateOutlineNumberForType5(); - break; - } - case 6: - { - CreateOutlineNumberForType6(); - break; - } - case 7: - { - CreateOutlineNumberForType7(); - break; - } - default: - { - // we only support 7 types template now - throw css::uno::RuntimeException(); - } - } -} - -void SwVbaListHelper::CreateOutlineNumberForType1() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = 0; - rtl::OUString sPrefix; - rtl::OUString sSuffix; - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - switch( nLevel ) - { - case 0: - case 1: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 2: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 3: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 4: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 5: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 6: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 7: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 8: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - default: - { - throw uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PREFIX )), uno::makeAny( sPrefix ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_SUFFIX )), uno::makeAny( sSuffix ) ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType2() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = style::NumberingType::ARABIC; - sal_Int16 nParentNumbering = 0; - rtl::OUString sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_SUFFIX )), uno::makeAny( sSuffix ) ); - if( nLevel != 0 ) - { - nParentNumbering = sal_Int16( nLevel - 1 ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PARENT_NUMBERING )), uno::makeAny( nParentNumbering ) ); - } - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType3() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = style::NumberingType::CHAR_SPECIAL; - rtl::OUString sCharStyleName( RTL_CONSTASCII_USTRINGPARAM("Bullet Symbols") ); - rtl::OUString aBulletChar; - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_CHAR_STYLE_NAME )), uno::makeAny( sCharStyleName ) ); - switch( nLevel ) - { - case 0: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_FOUR_DIAMONDS ) ); - break; - } - case 1: - case 5: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_ARROW ) ); - break; - } - case 2: - case 6: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_SQUARE ) ); - break; - } - case 3: - case 7: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_CLOSED_DOT ) ); - break; - } - case 4: - case 8: - { - aBulletChar = rtl::OUString( sal_Unicode( CHAR_DIAMOND ) ); - break; - } - default: - { - throw uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_BULLET_CHAR )), uno::makeAny( aBulletChar ) ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType4() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = 0; - rtl::OUString sPrefix; - rtl::OUString sSuffix; - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - switch( nLevel ) - { - case 0: - { - nNumberingType = style::NumberingType::ROMAN_UPPER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 1: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - sal_Int16 nParentNumbering = 0; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PARENT_NUMBERING )), uno::makeAny( nParentNumbering ) ); - break; - } - case 2: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 3: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 4: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 5: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 6: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 7: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 8: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - default: - { - throw uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PREFIX )), uno::makeAny( sPrefix ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_SUFFIX )), uno::makeAny( sSuffix ) ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType5() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = style::NumberingType::ARABIC; - sal_Int16 nParentNumbering = 0; - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - if( nLevel != 0 ) - { - nParentNumbering = sal_Int16( nLevel - 1 ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PARENT_NUMBERING )), uno::makeAny( nParentNumbering ) ); - } - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType6() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = 0; - rtl::OUString sPrefix; - rtl::OUString sSuffix; - uno::Sequence< beans::PropertyValue > aPropertyValues; - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - switch( nLevel ) - { - case 0: - { - nNumberingType = style::NumberingType::ROMAN_UPPER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 1: - { - nNumberingType = style::NumberingType::CHARS_UPPER_LETTER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 2: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 3: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString(); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 4: - { - nNumberingType = style::NumberingType::ARABIC; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 5: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 6: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode(')') ); - break; - } - case 7: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - case 8: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - sPrefix = rtl::OUString::valueOf( sal_Unicode('(') ); - sSuffix = rtl::OUString::valueOf( sal_Unicode('.') ); - break; - } - default: - { - throw uno::RuntimeException(); - } - } - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PREFIX )), uno::makeAny( sPrefix ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_SUFFIX )), uno::makeAny( sSuffix ) ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -void SwVbaListHelper::CreateOutlineNumberForType7() throw( css::uno::RuntimeException ) -{ - sal_Int16 nNumberingType = style::NumberingType::ARABIC; - uno::Sequence< beans::PropertyValue > aPropertyValues; - rtl::OUString sPrefix(RTL_CONSTASCII_USTRINGPARAM("Chapter ")); - - for( sal_Int32 nLevel = 0; nLevel < LIST_LEVEL_COUNT; nLevel++ ) - { - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_NUMBERING_TYPE )), uno::makeAny( nNumberingType ) ); - setOrAppendPropertyValue( aPropertyValues, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_PREFIX )), uno::makeAny( sPrefix ) ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - } -} - -uno::Any SwVbaListHelper::getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName ) throw( css::uno::RuntimeException ) -{ - uno::Sequence< beans::PropertyValue > aPropertyValues; - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - return getPropertyValue( aPropertyValues, sName ); -} - -void SwVbaListHelper::setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException ) -{ - uno::Sequence< beans::PropertyValue > aPropertyValues; - mxNumberingRules->getByIndex( nLevel ) >>= aPropertyValues; - setOrAppendPropertyValue( aPropertyValues, sName, aValue ); - mxNumberingRules->replaceByIndex( nLevel, uno::makeAny( aPropertyValues ) ); - mxStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( mxNumberingRules ) ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisthelper.hxx b/sw/source/ui/vba/vbalisthelper.hxx deleted file mode 100644 index 0e862fa0dd..0000000000 --- a/sw/source/ui/vba/vbalisthelper.hxx +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * Version: MPL 1.1 / GPLv3+ / LGPLv3+ - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Initial Developer of the Original Code is - * Novell Inc. - * Portions created by the Initial Developer are Copyright (C) 2010 the - * Initial Developer. All Rights Reserved. - * - * Contributor(s): <pflin@novell.com> - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 3 or later (the "GPLv3+"), or - * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), - * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable - * instead of those above. - */ -#ifndef SW_VBA_LISTHELPER_HXX -#define SW_VBA_LISTHELPER_HXX - -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/container/XIndexReplace.hpp> -#include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <boost/shared_ptr.hpp> - - -class SwVbaListHelper; -typedef ::boost::shared_ptr< SwVbaListHelper > SwVbaListHelperRef; - -class SwVbaListHelper -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::container::XIndexReplace > mxNumberingRules; - css::uno::Reference< css::container::XNameContainer > mxStyleFamily; - css::uno::Reference< css::beans::XPropertySet > mxStyleProps; - sal_Int32 mnGalleryType; - sal_Int32 mnTemplateType; - rtl::OUString msStyleName; - - void Init() throw( css::uno::RuntimeException ); - void CreateListTemplate() throw( css::uno::RuntimeException ); - void CreateBulletListTemplate() throw( css::uno::RuntimeException ); - void CreateNumberListTemplate() throw( css::uno::RuntimeException ); - void CreateOutlineNumberListTemplate() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType1() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType2() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType3() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType4() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType5() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType6() throw( css::uno::RuntimeException ); - void CreateOutlineNumberForType7() throw( css::uno::RuntimeException ); - -public: - SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw( css::uno::RuntimeException ); - - sal_Int32 getGalleryType() const { return mnGalleryType; } - css::uno::Reference< css::container::XIndexReplace > getNumberingRules() const { return mxNumberingRules; } - css::uno::Any getPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName ) throw( css::uno::RuntimeException ); - void setPropertyValueWithNameAndLevel( sal_Int32 nLevel, const rtl::OUString& sName, const css::uno::Any& aValue ) throw( css::uno::RuntimeException ); - -}; - -#endif//SW_VBA_LISTHELPER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistlevel.cxx b/sw/source/ui/vba/vbalistlevel.cxx deleted file mode 100644 index b35f7b52f5..0000000000 --- a/sw/source/ui/vba/vbalistlevel.cxx +++ /dev/null @@ -1,400 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalistlevel.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/style/NumberingType.hpp> -#include <ooo/vba/word/WdListNumberStyle.hpp> -#include <ooo/vba/word/WdTrailingCharacter.hpp> -#include <com/sun/star/text/HoriOrientation.hpp> -#include <ooo/vba/word/WdListLevelAlignment.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaListLevel::SwVbaListLevel( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) throw ( uno::RuntimeException ) : SwVbaListLevel_BASE( rParent, rContext ), pListHelper( pHelper ), mnLevel( nLevel ) -{ -} - -SwVbaListLevel::~SwVbaListLevel() -{ -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getAlignment() throw (uno::RuntimeException) -{ - sal_Int16 nAlignment = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ) ) >>= nAlignment; - switch( nAlignment ) - { - case text::HoriOrientation::LEFT: - { - nAlignment = word::WdListLevelAlignment::wdListLevelAlignLeft; - break; - } - case text::HoriOrientation::RIGHT: - { - nAlignment = word::WdListLevelAlignment::wdListLevelAlignRight; - break; - } - case text::HoriOrientation::CENTER: - { - nAlignment = word::WdListLevelAlignment::wdListLevelAlignCenter; - break; - } - default: - { - throw uno::RuntimeException(); - } - } - return nAlignment; -} - -void SAL_CALL SwVbaListLevel::setAlignment( ::sal_Int32 _alignment ) throw (uno::RuntimeException) -{ - sal_Int16 nAlignment = text::HoriOrientation::LEFT; - switch( _alignment ) - { - case word::WdListLevelAlignment::wdListLevelAlignLeft: - { - nAlignment = text::HoriOrientation::LEFT; - break; - } - case word::WdListLevelAlignment::wdListLevelAlignRight: - { - nAlignment = text::HoriOrientation::RIGHT; - break; - } - case word::WdListLevelAlignment::wdListLevelAlignCenter: - { - nAlignment = text::HoriOrientation::CENTER; - break; - } - default: - { - throw uno::RuntimeException(); - } - } - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Adjust") ), uno::makeAny( nAlignment ) ); -} - -uno::Reference< ::ooo::vba::word::XFont > SAL_CALL SwVbaListLevel::getFont() throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - return uno::Reference< word::XFont >(); -} - -void SAL_CALL SwVbaListLevel::setFont( const uno::Reference< ::ooo::vba::word::XFont >& /*_font*/ ) throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getIndex() throw (uno::RuntimeException) -{ - return mnLevel + 1; -} - -::rtl::OUString SAL_CALL SwVbaListLevel::getLinkedStyle() throw (uno::RuntimeException) -{ - // TODO: - return rtl::OUString(); -} - -void SAL_CALL SwVbaListLevel::setLinkedStyle( const ::rtl::OUString& /*_linkedstyle*/ ) throw (uno::RuntimeException) -{ - // TODO: -} - -::rtl::OUString SAL_CALL SwVbaListLevel::getNumberFormat() throw (uno::RuntimeException) -{ - // TODO:: - return rtl::OUString(); -} - -void SAL_CALL SwVbaListLevel::setNumberFormat( const ::rtl::OUString& /*_numberformat*/ ) throw (uno::RuntimeException) -{ - // TODO:: -} - -float SAL_CALL SwVbaListLevel::getNumberPosition() throw (uno::RuntimeException) -{ - // indentAt + firstlineindent - sal_Int32 nIndentAt = 0; - sal_Int32 nFirstLineIndent = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent; - - sal_Int32 nResult = nIndentAt + nFirstLineIndent; - - return static_cast< float >( Millimeter::getInPoints( nResult ) ); -} - -void SAL_CALL SwVbaListLevel::setNumberPosition( float _numberposition ) throw (uno::RuntimeException) -{ - sal_Int32 nNumberPosition = Millimeter::getInHundredthsOfOneMillimeter( _numberposition ); - - sal_Int32 nIndentAt = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt; - - sal_Int32 nFirstLineIndent = nNumberPosition - nIndentAt; - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) ); -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getNumberStyle() throw (uno::RuntimeException) -{ - sal_Int16 nNumberingType = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ) ) >>= nNumberingType; - switch( nNumberingType ) - { - case style::NumberingType::CHAR_SPECIAL: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleBullet; - break; - } - case style::NumberingType::CHARS_UPPER_LETTER: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseLetter; - break; - } - case style::NumberingType::CHARS_LOWER_LETTER: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseLetter; - break; - } - case style::NumberingType::ROMAN_UPPER: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleUppercaseRoman; - break; - } - case style::NumberingType::ROMAN_LOWER: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleLowercaseRoman; - break; - } - case style::NumberingType::ARABIC: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabic; - break; - } - case style::NumberingType::NUMBER_NONE: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleNone; - break; - } - case style::NumberingType::FULLWIDTH_ARABIC: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleArabicFullWidth; - break; - } - case style::NumberingType::CIRCLE_NUMBER: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleNumberInCircle; - break; - } - case style::NumberingType::CHARS_ARABIC: - { - nNumberingType = word::WdListNumberStyle::wdListNumberStyleCardinalText; - break; - } - default: - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } - } - return nNumberingType; -} - -void SAL_CALL SwVbaListLevel::setNumberStyle( ::sal_Int32 _numberstyle ) throw (uno::RuntimeException) -{ - sal_Int16 nNumberingType = 0; - switch( _numberstyle ) - { - case word::WdListNumberStyle::wdListNumberStyleBullet: - { - nNumberingType = style::NumberingType::CHAR_SPECIAL; - break; - } - case word::WdListNumberStyle::wdListNumberStyleUppercaseLetter: - { - nNumberingType = style::NumberingType::CHARS_UPPER_LETTER_N; - break; - } - case word::WdListNumberStyle::wdListNumberStyleLowercaseLetter: - { - nNumberingType = style::NumberingType::CHARS_LOWER_LETTER_N; - break; - } - case word::WdListNumberStyle::wdListNumberStyleUppercaseRoman: - { - nNumberingType = style::NumberingType::ROMAN_UPPER; - break; - } - case word::WdListNumberStyle::wdListNumberStyleLowercaseRoman: - { - nNumberingType = style::NumberingType::ROMAN_LOWER; - break; - } - case word::WdListNumberStyle::wdListNumberStyleArabic: - { - nNumberingType = style::NumberingType::ARABIC; - break; - } - case word::WdListNumberStyle::wdListNumberStyleNone: - { - nNumberingType = style::NumberingType::NUMBER_NONE; - break; - } - case word::WdListNumberStyle::wdListNumberStyleArabicFullWidth: - { - nNumberingType = style::NumberingType::FULLWIDTH_ARABIC; - break; - } - case word::WdListNumberStyle::wdListNumberStyleNumberInCircle: - { - nNumberingType = style::NumberingType::CIRCLE_NUMBER; - break; - } - case word::WdListNumberStyle::wdListNumberStyleCardinalText: - { - nNumberingType = style::NumberingType::CHARS_ARABIC; - break; - } - case word::WdListNumberStyle::wdListNumberStyleOrdinal: - case word::WdListNumberStyle::wdListNumberStyleOrdinalText: - case word::WdListNumberStyle::wdListNumberStyleKanji: - case word::WdListNumberStyle::wdListNumberStyleKanjiDigit: - case word::WdListNumberStyle::wdListNumberStyleAiueoHalfWidth: - case word::WdListNumberStyle::wdListNumberStyleIrohaHalfWidth: - { - nNumberingType = style::NumberingType::ARABIC; - break; - } - default: - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } - } - - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingType") ), uno::makeAny( nNumberingType ) ); -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getResetOnHigher() throw (uno::RuntimeException) -{ - //seems not support? - return 0; -} - -void SAL_CALL SwVbaListLevel::setResetOnHigher( ::sal_Int32 /*_resetonhigher*/ ) throw (uno::RuntimeException) -{ - //seems not support? -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getStartAt() throw (uno::RuntimeException) -{ - sal_Int16 nStartWith = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ) ) >>= nStartWith; - return nStartWith; -} - -void SAL_CALL SwVbaListLevel::setStartAt( ::sal_Int32 _startat ) throw (uno::RuntimeException) -{ - sal_Int16 nStartWith = (sal_Int16)_startat; - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StartWith") ), uno::makeAny( nStartWith ) ); -} - -float SAL_CALL SwVbaListLevel::getTabPosition() throw (uno::RuntimeException) -{ - sal_Int32 nTabPosition = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ) ) >>= nTabPosition; - - return static_cast< float >( Millimeter::getInPoints( nTabPosition ) ); -} - -void SAL_CALL SwVbaListLevel::setTabPosition( float _tabposition ) throw (uno::RuntimeException) -{ - sal_Int32 nTabPosition = Millimeter::getInHundredthsOfOneMillimeter( _tabposition ); - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition") ), uno::makeAny( nTabPosition ) ); -} - -float SAL_CALL SwVbaListLevel::getTextPosition() throw (uno::RuntimeException) -{ - // indentAt - sal_Int32 nIndentAt = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt; - - return static_cast< float >( Millimeter::getInPoints( nIndentAt ) ); -} - -void SAL_CALL SwVbaListLevel::setTextPosition( float _textposition ) throw (uno::RuntimeException) -{ - sal_Int32 nIndentAt = 0; - sal_Int32 nFirstLineIndent = 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ) ) >>= nIndentAt; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ) ) >>= nFirstLineIndent; - - sal_Int32 nAlignedAt = nIndentAt + nFirstLineIndent; - - nIndentAt = Millimeter::getInHundredthsOfOneMillimeter( _textposition ); - nFirstLineIndent = nAlignedAt - nIndentAt; - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IndentAt") ), uno::makeAny( nIndentAt ) ); - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstLineIndent") ), uno::makeAny( nFirstLineIndent ) ); -} - -::sal_Int32 SAL_CALL SwVbaListLevel::getTrailingCharacter() throw (uno::RuntimeException) -{ - sal_Int16 nLabelFollowedBy= 0; - pListHelper->getPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ) ) >>= nLabelFollowedBy; - - return nLabelFollowedBy; -} - -void SAL_CALL SwVbaListLevel::setTrailingCharacter( ::sal_Int32 _trailingcharacter ) throw (uno::RuntimeException) -{ - sal_Int16 nLabelFollowedBy = (sal_Int16)_trailingcharacter; - pListHelper->setPropertyValueWithNameAndLevel( mnLevel, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LabelFollowedBy") ), uno::makeAny( nLabelFollowedBy ) ); -} - -rtl::OUString& -SwVbaListLevel::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevel") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaListLevel::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevel" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistlevel.hxx b/sw/source/ui/vba/vbalistlevel.hxx deleted file mode 100644 index 9be001ae3e..0000000000 --- a/sw/source/ui/vba/vbalistlevel.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTLEVEL_HXX -#define SW_VBA_LISTLEVEL_HXX - -#include <ooo/vba/word/XListLevel.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include "vbalisthelper.hxx" - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListLevel > SwVbaListLevel_BASE; - -class SwVbaListLevel : public SwVbaListLevel_BASE -{ -private: - SwVbaListHelperRef pListHelper; - sal_Int32 mnLevel; - -public: - SwVbaListLevel( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper, sal_Int32 nLevel ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaListLevel(); - - // Attributes - virtual ::sal_Int32 SAL_CALL getAlignment() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAlignment( ::sal_Int32 _alignment ) throw (css::uno::RuntimeException); - virtual css::uno::Reference< ::ooo::vba::word::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFont( const css::uno::Reference< ::ooo::vba::word::XFont >& _font ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getIndex() throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getLinkedStyle() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLinkedStyle( const ::rtl::OUString& _linkedstyle ) throw (css::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getNumberFormat() throw (css::uno::RuntimeException); - virtual void SAL_CALL setNumberFormat( const ::rtl::OUString& _numberformat ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getNumberPosition() throw (css::uno::RuntimeException); - virtual void SAL_CALL setNumberPosition( float _numberposition ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getNumberStyle() throw (css::uno::RuntimeException); - virtual void SAL_CALL setNumberStyle( ::sal_Int32 _numberstyle ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getResetOnHigher() throw (css::uno::RuntimeException); - virtual void SAL_CALL setResetOnHigher( ::sal_Int32 _resetonhigher ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getStartAt() throw (css::uno::RuntimeException); - virtual void SAL_CALL setStartAt( ::sal_Int32 _startat ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getTabPosition() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTabPosition( float _tabposition ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getTextPosition() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTextPosition( float _textposition ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getTrailingCharacter() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTrailingCharacter( ::sal_Int32 _trailingcharacter ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_LISTLEVEL_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistlevels.cxx b/sw/source/ui/vba/vbalistlevels.cxx deleted file mode 100644 index 2c1301127d..0000000000 --- a/sw/source/ui/vba/vbalistlevels.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalistlevels.hxx" -#include "vbalistlevel.hxx" -#include <ooo/vba/word/WdListGalleryType.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class ListLevelsEnumWrapper : public EnumerationHelper_BASE -{ - SwVbaListLevels* pListLevels; - sal_Int32 nIndex; -public: - ListLevelsEnumWrapper( SwVbaListLevels* pLevels ) : pListLevels( pLevels ), nIndex( 1 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex <= pListLevels->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex <= pListLevels->getCount() ) - return pListLevels->Item( uno::makeAny( nIndex++ ), uno::Any() ); - throw container::NoSuchElementException(); - } -}; - -SwVbaListLevels::SwVbaListLevels( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, SwVbaListHelperRef pHelper ) throw (uno::RuntimeException) : SwVbaListLevels_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), pListHelper( pHelper ) -{ -} - -::sal_Int32 SAL_CALL SwVbaListLevels::getCount() throw (uno::RuntimeException) -{ - sal_Int32 nGalleryType = pListHelper->getGalleryType(); - if( nGalleryType == word::WdListGalleryType::wdBulletGallery - || nGalleryType == word::WdListGalleryType::wdNumberGallery ) - return 1; - else if( nGalleryType == word::WdListGalleryType::wdOutlineNumberGallery ) - return 9; - return 0; -} - -uno::Any SAL_CALL SwVbaListLevels::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) == sal_False ) - throw uno::RuntimeException(); - if( nIndex <=0 || nIndex > getCount() ) - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); - - return uno::makeAny( uno::Reference< word::XListLevel >( new SwVbaListLevel( this, mxContext, pListHelper, nIndex - 1 ) ) ); -} - -// XEnumerationAccess -uno::Type -SwVbaListLevels::getElementType() throw (uno::RuntimeException) -{ - return word::XListLevel::static_type(0); -} - -uno::Reference< container::XEnumeration > -SwVbaListLevels::createEnumeration() throw (uno::RuntimeException) -{ - return new ListLevelsEnumWrapper( this ); -} - -uno::Any -SwVbaListLevels::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaListLevels::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListLevels") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaListLevels::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListLevels") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalistlevels.hxx b/sw/source/ui/vba/vbalistlevels.hxx deleted file mode 100644 index 595c0fb34b..0000000000 --- a/sw/source/ui/vba/vbalistlevels.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTLEVELS_HXX -#define SW_VBA_LISTLEVELS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XListLevels.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include "vbalisthelper.hxx" - - -typedef CollTestImplHelper< ooo::vba::word::XListLevels > SwVbaListLevels_BASE; - -class SwVbaListLevels : public SwVbaListLevels_BASE -{ -private: - SwVbaListHelperRef pListHelper; - -public: - SwVbaListLevels( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, SwVbaListHelperRef pHelper ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaListLevels() {} - - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException ); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaListLevels_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_LISTLEVELS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisttemplate.cxx b/sw/source/ui/vba/vbalisttemplate.cxx deleted file mode 100644 index 49305c74e5..0000000000 --- a/sw/source/ui/vba/vbalisttemplate.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalisttemplate.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbalistlevels.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaListTemplate::SwVbaListTemplate( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw ( uno::RuntimeException ) : SwVbaListTemplate_BASE( rParent, rContext ) -{ - pListHelper.reset( new SwVbaListHelper( xTextDoc, nGalleryType, nTemplateType ) ); -} - -SwVbaListTemplate::~SwVbaListTemplate() -{ -} - -uno::Any SAL_CALL -SwVbaListTemplate::ListLevels( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaListLevels( mxParent, mxContext, pListHelper ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -void SwVbaListTemplate::applyListTemplate( uno::Reference< beans::XPropertySet >& xProps ) throw (uno::RuntimeException) -{ - uno::Reference< container::XIndexReplace > xNumberingRules = pListHelper->getNumberingRules(); - xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingRules") ) , uno::makeAny( xNumberingRules ) ); -} - -rtl::OUString& -SwVbaListTemplate::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListTemplate") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaListTemplate::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListTemplate" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisttemplate.hxx b/sw/source/ui/vba/vbalisttemplate.hxx deleted file mode 100644 index d876cffb03..0000000000 --- a/sw/source/ui/vba/vbalisttemplate.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTTEMPLATE_HXX -#define SW_VBA_LISTTEMPLATE_HXX - -#include <ooo/vba/word/XListTemplate.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include "vbalisthelper.hxx" - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XListTemplate > SwVbaListTemplate_BASE; - -class SwVbaListTemplate : public SwVbaListTemplate_BASE -{ -private: - SwVbaListHelperRef pListHelper; - -public: - SwVbaListTemplate( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaListTemplate(); - - void applyListTemplate( css::uno::Reference< css::beans::XPropertySet >& xProps ) throw ( css::uno::RuntimeException ); - - // Methods - virtual css::uno::Any SAL_CALL ListLevels( const css::uno::Any& index ) throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_LISTTEMPLATE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisttemplates.cxx b/sw/source/ui/vba/vbalisttemplates.cxx deleted file mode 100644 index e54aa16372..0000000000 --- a/sw/source/ui/vba/vbalisttemplates.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbalisttemplates.hxx" -#include "vbalisttemplate.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class ListTemplatesEnumWrapper : public EnumerationHelper_BASE -{ - SwVbaListTemplates* pListTemplates; - sal_Int32 nIndex; -public: - ListTemplatesEnumWrapper( SwVbaListTemplates* pTemplates ) : pListTemplates( pTemplates ), nIndex( 1 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex <= pListTemplates->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex <= pListTemplates->getCount() ) - return pListTemplates->Item( uno::makeAny( nIndex++ ), uno::Any() ); - throw container::NoSuchElementException(); - } -}; - -SwVbaListTemplates::SwVbaListTemplates( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw (uno::RuntimeException) : SwVbaListTemplates_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >() ), mxTextDocument( xTextDoc ), mnGalleryType( nType ) -{ -} - -::sal_Int32 SAL_CALL SwVbaListTemplates::getCount() throw (uno::RuntimeException) -{ - // 3 types of list( bullet, numbered and outline ) - return 7; -} - -uno::Any SAL_CALL SwVbaListTemplates::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) == sal_False ) - throw uno::RuntimeException(); - if( nIndex <=0 || nIndex > getCount() ) - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); - - return uno::makeAny( uno::Reference< word::XListTemplate >( new SwVbaListTemplate( this, mxContext, mxTextDocument, mnGalleryType, nIndex ) ) ); -} - -// XEnumerationAccess -uno::Type -SwVbaListTemplates::getElementType() throw (uno::RuntimeException) -{ - return word::XListTemplate::static_type(0); -} - -uno::Reference< container::XEnumeration > -SwVbaListTemplates::createEnumeration() throw (uno::RuntimeException) -{ - return new ListTemplatesEnumWrapper( this ); -} - -uno::Any -SwVbaListTemplates::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaListTemplates::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaListTemplates") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaListTemplates::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ListTemplates") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbalisttemplates.hxx b/sw/source/ui/vba/vbalisttemplates.hxx deleted file mode 100644 index a421379848..0000000000 --- a/sw/source/ui/vba/vbalisttemplates.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_LISTTEMPLATES_HXX -#define SW_VBA_LISTTEMPLATES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XListTemplates.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextDocument.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XListTemplates > SwVbaListTemplates_BASE; - -class SwVbaListTemplates : public SwVbaListTemplates_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - sal_Int32 mnGalleryType; - -public: - SwVbaListTemplates( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nType ) throw (css::uno::RuntimeException); - virtual ~SwVbaListTemplates() {} - - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException ); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaListTemplates_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_LISTTEMPLATES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaoptions.cxx b/sw/source/ui/vba/vbaoptions.cxx deleted file mode 100644 index f2dca6b947..0000000000 --- a/sw/source/ui/vba/vbaoptions.cxx +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaoptions.hxx" -#include <vbahelper/vbahelper.hxx> -#include <ooo/vba/word/WdDefaultFilePath.hpp> -#include <ooo/vba/word/WdLineStyle.hpp> -#include <ooo/vba/word/WdLineWidth.hpp> -#include <ooo/vba/word/WdColorIndex.hpp> -#include <com/sun/star/util/XStringSubstitution.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <osl/file.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaOptions::SwVbaOptions( uno::Reference<uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : SwVbaOptions_BASE( uno::Reference< XHelperInterface >(), xContext ) -{ - mxFactory.set( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); -} - -SwVbaOptions::~SwVbaOptions() -{ -} - -uno::Any SAL_CALL -SwVbaOptions::DefaultFilePath( sal_Int32 _path ) throw ( uno::RuntimeException ) -{ - switch( _path ) - { - case word::WdDefaultFilePath::wdDocumentsPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work") ); - break; - } - case word::WdDefaultFilePath::wdPicturesPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Gallery") ); - break; - } - case word::WdDefaultFilePath::wdUserTemplatesPath: - case word::WdDefaultFilePath::wdWorkgroupTemplatesPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template") ); - break; - } - case word::WdDefaultFilePath::wdStartupPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Addin") ); - break; - } - case word::WdDefaultFilePath::wdUserOptionsPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserConfig") ); - break; - } - case word::WdDefaultFilePath::wdToolsPath: - case word::WdDefaultFilePath::wdProgramPath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Module") ); - break; - } - case word::WdDefaultFilePath::wdTempFilePath: - { - msDefaultFilePath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Temp") ); - break; - } - default: - { - DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); - break; - } - } - return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( this ) ) ); -} - -void SwVbaOptions::setValueEvent( const uno::Any& value ) -{ - rtl::OUString sNewPath; - value >>= sNewPath; - rtl::OUString sNewPathUrl; - ::osl::File::getFileURLFromSystemPath( sNewPath, sNewPathUrl ); - uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSettings")) ), uno::UNO_QUERY_THROW ); - rtl::OUString sOldPathUrl; - xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sOldPathUrl; - // path could be a multipath, Microsoft doesn't support this feature in Word currently - // only the last path is from interest. - sal_Int32 nIndex = sOldPathUrl.lastIndexOf( sal_Unicode(';') ); - if( nIndex != -1 ) - { - sNewPathUrl = sOldPathUrl.copy( 0, nIndex + 1 ).concat( sNewPathUrl ); - } - xPathSettings->setPropertyValue( msDefaultFilePath, uno::makeAny( sNewPathUrl ) ); -} - -uno::Any SwVbaOptions::getValueEvent() -{ - uno::Reference< beans::XPropertySet > xPathSettings( mxFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSettings")) ), uno::UNO_QUERY_THROW ); - rtl::OUString sPathUrl; - xPathSettings->getPropertyValue( msDefaultFilePath ) >>= sPathUrl; - // path could be a multipath, Microsoft doesn't support this feature in Word currently - // only the last path is from interest. - sal_Int32 nIndex = sPathUrl.lastIndexOf( sal_Unicode(';') ); - if( nIndex != -1 ) - { - sPathUrl = sPathUrl.copy( nIndex + 1 ); - } - rtl::OUString sPath; - ::osl::File::getSystemPathFromFileURL( sPathUrl, sPath ); - return uno::makeAny( sPath ); -} - -sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineStyle() throw (uno::RuntimeException) -{ - return word::WdLineStyle::wdLineStyleSingle; -} - -void SAL_CALL SwVbaOptions::setDefaultBorderLineStyle( ::sal_Int32 /*_defaultborderlinestyle*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderLineWidth() throw (uno::RuntimeException) -{ - return word::WdLineWidth::wdLineWidth050pt; -} - -void SAL_CALL SwVbaOptions::setDefaultBorderLineWidth( ::sal_Int32 /*_defaultborderlinewidth*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -sal_Int32 SAL_CALL SwVbaOptions::getDefaultBorderColorIndex() throw (uno::RuntimeException) -{ - return word::WdColorIndex::wdAuto; -} - -void SAL_CALL SwVbaOptions::setDefaultBorderColorIndex( ::sal_Int32 /*_defaultbordercolorindex*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getReplaceSelection() throw (uno::RuntimeException) -{ - return sal_True; -} - -void SAL_CALL SwVbaOptions::setReplaceSelection( ::sal_Bool /*_replaceselection*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getMapPaperSize() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setMapPaperSize( ::sal_Bool /*_mappapersize*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyHeadings() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyHeadings( ::sal_Bool /*_autoformatasyoutypeapplyheadings*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyBulletedLists() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyBulletedLists( ::sal_Bool /*_autoformatasyoutypeapplybulletedlists*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeApplyNumberedLists() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeApplyNumberedLists( ::sal_Bool /*_autoformatasyoutypeapplynumberedlists*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeFormatListItemBeginning() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeFormatListItemBeginning( ::sal_Bool /*_autoformatasyoutypeformatlistitembeginning*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatAsYouTypeDefineStyles() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatAsYouTypeDefineStyles( ::sal_Bool /*_autoformatasyoutypedefinestyles*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyHeadings() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatApplyHeadings( ::sal_Bool /*_autoformatapplyheadings*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyLists() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatApplyLists( ::sal_Bool /*_autoformatapplylists*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaOptions::getAutoFormatApplyBulletedLists() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaOptions::setAutoFormatApplyBulletedLists( ::sal_Bool /*_autoformatapplybulletedlists*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - - -rtl::OUString& -SwVbaOptions::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaOptions") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaOptions::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Options" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaoptions.hxx b/sw/source/ui/vba/vbaoptions.hxx deleted file mode 100644 index 169f1beebb..0000000000 --- a/sw/source/ui/vba/vbaoptions.hxx +++ /dev/null @@ -1,90 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_OPTIONS_HXX -#define SW_VBA_OPTIONS_HXX - -#include <ooo/vba/word/XOptions.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <vbahelper/vbapropvalue.hxx> -#include <comphelper/processfactory.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XOptions > SwVbaOptions_BASE; - -class SwVbaOptions : public SwVbaOptions_BASE, - public PropListener -{ -private: - rtl::OUString msDefaultFilePath; - css::uno::Reference< css::lang::XMultiServiceFactory > mxFactory; -public: - SwVbaOptions( css::uno::Reference< css::uno::XComponentContext >& m_xContext ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaOptions(); - - // Attributes - virtual ::sal_Int32 SAL_CALL getDefaultBorderLineStyle() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDefaultBorderLineStyle( ::sal_Int32 _defaultborderlinestyle ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getDefaultBorderLineWidth() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDefaultBorderLineWidth( ::sal_Int32 _defaultborderlinewidth ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getDefaultBorderColorIndex() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDefaultBorderColorIndex( ::sal_Int32 _defaultbordercolorindex ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getReplaceSelection() throw (css::uno::RuntimeException); - virtual void SAL_CALL setReplaceSelection( ::sal_Bool _replaceselection ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getMapPaperSize() throw (css::uno::RuntimeException); - virtual void SAL_CALL setMapPaperSize( ::sal_Bool _mappapersize ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyHeadings() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatAsYouTypeApplyHeadings( ::sal_Bool _autoformatasyoutypeapplyheadings ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyBulletedLists() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatAsYouTypeApplyBulletedLists( ::sal_Bool _autoformatasyoutypeapplybulletedlists ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatAsYouTypeApplyNumberedLists() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatAsYouTypeApplyNumberedLists( ::sal_Bool _autoformatasyoutypeapplynumberedlists ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatAsYouTypeFormatListItemBeginning() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatAsYouTypeFormatListItemBeginning( ::sal_Bool _autoformatasyoutypeformatlistitembeginning ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatAsYouTypeDefineStyles() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatAsYouTypeDefineStyles( ::sal_Bool _autoformatasyoutypedefinestyles ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatApplyHeadings() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatApplyHeadings( ::sal_Bool _autoformatapplyheadings ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatApplyLists() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatApplyLists( ::sal_Bool _autoformatapplylists ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getAutoFormatApplyBulletedLists() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAutoFormatApplyBulletedLists( ::sal_Bool _autoformatapplybulletedlists ) throw (css::uno::RuntimeException); - - // Methods - virtual css::uno::Any SAL_CALL DefaultFilePath( sal_Int32 _path ) throw ( css::uno::RuntimeException ); - - //PropListener - virtual void setValueEvent( const css::uno::Any& value ); - virtual css::uno::Any getValueEvent(); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_OPTIONS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapagesetup.cxx b/sw/source/ui/vba/vbapagesetup.cxx deleted file mode 100644 index 4303e4813a..0000000000 --- a/sw/source/ui/vba/vbapagesetup.cxx +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbapagesetup.hxx" -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/text/XPageCursor.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <ooo/vba/word/WdSectionStart.hpp> -#include <ooo/vba/word/WdOrientation.hpp> -#include "wordvbahelper.hxx" - -using namespace ::com::sun::star; -using namespace ::ooo::vba; - -SwVbaPageSetup::SwVbaPageSetup(const uno::Reference< XHelperInterface >& xParent, - const uno::Reference< uno::XComponentContext >& xContext, - const uno::Reference< frame::XModel >& xModel, - const uno::Reference< beans::XPropertySet >& xProps ) throw (uno::RuntimeException): - SwVbaPageSetup_BASE( xParent, xContext ) -{ - mxModel.set( xModel, uno::UNO_QUERY_THROW ); - mxPageProps.set( xProps, uno::UNO_QUERY_THROW ); - mnOrientPortrait = word::WdOrientation::wdOrientPortrait; - mnOrientLandscape = word::WdOrientation::wdOrientLandscape; -} - -double SAL_CALL SwVbaPageSetup::getGutter() throw (uno::RuntimeException) -{ - // not support in Writer - return 0; -} - -void SAL_CALL SwVbaPageSetup::setGutter( double _gutter ) throw (uno::RuntimeException) -{ - // default add gutter into left margin - if( _gutter != 0 ) - { - double margin = VbaPageSetupBase::getLeftMargin() + _gutter; - VbaPageSetupBase::setLeftMargin( margin ); - } -} - -double SAL_CALL SwVbaPageSetup::getHeaderDistance() throw (uno::RuntimeException) -{ - sal_Bool isHeaderOn = sal_False; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))) >>= isHeaderOn; - if( !isHeaderOn ) - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn")), uno::makeAny( sal_True ) ); - return VbaPageSetupBase::getHeaderMargin(); -} - - /** - * changes the value of TopMargin to the value of new MS-Word-HeaderDistance. Subtracts the difference - * between old TopMargin and the new headerDistance from the value of HeaderSpacing (which defines the - * space between the header and the body of the text). calculates the new HeaderHeight (= height of the - * header + headerBodyDistance). - * - * @param: headerDistance is the value that is set in MS Word for the distance from the top of the page - * to the header - */ -void SAL_CALL SwVbaPageSetup::setHeaderDistance( double _headerdistance ) throw (uno::RuntimeException) -{ - sal_Int32 newHeaderDistance = Millimeter::getInHundredthsOfOneMillimeter( _headerdistance ); - sal_Bool isHeaderOn = sal_False; - sal_Int32 aktTopMargin = 0; - sal_Int32 aktSpacing = 0; - sal_Int32 aktHeaderHeight = 0; - - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))) >>= isHeaderOn; - if( !isHeaderOn ) - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn")), uno::makeAny( sal_True ) ); - - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin"))) >>= aktTopMargin; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderBodyDistance"))) >>= aktSpacing; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderHeight"))) >>= aktHeaderHeight; - - sal_Int32 newSpacing = aktSpacing - ( newHeaderDistance - aktTopMargin ); - sal_Int32 height = aktHeaderHeight - aktSpacing; - sal_Int32 newHeaderHeight = newSpacing + height; - - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin")), uno::makeAny( newHeaderDistance ) ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderBodyDistance")), uno::makeAny( newSpacing ) ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderHeight")), uno::makeAny( newHeaderHeight ) ); -} - -double SAL_CALL SwVbaPageSetup::getFooterDistance() throw (uno::RuntimeException) -{ - sal_Bool isFooterOn = sal_False; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))) >>= isFooterOn; - if( !isFooterOn ) - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn")), uno::makeAny( sal_True ) ); - return VbaPageSetupBase::getFooterMargin(); -} - -void SAL_CALL SwVbaPageSetup::setFooterDistance( double _footerdistance ) throw (uno::RuntimeException) -{ - sal_Int32 newFooterDistance = Millimeter::getInHundredthsOfOneMillimeter( _footerdistance ); - sal_Bool isFooterOn = sal_False; - sal_Int32 aktBottomMargin = 0; - sal_Int32 aktSpacing = 0; - sal_Int32 aktFooterHeight = 0; - - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn"))) >>= isFooterOn; - if( !isFooterOn ) - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn")), uno::makeAny( sal_True ) ); - - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin"))) >>= aktBottomMargin; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterBodyDistance"))) >>= aktSpacing; - mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterHeight"))) >>= aktFooterHeight; - - sal_Int32 newSpacing = aktSpacing - ( newFooterDistance - aktBottomMargin ); - sal_Int32 height = aktFooterHeight - aktSpacing; - sal_Int32 newFooterHeight = newSpacing + height; - - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin")), uno::makeAny( newFooterDistance ) ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterBodyDistance")), uno::makeAny( newSpacing ) ); - mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterHeight")), uno::makeAny( newFooterHeight ) ); -} - -sal_Bool SAL_CALL SwVbaPageSetup::getDifferentFirstPageHeaderFooter() throw (uno::RuntimeException) -{ - rtl::OUString pageStyle = getStyleOfFirstPage(); - if( pageStyle.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "First Page" ) ) ) - return sal_True; - - return sal_False; -} - -void SAL_CALL SwVbaPageSetup::setDifferentFirstPageHeaderFooter( sal_Bool status ) throw (uno::RuntimeException) -{ - if( status == getDifferentFirstPageHeaderFooter() ) - return; - - rtl::OUString newStyle; - if( status ) - newStyle = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("First Page") ); - else - newStyle = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - - uno::Reference< beans::XPropertySet > xStyleProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW ); - sal_Int32 nTopMargin = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin"))) >>= nTopMargin; - sal_Int32 nBottomMargin = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin"))) >>= nBottomMargin; - sal_Int32 nLeftMargin = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin"))) >>= nLeftMargin; - sal_Int32 nRightMargin = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin"))) >>= nRightMargin; - sal_Int32 nHeaderHeight = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderHeight"))) >>= nHeaderHeight; - sal_Int32 nFooterHeight = 0; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterHeight"))) >>= nFooterHeight; - - sal_Bool isHeaderOn = sal_False; - xStyleProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn"))) >>= isHeaderOn; - if( isHeaderOn ) - { - nTopMargin += nHeaderHeight; - nBottomMargin += nFooterHeight; - xStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn")), uno::makeAny( sal_False ) ); - xStyleProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn")), uno::makeAny( sal_False ) ); - } - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( mxModel ), uno::UNO_QUERY_THROW ); - if( xPageCursor->getPage() != 1 ) - { - xPageCursor->jumpToFirstPage(); - } - - uno::Reference< beans::XPropertySet > xCursorProps( xPageCursor, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xTableProps( xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ), uno::UNO_QUERY ); - if( xTableProps.is() ) - { - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageDescName") ), uno::makeAny( newStyle ) ); - } - else - { - xCursorProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageDescName") ), uno::makeAny( newStyle ) ); - } - - uno::Reference< beans::XPropertySet > xFirstPageProps( word::getCurrentPageStyle( mxModel ), uno::UNO_QUERY_THROW ); - xFirstPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin") ), uno::makeAny( nTopMargin ) ); - xFirstPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin") ), uno::makeAny( nBottomMargin ) ); - xFirstPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ), uno::makeAny( nLeftMargin ) ); - xFirstPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin") ), uno::makeAny( nRightMargin ) ); -} - -rtl::OUString SwVbaPageSetup::getStyleOfFirstPage() throw (uno::RuntimeException) -{ - rtl::OUString styleFirstPage; - uno::Reference< text::XPageCursor > xPageCursor( word::getXTextViewCursor( mxModel ), uno::UNO_QUERY_THROW ); - if( xPageCursor->getPage() != 1 ) - { - xPageCursor->jumpToFirstPage(); - } - - uno::Reference< beans::XPropertySet > xCursorProps( xPageCursor, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xTableProps( xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ), uno::UNO_QUERY ); - if( xTableProps.is() ) - { - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageDescName") ) ) >>= styleFirstPage; - } - else - { - xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageDescName") ) ) >>= styleFirstPage; - } - return styleFirstPage; -} - -::sal_Int32 SAL_CALL SwVbaPageSetup::getSectionStart() throw (uno::RuntimeException) -{ - // FIXME: - sal_Int32 wdSectionStart = word::WdSectionStart::wdSectionNewPage; - uno::Reference< container::XNamed > xNamed( mxPageProps, uno::UNO_QUERY_THROW ); - rtl::OUString sStyleName = xNamed->getName(); - if( sStyleName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Left Page")) ) - wdSectionStart = word::WdSectionStart::wdSectionEvenPage; - else if( sStyleName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Right Page")) ) - wdSectionStart = word::WdSectionStart::wdSectionOddPage; - else - wdSectionStart = word::WdSectionStart::wdSectionNewPage; - return wdSectionStart; -} - -void SAL_CALL SwVbaPageSetup::setSectionStart( ::sal_Int32 /*_sectionstart*/ ) throw (uno::RuntimeException) -{ - // fail to find corresponding feature in Writer - // #FIXME: -} - -rtl::OUString& -SwVbaPageSetup::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPageSetup") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaPageSetup::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.PageSetup" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapagesetup.hxx b/sw/source/ui/vba/vbapagesetup.hxx deleted file mode 100644 index 1437b4d92b..0000000000 --- a/sw/source/ui/vba/vbapagesetup.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PAGESETUP_HXX -#define SW_VBA_PAGESETUP_HXX - -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/word/XPageSetup.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbapagesetupbase.hxx> - -typedef cppu::ImplInheritanceHelper1< VbaPageSetupBase, ooo::vba::word::XPageSetup > SwVbaPageSetup_BASE; - -class SwVbaPageSetup : public SwVbaPageSetup_BASE -{ -private: - rtl::OUString getStyleOfFirstPage() throw (css::uno::RuntimeException); - -public: - SwVbaPageSetup( const css::uno::Reference< ooo::vba::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 >& xProps ) throw (css::uno::RuntimeException); - virtual ~SwVbaPageSetup(){} - - // Attributes - virtual double SAL_CALL getGutter() throw (css::uno::RuntimeException); - virtual void SAL_CALL setGutter( double _gutter ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getHeaderDistance() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeaderDistance( double _headerdistance ) throw (css::uno::RuntimeException); - virtual double SAL_CALL getFooterDistance() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFooterDistance( double _footerdistance ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getDifferentFirstPageHeaderFooter() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDifferentFirstPageHeaderFooter( sal_Bool status ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getSectionStart() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSectionStart( ::sal_Int32 _sectionstart ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapalette.cxx b/sw/source/ui/vba/vbapalette.cxx deleted file mode 100644 index 8943b73b4a..0000000000 --- a/sw/source/ui/vba/vbapalette.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "vbapalette.hxx" -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <ooo/vba/word/WdColor.hpp> -#include <ooo/vba/word/WdColorIndex.hpp> -#include <sal/macros.h> - -using namespace ::ooo::vba; -using namespace ::ooo::vba::word; -using namespace ::com::sun::star; - -static const sal_Int32 ColorTable[] = -{ -WdColor::wdColorAutomatic, // 0 -WdColor::wdColorBlack, // 1 -WdColor::wdColorBlue, // 2 -WdColor::wdColorTurquoise, // 3 -WdColor::wdColorBrightGreen, // 4 -WdColor::wdColorPink, // 5 -WdColor::wdColorRed, // 6 -WdColor::wdColorYellow, // 7 -WdColor::wdColorWhite, // 8 -WdColor::wdColorDarkBlue, // 9 -WdColor::wdColorTeal, // 10 -WdColor::wdColorGreen, // 11 -WdColor::wdColorViolet, // 12 -WdColor::wdColorDarkRed, // 13 -WdColor::wdColorDarkYellow, // 14 -WdColor::wdColorGray50, // 15 -WdColor::wdColorGray25, // 16 -}; - -typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE; - -class DefaultPalette : public XIndexAccess_BASE -{ -public: - DefaultPalette(){} - - // Methods XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) - { - return SAL_N_ELEMENTS(ColorTable); - } - - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 || Index >= getCount() ) - throw lang::IndexOutOfBoundsException(); - return uno::makeAny( sal_Int32( ColorTable[ Index ] ) ); - } - - // Methods XElementAcess - virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException) - { - return ::getCppuType( (sal_Int32*)0 ); - } - virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException) - { - return sal_True; - } - -}; - -VbaPalette::VbaPalette() -{ - mxPalette = new DefaultPalette(); -} - -uno::Reference< container::XIndexAccess > -VbaPalette::getPalette() const -{ - - return mxPalette; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapalette.hxx b/sw/source/ui/vba/vbapalette.hxx deleted file mode 100644 index 5d7b6fe652..0000000000 --- a/sw/source/ui/vba/vbapalette.hxx +++ /dev/null @@ -1,18 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef VBAPALETTE_HXX -#define VBAPALETTE_HXX -#include <vbahelper/vbahelper.hxx> - -class VbaPalette -{ - css::uno::Reference< css::container::XIndexAccess > mxPalette; -public: - VbaPalette(); - // if no palette available e.g. because the document doesn't have a - // palette defined then a default palette will be returned. - css::uno::Reference< css::container::XIndexAccess > getPalette() const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapane.cxx b/sw/source/ui/vba/vbapane.cxx deleted file mode 100644 index a76596c3fd..0000000000 --- a/sw/source/ui/vba/vbapane.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbapane.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbaview.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaPane::SwVbaPane( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, - const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : - SwVbaPane_BASE( rParent, rContext ), mxModel( xModel ) -{ -} - -SwVbaPane::~SwVbaPane() -{ -} - -uno::Any SAL_CALL -SwVbaPane::View() throw ( css::uno::RuntimeException ) -{ - return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this, mxContext, mxModel ) ) ); -} - -void SAL_CALL -SwVbaPane::Close( ) throw ( css::uno::RuntimeException ) -{ - rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseWin")); - dispatchRequests( mxModel,url ); -} - -rtl::OUString& -SwVbaPane::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPane") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaPane::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Pane" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapane.hxx b/sw/source/ui/vba/vbapane.hxx deleted file mode 100644 index bbb341dc86..0000000000 --- a/sw/source/ui/vba/vbapane.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PANE_HXX -#define SW_VBA_PANE_HXX - -#include <ooo/vba/word/XPane.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XPane > SwVbaPane_BASE; - -class SwVbaPane : public SwVbaPane_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - -public: - SwVbaPane( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, - const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaPane(); - - // Methods - virtual css::uno::Any SAL_CALL View( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_PANE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapanes.cxx b/sw/source/ui/vba/vbapanes.cxx deleted file mode 100644 index 076a26f7cb..0000000000 --- a/sw/source/ui/vba/vbapanes.cxx +++ /dev/null @@ -1,127 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbapanes.hxx" -#include "vbapane.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -// I assume there is only one pane in Writer -typedef ::cppu::WeakImplHelper1<container::XIndexAccess > PanesIndexAccess_Base; -class PanesIndexAccess : public PanesIndexAccess_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - -public: - PanesIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) {} - ~PanesIndexAccess(){} - - // XIndexAccess - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return 1; - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if( Index != 1 ) - throw container::NoSuchElementException(); - return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( mxParent, mxContext, mxModel ) ) ); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XPane::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } -}; - -class PanesEnumWrapper : public EnumerationHelper_BASE -{ - uno::Reference<container::XIndexAccess > m_xIndexAccess; - sal_Int32 nIndex; -public: - PanesEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < m_xIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( nIndex < m_xIndexAccess->getCount() ) - return m_xIndexAccess->getByIndex( nIndex++ ); - throw container::NoSuchElementException(); - } -}; - -SwVbaPanes::SwVbaPanes( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaPanes_BASE( xParent, xContext, new PanesIndexAccess( xParent, xContext, xModel ) ), mxModel( xModel ) -{ -} -// XEnumerationAccess -uno::Type -SwVbaPanes::getElementType() throw (uno::RuntimeException) -{ - return word::XPane::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaPanes::createEnumeration() throw (uno::RuntimeException) -{ - return new PanesEnumWrapper( m_xIndexAccess ); -} - -uno::Any -SwVbaPanes::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaPanes::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaPanes") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaPanes::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Panes") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbapanes.hxx b/sw/source/ui/vba/vbapanes.hxx deleted file mode 100644 index 5a7fd67eb4..0000000000 --- a/sw/source/ui/vba/vbapanes.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PANES_HXX -#define SW_VBA_PANES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XPanes.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef CollTestImplHelper< ooo::vba::word::XPanes > SwVbaPanes_BASE; - -class SwVbaPanes : public SwVbaPanes_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - -public: - SwVbaPanes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel ); - virtual ~SwVbaPanes() {} - - // 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); - - // SwVbaPanes_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_PANES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaparagraph.cxx b/sw/source/ui/vba/vbaparagraph.cxx deleted file mode 100644 index f512c5844a..0000000000 --- a/sw/source/ui/vba/vbaparagraph.cxx +++ /dev/null @@ -1,189 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaparagraph.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbarange.hxx" -#include <com/sun/star/lang/XServiceInfo.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaParagraph::SwVbaParagraph( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xDocument, const uno::Reference< text::XTextRange >& xTextRange ) throw ( uno::RuntimeException ) : - SwVbaParagraph_BASE( rParent, rContext ), mxTextDocument( xDocument ), mxTextRange( xTextRange ) -{ -} - -SwVbaParagraph::~SwVbaParagraph() -{ -} - -uno::Reference< word::XRange > SAL_CALL -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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaParagraph") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaParagraph::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Paragraph" ) ); - } - return aServiceNames; -} - -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > ParagraphCollectionHelper_BASE; - -class ParagraphCollectionHelper : public ParagraphCollectionHelper_BASE -{ -private: - uno::Reference< text::XTextDocument > mxTextDocument; - - uno::Reference< container::XEnumeration > getEnumeration() throw (uno::RuntimeException) - { - uno::Reference< container::XEnumerationAccess > xParEnumAccess( mxTextDocument->getText(), uno::UNO_QUERY_THROW ); - return xParEnumAccess->createEnumeration(); - } - -public: - ParagraphCollectionHelper( const uno::Reference< text::XTextDocument >& xDocument ) throw (uno::RuntimeException): mxTextDocument( xDocument ) - { - } - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return text::XTextRange::static_type(0); } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return sal_True; } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - sal_Int32 nCount = 0; - uno::Reference< container::XEnumeration > xParEnum = getEnumeration(); - while( xParEnum->hasMoreElements() ) - { - uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph") ) ) ) - { - nCount++; - } - } - return nCount; - } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) - { - if( Index < getCount() ) - { - sal_Int32 nCount = 0; - uno::Reference< container::XEnumeration > xParEnum = getEnumeration(); - while( xParEnum->hasMoreElements() ) - { - uno::Reference< lang::XServiceInfo > xServiceInfo( xParEnum->nextElement(), uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Paragraph") ) ) ) - { - if( Index == nCount ) - return uno::makeAny( xServiceInfo ); - nCount++; - } - } - } - throw lang::IndexOutOfBoundsException(); - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return getEnumeration(); - } -}; - -SwVbaParagraphs::SwVbaParagraphs( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDocument ) throw (uno::RuntimeException) : SwVbaParagraphs_BASE( xParent, xContext, new ParagraphCollectionHelper( xDocument ) ), mxTextDocument( xDocument ) -{ -} - -// XEnumerationAccess -uno::Type -SwVbaParagraphs::getElementType() throw (uno::RuntimeException) -{ - return word::XParagraph::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaParagraphs::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumerationAccess->createEnumeration(); -} - -uno::Any -SwVbaParagraphs::createCollectionObject( const css::uno::Any& aSource ) -{ - uno::Reference< text::XTextRange > xTextRange( aSource, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XParagraph >( new SwVbaParagraph( this, mxContext, mxTextDocument, xTextRange ) ) ); -} - -rtl::OUString& -SwVbaParagraphs::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaParagraphs") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaParagraphs::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Paragraphs") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaparagraph.hxx b/sw/source/ui/vba/vbaparagraph.hxx deleted file mode 100644 index a475ceb6bf..0000000000 --- a/sw/source/ui/vba/vbaparagraph.hxx +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PARAGRAPH_HXX -#define SW_VBA_PARAGRAPH_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XParagraphs.hpp> -#include <ooo/vba/word/XParagraph.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XTextDocument.hpp> - - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XParagraph > SwVbaParagraph_BASE; - -class SwVbaParagraph : public SwVbaParagraph_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::text::XTextRange > mxTextRange; - -public: - SwVbaParagraph( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xDocument, const css::uno::Reference< css::text::XTextRange >& xTextRange ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaParagraph(); - - // 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(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - - -/* class SwVbaParagraphs */ -typedef CollTestImplHelper< ooo::vba::word::XParagraphs > SwVbaParagraphs_BASE; - -class SwVbaParagraphs : public SwVbaParagraphs_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; -public: - SwVbaParagraphs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xDocument ) throw (css::uno::RuntimeException); - virtual ~SwVbaParagraphs() {} - - // 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); - - // SwVbaParagraphs_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_PARAGRAPH_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaparagraphformat.cxx b/sw/source/ui/vba/vbaparagraphformat.cxx deleted file mode 100644 index 8a2391f4c4..0000000000 --- a/sw/source/ui/vba/vbaparagraphformat.cxx +++ /dev/null @@ -1,579 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaparagraphformat.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "wordvbahelper.hxx" -#include <com/sun/star/style/LineSpacingMode.hpp> -#include <ooo/vba/word/WdLineSpacing.hpp> -#include <ooo/vba/word/WdParagraphAlignment.hpp> -#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; -using namespace ::com::sun::star; - -static const sal_Int16 CHARACTER_INDENT_FACTOR = 12; -static const sal_Int16 PERCENT100 = 100; -static const sal_Int16 PERCENT150 = 150; -static const sal_Int16 PERCENT200 = 200; - -SwVbaParagraphFormat::SwVbaParagraphFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< beans::XPropertySet >& rParaProps ) : SwVbaParagraphFormat_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mxParaProps( rParaProps ) -{ -} - -SwVbaParagraphFormat::~SwVbaParagraphFormat() -{ -} - -sal_Int32 SAL_CALL SwVbaParagraphFormat::getAlignment() throw (uno::RuntimeException) -{ - style::ParagraphAdjust aParaAdjust = style::ParagraphAdjust_LEFT; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAdjust") ) ) >>= aParaAdjust; - return getMSWordAlignment( aParaAdjust ); -} - -void SAL_CALL SwVbaParagraphFormat::setAlignment( sal_Int32 _alignment ) throw (uno::RuntimeException) -{ - style::ParagraphAdjust aParaAdjust = ( style::ParagraphAdjust ) getOOoAlignment( _alignment ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAdjust") ), uno::makeAny( aParaAdjust ) ); -} - -float SAL_CALL SwVbaParagraphFormat::getFirstLineIndent() throw (uno::RuntimeException) -{ - sal_Int32 indent = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaFirstLineIndent") ) ) >>= indent; - return (float)( Millimeter::getInPoints( indent ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setFirstLineIndent( float _firstlineindent ) throw (uno::RuntimeException) -{ - sal_Int32 indent = Millimeter::getInHundredthsOfOneMillimeter( _firstlineindent ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaFirstLineIndent") ), uno::makeAny( indent ) ); -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getKeepTogether() throw (uno::RuntimeException) -{ - sal_Bool bKeep = sal_False; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaKeepTogether") ) ) >>= bKeep; - return uno::makeAny ( bKeep ); -} - -void SAL_CALL SwVbaParagraphFormat::setKeepTogether( const uno::Any& _keeptogether ) throw (uno::RuntimeException) -{ - sal_Bool bKeep = sal_False; - if( _keeptogether >>= bKeep ) - { - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaKeepTogether") ), uno::makeAny( bKeep ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getKeepWithNext() throw (uno::RuntimeException) -{ - sal_Bool bKeep = sal_False; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaSplit") ) ) >>= bKeep; - return uno::makeAny ( bKeep ); -} - -void SAL_CALL SwVbaParagraphFormat::setKeepWithNext( const uno::Any& _keepwithnext ) throw (uno::RuntimeException) -{ - sal_Bool bKeep = sal_False; - if( _keepwithnext >>= bKeep ) - { - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaSplit") ), uno::makeAny( bKeep ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getHyphenation() throw (uno::RuntimeException) -{ - sal_Bool bHypn = sal_False; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation") ) ) >>= bHypn; - return uno::makeAny ( bHypn ); -} - -void SAL_CALL SwVbaParagraphFormat::setHyphenation( const uno::Any& _hyphenation ) throw (uno::RuntimeException) -{ - sal_Bool bHypn = sal_False; - if( _hyphenation >>= bHypn ) - { - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation") ), uno::makeAny( bHypn ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -float SAL_CALL SwVbaParagraphFormat::getLineSpacing() throw (uno::RuntimeException) -{ - style::LineSpacing aLineSpacing; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing; - return getMSWordLineSpacing( aLineSpacing ); -} - -void SAL_CALL SwVbaParagraphFormat::setLineSpacing( float _linespacing ) throw (uno::RuntimeException) -{ - style::LineSpacing aLineSpacing; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing; - aLineSpacing = getOOoLineSpacing( _linespacing, aLineSpacing.Mode ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ), uno::makeAny( aLineSpacing ) ); -} - -sal_Int32 SAL_CALL SwVbaParagraphFormat::getLineSpacingRule() throw (uno::RuntimeException) -{ - style::LineSpacing aLineSpacing; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing; - return getMSWordLineSpacingRule( aLineSpacing ); -} - -void SAL_CALL SwVbaParagraphFormat::setLineSpacingRule( sal_Int32 _linespacingrule ) throw (uno::RuntimeException) -{ - style::LineSpacing aLineSpacing = getOOoLineSpacingFromRule( _linespacingrule ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ), uno::makeAny( aLineSpacing ) ); -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getNoLineNumber() throw (uno::RuntimeException) -{ - sal_Bool noLineNum = sal_False; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineNumberCount") ) ) >>= noLineNum; - return uno::makeAny ( noLineNum ); -} - -void SAL_CALL SwVbaParagraphFormat::setNoLineNumber( const uno::Any& _nolinenumber ) throw (uno::RuntimeException) -{ - sal_Bool noLineNum = sal_False; - if( _nolinenumber >>= noLineNum ) - { - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineNumberCount") ), uno::makeAny( noLineNum ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -sal_Int32 SAL_CALL SwVbaParagraphFormat::getOutlineLevel() throw (uno::RuntimeException) -{ - sal_Int32 nLevel = word::WdOutlineLevel::wdOutlineLevelBodyText; - rtl::OUString aHeading; - const rtl::OUString HEADING = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Heading") ); - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ) ) >>= aHeading; - if( aHeading.indexOf( HEADING ) == 0 ) - { - // get the sub string after "Heading" - nLevel = aHeading.copy( HEADING.getLength() ).toInt32(); - } - return nLevel; -} - -void SAL_CALL SwVbaParagraphFormat::setOutlineLevel( sal_Int32 _outlinelevel ) throw (uno::RuntimeException) -{ - 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) -{ - style::BreakType aBreakType; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ) ) >>= aBreakType; - sal_Bool bBreakBefore = ( aBreakType == style::BreakType_PAGE_BEFORE || aBreakType == style::BreakType_PAGE_BOTH ); - return uno::makeAny( bBreakBefore ); -} - -void SAL_CALL SwVbaParagraphFormat::setPageBreakBefore( const uno::Any& _breakbefore ) throw (uno::RuntimeException) -{ - sal_Bool bBreakBefore = sal_False; - if( _breakbefore >>= bBreakBefore ) - { - style::BreakType aBreakType; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ) ) >>= aBreakType; - if( bBreakBefore ) - { - if( aBreakType == style::BreakType_NONE ) - aBreakType = style::BreakType_PAGE_BEFORE; - else if ( aBreakType == style::BreakType_PAGE_AFTER ) - aBreakType = style::BreakType_PAGE_BOTH; - } - else - { - if( aBreakType == style::BreakType_PAGE_BOTH ) - aBreakType = style::BreakType_PAGE_AFTER; - else if ( aBreakType == style::BreakType_PAGE_BEFORE ) - aBreakType = style::BreakType_PAGE_AFTER; - } - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ), uno::makeAny( aBreakType ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -float SAL_CALL SwVbaParagraphFormat::getSpaceBefore() throw (uno::RuntimeException) -{ - sal_Int32 nSpace = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTopMargin") ) ) >>= nSpace; - return (float)( Millimeter::getInPoints( nSpace ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setSpaceBefore( float _space ) throw (uno::RuntimeException) -{ - sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _space ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTopMargin") ), uno::makeAny( nSpace ) ); -} - -float SAL_CALL SwVbaParagraphFormat::getSpaceAfter() throw (uno::RuntimeException) -{ - sal_Int32 nSpace = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaBottomMargin") ) ) >>= nSpace; - return (float)( Millimeter::getInPoints( nSpace ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setSpaceAfter( float _space ) throw (uno::RuntimeException) -{ - sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _space ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaBottomMargin") ), uno::makeAny( nSpace ) ); -} - -float SAL_CALL SwVbaParagraphFormat::getLeftIndent() throw (uno::RuntimeException) -{ - sal_Int32 nIndent = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLeftMargin") ) ) >>= nIndent; - return (float)( Millimeter::getInPoints( nIndent ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setLeftIndent( float _leftindent ) throw (uno::RuntimeException) -{ - sal_Int32 nIndent = Millimeter::getInHundredthsOfOneMillimeter( _leftindent ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLeftMargin") ), uno::makeAny( nIndent ) ); -} - -float SAL_CALL SwVbaParagraphFormat::getRightIndent() throw (uno::RuntimeException) -{ - sal_Int32 nIndent = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaRightMargin") ) ) >>= nIndent; - return (float)( Millimeter::getInPoints( nIndent ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setRightIndent( float _rightindent ) throw (uno::RuntimeException) -{ - sal_Int32 nIndent = Millimeter::getInHundredthsOfOneMillimeter( _rightindent ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaRightMargin") ), uno::makeAny( nIndent ) ); -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getTabStops() throw (uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< word::XTabStops >( new SwVbaTabStops( this, mxContext, mxParaProps ) ) ); -} - -void SAL_CALL SwVbaParagraphFormat::setTabStops( const uno::Any& /*_tabstops*/ ) throw (uno::RuntimeException) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -uno::Any SAL_CALL SwVbaParagraphFormat::getWidowControl() throw (uno::RuntimeException) -{ - sal_Bool bWidow = sal_False; - sal_Int8 nWidow = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaWidows") ) ) >>= nWidow; - sal_Int8 nOrphan = 0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaOrphans") ) ) >>= nOrphan; - // if the amount of single lines on one page > 1 and the same of start and end of the paragraph, - // true is retured. - bWidow = ( nWidow > 1 && nOrphan == nWidow ); - return uno::makeAny( bWidow ); -} - -void SAL_CALL SwVbaParagraphFormat::setWidowControl( const uno::Any& _widowcontrol ) throw (uno::RuntimeException) -{ - // if we get true, the part of the paragraph on one page has to be - // at least two lines - sal_Bool bWidow = sal_False; - if( _widowcontrol >>= bWidow ) - { - sal_Int8 nControl = bWidow? 2:1; - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaWidows") ), uno::makeAny( nControl ) ); - mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaOrphans") ), uno::makeAny( nControl ) ); - } - else - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } -} - -style::LineSpacing SwVbaParagraphFormat::getOOoLineSpacing( float _lineSpace, sal_Int16 mode ) -{ - style::LineSpacing aLineSpacing; - if( mode != style::LineSpacingMode::MINIMUM && mode != style::LineSpacingMode::FIX ) - { - // special behaviour of word: if the space is set to these values, the rule and - // the height are changed accordingly - if( _lineSpace == CHARACTER_INDENT_FACTOR ) - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = PERCENT100; - } - else if( _lineSpace == ( sal_Int16 )( CHARACTER_INDENT_FACTOR * 1.5 ) ) - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = PERCENT150; - } - else if( _lineSpace == ( sal_Int16 )( ( CHARACTER_INDENT_FACTOR ) * 2 ) ) - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = PERCENT200; - } - else - { - aLineSpacing.Mode = style::LineSpacingMode::FIX; - aLineSpacing.Height = ( sal_Int16 )( Millimeter::getInHundredthsOfOneMillimeter( _lineSpace ) ); - } - } - else - { - aLineSpacing.Mode = mode; - aLineSpacing.Height = ( sal_Int16 )( Millimeter::getInHundredthsOfOneMillimeter( _lineSpace ) ); - } - return aLineSpacing; -} - -style::LineSpacing SwVbaParagraphFormat::getOOoLineSpacingFromRule( sal_Int32 _linespacingrule ) -{ - style::LineSpacing aLineSpacing; - switch( _linespacingrule ) - { - case word::WdLineSpacing::wdLineSpace1pt5: - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = PERCENT150; - break; - } - case word::WdLineSpacing::wdLineSpaceAtLeast: - { - aLineSpacing.Mode = style::LineSpacingMode::MINIMUM; - aLineSpacing.Height = getCharHeight(); - break; - } - case word::WdLineSpacing::wdLineSpaceDouble: - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = getCharHeight(); - break; - } - case word::WdLineSpacing::wdLineSpaceExactly: - case word::WdLineSpacing::wdLineSpaceMultiple: - { - aLineSpacing.Mode = style::LineSpacingMode::FIX; - aLineSpacing.Height = getCharHeight(); - break; - } - case word::WdLineSpacing::wdLineSpaceSingle: - { - aLineSpacing.Mode = style::LineSpacingMode::PROP; - aLineSpacing.Height = PERCENT100; - break; - } - default: - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - break; - } - } - return aLineSpacing; -} - -float SwVbaParagraphFormat::getMSWordLineSpacing( style::LineSpacing& rLineSpacing ) -{ - float wdLineSpacing = 0; - if( rLineSpacing.Mode != style::LineSpacingMode::PROP ) - { - wdLineSpacing = (float)( Millimeter::getInPoints( rLineSpacing.Height ) ); - } - else - { - wdLineSpacing = (float)( CHARACTER_INDENT_FACTOR * rLineSpacing.Height ) / PERCENT100; - } - return wdLineSpacing; -} - -sal_Int32 SwVbaParagraphFormat::getMSWordLineSpacingRule( style::LineSpacing& rLineSpacing ) -{ - sal_Int32 wdLineSpacing = word::WdLineSpacing::wdLineSpaceSingle; - switch( rLineSpacing.Mode ) - { - case style::LineSpacingMode::PROP: - { - switch( rLineSpacing.Height ) - { - case PERCENT100: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpaceSingle; - break; - } - case PERCENT150: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpace1pt5; - break; - } - case PERCENT200: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpaceDouble; - break; - } - default: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpaceMultiple; - } - } - break; - } - case style::LineSpacingMode::MINIMUM: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpaceAtLeast; - break; - } - case style::LineSpacingMode::FIX: - case style::LineSpacingMode::LEADING: - { - wdLineSpacing = word::WdLineSpacing::wdLineSpaceExactly; - break; - } - default: - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } - } - return wdLineSpacing; -} - -sal_Int16 SwVbaParagraphFormat::getCharHeight() throw (uno::RuntimeException) -{ - float fCharHeight = 0.0; - mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharHeight") ) ) >>= fCharHeight; - return (sal_Int16)( Millimeter::getInHundredthsOfOneMillimeter( fCharHeight ) ); -} - -sal_Int32 SwVbaParagraphFormat::getOOoAlignment( sal_Int32 _alignment ) -{ - sal_Int32 nParaAjust = style::ParagraphAdjust_LEFT; - switch( _alignment ) - { - case word::WdParagraphAlignment::wdAlignParagraphCenter: - { - nParaAjust = style::ParagraphAdjust_CENTER; - break; - } - case word::WdParagraphAlignment::wdAlignParagraphJustify: - { - nParaAjust = style::ParagraphAdjust_BLOCK; - break; - } - case word::WdParagraphAlignment::wdAlignParagraphLeft: - { - nParaAjust = style::ParagraphAdjust_LEFT; - break; - } - case word::WdParagraphAlignment::wdAlignParagraphRight: - { - nParaAjust = style::ParagraphAdjust_RIGHT; - break; - } - default: - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } - } - return nParaAjust; -} - -sal_Int32 SwVbaParagraphFormat::getMSWordAlignment( sal_Int32 _alignment ) -{ - sal_Int32 wdAlignment = word::WdParagraphAlignment::wdAlignParagraphLeft; - switch( _alignment ) - { - case style::ParagraphAdjust_CENTER: - { - wdAlignment = word::WdParagraphAlignment::wdAlignParagraphCenter; - break; - } - case style::ParagraphAdjust_LEFT: - { - wdAlignment = word::WdParagraphAlignment::wdAlignParagraphLeft; - break; - } - case style::ParagraphAdjust_BLOCK: - { - wdAlignment = word::WdParagraphAlignment::wdAlignParagraphJustify; - break; - } - case style::ParagraphAdjust_RIGHT: - { - wdAlignment = word::WdParagraphAlignment::wdAlignParagraphRight; - break; - } - default: - { - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } - } - return wdAlignment; -} - -rtl::OUString& -SwVbaParagraphFormat::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaParagraphFormat") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaParagraphFormat::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ParagraphFormat" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaparagraphformat.hxx b/sw/source/ui/vba/vbaparagraphformat.hxx deleted file mode 100644 index 232046ff0d..0000000000 --- a/sw/source/ui/vba/vbaparagraphformat.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PARAGRAPHFORMAT_HXX -#define SW_VBA_PARAGRAPHFORMAT_HXX - -#include <ooo/vba/word/XParagraphFormat.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/style/LineSpacing.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XParagraphFormat > SwVbaParagraphFormat_BASE; - -class SwVbaParagraphFormat : public SwVbaParagraphFormat_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::beans::XPropertySet > mxParaProps; - -private: - css::style::LineSpacing getOOoLineSpacing( float _lineSpace, sal_Int16 mode ); - css::style::LineSpacing getOOoLineSpacingFromRule( sal_Int32 _linespacingrule ); - float getMSWordLineSpacing( css::style::LineSpacing& rLineSpacing ); - sal_Int32 getMSWordLineSpacingRule( css::style::LineSpacing& rLineSpacing ); - sal_Int16 getCharHeight() throw (css::uno::RuntimeException); - sal_Int32 getOOoAlignment( sal_Int32 _alignment ); - sal_Int32 getMSWordAlignment( sal_Int32 _alignment ); - -public: - SwVbaParagraphFormat( 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::beans::XPropertySet >& rParaProps ); - virtual ~SwVbaParagraphFormat(); - - // Attributes - virtual ::sal_Int32 SAL_CALL getAlignment() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAlignment( ::sal_Int32 _alignment ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getFirstLineIndent() throw (css::uno::RuntimeException); - virtual void SAL_CALL setFirstLineIndent( float _firstlineindent ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getKeepTogether() throw (css::uno::RuntimeException); - virtual void SAL_CALL setKeepTogether( const css::uno::Any& _keeptogether ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getKeepWithNext() throw (css::uno::RuntimeException); - virtual void SAL_CALL setKeepWithNext( const css::uno::Any& _keepwithnext ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getHyphenation() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHyphenation( const css::uno::Any& _hyphenation ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getLineSpacing() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLineSpacing( float _linespacing ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getLineSpacingRule() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLineSpacingRule( ::sal_Int32 _linespacingrule ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getNoLineNumber() throw (css::uno::RuntimeException); - virtual void SAL_CALL setNoLineNumber( const css::uno::Any& _nolinenumber ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getOutlineLevel() throw (css::uno::RuntimeException); - virtual void SAL_CALL setOutlineLevel( ::sal_Int32 _outlinelevel ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getPageBreakBefore() throw (css::uno::RuntimeException); - virtual void SAL_CALL setPageBreakBefore( const css::uno::Any& _pagebreakbefore ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getSpaceBefore() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSpaceBefore( float _spacebefore ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getSpaceAfter() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSpaceAfter( float _spaceafter ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getLeftIndent() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLeftIndent( float _leftindent ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getRightIndent() throw (css::uno::RuntimeException); - virtual void SAL_CALL setRightIndent( float _rightindent ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getTabStops() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTabStops( const css::uno::Any& _tabstops ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getWidowControl() throw (css::uno::RuntimeException); - virtual void SAL_CALL setWidowControl( const css::uno::Any& _widowcontrol ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_PARAGRAPHFORMAT_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarange.cxx b/sw/source/ui/vba/vbarange.cxx deleted file mode 100644 index f58f7ab89b..0000000000 --- a/sw/source/ui/vba/vbarange.cxx +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbarange.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbarangehelper.hxx" -#include <ooo/vba/word/WdBreakType.hpp> -#include <com/sun/star/style/BreakType.hpp> -#include <com/sun/star/text/ControlCharacter.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#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; - -SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) -{ - uno::Reference< text::XTextRange > xEnd; - initialize( rStart, xEnd ); -} - -SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) -{ - initialize( rStart, rEnd ); -} - -SwVbaRange::SwVbaRange( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd, const uno::Reference< text::XText >& rText, sal_Bool _bMaySpanEndOfDocument ) throw (uno::RuntimeException) : SwVbaRange_BASE( rParent, rContext ),mxTextDocument( rTextDocument ), mxText( rText ), mbMaySpanEndOfDocument( _bMaySpanEndOfDocument ) -{ - initialize( rStart, rEnd ); -} - -SwVbaRange::~SwVbaRange() -{ -} - -void SwVbaRange::initialize( const uno::Reference< text::XTextRange >& rStart, const uno::Reference< text::XTextRange >& rEnd ) throw (uno::RuntimeException) -{ - if( !mxText.is() ) - { - mxText = mxTextDocument->getText(); - } - - 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() ) - mxTextCursor->gotoRange( rEnd, sal_True ); - else - mxTextCursor->gotoEnd( sal_True ); -} - -uno::Reference< text::XTextRange > SAL_CALL -SwVbaRange::getXTextRange() throw (uno::RuntimeException) -{ - uno::Reference< text::XTextRange > xTextRange( mxTextCursor, uno::UNO_QUERY_THROW ); - return xTextRange; -} - -/** -* The complexity in this method is because we need to workaround -* an issue that the last paragraph in a document does not have a trailing CRLF. -* @return -*/ -rtl::OUString SAL_CALL -SwVbaRange::getText() throw ( uno::RuntimeException ) -{ - rtl::OUString aText = mxTextCursor->getString(); - sal_Int32 nLen = aText.getLength(); - - // FIXME: should add a line separator if the range includes the last paragraph - if( nLen == 0 ) - { - if( mxTextCursor->isCollapsed() ) - { - mxTextCursor->goRight( 1, sal_True ); - aText = mxTextCursor->getString(); - mxTextCursor->collapseToStart(); - } - else - { - uno::Reference< text::XTextRange > xStart = mxTextCursor->getStart(); - uno::Reference< text::XTextRange > xEnd = mxTextCursor->getEnd(); - mxTextCursor->collapseToEnd(); - mxTextCursor->goRight( 1, sal_True ); - mxTextCursor->gotoRange( xStart, sal_False ); - mxTextCursor->gotoRange( xEnd, sal_True ); - } - } - - return aText; -} - -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 - 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 -void SAL_CALL SwVbaRange::InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException) -{ - // default type is wdPageBreak; - sal_Int32 nBreakType = word::WdBreakType::wdPageBreak; - if( _breakType.hasValue() ) - _breakType >>= nBreakType; - - style::BreakType eBreakType = style::BreakType_NONE; - switch( nBreakType ) - { - case word::WdBreakType::wdPageBreak: - eBreakType = style::BreakType_PAGE_BEFORE; - break; - case word::WdBreakType::wdColumnBreak: - eBreakType = style::BreakType_COLUMN_AFTER; - break; - case word::WdBreakType::wdLineBreak: - case word::WdBreakType::wdLineBreakClearLeft: - case word::WdBreakType::wdLineBreakClearRight: - case word::WdBreakType::wdSectionBreakContinuous: - case word::WdBreakType::wdSectionBreakEvenPage: - case word::WdBreakType::wdSectionBreakNextPage: - case word::WdBreakType::wdSectionBreakOddPage: - case word::WdBreakType::wdTextWrappingBreak: - DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); - break; - default: - DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() ); - } - - if( eBreakType != style::BreakType_NONE ) - { - if( !mxTextCursor->isCollapsed() ) - { - mxTextCursor->setString( rtl::OUString() ); - mxTextCursor->collapseToStart(); - } - - uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW ); - xProp->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ), uno::makeAny( eBreakType ) ); - } -} - -void SAL_CALL -SwVbaRange::Select() throw ( uno::RuntimeException ) -{ - uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextViewCursor > xTextViewCursor = word::getXTextViewCursor( xModel ); - xTextViewCursor->gotoRange( mxTextCursor->getStart(), sal_False ); - xTextViewCursor->gotoRange( mxTextCursor->getEnd(), sal_True ); -} - -void SAL_CALL -SwVbaRange::InsertParagraph() throw ( uno::RuntimeException ) -{ - mxTextCursor->setString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("") ) ); - InsertParagraphBefore(); -} - -void SAL_CALL -SwVbaRange::InsertParagraphBefore() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xTextRange = mxTextCursor->getStart(); - mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_True ); - mxTextCursor->gotoRange( xTextRange, sal_True ); -} - -void SAL_CALL -SwVbaRange::InsertParagraphAfter() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xTextRange = mxTextCursor->getEnd(); - mxText->insertControlCharacter( xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_True ); -} - -uno::Reference< word::XParagraphFormat > SAL_CALL -SwVbaRange::getParagraphFormat() throw ( uno::RuntimeException ) -{ - uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); - return uno::Reference< word::XParagraphFormat >( new SwVbaParagraphFormat( this, mxContext, mxTextDocument, xParaProps ) ); -} - -void SAL_CALL -SwVbaRange::setParagraphFormat( const uno::Reference< word::XParagraphFormat >& /*rParagraphFormat*/ ) throw ( uno::RuntimeException ) -{ - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); -} - -void SwVbaRange::GetStyleInfo(rtl::OUString& aStyleName, rtl::OUString& aStyleType ) throw ( uno::RuntimeException ) -{ - uno::Reference< beans::XPropertySet > xProp( mxTextCursor, uno::UNO_QUERY_THROW ); - if( ( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharStyleName") ) ) >>= aStyleName ) && aStyleName.getLength() ) - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharacterStyles") ); - } - else if( ( xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ) ) >>= aStyleName ) && aStyleName.getLength() ) - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ); - } - if( aStyleType.getLength() == 0 ) - { - 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 ); - 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::Any& rStyle ) throw ( uno::RuntimeException ) -{ - uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); - SwVbaStyle::setStyle( xParaProps, rStyle ); -} - -uno::Reference< word::XFont > SAL_CALL -SwVbaRange::getFont() throw ( uno::RuntimeException ) -{ - VbaPalette aColors; - 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 ); - return SwVbaStyle::getLanguageID( xParaProps ); -} - -void SAL_CALL SwVbaRange::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); - SwVbaStyle::setLanguageID( xParaProps, _languageid ); -} - -uno::Any SAL_CALL -SwVbaRange::PageSetup( ) throw (uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xParaProps( mxTextCursor, uno::UNO_QUERY_THROW ); - uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); - rtl::OUString aPageStyleName; - xParaProps->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 ); - uno::Reference< beans::XPropertySet > xPageProps( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, xModel, xPageProps ) ) ); -} - -::sal_Int32 SAL_CALL SwVbaRange::getStart() throw (uno::RuntimeException) -{ - uno::Reference< text::XText > xText = mxTextDocument->getText(); - return SwVbaRangeHelper::getPosition( xText, mxTextCursor->getStart() ); -} - -void SAL_CALL SwVbaRange::setStart( ::sal_Int32 _start ) throw (uno::RuntimeException) -{ - uno::Reference< text::XText > xText = mxTextDocument->getText(); - uno::Reference< text::XTextRange > xStart = SwVbaRangeHelper::getRangeByPosition( xText, _start ); - uno::Reference< text::XTextRange > xEnd = mxTextCursor->getEnd(); - - mxTextCursor->gotoRange( xStart, sal_False ); - mxTextCursor->gotoRange( xEnd, sal_True ); -} - -::sal_Int32 SAL_CALL SwVbaRange::getEnd() throw (uno::RuntimeException) -{ - uno::Reference< text::XText > xText = mxTextDocument->getText(); - return SwVbaRangeHelper::getPosition( xText, mxTextCursor->getEnd() ); -} - -void SAL_CALL SwVbaRange::setEnd( ::sal_Int32 _end ) throw (uno::RuntimeException) -{ - uno::Reference< text::XText > xText = mxTextDocument->getText(); - uno::Reference< text::XTextRange > xEnd = SwVbaRangeHelper::getRangeByPosition( xText, _end ); - - mxTextCursor->collapseToStart(); - 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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRange") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaRange::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Range" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarange.hxx b/sw/source/ui/vba/vbarange.hxx deleted file mode 100644 index f29bfeb209..0000000000 --- a/sw/source/ui/vba/vbarange.hxx +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_RANGE_HXX -#define SW_VBA_RANGE_HXX - -#include <ooo/vba/word/XRange.hpp> -#include <ooo/vba/word/XParagraphFormat.hpp> -#include <ooo/vba/word/XFont.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#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; - -class SwVbaRange : public SwVbaRange_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::text::XTextCursor > mxTextCursor; - css::uno::Reference< css::text::XText > mxText; - sal_Bool mbMaySpanEndOfDocument; - -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); - 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, const css::uno::Reference< css::text::XText >& rText, sal_Bool _bMaySpanEndOfDocument = sal_False ) throw (css::uno::RuntimeException); - virtual ~SwVbaRange(); - css::uno::Reference< css::text::XTextDocument > getDocument() const { return mxTextDocument; } - - virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getXTextRange() throw (css::uno::RuntimeException); - css::uno::Reference< css::text::XText > getXText() const { 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::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); - virtual void SAL_CALL InsertParagraph() throw (css::uno::RuntimeException); - virtual void SAL_CALL InsertParagraphBefore() throw (css::uno::RuntimeException); - virtual void SAL_CALL InsertParagraphAfter() throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getLanguageID() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLanguageID( ::sal_Int32 _languageid ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL PageSetup() throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getStart() throw (css::uno::RuntimeException); - 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(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_RANGE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarangehelper.cxx b/sw/source/ui/vba/vbarangehelper.cxx deleted file mode 100644 index 3723d0cb71..0000000000 --- a/sw/source/ui/vba/vbarangehelper.cxx +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "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; - -/** - * get a range in a xText by creating - * a cursor that iterates over the text. If the iterating cursor is - * equal to the desired position, the range equivalent is returned. - * Some special cases are tables that are inside of the text, because the - * position has to be adjusted. - * @param xText a text where a range position is searched - * @param position a position inside o the text - * @return a range for the postion; null is returned if no range can be - * constructed. - */ -uno::Reference< text::XTextRange > SwVbaRangeHelper::getRangeByPosition( const uno::Reference< text::XText >& rText, sal_Int32 _position ) throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xRange; - if( rText.is() ) - { - sal_Int32 nPos = 0; - uno::Reference< text::XTextCursor > xCursor = rText->createTextCursor(); - xCursor->collapseToStart(); - sal_Bool bCanGo = sal_True; - while( !xRange.is() && bCanGo ) - { - if( _position == nPos ) - { - xRange = xCursor->getStart(); - } - else - { - bCanGo = xCursor->goRight( 1, sal_False ); - nPos++; - } - } - } - return xRange; -} - - -void SwVbaRangeHelper::insertString( uno::Reference< text::XTextRange >& rTextRange, uno::Reference< text::XText >& rText, const rtl::OUString& rStr, sal_Bool _bAbsorb ) throw ( uno::RuntimeException ) -{ - sal_Int32 nlastIndex = 0; - sal_Int32 nIndex = 0; - uno::Reference< text::XTextRange > xRange = rTextRange; - - while(( nIndex = rStr.indexOf('\n', nlastIndex)) >= 0 ) - { - xRange = xRange->getEnd(); - if( nlastIndex < ( nIndex - 1 ) ) - { - rText->insertString( xRange, rStr.copy( nlastIndex, ( nIndex - 1 - nlastIndex ) ), _bAbsorb ); - xRange = xRange->getEnd(); - } - - rText->insertControlCharacter( xRange, text::ControlCharacter::PARAGRAPH_BREAK, _bAbsorb ); - nlastIndex = nIndex + 1; - } - - if( nlastIndex < rStr.getLength() ) - { - xRange = xRange->getEnd(); - - rtl::OUString aWatt = rStr.copy( nlastIndex ); - rText->insertString( xRange, aWatt, _bAbsorb ); - } -} - -uno::Reference< text::XTextCursor > SwVbaRangeHelper::initCursor( const uno::Reference< text::XTextRange >& rTextRange, const uno::Reference< text::XText >& rText ) throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextCursor > xTextCursor; - sal_Bool bGotTextCursor = sal_False; - - try - { - xTextCursor = rText->createTextCursorByRange( rTextRange ); - bGotTextCursor = sal_True; - } - catch (uno::Exception& e) - { - DebugHelper::exception(e); - } - - if( !bGotTextCursor || !xTextCursor.is() ) - { - try - { - uno::Reference< text::XText > xText = rTextRange->getText(); - xTextCursor = xText->createTextCursor(); - bGotTextCursor = sal_True; - } - catch( uno::Exception& e ) - { - DebugHelper::exception(e); - } - } - - if( !bGotTextCursor || !xTextCursor.is() ) - { - try - { - xTextCursor = rText->createTextCursor(); - bGotTextCursor = sal_True; - } - catch( uno::Exception& e ) - { - DebugHelper::exception(e); - } - } - return xTextCursor; -} - -sal_Int32 SwVbaRangeHelper::getPosition( const uno::Reference< text::XText >& rText, const uno::Reference< text::XTextRange >& rTextRange ) throw ( uno::RuntimeException ) -{ - sal_Int32 nPosition = -1; - if( rText.is() && rTextRange.is() ) - { - nPosition = 0; - uno::Reference< text::XTextCursor > xCursor = rText->createTextCursor(); - xCursor->collapseToStart(); - uno::Reference< text::XTextRangeCompare > xCompare( rText, uno::UNO_QUERY_THROW ); - // compareValue is 0 if the ranges are equal - sal_Int32 nCompareValue = xCompare->compareRegionStarts( xCursor->getStart(), rTextRange ); - sal_Bool canGo = sal_True; - - while( nCompareValue !=0 && canGo ) - { - canGo = xCursor->goRight( 1, sal_False ); - nCompareValue = xCompare->compareRegionStarts( xCursor->getStart(), rTextRange ); - nPosition++; - } - - // check fails: no correct position found - if( !canGo && nCompareValue != 0 ) - { - nPosition = -1; - } - } - - 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 >(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarangehelper.hxx b/sw/source/ui/vba/vbarangehelper.hxx deleted file mode 100644 index 283a97f538..0000000000 --- a/sw/source/ui/vba/vbarangehelper.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_RANGEHELPER_HXX -#define SW_VBA_RANGEHELPER_HXX - -#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 -{ -public: - static css::uno::Reference< css::text::XTextRange > getRangeByPosition( const css::uno::Reference< css::text::XText >& rText, sal_Int32 _position )throw ( css::uno::RuntimeException ); - 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 */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbareplacement.cxx b/sw/source/ui/vba/vbareplacement.cxx deleted file mode 100644 index fd8d4ecb9f..0000000000 --- a/sw/source/ui/vba/vbareplacement.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbareplacement.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaReplacement::SwVbaReplacement( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< util::XPropertyReplace >& xPropertyReplace ) throw ( uno::RuntimeException ) : - SwVbaReplacement_BASE( rParent, rContext ), mxPropertyReplace( xPropertyReplace ) -{ -} - -SwVbaReplacement::~SwVbaReplacement() -{ -} - -::rtl::OUString SAL_CALL SwVbaReplacement::getText() throw (uno::RuntimeException) -{ - return mxPropertyReplace->getReplaceString(); -} - -void SAL_CALL SwVbaReplacement::setText( const ::rtl::OUString& _text ) throw (uno::RuntimeException) -{ - mxPropertyReplace->setReplaceString( _text ); -} - -void SAL_CALL SwVbaReplacement::ClearFormatting( ) throw (uno::RuntimeException) -{ - uno::Sequence< beans::PropertyValue > aPropValues; - mxPropertyReplace->setReplaceAttributes( aPropValues ); -} - -rtl::OUString& -SwVbaReplacement::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaReplacement") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaReplacement::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Replacement" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbareplacement.hxx b/sw/source/ui/vba/vbareplacement.hxx deleted file mode 100644 index 52778bd92d..0000000000 --- a/sw/source/ui/vba/vbareplacement.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_REPLACEMENT_HXX -#define SW_VBA_REPLACEMENT_HXX - -#include <ooo/vba/word/XReplacement.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/util/XPropertyReplace.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XReplacement > SwVbaReplacement_BASE; - -class SwVbaReplacement : public SwVbaReplacement_BASE -{ -private: - css::uno::Reference< css::util::XPropertyReplace> mxPropertyReplace; - -public: - SwVbaReplacement( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::util::XPropertyReplace >& xPropertyReplace ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaReplacement(); - - // Attributes - 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(); -}; -#endif /* SW_VBA_REPLACEMENT_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarevision.cxx b/sw/source/ui/vba/vbarevision.cxx deleted file mode 100644 index 5c1f0e841b..0000000000 --- a/sw/source/ui/vba/vbarevision.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbarevision.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/document/XRedlinesSupplier.hpp> -#include "wordvbahelper.hxx" -#include <docsh.hxx> -#include <doc.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaRevision::SwVbaRevision( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xRedlineProps ) throw ( uno::RuntimeException ) : SwVbaRevision_BASE( rParent, rContext ), mxModel( xModel ), mxRedlineProps( xRedlineProps ) -{ -} - -SwVbaRevision::~SwVbaRevision() -{ -} - -sal_Int32 SwVbaRevision::GetPosition() throw (css::uno::RuntimeException) -{ - sal_Int32 nPos = -1; - uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xRedlines->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - uno::Reference< beans::XPropertySet > xProps( xRedlines->getByIndex( i ), uno::UNO_QUERY_THROW ); - if( xProps == mxRedlineProps ) - { - nPos = i; - OSL_TRACE(" SwVbaRevision::SwVbaRevision, the redline position is %d, ", nPos ); - break; - } - } - if( nPos == -1 ) - throw uno::RuntimeException(); - - return nPos; -} - -void SAL_CALL -SwVbaRevision::Accept() throw ( css::uno::RuntimeException ) -{ - SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc(); - if( pDoc ) - pDoc->AcceptRedline( GetPosition(), sal_True ); -} - -void SAL_CALL -SwVbaRevision::Reject( ) throw ( css::uno::RuntimeException ) -{ - SwDoc* pDoc = word::getDocShell( mxModel )->GetDoc(); - if( pDoc ) - pDoc->RejectRedline( GetPosition(), sal_True ); -} - -rtl::OUString& -SwVbaRevision::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRevision") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaRevision::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Revision" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarevision.hxx b/sw/source/ui/vba/vbarevision.hxx deleted file mode 100644 index 1ecadcd1f6..0000000000 --- a/sw/source/ui/vba/vbarevision.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_REVISION_HXX -#define SW_VBA_REVISION_HXX - -#include <ooo/vba/word/XRevision.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRevision > SwVbaRevision_BASE; - -class SwVbaRevision : public SwVbaRevision_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::beans::XPropertySet > mxRedlineProps; - -private: - sal_Int32 GetPosition() throw (css::uno::RuntimeException); - -public: - SwVbaRevision( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xRedlineProps ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaRevision(); - - // Methods - virtual void SAL_CALL Accept( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Reject( ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_REVISION_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarevisions.cxx b/sw/source/ui/vba/vbarevisions.cxx deleted file mode 100644 index e9ebc7e3b4..0000000000 --- a/sw/source/ui/vba/vbarevisions.cxx +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbarevisions.hxx" -#include "vbarevision.hxx" -#include <cppuhelper/implbase2.hxx> -#include <com/sun/star/document/XRedlinesSupplier.hpp> -#include <com/sun/star/text/XTextRangeCompare.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef ::cppu::WeakImplHelper1< container::XEnumeration > RevisionEnumeration_BASE; -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > RevisionCollectionHelper_BASE; -typedef std::vector< uno::Reference< beans::XPropertySet > > RevisionMap; - -class RedlinesEnumeration : public RevisionEnumeration_BASE -{ - RevisionMap mRevisionMap; - RevisionMap::iterator mIt; -public: - RedlinesEnumeration( const RevisionMap& sMap ) : mRevisionMap( sMap ), mIt( mRevisionMap.begin() ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( mIt != mRevisionMap.end() ); - } - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - uno::Reference< beans::XPropertySet > xRevision( *mIt++ ); - return uno::makeAny( xRevision ) ; - } -}; - -class RevisionCollectionHelper : public RevisionCollectionHelper_BASE -{ - RevisionMap mRevisionMap; -public: -RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw (uno::RuntimeException); - - // XElementAccess - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return beans::XPropertySet::static_type(0); } - virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return ( !mRevisionMap.empty() ); } - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) { return mRevisionMap.size(); } - virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException ) - { - if ( Index < 0 || Index >= getCount() ) - throw lang::IndexOutOfBoundsException(); - - return uno::makeAny( mRevisionMap[ Index ] ); - - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new RedlinesEnumeration( mRevisionMap ); - } -}; - -RevisionCollectionHelper::RevisionCollectionHelper( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ) throw (uno::RuntimeException) - { - uno::Reference< text::XTextRangeCompare > xTRC( xTextRange->getText(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XRedlinesSupplier > xRedlinesSupp( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xRedlines( xRedlinesSupp->getRedlines(), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xRedlines->getCount(); - for( sal_Int32 index = 0; index < nCount; index++ ) - { - uno::Reference< text::XTextRange > xRedlineRange( xRedlines->getByIndex( index ), uno::UNO_QUERY_THROW ); - if( xTRC->compareRegionStarts( xTextRange, xRedlineRange ) >= 0 && xTRC->compareRegionEnds( xTextRange, xRedlineRange ) <= 0 ) - { - uno::Reference< beans::XPropertySet > xRedlineProps( xRedlineRange, uno::UNO_QUERY_THROW ); - mRevisionMap.push_back( xRedlineProps ); - } - } - } -class RevisionsEnumeration : public EnumerationHelperImpl -{ - uno::Reference< frame::XModel > m_xModel; -public: - RevisionsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ) {} - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - uno::Reference< beans::XPropertySet > xRevision( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XRevision > ( new SwVbaRevision( m_xParent, m_xContext, m_xModel, xRevision ) ) ); - } - -}; - -SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextRange >& xTextRange ): SwVbaRevisions_BASE( xParent, xContext, new RevisionCollectionHelper( xModel, xTextRange ) ), mxModel( xModel ) -{ -} - -SwVbaRevisions::SwVbaRevisions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< container::XIndexAccess >& xIndexAccess ): SwVbaRevisions_BASE( xParent, xContext, xIndexAccess ), mxModel( xModel ) -{ -} - -// XEnumerationAccess -uno::Type -SwVbaRevisions::getElementType() throw (uno::RuntimeException) -{ - return word::XRevision::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaRevisions::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new RevisionsEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel ); -} - -uno::Any -SwVbaRevisions::createCollectionObject( const css::uno::Any& aSource ) -{ - uno::Reference< beans::XPropertySet > xRevision( aSource, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XRevision > ( new SwVbaRevision( this, mxContext, mxModel, xRevision ) ) ); -} - -void SAL_CALL SwVbaRevisions::AcceptAll( ) throw (css::uno::RuntimeException) -{ - // First we need to put all the redline into a vector, because if the redline is accepted, - // it will auto delete in the document. - std::vector< uno::Reference< word::XRevision > > aRevisions; - uno::Reference< container::XEnumeration > xEnumeration = createEnumeration(); - while( xEnumeration->hasMoreElements() ) - { - uno::Reference< word::XRevision > xRevision( xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - aRevisions.push_back( xRevision ); - } - - std::vector< uno::Reference< word::XRevision > >::iterator it = aRevisions.begin(); - for( ; it != aRevisions.end(); ++it ) - { - uno::Reference< word::XRevision > xRevision( *it ); - xRevision->Accept(); - } -} - -void SAL_CALL SwVbaRevisions::RejectAll( ) throw (css::uno::RuntimeException) -{ - throw uno::RuntimeException(); -} - -rtl::OUString& -SwVbaRevisions::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRevisions") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaRevisions::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Revisions") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarevisions.hxx b/sw/source/ui/vba/vbarevisions.hxx deleted file mode 100644 index 142bf8987b..0000000000 --- a/sw/source/ui/vba/vbarevisions.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_PANES_HXX -#define SW_VBA_PANES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XRevisions.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextRange.hpp> - - -typedef CollTestImplHelper< ooo::vba::word::XRevisions > SwVbaRevisions_BASE; - -class SwVbaRevisions : public SwVbaRevisions_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - -public: - SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextRange >& xTextRange ); - - SwVbaRevisions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess ); - virtual ~SwVbaRevisions() {} - - // Methods - virtual void SAL_CALL AcceptAll( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL RejectAll( ) throw (css::uno::RuntimeException); - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaRevisions_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_PANES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarow.cxx b/sw/source/ui/vba/vbarow.cxx deleted file mode 100644 index 7199b99f4b..0000000000 --- a/sw/source/ui/vba/vbarow.cxx +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbarow.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/table/XCellRange.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <ooo/vba/word/WdRowHeightRule.hpp> -#include <ooo/vba/word/WdConstants.hpp> -#include <rtl/ustrbuf.hxx> -#include "wordvbahelper.hxx" -#include "vbatablehelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaRow::SwVbaRow( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext,const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( uno::RuntimeException ) : - SwVbaRow_BASE( rParent, rContext ), mxTextTable( xTextTable ), mnIndex( nIndex ) -{ - mxTableRows = mxTextTable->getRows(); - mxRowProps.set( mxTableRows->getByIndex( mnIndex ), uno::UNO_QUERY_THROW ); -} - -SwVbaRow::~SwVbaRow() -{ -} - -uno::Any SAL_CALL SwVbaRow::getHeight() throw (css::uno::RuntimeException) -{ - if( getHeightRule() == word::WdRowHeightRule::wdRowHeightAuto ) - return uno::makeAny( sal_Int32( word::WdConstants::wdUndefined ) ); - - sal_Int32 nHeight = 0; - mxRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ) ) >>= nHeight; - return uno::makeAny( (float)Millimeter::getInPoints( nHeight ) ); -} - -void SAL_CALL SwVbaRow::setHeight( const uno::Any& _height ) throw (css::uno::RuntimeException) -{ - float height = 0; - _height >>= height; - - sal_Int32 nHeight = Millimeter::getInHundredthsOfOneMillimeter( height ); - mxRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Height") ), uno::makeAny( nHeight ) ); -} - -::sal_Int32 SAL_CALL SwVbaRow::getHeightRule() throw (css::uno::RuntimeException) -{ - sal_Bool isAutoHeight = sal_False; - mxRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoHeight") ) ) >>= isAutoHeight; - return isAutoHeight ? word::WdRowHeightRule::wdRowHeightAuto : word::WdRowHeightRule::wdRowHeightExactly; -} - -void SAL_CALL SwVbaRow::setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException) -{ - sal_Bool isAutoHeight = ( _heightrule == word::WdRowHeightRule::wdRowHeightAuto ); - mxRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsAutoHeight") ), uno::makeAny( isAutoHeight ) ); -} - -void SAL_CALL -SwVbaRow::Select( ) throw ( uno::RuntimeException ) -{ - SelectRow( getCurrentWordDoc(mxContext), mxTextTable, mnIndex, mnIndex ); -} - -void SwVbaRow::SelectRow( const uno::Reference< frame::XModel >& xModel, const uno::Reference< text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow ) throw ( uno::RuntimeException ) -{ - rtl::OUStringBuffer aRangeName; - aRangeName.appendAscii("A").append(sal_Int32( nStartRow + 1 ) ); - SwVbaTableHelper aTableHelper( xTextTable ); - sal_Int32 nColCount = aTableHelper.getTabColumnsCount( nEndRow ); - // FIXME: the column count > 26 - //sal_Char cCol = 'A' + nColCount - 1; - rtl::OUString sCol = aTableHelper.getColumnStr( nColCount - 1); - aRangeName.appendAscii(":").append( sCol ).append( sal_Int32( nEndRow + 1 ) ); - - uno::Reference< table::XCellRange > xCellRange( xTextTable, uno::UNO_QUERY_THROW ); - rtl::OUString sSelRange = aRangeName.makeStringAndClear(); - uno::Reference< table::XCellRange > xSelRange = xCellRange->getCellRangeByName( sSelRange ); - - uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW ); - xSelection->select( uno::makeAny( xSelRange ) ); -} - -void SAL_CALL SwVbaRow::SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException) -{ - setHeightRule( heightrule ); - setHeight( uno::makeAny( height ) ); -} - -rtl::OUString& -SwVbaRow::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRow") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaRow::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Row" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarow.hxx b/sw/source/ui/vba/vbarow.hxx deleted file mode 100644 index e4cf51f4e9..0000000000 --- a/sw/source/ui/vba/vbarow.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_ROW_HXX -#define SW_VBA_ROW_HXX - -#include <ooo/vba/word/XRow.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/table/XTableRows.hpp> -#include <com/sun/star/text/XTextTable.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XRow > SwVbaRow_BASE; - -class SwVbaRow : public SwVbaRow_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - css::uno::Reference< css::table::XTableRows > mxTableRows; - css::uno::Reference< css::beans::XPropertySet > mxRowProps; - sal_Int32 mnIndex; - -public: - SwVbaRow( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nIndex ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaRow(); - - // Attributes - virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeight( const css::uno::Any& _height ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getHeightRule() throw (css::uno::RuntimeException); - virtual void SAL_CALL setHeightRule( ::sal_Int32 _heightrule ) throw (css::uno::RuntimeException); - - // Methods - virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL SetHeight( float height, sal_Int32 heightrule ) throw (css::uno::RuntimeException); - - static void SelectRow( const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::text::XTextTable >& xTextTable, sal_Int32 nStartRow, sal_Int32 nEndRow ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_ROW_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarows.cxx b/sw/source/ui/vba/vbarows.cxx deleted file mode 100644 index 7b1f939251..0000000000 --- a/sw/source/ui/vba/vbarows.cxx +++ /dev/null @@ -1,368 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbarows.hxx" -#include "vbarow.hxx" -#include <com/sun/star/text/HoriOrientation.hpp> -#include <com/sun/star/table/XCellRange.hpp> -#include <ooo/vba/word/WdRowAlignment.hpp> -#include <ooo/vba/word/WdConstants.hpp> -#include <ooo/vba/word/WdRulerStyle.hpp> -#include "wordvbahelper.hxx" -#include "vbacolumns.hxx" -#include "vbatablehelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -class RowsEnumWrapper : public EnumerationHelper_BASE -{ - uno::WeakReference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< text::XTextTable > mxTextTable; - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 nIndex; - -public: - RowsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< text::XTextTable >& xTextTable ) : mxParent( xParent ), mxContext( xContext ), mxTextTable( xTextTable ), nIndex( 0 ) - { - mxIndexAccess.set( mxTextTable->getRows(), uno::UNO_QUERY ); - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if( nIndex < mxIndexAccess->getCount() ) - { - return uno::makeAny( uno::Reference< word::XRow > ( new SwVbaRow( mxParent, mxContext, mxTextTable, nIndex++ ) ) ); - } - throw container::NoSuchElementException(); - } -}; - -SwVbaRows::SwVbaRows( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableRows >& xTableRows ) throw (uno::RuntimeException) : SwVbaRows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableRows, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableRows( xTableRows ) -{ - mnStartRowIndex = 0; - mnEndRowIndex = m_xIndexAccess->getCount() - 1; -} - -SwVbaRows::SwVbaRows( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextTable >& xTextTable, const uno::Reference< table::XTableRows >& xTableRows, sal_Int32 nStarIndex, sal_Int32 nEndIndex ) throw (uno::RuntimeException) : SwVbaRows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xTableRows, uno::UNO_QUERY_THROW ) ), mxTextTable( xTextTable ), mxTableRows( xTableRows ), mnStartRowIndex( nStarIndex ), mnEndRowIndex( nEndIndex ) -{ - if( mnEndRowIndex < mnStartRowIndex ) - throw uno::RuntimeException(); -} - -/** - * get the alignment of the rows: SO format com.sun.star.text.HoriOrientation - * is mapped to WdRowAlignment in Word - * @return the alignment - */ -::sal_Int32 SAL_CALL SwVbaRows::getAlignment() throw (uno::RuntimeException) -{ - sal_Int16 nAlignment = text::HoriOrientation::LEFT; - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") ) ) >>= nAlignment; - sal_Int32 nRet = 0; - switch( nAlignment ) - { - case text::HoriOrientation::CENTER: - { - nRet = word::WdRowAlignment::wdAlignRowCenter; - break; - } - case text::HoriOrientation::RIGHT: - { - nRet = word::WdRowAlignment::wdAlignRowRight; - break; - } - default: - { - nRet = word::WdRowAlignment::wdAlignRowLeft; - } - } - return nRet; -} - -void SAL_CALL SwVbaRows::setAlignment( ::sal_Int32 _alignment ) throw (uno::RuntimeException) -{ - sal_Int16 nAlignment = text::HoriOrientation::LEFT; - switch( _alignment ) - { - case word::WdRowAlignment::wdAlignRowCenter: - { - nAlignment = text::HoriOrientation::CENTER; - break; - } - case word::WdRowAlignment::wdAlignRowRight: - { - nAlignment = text::HoriOrientation::RIGHT; - break; - } - default: - { - nAlignment = text::HoriOrientation::LEFT; - } - } - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HoriOrient") ), uno::makeAny( nAlignment ) ); -} - -uno::Any SAL_CALL SwVbaRows::getAllowBreakAcrossPages() throw (uno::RuntimeException) -{ - sal_Bool bAllowBreak = sal_False; - uno::Reference< container::XIndexAccess > xRowsAccess( mxTableRows, uno::UNO_QUERY_THROW ); - for( sal_Int32 index = mnStartRowIndex; index <= mnEndRowIndex; ++index ) - { - uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex( index ), uno::UNO_QUERY_THROW ); - sal_Bool bSplit = sal_False; - xRowProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsSplitAllowed") ) ) >>= bSplit; - if( index == 0 ) - { - bAllowBreak = bSplit; - } - if( bSplit != bAllowBreak ) - { - sal_Int32 nRet = word::WdConstants::wdUndefined; - return uno::makeAny( nRet ); - } - } - return uno::makeAny( bAllowBreak ); -} - -void SAL_CALL SwVbaRows::setAllowBreakAcrossPages( const uno::Any& _allowbreakacrosspages ) throw (uno::RuntimeException) -{ - sal_Bool bAllowBreak = sal_False; - _allowbreakacrosspages >>= bAllowBreak; - uno::Reference< container::XIndexAccess > xRowsAccess( mxTableRows, uno::UNO_QUERY_THROW ); - for( sal_Int32 index = mnStartRowIndex; index <= mnEndRowIndex; ++index ) - { - uno::Reference< beans::XPropertySet > xRowProps( xRowsAccess->getByIndex( index ), uno::UNO_QUERY_THROW ); - xRowProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsSplitAllowed") ), uno::makeAny( bAllowBreak ) ); - } -} - -float SAL_CALL SwVbaRows::getSpaceBetweenColumns() throw (uno::RuntimeException) -{ - // just get the first spacing of the first cell - uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW ); - uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( 0, mnStartRowIndex ), uno::UNO_QUERY_THROW ); - sal_Int32 nLeftBorderDistance = 0; - sal_Int32 nRightBorderDistance = 0; - xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftBorderDistance") ) ) >>= nLeftBorderDistance; - xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightBorderDistance") ) ) >>= nRightBorderDistance; - return static_cast< float >( Millimeter::getInPoints( nLeftBorderDistance + nRightBorderDistance ) ); -} - -void SAL_CALL SwVbaRows::setSpaceBetweenColumns( float _spacebetweencolumns ) throw (uno::RuntimeException) -{ - sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _spacebetweencolumns ) / 2; - uno::Reference< container::XIndexAccess > xColumnAccess( mxTextTable->getColumns(), uno::UNO_QUERY_THROW ); - uno::Reference< table::XCellRange > xCellRange( mxTextTable, uno::UNO_QUERY_THROW ); - SwVbaTableHelper aTableHelper( mxTextTable ); - for( sal_Int32 row = mnStartRowIndex; row <= mnEndRowIndex; ++row ) - { - sal_Int32 nColumns = aTableHelper.getTabColumnsCount( row ); - for( sal_Int32 column = 0; column < nColumns; ++column ) - { - uno::Reference< beans::XPropertySet > xCellProps( xCellRange->getCellByPosition( column, row ), uno::UNO_QUERY_THROW ); - xCellProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftBorderDistance") ), uno::makeAny( nSpace ) ); - xCellProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightBorderDistance") ), uno::makeAny( nSpace ) ); - } - } -} - -void SAL_CALL SwVbaRows::Delete( ) throw (uno::RuntimeException) -{ - mxTableRows->removeByIndex( mnStartRowIndex, getCount() ); -} - -void SAL_CALL SwVbaRows::SetLeftIndent( float LeftIndent, ::sal_Int32 RulerStyle ) throw (uno::RuntimeException) -{ - uno::Reference< word::XColumns > xColumns( new SwVbaColumns( getParent(), mxContext, mxTextTable, mxTextTable->getColumns() ) ); - sal_Int32 nIndent = (sal_Int32)( LeftIndent ); - switch( RulerStyle ) - { - case word::WdRulerStyle::wdAdjustFirstColumn: - { - setIndentWithAdjustFirstColumn( xColumns, nIndent ); - break; - } - case word::WdRulerStyle::wdAdjustNone: - { - setIndentWithAdjustNone( nIndent ); - break; - } - case word::WdRulerStyle::wdAdjustProportional: - { - setIndentWithAdjustProportional( xColumns, nIndent ); - break; - } - case word::WdRulerStyle::wdAdjustSameWidth: - { - setIndentWithAdjustSameWidth( xColumns, nIndent ); - break; - } - default: - { - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - } - } -} - -void SwVbaRows::setIndentWithAdjustNone( sal_Int32 indent ) throw (uno::RuntimeException) -{ - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - sal_Int32 nMargin = 0; - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ) ) >>= nMargin; - nMargin += indent; - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ), uno::makeAny( nMargin ) ); -} - - void SwVbaRows::setIndentWithAdjustFirstColumn( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException) - { - sal_Int32 nIndex = 1; - uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW ); - uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( nIndex ), uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nWidth = xColumn->getWidth(); - nWidth -= indent; - xColumn->setWidth( nWidth ); - setIndentWithAdjustNone( indent ); - } - - void SwVbaRows::setIndentWithAdjustProportional( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException) - { - // calculate the new width and get the proportion between old and new - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - sal_Int32 nWidth = 0; - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth; - sal_Int32 nNewWidth = nWidth - indent; - double propFactor = (double)nNewWidth/(double)nWidth; - - // get all columns, calculate and set the new width of the columns - uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW ); - sal_Int32 nColCount = xCol->getCount(); - for( sal_Int32 i = 0; i < nColCount; i++ ) - { - uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( i ), uno::Any() ), uno::UNO_QUERY_THROW ); - sal_Int32 nColWidth = xColumn->getWidth(); - sal_Int32 nNewColWidth = ( sal_Int32 )( propFactor * nColWidth ); - xColumn->setWidth( nNewColWidth ); - } - - // set the width and position of the table - setIndentWithAdjustNone( indent ); - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( nNewWidth ) ); - } - - void SwVbaRows::setIndentWithAdjustSameWidth( const uno::Reference< word::XColumns >& xColumns, sal_Int32 indent ) throw (uno::RuntimeException) - { - // calculate the new width and get the width of all columns - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - sal_Int32 nWidth = 0; - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth; - sal_Int32 nNewWidth = nWidth - indent; - - // get all columns, calculate and set the new width of the columns - uno::Reference< XCollection > xCol( xColumns, uno::UNO_QUERY_THROW ); - sal_Int32 nColCount = xCol->getCount(); - sal_Int32 nNewColWidth = (sal_Int32)( double( nNewWidth )/nColCount ); - for( sal_Int32 i = 0; i < nColCount; i++ ) - { - uno::Reference< word::XColumn > xColumn( xCol->Item( uno::makeAny( i ), uno::Any() ), uno::UNO_QUERY_THROW ); - xColumn->setWidth( nNewColWidth ); - } - - // set the width and position of the table - setIndentWithAdjustNone( indent ); - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( nNewWidth ) ); - } - -void SAL_CALL SwVbaRows::Select( ) throw (uno::RuntimeException) -{ - SwVbaRow::SelectRow( getCurrentWordDoc(mxContext), mxTextTable, mnStartRowIndex, mnEndRowIndex ); -} - -::sal_Int32 SAL_CALL SwVbaRows::getCount() throw (uno::RuntimeException) -{ - return ( mnEndRowIndex - mnStartRowIndex + 1 ); -} - -uno::Any SAL_CALL SwVbaRows::Item( const uno::Any& Index1, const uno::Any& /*not processed in this base class*/ ) throw (uno::RuntimeException) -{ - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) == sal_True ) - { - if( nIndex <= 0 || nIndex > getCount() ) - { - throw lang::IndexOutOfBoundsException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); - } - return uno::makeAny( uno::Reference< word::XRow >( new SwVbaRow( this, mxContext, mxTextTable, nIndex - 1 ) ) ); - } - throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Index out of bounds") ), uno::Reference< uno::XInterface >() ); -} - -// XEnumerationAccess -uno::Type -SwVbaRows::getElementType() throw (uno::RuntimeException) -{ - return word::XRow::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaRows::createEnumeration() throw (uno::RuntimeException) -{ - return new RowsEnumWrapper( this, mxContext, mxTextTable ); -} - -uno::Any -SwVbaRows::createCollectionObject( const uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaRows::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaRows") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaRows::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Rows") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbarows.hxx b/sw/source/ui/vba/vbarows.hxx deleted file mode 100644 index eb310dc0e1..0000000000 --- a/sw/source/ui/vba/vbarows.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_ROWS_HXX -#define SW_VBA_ROWS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XRows.hpp> -#include <ooo/vba/word/XColumns.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/table/XTableRows.hpp> -#include <com/sun/star/text/XTextTable.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XRows > SwVbaRows_BASE; - -class SwVbaRows : public SwVbaRows_BASE -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - css::uno::Reference< css::table::XTableRows > mxTableRows; - sal_Int32 mnStartRowIndex; - sal_Int32 mnEndRowIndex; - -private: - void setIndentWithAdjustNone( sal_Int32 indent ) throw (css::uno::RuntimeException); - void setIndentWithAdjustFirstColumn( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException); - void setIndentWithAdjustProportional( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException); - void setIndentWithAdjustSameWidth( const css::uno::Reference< ooo::vba::word::XColumns >& xColumns, sal_Int32 indent ) throw (css::uno::RuntimeException); - -public: - SwVbaRows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, const css::uno::Reference< css::table::XTableRows >& xTableRows ) throw ( css::uno::RuntimeException ); - SwVbaRows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextTable >& xTextTable, const css::uno::Reference< css::table::XTableRows >& xTableRows, sal_Int32 nStarIndex, sal_Int32 nEndIndex ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaRows() {} - - // Attributes - virtual ::sal_Int32 SAL_CALL getAlignment() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAlignment( ::sal_Int32 _alignment ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getAllowBreakAcrossPages() throw (css::uno::RuntimeException); - virtual void SAL_CALL setAllowBreakAcrossPages( const css::uno::Any& _allowbreakacrosspages ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getSpaceBetweenColumns() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSpaceBetweenColumns( float _spacebetweencolumns ) throw (css::uno::RuntimeException); - - // Methods - virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL SetLeftIndent( float LeftIndent, ::sal_Int32 RulerStyle ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Select( ) throw (css::uno::RuntimeException); - - //XCollection - virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& /*not processed in this base class*/ ) throw ( css::uno::RuntimeException ); - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaRows_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_ROWS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasection.cxx b/sw/source/ui/vba/vbasection.cxx deleted file mode 100644 index 70d9c8df78..0000000000 --- a/sw/source/ui/vba/vbasection.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbasection.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbapagesetup.hxx" -#include "vbaheadersfooters.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaSection::SwVbaSection( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& xModel, const uno::Reference< beans::XPropertySet >& xProps ) throw ( uno::RuntimeException ) : - SwVbaSection_BASE( rParent, rContext ), mxModel( xModel ), mxPageProps( xProps ) -{ -} - -SwVbaSection::~SwVbaSection() -{ -} - -::sal_Bool SAL_CALL SwVbaSection::getProtectedForForms() throw (uno::RuntimeException) -{ - return sal_False; -} - -void SAL_CALL SwVbaSection::setProtectedForForms( ::sal_Bool /*_protectedforforms*/ ) throw (uno::RuntimeException) -{ -} - -uno::Any SAL_CALL SwVbaSection::Headers( const uno::Any& index ) throw (uno::RuntimeException) -{ - 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( const uno::Any& index ) throw (uno::RuntimeException) -{ - 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 -SwVbaSection::PageSetup( ) throw (uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< word::XPageSetup >( new SwVbaPageSetup( this, mxContext, mxModel, mxPageProps ) ) ); -} - -rtl::OUString& -SwVbaSection::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSection") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaSection::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Section" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasection.hxx b/sw/source/ui/vba/vbasection.hxx deleted file mode 100644 index 89819155c8..0000000000 --- a/sw/source/ui/vba/vbasection.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_SECTION_HXX -#define SW_VBA_SECTION_HXX - -#include <ooo/vba/word/XSection.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XSection > SwVbaSection_BASE; - -class SwVbaSection : public SwVbaSection_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::beans::XPropertySet > mxPageProps; - -public: - SwVbaSection( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::frame::XModel >& xModel, const css::uno::Reference< css::beans::XPropertySet >& xProps ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaSection(); - - // Attributes - virtual ::sal_Bool SAL_CALL getProtectedForForms() throw (css::uno::RuntimeException); - virtual void SAL_CALL setProtectedForForms( ::sal_Bool _protectedforforms ) throw (css::uno::RuntimeException); - - // Methods - 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 - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_SECTION_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasections.cxx b/sw/source/ui/vba/vbasections.cxx deleted file mode 100644 index 60a2edd1d5..0000000000 --- a/sw/source/ui/vba/vbasections.cxx +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbasections.hxx" -#include "vbasection.hxx" -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/style/XStyle.hpp> -#include <docsh.hxx> -#include <doc.hxx> -#include "wordvbahelper.hxx" - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef ::cppu::WeakImplHelper1< container::XEnumeration > SectionEnumeration_BASE; -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > SectionCollectionHelper_Base; -typedef std::vector< uno::Reference< beans::XPropertySet > > XSectionVec; - -class SectionEnumeration : public SectionEnumeration_BASE -{ - XSectionVec mxSections; - XSectionVec::iterator mIt; - -public: - SectionEnumeration( const XSectionVec& rVec ) : mxSections( rVec ), mIt( mxSections.begin() ) {} - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( mIt != mxSections.end() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( hasMoreElements() ) - return uno::makeAny( *mIt++ ); - throw container::NoSuchElementException(); - } -}; - -// here I regard pagestyle as section -class SectionCollectionHelper : public SectionCollectionHelper_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxModel; - XSectionVec mxSections; - -public: - SectionCollectionHelper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : mxParent( xParent ), mxContext( xContext ), mxModel( xModel ) - { - uno::Reference< style::XStyleFamiliesSupplier > xSytleFamSupp( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XNameAccess > xSytleFamNames( xSytleFamSupp->getStyleFamilies(), uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xPageStyles( xSytleFamNames->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles") ) ), uno::UNO_QUERY_THROW ); - sal_Int32 nCount = xPageStyles->getCount(); - for( sal_Int32 index = 0; index < nCount; ++index ) - { - uno::Reference< style::XStyle > xStyle( xPageStyles->getByIndex( index ), uno::UNO_QUERY_THROW ); - // only the pagestyles in using are considered - if( xStyle->isInUse( ) ) - { - uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW ); - mxSections.push_back( xPageProps ); - } - } - } - - 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 - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return mxSections.size(); - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 || Index >= getCount() ) - throw css::lang::IndexOutOfBoundsException(); - - uno::Reference< beans::XPropertySet > xPageProps( mxSections[ Index ], uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XSection >( new SwVbaSection( mxParent, mxContext, mxModel, xPageProps ) ) ); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XSection::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new SectionEnumeration( mxSections ); - } -}; - -class SectionsEnumWrapper : public EnumerationHelperImpl -{ - uno::Reference< frame::XModel > mxModel; -public: - SectionsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel ){} - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - uno::Reference< beans::XPropertySet > xPageProps( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XSection > ( new SwVbaSection( m_xParent, m_xContext, mxModel, xPageProps ) ) ); - } -}; - -SwVbaSections::SwVbaSections( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ): SwVbaSections_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new SectionCollectionHelper( xParent, xContext, xModel ) ) ), mxModel( xModel ) -{ -} - -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) -{ - if( m_xIndexAccess->getCount() ) - { - // check if the first section is our want - uno::Reference< word::XSection > xSection( m_xIndexAccess->getByIndex( 0 ), uno::UNO_QUERY_THROW ); - return xSection->PageSetup(); - } - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("There is no section") ), uno::Reference< uno::XInterface >() ); -} - -// XEnumerationAccess -uno::Type SAL_CALL -SwVbaSections::getElementType() throw (uno::RuntimeException) -{ - return word::XSection::static_type(0); -} - -uno::Reference< container::XEnumeration > SAL_CALL -SwVbaSections::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new SectionsEnumWrapper( this, mxContext, xEnumAccess->createEnumeration(), mxModel ); -} - -uno::Any -SwVbaSections::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaSections::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSections") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaSections::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Sections") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasections.hxx b/sw/source/ui/vba/vbasections.hxx deleted file mode 100644 index 051b2dc912..0000000000 --- a/sw/source/ui/vba/vbasections.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_SECTIONS_HXX -#define SW_VBA_SECTIONS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#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; - -class SwVbaSections : public SwVbaSections_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - -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 - 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); - - virtual css::uno::Any SAL_CALL PageSetup( ) throw (css::uno::RuntimeException); - - // SwVbaSections_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_SECTIONS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx deleted file mode 100644 index 3b115ad4c7..0000000000 --- a/sw/source/ui/vba/vbaselection.cxx +++ /dev/null @@ -1,1197 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaselection.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include "vbarange.hxx" -#include "vbafind.hxx" -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <com/sun/star/text/XTextTableCursor.hpp> -#include <com/sun/star/text/ControlCharacter.hpp> -#include <com/sun/star/table/XCell.hpp> -#include <ooo/vba/word/WdUnits.hpp> -#include <ooo/vba/word/WdMovementType.hpp> -#include <ooo/vba/word/WdGoToItem.hpp> -#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" -#include "vbaheaderfooterhelper.hxx" -#include <vbahelper/vbashaperange.hxx> -#include <com/sun/star/drawing/XDrawPageSupplier.hpp> -#include <com/sun/star/drawing/XDrawPage.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; - -SwVbaSelection::SwVbaSelection( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< frame::XModel >& rModel ) throw ( uno::RuntimeException ) : SwVbaSelection_BASE( rParent, rContext ), mxModel( rModel ) -{ - mxTextViewCursor = word::getXTextViewCursor( mxModel ); -} - -SwVbaSelection::~SwVbaSelection() -{ -} - -uno::Reference< text::XTextRange > SwVbaSelection::GetSelectedRange() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xTextRange; - uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel->getCurrentSelection(), uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextRanges") ) ) ) - { - uno::Reference< container::XIndexAccess > xTextRanges( xServiceInfo, uno::UNO_QUERY_THROW ); - if( xTextRanges->getCount() > 0 ) - { - // if there are multipul selection, just return the last selected Range. - xTextRange.set( xTextRanges->getByIndex( xTextRanges->getCount()-1 ), uno::UNO_QUERY_THROW ); - } - } - else - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } - return xTextRange; -} - -uno::Reference< word::XRange > SAL_CALL -SwVbaSelection::getRange() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xTextRange = GetSelectedRange(); - uno::Reference< text::XTextDocument > xDocument( mxModel, uno::UNO_QUERY_THROW ); - return uno::Reference< word::XRange >( new SwVbaRange( this, mxContext, xDocument, xTextRange->getStart(), xTextRange->getEnd(), mxTextViewCursor->getText() ) ); -} - -rtl::OUString SAL_CALL -SwVbaSelection::getText() throw ( uno::RuntimeException ) -{ - return getRange()->getText(); -} - -void SAL_CALL -SwVbaSelection::setText( const rtl::OUString& rText ) throw ( uno::RuntimeException ) -{ - getRange()->setText( rText ); -} - -void SAL_CALL -SwVbaSelection::TypeText( const rtl::OUString& rText ) throw ( uno::RuntimeException ) -{ - // FIXME: handle the property Options.ReplaceSelection, the default value is sal_True - setText( rText ); -} - -void SAL_CALL -SwVbaSelection::HomeKey( const uno::Any& _unit, const uno::Any& _extend ) throw ( uno::RuntimeException ) -{ - sal_Int32 nUnit = word::WdUnits::wdLine; - 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 - 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 - uno::Reference< view::XLineCursor > xLineCursor( mxTextViewCursor, uno::UNO_QUERY_THROW ); - xLineCursor->gotoStartOfLine( bExtend ); - break; - } - default: - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - break; - } - } -} - -void SAL_CALL -SwVbaSelection::EndKey( const uno::Any& _unit, const uno::Any& _extend ) throw ( uno::RuntimeException ) -{ - sal_Int32 nUnit = word::WdUnits::wdLine; - 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 - 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 - uno::Reference< view::XLineCursor > xLineCursor( mxTextViewCursor, uno::UNO_QUERY_THROW ); - xLineCursor->gotoEndOfLine( bExtend ); - break; - } - default: - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - break; - } - } -} - -void SAL_CALL -SwVbaSelection::Delete( const uno::Any& _unit, const uno::Any& _count ) throw ( uno::RuntimeException ) -{ - 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::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; - uno::Reference< table::XCell > xCell; - xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextTable; - xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cell") ) ) >>= xCell; - if( !xTextTable.is() || !xCell.is() ) - { - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - return; - } - uno::Reference< beans::XPropertySet > xCellProps( xCell, uno::UNO_QUERY_THROW ); - rtl::OUString aCellName; - xCellProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CellName") ) ) >>= aCellName; - uno::Reference< text::XTextTableCursor > xTextTableCursor = xTextTable->createCursorByCellName( aCellName ); - // move the table cursor - switch( eDirection ) - { - case word::MOVE_LEFT: - { - xTextTableCursor->goLeft( nCount, sal_False ); - break; - } - case word::MOVE_RIGHT: - { - xTextTableCursor->goRight( nCount, sal_False ); - break; - } - case word::MOVE_UP: - { - xTextTableCursor->goUp( nCount, sal_False ); - break; - } - case word::MOVE_DOWN: - { - xTextTableCursor->goDown( nCount, sal_False ); - break; - } - default: - { - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - return; - } - } - // move the view cursor - xCell = xTextTable->getCellByName( xTextTableCursor->getRangeName() ); - mxTextViewCursor->gotoRange( uno::Reference< text::XTextRange >( xCell, uno::UNO_QUERY_THROW ), sal_False ); -} - -void SAL_CALL -SwVbaSelection::MoveRight( 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 ) - { - MoveLeft( _unit, uno::makeAny( -nCount ), _extend ); - return; - } - - 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 nCount = 1; - if( _count.hasValue() ) - _count >>= nCount; - - if( nCount == 0 ) - return; - - if( nCount < 0 ) - { - MoveRight( _unit, uno::makeAny( -nCount ), _extend ); - return; - } - - 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 nCount = 1; - - if( _count.hasValue() ) - _count >>= nCount; - - if( nCount == 0 ) - return; - - if( nCount < 0 ) - { - MoveUp( _unit, uno::makeAny( -nCount ), _extend ); - return; - } - - 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 ) - { - MoveDown( _unit, uno::makeAny( -nCount ), _extend ); - return; - } - - Move( _unit, _count, _extend, word::MOVE_UP ); -} - -void SAL_CALL -SwVbaSelection::TypeParagraph() throw ( uno::RuntimeException ) -{ - // #FIXME: if the selection is an entire paragraph, it's replaced - // by the new paragraph - sal_Bool isCollapsed = mxTextViewCursor->isCollapsed(); - InsertParagraph(); - if( isCollapsed ) - mxTextViewCursor->collapseToStart(); -} - -void SAL_CALL -SwVbaSelection::InsertParagraph() throw ( uno::RuntimeException ) -{ - // #FIME: the selection should include the new paragraph. - getRange()->InsertParagraph(); -} - -void SAL_CALL -SwVbaSelection::InsertParagraphBefore() throw ( uno::RuntimeException ) -{ - getRange()->InsertParagraphBefore(); -} - -void SAL_CALL -SwVbaSelection::InsertParagraphAfter() throw ( uno::RuntimeException ) -{ - getRange()->InsertParagraphAfter(); -} - -uno::Reference< word::XParagraphFormat > SAL_CALL -SwVbaSelection::getParagraphFormat() throw ( uno::RuntimeException ) -{ - return getRange()->getParagraphFormat(); -} - -void SAL_CALL -SwVbaSelection::setParagraphFormat( const uno::Reference< word::XParagraphFormat >& rParagraphFormat ) throw ( uno::RuntimeException ) -{ - return getRange()->setParagraphFormat( rParagraphFormat ); -} - -uno::Reference< word::XFind > SAL_CALL -SwVbaSelection::getFind() throw ( uno::RuntimeException ) -{ - uno::Reference< text::XTextRange > xTextRange = GetSelectedRange(); - return uno::Reference< word::XFind >( new SwVbaFind( this, mxContext, mxModel, xTextRange ) ); -} - -uno::Any SAL_CALL -SwVbaSelection::getStyle() throw ( uno::RuntimeException ) -{ - return getRange()->getStyle(); -} - -void SAL_CALL -SwVbaSelection::setStyle( const uno::Any& rStyle ) throw ( uno::RuntimeException ) -{ - uno::Reference< beans::XPropertySet > xParaProps( mxTextViewCursor, uno::UNO_QUERY_THROW ); - return SwVbaStyle::setStyle( xParaProps, rStyle ); -} - -uno::Reference< word::XFont > SAL_CALL -SwVbaSelection::getFont() throw ( uno::RuntimeException ) -{ - return getRange()->getFont(); -} - -void SAL_CALL -SwVbaSelection::TypeBackspace() throw ( uno::RuntimeException ) -{ - rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SwBackspace")); - dispatchRequests( mxModel,url ); -} - -uno::Reference< word::XRange > SAL_CALL SwVbaSelection::GoTo( const uno::Any& _what, const uno::Any& _which, const uno::Any& _count, const uno::Any& _name ) throw (uno::RuntimeException) -{ - sal_Int32 nWhat = 0; - if( ( _what >>= nWhat ) != sal_True ) - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - switch( nWhat ) - { - case word::WdGoToItem::wdGoToBookmark: - { - rtl::OUString sName; - uno::Reference< word::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW ); - uno::Reference< word::XBookmark > xBookmark( xApplication->getActiveDocument()->Bookmarks(_name), uno::UNO_QUERY_THROW ); - xBookmark->Select(); - break; - } - case word::WdGoToItem::wdGoToPage: - { - uno::Reference< text::XPageCursor > xPageCursor( mxTextViewCursor, uno::UNO_QUERY_THROW ); - sal_Int32 nCurrPage = xPageCursor->getPage(); - sal_Int32 nLastPage = word::getPageCount( mxModel ); - 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::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: - { - 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 >() ); - } - return getRange(); -} - -::sal_Int32 SAL_CALL SwVbaSelection::getLanguageID() throw (uno::RuntimeException) -{ - return getRange()->getLanguageID(); -} - -void SAL_CALL SwVbaSelection::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException) -{ - getRange()->setLanguageID( _languageid ); -} - -uno::Any SAL_CALL SwVbaSelection::Information( sal_Int32 _type ) throw (uno::RuntimeException) -{ - uno::Any result; - switch( _type ) - { - case word::WdInformation::wdActiveEndPageNumber: - { - result = uno::makeAny( SwVbaInformationHelper::handleWdActiveEndPageNumber( mxTextViewCursor ) ); - break; - } - case word::WdInformation::wdNumberOfPagesInDocument: - { - result = uno::makeAny( SwVbaInformationHelper::handleWdNumberOfPagesInDocument( mxModel ) ); - break; - } - case word::WdInformation::wdVerticalPositionRelativeToPage: - { - 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.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "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 >() ); - } - return result; -} - -void SAL_CALL SwVbaSelection::InsertBreak( const uno::Any& _breakType ) throw (uno::RuntimeException) -{ - getRange()->InsertBreak( _breakType ); -} - -uno::Any SAL_CALL -SwVbaSelection::Tables( 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 table - if ( !aIndex.hasValue() ) // currently we can't support multiple tables in a selection - throw uno::RuntimeException(); - - sal_Int32 nIndex = 0; - aIndex >>= nIndex; - - uno::Any aRet; - - 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 ) - { - SwFrmFmt* pFmt = pTTCursor->GetFrmFmt(); - rtl::OUString sTableName; - if ( pFmt ) - { - uno::Reference< text::XTextTable > xTbl = SwXTextTables::GetObject(*pFmt); - uno::Reference< css::text::XTextDocument > xTextDoc( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< word::XTable > xVBATbl = new SwVbaTable( mxParent, mxContext, xTextDoc, xTbl ); - aRet <<= xVBATbl; - } - } - return aRet; - -} - -uno::Any SAL_CALL -SwVbaSelection::Fields( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< XCollection > xCol( new SwVbaFields( mxParent, mxContext, mxModel ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -uno::Reference< word::XHeaderFooter > SAL_CALL -SwVbaSelection::getHeaderFooter() throw ( uno::RuntimeException ) -{ - 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 ); - if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) || HeaderFooterHelper::isEvenPagesFooter( mxModel ) ) - nIndex = word::WdHeaderFooterIndex::wdHeaderFooterEvenPages; - 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 ) ); - - } - return uno::Reference< word::XHeaderFooter >(); -} - -uno::Any SAL_CALL -SwVbaSelection::ShapeRange( ) throw (uno::RuntimeException) -{ - uno::Reference< drawing::XShapes > xShapes( mxModel->getCurrentSelection(), uno::UNO_QUERY ); - if ( !xShapes.is() ) - { - 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(RTL_CONSTASCII_USTRINGPARAM("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(); - uno::Reference< container::XIndexAccess > xShapesAccess( xShapes, uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< msforms::XShapeRange >( new ScVbaShapeRange( this, mxContext, xShapesAccess, xDrawPage, mxModel ) ) ); -} - -::sal_Int32 SAL_CALL SwVbaSelection::getStart() throw (uno::RuntimeException) -{ - return getRange()->getStart(); -} - -void SAL_CALL SwVbaSelection::setStart( ::sal_Int32 _start ) throw (uno::RuntimeException) -{ - getRange()->setStart( _start ); -} -::sal_Int32 SAL_CALL SwVbaSelection::getEnd() throw (uno::RuntimeException) -{ - return getRange()->getEnd(); -} - -void SAL_CALL SwVbaSelection::setEnd( ::sal_Int32 _end ) throw (uno::RuntimeException) -{ - 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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSelection") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaSelection::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Selection" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaselection.hxx b/sw/source/ui/vba/vbaselection.hxx deleted file mode 100644 index edda22be4b..0000000000 --- a/sw/source/ui/vba/vbaselection.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_SELECTION_HXX -#define SW_VBA_SELECTION_HXX - -#include <ooo/vba/word/XSelection.hpp> -#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; - -class SwVbaSelection : public SwVbaSelection_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextViewCursor > mxTextViewCursor; - css::uno::Reference< ooo::vba::word::XRange > mxRange; - -private: - 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 ); - virtual ~SwVbaSelection(); - - // 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::XRange > SAL_CALL getRange() throw (css::uno::RuntimeException); - virtual void SAL_CALL HomeKey( const css::uno::Any& _unit, const css::uno::Any& _extend ) throw (css::uno::RuntimeException); - virtual void SAL_CALL EndKey( const css::uno::Any& _unit, const css::uno::Any& _extend ) throw (css::uno::RuntimeException); - virtual void SAL_CALL TypeText( const rtl::OUString& rText ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Delete( const css::uno::Any& _unit, const css::uno::Any& _count ) throw (css::uno::RuntimeException); - 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); - virtual void SAL_CALL InsertParagraphAfter() 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::XFind > SAL_CALL getFind() 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); - virtual ::sal_Int32 SAL_CALL getLanguageID( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL setLanguageID( ::sal_Int32 _languageid ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Information( sal_Int32 _type ) throw (css::uno::RuntimeException); - virtual void SAL_CALL InsertBreak( const css::uno::Any& _breakType ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL Tables( 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); - virtual css::uno::Reference< ooo::vba::word::XHeaderFooter > SAL_CALL getHeaderFooter() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL ShapeRange( ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getStart() throw (css::uno::RuntimeException); - 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(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_SELECTION_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbastyle.cxx b/sw/source/ui/vba/vbastyle.cxx deleted file mode 100644 index 5ff6697df1..0000000000 --- a/sw/source/ui/vba/vbastyle.cxx +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "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< 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 ); -} - -void SAL_CALL -SwVbaStyle::setName( const ::rtl::OUString& Name ) throw (uno::RuntimeException) -{ - mxStyle->setName(Name); -} - -::rtl::OUString SAL_CALL -SwVbaStyle::getName() throw (uno::RuntimeException) -{ - return mxStyle->getName(); -} - -sal_Int32 SwVbaStyle::getLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps ) throw (uno::RuntimeException) -{ - lang::Locale aLocale; - xTCProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharLocale") ) ) >>= aLocale; - return MsLangId::convertLocaleToLanguage( aLocale ); -} - -void SwVbaStyle::setLanguageID( const uno::Reference< beans::XPropertySet >& xTCProps, sal_Int32 _languageid ) throw (uno::RuntimeException) -{ - lang::Locale aLocale = MsLangId::convertLanguageToLocale( static_cast<LanguageType>(_languageid) ); - xTCProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharLocale") ), uno::makeAny( aLocale ) ) ; -} - -::sal_Int32 SAL_CALL SwVbaStyle::getLanguageID() throw (uno::RuntimeException) -{ - return getLanguageID( mxStyleProps ); -} - -void SAL_CALL SwVbaStyle::setLanguageID( ::sal_Int32 _languageid ) throw (uno::RuntimeException) -{ - setLanguageID( mxStyleProps, _languageid ); -} - -::sal_Int32 SAL_CALL SwVbaStyle::getType() throw (uno::RuntimeException) -{ - sal_Int32 nType = word::WdStyleType::wdStyleTypeParagraph; - uno::Reference< lang::XServiceInfo > xServiceInfo( mxStyle, uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.ParagraphStyle") ) ) ) - nType = word::WdStyleType::wdStyleTypeParagraph; - else if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.CharacterStyle") ) ) ) - nType = word::WdStyleType::wdStyleTypeCharacter; - else - nType = word::WdStyleType::wdStyleTypeList; - return nType; -} - -uno::Reference< word::XFont > SAL_CALL -SwVbaStyle::getFont() throw ( uno::RuntimeException ) -{ - VbaPalette aColors; - return new SwVbaFont( mxParent, mxContext, aColors.getPalette(), mxStyleProps ); -} - - -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 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 ) -{ - rtl::OUString aStyleType; - switch( _wdStyleType ) - { - case word::WdStyleType::wdStyleTypeParagraph: - case word::WdStyleType::wdStyleTypeTable: - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ); - break; - } - case word::WdStyleType::wdStyleTypeCharacter: - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharStyleName") ); - break; - } - case word::WdStyleType::wdStyleTypeList: - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberingStyleName") ); - break; - } - default: - DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() ); - } - 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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaStyle") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaStyle::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.XStyle" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbastyle.hxx b/sw/source/ui/vba/vbastyle.hxx deleted file mode 100644 index 0af922d174..0000000000 --- a/sw/source/ui/vba/vbastyle.hxx +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_STYLE_HXX -#define SW_VBA_STYLE_HXX -#include <ooo/vba/word/XStyle.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/XModel.hpp> -#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; - -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::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 >& 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); - - // Attributes - virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); - virtual void SAL_CALL setName( const rtl::OUString& Name ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getLanguageID( ) throw (css::uno::RuntimeException); - 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(RTL_CONSTASCII_USTRINGPARAM("Name")); } - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif //SW_VBA_AXIS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbastyles.cxx b/sw/source/ui/vba/vbastyles.cxx deleted file mode 100644 index 725569e39a..0000000000 --- a/sw/source/ui/vba/vbastyles.cxx +++ /dev/null @@ -1,380 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbastyles.hxx" -#include "vbastyle.hxx" -#include <cppuhelper/implbase3.hxx> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> -#include <com/sun/star/style/XStyle.hpp> -#include <ooo/vba/word/WdBuiltinStyle.hpp> -#include <ooo/vba/word/WdStyleType.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -struct BuiltinStyleTable -{ - sal_Int32 wdBuiltinStyle; - const sal_Char* pOOoStyleName; - sal_Int32 wdStyleType; -}; - -static const BuiltinStyleTable aBuiltinStyleTable[] = -{ - { word::WdBuiltinStyle::wdStyleBlockQuotation, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyText, "Text body", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyText2, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyText3, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent, "First line indent", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyTextFirstIndent2, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyTextIndent, "Text body indent", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyTextIndent2, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleBodyTextIndent3, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleCaption, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleClosing, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleCommentReference, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleCommentText, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleDate, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleDefaultParagraphFont, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleEmphasis, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleEndnoteReference, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleEndnoteText, "Endnote", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleEnvelopeAddress, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleEnvelopeReturn, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleFooter, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleFootnoteReference, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleFootnoteText, "Footnote", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeader, "Header", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading1, "Heading 1", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading2, "Heading 2", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading3, "Heading 3", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading4, "Heading 4", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading5, "Heading 5", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading6, "Heading 6", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading7, "Heading 7", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading8, "Heading 8", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHeading9, "Heading 9", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlAcronym, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlAddress, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlCite, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlCode, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlDfn, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlKbd, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlNormal, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlPre, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlSamp, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlTt, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHtmlVar, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHyperlink, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleHyperlinkFollowed, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex1, "Index 1", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex2, "Index 2", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex3, "Index 3", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex4, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex5, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex6, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex7, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex8, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndex9, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleIndexHeading, "Index Heading", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleLineNumber, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleList, "List", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleList2, "List 2", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleList3, "List 3", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleList4, "List 4", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleList5, "List 5", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListBullet, "List 1", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListBullet2, "List 2", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListBullet3, "List 3", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListBullet4, "List 4", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListBullet5, "List 5", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListContinue, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListContinue2, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListContinue3, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListContinue4, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListContinue5, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleListNumber, "Numbering 1", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListNumber2, "Numbering 2", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListNumber3, "Numbering 3", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListNumber4, "Numbering 4", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleListNumber5, "Numbering 5", word::WdStyleType::wdStyleTypeList }, - { word::WdBuiltinStyle::wdStyleMacroText, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleMessageHeader, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleNavPane, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleNormal, "Default", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleNormalIndent, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleNormalTable, "Table", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleNoteHeading, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStylePageNumber, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStylePlainText, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleSalutation, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleSignature, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleStrong, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleSubtitle, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTableOfAuthorities, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTableOfFigures, "", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTitle, "Title", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOAHeading, "Contents Heading", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC1, "Contents 1", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC2, "Contents 2", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC3, "Contents 3", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC4, "Contents 4", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC5, "Contents 5", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC6, "Contents 6", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC7, "Contents 7", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC8, "Contents 8", word::WdStyleType::wdStyleTypeParagraph }, - { word::WdBuiltinStyle::wdStyleTOC9, "Contents 9", word::WdStyleType::wdStyleTypeParagraph }, - { 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 } -}; - -typedef ::cppu::WeakImplHelper1< container::XEnumeration > StyleEnumeration_BASE; -typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > StyleCollectionHelper_BASE; - -class StyleCollectionHelper : public StyleCollectionHelper_BASE -{ -private: - uno::Reference< frame::XModel > mxModel; - 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); - uno::Reference< container::XNameAccess > xStyleFamilies = xStyleSupplier->getStyleFamilies(); - mxParaStyles.set( xStyleFamilies->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ) ), uno::UNO_QUERY_THROW ); - } - // 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; } - // XNameAcess - virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasByName(aName) ) - throw container::NoSuchElementException(); - return cachePos; - } - virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException) - { - 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++ ) - { - if( aName.equalsIgnoreAsciiCaseAscii( pTable->pMSOStyleName ) ) - { - //Found it - rtl::OUString sStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName ); - if( mxParaStyles->hasByName( sStyleName ) ) - { - cachePos = mxParaStyles->getByName( sStyleName ); - return sal_True; - } - return sal_False; - } - } - - if( mxParaStyles->hasByName( aName ) ) - { - cachePos = mxParaStyles->getByName( aName ); - return sal_True; - } - else - { - uno::Sequence< rtl::OUString > sElementNames = mxParaStyles->getElementNames(); - for( sal_Int32 j = 0; j < sElementNames.getLength(); j++ ) - { - rtl::OUString aStyleName = sElementNames[j]; - if( aStyleName.equalsIgnoreAsciiCase( aName ) ) - { - cachePos = mxParaStyles->getByName( aStyleName ); - return sal_True; - } - } - } - return sal_False; - } - - // XIndexAccess - virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - 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(); - - 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) - { - 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 ); -} - -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, mxModel, xStyleProp ) ) ); -} - -uno::Type SAL_CALL -SwVbaStyles::getElementType() throw (uno::RuntimeException) -{ - return word::XStyle::static_type(0); -} - -uno::Reference< container::XEnumeration > SAL_CALL -SwVbaStyles::createEnumeration() throw (uno::RuntimeException) -{ - return new StylesEnumWrapper( this ); -} - -uno::Any SAL_CALL -SwVbaStyles::Item( const uno::Any& Index1, const uno::Any& Index2 ) throw (uno::RuntimeException) -{ - //handle WdBuiltinStyle - sal_Int32 nIndex = 0; - if( ( Index1 >>= nIndex ) && ( nIndex < 0 ) ) - { - for( const BuiltinStyleTable* pTable = aBuiltinStyleTable; pTable != NULL; pTable++ ) - { - if( nIndex == pTable->wdBuiltinStyle ) - { - rtl::OUString aStyleName = rtl::OUString::createFromAscii( pTable->pOOoStyleName ); - if( aStyleName.getLength() > 0 ) - { - rtl::OUString aStyleType; - switch( pTable->wdStyleType ) - { - case word::WdStyleType::wdStyleTypeParagraph: - case word::WdStyleType::wdStyleTypeTable: - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ); - break; - } - case word::WdStyleType::wdStyleTypeCharacter: - { - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharacterStyles") ); - break; - } - case word::WdStyleType::wdStyleTypeList: - { - // should use Paragraph style and set the property "NumberingStyleName" - aStyleType = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphStyles") ); - break; - } - default: - DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() ); - } - 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 ); - // 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 - { - OSL_TRACE("SwVbaStyles::Item: the builtin style type is not implemented"); - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() ); - } - } - } - } - return SwVbaStyles_BASE::Item( Index1, Index2 ); -} - -rtl::OUString& -SwVbaStyles::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaStyles") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaStyles::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.XStyles" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbastyles.hxx b/sw/source/ui/vba/vbastyles.hxx deleted file mode 100644 index a3c2fd1bf0..0000000000 --- a/sw/source/ui/vba/vbastyles.hxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_STYLES_HXX -#define SW_VBA_STYLES_HXX - -#include <ooo/vba/word/XStyles.hpp> -#include <vbahelper/vbacollectionimpl.hxx> - -typedef CollTestImplHelper< ooo::vba::word::XStyles > SwVbaStyles_BASE; -class SwVbaStyles: public SwVbaStyles_BASE -{ - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF; -public: - SwVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::script::BasicErrorException ); - - virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2 ) 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); - virtual css::uno::Any createCollectionObject(const css::uno::Any&); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasystem.cxx b/sw/source/ui/vba/vbasystem.cxx deleted file mode 100644 index de4d8fd137..0000000000 --- a/sw/source/ui/vba/vbasystem.cxx +++ /dev/null @@ -1,292 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbasystem.hxx" -#include <vbahelper/vbahelper.hxx> -#include <ooo/vba/word/WdCursorType.hpp> -#include <tools/diagnose_ex.h> -#include <tools/config.hxx> -#include <tools/string.hxx> -#include <osl/file.hxx> -#include <tools/urlobj.hxx> - -#ifdef WNT -#include <windows.h> -#include <tchar.h> -#endif - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -PrivateProfileStringListener::~PrivateProfileStringListener() -{ -} - -void PrivateProfileStringListener::Initialize( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey ) -{ - maFileName = rFileName; - 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 - 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 ); -} - -void PrivateProfileStringListener::setValueEvent( const css::uno::Any& value ) -{ - // set the private profile string - rtl::OUString aValue; - value >>= aValue; - 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 ) -{ -} - -SwVbaSystem::~SwVbaSystem() -{ -} - -sal_Int32 SAL_CALL -SwVbaSystem::getCursor() throw (uno::RuntimeException) -{ - sal_Int32 nPointerStyle = getPointerStyle( getCurrentWordDoc(mxContext) ); - - switch( nPointerStyle ) - { - case POINTER_ARROW: - return word::WdCursorType::wdCursorNorthwestArrow; - case POINTER_NULL: - return word::WdCursorType::wdCursorNormal; - case POINTER_WAIT: - return word::WdCursorType::wdCursorWait; - case POINTER_TEXT: - return word::WdCursorType::wdCursorIBeam; - default: - return word::WdCursorType::wdCursorNormal; - } -} - -void SAL_CALL -SwVbaSystem::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException) -{ - try - { - switch( _cursor ) - { - case word::WdCursorType::wdCursorNorthwestArrow: - { - const Pointer& rPointer( POINTER_ARROW ); - setCursorHelper( getCurrentWordDoc(mxContext), rPointer, sal_False ); - break; - } - case word::WdCursorType::wdCursorWait: - { - const Pointer& rPointer( static_cast< PointerStyle >( POINTER_WAIT ) ); - //It will set the edit window, toobar and statusbar's mouse pointer. - setCursorHelper( getCurrentWordDoc(mxContext), rPointer, sal_True ); - break; - } - case word::WdCursorType::wdCursorIBeam: - { - const Pointer& rPointer( static_cast< PointerStyle >( POINTER_TEXT ) ); - //It will set the edit window, toobar and statusbar's mouse pointer. - setCursorHelper( getCurrentWordDoc( mxContext ), rPointer, sal_True ); - break; - } - case word::WdCursorType::wdCursorNormal: - { - const Pointer& rPointer( POINTER_NULL ); - setCursorHelper( getCurrentWordDoc( mxContext ), rPointer, sal_False ); - break; - } - default: - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() ); - // TODO: isn't this a flaw in the API? It should be allowed to throw an - // IllegalArgumentException, or so - } - } - catch( const uno::Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } -} - -uno::Any SAL_CALL -SwVbaSystem::PrivateProfileString( const rtl::OUString& rFilename, const rtl::OUString& rSection, const rtl::OUString& rKey ) throw ( uno::RuntimeException ) -{ - // 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; - 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); - maPrivateProfileStringListener.Initialize( sFileUrl, aGroupName, aKey ); - - return uno::makeAny( uno::Reference< XPropValue > ( new ScVbaPropValue( &maPrivateProfileStringListener ) ) ); -} - -rtl::OUString& -SwVbaSystem::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaSystem") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaSystem::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.System" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbasystem.hxx b/sw/source/ui/vba/vbasystem.hxx deleted file mode 100644 index 82db6a5f71..0000000000 --- a/sw/source/ui/vba/vbasystem.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_SYSTEM_HXX -#define SW_VBA_SYSTEM_HXX - -#include <ooo/vba/word/XSystem.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <vbahelper/vbapropvalue.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XSystem > SwVbaSystem_BASE; - -class PrivateProfileStringListener : public PropListener -{ -private: - rtl::OUString maFileName; - ByteString maGroupName; - ByteString maKey; -public: - PrivateProfileStringListener(){}; - virtual ~PrivateProfileStringListener(); - void Initialize( const rtl::OUString& rFileName, const ByteString& rGroupName, const ByteString& rKey ); - - //PropListener - virtual void setValueEvent( const css::uno::Any& value ); - virtual css::uno::Any getValueEvent(); -}; - -class SwVbaSystem : public SwVbaSystem_BASE -{ -private: - PrivateProfileStringListener maPrivateProfileStringListener; - -public: - SwVbaSystem( css::uno::Reference< css::uno::XComponentContext >& m_xContext ); - virtual ~SwVbaSystem(); - - // XSystem - virtual sal_Int32 SAL_CALL getCursor() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL setCursor( sal_Int32 _cursor ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL PrivateProfileString( const rtl::OUString& rFilename, const rtl::OUString& rSection, const rtl::OUString& rKey ) throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_SYSTEM_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatable.cxx b/sw/source/ui/vba/vbatable.cxx deleted file mode 100644 index 6809e4b0e4..0000000000 --- a/sw/source/ui/vba/vbatable.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "vbatable.hxx" -#include "vbarange.hxx" -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <com/sun/star/text/XTextTablesSupplier.hpp> -#include <com/sun/star/table/XTableRows.hpp> -#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 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 ); -} - -uno::Reference< word::XRange > SAL_CALL -SwVbaTable::Range( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - return new SwVbaRange( mxParent, mxContext, mxTextDocument, mxTextTable->getAnchor() ); -} - -void SAL_CALL -SwVbaTable::Select( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - uno::Reference< frame::XModel > xModel( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< frame::XController > xController = xModel->getCurrentController(); - - uno::Reference< text::XTextViewCursorSupplier > xViewCursorSupplier( xController, uno::UNO_QUERY_THROW ); - uno::Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY_THROW ); - - // set the view cursor to the start of the table. - xSelectionSupplier->select( uno::makeAny( mxTextTable ) ); - - // go to the end of the table and span the view - uno::Reference< text::XTextViewCursor > xCursor = xViewCursorSupplier->getViewCursor(); - xCursor->gotoEnd(sal_True); - -} - -void SAL_CALL -SwVbaTable::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) -{ - uno::Reference< table::XTableRows > xRows( mxTextTable->getRows() ); - xRows->removeByIndex( 0, xRows->getCount() ); -} - -uno::Reference< word::XRange > SAL_CALL -SwVbaTable::ConvertToText( const uno::Any& /*Separator*/, const uno::Any& /*NestedTables*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - // #FIXME the helper api uses the dreaded dispatch mechanism, holding off - // implementation while I look for alternative solution - throw uno::RuntimeException(); -} - -rtl::OUString SAL_CALL -SwVbaTable::getName() throw (uno::RuntimeException) -{ - uno::Reference< container::XNamed > xNamed( mxTextTable, uno::UNO_QUERY_THROW ); - return xNamed->getName(); -} - -uno::Any SAL_CALL -SwVbaTable::Borders( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< table::XCellRange > aCellRange( mxTextTable, uno::UNO_QUERY_THROW ); - VbaPalette aPalette; - uno::Reference< XCollection > xCol( new SwVbaBorders( this, mxContext, aCellRange, aPalette ) ); - if ( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - 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() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTable") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaTable::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Table" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatable.hxx b/sw/source/ui/vba/vbatable.hxx deleted file mode 100644 index 2e95d0ca41..0000000000 --- a/sw/source/ui/vba/vbatable.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef SW_VBA_TABLE_HXX -#define SW_VBA_TABLE_HXX -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <ooo/vba/word/XRange.hpp> -#include <ooo/vba/word/XTable.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTable > SwVbaTable_BASE; - -class SwVbaTable : public SwVbaTable_BASE -{ - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::text::XTextTable > mxTextTable; -public: - SwVbaTable( 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::XTextTable >& xTextTable) throw ( css::uno::RuntimeException); - css::uno::Reference< css::text::XTextDocument > getDocument() const { return mxTextDocument; }; - virtual css::uno::Reference< ::ooo::vba::word::XRange > SAL_CALL Range( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Select( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException); - 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(); -}; -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatablehelper.cxx b/sw/source/ui/vba/vbatablehelper.cxx deleted file mode 100644 index de37466c18..0000000000 --- a/sw/source/ui/vba/vbatablehelper.cxx +++ /dev/null @@ -1,295 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatablehelper.hxx" -#include <swtable.hxx> -#include <unotbl.hxx> -#include <docsh.hxx> - -using namespace ::com::sun::star; -using namespace ::ooo::vba; - -#define UNO_TABLE_COLUMN_SUM 10000 - -SwVbaTableHelper::SwVbaTableHelper( const uno::Reference< text::XTextTable >& xTextTable ) throw (uno::RuntimeException) : mxTextTable( xTextTable ), pDoc( NULL ) -{ - pTable = GetSwTable( mxTextTable ); -} - -SwTable* SwVbaTableHelper::GetSwTable( const uno::Reference< text::XTextTable >& xTextTable ) throw (uno::RuntimeException) -{ - uno::Reference< lang::XUnoTunnel > xTunnel( xTextTable, uno::UNO_QUERY_THROW ); - SwXTextTable* pXTextTable = reinterpret_cast< SwXTextTable * >( sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextTable::getUnoTunnelId()))); - if( !pXTextTable ) - throw uno::RuntimeException(); - - SwFrmFmt* pFrmFmt = pXTextTable->GetFrmFmt(); - if( !pFrmFmt ) - throw uno::RuntimeException(); - - SwTable* pTable = SwTable::FindTable( pFrmFmt ); - return pTable; -} - -sal_Int32 SwVbaTableHelper::getTabColumnsCount( sal_Int32 nRowIndex ) throw (uno::RuntimeException) -{ - sal_Int32 nRet = 0; - if(!pTable->IsTblComplex()) - { - SwTableLines& rLines = pTable->GetTabLines(); - SwTableLine* pLine = rLines.GetObject( nRowIndex ); - nRet = pLine->GetTabBoxes().Count(); - } - return nRet; -} - -sal_Int32 SwVbaTableHelper::getTabColumnsMaxCount( ) throw (uno::RuntimeException) -{ - sal_Int32 nRet = 0; - //sal_Int32 nRowCount = mxTextTable->getRows()->getCount(); - sal_Int32 nRowCount = pTable->GetTabLines().Count(); - for( sal_Int32 index = 0; index < nRowCount; index++ ) - { - sal_Int32 nColCount = getTabColumnsCount( index ); - if( nRet < nColCount ) - nRet = nColCount; - } - return nRet; -} - -sal_Int32 SwVbaTableHelper::getTabRowIndex( const rtl::OUString& CellName ) throw (uno::RuntimeException) -{ - sal_Int32 nRet = 0; - String sCellName(CellName); - SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName ); - if( !pBox ) - throw uno::RuntimeException(); - - const SwTableLine* pLine = pBox->GetUpper(); - const SwTableLines* pLines = pLine->GetUpper() - ? &pLine->GetUpper()->GetTabLines() : &pTable->GetTabLines(); - nRet = pLines->GetPos( pLine ); - return nRet; -} - -sal_Int32 SwVbaTableHelper::getTabColIndex( const rtl::OUString& CellName ) throw (uno::RuntimeException) -{ - sal_Int32 nRet = 0; - String sCellName(CellName); - const SwTableBox* pBox = (SwTableBox*)pTable->GetTblBox( sCellName ); - if( !pBox ) - throw uno::RuntimeException(); - const SwTableBoxes* pBoxes = &pBox->GetUpper()->GetTabBoxes(); - nRet = pBoxes->GetPos( pBox ); - return nRet; -} - -rtl::OUString SwVbaTableHelper::getColumnStr( sal_Int32 nCol ) -{ - const sal_Int32 coDiff = 52; // 'A'-'Z' 'a' - 'z' - sal_Int32 nCalc = 0; - - String sRet; - do{ - nCalc = nCol % coDiff; - if( nCalc >= 26 ) - sRet.Insert( sal_Unicode('a' - 26 + nCalc ), 0 ); - else - sRet.Insert( sal_Unicode('A' + nCalc ), 0 ); - - if( 0 == ( nCol = nCol - nCalc ) ) - break; - nCol /= coDiff; - --nCol; - }while(1); - return sRet; -} - -sal_Int32 SwVbaTableHelper::getTableWidth( ) throw (uno::RuntimeException) -{ - sal_Int32 nWidth = 0; - sal_Bool isWidthRelatvie = sal_False; - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsWidthRelative") ) ) >>= isWidthRelatvie; - if( isWidthRelatvie ) - { - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RelativeWidth") ) ) >>= nWidth; - } - else - { - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ) ) >>= nWidth; - } - return nWidth; -} - -void SwVbaTableHelper::setTableWidth( sal_Int32 _width ) throw (uno::RuntimeException) -{ - sal_Bool isWidthRelatvie = sal_False; - uno::Reference< beans::XPropertySet > xTableProps( mxTextTable, uno::UNO_QUERY_THROW ); - xTableProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsWidthRelative") ) ) >>= isWidthRelatvie; - if( isWidthRelatvie ) - { - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RelativeWidth") ), uno::makeAny( _width )); - } - else - { - xTableProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width") ), uno::makeAny( _width ) ); - } -} - -SwTableBox* SwVbaTableHelper::GetTabBox( sal_Int32 nCol, sal_Int32 nRow ) throw (css::uno::RuntimeException) -{ - SwTableLines& rLines = pTable->GetTabLines(); - sal_Int32 nRowCount = rLines.Count(); - if( nRowCount < nRow ) - throw uno::RuntimeException(); - - SwTableBox* pStart = NULL; - SwTableLine* pLine = rLines.GetObject( nRow ); - if( pLine->GetTabBoxes().Count() < nCol ) - throw uno::RuntimeException(); - - pStart = pLine->GetTabBoxes()[ nCol ]; - - if( !pStart ) - throw uno::RuntimeException(); - - return pStart; -} - -void SwVbaTableHelper::InitTabCols( SwTabCols& rCols, const SwTableBox *pStart, sal_Bool /*bCurRowOnly*/ ) -{ - rCols.SetLeftMin ( 0 ); - rCols.SetLeft ( 0 ); - rCols.SetRight ( UNO_TABLE_COLUMN_SUM ); - rCols.SetRightMax( UNO_TABLE_COLUMN_SUM ); - pTable->GetTabCols( rCols, pStart, sal_False, sal_False ); -} - -sal_Int32 SwVbaTableHelper::GetColCount( SwTabCols& rCols ) const -{ - sal_Int32 nCount = 0; - for(sal_Int32 i = 0; i < rCols.Count(); i++ ) - if(rCols.IsHidden(i)) - nCount ++; - return rCols.Count() - nCount; -} - -sal_Int32 SwVbaTableHelper::GetRightSeparator( SwTabCols& rCols, sal_Int32 nNum) const -{ - OSL_ENSURE( nNum < (sal_Int32)GetColCount( rCols ) ,"Index out of range"); - sal_Int32 i = 0; - while( nNum >= 0 ) - { - if( !rCols.IsHidden( static_cast< sal_uInt16 >(i)) ) - nNum--; - i++; - } - return i - 1; -} - -sal_Int32 SwVbaTableHelper::GetColWidth( sal_Int32 nCol, sal_Int32 nRow, sal_Bool bCurRowOnly ) throw (uno::RuntimeException) -{ - SwTableBox* pStart = GetTabBox( nCol, nRow ); - SwTabCols aCols; - InitTabCols( aCols, pStart, bCurRowOnly ); - sal_Int32 nWidth = GetColWidth( aCols, nCol ); - - sal_Int32 nTableWidth = getTableWidth( ); - double dAbsWidth = ( (double)nWidth / UNO_TABLE_COLUMN_SUM ) * (double) nTableWidth; - return ( sal_Int32 )Millimeter::getInPoints( static_cast<int>(dAbsWidth) ); -} - -sal_Int32 SwVbaTableHelper::GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) throw (uno::RuntimeException) -{ - SwTwips nWidth = 0; - - if( rCols.Count() > 0 ) - { - if(rCols.Count() == GetColCount( rCols )) - { - nWidth = (SwTwips)((nNum == rCols.Count()) ? - rCols.GetRight() - rCols[nNum-1] : - nNum == 0 ? rCols[nNum] - rCols.GetLeft() : - rCols[nNum] - rCols[nNum-1]); - } - else - { - SwTwips nRValid = nNum < GetColCount( rCols ) ? - rCols[(sal_uInt16)GetRightSeparator( rCols, nNum)]: - rCols.GetRight(); - SwTwips nLValid = nNum ? - rCols[(sal_uInt16)GetRightSeparator( rCols, nNum - 1)]: - rCols.GetLeft(); - nWidth = nRValid - nLValid; - } - } - else - nWidth = rCols.GetRight(); - - return nWidth; -} - -void SwVbaTableHelper::SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow, sal_Bool bCurRowOnly ) throw (css::uno::RuntimeException) -{ - double dAbsWidth = Millimeter::getInHundredthsOfOneMillimeter( _width ); - sal_Int32 nTableWidth = getTableWidth( ); - sal_Int32 nNewWidth = (sal_Int32)( dAbsWidth/nTableWidth * UNO_TABLE_COLUMN_SUM ); - - SwTableBox* pStart = GetTabBox( nCol, nRow ); - SwTabCols aOldCols; - InitTabCols( aOldCols, pStart, bCurRowOnly ); - - SwTabCols aCols( aOldCols ); - if ( aCols.Count() > 0 ) - { - SwTwips nWidth = GetColWidth( aCols, nCol); - - int nDiff = (int)(nNewWidth - nWidth); - if( !nCol ) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator(aCols, 0)) ] += nDiff; - else if( nCol < GetColCount( aCols ) ) - { - if(nDiff < GetColWidth( aCols, nCol + 1) - MINLAY) - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol)) ] += nDiff; - else - { - int nDiffLeft = nDiff - (int)GetColWidth( aCols, nCol + 1) + (int)MINLAY; - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol)) ] += (nDiff - nDiffLeft); - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol - 1)) ] -= nDiffLeft; - } - } - else - aCols[ static_cast< sal_uInt16 >(GetRightSeparator( aCols, nCol-1)) ] -= nDiff; - } - else - aCols.SetRight( Min( (long)nNewWidth, aCols.GetRightMax()) ); - - pTable->SetTabCols(aCols, aOldCols, pStart, bCurRowOnly ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatablehelper.hxx b/sw/source/ui/vba/vbatablehelper.hxx deleted file mode 100644 index 0dcd630d07..0000000000 --- a/sw/source/ui/vba/vbatablehelper.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_WORD_VBA_TABLEHELPER_HXX -#define SW_WORD_VBA_TABLEHELPER_HXX - -#include <com/sun/star/text/XTextTable.hpp> -#include "wordvbahelper.hxx" -#include <swtable.hxx> -#include <tabcol.hxx> -#include <doc.hxx> - -class SwVbaTableHelper -{ -private: - css::uno::Reference< css::text::XTextTable > mxTextTable; - SwTable* pTable; - SwDoc* pDoc; - -private: - SwTableBox* GetTabBox( sal_Int32 nCol, sal_Int32 nRow ) throw (css::uno::RuntimeException); - void InitTabCols( SwTabCols& rCols, const SwTableBox *pStart, sal_Bool bCurRowOnly = sal_False ); - sal_Int32 GetRightSeparator( SwTabCols& rCols, sal_Int32 nNum) const; - sal_Int32 GetColCount( SwTabCols& rCols ) const; - sal_Int32 GetColWidth( SwTabCols& rCols, sal_Int32 nNum ) throw (css::uno::RuntimeException); - -public: - SwVbaTableHelper( const css::uno::Reference< css::text::XTextTable >& xTextTable ) throw (css::uno::RuntimeException); - ~SwVbaTableHelper() {} - sal_Int32 getTabColumnsCount( sal_Int32 nRowIndex ) throw (css::uno::RuntimeException); - sal_Int32 getTabColumnsMaxCount( ) throw (css::uno::RuntimeException); - sal_Int32 getTabRowIndex( const rtl::OUString& sCellName ) throw (css::uno::RuntimeException); - sal_Int32 getTabColIndex( const rtl::OUString& sCellName ) throw (css::uno::RuntimeException); - sal_Int32 getTableWidth( ) throw (css::uno::RuntimeException); - void setTableWidth( sal_Int32 _width ) throw (css::uno::RuntimeException); - - sal_Int32 GetColWidth( sal_Int32 nCol, sal_Int32 nRow = 0, sal_Bool bCurRowOnly = sal_False ) throw (css::uno::RuntimeException); - void SetColWidth( sal_Int32 _width, sal_Int32 nCol, sal_Int32 nRow = 0, sal_Bool bCurRowOnly = sal_False ) throw (css::uno::RuntimeException); - - static SwTable* GetSwTable( const css::uno::Reference< css::text::XTextTable >& xTextTable ) throw (css::uno::RuntimeException); - static rtl::OUString getColumnStr( sal_Int32 nCol ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatableofcontents.cxx b/sw/source/ui/vba/vbatableofcontents.cxx deleted file mode 100644 index 09a29238ba..0000000000 --- a/sw/source/ui/vba/vbatableofcontents.cxx +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatableofcontents.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <ooo/vba/word/WdTabLeader.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaTableOfContents::SwVbaTableOfContents( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& xDoc, const uno::Reference< text::XDocumentIndex >& xDocumentIndex ) throw ( uno::RuntimeException ) : - SwVbaTableOfContents_BASE( rParent, rContext ), mxTextDocument( xDoc ), mxDocumentIndex( xDocumentIndex ) -{ - mxTocProps.set( mxDocumentIndex, uno::UNO_QUERY_THROW ); -} - - -SwVbaTableOfContents::~SwVbaTableOfContents() -{ -} - -::sal_Int32 SAL_CALL SwVbaTableOfContents::getLowerHeadingLevel() throw (uno::RuntimeException) -{ - sal_Int16 nLevel = 0; - mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ) ) >>= nLevel; - return nLevel; -} - -void SAL_CALL SwVbaTableOfContents::setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (uno::RuntimeException) -{ - mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Level") ), uno::makeAny( sal_Int8( _lowerheadinglevel ) ) ); -} - -::sal_Int32 SAL_CALL SwVbaTableOfContents::getTabLeader() throw (uno::RuntimeException) -{ - // not support in Writer - return word::WdTabLeader::wdTabLeaderDots; -} - -void SAL_CALL SwVbaTableOfContents::setTabLeader( ::sal_Int32 /*_tableader*/ ) throw (uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL SwVbaTableOfContents::getUseFields() throw (css::uno::RuntimeException) -{ - sal_Bool bUseFields = sal_False; - mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ) ) >>= bUseFields; - return bUseFields; -} - -void SAL_CALL SwVbaTableOfContents::setUseFields( ::sal_Bool _useFields ) throw (css::uno::RuntimeException) -{ - mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromMarks") ), uno::makeAny( _useFields ) ); -} - -::sal_Bool SAL_CALL SwVbaTableOfContents::getUseOutlineLevels() throw (css::uno::RuntimeException) -{ - sal_Bool bUseOutlineLevels = sal_False; - mxTocProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ) ) >>= bUseOutlineLevels; - return bUseOutlineLevels; -} - -void SAL_CALL SwVbaTableOfContents::setUseOutlineLevels( ::sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException) -{ - mxTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CreateFromOutline") ), uno::makeAny( _useOutlineLevels ) ); -} - -void SAL_CALL SwVbaTableOfContents::Delete( ) throw (uno::RuntimeException) -{ - uno::Reference< text::XTextContent > xTextContent( mxDocumentIndex, uno::UNO_QUERY_THROW ); - mxTextDocument->getText()->removeTextContent( xTextContent ); -} - -void SAL_CALL SwVbaTableOfContents::Update( ) throw (uno::RuntimeException) -{ - mxDocumentIndex->update(); -} - -rtl::OUString& -SwVbaTableOfContents::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTableOfContents") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaTableOfContents::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TableOfContents" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatableofcontents.hxx b/sw/source/ui/vba/vbatableofcontents.hxx deleted file mode 100644 index 27b39a5da2..0000000000 --- a/sw/source/ui/vba/vbatableofcontents.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_TABLEOFCONTENTS_HXX -#define SW_VBA_TABLEOFCONTENTS_HXX - -#include <ooo/vba/word/XTableOfContents.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XDocumentIndex.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTableOfContents > SwVbaTableOfContents_BASE; - -class SwVbaTableOfContents : public SwVbaTableOfContents_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - css::uno::Reference< css::text::XDocumentIndex > mxDocumentIndex; - css::uno::Reference< css::beans::XPropertySet > mxTocProps; - -public: - SwVbaTableOfContents( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::text::XTextDocument >& xDoc, const css::uno::Reference< css::text::XDocumentIndex >& xDocumentIndex ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaTableOfContents(); - - // Attributes - virtual ::sal_Int32 SAL_CALL getLowerHeadingLevel() throw (css::uno::RuntimeException); - virtual void SAL_CALL setLowerHeadingLevel( ::sal_Int32 _lowerheadinglevel ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getTabLeader() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTabLeader( ::sal_Int32 _tableader ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getUseFields() throw (css::uno::RuntimeException); - virtual void SAL_CALL setUseFields( ::sal_Bool _useFields ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getUseOutlineLevels() throw (css::uno::RuntimeException); - virtual void SAL_CALL setUseOutlineLevels( ::sal_Bool _useOutlineLevels ) throw (css::uno::RuntimeException); - - // Methods - virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException); - virtual void SAL_CALL Update( ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_TABLEOFCONTENTS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatables.cxx b/sw/source/ui/vba/vbatables.cxx deleted file mode 100644 index b35624c3d1..0000000000 --- a/sw/source/ui/vba/vbatables.cxx +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#include "vbatables.hxx" -#include "vbatable.hxx" -#include "vbarange.hxx" -#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; -using namespace css; - -uno::Reference< container::XIndexAccess > lcl_getTables( const uno::Reference< frame::XModel >& xDoc ) -{ - uno::Reference< container::XIndexAccess > xTables; - uno::Reference< text::XTextTablesSupplier > xSupp( xDoc, uno::UNO_QUERY ); - if ( xSupp.is() ) - xTables.set( xSupp->getTextTables(), uno::UNO_QUERY_THROW ); - return xTables; -} - -uno::Any lcl_createTable( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xDocument, const uno::Any& aSource ) -{ - uno::Reference< text::XTextTable > xTextTable( aSource, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextDocument > xTextDocument( xDocument, uno::UNO_QUERY_THROW ); - uno::Reference< word::XTable > xTable( new SwVbaTable( xParent, xContext, xTextDocument, xTextTable ) ); - 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.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("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 -{ - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< frame::XModel > mxDocument; - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 mnCurIndex; -public: - TableEnumerationImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xDocument, const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxParent( xParent ), mxContext( xContext ), mxDocument( xDocument ), mxIndexAccess( xIndexAccess ), mnCurIndex(0) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( mnCurIndex < mxIndexAccess->getCount() ); - } - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( !hasMoreElements() ) - throw container::NoSuchElementException(); - return lcl_createTable( mxParent, mxContext, mxDocument, mxIndexAccess->getByIndex( mnCurIndex++ ) ); - } - -}; - -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 ) -{ -} - - -uno::Reference< word::XTable > SAL_CALL -SwVbaTables::Add( const uno::Reference< word::XRange >& Range, const uno::Any& NumRows, const uno::Any& NumColumns, const uno::Any& /*DefaultTableBehavior*/, const uno::Any& /*AutoFitBehavior*/ ) throw (script::BasicErrorException, uno::RuntimeException) -{ - sal_Int32 nCols = 0; - sal_Int32 nRows = 0; - SwVbaRange* pVbaRange = dynamic_cast< SwVbaRange* >( Range.get() ); - // Preconditions - if ( !( pVbaRange && ( NumRows >>= nRows ) && ( NumColumns >>= nCols ) ) ) - throw uno::RuntimeException(); // #FIXME better exception?? - if ( nCols <= 0 || nRows <= 0 ) - throw uno::RuntimeException(); // #FIXME better exception?? - - uno::Reference< frame::XModel > xModel( pVbaRange->getDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< lang::XMultiServiceFactory > xMsf( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextRange > xTextRange = pVbaRange->getXTextRange(); - - uno::Reference< text::XTextTable > xTable; - xTable.set( xMsf->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextTable")) ), uno::UNO_QUERY_THROW ); - - xTable->initialize( nRows, nCols ); - uno::Reference< text::XText > xText = xTextRange->getText(); - 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; -} - -uno::Reference< container::XEnumeration > SAL_CALL -SwVbaTables::createEnumeration() throw (uno::RuntimeException) -{ - return new TableEnumerationImpl( mxParent, mxContext, mxDocument, m_xIndexAccess ); -} - -// ScVbaCollectionBaseImpl -uno::Any -SwVbaTables::createCollectionObject( const uno::Any& aSource ) -{ - return lcl_createTable( mxParent, mxContext, mxDocument, aSource ); -} - -// XHelperInterface -rtl::OUString& -SwVbaTables::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTables") ); - return sImplName; -} - -// XEnumerationAccess -uno::Type SAL_CALL -SwVbaTables::getElementType() throw (uno::RuntimeException) -{ - return word::XTable::static_type(0); -} - -uno::Sequence<rtl::OUString> -SwVbaTables::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Tables" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatables.hxx b/sw/source/ui/vba/vbatables.hxx deleted file mode 100644 index 00e1a9037d..0000000000 --- a/sw/source/ui/vba/vbatables.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -#ifndef SW_VBA_TABLES_HXX -#define SW_VBA_TABLES_HXX - -#include <ooo/vba/word/XTables.hpp> -#include <vbahelper/vbacollectionimpl.hxx> - - -typedef CollTestImplHelper< ov::word::XTables > SwVbaTables_BASE; - -class SwVbaTables : public SwVbaTables_BASE -{ - css::uno::Reference< css::frame::XModel > mxDocument; -public: - SwVbaTables( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xDocument ); - // XTables - virtual css::uno::Reference< ov::word::XTable > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& NumRows, const css::uno::Any& NumColumns, const css::uno::Any& DefaultTableBehavior, const css::uno::Any& AutoFitBehavior ) throw (css::script::BasicErrorException, 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); - // ScVbaCollectionBaseImpl - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatablesofcontents.cxx b/sw/source/ui/vba/vbatablesofcontents.cxx deleted file mode 100644 index 0401e8add5..0000000000 --- a/sw/source/ui/vba/vbatablesofcontents.cxx +++ /dev/null @@ -1,195 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatablesofcontents.hxx" -#include "vbatableofcontents.hxx" -#include "vbarange.hxx" -#include <com/sun/star/text/XDocumentIndexesSupplier.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > TableOfContentsCollectionHelper_Base; -typedef std::vector< uno::Reference< text::XDocumentIndex > > XTocVec; - -class TablesOfContentsEnumWrapper : public EnumerationHelper_BASE -{ - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 nIndex; - -public: - TablesOfContentsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 ) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if( nIndex < mxIndexAccess->getCount() ) - { - return mxIndexAccess->getByIndex( nIndex++ ); - } - throw container::NoSuchElementException(); - } -}; - -class TableOfContentsCollectionHelper : public TableOfContentsCollectionHelper_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< text::XTextDocument > mxTextDocument; - XTocVec maToc; - -public: - TableOfContentsCollectionHelper( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDoc ) throw ( uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxTextDocument( xDoc ) - { - uno::Reference< text::XDocumentIndexesSupplier > xDocIndexSupp( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xDocIndexes = xDocIndexSupp->getDocumentIndexes(); - sal_Int32 nCount = xDocIndexes->getCount(); - for( sal_Int32 i = 0; i < nCount; i++ ) - { - uno::Reference< text::XDocumentIndex > xToc( xDocIndexes->getByIndex(i), uno::UNO_QUERY_THROW ); - if( xToc->getServiceName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.ContentIndex")) ) - { - maToc.push_back( xToc ); - } - } - } - - virtual ~TableOfContentsCollectionHelper() {} - - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return maToc.size(); - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 || Index >= getCount() ) - throw lang::IndexOutOfBoundsException(); - - uno::Reference< text::XDocumentIndex > xToc( maToc[Index], uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XTableOfContents >( new SwVbaTableOfContents( mxParent, mxContext, mxTextDocument, xToc ) ) ); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XTableOfContents::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new TablesOfContentsEnumWrapper( this ); - } -}; - -SwVbaTablesOfContents::SwVbaTablesOfContents( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< text::XTextDocument >& xDoc ) throw (uno::RuntimeException) : SwVbaTablesOfContents_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TableOfContentsCollectionHelper( xParent, xContext, xDoc ) ) ), mxTextDocument( xDoc ) -{ -} - -uno::Reference< word::XTableOfContents > SAL_CALL -SwVbaTablesOfContents::Add( const uno::Reference< word::XRange >& Range, const uno::Any& /*UseHeadingStyles*/, const uno::Any& /*UpperHeadingLevel*/, const uno::Any& LowerHeadingLevel, const uno::Any& UseFields, const uno::Any& /*TableID*/, const uno::Any& /*RightAlignPageNumbers*/, const uno::Any& /*IncludePageNumbers*/, const uno::Any& /*AddedStyles*/, const uno::Any& /*UseHyperlinks*/, const uno::Any& /*HidePageNumbersInWeb*/, const uno::Any& /*UseOutlineLevels*/ ) throw (uno::RuntimeException) -{ - uno::Reference< lang::XMultiServiceFactory > xDocMSF( mxTextDocument, uno::UNO_QUERY_THROW ); - uno::Reference< text::XDocumentIndex > xDocumentIndex( xDocMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ContentIndex")) ), uno::UNO_QUERY_THROW ); - - uno::Reference< beans::XPropertySet > xTocProps( xDocumentIndex, uno::UNO_QUERY_THROW ); - sal_Bool isProtected = sal_False; - xTocProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IsProtected") ), uno::makeAny( isProtected ) ); - - uno::Reference< word::XTableOfContents > xToc( new SwVbaTableOfContents( this, mxContext, mxTextDocument, xDocumentIndex ) ); - - sal_Int32 nLowerHeadingLevel = 9; - if( LowerHeadingLevel.hasValue() ) - LowerHeadingLevel >>= nLowerHeadingLevel; - xToc->setLowerHeadingLevel( nLowerHeadingLevel ); - - sal_Bool bUseFields = sal_False; - if( UseFields.hasValue() ) - UseFields >>= bUseFields; - xToc->setUseFields( bUseFields ); - - sal_Bool bUseOutlineLevels = sal_True; - xToc->setUseOutlineLevels( bUseOutlineLevels ); - - SwVbaRange* pVbaRange = dynamic_cast<SwVbaRange*>( Range.get() ); - if( !pVbaRange ) - throw uno::RuntimeException(); - - uno::Reference< text::XTextRange > xTextRange = pVbaRange->getXTextRange(); - uno::Reference< text::XText > xText = pVbaRange->getXText(); - uno::Reference< text::XTextContent > xTextContent( xDocumentIndex, uno::UNO_QUERY_THROW ); - xText->insertTextContent( xTextRange, xTextContent, sal_False ); - xToc->Update(); - - return xToc; -} - -// XEnumerationAccess -uno::Type -SwVbaTablesOfContents::getElementType() throw (uno::RuntimeException) -{ - return word::XTableOfContents::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaTablesOfContents::createEnumeration() throw (uno::RuntimeException) -{ - return new TablesOfContentsEnumWrapper( m_xIndexAccess ); -} - -uno::Any -SwVbaTablesOfContents::createCollectionObject( const uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaTablesOfContents::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTablesOfContents") ); - return sImplName; -} - -uno::Sequence<rtl::OUString> -SwVbaTablesOfContents::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TablesOfContents") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatablesofcontents.hxx b/sw/source/ui/vba/vbatablesofcontents.hxx deleted file mode 100644 index 04b30d0b12..0000000000 --- a/sw/source/ui/vba/vbatablesofcontents.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_TABLESOFCONTENTS_HXX -#define SW_VBA_TABLESOFCONTENTS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XTablesOfContents.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextDocument.hpp> -#include <ooo/vba/word/XTableOfContents.hpp> -#include <ooo/vba/word/XRange.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XTablesOfContents > SwVbaTablesOfContents_BASE; - -class SwVbaTablesOfContents : public SwVbaTablesOfContents_BASE -{ -private: - css::uno::Reference< css::text::XTextDocument > mxTextDocument; - -public: - SwVbaTablesOfContents( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::text::XTextDocument >& xDoc ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaTablesOfContents() {} - - // Methods - virtual css::uno::Reference< ::ooo::vba::word::XTableOfContents > SAL_CALL Add( const css::uno::Reference< ::ooo::vba::word::XRange >& Range, const css::uno::Any& UseHeadingStyles, const css::uno::Any& UpperHeadingLevel, const css::uno::Any& LowerHeadingLevel, const css::uno::Any& UseFields, const css::uno::Any& TableID, const css::uno::Any& RightAlignPageNumbers, const css::uno::Any& IncludePageNumbers, const css::uno::Any& AddedStyles, const css::uno::Any& UseHyperlinks, const css::uno::Any& HidePageNumbersInWeb, const css::uno::Any& UseOutlineLevels ) throw (css::uno::RuntimeException); - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaTablesOfContents_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_TABLESOFCONTENTS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatabstop.cxx b/sw/source/ui/vba/vbatabstop.cxx deleted file mode 100644 index 4ed72202bc..0000000000 --- a/sw/source/ui/vba/vbatabstop.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatabstop.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaTabStop::SwVbaTabStop( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< beans::XPropertySet >& xParaProps, const style::TabStop& aTabStop ) throw ( uno::RuntimeException ) : SwVbaTabStop_BASE( rParent, rContext ), mxParaProps( xParaProps ), maTabStop( aTabStop ) -{ -} - -SwVbaTabStop::~SwVbaTabStop() -{ -} - -rtl::OUString& -SwVbaTabStop::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTabStop") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaTabStop::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TabStop" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatabstop.hxx b/sw/source/ui/vba/vbatabstop.hxx deleted file mode 100644 index 0de7c0d7e4..0000000000 --- a/sw/source/ui/vba/vbatabstop.hxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_TABSTOP_HXX -#define SW_VBA_TABSTOP_HXX - -#include <ooo/vba/word/XTabStop.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/style/TabStop.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTabStop > SwVbaTabStop_BASE; - -class SwVbaTabStop : public SwVbaTabStop_BASE -{ -private: - css::uno::Reference< css::beans::XPropertySet > mxParaProps; - css::style::TabStop maTabStop; - -public: - SwVbaTabStop( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps, const css::style::TabStop& aTabStop ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaTabStop(); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_TABSTOP_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatabstops.cxx b/sw/source/ui/vba/vbatabstops.cxx deleted file mode 100644 index a8b0abd5cb..0000000000 --- a/sw/source/ui/vba/vbatabstops.cxx +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatabstops.hxx" -#include "vbatabstop.hxx" -#include <com/sun/star/style/TabAlign.hpp> -#include <ooo/vba/word/WdTabLeader.hpp> -#include <ooo/vba/word/WdTabAlignment.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -uno::Sequence< style::TabStop > lcl_getTabStops( const uno::Reference< beans::XPropertySet >& xParaProps ) throw (uno::RuntimeException) -{ - uno::Sequence< style::TabStop > aSeq; - xParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTabStops") ) ) >>= aSeq; - return aSeq; -} - -void lcl_setTabStops( const uno::Reference< beans::XPropertySet >& xParaProps, const uno::Sequence< style::TabStop >& aSeq ) throw (uno::RuntimeException) -{ - xParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTabStops") ), uno::makeAny( aSeq ) ); -} - -typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > TabStopCollectionHelper_Base; - -class TabStopsEnumWrapper : public EnumerationHelper_BASE -{ - uno::Reference< container::XIndexAccess > mxIndexAccess; - sal_Int32 nIndex; - -public: - TabStopsEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : mxIndexAccess( xIndexAccess ), nIndex( 0 ) - { - } - virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) - { - return ( nIndex < mxIndexAccess->getCount() ); - } - - virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) - { - if( nIndex < mxIndexAccess->getCount() ) - { - return mxIndexAccess->getByIndex( nIndex++ ); - } - throw container::NoSuchElementException(); - } -}; - -class TabStopCollectionHelper : public TabStopCollectionHelper_Base -{ -private: - uno::Reference< XHelperInterface > mxParent; - uno::Reference< uno::XComponentContext > mxContext; - uno::Reference< beans::XPropertySet > mxParaProps; - uno::Sequence< style::TabStop > maTabStops; - -public: - TabStopCollectionHelper( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps ) throw ( css::uno::RuntimeException ): mxParent( xParent ), mxContext( xContext ), mxParaProps( xParaProps ) - { - maTabStops = lcl_getTabStops( xParaProps ); - } - - virtual ~TabStopCollectionHelper() {} - - virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) - { - return maTabStops.getLength(); - } - virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) - { - if ( Index < 0 || Index >= getCount() ) - throw css::lang::IndexOutOfBoundsException(); - - const style::TabStop* pTabs = maTabStops.getConstArray(); - return uno::makeAny( uno::Reference< word::XTabStop >( new SwVbaTabStop( mxParent, mxContext, mxParaProps, pTabs[ Index ] ) ) ); - } - virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) - { - return word::XTabStop::static_type(0); - } - virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) - { - return sal_True; - } - // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException) - { - return new TabStopsEnumWrapper( this ); - } -}; - -SwVbaTabStops::SwVbaTabStops( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& xParaProps ) throw (uno::RuntimeException) : SwVbaTabStops_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( new TabStopCollectionHelper( xParent, xContext, xParaProps ) ) ), mxParaProps( xParaProps ) -{ -} - -uno::Reference< word::XTabStop > SAL_CALL SwVbaTabStops::Add( float Position, const uno::Any& Alignment, const uno::Any& Leader ) throw (uno::RuntimeException) -{ - sal_Int32 nPosition = Millimeter::getInHundredthsOfOneMillimeter( Position ); - - style::TabAlign nAlign = style::TabAlign_LEFT; - if( Alignment.hasValue() ) - { - sal_Int32 wdAlign = word::WdTabAlignment::wdAlignTabLeft; - Alignment >>= wdAlign; - switch( wdAlign ) - { - case word::WdTabAlignment::wdAlignTabLeft: - { - nAlign = style::TabAlign_LEFT; - break; - } - case word::WdTabAlignment::wdAlignTabRight: - { - nAlign = style::TabAlign_RIGHT; - break; - } - case word::WdTabAlignment::wdAlignTabCenter: - { - nAlign = style::TabAlign_CENTER; - break; - } - case word::WdTabAlignment::wdAlignTabDecimal: - { - nAlign = style::TabAlign_DECIMAL; - break; - } - case word::WdTabAlignment::wdAlignTabBar: - case word::WdTabAlignment::wdAlignTabList: - { - DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); - break; - } - default: - { - //left - } - } - } - - sal_Char cLeader = ' '; // default is space - if( Leader.hasValue() ) - { - sal_Int32 wdLeader = word::WdTabLeader::wdTabLeaderSpaces; - Leader >>= wdLeader; - switch( wdLeader ) - { - case word::WdTabLeader::wdTabLeaderSpaces: - { - cLeader = ' '; - break; - } - case word::WdTabLeader::wdTabLeaderMiddleDot: - { - cLeader = 183; - break; - } - case word::WdTabLeader::wdTabLeaderDots: - { - cLeader = '.'; - break; - } - case word::WdTabLeader::wdTabLeaderDashes: - case word::WdTabLeader::wdTabLeaderHeavy: - case word::WdTabLeader::wdTabLeaderLines: - { - cLeader = '_'; - break; - } - default: - { - //left - } - } - } - - sal_Char cDecimal = '.'; // default value - - style::TabStop aTab; - aTab.Position = nPosition; - aTab.Alignment = nAlign; - aTab.DecimalChar = cDecimal; - aTab.FillChar = cLeader; - - uno::Sequence< style::TabStop > aOldTabs = lcl_getTabStops( mxParaProps ); - sal_Bool bOverWriter = sal_False; - - sal_Int32 nTabs = aOldTabs.getLength(); - uno::Sequence< style::TabStop > aNewTabs( nTabs + 1 ); - - style::TabStop* pOldTab = aOldTabs.getArray(); - style::TabStop* pNewTab = aNewTabs.getArray(); - pNewTab[0] = aTab; - for( sal_Int32 nIndex = 0; nIndex < nTabs && !bOverWriter; nIndex++ ) - { - if( pOldTab[nIndex].Position == nPosition ) - { - bOverWriter = sal_True; - pOldTab[nIndex] = aTab; - break; - } - pNewTab[ nIndex+1 ] = pOldTab[ nIndex ]; - } - if( bOverWriter ) - lcl_setTabStops( mxParaProps, aOldTabs ); - else - lcl_setTabStops( mxParaProps, aNewTabs ); - - return uno::Reference< word::XTabStop >( new SwVbaTabStop( this, mxContext, mxParaProps, aTab ) ); -} - -void SAL_CALL SwVbaTabStops::ClearAll() throw (uno::RuntimeException) -{ - uno::Sequence< style::TabStop > aSeq; - lcl_setTabStops( mxParaProps, aSeq ); -} - -// XEnumerationAccess -uno::Type -SwVbaTabStops::getElementType() throw (uno::RuntimeException) -{ - return word::XTabStop::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaTabStops::createEnumeration() throw (uno::RuntimeException) -{ - return new TabStopsEnumWrapper( m_xIndexAccess ); -} - -uno::Any -SwVbaTabStops::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -rtl::OUString& -SwVbaTabStops::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTabStops") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaTabStops::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.TabStops") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatabstops.hxx b/sw/source/ui/vba/vbatabstops.hxx deleted file mode 100644 index f5b000131e..0000000000 --- a/sw/source/ui/vba/vbatabstops.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_TABSTOPS_HXX -#define SW_VBA_TABSTOPS_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XTabStops.hpp> -#include <ooo/vba/word/XTabStop.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef CollTestImplHelper< ooo::vba::word::XTabStops > SwVbaTabStops_BASE; - -class SwVbaTabStops : public SwVbaTabStops_BASE -{ -private: - css::uno::Reference< css::beans::XPropertySet > mxParaProps; - -public: - SwVbaTabStops( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& xParaProps ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaTabStops() {} - - // Methods - virtual css::uno::Reference< ::ooo::vba::word::XTabStop > SAL_CALL Add( float Position, const css::uno::Any& Alignment, const css::uno::Any& Leader ) throw (css::uno::RuntimeException); - virtual void SAL_CALL ClearAll( ) throw (css::uno::RuntimeException); - - // XEnumerationAccess - virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException); - virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException); - - // SwVbaTabStops_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif /* SW_VBA_TABSTOPS_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatemplate.cxx b/sw/source/ui/vba/vbatemplate.cxx deleted file mode 100644 index d63e003786..0000000000 --- a/sw/source/ui/vba/vbatemplate.cxx +++ /dev/null @@ -1,148 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbatemplate.hxx" -#include <vbahelper/vbahelper.hxx> -#include "wordvbahelper.hxx" -#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; - -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 ) -{ -} - - -SwVbaTemplate::~SwVbaTemplate() -{ -} - -rtl::OUString -SwVbaTemplate::getName() throw ( css::uno::RuntimeException ) -{ - 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 -SwVbaTemplate::AutoTextEntries( const uno::Any& index ) throw (uno::RuntimeException) -{ - uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); - uno::Reference< text::XAutoTextContainer > xAutoTextContainer( xMgr->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AutoTextContainer") ) ), uno::UNO_QUERY_THROW ); - - // the default template is "Normal.dot" in Word. - rtl::OUString sGroup( RTL_CONSTASCII_USTRINGPARAM("Normal") ); - rtl::OUString sName = getName(); - sal_Int32 nIndex = sName.lastIndexOf( sal_Unicode('.') ); - if( nIndex > 0 ) - { - sGroup = sName.copy( 0, sName.lastIndexOf( sal_Unicode('.') ) ); - } - String sNewGroup = lcl_CheckGroupName( sGroup ); - - uno::Reference< container::XIndexAccess > xGroup; - if( xAutoTextContainer->hasByName( sNewGroup ) ) - { - xGroup.set( xAutoTextContainer->getByName( sNewGroup ), uno::UNO_QUERY_THROW ); - } - else - { - throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Auto Text Entry doesn't exist") ), uno::Reference< uno::XInterface >() ); - } - - uno::Reference< XCollection > xCol( new SwVbaAutoTextEntries( this, mxContext, xGroup ) ); - if( index.hasValue() ) - return xCol->Item( index, uno::Any() ); - return uno::makeAny( xCol ); -} - -rtl::OUString& -SwVbaTemplate::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaTemplate") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaTemplate::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Template" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbatemplate.hxx b/sw/source/ui/vba/vbatemplate.hxx deleted file mode 100644 index 2bfe75d2d3..0000000000 --- a/sw/source/ui/vba/vbatemplate.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_TEMPLATE_HXX -#define SW_VBA_TEMPLATE_HXX - -#include <ooo/vba/word/XTemplate.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XTemplate > SwVbaTemplate_BASE; - -class SwVbaTemplate : public SwVbaTemplate_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - 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& ); - virtual ~SwVbaTemplate(); - - // 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(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_TEMPLATE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbavariable.cxx b/sw/source/ui/vba/vbavariable.cxx deleted file mode 100644 index e10d873bdb..0000000000 --- a/sw/source/ui/vba/vbavariable.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbavariable.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -SwVbaVariable::SwVbaVariable( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, - const uno::Reference< beans::XPropertyAccess >& rUserDefined, const rtl::OUString& rName ) throw ( uno::RuntimeException ) : - SwVbaVariable_BASE( rParent, rContext ), mxUserDefined( rUserDefined ), maName( rName ) -{ -} - -SwVbaVariable::~SwVbaVariable() -{ -} - -rtl::OUString SAL_CALL -SwVbaVariable::getName() throw ( css::uno::RuntimeException ) -{ - return maName; -} - -void SAL_CALL -SwVbaVariable::setName( const rtl::OUString& ) throw ( css::uno::RuntimeException ) -{ - throw uno::RuntimeException( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM(" Fail to set name")), uno::Reference< uno::XInterface >() ); -} - -uno::Any SAL_CALL -SwVbaVariable::getValue() throw ( css::uno::RuntimeException ) -{ - uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW ); - return xProp->getPropertyValue( maName ); -} - -void SAL_CALL -SwVbaVariable::setValue( const uno::Any& rValue ) throw ( css::uno::RuntimeException ) -{ - // FIXME: fail to set the value if the new type of vaue is differenct from the original one. - uno::Reference< beans::XPropertySet > xProp( mxUserDefined, uno::UNO_QUERY_THROW ); - xProp->setPropertyValue( maName, rValue ); -} - -sal_Int32 SAL_CALL -SwVbaVariable::getIndex() throw ( css::uno::RuntimeException ) -{ - const uno::Sequence< beans::PropertyValue > props = mxUserDefined->getPropertyValues(); - for (sal_Int32 i = 0; i < props.getLength(); ++i) - { - if( maName.equals( props[i].Name ) ) - return i+1; - } - - return 0; -} - -rtl::OUString& -SwVbaVariable::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaVariable") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaVariable::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Variable" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbavariable.hxx b/sw/source/ui/vba/vbavariable.hxx deleted file mode 100644 index f701c66a3a..0000000000 --- a/sw/source/ui/vba/vbavariable.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_VARIABLE_HXX -#define SW_VBA_VARIABLE_HXX - -#include <ooo/vba/word/XVariable.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <cppuhelper/implbase1.hxx> -#include <com/sun/star/beans/XPropertyAccess.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XVariable > SwVbaVariable_BASE; - -class SwVbaVariable : public SwVbaVariable_BASE -{ -private: - css::uno::Reference< css::beans::XPropertyAccess > mxUserDefined; - rtl::OUString maName; - -public: - SwVbaVariable( const css::uno::Reference< ooo::vba::XHelperInterface >& rParent, const css::uno::Reference< css::uno::XComponentContext >& rContext, - const css::uno::Reference< css::beans::XPropertyAccess >& rUserDefined, const rtl::OUString& rName ) throw ( css::uno::RuntimeException ); - virtual ~SwVbaVariable(); - - // XVariable - virtual rtl::OUString SAL_CALL getName() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL setName( const rtl::OUString& ) throw ( css::uno::RuntimeException ); - virtual css::uno::Any SAL_CALL getValue() throw ( css::uno::RuntimeException ); - virtual void SAL_CALL setValue( const css::uno::Any& rValue ) throw ( css::uno::RuntimeException ); - virtual sal_Int32 SAL_CALL getIndex() throw ( css::uno::RuntimeException ); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_VARIABLE_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbavariables.cxx b/sw/source/ui/vba/vbavariables.cxx deleted file mode 100644 index c6a4ef2edc..0000000000 --- a/sw/source/ui/vba/vbavariables.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbavariables.hxx" -#include "vbavariable.hxx" -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -uno::Reference< container::XIndexAccess > createVariablesAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertyAccess >& xUserDefined ) throw ( uno::RuntimeException ) -{ - // FIXME: the performance is poor? - XNamedObjectCollectionHelper< word::XVariable >::XNamedVec mVariables; - const uno::Sequence< beans::PropertyValue > props = xUserDefined->getPropertyValues(); - sal_Int32 nCount = props.getLength(); - mVariables.reserve( nCount ); - for( sal_Int32 i=0; i < nCount; i++ ) - mVariables.push_back( uno::Reference< word::XVariable > ( new SwVbaVariable( xParent, xContext, xUserDefined, props[i].Name ) ) ); - - uno::Reference< container::XIndexAccess > xVariables( new XNamedObjectCollectionHelper< word::XVariable >( mVariables ) ); - return xVariables; -} - -SwVbaVariables::SwVbaVariables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertyAccess >& rUserDefined ): SwVbaVariables_BASE( xParent, xContext, createVariablesAccess( xParent, xContext, rUserDefined ) ), mxUserDefined( rUserDefined ) -{ -} -// XEnumerationAccess -uno::Type -SwVbaVariables::getElementType() throw (uno::RuntimeException) -{ - return word::XVariable::static_type(0); -} -uno::Reference< container::XEnumeration > -SwVbaVariables::createEnumeration() throw (uno::RuntimeException) -{ - uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return xEnumerationAccess->createEnumeration(); -} - -uno::Any -SwVbaVariables::createCollectionObject( const css::uno::Any& aSource ) -{ - return aSource; -} - -uno::Any SAL_CALL -SwVbaVariables::Add( const rtl::OUString& rName, const uno::Any& rValue ) throw (uno::RuntimeException) -{ - uno::Any aValue; - if( rValue.hasValue() ) - aValue = rValue; - else - aValue <<= rtl::OUString(); - uno::Reference< beans::XPropertyContainer > xPropertyContainer( mxUserDefined, uno::UNO_QUERY_THROW ); - xPropertyContainer->addProperty( rName, beans::PropertyAttribute::MAYBEVOID | beans::PropertyAttribute::REMOVEABLE, aValue ); - - return uno::makeAny( uno::Reference< word::XVariable >( new SwVbaVariable( getParent(), mxContext, mxUserDefined, rName ) ) ); -} - -rtl::OUString& -SwVbaVariables::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaVariables") ); - return sImplName; -} - -css::uno::Sequence<rtl::OUString> -SwVbaVariables::getServiceNames() -{ - static uno::Sequence< rtl::OUString > sNames; - if ( sNames.getLength() == 0 ) - { - sNames.realloc( 1 ); - sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Variables") ); - } - return sNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbavariables.hxx b/sw/source/ui/vba/vbavariables.hxx deleted file mode 100644 index 5b562b776f..0000000000 --- a/sw/source/ui/vba/vbavariables.hxx +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_VARIABLES_HXX -#define SW_VBA_VARIABLES_HXX - -#include <vbahelper/vbacollectionimpl.hxx> -#include <ooo/vba/word/XVariables.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/beans/XPropertyAccess.hpp> - -typedef CollTestImplHelper< ooo::vba::word::XVariables > SwVbaVariables_BASE; - -class SwVbaVariables : public SwVbaVariables_BASE -{ -private: - css::uno::Reference< css::beans::XPropertyAccess > mxUserDefined; - -public: - SwVbaVariables( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertyAccess >& rUserDefined ); - virtual ~SwVbaVariables() {} - - // 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); - - // SwVbaVariables_BASE - virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ); - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); - - // XVariables - virtual css::uno::Any SAL_CALL Add( const rtl::OUString& rName, const css::uno::Any& rValue ) throw (css::uno::RuntimeException); -}; - -#endif /* SW_VBA_VARIABLES_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaview.cxx b/sw/source/ui/vba/vbaview.cxx deleted file mode 100644 index 7ce8f8818e..0000000000 --- a/sw/source/ui/vba/vbaview.cxx +++ /dev/null @@ -1,401 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbaview.hxx" -#include <vbahelper/vbahelper.hxx> -#include <tools/diagnose_ex.h> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/view/XViewSettingsSupplier.hpp> -#include <com/sun/star/text/XTextViewCursorSupplier.hpp> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/text/XTextTable.hpp> -#include <com/sun/star/table/XCellRange.hpp> -#include <com/sun/star/text/XTextDocument.hpp> -#include <com/sun/star/text/XFootnotesSupplier.hpp> -#include <com/sun/star/text/XEndnotesSupplier.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/frame/XController.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <ooo/vba/word/WdSpecialPane.hpp> -#include <ooo/vba/word/WdViewType.hpp> -#include <ooo/vba/word/WdSeekView.hpp> - -#include "wordvbahelper.hxx" -#include "vbaheaderfooterhelper.hxx" -#include <view.hxx> - -using namespace ::ooo::vba; -using namespace ::com::sun::star; - -static const sal_Int32 DEFAULT_BODY_DISTANCE = 500; - -SwVbaView::SwVbaView( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, - const uno::Reference< frame::XModel >& rModel ) throw ( uno::RuntimeException ) : - SwVbaView_BASE( rParent, rContext ), mxModel( rModel ) -{ - uno::Reference< frame::XController > xController = mxModel->getCurrentController(); - - uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp( xController, uno::UNO_QUERY_THROW ); - mxViewCursor = xTextViewCursorSupp->getViewCursor(); - - uno::Reference< view::XViewSettingsSupplier > xViewSettingSupp( xController, uno::UNO_QUERY_THROW ); - mxViewSettings.set( xViewSettingSupp->getViewSettings(), uno::UNO_QUERY_THROW ); -} - -SwVbaView::~SwVbaView() -{ -} - -::sal_Int32 SAL_CALL -SwVbaView::getSeekView() throw (css::uno::RuntimeException) -{ - // FIXME: if the view cursor is in table, field, section and frame - // handle if the cursor is in table - uno::Reference< text::XText > xCurrentText = mxViewCursor->getText(); - uno::Reference< beans::XPropertySet > xCursorProps( mxViewCursor, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextContent > xTextContent; - while( xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextTable") ) ) >>= xTextContent ) - { - xCurrentText = xTextContent->getAnchor()->getText(); - xCursorProps.set( xCurrentText->createTextCursor(), uno::UNO_QUERY_THROW ); - } - uno::Reference< lang::XServiceInfo > xServiceInfo( xCurrentText, uno::UNO_QUERY_THROW ); - rtl::OUString aImplName = xServiceInfo->getImplementationName(); - if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXBodyText")) ) - { - return word::WdSeekView::wdSeekMainDocument; - } - else if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXHeadFootText")) ) - { - if( HeaderFooterHelper::isHeader( mxModel ) ) - { - if( HeaderFooterHelper::isFirstPageHeader( mxModel ) ) - return word::WdSeekView::wdSeekFirstPageHeader; - else if( HeaderFooterHelper::isEvenPagesHeader( mxModel ) ) - return word::WdSeekView::wdSeekEvenPagesHeader; - else - return word::WdSeekView::wdSeekPrimaryHeader; - } - else - { - if( HeaderFooterHelper::isFirstPageFooter( mxModel ) ) - return word::WdSeekView::wdSeekFirstPageFooter; - else if( HeaderFooterHelper::isEvenPagesFooter( mxModel ) ) - return word::WdSeekView::wdSeekEvenPagesFooter; - else - return word::WdSeekView::wdSeekPrimaryFooter; - } - } - else if( aImplName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SwXFootnote")) ) - { - if( xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote") ) ) ) - return word::WdSeekView::wdSeekEndnotes; - else - return word::WdSeekView::wdSeekFootnotes; - } - - return word::WdSeekView::wdSeekMainDocument; -} - -void SAL_CALL -SwVbaView::setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeException) -{ - // FIXME: save the current cursor position, if the cursor is in the main - // document, so we can jump back to this position, if the macro sets - // the ViewMode back to wdSeekMainDocument - - word::gotoSelectedObjectAnchor( mxModel ); - switch( _seekview ) - { - case word::WdSeekView::wdSeekFirstPageFooter: - case word::WdSeekView::wdSeekFirstPageHeader: - case word::WdSeekView::wdSeekCurrentPageFooter: - case word::WdSeekView::wdSeekCurrentPageHeader: - case word::WdSeekView::wdSeekPrimaryFooter: - case word::WdSeekView::wdSeekPrimaryHeader: - case word::WdSeekView::wdSeekEvenPagesFooter: - case word::WdSeekView::wdSeekEvenPagesHeader: - { - // need to test - mxViewCursor->gotoRange( getHFTextRange( _seekview ), sal_False ); - break; - } - case word::WdSeekView::wdSeekFootnotes: - { - uno::Reference< text::XFootnotesSupplier > xFootnotesSupp( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xFootnotes( xFootnotesSupp->getFootnotes(), uno::UNO_QUERY_THROW ); - if( xFootnotes->getCount() > 0 ) - { - uno::Reference< text::XText > xText( xFootnotes->getByIndex(0), uno::UNO_QUERY_THROW ); - mxViewCursor->gotoRange( xText->getStart(), sal_False ); - } - else - { - DebugHelper::exception( SbERR_NO_ACTIVE_OBJECT, rtl::OUString() ); - } - break; - } - case word::WdSeekView::wdSeekEndnotes: - { - uno::Reference< text::XEndnotesSupplier > xEndnotesSupp( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< container::XIndexAccess > xEndnotes( xEndnotesSupp->getEndnotes(), uno::UNO_QUERY_THROW ); - if( xEndnotes->getCount() > 0 ) - { - uno::Reference< text::XText > xText( xEndnotes->getByIndex(0), uno::UNO_QUERY_THROW ); - mxViewCursor->gotoRange( xText->getStart(), sal_False ); - } - else - { - DebugHelper::exception( SbERR_NO_ACTIVE_OBJECT, rtl::OUString() ); - } - break; - } - case word::WdSeekView::wdSeekMainDocument: - { - uno::Reference< text::XTextDocument > xTextDocument( mxModel, uno::UNO_QUERY_THROW ); - uno::Reference< text::XText > xText = xTextDocument->getText(); - mxViewCursor->gotoRange( word::getFirstObjectPosition( xText ), sal_False ); - break; - } - } -} - -::sal_Int32 SAL_CALL -SwVbaView::getSplitSpecial() throw (css::uno::RuntimeException) -{ - return word::WdSpecialPane::wdPaneNone; -} - -void SAL_CALL -SwVbaView::setSplitSpecial( ::sal_Int32/* _splitspecial */) throw (css::uno::RuntimeException) -{ - // not support in Writer -} - -::sal_Bool SAL_CALL -SwVbaView::getTableGridLines() throw (css::uno::RuntimeException) -{ - sal_Bool bShowTableGridLine = sal_False; - mxViewSettings->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowTableBoundaries"))) >>= bShowTableGridLine; - return bShowTableGridLine; -} - -void SAL_CALL -SwVbaView::setTableGridLines( ::sal_Bool _tablegridlines ) throw (css::uno::RuntimeException) -{ - mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowTableBoundaries")), uno::makeAny( _tablegridlines ) ); -} - -::sal_Int32 SAL_CALL -SwVbaView::getType() throw (css::uno::RuntimeException) -{ - // FIXME: handle wdPrintPreview type - sal_Bool bOnlineLayout = sal_False; - mxViewSettings->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout"))) >>= bOnlineLayout; - return bOnlineLayout ? word::WdViewType::wdWebView : word::WdViewType::wdPrintView; -} - -void SAL_CALL -SwVbaView::setType( ::sal_Int32 _type ) throw (css::uno::RuntimeException) -{ - // FIXME: handle wdPrintPreview type - switch( _type ) - { - case word::WdViewType::wdPrintView: - case word::WdViewType::wdNormalView: - { - mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout")), uno::makeAny( sal_False ) ); - break; - } - case word::WdViewType::wdWebView: - { - mxViewSettings->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ShowOnlineLayout")), uno::makeAny( sal_True ) ); - break; - } - case word::WdViewType::wdPrintPreview: - { - PrintPreviewHelper( uno::Any(),word::getView( mxModel ) ); - break; - } - default: - DebugHelper::exception( SbERR_NOT_IMPLEMENTED, rtl::OUString() ); - - } -} - -uno::Reference< text::XTextRange > SwVbaView::getHFTextRange( sal_Int32 nType ) throw (uno::RuntimeException) -{ - mxModel->lockControllers(); - - rtl::OUString aPropIsOn; - rtl::OUString aPropIsShared; - rtl::OUString aPropBodyDistance; - rtl::OUString aPropText; - - switch( nType ) - { - case word::WdSeekView::wdSeekCurrentPageFooter: - case word::WdSeekView::wdSeekFirstPageFooter: - case word::WdSeekView::wdSeekPrimaryFooter: - case word::WdSeekView::wdSeekEvenPagesFooter: - { - aPropIsOn = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsOn") ); - aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterIsShared") ); - aPropBodyDistance = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterBodyDistance") ); - aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FooterText") ); - break; - } - case word::WdSeekView::wdSeekCurrentPageHeader: - case word::WdSeekView::wdSeekFirstPageHeader: - case word::WdSeekView::wdSeekPrimaryHeader: - case word::WdSeekView::wdSeekEvenPagesHeader: - { - aPropIsOn = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsOn") ); - aPropIsShared = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderIsShared") ); - aPropBodyDistance = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderBodyDistance") ); - aPropText = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HeaderText") ); - break; - } - } - - uno::Reference< text::XPageCursor > xPageCursor( mxViewCursor, uno::UNO_QUERY_THROW ); - - if( nType == word::WdSeekView::wdSeekFirstPageFooter - || nType == word::WdSeekView::wdSeekFirstPageHeader ) - { - xPageCursor->jumpToFirstPage(); - } - - uno::Reference< style::XStyle > xStyle; - uno::Reference< text::XText > xText; - switch( nType ) - { - case word::WdSeekView::wdSeekPrimaryFooter: - case word::WdSeekView::wdSeekPrimaryHeader: - case word::WdSeekView::wdSeekEvenPagesFooter: - case word::WdSeekView::wdSeekEvenPagesHeader: - { - // The primary header is the first header of the section. - // If the header is not shared between odd and even pages - // the odd page's header is the primary header. If the - // first page's header is different from the rest of the - // document, it is NOT the primary header ( the next primary - // header would be on page 3 ) - // The even pages' header is only available if the header is - // not shared and the current style is applied to a page with - // an even page number - uno::Reference< beans::XPropertySet > xCursorProps( mxViewCursor, uno::UNO_QUERY_THROW ); - rtl::OUString aPageStyleName; - xCursorProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyleName"))) >>= aPageStyleName; - if( aPageStyleName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("First Page")) ) - { - // go to the beginning of where the next style is used - sal_Bool hasNextPage = sal_False; - xStyle = word::getCurrentPageStyle( mxModel ); - do - { - hasNextPage = xPageCursor->jumpToNextPage(); - } - while( hasNextPage && ( xStyle == word::getCurrentPageStyle( mxModel ) ) ); - - if( !hasNextPage ) - DebugHelper::exception( SbERR_BAD_ACTION, rtl::OUString() ); - } - break; - } - default: - { - break; - } - } - - xStyle = word::getCurrentPageStyle( mxModel ); - uno::Reference< beans::XPropertySet > xPageProps( xStyle, uno::UNO_QUERY_THROW ); - sal_Bool isOn = sal_False; - xPageProps->getPropertyValue( aPropIsOn ) >>= isOn; - sal_Bool isShared = sal_False; - xPageProps->getPropertyValue( aPropIsShared ) >>= isShared; - if( !isOn ) - { - xPageProps->setPropertyValue( aPropIsOn, uno::makeAny( sal_True ) ); - xPageProps->setPropertyValue( aPropBodyDistance, uno::makeAny( DEFAULT_BODY_DISTANCE ) ); - } - if( !isShared ) - { - rtl::OUString aTempPropText = aPropText; - if( nType == word::WdSeekView::wdSeekEvenPagesFooter - || nType == word::WdSeekView::wdSeekEvenPagesHeader ) - { - aTempPropText += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Left") ); - } - else - { - aTempPropText += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Right") ); - } - xText.set( xPageProps->getPropertyValue( aTempPropText), uno::UNO_QUERY_THROW ); - } - else - { - if( nType == word::WdSeekView::wdSeekEvenPagesFooter - || nType == word::WdSeekView::wdSeekEvenPagesHeader ) - { - DebugHelper::exception( SbERR_BAD_ACTION, rtl::OUString() ); - } - xText.set( xPageProps->getPropertyValue( aPropText ), uno::UNO_QUERY_THROW ); - } - - mxModel->unlockControllers(); - if( !xText.is() ) - { - DebugHelper::exception( SbERR_INTERNAL_ERROR, rtl::OUString() ); - } - uno::Reference< text::XTextRange > xTextRange = word::getFirstObjectPosition( xText ); - return xTextRange; -} - -rtl::OUString& -SwVbaView::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaView") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaView::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.View" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbaview.hxx b/sw/source/ui/vba/vbaview.hxx deleted file mode 100644 index 8131a8fad6..0000000000 --- a/sw/source/ui/vba/vbaview.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_VIEW_HXX -#define SW_VBA_VIEW_HXX - -#include <ooo/vba/word/XView.hpp> -#include <vbahelper/vbahelperinterface.hxx> -#include <com/sun/star/text/XTextViewCursor.hpp> -#include <com/sun/star/text/XTextRange.hpp> -#include <com/sun/star/text/XText.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XView > SwVbaView_BASE; - -class SwVbaView : public SwVbaView_BASE -{ -private: - css::uno::Reference< css::frame::XModel > mxModel; - css::uno::Reference< css::text::XTextViewCursor > mxViewCursor; - css::uno::Reference< css::beans::XPropertySet > mxViewSettings; - - css::uno::Reference< css::text::XTextRange > getHFTextRange( sal_Int32 nType ) throw (css::uno::RuntimeException); - css::uno::Reference< css::text::XTextRange > getFirstObjectPosition( const css::uno::Reference< css::text::XText >& xText ) throw (css::uno::RuntimeException); - -public: - SwVbaView( 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 ); - virtual ~SwVbaView(); - - // XView - virtual ::sal_Int32 SAL_CALL getSeekView() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSeekView( ::sal_Int32 _seekview ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getSplitSpecial() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSplitSpecial( ::sal_Int32 _splitspecial ) throw (css::uno::RuntimeException); - virtual ::sal_Bool SAL_CALL getTableGridLines() throw (css::uno::RuntimeException); - virtual void SAL_CALL setTableGridLines( ::sal_Bool _tablegridlines ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException); - virtual void SAL_CALL setType( ::sal_Int32 _type ) throw (css::uno::RuntimeException); - - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; -#endif /* SW_VBA_VIEW_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbawindow.cxx b/sw/source/ui/vba/vbawindow.cxx deleted file mode 100644 index 43cf4764d2..0000000000 --- a/sw/source/ui/vba/vbawindow.cxx +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <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> - -using namespace ::com::sun::star; -using namespace ::ooo::vba; - -SwVbaWindow::SwVbaWindow( - const uno::Reference< XHelperInterface >& xParent, - const uno::Reference< uno::XComponentContext >& xContext, - const uno::Reference< frame::XModel >& xModel, - const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : - WindowImpl_BASE( xParent, xContext, xModel, xController ) -{ -} - -void -SwVbaWindow::Activate() throw (css::uno::RuntimeException) -{ - SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); - - document.Activate(); -} - -void -SwVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& RouteDocument ) throw (uno::RuntimeException) -{ - // FIXME: it is incorrect when there are more than 1 windows - SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); - uno::Any FileName; - document.Close(SaveChanges, FileName, RouteDocument ); -} - -uno::Any SAL_CALL -SwVbaWindow::getView() throw (uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this, mxContext, m_xModel ) ) ); -} - -void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeException) -{ - sal_Int32 nType = 0; - if( _view >>= nType ) - { - SwVbaView view( this, mxContext, m_xModel ); - view.setType( nType ); - } -} - -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 ) ); - if( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) - return uno::makeAny( xPanes ); - - return uno::Any( xPanes->Item( aIndex, uno::Any() ) ); -} - -uno::Any SAL_CALL -SwVbaWindow::ActivePane() throw (uno::RuntimeException) -{ - return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( this, mxContext, m_xModel ) ) ); -} - -rtl::OUString& -SwVbaWindow::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaWindow") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaWindow::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Window" ) ); - } - return aServiceNames; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbawindow.hxx b/sw/source/ui/vba/vbawindow.hxx deleted file mode 100644 index f69fa3803d..0000000000 --- a/sw/source/ui/vba/vbawindow.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_WINDOW_HXX -#define SW_VBA_WINDOW_HXX -#include <cppuhelper/implbase1.hxx> -#include <ooo/vba/word/XWindow.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> - -#include <vbahelper/vbahelperinterface.hxx> -#include <vbahelper/vbawindowbase.hxx> - -typedef cppu::ImplInheritanceHelper1< VbaWindowBase, ov::word::XWindow > WindowImpl_BASE; - -class SwVbaWindow : public WindowImpl_BASE -{ -public: - SwVbaWindow( - 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::frame::XController >& xController ) - throw (css::uno::RuntimeException); - - // 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); - virtual css::uno::Any SAL_CALL Panes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL ActivePane() throw (css::uno::RuntimeException); - // XHelperInterface - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif //SW_VBA_WINDOW_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbawrapformat.cxx b/sw/source/ui/vba/vbawrapformat.cxx deleted file mode 100644 index a6c2e7c43a..0000000000 --- a/sw/source/ui/vba/vbawrapformat.cxx +++ /dev/null @@ -1,254 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "vbawrapformat.hxx" -#include <ooo/vba/word/WdWrapSideType.hpp> -#include <ooo/vba/word/WdWrapType.hpp> -#include <com/sun/star/text/WrapTextMode.hpp> -#include <vbahelper/vbahelper.hxx> -#include <vbahelper/helperdecl.hxx> - -using namespace ooo::vba; -using namespace com::sun::star; - -SwVbaWrapFormat::SwVbaWrapFormat( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& xContext ) : SwVbaWrapFormat_BASE( getXSomethingFromArgs< XHelperInterface >( aArgs, 0 ), xContext ), m_xShape( getXSomethingFromArgs< drawing::XShape >( aArgs, 1, false ) ), mnWrapFormatType( 0 ), mnSide( word::WdWrapSideType::wdWrapBoth ) -{ - m_xPropertySet.set( m_xShape, uno::UNO_QUERY_THROW ); -} - -void SwVbaWrapFormat::makeWrap() throw (uno::RuntimeException) -{ - text::WrapTextMode eTextMode = text::WrapTextMode_NONE; - if( mnSide == word::WdWrapSideType::wdWrapLeft ) - { - eTextMode = text::WrapTextMode_LEFT; - } - else if( mnSide == word::WdWrapSideType::wdWrapRight ) - { - eTextMode = text::WrapTextMode_RIGHT; - } - else if( mnSide == word::WdWrapSideType::wdWrapBoth || - mnSide == word::WdWrapSideType::wdWrapLargest ) - { - switch( mnWrapFormatType ) - { - case word::WdWrapType::wdWrapNone: - case word::WdWrapType::wdWrapThrough: - { - eTextMode = text::WrapTextMode_THROUGHT; - break; - } - case word::WdWrapType::wdWrapInline: - case word::WdWrapType::wdWrapTopBottom: - { - eTextMode = text::WrapTextMode_NONE; - break; - } - case word::WdWrapType::wdWrapSquare: - { - eTextMode = text::WrapTextMode_PARALLEL; - m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SurroundContour") ), uno::makeAny( sal_False ) ); - break; - } - case word::WdWrapType::wdWrapTight: - { - eTextMode = text::WrapTextMode_PARALLEL; - m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SurroundContour") ), uno::makeAny( sal_True ) ); - break; - } - default: - { - DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString()); - } - } - } - m_xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextWrap") ), uno::makeAny( eTextMode ) ); -} - -::sal_Int32 SAL_CALL SwVbaWrapFormat::getType() throw (uno::RuntimeException) -{ - sal_Int32 nType = word::WdWrapType::wdWrapSquare; - text::WrapTextMode eTextMode; - m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextWrap") )) >>= eTextMode; - switch( eTextMode ) - { - case text::WrapTextMode_NONE: - { - nType = word::WdWrapType::wdWrapTopBottom; - break; - } - case text::WrapTextMode_THROUGHT: - { - nType = word::WdWrapType::wdWrapNone; - break; - } - case text::WrapTextMode_PARALLEL: - { - sal_Bool bContour = sal_False; - m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SurroundContour") )) >>= bContour; - if( bContour ) - nType = word::WdWrapType::wdWrapTight; - else - nType = word::WdWrapType::wdWrapSquare; - break; - } - case text::WrapTextMode_DYNAMIC: - case text::WrapTextMode_LEFT: - case text::WrapTextMode_RIGHT: - { - nType = word::WdWrapType::wdWrapThrough; - break; - } - default: - { - nType = word::WdWrapType::wdWrapSquare; - } - } - return nType; -} - -void SAL_CALL SwVbaWrapFormat::setType( ::sal_Int32 _type ) throw (uno::RuntimeException) -{ - mnWrapFormatType = _type; - makeWrap(); -} - -::sal_Int32 SAL_CALL SwVbaWrapFormat::getSide() throw (uno::RuntimeException) -{ - sal_Int32 nSide = word::WdWrapSideType::wdWrapBoth; - text::WrapTextMode eTextMode; - m_xPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextWrap") )) >>= eTextMode; - switch( eTextMode ) - { - case text::WrapTextMode_LEFT: - { - nSide = word::WdWrapSideType::wdWrapLeft; - break; - } - case text::WrapTextMode_RIGHT: - { - nSide = word::WdWrapSideType::wdWrapRight; - break; - } - default: - { - nSide = word::WdWrapSideType::wdWrapBoth; - } - } - return nSide; -} - -void SAL_CALL SwVbaWrapFormat::setSide( ::sal_Int32 _side ) throw (uno::RuntimeException) -{ - mnSide = _side; - makeWrap(); -} - -float SwVbaWrapFormat::getDistance( const rtl::OUString& sName ) throw (uno::RuntimeException) -{ - sal_Int32 nDistance = 0; - m_xPropertySet->getPropertyValue( sName ) >>= nDistance; - return static_cast< float >( Millimeter::getInPoints( nDistance ) ); -} - -void SwVbaWrapFormat::setDistance( const rtl::OUString& sName, float _distance ) throw (uno::RuntimeException) -{ - sal_Int32 nDistance = Millimeter::getInHundredthsOfOneMillimeter( _distance ); - m_xPropertySet->setPropertyValue( sName, uno::makeAny( nDistance ) ); -} - -float SAL_CALL SwVbaWrapFormat::getDistanceTop() throw (uno::RuntimeException) -{ - return getDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin") ) ); -} - -void SAL_CALL SwVbaWrapFormat::setDistanceTop( float _distancetop ) throw (uno::RuntimeException) -{ - setDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TopMargin") ), _distancetop ); -} - -float SAL_CALL SwVbaWrapFormat::getDistanceBottom() throw (uno::RuntimeException) -{ - return getDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin") ) ); -} - -void SAL_CALL SwVbaWrapFormat::setDistanceBottom( float _distancebottom ) throw (uno::RuntimeException) -{ - setDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BottomMargin") ), _distancebottom ); -} - -float SAL_CALL SwVbaWrapFormat::getDistanceLeft() throw (uno::RuntimeException) -{ - return getDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ) ); -} - -void SAL_CALL SwVbaWrapFormat::setDistanceLeft( float _distanceleft ) throw (uno::RuntimeException) -{ - setDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LeftMargin") ), _distanceleft ); -} - -float SAL_CALL SwVbaWrapFormat::getDistanceRight() throw (uno::RuntimeException) -{ - return getDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin") ) ); -} - -void SAL_CALL SwVbaWrapFormat::setDistanceRight( float _distanceright ) throw (uno::RuntimeException) -{ - setDistance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightMargin") ), _distanceright ); -} - -rtl::OUString& -SwVbaWrapFormat::getServiceImplName() -{ - static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaWrapFormat") ); - return sImplName; -} - -uno::Sequence< rtl::OUString > -SwVbaWrapFormat::getServiceNames() -{ - static uno::Sequence< rtl::OUString > aServiceNames; - if ( aServiceNames.getLength() == 0 ) - { - aServiceNames.realloc( 1 ); - aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.WrapFormat" ) ); - } - return aServiceNames; -} - -namespace wrapformat -{ -namespace sdecl = comphelper::service_decl; -sdecl::vba_service_class_<SwVbaWrapFormat, sdecl::with_args<true> > serviceImpl; -extern sdecl::ServiceDecl const serviceDecl( - serviceImpl, - "SwVbaWrapFormat", - "ooo.vba.word.WrapFormat" ); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/vbawrapformat.hxx b/sw/source/ui/vba/vbawrapformat.hxx deleted file mode 100644 index 024498c8e8..0000000000 --- a/sw/source/ui/vba/vbawrapformat.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_VBA_XWRAPFORMAT_HXX -#define SW_VBA_XWRAPFORMAT_HXX - -#include <com/sun/star/drawing/XShape.hpp> -#include <ooo/vba/word/XWrapFormat.hpp> -#include <vbahelper/vbahelperinterface.hxx> - -typedef InheritedHelperInterfaceImpl1< ooo::vba::word::XWrapFormat > SwVbaWrapFormat_BASE; - -class SwVbaWrapFormat : public SwVbaWrapFormat_BASE -{ -private: - css::uno::Reference< css::drawing::XShape > m_xShape; - css::uno::Reference< css::beans::XPropertySet > m_xPropertySet; - sal_Int32 mnWrapFormatType; - sal_Int32 mnSide; - -private: - void makeWrap() throw (css::uno::RuntimeException); - float getDistance( const rtl::OUString& sName ) throw (css::uno::RuntimeException); - void setDistance( const rtl::OUString& sName, float _distance ) throw (css::uno::RuntimeException); - -public: - SwVbaWrapFormat( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ); - - virtual ::sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException); - virtual void SAL_CALL setType( ::sal_Int32 _type ) throw (css::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getSide() throw (css::uno::RuntimeException); - virtual void SAL_CALL setSide( ::sal_Int32 _side ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getDistanceTop() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDistanceTop( float _distancetop ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getDistanceBottom() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDistanceBottom( float _distancebottom ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getDistanceLeft() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDistanceLeft( float _distanceleft ) throw (css::uno::RuntimeException); - virtual float SAL_CALL getDistanceRight() throw (css::uno::RuntimeException); - virtual void SAL_CALL setDistanceRight( float _distanceright ) throw (css::uno::RuntimeException); - - virtual rtl::OUString& getServiceImplName(); - virtual css::uno::Sequence<rtl::OUString> getServiceNames(); -}; - -#endif//SW_VBA_XWRAPFORMAT_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/wordvbahelper.cxx b/sw/source/ui/vba/wordvbahelper.cxx deleted file mode 100644 index fa1f5092c8..0000000000 --- a/sw/source/ui/vba/wordvbahelper.cxx +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <docsh.hxx> -#include "wordvbahelper.hxx" -#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> -#include <viewsh.hxx> - -using namespace ::com::sun::star; -using namespace ::ooo::vba; - -#define FIRST_PAGE 1; - -namespace ooo -{ -namespace vba -{ -namespace word -{ - -SwDocShell* getDocShell( const uno::Reference< frame::XModel>& xModel ) -{ - uno::Reference< lang::XUnoTunnel > xTunnel( xModel, uno::UNO_QUERY_THROW ); - SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >( sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId()))); - return pXDoc ? pXDoc->GetDocShell() : 0; -} - -SwView* getView( const uno::Reference< frame::XModel>& xModel ) -{ - SwDocShell* pDocShell = getDocShell( xModel ); - return pDocShell? pDocShell->GetView() : 0; -} - -uno::Reference< text::XTextViewCursor > getXTextViewCursor( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) -{ - uno::Reference< frame::XController > xController = xModel->getCurrentController(); - uno::Reference< text::XTextViewCursorSupplier > xTextViewCursorSupp( xController, uno::UNO_QUERY_THROW ); - uno::Reference< text::XTextViewCursor > xTextViewCursor = xTextViewCursorSupp->getViewCursor(); - return xTextViewCursor; -} - -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; - 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 ); - uno::Reference< style::XStyle > xStyle( xPageStyles->getByName( aPageStyleName ), uno::UNO_QUERY_THROW ); - - return xStyle; -} - -sal_Int32 getPageCount( const uno::Reference< frame::XModel>& xModel ) throw (uno::RuntimeException) -{ - SwDocShell* pDocShell = getDocShell( xModel ); - ViewShell* pViewSh = pDocShell ? pDocShell->GetDoc()->GetCurrentViewShell() : 0; - return pViewSh ? pViewSh->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 -} // -} // - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/vba/wordvbahelper.hxx b/sw/source/ui/vba/wordvbahelper.hxx deleted file mode 100644 index becdce534a..0000000000 --- a/sw/source/ui/vba/wordvbahelper.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef SW_WORD_VBA_HELPER_HXX -#define SW_WORD_VBA_HELPER_HXX - -#include <vbahelper/vbahelper.hxx> -#include <com/sun/star/text/XText.hpp> -#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; -namespace ooo -{ - namespace vba - { - namespace word - { - //css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException); - SwDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ); - 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 -} // ooo -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |