LibreOffice Module embeddedobj (master) 1
specialobject.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
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>
28
30#include <osl/diagnose.h>
32
33#include <specialobject.hxx>
34
35using namespace ::com::sun::star;
36
37
38OSpecialEmbeddedObject::OSpecialEmbeddedObject( const uno::Reference< uno::XComponentContext >& rxContext, const uno::Sequence< beans::NamedValue >& aObjectProps )
39: OCommonEmbeddedObject( rxContext, aObjectProps )
40{
41 maSize.Width = maSize.Height = 10000;
42 m_nObjectState = embed::EmbedStates::LOADED;
43}
44
45
47{
48 uno::Any aReturn = ::cppu::queryInterface( rType,
49 static_cast< embed::XEmbeddedObject* >( this ),
50 static_cast< embed::XInplaceObject* >( this ),
51 static_cast< embed::XCommonEmbedPersist* >( static_cast< embed::XEmbedPersist* >( this ) ),
52 static_cast< embed::XVisualObject* >( this ),
53 static_cast< embed::XClassifiedObject* >( this ),
54 static_cast< embed::XComponentSupplier* >( this ),
55 static_cast< util::XCloseable* >( this ),
56 static_cast< lang::XServiceInfo* >( this ),
57 static_cast< lang::XTypeProvider* >( this ),
58 static_cast< document::XEventBroadcaster* >( this ) );
59 if ( aReturn.hasValue() )
60 return aReturn;
61 else
62 return ::cppu::OWeakObject::queryInterface( rType ) ;
63
64}
65
66
67embed::VisualRepresentation SAL_CALL OSpecialEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 nAspect )
68{
69 ::osl::MutexGuard aGuard( m_aMutex );
70 if ( m_bDisposed )
71 throw lang::DisposedException(); // TODO
72
73 // TODO: if object is in loaded state it should switch itself to the running state
74 if ( m_nObjectState == -1 || m_nObjectState == embed::EmbedStates::LOADED )
75 throw embed::WrongStateException( "The own object has no model!",
76 static_cast< ::cppu::OWeakObject* >(this) );
77
78 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
79 if ( nAspect == embed::Aspects::MSOLE_ICON )
80 // no representation can be retrieved
81 throw embed::WrongStateException( "Illegal call!",
82 static_cast< ::cppu::OWeakObject* >(this) );
83
84 // TODO: return for the aspect of the document
85 embed::VisualRepresentation aVisualRepresentation;
86 return aVisualRepresentation;
87}
88
89void SAL_CALL OSpecialEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
90{
91 ::osl::MutexGuard aGuard( m_aMutex );
92 if ( m_bDisposed )
93 throw lang::DisposedException(); // TODO
94
95 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
96 if ( nAspect == embed::Aspects::MSOLE_ICON )
97 // no representation can be retrieved
98 throw embed::WrongStateException( "Illegal call!",
99 static_cast< ::cppu::OWeakObject* >(this) );
100
101 maSize = aSize;
102}
103
104awt::Size SAL_CALL OSpecialEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
105{
106 ::osl::MutexGuard aGuard( m_aMutex );
107 if ( m_bDisposed )
108 throw lang::DisposedException(); // TODO
109
110 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
111 if ( nAspect == embed::Aspects::MSOLE_ICON )
112 // no representation can be retrieved
113 throw embed::WrongStateException( "Illegal call!",
114 static_cast< ::cppu::OWeakObject* >(this) );
115
116 if ( m_nObjectState == -1 )
117 throw embed::WrongStateException( "The own object has no model!",
118 static_cast< ::cppu::OWeakObject* >(this) );
119
120 return maSize;
121}
122
123sal_Int32 SAL_CALL OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect )
124{
125 ::osl::MutexGuard aGuard( m_aMutex );
126 if ( m_bDisposed )
127 throw lang::DisposedException(); // TODO
128
129 OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!" );
130 if ( nAspect == embed::Aspects::MSOLE_ICON )
131 // no representation can be retrieved
132 throw embed::WrongStateException( "Illegal call!",
133 static_cast< ::cppu::OWeakObject* >(this) );
134
135 return embed::EmbedMapUnits::ONE_100TH_MM;
136}
137
138void SAL_CALL OSpecialEmbeddedObject::changeState( sal_Int32 nNewState )
139{
140 if ( nNewState == embed::EmbedStates::UI_ACTIVE )
141 nNewState = embed::EmbedStates::INPLACE_ACTIVE;
143}
144
145void SAL_CALL OSpecialEmbeddedObject::doVerb( sal_Int32 nVerbID )
146{
147 ::osl::MutexGuard aGuard( m_aMutex );
148 if ( m_bDisposed )
149 throw lang::DisposedException(); // TODO
150
151 if ( m_nObjectState == -1 )
152 throw embed::WrongStateException( "The object has no persistence!",
153 static_cast< ::cppu::OWeakObject* >(this) );
154
155 if ( nVerbID == -7 )
156 {
157
158 uno::Reference < ui::dialogs::XExecutableDialog > xDlg( m_xDocHolder->GetComponent(), uno::UNO_QUERY );
159 if ( !xDlg.is() )
160 throw embed::UnreachableStateException();
161 xDlg->execute();
162 }
163 else
165}
166
168 const uno::Sequence< beans::PropertyValue >&,
169 const uno::Sequence< beans::PropertyValue >&)
170{
171 // Allow IFrames to reload their content
173}
174
176{
177 return "com.sun.star.comp.embed.OSpecialEmbeddedObject";
178}
179
180sal_Bool SAL_CALL OSpecialEmbeddedObject::supportsService(const OUString& ServiceName)
181{
183}
184
185uno::Sequence<OUString> SAL_CALL OSpecialEmbeddedObject::getSupportedServiceNames()
186{
187 return { "com.sun.star.comp.embed.OSpecialEmbeddedObject" };
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Represents an OLE object that has native data and we loaded that data into a document model successfu...
virtual void SAL_CALL changeState(sal_Int32 nNewState) override
Definition: embedobj.cxx:476
void SetInplaceActiveState()
Definition: embedobj.cxx:219
rtl::Reference< DocumentHolder > m_xDocHolder
virtual void SAL_CALL doVerb(sal_Int32 nVerbID) override
Definition: embedobj.cxx:566
virtual void SAL_CALL reload(const css::uno::Sequence< css::beans::PropertyValue > &lArguments, const css::uno::Sequence< css::beans::PropertyValue > &lObjArgs) override
virtual void SAL_CALL doVerb(sal_Int32 nVerbID) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
OUString SAL_CALL getImplementationName() override
virtual sal_Int32 SAL_CALL getMapUnit(sal_Int64 nAspect) override
OSpecialEmbeddedObject(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Sequence< css::beans::NamedValue > &aObjectProps)
virtual css::embed::VisualRepresentation SAL_CALL getPreferredVisualRepresentation(::sal_Int64 nAspect) override
virtual void SAL_CALL changeState(sal_Int32 nNewState) override
css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::awt::Size SAL_CALL getVisualAreaSize(sal_Int64 nAspect) override
virtual void SAL_CALL setVisualAreaSize(sal_Int64 nAspect, const css::awt::Size &aSize) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
bool hasValue()
unsigned char sal_Bool