25 #include <com/sun/star/deployment/PackageInformationProvider.hpp>
26 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
33 #include <rtl/ustrbuf.hxx>
37 #include <string_view>
44 using ::com::sun::star::uno::Reference;
45 using ::com::sun::star::uno::UNO_QUERY_THROW;
46 using ::com::sun::star::uno::UNO_SET_THROW;
47 using ::com::sun::star::uno::Exception;
48 using ::com::sun::star::uno::Sequence;
49 using ::com::sun::star::uno::XComponentContext;
50 using ::com::sun::star::ucb::XContent;
51 using ::com::sun::star::ucb::XContentIdentifier;
52 using ::com::sun::star::sdbc::XRow;
53 using ::com::sun::star::ucb::IllegalIdentifierException;
54 using ::com::sun::star::deployment::PackageInformationProvider;
55 using ::com::sun::star::deployment::XPackageInformationProvider;
56 using ::com::sun::star::sdbc::XResultSet;
63 OUString lcl_compose( std::u16string_view i_rBaseURL,
const OUString& i_rRelativeURL )
67 OUStringBuffer aComposer( i_rBaseURL );
69 aComposer.append(
'/' );
70 aComposer.append( i_rRelativeURL );
71 return aComposer.makeStringAndClear();
80 const ::rtl::Reference< Content >& i_rContent )
91 const Reference< XPackageInformationProvider > xPackageInfo = PackageInformationProvider::get(
m_xContext );
93 const OUString sContentIdentifier(
m_xContent->getIdentifier()->getContentIdentifier() );
95 switch (
m_xContent->getExtensionContentType() )
99 const Sequence< Sequence< OUString > > aExtensionInfo( xPackageInfo->getExtensionList() );
100 for (
auto const & extInfo : aExtensionInfo )
102 if ( !extInfo.hasElements() )
104 SAL_WARN(
"ucb.ucp.ext",
"illegal extension info" );
108 const OUString& rLocalId = extInfo[0];
118 const OUString sPackageLocation(
m_xContent->getPhysicalURL() );
124 const Reference< XResultSet > xFolderContent( aWrappedContent.createCursor( aPropertyNames ), UNO_SET_THROW );
125 const Reference< XRow > xContentRow( xFolderContent, UNO_QUERY_THROW );
126 while ( xFolderContent->next() )
129 aEntry.
sId = lcl_compose( sContentIdentifier, xContentRow->getString( 1 ) );
135 OSL_FAIL(
"DataSupplier::fetchData: unimplemented content type!" );
153 ::osl::Guard< ::osl::Mutex > aGuard(
m_aMutex );
158 if ( !sId.isEmpty() )
162 OSL_FAIL(
"DataSupplier::queryContentIdentifierString: illegal index, or illegal result entry id!" );
169 ::osl::Guard< ::osl::Mutex > aGuard(
m_aMutex );
179 if ( !sId.isEmpty() )
181 Reference< XContentIdentifier >
xId = new ::ucbhelper::ContentIdentifier( sId );
186 return Reference< XContentIdentifier >();
192 ::osl::Guard< ::osl::Mutex > aGuard(
m_aMutex );
206 pContent.set( dynamic_cast< Content* >(
xContent.get() ) );
207 OSL_ENSURE( pContent.is() || !
xContent.is(),
"DataSupplier::queryContent: invalid content implementation!" );
212 catch (
const IllegalIdentifierException& )
224 ::osl::ClearableGuard< ::osl::Mutex > aGuard(
m_aMutex );
233 ::osl::ClearableGuard< ::osl::Mutex > aGuard(
m_aMutex );
252 ::osl::MutexGuard aGuard(
m_aMutex );
261 switch (
m_xContent->getExtensionContentType() )
268 if ( sTitle.endsWith(
"/") )
269 sTitle = sTitle.copy( 0, sTitle.getLength() - 1 );
277 xRow =
m_aResults[ i_nIndex ].pContent->getPropertyValues(
282 OSL_FAIL(
"DataSupplier::queryPropertyValues: unhandled case!" );
293 ::osl::Guard< ::osl::Mutex > aGuard(
m_aMutex );
::rtl::Reference< Content > m_xContent
virtual sal_uInt32 totalCount() override
virtual void validate() override
virtual void close() override
virtual void releasePropertyValues(sal_uInt32 nIndex) override
static OUString getRootURL()
DataSupplier(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const rtl::Reference< Content > &rContent)
virtual OUString queryContentIdentifierString(sal_uInt32 nIndex) override
#define DBG_UNHANDLED_EXCEPTION(...)
uno::Reference< ucb::XContent > m_xContent
virtual css::uno::Reference< css::ucb::XContentIdentifier > queryContentIdentifier(sal_uInt32 nIndex) override
virtual ~DataSupplier() override
#define ENSURE_OR_RETURN(c, m, r)
rtl::Reference< ResultSet > getResultSet() const
virtual bool isCountFinal() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
static css::uno::Reference< css::sdbc::XRow > getArtificialNodePropertyValues(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Sequence< css::beans::Property > &rProperties, const OUString &rTitle)
css::uno::Environment getEnvironment(OUString const &name, std::u16string_view implementation)
virtual css::uno::Reference< css::sdbc::XRow > queryPropertyValues(sal_uInt32 nIndex) override
constexpr bool ends_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
::rtl::Reference< OContentHelper > xContent
#define SAL_WARN(area, stream)
static OUString encodeIdentifier(const OUString &i_rIdentifier)
Reference< XComponentContext > m_xContext
virtual bool getResult(sal_uInt32 nIndex) override
virtual sal_uInt32 currentCount() override
virtual css::uno::Reference< css::ucb::XContent > queryContent(sal_uInt32 nIndex) override
Reference< XContentIdentifier > xId
static OUString decodeIdentifier(const OUString &i_rIdentifier)