diff options
author | David Tardon <dtardon@redhat.com> | 2014-06-04 14:08:52 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-06-04 15:48:39 +0200 |
commit | 31ba2cb2fcb3b9466c553cf12d50bc6437ee826f (patch) | |
tree | f8977345770fad1787f078a0461d4ae10043eaa3 /writerperfect/source/common | |
parent | ccb51e13ed8602d4b394c99116a41e53a22403f2 (diff) |
add convenience functions to handle dirs
Change-Id: I81c94565e09e0d839d95bf4f09b029838bb37ad5
Diffstat (limited to 'writerperfect/source/common')
-rw-r--r-- | writerperfect/source/common/DirectoryStream.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/writerperfect/source/common/DirectoryStream.cxx b/writerperfect/source/common/DirectoryStream.cxx index b720eececaaa..e22e8066505d 100644 --- a/writerperfect/source/common/DirectoryStream.cxx +++ b/writerperfect/source/common/DirectoryStream.cxx @@ -19,6 +19,7 @@ * For further information visit http://libwpd.sourceforge.net */ +#include <com/sun/star/container/XChild.hpp> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -38,6 +39,7 @@ #include <writerperfect/DirectoryStream.hxx> #include <writerperfect/WPXSvInputStream.hxx> +namespace container = com::sun::star::container; namespace io = com::sun::star::io; namespace sdbc = com::sun::star::sdbc; namespace ucb = com::sun::star::ucb; @@ -112,6 +114,45 @@ DirectoryStream::~DirectoryStream() delete m_pImpl; } +DirectoryStream *DirectoryStream::createForParent(const com::sun::star::uno::Reference<com::sun::star::ucb::XContent> &xContent) try +{ + if (!xContent.is()) + return 0; + + DirectoryStream *pDir(0); + + const uno::Reference<container::XChild> xChild(xContent, uno::UNO_QUERY); + if (xChild.is()) + { + const uno::Reference<ucb::XContent> xDirContent(xChild->getParent(), uno::UNO_QUERY); + if (xDirContent.is()) + { + pDir = new writerperfect::DirectoryStream(xDirContent); + if (!pDir->isStructured()) + pDir = 0; + } + } + + return pDir; +} +catch (...) +{ +return 0; +} + +bool DirectoryStream::isDirectory(const com::sun::star::uno::Reference<com::sun::star::ucb::XContent> &xContent) try +{ + if (!xContent.is()) + return false; + + ucbhelper::Content aContent(xContent, uno::Reference<ucb::XCommandEnvironment>(), comphelper::getProcessComponentContext()); + return aContent.isFolder(); +} +catch (...) +{ + return false; +} + bool DirectoryStream::isStructured() { return true; |