22 #include <string_view>
26 #include <rtl/uri.hxx>
27 #include <rtl/ustrbuf.hxx>
30 #include <com/sun/star/io/XOutputStream.hpp>
31 #include <com/sun/star/ucb/CommandFailedException.hpp>
32 #include <com/sun/star/ucb/ContentInfo.hpp>
33 #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
34 #include <com/sun/star/ucb/ContentCreationException.hpp>
64 if (ret_ucbContent !=
nullptr)
67 *ret_ucbContent = ucbContent;
88 &ucb_content, url_, xCmdEnv,
false ))
91 if (ret_ucb_content !=
nullptr)
92 *ret_ucb_content = ucb_content;
99 sal_Int32 slash = url.lastIndexOf(
'/' );
103 slash = url.lastIndexOf(
'/' );
108 throw ContentCreationException(
109 "Cannot create folder (invalid path): '" + url +
"'",
110 Reference<XInterface>(), ContentCreationError_UNKNOWN );
115 &parentContent, url.copy( 0, slash ), xCmdEnv, throw_exc ))
117 const Any title( ::rtl::Uri::decode( url.copy( slash + 1 ),
118 rtl_UriDecodeWithCharset,
119 RTL_TEXTENCODING_UTF8 ) );
120 const Sequence<ContentInfo> infos(
125 if ((info.Attributes & ContentInfoAttribute::KIND_FOLDER) != 0)
129 if ( rProps.getLength() != 1 || rProps[ 0 ].Name !=
"Title" )
136 Sequence<Any>( &title, 1 ),
138 if (ret_ucb_content !=
nullptr)
139 *ret_ucb_content = ucb_content;
146 catch (
const CommandFailedException &) {
158 throw ContentCreationException(
159 "Cannot create folder: '" + url +
"'",
160 Reference<XInterface>(), ContentCreationError_UNKNOWN );
174 "delete",
Any(
true ) );
191 std::vector<sal_Int8>
bytes;
192 Reference<io::XOutputStream>
xStream(
196 "::ucbhelper::Content::openStream( XOutputStream ) failed!",
202 bool readLine( OUString * res, OUString
const & startingWith,
207 OUString file( reinterpret_cast<char const *>(bytes.data()),
208 bytes.size(), textenc );
212 if (file.match( startingWith, pos ))
215 sal_Int32 start = pos;
216 pos += startingWith.getLength();
219 pos = file.indexOf(
LF, pos );
221 buf.append( std::u16string_view(file).substr(start) );
225 if (pos > 0 && file[ pos - 1 ] ==
CR)
228 buf.append( std::u16string_view(file).substr(start, pos - start - 1) );
232 buf.append( std::u16string_view(file).substr(start, pos - start) );
235 if (pos < file.getLength() &&
236 (file[ pos ] ==
' ' || file[ pos ] ==
'\t'))
246 *res = buf.makeStringAndClear();
250 sal_Int32 next_lf = file.indexOf(
LF, pos );
263 OUString file( reinterpret_cast<char const *>(bytes.data()),
264 bytes.size(), RTL_TEXTENCODING_UTF8);
271 sal_Int32 start = pos;
274 pos = file.indexOf(
LF, pos );
276 buf.append( std::u16string_view(file).substr(start) );
281 if (pos > 0 && file[ pos - 1 ] ==
CR)
283 buf.append( std::u16string_view(file).substr(start, pos - start - 1) );
285 buf.append( std::u16string_view(file).substr(start, pos - start) );
288 OUString aLine = buf.makeStringAndClear();
290 sal_Int32 posEqual = aLine.indexOf(
'=');
291 if (posEqual > 0 && (posEqual + 1) < aLine.getLength())
293 OUString
name = aLine.copy(0, posEqual);
294 OUString
value = aLine.copy(posEqual + 1);
295 out_result.emplace_back(name, value);
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readProperties(std::vector< std::pair< OUString, OUString > > &out_result,::ucbhelper::Content &ucb_content)
bool insertNewContent(const OUString &rContentType, const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rPropertyValues, Content &rNewContent)
std::vector< sal_uInt8 > bytes
css::uno::Sequence< css::ucb::ContentInfo > queryCreatableContentsInfo()
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC std::vector< sal_Int8 > readFile(::ucbhelper::Content &ucb_content)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readLine(OUString *res, OUString const &startingWith,::ucbhelper::Content &ucb_content, rtl_TextEncoding textenc)
void setCommandEnvironment(const css::uno::Reference< css::ucb::XCommandEnvironment > &xNewEnv)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_ucb_content(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
OUString expandUnoRcUrl(OUString const &url)
css::uno::Reference< css::io::XInputStream > openStream()
static css::uno::Sequence< OUString > getTitleSequence()
Reference< XComponentContext > getProcessComponentContext()
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path(OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
Reference< io::XOutputStream > createOutputStream(std::vector< sal_Int8 > *pOutData)
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool create_folder(::ucbhelper::Content *ucb_content, OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)