25#include <rtl/ustrbuf.hxx>
28#include <com/sun/star/io/XOutputStream.hpp>
29#include <com/sun/star/ucb/CommandFailedException.hpp>
30#include <com/sun/star/ucb/ContentInfo.hpp>
31#include <com/sun/star/ucb/ContentInfoAttribute.hpp>
32#include <com/sun/star/ucb/ContentCreationException.hpp>
45 Reference<XCommandEnvironment>
const & xCmdEnv,
57 url, Reference<XCommandEnvironment>(),
62 if (ret_ucbContent !=
nullptr)
65 *ret_ucbContent = ucbContent;
82 Reference<XCommandEnvironment>
const & xCmdEnv,
bool throw_exc )
86 &ucb_content,
url_, xCmdEnv,
false ))
89 if (ret_ucb_content !=
nullptr)
90 *ret_ucb_content = ucb_content;
97 sal_Int32 slash = url.lastIndexOf(
'/' );
101 slash = url.lastIndexOf(
'/' );
106 throw ContentCreationException(
107 "Cannot create folder (invalid path): '" + url +
"'",
108 Reference<XInterface>(), ContentCreationError_UNKNOWN );
113 &parentContent, url.copy( 0, slash ), xCmdEnv, throw_exc ))
115 const Any title( ::rtl::Uri::decode( url.copy( slash + 1 ),
116 rtl_UriDecodeWithCharset,
117 RTL_TEXTENCODING_UTF8 ) );
118 const Sequence<ContentInfo> infos(
123 if ((info.Attributes & ContentInfoAttribute::KIND_FOLDER) != 0)
126 Sequence<beans::Property>
const & rProps = info.Properties;
127 if ( rProps.getLength() != 1 || rProps[ 0 ].Name !=
"Title" )
134 Sequence<Any>( &title, 1 ),
136 if (ret_ucb_content !=
nullptr)
137 *ret_ucb_content = ucb_content;
144 catch (
const CommandFailedException &) {
156 throw ContentCreationException(
157 "Cannot create folder: '" + url +
"'",
158 Reference<XInterface>(), ContentCreationError_UNKNOWN );
164 Reference<XCommandEnvironment>
const & xCmdEnv,
172 "delete",
Any(
true ) );
189 std::vector<sal_Int8>
bytes;
190 Reference<io::XOutputStream>
xStream(
191 ::xmlscript::createOutputStream( &
bytes ) );
194 "::ucbhelper::Content::openStream( XOutputStream ) failed!",
200bool readLine( OUString * res, std::u16string_view startingWith,
205 OUString file(
reinterpret_cast<char const *
>(
bytes.data()),
206 bytes.size(), textenc );
210 if (file.match( startingWith,
pos ))
214 pos += startingWith.size();
219 buf.append( file.subView(
start) );
223 if (
pos > 0 && file[
pos - 1 ] ==
CR)
233 if (
pos < file.getLength() &&
234 (file[
pos ] ==
' ' || file[
pos ] ==
'\t'))
244 *res = buf.makeStringAndClear();
248 sal_Int32 next_lf = file.indexOf(
LF,
pos );
261 OUString file(
reinterpret_cast<char const *
>(
bytes.data()),
262 bytes.size(), RTL_TEXTENCODING_UTF8);
274 buf.append( file.subView(
start) );
279 if (
pos > 0 && file[
pos - 1 ] ==
CR)
286 OUString aLine = buf.makeStringAndClear();
288 sal_Int32 posEqual = aLine.indexOf(
'=');
289 if (posEqual > 0 && (posEqual + 1) < aLine.getLength())
291 OUString
name = aLine.copy(0, posEqual);
292 OUString
value = aLine.copy(posEqual + 1);
css::uno::Any executeCommand(const OUString &rCommandName, const css::uno::Any &rCommandArgument)
bool insertNewContent(const OUString &rContentType, const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rPropertyValues, Content &rNewContent)
css::uno::Sequence< css::ucb::ContentInfo > queryCreatableContentsInfo()
css::uno::Reference< css::io::XInputStream > openStream()
void setCommandEnvironment(const css::uno::Reference< css::ucb::XCommandEnvironment > &xNewEnv)
Reference< XComponentContext > getProcessComponentContext()
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)
OUString expandUnoRcUrl(OUString const &url)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readProperties(std::vector< std::pair< OUString, OUString > > &out_result, ::ucbhelper::Content &ucb_content)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool erase_path(OUString const &url, css::uno::Reference< css::ucb::XCommandEnvironment > const &xCmdEnv, bool throw_exc=true)
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)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool readLine(OUString *res, std::u16string_view startingWith, ::ucbhelper::Content &ucb_content, rtl_TextEncoding textenc)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC std::vector< sal_Int8 > readFile(::ucbhelper::Content &ucb_content)
std::vector< sal_uInt8 > bytes
static css::uno::Sequence< OUString > getTitleSequence()