19#include <com/sun/star/beans/PropertyValue.hpp>
26#include <com/sun/star/beans/NamedValue.hpp>
27#include <com/sun/star/frame/Desktop.hpp>
28#include <com/sun/star/frame/XComponentLoader.hpp>
29#include <com/sun/star/frame/FrameSearchFlag.hpp>
30#include <com/sun/star/embed/XTransactedObject.hpp>
32#include <com/sun/star/task/XJob.hpp>
40#include <core_resource.hxx>
62OReportEngineJFree::~OReportEngineJFree()
70 ReportEnginePropertySet::dispose();
71 cppu::WeakComponentImplHelperBase::dispose();
72 m_xActiveConnection.clear();
75OUString OReportEngineJFree::getImplementationName_Static( )
77 return "com.sun.star.comp.report.OReportEngineJFree";
81OUString SAL_CALL OReportEngineJFree::getImplementationName( )
83 return getImplementationName_Static();
86uno::Sequence< OUString > OReportEngineJFree::getSupportedServiceNames_Static( )
88 uno::Sequence< OUString > aServices {
"com.sun.star.report.ReportEngine" };
93uno::Reference< uno::XInterface > OReportEngineJFree::create(uno::Reference< uno::XComponentContext >
const & xContext)
99uno::Sequence< OUString > SAL_CALL OReportEngineJFree::getSupportedServiceNames( )
101 return getSupportedServiceNames_Static();
104sal_Bool SAL_CALL OReportEngineJFree::supportsService(
const OUString& ServiceName)
111uno::Reference< report::XReportDefinition > SAL_CALL OReportEngineJFree::getReportDefinition()
117void SAL_CALL OReportEngineJFree::setReportDefinition(
const uno::Reference< report::XReportDefinition >& _report )
120 throw lang::IllegalArgumentException();
124 if ( m_xReport != _report )
133uno::Reference< task::XStatusIndicator > SAL_CALL OReportEngineJFree::getStatusIndicator()
136 return m_StatusIndicator;
139void SAL_CALL OReportEngineJFree::setStatusIndicator(
const uno::Reference< task::XStatusIndicator >& _statusindicator )
144OUString OReportEngineJFree::getNewOutputName()
147 ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
148 if ( !m_xReport.is() || !m_xActiveConnection.is() )
149 throw lang::IllegalArgumentException();
151 static constexpr OUStringLiteral s_sMediaType =
u"MediaType";
154 const OUString sMimeType = m_xReport->getMimeType();
156 OUString sExt(
".rpt");
158 sExt = ::comphelper::string::stripStart(pFilter->GetDefaultExtension(),
'*');
160 uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(
m_xContext);
162 uno::Sequence< beans::PropertyValue > aEmpty;
163 uno::Reference< beans::XPropertySet> xStorageProp(xTemp,uno::UNO_QUERY);
164 if ( xStorageProp.is() )
166 xStorageProp->setPropertyValue( s_sMediaType,
uno::Any(sMimeType));
168 m_xReport->storeToStorage(xTemp,aEmpty);
171 OUString
sName = m_xReport->getCaption();
172 if (
sName.isEmpty() )
173 sName = m_xReport->getName();
174 sFileURL = ::utl::CreateTempURL(
sName,
false, sExt);
175 if ( sFileURL.isEmpty() )
182 sFileURL = aFile.
GetURL();
185 sFileURL = aTestFile.
GetURL();
188 uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,
m_xContext);
190 xStorageProp.set(xOut,uno::UNO_QUERY);
191 if ( xStorageProp.is() )
193 xStorageProp->setPropertyValue( s_sMediaType,
uno::Any(sMimeType));
202 uno::Sequence< beans::NamedValue > aConvertedProperties{
209 {
"Title",
uno::Any(m_xReport->getCaption()) }
212 OUString sOutputName;
215 const OUString sReportEngineServiceName = ::dbtools::getDefaultReportEngineServiceName(
m_xContext);
216 uno::Reference<task::XJob> xJob(
m_xContext->getServiceManager()->createInstanceWithContext(sReportEngineServiceName,
m_xContext),uno::UNO_QUERY_THROW);
217 if ( !m_xReport->getCommand().isEmpty() )
219 xJob->execute(aConvertedProperties);
220 if ( xStorageProp.is() )
222 sOutputName = sFileURL;
226 uno::Reference<embed::XTransactedObject> xTransact(xOut,uno::UNO_QUERY);
227 if ( !sOutputName.isEmpty() && xTransact.is() )
230 if ( sOutputName.isEmpty() )
231 throw lang::IllegalArgumentException();
237uno::Reference< frame::XModel > SAL_CALL OReportEngineJFree::createDocumentModel( )
239 return createDocumentAlive(
nullptr,
true);
242uno::Reference< frame::XModel > SAL_CALL OReportEngineJFree::createDocumentAlive(
const uno::Reference< frame::XFrame >& _frame )
244 return createDocumentAlive(_frame,
false);
247uno::Reference< frame::XModel > OReportEngineJFree::createDocumentAlive(
const uno::Reference< frame::XFrame >& _frame,
bool _bHidden )
249 uno::Reference< frame::XModel >
xModel;
250 OUString sOutputName = getNewOutputName();
251 if ( !sOutputName.isEmpty() )
253 ::osl::MutexGuard aGuard(m_aMutex);
254 ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
255 uno::Reference<frame::XComponentLoader> xFrameLoad(_frame,uno::UNO_QUERY);
256 if ( !xFrameLoad.is() )
259 xFrameLoad = frame::Desktop::create(m_xContext);
260 sal_Int32
const nFrameSearchFlag = frame::FrameSearchFlag::TASKS | frame::FrameSearchFlag::CREATE;
261 uno::Reference< frame::XFrame>
xFrame = uno::Reference< frame::XFrame>(xFrameLoad,uno::UNO_QUERY_THROW)->findFrame(
"_blank",nFrameSearchFlag);
262 xFrameLoad.set( xFrame,uno::UNO_QUERY);
265 if ( xFrameLoad.is() )
267 uno::Sequence < beans::PropertyValue > aArgs( _bHidden ? 3 : 2 );
268 auto pArgs = aArgs.getArray();
270 pArgs[nLen].Name =
"AsTemplate";
271 pArgs[nLen++].Value <<=
false;
273 pArgs[nLen].Name =
"ReadOnly";
274 pArgs[nLen++].Value <<=
true;
278 pArgs[nLen].Name =
"Hidden";
279 pArgs[nLen++].Value <<=
true;
282 xModel.set( xFrameLoad->loadComponentFromURL(
293util::URL SAL_CALL OReportEngineJFree::createDocument( )
296 uno::Reference< frame::XModel >
xModel = createDocumentModel();
300 ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
305void SAL_CALL OReportEngineJFree::interrupt( )
308 ::connectivity::checkDisposed(ReportEngineBase::rBHelper.bDisposed);
311uno::Reference< beans::XPropertySetInfo > SAL_CALL OReportEngineJFree::getPropertySetInfo( )
313 return ReportEnginePropertySet::getPropertySetInfo();
316void SAL_CALL OReportEngineJFree::setPropertyValue(
const OUString& aPropertyName,
const uno::Any& aValue )
318 ReportEnginePropertySet::setPropertyValue( aPropertyName, aValue );
321uno::Any SAL_CALL OReportEngineJFree::getPropertyValue(
const OUString& PropertyName )
323 return ReportEnginePropertySet::getPropertyValue( PropertyName);
326void SAL_CALL OReportEngineJFree::addPropertyChangeListener(
const OUString& aPropertyName,
const uno::Reference< beans::XPropertyChangeListener >& xListener )
328 ReportEnginePropertySet::addPropertyChangeListener( aPropertyName, xListener );
331void SAL_CALL OReportEngineJFree::removePropertyChangeListener(
const OUString& aPropertyName,
const uno::Reference< beans::XPropertyChangeListener >& aListener )
333 ReportEnginePropertySet::removePropertyChangeListener( aPropertyName, aListener );
336void SAL_CALL OReportEngineJFree::addVetoableChangeListener(
const OUString& PropertyName,
const uno::Reference< beans::XVetoableChangeListener >& aListener )
338 ReportEnginePropertySet::addVetoableChangeListener( PropertyName, aListener );
341void SAL_CALL OReportEngineJFree::removeVetoableChangeListener(
const OUString& PropertyName,
const uno::Reference< beans::XVetoableChangeListener >& aListener )
343 ReportEnginePropertySet::removeVetoableChangeListener( PropertyName, aListener );
346uno::Reference< sdbc::XConnection > SAL_CALL OReportEngineJFree::getActiveConnection()
348 return m_xActiveConnection;
351void SAL_CALL OReportEngineJFree::setActiveConnection(
const uno::Reference< sdbc::XConnection >& _activeconnection )
353 if ( !_activeconnection.is() )
354 throw lang::IllegalArgumentException();
358::sal_Int32 SAL_CALL OReportEngineJFree::getMaxRows()
364void SAL_CALL OReportEngineJFree::setMaxRows( ::sal_Int32 MaxRows )
Reference< XComponentContext > m_xContext
static std::shared_ptr< const SfxFilter > GetDefaultFilter(std::u16string_view rName)
OUString GetFirstName() const
OUString GetLastName() const
OUString GetDocServiceNameFromMediaType(const OUString &aMediaType)
OReportEngineJFree(const OReportEngineJFree &)=delete
OUString const & GetURL() const
OUString RptResId(TranslateId aId)
void set(css::uno::UnoInterfaceReference const &value)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
::cppu::WeakComponentImplHelper< css::report::XReportEngine,css::lang::XServiceInfo > ReportEngineBase
::cppu::PropertySetMixin< css::report::XReportEngine > ReportEnginePropertySet
IMPLEMENT_FORWARD_XINTERFACE2(ChildWindowPane, ChildWindowPaneInterfaceBase, Pane)
constexpr OUStringLiteral PROPERTY_STATUSINDICATOR
constexpr OUStringLiteral PROPERTY_ACTIVECONNECTION
constexpr OUStringLiteral PROPERTY_MAXROWS
constexpr OUStringLiteral PROPERTY_REPORTDEFINITION
Reference< XFrame > xFrame
Reference< XModel > xModel