1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #include <vbahelper/helperdecl.hxx> 24 #include "vbawindow.hxx" 25 #include "vbaglobals.hxx" 26 #include "vbadocument.hxx" 27 #include "vbaview.hxx" 28 #include "vbapanes.hxx" 29 #include "vbapane.hxx" 30 31 using namespace ::com::sun::star; 32 using namespace ::ooo::vba; 33 34 SwVbaWindow::SwVbaWindow( 35 const uno::Reference< XHelperInterface >& xParent, 36 const uno::Reference< uno::XComponentContext >& xContext, 37 const uno::Reference< frame::XModel >& xModel, 38 const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) : 39 WindowImpl_BASE( xParent, xContext, xModel, xController ) 40 { 41 } 42 43 void 44 SwVbaWindow::Activate() throw (css::uno::RuntimeException) 45 { 46 SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); 47 48 document.Activate(); 49 } 50 51 void 52 SwVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& RouteDocument ) throw (uno::RuntimeException) 53 { 54 // FIXME: it is incorrect when there are more than 1 windows 55 SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel ); 56 uno::Any FileName; 57 document.Close(SaveChanges, FileName, RouteDocument ); 58 } 59 60 uno::Any SAL_CALL 61 SwVbaWindow::getView() throw (uno::RuntimeException) 62 { 63 return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this, mxContext, m_xModel ) ) ); 64 } 65 66 void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeException) 67 { 68 sal_Int32 nType = 0; 69 if( _view >>= nType ) 70 { 71 SwVbaView view( this, mxContext, m_xModel ); 72 view.setType( nType ); 73 } 74 } 75 76 uno::Any SAL_CALL 77 SwVbaWindow::Panes( const uno::Any& aIndex ) throw (uno::RuntimeException) 78 { 79 uno::Reference< XCollection > xPanes( new SwVbaPanes( this, mxContext, m_xModel ) ); 80 if( aIndex.getValueTypeClass() == uno::TypeClass_VOID ) 81 return uno::makeAny( xPanes ); 82 83 return uno::Any( xPanes->Item( aIndex, uno::Any() ) ); 84 } 85 86 uno::Any SAL_CALL 87 SwVbaWindow::ActivePane() throw (uno::RuntimeException) 88 { 89 return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( this, mxContext, m_xModel ) ) ); 90 } 91 92 rtl::OUString& 93 SwVbaWindow::getServiceImplName() 94 { 95 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaWindow") ); 96 return sImplName; 97 } 98 99 uno::Sequence< rtl::OUString > 100 SwVbaWindow::getServiceNames() 101 { 102 static uno::Sequence< rtl::OUString > aServiceNames; 103 if ( aServiceNames.getLength() == 0 ) 104 { 105 aServiceNames.realloc( 1 ); 106 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Window" ) ); 107 } 108 return aServiceNames; 109 } 110