23 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
26 #include <osl/mutex.hxx>
27 #include <rtl/ustrbuf.hxx>
34 using ::com::sun::star::uno::Reference;
35 using ::com::sun::star::uno::XInterface;
36 using ::com::sun::star::uno::Sequence;
37 using ::com::sun::star::ucb::XContentIdentifier;
38 using ::com::sun::star::ucb::IllegalIdentifierException;
39 using ::com::sun::star::ucb::XContent;
40 using ::com::sun::star::uno::XComponentContext;
59 return "org.openoffice.comp.ucp.ext.ContentProvider";
65 return {
"com.sun.star.ucb.ContentProvider",
"com.sun.star.ucb.ExtensionContentProvider" };
71 return "vnd.sun.star.extension://";
77 return "application/vnd.sun.star.extension-content";
83 void lcl_ensureAndTransfer( std::u16string_view& io_rIdentifierFragment, OUStringBuffer& o_rNormalization,
const sal_Unicode i_nLeadingChar )
85 if ( ( io_rIdentifierFragment.empty() ) || ( io_rIdentifierFragment[0] != i_nLeadingChar ) )
86 throw IllegalIdentifierException();
87 io_rIdentifierFragment = io_rIdentifierFragment.substr( 1 );
88 o_rNormalization.append( i_nLeadingChar );
96 static const OUStringLiteral sScheme( u
"vnd.sun.star.extension" );
97 if ( !i_rIdentifier->getContentProviderScheme().equalsIgnoreAsciiCase( sScheme ) )
98 throw IllegalIdentifierException();
101 const OUString sIdentifier( i_rIdentifier->getContentIdentifier() );
104 OUStringBuffer aComposer;
105 aComposer.append( sIdentifier.copy( 0, sScheme.getLength() ).toAsciiLowerCase() );
108 std::u16string_view sRemaining( sIdentifier.subView( sScheme.getLength() ) );
109 lcl_ensureAndTransfer( sRemaining, aComposer,
':' );
112 lcl_ensureAndTransfer( sRemaining, aComposer,
'/' );
115 if ( sRemaining.empty() )
118 aComposer.append(
"//" );
122 if ( sRemaining[0] !=
'/' )
124 aComposer.append(
'/' );
125 aComposer.append( sRemaining );
129 lcl_ensureAndTransfer( sRemaining, aComposer,
'/' );
131 if ( sRemaining.empty() )
134 aComposer.append(
'/' );
138 aComposer.append( sRemaining );
142 const Reference< XContentIdentifier > xNormalizedIdentifier( new ::ucbhelper::ContentIdentifier( aComposer.makeStringAndClear() ) );
144 ::osl::MutexGuard aGuard(
m_aMutex );
153 if ( !
xContent->getIdentifier().is() )
154 throw IllegalIdentifierException();
164 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
166 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any>
const&)
ContentProvider(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
static OUString getArtificialNodeContentType()
virtual ~ContentProvider() override
static OUString getRootURL()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
::ucbhelper::ContentProviderImplHelper ContentProvider_Base
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL queryContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier) override
rtl::Reference< ContentImplHelper > queryExistingContent(const css::uno::Reference< css::ucb::XContentIdentifier > &Identifier)
css::uno::Reference< css::uno::XComponentContext > m_xContext
void registerNewContent(const css::uno::Reference< css::ucb::XContent > &xContent)
virtual OUString SAL_CALL getImplementationName() override
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_ext_ContentProvider_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
::rtl::Reference< OContentHelper > xContent