1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <ooo/vba/word/WdWindowState.hpp>
21 #include <sal/log.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <vcl/wrkwin.hxx>
25 #include "vbawindow.hxx"
26 #include "vbadocument.hxx"
27 #include "vbaview.hxx"
28 #include "vbapanes.hxx"
29 #include "vbapane.hxx"
30 #include "wordvbahelper.hxx"
33 using namespace ::com::sun::star
;
34 using namespace ::ooo::vba
;
36 SwVbaWindow::SwVbaWindow(
37 const uno::Reference
< XHelperInterface
>& xParent
,
38 const uno::Reference
< uno::XComponentContext
>& xContext
,
39 const uno::Reference
< frame::XModel
>& xModel
,
40 const uno::Reference
< frame::XController
>& xController
) :
41 WindowImpl_BASE( xParent
, xContext
, xModel
, xController
)
46 SwVbaWindow::Activate()
48 rtl::Reference
<SwVbaDocument
> document( new SwVbaDocument(uno::Reference
< XHelperInterface
>( Application(), uno::UNO_QUERY_THROW
), mxContext
, m_xModel
) );
54 SwVbaWindow::Close( const uno::Any
& SaveChanges
, const uno::Any
& RouteDocument
)
56 // FIXME: it is incorrect when there are more than 1 windows
57 rtl::Reference
<SwVbaDocument
> document( new SwVbaDocument(uno::Reference
< XHelperInterface
>( Application(), uno::UNO_QUERY_THROW
), mxContext
, m_xModel
) );
59 document
->Close(SaveChanges
, FileName
, RouteDocument
);
63 SwVbaWindow::getView()
65 return uno::Any( uno::Reference
< word::XView
>( new SwVbaView( this, mxContext
, m_xModel
) ) );
68 void SAL_CALL
SwVbaWindow::setView( const uno::Any
& _view
)
73 rtl::Reference
<SwVbaView
> view( new SwVbaView(this, mxContext
, m_xModel
) );
74 view
->setType( nType
);
79 SwVbaWindow::getWindowState()
81 sal_Int32 nwindowState
= word::WdWindowState::wdWindowStateNormal
;
82 SwView
* pView
= word::getView( m_xModel
);
83 SfxViewFrame
& rViewFrame
= pView
->GetViewFrame();
84 WorkWindow
* pWork
= static_cast<WorkWindow
*>( rViewFrame
.GetFrame().GetSystemWindow() );
87 if ( pWork
-> IsMaximized())
88 nwindowState
= word::WdWindowState::wdWindowStateMaximize
;
89 else if (pWork
-> IsMinimized())
90 nwindowState
= word::WdWindowState::wdWindowStateMinimize
;
92 return uno::Any( nwindowState
);
96 SwVbaWindow::setWindowState( const uno::Any
& _windowstate
)
98 sal_Int32 nwindowState
= word::WdWindowState::wdWindowStateMaximize
;
99 _windowstate
>>= nwindowState
;
100 SwView
* pView
= word::getView( m_xModel
);
101 SfxViewFrame
& rViewFrame
= pView
->GetViewFrame();
102 WorkWindow
* pWork
= static_cast<WorkWindow
*>( rViewFrame
.GetFrame().GetSystemWindow() );
105 if ( nwindowState
== word::WdWindowState::wdWindowStateMaximize
)
107 else if (nwindowState
== word::WdWindowState::wdWindowStateMinimize
)
109 else if (nwindowState
== word::WdWindowState::wdWindowStateNormal
)
112 SAL_WARN("sw.vba", "Unhandled window state " << nwindowState
);
117 SwVbaWindow::getCaption()
119 SwView
* pView
= word::getView( m_xModel
);
123 uno::Reference
< css::beans::XPropertySet
> xFrameProps( pView
->GetViewFrame().GetFrame().GetFrameInterface()->getController()->getFrame(), uno::UNO_QUERY
);
124 if( !xFrameProps
.is() )
128 xFrameProps
->getPropertyValue( "Title" ) >>= sTitle
;
134 SwVbaWindow::setCaption( const OUString
& _caption
)
136 SwView
* pView
= word::getView( m_xModel
);
140 uno::Reference
< css::beans::XPropertySet
> xFrameProps( pView
->GetViewFrame().GetFrame().GetFrameInterface()->getController()->getFrame(), uno::UNO_QUERY
);
141 if( !xFrameProps
.is() )
144 xFrameProps
->setPropertyValue( "Title", uno::Any( _caption
) );
148 SwVbaWindow::Panes( const uno::Any
& aIndex
)
150 uno::Reference
< XCollection
> xPanes( new SwVbaPanes( this, mxContext
, m_xModel
) );
151 if( aIndex
.getValueTypeClass() == uno::TypeClass_VOID
)
152 return uno::Any( xPanes
);
154 return xPanes
->Item( aIndex
, uno::Any() );
158 SwVbaWindow::ActivePane()
160 return uno::Any( uno::Reference
< word::XPane
>( new SwVbaPane( this, mxContext
, m_xModel
) ) );
164 SwVbaWindow::getServiceImplName()
166 return "SwVbaWindow";
169 uno::Sequence
< OUString
>
170 SwVbaWindow::getServiceNames()
172 static uno::Sequence
< OUString
> const aServiceNames
174 "ooo.vba.word.Window"
176 return aServiceNames
;
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */