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 <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
21 #include <com/sun/star/embed/EmbedStates.hpp>
22 #include <com/sun/star/embed/EmbedVerbs.hpp>
23 #include <com/sun/star/embed/EmbedUpdateModes.hpp>
24 #include <com/sun/star/embed/XEmbeddedClient.hpp>
25 #include <com/sun/star/embed/XInplaceClient.hpp>
26 #include <com/sun/star/embed/XWindowSupplier.hpp>
27 #include <com/sun/star/embed/Aspects.hpp>
28 #include <com/sun/star/awt/XWindowPeer.hpp>
29 #include <com/sun/star/util/XCloseBroadcaster.hpp>
30 #include <com/sun/star/util/XCloseable.hpp>
31 #include <com/sun/star/util/XModifiable.hpp>
32 #include <com/sun/star/frame/XFrame.hpp>
33 #include <com/sun/star/frame/XComponentLoader.hpp>
34 #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/embed/EmbedMapUnits.hpp>
38 #include <cppuhelper/queryinterface.hxx>
39 #include <cppuhelper/typeprovider.hxx>
41 #include "specialobject.hxx"
42 #include "intercept.hxx"
44 using namespace ::com::sun::star
;
47 OSpecialEmbeddedObject::OSpecialEmbeddedObject( const uno::Reference
< uno::XComponentContext
>& rxContext
, const uno::Sequence
< beans::NamedValue
>& aObjectProps
)
48 : OCommonEmbeddedObject( rxContext
, aObjectProps
)
50 maSize
.Width
= maSize
.Height
= 10000;
51 m_nObjectState
= embed::EmbedStates::LOADED
;
55 uno::Any SAL_CALL
OSpecialEmbeddedObject::queryInterface( const uno::Type
& rType
)
56 throw( uno::RuntimeException
, std::exception
)
60 aReturn
= ::cppu::queryInterface( rType
,
61 static_cast< embed::XEmbeddedObject
* >( this ),
62 static_cast< embed::XInplaceObject
* >( this ),
63 static_cast< embed::XVisualObject
* >( this ),
64 static_cast< embed::XClassifiedObject
* >( this ),
65 static_cast< embed::XComponentSupplier
* >( this ),
66 static_cast< util::XCloseable
* >( this ),
67 static_cast< document::XEventBroadcaster
* >( this ) );
68 if ( aReturn
.hasValue() )
71 return ::cppu::OWeakObject::queryInterface( rType
) ;
76 embed::VisualRepresentation SAL_CALL
OSpecialEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect
)
77 throw ( lang::IllegalArgumentException
,
78 embed::WrongStateException
,
80 uno::RuntimeException
, std::exception
)
82 ::osl::MutexGuard
aGuard( m_aMutex
);
84 throw lang::DisposedException(); // TODO
86 // TODO: if object is in loaded state it should switch itself to the running state
87 if ( m_nObjectState
== -1 || m_nObjectState
== embed::EmbedStates::LOADED
)
88 throw embed::WrongStateException( "The own object has no model!",
89 static_cast< ::cppu::OWeakObject
* >(this) );
91 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
92 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
93 // no representation can be retrieved
94 throw embed::WrongStateException( "Illegal call!",
95 static_cast< ::cppu::OWeakObject
* >(this) );
97 // TODO: return for the aspect of the document
98 embed::VisualRepresentation aVisualRepresentation
;
99 return aVisualRepresentation
;
102 void SAL_CALL
OSpecialEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect
, const awt::Size
& aSize
)
103 throw ( lang::IllegalArgumentException
,
104 embed::WrongStateException
,
106 uno::RuntimeException
, std::exception
)
108 ::osl::MutexGuard
aGuard( m_aMutex
);
110 throw lang::DisposedException(); // TODO
112 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
113 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
114 // no representation can be retrieved
115 throw embed::WrongStateException( "Illegal call!",
116 static_cast< ::cppu::OWeakObject
* >(this) );
121 awt::Size SAL_CALL
OSpecialEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect
)
122 throw ( lang::IllegalArgumentException
,
123 embed::WrongStateException
,
125 uno::RuntimeException
, std::exception
)
127 ::osl::MutexGuard
aGuard( m_aMutex
);
129 throw lang::DisposedException(); // TODO
131 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
132 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
133 // no representation can be retrieved
134 throw embed::WrongStateException( "Illegal call!",
135 static_cast< ::cppu::OWeakObject
* >(this) );
137 if ( m_nObjectState
== -1 )
138 throw embed::WrongStateException( "The own object has no model!",
139 static_cast< ::cppu::OWeakObject
* >(this) );
144 sal_Int32 SAL_CALL
OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect
)
145 throw ( uno::Exception
,
146 uno::RuntimeException
, std::exception
)
148 ::osl::MutexGuard
aGuard( m_aMutex
);
150 throw lang::DisposedException(); // TODO
152 OSL_ENSURE( nAspect
!= embed::Aspects::MSOLE_ICON
, "For iconified objects no graphical replacement is required!\n" );
153 if ( nAspect
== embed::Aspects::MSOLE_ICON
)
154 // no representation can be retrieved
155 throw embed::WrongStateException( "Illegal call!",
156 static_cast< ::cppu::OWeakObject
* >(this) );
158 return embed::EmbedMapUnits::ONE_100TH_MM
;
161 void SAL_CALL
OSpecialEmbeddedObject::changeState( sal_Int32 nNewState
)
162 throw ( css::embed::UnreachableStateException
,
163 css::embed::WrongStateException
,
165 css::uno::RuntimeException
, std::exception
)
167 if ( nNewState
== embed::EmbedStates::UI_ACTIVE
)
168 nNewState
= embed::EmbedStates::INPLACE_ACTIVE
;
169 OCommonEmbeddedObject::changeState( nNewState
);
172 void SAL_CALL
OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID
)
173 throw ( lang::IllegalArgumentException
,
174 embed::WrongStateException
,
175 embed::UnreachableStateException
,
177 uno::RuntimeException
, std::exception
)
179 ::osl::MutexGuard
aGuard( m_aMutex
);
181 throw lang::DisposedException(); // TODO
183 if ( m_nObjectState
== -1 )
184 throw embed::WrongStateException( "The object has no persistence!",
185 static_cast< ::cppu::OWeakObject
* >(this) );
190 uno::Reference
< ui::dialogs::XExecutableDialog
> xDlg( m_pDocHolder
->GetComponent(), uno::UNO_QUERY
);
194 throw embed::UnreachableStateException();
197 OCommonEmbeddedObject::doVerb( nVerbID
);
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */