tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / embeddedobj / source / commonembedding / specialobject.cxx
blob82380d851e3cd44300ed1f3d27286d97c0ba8731
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/UnreachableStateException.hpp>
23 #include <com/sun/star/embed/WrongStateException.hpp>
24 #include <com/sun/star/embed/Aspects.hpp>
25 #include <com/sun/star/util/XCloseable.hpp>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/embed/EmbedMapUnits.hpp>
29 #include <cppuhelper/queryinterface.hxx>
30 #include <osl/diagnose.h>
31 #include <cppuhelper/supportsservice.hxx>
32 #include <officecfg/Office/Common.hxx>
34 #include <specialobject.hxx>
36 using namespace ::com::sun::star;
39 OSpecialEmbeddedObject::OSpecialEmbeddedObject( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Sequence< beans::NamedValue >& aObjectProps )
40 : OCommonEmbeddedObject( rxContext, aObjectProps )
42 maSize.Width = maSize.Height = 10000;
43 m_nObjectState = embed::EmbedStates::LOADED;
47 uno::Any SAL_CALL OSpecialEmbeddedObject::queryInterface( const uno::Type& rType )
49 uno::Any aReturn = ::cppu::queryInterface( rType,
50 static_cast< embed::XEmbeddedObject* >( this ),
51 static_cast< embed::XInplaceObject* >( this ),
52 static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ),
53 static_cast< embed::XVisualObject* >( this ),
54 static_cast< embed::XClassifiedObject* >( this ),
55 static_cast< embed::XComponentSupplier* >( this ),
56 static_cast< util::XCloseable* >( this ),
57 static_cast< lang::XServiceInfo* >( this ),
58 static_cast< lang::XTypeProvider* >( this ),
59 static_cast< document::XEventBroadcaster* >( this ) );
60 if ( aReturn.hasValue() )
61 return aReturn;
62 else
63 return ::cppu::OWeakObject::queryInterface( rType ) ;
68 embed::VisualRepresentation SAL_CALL OSpecialEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect )
70 ::osl::MutexGuard aGuard( m_aMutex );
71 if ( m_bDisposed )
72 throw lang::DisposedException(); // TODO
74 // TODO: if object is in loaded state it should switch itself to the running state
75 if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED )
76 throw embed::WrongStateException( u"The own object has no model!"_ustr,
77 static_cast< ::cppu::OWeakObject* >(this) );
79 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
80 if ( nAspect == embed::Aspects::MSOLE_ICON )
81 // no representation can be retrieved
82 throw embed::WrongStateException( u"Illegal call!"_ustr,
83 static_cast< ::cppu::OWeakObject* >(this) );
85 // TODO: return for the aspect of the document
86 embed::VisualRepresentation aVisualRepresentation;
87 return aVisualRepresentation;
90 void SAL_CALL OSpecialEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
92 ::osl::MutexGuard aGuard( m_aMutex );
93 if ( m_bDisposed )
94 throw lang::DisposedException(); // TODO
96 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
97 if ( nAspect == embed::Aspects::MSOLE_ICON )
98 // no representation can be retrieved
99 throw embed::WrongStateException( u"Illegal call!"_ustr,
100 static_cast< ::cppu::OWeakObject* >(this) );
102 maSize = aSize;
105 awt::Size SAL_CALL OSpecialEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
107 ::osl::MutexGuard aGuard( m_aMutex );
108 if ( m_bDisposed )
109 throw lang::DisposedException(); // TODO
111 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
112 if ( nAspect == embed::Aspects::MSOLE_ICON )
113 // no representation can be retrieved
114 throw embed::WrongStateException( u"Illegal call!"_ustr,
115 static_cast< ::cppu::OWeakObject* >(this) );
117 if ( m_nObjectState == -1 )
118 throw embed::WrongStateException( u"The own object has no model!"_ustr,
119 static_cast< ::cppu::OWeakObject* >(this) );
121 return maSize;
124 sal_Int32 SAL_CALL OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect )
126 ::osl::MutexGuard aGuard( m_aMutex );
127 if ( m_bDisposed )
128 throw lang::DisposedException(); // TODO
130 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
131 if ( nAspect == embed::Aspects::MSOLE_ICON )
132 // no representation can be retrieved
133 throw embed::WrongStateException( u"Illegal call!"_ustr,
134 static_cast< ::cppu::OWeakObject* >(this) );
136 return embed::EmbedMapUnits::ONE_100TH_MM;
139 void SAL_CALL OSpecialEmbeddedObject::changeState( sal_Int32 nNewState )
141 if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get()
142 && nNewState != embed::EmbedStates::LOADED )
143 throw embed::UnreachableStateException();
145 if ( nNewState == embed::EmbedStates::UI_ACTIVE )
146 nNewState = embed::EmbedStates::INPLACE_ACTIVE;
147 OCommonEmbeddedObject::changeState( nNewState );
150 void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
152 ::osl::MutexGuard aGuard( m_aMutex );
153 if ( m_bDisposed )
154 throw lang::DisposedException(); // TODO
156 if ( m_nObjectState == -1 )
157 throw embed::WrongStateException( u"The object has no persistence!"_ustr,
158 static_cast< ::cppu::OWeakObject* >(this) );
160 if ( nVerbID == -7 )
163 uno::Reference < ui::dialogs::XExecutableDialog > xDlg( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
164 if ( !xDlg.is() )
165 throw embed::UnreachableStateException();
166 xDlg->execute();
168 else
169 OCommonEmbeddedObject::doVerb( nVerbID );
172 void SAL_CALL OSpecialEmbeddedObject::reload(
173 const uno::Sequence< beans::PropertyValue >&,
174 const uno::Sequence< beans::PropertyValue >&)
176 // Allow IFrames to reload their content
177 SetInplaceActiveState();
180 OUString SAL_CALL OSpecialEmbeddedObject::getImplementationName()
182 return u"com.sun.star.comp.embed.OSpecialEmbeddedObject"_ustr;
185 sal_Bool SAL_CALL OSpecialEmbeddedObject::supportsService(const OUString& ServiceName)
187 return cppu::supportsService(this, ServiceName);
190 uno::Sequence<OUString> SAL_CALL OSpecialEmbeddedObject::getSupportedServiceNames()
192 return { u"com.sun.star.comp.embed.OSpecialEmbeddedObject"_ustr };
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */