1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #include <vbahelper/helperdecl.hxx> 28 #include "vbawindow.hxx" 29 #include "vbaglobals.hxx" 30 #include "vbadocument.hxx" 31 #include "vbaview.hxx" 32 #include "vbapanes.hxx" 33 #include "vbapane.hxx" 34 35 using namespace ::com::sun::star; 36 using namespace ::ooo::vba; 37 38 SwVbaWindow::SwVbaWindow( 39 const uno::Reference< XHelperInterface >& xParent, 40 const uno::Reference< uno::XComponentContext >& xContext, 41 const uno::Reference< frame::XModel >& xModel, 42 const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : 43 WindowImpl_BASE( xParent, xContext, xModel, xController ) 44 { 45 } 46 47 void 48 SwVbaWindow::Activate() throw (css::uno::RuntimeException) 49 { 50 SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); 51 52 document.Activate(); 53 } 54 55 void 56 SwVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& RouteDocument ) throw (uno::RuntimeException) 57 { 58 // FIXME: it is incorrect when there are more than 1 windows 59 SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); 60 uno::Any FileName; 61 document.Close(SaveChanges, FileName, RouteDocument ); 62 } 63 64 uno::Any SAL_CALL 65 SwVbaWindow::getView() throw (uno::RuntimeException) 66 { 67 return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this, mxContext, m_xModel ) ) ); 68 } 69 70 void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeException) 71 { 72 sal_Int32 nType = 0; 73 if( _view >>= nType ) 74 { 75 SwVbaView view( this, mxContext, m_xModel ); 76 view.setType( nType ); 77 } 78 } 79 80 uno::Any SAL_CALL 81 SwVbaWindow::Panes( const uno::Any& aIndex ) throw (uno::RuntimeException) 82 { 83 uno::Reference< XCollection > xPanes( new SwVbaPanes( this, mxContext, m_xModel ) ); 84 if( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) 85 return uno::makeAny( xPanes ); 86 87 return uno::Any( xPanes->Item( aIndex, uno::Any() ) ); 88 } 89 90 uno::Any SAL_CALL 91 SwVbaWindow::ActivePane() throw (uno::RuntimeException) 92 { 93 return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( this, mxContext, m_xModel ) ) ); 94 } 95 96 rtl::OUString& 97 SwVbaWindow::getServiceImplName() 98 { 99 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaWindow") ); 100 return sImplName; 101 } 102 103 uno::Sequence< rtl::OUString > 104 SwVbaWindow::getServiceNames() 105 { 106 static uno::Sequence< rtl::OUString > aServiceNames; 107 if ( aServiceNames.getLength() == 0 ) 108 { 109 aServiceNames.realloc( 1 ); 110 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Window" ) ); 111 } 112 return aServiceNames; 113 } 114