20#include <core_resource.hxx>
22#include <osl/diagnose.h>
27#include <com/sun/star/lang/XMultiServiceFactory.hpp>
28#include <com/sun/star/frame/XComponentLoader.hpp>
29#include <com/sun/star/sdbc/SQLException.hpp>
30#include <com/sun/star/ucb/XCommandProcessor.hpp>
31#include <com/sun/star/ucb/OpenCommandArgument.hpp>
32#include <com/sun/star/ucb/OpenMode.hpp>
33#include <com/sun/star/task/XJobExecutor.hpp>
39#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
46#include <com/sun/star/io/WrongFormatException.hpp>
61 using namespace ::
svt;
65 Sequence< sal_Int8 > lcl_GetSequenceClassID( sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3,
69 Sequence< sal_Int8 > aResult{
static_cast<sal_Int8>(
n1 >> 24),
70 static_cast<sal_Int8>(( n1 << 8 ) >> 24),
71 static_cast<sal_Int8>(( n1 << 16 ) >> 24),
72 static_cast<sal_Int8>(( n1 << 24 ) >> 24),
74 static_cast<sal_Int8>(( n2 << 8 ) >> 8),
76 static_cast<sal_Int8>(( n3 << 8 ) >> 8),
94 ,m_xDocumentContainer(_rxContainer)
96 ,m_xDocumentUI( i_rDocumentUI )
97 ,m_pDialogParent(pDialogParent)
98 ,m_sDataSourceName(
std::move(_sDataSourceName))
100 OSL_ENSURE(
m_xContext.is(),
"OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid service factory!");
101 assert(
m_pDialogParent &&
"OLinkedDocumentsAccess::OLinkedDocumentsAccess: really need a dialog parent!");
107 ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
110 OSL_ENSURE(
m_xDocumentContainer.is(),
"OLinkedDocumentsAccess::OLinkedDocumentsAccess: invalid document container!");
112 if ( !xComponentLoader.is() )
119 switch ( _eOpenMode )
130 sOpenMode =
"openDesign";
134 OSL_FAIL(
"OLinkedDocumentsAccess::implOpen: invalid open mode!" );
142 if ( xHier.is() && xHier->hasByHierarchicalName(_rLinkName) )
144 _xDefinition.set(xHier->getByHierarchicalName(_rLinkName),UNO_QUERY);
149 xRet = xComponentLoader->loadComponentFromURL( _rLinkName, OUString(), 0,
aArguments.getPropertyValues() );
154 const sal_Int32 _nCommandType,
const OUString& _rObjectName )
164 if ( !_rObjectName.isEmpty() && ( _nCommandType != -1 ) )
166 aArgs.
put(
"CommandType", _nCommandType );
167 aArgs.
put(
"Command", _rObjectName );
175 xWizard.set(
m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
176 OUString::createFromAscii( _pWizardService ),
179 ), UNO_QUERY_THROW );
182 xWizard->trigger(
"start" );
183 ::comphelper::disposeComponent( xWizard );
192 impl_newWithPilot(
"com.sun.star.wizards.form.CallFormWizard", _nCommandType, _rObjectName );
197 impl_newWithPilot(
"com.sun.star.wizards.report.CallReportWizard", _nCommandType, _rObjectName );
201 impl_newWithPilot(
"com.sun.star.wizards.table.CallTableWizard", -1, OUString() );
205 impl_newWithPilot(
"com.sun.star.wizards.query.CallQueryWizard", -1, OUString() );
210 OSL_ENSURE(
m_xDocumentContainer.is(),
"OLinkedDocumentsAccess::newDocument: invalid document container!");
213 if ( !i_rCreationArgs.has(
"ClassID" )
214 && !i_rCreationArgs.has(
"MediaType" )
215 && !i_rCreationArgs.has(
"DocumentServiceName" )
218 switch ( i_nActionID )
238 OSL_FAIL(
"OLinkedDocumentsAccess::newDocument: please use newFormWithPilot!" );
253 if ( aClassId.hasElements() )
254 aCreationArgs.
put(
"ClassID", aClassId );
259 if ( aCreationArgs.
has(
"Hidden" ) )
261 aCommandArgs.
put(
"Hidden", aCreationArgs.
get(
"Hidden" ) );
262 aCreationArgs.
remove(
"Hidden" );
271 o_rDefinition.set( xContent, UNO_QUERY );
274 OpenCommandArgument aOpenModeArg;
275 aOpenModeArg.Mode = OpenMode::DOCUMENT;
276 aCommandArgs.
put(
"OpenMode", aOpenModeArg );
282 xNewDocument.set( xContent->execute(
aCommand, xContent->createCommandIdentifier(),
nullptr ), UNO_QUERY );
294 ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection& _rAdditionalArgs )
300 xRet =
impl_open( _rLinkName, _xDefinition, _eOpenMode, _rAdditionalArgs );
306 css::sdbc::SQLException aSQLException;
311 catch(
const css::io::WrongFormatException &e)
313 css::sdbc::SQLException aSQLException;
314 aSQLException.Message = e.Message;
315 aSQLException.Context = e.Context;
319 OUString sText(
DBA_RES( RID_STR_EXTENSION_NOT_PRESENT ) );
320 sText = sText.replaceFirst(
"$file$",_rLinkName);
329 Any aAny = ::cppu::getCaughtException();
330 css::sdbc::SQLException
a;
333 css::sdbc::SQLException aSQLException;
334 aSQLException.Message = e.Message;
335 aSQLException.Context = e.Context;
#define ID_FORM_NEW_IMPRESS
#define ID_REPORT_NEW_TEXT
static css::uno::Sequence< sal_Int8 > GetSequenceClassID(sal_uInt32 n1, sal_uInt16 n2, sal_uInt16 n3, sal_uInt8 b8, sal_uInt8 b9, sal_uInt8 b10, sal_uInt8 b11, sal_uInt8 b12, sal_uInt8 b13, sal_uInt8 b14, sal_uInt8 b15)
css::uno::Sequence< css::uno::Any > getWrappedPropertyValues() const
bool has(const OUString &_rValueName) const
const css::uno::Any & get(const OUString &_rValueName) const
bool remove(const OUString &_rValueName)
bool put(const OUString &_rValueName, const VALUE_TYPE &_rValue)
css::uno::Sequence< css::beans::PropertyValue > getPropertyValues() const
~OLinkedDocumentsAccess()
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::lang::XComponent > impl_open(const OUString &_rLinkName, css::uno::Reference< css::lang::XComponent > &_xDefinition, ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection &_rAdditionalArgs)
void newFormWithPilot(const sal_Int32 _nCommandType, const OUString &_rObjectName)
css::uno::Reference< css::container::XNameAccess > m_xDocumentContainer
OUString m_sDataSourceName
css::uno::Reference< css::sdbc::XConnection > m_xConnection
css::uno::Reference< css::lang::XComponent > newDocument(sal_Int32 i_nActionID, const ::comphelper::NamedValueCollection &i_rCreationArgs, css::uno::Reference< css::lang::XComponent > &o_rDefinition)
void newReportWithPilot(const sal_Int32 _nCommandType, const OUString &_rObjectName)
css::uno::Reference< css::lang::XComponent > open(const OUString &_rLinkName, css::uno::Reference< css::lang::XComponent > &_xDefinition, ElementOpenMode _eOpenMode, const ::comphelper::NamedValueCollection &_rAdditionalArgs)
weld::Window * m_pDialogParent
void impl_newWithPilot(const char *_pWizardService, const sal_Int32 _nCommandType, const OUString &_rObjectName)
OLinkedDocumentsAccess(weld::Window *pDialogParent, const css::uno::Reference< css::sdb::application::XDatabaseDocumentUI > &i_rDocumentUI, const css::uno::Reference< css::uno::XComponentContext > &_rxContext, const css::uno::Reference< css::container::XNameAccess > &_rxContainer, const css::uno::Reference< css::sdbc::XConnection > &_xConnection, OUString _sDataSourceName)
css::uno::Reference< css::sdb::application::XDatabaseDocumentUI > m_xDocumentUI
#define SO3_SIMPRESS_CLASSID
#define SO3_RPT_CLASSID_90
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
Reference< XComponentContext > m_xContext
#define DBG_UNHANDLED_EXCEPTION(...)
Sequence< PropertyValue > aArguments
Reference< XConnection > m_xConnection
constexpr OUStringLiteral SERVICE_SDB_DOCUMENTDEFINITION
constexpr OUStringLiteral PROPERTY_ACTIVE_CONNECTION(u"ActiveConnection")