Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #include <vbahelper/helperdecl.hxx>
29 : : #include <ooo/vba/word/WdWindowState.hpp>
30 : : #include <vcl/wrkwin.hxx>
31 : :
32 : : #include "vbawindow.hxx"
33 : : #include "vbaglobals.hxx"
34 : : #include "vbadocument.hxx"
35 : : #include "vbaview.hxx"
36 : : #include "vbapanes.hxx"
37 : : #include "vbapane.hxx"
38 : : #include "wordvbahelper.hxx"
39 : : #include <view.hxx>
40 : :
41 : : using namespace ::com::sun::star;
42 : : using namespace ::ooo::vba;
43 : :
44 : 0 : SwVbaWindow::SwVbaWindow(
45 : : const uno::Reference< XHelperInterface >& xParent,
46 : : const uno::Reference< uno::XComponentContext >& xContext,
47 : : const uno::Reference< frame::XModel >& xModel,
48 : : const uno::Reference< frame::XController >& xController ) throw (uno::RuntimeException) :
49 : 0 : WindowImpl_BASE( xParent, xContext, xModel, xController )
50 : : {
51 : 0 : }
52 : :
53 : : void
54 : 0 : SwVbaWindow::Activate() throw (css::uno::RuntimeException)
55 : : {
56 [ # # ][ # # ]: 0 : SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
[ # # ]
57 : :
58 [ # # ][ # # ]: 0 : document.Activate();
59 : 0 : }
60 : :
61 : : void
62 : 0 : SwVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& RouteDocument ) throw (uno::RuntimeException)
63 : : {
64 : : // FIXME: it is incorrect when there are more than 1 windows
65 [ # # ][ # # ]: 0 : SwVbaDocument document( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
[ # # ]
66 : 0 : uno::Any FileName;
67 [ # # ][ # # ]: 0 : document.Close(SaveChanges, FileName, RouteDocument );
68 : 0 : }
69 : :
70 : : uno::Any SAL_CALL
71 : 0 : SwVbaWindow::getView() throw (uno::RuntimeException)
72 : : {
73 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XView >( new SwVbaView( this, mxContext, m_xModel ) ) );
[ # # ][ # # ]
74 : : }
75 : :
76 : 0 : void SAL_CALL SwVbaWindow::setView( const uno::Any& _view ) throw (uno::RuntimeException)
77 : : {
78 : 0 : sal_Int32 nType = 0;
79 [ # # ]: 0 : if( _view >>= nType )
80 : : {
81 [ # # ][ # # ]: 0 : SwVbaView view( this, mxContext, m_xModel );
82 [ # # ][ # # ]: 0 : view.setType( nType );
83 : : }
84 : 0 : }
85 : :
86 : : uno::Any SAL_CALL
87 : 0 : SwVbaWindow::getWindowState() throw (uno::RuntimeException)
88 : : {
89 : 0 : sal_Int32 nwindowState = word::WdWindowState::wdWindowStateNormal;
90 [ # # ]: 0 : SwView* pView = word::getView( m_xModel );
91 : 0 : SfxViewFrame* pViewFrame = pView -> GetViewFrame();
92 [ # # ][ # # ]: 0 : WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
93 [ # # ]: 0 : if ( pWork )
94 : : {
95 [ # # ][ # # ]: 0 : if ( pWork -> IsMaximized())
96 : 0 : nwindowState = word::WdWindowState::wdWindowStateMaximize;
97 [ # # ][ # # ]: 0 : else if (pWork -> IsMinimized())
98 : 0 : nwindowState = word::WdWindowState::wdWindowStateMinimize;
99 : : }
100 [ # # ]: 0 : return uno::makeAny( nwindowState );
101 : : }
102 : :
103 : : void SAL_CALL
104 : 0 : SwVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeException)
105 : : {
106 : 0 : sal_Int32 nwindowState = word::WdWindowState::wdWindowStateMaximize;
107 : 0 : _windowstate >>= nwindowState;
108 [ # # ]: 0 : SwView* pView = word::getView( m_xModel );
109 : 0 : SfxViewFrame* pViewFrame = pView -> GetViewFrame();
110 [ # # ][ # # ]: 0 : WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
111 [ # # ]: 0 : if ( pWork )
112 : : {
113 [ # # ]: 0 : if ( nwindowState == word::WdWindowState::wdWindowStateMaximize )
114 [ # # ]: 0 : pWork -> Maximize();
115 [ # # ]: 0 : else if (nwindowState == word::WdWindowState::wdWindowStateMinimize)
116 [ # # ]: 0 : pWork -> Minimize();
117 [ # # ]: 0 : else if (nwindowState == word::WdWindowState::wdWindowStateNormal)
118 [ # # ]: 0 : pWork -> Restore();
119 : : else
120 [ # # ][ # # ]: 0 : throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
121 : : }
122 : 0 : }
123 : :
124 : : uno::Any SAL_CALL
125 : 0 : SwVbaWindow::Panes( const uno::Any& aIndex ) throw (uno::RuntimeException)
126 : : {
127 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xPanes( new SwVbaPanes( this, mxContext, m_xModel ) );
[ # # ][ # # ]
128 [ # # ]: 0 : if( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
129 [ # # ]: 0 : return uno::makeAny( xPanes );
130 : :
131 [ # # ][ # # ]: 0 : return uno::Any( xPanes->Item( aIndex, uno::Any() ) );
132 : : }
133 : :
134 : : uno::Any SAL_CALL
135 : 0 : SwVbaWindow::ActivePane() throw (uno::RuntimeException)
136 : : {
137 [ # # ][ # # ]: 0 : return uno::makeAny( uno::Reference< word::XPane >( new SwVbaPane( this, mxContext, m_xModel ) ) );
[ # # ][ # # ]
138 : : }
139 : :
140 : : rtl::OUString
141 : 0 : SwVbaWindow::getServiceImplName()
142 : : {
143 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SwVbaWindow"));
144 : : }
145 : :
146 : : uno::Sequence< rtl::OUString >
147 : 0 : SwVbaWindow::getServiceNames()
148 : : {
149 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
150 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
151 : : {
152 : 0 : aServiceNames.realloc( 1 );
153 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.Window" ) );
154 : : }
155 : 0 : return aServiceNames;
156 : : }
157 : :
158 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|