nss: upgrade to release 3.73
[LibreOffice.git] / ucb / source / core / FileAccess.cxx
blob4a816618471e5ed8e8e7d0d33b98946dfd7e4ebc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <cppuhelper/exc_hlp.hxx>
21 #include <comphelper/processfactory.hxx>
22 #include <comphelper/sequence.hxx>
23 #include <cppuhelper/factory.hxx>
24 #include <cppuhelper/implbase.hxx>
25 #include <cppuhelper/supportsservice.hxx>
27 #include <tools/urlobj.hxx>
28 #include <ucbhelper/content.hxx>
29 #include <unotools/streamwrap.hxx>
30 #include <tools/stream.hxx>
32 #include <com/sun/star/beans/Property.hpp>
33 #include <com/sun/star/container/XChild.hpp>
34 #include <com/sun/star/io/XActiveDataSink.hpp>
35 #include <com/sun/star/io/XActiveDataStreamer.hpp>
36 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/sdbc/XResultSet.hpp>
39 #include <com/sun/star/ucb/ContentCreationException.hpp>
40 #include <com/sun/star/ucb/CommandFailedException.hpp>
41 #include <com/sun/star/ucb/ContentInfo.hpp>
42 #include <com/sun/star/ucb/ContentInfoAttribute.hpp>
43 #include <com/sun/star/ucb/InsertCommandArgument.hpp>
44 #include <com/sun/star/ucb/InteractiveIOException.hpp>
45 #include <com/sun/star/ucb/NameClash.hpp>
46 #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
47 #include <com/sun/star/ucb/OpenMode.hpp>
48 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
49 #include <com/sun/star/ucb/XContent.hpp>
50 #include <com/sun/star/ucb/XContentAccess.hpp>
51 #include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
52 #include <com/sun/star/util/theMacroExpander.hpp>
54 #include <vector>
56 #define SERVICE_NAME "com.sun.star.ucb.SimpleFileAccess"
58 using namespace ::com::sun::star::uno;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::io;
61 using namespace ::com::sun::star::ucb;
62 using namespace ::com::sun::star::sdbc;
63 using namespace ::com::sun::star::task;
64 using namespace ::com::sun::star::util;
65 using namespace ::com::sun::star::beans;
66 using namespace ::com::sun::star::registry;
67 using namespace ::com::sun::star::container;
69 using ::std::vector;
71 namespace
74 // Implementation XSimpleFileAccess
75 typedef cppu::WeakImplHelper<XSimpleFileAccess3, css::lang::XServiceInfo>
76 FileAccessHelper;
77 class OCommandEnvironment;
79 class OFileAccess : public FileAccessHelper
81 Reference< XComponentContext > m_xContext;
82 rtl::Reference<OCommandEnvironment> mxEnvironment;
84 /// @throws CommandAbortedException
85 /// @throws Exception
86 /// @throws RuntimeException
87 void transferImpl( const OUString& rSource, const OUString& rDest, bool bMoveData );
88 /// @throws Exception
89 bool createNewFile( const OUString & rParentURL,
90 const OUString & rTitle,
91 const Reference< XInputStream >& data );
93 public:
94 explicit OFileAccess( const Reference< XComponentContext > & xContext )
95 : m_xContext( xContext) {}
96 // Methods
97 virtual void SAL_CALL copy( const OUString& SourceURL, const OUString& DestURL ) override;
98 virtual void SAL_CALL move( const OUString& SourceURL, const OUString& DestURL ) override;
99 virtual void SAL_CALL kill( const OUString& FileURL ) override;
100 virtual sal_Bool SAL_CALL isFolder( const OUString& FileURL ) override;
101 virtual sal_Bool SAL_CALL isReadOnly( const OUString& FileURL ) override;
102 virtual void SAL_CALL setReadOnly( const OUString& FileURL, sal_Bool bReadOnly ) override;
103 virtual void SAL_CALL createFolder( const OUString& NewFolderURL ) override;
104 virtual sal_Int32 SAL_CALL getSize( const OUString& FileURL ) override;
105 virtual OUString SAL_CALL getContentType( const OUString& FileURL ) override;
106 virtual css::util::DateTime SAL_CALL getDateTimeModified( const OUString& FileURL ) override;
107 virtual css::uno::Sequence< OUString > SAL_CALL getFolderContents( const OUString& FolderURL, sal_Bool bIncludeFolders ) override;
108 virtual sal_Bool SAL_CALL exists( const OUString& FileURL ) override;
109 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL openFileRead( const OUString& FileURL ) override;
110 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL openFileWrite( const OUString& FileURL ) override;
111 virtual css::uno::Reference< css::io::XStream > SAL_CALL openFileReadWrite( const OUString& FileURL ) override;
112 virtual void SAL_CALL setInteractionHandler( const css::uno::Reference< css::task::XInteractionHandler >& Handler ) override;
113 virtual void SAL_CALL writeFile( const OUString& FileURL, const css::uno::Reference< css::io::XInputStream >& data ) override;
114 virtual sal_Bool SAL_CALL isHidden( const OUString& FileURL ) override;
115 virtual void SAL_CALL setHidden( const OUString& FileURL, sal_Bool bHidden ) override;
117 OUString SAL_CALL getImplementationName() override
118 { return "com.sun.star.comp.ucb.SimpleFileAccess"; }
120 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override
121 { return cppu::supportsService(this, ServiceName); }
123 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override
124 { return { SERVICE_NAME }; }
127 // Implementation XActiveDataSink
129 class OActiveDataSink : public cppu::WeakImplHelper< XActiveDataSink >
131 Reference< XInputStream > mxStream;
133 public:
135 // Methods
136 virtual void SAL_CALL setInputStream( const Reference< XInputStream >& aStream ) override;
137 virtual Reference< XInputStream > SAL_CALL getInputStream( ) override;
140 // Implementation XActiveDataStreamer
142 class OActiveDataStreamer : public cppu::WeakImplHelper< XActiveDataStreamer >
144 Reference< XStream > mxStream;
146 public:
148 // Methods
149 virtual void SAL_CALL setStream( const Reference< XStream >& aStream ) override;
150 virtual Reference< XStream > SAL_CALL getStream() override;
153 // Implementation XCommandEnvironment
155 class OCommandEnvironment : public cppu::WeakImplHelper< XCommandEnvironment >
157 Reference< XInteractionHandler > mxInteraction;
159 public:
160 void setHandler( const Reference< XInteractionHandler >& xInteraction_ )
162 mxInteraction = xInteraction_;
165 // Methods
166 virtual Reference< XInteractionHandler > SAL_CALL getInteractionHandler() override;
167 virtual Reference< XProgressHandler > SAL_CALL getProgressHandler() override;
170 void OActiveDataSink::setInputStream( const Reference< XInputStream >& aStream )
172 mxStream = aStream;
175 Reference< XInputStream > OActiveDataSink::getInputStream()
177 return mxStream;
180 void OActiveDataStreamer::setStream( const Reference< XStream >& aStream )
182 mxStream = aStream;
185 Reference< XStream > OActiveDataStreamer::getStream()
187 return mxStream;
190 Reference< XInteractionHandler > OCommandEnvironment::getInteractionHandler()
192 return mxInteraction;
195 Reference< XProgressHandler > OCommandEnvironment::getProgressHandler()
197 Reference< XProgressHandler > xRet;
198 return xRet;
201 void OFileAccess::transferImpl( const OUString& rSource,
202 const OUString& rDest,
203 bool bMoveData )
205 // SfxContentHelper::Transfer_Impl
206 INetURLObject aSourceObj( rSource, INetProtocol::File );
207 INetURLObject aDestObj( rDest, INetProtocol::File );
208 OUString aName = aDestObj.getName(
209 INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
210 OUString aDestURL;
211 OUString aSourceURL = aSourceObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
212 if ( aDestObj.removeSegment() )
214 // hierarchical URL.
216 aDestObj.setFinalSlash();
217 aDestURL = aDestObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
219 else
221 // non-hierarchical URL
223 // #i29648#
226 if ( aDestObj.GetProtocol() == INetProtocol::VndSunStarExpand )
228 // Hack: Expand destination URL using Macro Expander and try again
229 // with the hopefully hierarchical expanded URL...
233 Reference< XMacroExpander > xExpander = theMacroExpander::get(m_xContext);
235 aDestURL = xExpander->expandMacros(
236 aDestObj.GetURLPath( INetURLObject::DecodeMechanism::WithCharset ) );
238 catch ( Exception const & )
240 css::uno::Any anyEx = cppu::getCaughtException();
241 throw css::lang::WrappedTargetRuntimeException(
242 "OFileAccess::transferrImpl - Unable to obtain destination folder URL!",
243 static_cast< cppu::OWeakObject * >( this ), anyEx );
246 transferImpl( rSource, aDestURL, bMoveData );
247 return;
250 throw RuntimeException(
251 "OFileAccess::transferrImpl - Unable to obtain destination folder URL!",
252 static_cast< cppu::OWeakObject * >( this ) );
256 ucbhelper::Content aDestPath( aDestURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
257 ucbhelper::Content aSrc ( aSourceURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
261 aDestPath.transferContent(aSrc,
262 bMoveData
263 ? ucbhelper::InsertOperation::Move
264 : ucbhelper::InsertOperation::Copy,
265 aName,
266 css::ucb::NameClash::OVERWRITE);
268 catch ( css::ucb::CommandFailedException const & )
270 // Interaction Handler already handled the error that has occurred...
274 void OFileAccess::copy( const OUString& SourceURL, const OUString& DestURL )
276 transferImpl( SourceURL, DestURL, false );
279 void OFileAccess::move( const OUString& SourceURL, const OUString& DestURL )
281 transferImpl( SourceURL, DestURL, true );
284 void OFileAccess::kill( const OUString& FileURL )
286 // SfxContentHelper::Kill
287 INetURLObject aDeleteObj( FileURL, INetProtocol::File );
288 ucbhelper::Content aCnt( aDeleteObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
291 aCnt.executeCommand( "delete", makeAny( true ) );
293 catch ( css::ucb::CommandFailedException const & )
295 // Interaction Handler already handled the error that has occurred...
299 sal_Bool OFileAccess::isFolder( const OUString& FileURL )
301 bool bRet = false;
304 INetURLObject aURLObj( FileURL, INetProtocol::File );
305 ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
306 bRet = aCnt.isFolder();
308 catch (const Exception &) {}
309 return bRet;
312 sal_Bool OFileAccess::isReadOnly( const OUString& FileURL )
314 INetURLObject aURLObj( FileURL, INetProtocol::File );
315 ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
316 Any aRetAny = aCnt.getPropertyValue("IsReadOnly");
317 bool bRet = false;
318 aRetAny >>= bRet;
319 return bRet;
322 void OFileAccess::setReadOnly( const OUString& FileURL, sal_Bool bReadOnly )
324 INetURLObject aURLObj( FileURL, INetProtocol::File );
325 ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
326 aCnt.setPropertyValue("IsReadOnly", Any(bReadOnly) );
329 void OFileAccess::createFolder( const OUString& NewFolderURL )
331 // Does the folder already exist?
332 if( NewFolderURL.isEmpty() || isFolder( NewFolderURL ) )
333 return;
335 // SfxContentHelper::MakeFolder
336 INetURLObject aURL( NewFolderURL, INetProtocol::File );
337 OUString aTitle = aURL.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset );
338 if ( !aTitle.isEmpty() )
340 aURL.removeSegment();
342 // Does the base folder exist? Otherwise create it first
343 OUString aBaseFolderURLStr = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
344 if( !isFolder( aBaseFolderURLStr ) )
346 createFolder( aBaseFolderURLStr );
350 ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
352 const Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo();
354 for ( const ContentInfo & rCurr : aInfo )
356 // Simply look for the first KIND_FOLDER...
357 if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER )
359 // Make sure the only required bootstrap property is "Title",
360 const Sequence< Property > & rProps = rCurr.Properties;
361 if ( rProps.getLength() != 1 )
362 continue;
364 if ( rProps[ 0 ].Name != "Title" )
365 continue;
367 Sequence<OUString> aNames { "Title" };
368 Sequence< Any > aValues(1);
369 Any* pValues = aValues.getArray();
370 pValues[0] <<= aTitle;
372 ucbhelper::Content aNew;
375 if ( !aCnt.insertNewContent( rCurr.Type, aNames, aValues, aNew ) )
376 continue;
378 // Success. We're done.
379 return;
381 catch ( css::ucb::CommandFailedException const & )
383 // Interaction Handler already handled the error that has occurred...
384 continue;
390 sal_Int32 OFileAccess::getSize( const OUString& FileURL )
392 // SfxContentHelper::GetSize
393 sal_Int32 nSize = 0;
394 sal_Int64 nTemp = 0;
395 INetURLObject aObj( FileURL, INetProtocol::File );
396 ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
397 aCnt.getPropertyValue( "Size" ) >>= nTemp;
398 nSize = static_cast<sal_Int32>(nTemp);
399 return nSize;
402 OUString OFileAccess::getContentType( const OUString& FileURL )
404 INetURLObject aObj( FileURL, INetProtocol::File );
405 ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
407 Reference< XContent > xContent = aCnt.get();
408 OUString aTypeStr = xContent->getContentType();
409 return aTypeStr;
412 css::util::DateTime OFileAccess::getDateTimeModified( const OUString& FileURL )
414 INetURLObject aFileObj( FileURL, INetProtocol::File );
415 css::util::DateTime aDateTime;
417 Reference< XCommandEnvironment > aCmdEnv;
418 ucbhelper::Content aYoung( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), aCmdEnv, comphelper::getProcessComponentContext() );
419 aYoung.getPropertyValue("DateModified") >>= aDateTime;
420 return aDateTime;
423 Sequence< OUString > OFileAccess::getFolderContents( const OUString& FolderURL, sal_Bool bIncludeFolders )
425 // SfxContentHelper::GetFolderContents
427 std::vector<OUString> aFiles;
428 INetURLObject aFolderObj( FolderURL, INetProtocol::File );
430 ucbhelper::Content aCnt( aFolderObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
431 Reference< XResultSet > xResultSet;
432 Sequence< OUString > aProps(0);
434 ucbhelper::ResultSetInclude eInclude = bIncludeFolders ? ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS : ucbhelper::INCLUDE_DOCUMENTS_ONLY;
438 xResultSet = aCnt.createCursor( aProps, eInclude );
440 catch ( css::ucb::CommandFailedException const & )
442 // Interaction Handler already handled the error that has occurred...
445 if ( xResultSet.is() )
447 Reference< css::ucb::XContentAccess > xContentAccess( xResultSet, UNO_QUERY );
449 while ( xResultSet->next() )
451 OUString aId = xContentAccess->queryContentIdentifierString();
452 INetURLObject aURL( aId, INetProtocol::File );
453 aFiles.push_back( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
457 return comphelper::containerToSequence(aFiles);
460 sal_Bool OFileAccess::exists( const OUString& FileURL )
462 bool bRet = false;
465 bRet = isFolder( FileURL );
466 if( !bRet )
468 Reference< XInputStream > xStream = openFileRead( FileURL );
469 bRet = xStream.is();
470 if( bRet )
471 xStream->closeInput();
474 catch (const Exception &) {}
475 return bRet;
478 Reference< XInputStream > OFileAccess::openFileRead( const OUString& FileURL )
480 Reference< XInputStream > xRet;
481 INetURLObject aObj( FileURL, INetProtocol::File );
482 ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
484 Reference<XActiveDataSink> xSink = new OActiveDataSink;
488 bool bRet = aCnt.openStream( xSink );
489 if( bRet )
490 xRet = xSink->getInputStream();
492 catch ( css::ucb::CommandFailedException const & )
494 // Interaction Handler already handled the error that has occurred...
497 return xRet;
500 Reference< XOutputStream > OFileAccess::openFileWrite( const OUString& FileURL )
502 Reference< XOutputStream > xRet;
503 Reference< XStream > xStream = OFileAccess::openFileReadWrite( FileURL );
504 if( xStream.is() )
505 xRet = xStream->getOutputStream();
506 return xRet;
509 Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
511 Reference<XActiveDataStreamer> xSink = new OActiveDataStreamer;
513 OpenCommandArgument2 aArg;
514 aArg.Mode = OpenMode::DOCUMENT;
515 aArg.Priority = 0; // unused
516 aArg.Sink = xSink;
517 aArg.Properties = Sequence< Property >( 0 ); // unused
519 Any aCmdArg;
520 aCmdArg <<= aArg;
522 INetURLObject aFileObj( FileURL, INetProtocol::File );
523 ucbhelper::Content aCnt( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
525 // Be silent...
526 Reference< XInteractionHandler > xIH;
527 if ( mxEnvironment.is() )
529 xIH = mxEnvironment->getInteractionHandler();
530 mxEnvironment->setHandler( nullptr );
535 aCnt.executeCommand( "open", aCmdArg );
537 catch ( InteractiveIOException const & e )
539 if ( xIH.is() && mxEnvironment.is() )
540 mxEnvironment->setHandler( xIH );
542 if ( e.Code == IOErrorCode_NOT_EXISTING )
544 // Create file...
545 SvMemoryStream aStream(0,0);
546 ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
547 Reference< XInputStream > xInput( pInput );
548 InsertCommandArgument aInsertArg;
549 aInsertArg.Data = xInput;
550 aInsertArg.ReplaceExisting = false;
552 aCmdArg <<= aInsertArg;
553 aCnt.executeCommand( "insert", aCmdArg );
555 // Retry...
556 return openFileReadWrite( FileURL );
559 throw;
562 if ( xIH.is() && mxEnvironment.is() )
563 mxEnvironment->setHandler( xIH );
565 Reference< XStream > xRet = xSink->getStream();
566 return xRet;
569 void OFileAccess::setInteractionHandler( const Reference< XInteractionHandler >& Handler )
571 if( !mxEnvironment.is() )
573 mxEnvironment = new OCommandEnvironment;
575 mxEnvironment->setHandler( Handler );
578 bool OFileAccess::createNewFile( const OUString & rParentURL,
579 const OUString & rTitle,
580 const Reference< XInputStream >& data )
582 ucbhelper::Content aParentCnt( rParentURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
584 const Sequence< ContentInfo > aInfo = aParentCnt.queryCreatableContentsInfo();
586 for ( const ContentInfo & rCurr : aInfo )
588 if ( ( rCurr.Attributes
589 & ContentInfoAttribute::KIND_DOCUMENT ) &&
590 ( rCurr.Attributes
591 & ContentInfoAttribute::INSERT_WITH_INPUTSTREAM ) )
593 // Make sure the only required bootstrap property is
594 // "Title",
595 const Sequence< Property > & rProps = rCurr.Properties;
596 if ( rProps.getLength() != 1 )
597 continue;
599 if ( rProps[ 0 ].Name != "Title" )
600 continue;
602 Sequence<OUString> aNames { "Title" };
603 Sequence< Any > aValues(1);
604 Any* pValues = aValues.getArray();
605 pValues[0] <<= rTitle;
609 ucbhelper::Content aNew;
610 if ( aParentCnt.insertNewContent(
611 rCurr.Type, aNames, aValues, data, aNew ) )
612 return true; // success.
613 else
614 continue;
616 catch ( CommandFailedException const & )
618 // Interaction Handler already handled the
619 // error that has occurred...
620 continue;
625 return false;
628 void SAL_CALL OFileAccess::writeFile( const OUString& FileURL,
629 const Reference< XInputStream >& data )
631 INetURLObject aURL( FileURL, INetProtocol::File );
634 ucbhelper::Content aCnt(
635 aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(),
636 comphelper::getProcessComponentContext() );
640 aCnt.writeStream( data, true /* bReplaceExisting */ );
642 catch ( CommandFailedException const & )
644 // Interaction Handler already handled the error that has occurred...
647 catch ( ContentCreationException const & e )
649 // Most probably file does not exist. Try to create.
650 if ( e.eError == ContentCreationError_CONTENT_CREATION_FAILED )
652 INetURLObject aParentURLObj( aURL );
653 if ( aParentURLObj.removeSegment() )
655 OUString aParentURL
656 = aParentURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
658 // ensure all parent folders exist.
659 createFolder( aParentURL );
661 // create the new file...
662 OUString aTitle
663 = aURL.getName( INetURLObject::LAST_SEGMENT,
664 true,
665 INetURLObject::DecodeMechanism::WithCharset );
666 if ( createNewFile( aParentURL, aTitle, data ) )
668 // success
669 return;
674 throw;
678 sal_Bool OFileAccess::isHidden( const OUString& FileURL )
680 INetURLObject aURLObj( FileURL, INetProtocol::File );
681 ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
682 Any aRetAny = aCnt.getPropertyValue("IsHidden");
683 bool bRet = false;
684 aRetAny >>= bRet;
685 return bRet;
688 void OFileAccess::setHidden( const OUString& FileURL, sal_Bool bHidden )
690 INetURLObject aURLObj( FileURL, INetProtocol::File );
691 ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
692 aCnt.setPropertyValue("IsHidden", Any(bHidden) );
696 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
697 ucb_OFileAccess_get_implementation(
698 css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
700 return cppu::acquire(new OFileAccess(context));
703 }; // namespace end
706 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */